From fc2753099db90e9345a05823a0a8623cc5832b7c Mon Sep 17 00:00:00 2001 From: splincode Date: Wed, 17 Jul 2024 17:52:47 +0300 Subject: [PATCH] feat: support break line inside details content --- projects/editor/src/extensions/enter/index.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/projects/editor/src/extensions/enter/index.ts b/projects/editor/src/extensions/enter/index.ts index f6864697a..3c3a56c80 100644 --- a/projects/editor/src/extensions/enter/index.ts +++ b/projects/editor/src/extensions/enter/index.ts @@ -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); - 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(); }, }; },