fix: fix enter at title end

pull/21/head
fantasticit 2022-03-29 15:33:21 +08:00
parent 4a4d0d2133
commit 2a2644ef66
1 changed files with 2 additions and 5 deletions

View File

@ -19,8 +19,6 @@ declare module '@tiptap/core' {
export const Title = Node.create<TitleOptions>({
name: 'title',
content: 'inline*',
group: 'block',
defining: true,
addOptions() {
return {
@ -61,11 +59,10 @@ export const Title = Node.create<TitleOptions>({
const $head = state.selection.$head;
const titleNode = $head.node($head.depth);
const insertPos = titleNode.firstChild.nodeSize + 1;
dispatch(state.tr.insert(insertPos, paragraph.create()));
const endPos = titleNode.firstChild.nodeSize + 1;
const newState = view.state;
const next = new TextSelection(newState.doc.resolve(insertPos + 1));
const next = new TextSelection(newState.doc.resolve(endPos + 2));
dispatch(newState.tr.setSelection(next));
return true;
}