Examples: Syntax highlighting for React (#1583)

* Docs: Syntax highlighting - add react example

* Docs: Clean up syntax highlighting demo, make use of functional component

* fix: focus view asynchronously, fix #1520

Co-authored-by: Sven Adlung <info@svenadlung.de>
Co-authored-by: Philipp Kühn <kontakt@philipp-kuehn.com>
This commit is contained in:
Hans Pagel
2021-07-28 23:42:11 +02:00
committed by GitHub
parent e76f7966b5
commit 47d1d3425c
8 changed files with 188 additions and 2 deletions

View File

@@ -73,7 +73,13 @@ export const focus: RawCommands['focus'] = (position = null) => ({
tr.setStoredMarks(storedMarks)
}
view.focus()
// focus async because in some situations weird things happen
// see: https://github.com/ueberdosis/tiptap/issues/1520
setTimeout(() => {
if (!editor.isDestroyed) {
view.focus()
}
}, 0)
}
return true