@blocknote/core 0.30.0 → 0.31.0
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.cjs +9 -9
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +2771 -2245
- package/dist/blocknote.js.map +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js.map +1 -1
- package/dist/{en-D4taoCs4.cjs → en-BXVKCwYt.cjs} +2 -2
- package/dist/en-BXVKCwYt.cjs.map +1 -0
- package/dist/{en-B7ycW7c8.js → en-qGo6sk9V.js} +2 -3
- package/dist/en-qGo6sk9V.js.map +1 -0
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +20 -39
- package/dist/locales.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +8 -7
- package/src/api/README.md +1 -1
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +19 -14
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +7 -8
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +3 -3
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +12 -12
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +14 -14
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +16 -16
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +8 -8
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +12 -12
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +8 -8
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +10 -10
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +2 -2
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +2816 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +200 -42
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +104 -34
- package/src/api/blockManipulation/getBlock/getBlock.ts +9 -9
- package/src/api/blockManipulation/insertContentAt.ts +1 -1
- package/src/api/blockManipulation/selections/selection.ts +59 -12
- package/src/api/blockManipulation/selections/{textCursorPosition/textCursorPosition.ts → textCursorPosition.ts} +13 -13
- package/src/api/blockManipulation/tables/tables.test.ts +106 -106
- package/src/api/blockManipulation/tables/tables.ts +35 -35
- package/src/api/clipboard/fromClipboard/fileDropExtension.ts +2 -2
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +9 -9
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +3 -3
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +3 -3
- package/src/api/clipboard/toClipboard/copyExtension.ts +22 -22
- package/src/api/exporters/html/externalHTMLExporter.ts +6 -6
- package/src/api/exporters/html/internalHTMLSerializer.ts +3 -3
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +16 -16
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +14 -14
- package/src/api/exporters/markdown/markdownExporter.ts +3 -3
- package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +3 -3
- package/src/api/getBlockInfoFromPos.ts +6 -6
- package/src/api/nodeConversions/blockToNode.ts +31 -28
- package/src/api/nodeConversions/fragmentToBlocks.ts +1 -1
- package/src/api/nodeConversions/nodeToBlock.ts +240 -41
- package/src/api/nodeUtil.test.ts +16 -16
- package/src/api/nodeUtil.ts +10 -10
- package/src/api/parsers/html/parseHTML.ts +1 -1
- package/src/api/parsers/html/util/nestedLists.ts +2 -2
- package/src/api/parsers/markdown/parseMarkdown.ts +1 -1
- package/src/api/pmUtil.ts +7 -7
- package/src/api/positionMapping.test.ts +3 -3
- package/src/api/positionMapping.ts +5 -5
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +4 -4
- package/src/blocks/CodeBlockContent/CodeBlockContent.ts +18 -18
- package/src/blocks/FileBlockContent/FileBlockContent.ts +2 -2
- package/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.ts +2 -2
- package/src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts +6 -6
- package/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.ts +2 -2
- package/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.ts +1 -1
- package/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts +7 -7
- package/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.ts +1 -1
- package/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.ts +1 -1
- package/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts +2 -2
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +6 -6
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +4 -4
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +4 -4
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +10 -10
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +4 -4
- package/src/blocks/ListItemBlockContent/getListItemContent.ts +5 -5
- package/src/blocks/PageBreakBlockContent/PageBreakBlockContent.ts +1 -1
- package/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.ts +3 -3
- package/src/blocks/PageBreakBlockContent/schema.ts +2 -2
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +3 -3
- package/src/blocks/QuoteBlockContent/QuoteBlockContent.ts +4 -4
- package/src/blocks/README.md +1 -1
- package/src/blocks/TableBlockContent/TableBlockContent.ts +37 -7
- package/src/blocks/TableBlockContent/TableExtension.ts +3 -3
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +4 -4
- package/src/blocks/defaultBlockHelpers.ts +8 -8
- package/src/blocks/defaultBlockTypeGuards.ts +16 -16
- package/src/blocks/defaultBlocks.ts +3 -3
- package/src/comments/threadstore/DefaultThreadStoreAuth.ts +3 -3
- package/src/comments/threadstore/ThreadStore.ts +1 -1
- package/src/comments/threadstore/TipTapThreadStore.ts +10 -10
- package/src/comments/threadstore/yjs/RESTYjsThreadStore.ts +4 -4
- package/src/comments/threadstore/yjs/YjsThreadStore.test.ts +2 -2
- package/src/comments/threadstore/yjs/YjsThreadStore.ts +14 -14
- package/src/comments/threadstore/yjs/YjsThreadStoreBase.ts +1 -1
- package/src/comments/threadstore/yjs/yjsHelpers.ts +6 -6
- package/src/editor/Block.css +35 -1
- package/src/editor/BlockNoteEditor.test.ts +10 -3
- package/src/editor/BlockNoteEditor.ts +95 -38
- package/src/editor/BlockNoteExtension.ts +26 -0
- package/src/editor/BlockNoteExtensions.ts +38 -22
- package/src/editor/BlockNoteSchema.ts +4 -4
- package/src/editor/BlockNoteTipTapEditor.ts +33 -12
- package/src/editor/README.md +1 -1
- package/src/editor/cursorPositionTypes.ts +1 -1
- package/src/editor/editor.css +15 -3
- package/src/editor/selectionTypes.ts +1 -1
- package/src/editor/transformPasted.ts +2 -2
- package/src/exporter/Exporter.ts +5 -5
- package/src/exporter/mapping.ts +7 -7
- package/src/extensions/BackgroundColor/BackgroundColorMark.ts +1 -1
- package/src/extensions/Collaboration/CursorPlugin.ts +15 -9
- package/src/extensions/Collaboration/ForkYDocPlugin.test.ts +166 -0
- package/src/extensions/Collaboration/ForkYDocPlugin.ts +174 -0
- package/src/extensions/Collaboration/SyncPlugin.ts +7 -4
- package/src/extensions/Collaboration/UndoPlugin.ts +7 -4
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor-forked.json +30 -0
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor.json +30 -0
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-forked.html +1 -0
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap.html +1 -0
- package/src/extensions/Comments/CommentsPlugin.ts +80 -75
- package/src/extensions/Comments/userstore/UserStore.ts +2 -2
- package/src/extensions/FilePanel/FilePanelPlugin.ts +56 -55
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +60 -30
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +26 -26
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +33 -32
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +45 -42
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +113 -110
- package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +179 -170
- package/src/extensions/README.md +1 -1
- package/src/extensions/ShowSelection/ShowSelectionPlugin.ts +22 -19
- package/src/extensions/SideMenu/MultipleNodeSelection.ts +1 -1
- package/src/extensions/SideMenu/SideMenuPlugin.ts +49 -48
- package/src/extensions/SideMenu/dragging.ts +8 -8
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +176 -176
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +2 -2
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +16 -16
- package/src/extensions/Suggestions/SuggestionMarks.ts +175 -0
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +199 -195
- package/src/extensions/TrailingNode/TrailingNodeExtension.ts +1 -1
- package/src/extensions/UniqueID/UniqueID.ts +6 -6
- package/src/extensions/getDraggableBlockFromElement.ts +1 -1
- package/src/fonts/inter.css +18 -9
- package/src/i18n/locales/ar.ts +0 -1
- package/src/i18n/locales/de.ts +0 -1
- package/src/i18n/locales/en.ts +0 -1
- package/src/i18n/locales/es.ts +0 -1
- package/src/i18n/locales/fr.ts +0 -1
- package/src/i18n/locales/hr.ts +0 -1
- package/src/i18n/locales/is.ts +0 -1
- package/src/i18n/locales/it.ts +0 -1
- package/src/i18n/locales/ja.ts +0 -1
- package/src/i18n/locales/ko.ts +0 -1
- package/src/i18n/locales/nl.ts +0 -1
- package/src/i18n/locales/no.ts +0 -1
- package/src/i18n/locales/pl.ts +0 -1
- package/src/i18n/locales/pt.ts +0 -1
- package/src/i18n/locales/ru.ts +0 -1
- package/src/i18n/locales/sk.ts +0 -1
- package/src/i18n/locales/uk.ts +0 -1
- package/src/i18n/locales/vi.ts +0 -1
- package/src/i18n/locales/zh-tw.ts +0 -1
- package/src/i18n/locales/zh.ts +0 -1
- package/src/index.ts +18 -8
- package/src/locales.ts +1 -1
- package/src/pm-nodes/BlockContainer.ts +1 -1
- package/src/pm-nodes/BlockGroup.ts +2 -2
- package/src/pm-nodes/Doc.ts +5 -4
- package/src/schema/README.md +1 -1
- package/src/schema/blocks/createSpec.ts +14 -14
- package/src/schema/blocks/internal.ts +17 -17
- package/src/schema/blocks/types.ts +25 -25
- package/src/schema/inlineContent/createSpec.ts +16 -20
- package/src/schema/inlineContent/internal.ts +9 -9
- package/src/schema/inlineContent/types.ts +26 -26
- package/src/schema/propTypes.ts +8 -8
- package/src/schema/styles/createSpec.ts +2 -2
- package/src/schema/styles/internal.ts +7 -7
- package/src/schema/styles/types.ts +2 -2
- package/src/util/EventEmitter.ts +4 -4
- package/src/util/README.md +1 -1
- package/src/util/combineByGroup.ts +1 -1
- package/src/util/table.ts +33 -30
- package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.d.ts +1 -1
- package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.d.ts +4 -0
- package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.d.ts +1 -0
- package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.d.ts +3 -1
- package/types/src/api/blockManipulation/selections/selection.d.ts +10 -0
- package/types/src/api/blockManipulation/selections/textCursorPosition.d.ts +5 -0
- package/types/src/api/blockManipulation/transactions.test.d.ts +0 -0
- package/types/src/api/clipboard/clipboardExternal.test.d.ts +1 -0
- package/types/src/api/clipboard/clipboardInternal.test.d.ts +1 -0
- package/types/src/api/clipboard/testUtil.d.ts +541 -0
- package/types/src/api/exporters/html/htmlConversion.test.d.ts +1 -0
- package/types/src/api/exporters/markdown/markdownExporter.test.d.ts +1 -0
- package/types/src/api/nodeConversions/nodeConversions.test.d.ts +1 -0
- package/types/src/api/nodeConversions/nodeToBlock.d.ts +39 -2
- package/types/src/api/parsers/html/parseHTML.test.d.ts +1 -0
- package/types/src/api/parsers/markdown/parseMarkdown.test.d.ts +1 -0
- package/types/src/api/pmUtil.d.ts +3 -3
- package/types/src/api/testUtil/cases/customBlocks.d.ts +670 -0
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +558 -0
- package/types/src/api/testUtil/cases/customStyles.d.ts +552 -0
- package/types/src/api/testUtil/cases/defaultSchema.d.ts +4 -0
- package/types/src/api/testUtil/index.d.ts +14 -0
- package/types/src/api/testUtil/partialBlockTestUtil.d.ts +9 -0
- package/types/src/api/testUtil/paste.d.ts +2 -0
- package/types/src/blocks/CodeBlockContent/defaultSupportedLanguages.d.ts +6 -0
- package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +9 -1
- package/types/src/editor/BlockNoteEditor.d.ts +58 -10
- package/types/src/editor/BlockNoteExtension.d.ts +9 -0
- package/types/src/editor/BlockNoteExtensions.d.ts +2 -2
- package/types/src/editor/BlockNoteTipTapEditor.d.ts +2 -2
- package/types/src/extensions/Collaboration/CursorPlugin.d.ts +3 -3
- package/types/src/extensions/Collaboration/ForkYDocPlugin.d.ts +41 -0
- package/types/src/extensions/Collaboration/ForkYDocPlugin.test.d.ts +1 -0
- package/types/src/extensions/Collaboration/SyncPlugin.d.ts +3 -3
- package/types/src/extensions/Collaboration/UndoPlugin.d.ts +3 -3
- package/types/src/extensions/Collaboration/createCollaborationExtensions.d.ts +17 -0
- package/types/src/extensions/Comments/CommentsPlugin.d.ts +2 -4
- package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +3 -4
- package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +5 -5
- package/types/src/extensions/LinkToolbar/LinkToolbarPlugin.d.ts +3 -4
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.d.ts +2 -3
- package/types/src/extensions/Placeholder/PlaceholderPlugin.d.ts +2 -3
- package/types/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.d.ts +2 -3
- package/types/src/extensions/ShowSelection/ShowSelectionPlugin.d.ts +2 -3
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +3 -4
- package/types/src/extensions/SuggestionMenu/SuggestionPlugin.d.ts +2 -4
- package/types/src/extensions/Suggestions/SuggestionMarks.d.ts +4 -0
- package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +5 -6
- package/types/src/i18n/locales/en.d.ts +0 -1
- package/types/src/i18n/locales/sk.d.ts +0 -1
- package/types/src/index.d.ts +15 -8
- package/dist/en-B7ycW7c8.js.map +0 -1
- package/dist/en-D4taoCs4.cjs.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/api/blockManipulation/selections/__snapshots__/selection.test.ts.snap +0 -844
- package/src/api/blockManipulation/selections/selection.test.ts +0 -72
- package/src/api/blockManipulation/selections/textCursorPosition/__snapshots__/textCursorPosition.test.ts.snap +0 -316
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts +0 -74
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { setupTestEnv } from "../setupTestEnv.js";
|
|
4
|
-
import { getSelection, setSelection } from "./selection.js";
|
|
5
|
-
|
|
6
|
-
const getEditor = setupTestEnv();
|
|
7
|
-
|
|
8
|
-
describe("Test getSelection & setSelection", () => {
|
|
9
|
-
it("Basic", () => {
|
|
10
|
-
getEditor().transact((tr) => {
|
|
11
|
-
setSelection(tr, "paragraph-0", "paragraph-1");
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
expect(getEditor().transact((tr) => getSelection(tr))).toMatchSnapshot();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("Starts in block with children", () => {
|
|
18
|
-
getEditor().transact((tr) => {
|
|
19
|
-
setSelection(tr, "paragraph-with-children", "paragraph-2");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
expect(getEditor().transact((tr) => getSelection(tr))).toMatchSnapshot();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("Starts in nested block", () => {
|
|
26
|
-
getEditor().transact((tr) => {
|
|
27
|
-
setSelection(tr, "nested-paragraph-0", "paragraph-2");
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
expect(getEditor().transact((tr) => getSelection(tr))).toMatchSnapshot();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("Ends in block with children", () => {
|
|
34
|
-
getEditor().transact((tr) => {
|
|
35
|
-
setSelection(tr, "paragraph-1", "paragraph-with-children");
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
expect(getEditor().transact((tr) => getSelection(tr))).toMatchSnapshot();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("Ends in nested block", () => {
|
|
42
|
-
getEditor().transact((tr) => {
|
|
43
|
-
setSelection(tr, "paragraph-1", "nested-paragraph-0");
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
expect(getEditor().transact((tr) => getSelection(tr))).toMatchSnapshot();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("Contains block with children", () => {
|
|
50
|
-
getEditor().transact((tr) => {
|
|
51
|
-
setSelection(tr, "paragraph-1", "paragraph-2");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
expect(getEditor().transact((tr) => getSelection(tr))).toMatchSnapshot();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("Starts in table", () => {
|
|
58
|
-
getEditor().transact((tr) => {
|
|
59
|
-
setSelection(tr, "table-0", "paragraph-7");
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
expect(getEditor().transact((tr) => getSelection(tr))).toMatchSnapshot();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("Ends in table", () => {
|
|
66
|
-
getEditor().transact((tr) => {
|
|
67
|
-
setSelection(tr, "paragraph-6", "table-0");
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
expect(getEditor().transact((tr) => getSelection(tr))).toMatchSnapshot();
|
|
71
|
-
});
|
|
72
|
-
});
|
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`Test getTextCursorPosition & setTextCursorPosition > Basic 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"block": {
|
|
6
|
-
"children": [],
|
|
7
|
-
"content": [
|
|
8
|
-
{
|
|
9
|
-
"styles": {},
|
|
10
|
-
"text": "Paragraph 1",
|
|
11
|
-
"type": "text",
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
"id": "paragraph-1",
|
|
15
|
-
"props": {
|
|
16
|
-
"backgroundColor": "default",
|
|
17
|
-
"textAlignment": "left",
|
|
18
|
-
"textColor": "default",
|
|
19
|
-
},
|
|
20
|
-
"type": "paragraph",
|
|
21
|
-
},
|
|
22
|
-
"nextBlock": {
|
|
23
|
-
"children": [
|
|
24
|
-
{
|
|
25
|
-
"children": [
|
|
26
|
-
{
|
|
27
|
-
"children": [],
|
|
28
|
-
"content": [
|
|
29
|
-
{
|
|
30
|
-
"styles": {},
|
|
31
|
-
"text": "Double Nested Paragraph 0",
|
|
32
|
-
"type": "text",
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
"id": "double-nested-paragraph-0",
|
|
36
|
-
"props": {
|
|
37
|
-
"backgroundColor": "default",
|
|
38
|
-
"textAlignment": "left",
|
|
39
|
-
"textColor": "default",
|
|
40
|
-
},
|
|
41
|
-
"type": "paragraph",
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
"content": [
|
|
45
|
-
{
|
|
46
|
-
"styles": {},
|
|
47
|
-
"text": "Nested Paragraph 0",
|
|
48
|
-
"type": "text",
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
"id": "nested-paragraph-0",
|
|
52
|
-
"props": {
|
|
53
|
-
"backgroundColor": "default",
|
|
54
|
-
"textAlignment": "left",
|
|
55
|
-
"textColor": "default",
|
|
56
|
-
},
|
|
57
|
-
"type": "paragraph",
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
"content": [
|
|
61
|
-
{
|
|
62
|
-
"styles": {},
|
|
63
|
-
"text": "Paragraph with children",
|
|
64
|
-
"type": "text",
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
"id": "paragraph-with-children",
|
|
68
|
-
"props": {
|
|
69
|
-
"backgroundColor": "default",
|
|
70
|
-
"textAlignment": "left",
|
|
71
|
-
"textColor": "default",
|
|
72
|
-
},
|
|
73
|
-
"type": "paragraph",
|
|
74
|
-
},
|
|
75
|
-
"parentBlock": undefined,
|
|
76
|
-
"prevBlock": {
|
|
77
|
-
"children": [],
|
|
78
|
-
"content": [
|
|
79
|
-
{
|
|
80
|
-
"styles": {},
|
|
81
|
-
"text": "Paragraph 0",
|
|
82
|
-
"type": "text",
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
"id": "paragraph-0",
|
|
86
|
-
"props": {
|
|
87
|
-
"backgroundColor": "default",
|
|
88
|
-
"textAlignment": "left",
|
|
89
|
-
"textColor": "default",
|
|
90
|
-
},
|
|
91
|
-
"type": "paragraph",
|
|
92
|
-
},
|
|
93
|
-
}
|
|
94
|
-
`;
|
|
95
|
-
|
|
96
|
-
exports[`Test getTextCursorPosition & setTextCursorPosition > First block 1`] = `
|
|
97
|
-
{
|
|
98
|
-
"block": {
|
|
99
|
-
"children": [],
|
|
100
|
-
"content": [
|
|
101
|
-
{
|
|
102
|
-
"styles": {},
|
|
103
|
-
"text": "Paragraph 0",
|
|
104
|
-
"type": "text",
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
"id": "paragraph-0",
|
|
108
|
-
"props": {
|
|
109
|
-
"backgroundColor": "default",
|
|
110
|
-
"textAlignment": "left",
|
|
111
|
-
"textColor": "default",
|
|
112
|
-
},
|
|
113
|
-
"type": "paragraph",
|
|
114
|
-
},
|
|
115
|
-
"nextBlock": {
|
|
116
|
-
"children": [],
|
|
117
|
-
"content": [
|
|
118
|
-
{
|
|
119
|
-
"styles": {},
|
|
120
|
-
"text": "Paragraph 1",
|
|
121
|
-
"type": "text",
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
"id": "paragraph-1",
|
|
125
|
-
"props": {
|
|
126
|
-
"backgroundColor": "default",
|
|
127
|
-
"textAlignment": "left",
|
|
128
|
-
"textColor": "default",
|
|
129
|
-
},
|
|
130
|
-
"type": "paragraph",
|
|
131
|
-
},
|
|
132
|
-
"parentBlock": undefined,
|
|
133
|
-
"prevBlock": undefined,
|
|
134
|
-
}
|
|
135
|
-
`;
|
|
136
|
-
|
|
137
|
-
exports[`Test getTextCursorPosition & setTextCursorPosition > Last block 1`] = `
|
|
138
|
-
{
|
|
139
|
-
"block": {
|
|
140
|
-
"children": [],
|
|
141
|
-
"content": [],
|
|
142
|
-
"id": "trailing-paragraph",
|
|
143
|
-
"props": {
|
|
144
|
-
"backgroundColor": "default",
|
|
145
|
-
"textAlignment": "left",
|
|
146
|
-
"textColor": "default",
|
|
147
|
-
},
|
|
148
|
-
"type": "paragraph",
|
|
149
|
-
},
|
|
150
|
-
"nextBlock": undefined,
|
|
151
|
-
"parentBlock": undefined,
|
|
152
|
-
"prevBlock": {
|
|
153
|
-
"children": [
|
|
154
|
-
{
|
|
155
|
-
"children": [
|
|
156
|
-
{
|
|
157
|
-
"children": [],
|
|
158
|
-
"content": [
|
|
159
|
-
{
|
|
160
|
-
"styles": {},
|
|
161
|
-
"text": "Double Nested Paragraph 1",
|
|
162
|
-
"type": "text",
|
|
163
|
-
},
|
|
164
|
-
],
|
|
165
|
-
"id": "double-nested-paragraph-1",
|
|
166
|
-
"props": {
|
|
167
|
-
"backgroundColor": "default",
|
|
168
|
-
"textAlignment": "left",
|
|
169
|
-
"textColor": "default",
|
|
170
|
-
},
|
|
171
|
-
"type": "paragraph",
|
|
172
|
-
},
|
|
173
|
-
],
|
|
174
|
-
"content": [
|
|
175
|
-
{
|
|
176
|
-
"styles": {},
|
|
177
|
-
"text": "Nested Paragraph 1",
|
|
178
|
-
"type": "text",
|
|
179
|
-
},
|
|
180
|
-
],
|
|
181
|
-
"id": "nested-paragraph-1",
|
|
182
|
-
"props": {
|
|
183
|
-
"backgroundColor": "default",
|
|
184
|
-
"textAlignment": "left",
|
|
185
|
-
"textColor": "default",
|
|
186
|
-
},
|
|
187
|
-
"type": "paragraph",
|
|
188
|
-
},
|
|
189
|
-
],
|
|
190
|
-
"content": [
|
|
191
|
-
{
|
|
192
|
-
"styles": {
|
|
193
|
-
"bold": true,
|
|
194
|
-
},
|
|
195
|
-
"text": "Heading",
|
|
196
|
-
"type": "text",
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
"styles": {},
|
|
200
|
-
"text": " with styled ",
|
|
201
|
-
"type": "text",
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
"styles": {
|
|
205
|
-
"italic": true,
|
|
206
|
-
},
|
|
207
|
-
"text": "content",
|
|
208
|
-
"type": "text",
|
|
209
|
-
},
|
|
210
|
-
],
|
|
211
|
-
"id": "heading-with-everything",
|
|
212
|
-
"props": {
|
|
213
|
-
"backgroundColor": "red",
|
|
214
|
-
"level": 2,
|
|
215
|
-
"textAlignment": "center",
|
|
216
|
-
"textColor": "red",
|
|
217
|
-
},
|
|
218
|
-
"type": "heading",
|
|
219
|
-
},
|
|
220
|
-
}
|
|
221
|
-
`;
|
|
222
|
-
|
|
223
|
-
exports[`Test getTextCursorPosition & setTextCursorPosition > Nested block 1`] = `
|
|
224
|
-
{
|
|
225
|
-
"block": {
|
|
226
|
-
"children": [
|
|
227
|
-
{
|
|
228
|
-
"children": [],
|
|
229
|
-
"content": [
|
|
230
|
-
{
|
|
231
|
-
"styles": {},
|
|
232
|
-
"text": "Double Nested Paragraph 0",
|
|
233
|
-
"type": "text",
|
|
234
|
-
},
|
|
235
|
-
],
|
|
236
|
-
"id": "double-nested-paragraph-0",
|
|
237
|
-
"props": {
|
|
238
|
-
"backgroundColor": "default",
|
|
239
|
-
"textAlignment": "left",
|
|
240
|
-
"textColor": "default",
|
|
241
|
-
},
|
|
242
|
-
"type": "paragraph",
|
|
243
|
-
},
|
|
244
|
-
],
|
|
245
|
-
"content": [
|
|
246
|
-
{
|
|
247
|
-
"styles": {},
|
|
248
|
-
"text": "Nested Paragraph 0",
|
|
249
|
-
"type": "text",
|
|
250
|
-
},
|
|
251
|
-
],
|
|
252
|
-
"id": "nested-paragraph-0",
|
|
253
|
-
"props": {
|
|
254
|
-
"backgroundColor": "default",
|
|
255
|
-
"textAlignment": "left",
|
|
256
|
-
"textColor": "default",
|
|
257
|
-
},
|
|
258
|
-
"type": "paragraph",
|
|
259
|
-
},
|
|
260
|
-
"nextBlock": undefined,
|
|
261
|
-
"parentBlock": {
|
|
262
|
-
"children": [
|
|
263
|
-
{
|
|
264
|
-
"children": [
|
|
265
|
-
{
|
|
266
|
-
"children": [],
|
|
267
|
-
"content": [
|
|
268
|
-
{
|
|
269
|
-
"styles": {},
|
|
270
|
-
"text": "Double Nested Paragraph 0",
|
|
271
|
-
"type": "text",
|
|
272
|
-
},
|
|
273
|
-
],
|
|
274
|
-
"id": "double-nested-paragraph-0",
|
|
275
|
-
"props": {
|
|
276
|
-
"backgroundColor": "default",
|
|
277
|
-
"textAlignment": "left",
|
|
278
|
-
"textColor": "default",
|
|
279
|
-
},
|
|
280
|
-
"type": "paragraph",
|
|
281
|
-
},
|
|
282
|
-
],
|
|
283
|
-
"content": [
|
|
284
|
-
{
|
|
285
|
-
"styles": {},
|
|
286
|
-
"text": "Nested Paragraph 0",
|
|
287
|
-
"type": "text",
|
|
288
|
-
},
|
|
289
|
-
],
|
|
290
|
-
"id": "nested-paragraph-0",
|
|
291
|
-
"props": {
|
|
292
|
-
"backgroundColor": "default",
|
|
293
|
-
"textAlignment": "left",
|
|
294
|
-
"textColor": "default",
|
|
295
|
-
},
|
|
296
|
-
"type": "paragraph",
|
|
297
|
-
},
|
|
298
|
-
],
|
|
299
|
-
"content": [
|
|
300
|
-
{
|
|
301
|
-
"styles": {},
|
|
302
|
-
"text": "Paragraph with children",
|
|
303
|
-
"type": "text",
|
|
304
|
-
},
|
|
305
|
-
],
|
|
306
|
-
"id": "paragraph-with-children",
|
|
307
|
-
"props": {
|
|
308
|
-
"backgroundColor": "default",
|
|
309
|
-
"textAlignment": "left",
|
|
310
|
-
"textColor": "default",
|
|
311
|
-
},
|
|
312
|
-
"type": "paragraph",
|
|
313
|
-
},
|
|
314
|
-
"prevBlock": undefined,
|
|
315
|
-
}
|
|
316
|
-
`;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { setupTestEnv } from "../../setupTestEnv.js";
|
|
4
|
-
import {
|
|
5
|
-
getTextCursorPosition,
|
|
6
|
-
setTextCursorPosition,
|
|
7
|
-
} from "./textCursorPosition.js";
|
|
8
|
-
|
|
9
|
-
const getEditor = setupTestEnv();
|
|
10
|
-
|
|
11
|
-
describe("Test getTextCursorPosition & setTextCursorPosition", () => {
|
|
12
|
-
it("Basic", () => {
|
|
13
|
-
getEditor().transact((tr) => {
|
|
14
|
-
setTextCursorPosition(tr, "paragraph-1");
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
expect(
|
|
18
|
-
getEditor().transact((tr) => getTextCursorPosition(tr))
|
|
19
|
-
).toMatchSnapshot();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("First block", () => {
|
|
23
|
-
getEditor().transact((tr) => {
|
|
24
|
-
setTextCursorPosition(tr, "paragraph-0");
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
expect(
|
|
28
|
-
getEditor().transact((tr) => getTextCursorPosition(tr))
|
|
29
|
-
).toMatchSnapshot();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("Last block", () => {
|
|
33
|
-
getEditor().transact((tr) => {
|
|
34
|
-
setTextCursorPosition(tr, "trailing-paragraph");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
expect(
|
|
38
|
-
getEditor().transact((tr) => getTextCursorPosition(tr))
|
|
39
|
-
).toMatchSnapshot();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("Nested block", () => {
|
|
43
|
-
getEditor().transact((tr) => {
|
|
44
|
-
setTextCursorPosition(tr, "nested-paragraph-0");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
expect(
|
|
48
|
-
getEditor().transact((tr) => getTextCursorPosition(tr))
|
|
49
|
-
).toMatchSnapshot();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("Set to start", () => {
|
|
53
|
-
getEditor().transact((tr) => {
|
|
54
|
-
setTextCursorPosition(tr, "paragraph-1", "start");
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
expect(
|
|
58
|
-
getEditor().transact((tr) => tr.selection.$from.parentOffset) === 0
|
|
59
|
-
).toBeTruthy();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("Set to end", () => {
|
|
63
|
-
getEditor().transact((tr) => {
|
|
64
|
-
setTextCursorPosition(tr, "paragraph-1", "end");
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
expect(
|
|
68
|
-
getEditor().transact((tr) => tr.selection.$from.parentOffset) ===
|
|
69
|
-
getEditor().transact(
|
|
70
|
-
(tr) => tr.selection.$from.node().firstChild!.nodeSize
|
|
71
|
-
)
|
|
72
|
-
).toBeTruthy();
|
|
73
|
-
});
|
|
74
|
-
});
|