mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Minor redesign of Export Dialog (#604)
This commit is contained in:
parent
97b11b0f53
commit
ba4fc0f1b3
5 changed files with 45 additions and 42 deletions
47
src/components/ProjectName.tsx
Normal file
47
src/components/ProjectName.tsx
Normal file
|
@ -0,0 +1,47 @@
|
|||
import "./ProjectName.css";
|
||||
|
||||
import React, { Component } from "react";
|
||||
import { selectNode, removeSelection } from "../utils";
|
||||
|
||||
type Props = {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
label: string;
|
||||
};
|
||||
|
||||
export class ProjectName extends Component<Props> {
|
||||
private handleFocus = (e: React.FocusEvent<HTMLElement>) => {
|
||||
selectNode(e.currentTarget);
|
||||
};
|
||||
|
||||
private handleBlur = (e: React.FocusEvent<HTMLElement>) => {
|
||||
const value = e.currentTarget.innerText.trim();
|
||||
if (value !== this.props.value) this.props.onChange(value);
|
||||
removeSelection();
|
||||
};
|
||||
|
||||
private handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
e.currentTarget.blur();
|
||||
}
|
||||
};
|
||||
|
||||
public render() {
|
||||
return (
|
||||
<span
|
||||
suppressContentEditableWarning
|
||||
contentEditable="true"
|
||||
data-type="wysiwyg"
|
||||
className="ProjectName"
|
||||
role="textbox"
|
||||
aria-label={this.props.label}
|
||||
onBlur={this.handleBlur}
|
||||
onKeyDown={this.handleKeyDown}
|
||||
onFocus={this.handleFocus}
|
||||
>
|
||||
{this.props.value}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue