@blocknote/core 0.44.2 → 0.46.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 (92) hide show
  1. package/dist/BlockNoteExtension-BWw0r8Gy.cjs.map +1 -1
  2. package/dist/BlockNoteExtension-C2X7LW-V.js.map +1 -1
  3. package/dist/{BlockNoteSchema-BsTi0fNS.js → BlockNoteSchema-DsMVJZv4.js} +2 -2
  4. package/dist/{BlockNoteSchema-BsTi0fNS.js.map → BlockNoteSchema-DsMVJZv4.js.map} +1 -1
  5. package/dist/{BlockNoteSchema-CBNkNhkw.cjs → BlockNoteSchema-qt4Czo0-.cjs} +2 -2
  6. package/dist/{BlockNoteSchema-CBNkNhkw.cjs.map → BlockNoteSchema-qt4Czo0-.cjs.map} +1 -1
  7. package/dist/ShowSelection-B0ch3unP.js +51 -0
  8. package/dist/ShowSelection-B0ch3unP.js.map +1 -0
  9. package/dist/ShowSelection-BxnbRvy4.cjs +2 -0
  10. package/dist/ShowSelection-BxnbRvy4.cjs.map +1 -0
  11. package/dist/{TrailingNode-CG2a-HDA.js → TrailingNode-C-Kyrtf1.js} +715 -709
  12. package/dist/TrailingNode-C-Kyrtf1.js.map +1 -0
  13. package/dist/TrailingNode-W7GJVng5.cjs +2 -0
  14. package/dist/TrailingNode-W7GJVng5.cjs.map +1 -0
  15. package/dist/{blockToNode-DBNbhwwC.js → blockToNode-BNoNIXU7.js} +2 -2
  16. package/dist/{blockToNode-DBNbhwwC.js.map → blockToNode-BNoNIXU7.js.map} +1 -1
  17. package/dist/{blockToNode-w7H99R6p.cjs → blockToNode-CumVjgem.cjs} +2 -2
  18. package/dist/{blockToNode-w7H99R6p.cjs.map → blockToNode-CumVjgem.cjs.map} +1 -1
  19. package/dist/blocknote.cjs +4 -4
  20. package/dist/blocknote.cjs.map +1 -1
  21. package/dist/blocknote.js +1118 -1077
  22. package/dist/blocknote.js.map +1 -1
  23. package/dist/blocks.cjs +1 -1
  24. package/dist/blocks.js +2 -2
  25. package/dist/comments.cjs +1 -1
  26. package/dist/comments.cjs.map +1 -1
  27. package/dist/comments.js +3 -3
  28. package/dist/comments.js.map +1 -1
  29. package/dist/{defaultBlocks-B63ufZ5N.js → defaultBlocks-CXOCngjC.js} +273 -312
  30. package/dist/defaultBlocks-CXOCngjC.js.map +1 -0
  31. package/dist/defaultBlocks-IsUGVZIq.cjs +6 -0
  32. package/dist/defaultBlocks-IsUGVZIq.cjs.map +1 -0
  33. package/dist/extensions.cjs +1 -1
  34. package/dist/extensions.js +4 -4
  35. package/dist/style.css +1 -1
  36. package/dist/tsconfig.tsbuildinfo +1 -1
  37. package/dist/webpack-stats.json +1 -1
  38. package/dist/yjs.cjs +1 -1
  39. package/dist/yjs.js +1 -1
  40. package/package.json +18 -18
  41. package/src/api/blockManipulation/selections/selection.ts +9 -4
  42. package/src/api/blockManipulation/tables/tables.test.ts +140 -0
  43. package/src/api/blockManipulation/tables/tables.ts +1 -1
  44. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +17 -0
  45. package/src/api/parsers/markdown/parseMarkdown.ts +11 -0
  46. package/src/blocks/ListItem/BulletListItem/block.ts +1 -1
  47. package/src/blocks/ListItem/CheckListItem/block.ts +6 -4
  48. package/src/blocks/ListItem/NumberedListItem/block.ts +6 -2
  49. package/src/comments/extension.ts +6 -2
  50. package/src/editor/Block.css +1 -1
  51. package/src/editor/BlockNoteEditor.test.ts +0 -1
  52. package/src/editor/BlockNoteEditor.ts +9 -39
  53. package/src/editor/BlockNoteExtension.ts +5 -0
  54. package/src/editor/managers/EventManager.ts +1 -1
  55. package/src/editor/managers/ExtensionManager/extensions.ts +3 -13
  56. package/src/editor/managers/ExtensionManager/index.ts +7 -2
  57. package/src/editor/managers/SelectionManager.ts +10 -10
  58. package/src/extensions/BlockChange/BlockChange.ts +2 -2
  59. package/src/extensions/Collaboration/Collaboration.ts +55 -0
  60. package/src/extensions/Collaboration/ForkYDoc.ts +4 -9
  61. package/src/extensions/Collaboration/YCursorPlugin.ts +56 -60
  62. package/src/extensions/Collaboration/YSync.ts +2 -2
  63. package/src/extensions/Collaboration/YUndo.ts +2 -2
  64. package/src/extensions/LinkToolbar/LinkToolbar.ts +1 -1
  65. package/src/extensions/ShowSelection/ShowSelection.ts +14 -4
  66. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +40 -68
  67. package/src/extensions/TableHandles/TableHandles.ts +9 -5
  68. package/src/index.ts +2 -1
  69. package/src/schema/blocks/createSpec.ts +3 -0
  70. package/src/util/expandToWords.ts +38 -0
  71. package/types/src/api/blockManipulation/selections/selection.d.ts +1 -1
  72. package/types/src/editor/BlockNoteEditor.d.ts +5 -34
  73. package/types/src/editor/BlockNoteExtension.d.ts +4 -0
  74. package/types/src/editor/managers/SelectionManager.d.ts +4 -4
  75. package/types/src/extensions/Collaboration/Collaboration.d.ts +76 -0
  76. package/types/src/extensions/Collaboration/ForkYDoc.d.ts +2 -11
  77. package/types/src/extensions/Collaboration/YCursorPlugin.d.ts +3 -11
  78. package/types/src/extensions/Collaboration/YSync.d.ts +2 -4
  79. package/types/src/extensions/Collaboration/YUndo.d.ts +1 -1
  80. package/types/src/extensions/ShowSelection/ShowSelection.d.ts +10 -4
  81. package/types/src/index.d.ts +2 -1
  82. package/types/src/util/expandToWords.d.ts +13 -0
  83. package/dist/ShowSelection-BW37oJ6h.cjs +0 -2
  84. package/dist/ShowSelection-BW37oJ6h.cjs.map +0 -1
  85. package/dist/ShowSelection-Dz-NEase.js +0 -43
  86. package/dist/ShowSelection-Dz-NEase.js.map +0 -1
  87. package/dist/TrailingNode-CG2a-HDA.js.map +0 -1
  88. package/dist/TrailingNode-Du4SNHun.cjs +0 -2
  89. package/dist/TrailingNode-Du4SNHun.cjs.map +0 -1
  90. package/dist/defaultBlocks-B63ufZ5N.js.map +0 -1
  91. package/dist/defaultBlocks-BX6UxQa8.cjs +0 -6
  92. package/dist/defaultBlocks-BX6UxQa8.cjs.map +0 -1
@@ -89,41 +89,24 @@ export function getDefaultSlashMenuItems<
89
89
  const items: DefaultSuggestionItem[] = [];
90
90
 
91
91
  if (editorHasBlockWithType(editor, "heading", { level: "number" })) {
92
- items.push(
93
- {
94
- onItemClick: () => {
95
- insertOrUpdateBlockForSlashMenu(editor, {
96
- type: "heading",
97
- props: { level: 1 },
98
- });
99
- },
100
- badge: formatKeyboardShortcut("Mod-Alt-1"),
101
- key: "heading",
102
- ...editor.dictionary.slash_menu.heading,
103
- },
104
- {
105
- onItemClick: () => {
106
- insertOrUpdateBlockForSlashMenu(editor, {
107
- type: "heading",
108
- props: { level: 2 },
109
- });
110
- },
111
- badge: formatKeyboardShortcut("Mod-Alt-2"),
112
- key: "heading_2",
113
- ...editor.dictionary.slash_menu.heading_2,
114
- },
115
- {
116
- onItemClick: () => {
117
- insertOrUpdateBlockForSlashMenu(editor, {
118
- type: "heading",
119
- props: { level: 3 },
120
- });
121
- },
122
- badge: formatKeyboardShortcut("Mod-Alt-3"),
123
- key: "heading_3",
124
- ...editor.dictionary.slash_menu.heading_3,
125
- },
126
- );
92
+ (editor.schema.blockSchema.heading.propSchema.level.values || [])
93
+ .filter((level): level is 1 | 2 | 3 => level <= 3)
94
+ .forEach((level) => {
95
+ items.push({
96
+ onItemClick: () => {
97
+ insertOrUpdateBlockForSlashMenu(editor, {
98
+ type: "heading",
99
+ props: { level: level },
100
+ });
101
+ },
102
+ badge: formatKeyboardShortcut(`Mod-Alt-${level}`),
103
+ key:
104
+ level === 1 ? ("heading" as const) : (`heading_${level}` as const),
105
+ ...editor.dictionary.slash_menu[
106
+ level === 1 ? ("heading" as const) : (`heading_${level}` as const)
107
+ ],
108
+ });
109
+ });
127
110
  }
128
111
 
129
112
  if (editorHasBlockWithType(editor, "quote")) {
@@ -316,39 +299,27 @@ export function getDefaultSlashMenuItems<
316
299
  isToggleable: "boolean",
317
300
  })
