@blocknote/core 0.30.0 → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.cjs +2 -2
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +22 -20
- package/dist/blocknote.js.map +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +5 -3
- package/src/api/README.md +1 -1
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +19 -14
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +5 -5
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +3 -3
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +12 -12
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +14 -14
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +16 -16
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +8 -8
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +12 -12
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +7 -7
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +10 -10
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +2 -2
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +42 -42
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +18 -18
- package/src/api/blockManipulation/getBlock/getBlock.ts +9 -9
- package/src/api/blockManipulation/insertContentAt.ts +1 -1
- package/src/api/blockManipulation/selections/selection.ts +11 -11
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts +7 -7
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +6 -6
- package/src/api/blockManipulation/tables/tables.test.ts +106 -106
- package/src/api/blockManipulation/tables/tables.ts +35 -35
- package/src/api/clipboard/fromClipboard/fileDropExtension.ts +2 -2
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +9 -9
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +3 -3
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +3 -3
- package/src/api/clipboard/toClipboard/copyExtension.ts +22 -22
- package/src/api/exporters/html/externalHTMLExporter.ts +6 -6
- package/src/api/exporters/html/internalHTMLSerializer.ts +3 -3
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +16 -16
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +14 -14
- package/src/api/exporters/markdown/markdownExporter.ts +3 -3
- package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +3 -3
- package/src/api/getBlockInfoFromPos.ts +6 -6
- package/src/api/nodeConversions/blockToNode.ts +26 -26
- package/src/api/nodeConversions/fragmentToBlocks.ts +1 -1
- package/src/api/nodeConversions/nodeToBlock.ts +37 -33
- package/src/api/nodeUtil.test.ts +16 -16
- package/src/api/nodeUtil.ts +10 -10
- package/src/api/parsers/html/parseHTML.ts +1 -1
- package/src/api/parsers/html/util/nestedLists.ts +2 -2
- package/src/api/parsers/markdown/parseMarkdown.ts +1 -1
- package/src/api/pmUtil.ts +4 -4
- package/src/api/positionMapping.test.ts +3 -3
- package/src/api/positionMapping.ts +5 -5
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +4 -4
- package/src/blocks/CodeBlockContent/CodeBlockContent.ts +12 -12
- package/src/blocks/FileBlockContent/FileBlockContent.ts +2 -2
- package/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.ts +2 -2
- package/src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts +5 -5
- package/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.ts +2 -2
- package/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.ts +1 -1
- package/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts +7 -7
- package/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.ts +1 -1
- package/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.ts +1 -1
- package/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts +2 -2
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +6 -6
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +4 -4
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +4 -4
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +10 -10
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +4 -4
- package/src/blocks/ListItemBlockContent/getListItemContent.ts +5 -5
- package/src/blocks/PageBreakBlockContent/PageBreakBlockContent.ts +1 -1
- package/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.ts +3 -3
- package/src/blocks/PageBreakBlockContent/schema.ts +2 -2
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +3 -3
- package/src/blocks/QuoteBlockContent/QuoteBlockContent.ts +4 -4
- package/src/blocks/README.md +1 -1
- package/src/blocks/TableBlockContent/TableBlockContent.ts +5 -5
- package/src/blocks/TableBlockContent/TableExtension.ts +3 -3
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +4 -4
- package/src/blocks/defaultBlockHelpers.ts +8 -8
- package/src/blocks/defaultBlockTypeGuards.ts +16 -16
- package/src/blocks/defaultBlocks.ts +3 -3
- package/src/comments/threadstore/DefaultThreadStoreAuth.ts +3 -3
- package/src/comments/threadstore/ThreadStore.ts +1 -1
- package/src/comments/threadstore/TipTapThreadStore.ts +10 -10
- package/src/comments/threadstore/yjs/RESTYjsThreadStore.ts +4 -4
- package/src/comments/threadstore/yjs/YjsThreadStore.test.ts +2 -2
- package/src/comments/threadstore/yjs/YjsThreadStore.ts +14 -14
- package/src/comments/threadstore/yjs/YjsThreadStoreBase.ts +1 -1
- package/src/comments/threadstore/yjs/yjsHelpers.ts +6 -6
- package/src/editor/Block.css +8 -0
- package/src/editor/BlockNoteEditor.test.ts +3 -3
- package/src/editor/BlockNoteEditor.ts +7 -1
- package/src/editor/BlockNoteExtensions.ts +10 -10
- package/src/editor/BlockNoteSchema.ts +4 -4
- package/src/editor/BlockNoteTipTapEditor.ts +10 -10
- package/src/editor/README.md +1 -1
- package/src/editor/cursorPositionTypes.ts +1 -1
- package/src/editor/editor.css +15 -3
- package/src/editor/selectionTypes.ts +1 -1
- package/src/editor/transformPasted.ts +2 -2
- package/src/exporter/Exporter.ts +5 -5
- package/src/exporter/mapping.ts +7 -7
- package/src/extensions/BackgroundColor/BackgroundColorMark.ts +1 -1
- package/src/extensions/Collaboration/CursorPlugin.ts +2 -2
- package/src/extensions/Comments/CommentsPlugin.ts +9 -9
- package/src/extensions/Comments/userstore/UserStore.ts +2 -2
- package/src/extensions/FilePanel/FilePanelPlugin.ts +7 -7
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +4 -4
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +26 -26
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +11 -11
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +4 -4
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +10 -10
- package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +2 -2
- package/src/extensions/README.md +1 -1
- package/src/extensions/SideMenu/MultipleNodeSelection.ts +1 -1
- package/src/extensions/SideMenu/SideMenuPlugin.ts +31 -31
- package/src/extensions/SideMenu/dragging.ts +8 -8
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +17 -17
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +2 -2
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +12 -12
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +54 -53
- package/src/extensions/TrailingNode/TrailingNodeExtension.ts +1 -1
- package/src/extensions/UniqueID/UniqueID.ts +6 -6
- package/src/extensions/getDraggableBlockFromElement.ts +1 -1
- package/src/fonts/inter.css +18 -9
- package/src/locales.ts +1 -1
- package/src/pm-nodes/BlockGroup.ts +1 -1
- package/src/pm-nodes/Doc.ts +4 -4
- package/src/schema/README.md +1 -1
- package/src/schema/blocks/createSpec.ts +14 -14
- package/src/schema/blocks/internal.ts +17 -17
- package/src/schema/blocks/types.ts +25 -25
- package/src/schema/inlineContent/createSpec.ts +16 -20
- package/src/schema/inlineContent/internal.ts +9 -9
- package/src/schema/inlineContent/types.ts +26 -26
- package/src/schema/propTypes.ts +8 -8
- package/src/schema/styles/createSpec.ts +2 -2
- package/src/schema/styles/internal.ts +7 -7
- package/src/schema/styles/types.ts +2 -2
- package/src/util/EventEmitter.ts +4 -4
- package/src/util/README.md +1 -1
- package/src/util/combineByGroup.ts +1 -1
- package/src/util/table.ts +33 -30
- package/types/src/editor/BlockNoteEditor.d.ts +3 -1
|
@@ -28,14 +28,14 @@ function removeUndefined<T extends Record<string, any> | undefined>(obj: T): T {
|
|
|
28
28
|
return obj;
|
|
29
29
|
}
|
|
30
30
|
return Object.fromEntries(
|
|
31
|
-
Object.entries(obj).filter(([, value]) => value !== undefined)
|
|
31
|
+
Object.entries(obj).filter(([, value]) => value !== undefined),
|
|
32
32
|
) as T;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export class BlockNoteSchema<
|
|
36
36
|
BSchema extends BlockSchema,
|
|
37
37
|
ISchema extends InlineContentSchema,
|
|
38
|
-
SSchema extends StyleSchema
|
|
38
|
+
SSchema extends StyleSchema,
|
|
39
39
|
> {
|
|
40
40
|
public readonly blockSpecs: BlockSpecs;
|
|
41
41
|
public readonly inlineContentSpecs: InlineContentSpecs;
|
|
@@ -61,7 +61,7 @@ export class BlockNoteSchema<
|
|
|
61
61
|
public static create<
|
|
62
62
|
BSpecs extends BlockSpecs = typeof defaultBlockSpecs,
|
|
63
63
|
ISpecs extends InlineContentSpecs = typeof defaultInlineContentSpecs,
|
|
64
|
-
SSpecs extends StyleSpecs = typeof defaultStyleSpecs
|
|
64
|
+
SSpecs extends StyleSpecs = typeof defaultStyleSpecs,
|
|
65
65
|
>(options?: {
|
|
66
66
|
/**
|
|
67
67
|
* A list of custom block types that should be available in the editor.
|
|
@@ -100,7 +100,7 @@ export class BlockNoteSchema<
|
|
|
100
100
|
|
|
101
101
|
this.blockSchema = getBlockSchemaFromSpecs(this.blockSpecs) as any;
|
|
102
102
|
this.inlineContentSchema = getInlineContentSchemaFromSpecs(
|
|
103
|
-
this.inlineContentSpecs
|
|
103
|
+
this.inlineContentSpecs,
|
|
104
104
|
) as any;
|
|
105
105
|
this.styleSchema = getStyleSchemaFromSpecs(this.styleSpecs) as any;
|
|
106
106
|
}
|
|
@@ -26,7 +26,7 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
|
|
|
26
26
|
|
|
27
27
|
public static create = (
|
|
28
28
|
options: BlockNoteTipTapEditorOptions,
|
|
29
|
-
styleSchema: StyleSchema
|
|
29
|
+
styleSchema: StyleSchema,
|
|
30
30
|
) => {
|
|
31
31
|
// because we separate the constructor from the creation of the view,
|
|
32
32
|
// we need to patch setTimeout to prevent this code from having any effect:
|
|
@@ -48,7 +48,7 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
|
|
|
48
48
|
|
|
49
49
|
protected constructor(
|
|
50
50
|
options: BlockNoteTipTapEditorOptions,
|
|
51
|
-
styleSchema: StyleSchema
|
|
51
|
+
styleSchema: StyleSchema,
|
|
52
52
|
) {
|
|
53
53
|
// possible fix for next.js server side rendering
|
|
54
54
|
// const d = globalThis.document;
|
|
@@ -93,7 +93,7 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
|
|
|
93
93
|
|
|
94
94
|
try {
|
|
95
95
|
const pmNodes = options?.content.map((b) =>
|
|
96
|
-
blockToNode(b, this.schema, styleSchema).toJSON()
|
|
96
|
+
blockToNode(b, this.schema, styleSchema).toJSON(),
|
|
97
97
|
);
|
|
98
98
|
doc = createDocument(
|
|
99
99
|
{
|
|
@@ -106,17 +106,17 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
|
|
|
106
106
|
],
|
|
107
107
|
},
|
|
108
108
|
this.schema,
|
|
109
|
-
this.options.parseOptions
|
|
109
|
+
this.options.parseOptions,
|
|
110
110
|
);
|
|
111
111
|
} catch (e) {
|
|
112
112
|
// eslint-disable-next-line no-console
|
|
113
113
|
console.error(
|
|
114
114
|
"Error creating document from blocks passed as `initialContent`. Caused by exception: ",
|
|
115
|
-
e
|
|
115
|
+
e,
|
|
116
116
|
);
|
|
117
117
|
throw new Error(
|
|
118
118
|
"Error creating document from blocks passed as `initialContent`:\n" +
|
|
119
|
-
+JSON.stringify(options.content)
|
|
119
|
+
+JSON.stringify(options.content),
|
|
120
120
|
);
|
|
121
121
|
}
|
|
122
122
|
|
|
@@ -221,7 +221,7 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
|
|
|
221
221
|
*/
|
|
222
222
|
private createViewAlternative(
|
|
223
223
|
blockNoteEditor: BlockNoteEditor<any, any, any>,
|
|
224
|
-
contentComponent?: any
|
|
224
|
+
contentComponent?: any,
|
|
225
225
|
) {
|
|
226
226
|
(this as any).contentComponent = contentComponent;
|
|
227
227
|
|
|
@@ -244,7 +244,7 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
|
|
|
244
244
|
state: this.state,
|
|
245
245
|
markViews,
|
|
246
246
|
nodeViews: this.extensionManager.nodeViews,
|
|
247
|
-
}
|
|
247
|
+
},
|
|
248
248
|
);
|
|
249
249
|
|
|
250
250
|
// `editor.view` is not yet available at this time.
|
|
@@ -263,7 +263,7 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
|
|
|
263
263
|
this.commands.focus(
|
|
264
264
|
this.options.autofocus ||
|
|
265
265
|
this.options.element.getAttribute("data-bn-autofocus") === "true",
|
|
266
|
-
{ scrollIntoView: false }
|
|
266
|
+
{ scrollIntoView: false },
|
|
267
267
|
);
|
|
268
268
|
this.emit("create", { editor: this });
|
|
269
269
|
this.isInitialized = true;
|
|
@@ -277,7 +277,7 @@ export class BlockNoteTipTapEditor extends TiptapEditor {
|
|
|
277
277
|
public mount = (
|
|
278
278
|
blockNoteEditor: BlockNoteEditor<any, any, any>,
|
|
279
279
|
element?: HTMLElement | null,
|
|
280
|
-
contentComponent?: any
|
|
280
|
+
contentComponent?: any,
|
|
281
281
|
) => {
|
|
282
282
|
if (!element) {
|
|
283
283
|
this.destroy();
|
package/src/editor/README.md
CHANGED
package/src/editor/editor.css
CHANGED
|
@@ -55,9 +55,21 @@ Tippy popups that are appended to document.body directly
|
|
|
55
55
|
.bn-default-styles {
|
|
56
56
|
font-size: 16px;
|
|
57
57
|
font-weight: normal;
|
|
58
|
-
font-family:
|
|
59
|
-
"
|
|
60
|
-
"
|
|
58
|
+
font-family:
|
|
59
|
+
"Inter",
|
|
60
|
+
"SF Pro Display",
|
|
61
|
+
-apple-system,
|
|
62
|
+
BlinkMacSystemFont,
|
|
63
|
+
"Open Sans",
|
|
64
|
+
"Segoe UI",
|
|
65
|
+
"Roboto",
|
|
66
|
+
"Oxygen",
|
|
67
|
+
"Ubuntu",
|
|
68
|
+
"Cantarell",
|
|
69
|
+
"Fira Sans",
|
|
70
|
+
"Droid Sans",
|
|
71
|
+
"Helvetica Neue",
|
|
72
|
+
sans-serif;
|
|
61
73
|
-webkit-font-smoothing: antialiased;
|
|
62
74
|
-moz-osx-font-smoothing: grayscale;
|
|
63
75
|
}
|
|
@@ -36,7 +36,7 @@ export function wrapTableRows(f: Fragment, schema: Schema) {
|
|
|
36
36
|
// create new table to wrap tableRow with
|
|
37
37
|
const newTable = schema.nodes.table.createChecked(
|
|
38
38
|
undefined,
|
|
39
|
-
f.child(i)
|
|
39
|
+
f.child(i),
|
|
40
40
|
);
|
|
41
41
|
newItems.push(newTable);
|
|
42
42
|
}
|
|
@@ -96,7 +96,7 @@ export function transformPasted(slice: Slice, view: EditorView) {
|
|
|
96
96
|
}
|
|
97
97
|
const container = view.state.schema.nodes.blockContainer.createChecked(
|
|
98
98
|
undefined,
|
|
99
|
-
content
|
|
99
|
+
content,
|
|
100
100
|
);
|
|
101
101
|
f = f.replaceChild(i, container);
|
|
102
102
|
}
|
package/src/exporter/Exporter.ts
CHANGED
|
@@ -42,7 +42,7 @@ export abstract class Exporter<
|
|
|
42
42
|
RB,
|
|
43
43
|
RI,
|
|
44
44
|
RS,
|
|
45
|
-
TS
|
|
45
|
+
TS,
|
|
46
46
|
> {
|
|
47
47
|
public constructor(
|
|
48
48
|
_schema: BlockNoteSchema<B, I, S>, // only used for type inference
|
|
@@ -51,7 +51,7 @@ export abstract class Exporter<
|
|
|
51
51
|
inlineContentMapping: InlineContentMapping<I, S, RI, TS>;
|
|
52
52
|
styleMapping: StyleMapping<S, RS>;
|
|
53
53
|
},
|
|
54
|
-
public readonly options: ExporterOptions
|
|
54
|
+
public readonly options: ExporterOptions,
|
|
55
55
|
) {}
|
|
56
56
|
|
|
57
57
|
public async resolveFile(url: string) {
|
|
@@ -76,7 +76,7 @@ export abstract class Exporter<
|
|
|
76
76
|
public mapInlineContent(inlineContent: InlineContent<I, S>) {
|
|
77
77
|
return this.mappings.inlineContentMapping[inlineContent.type](
|
|
78
78
|
inlineContent,
|
|
79
|
-
this
|
|
79
|
+
this,
|
|
80
80
|
);
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -89,13 +89,13 @@ export abstract class Exporter<
|
|
|
89
89
|
public async mapBlock(
|
|
90
90
|
block: BlockFromConfig<B[keyof B], I, S>,
|
|
91
91
|
nestingLevel: number,
|
|
92
|
-
numberedListIndex: number
|
|
92
|
+
numberedListIndex: number,
|
|
93
93
|
) {
|
|
94
94
|
return this.mappings.blockMapping[block.type](
|
|
95
95
|
block,
|
|
96
96
|
this,
|
|
97
97
|
nestingLevel,
|
|
98
|
-
numberedListIndex
|
|
98
|
+
numberedListIndex,
|
|
99
99
|
);
|
|
100
100
|
}
|
|
101
101
|
}
|
package/src/exporter/mapping.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type BlockMapping<
|
|
|
17
17
|
I extends InlineContentSchema,
|
|
18
18
|
S extends StyleSchema,
|
|
19
19
|
RB,
|
|
20
|
-
RI
|
|
20
|
+
RI,
|
|
21
21
|
> = {
|
|
22
22
|
[K in keyof B]: (
|
|
23
23
|
block: BlockFromConfigNoChildren<B[K], I, S>,
|
|
@@ -26,7 +26,7 @@ export type BlockMapping<
|
|
|
26
26
|
// this is why there are many `any` types here (same for types below)
|
|
27
27
|
exporter: Exporter<any, any, any, RB, RI, any, any>,
|
|
28
28
|
nestingLevel: number,
|
|
29
|
-
numberedListIndex?: number
|
|
29
|
+
numberedListIndex?: number,
|
|
30
30
|
) => RB | Promise<RB>;
|
|
31
31
|
};
|
|
32
32
|
|
|
@@ -37,11 +37,11 @@ export type InlineContentMapping<
|
|
|
37
37
|
I extends InlineContentSchema,
|
|
38
38
|
S extends StyleSchema,
|
|
39
39
|
RI,
|
|
40
|
-
TS
|
|
40
|
+
TS,
|
|
41
41
|
> = {
|
|
42
42
|
[K in keyof I]: (
|
|
43
43
|
inlineContent: InlineContentFromConfig<I[K], S>,
|
|
44
|
-
exporter: Exporter<any, I, S, any, RI, any, TS
|
|
44
|
+
exporter: Exporter<any, I, S, any, RI, any, TS>,
|
|
45
45
|
) => RI;
|
|
46
46
|
};
|
|
47
47
|
|
|
@@ -51,7 +51,7 @@ export type InlineContentMapping<
|
|
|
51
51
|
export type StyleMapping<S extends StyleSchema, RS> = {
|
|
52
52
|
[K in keyof S]: (
|
|
53
53
|
style: Styles<S>[K],
|
|
54
|
-
exporter: Exporter<any, any, any, any, any, RS, any
|
|
54
|
+
exporter: Exporter<any, any, any, any, any, RS, any>,
|
|
55
55
|
) => RS;
|
|
56
56
|
};
|
|
57
57
|
|
|
@@ -62,13 +62,13 @@ export type StyleMapping<S extends StyleSchema, RS> = {
|
|
|
62
62
|
export function mappingFactory<
|
|
63
63
|
B extends BlockSchema,
|
|
64
64
|
I extends InlineContentSchema,
|
|
65
|
-
S extends StyleSchema
|
|
65
|
+
S extends StyleSchema,
|
|
66
66
|
>(_schema: BlockNoteSchema<B, I, S>) {
|
|
67
67
|
return {
|
|
68
68
|
createBlockMapping: <R, RI>(mapping: BlockMapping<B, I, S, R, RI>) =>
|
|
69
69
|
mapping,
|
|
70
70
|
createInlineContentMapping: <R, RS>(
|
|
71
|
-
mapping: InlineContentMapping<I, S, R, RS
|
|
71
|
+
mapping: InlineContentMapping<I, S, R, RS>,
|
|
72
72
|
) => mapping,
|
|
73
73
|
createStyleMapping: <R>(mapping: StyleMapping<S, R>) => mapping,
|
|
74
74
|
};
|
|
@@ -23,7 +23,7 @@ export class CursorPlugin {
|
|
|
23
23
|
provider: { awareness: Awareness };
|
|
24
24
|
renderCursor?: (user: CollaborationUser) => HTMLElement;
|
|
25
25
|
showCursorLabels?: "always" | "activity";
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
27
|
) {
|
|
28
28
|
this.provider = collaboration.provider;
|
|
29
29
|
this.recentlyUpdatedCursors = new Map();
|
|
@@ -58,7 +58,7 @@ export class CursorPlugin {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
}
|
|
61
|
+
},
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -102,7 +102,7 @@ export class CommentsPlugin extends EventEmitter<any> {
|
|
|
102
102
|
const trimmedFrom = Math.max(pos, 0);
|
|
103
103
|
const trimmedTo = Math.min(
|
|
104
104
|
pos + node.nodeSize,
|
|
105
|
-
tr.doc.content.size - 1
|
|
105
|
+
tr.doc.content.size - 1,
|
|
106
106
|
);
|
|
107
107
|
tr.removeMark(trimmedFrom, trimmedTo, mark);
|
|
108
108
|
tr.addMark(
|
|
@@ -111,7 +111,7 @@ export class CommentsPlugin extends EventEmitter<any> {
|
|
|
111
111
|
markType.create({
|
|
112
112
|
...mark.attrs,
|
|
113
113
|
orphan: isOrphan,
|
|
114
|
-
})
|
|
114
|
+
}),
|
|
115
115
|
);
|
|
116
116
|
|
|
117
117
|
if (isOrphan && this.selectedThreadId === markThreadId) {
|
|
@@ -129,7 +129,7 @@ export class CommentsPlugin extends EventEmitter<any> {
|
|
|
129
129
|
constructor(
|
|
130
130
|
private readonly editor: BlockNoteEditor<any, any, any>,
|
|
131
131
|
public readonly threadStore: ThreadStore,
|
|
132
|
-
private readonly markType: string
|
|
132
|
+
private readonly markType: string,
|
|
133
133
|
) {
|
|
134
134
|
super();
|
|
135
135
|
|
|
@@ -187,7 +187,7 @@ export class CommentsPlugin extends EventEmitter<any> {
|
|
|
187
187
|
|
|
188
188
|
if (self.selectedThreadId) {
|
|
189
189
|
const selectedThreadPosition = threadPositions.get(
|
|
190
|
-
self.selectedThreadId
|
|
190
|
+
self.selectedThreadId,
|
|
191
191
|
);
|
|
192
192
|
|
|
193
193
|
if (selectedThreadPosition) {
|
|
@@ -197,8 +197,8 @@ export class CommentsPlugin extends EventEmitter<any> {
|
|
|
197
197
|
selectedThreadPosition.to,
|
|
198
198
|
{
|
|
199
199
|
class: "bn-thread-mark-selected",
|
|
200
|
-
}
|
|
201
|
-
)
|
|
200
|
+
},
|
|
201
|
+
),
|
|
202
202
|
);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
@@ -228,7 +228,7 @@ export class CommentsPlugin extends EventEmitter<any> {
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
const commentMark = node.marks.find(
|
|
231
|
-
(mark) => mark.type.name === markType && mark.attrs.orphan !== true
|
|
231
|
+
(mark) => mark.type.name === markType && mark.attrs.orphan !== true,
|
|
232
232
|
);
|
|
233
233
|
|
|
234
234
|
const threadId = commentMark?.attrs.threadId as string | undefined;
|
|
@@ -246,7 +246,7 @@ export class CommentsPlugin extends EventEmitter<any> {
|
|
|
246
246
|
pendingComment: boolean;
|
|
247
247
|
selectedThreadId: string | undefined;
|
|
248
248
|
threadPositions: Map<string, { from: number; to: number }>;
|
|
249
|
-
}) => void
|
|
249
|
+
}) => void,
|
|
250
250
|
) {
|
|
251
251
|
return this.on("update", callback);
|
|
252
252
|
}
|
|
@@ -263,7 +263,7 @@ export class CommentsPlugin extends EventEmitter<any> {
|
|
|
263
263
|
this.editor.transact((tr) =>
|
|
264
264
|
tr.setMeta(PLUGIN_KEY, {
|
|
265
265
|
name: SET_SELECTED_THREAD_ID,
|
|
266
|
-
})
|
|
266
|
+
}),
|
|
267
267
|
);
|
|
268
268
|
|
|
269
269
|
if (threadId && scrollToThread) {
|
|
@@ -14,7 +14,7 @@ export class UserStore<U extends User> extends EventEmitter<any> {
|
|
|
14
14
|
private loadingUsers = new Set<string>();
|
|
15
15
|
|
|
16
16
|
public constructor(
|
|
17
|
-
private readonly resolveUsers: (userIds: string[]) => Promise<U[]
|
|
17
|
+
private readonly resolveUsers: (userIds: string[]) => Promise<U[]>,
|
|
18
18
|
) {
|
|
19
19
|
super();
|
|
20
20
|
}
|
|
@@ -24,7 +24,7 @@ export class UserStore<U extends User> extends EventEmitter<any> {
|
|
|
24
24
|
*/
|
|
25
25
|
public async loadUsers(userIds: string[]) {
|
|
26
26
|
const missingUsers = userIds.filter(
|
|
27
|
-
(id) => !this.userCache.has(id) && !this.loadingUsers.has(id)
|
|
27
|
+
(id) => !this.userCache.has(id) && !this.loadingUsers.has(id),
|
|
28
28
|
);
|
|
29
29
|
|
|
30
30
|
if (missingUsers.length === 0) {
|
|
@@ -14,7 +14,7 @@ import { ySyncPluginKey } from "y-prosemirror";
|
|
|
14
14
|
|
|
15
15
|
export type FilePanelState<
|
|
16
16
|
I extends InlineContentSchema,
|
|
17
|
-
S extends StyleSchema
|
|
17
|
+
S extends StyleSchema,
|
|
18
18
|
> = UiElementPosition & {
|
|
19
19
|
// TODO: This typing is not quite right (children should be from BSchema)
|
|
20
20
|
block: BlockFromConfig<FileBlockConfig, I, S>;
|
|
@@ -34,7 +34,7 @@ export class FilePanelView<I extends InlineContentSchema, S extends StyleSchema>
|
|
|
34
34
|
>,
|
|
35
35
|
private readonly pluginKey: PluginKey<FilePanelState<I, S>>,
|
|
36
36
|
private readonly pmView: EditorView,
|
|
37
|
-
emitUpdate: (state: FilePanelState<I, S>) => void
|
|
37
|
+
emitUpdate: (state: FilePanelState<I, S>) => void,
|
|
38
38
|
) {
|
|
39
39
|
this.emitUpdate = () => {
|
|
40
40
|
if (!this.state) {
|
|
@@ -71,7 +71,7 @@ export class FilePanelView<I extends InlineContentSchema, S extends StyleSchema>
|
|
|
71
71
|
scrollHandler = () => {
|
|
72
72
|
if (this.state?.show) {
|
|
73
73
|
const blockElement = this.pmView.root.querySelector(
|
|
74
|
-
`[data-node-type="blockContainer"][data-id="${this.state.block.id}"]
|
|
74
|
+
`[data-node-type="blockContainer"][data-id="${this.state.block.id}"]`,
|
|
75
75
|
);
|
|
76
76
|
if (!blockElement) {
|
|
77
77
|
return;
|
|
@@ -87,7 +87,7 @@ export class FilePanelView<I extends InlineContentSchema, S extends StyleSchema>
|
|
|
87
87
|
|
|
88
88
|
if (!this.state?.show && pluginState?.block && this.editor.isEditable) {
|
|
89
89
|
const blockElement = this.pmView.root.querySelector(
|
|
90
|
-
`[data-node-type="blockContainer"][data-id="${pluginState.block.id}"]
|
|
90
|
+
`[data-node-type="blockContainer"][data-id="${pluginState.block.id}"]`,
|
|
91
91
|
);
|
|
92
92
|
if (!blockElement) {
|
|
93
93
|
return;
|
|
@@ -132,12 +132,12 @@ export class FilePanelView<I extends InlineContentSchema, S extends StyleSchema>
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
const filePanelPluginKey = new PluginKey<FilePanelState<any, any>>(
|
|
135
|
-
"FilePanelPlugin"
|
|
135
|
+
"FilePanelPlugin",
|
|
136
136
|
);
|
|
137
137
|
|
|
138
138
|
export class FilePanelProsemirrorPlugin<
|
|
139
139
|
I extends InlineContentSchema,
|
|
140
|
-
S extends StyleSchema
|
|
140
|
+
S extends StyleSchema,
|
|
141
141
|
> extends EventEmitter<any> {
|
|
142
142
|
private view: FilePanelView<I, S> | undefined;
|
|
143
143
|
public readonly plugin: Plugin;
|
|
@@ -155,7 +155,7 @@ export class FilePanelProsemirrorPlugin<
|
|
|
155
155
|
editorView,
|
|
156
156
|
(state) => {
|
|
157
157
|
this.emit("update", state);
|
|
158
|
-
}
|
|
158
|
+
},
|
|
159
159
|
);
|
|
160
160
|
return this.view;
|
|
161
161
|
},
|
|
@@ -53,12 +53,12 @@ export class FormattingToolbarView implements PluginView {
|
|
|
53
53
|
StyleSchema
|
|
54
54
|
>,
|
|
55
55
|
private readonly pmView: EditorView,
|
|
56
|
-
emitUpdate: (state: FormattingToolbarState) => void
|
|
56
|
+
emitUpdate: (state: FormattingToolbarState) => void,
|
|
57
57
|
) {
|
|
58
58
|
this.emitUpdate = () => {
|
|
59
59
|
if (!this.state) {
|
|
60
60
|
throw new Error(
|
|
61
|
-
"Attempting to update uninitialized formatting toolbar"
|
|
61
|
+
"Attempting to update uninitialized formatting toolbar",
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -96,7 +96,7 @@ export class FormattingToolbarView implements PluginView {
|
|
|
96
96
|
(editorWrapper === (event.relatedTarget as Node) ||
|
|
97
97
|
editorWrapper.contains(event.relatedTarget as Node) ||
|
|
98
98
|
(event.relatedTarget as HTMLElement).matches(
|
|
99
|
-
".bn-ui-container, .bn-ui-container *"
|
|
99
|
+
".bn-ui-container, .bn-ui-container *",
|
|
100
100
|
))
|
|
101
101
|
) {
|
|
102
102
|
return;
|
|
@@ -233,7 +233,7 @@ export class FormattingToolbarView implements PluginView {
|
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
export const formattingToolbarPluginKey = new PluginKey(
|
|
236
|
-
"FormattingToolbarPlugin"
|
|
236
|
+
"FormattingToolbarPlugin",
|
|
237
237
|
);
|
|
238
238
|
|
|
239
239
|
export class FormattingToolbarProsemirrorPlugin extends EventEmitter<any> {
|