@blocknote/core 0.19.2 → 0.21.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.js +2035 -1758
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +6 -6
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js +6 -3
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js.map +1 -1
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js +219 -0
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js +175 -0
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js +4 -1
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js.map +1 -1
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js +6 -3
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js.map +1 -1
- package/dist/src/api/blockManipulation/getBlock/getBlock.js +56 -0
- package/dist/src/api/blockManipulation/getBlock/getBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/selection.js +149 -0
- package/dist/src/api/blockManipulation/selections/selection.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/selection.test.js +39 -0
- package/dist/src/api/blockManipulation/selections/selection.test.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js +3 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js.map +1 -1
- package/dist/src/api/clipboard/clipboard.test.js +6 -3
- package/dist/src/api/clipboard/clipboard.test.js.map +1 -1
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js +1 -1
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js.map +1 -1
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js +2 -3
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js.map +1 -1
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js +5 -5
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js.map +1 -1
- package/dist/src/api/clipboard/toClipboard/copyExtension.js +4 -2
- package/dist/src/api/clipboard/toClipboard/copyExtension.js.map +1 -1
- package/dist/src/api/nodeUtil.js +1 -1
- package/dist/src/api/nodeUtil.js.map +1 -1
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js +4 -1
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js.map +1 -1
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js +14 -7
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +1 -1
- package/dist/src/blocks/AudioBlockContent/{audioBlockHelpers.js → parseAudioElement.js} +1 -1
- package/dist/src/blocks/AudioBlockContent/parseAudioElement.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js +5 -4
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +1 -1
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.js +5 -0
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.js +10 -0
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createAddFileButton.js +39 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createAddFileButton.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.js +51 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.js +17 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js +147 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js +9 -0
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js +11 -0
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js.map +1 -0
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js +17 -9
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +1 -1
- package/dist/src/blocks/ImageBlockContent/{imageBlockHelpers.js → parseImageElement.js} +1 -1
- package/dist/src/blocks/ImageBlockContent/parseImageElement.js.map +1 -0
- package/dist/src/blocks/TableBlockContent/TableExtension.js +8 -1
- package/dist/src/blocks/TableBlockContent/TableExtension.js.map +1 -1
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js +18 -7
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +1 -1
- package/dist/src/blocks/VideoBlockContent/{videoBlockHelpers.js → parseVideoElement.js} +1 -1
- package/dist/src/blocks/VideoBlockContent/parseVideoElement.js.map +1 -0
- package/dist/src/editor/BlockNoteEditor.js +64 -62
- package/dist/src/editor/BlockNoteEditor.js.map +1 -1
- package/dist/src/editor/BlockNoteExtensions.js +5 -8
- package/dist/src/editor/BlockNoteExtensions.js.map +1 -1
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js +4 -2
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js.map +1 -1
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +10 -8
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +1 -1
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js +7 -3
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js.map +1 -1
- package/dist/src/extensions/LinkToolbar/protocols.js +14 -0
- package/dist/src/extensions/LinkToolbar/protocols.js.map +1 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +19 -13
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +1 -1
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js +5 -1
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +1 -1
- package/dist/src/extensions/SideMenu/dragging.js +8 -1
- package/dist/src/extensions/SideMenu/dragging.js.map +1 -1
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js +3 -3
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js.map +1 -1
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js +37 -11
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js.map +1 -1
- package/dist/src/i18n/locales/ru.js +1 -1
- package/dist/src/index.js +9 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/schema/inlineContent/createSpec.js +1 -1
- package/dist/src/schema/inlineContent/createSpec.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +3 -3
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +6 -6
- package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +9506 -0
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +295 -0
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +336 -0
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +5 -1
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +11 -3
- package/src/api/blockManipulation/getBlock/getBlock.ts +141 -0
- package/src/api/blockManipulation/selections/__snapshots__/selection.test.ts.snap +660 -0
- package/src/api/blockManipulation/selections/selection.test.ts +56 -0
- package/src/api/blockManipulation/selections/selection.ts +244 -0
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +4 -0
- package/src/api/clipboard/__snapshots__/tableAllCells.html +1 -1
- package/src/api/clipboard/__snapshots__/tableCell.html +1 -1
- package/src/api/clipboard/__snapshots__/tableRow.html +1 -1
- package/src/api/clipboard/clipboard.test.ts +7 -3
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +7 -14
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +6 -6
- package/src/api/clipboard/toClipboard/copyExtension.ts +7 -2
- package/src/api/exporters/html/__snapshots__/file/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/file/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/file/noCaption/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/file/noName/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noCaption/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noName/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noPreview/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/internal.html +1 -1
- package/src/api/exporters/markdown/__snapshots__/simpleImage/basic/markdown.md +1 -1
- package/src/api/exporters/markdown/__snapshots__/simpleImage/nested/markdown.md +2 -2
- package/src/api/exporters/markdown/__snapshots__/simpleImage/noCaption/markdown.md +1 -1
- package/src/api/exporters/markdown/__snapshots__/simpleImage/noName/markdown.md +1 -1
- package/src/api/nodeUtil.ts +2 -2
- package/src/api/parsers/markdown/parseMarkdown.test.ts +5 -7
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +13 -14
- package/src/blocks/FileBlockContent/FileBlockContent.ts +5 -12
- package/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.ts +5 -0
- package/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.ts +16 -0
- package/src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts +63 -0
- package/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.ts +80 -0
- package/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.ts +24 -0
- package/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts +204 -0
- package/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.ts +13 -0
- package/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.ts +15 -0
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +20 -28
- package/src/blocks/TableBlockContent/TableExtension.ts +12 -1
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +20 -27
- package/src/editor/Block.css +35 -51
- package/src/editor/BlockNoteEditor.ts +101 -92
- package/src/editor/BlockNoteExtensions.ts +9 -8
- package/src/editor/editor.css +1 -0
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +4 -2
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +11 -8
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +11 -4
- package/src/extensions/LinkToolbar/protocols.ts +13 -0
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +29 -21
- package/src/extensions/SideMenu/SideMenuPlugin.ts +5 -1
- package/src/extensions/SideMenu/dragging.ts +8 -1
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +3 -6
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +49 -12
- package/src/i18n/locales/ru.ts +1 -1
- package/src/index.ts +9 -2
- package/src/schema/inlineContent/createSpec.ts +2 -2
- package/types/src/api/blockManipulation/commands/moveBlocks/moveBlocks.d.ts +15 -0
- package/types/src/api/blockManipulation/getBlock/getBlock.d.ts +7 -0
- package/types/src/api/blockManipulation/selections/selection.d.ts +5 -0
- package/types/src/api/blockManipulation/selections/selection.test.d.ts +1 -0
- package/types/src/api/clipboard/fromClipboard/handleVSCodePaste.d.ts +2 -3
- package/types/src/api/clipboard/fromClipboard/pasteExtension.d.ts +1 -3
- package/types/src/api/nodeUtil.d.ts +1 -1
- package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +2 -5
- package/types/src/blocks/FileBlockContent/FileBlockContent.d.ts +2 -5
- package/types/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.d.ts +3 -0
- package/types/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.d.ts +4 -0
- package/types/src/blocks/FileBlockContent/helpers/render/createAddFileButton.d.ts +6 -0
- package/types/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.d.ts +9 -0
- package/types/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.d.ts +6 -0
- package/types/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.d.ts +9 -0
- package/types/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.d.ts +3 -0
- package/types/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.d.ts +3 -0
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +2 -5
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +2 -5
- package/types/src/editor/BlockNoteEditor.d.ts +60 -14
- package/types/src/editor/BlockNoteExtensions.d.ts +1 -0
- package/types/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.d.ts +1 -0
- package/types/src/extensions/LinkToolbar/protocols.d.ts +2 -0
- package/types/src/index.d.ts +9 -2
- package/types/src/pm-nodes/BlockContainer.d.ts +2 -2
- package/types/src/pm-nodes/BlockGroup.d.ts +2 -2
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js +0 -116
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js +0 -110
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js.map +0 -1
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js +0 -317
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js.map +0 -1
- package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js.map +0 -1
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js.map +0 -1
- package/src/api/blockManipulation/commands/moveBlock/__snapshots__/moveBlock.test.ts.snap +0 -3799
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.test.ts +0 -196
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.ts +0 -176
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +0 -456
- package/types/src/api/blockManipulation/commands/moveBlock/moveBlock.d.ts +0 -5
- package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +0 -41
- /package/src/blocks/AudioBlockContent/{audioBlockHelpers.ts → parseAudioElement.ts} +0 -0
- /package/src/blocks/ImageBlockContent/{imageBlockHelpers.ts → parseImageElement.ts} +0 -0
- /package/src/blocks/VideoBlockContent/{videoBlockHelpers.ts → parseVideoElement.ts} +0 -0
- /package/types/src/api/blockManipulation/commands/{moveBlock/moveBlock.test.d.ts → moveBlocks/moveBlocks.test.d.ts} +0 -0
- /package/types/src/blocks/AudioBlockContent/{audioBlockHelpers.d.ts → parseAudioElement.d.ts} +0 -0
- /package/types/src/blocks/ImageBlockContent/{imageBlockHelpers.d.ts → parseImageElement.d.ts} +0 -0
- /package/types/src/blocks/VideoBlockContent/{videoBlockHelpers.d.ts → parseVideoElement.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseEmbedElement.js","sourceRoot":"","sources":["../../../../../../src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,YAA8B,EAAE,EAAE;IAClE,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,IAAI,SAAS,CAAC;IAE1C,OAAO,EAAE,GAAG,EAAE,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const parseFigureElement = (figureElement, targetTag) => {
|
|
2
|
+
const targetElement = figureElement.querySelector(targetTag);
|
|
3
|
+
if (!targetElement) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
const captionElement = figureElement.querySelector("figcaption");
|
|
7
|
+
const caption = captionElement?.textContent ?? undefined;
|
|
8
|
+
return { targetElement, caption };
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=parseFigureElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseFigureElement.js","sourceRoot":"","sources":["../../../../../../src/blocks/FileBlockContent/helpers/parse/parseFigureElement.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,aAA0B,EAC1B,SAAiB,EACjB,EAAE;IACF,MAAM,aAAa,GAAG,aAAa,CAAC,aAAa,CAC/C,SAAS,CACY,CAAC;IACxB,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,cAAc,GAAG,aAAa,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,cAAc,EAAE,WAAW,IAAI,SAAS,CAAC;IAEzD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;AACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const createAddFileButton = (block, editor, buttonText, buttonIcon) => {
|
|
2
|
+
const addFileButton = document.createElement("div");
|
|
3
|
+
addFileButton.className = "bn-add-file-button";
|
|
4
|
+
const addFileButtonIcon = document.createElement("div");
|
|
5
|
+
addFileButtonIcon.className = "bn-add-file-button-icon";
|
|
6
|
+
if (buttonIcon) {
|
|
7
|
+
addFileButtonIcon.appendChild(buttonIcon);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
addFileButtonIcon.innerHTML =
|
|
11
|
+
'<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>';
|
|
12
|
+
}
|
|
13
|
+
addFileButton.appendChild(addFileButtonIcon);
|
|
14
|
+
const addFileButtonText = document.createElement("p");
|
|
15
|
+
addFileButtonText.className = "bn-add-file-button-text";
|
|
16
|
+
addFileButtonText.innerHTML =
|
|
17
|
+
buttonText || editor.dictionary.file_blocks.file.add_button_text;
|
|
18
|
+
addFileButton.appendChild(addFileButtonText);
|
|
19
|
+
// Prevents focus from moving to the button.
|
|
20
|
+
const addFileButtonMouseDownHandler = (event) => {
|
|
21
|
+
event.preventDefault();
|
|
22
|
+
};
|
|
23
|
+
// Opens the file toolbar.
|
|
24
|
+
const addFileButtonClickHandler = () => {
|
|
25
|
+
editor.dispatch(editor._tiptapEditor.state.tr.setMeta(editor.filePanel.plugin, {
|
|
26
|
+
block: block,
|
|
27
|
+
}));
|
|
28
|
+
};
|
|
29
|
+
addFileButton.addEventListener("mousedown", addFileButtonMouseDownHandler, true);
|
|
30
|
+
addFileButton.addEventListener("click", addFileButtonClickHandler, true);
|
|
31
|
+
return {
|
|
32
|
+
dom: addFileButton,
|
|
33
|
+
destroy: () => {
|
|
34
|
+
addFileButton.removeEventListener("mousedown", addFileButtonMouseDownHandler, true);
|
|
35
|
+
addFileButton.removeEventListener("click", addFileButtonClickHandler, true);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=createAddFileButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAddFileButton.js","sourceRoot":"","sources":["../../../../../../src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,KAAiD,EACjD,MAAsC,EACtC,UAAmB,EACnB,UAAwB,EACxB,EAAE;IACF,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACpD,aAAa,CAAC,SAAS,GAAG,oBAAoB,CAAC;IAE/C,MAAM,iBAAiB,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACxD,iBAAiB,CAAC,SAAS,GAAG,yBAAyB,CAAC;IACxD,IAAI,UAAU,EAAE,CAAC;QACf,iBAAiB,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC5C,CAAC;SAAM,CAAC;QACN,iBAAiB,CAAC,SAAS;YACzB,qQAAqQ,CAAC;IAC1Q,CAAC;IACD,aAAa,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAE7C,MAAM,iBAAiB,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACtD,iBAAiB,CAAC,SAAS,GAAG,yBAAyB,CAAC;IACxD,iBAAiB,CAAC,SAAS;QACzB,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC;IACnE,aAAa,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAE7C,4CAA4C;IAC5C,MAAM,6BAA6B,GAAG,CAAC,KAAiB,EAAE,EAAE;QAC1D,KAAK,CAAC,cAAc,EAAE,CAAC;IACzB,CAAC,CAAC;IACF,0BAA0B;IAC1B,MAAM,yBAAyB,GAAG,GAAG,EAAE;QACrC,MAAM,CAAC,QAAQ,CACb,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,SAAU,CAAC,MAAM,EAAE;YAC9D,KAAK,EAAE,KAAK;SACb,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;IACF,aAAa,CAAC,gBAAgB,CAC5B,WAAW,EACX,6BAA6B,EAC7B,IAAI,CACL,CAAC;IACF,aAAa,CAAC,gBAAgB,CAAC,OAAO,EAAE,yBAAyB,EAAE,IAAI,CAAC,CAAC;IAEzE,OAAO;QACL,GAAG,EAAE,aAAa;QAClB,OAAO,EAAE,GAAG,EAAE;YACZ,aAAa,CAAC,mBAAmB,CAC/B,WAAW,EACX,6BAA6B,EAC7B,IAAI,CACL,CAAC;YACF,aAAa,CAAC,mBAAmB,CAC/B,OAAO,EACP,yBAAyB,EACzB,IAAI,CACL,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createAddFileButton } from "./createAddFileButton.js";
|
|
2
|
+
import { createFileNameWithIcon } from "./createFileNameWithIcon.js";
|
|
3
|
+
export const createFileBlockWrapper = (block, editor, element, buttonText, buttonIcon) => {
|
|
4
|
+
const wrapper = document.createElement("div");
|
|
5
|
+
wrapper.className = "bn-file-block-content-wrapper";
|
|
6
|
+
// Show the add file button if the file has not been uploaded yet. Change to
|
|
7
|
+
// show a loader if a file upload for the block begins.
|
|
8
|
+
if (block.props.url === "") {
|
|
9
|
+
const addFileButton = createAddFileButton(block, editor, buttonText, buttonIcon);
|
|
10
|
+
wrapper.appendChild(addFileButton.dom);
|
|
11
|
+
const destroyUploadStartHandler = editor.onUploadStart((blockId) => {
|
|
12
|
+
if (blockId === block.id) {
|
|
13
|
+
wrapper.removeChild(addFileButton.dom);
|
|
14
|
+
const loading = document.createElement("div");
|
|
15
|
+
loading.className = "bn-file-loading-preview";
|
|
16
|
+
loading.textContent = "Loading...";
|
|
17
|
+
wrapper.appendChild(loading);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
dom: wrapper,
|
|
22
|
+
destroy: () => {
|
|
23
|
+
destroyUploadStartHandler();
|
|
24
|
+
addFileButton.destroy();
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const ret = { dom: wrapper };
|
|
29
|
+
// Show the file preview, or the file name and icon.
|
|
30
|
+
if (block.props.showPreview === false || !element) {
|
|
31
|
+
// Show file name and icon.
|
|
32
|
+
const fileNameWithIcon = createFileNameWithIcon(block);
|
|
33
|
+
wrapper.appendChild(fileNameWithIcon.dom);
|
|
34
|
+
ret.destroy = () => {
|
|
35
|
+
fileNameWithIcon.destroy?.();
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// Show file preview.
|
|
40
|
+
wrapper.appendChild(element.dom);
|
|
41
|
+
}
|
|
42
|
+
// Show the caption if there is one.
|
|
43
|
+
if (block.props.caption) {
|
|
44
|
+
const caption = document.createElement("p");
|
|
45
|
+
caption.className = "bn-file-caption";
|
|
46
|
+
caption.textContent = block.props.caption;
|
|
47
|
+
wrapper.appendChild(caption);
|
|
48
|
+
}
|
|
49
|
+
return ret;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=createFileBlockWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFileBlockWrapper.js","sourceRoot":"","sources":["../../../../../../src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EA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,KAAK,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;QAClD,2BAA2B;QAC3B,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACvD,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAE1C,GAAG,CAAC,OAAO,GAAG,GAAG,EAAE;YACjB,gBAAgB,CAAC,OAAO,EAAE,EAAE,CAAC;QAC/B,CAAC,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,qBAAqB;QACrB,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED,oCAAoC;IACpC,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAC5C,OAAO,CAAC,SAAS,GAAG,iBAAiB,CAAC;QACtC,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;QAC1C,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const FILE_ICON_SVG = `<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>`;
|
|
2
|
+
export const createFileNameWithIcon = (block) => {
|
|
3
|
+
const file = document.createElement("div");
|
|
4
|
+
file.className = "bn-file-name-with-icon";
|
|
5
|
+
const icon = document.createElement("div");
|
|
6
|
+
icon.className = "bn-file-icon";
|
|
7
|
+
icon.innerHTML = FILE_ICON_SVG;
|
|
8
|
+
file.appendChild(icon);
|
|
9
|
+
const fileName = document.createElement("p");
|
|
10
|
+
fileName.className = "bn-file-name";
|
|
11
|
+
fileName.textContent = block.props.name;
|
|
12
|
+
file.appendChild(fileName);
|
|
13
|
+
return {
|
|
14
|
+
dom: file,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=createFileNameWithIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFileNameWithIcon.js","sourceRoot":"","sources":["../../../../../../src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAG,qQAAqQ,CAAC;AAEnS,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,KAAiD,EACL,EAAE;IAC9C,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC3C,IAAI,CAAC,SAAS,GAAG,wBAAwB,CAAC;IAE1C,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC3C,IAAI,CAAC,SAAS,GAAG,cAAc,CAAC;IAChC,IAAI,CAAC,SAAS,GAAG,aAAa,CAAC;IAC/B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAEvB,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC7C,QAAQ,CAAC,SAAS,GAAG,cAAc,CAAC;IACpC,QAAQ,CAAC,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;IACxC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAE3B,OAAO;QACL,GAAG,EAAE,IAAI;KACV,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { createFileBlockWrapper } from "./createFileBlockWrapper.js";
|
|
2
|
+
export const createResizableFileBlockWrapper = (block, editor, element, resizeHandlesContainerElement, buttonText, buttonIcon) => {
|
|
3
|
+
const { dom, destroy } = createFileBlockWrapper(block, editor, element, buttonText, buttonIcon);
|
|
4
|
+
const wrapper = dom;
|
|
5
|
+
if (block.props.url && block.props.showPreview) {
|
|
6
|
+
wrapper.style.width = `${block.props.previewWidth}px`;
|
|
7
|
+
}
|
|
8
|
+
const leftResizeHandle = document.createElement("div");
|
|
9
|
+
leftResizeHandle.className = "bn-resize-handle";
|
|
10
|
+
leftResizeHandle.style.left = "4px";
|
|
11
|
+
const rightResizeHandle = document.createElement("div");
|
|
12
|
+
rightResizeHandle.className = "bn-resize-handle";
|
|
13
|
+
rightResizeHandle.style.right = "4px";
|
|
14
|
+
// Temporary parameters set when the user begins resizing the element, used to
|
|
15
|
+
// calculate the new width of the element.
|
|
16
|
+
let resizeParams;
|
|
17
|
+
let width = block.props.previewWidth;
|
|
18
|
+
// Updates the element width with an updated width depending on the cursor X
|
|
19
|
+
// offset from when the resize began, and which resize handle is being used.
|
|
20
|
+
const windowMouseMoveHandler = (event) => {
|
|
21
|
+
if (!resizeParams) {
|
|
22
|
+
if (!editor.isEditable &&
|
|
23
|
+
resizeHandlesContainerElement.contains(leftResizeHandle) &&
|
|
24
|
+
resizeHandlesContainerElement.contains(rightResizeHandle)) {
|
|
25
|
+
resizeHandlesContainerElement.removeChild(leftResizeHandle);
|
|
26
|
+
resizeHandlesContainerElement.removeChild(rightResizeHandle);
|
|
27
|
+
}
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
let newWidth;
|
|
31
|
+
if (block.props.textAlignment === "center") {
|
|
32
|
+
if (resizeParams.handleUsed === "left") {
|
|
33
|
+
newWidth =
|
|
34
|
+
resizeParams.initialWidth +
|
|
35
|
+
(resizeParams.initialClientX - event.clientX) * 2;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
newWidth =
|
|
39
|
+
resizeParams.initialWidth +
|
|
40
|
+
(event.clientX - resizeParams.initialClientX) * 2;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
if (resizeParams.handleUsed === "left") {
|
|
45
|
+
newWidth =
|
|
46
|
+
resizeParams.initialWidth +
|
|
47
|
+
resizeParams.initialClientX -
|
|
48
|
+
event.clientX;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
newWidth =
|
|
52
|
+
resizeParams.initialWidth +
|
|
53
|
+
event.clientX -
|
|
54
|
+
resizeParams.initialClientX;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Min element width in px.
|
|
58
|
+
const minWidth = 64;
|
|
59
|
+
// Ensures the element is not wider than the editor and not narrower than a
|
|
60
|
+
// predetermined minimum width.
|
|
61
|
+
width = Math.max(newWidth, minWidth);
|
|
62
|
+
wrapper.style.width = `${width}px`;
|
|
63
|
+
};
|
|
64
|
+
// Stops mouse movements from resizing the element and updates the block's
|
|
65
|
+
// `width` prop to the new value.
|
|
66
|
+
const windowMouseUpHandler = (event) => {
|
|
67
|
+
// Hides the drag handles if the cursor is no longer over the element.
|
|
68
|
+
if ((!event.target ||
|
|
69
|
+
!wrapper.contains(event.target) ||
|
|
70
|
+
!editor.isEditable) &&
|
|
71
|
+
resizeHandlesContainerElement.contains(leftResizeHandle) &&
|
|
72
|
+
resizeHandlesContainerElement.contains(rightResizeHandle)) {
|
|
73
|
+
resizeHandlesContainerElement.removeChild(leftResizeHandle);
|
|
74
|
+
resizeHandlesContainerElement.removeChild(rightResizeHandle);
|
|
75
|
+
}
|
|
76
|
+
if (!resizeParams) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
resizeParams = undefined;
|
|
80
|
+
editor.updateBlock(block, {
|
|
81
|
+
props: {
|
|
82
|
+
previewWidth: width,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
// Shows the resize handles when hovering over the wrapper with the cursor.
|
|
87
|
+
const wrapperMouseEnterHandler = () => {
|
|
88
|
+
if (editor.isEditable) {
|
|
89
|
+
resizeHandlesContainerElement.appendChild(leftResizeHandle);
|
|
90
|
+
resizeHandlesContainerElement.appendChild(rightResizeHandle);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
// Hides the resize handles when the cursor leaves the wrapper, unless the
|
|
94
|
+
// cursor moves to one of the resize handles.
|
|
95
|
+
const wrapperMouseLeaveHandler = (event) => {
|
|
96
|
+
if (event.relatedTarget === leftResizeHandle ||
|
|
97
|
+
event.relatedTarget === rightResizeHandle) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (resizeParams) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (editor.isEditable &&
|
|
104
|
+
resizeHandlesContainerElement.contains(leftResizeHandle) &&
|
|
105
|
+
resizeHandlesContainerElement.contains(rightResizeHandle)) {
|
|
106
|
+
resizeHandlesContainerElement.removeChild(leftResizeHandle);
|
|
107
|
+
resizeHandlesContainerElement.removeChild(rightResizeHandle);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
// Sets the resize params, allowing the user to begin resizing the element by
|
|
111
|
+
// moving the cursor left or right.
|
|
112
|
+
const leftResizeHandleMouseDownHandler = (event) => {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
resizeParams = {
|
|
115
|
+
handleUsed: "left",
|
|
116
|
+
initialWidth: wrapper.clientWidth,
|
|
117
|
+
initialClientX: event.clientX,
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
const rightResizeHandleMouseDownHandler = (event) => {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
resizeParams = {
|
|
123
|
+
handleUsed: "right",
|
|
124
|
+
initialWidth: wrapper.clientWidth,
|
|
125
|
+
initialClientX: event.clientX,
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
window.addEventListener("mousemove", windowMouseMoveHandler);
|
|
129
|
+
window.addEventListener("mouseup", windowMouseUpHandler);
|
|
130
|
+
wrapper.addEventListener("mouseenter", wrapperMouseEnterHandler);
|
|
131
|
+
wrapper.addEventListener("mouseleave", wrapperMouseLeaveHandler);
|
|
132
|
+
leftResizeHandle.addEventListener("mousedown", leftResizeHandleMouseDownHandler);
|
|
133
|
+
rightResizeHandle.addEventListener("mousedown", rightResizeHandleMouseDownHandler);
|
|
134
|
+
return {
|
|
135
|
+
dom: wrapper,
|
|
136
|
+
destroy: () => {
|
|
137
|
+
destroy?.();
|
|
138
|
+
window.removeEventListener("mousemove", windowMouseMoveHandler);
|
|
139
|
+
window.removeEventListener("mouseup", windowMouseUpHandler);
|
|
140
|
+
wrapper.removeEventListener("mouseenter", wrapperMouseEnterHandler);
|
|
141
|
+
wrapper.removeEventListener("mouseleave", wrapperMouseLeaveHandler);
|
|
142
|
+
leftResizeHandle.removeEventListener("mousedown", leftResizeHandleMouseDownHandler);
|
|
143
|
+
rightResizeHandle.removeEventListener("mousedown", rightResizeHandleMouseDownHandler);
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=createResizableFileBlockWrapper.js.map
|
package/dist/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createResizableFileBlockWrapper.js","sourceRoot":"","sources":["../../../../../../src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC7C,KAAiD,EACjD,MAAsC,EACtC,OAAmD,EACnD,6BAA0C,EAC1C,UAAkB,EAClB,UAAuB,EACoB,EAAE;IAC7C,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,sBAAsB,CAC7C,KAAK,EACL,MAAM,EACN,OAAO,EACP,UAAU,EACV,UAAU,CACX,CAAC;IACF,MAAM,OAAO,GAAG,GAAG,CAAC;IACpB,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,K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
+
const captionElement = document.createElement("figcaption");
|
|
4
|
+
captionElement.textContent = caption;
|
|
5
|
+
figure.appendChild(element);
|
|
6
|
+
figure.appendChild(captionElement);
|
|
7
|
+
return { dom: figure };
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=createFigureWithCaption.js.map
|
package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFigureWithCaption.js","sourceRoot":"","sources":["../../../../../../src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,OAAoB,EACpB,OAAe,EACf,EAAE;IACF,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,cAAc,GAAG,QAAQ,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IAC5D,cAAc,CAAC,WAAW,GAAG,OAAO,CAAC;IAErC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5B,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAEnC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;AACzB,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const createLinkWithCaption = (element, caption) => {
|
|
2
|
+
const wrapper = document.createElement("div");
|
|
3
|
+
const fileCaption = document.createElement("p");
|
|
4
|
+
fileCaption.textContent = caption;
|
|
5
|
+
wrapper.appendChild(element);
|
|
6
|
+
wrapper.appendChild(fileCaption);
|
|
7
|
+
return {
|
|
8
|
+
dom: wrapper,
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=createLinkWithCaption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createLinkWithCaption.js","sourceRoot":"","sources":["../../../../../../src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,OAAoB,EACpB,OAAe,EACf,EAAE;IACF,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAChD,WAAW,CAAC,WAAW,GAAG,OAAO,CAAC;IAElC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7B,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAEjC,OAAO;QACL,GAAG,EAAE,OAAO;KACb,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createBlockSpec, } from "../../schema/index.js";
|
|
2
2
|
import { defaultProps } from "../defaultProps.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { parseFigureElement } from "../FileBlockContent/helpers/parse/parseFigureElement.js";
|
|
4
|
+
import { createFigureWithCaption } from "../FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js";
|
|
5
|
+
import { createLinkWithCaption } from "../FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js";
|
|
6
|
+
import { createResizableFileBlockWrapper } from "../FileBlockContent/helpers/render/createResizableFileBlockWrapper.js";
|
|
7
|
+
import { parseImageElement } from "./parseImageElement.js";
|
|
5
8
|
export const FILE_IMAGE_ICON_SVG = '<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>';
|
|
6
9
|
export const imagePropSchema = {
|
|
7
10
|
textAlignment: defaultProps.textAlignment,
|
|
@@ -36,18 +39,23 @@ export const imageBlockConfig = {
|
|
|
36
39
|
export const imageRender = (block, editor) => {
|
|
37
40
|
const icon = document.createElement("div");
|
|
38
41
|
icon.innerHTML = FILE_IMAGE_ICON_SVG;
|
|
42
|
+
const imageWrapper = document.createElement("div");
|
|
43
|
+
imageWrapper.className = "bn-visual-media-wrapper";
|
|
39
44
|
const image = document.createElement("img");
|
|
40
45
|
image.className = "bn-visual-media";
|
|
41
|
-
editor.resolveFileUrl
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
if (editor.resolveFileUrl) {
|
|
47
|
+
editor.resolveFileUrl(block.props.url).then((downloadUrl) => {
|
|
48
|
+
image.src = downloadUrl;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
image.src = block.props.url;
|
|
53
|
+
}
|
|
44
54
|
image.alt = block.props.name || block.props.caption || "BlockNote image";
|
|
45
55
|
image.contentEditable = "false";
|
|
46
56
|
image.draggable = false;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const element = createFileAndCaptionWrapper(block, file.dom);
|
|
50
|
-
return createFileBlockWrapper(block, editor, element, editor.dictionary.file_blocks.image.add_button_text, icon.firstElementChild);
|
|
57
|
+
imageWrapper.appendChild(image);
|
|
58
|
+
return createResizableFileBlockWrapper(block, editor, { dom: imageWrapper }, imageWrapper, editor.dictionary.file_blocks.image.add_button_text, icon.firstElementChild);
|
|
51
59
|
};
|
|
52
60
|
export const imageParse = (element) => {
|
|
53
61
|
if (element.tagName === "IMG") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageBlockContent.js","sourceRoot":"","sources":["../../../../src/blocks/ImageBlockContent/ImageBlockContent.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,eAAe,GAIhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"ImageBlockContent.js","sourceRoot":"","sources":["../../../../src/blocks/ImageBlockContent/ImageBlockContent.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,eAAe,GAIhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yDAAyD,CAAC;AAC7F,OAAO,EAAE,uBAAuB,EAAE,MAAM,uEAAuE,CAAC;AAChH,OAAO,EAAE,qBAAqB,EAAE,MAAM,qEAAqE,CAAC;AAC5G,OAAO,EAAE,+BAA+B,EAAE,MAAM,uEAAuE,CAAC;AACxH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,CAAC,MAAM,mBAAmB,GAC9B,gaAAga,CAAC;AAEna,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,aAAa,EAAE,YAAY,CAAC,aAAa;IACzC,eAAe,EAAE,YAAY,CAAC,eAAe;IAC7C,aAAa;IACb,IAAI,EAAE;QACJ,OAAO,EAAE,EAAW;KACrB;IACD,YAAY;IACZ,GAAG,EAAE;QACH,OAAO,EAAE,EAAW;KACrB;IACD,gBAAgB;IAChB,OAAO,EAAE;QACP,OAAO,EAAE,EAAW;KACrB;IAED,WAAW,EAAE;QACX,OAAO,EAAE,IAAI;KACd;IACD,4BAA4B;IAC5B,YAAY,EAAE;QACZ,OAAO,EAAE,GAAG;KACb;CACmB,CAAC;AAEvB,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,OAAgB;IACtB,UAAU,EAAE,eAAe;IAC3B,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,IAAI;IACjB,eAAe,EAAE,CAAC,SAAS,CAAC;CACH,CAAC;AAE5B,MAAM,CAAC,MAAM,WAAW,GAAG,C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AC,CAAC;QACpC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;QAC7B,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;IAC1D,CAAC;IAED,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACxB,IAAI,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YAC5B,OAAO,uBAAuB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7D,CAAC;aAAM,CAAC;YACN,OAAO,qBAAqB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG,EAAE,KAAK;KACX,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC,gBAAgB,EAAE;IAC1D,MAAM,EAAE,WAAW;IACnB,KAAK,EAAE,UAAU;IACjB,cAAc,EAAE,mBAAmB;CACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseImageElement.js","sourceRoot":"","sources":["../../../../src/blocks/ImageBlockContent/parseImageElement.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,YAA8B,EAAE,EAAE;IAClE,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,IAAI,SAAS,CAAC;IAC1C,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,IAAI,SAAS,CAAC;IAErD,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC;AAC/B,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { callOrReturn, Extension, getExtensionField } from "@tiptap/core";
|
|
2
|
-
import { columnResizing, tableEditing } from "prosemirror-tables";
|
|
2
|
+
import { columnResizing, goToNextCell, tableEditing } from "prosemirror-tables";
|
|
3
3
|
export const RESIZE_MIN_WIDTH = 35;
|
|
4
4
|
export const EMPTY_CELL_WIDTH = 120;
|
|
5
5
|
export const EMPTY_CELL_HEIGHT = 31;
|
|
@@ -41,6 +41,13 @@ export const TableExtension = Extension.create({
|
|
|
41
41
|
selectionIsAtStartOfNode &&
|
|
42
42
|
selectionIsInTableParagraphNode);
|
|
43
43
|
},
|
|
44
|
+
// Enables navigating cells using the tab key.
|
|
45
|
+
Tab: () => {
|
|
46
|
+
return this.editor.commands.command(({ state, dispatch, view }) => goToNextCell(1)(state, dispatch, view));
|
|
47
|
+
},
|
|
48
|
+
"Shift-Tab": () => {
|
|
49
|
+
return this.editor.commands.command(({ state, dispatch, view }) => goToNextCell(-1)(state, dispatch, view));
|
|
50
|
+
},
|
|
44
51
|
};
|
|
45
52
|
},
|
|
46
53
|
extendNodeSchema(extension) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableExtension.js","sourceRoot":"","sources":["../../../../src/blocks/TableBlockContent/TableExtension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"TableExtension.js","sourceRoot":"","sources":["../../../../src/blocks/TableBlockContent/TableExtension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEhF,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,MAAM,CAAC,MAAM,iBAAiB,GAAG,E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BACR,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,CAChE,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,CACvC,CAAC;YACJ,CAAC;YACD,WAAW,EAAE,GAAG,EAAE;gBAChB,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,CAChE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,CACxC,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC;IAED,gBAAgB,CAAC,SAAS;QACxB,MAAM,OAAO,GAAG;YACd,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,OAAO,EAAE,SAAS,CAAC,OAAO;SAC3B,CAAC;QAEF,OAAO;YACL,SAAS,EAAE,YAAY,CACrB,iBAAiB,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,CACnD;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createBlockSpec, } from "../../schema/index.js";
|
|
2
2
|
import { defaultProps } from "../defaultProps.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { parseFigureElement } from "../FileBlockContent/helpers/parse/parseFigureElement.js";
|
|
4
|
+
import { createFigureWithCaption } from "../FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js";
|
|
5
|
+
import { createLinkWithCaption } from "../FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js";
|
|
6
|
+
import { createResizableFileBlockWrapper } from "../FileBlockContent/helpers/render/createResizableFileBlockWrapper.js";
|
|
7
|
+
import { parseVideoElement } from "./parseVideoElement.js";
|
|
5
8
|
export const FILE_VIDEO_ICON_SVG = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z"></path></svg>';
|
|
6
9
|
export const videoPropSchema = {
|
|
7
10
|
textAlignment: defaultProps.textAlignment,
|
|
@@ -36,16 +39,24 @@ export const videoBlockConfig = {
|
|
|
36
39
|
export const videoRender = (block, editor) => {
|
|
37
40
|
const icon = document.createElement("div");
|
|
38
41
|
icon.innerHTML = FILE_VIDEO_ICON_SVG;
|
|
42
|
+
const videoWrapper = document.createElement("div");
|
|
43
|
+
videoWrapper.className = "bn-visual-media-wrapper";
|
|
39
44
|
const video = document.createElement("video");
|
|
40
45
|
video.className = "bn-visual-media";
|
|
41
|
-
|
|
46
|
+
if (editor.resolveFileUrl) {
|
|
47
|
+
editor.resolveFileUrl(block.props.url).then((downloadUrl) => {
|
|
48
|
+
video.src = downloadUrl;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
video.src = block.props.url;
|
|
53
|
+
}
|
|
42
54
|
video.controls = true;
|
|
43
55
|
video.contentEditable = "false";
|
|
44
56
|
video.draggable = false;
|
|
45
|
-
video.width =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return createFileBlockWrapper(block, editor, element, editor.dictionary.file_blocks.video.add_button_text, icon.firstElementChild);
|
|
57
|
+
video.width = block.props.previewWidth;
|
|
58
|
+
videoWrapper.appendChild(video);
|
|
59
|
+
return createResizableFileBlockWrapper(block, editor, { dom: videoWrapper }, videoWrapper, editor.dictionary.file_blocks.video.add_button_text, icon.firstElementChild);
|
|
49
60
|
};
|
|
50
61
|
export const videoParse = (element) => {
|
|
51
62
|
if (element.tagName === "VIDEO") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoBlockContent.js","sourceRoot":"","sources":["../../../../src/blocks/VideoBlockContent/VideoBlockContent.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,eAAe,GAIhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"VideoBlockContent.js","sourceRoot":"","sources":["../../../../src/blocks/VideoBlockContent/VideoBlockContent.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,eAAe,GAIhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yDAAyD,CAAC;AAC7F,OAAO,EAAE,uBAAuB,EAAE,MAAM,uEAAuE,CAAC;AAChH,OAAO,EAAE,qBAAqB,EAAE,MAAM,qEAAqE,CAAC;AAC5G,OAAO,EAAE,+BAA+B,EAAE,MAAM,uEAAuE,CAAC;AACxH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,CAAC,MAAM,mBAAmB,GAC9B,8ZAA8Z,CAAC;AAEja,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,aAAa,EAAE,YAAY,CAAC,aAAa;IACzC,eAAe,EAAE,YAAY,CAAC,eAAe;IAC7C,aAAa;IACb,IAAI,EAAE;QACJ,OAAO,EAAE,EAAW;KACrB;IACD,YAAY;IACZ,GAAG,EAAE;QACH,OAAO,EAAE,EAAW;KACrB;IACD,gBAAgB;IAChB,OAAO,EAAE;QACP,OAAO,EAAE,EAAW;KACrB;IAED,WAAW,EAAE;QACX,OAAO,EAAE,IAAI;K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