Skip to content

Commit

Permalink
feat: support break line inside details content
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Jul 17, 2024
1 parent 235dff8 commit fc27530
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions projects/editor/src/extensions/enter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@ export const TuiCustomEnter = Extension.create({
addKeyboardShortcuts() {
return {
Enter: ({editor}) => {
editor.commands.setHardBreak();
editor.commands.setHardBreak();
if (editor.isActive('summary')) {
editor.commands.selectNodeForward();
editor?.commands.focus(editor?.state.selection.anchor + 1);

Check failure on line 10 in projects/editor/src/extensions/enter/index.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe arithmetic operation on optional chaining. It can result in NaN

return true;
if (globalThis.document) {
editor.view
.nodeDOM(editor.state.selection.anchor)
?.parentElement?.closest('details')
?.querySelector('[data-type="details-content"]')
?.prepend(document.createElement('p'));
}

return false;
}

return this.editor.chain().createParagraphNear().run();
},
};
},
Expand Down

0 comments on commit fc27530

Please sign in to comment.