@blocknote/core 0.16.0 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.js +3292 -2755
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +6 -6
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +5 -2
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +3087 -0
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +132 -0
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +71 -0
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +2276 -0
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +131 -0
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +103 -0
- package/src/api/blockManipulation/commands/moveBlock/__snapshots__/moveBlock.test.ts.snap +3767 -0
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.test.ts +192 -0
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.ts +178 -0
- package/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap +1136 -0
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.ts +34 -0
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.ts +100 -0
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +4931 -0
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +222 -0
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +70 -0
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +2924 -0
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +136 -0
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +48 -0
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +8376 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +300 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +199 -0
- package/src/api/blockManipulation/insertContentAt.ts +96 -0
- package/src/api/blockManipulation/selections/textCursorPosition/__snapshots__/textCursorPosition.test.ts.snap +316 -0
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts +53 -0
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +130 -0
- package/src/api/blockManipulation/setupTestEnv.ts +179 -0
- package/src/api/clipboard/__snapshots__/tableAllCells.html +1 -1
- package/src/api/clipboard/clipboard.test.ts +5 -6
- package/src/api/clipboard/fromClipboard/fileDropExtension.ts +8 -4
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +11 -6
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +8 -4
- package/src/api/clipboard/toClipboard/copyExtension.ts +113 -61
- package/src/api/exporters/html/__snapshots__/complex/misc/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/lists/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/lists/nested/external.html +1 -1
- package/src/api/exporters/html/externalHTMLExporter.ts +42 -94
- package/src/api/exporters/html/htmlConversion.test.ts +19 -13
- package/src/api/exporters/html/internalHTMLSerializer.ts +21 -72
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +263 -0
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +158 -0
- package/src/api/exporters/markdown/markdownExporter.test.ts +10 -10
- package/src/api/exporters/markdown/markdownExporter.ts +11 -7
- package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +2 -2
- package/src/api/getBlockInfoFromPos.ts +172 -90
- package/src/api/nodeConversions/blockToNode.ts +257 -0
- package/src/api/nodeConversions/fragmentToBlocks.ts +60 -0
- package/src/api/nodeConversions/nodeConversions.test.ts +9 -8
- package/src/api/nodeConversions/{nodeConversions.ts → nodeToBlock.ts} +20 -262
- package/src/api/parsers/html/parseHTML.test.ts +2 -2
- package/src/api/parsers/html/parseHTML.ts +8 -4
- package/src/api/parsers/html/util/nestedLists.test.ts +2 -2
- package/src/api/parsers/markdown/parseMarkdown.test.ts +2 -2
- package/src/api/parsers/markdown/parseMarkdown.ts +8 -4
- package/src/api/testUtil/cases/customBlocks.ts +11 -11
- package/src/api/testUtil/cases/customInlineContent.ts +6 -6
- package/src/api/testUtil/cases/customStyles.ts +6 -6
- package/src/api/testUtil/cases/defaultSchema.ts +4 -4
- package/src/api/testUtil/index.ts +6 -6
- package/src/api/testUtil/partialBlockTestUtil.ts +5 -5
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +5 -5
- package/src/blocks/FileBlockContent/FileBlockContent.ts +4 -4
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +2 -2
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +61 -39
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +5 -5
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +30 -18
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +67 -33
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +23 -19
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +22 -24
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +31 -19
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +16 -11
- package/src/blocks/TableBlockContent/TableBlockContent.ts +4 -4
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +5 -5
- package/src/blocks/defaultBlockHelpers.ts +4 -4
- package/src/blocks/defaultBlockTypeGuards.ts +5 -5
- package/src/blocks/defaultBlocks.ts +13 -13
- package/src/blocks/defaultProps.ts +1 -1
- package/src/editor/BlockNoteEditor.test.ts +14 -7
- package/src/editor/BlockNoteEditor.ts +82 -149
- package/src/editor/BlockNoteExtensions.ts +15 -11
- package/src/editor/BlockNoteSchema.ts +7 -7
- package/src/editor/BlockNoteTipTapEditor.ts +5 -3
- package/src/editor/cursorPositionTypes.ts +7 -2
- package/src/editor/selectionTypes.ts +6 -2
- package/src/extensions/BackgroundColor/BackgroundColorExtension.ts +1 -1
- package/src/extensions/BackgroundColor/BackgroundColorMark.ts +1 -1
- package/src/extensions/FilePanel/FilePanelPlugin.ts +4 -4
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +8 -4
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +334 -0
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +9 -4
- package/src/extensions/{NonEditableBlocks/NonEditableBlockPlugin.ts → NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts} +2 -2
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +1 -1
- package/src/extensions/SideMenu/SideMenuPlugin.ts +72 -401
- package/src/extensions/SideMenu/dragging.ts +251 -0
- package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +1 -1
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +8 -4
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +8 -4
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +19 -15
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +11 -7
- package/src/extensions/TextColor/TextColorExtension.ts +1 -1
- package/src/extensions/TextColor/TextColorMark.ts +1 -1
- package/src/i18n/dictionary.ts +1 -1
- package/src/i18n/locales/ar.ts +1 -1
- package/src/i18n/locales/fr.ts +1 -1
- package/src/i18n/locales/hr.ts +308 -0
- package/src/i18n/locales/index.ts +15 -14
- package/src/i18n/locales/is.ts +1 -1
- package/src/i18n/locales/ja.ts +1 -1
- package/src/i18n/locales/ko.ts +1 -1
- package/src/i18n/locales/nl.ts +1 -1
- package/src/i18n/locales/pl.ts +1 -1
- package/src/i18n/locales/pt.ts +1 -1
- package/src/i18n/locales/ru.ts +1 -1
- package/src/i18n/locales/vi.ts +1 -1
- package/src/i18n/locales/zh.ts +1 -1
- package/src/index.ts +45 -44
- package/src/pm-nodes/BlockContainer.ts +3 -647
- package/src/pm-nodes/BlockGroup.ts +2 -2
- package/src/pm-nodes/index.ts +3 -3
- package/src/schema/blocks/createSpec.ts +8 -7
- package/src/schema/blocks/internal.ts +9 -9
- package/src/schema/blocks/types.ts +4 -4
- package/src/schema/index.ts +10 -10
- package/src/schema/inlineContent/createSpec.ts +9 -10
- package/src/schema/inlineContent/internal.ts +3 -3
- package/src/schema/inlineContent/types.ts +2 -2
- package/src/schema/styles/createSpec.ts +4 -3
- package/src/schema/styles/internal.ts +1 -1
- package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.d.ts +4 -0
- package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +7 -0
- package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.d.ts +1 -0
- package/types/src/api/blockManipulation/commands/moveBlock/moveBlock.d.ts +5 -0
- package/types/src/api/blockManipulation/commands/moveBlock/moveBlock.test.d.ts +1 -0
- package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.d.ts +7 -0
- package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.d.ts +1 -0
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +7 -0
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.d.ts +1 -0
- package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.d.ts +5 -0
- package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.test.d.ts +1 -0
- package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.d.ts +11 -0
- package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.test.d.ts +1 -0
- package/types/src/api/blockManipulation/insertContentAt.d.ts +6 -0
- package/types/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.d.ts +5 -0
- package/types/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.d.ts +1 -0
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +492 -0
- package/types/src/api/clipboard/fromClipboard/fileDropExtension.d.ts +3 -3
- package/types/src/api/clipboard/fromClipboard/handleFileInsertion.d.ts +1 -1
- package/types/src/api/clipboard/fromClipboard/pasteExtension.d.ts +2 -2
- package/types/src/api/clipboard/toClipboard/copyExtension.d.ts +5 -5
- package/types/src/api/exporters/html/externalHTMLExporter.d.ts +7 -9
- package/types/src/api/exporters/html/internalHTMLSerializer.d.ts +6 -10
- package/types/src/api/exporters/html/util/serializeBlocksExternalHTML.d.ts +10 -0
- package/types/src/api/exporters/html/util/serializeBlocksInternalHTML.d.ts +11 -0
- package/types/src/api/exporters/markdown/markdownExporter.d.ts +3 -3
- package/types/src/api/getBlockInfoFromPos.d.ts +63 -20
- package/types/src/api/nodeConversions/blockToNode.d.ts +15 -0
- package/types/src/api/nodeConversions/fragmentToBlocks.d.ts +7 -0
- package/types/src/api/nodeConversions/nodeToBlock.d.ts +16 -0
- package/types/src/api/parsers/html/parseHTML.d.ts +2 -2
- package/types/src/api/parsers/markdown/parseMarkdown.d.ts +2 -2
- package/types/src/api/testUtil/cases/customBlocks.d.ts +39 -39
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +35 -35
- package/types/src/api/testUtil/cases/customStyles.d.ts +35 -35
- package/types/src/api/testUtil/cases/defaultSchema.d.ts +2 -2
- package/types/src/api/testUtil/index.d.ts +6 -6
- package/types/src/api/testUtil/partialBlockTestUtil.d.ts +4 -4
- package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +4 -4
- package/types/src/blocks/FileBlockContent/FileBlockContent.d.ts +4 -4
- package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +2 -2
- package/types/src/blocks/HeadingBlockContent/HeadingBlockContent.d.ts +2 -2
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +4 -4
- package/types/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +2 -2
- package/types/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.d.ts +2 -2
- package/types/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.d.ts +2 -2
- package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +2 -2
- package/types/src/blocks/ParagraphBlockContent/ParagraphBlockContent.d.ts +2 -2
- package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +2 -2
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +4 -4
- package/types/src/blocks/defaultBlockHelpers.d.ts +3 -3
- package/types/src/blocks/defaultBlockTypeGuards.d.ts +4 -4
- package/types/src/blocks/defaultBlocks.d.ts +38 -38
- package/types/src/blocks/defaultProps.d.ts +1 -1
- package/types/src/editor/BlockNoteEditor.d.ts +28 -16
- package/types/src/editor/BlockNoteExtensions.d.ts +3 -3
- package/types/src/editor/BlockNoteSchema.d.ts +4 -4
- package/types/src/editor/BlockNoteTipTapEditor.d.ts +2 -2
- package/types/src/editor/cursorPositionTypes.d.ts +3 -2
- package/types/src/editor/selectionTypes.d.ts +2 -2
- package/types/src/extensions/BackgroundColor/BackgroundColorMark.d.ts +1 -1
- package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +4 -4
- package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +4 -4
- package/types/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.d.ts +5 -0
- package/types/src/extensions/LinkToolbar/LinkToolbarPlugin.d.ts +4 -4
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.d.ts +2 -0
- package/types/src/extensions/Placeholder/PlaceholderPlugin.d.ts +1 -1
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +12 -28
- package/types/src/extensions/SideMenu/dragging.d.ts +17 -0
- package/types/src/extensions/SuggestionMenu/DefaultSuggestionItem.d.ts +1 -1
- package/types/src/extensions/SuggestionMenu/SuggestionPlugin.d.ts +4 -4
- package/types/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.d.ts +3 -3
- package/types/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.d.ts +4 -4
- package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +4 -4
- package/types/src/extensions/TextColor/TextColorMark.d.ts +1 -1
- package/types/src/i18n/dictionary.d.ts +1 -1
- package/types/src/i18n/locales/ar.d.ts +1 -1
- package/types/src/i18n/locales/fr.d.ts +1 -1
- package/types/src/i18n/locales/hr.d.ts +239 -0
- package/types/src/i18n/locales/index.d.ts +15 -14
- package/types/src/i18n/locales/is.d.ts +1 -1
- package/types/src/i18n/locales/ja.d.ts +1 -1
- package/types/src/i18n/locales/ko.d.ts +1 -1
- package/types/src/i18n/locales/nl.d.ts +1 -1
- package/types/src/i18n/locales/pl.d.ts +1 -1
- package/types/src/i18n/locales/pt.d.ts +1 -1
- package/types/src/i18n/locales/ru.d.ts +1 -1
- package/types/src/i18n/locales/vi.d.ts +1 -1
- package/types/src/i18n/locales/zh.d.ts +1 -1
- package/types/src/index.d.ts +45 -44
- package/types/src/pm-nodes/BlockContainer.d.ts +2 -16
- package/types/src/pm-nodes/BlockGroup.d.ts +1 -1
- package/types/src/pm-nodes/index.d.ts +3 -3
- package/types/src/schema/blocks/createSpec.d.ts +5 -5
- package/types/src/schema/blocks/internal.d.ts +5 -5
- package/types/src/schema/blocks/types.d.ts +4 -4
- package/types/src/schema/index.d.ts +10 -10
- package/types/src/schema/inlineContent/createSpec.d.ts +3 -3
- package/types/src/schema/inlineContent/internal.d.ts +2 -2
- package/types/src/schema/inlineContent/types.d.ts +2 -2
- package/types/src/schema/styles/createSpec.d.ts +1 -1
- package/types/src/schema/styles/internal.d.ts +1 -1
- package/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap +0 -714
- package/src/api/blockManipulation/blockManipulation.test.ts +0 -292
- package/src/api/blockManipulation/blockManipulation.ts +0 -350
- package/src/api/exporters/html/util/sharedHTMLConversion.ts +0 -130
- package/src/api/exporters/html/util/simplifyBlocksRehypePlugin.ts +0 -218
- package/src/api/getCurrentBlockContentType.ts +0 -14
- package/types/src/api/blockManipulation/blockManipulation.d.ts +0 -14
- package/types/src/api/exporters/html/util/sharedHTMLConversion.d.ts +0 -9
- package/types/src/api/exporters/html/util/simplifyBlocksRehypePlugin.d.ts +0 -16
- package/types/src/api/getCurrentBlockContentType.d.ts +0 -2
- package/types/src/api/nodeConversions/nodeConversions.d.ts +0 -24
- package/types/src/extensions/NonEditableBlocks/NonEditableBlockPlugin.d.ts +0 -2
- /package/types/src/api/blockManipulation/{blockManipulation.test.d.ts → commands/insertBlocks/insertBlocks.test.d.ts} +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { InputRule } from "@tiptap/core";
|
|
2
|
+
import { updateBlockCommand } from "../../api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
3
|
+
import { getBlockInfoFromSelection } from "../../api/getBlockInfoFromPos.js";
|
|
2
4
|
import {
|
|
3
5
|
PropSchema,
|
|
4
6
|
createBlockSpecFromStronglyTypedTiptapNode,
|
|
5
7
|
createStronglyTypedTiptapNode,
|
|
6
|
-
} from "../../schema";
|
|
7
|
-
import { createDefaultBlockDOMOutputSpec } from "../defaultBlockHelpers";
|
|
8
|
-
import { defaultProps } from "../defaultProps";
|
|
9
|
-
import { getCurrentBlockContentType } from "../../api/getCurrentBlockContentType";
|
|
8
|
+
} from "../../schema/index.js";
|
|
9
|
+
import { createDefaultBlockDOMOutputSpec } from "../defaultBlockHelpers.js";
|
|
10
|
+
import { defaultProps } from "../defaultProps.js";
|
|
10
11
|
|
|
11
12
|
export const headingPropSchema = {
|
|
12
13
|
...defaultProps,
|
|
@@ -46,19 +47,27 @@ const HeadingBlockContent = createStronglyTypedTiptapNode({
|
|
|
46
47
|
return new InputRule({
|
|
47
48
|
find: new RegExp(`^(#{${level}})\\s$`),
|
|
48
49
|
handler: ({ state, chain, range }) => {
|
|
49
|
-
|
|
50
|
+
const blockInfo = getBlockInfoFromSelection(state);
|
|
51
|
+
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
50
52
|
return;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
chain()
|
|
54
|
-
.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
.command(
|
|
57
|
+
updateBlockCommand(
|
|
58
|
+
this.options.editor,
|
|
59
|
+
blockInfo.blockContainer.beforePos,
|
|
60
|
+
{
|
|
61
|
+
type: "heading",
|
|
62
|
+
props: {
|
|
63
|
+
level: level as any,
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
)
|
|
60
68
|
// Removes the "#" character(s) used to set the heading.
|
|
61
|
-
.deleteRange({ from: range.from, to: range.to })
|
|
69
|
+
.deleteRange({ from: range.from, to: range.to })
|
|
70
|
+
.run();
|
|
62
71
|
},
|
|
63
72
|
});
|
|
64
73
|
}),
|
|
@@ -68,48 +77,61 @@ const HeadingBlockContent = createStronglyTypedTiptapNode({
|
|
|
68
77
|
addKeyboardShortcuts() {
|
|
69
78
|
return {
|
|
70
79
|
"Mod-Alt-1": () => {
|
|
71
|
-
|
|
80
|
+
const blockInfo = getBlockInfoFromSelection(this.editor.state);
|
|
81
|
+
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
72
82
|
return true;
|
|
73
83
|
}
|
|
74
84
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
// call updateBlockCommand
|
|
86
|
+
return this.editor.commands.command(
|
|
87
|
+
updateBlockCommand(
|
|
88
|
+
this.options.editor,
|
|
89
|
+
blockInfo.blockContainer.beforePos,
|
|
90
|
+
{
|
|
91
|
+
type: "heading",
|
|
92
|
+
props: {
|
|
93
|
+
level: 1 as any,
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
)
|
|
83
97
|
);
|
|
84
98
|
},
|
|
85
99
|
"Mod-Alt-2": () => {
|
|
86
|
-
|
|
100
|
+
const blockInfo = getBlockInfoFromSelection(this.editor.state);
|
|
101
|
+
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
87
102
|
return true;
|
|
88
103
|
}
|
|
89
104
|
|
|
90
|
-
return this.editor.commands.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
105
|
+
return this.editor.commands.command(
|
|
106
|
+
updateBlockCommand(
|
|
107
|
+
this.options.editor,
|
|
108
|
+
blockInfo.blockContainer.beforePos,
|
|
109
|
+
{
|
|
110
|
+
type: "heading",
|
|
111
|
+
props: {
|
|
112
|
+
level: 2 as any,
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
)
|
|
98
116
|
);
|
|
99
117
|
},
|
|
100
118
|
"Mod-Alt-3": () => {
|
|
101
|
-
|
|
119
|
+
const blockInfo = getBlockInfoFromSelection(this.editor.state);
|
|
120
|
+
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
102
121
|
return true;
|
|
103
122
|
}
|
|
104
123
|
|
|
105
|
-
return this.editor.commands.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
124
|
+
return this.editor.commands.command(
|
|
125
|
+
updateBlockCommand(
|
|
126
|
+
this.options.editor,
|
|
127
|
+
blockInfo.blockContainer.beforePos,
|
|
128
|
+
{
|
|
129
|
+
type: "heading",
|
|
130
|
+
props: {
|
|
131
|
+
level: 3 as any,
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
)
|
|
113
135
|
);
|
|
114
136
|
},
|
|
115
137
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
1
|
+
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
2
2
|
import {
|
|
3
3
|
BlockFromConfig,
|
|
4
4
|
createBlockSpec,
|
|
5
5
|
FileBlockConfig,
|
|
6
6
|
Props,
|
|
7
7
|
PropSchema,
|
|
8
|
-
} from "../../schema";
|
|
9
|
-
import { defaultProps } from "../defaultProps";
|
|
8
|
+
} from "../../schema/index.js";
|
|
9
|
+
import { defaultProps } from "../defaultProps.js";
|
|
10
10
|
import {
|
|
11
11
|
createFigureWithCaption,
|
|
12
12
|
createFileAndCaptionWrapper,
|
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
createLinkWithCaption,
|
|
15
15
|
createResizeHandlesWrapper,
|
|
16
16
|
parseFigureElement,
|
|
17
|
-
} from "../FileBlockContent/fileBlockHelpers";
|
|
18
|
-
import { parseImageElement } from "./imageBlockHelpers";
|
|
17
|
+
} from "../FileBlockContent/fileBlockHelpers.js";
|
|
18
|
+
import { parseImageElement } from "./imageBlockHelpers.js";
|
|
19
19
|
|
|
20
20
|
export const imagePropSchema = {
|
|
21
21
|
textAlignment: defaultProps.textAlignment,
|
package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { InputRule } from "@tiptap/core";
|
|
2
|
+
import { updateBlockCommand } from "../../../api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
3
|
+
import { getBlockInfoFromSelection } from "../../../api/getBlockInfoFromPos.js";
|
|
2
4
|
import {
|
|
3
5
|
PropSchema,
|
|
4
6
|
createBlockSpecFromStronglyTypedTiptapNode,
|
|
5
7
|
createStronglyTypedTiptapNode,
|
|
6
|
-
} from "../../../schema";
|
|
7
|
-
import { createDefaultBlockDOMOutputSpec } from "../../defaultBlockHelpers";
|
|
8
|
-
import { defaultProps } from "../../defaultProps";
|
|
9
|
-
import { handleEnter } from "../ListItemKeyboardShortcuts";
|
|
10
|
-
import { getCurrentBlockContentType } from "../../../api/getCurrentBlockContentType";
|
|
8
|
+
} from "../../../schema/index.js";
|
|
9
|
+
import { createDefaultBlockDOMOutputSpec } from "../../defaultBlockHelpers.js";
|
|
10
|
+
import { defaultProps } from "../../defaultProps.js";
|
|
11
|
+
import { handleEnter } from "../ListItemKeyboardShortcuts.js";
|
|
11
12
|
|
|
12
13
|
export const bulletListItemPropSchema = {
|
|
13
14
|
...defaultProps,
|
|
@@ -26,15 +27,22 @@ const BulletListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
26
27
|
new InputRule({
|
|
27
28
|
find: new RegExp(`^[-+*]\\s$`),
|
|
28
29
|
handler: ({ state, chain, range }) => {
|
|
29
|
-
|
|
30
|
+
const blockInfo = getBlockInfoFromSelection(state);
|
|
31
|
+
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
30
32
|
return;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
chain()
|
|
34
|
-
.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
.command(
|
|
37
|
+
updateBlockCommand(
|
|
38
|
+
this.options.editor,
|
|
39
|
+
blockInfo.blockContainer.beforePos,
|
|
40
|
+
{
|
|
41
|
+
type: "bulletListItem",
|
|
42
|
+
props: {},
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
)
|
|
38
46
|
// Removes the "-", "+", or "*" character used to set the list.
|
|
39
47
|
.deleteRange({ from: range.from, to: range.to });
|
|
40
48
|
},
|
|
@@ -44,18 +52,22 @@ const BulletListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
44
52
|
|
|
45
53
|
addKeyboardShortcuts() {
|
|
46
54
|
return {
|
|
47
|
-
Enter: () => handleEnter(this.editor),
|
|
55
|
+
Enter: () => handleEnter(this.options.editor),
|
|
48
56
|
"Mod-Shift-8": () => {
|
|
49
|
-
|
|
57
|
+
const blockInfo = getBlockInfoFromSelection(this.editor.state);
|
|
58
|
+
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
50
59
|
return true;
|
|
51
60
|
}
|
|
52
61
|
|
|
53
|
-
return this.editor.commands.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
return this.options.editor.commands.command(
|
|
63
|
+
updateBlockCommand(
|
|
64
|
+
this.options.editor,
|
|
65
|
+
blockInfo.blockContainer.beforePos,
|
|
66
|
+
{
|
|
67
|
+
type: "bulletListItem",
|
|
68
|
+
props: {},
|
|
69
|
+
}
|
|
70
|
+
)
|
|
59
71
|
);
|
|
60
72
|
},
|
|
61
73
|
};
|
package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { InputRule } from "@tiptap/core";
|
|
2
|
+
import { updateBlockCommand } from "../../../api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
3
|
+
import {
|
|
4
|
+
getBlockInfoFromSelection,
|
|
5
|
+
getNearestBlockContainerPos,
|
|
6
|
+
} from "../../../api/getBlockInfoFromPos.js";
|
|
2
7
|
import {
|
|
3
8
|
PropSchema,
|
|
4
9
|
createBlockSpecFromStronglyTypedTiptapNode,
|
|
5
10
|
createStronglyTypedTiptapNode,
|
|
6
|
-
} from "../../../schema";
|
|
7
|
-
import { createDefaultBlockDOMOutputSpec } from "../../defaultBlockHelpers";
|
|
8
|
-
import { defaultProps } from "../../defaultProps";
|
|
9
|
-
import { handleEnter } from "../ListItemKeyboardShortcuts";
|
|
10
|
-
import { getCurrentBlockContentType } from "../../../api/getCurrentBlockContentType";
|
|
11
|
+
} from "../../../schema/index.js";
|
|
12
|
+
import { createDefaultBlockDOMOutputSpec } from "../../defaultBlockHelpers.js";
|
|
13
|
+
import { defaultProps } from "../../defaultProps.js";
|
|
14
|
+
import { handleEnter } from "../ListItemKeyboardShortcuts.js";
|
|
11
15
|
|
|
12
16
|
export const checkListItemPropSchema = {
|
|
13
17
|
...defaultProps,
|
|
@@ -44,17 +48,24 @@ const checkListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
44
48
|
new InputRule({
|
|
45
49
|
find: new RegExp(`\\[\\s*\\]\\s$`),
|
|
46
50
|
handler: ({ state, chain, range }) => {
|
|
47
|
-
|
|
51
|
+
const blockInfo = getBlockInfoFromSelection(state);
|
|
52
|
+
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
48
53
|
return;
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
chain()
|
|
52
|
-
.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
.command(
|
|
58
|
+
updateBlockCommand(
|
|
59
|
+
this.options.editor,
|
|
60
|
+
blockInfo.blockContainer.beforePos,
|
|
61
|
+
{
|
|
62
|
+
type: "checkListItem",
|
|
63
|
+
props: {
|
|
64
|
+
checked: false as any,
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
)
|
|
58
69
|
// Removes the characters used to set the list.
|
|
59
70
|
.deleteRange({ from: range.from, to: range.to });
|
|
60
71
|
},
|
|
@@ -62,17 +73,25 @@ const checkListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
62
73
|
new InputRule({
|
|
63
74
|
find: new RegExp(`\\[[Xx]\\]\\s$`),
|
|
64
75
|
handler: ({ state, chain, range }) => {
|
|
65
|
-
|
|
76
|
+
const blockInfo = getBlockInfoFromSelection(state);
|
|
77
|
+
|
|
78
|
+
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
66
79
|
return;
|
|
67
80
|
}
|
|
68
81
|
|
|
69
82
|
chain()
|
|
70
|
-
.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
.command(
|
|
84
|
+
updateBlockCommand(
|
|
85
|
+
this.options.editor,
|
|
86
|
+
blockInfo.blockContainer.beforePos,
|
|
87
|
+
{
|
|
88
|
+
type: "checkListItem",
|
|
89
|
+
props: {
|
|
90
|
+
checked: true as any,
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
)
|
|
76
95
|
// Removes the characters used to set the list.
|
|
77
96
|
.deleteRange({ from: range.from, to: range.to });
|
|
78
97
|
},
|
|
@@ -82,18 +101,22 @@ const checkListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
82
101
|
|
|
83
102
|
addKeyboardShortcuts() {
|
|
84
103
|
return {
|
|
85
|
-
Enter: () => handleEnter(this.editor),
|
|
104
|
+
Enter: () => handleEnter(this.options.editor),
|
|
86
105
|
"Mod-Shift-9": () => {
|
|
87
|
-
|
|
106
|
+
const blockInfo = getBlockInfoFromSelection(this.options.editor.state);
|
|
107
|
+
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
88
108
|
return true;
|
|
89
109
|
}
|
|
90
110
|
|
|
91
|
-
return this.editor.commands.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
111
|
+
return this.editor.commands.command(
|
|
112
|
+
updateBlockCommand(
|
|
113
|
+
this.options.editor,
|
|
114
|
+
blockInfo.blockContainer.beforePos,
|
|
115
|
+
{
|
|
116
|
+
type: "checkListItem",
|
|
117
|
+
props: {},
|
|
118
|
+
}
|
|
119
|
+
)
|
|
97
120
|
);
|
|
98
121
|
},
|
|
99
122
|
};
|
|
@@ -211,13 +234,24 @@ const checkListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
211
234
|
return;
|
|
212
235
|
}
|
|
213
236
|
|
|
237
|
+
// TODO: test
|
|
214
238
|
if (typeof getPos !== "boolean") {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
239
|
+
const beforeBlockContainerPos = getNearestBlockContainerPos(
|
|
240
|
+
editor.state.doc,
|
|
241
|
+
getPos()
|
|
242
|
+
);
|
|
243
|
+
this.editor.commands.command(
|
|
244
|
+
updateBlockCommand(
|
|
245
|
+
this.options.editor,
|
|
246
|
+
beforeBlockContainerPos.posBeforeNode,
|
|
247
|
+
{
|
|
248
|
+
type: "checkListItem",
|
|
249
|
+
props: {
|
|
250
|
+
checked: checkbox.checked as any,
|
|
251
|
+
},
|
|
252
|
+
}
|
|
253
|
+
)
|
|
254
|
+
);
|
|
221
255
|
}
|
|
222
256
|
};
|
|
223
257
|
checkbox.addEventListener("change", changeHandler);
|
|
@@ -1,35 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { splitBlockCommand } from "../../api/blockManipulation/commands/splitBlock/splitBlock.js";
|
|
2
|
+
import { updateBlockCommand } from "../../api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
3
|
+
import { getBlockInfoFromSelection } from "../../api/getBlockInfoFromPos.js";
|
|
4
|
+
import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
3
5
|
|
|
4
|
-
export const handleEnter = (editor:
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
)
|
|
6
|
+
export const handleEnter = (editor: BlockNoteEditor<any, any, any>) => {
|
|
7
|
+
const ttEditor = editor._tiptapEditor;
|
|
8
|
+
const { blockContent, blockContainer } = getBlockInfoFromSelection(
|
|
9
|
+
ttEditor.state
|
|
10
|
+
);
|
|
9
11
|
|
|
10
12
|
const selectionEmpty =
|
|
11
|
-
|
|
13
|
+
ttEditor.state.selection.anchor === ttEditor.state.selection.head;
|
|
12
14
|
|
|
13
15
|
if (
|
|
14
16
|
!(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
blockContent.node.type.name === "bulletListItem" ||
|
|
18
|
+
blockContent.node.type.name === "numberedListItem" ||
|
|
19
|
+
blockContent.node.type.name === "checkListItem"
|
|
18
20
|
) ||
|
|
19
21
|
!selectionEmpty
|
|
20
22
|
) {
|
|
21
23
|
return false;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
return
|
|
26
|
+
return ttEditor.commands.first(({ state, chain, commands }) => [
|
|
25
27
|
() =>
|
|
26
28
|
// Changes list item block to a paragraph block if the content is empty.
|
|
27
29
|
commands.command(() => {
|
|
28
|
-
if (
|
|
29
|
-
return commands.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
if (blockContent.node.childCount === 0) {
|
|
31
|
+
return commands.command(
|
|
32
|
+
updateBlockCommand(editor, blockContainer.beforePos, {
|
|
33
|
+
type: "paragraph",
|
|
34
|
+
props: {},
|
|
35
|
+
})
|
|
36
|
+
);
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
return false;
|
|
@@ -39,10 +43,10 @@ export const handleEnter = (editor: Editor) => {
|
|
|
39
43
|
// Splits the current block, moving content inside that's after the cursor
|
|
40
44
|
// to a new block of the same type below.
|
|
41
45
|
commands.command(() => {
|
|
42
|
-
if (
|
|
46
|
+
if (blockContent.node.childCount > 0) {
|
|
43
47
|
chain()
|
|
44
48
|
.deleteSelection()
|
|
45
|
-
.
|
|
49
|
+
.command(splitBlockCommand(state.selection.from, true))
|
|
46
50
|
.run();
|
|
47
51
|
|
|
48
52
|
return true;
|
package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Plugin, PluginKey } from "prosemirror-state";
|
|
2
|
-
import {
|
|
2
|
+
import { getBlockInfo } from "../../../api/getBlockInfoFromPos.js";
|
|
3
3
|
|
|
4
4
|
// ProseMirror Plugin which automatically assigns indices to ordered list items per nesting level.
|
|
5
5
|
const PLUGIN_KEY = new PluginKey(`numbered-list-indexing`);
|
|
@@ -21,46 +21,44 @@ export const NumberedListIndexingPlugin = () => {
|
|
|
21
21
|
node.firstChild!.type.name === "numberedListItem"
|
|
22
22
|
) {
|
|
23
23
|
let newIndex = "1";
|
|
24
|
-
const isFirstBlockInDoc = pos === 1;
|
|
25
24
|
|
|
26
|
-
const blockInfo =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
25
|
+
const blockInfo = getBlockInfo({
|
|
26
|
+
posBeforeNode: pos,
|
|
27
|
+
node,
|
|
28
|
+
});
|
|
30
29
|
|
|
31
30
|
// Checks if this block is the start of a new ordered list, i.e. if it's the first block in the document, the
|
|
32
31
|
// first block in its nesting level, or the previous block is not an ordered list item.
|
|
33
|
-
if (!isFirstBlockInDoc) {
|
|
34
|
-
const prevBlockInfo = getBlockInfoFromPos(tr.doc, pos - 2)!;
|
|
35
|
-
if (prevBlockInfo === undefined) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
32
|
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
const prevBlock = tr.doc.resolve(
|
|
34
|
+
blockInfo.blockContainer.beforePos
|
|
35
|
+
).nodeBefore;
|
|
41
36
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
if (prevBlock) {
|
|
38
|
+
const prevBlockInfo = getBlockInfo({
|
|
39
|
+
posBeforeNode:
|
|
40
|
+
blockInfo.blockContainer.beforePos - prevBlock.nodeSize,
|
|
41
|
+
node: prevBlock,
|
|
42
|
+
});
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
const isPrevBlockOrderedListItem =
|
|
45
|
+
prevBlockInfo.blockContent.node.type.name === "numberedListItem";
|
|
48
46
|
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
if (isPrevBlockOrderedListItem) {
|
|
48
|
+
const prevBlockIndex =
|
|
49
|
+
prevBlockInfo.blockContent.node.attrs["index"];
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
}
|
|
51
|
+
newIndex = (parseInt(prevBlockIndex) + 1).toString();
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
const contentNode = blockInfo.
|
|
55
|
+
const contentNode = blockInfo.blockContent.node;
|
|
58
56
|
const index = contentNode.attrs["index"];
|
|
59
57
|
|
|
60
58
|
if (index !== newIndex) {
|
|
61
59
|
modified = true;
|
|
62
60
|
|
|
63
|
-
tr.setNodeMarkup(
|
|
61
|
+
tr.setNodeMarkup(blockInfo.blockContent.beforePos, undefined, {
|
|
64
62
|
index: newIndex,
|
|
65
63
|
});
|
|
66
64
|
}
|
package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { InputRule } from "@tiptap/core";
|
|
2
|
+
import { updateBlockCommand } from "../../../api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
3
|
+
import { getBlockInfoFromSelection } from "../../../api/getBlockInfoFromPos.js";
|
|
2
4
|
import {
|
|
3
5
|
PropSchema,
|
|
4
6
|
createBlockSpecFromStronglyTypedTiptapNode,
|
|
5
7
|
createStronglyTypedTiptapNode,
|
|
6
|
-
} from "../../../schema";
|
|
7
|
-
import { createDefaultBlockDOMOutputSpec } from "../../defaultBlockHelpers";
|
|
8
|
-
import { defaultProps } from "../../defaultProps";
|
|
9
|
-
import { handleEnter } from "../ListItemKeyboardShortcuts";
|
|
10
|
-
import { NumberedListIndexingPlugin } from "./NumberedListIndexingPlugin";
|
|
11
|
-
import { getCurrentBlockContentType } from "../../../api/getCurrentBlockContentType";
|
|
8
|
+
} from "../../../schema/index.js";
|
|
9
|
+
import { createDefaultBlockDOMOutputSpec } from "../../defaultBlockHelpers.js";
|
|
10
|
+
import { defaultProps } from "../../defaultProps.js";
|
|
11
|
+
import { handleEnter } from "../ListItemKeyboardShortcuts.js";
|
|
12
|
+
import { NumberedListIndexingPlugin } from "./NumberedListIndexingPlugin.js";
|
|
12
13
|
|
|
13
14
|
export const numberedListItemPropSchema = {
|
|
14
15
|
...defaultProps,
|
|
@@ -39,15 +40,22 @@ const NumberedListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
39
40
|
new InputRule({
|
|
40
41
|
find: new RegExp(`^1\\.\\s$`),
|
|
41
42
|
handler: ({ state, chain, range }) => {
|
|
42
|
-
|
|
43
|
+
const blockInfo = getBlockInfoFromSelection(state);
|
|
44
|
+
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
43
45
|
return;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
chain()
|
|
47
|
-
.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
.command(
|
|
50
|
+
updateBlockCommand(
|
|
51
|
+
this.options.editor,
|
|
52
|
+
blockInfo.blockContainer.beforePos,
|
|
53
|
+
{
|
|
54
|
+
type: "numberedListItem",
|
|
55
|
+
props: {},
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
)
|
|
51
59
|
// Removes the "1." characters used to set the list.
|
|
52
60
|
.deleteRange({ from: range.from, to: range.to });
|
|
53
61
|
},
|
|
@@ -57,18 +65,22 @@ const NumberedListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
57
65
|
|
|
58
66
|
addKeyboardShortcuts() {
|
|
59
67
|
return {
|
|
60
|
-
Enter: () => handleEnter(this.editor),
|
|
68
|
+
Enter: () => handleEnter(this.options.editor),
|
|
61
69
|
"Mod-Shift-7": () => {
|
|
62
|
-
|
|
70
|
+
const blockInfo = getBlockInfoFromSelection(this.editor.state);
|
|
71
|
+
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
63
72
|
return true;
|
|
64
73
|
}
|
|
65
74
|
|
|
66
|
-
return this.editor.commands.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
return this.editor.commands.command(
|
|
76
|
+
updateBlockCommand(
|
|
77
|
+
this.options.editor,
|
|
78
|
+
blockInfo.blockContainer.beforePos,
|
|
79
|
+
{
|
|
80
|
+
type: "numberedListItem",
|
|
81
|
+
props: {},
|
|
82
|
+
}
|
|
83
|
+
)
|
|
72
84
|
);
|
|
73
85
|
},
|
|
74
86
|
};
|