Skip to content

Commit

Permalink
chore: allow users to create new react nodeview editor content compon…
Browse files Browse the repository at this point in the history
…ents
  • Loading branch information
bdbch committed Feb 23, 2023
1 parent 8bf8fd2 commit 3499597
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ export default Node.create({
]
},

addKeyboardShortcuts() {
return {
'Mod-Enter': () => {
return this.editor.chain().insertContentAt(this.editor.state.selection.head, { type: this.type.name }).focus().run()
},
}
},

renderHTML({ HTMLAttributes }) {
return ['react-component', mergeAttributes(HTMLAttributes), 0]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default () => {
This is still the text editor you’re used to, but enriched with node views.
</p>
<react-component>
<p>This is editable.</p>
<p>This is editable. You can create a new component by pressing Mod+Enter.</p>
</react-component>
<p>
Did you see that? That’s a React component. We are really living in the future.
Expand Down

0 comments on commit 3499597

Please sign in to comment.