Skip to content

Commit

Permalink
Fix error with contentEditable (excalidraw#803)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-f1 authored Feb 22, 2020
1 parent 277eeb4 commit 43236be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/components/ProjectName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,19 @@ export class ProjectName extends Component<Props> {
e.currentTarget.blur();
}
};
private makeEditable = (editable: HTMLSpanElement) => {
try {
editable.contentEditable = "plaintext-only";
} catch {
editable.contentEditable = "true";
}
};

public render() {
return (
<span
suppressContentEditableWarning
contentEditable={"plaintext-only" as any}
ref={this.makeEditable}
data-type="wysiwyg"
className="ProjectName"
role="textbox"
Expand Down
6 changes: 5 additions & 1 deletion src/element/textWysiwyg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export function textWysiwyg({
// But this solution has an issue — it allows to paste
// multiline text, which is not currently supported
const editable = document.createElement("div");
editable.contentEditable = "plaintext-only";
try {
editable.contentEditable = "plaintext-only";
} catch {
editable.contentEditable = "true";
}
editable.tabIndex = 0;
editable.innerText = initText;
editable.dataset.type = "wysiwyg";
Expand Down

0 comments on commit 43236be

Please sign in to comment.