@blocknote/core 0.3.0 → 0.4.2
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 +12698 -1341
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +50 -1
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +16 -5
- package/src/BlockNoteEditor.test.ts +12 -0
- package/src/BlockNoteEditor.ts +39 -15
- package/src/BlockNoteExtensions.ts +36 -32
- package/src/api/Editor.ts +226 -0
- package/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap +616 -0
- package/src/api/blockManipulation/blockManipulation.test.ts +172 -0
- package/src/api/blockManipulation/blockManipulation.ts +125 -0
- package/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap +346 -0
- package/src/api/formatConversions/formatConversions.test.ts +766 -0
- package/src/api/formatConversions/formatConversions.ts +86 -0
- package/src/api/formatConversions/removeUnderlinesRehypePlugin.ts +39 -0
- package/src/api/formatConversions/simplifyBlocksRehypePlugin.ts +125 -0
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +268 -0
- package/src/api/nodeConversions/nodeConversions.test.ts +244 -0
- package/src/api/nodeConversions/nodeConversions.ts +279 -0
- package/src/api/nodeConversions/testUtil.ts +61 -0
- package/src/api/util/nodeUtil.ts +38 -0
- package/src/editor.module.css +8 -1
- package/src/extensions/Blocks/PreviousBlockTypePlugin.ts +7 -1
- package/src/extensions/Blocks/api/blockTypes.ts +90 -0
- package/src/extensions/Blocks/api/cursorPositionTypes.ts +5 -0
- package/src/extensions/Blocks/api/inlineContentTypes.ts +35 -0
- package/src/extensions/Blocks/helpers/getBlockInfoFromPos.ts +4 -4
- package/src/extensions/Blocks/nodes/Block.module.css +39 -36
- package/src/extensions/Blocks/nodes/BlockContainer.ts +74 -23
- package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +23 -5
- package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +28 -6
- package/src/extensions/DraggableBlocks/DraggableBlocksPlugin.ts +149 -87
- package/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.ts +2 -2
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +3 -3
- package/src/extensions/SlashMenu/SlashMenuExtension.ts +7 -12
- package/src/extensions/SlashMenu/SlashMenuItem.ts +4 -1
- package/src/extensions/SlashMenu/{defaultCommands.tsx → defaultSlashCommands.tsx} +34 -17
- package/src/extensions/SlashMenu/index.ts +7 -4
- package/src/extensions/UniqueID/UniqueID.ts +1 -1
- package/src/index.ts +4 -2
- package/src/shared/utils.ts +6 -0
- package/types/src/BlockNoteEditor.d.ts +13 -4
- package/types/src/BlockNoteEditor.test.d.ts +1 -0
- package/types/src/BlockNoteExtensions.d.ts +7 -3
- package/types/src/api/Editor.d.ts +93 -0
- package/types/src/api/blockManipulation/blockManipulation.d.ts +6 -0
- package/types/src/api/blockManipulation/blockManipulation.test.d.ts +1 -0
- package/types/src/api/formatConversions/formatConversions.d.ts +6 -0
- package/types/src/api/formatConversions/formatConversions.test.d.ts +1 -0
- package/types/src/api/formatConversions/removeUnderlinesRehypePlugin.d.ts +6 -0
- package/types/src/api/formatConversions/simplifyBlocksRehypePlugin.d.ts +16 -0
- package/types/src/api/nodeConversions/nodeConversions.d.ts +15 -0
- package/types/src/api/nodeConversions/nodeConversions.test.d.ts +1 -0
- package/types/src/api/nodeConversions/testUtil.d.ts +2 -0
- package/types/src/api/util/nodeUtil.d.ts +8 -0
- package/types/src/extensions/Blocks/api/blockTypes.d.ts +37 -0
- package/types/src/extensions/Blocks/api/cursorPositionTypes.d.ts +4 -0
- package/types/src/extensions/Blocks/api/inlineContentTypes.d.ts +29 -0
- package/types/src/extensions/Blocks/nodes/BlockContainer.d.ts +3 -3
- package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +15 -0
- package/types/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.d.ts +2 -2
- package/types/src/extensions/SlashMenu/SlashMenuExtension.d.ts +1 -3
- package/types/src/extensions/SlashMenu/SlashMenuItem.d.ts +4 -1
- package/types/src/extensions/SlashMenu/index.d.ts +3 -3
- package/types/src/index.d.ts +4 -2
- package/types/src/shared/utils.d.ts +3 -0
- package/src/extensions/Blocks/apiTypes.ts +0 -48
- package/types/src/EditorElement.d.ts +0 -7
- package/types/src/api/Document.d.ts +0 -5
- package/types/src/extensions/Blocks/BlockAttributes.d.ts +0 -2
- package/types/src/extensions/Blocks/MultipleNodeSelection.d.ts +0 -24
- package/types/src/extensions/Blocks/apiTypes.d.ts +0 -16
- package/types/src/extensions/Blocks/nodes/Block.d.ts +0 -24
- package/types/src/extensions/Blocks/nodes/BlockContent/BlockContentTypes.d.ts +0 -4
- package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContentTypes.d.ts +0 -4
- package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContentTypes.d.ts +0 -2
- package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContentTypes.d.ts +0 -2
- package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContentTypes.d.ts +0 -2
- package/types/src/extensions/Blocks/nodes/BlockTypes/HeadingBlock/HeadingContent.d.ts +0 -8
- package/types/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/ListItemContent.d.ts +0 -8
- package/types/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/OrderedListItemIndexPlugin.d.ts +0 -2
- package/types/src/extensions/Blocks/nodes/BlockTypes/TextBlock/TextContent.d.ts +0 -6
- package/types/src/extensions/BubbleMenu/BubbleMenuExtension.d.ts +0 -8
- package/types/src/extensions/BubbleMenu/BubbleMenuFactoryTypes.d.ts +0 -27
- package/types/src/extensions/BubbleMenu/BubbleMenuPlugin.d.ts +0 -44
- package/types/src/extensions/DraggableBlocks/BlockMenuFactoryTypes.d.ts +0 -12
- package/types/src/extensions/DraggableBlocks/DragMenuFactoryTypes.d.ts +0 -18
- package/types/src/extensions/Hyperlinks/HyperlinkMark.d.ts +0 -8
- package/types/src/extensions/Hyperlinks/HyperlinkMenuFactoryTypes.d.ts +0 -11
- package/types/src/extensions/Hyperlinks/HyperlinkMenuPlugin.d.ts +0 -11
- package/types/src/extensions/Paragraph/FixedParagraph.d.ts +0 -1
- package/types/src/extensions/SlashMenu/defaultCommands.d.ts +0 -8
- package/types/src/utils.d.ts +0 -2
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
import { Block, BlockNoteEditor, PartialBlock } from "../..";
|
|
3
|
+
|
|
4
|
+
let editor: BlockNoteEditor;
|
|
5
|
+
|
|
6
|
+
function waitForEditor() {
|
|
7
|
+
// wait for create event on editor,
|
|
8
|
+
// this is necessary because otherwise UniqueId.create hasn't been called yet, and
|
|
9
|
+
// blocks would have "null" as their id
|
|
10
|
+
return new Promise<void>((resolve) => {
|
|
11
|
+
editor._tiptapEditor.on("create", () => {
|
|
12
|
+
resolve();
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let singleBlock: PartialBlock;
|
|
18
|
+
|
|
19
|
+
let multipleBlocks: PartialBlock[];
|
|
20
|
+
|
|
21
|
+
let insert: (placement: "before" | "nested" | "after") => Block[];
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
(window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS = {};
|
|
25
|
+
|
|
26
|
+
editor = new BlockNoteEditor();
|
|
27
|
+
|
|
28
|
+
singleBlock = {
|
|
29
|
+
type: "paragraph",
|
|
30
|
+
content: "Paragraph",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
multipleBlocks = [
|
|
34
|
+
{
|
|
35
|
+
type: "heading",
|
|
36
|
+
props: {
|
|
37
|
+
level: "1",
|
|
38
|
+
},
|
|
39
|
+
content: "Heading 1",
|
|
40
|
+
children: [
|
|
41
|
+
{
|
|
42
|
+
type: "heading",
|
|
43
|
+
props: {
|
|
44
|
+
level: "1",
|
|
45
|
+
},
|
|
46
|
+
content: "Nested Heading 1",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: "heading",
|
|
52
|
+
props: {
|
|
53
|
+
level: "2",
|
|
54
|
+
},
|
|
55
|
+
content: "Heading 2",
|
|
56
|
+
children: [
|
|
57
|
+
{
|
|
58
|
+
type: "heading",
|
|
59
|
+
props: {
|
|
60
|
+
level: "2",
|
|
61
|
+
},
|
|
62
|
+
content: "Nested Heading 2",
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
insert = (placement) => {
|
|
69
|
+
const existingBlock = editor.topLevelBlocks[0];
|
|
70
|
+
editor.insertBlocks(multipleBlocks, existingBlock, placement);
|
|
71
|
+
|
|
72
|
+
return editor.topLevelBlocks;
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
afterEach(() => {
|
|
77
|
+
editor._tiptapEditor.destroy();
|
|
78
|
+
editor = undefined as any;
|
|
79
|
+
|
|
80
|
+
delete (window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe("Inserting Blocks with Different Placements", () => {
|
|
84
|
+
it("Insert before existing block", async () => {
|
|
85
|
+
await waitForEditor();
|
|
86
|
+
|
|
87
|
+
const output = insert("before");
|
|
88
|
+
|
|
89
|
+
expect(output).toMatchSnapshot();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("Insert nested inside existing block", async () => {
|
|
93
|
+
await waitForEditor();
|
|
94
|
+
|
|
95
|
+
const output = insert("nested");
|
|
96
|
+
|
|
97
|
+
expect(output).toMatchSnapshot();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("Insert after existing block", async () => {
|
|
101
|
+
await waitForEditor();
|
|
102
|
+
|
|
103
|
+
const output = insert("after");
|
|
104
|
+
|
|
105
|
+
expect(output).toMatchSnapshot();
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe("Insert, Update, & Delete Blocks", () => {
|
|
110
|
+
it("Insert, update, & delete single block", async () => {
|
|
111
|
+
await waitForEditor();
|
|
112
|
+
|
|
113
|
+
const existingBlock = editor.topLevelBlocks[0];
|
|
114
|
+
editor.insertBlocks([singleBlock], existingBlock);
|
|
115
|
+
|
|
116
|
+
expect(editor.topLevelBlocks).toMatchSnapshot();
|
|
117
|
+
|
|
118
|
+
const newBlock = editor.topLevelBlocks[0];
|
|
119
|
+
editor.updateBlock(newBlock, {
|
|
120
|
+
type: "heading",
|
|
121
|
+
props: {
|
|
122
|
+
textAlignment: "right",
|
|
123
|
+
level: "3",
|
|
124
|
+
},
|
|
125
|
+
content: [
|
|
126
|
+
{
|
|
127
|
+
type: "text",
|
|
128
|
+
text: "Heading ",
|
|
129
|
+
styles: {
|
|
130
|
+
textColor: "red",
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: "text",
|
|
135
|
+
text: "3",
|
|
136
|
+
styles: {
|
|
137
|
+
backgroundColor: "red",
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
children: [singleBlock],
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
expect(editor.topLevelBlocks).toMatchSnapshot();
|
|
145
|
+
|
|
146
|
+
const updatedBlock = editor.topLevelBlocks[0];
|
|
147
|
+
editor.removeBlocks([updatedBlock]);
|
|
148
|
+
|
|
149
|
+
expect(editor.topLevelBlocks).toMatchSnapshot();
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("Insert, update, & delete multiple blocks", async () => {
|
|
153
|
+
await waitForEditor();
|
|
154
|
+
|
|
155
|
+
const existingBlock = editor.topLevelBlocks[0];
|
|
156
|
+
editor.insertBlocks(multipleBlocks, existingBlock);
|
|
157
|
+
|
|
158
|
+
expect(editor.topLevelBlocks).toMatchSnapshot();
|
|
159
|
+
|
|
160
|
+
const newBlock = editor.topLevelBlocks[0];
|
|
161
|
+
editor.updateBlock(newBlock, {
|
|
162
|
+
type: "paragraph",
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
expect(editor.topLevelBlocks).toMatchSnapshot();
|
|
166
|
+
|
|
167
|
+
const updatedBlocks = editor.topLevelBlocks.slice(0, 2);
|
|
168
|
+
editor.removeBlocks([updatedBlocks[0].children[0], updatedBlocks[1]]);
|
|
169
|
+
|
|
170
|
+
expect(editor.topLevelBlocks).toMatchSnapshot();
|
|
171
|
+
});
|
|
172
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Editor } from "@tiptap/core";
|
|
2
|
+
import { Node } from "prosemirror-model";
|
|
3
|
+
import {
|
|
4
|
+
BlockIdentifier,
|
|
5
|
+
PartialBlock,
|
|
6
|
+
} from "../../extensions/Blocks/api/blockTypes";
|
|
7
|
+
import { blockToNode } from "../nodeConversions/nodeConversions";
|
|
8
|
+
import { getNodeById } from "../util/nodeUtil";
|
|
9
|
+
|
|
10
|
+
export function insertBlocks(
|
|
11
|
+
blocksToInsert: PartialBlock[],
|
|
12
|
+
referenceBlock: BlockIdentifier,
|
|
13
|
+
placement: "before" | "after" | "nested" = "before",
|
|
14
|
+
editor: Editor
|
|
15
|
+
): void {
|
|
16
|
+
const id =
|
|
17
|
+
typeof referenceBlock === "string" ? referenceBlock : referenceBlock.id;
|
|
18
|
+
|
|
19
|
+
const nodesToInsert: Node[] = [];
|
|
20
|
+
for (const blockSpec of blocksToInsert) {
|
|
21
|
+
nodesToInsert.push(blockToNode(blockSpec, editor.schema));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let insertionPos = -1;
|
|
25
|
+
|
|
26
|
+
const { node, posBeforeNode } = getNodeById(id, editor.state.doc);
|
|
27
|
+
|
|
28
|
+
if (placement === "before") {
|
|
29
|
+
insertionPos = posBeforeNode;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (placement === "after") {
|
|
33
|
+
insertionPos = posBeforeNode + node.nodeSize;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (placement === "nested") {
|
|
37
|
+
// Case if block doesn't already have children.
|
|
38
|
+
if (node.childCount < 2) {
|
|
39
|
+
insertionPos = posBeforeNode + node.firstChild!.nodeSize + 1;
|
|
40
|
+
|
|
41
|
+
const blockGroupNode = editor.state.schema.nodes["blockGroup"].create(
|
|
42
|
+
{},
|
|
43
|
+
nodesToInsert
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
editor.view.dispatch(
|
|
47
|
+
editor.state.tr.insert(insertionPos, blockGroupNode)
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
insertionPos = posBeforeNode + node.firstChild!.nodeSize + 2;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
editor.view.dispatch(editor.state.tr.insert(insertionPos, nodesToInsert));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function updateBlock(
|
|
60
|
+
blockToUpdate: BlockIdentifier,
|
|
61
|
+
update: PartialBlock,
|
|
62
|
+
editor: Editor
|
|
63
|
+
) {
|
|
64
|
+
const id =
|
|
65
|
+
typeof blockToUpdate === "string" ? blockToUpdate : blockToUpdate.id;
|
|
66
|
+
const { posBeforeNode } = getNodeById(id, editor.state.doc);
|
|
67
|
+
|
|
68
|
+
editor.commands.BNUpdateBlock(posBeforeNode + 1, update);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function removeBlocks(
|
|
72
|
+
blocksToRemove: BlockIdentifier[],
|
|
73
|
+
editor: Editor
|
|
74
|
+
) {
|
|
75
|
+
const idsOfBlocksToRemove = new Set<string>(
|
|
76
|
+
blocksToRemove.map((block) =>
|
|
77
|
+
typeof block === "string" ? block : block.id
|
|
78
|
+
)
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
let removedSize = 0;
|
|
82
|
+
|
|
83
|
+
editor.state.doc.descendants((node, pos) => {
|
|
84
|
+
// Skips traversing nodes after all target blocks have been removed.
|
|
85
|
+
if (idsOfBlocksToRemove.size === 0) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Keeps traversing nodes if block with target ID has not been found.
|
|
90
|
+
if (
|
|
91
|
+
node.type.name !== "blockContainer" ||
|
|
92
|
+
!idsOfBlocksToRemove.has(node.attrs.id)
|
|
93
|
+
) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
idsOfBlocksToRemove.delete(node.attrs.id);
|
|
98
|
+
const oldDocSize = editor.state.doc.nodeSize;
|
|
99
|
+
|
|
100
|
+
editor.commands.BNDeleteBlock(pos - removedSize + 1);
|
|
101
|
+
|
|
102
|
+
const newDocSize = editor.state.doc.nodeSize;
|
|
103
|
+
removedSize += oldDocSize - newDocSize;
|
|
104
|
+
|
|
105
|
+
return false;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
if (idsOfBlocksToRemove.size > 0) {
|
|
109
|
+
let notFoundIds = [...idsOfBlocksToRemove].join("\n");
|
|
110
|
+
|
|
111
|
+
throw Error(
|
|
112
|
+
"Blocks with the following IDs could not be found in the editor: " +
|
|
113
|
+
notFoundIds
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function replaceBlocks(
|
|
119
|
+
blocksToRemove: BlockIdentifier[],
|
|
120
|
+
blocksToInsert: PartialBlock[],
|
|
121
|
+
editor: Editor
|
|
122
|
+
) {
|
|
123
|
+
insertBlocks(blocksToInsert, blocksToRemove[0], "before", editor);
|
|
124
|
+
removeBlocks(blocksToRemove, editor);
|
|
125
|
+
}
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
// Vitest Snapshot v1
|
|
2
|
+
|
|
3
|
+
exports[`Complex Block/HTML/Markdown Conversions > Convert complex blocks to HTML 1`] = `"<h1>Heading 1</h1><h2>Heading 2</h2><h3>Heading 3</h3><p><span data-text-color=\\"purple\\"><span data-background-color=\\"green\\">Paragraph</span></span></p><p>P<strong>ara</strong><em>grap</em>h</p><p>P<u>ara</u><s>grap</s>h</p><ul><li><p>Bullet List Item</p></li><li><p>Bullet List Item</p><ul><li><p>Bullet List Item</p><ul><li><p>Bullet List Item</p></li></ul><p>Paragraph</p><ol><li><p>Numbered List Item</p></li><li><p>Numbered List Item</p></li><li><p>Numbered List Item</p><ol><li><p>Numbered List Item</p></li></ol></li></ol><ul><li><p>Bullet List Item</p></li></ul></li><li><p>Bullet List Item</p></li></ul></li><li><p>Bullet List Item</p></li></ul>"`;
|
|
4
|
+
|
|
5
|
+
exports[`Complex Block/HTML/Markdown Conversions > Convert complex blocks to Markdown 1`] = `
|
|
6
|
+
"# Heading 1
|
|
7
|
+
|
|
8
|
+
## Heading 2
|
|
9
|
+
|
|
10
|
+
### Heading 3
|
|
11
|
+
|
|
12
|
+
Paragraph
|
|
13
|
+
|
|
14
|
+
P**ara***grap*h
|
|
15
|
+
|
|
16
|
+
Para~~grap~~h
|
|
17
|
+
|
|
18
|
+
* Bullet List Item
|
|
19
|
+
|
|
20
|
+
* Bullet List Item
|
|
21
|
+
|
|
22
|
+
* Bullet List Item
|
|
23
|
+
|
|
24
|
+
* Bullet List Item
|
|
25
|
+
|
|
26
|
+
Paragraph
|
|
27
|
+
|
|
28
|
+
1. Numbered List Item
|
|
29
|
+
|
|
30
|
+
2. Numbered List Item
|
|
31
|
+
|
|
32
|
+
3. Numbered List Item
|
|
33
|
+
|
|
34
|
+
1. Numbered List Item
|
|
35
|
+
|
|
36
|
+
* Bullet List Item
|
|
37
|
+
|
|
38
|
+
* Bullet List Item
|
|
39
|
+
|
|
40
|
+
* Bullet List Item
|
|
41
|
+
"
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
exports[`Nested Block/HTML/Markdown Conversions > Convert nested blocks to HTML 1`] = `"<h1>Heading</h1><p>Paragraph</p><ul><li><p>Bullet List Item</p><ol><li><p>Numbered List Item</p></li></ol></li></ul>"`;
|
|
45
|
+
|
|
46
|
+
exports[`Nested Block/HTML/Markdown Conversions > Convert nested blocks to Markdown 1`] = `
|
|
47
|
+
"# Heading
|
|
48
|
+
|
|
49
|
+
Paragraph
|
|
50
|
+
|
|
51
|
+
* Bullet List Item
|
|
52
|
+
|
|
53
|
+
1. Numbered List Item
|
|
54
|
+
"
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
exports[`Non-Nested Block/HTML/Markdown Conversions > Convert non-nested HTML to blocks 1`] = `
|
|
58
|
+
[
|
|
59
|
+
{
|
|
60
|
+
"children": [],
|
|
61
|
+
"content": [
|
|
62
|
+
{
|
|
63
|
+
"styles": {},
|
|
64
|
+
"text": "Heading",
|
|
65
|
+
"type": "text",
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
"id": 27,
|
|
69
|
+
"props": {
|
|
70
|
+
"backgroundColor": "default",
|
|
71
|
+
"level": "1",
|
|
72
|
+
"textAlignment": "left",
|
|
73
|
+
"textColor": "default",
|
|
74
|
+
},
|
|
75
|
+
"type": "heading",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"children": [],
|
|
79
|
+
"content": [
|
|
80
|
+
{
|
|
81
|
+
"styles": {},
|
|
82
|
+
"text": "Paragraph",
|
|
83
|
+
"type": "text",
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
"id": 28,
|
|
87
|
+
"props": {
|
|
88
|
+
"backgroundColor": "default",
|
|
89
|
+
"textAlignment": "left",
|
|
90
|
+
"textColor": "default",
|
|
91
|
+
},
|
|
92
|
+
"type": "paragraph",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"children": [],
|
|
96
|
+
"content": [
|
|
97
|
+
{
|
|
98
|
+
"styles": {},
|
|
99
|
+
"text": "Bullet List Item",
|
|
100
|
+
"type": "text",
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
"id": 29,
|
|
104
|
+
"props": {
|
|
105
|
+
"backgroundColor": "default",
|
|
106
|
+
"textAlignment": "left",
|
|
107
|
+
"textColor": "default",
|
|
108
|
+
},
|
|
109
|
+
"type": "bulletListItem",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"children": [],
|
|
113
|
+
"content": [
|
|
114
|
+
{
|
|
115
|
+
"styles": {},
|
|
116
|
+
"text": "Numbered List Item",
|
|
117
|
+
"type": "text",
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
"id": 30,
|
|
121
|
+
"props": {
|
|
122
|
+
"backgroundColor": "default",
|
|
123
|
+
"textAlignment": "left",
|
|
124
|
+
"textColor": "default",
|
|
125
|
+
},
|
|
126
|
+
"type": "numberedListItem",
|
|
127
|
+
},
|
|
128
|
+
]
|
|
129
|
+
`;
|
|
130
|
+
|
|
131
|
+
exports[`Non-Nested Block/HTML/Markdown Conversions > Convert non-nested Markdown to blocks 1`] = `
|
|
132
|
+
[
|
|
133
|
+
{
|
|
134
|
+
"children": [],
|
|
135
|
+
"content": [
|
|
136
|
+
{
|
|
137
|
+
"styles": {},
|
|
138
|
+
"text": "Heading",
|
|
139
|
+
"type": "text",
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
"id": 27,
|
|
143
|
+
"props": {
|
|
144
|
+
"backgroundColor": "default",
|
|
145
|
+
"level": "1",
|
|
146
|
+
"textAlignment": "left",
|
|
147
|
+
"textColor": "default",
|
|
148
|
+
},
|
|
149
|
+
"type": "heading",
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"children": [],
|
|
153
|
+
"content": [
|
|
154
|
+
{
|
|
155
|
+
"styles": {},
|
|
156
|
+
"text": "Paragraph",
|
|
157
|
+
"type": "text",
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
"id": 28,
|
|
161
|
+
"props": {
|
|
162
|
+
"backgroundColor": "default",
|
|
163
|
+
"textAlignment": "left",
|
|
164
|
+
"textColor": "default",
|
|
165
|
+
},
|
|
166
|
+
"type": "paragraph",
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"children": [],
|
|
170
|
+
"content": [
|
|
171
|
+
{
|
|
172
|
+
"styles": {},
|
|
173
|
+
"text": "Bullet List Item",
|
|
174
|
+
"type": "text",
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
"id": 29,
|
|
178
|
+
"props": {
|
|
179
|
+
"backgroundColor": "default",
|
|
180
|
+
"textAlignment": "left",
|
|
181
|
+
"textColor": "default",
|
|
182
|
+
},
|
|
183
|
+
"type": "bulletListItem",
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"children": [],
|
|
187
|
+
"content": [
|
|
188
|
+
{
|
|
189
|
+
"styles": {},
|
|
190
|
+
"text": "Numbered List Item",
|
|
191
|
+
"type": "text",
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
"id": 30,
|
|
195
|
+
"props": {
|
|
196
|
+
"backgroundColor": "default",
|
|
197
|
+
"textAlignment": "left",
|
|
198
|
+
"textColor": "default",
|
|
199
|
+
},
|
|
200
|
+
"type": "numberedListItem",
|
|
201
|
+
},
|
|
202
|
+
]
|
|
203
|
+
`;
|
|
204
|
+
|
|
205
|
+
exports[`Non-Nested Block/HTML/Markdown Conversions > Convert non-nested blocks to HTML 1`] = `"<h1>Heading</h1><p>Paragraph</p><ul><li><p>Bullet List Item</p></li></ul><ol><li><p>Numbered List Item</p></li></ol>"`;
|
|
206
|
+
|
|
207
|
+
exports[`Non-Nested Block/HTML/Markdown Conversions > Convert non-nested blocks to Markdown 1`] = `
|
|
208
|
+
"# Heading
|
|
209
|
+
|
|
210
|
+
Paragraph
|
|
211
|
+
|
|
212
|
+
* Bullet List Item
|
|
213
|
+
|
|
214
|
+
1. Numbered List Item
|
|
215
|
+
"
|
|
216
|
+
`;
|
|
217
|
+
|
|
218
|
+
exports[`Styled Block/HTML/Markdown Conversions > Convert styled HTML to blocks 1`] = `
|
|
219
|
+
[
|
|
220
|
+
{
|
|
221
|
+
"children": [],
|
|
222
|
+
"content": [
|
|
223
|
+
{
|
|
224
|
+
"styles": {
|
|
225
|
+
"bold": true,
|
|
226
|
+
},
|
|
227
|
+
"text": "Bold",
|
|
228
|
+
"type": "text",
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"styles": {
|
|
232
|
+
"italic": true,
|
|
233
|
+
},
|
|
234
|
+
"text": "Italic",
|
|
235
|
+
"type": "text",
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"styles": {
|
|
239
|
+
"underline": true,
|
|
240
|
+
},
|
|
241
|
+
"text": "Underline",
|
|
242
|
+
"type": "text",
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
"styles": {
|
|
246
|
+
"strike": true,
|
|
247
|
+
},
|
|
248
|
+
"text": "Strikethrough",
|
|
249
|
+
"type": "text",
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"styles": {
|
|
253
|
+
"textColor": "red",
|
|
254
|
+
},
|
|
255
|
+
"text": "TextColor",
|
|
256
|
+
"type": "text",
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"styles": {
|
|
260
|
+
"backgroundColor": "red",
|
|
261
|
+
},
|
|
262
|
+
"text": "BackgroundColor",
|
|
263
|
+
"type": "text",
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"styles": {
|
|
267
|
+
"bold": true,
|
|
268
|
+
"italic": true,
|
|
269
|
+
},
|
|
270
|
+
"text": "Multiple",
|
|
271
|
+
"type": "text",
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
"id": 27,
|
|
275
|
+
"props": {
|
|
276
|
+
"backgroundColor": "default",
|
|
277
|
+
"textAlignment": "left",
|
|
278
|
+
"textColor": "default",
|
|
279
|
+
},
|
|
280
|
+
"type": "paragraph",
|
|
281
|
+
},
|
|
282
|
+
]
|
|
283
|
+
`;
|
|
284
|
+
|
|
285
|
+
exports[`Styled Block/HTML/Markdown Conversions > Convert styled Markdown to blocks 1`] = `
|
|
286
|
+
[
|
|
287
|
+
{
|
|
288
|
+
"children": [],
|
|
289
|
+
"content": [
|
|
290
|
+
{
|
|
291
|
+
"styles": {
|
|
292
|
+
"bold": true,
|
|
293
|
+
},
|
|
294
|
+
"text": "Bold",
|
|
295
|
+
"type": "text",
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
"styles": {
|
|
299
|
+
"italic": true,
|
|
300
|
+
},
|
|
301
|
+
"text": "Italic",
|
|
302
|
+
"type": "text",
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"styles": {},
|
|
306
|
+
"text": "Underline",
|
|
307
|
+
"type": "text",
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"styles": {
|
|
311
|
+
"strike": true,
|
|
312
|
+
},
|
|
313
|
+
"text": "Strikethrough",
|
|
314
|
+
"type": "text",
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"styles": {},
|
|
318
|
+
"text": "TextColorBackgroundColor",
|
|
319
|
+
"type": "text",
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"styles": {
|
|
323
|
+
"bold": true,
|
|
324
|
+
"italic": true,
|
|
325
|
+
},
|
|
326
|
+
"text": "Multiple",
|
|
327
|
+
"type": "text",
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
"id": 27,
|
|
331
|
+
"props": {
|
|
332
|
+
"backgroundColor": "default",
|
|
333
|
+
"textAlignment": "left",
|
|
334
|
+
"textColor": "default",
|
|
335
|
+
},
|
|
336
|
+
"type": "paragraph",
|
|
337
|
+
},
|
|
338
|
+
]
|
|
339
|
+
`;
|
|
340
|
+
|
|
341
|
+
exports[`Styled Block/HTML/Markdown Conversions > Convert styled blocks to HTML 1`] = `"<p><strong>Bold</strong><em>Italic</em><u>Underline</u><s>Strikethrough</s><span data-text-color=\\"red\\">TextColor</span><span data-background-color=\\"red\\">BackgroundColor</span><strong><em>Multiple</em></strong></p>"`;
|
|
342
|
+
|
|
343
|
+
exports[`Styled Block/HTML/Markdown Conversions > Convert styled blocks to Markdown 1`] = `
|
|
344
|
+
"**Bold***Italic*Underline~~Strikethrough~~TextColorBackgroundColor***Multiple***
|
|
345
|
+
"
|
|
346
|
+
`;
|