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 73c6f9c commit 55c53da
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions projects/tui-editor/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 as any)?.setHardBreak?.();
(editor.commands as any)?.setHardBreak?.();
if (editor.isActive(`summary`)) {
editor.commands.selectNodeForward();
editor?.commands.focus((editor?.state.selection.anchor ?? 0) + 1);

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 55c53da

Please sign in to comment.