Skip to content

Commit

Permalink
chore: allow new ReactComponentContent components to be created (#3782)
Browse files Browse the repository at this point in the history
* chore: allow users to create new react nodeview editor content components

* style: remove trailing spaces
  • Loading branch information
bdbch authored Feb 27, 2023
1 parent 0300630 commit acf186d
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 acf186d

Please sign in to comment.