@blocknote/core 0.47.3 → 0.48.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.
Files changed (121) hide show
  1. package/dist/BlockNoteExtension-B6RhuQ3V.js +27 -0
  2. package/dist/BlockNoteExtension-B6RhuQ3V.js.map +1 -0
  3. package/dist/BlockNoteExtension-ab0REuob.cjs +2 -0
  4. package/dist/BlockNoteExtension-ab0REuob.cjs.map +1 -0
  5. package/dist/EventEmitter-CuPnGDYt.js +22 -0
  6. package/dist/EventEmitter-CuPnGDYt.js.map +1 -0
  7. package/dist/EventEmitter-DHdSnYCD.cjs +2 -0
  8. package/dist/EventEmitter-DHdSnYCD.cjs.map +1 -0
  9. package/dist/ShowSelection-BsHFfdMi.js +29 -0
  10. package/dist/ShowSelection-BsHFfdMi.js.map +1 -0
  11. package/dist/ShowSelection-DhXglbt8.cjs +2 -0
  12. package/dist/ShowSelection-DhXglbt8.cjs.map +1 -0
  13. package/dist/blocknote.cjs +1 -5
  14. package/dist/blocknote.js +7 -4256
  15. package/dist/blocks-BEvIOzln.cjs +11 -0
  16. package/dist/blocks-BEvIOzln.cjs.map +1 -0
  17. package/dist/blocks-DYl7UTS4.js +3313 -0
  18. package/dist/blocks-DYl7UTS4.js.map +1 -0
  19. package/dist/blocks.cjs +1 -2
  20. package/dist/blocks.js +2 -74
  21. package/dist/comments.cjs +2 -2
  22. package/dist/comments.cjs.map +1 -1
  23. package/dist/comments.js +604 -900
  24. package/dist/comments.js.map +1 -1
  25. package/dist/en-C4ykW581.cjs +2 -0
  26. package/dist/en-C4ykW581.cjs.map +1 -0
  27. package/dist/en-QsSI16s5.js +453 -0
  28. package/dist/en-QsSI16s5.js.map +1 -0
  29. package/dist/extensions-3nf9PPhA.js +1495 -0
  30. package/dist/extensions-3nf9PPhA.js.map +1 -0
  31. package/dist/extensions-D9y6evn6.cjs +2 -0
  32. package/dist/extensions-D9y6evn6.cjs.map +1 -0
  33. package/dist/extensions.cjs +1 -2
  34. package/dist/extensions.js +4 -36
  35. package/dist/locales.cjs +2 -2
  36. package/dist/locales.cjs.map +1 -1
  37. package/dist/locales.js +10049 -9111
  38. package/dist/locales.js.map +1 -1
  39. package/dist/src-BKJH7Jla.cjs +5 -0
  40. package/dist/src-BKJH7Jla.cjs.map +1 -0
  41. package/dist/src-Hjv1f5lc.js +2386 -0
  42. package/dist/src-Hjv1f5lc.js.map +1 -0
  43. package/dist/style.css +2 -1
  44. package/dist/webpack-stats.json +1 -1
  45. package/dist/yjs.cjs +2 -2
  46. package/dist/yjs.cjs.map +1 -1
  47. package/dist/yjs.js +20 -38
  48. package/dist/yjs.js.map +1 -1
  49. package/package.json +8 -8
  50. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +15 -1
  51. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +5 -0
  52. package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +1095 -0
  53. package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +661 -0
  54. package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +128 -11
  55. package/src/blocks/File/helpers/render/createResizableFileBlockWrapper.ts +17 -23
  56. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +346 -0
  57. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +143 -71
  58. package/src/editor/Block.css +5 -8
  59. package/src/editor/BlockNoteEditor.ts +38 -1
  60. package/src/editor/editor.css +0 -20
  61. package/src/editor/managers/ExtensionManager/extensions.ts +12 -1
  62. package/src/editor/performance.test.ts +134 -0
  63. package/src/extensions/Collaboration/ForkYDoc.test.ts +115 -103
  64. package/src/extensions/Placeholder/Placeholder.ts +1 -1
  65. package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +86 -0
  66. package/src/extensions/PreviousBlockType/PreviousBlockType.ts +33 -49
  67. package/src/extensions/SideMenu/SideMenu.ts +14 -8
  68. package/src/extensions/TableHandles/TableHandles.ts +14 -0
  69. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +57 -17
  70. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +9 -8
  71. package/src/index.ts +1 -1
  72. package/src/schema/blocks/createSpec.ts +6 -2
  73. package/src/schema/inlineContent/types.ts +0 -1
  74. package/src/vite-env.d.ts +6 -0
  75. package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +14 -1
  76. package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.test.d.ts +1 -0
  77. package/types/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.d.ts +1 -0
  78. package/types/src/editor/BlockNoteEditor.d.ts +13 -0
  79. package/types/src/editor/performance.test.d.ts +1 -0
  80. package/types/src/extensions/PreviousBlockType/PreviousBlockType.test.d.ts +1 -0
  81. package/types/src/extensions/SideMenu/SideMenu.d.ts +6 -0
  82. package/types/src/extensions/TableHandles/TableHandles.d.ts +6 -0
  83. package/dist/BlockNoteExtension-BWw0r8Gy.cjs +0 -2
  84. package/dist/BlockNoteExtension-BWw0r8Gy.cjs.map +0 -1
  85. package/dist/BlockNoteExtension-C2X7LW-V.js +0 -25
  86. package/dist/BlockNoteExtension-C2X7LW-V.js.map +0 -1
  87. package/dist/BlockNoteSchema-CCs_V3lo.cjs +0 -2
  88. package/dist/BlockNoteSchema-CCs_V3lo.cjs.map +0 -1
  89. package/dist/BlockNoteSchema-ooiKsd5B.js +0 -270
  90. package/dist/BlockNoteSchema-ooiKsd5B.js.map +0 -1
  91. package/dist/EventEmitter-CLwfmbqG.cjs +0 -2
  92. package/dist/EventEmitter-CLwfmbqG.cjs.map +0 -1
  93. package/dist/EventEmitter-CjSwpTbz.js +0 -27
  94. package/dist/EventEmitter-CjSwpTbz.js.map +0 -1
  95. package/dist/ShowSelection-B0ch3unP.js +0 -51
  96. package/dist/ShowSelection-B0ch3unP.js.map +0 -1
  97. package/dist/ShowSelection-BxnbRvy4.cjs +0 -2
  98. package/dist/ShowSelection-BxnbRvy4.cjs.map +0 -1
  99. package/dist/TrailingNode-GzE59m_7.js +0 -2288
  100. package/dist/TrailingNode-GzE59m_7.js.map +0 -1
  101. package/dist/TrailingNode-n0WdMPUl.cjs +0 -2
  102. package/dist/TrailingNode-n0WdMPUl.cjs.map +0 -1
  103. package/dist/blockToNode-BNoNIXU7.js +0 -1140
  104. package/dist/blockToNode-BNoNIXU7.js.map +0 -1
  105. package/dist/blockToNode-CumVjgem.cjs +0 -7
  106. package/dist/blockToNode-CumVjgem.cjs.map +0 -1
  107. package/dist/blocknote.cjs.map +0 -1
  108. package/dist/blocknote.js.map +0 -1
  109. package/dist/blocks.cjs.map +0 -1
  110. package/dist/blocks.js.map +0 -1
  111. package/dist/defaultBlocks-Dg9kQWXm.cjs +0 -6
  112. package/dist/defaultBlocks-Dg9kQWXm.cjs.map +0 -1
  113. package/dist/defaultBlocks-ZzGbYgQn.js +0 -3284
  114. package/dist/defaultBlocks-ZzGbYgQn.js.map +0 -1
  115. package/dist/en-Cl87Uuyf.cjs +0 -2
  116. package/dist/en-Cl87Uuyf.cjs.map +0 -1
  117. package/dist/en-njEqD7AG.js +0 -408
  118. package/dist/en-njEqD7AG.js.map +0 -1
  119. package/dist/extensions.cjs.map +0 -1
  120. package/dist/extensions.js.map +0 -1
  121. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -9,7 +9,11 @@ import {
9
9
  getPrevBlockInfo,
10
10
  mergeBlocksCommand,
11
11
  } from "../../../api/blockManipulation/commands/mergeBlocks/mergeBlocks.js";
12
- import { nestBlock } from "../../../api/blockManipulation/commands/nestBlock/nestBlock.js";
12
+ import {
13
+ liftItem,
14
+ nestBlock,
15
+ unnestBlock,
16
+ } from "../../../api/blockManipulation/commands/nestBlock/nestBlock.js";
13
17
  import { fixColumnList } from "../../../api/blockManipulation/commands/replaceBlocks/util/fixColumnList.js";
14
18
  import { splitBlockCommand } from "../../../api/blockManipulation/commands/splitBlock/splitBlock.js";
15
19
  import { updateBlockCommand } from "../../../api/blockManipulation/commands/updateBlock/updateBlock.js";
@@ -63,7 +67,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
63
67
  }),
64
68
  // Removes a level of nesting if the block is indented if the selection is at the start of the block.
65
69
  () =>
