mirror of https://github.com/fantasticit/think.git
fix: fix enter at title end
parent
4a4d0d2133
commit
2a2644ef66
|
@ -19,8 +19,6 @@ declare module '@tiptap/core' {
|
||||||
export const Title = Node.create<TitleOptions>({
|
export const Title = Node.create<TitleOptions>({
|
||||||
name: 'title',
|
name: 'title',
|
||||||
content: 'inline*',
|
content: 'inline*',
|
||||||
group: 'block',
|
|
||||||
defining: true,
|
|
||||||
|
|
||||||
addOptions() {
|
addOptions() {
|
||||||
return {
|
return {
|
||||||
|
@ -61,11 +59,10 @@ export const Title = Node.create<TitleOptions>({
|
||||||
|
|
||||||
const $head = state.selection.$head;
|
const $head = state.selection.$head;
|
||||||
const titleNode = $head.node($head.depth);
|
const titleNode = $head.node($head.depth);
|
||||||
const insertPos = titleNode.firstChild.nodeSize + 1;
|
const endPos = titleNode.firstChild.nodeSize + 1;
|
||||||
dispatch(state.tr.insert(insertPos, paragraph.create()));
|
|
||||||
|
|
||||||
const newState = view.state;
|
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));
|
dispatch(newState.tr.setSelection(next));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue