@blocknote/core 0.49.0 → 0.51.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 +1 -1
- package/dist/blocknote.js +4 -4
- package/dist/{blocks-CSfJen16.js → blocks-D0lMxErU.js} +612 -568
- package/dist/blocks-D0lMxErU.js.map +1 -0
- package/dist/blocks-KyMOxPT3.cjs +11 -0
- package/dist/blocks-KyMOxPT3.cjs.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/comments.cjs +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +17 -14
- package/dist/comments.js.map +1 -1
- package/dist/{en-QsSI16s5.js → en-B9hMApn4.js} +4 -2
- package/dist/en-B9hMApn4.js.map +1 -0
- package/dist/{en-C4ykW581.cjs → en-Cj5r8sW_.cjs} +2 -2
- package/dist/en-Cj5r8sW_.cjs.map +1 -0
- package/dist/{extensions-C3nguvVr.js → extensions-CQFfm5f5.js} +621 -353
- package/dist/extensions-CQFfm5f5.js.map +1 -0
- package/dist/extensions-Cuw3zOdC.cjs +52 -0
- package/dist/extensions-Cuw3zOdC.cjs.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +3 -3
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +68 -24
- package/dist/locales.js.map +1 -1
- package/dist/{src-DQfz4zLM.js → src-DK_8q1j5.js} +1135 -625
- package/dist/src-DK_8q1j5.js.map +1 -0
- package/dist/src-_83jmA7A.cjs +21 -0
- package/dist/src-_83jmA7A.cjs.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.js +8 -8
- package/package.json +1 -13
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +7 -7
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +5 -3
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +5 -5
- package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +2550 -291
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +83 -2
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +103 -42
- package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +0 -143
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +12 -12
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +5 -3
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +6 -6
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +22 -22
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +12 -8
- package/src/api/blockManipulation/setupTestEnv.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +2 -6
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +7 -2
- package/src/api/clipboard/toClipboard/copyExtension.ts +21 -16
- package/src/api/exporters/markdown/htmlToMarkdown.ts +813 -0
- package/src/api/exporters/markdown/markdownExporter.ts +2 -21
- package/src/api/nodeConversions/blockToNode.ts +3 -2
- package/src/api/parsers/html/util/__snapshots__/nestedLists.test.ts.snap +122 -107
- package/src/api/parsers/html/util/nestedLists.test.ts +1 -12
- package/src/api/parsers/markdown/markdownToHtml.ts +1194 -0
- package/src/api/parsers/markdown/parseMarkdown.ts +2 -101
- package/src/blocks/Audio/block.ts +1 -4
- package/src/blocks/Code/block.test.ts +258 -0
- package/src/blocks/File/block.ts +1 -4
- package/src/blocks/File/helpers/render/createFileBlockWrapper.ts +7 -2
- package/src/blocks/Image/block.ts +9 -6
- package/src/blocks/ListItem/BulletListItem/block.ts +7 -4
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +3 -4
- package/src/blocks/Table/TableExtension.ts +38 -9
- package/src/blocks/Video/block.ts +4 -5
- package/src/blocks/Video/parseVideoElement.ts +2 -1
- package/src/blocks/defaultBlocks.ts +34 -1
- package/src/comments/extension.ts +30 -11
- package/src/editor/Block.css +22 -18
- package/src/editor/BlockNoteEditor.test.ts +10 -4
- package/src/editor/BlockNoteEditor.ts +30 -13
- package/src/editor/managers/BlockManager.ts +10 -6
- package/src/editor/managers/ExtensionManager/extensions.ts +8 -9
- package/src/editor/managers/ExtensionManager/index.ts +80 -25
- package/src/editor/performance.test.ts +2 -2
- package/src/editor/transformPasted.test.ts +295 -0
- package/src/editor/transformPasted.ts +77 -0
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor-forked.json +1 -12
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor.json +0 -11
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-forked.html +1 -1
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap.html +1 -1
- package/src/extensions/SideMenu/SideMenu.ts +2 -2
- package/src/extensions/SideMenu/dragging.ts +7 -10
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +21 -0
- package/src/extensions/TableHandles/TableHandles.ts +2 -0
- package/src/extensions/TrailingNode/TrailingNode.ts +124 -65
- package/src/extensions/tiptap-extensions/Link/index.ts +1 -1
- package/src/extensions/tiptap-extensions/Link/link.ts +49 -18
- package/src/i18n/locales/ar.ts +3 -1
- package/src/i18n/locales/de.ts +3 -1
- package/src/i18n/locales/en.ts +3 -1
- package/src/i18n/locales/es.ts +3 -1
- package/src/i18n/locales/fa.ts +3 -1
- package/src/i18n/locales/fr.ts +4 -2
- package/src/i18n/locales/he.ts +3 -1
- package/src/i18n/locales/hr.ts +3 -1
- package/src/i18n/locales/is.ts +3 -1
- package/src/i18n/locales/it.ts +3 -1
- package/src/i18n/locales/ja.ts +3 -1
- package/src/i18n/locales/ko.ts +3 -1
- package/src/i18n/locales/nl.ts +3 -1
- package/src/i18n/locales/no.ts +3 -1
- package/src/i18n/locales/pl.ts +3 -1
- package/src/i18n/locales/pt.ts +3 -1
- package/src/i18n/locales/ru.ts +3 -1
- package/src/i18n/locales/sk.ts +3 -1
- package/src/i18n/locales/uk.ts +3 -1
- package/src/i18n/locales/uz.ts +3 -1
- package/src/i18n/locales/vi.ts +3 -1
- package/src/i18n/locales/zh-tw.ts +3 -1
- package/src/i18n/locales/zh.ts +3 -1
- package/types/src/api/blockManipulation/commands/moveBlocks/moveBlocks.d.ts +13 -2
- package/types/src/api/clipboard/fromClipboard/handleVSCodePaste.d.ts +1 -1
- package/types/src/api/exporters/markdown/htmlToMarkdown.d.ts +11 -0
- package/types/src/api/parsers/markdown/markdownToHtml.d.ts +5 -0
- package/types/src/blocks/Code/block.test.d.ts +1 -0
- package/types/src/blocks/Video/block.d.ts +2 -0
- package/types/src/blocks/Video/parseVideoElement.d.ts +1 -0
- package/types/src/comments/extension.d.ts +2 -1
- package/types/src/editor/BlockNoteEditor.d.ts +20 -6
- package/types/src/editor/managers/BlockManager.d.ts +8 -4
- package/types/src/editor/transformPasted.test.d.ts +1 -0
- package/types/src/extensions/TrailingNode/TrailingNode.d.ts +8 -3
- package/types/src/extensions/tiptap-extensions/Link/index.d.ts +1 -1
- package/types/src/extensions/tiptap-extensions/Link/link.d.ts +12 -0
- package/types/src/i18n/locales/en.d.ts +2 -0
- package/types/src/i18n/locales/fa.d.ts +2 -0
- package/types/src/i18n/locales/sk.d.ts +2 -0
- package/dist/blocks-CSfJen16.js.map +0 -1
- package/dist/blocks-_lpGWKOa.cjs +0 -11
- package/dist/blocks-_lpGWKOa.cjs.map +0 -1
- package/dist/en-C4ykW581.cjs.map +0 -1
- package/dist/en-QsSI16s5.js.map +0 -1
- package/dist/extensions-BfYaEv6F.cjs +0 -2
- package/dist/extensions-BfYaEv6F.cjs.map +0 -1
- package/dist/extensions-C3nguvVr.js.map +0 -1
- package/dist/src-ChTwrMcE.cjs +0 -5
- package/dist/src-ChTwrMcE.cjs.map +0 -1
- package/dist/src-DQfz4zLM.js.map +0 -1
- package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +0 -42
- package/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.ts +0 -19
- package/src/api/exporters/markdown/util/removeUnderlinesRehypePlugin.ts +0 -39
- package/types/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.d.ts +0 -7
- package/types/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.d.ts +0 -2
- package/types/src/api/exporters/markdown/util/removeUnderlinesRehypePlugin.d.ts +0 -6
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Element as HASTElement, Parent as HASTParent } from "hast";
|
|
2
|
-
import { fromDom } from "hast-util-from-dom";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Rehype plugin which adds a space after each checkbox input element. This is
|
|
6
|
-
* because remark doesn't add any spaces between the checkbox input and the text
|
|
7
|
-
* itself, but these are needed for correct Markdown syntax.
|
|
8
|
-
*/
|
|
9
|
-
export function addSpacesToCheckboxes() {
|
|
10
|
-
const helper = (tree: HASTParent) => {
|
|
11
|
-
if (tree.children && "length" in tree.children && tree.children.length) {
|
|
12
|
-
for (let i = tree.children.length - 1; i >= 0; i--) {
|
|
13
|
-
const child = tree.children[i];
|
|
14
|
-
const nextChild =
|
|
15
|
-
i + 1 < tree.children.length ? tree.children[i + 1] : undefined;
|
|
16
|
-
|
|
17
|
-
// Checks for paragraph element after checkbox input element.
|
|
18
|
-
if (
|
|
19
|
-
child.type === "element" &&
|
|
20
|
-
child.tagName === "input" &&
|
|
21
|
-
child.properties?.type === "checkbox" &&
|
|
22
|
-
nextChild?.type === "element" &&
|
|
23
|
-
nextChild.tagName === "p"
|
|
24
|
-
) {
|
|
25
|
-
// Converts paragraph to span, otherwise remark will think it needs to
|
|
26
|
-
// be on a new line.
|
|
27
|
-
nextChild.tagName = "span";
|
|
28
|
-
// Adds a space after the checkbox input element.
|
|
29
|
-
nextChild.children.splice(
|
|
30
|
-
0,
|
|
31
|
-
0,
|
|
32
|
-
fromDom(document.createTextNode(" ")) as HASTElement,
|
|
33
|
-
);
|
|
34
|
-
} else {
|
|
35
|
-
helper(child as HASTParent);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return helper;
|
|
42
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Parent as HASTParent } from "hast";
|
|
2
|
-
import { visit } from "unist-util-visit";
|
|
3
|
-
|
|
4
|
-
// Originally, rehypeParse parses videos as links, which is incorrect.
|
|
5
|
-
export function convertVideoToMarkdown() {
|
|
6
|
-
return (tree: HASTParent) => {
|
|
7
|
-
visit(tree, "element", (node, index, parent) => {
|
|
8
|
-
if (parent && node.tagName === "video") {
|
|
9
|
-
const src = node.properties?.src || node.properties?.["data-url"] || "";
|
|
10
|
-
const name =
|
|
11
|
-
node.properties?.title || node.properties?.["data-name"] || "";
|
|
12
|
-
parent.children[index!] = {
|
|
13
|
-
type: "text",
|
|
14
|
-
value: ``,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Element as HASTElement, Parent as HASTParent } from "hast";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Rehype plugin which removes <u> tags. Used to remove underlines before converting HTML to markdown, as Markdown
|
|
5
|
-
* doesn't support underlines.
|
|
6
|
-
*/
|
|
7
|
-
export function removeUnderlines() {
|
|
8
|
-
const removeUnderlinesHelper = (tree: HASTParent) => {
|
|
9
|
-
let numChildElements = tree.children.length;
|
|
10
|
-
|
|
11
|
-
for (let i = 0; i < numChildElements; i++) {
|
|
12
|
-
const node = tree.children[i];
|
|
13
|
-
|
|
14
|
-
if (node.type === "element") {
|
|
15
|
-
// Recursively removes underlines from child elements.
|
|
16
|
-
removeUnderlinesHelper(node);
|
|
17
|
-
|
|
18
|
-
if ((node as HASTElement).tagName === "u") {
|
|
19
|
-
// Lifts child nodes outside underline element, deletes the underline element, and updates current index &
|
|
20
|
-
// the number of child elements.
|
|
21
|
-
if (node.children.length > 0) {
|
|
22
|
-
tree.children.splice(i, 1, ...node.children);
|
|
23
|
-
|
|
24
|
-
const numElementsAdded = node.children.length - 1;
|
|
25
|
-
numChildElements += numElementsAdded;
|
|
26
|
-
i += numElementsAdded;
|
|
27
|
-
} else {
|
|
28
|
-
tree.children.splice(i, 1);
|
|
29
|
-
|
|
30
|
-
numChildElements--;
|
|
31
|
-
i--;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return removeUnderlinesHelper;
|
|
39
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Parent as HASTParent } from "hast";
|
|
2
|
-
/**
|
|
3
|
-
* Rehype plugin which adds a space after each checkbox input element. This is
|
|
4
|
-
* because remark doesn't add any spaces between the checkbox input and the text
|
|
5
|
-
* itself, but these are needed for correct Markdown syntax.
|
|
6
|
-
*/
|
|
7
|
-
export declare function addSpacesToCheckboxes(): (tree: HASTParent) => void;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Parent as HASTParent } from "hast";
|
|
2
|
-
/**
|
|
3
|
-
* Rehype plugin which removes <u> tags. Used to remove underlines before converting HTML to markdown, as Markdown
|
|
4
|
-
* doesn't support underlines.
|
|
5
|
-
*/
|
|
6
|
-
export declare function removeUnderlines(): (tree: HASTParent) => void;
|