66
- commands.command(({ state }) => {
70
+ commands.command(({ state, tr }) => {
67
71
  const blockInfo = getBlockInfoFromSelection(state);
68
72
  if (!blockInfo.isBlockContainer) {
69
73
  return false;
@@ -74,7 +78,11 @@ export const KeyboardShortcutsExtension = Extension.create<{
74
78
  state.selection.from === blockContent.beforePos + 1;
75
79
 
76
80
  if (selectionAtBlockStart) {
77
- return commands.liftListItem("blockContainer");
81
+ return liftItem(
82
+ tr,
83
+ tr.doc.type.schema.nodes["blockContainer"],
84
+ tr.doc.type.schema.nodes["blockGroup"],
85
+ );
78
86
  }
79
87
 
80
88
  return false;
@@ -128,6 +136,13 @@ export const KeyboardShortcutsExtension = Extension.create<{
128
136
  return false;
129
137
  }
130
138
 
139
+ const selectionAtBlockStart =
140
+ state.selection.from ===
141
+ blockInfo.blockContent.beforePos + 1;
142
+ if (!selectionAtBlockStart) {
143
+ return false;
144
+ }
145
+
131
146
  const prevBlockInfo = getPrevBlockInfo(
132
147
  state.doc,
133
148
  blockInfo.bnBlock.beforePos,
@@ -226,13 +241,26 @@ export const KeyboardShortcutsExtension = Extension.create<{
226
241
  state.doc,
227
242
  blockInfo.bnBlock.beforePos,
228
243
  );
229
- if (!prevBlockInfo || !prevBlockInfo.isBlockContainer) {
244
+ if (!prevBlockInfo) {
245
+ return false;
246
+ }
247
+ const bottomNestedPrevBlockInfo = getBottomNestedBlockInfo(
248
+ state.doc,
249
+ prevBlockInfo,
250
+ );
251
+ if (!bottomNestedPrevBlockInfo.isBlockContainer) {
252
+ return false;
253
+ }
254
+ if (
255
+ !bottomNestedPrevBlockInfo ||
256
+ !bottomNestedPrevBlockInfo.isBlockContainer
257
+ ) {
230
258
  return false;
231
259
  }
232
260
 
233
261
  let chainedCommands = chain();
234
262
 
235
- // Moves the children of the current block to the previous one.
263
+ // Moves the children the current block.
236
264
  if (blockInfo.childContainer) {
237
265
  chainedCommands.insertContentAt(
238
266
  blockInfo.bnBlock.afterPos,
@@ -241,8 +269,8 @@ export const KeyboardShortcutsExtension = Extension.create<{
241
269
  }
242
270
 
243
271
  if (
244
- prevBlockInfo.blockContent.node.type.spec.content ===
245
- "tableRow+"
272
+ bottomNestedPrevBlockInfo.blockContent.node.type.spec
273
+ .content === "tableRow+"
246
274
  ) {
247
275
  const tableBlockEndPos = blockInfo.bnBlock.beforePos - 1;
248
276
  const tableBlockContentEndPos = tableBlockEndPos - 1;
@@ -254,17 +282,18 @@ export const KeyboardShortcutsExtension = Extension.create<{
254
282
  lastCellParagraphEndPos,
255
283
  );
256
284
  } else if (
257
- prevBlockInfo.blockContent.node.type.spec.content === ""
285
+ bottomNestedPrevBlockInfo.blockContent.node.type.spec
286
+ .content === ""
258
287
  ) {
259
288
  chainedCommands = chainedCommands.setNodeSelection(
260
- prevBlockInfo.blockContent.beforePos,
289
+ bottomNestedPrevBlockInfo.blockContent.beforePos,
261
290
  );
262
291
  } else {
263
- const blockContentStartPos =
264
- prevBlockInfo.blockContent.afterPos - 1;
292
+ const blockContentEndPos =
293
+ bottomNestedPrevBlockInfo.blockContent.afterPos - 1;
265
294
 
266
295
  chainedCommands =
267
- chainedCommands.setTextSelection(blockContentStartPos);
296
+ chainedCommands.setTextSelection(blockContentEndPos);
268
297
  }
269
298
 
270
299
  return chainedCommands
@@ -440,8 +469,8 @@ export const KeyboardShortcutsExtension = Extension.create<{
440
469
 
441
470
  return false;
442
471
  }),
443
- // If the previous block is a columnList, moves the current block to
444
- // the end of the last column in it.
472
+ // If the next block is a columnList, moves the first block from its
473
+ // first column to after the current block.
445
474
  () =>
446
475
  commands.command(({ state, tr, dispatch }) => {
447
476
  const blockInfo = getBlockInfoFromSelection(state);
@@ -449,6 +478,13 @@ export const KeyboardShortcutsExtension = Extension.create<{
449
478
  return false;
450
479
  }
451
480
 
481
+ const selectionAtBlockEnd =
482
+ state.selection.from ===
483
+ blockInfo.blockContent.afterPos - 1;
484
+ if (!selectionAtBlockEnd) {
485
+ return false;
486
+ }
487
+
452
488
  const nextBlockInfo = getNextBlockInfo(
453
489
  state.doc,
454
490
  blockInfo.bnBlock.beforePos,
@@ -734,7 +770,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
734
770
  // Removes a level of nesting if the block is empty & indented, while the selection is also empty & at the start
735
771
  // of the block.
736
772
  () =>
737
- commands.command(({ state }) => {
773
+ commands.command(({ state, tr }) => {
738
774
  const blockInfo = getBlockInfoFromSelection(state);
739
775
  if (!blockInfo.isBlockContainer) {
740
776
  return false;
@@ -756,7 +792,11 @@ export const KeyboardShortcutsExtension = Extension.create<{
756
792
  blockEmpty &&
757
793
  blockIndented
758
794
  ) {
759
- return commands.liftListItem("blockContainer");
795
+ return liftItem(
796
+ tr,
797
+ tr.doc.type.schema.nodes["blockContainer"],
798
+ tr.doc.type.schema.nodes["blockGroup"],
799
+ );
760
800
  }
761
801
 
762
802
  return false;
@@ -926,7 +966,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
926
966
  // don't handle tabs if a toolbar is shown, so we can tab into / out of it
927
967
  return false;
928
968
  }
929
- return this.editor.commands.liftListItem("blockContainer");
969
+ return unnestBlock(this.options.editor);
930
970
  },
931
971
  "Shift-Mod-ArrowUp": () => {
932
972
  this.options.editor.moveBlocksUp();
@@ -51,6 +51,9 @@ const UniqueID = Extension.create({
51
51
  attributeName: "id",
52
52
  types: [],
53
53
  setIdAttribute: false,
54
+ isWithinEditor: undefined as
55
+ | ((element: Element) => boolean)
56
+ | undefined,
54
57
  generateID: () => {
55
58
  // Use mock ID if tests are running.
56
59
  if (typeof window !== "undefined" && (window as any).__TEST_OPTIONS) {
@@ -128,6 +131,7 @@ const UniqueID = Extension.create({
128
131
  // view.dispatch(tr);
129
132
  // },
130
133
  addProseMirrorPlugins() {
134
+ const { isWithinEditor } = this.options;
131
135
  let dragSourceElement: any = null;
132
136
  let transformPasted = false;
133
137
  return [
@@ -228,14 +232,11 @@ const UniqueID = Extension.create({
228
232
  // we register a global drag handler to track the current drag source element
229
233
  view(view) {
230
234
  const handleDragstart = (event: any) => {
231
- let _a;
232
- dragSourceElement = (
233
- (_a = view.dom.parentElement) === null || _a === void 0
234
- ? void 0
235
- : _a.contains(event.target)
236
- )
237
- ? view.dom.parentElement
238
- : null;
235
+ const editorParent = view.dom.parentElement;
236
+ const isFromEditor =
237
+ editorParent?.contains(event.target) ||
238
+ isWithinEditor?.(event.target);
239
+ dragSourceElement = isFromEditor ? editorParent : null;
239
240
  };
240
241
  window.addEventListener("dragstart", handleDragstart);
241
242
  return {
package/src/index.ts CHANGED
@@ -29,7 +29,7 @@ export type { CodeBlockOptions } from "./blocks/Code/block.js";
29
29
  export { assertEmpty, UnreachableCaseError } from "./util/typescript.js";
30
30
 
31
31
  export * from "./util/EventEmitter.js";
32
- // for testing from react (TODO: move):
32
+ // for testing from react (TODO: move)
33
33
  // Unit testing
34
34
  export { selectedFragmentToHTML } from "./api/clipboard/toClipboard/copyExtension.js";
35
35
 
@@ -211,15 +211,19 @@ export function addNodeAndExtensionsToSpec<
211
211
  editor as any,
212
212
  );
213
213
 
214
+ // Cast needed because render returns `dom: HTMLElement | DocumentFragment`
215
+ // but tiptap's NodeView expects `dom: HTMLElement`
216
+ const typedNodeView = nodeView as unknown as NodeView;
217
+
214
218
  if (blockImplementation.meta?.selectable === false) {
215
- applyNonSelectableBlockFix(nodeView, this.editor);
219
+ applyNonSelectableBlockFix(typedNodeView, this.editor);
216
220
  }
217
221
 
218
222
  // See explanation for why `update` is not implemented for NodeViews
219
223
  // https://github.com/TypeCellOS/BlockNote/pull/1904#discussion_r2313461464
220
224
  // TODO: in a future version, we might want to implement updates so that
221
225
  // vanilla blocks don't always re-render entirely (https://github.com/TypeCellOS/BlockNote/issues/220)
222
- return nodeView;
226
+ return typedNodeView;
223
227
  };
224
228
  },
225
229
  });
@@ -15,7 +15,6 @@ export type InlineContentConfig = CustomInlineContentConfig | "text" | "link";
15
15
 
16
16
  // InlineContentImplementation contains the "implementation" info about an InlineContent element
17
17
  // such as the functions / Nodes required to render and / or serialize it
18
- // @ts-ignore
19
18
  export type InlineContentImplementation<T extends InlineContentConfig> =
20
19
  T extends "link" | "text"
21
20
  ? undefined
package/src/vite-env.d.ts CHANGED
@@ -1 +1,7 @@
1
1
  /// <reference types="vite/client" />
2
+
3
+ declare const process: {
4
+ env: {
5
+ NODE_ENV: string;
6
+ };
7
+ };
@@ -1,5 +1,18 @@
1
+ import { NodeType } from "prosemirror-model";
2
+ import { Transaction } from "prosemirror-state";
1
3
  import { BlockNoteEditor } from "../../../../editor/BlockNoteEditor.js";
2
4
  export declare function nestBlock(editor: BlockNoteEditor<any, any, any>): boolean;
3
- export declare function unnestBlock(editor: BlockNoteEditor<any, any, any>): void;
5
+ /**
6
+ * Modified version of prosemirror-schema-list's liftListItem.
7
+ * https://github.com/ProseMirror/prosemirror-schema-list/blob/master/src/schema-list.ts
8
+ *
9
+ * Changes from the original:
10
+ * 1. Range predicate checks node.type instead of firstChild.type (same as sinkItem)
11
+ * 2. Passes groupType to liftToOuterList
12
+ * 3. Operates on Transaction directly instead of state+dispatch
13
+ * 4. Skips liftOutOfList (root-level blocks can't be unnested in BlockNote)
14
+ */
15
+ export declare function liftItem(tr: Transaction, itemType: NodeType, groupType: NodeType): boolean;
16
+ export declare function unnestBlock(editor: BlockNoteEditor<any, any, any>): boolean;
4
17
  export declare function canNestBlock(editor: BlockNoteEditor<any, any, any>): boolean;
5
18
  export declare function canUnnestBlock(editor: BlockNoteEditor<any, any, any>): boolean;
@@ -367,6 +367,19 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
367
367
  */
368
368
  get prosemirrorView(): import("prosemirror-view").EditorView;
369
369
  get domElement(): HTMLDivElement | undefined;
370
+ private _portalElement;
371
+ /**
372
+ * The portal container element at `document.body` used by floating UI
373
+ * elements (menus, toolbars) to escape overflow:hidden ancestors.
374
+ * Set by BlockNoteView; undefined in headless mode.
375
+ */
376
+ get portalElement(): HTMLElement;
377
+ /**
378
+ * Checks whether a DOM element belongs to this editor — either inside the
379
+ * editor's DOM tree or inside its portal container (used for floating UI
380
+ * elements like menus and toolbars).
381
+ */
382
+ isWithinEditor: (element: Element) => boolean;
370
383
  isFocused(): boolean;
371
384
  get headless(): boolean;
372
385
  /**
@@ -0,0 +1 @@
1
+ export {};
@@ -125,4 +125,10 @@ export declare const SideMenuExtension: (options?: any) => import("../../index.j
125
125
  * mouse cursor.
126
126
  */
127
127
  readonly unfreezeMenu: () => void;
128
+ /**
129
+ * Hides the side menu unless it is currently frozen (e.g. the drag
130
+ * handle menu is open). Used to dismiss the menu on scroll without
131
+ * interfering with open submenus.
132
+ */
133
+ readonly hideMenuIfNotFrozen: () => void;
128
134
  }>;
@@ -76,6 +76,12 @@ export declare const TableHandlesExtension: (options?: any) => import("../../ind
76
76
  * same cell regardless of which cell is hovered by the mouse cursor.
77
77
  */
78
78
  readonly unfreezeHandles: () => void;
79
+ /**
80
+ * Hides the table handles unless they are currently frozen (e.g. a
81
+ * handle menu is open). Used to dismiss the handles on scroll without
82
+ * interfering with open submenus.
83
+ */
84
+ readonly hideHandlesIfNotFrozen: () => void;
79
85
  readonly getCellsAtRowHandle: (block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, relativeRowIndex: RelativeCellIndices["row"]) => (RelativeCellIndices & {
80
86
  cell: import("../../index.js").TableCell<any, any>;
81
87
  })[];
@@ -1,2 +0,0 @@
1
- "use strict";const c=require("@tanstack/store"),e=Symbol("originalFactory");function u(t){if(typeof t=="object"&&"key"in t)return function n(){return t[e]=n,t};if(typeof t!="function")throw new Error("factory must be a function");return function n(o){return i=>{const r=t({editor:i.editor,options:o});return r[e]=n,r}}}function s(t,n){return new c.Store(t,n)}exports.createExtension=u;exports.createStore=s;exports.originalFactorySymbol=e;
2
- //# sourceMappingURL=BlockNoteExtension-BWw0r8Gy.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BlockNoteExtension-BWw0r8Gy.cjs","sources":["../src/editor/managers/ExtensionManager/symbol.ts","../src/editor/BlockNoteExtension.ts"],"sourcesContent":["/**\n * Symbol used to track the original factory function for extensions.\n * This allows us to retrieve the original factory for comparison and other operations.\n */\nexport const originalFactorySymbol = Symbol(\"originalFactory\");\n","import { Store, StoreOptions } from \"@tanstack/store\";\nimport { type AnyExtension } from \"@tiptap/core\";\nimport type { Plugin as ProsemirrorPlugin } from \"prosemirror-state\";\nimport type { PartialBlockNoDefaults } from \"../schema/index.js\";\nimport type { BlockNoteEditor } from \"./BlockNoteEditor.js\";\nimport { originalFactorySymbol } from \"./managers/ExtensionManager/symbol.js\";\n\n/**\n * This function is called when the extension is destroyed.\n */\ntype OnDestroy = () => void;\n\n/**\n * Describes a BlockNote extension.\n */\nexport interface Extension<State = any, Key extends string = string> {\n /**\n * The unique identifier for the extension.\n */\n readonly key: Key;\n\n /**\n * Triggered when the extension is mounted to the editor.\n */\n readonly mount?: (ctx: {\n /**\n * The DOM element that the editor is mounted to.\n */\n dom: HTMLElement;\n /**\n * The root document of the {@link document} that the editor is mounted to.\n */\n root: Document | ShadowRoot;\n /**\n * An {@link AbortSignal} that will be aborted when the extension is destroyed.\n */\n signal: AbortSignal;\n }) => void | OnDestroy;\n\n /**\n * The store for the extension.\n */\n readonly store?: Store<State>;\n\n /**\n * Declares what {@link Extension}s that this extension depends on.\n */\n readonly runsBefore?: ReadonlyArray<string>;\n\n /**\n * Input rules for a block: An input rule is what is used to replace text in a block when a regular expression match is found.\n * As an example, typing `#` in a paragraph block will trigger an input rule to replace the text with a heading block.\n */\n readonly inputRules?: ReadonlyArray<InputRule>;\n\n /**\n * A mapping of a keyboard shortcut to a function that will be called when the shortcut is pressed\n *\n * The keys are in the format:\n * - Key names may be strings like `Shift-Ctrl-Enter`—a key identifier prefixed with zero or more modifiers\n * - Key identifiers are based on the strings that can appear in KeyEvent.key\n * - Use lowercase letters to refer to letter keys (or uppercase letters if you want shift to be held)\n * - You may use `Space` as an alias for the \" \" name\n * - Modifiers can be given in any order: `Shift-` (or `s-`), `Alt-` (or `a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or `Meta-`)\n * - For characters that are created by holding shift, the Shift- prefix is implied, and should not be added explicitly\n * - You can use Mod- as a shorthand for Cmd- on Mac and Ctrl- on other platforms\n *\n * @example\n * ```typescript\n * keyboardShortcuts: {\n * \"Mod-Enter\": (ctx) => { return true; },\n * \"Shift-Ctrl-Space\": (ctx) => { return true; },\n * \"a\": (ctx) => { return true; },\n * \"Space\": (ctx) => { return true; }\n * }\n * ```\n */\n readonly keyboardShortcuts?: Record<\n string,\n (ctx: { editor: BlockNoteEditor<any, any, any> }) => boolean\n >;\n\n /**\n * Add additional prosemirror plugins to the editor.\n */\n readonly prosemirrorPlugins?: ReadonlyArray<ProsemirrorPlugin>;\n\n /**\n * Add additional tiptap extensions to the editor.\n */\n readonly tiptapExtensions?: ReadonlyArray<AnyExtension>;\n\n /**\n * Add additional BlockNote extensions to the editor.\n */\n readonly blockNoteExtensions?: ReadonlyArray<ExtensionFactoryInstance>;\n}\n\n/**\n * An input rule is what is used to replace text in a block when a regular expression match is found.\n * As an example, typing `#` in a paragraph block will trigger an input rule to replace the text with a heading block.\n */\ntype InputRule = {\n /**\n * The regex to match when to trigger the input rule\n */\n find: RegExp;\n /**\n * The function to call when the input rule is matched\n * @returns undefined if the input rule should not be triggered, or an object with the type and props to update the block\n */\n replace: (props: {\n /**\n * The result of the regex match\n */\n match: RegExpMatchArray;\n // TODO this will be a Point, when we have the Location API\n /**\n * The range of the text that was matched\n */\n range: { from: number; to: number };\n /**\n * The editor instance\n */\n editor: BlockNoteEditor<any, any, any>;\n }) => undefined | PartialBlockNoDefaults<any, any, any>;\n};\n\n/**\n * These are the arguments that are passed to an {@link ExtensionFactoryInstance}.\n */\nexport interface ExtensionOptions<\n Options extends Record<string, any> | undefined =\n | Record<string, any>\n | undefined,\n> {\n options: Options;\n editor: BlockNoteEditor<any, any, any>;\n}\n\n// a type that maps the extension key to the return type of the extension factory\nexport type ExtensionMap<T extends ReadonlyArray<ExtensionFactoryInstance>> = {\n [K in T[number] extends ExtensionFactoryInstance<infer Ext>\n ? Ext[\"key\"]\n : never]: T[number] extends ExtensionFactoryInstance<infer Ext>\n ? Ext\n : never;\n};\n\n/**\n * This is a type that represents the function which will actually create the extension.\n * It requires the editor instance to be passed in, but will already have the options applied automatically.\n *\n * @note Only the BlockNoteEditor should instantiate this function, not the user. Look at {@link createExtension} for user-facing functions.\n */\nexport type ExtensionFactoryInstance<\n Ext extends Extension<any, any> = Extension<any, any>,\n> = (ctx: Omit<ExtensionOptions<any>, \"options\">) => Ext;\n\n/**\n * This is the return type of the {@link createExtension} function.\n * It is a function that can be invoked with the extension's options to create a new extension factory.\n */\nexport type ExtensionFactory<\n State = any,\n Key extends string = string,\n Factory extends (ctx: any) => Extension<State, Key> = (\n ctx: ExtensionOptions<any>,\n ) => Extension<State, Key>,\n> =\n Parameters<Factory>[0] extends ExtensionOptions<infer Options>\n ? undefined extends Options\n ? (\n options?: Exclude<Options, undefined>,\n ) => ExtensionFactoryInstance<ReturnType<Factory>>\n : (options: Options) => ExtensionFactoryInstance<ReturnType<Factory>>\n : () => ExtensionFactoryInstance<ReturnType<Factory>>;\n\n/**\n * Constructs a BlockNote {@link ExtensionFactory} from a factory function or object\n */\n// This overload is for `createExtension({ key: \"test\", ... })`\nexport function createExtension<\n const State = any,\n const Key extends string = string,\n const Ext extends Extension<State, Key> = Extension<State, Key>,\n>(factory: Ext): ExtensionFactoryInstance<Ext>;\n// This overload is for `createExtension(({editor, options}) => ({ key: \"test\", ... }))`\nexport function createExtension<\n const State = any,\n const Options extends Record<string, any> | undefined = any,\n const Key extends string = string,\n const Factory extends (ctx: any) => Extension<State, Key> = (\n ctx: ExtensionOptions<Options>,\n ) => Extension<State, Key>,\n>(factory: Factory): ExtensionFactory<State, Key, Factory>;\n// This overload is for both of the above overloads as it is the implementation of the function\nexport function createExtension<\n const State = any,\n const Options extends Record<string, any> | undefined = any,\n const Key extends string = string,\n const Factory extends\n | Extension<State, Key>\n | ((ctx: any) => Extension<State, Key>) = (\n ctx: ExtensionOptions<Options>,\n ) => Extension<State, Key>,\n>(\n factory: Factory,\n): Factory extends Extension<State, Key>\n ? ExtensionFactoryInstance<Factory>\n : Factory extends (ctx: any) => Extension<State, Key>\n ? ExtensionFactory<State, Key, Factory>\n : never {\n if (typeof factory === \"object\" && \"key\" in factory) {\n return function factoryFn() {\n (factory as any)[originalFactorySymbol] = factoryFn;\n return factory;\n } as any;\n }\n\n if (typeof factory !== \"function\") {\n throw new Error(\"factory must be a function\");\n }\n\n return function factoryFn(options: Options) {\n return (ctx: { editor: BlockNoteEditor<any, any, any> }) => {\n const extension = factory({ editor: ctx.editor, options });\n // We stick a symbol onto the extension to allow us to retrieve the original factory for comparison later.\n // This enables us to do things like: `editor.getExtension(YSync).prosemirrorPlugins`\n (extension as any)[originalFactorySymbol] = factoryFn;\n return extension;\n };\n } as any;\n}\n\nexport function createStore<T = any>(\n initialState: T,\n options?: StoreOptions<T>,\n): Store<T> {\n return new Store(initialState, options);\n}\n"],"names":["originalFactorySymbol","createExtension","factory","factoryFn","options","ctx","extension","createStore","initialState","Store"],"mappings":"gDAIaA,EAAwB,OAAO,iBAAiB,ECiMtD,SAASC,EAUdC,EAKU,CACV,GAAI,OAAOA,GAAY,UAAY,QAASA,EAC1C,OAAO,SAASC,GAAY,CACzB,OAAAD,EAAgBF,CAAqB,EAAIG,EACnCD,CACT,EAGF,GAAI,OAAOA,GAAY,WACrB,MAAM,IAAI,MAAM,4BAA4B,EAG9C,OAAO,SAASC,EAAUC,EAAkB,CAC1C,OAAQC,GAAoD,CAC1D,MAAMC,EAAYJ,EAAQ,CAAE,OAAQG,EAAI,OAAQ,QAAAD,EAAS,EAGxD,OAAAE,EAAkBN,CAAqB,EAAIG,EACrCG,CACT,CACF,CACF,CAEO,SAASC,EACdC,EACAJ,EACU,CACV,OAAO,IAAIK,EAAAA,MAAMD,EAAcJ,CAAO,CACxC"}
@@ -1,25 +0,0 @@
1
- import { Store as u } from "@tanstack/store";
2
- const r = Symbol("originalFactory");
3
- function a(n) {
4
- if (typeof n == "object" && "key" in n)
5
- return function t() {
6
- return n[r] = t, n;
7
- };
8
- if (typeof n != "function")
9
- throw new Error("factory must be a function");
10
- return function t(e) {
11
- return (i) => {
12
- const o = n({ editor: i.editor, options: e });
13
- return o[r] = t, o;
14
- };
15
- };
16
- }
17
- function f(n, t) {
18
- return new u(n, t);
19
- }
20
- export {
21
- f as a,
22
- a as c,
23
- r as o
24
- };
25
- //# sourceMappingURL=BlockNoteExtension-C2X7LW-V.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BlockNoteExtension-C2X7LW-V.js","sources":["../src/editor/managers/ExtensionManager/symbol.ts","../src/editor/BlockNoteExtension.ts"],"sourcesContent":["/**\n * Symbol used to track the original factory function for extensions.\n * This allows us to retrieve the original factory for comparison and other operations.\n */\nexport const originalFactorySymbol = Symbol(\"originalFactory\");\n","import { Store, StoreOptions } from \"@tanstack/store\";\nimport { type AnyExtension } from \"@tiptap/core\";\nimport type { Plugin as ProsemirrorPlugin } from \"prosemirror-state\";\nimport type { PartialBlockNoDefaults } from \"../schema/index.js\";\nimport type { BlockNoteEditor } from \"./BlockNoteEditor.js\";\nimport { originalFactorySymbol } from \"./managers/ExtensionManager/symbol.js\";\n\n/**\n * This function is called when the extension is destroyed.\n */\ntype OnDestroy = () => void;\n\n/**\n * Describes a BlockNote extension.\n */\nexport interface Extension<State = any, Key extends string = string> {\n /**\n * The unique identifier for the extension.\n */\n readonly key: Key;\n\n /**\n * Triggered when the extension is mounted to the editor.\n */\n readonly mount?: (ctx: {\n /**\n * The DOM element that the editor is mounted to.\n */\n dom: HTMLElement;\n /**\n * The root document of the {@link document} that the editor is mounted to.\n */\n root: Document | ShadowRoot;\n /**\n * An {@link AbortSignal} that will be aborted when the extension is destroyed.\n */\n signal: AbortSignal;\n }) => void | OnDestroy;\n\n /**\n * The store for the extension.\n */\n readonly store?: Store<State>;\n\n /**\n * Declares what {@link Extension}s that this extension depends on.\n */\n readonly runsBefore?: ReadonlyArray<string>;\n\n /**\n * Input rules for a block: An input rule is what is used to replace text in a block when a regular expression match is found.\n * As an example, typing `#` in a paragraph block will trigger an input rule to replace the text with a heading block.\n */\n readonly inputRules?: ReadonlyArray<InputRule>;\n\n /**\n * A mapping of a keyboard shortcut to a function that will be called when the shortcut is pressed\n *\n * The keys are in the format:\n * - Key names may be strings like `Shift-Ctrl-Enter`—a key identifier prefixed with zero or more modifiers\n * - Key identifiers are based on the strings that can appear in KeyEvent.key\n * - Use lowercase letters to refer to letter keys (or uppercase letters if you want shift to be held)\n * - You may use `Space` as an alias for the \" \" name\n * - Modifiers can be given in any order: `Shift-` (or `s-`), `Alt-` (or `a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or `Meta-`)\n * - For characters that are created by holding shift, the Shift- prefix is implied, and should not be added explicitly\n * - You can use Mod- as a shorthand for Cmd- on Mac and Ctrl- on other platforms\n *\n * @example\n * ```typescript\n * keyboardShortcuts: {\n * \"Mod-Enter\": (ctx) => { return true; },\n * \"Shift-Ctrl-Space\": (ctx) => { return true; },\n * \"a\": (ctx) => { return true; },\n * \"Space\": (ctx) => { return true; }\n * }\n * ```\n */\n readonly keyboardShortcuts?: Record<\n string,\n (ctx: { editor: BlockNoteEditor<any, any, any> }) => boolean\n >;\n\n /**\n * Add additional prosemirror plugins to the editor.\n */\n readonly prosemirrorPlugins?: ReadonlyArray<ProsemirrorPlugin>;\n\n /**\n * Add additional tiptap extensions to the editor.\n */\n readonly tiptapExtensions?: ReadonlyArray<AnyExtension>;\n\n /**\n * Add additional BlockNote extensions to the editor.\n */\n readonly blockNoteExtensions?: ReadonlyArray<ExtensionFactoryInstance>;\n}\n\n/**\n * An input rule is what is used to replace text in a block when a regular expression match is found.\n * As an example, typing `#` in a paragraph block will trigger an input rule to replace the text with a heading block.\n */\ntype InputRule = {\n /**\n * The regex to match when to trigger the input rule\n */\n find: RegExp;\n /**\n * The function to call when the input rule is matched\n * @returns undefined if the input rule should not be triggered, or an object with the type and props to update the block\n */\n replace: (props: {\n /**\n * The result of the regex match\n */\n match: RegExpMatchArray;\n // TODO this will be a Point, when we have the Location API\n /**\n * The range of the text that was matched\n */\n range: { from: number; to: number };\n /**\n * The editor instance\n */\n editor: BlockNoteEditor<any, any, any>;\n }) => undefined | PartialBlockNoDefaults<any, any, any>;\n};\n\n/**\n * These are the arguments that are passed to an {@link ExtensionFactoryInstance}.\n */\nexport interface ExtensionOptions<\n Options extends Record<string, any> | undefined =\n | Record<string, any>\n | undefined,\n> {\n options: Options;\n editor: BlockNoteEditor<any, any, any>;\n}\n\n// a type that maps the extension key to the return type of the extension factory\nexport type ExtensionMap<T extends ReadonlyArray<ExtensionFactoryInstance>> = {\n [K in T[number] extends ExtensionFactoryInstance<infer Ext>\n ? Ext[\"key\"]\n : never]: T[number] extends ExtensionFactoryInstance<infer Ext>\n ? Ext\n : never;\n};\n\n/**\n * This is a type that represents the function which will actually create the extension.\n * It requires the editor instance to be passed in, but will already have the options applied automatically.\n *\n * @note Only the BlockNoteEditor should instantiate this function, not the user. Look at {@link createExtension} for user-facing functions.\n */\nexport type ExtensionFactoryInstance<\n Ext extends Extension<any, any> = Extension<any, any>,\n> = (ctx: Omit<ExtensionOptions<any>, \"options\">) => Ext;\n\n/**\n * This is the return type of the {@link createExtension} function.\n * It is a function that can be invoked with the extension's options to create a new extension factory.\n */\nexport type ExtensionFactory<\n State = any,\n Key extends string = string,\n Factory extends (ctx: any) => Extension<State, Key> = (\n ctx: ExtensionOptions<any>,\n ) => Extension<State, Key>,\n> =\n Parameters<Factory>[0] extends ExtensionOptions<infer Options>\n ? undefined extends Options\n ? (\n options?: Exclude<Options, undefined>,\n ) => ExtensionFactoryInstance<ReturnType<Factory>>\n : (options: Options) => ExtensionFactoryInstance<ReturnType<Factory>>\n : () => ExtensionFactoryInstance<ReturnType<Factory>>;\n\n/**\n * Constructs a BlockNote {@link ExtensionFactory} from a factory function or object\n */\n// This overload is for `createExtension({ key: \"test\", ... })`\nexport function createExtension<\n const State = any,\n const Key extends string = string,\n const Ext extends Extension<State, Key> = Extension<State, Key>,\n>(factory: Ext): ExtensionFactoryInstance<Ext>;\n// This overload is for `createExtension(({editor, options}) => ({ key: \"test\", ... }))`\nexport function createExtension<\n const State = any,\n const Options extends Record<string, any> | undefined = any,\n const Key extends string = string,\n const Factory extends (ctx: any) => Extension<State, Key> = (\n ctx: ExtensionOptions<Options>,\n ) => Extension<State, Key>,\n>(factory: Factory): ExtensionFactory<State, Key, Factory>;\n// This overload is for both of the above overloads as it is the implementation of the function\nexport function createExtension<\n const State = any,\n const Options extends Record<string, any> | undefined = any,\n const Key extends string = string,\n const Factory extends\n | Extension<State, Key>\n | ((ctx: any) => Extension<State, Key>) = (\n ctx: ExtensionOptions<Options>,\n ) => Extension<State, Key>,\n>(\n factory: Factory,\n): Factory extends Extension<State, Key>\n ? ExtensionFactoryInstance<Factory>\n : Factory extends (ctx: any) => Extension<State, Key>\n ? ExtensionFactory<State, Key, Factory>\n : never {\n if (typeof factory === \"object\" && \"key\" in factory) {\n return function factoryFn() {\n (factory as any)[originalFactorySymbol] = factoryFn;\n return factory;\n } as any;\n }\n\n if (typeof factory !== \"function\") {\n throw new Error(\"factory must be a function\");\n }\n\n return function factoryFn(options: Options) {\n return (ctx: { editor: BlockNoteEditor<any, any, any> }) => {\n const extension = factory({ editor: ctx.editor, options });\n // We stick a symbol onto the extension to allow us to retrieve the original factory for comparison later.\n // This enables us to do things like: `editor.getExtension(YSync).prosemirrorPlugins`\n (extension as any)[originalFactorySymbol] = factoryFn;\n return extension;\n };\n } as any;\n}\n\nexport function createStore<T = any>(\n initialState: T,\n options?: StoreOptions<T>,\n): Store<T> {\n return new Store(initialState, options);\n}\n"],"names":["originalFactorySymbol","createExtension","factory","factoryFn","options","ctx","extension","createStore","initialState","Store"],"mappings":";AAIO,MAAMA,IAAwB,OAAO,iBAAiB;ACiMtD,SAASC,EAUdC,GAKU;AACV,MAAI,OAAOA,KAAY,YAAY,SAASA;AAC1C,WAAO,SAASC,IAAY;AACzB,aAAAD,EAAgBF,CAAqB,IAAIG,GACnCD;AAAA,IACT;AAGF,MAAI,OAAOA,KAAY;AACrB,UAAM,IAAI,MAAM,4BAA4B;AAG9C,SAAO,SAASC,EAAUC,GAAkB;AAC1C,WAAO,CAACC,MAAoD;AAC1D,YAAMC,IAAYJ,EAAQ,EAAE,QAAQG,EAAI,QAAQ,SAAAD,GAAS;AAGxD,aAAAE,EAAkBN,CAAqB,IAAIG,GACrCG;AAAA,IACT;AAAA,EACF;AACF;AAEO,SAASC,EACdC,GACAJ,GACU;AACV,SAAO,IAAIK,EAAMD,GAAcJ,CAAO;AACxC;"}
@@ -1,2 +0,0 @@
1
- "use strict";var C=Object.defineProperty;var O=(t,e,n)=>e in t?C(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var a=(t,e,n)=>O(t,typeof e!="symbol"?e+"":e,n);const l=require("./defaultBlocks-Dg9kQWXm.cjs");function w(t){const e=D(t);let{roots:n,nonRoots:r}=f(e);const s=[];for(;n.size;){s.push(n);const o=new Set;for(const c of n){const i=t.get(c);if(i)for(const p of i){const m=e.get(p);if(m===void 0)continue;const S=m-1;e.set(p,S),S===0&&o.add(p)}}n=o}if(r=f(e).nonRoots,r.size)throw new Error(`Cycle(s) detected; toposort only works on acyclic graphs. Cyclic nodes: ${Array.from(r).join(", ")}`);return s}function j(t){const e=x(t);return w(e)}function D(t){const e=new Map;for(const[n,r]of t.entries()){e.has(n)||e.set(n,0);for(const s of r){const o=e.get(s)??0;e.set(s,o+1)}}return e}function f(t){const e=new Set,n=new Set;for(const[r,s]of t.entries())s===0?e.add(r):n.add(r);return{roots:e,nonRoots:n}}function x(t){const e=new Map;for(const[n,r]of t.entries()){e.has(n)||e.set(n,new Set);for(const s of r)e.has(s)||e.set(s,new Set),e.get(s).add(n)}return e}function E(){return new Map}function h(t,e,n){return t.has(e)||t.set(e,new Set),t.get(e).add(n),t}function k(t){const e=E();for(const s of t)Array.isArray(s.runsBefore)&&s.runsBefore.length>0?s.runsBefore.forEach(o=>{h(e,s.key,o)}):h(e,"default",s.key);const n=j(e),r=n.findIndex(s=>s.has("default"));return s=>91+(n.findIndex(c=>c.has(s))+r)*10}function u(t){return t&&Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}class g{constructor(e){a(this,"BlockNoteEditor","only for types");a(this,"Block","only for types");a(this,"PartialBlock","only for types");a(this,"inlineContentSpecs");a(this,"styleSpecs");a(this,"blockSpecs");a(this,"blockSchema");a(this,"inlineContentSchema");a(this,"styleSchema");this.opts=e;const{blockSpecs:n,inlineContentSpecs:r,styleSpecs:s,blockSchema:o,inlineContentSchema:c,styleSchema:i}=this.init();this.blockSpecs=n,this.styleSpecs=s,this.styleSchema=i,this.inlineContentSpecs=r,this.blockSchema=o,this.inlineContentSchema=c}init(){const e=k(Object.entries({...this.opts.blockSpecs,...this.opts.inlineContentSpecs,...this.opts.styleSpecs}).map(([o,c])=>{var i;return{key:o,runsBefore:((i=c.implementation)==null?void 0:i.runsBefore)??[]}})),n=Object.fromEntries(Object.entries(this.opts.blockSpecs).map(([o,c])=>[o,l.addNodeAndExtensionsToSpec(c.config,c.implementation,c.extensions,e(o))])),r=Object.fromEntries(Object.entries(this.opts.inlineContentSpecs).map(([o,c])=>{var i;return typeof c.config!="object"?[o,c]:[o,{...c,implementation:{...c.implementation,node:(i=c.implementation)==null?void 0:i.node.extend({priority:e(o)})}}]})),s=Object.fromEntries(Object.entries(this.opts.styleSpecs).map(([o,c])=>{var i;return[o,{...c,implementation:{...c.implementation,mark:(i=c.implementation)==null?void 0:i.mark.extend({priority:e(o)})}}]}));return{blockSpecs:n,blockSchema:Object.fromEntries(Object.entries(n).map(([o,c])=>[o,c.config])),inlineContentSpecs:u(r),styleSpecs:u(s),inlineContentSchema:l.getInlineContentSchemaFromSpecs(r),styleSchema:l.getStyleSchemaFromSpecs(s)}}extend(e){Object.assign(this.opts.blockSpecs,e.blockSpecs),Object.assign(this.opts.inlineContentSpecs,e.inlineContentSpecs),Object.assign(this.opts.styleSpecs,e.styleSpecs);const{blockSpecs:n,inlineContentSpecs:r,styleSpecs:s,blockSchema:o,inlineContentSchema:c,styleSchema:i}=this.init();return this.blockSpecs=n,this.styleSpecs=s,this.styleSchema=i,this.inlineContentSpecs=r,this.blockSchema=o,this.inlineContentSchema=c,this}}const y=l.createBlockConfig(()=>({type:"pageBreak",propSchema:{},content:"none"})),b=l.createBlockSpec(y,{parse(t){if(t.tagName==="DIV"&&t.hasAttribute("data-page-break"))return{}},render(){const t=document.createElement("div");return t.setAttribute("data-page-break",""),{dom:t}},toExternalHTML(){const t=document.createElement("div");return t.setAttribute("data-page-break",""),{dom:t}}}),P=t=>t.extend({blockSpecs:{pageBreak:b()}}),I=async t=>{const e=new FormData;return e.append("file",t),(await(await fetch("https://tmpfiles.org/api/v1/upload",{method:"POST",body:e})).json()).data.url.replace("tmpfiles.org/","tmpfiles.org/dl/")};function B(t){return"pageBreak"in t.schema.blockSchema}function v(t){const e=[];return B(t)&&e.push({...t.dictionary.slash_menu.page_break,onItemClick:()=>{l.insertOrUpdateBlockForSlashMenu(t,{type:"pageBreak"})},key:"page_break"}),e}class d extends g{static create(e){return new d({blockSpecs:(e==null?void 0:e.blockSpecs)??l.defaultBlockSpecs,inlineContentSpecs:(e==null?void 0:e.inlineContentSpecs)??l.defaultInlineContentSpecs,styleSpecs:(e==null?void 0:e.styleSpecs)??l.defaultStyleSpecs})}}exports.BlockNoteSchema=d;exports.CustomBlockNoteSchema=g;exports.checkPageBreakBlocksInSchema=B;exports.createPageBreakBlockConfig=y;exports.createPageBreakBlockSpec=b;exports.getPageBreakSlashMenuItems=v;exports.sortByDependencies=k;exports.uploadToTmpFilesDotOrg_DEV_ONLY=I;exports.withPageBreak=P;
2
- //# sourceMappingURL=BlockNoteSchema-CCs_V3lo.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BlockNoteSchema-CCs_V3lo.cjs","sources":["../src/util/topo-sort.ts","../src/schema/schema.ts","../src/blocks/PageBreak/block.ts","../src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.ts","../src/blocks/PageBreak/getPageBreakSlashMenuItems.ts","../src/blocks/BlockNoteSchema.ts"],"sourcesContent":["/**\n * Instead of depending on the NPM package, we vendor this file from https://github.com/n1ru4l/toposort/blob/main/src/toposort.ts (MIT)\n *\n * There was a recent publish, despite not having been updated in 2 years, which is suspicious.\n *\n * This file is also simple enough that we can maintain it ourselves.\n */\n\nexport type DirectedAcyclicGraph = Map<string, Iterable<string>>;\nexport type DependencyGraph = DirectedAcyclicGraph;\n\nexport type TaskList = Array<Set<string>>;\n\n// Add more specific types for better type safety\nexport type NodeId = string;\nexport type DependencyMap = Map<NodeId, Set<NodeId>>;\n\nexport function toposort(dag: DirectedAcyclicGraph): TaskList {\n const inDegrees = countInDegrees(dag);\n\n let { roots, nonRoots } = getRootsAndNonRoots(inDegrees);\n\n const sorted: TaskList = [];\n\n while (roots.size) {\n sorted.push(roots);\n\n const newRoots = new Set<NodeId>();\n for (const root of roots) {\n const dependents = dag.get(root);\n if (!dependents) {\n // Handle case where node has no dependents\n continue;\n }\n\n for (const dependent of dependents) {\n const currentDegree = inDegrees.get(dependent);\n if (currentDegree === undefined) {\n // Handle case where dependent node is not in inDegrees\n continue;\n }\n\n const newDegree = currentDegree - 1;\n inDegrees.set(dependent, newDegree);\n\n if (newDegree === 0) {\n newRoots.add(dependent);\n }\n }\n }\n\n roots = newRoots;\n }\n nonRoots = getRootsAndNonRoots(inDegrees).nonRoots;\n\n if (nonRoots.size) {\n throw new Error(\n `Cycle(s) detected; toposort only works on acyclic graphs. Cyclic nodes: ${Array.from(nonRoots).join(\", \")}`,\n );\n }\n\n return sorted;\n}\n\nexport function toposortReverse(deps: DependencyGraph): TaskList {\n const dag = reverse(deps);\n return toposort(dag);\n}\n\ntype InDegrees = Map<NodeId, number>;\n\nfunction countInDegrees(dag: DirectedAcyclicGraph): InDegrees {\n const counts: InDegrees = new Map();\n\n for (const [vx, dependents] of dag.entries()) {\n // Initialize count for current node if not present\n if (!counts.has(vx)) {\n counts.set(vx, 0);\n }\n\n for (const dependent of dependents) {\n const currentCount = counts.get(dependent) ?? 0;\n counts.set(dependent, currentCount + 1);\n }\n }\n\n return counts;\n}\n\nfunction getRootsAndNonRoots(counts: InDegrees) {\n const roots = new Set<NodeId>();\n const nonRoots = new Set<NodeId>();\n\n for (const [id, deg] of counts.entries()) {\n if (deg === 0) {\n roots.add(id);\n } else {\n nonRoots.add(id);\n }\n }\n\n return { roots, nonRoots };\n}\n\nfunction reverse(deps: DirectedAcyclicGraph): DependencyGraph {\n const reversedDeps: DependencyMap = new Map();\n\n for (const [name, dependsOn] of deps.entries()) {\n // Ensure the source node exists in the reversed map\n if (!reversedDeps.has(name)) {\n reversedDeps.set(name, new Set());\n }\n\n for (const dependsOnName of dependsOn) {\n if (!reversedDeps.has(dependsOnName)) {\n reversedDeps.set(dependsOnName, new Set());\n }\n reversedDeps.get(dependsOnName)!.add(name);\n }\n }\n\n return reversedDeps;\n}\n\nexport function createDependencyGraph(): DependencyMap {\n return new Map();\n}\n\nexport function addDependency(\n graph: DependencyMap,\n from: NodeId,\n to: NodeId,\n): DependencyMap {\n if (!graph.has(from)) {\n graph.set(from, new Set());\n }\n graph.get(from)!.add(to);\n return graph;\n}\n\nexport function removeDependency(\n graph: DependencyMap,\n from: NodeId,\n to: NodeId,\n): boolean {\n const dependents = graph.get(from);\n if (!dependents) {\n return false;\n }\n return dependents.delete(to);\n}\n\nexport function hasDependency(\n graph: DependencyMap,\n from: NodeId,\n to: NodeId,\n): boolean {\n const dependents = graph.get(from);\n return dependents ? dependents.has(to) : false;\n}\n\n/**\n * Sorts a list of items by their dependencies\n * @returns A function which can retrieve the priority of an item\n */\nexport function sortByDependencies(\n items: { key: string; runsBefore?: ReadonlyArray<string> }[],\n) {\n const dag = createDependencyGraph();\n\n for (const item of items) {\n if (Array.isArray(item.runsBefore) && item.runsBefore.length > 0) {\n item.runsBefore.forEach((runBefore) => {\n addDependency(dag, item.key, runBefore);\n });\n } else {\n addDependency(dag, \"default\", item.key);\n }\n }\n const sortedSpecs = toposortReverse(dag);\n const defaultIndex = sortedSpecs.findIndex((set) => set.has(\"default\"));\n\n /**\n * The priority of an item is described relative to the \"default\" (an arbitrary string which can be used as the reference)\n *\n * Since items are topologically sorted, we can see what their relative position is to the \"default\"\n * Each layer away from the default is 10 priority points (arbitrarily chosen)\n * The default is fixed at 101 (1 point higher than any tiptap extension, giving priority to custom blocks than any defaults)\n *\n * This is a bit of a hack, but it's a simple way to ensure that custom items are always rendered with higher priority than default items\n * and that custom items are rendered in the order they are defined in the list\n */\n\n /**\n * Retrieves the priority of an item based on its position in the topologically sorted list\n * @param key - The key of the item to get the priority of\n * @returns The priority of the item\n */\n return (key: string) => {\n const index = sortedSpecs.findIndex((set) => set.has(key));\n // the default index should map to 101\n // one before the default index is 91\n // one after is 111\n return 91 + (index + defaultIndex) * 10;\n };\n}\n","import { BlockNoteEditor } from \"../editor/BlockNoteEditor.js\";\nimport { sortByDependencies } from \"../util/topo-sort.js\";\nimport {\n BlockNoDefaults,\n BlockSchema,\n BlockSpecs,\n InlineContentConfig,\n InlineContentSchema,\n InlineContentSpec,\n InlineContentSpecs,\n LooseBlockSpec,\n PartialBlockNoDefaults,\n StyleSchema,\n StyleSpecs,\n addNodeAndExtensionsToSpec,\n getInlineContentSchemaFromSpecs,\n getStyleSchemaFromSpecs,\n} from \"./index.js\";\n\nfunction removeUndefined<T extends Record<string, any> | undefined>(obj: T): T {\n if (!obj) {\n return obj;\n }\n return Object.fromEntries(\n Object.entries(obj).filter(([, value]) => value !== undefined),\n ) as T;\n}\n\nexport class CustomBlockNoteSchema<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n> {\n // Helper so that you can use typeof schema.BlockNoteEditor\n public readonly BlockNoteEditor: BlockNoteEditor<BSchema, ISchema, SSchema> =\n \"only for types\" as any;\n\n public readonly Block: BlockNoDefaults<BSchema, ISchema, SSchema> =\n \"only for types\" as any;\n\n public readonly PartialBlock: PartialBlockNoDefaults<\n BSchema,\n ISchema,\n SSchema\n > = \"only for types\" as any;\n\n public inlineContentSpecs: InlineContentSpecs;\n public styleSpecs: StyleSpecs;\n public blockSpecs: {\n [K in keyof BSchema]: K extends string\n ? LooseBlockSpec<K, BSchema[K][\"propSchema\"], BSchema[K][\"content\"]>\n : never;\n };\n\n public blockSchema: BSchema;\n public inlineContentSchema: ISchema;\n public styleSchema: SSchema;\n\n constructor(\n private opts: {\n blockSpecs: BlockSpecs;\n inlineContentSpecs: InlineContentSpecs;\n styleSpecs: StyleSpecs;\n },\n ) {\n const {\n blockSpecs,\n inlineContentSpecs,\n styleSpecs,\n blockSchema,\n inlineContentSchema,\n styleSchema,\n } = this.init();\n this.blockSpecs = blockSpecs;\n this.styleSpecs = styleSpecs;\n this.styleSchema = styleSchema;\n this.inlineContentSpecs = inlineContentSpecs;\n this.blockSchema = blockSchema;\n this.inlineContentSchema = inlineContentSchema;\n }\n\n private init() {\n const getPriority = sortByDependencies(\n Object.entries({\n ...this.opts.blockSpecs,\n ...this.opts.inlineContentSpecs,\n ...this.opts.styleSpecs,\n }).map(([key, val]) => ({\n key: key,\n runsBefore: val.implementation?.runsBefore ?? [],\n })),\n );\n\n const blockSpecs = Object.fromEntries(\n Object.entries(this.opts.blockSpecs).map(([key, blockSpec]) => {\n return [\n key,\n addNodeAndExtensionsToSpec(\n blockSpec.config,\n blockSpec.implementation,\n blockSpec.extensions,\n getPriority(key),\n ),\n ];\n }),\n ) as {\n [K in keyof BSchema]: K extends string\n ? LooseBlockSpec<K, BSchema[K][\"propSchema\"], BSchema[K][\"content\"]>\n : never;\n };\n\n const inlineContentSpecs = Object.fromEntries(\n Object.entries(this.opts.inlineContentSpecs).map(\n ([key, inlineContentSpec]) => {\n // Case for text and links.\n if (typeof inlineContentSpec.config !== \"object\") {\n return [key, inlineContentSpec];\n }\n\n return [\n key,\n {\n ...inlineContentSpec,\n implementation: {\n ...inlineContentSpec.implementation,\n node: inlineContentSpec.implementation?.node.extend({\n priority: getPriority(key),\n }),\n },\n },\n ];\n },\n ),\n ) as InlineContentSpecs;\n\n const styleSpecs = Object.fromEntries(\n Object.entries(this.opts.styleSpecs).map(([key, styleSpec]) => [\n key,\n {\n ...styleSpec,\n implementation: {\n ...styleSpec.implementation,\n mark: styleSpec.implementation?.mark.extend({\n priority: getPriority(key),\n }),\n },\n },\n ]),\n ) as StyleSpecs;\n\n return {\n blockSpecs,\n blockSchema: Object.fromEntries(\n Object.entries(blockSpecs).map(([key, blockDef]) => {\n return [key, blockDef.config];\n }),\n ) as any,\n inlineContentSpecs: removeUndefined(inlineContentSpecs),\n styleSpecs: removeUndefined(styleSpecs),\n inlineContentSchema: getInlineContentSchemaFromSpecs(\n inlineContentSpecs,\n ) as any,\n styleSchema: getStyleSchemaFromSpecs(styleSpecs) as any,\n };\n }\n\n /**\n * Adds additional block specs to the current schema in a builder pattern.\n * This method allows extending the schema after it has been created.\n *\n * @param additionalBlockSpecs - Additional block specs to add to the schema\n * @returns The current schema instance for chaining\n */\n public extend<\n AdditionalBlockSpecs extends BlockSpecs = Record<string, never>,\n AdditionalInlineContentSpecs extends Record<\n string,\n InlineContentSpec<InlineContentConfig>\n > = Record<string, never>,\n AdditionalStyleSpecs extends StyleSpecs = Record<string, never>,\n >(opts: {\n blockSpecs?: AdditionalBlockSpecs;\n inlineContentSpecs?: AdditionalInlineContentSpecs;\n styleSpecs?: AdditionalStyleSpecs;\n }): CustomBlockNoteSchema<\n AdditionalBlockSpecs extends undefined | Record<string, never>\n ? BSchema\n : BSchema & {\n [K in keyof AdditionalBlockSpecs]: K extends string\n ? AdditionalBlockSpecs[K][\"config\"]\n : never;\n },\n AdditionalInlineContentSpecs extends undefined | Record<string, never>\n ? ISchema\n : ISchema & {\n [K in keyof AdditionalInlineContentSpecs]: AdditionalInlineContentSpecs[K][\"config\"];\n },\n AdditionalStyleSpecs extends undefined | Record<string, never>\n ? SSchema\n : SSchema & {\n [K in keyof AdditionalStyleSpecs]: AdditionalStyleSpecs[K][\"config\"];\n }\n > {\n // Merge the new specs with existing ones\n Object.assign(this.opts.blockSpecs, opts.blockSpecs);\n Object.assign(this.opts.inlineContentSpecs, opts.inlineContentSpecs);\n Object.assign(this.opts.styleSpecs, opts.styleSpecs);\n\n // Reinitialize the block specs with the merged specs\n const {\n blockSpecs,\n inlineContentSpecs,\n styleSpecs,\n blockSchema,\n inlineContentSchema,\n styleSchema,\n } = this.init();\n this.blockSpecs = blockSpecs;\n this.styleSpecs = styleSpecs;\n this.styleSchema = styleSchema;\n this.inlineContentSpecs = inlineContentSpecs;\n this.blockSchema = blockSchema;\n this.inlineContentSchema = inlineContentSchema;\n\n return this as any;\n }\n}\n","import {\n BlockSchema,\n createBlockConfig,\n createBlockSpec,\n InlineContentSchema,\n StyleSchema,\n} from \"../../schema/index.js\";\nimport { BlockNoteSchema } from \"../BlockNoteSchema.js\";\n\nexport type PageBreakBlockConfig = ReturnType<\n typeof createPageBreakBlockConfig\n>;\n\nexport const createPageBreakBlockConfig = createBlockConfig(\n () =>\n ({\n type: \"pageBreak\" as const,\n propSchema: {},\n content: \"none\",\n }) as const,\n);\n\nexport const createPageBreakBlockSpec = createBlockSpec(\n createPageBreakBlockConfig,\n {\n parse(element) {\n if (\n element.tagName === \"DIV\" &&\n element.hasAttribute(\"data-page-break\")\n ) {\n return {};\n }\n\n return undefined;\n },\n render() {\n const pageBreak = document.createElement(\"div\");\n\n pageBreak.setAttribute(\"data-page-break\", \"\");\n\n return {\n dom: pageBreak,\n };\n },\n toExternalHTML() {\n const pageBreak = document.createElement(\"div\");\n\n pageBreak.setAttribute(\"data-page-break\", \"\");\n\n return {\n dom: pageBreak,\n };\n },\n },\n);\n\n/**\n * Adds page break support to the given schema.\n */\nexport const withPageBreak = <\n B extends BlockSchema,\n I extends InlineContentSchema,\n S extends StyleSchema,\n>(\n schema: BlockNoteSchema<B, I, S>,\n) => {\n return schema.extend({\n blockSpecs: {\n pageBreak: createPageBreakBlockSpec(),\n },\n });\n};\n","/**\n * Uploads a file to tmpfiles.org and returns the URL to the uploaded file.\n *\n * @warning This function should only be used for development purposes, replace with your own backend!\n */\nexport const uploadToTmpFilesDotOrg_DEV_ONLY = async (\n file: File,\n): Promise<string> => {\n const body = new FormData();\n body.append(\"file\", file);\n\n const ret = await fetch(\"https://tmpfiles.org/api/v1/upload\", {\n method: \"POST\",\n body: body,\n });\n return (await ret.json()).data.url.replace(\n \"tmpfiles.org/\",\n \"tmpfiles.org/dl/\",\n );\n};\n","import { BlockNoteEditor } from \"../../editor/BlockNoteEditor.js\";\nimport { DefaultSuggestionItem } from \"../../extensions/SuggestionMenu/DefaultSuggestionItem.js\";\nimport { insertOrUpdateBlockForSlashMenu } from \"../../extensions/SuggestionMenu/getDefaultSlashMenuItems.js\";\nimport {\n BlockSchema,\n InlineContentSchema,\n StyleSchema,\n} from \"../../schema/index.js\";\nimport { createPageBreakBlockConfig } from \"./block.js\";\n\nexport function checkPageBreakBlocksInSchema<\n I extends InlineContentSchema,\n S extends StyleSchema,\n>(\n editor: BlockNoteEditor<any, I, S>,\n): editor is BlockNoteEditor<\n {\n pageBreak: ReturnType<typeof createPageBreakBlockConfig>;\n },\n I,\n S\n> {\n return \"pageBreak\" in editor.schema.blockSchema;\n}\n\nexport function getPageBreakSlashMenuItems<\n BSchema extends BlockSchema,\n I extends InlineContentSchema,\n S extends StyleSchema,\n>(editor: BlockNoteEditor<BSchema, I, S>) {\n const items: (Omit<DefaultSuggestionItem, \"key\"> & { key: \"page_break\" })[] =\n [];\n\n if (checkPageBreakBlocksInSchema(editor)) {\n items.push({\n ...editor.dictionary.slash_menu.page_break,\n onItemClick: () => {\n insertOrUpdateBlockForSlashMenu(editor, {\n type: \"pageBreak\",\n });\n },\n key: \"page_break\",\n });\n }\n\n return items;\n}\n","import {\n BlockSchema,\n BlockSchemaFromSpecs,\n BlockSpecs,\n CustomBlockNoteSchema,\n InlineContentSchema,\n InlineContentSchemaFromSpecs,\n InlineContentSpecs,\n StyleSchema,\n StyleSchemaFromSpecs,\n StyleSpecs,\n} from \"../schema/index.js\";\nimport {\n defaultBlockSpecs,\n defaultInlineContentSpecs,\n defaultStyleSpecs,\n} from \"./defaultBlocks.js\";\n\nexport class BlockNoteSchema<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n> extends CustomBlockNoteSchema<BSchema, ISchema, SSchema> {\n public static create<\n BSpecs extends BlockSpecs | undefined = undefined,\n ISpecs extends InlineContentSpecs | undefined = undefined,\n SSpecs extends StyleSpecs | undefined = undefined,\n >(options?: {\n /**\n * A list of custom block types that should be available in the editor.\n */\n blockSpecs?: BSpecs;\n /**\n * A list of custom InlineContent types that should be available in the editor.\n */\n inlineContentSpecs?: ISpecs;\n /**\n * A list of custom Styles that should be available in the editor.\n */\n styleSpecs?: SSpecs;\n }): BlockNoteSchema<\n BSpecs extends undefined\n ? BlockSchemaFromSpecs<typeof defaultBlockSpecs>\n : BlockSchemaFromSpecs<NonNullable<BSpecs>>,\n ISpecs extends undefined\n ? InlineContentSchemaFromSpecs<typeof defaultInlineContentSpecs>\n : InlineContentSchemaFromSpecs<NonNullable<ISpecs>>,\n SSpecs extends undefined\n ? StyleSchemaFromSpecs<typeof defaultStyleSpecs>\n : StyleSchemaFromSpecs<NonNullable<SSpecs>>\n > {\n return new BlockNoteSchema<any, any, any>({\n blockSpecs: options?.blockSpecs ?? defaultBlockSpecs,\n inlineContentSpecs:\n options?.inlineContentSpecs ?? defaultInlineContentSpecs,\n styleSpecs: options?.styleSpecs ?? defaultStyleSpecs,\n });\n }\n}\n"],"names":["toposort","dag","inDegrees","countInDegrees","roots","nonRoots","getRootsAndNonRoots","sorted","newRoots","root","dependents","dependent","currentDegree","newDegree","toposortReverse","deps","reverse","counts","vx","currentCount","id","deg","reversedDeps","name","dependsOn","dependsOnName","createDependencyGraph","addDependency","graph","from","to","sortByDependencies","items","item","runBefore","sortedSpecs","defaultIndex","set","key","removeUndefined","obj","value","CustomBlockNoteSchema","opts","__publicField","blockSpecs","inlineContentSpecs","styleSpecs","blockSchema","inlineContentSchema","styleSchema","getPriority","val","_a","blockSpec","addNodeAndExtensionsToSpec","inlineContentSpec","styleSpec","blockDef","getInlineContentSchemaFromSpecs","getStyleSchemaFromSpecs","createPageBreakBlockConfig","createBlockConfig","createPageBreakBlockSpec","createBlockSpec","element","pageBreak","withPageBreak","schema","uploadToTmpFilesDotOrg_DEV_ONLY","file","body","checkPageBreakBlocksInSchema","editor","getPageBreakSlashMenuItems","insertOrUpdateBlockForSlashMenu","BlockNoteSchema","options","defaultBlockSpecs","defaultInlineContentSpecs","defaultStyleSpecs"],"mappings":"iOAiBO,SAASA,EAASC,EAAqC,CAC5D,MAAMC,EAAYC,EAAeF,CAAG,EAEpC,GAAI,CAAE,MAAAG,EAAO,SAAAC,GAAaC,EAAoBJ,CAAS,EAEvD,MAAMK,EAAmB,CAAA,EAEzB,KAAOH,EAAM,MAAM,CACjBG,EAAO,KAAKH,CAAK,EAEjB,MAAMI,MAAe,IACrB,UAAWC,KAAQL,EAAO,CACxB,MAAMM,EAAaT,EAAI,IAAIQ,CAAI,EAC/B,GAAKC,EAKL,UAAWC,KAAaD,EAAY,CAClC,MAAME,EAAgBV,EAAU,IAAIS,CAAS,EAC7C,GAAIC,IAAkB,OAEpB,SAGF,MAAMC,EAAYD,EAAgB,EAClCV,EAAU,IAAIS,EAAWE,CAAS,EAE9BA,IAAc,GAChBL,EAAS,IAAIG,CAAS,CAE1B,CACF,CAEAP,EAAQI,CACV,CAGA,GAFAH,EAAWC,EAAoBJ,CAAS,EAAE,SAEtCG,EAAS,KACX,MAAM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