Merge pull request #21 from fantasticit/bugfix/title

This commit is contained in:
fantasticit 2022-03-29 15:43:05 +08:00 committed by GitHub
commit e7a70622d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 8 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,12 @@ 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;
dispatch(state.tr.insert(endPos, paragraph.create()));
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;
}

View File

@ -2,7 +2,7 @@
code {
padding: 4px;
font-family: Consolas, Menlo, Courier, monospace;
font-size: .875rem;
font-size: 0.875rem;
line-height: 1.3;
cursor: text;
background-color: var(--semi-color-fill-1);
@ -25,7 +25,7 @@
padding: 0;
margin: 8px;
overflow: auto;
font-size: .875rem;
font-size: 0.875rem;
line-height: 1.5rem;
color: inherit;
white-space: pre;
@ -33,6 +33,12 @@
overscroll-behavior: contain;
}
}
.node-codeBlock {
&::before {
opacity: 0;
}
}
}
/*!
@ -276,6 +282,6 @@ body[theme-mode='dark'] {
}
img {
opacity: .75;
opacity: 0.75;
}
}

View File

@ -1,5 +1,6 @@
.wrap {
position: relative;
margin-top: 0.75em;
.handleWrap {
display: flex;