-
how do we change default behaviour of enter keydown in editor? |
Beta Was this translation helpful? Give feedback.
Answered by
splincode
Dec 10, 2024
Replies: 1 comment 3 replies
-
You can customize your extensions. Is this what we are talking about? @Component({
// ...
providers: [
{
provide: TUI_EDITOR_EXTENSIONS,
useValue: [
import('@taiga-ui/editor').then(() =>
Extension.create({
name: 'customEnter',
addKeyboardShortcuts() {
return {
Enter: ({editor}) => {
if (editor.isActive('summary')) {
editor.commands.selectNodeForward();
editor?.commands.focus(
(editor?.state.selection.anchor ?? 0) + 1,
);
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();
},
};
},
}),
),
],
},
],
})
export class Example {
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mateen777