@blocknote/core 0.15.7 → 0.15.9
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 +1284 -1182
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +5 -5
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +23 -23
- package/src/api/exporters/copyExtension.ts +48 -33
- package/src/api/exporters/html/__snapshots__/complex/misc/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/customParagraph/styled/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/file/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/file/nested/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/file/noCaption/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/file/noName/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/fontSize/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/between-links/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/end/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/link/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/multiple/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/only/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/start/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/styles/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/nested/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noCaption/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noName/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noPreview/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/link/adjacent/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/link/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/link/styled/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/mention/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/paragraph/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/paragraph/empty/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/paragraph/lineBreaks/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/paragraph/nested/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/paragraph/styled/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/nested/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/styled/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/button/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/small/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/tag/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots_fragment_edge_cases__/selectionLeavesBlockChildren.html +1 -1
- package/src/api/exporters/html/__snapshots_fragment_edge_cases__/selectionSpansBlocksChildren.html +1 -1
- package/src/api/exporters/html/__snapshots_fragment_edge_cases__/selectionWithinBlockChildren.html +1 -1
- package/src/api/exporters/html/util/simplifyBlocksRehypePlugin.ts +51 -2
- package/src/api/parsers/handleFileInsertion.ts +30 -17
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +23 -47
- package/src/blocks/FileBlockContent/FileBlockContent.ts +4 -22
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +72 -1
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +35 -61
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +33 -58
- package/src/editor/BlockNoteEditor.test.ts +13 -0
- package/src/editor/BlockNoteEditor.ts +71 -6
- package/src/editor/BlockNoteExtensions.ts +4 -2
- package/src/editor/BlockNoteTipTapEditor.ts +4 -1
- package/src/extensions/FilePanel/FilePanelPlugin.ts +10 -6
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +0 -1
- package/src/extensions/SideMenu/SideMenuPlugin.ts +22 -11
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +6 -3
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +5 -1
- package/src/extensions/UniqueID/UniqueID.ts +15 -4
- package/src/pm-nodes/BlockContainer.ts +1 -2
- package/src/schema/inlineContent/createSpec.ts +54 -5
- package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +2 -2
- package/types/src/blocks/FileBlockContent/FileBlockContent.d.ts +2 -2
- package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +11 -1
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +2 -2
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +2 -2
- package/types/src/editor/BlockNoteEditor.d.ts +23 -4
- package/types/src/editor/BlockNoteExtensions.d.ts +1 -0
- package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +1 -1
- package/types/src/schema/inlineContent/createSpec.d.ts +3 -3
package/dist/webpack-stats.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"builtAt":
|
|
1
|
+
{"builtAt":1726696353895,"assets":[{"name":"blocknote.umd.cjs","size":199501},{"name":"blocknote.umd.cjs.map","size":722376}],"chunks":[{"id":"a1ee98a","entry":true,"initial":true,"files":["blocknote.umd.cjs"],"names":["index"]}],"modules":[{"name":"./src/i18n/locales/ar.ts","size":6582,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/de.ts","size":7183,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/en.ts","size":6664,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/es.ts","size":6796,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/fr.ts","size":7294,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/is.ts","size":6876,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ja.ts","size":6323,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ko.ts","size":6146,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/nl.ts","size":7079,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/pl.ts","size":6768,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/pt.ts","size":6965,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ru.ts","size":7638,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/vi.ts","size":6927,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/zh.ts","size":6093,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/index.ts","size":0,"chunks":["a1ee98a"]},{"name":"./src/util/esmDependencies.ts","size":820,"chunks":["a1ee98a"]},{"name":"./src/extensions/UniqueID/UniqueID.ts","size":8887,"chunks":["a1ee98a"]},{"name":"./src/api/getBlockInfoFromPos.ts","size":1691,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/types.ts","size":302,"chunks":["a1ee98a"]},{"name":"./src/util/typescript.ts","size":331,"chunks":["a1ee98a"]},{"name":"./src/api/nodeConversions/nodeConversions.ts","size":11998,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/util/sharedHTMLConversion.ts","size":2311,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/util/simplifyBlocksRehypePlugin.ts","size":4488,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/externalHTMLExporter.ts","size":1320,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/internalHTMLSerializer.ts","size":758,"chunks":["a1ee98a"]},{"name":"./src/api/getCurrentBlockContentType.ts","size":192,"chunks":["a1ee98a"]},{"name":"./src/util/browser.ts","size":536,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlockHelpers.ts","size":1691,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultProps.ts","size":269,"chunks":["a1ee98a"]},{"name":"./src/util/string.ts","size":299,"chunks":["a1ee98a"]},{"name":"./src/schema/blocks/internal.ts","size":3877,"chunks":["a1ee98a"]},{"name":"./src/schema/blocks/createSpec.ts","size":2814,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/internal.ts","size":1357,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/createSpec.ts","size":2727,"chunks":["a1ee98a"]},{"name":"./src/schema/styles/internal.ts","size":1162,"chunks":["a1ee98a"]},{"name":"./src/schema/styles/createSpec.ts","size":1263,"chunks":["a1ee98a"]},{"name":"./src/blocks/FileBlockContent/fileBlockHelpers.ts","size":10029,"chunks":["a1ee98a"]},{"name":"./src/blocks/AudioBlockContent/audioBlockHelpers.ts","size":108,"chunks":["a1ee98a"]},{"name":"./src/blocks/AudioBlockContent/AudioBlockContent.ts","size":3075,"chunks":["a1ee98a"]},{"name":"./src/blocks/FileBlockContent/FileBlockContent.ts","size":1581,"chunks":["a1ee98a"]},{"name":"./src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts","size":316,"chunks":["a1ee98a"]},{"name":"./src/blocks/ImageBlockContent/imageBlockHelpers.ts","size":175,"chunks":["a1ee98a"]},{"name":"./src/blocks/ImageBlockContent/ImageBlockContent.ts","size":3242,"chunks":["a1ee98a"]},{"name":"./src/blocks/VideoBlockContent/videoBlockHelpers.ts","size":175,"chunks":["a1ee98a"]},{"name":"./src/blocks/VideoBlockContent/VideoBlockContent.ts","size":3050,"chunks":["a1ee98a"]},{"name":"./src/extensions/BackgroundColor/BackgroundColorMark.ts","size":946,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextColor/TextColorMark.ts","size":866,"chunks":["a1ee98a"]},{"name":"./src/blocks/HeadingBlockContent/HeadingBlockContent.ts","size":3439,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts","size":1201,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts","size":3122,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts","size":1862,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts","size":3437,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts","size":6423,"chunks":["a1ee98a"]},{"name":"./src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts","size":1307,"chunks":["a1ee98a"]},{"name":"./src/blocks/TableBlockContent/TableExtension.ts","size":1462,"chunks":["a1ee98a"]},{"name":"./src/blocks/TableBlockContent/TableBlockContent.ts","size":1624,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlocks.ts","size":1123,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlockTypeGuards.ts","size":1580,"chunks":["a1ee98a"]},{"name":"./src/api/nodeUtil.ts","size":548,"chunks":["a1ee98a"]},{"name":"./src/api/blockManipulation/blockManipulation.ts","size":5664,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/removeUnderlinesRehypePlugin.ts","size":752,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts","size":962,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/markdownExporter.ts","size":837,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/html/util/nestedLists.ts","size":2174,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/html/parseHTML.ts","size":503,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/markdown/parseMarkdown.ts","size":1104,"chunks":["a1ee98a"]},{"name":"./src/util/EventEmitter.ts","size":744,"chunks":["a1ee98a"]},{"name":"./src/extensions/FilePanel/FilePanelPlugin.ts","size":3584,"chunks":["a1ee98a"]},{"name":"./src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts","size":5062,"chunks":["a1ee98a"]},{"name":"./src/extensions/LinkToolbar/LinkToolbarPlugin.ts","size":7365,"chunks":["a1ee98a"]},{"name":"./src/extensions/SideMenu/MultipleNodeSelection.ts","size":1616,"chunks":["a1ee98a"]},{"name":"./src/extensions/SideMenu/SideMenuPlugin.ts","size":17383,"chunks":["a1ee98a"]},{"name":"./src/extensions/SuggestionMenu/SuggestionPlugin.ts","size":7996,"chunks":["a1ee98a"]},{"name":"./src/extensions/TableHandles/TableHandlesPlugin.ts","size":15279,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/copyExtension.ts","size":3195,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/acceptedMIMETypes.ts","size":91,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/handleFileInsertion.ts","size":3396,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/fileDropExtension.ts","size":884,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/pasteExtension.ts","size":1244,"chunks":["a1ee98a"]},{"name":"./src/extensions/BackgroundColor/BackgroundColorExtension.ts","size":791,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextAlignment/TextAlignmentExtension.ts","size":928,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextColor/TextColorExtension.ts","size":725,"chunks":["a1ee98a"]},{"name":"./src/extensions/TrailingNode/TrailingNodeExtension.ts","size":1594,"chunks":["a1ee98a"]},{"name":"./src/extensions/NonEditableBlocks/NonEditableBlockPlugin.ts","size":1086,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/BlockContainer.ts","size":18085,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/BlockGroup.ts","size":1097,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/Doc.ts","size":90,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteExtensions.ts","size":4286,"chunks":["a1ee98a"]},{"name":"./src/editor/transformPasted.ts","size":1062,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteSchema.ts","size":1044,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteTipTapEditor.ts","size":2883,"chunks":["a1ee98a"]},{"name":"./src/extensions/Placeholder/PlaceholderPlugin.ts","size":2762,"chunks":["a1ee98a"]},{"name":"./src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts","size":4572,"chunks":["a1ee98a"]},{"name":"./src/style.css","size":0,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteEditor.ts","size":27988,"chunks":["a1ee98a"]},{"name":"./src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts","size":700,"chunks":["a1ee98a"]},{"name":"./src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts","size":6416,"chunks":["a1ee98a"]},{"name":"./src/api/testUtil/partialBlockTestUtil.ts","size":2166,"chunks":["a1ee98a"]},{"name":"./src/index.ts","size":0,"chunks":["a1ee98a"]}]}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"homepage": "https://github.com/TypeCellOS/BlockNote",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
|
-
"version": "0.15.
|
|
6
|
+
"version": "0.15.9",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
9
9
|
"types",
|
|
@@ -55,26 +55,26 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@emoji-mart/data": "^1.2.1",
|
|
58
|
-
"@tiptap/core": "^2.
|
|
59
|
-
"@tiptap/extension-bold": "^2.
|
|
60
|
-
"@tiptap/extension-code": "^2.
|
|
61
|
-
"@tiptap/extension-collaboration": "^2.
|
|
62
|
-
"@tiptap/extension-collaboration-cursor": "^2.
|
|
63
|
-
"@tiptap/extension-dropcursor": "^2.
|
|
64
|
-
"@tiptap/extension-gapcursor": "^2.
|
|
65
|
-
"@tiptap/extension-hard-break": "^2.
|
|
66
|
-
"@tiptap/extension-history": "^2.
|
|
67
|
-
"@tiptap/extension-horizontal-rule": "^2.
|
|
68
|
-
"@tiptap/extension-italic": "^2.
|
|
69
|
-
"@tiptap/extension-link": "^2.
|
|
70
|
-
"@tiptap/extension-paragraph": "^2.
|
|
71
|
-
"@tiptap/extension-strike": "^2.
|
|
72
|
-
"@tiptap/extension-table-cell": "^2.
|
|
73
|
-
"@tiptap/extension-table-header": "^2.
|
|
74
|
-
"@tiptap/extension-table-row": "^2.
|
|
75
|
-
"@tiptap/extension-text": "^2.
|
|
76
|
-
"@tiptap/extension-underline": "^2.
|
|
77
|
-
"@tiptap/pm": "^2.
|
|
58
|
+
"@tiptap/core": "^2.7.1",
|
|
59
|
+
"@tiptap/extension-bold": "^2.7.1",
|
|
60
|
+
"@tiptap/extension-code": "^2.7.1",
|
|
61
|
+
"@tiptap/extension-collaboration": "^2.7.1",
|
|
62
|
+
"@tiptap/extension-collaboration-cursor": "^2.7.1",
|
|
63
|
+
"@tiptap/extension-dropcursor": "^2.7.1",
|
|
64
|
+
"@tiptap/extension-gapcursor": "^2.7.1",
|
|
65
|
+
"@tiptap/extension-hard-break": "^2.7.1",
|
|
66
|
+
"@tiptap/extension-history": "^2.7.1",
|
|
67
|
+
"@tiptap/extension-horizontal-rule": "^2.7.1",
|
|
68
|
+
"@tiptap/extension-italic": "^2.7.1",
|
|
69
|
+
"@tiptap/extension-link": "^2.7.1",
|
|
70
|
+
"@tiptap/extension-paragraph": "^2.7.1",
|
|
71
|
+
"@tiptap/extension-strike": "^2.7.1",
|
|
72
|
+
"@tiptap/extension-table-cell": "^2.7.1",
|
|
73
|
+
"@tiptap/extension-table-header": "^2.7.1",
|
|
74
|
+
"@tiptap/extension-table-row": "^2.7.1",
|
|
75
|
+
"@tiptap/extension-text": "^2.7.1",
|
|
76
|
+
"@tiptap/extension-underline": "^2.7.1",
|
|
77
|
+
"@tiptap/pm": "^2.7.1",
|
|
78
78
|
"emoji-mart": "^5.6.0",
|
|
79
79
|
"hast-util-from-dom": "^4.2.0",
|
|
80
80
|
"prosemirror-model": "^1.21.0",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"remark-stringify": "^10.0.2",
|
|
93
93
|
"unified": "^10.1.2",
|
|
94
94
|
"uuid": "^8.3.2",
|
|
95
|
-
"y-prosemirror": "1.2.
|
|
95
|
+
"y-prosemirror": "1.2.12",
|
|
96
96
|
"y-protocols": "^1.0.6",
|
|
97
97
|
"yjs": "^13.6.15"
|
|
98
98
|
},
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"access": "public",
|
|
120
120
|
"registry": "https://registry.npmjs.org/"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "7a549f62261916fbfad2c7b4b7c72a7252d793c3"
|
|
123
123
|
}
|
|
@@ -24,7 +24,7 @@ async function selectedFragmentToHTML<
|
|
|
24
24
|
}> {
|
|
25
25
|
const selectedFragment = view.state.selection.content().content;
|
|
26
26
|
|
|
27
|
-
const internalHTMLSerializer =
|
|
27
|
+
const internalHTMLSerializer = createInternalHTMLSerializer(
|
|
28
28
|
view.state.schema,
|
|
29
29
|
editor
|
|
30
30
|
);
|
|
@@ -48,6 +48,46 @@ async function selectedFragmentToHTML<
|
|
|
48
48
|
return { internalHTML, externalHTML, plainText };
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
const copyToClipboard = <
|
|
52
|
+
BSchema extends BlockSchema,
|
|
53
|
+
I extends InlineContentSchema,
|
|
54
|
+
S extends StyleSchema
|
|
55
|
+
>(
|
|
56
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
57
|
+
view: EditorView,
|
|
58
|
+
event: ClipboardEvent
|
|
59
|
+
) => {
|
|
60
|
+
// Stops the default browser copy behaviour.
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
event.clipboardData!.clearData();
|
|
63
|
+
|
|
64
|
+
// Checks if a `blockContent` node is being copied and expands
|
|
65
|
+
// the selection to the parent `blockContainer` node. This is
|
|
66
|
+
// for the use-case in which only a block without content is
|
|
67
|
+
// selected, e.g. an image block.
|
|
68
|
+
if (
|
|
69
|
+
"node" in view.state.selection &&
|
|
70
|
+
(view.state.selection.node as Node).type.spec.group === "blockContent"
|
|
71
|
+
) {
|
|
72
|
+
editor.dispatch(
|
|
73
|
+
editor._tiptapEditor.state.tr.setSelection(
|
|
74
|
+
new NodeSelection(view.state.doc.resolve(view.state.selection.from - 1))
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
(async () => {
|
|
80
|
+
const { internalHTML, externalHTML, plainText } =
|
|
81
|
+
await selectedFragmentToHTML(view, editor);
|
|
82
|
+
|
|
83
|
+
// TODO: Writing to other MIME types not working in Safari for
|
|
84
|
+
// some reason.
|
|
85
|
+
event.clipboardData!.setData("blocknote/html", internalHTML);
|
|
86
|
+
event.clipboardData!.setData("text/html", externalHTML);
|
|
87
|
+
event.clipboardData!.setData("text/plain", plainText);
|
|
88
|
+
})();
|
|
89
|
+
};
|
|
90
|
+
|
|
51
91
|
export const createCopyToClipboardExtension = <
|
|
52
92
|
BSchema extends BlockSchema,
|
|
53
93
|
I extends InlineContentSchema,
|
|
@@ -63,38 +103,13 @@ export const createCopyToClipboardExtension = <
|
|
|
63
103
|
props: {
|
|
64
104
|
handleDOMEvents: {
|
|
65
105
|
copy(view, event) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// selected, e.g. an image block.
|
|
74
|
-
if (
|
|
75
|
-
"node" in view.state.selection &&
|
|
76
|
-
(view.state.selection.node as Node).type.spec.group ===
|
|
77
|
-
"blockContent"
|
|
78
|
-
) {
|
|
79
|
-
editor.dispatch(
|
|
80
|
-
editor._tiptapEditor.state.tr.setSelection(
|
|
81
|
-
new NodeSelection(
|
|
82
|
-
view.state.doc.resolve(view.state.selection.from - 1)
|
|
83
|
-
)
|
|
84
|
-
)
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
(async () => {
|
|
89
|
-
const { internalHTML, externalHTML, plainText } =
|
|
90
|
-
await selectedFragmentToHTML(view, editor);
|
|
91
|
-
|
|
92
|
-
// TODO: Writing to other MIME types not working in Safari for
|
|
93
|
-
// some reason.
|
|
94
|
-
event.clipboardData!.setData("blocknote/html", internalHTML);
|
|
95
|
-
event.clipboardData!.setData("text/html", externalHTML);
|
|
96
|
-
event.clipboardData!.setData("text/plain", plainText);
|
|
97
|
-
})();
|
|
106
|
+
copyToClipboard(editor, view, event);
|
|
107
|
+
// Prevent default PM handler to be called
|
|
108
|
+
return true;
|
|
109
|
+
},
|
|
110
|
+
cut(view, event) {
|
|
111
|
+
copyToClipboard(editor, view, event);
|
|
112
|
+
view.dispatch(view.state.tr.deleteSelection());
|
|
98
113
|
// Prevent default PM handler to be called
|
|
99
114
|
return true;
|
|
100
115
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<h2
|
|
1
|
+
<h2 data-text-color="yellow" data-background-color="blue" data-text-alignment="right" data-level="2"><strong><u>Heading </u></strong><em><s>2</s></em></h2><p data-background-color="red">Paragraph</p><ul><li><p class="bn-inline-content"></p></li></ul>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p class="custom-paragraph">Hello World</p>
|
|
1
|
+
<p class="custom-paragraph" data-text-color="orange" data-background-color="pink" data-text-alignment="center">Hello World</p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<div><a href="exampleURL">example</a><p>Caption</p></div>
|
|
1
|
+
<div data-name="example" data-url="exampleURL" data-caption="Caption"><a href="exampleURL">example</a><p>Caption</p></div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<div><a href="exampleURL">example</a><p>Caption</p></div><div><a href="exampleURL">example</a><p>Caption</p></div>
|
|
1
|
+
<div data-name="example" data-url="exampleURL" data-caption="Caption"><a href="exampleURL">example</a><p>Caption</p></div><div data-name="example" data-url="exampleURL" data-caption="Caption"><a href="exampleURL">example</a><p>Caption</p></div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<a href="exampleURL">example</a>
|
|
1
|
+
<a href="exampleURL" data-name="example" data-url="exampleURL">example</a>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<div><a href="exampleURL">exampleURL</a><p>Caption</p></div>
|
|
1
|
+
<div data-url="exampleURL" data-caption="Caption"><a href="exampleURL">exampleURL</a><p>Caption</p></div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p><span style="font-size: 18px" data-style-type="fontSize" data-value="18px" data-editable="">This is text with a custom fontSize</span></p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p>Text1<br>Text2</p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p><a target="_blank" rel="noopener noreferrer nofollow" href="https://www.website.com">Link1</a><br><a target="_blank" rel="noopener noreferrer nofollow" href="https://www.website2.com">Link2</a></p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p>Text1<br></p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p><a target="_blank" rel="noopener noreferrer nofollow" href="https://www.website.com">Link1</a><br><a target="_blank" rel="noopener noreferrer nofollow" href="https://www.website.com">Link1</a></p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p>Text1<br>Text2<br>Text3</p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p><br></p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p><br>Text1</p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p>Text1<br><strong>Text2</strong></p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<figure><img src="exampleURL" alt="example" width="256"><figcaption>Caption</figcaption></figure>
|
|
1
|
+
<figure data-name="example" data-url="exampleURL" data-caption="Caption" data-preview-width="256"><img src="exampleURL" alt="example" width="256"><figcaption>Caption</figcaption></figure>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<figure><img src="exampleURL" alt="Caption" width="256"><figcaption>Caption</figcaption></figure><figure><img src="exampleURL" alt="Caption" width="256"><figcaption>Caption</figcaption></figure>
|
|
1
|
+
<figure data-url="exampleURL" data-caption="Caption" data-preview-width="256"><img src="exampleURL" alt="Caption" width="256"><figcaption>Caption</figcaption></figure><figure data-url="exampleURL" data-caption="Caption" data-preview-width="256"><img src="exampleURL" alt="Caption" width="256"><figcaption>Caption</figcaption></figure>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<img src="exampleURL" alt="example" width="256">
|
|
1
|
+
<img src="exampleURL" alt="example" width="256" data-name="example" data-url="exampleURL" data-preview-width="256">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<figure><img src="exampleURL" alt="Caption" width="256"><figcaption>Caption</figcaption></figure>
|
|
1
|
+
<figure data-url="exampleURL" data-caption="Caption" data-preview-width="256"><img src="exampleURL" alt="Caption" width="256"><figcaption>Caption</figcaption></figure>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<div><a href="exampleURL">example</a><p>Caption</p></div>
|
|
1
|
+
<div data-name="example" data-url="exampleURL" data-caption="Caption" data-show-preview="false" data-preview-width="256"><a href="exampleURL">example</a><p>Caption</p></div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p><a target="_blank" rel="noopener noreferrer nofollow" href="https://www.website.com">Website</a><a target="_blank" rel="noopener noreferrer nofollow" href="https://www.website2.com">Website2</a></p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p><a target="_blank" rel="noopener noreferrer nofollow" href="https://www.website.com">Website</a></p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p><strong><a target="_blank" rel="noopener noreferrer nofollow" href="https://www.website.com">Web</a></strong><a target="_blank" rel="noopener noreferrer nofollow" href="https://www.website.com">site</a></p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p>I enjoy working with <span data-inline-content-type="mention" data-user="Matthew">@Matthew</span></p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p>Paragraph</p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p></p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p>Line 1<br>Line 2</p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p>Paragraph</p><p>Nested Paragraph 1</p><p>Nested Paragraph 2</p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p data-text-color="orange" data-background-color="pink" data-text-alignment="center">Plain <span data-text-color="red">Red Text </span><span data-background-color="blue">Blue Background </span><span data-text-color="red"><span data-background-color="blue">Mixed Colors</span></span></p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p class="
|
|
1
|
+
<p class="simple-custom-paragraph" data-editable="">Custom Paragraph</p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p class="
|
|
1
|
+
<p class="simple-custom-paragraph" data-editable="">Custom Paragraph</p><p class="simple-custom-paragraph" data-editable="">Nested Custom Paragraph 1</p><p class="simple-custom-paragraph" data-editable="">Nested Custom Paragraph 2</p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p class="
|
|
1
|
+
<p class="simple-custom-paragraph" data-editable="" data-text-color="orange" data-background-color="pink" data-text-alignment="center">Plain <span data-text-color="red">Red Text </span><span data-background-color="blue">Blue Background </span><span data-text-color="red"><span data-background-color="blue">Mixed Colors</span></span></p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<div
|
|
1
|
+
<div data-name="example" data-url="exampleURL" data-caption="Caption" data-preview-width="256"><div class="bn-file-and-caption-wrapper"><div class="bn-visual-media-wrapper"><img class="bn-visual-media" alt="example" draggable="false" width="0"></div><p class="bn-file-caption">Caption</p></div></div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<div
|
|
1
|
+
<div><div class="bn-add-file-button"><div class="bn-add-file-button-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z"></path></svg></div><p class="bn-add-file-button-text">Add image</p></div></div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<div
|
|
1
|
+
<div data-name="example" data-url="exampleURL" data-caption="Caption" data-preview-width="256"><div class="bn-file-and-caption-wrapper"><div class="bn-visual-media-wrapper"><img class="bn-visual-media" alt="example" draggable="false" width="0"></div><p class="bn-file-caption">Caption</p></div></div><div data-name="example" data-url="exampleURL" data-caption="Caption" data-preview-width="256"><div class="bn-file-and-caption-wrapper"><div class="bn-visual-media-wrapper"><img class="bn-visual-media" alt="example" draggable="false" width="0"></div><p class="bn-file-caption">Caption</p></div></div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<div
|
|
1
|
+
<div data-name="example" data-url="exampleURL" data-preview-width="256"><div class="bn-file-and-caption-wrapper"><div class="bn-visual-media-wrapper"><img class="bn-visual-media" alt="example" draggable="false" width="0"></div><p class="bn-file-caption"></p></div></div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<div
|
|
1
|
+
<div data-url="exampleURL" data-caption="Caption" data-preview-width="256"><div class="bn-file-and-caption-wrapper"><div class="bn-visual-media-wrapper"><img class="bn-visual-media" alt="Caption" draggable="false" width="0"></div><p class="bn-file-caption">Caption</p></div></div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<div
|
|
1
|
+
<div data-name="example" data-url="exampleURL" data-caption="Caption" data-show-preview="false" data-preview-width="256"><div class="bn-file-default-preview"><div class="bn-file-default-preview-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg></div><p class="bn-file-default-preview-name">example</p></div><p class="bn-file-caption">Caption</p></div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p><small data-style-type="small" data-editable="">This is a small text</small></p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p>I love <span data-inline-content-type="tag">#<span data-editable="">BlockNote</span></span></p>
|
package/src/api/exporters/html/__snapshots_fragment_edge_cases__/selectionLeavesBlockChildren.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p>Nested Paragraph 1</p><p>Nested Paragraph 2</p><p>Nested Paragraph 3</p><p>Paragraph 2</p>
|
package/src/api/exporters/html/__snapshots_fragment_edge_cases__/selectionSpansBlocksChildren.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p>Nested Paragraph 1</p><p>Nested Paragraph 2</p><p>Nested Paragraph 3</p><p>Paragraph 2</p><p>Nested Paragraph 1</p><p>Nested Paragraph 2</p><p>Nested Paragraph 3</p>
|
package/src/api/exporters/html/__snapshots_fragment_edge_cases__/selectionWithinBlockChildren.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p>Nested Paragraph 1</p><p>Nested Paragraph 2</p><p>Nested Paragraph 3</p>
|
|
@@ -6,6 +6,23 @@ type SimplifyBlocksOptions = {
|
|
|
6
6
|
unorderedListItemBlockTypes: Set<string>;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
function addAttributesAndRemoveClasses(
|
|
10
|
+
element: HASTElement,
|
|
11
|
+
attributes: Record<string, unknown>
|
|
12
|
+
) {
|
|
13
|
+
// Removes all BlockNote specific class names.
|
|
14
|
+
const className =
|
|
15
|
+
((element.properties?.className as string[]) || []).filter(
|
|
16
|
+
(className) => !className.startsWith("bn-")
|
|
17
|
+
) || [];
|
|
18
|
+
// Adds all block props as data attributes.
|
|
19
|
+
element.properties = {
|
|
20
|
+
...element.properties,
|
|
21
|
+
...attributes,
|
|
22
|
+
className: className.length > 0 ? className : undefined,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
9
26
|
/**
|
|
10
27
|
* Rehype plugin which converts the HTML output string rendered by BlockNote into a simplified structure which better
|
|
11
28
|
* follows HTML standards. It does several things:
|
|
@@ -62,6 +79,34 @@ export function simplifyBlocks(options: SimplifyBlocksOptions) {
|
|
|
62
79
|
return classNames?.includes("bn-block-group");
|
|
63
80
|
}) as HASTElement | undefined;
|
|
64
81
|
|
|
82
|
+
// Saves the data attributes of the block container, excluding the block
|
|
83
|
+
// ID and node type as we're removing the block structure. This means that
|
|
84
|
+
// only attributes for the block's props are saved.
|
|
85
|
+
const blockContainerDataAttributes = Object.fromEntries(
|
|
86
|
+
Object.entries(blockContainer.properties || {}).filter(
|
|
87
|
+
([key]) =>
|
|
88
|
+
key.startsWith("data") && key !== "dataId" && key !== "dataNodeType"
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
|
+
// Saves the data attributes of the block content, excluding the block
|
|
92
|
+
// content type as we're removing the block structure. This means that
|
|
93
|
+
// only attributes for the block's props are saved.
|
|
94
|
+
const blockContentDataAttributes = Object.fromEntries(
|
|
95
|
+
Object.entries(blockContent?.properties || {}).filter(
|
|
96
|
+
([key]) =>
|
|
97
|
+
key.startsWith("data") &&
|
|
98
|
+
key !== "dataContentType" &&
|
|
99
|
+
key !== "dataFileBlock" &&
|
|
100
|
+
key !== "dataNodeViewWrapper" &&
|
|
101
|
+
key !== "dataEditable"
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
// All the block's props as data attributes.
|
|
105
|
+
const blockPropsDataAttributes = {
|
|
106
|
+
...blockContainerDataAttributes,
|
|
107
|
+
...blockContentDataAttributes,
|
|
108
|
+
};
|
|
109
|
+
|
|
65
110
|
// When the selection starts in a nested block, the Fragment from it omits
|
|
66
111
|
// the `blockContent` node of the parent `blockContainer` if it's not also
|
|
67
112
|
// included in the selection. This is because ProseMirror preserves the
|
|
@@ -142,7 +187,9 @@ export function simplifyBlocks(options: SimplifyBlocksOptions) {
|
|
|
142
187
|
// Lifts all children out of the current block, as only list items should allow nesting.
|
|
143
188
|
tree.children.splice(i + 1, 0, ...blockGroup.children);
|
|
144
189
|
// Replaces the block with only the content inside it.
|
|
145
|
-
|
|
190
|
+
const content = blockContent.children[0] as HASTElement;
|
|
191
|
+
addAttributesAndRemoveClasses(content, blockPropsDataAttributes);
|
|
192
|
+
tree.children[i] = content;
|
|
146
193
|
|
|
147
194
|
// Updates the current index and number of child elements.
|
|
148
195
|
const numElementsAdded = blockGroup.children.length;
|
|
@@ -150,7 +197,9 @@ export function simplifyBlocks(options: SimplifyBlocksOptions) {
|
|
|
150
197
|
numChildElements += numElementsAdded;
|
|
151
198
|
} else {
|
|
152
199
|
// Replaces the block with only the content inside it.
|
|
153
|
-
|
|
200
|
+
const content = blockContent.children[0] as HASTElement;
|
|
201
|
+
addAttributesAndRemoveClasses(content, blockPropsDataAttributes);
|
|
202
|
+
tree.children[i] = content;
|
|
154
203
|
}
|
|
155
204
|
}
|
|
156
205
|
|