318
301
  ) {
319
- items.push(
320
- {
321
- onItemClick: () => {
322
- insertOrUpdateBlockForSlashMenu(editor, {
323
- type: "heading",
324
- props: { level: 1, isToggleable: true },
325
- });
326
- },
327
- key: "toggle_heading",
328
- ...editor.dictionary.slash_menu.toggle_heading,
329
- },
330
- {
331
- onItemClick: () => {
332
- insertOrUpdateBlockForSlashMenu(editor, {
333
- type: "heading",
334
- props: { level: 2, isToggleable: true },
335
- });
336
- },
337
-
338
- key: "toggle_heading_2",
339
- ...editor.dictionary.slash_menu.toggle_heading_2,
340
- },
341
- {
342
- onItemClick: () => {
343
- insertOrUpdateBlockForSlashMenu(editor, {
344
- type: "heading",
345
- props: { level: 3, isToggleable: true },
346
- });
347
- },
348
- key: "toggle_heading_3",
349
- ...editor.dictionary.slash_menu.toggle_heading_3,
350
- },
351
- );
302
+ (editor.schema.blockSchema.heading.propSchema.level.values || [])
303
+ .filter((level): level is 1 | 2 | 3 => level <= 3)
304
+ .forEach((level) => {
305
+ items.push({
306
+ onItemClick: () => {
307
+ insertOrUpdateBlockForSlashMenu(editor, {
308
+ type: "heading",
309
+ props: { level: level, isToggleable: true },
310
+ });
311
+ },
312
+ key:
313
+ level === 1
314
+ ? ("toggle_heading" as const)
315
+ : (`toggle_heading_${level}` as const),
316
+ ...editor.dictionary.slash_menu[
317
+ level === 1
318
+ ? ("toggle_heading" as const)
319
+ : (`toggle_heading_${level}` as const)
320
+ ],
321
+ });
322
+ });
352
323
  }
353
324
 
354
325
  if (editorHasBlockWithType(editor, "heading", { level: "number" })) {
@@ -362,6 +333,7 @@ export function getDefaultSlashMenuItems<
362
333
  props: { level: level },
363
334
  });
364
335
  },
336
+ badge: formatKeyboardShortcut(`Mod-Alt-${level}`),
365
337
  key: `heading_${level}`,
366
338
  ...editor.dictionary.slash_menu[`heading_${level}`],
367
339
  });
