Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Unexpected update block #1175

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ const HeadingBlockContent = createStronglyTypedTiptapNode({
find: new RegExp(`^(#{${level}})\\s$`),
handler: ({ state, chain, range }) => {
const blockInfo = getBlockInfoFromSelection(state);
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
if (
blockInfo.blockContent.node.type.spec.content !== "inline*" ||
(blockInfo.blockContent.node.type.name !== "paragraph" &&
blockInfo.blockContent.node.type.name !== "heading")
) {
return;
}

Expand Down Expand Up @@ -78,7 +82,11 @@ const HeadingBlockContent = createStronglyTypedTiptapNode({
return {
"Mod-Alt-1": () => {
const blockInfo = getBlockInfoFromSelection(this.editor.state);
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
if (
blockInfo.blockContent.node.type.spec.content !== "inline*" ||
(blockInfo.blockContent.node.type.name !== "paragraph" &&
blockInfo.blockContent.node.type.name !== "heading")
) {
return true;
}

Expand All @@ -98,7 +106,11 @@ const HeadingBlockContent = createStronglyTypedTiptapNode({
},
"Mod-Alt-2": () => {
const blockInfo = getBlockInfoFromSelection(this.editor.state);
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
if (
blockInfo.blockContent.node.type.spec.content !== "inline*" ||
(blockInfo.blockContent.node.type.name !== "paragraph" &&
blockInfo.blockContent.node.type.name !== "heading")
) {
return true;
}

Expand All @@ -117,7 +129,11 @@ const HeadingBlockContent = createStronglyTypedTiptapNode({
},
"Mod-Alt-3": () => {
const blockInfo = getBlockInfoFromSelection(this.editor.state);
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
if (
blockInfo.blockContent.node.type.spec.content !== "inline*" ||
(blockInfo.blockContent.node.type.name !== "paragraph" &&
blockInfo.blockContent.node.type.name !== "heading")
) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ const BulletListItemBlockContent = createStronglyTypedTiptapNode({
find: new RegExp(`^[-+*]\\s$`),
handler: ({ state, chain, range }) => {
const blockInfo = getBlockInfoFromSelection(state);
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
if (
blockInfo.blockContent.node.type.spec.content !== "inline*" ||
blockInfo.blockContent.node.type.name !== "paragraph"
) {
return;
}

Expand All @@ -55,7 +58,10 @@ const BulletListItemBlockContent = createStronglyTypedTiptapNode({
Enter: () => handleEnter(this.options.editor),
"Mod-Shift-8": () => {
const blockInfo = getBlockInfoFromSelection(this.editor.state);
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
if (
blockInfo.blockContent.node.type.spec.content !== "inline*" ||
blockInfo.blockContent.node.type.name !== "paragraph"
) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ const checkListItemBlockContent = createStronglyTypedTiptapNode({
find: new RegExp(`\\[\\s*\\]\\s$`),
handler: ({ state, chain, range }) => {
const blockInfo = getBlockInfoFromSelection(state);
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
if (
blockInfo.blockContent.node.type.spec.content !== "inline*" ||
blockInfo.blockContent.node.type.name !== "paragraph"
) {
return;
}

Expand All @@ -75,7 +78,10 @@ const checkListItemBlockContent = createStronglyTypedTiptapNode({
handler: ({ state, chain, range }) => {
const blockInfo = getBlockInfoFromSelection(state);

if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
if (
blockInfo.blockContent.node.type.spec.content !== "inline*" ||
blockInfo.blockContent.node.type.name !== "paragraph"
) {
return;
}

Expand Down Expand Up @@ -104,7 +110,10 @@ const checkListItemBlockContent = createStronglyTypedTiptapNode({
Enter: () => handleEnter(this.options.editor),
"Mod-Shift-9": () => {
const blockInfo = getBlockInfoFromSelection(this.options.editor.state);
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
if (
blockInfo.blockContent.node.type.spec.content !== "inline*" ||
blockInfo.blockContent.node.type.name !== "paragraph"
) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ const NumberedListItemBlockContent = createStronglyTypedTiptapNode({
find: new RegExp(`^1\\.\\s$`),
handler: ({ state, chain, range }) => {
const blockInfo = getBlockInfoFromSelection(state);
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
if (
blockInfo.blockContent.node.type.spec.content !== "inline*" ||
blockInfo.blockContent.node.type.name !== "paragraph"
) {
return;
}

Expand All @@ -68,7 +71,10 @@ const NumberedListItemBlockContent = createStronglyTypedTiptapNode({
Enter: () => handleEnter(this.options.editor),
"Mod-Shift-7": () => {
const blockInfo = getBlockInfoFromSelection(this.editor.state);
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
if (
blockInfo.blockContent.node.type.spec.content !== "inline*" ||
blockInfo.blockContent.node.type.name !== "paragraph"
) {
return true;
}

Expand Down