@@ -621,12 +621,16 @@ export const TableHandlesExtension = createExtension(({ editor }) => {
621
621
  key: tableHandlesPluginKey,
622
622
  view: (editorView) => {
623
623
  view = new TableHandlesView(editor as any, editorView, (state) => {
624
- store.setState({
625
- ...state,
626
- draggingState: state.draggingState
627
- ? { ...state.draggingState }
624
+ store.setState(
625
+ state.block
626
+ ? {
627
+ ...state,
628
+ draggingState: state.draggingState
629
+ ? { ...state.draggingState }
630
+ : undefined,
631
+ }
628
632
  : undefined,
629
- });
633
+ );
630
634
  });
631
635
  return view;
632
636
  },
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export * from "./api/blockManipulation/commands/insertBlocks/insertBlocks.js";
2
2
  export * from "./api/blockManipulation/commands/replaceBlocks/replaceBlocks.js";
3
- export * from "./api/blockManipulation/commands/updateBlock/updateBlock.js";
4
3
  export * from "./api/blockManipulation/commands/replaceBlocks/util/fixColumnList.js";
4
+ export * from "./api/blockManipulation/commands/updateBlock/updateBlock.js";
5
5
  export * from "./api/exporters/html/externalHTMLExporter.js";
6
6
  export * from "./api/exporters/html/internalHTMLSerializer.js";
7
7
  export * from "./api/getBlockInfoFromPos.js";
@@ -19,6 +19,7 @@ export * from "./i18n/dictionary.js";
19
19
  export * from "./schema/index.js";
20
20
  export * from "./util/browser.js";
21
21
  export * from "./util/combineByGroup.js";
22
+ export * from "./util/expandToWords.js";
22
23
  export * from "./util/string.js";
23
24
  export * from "./util/table.js";
24
25
  export * from "./util/typescript.js";
@@ -70,6 +70,8 @@ export function getParseRules<
70
70
 
71
71
  return props;
72
72
  },
73
+ // Because we do the parsing ourselves, we want to preserve whitespace for content we've parsed
74
+ preserveWhitespace: true,
73
75
  getContent:
74
76
  config.content === "inline" || config.content === "none"
75
77
  ? (node, schema) => {
@@ -97,6 +99,7 @@ export function getParseRules<
97
99
  const parser = DOMParser.fromSchema(schema);
98
100
  const parsed = parser.parse(clone, {
99
101
  topNode: schema.nodes.paragraph.create(),
102
+ preserveWhitespace: true,
100
103
  });
101
104
 
102
105
  return parsed.content;
@@ -0,0 +1,38 @@
1
+ import type { Node, ResolvedPos } from "prosemirror-model";
2
+
3
+ /**
4
+ * Expands a range (start to end) to include the rest of the word if it starts or ends within a word
5
+ */
6
+ export function expandPMRangeToWords(
7
+ doc: Node,
8
+ range: { $from: ResolvedPos; $to: ResolvedPos },
9
+ ) {
10
+ let { $from, $to } = range;
11
+
12
+ // Expand Start
13
+ // If the selection starts with a word character or punctuation, check if we need to expand left to include the rest of the word
14
+ if ($from.pos > $from.start() && $from.pos < doc.content.size) {
15
+ const charAfterStart = doc.textBetween($from.pos, $from.pos + 1);
16
+ if (/^[\w\p{P}]$/u.test(charAfterStart)) {
17
+ const textBefore = doc.textBetween($from.start(), $from.pos);
18
+ const wordMatch = textBefore.match(/[\w\p{P}]+$/u);
19
+ if (wordMatch) {
20
+ $from = doc.resolve($from.pos - wordMatch[0].length);
21
+ }
22
+ }
23
+ }
24
+
25
+ // Expand End
26
+ // If the selection ends with a word characte or punctuation, check if we need to expand right to include the rest of the word
27
+ if ($to.pos < $to.end() && $to.pos > 0) {
28
+ const charBeforeEnd = doc.textBetween($to.pos - 1, $to.pos);
29
+ if (/^[\w\p{P}]$/u.test(charBeforeEnd)) {
30
+ const textAfter = doc.textBetween($to.pos, $to.end());
31
+ const wordMatch = textAfter.match(/^[\w\p{P}]+/u);
32
+ if (wordMatch) {
33
+ $to = doc.resolve($to.pos + wordMatch[0].length);
34
+ }
35
+ }
36
+ }
37
+ return { $from, $to, from: $from.pos, to: $to.pos };
38
+ }
@@ -4,7 +4,7 @@ import { Selection } from "../../../editor/selectionTypes.js";
4
4
  import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema/index.js";
5
5
  export declare function getSelection<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(tr: Transaction): Selection<BSchema, I, S> | undefined;
6
6
  export declare function setSelection(tr: Transaction, startBlock: BlockIdentifier, endBlock: BlockIdentifier): void;
7
- export declare function getSelectionCutBlocks(tr: Transaction): {
7
+ export declare function getSelectionCutBlocks(tr: Transaction, expandToWords?: boolean): {
8
8
  blocks: Block<Record<string, import("../../../index.js").BlockConfig<string, import("../../../index.js").PropSchema, "inline" | "none" | "table">>, InlineContentSchema, StyleSchema>[];
9
9
  blockCutAtStart: string | undefined;
10
10
  blockCutAtEnd: string | undefined;
@@ -1,9 +1,9 @@
1
1
  import { EditorOptions, FocusPosition, Editor as TiptapEditor } from "@tiptap/core";
2
2
  import { type Command, type Plugin, type Transaction } from "@tiptap/pm/state";
3
3
  import { Node, Schema } from "prosemirror-model";
4
- import * as Y from "yjs";
5
4
  import type { BlocksChanged } from "../api/getBlocksChangedByTransaction.js";
6
5
  import { Block, BlockNoteSchema, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, PartialBlock } from "../blocks/index.js";
6
+ import type { CollaborationOptions } from "../extensions/Collaboration/Collaboration.js";
7
7
  import type { Dictionary } from "../i18n/dictionary.js";
8
8
  import type { BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, BlockSpecs, CustomBlockNoteSchema, InlineContentSchema, InlineContentSpecs, PartialInlineContent, Styles, StyleSchema, StyleSpecs } from "../schema/index.js";
9
9
  import "../style.css";
@@ -30,37 +30,8 @@ export interface BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema ext
30
30
  /**
31
31
  * When enabled, allows for collaboration between multiple users.
32
32
  * See [Real-time Collaboration](https://www.blocknotejs.org/docs/advanced/real-time-collaboration) for more info.
33
- *
34
- * @remarks `CollaborationOptions`
35
33
  */
36
- collaboration?: {
37
- /**
38
- * The Yjs XML fragment that's used for collaboration.
39
- */
40
- fragment: Y.XmlFragment;
41
- /**
42
- * The user info for the current user that's shown to other collaborators.
43
- */
44
- user: {
45
- name: string;
46
- color: string;
47
- };
48
- /**
49
- * A Yjs provider (used for awareness / cursor information)
50
- */
51
- provider: any;
52
- /**
53
- * Optional function to customize how cursors of users are rendered
54
- */
55
- renderCursor?: (user: any) => HTMLElement;
56
- /**
57
- * Optional flag to set when the user label should be shown with the default
58
- * collaboration cursor. Setting to "always" will always show the label,
59
- * while "activity" will only show the label when the user moves the cursor
60
- * or types. Defaults to "activity".
61
- */
62
- showCursorLabels?: "always" | "activity";
63
- };
34
+ collaboration?: CollaborationOptions;
64
35
  /**
65
36
  * Use default BlockNote font and reset the styles of <p> <li> <h1> elements etc., that are used in BlockNote.
66
37
  *
@@ -481,9 +452,9 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
481
452
  * @returns A function to remove the callback.
482
453
  */
483
454
  onBeforeChange(callback: (context: {
484
- getChanges: () => BlocksChanged<any, any, any>;
455
+ getChanges: () => BlocksChanged<BSchema, ISchema, SSchema>;
485
456
  tr: Transaction;
486
- }) => boolean | void): (() => void) | undefined;
457
+ }) => boolean | void): () => void;
487
458
  /**
488
459
  * Gets a snapshot of the current text cursor position.
489
460
  * @returns A snapshot of the current text cursor position.
@@ -510,7 +481,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
510
481
  * If the selection starts / ends halfway through a block, the returned block will be
511
482
  * only the part of the block that is included in the selection.
512
483
  */
513
- getSelectionCutBlocks(): {
484
+ getSelectionCutBlocks(expandToWords?: boolean): {
514
485
  blocks: Block<Record<string, import("../index.js").BlockConfig<string, import("../index.js").PropSchema, "inline" | "none" | "table">>, InlineContentSchema, StyleSchema>[];
515
486
  blockCutAtStart: string | undefined;
516
487
  blockCutAtEnd: string | undefined;
@@ -78,6 +78,10 @@ export interface Extension<State = any, Key extends string = string> {
78
78
  * Add additional tiptap extensions to the editor.
79
79
  */
80
80
  readonly tiptapExtensions?: ReadonlyArray<AnyExtension>;
81
+ /**
82
+ * Add additional BlockNote extensions to the editor.
83
+ */
84
+ readonly blockNoteExtensions?: ReadonlyArray<ExtensionFactoryInstance>;
81
85
  }
82
86
  /**
83
87
  * An input rule is what is used to replace text in a block when a regular expression match is found.
@@ -1,8 +1,8 @@
1
- import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../schema/index.js";
2
1
  import { DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema } from "../../blocks/defaultBlocks.js";
3
- import { Selection } from "../selectionTypes.js";
4
- import { TextCursorPosition } from "../cursorPositionTypes.js";
2
+ import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../schema/index.js";
5
3
  import { BlockNoteEditor } from "../BlockNoteEditor.js";
4
+ import { TextCursorPosition } from "../cursorPositionTypes.js";
5
+ import { Selection } from "../selectionTypes.js";
6
6
  export declare class SelectionManager<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> {
7
7
  private editor;
8
8
  constructor(editor: BlockNoteEditor<BSchema, ISchema, SSchema>);
@@ -20,7 +20,7 @@ export declare class SelectionManager<BSchema extends BlockSchema = DefaultBlock
20
20
  * If the selection starts / ends halfway through a block, the returned block will be
21
21
  * only the part of the block that is included in the selection.
22
22
  */
23
- getSelectionCutBlocks(): {
23
+ getSelectionCutBlocks(expandToWords?: boolean): {
24
24
  blocks: import("../../index.js").Block<Record<string, import("../../index.js").BlockConfig<string, import("../../index.js").PropSchema, "inline" | "none" | "table">>, InlineContentSchema, StyleSchema>[];
25
25
  blockCutAtStart: string | undefined;
26
26
  blockCutAtEnd: string | undefined;
@@ -0,0 +1,76 @@
1
+ import type * as Y from "yjs";
2
+ import type { Awareness } from "y-protocols/awareness";
3
+ export type CollaborationOptions = {
4
+ /**
5
+ * The Yjs XML fragment that's used for collaboration.
6
+ */
7
+ fragment: Y.XmlFragment;
8
+ /**
9
+ * The user info for the current user that's shown to other collaborators.
10
+ */
11
+ user: {
12
+ name: string;
13
+ color: string;
14
+ };
15
+ /**
16
+ * A Yjs provider (used for awareness / cursor information)
17
+ */
18
+ provider?: {
19
+ awareness?: Awareness;
20
+ };
21
+ /**
22
+ * Optional function to customize how cursors of users are rendered
23
+ */
24
+ renderCursor?: (user: any) => HTMLElement;
25
+ /**
26
+ * Optional flag to set when the user label should be shown with the default
27
+ * collaboration cursor. Setting to "always" will always show the label,
28
+ * while "activity" will only show the label when the user moves the cursor
29
+ * or types. Defaults to "activity".
30
+ */
31
+ showCursorLabels?: "always" | "activity";
32
+ };
33
+ export declare const CollaborationExtension: (options: CollaborationOptions) => import("../../index.js").ExtensionFactoryInstance<{
34
+ readonly key: "collaboration";
35
+ readonly blockNoteExtensions: readonly [import("../../index.js").ExtensionFactoryInstance<{
36
+ readonly key: "yForkDoc";
37
+ readonly store: import("@tanstack/store").Store<{
38
+ isForked: boolean;
39
+ }, (cb: {
40
+ isForked: boolean;
41
+ }) => {
42
+ isForked: boolean;
43
+ }>;
44
+ readonly fork: () => void;
45
+ readonly merge: ({ keepChanges }: {
46
+ keepChanges: boolean;
47
+ }) => void;
48
+ }>, import("../../index.js").ExtensionFactoryInstance<{
49
+ readonly key: "yCursor";
50
+ readonly prosemirrorPlugins: any[];
51
+ readonly dependsOn: readonly ["ySync"];
52
+ readonly updateUser: (user: {
53
+ name: string;
54
+ color: string;
55
+ [key: string]: string;
56
+ }) => void;
57
+ }>, import("../../index.js").ExtensionFactoryInstance<{
58
+ readonly key: "ySync";
59
+ readonly prosemirrorPlugins: readonly [any];
60
+ readonly runsBefore: readonly ["default"];
61
+ }>, import("../../index.js").ExtensionFactoryInstance<{
62
+ readonly key: "yUndo";
63
+ readonly prosemirrorPlugins: readonly [import("prosemirror-state").Plugin<{
64
+ undoManager: Y.UndoManager;
65
+ prevSel: any;
66
+ hasUndoOps: boolean;
67
+ hasRedoOps: boolean;
68
+ }>];
69
+ readonly dependsOn: readonly ["yCursor", "ySync"];
70
+ readonly undoCommand: import("prosemirror-state").Command;
71
+ readonly redoCommand: import("prosemirror-state").Command;
72
+ }>, import("../../index.js").ExtensionFactoryInstance<{
73
+ readonly key: "schemaMigration";
74
+ readonly prosemirrorPlugins: readonly [import("prosemirror-state").Plugin<any>];
75
+ }>];
76
+ }>;
@@ -1,14 +1,5 @@
1
- import * as Y from "yjs";
2
- export declare const ForkYDocExtension: (options: {
3
- fragment: Y.XmlFragment;
4
- user: {
5
- name: string;
6
- color: string;
7
- };
8
- provider: any;
9
- renderCursor?: (user: any) => HTMLElement;
10
- showCursorLabels?: "always" | "activity";
11
- }) => import("../../index.js").ExtensionFactoryInstance<{
1
+ import { CollaborationOptions } from "./Collaboration.js";
2
+ export declare const ForkYDocExtension: (options: CollaborationOptions) => import("../../index.js").ExtensionFactoryInstance<{
12
3
  readonly key: "yForkDoc";
13
4
  readonly store: import("@tanstack/store").Store<{
14
5
  isForked: boolean;
@@ -1,20 +1,12 @@
1
+ import { CollaborationOptions } from "./Collaboration.js";
1
2
  export type CollaborationUser = {
2
3
  name: string;
3
4
  color: string;
4
5
  [key: string]: string;
5
6
  };
6
- export declare const YCursorExtension: (options: {
7
- fragment: import("yjs").XmlFragment;
8
- user: {
9
- name: string;
10
- color: string;
11
- };
12
- provider: any;
13
- renderCursor?: (user: any) => HTMLElement;
14
- showCursorLabels?: "always" | "activity";
15
- }) => import("../../index.js").ExtensionFactoryInstance<{
7
+ export declare const YCursorExtension: (options: CollaborationOptions) => import("../../index.js").ExtensionFactoryInstance<{
16
8
  readonly key: "yCursor";
17
- readonly prosemirrorPlugins: readonly [any];
9
+ readonly prosemirrorPlugins: any[];
18
10
  readonly dependsOn: readonly ["ySync"];
19
11
  readonly updateUser: (user: {
20
12
  name: string;
@@ -1,7 +1,5 @@
1
- import { XmlFragment } from "yjs";
2
- export declare const YSyncExtension: (options: {
3
- fragment: XmlFragment;
4
- }) => import("../../index.js").ExtensionFactoryInstance<{
1
+ import { CollaborationOptions } from "./Collaboration.js";
2
+ export declare const YSyncExtension: (options: Pick<CollaborationOptions, "fragment">) => import("../../index.js").ExtensionFactoryInstance<{
5
3
  readonly key: "ySync";
6
4
  readonly prosemirrorPlugins: readonly [any];
7
5
  readonly runsBefore: readonly ["default"];
@@ -1,4 +1,4 @@
1
- export declare const YUndoExtension: (options?: any) => import("../../index.js").ExtensionFactoryInstance<{
1
+ export declare const YUndoExtension: () => import("../../index.js").ExtensionFactoryInstance<{
2
2
  readonly key: "yUndo";
3
3
  readonly prosemirrorPlugins: readonly [import("prosemirror-state").Plugin<{
4
4
  undoManager: import("yjs").UndoManager;
@@ -7,15 +7,21 @@ import { Plugin } from "prosemirror-state";
7
7
  export declare const ShowSelectionExtension: (options?: any) => import("../../index.js").ExtensionFactoryInstance<{
8
8
  readonly key: "showSelection";
9
9
  readonly store: import("@tanstack/store").Store<{
10
- enabled: boolean;
10
+ enabledSet: Set<string>;
11
11
  }, (cb: {
12
- enabled: boolean;
12
+ enabledSet: Set<string>;
13
13
  }) => {
14
- enabled: boolean;
14
+ enabledSet: Set<string>;
15
15
  }>;
16
16
  readonly prosemirrorPlugins: readonly [Plugin<any>];
17
17
  /**
18
18
  * Show or hide the selection decoration
19
+ *
20
+ * @param shouldShow - Whether to show the selection decoration
21
+ * @param key - The key of the selection to show or hide,
22
+ * this is necessary to prevent disabling ShowSelection from one place
23
+ * will interfere with other parts of the code that need to show the selection decoration
24
+ * (e.g.: CreateLinkButton and AIExtension)
19
25
  */
20
- readonly showSelection: (shouldShow: boolean) => void;
26
+ readonly showSelection: (shouldShow: boolean, key: string) => void;
21
27
  }>;
@@ -1,7 +1,7 @@
1
1
  export * from "./api/blockManipulation/commands/insertBlocks/insertBlocks.js";
2
2
  export * from "./api/blockManipulation/commands/replaceBlocks/replaceBlocks.js";
3
- export * from "./api/blockManipulation/commands/updateBlock/updateBlock.js";
4
3
  export * from "./api/blockManipulation/commands/replaceBlocks/util/fixColumnList.js";
4
+ export * from "./api/blockManipulation/commands/updateBlock/updateBlock.js";
5
5
  export * from "./api/exporters/html/externalHTMLExporter.js";
6
6
  export * from "./api/exporters/html/internalHTMLSerializer.js";
7
7
  export * from "./api/getBlockInfoFromPos.js";
@@ -19,6 +19,7 @@ export * from "./i18n/dictionary.js";
19
19
  export * from "./schema/index.js";
20
20
  export * from "./util/browser.js";
21
21
  export * from "./util/combineByGroup.js";
22
+ export * from "./util/expandToWords.js";
22
23
  export * from "./util/string.js";
23
24
  export * from "./util/table.js";
24
25
  export * from "./util/typescript.js";
@@ -0,0 +1,13 @@
1
+ import type { Node, ResolvedPos } from "prosemirror-model";
2
+ /**
3
+ * Expands a range (start to end) to include the rest of the word if it starts or ends within a word
4
+ */
5
+ export declare function expandPMRangeToWords(doc: Node, range: {
6
+ $from: ResolvedPos;
7
+ $to: ResolvedPos;
8
+ }): {
9
+ $from: ResolvedPos;
10
+ $to: ResolvedPos;
11
+ from: number;
12
+ to: number;
13
+ };
@@ -1,2 +0,0 @@
1
- "use strict";const i=require("prosemirror-state"),o=require("prosemirror-view"),r=require("./BlockNoteExtension-BWw0r8Gy.cjs"),s=new i.PluginKey("blocknote-show-selection"),u=r.createExtension(({editor:c})=>{const t=r.createStore({enabled:!1},{onUpdate(){c.transact(e=>e.setMeta(s,{}))}});return{key:"showSelection",store:t,prosemirrorPlugins:[new i.Plugin({key:s,props:{decorations:e=>{const{doc:a,selection:n}=e;if(!t.state.enabled)return o.DecorationSet.empty;const l=o.Decoration.inline(n.from,n.to,{"data-show-selection":"true"});return o.DecorationSet.create(a,[l])}}})],showSelection(e){t.setState({enabled:e})}}});exports.ShowSelectionExtension=u;
2
- //# sourceMappingURL=ShowSelection-BW37oJ6h.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ShowSelection-BW37oJ6h.cjs","sources":["../src/extensions/ShowSelection/ShowSelection.ts"],"sourcesContent":["import { Plugin, PluginKey } from \"prosemirror-state\";\nimport { Decoration, DecorationSet } from \"prosemirror-view\";\nimport {\n createExtension,\n createStore,\n} from \"../../editor/BlockNoteExtension.js\";\n\nconst PLUGIN_KEY = new PluginKey(`blocknote-show-selection`);\n\n/**\n * Plugin that shows adds a decoration around the current selection\n * This can be used to highlight the current selection in the UI even when the\n * text editor is not focused.\n */\nexport const ShowSelectionExtension = createExtension(({ editor }) => {\n const store = createStore(\n { enabled: false },\n {\n onUpdate() {\n editor.transact((tr) => tr.setMeta(PLUGIN_KEY, {}));\n },\n },\n );\n return {\n key: \"showSelection\",\n store,\n prosemirrorPlugins: [\n new Plugin({\n key: PLUGIN_KEY,\n props: {\n decorations: (state) => {\n const { doc, selection } = state;\n if (!store.state.enabled) {\n return DecorationSet.empty;\n }\n const dec = Decoration.inline(selection.from, selection.to, {\n \"data-show-selection\": \"true\",\n });\n return DecorationSet.create(doc, [dec]);\n },\n },\n }),\n ],\n /**\n * Show or hide the selection decoration\n */\n showSelection(shouldShow: boolean) {\n store.setState({ enabled: shouldShow });\n },\n } as const;\n});\n"],"names":["PLUGIN_KEY","PluginKey","ShowSelectionExtension","createExtension","editor","store","createStore","tr","Plugin","state","doc","selection","DecorationSet","dec","Decoration","shouldShow"],"mappings":"+HAOMA,EAAa,IAAIC,EAAAA,UAAU,0BAA0B,EAO9CC,EAAyBC,EAAAA,gBAAgB,CAAC,CAAE,OAAAC,KAAa,CACpE,MAAMC,EAAQC,EAAAA,YACZ,CAAE,QAAS,EAAA,EACX,CACE,UAAW,CACTF,EAAO,SAAUG,GAAOA,EAAG,QAAQP,EAAY,CAAA,CAAE,CAAC,CACpD,CAAA,CACF,EAEF,MAAO,CACL,IAAK,gBACL,MAAAK,EACA,mBAAoB,CAClB,IAAIG,SAAO,CACT,IAAKR,EACL,MAAO,CACL,YAAcS,GAAU,CACtB,KAAM,CAAE,IAAAC,EAAK,UAAAC,CAAA,EAAcF,EAC3B,GAAI,CAACJ,EAAM,MAAM,QACf,OAAOO,EAAAA,cAAc,MAEvB,MAAMC,EAAMC,EAAAA,WAAW,OAAOH,EAAU,KAAMA,EAAU,GAAI,CAC1D,sBAAuB,MAAA,CACxB,EACD,OAAOC,EAAAA,cAAc,OAAOF,EAAK,CAACG,CAAG,CAAC,CACxC,CAAA,CACF,CACD,CAAA,EAKH,cAAcE,EAAqB,CACjCV,EAAM,SAAS,CAAE,QAASU,CAAA,CAAY,CACxC,CAAA,CAEJ,CAAC"}
@@ -1,43 +0,0 @@
1
- import { PluginKey as i, Plugin as l } from "prosemirror-state";
2
- import { DecorationSet as n, Decoration as m } from "prosemirror-view";
3
- import { c as p, a as d } from "./BlockNoteExtension-C2X7LW-V.js";
4
- const r = new i("blocknote-show-selection"), f = p(({ editor: s }) => {
5
- const t = d(
6
- { enabled: !1 },
7
- {
8
- onUpdate() {
9
- s.transact((e) => e.setMeta(r, {}));
10
- }
11
- }
12
- );
13
- return {
14
- key: "showSelection",
15
- store: t,
16
- prosemirrorPlugins: [
17
- new l({
18
- key: r,
19
- props: {
20
- decorations: (e) => {
21
- const { doc: a, selection: o } = e;
22
- if (!t.state.enabled)
23
- return n.empty;
24
- const c = m.inline(o.from, o.to, {
25
- "data-show-selection": "true"
26
- });
27
- return n.create(a, [c]);
28
- }
29
- }
30
- })
31
- ],
32
- /**
33
- * Show or hide the selection decoration
34
- */
35
- showSelection(e) {
36
- t.setState({ enabled: e });
37
- }
38
- };
39
- });
40
- export {
41
- f as S
42
- };
43
- //# sourceMappingURL=ShowSelection-Dz-NEase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ShowSelection-Dz-NEase.js","sources":["../src/extensions/ShowSelection/ShowSelection.ts"],"sourcesContent":["import { Plugin, PluginKey } from \"prosemirror-state\";\nimport { Decoration, DecorationSet } from \"prosemirror-view\";\nimport {\n createExtension,\n createStore,\n} from \"../../editor/BlockNoteExtension.js\";\n\nconst PLUGIN_KEY = new PluginKey(`blocknote-show-selection`);\n\n/**\n * Plugin that shows adds a decoration around the current selection\n * This can be used to highlight the current selection in the UI even when the\n * text editor is not focused.\n */\nexport const ShowSelectionExtension = createExtension(({ editor }) => {\n const store = createStore(\n { enabled: false },\n {\n onUpdate() {\n editor.transact((tr) => tr.setMeta(PLUGIN_KEY, {}));\n },\n },\n );\n return {\n key: \"showSelection\",\n store,\n prosemirrorPlugins: [\n new Plugin({\n key: PLUGIN_KEY,\n props: {\n decorations: (state) => {\n const { doc, selection } = state;\n if (!store.state.enabled) {\n return DecorationSet.empty;\n }\n const dec = Decoration.inline(selection.from, selection.to, {\n \"data-show-selection\": \"true\",\n });\n return DecorationSet.create(doc, [dec]);\n },\n },\n }),\n ],\n /**\n * Show or hide the selection decoration\n */\n showSelection(shouldShow: boolean) {\n store.setState({ enabled: shouldShow });\n },\n } as const;\n});\n"],"names":["PLUGIN_KEY","PluginKey","ShowSelectionExtension","createExtension","editor","store","createStore","tr","Plugin","state","doc","selection","DecorationSet","dec","Decoration","shouldShow"],"mappings":";;;AAOA,MAAMA,IAAa,IAAIC,EAAU,0BAA0B,GAO9CC,IAAyBC,EAAgB,CAAC,EAAE,QAAAC,QAAa;AACpE,QAAMC,IAAQC;AAAA,IACZ,EAAE,SAAS,GAAA;AAAA,IACX;AAAA,MACE,WAAW;AACT,QAAAF,EAAO,SAAS,CAACG,MAAOA,EAAG,QAAQP,GAAY,CAAA,CAAE,CAAC;AAAA,MACpD;AAAA,IAAA;AAAA,EACF;AAEF,SAAO;AAAA,IACL,KAAK;AAAA,IACL,OAAAK;AAAA,IACA,oBAAoB;AAAA,MAClB,IAAIG,EAAO;AAAA,QACT,KAAKR;AAAA,QACL,OAAO;AAAA,UACL,aAAa,CAACS,MAAU;AACtB,kBAAM,EAAE,KAAAC,GAAK,WAAAC,EAAA,IAAcF;AAC3B,gBAAI,CAACJ,EAAM,MAAM;AACf,qBAAOO,EAAc;AAEvB,kBAAMC,IAAMC,EAAW,OAAOH,EAAU,MAAMA,EAAU,IAAI;AAAA,cAC1D,uBAAuB;AAAA,YAAA,CACxB;AACD,mBAAOC,EAAc,OAAOF,GAAK,CAACG,CAAG,CAAC;AAAA,UACxC;AAAA,QAAA;AAAA,MACF,CACD;AAAA,IAAA;AAAA;AAAA;AAAA;AAAA,IAKH,cAAcE,GAAqB;AACjC,MAAAV,EAAM,SAAS,EAAE,SAASU,EAAA,CAAY;AAAA,IACxC;AAAA,EAAA;AAEJ,CAAC;"}