@blocknote/core 0.29.1 → 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/README.md +125 -0
- package/dist/blocknote.cjs +9 -9
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +1501 -1359
- package/dist/blocknote.js.map +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js.map +1 -1
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +751 -9
- package/dist/locales.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 +7 -8
- package/src/api/README.md +1 -1
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -7
- 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/__snapshots__/mergeBlocks.test.ts.snap +0 -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/__snapshots__/moveBlocks.test.ts.snap +0 -20
- 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/__snapshots__/replaceBlocks.test.ts.snap +0 -12
- 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/__snapshots__/splitBlock.test.ts.snap +0 -6
- 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/__snapshots__/updateBlock.test.ts.snap +0 -17
- 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 +21 -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 +9 -4
- package/src/blocks/CodeBlockContent/CodeBlockContent.ts +40 -26
- package/src/blocks/FileBlockContent/FileBlockContent.ts +7 -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 +15 -8
- 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 +9 -6
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +14 -6
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +13 -29
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +24 -13
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +13 -30
- package/src/blocks/ListItemBlockContent/getListItemContent.ts +115 -0
- 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 +9 -5
- package/src/blocks/QuoteBlockContent/QuoteBlockContent.ts +10 -5
- package/src/blocks/README.md +1 -1
- package/src/blocks/TableBlockContent/TableBlockContent.ts +76 -19
- package/src/blocks/TableBlockContent/TableExtension.ts +3 -3
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +14 -6
- package/src/blocks/defaultBlockHelpers.ts +24 -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 +10 -1
- package/src/editor/BlockNoteEditor.test.ts +3 -3
- package/src/editor/BlockNoteEditor.ts +110 -61
- package/src/editor/BlockNoteExtensions.ts +24 -15
- 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 +152 -0
- package/src/extensions/Collaboration/SyncPlugin.ts +15 -0
- package/src/extensions/Collaboration/UndoPlugin.ts +14 -0
- package/src/extensions/Comments/CommentsPlugin.ts +9 -9
- package/src/extensions/Comments/userstore/UserStore.ts +2 -2
- package/src/extensions/FilePanel/FilePanelPlugin.ts +37 -28
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +6 -8
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +29 -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/i18n/locales/index.ts +2 -0
- package/src/i18n/locales/ru.ts +2 -2
- package/src/i18n/locales/sk.ts +355 -0
- package/src/i18n/locales/zh-tw.ts +390 -0
- package/src/locales.ts +1 -1
- package/src/pm-nodes/BlockContainer.ts +7 -6
- 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 +15 -15
- package/src/schema/blocks/internal.ts +17 -18
- package/src/schema/blocks/types.ts +27 -26
- 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/api/blockManipulation/setupTestEnv.d.ts +8 -4
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +8 -4
- package/types/src/blocks/ListItemBlockContent/getListItemContent.d.ts +28 -0
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +8 -4
- package/types/src/blocks/defaultBlockHelpers.d.ts +1 -0
- package/types/src/blocks/defaultBlocks.d.ts +16 -8
- package/types/src/editor/BlockNoteEditor.d.ts +21 -2
- package/types/src/extensions/Collaboration/CursorPlugin.d.ts +31 -0
- package/types/src/extensions/Collaboration/SyncPlugin.d.ts +7 -0
- package/types/src/extensions/Collaboration/UndoPlugin.d.ts +6 -0
- package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +1 -1
- package/types/src/i18n/locales/index.d.ts +2 -0
- package/types/src/i18n/locales/sk.d.ts +313 -0
- package/types/src/i18n/locales/zh-tw.d.ts +2 -0
- package/types/src/schema/blocks/types.d.ts +2 -1
- package/src/extensions/Collaboration/createCollaborationExtensions.ts +0 -147
- package/types/src/extensions/Collaboration/createCollaborationExtensions.d.ts +0 -17
|
@@ -56,12 +56,12 @@ export const TableExtension = Extension.create({
|
|
|
56
56
|
// Enables navigating cells using the tab key.
|
|
57
57
|
Tab: () => {
|
|
58
58
|
return this.editor.commands.command(({ state, dispatch, view }) =>
|
|
59
|
-
goToNextCell(1)(state, dispatch, view)
|
|
59
|
+
goToNextCell(1)(state, dispatch, view),
|
|
60
60
|
);
|
|
61
61
|
},
|
|
62
62
|
"Shift-Tab": () => {
|
|
63
63
|
return this.editor.commands.command(({ state, dispatch, view }) =>
|
|
64
|
-
goToNextCell(-1)(state, dispatch, view)
|
|
64
|
+
goToNextCell(-1)(state, dispatch, view),
|
|
65
65
|
);
|
|
66
66
|
},
|
|
67
67
|
};
|
|
@@ -76,7 +76,7 @@ export const TableExtension = Extension.create({
|
|
|
76
76
|
|
|
77
77
|
return {
|
|
78
78
|
tableRole: callOrReturn(
|
|
79
|
-
getExtensionField(extension, "tableRole", context)
|
|
79
|
+
getExtensionField(extension, "tableRole", context),
|
|
80
80
|
),
|
|
81
81
|
};
|
|
82
82
|
},
|
|
@@ -37,7 +37,8 @@ export const videoPropSchema = {
|
|
|
37
37
|
},
|
|
38
38
|
// File preview width in px.
|
|
39
39
|
previewWidth: {
|
|
40
|
-
default:
|
|
40
|
+
default: undefined,
|
|
41
|
+
type: "number",
|
|
41
42
|
},
|
|
42
43
|
} satisfies PropSchema;
|
|
43
44
|
|
|
@@ -51,7 +52,7 @@ export const videoBlockConfig = {
|
|
|
51
52
|
|
|
52
53
|
export const videoRender = (
|
|
53
54
|
block: BlockFromConfig<typeof videoBlockConfig, any, any>,
|
|
54
|
-
editor: BlockNoteEditor<any, any, any
|
|
55
|
+
editor: BlockNoteEditor<any, any, any>,
|
|
55
56
|
) => {
|
|
56
57
|
const icon = document.createElement("div");
|
|
57
58
|
icon.innerHTML = FILE_VIDEO_ICON_SVG;
|
|
@@ -80,14 +81,19 @@ export const videoRender = (
|
|
|
80
81
|
{ dom: videoWrapper },
|
|
81
82
|
videoWrapper,
|
|
82
83
|
editor.dictionary.file_blocks.video.add_button_text,
|
|
83
|
-
icon.firstElementChild as HTMLElement
|
|
84
|
+
icon.firstElementChild as HTMLElement,
|
|
84
85
|
);
|
|
85
86
|
};
|
|
86
87
|
|
|
87
88
|
export const videoParse = (
|
|
88
|
-
element: HTMLElement
|
|
89
|
+
element: HTMLElement,
|
|
89
90
|
): Partial<Props<typeof videoBlockConfig.propSchema>> | undefined => {
|
|
90
91
|
if (element.tagName === "VIDEO") {
|
|
92
|
+
// Ignore if parent figure has already been parsed.
|
|
93
|
+
if (element.closest("figure")) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
91
97
|
return parseVideoElement(element as HTMLVideoElement);
|
|
92
98
|
}
|
|
93
99
|
|
|
@@ -109,7 +115,7 @@ export const videoParse = (
|
|
|
109
115
|
};
|
|
110
116
|
|
|
111
117
|
export const videoToExternalHTML = (
|
|
112
|
-
block: BlockFromConfig<typeof videoBlockConfig, any, any
|
|
118
|
+
block: BlockFromConfig<typeof videoBlockConfig, any, any>,
|
|
113
119
|
) => {
|
|
114
120
|
if (!block.props.url) {
|
|
115
121
|
const div = document.createElement("p");
|
|
@@ -124,7 +130,9 @@ export const videoToExternalHTML = (
|
|
|
124
130
|
if (block.props.showPreview) {
|
|
125
131
|
video = document.createElement("video");
|
|
126
132
|
video.src = block.props.url;
|
|
127
|
-
|
|
133
|
+
if (block.props.previewWidth) {
|
|
134
|
+
video.width = block.props.previewWidth;
|
|
135
|
+
}
|
|
128
136
|
} else {
|
|
129
137
|
video = document.createElement("a");
|
|
130
138
|
video.href = block.props.url;
|
|
@@ -18,12 +18,12 @@ export function createDefaultBlockDOMOutputSpec(
|
|
|
18
18
|
blockName: string,
|
|
19
19
|
htmlTag: string,
|
|
20
20
|
blockContentHTMLAttributes: Record<string, string>,
|
|
21
|
-
inlineContentHTMLAttributes: Record<string, string
|
|
21
|
+
inlineContentHTMLAttributes: Record<string, string>,
|
|
22
22
|
) {
|
|
23
23
|
const blockContent = document.createElement("div");
|
|
24
24
|
blockContent.className = mergeCSSClasses(
|
|
25
25
|
"bn-block-content",
|
|
26
|
-
blockContentHTMLAttributes.class
|
|
26
|
+
blockContentHTMLAttributes.class,
|
|
27
27
|
);
|
|
28
28
|
blockContent.setAttribute("data-content-type", blockName);
|
|
29
29
|
for (const [attribute, value] of Object.entries(blockContentHTMLAttributes)) {
|
|
@@ -35,10 +35,10 @@ export function createDefaultBlockDOMOutputSpec(
|
|
|
35
35
|
const inlineContent = document.createElement(htmlTag);
|
|
36
36
|
inlineContent.className = mergeCSSClasses(
|
|
37
37
|
"bn-inline-content",
|
|
38
|
-
inlineContentHTMLAttributes.class
|
|
38
|
+
inlineContentHTMLAttributes.class,
|
|
39
39
|
);
|
|
40
40
|
for (const [attribute, value] of Object.entries(
|
|
41
|
-
inlineContentHTMLAttributes
|
|
41
|
+
inlineContentHTMLAttributes,
|
|
42
42
|
)) {
|
|
43
43
|
if (attribute !== "class") {
|
|
44
44
|
inlineContent.setAttribute(attribute, value);
|
|
@@ -59,10 +59,10 @@ export function createDefaultBlockDOMOutputSpec(
|
|
|
59
59
|
export const defaultBlockToHTML = <
|
|
60
60
|
BSchema extends BlockSchema,
|
|
61
61
|
I extends InlineContentSchema,
|
|
62
|
-
S extends StyleSchema
|
|
62
|
+
S extends StyleSchema,
|
|
63
63
|
>(
|
|
64
64
|
block: BlockNoDefaults<BSchema, I, S>,
|
|
65
|
-
editor: BlockNoteEditor<BSchema, I, S
|
|
65
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
66
66
|
): {
|
|
67
67
|
dom: HTMLElement;
|
|
68
68
|
contentDOM?: HTMLElement;
|
|
@@ -78,7 +78,7 @@ export const defaultBlockToHTML = <
|
|
|
78
78
|
|
|
79
79
|
if (toDOM === undefined) {
|
|
80
80
|
throw new Error(
|
|
81
|
-
"This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`."
|
|
81
|
+
"This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.",
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -86,7 +86,7 @@ export const defaultBlockToHTML = <
|
|
|
86
86
|
|
|
87
87
|
if (typeof renderSpec !== "object" || !("dom" in renderSpec)) {
|
|
88
88
|
throw new Error(
|
|
89
|
-
"Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property."
|
|
89
|
+
"Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property.",
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -95,3 +95,19 @@ export const defaultBlockToHTML = <
|
|
|
95
95
|
contentDOM?: HTMLElement;
|
|
96
96
|
};
|
|
97
97
|
};
|
|
98
|
+
|
|
99
|
+
// Function that merges all paragraphs into a single one separated by line breaks.
|
|
100
|
+
// This is used when parsing blocks like list items and table cells, as they may
|
|
101
|
+
// contain multiple paragraphs that ProseMirror will not be able to handle
|
|
102
|
+
// properly.
|
|
103
|
+
export function mergeParagraphs(element: HTMLElement) {
|
|
104
|
+
const paragraphs = element.querySelectorAll("p");
|
|
105
|
+
if (paragraphs.length > 1) {
|
|
106
|
+
const firstParagraph = paragraphs[0];
|
|
107
|
+
for (let i = 1; i < paragraphs.length; i++) {
|
|
108
|
+
const paragraph = paragraphs[i];
|
|
109
|
+
firstParagraph.innerHTML += "<br>" + paragraph.innerHTML;
|
|
110
|
+
paragraph.remove();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -20,10 +20,10 @@ import { Selection } from "prosemirror-state";
|
|
|
20
20
|
export function checkDefaultBlockTypeInSchema<
|
|
21
21
|
BlockType extends keyof DefaultBlockSchema,
|
|
22
22
|
I extends InlineContentSchema,
|
|
23
|
-
S extends StyleSchema
|
|
23
|
+
S extends StyleSchema,
|
|
24
24
|
>(
|
|
25
25
|
blockType: BlockType,
|
|
26
|
-
editor: BlockNoteEditor<any, I, S
|
|
26
|
+
editor: BlockNoteEditor<any, I, S>,
|
|
27
27
|
): editor is BlockNoteEditor<{ Type: DefaultBlockSchema[BlockType] }, I, S> {
|
|
28
28
|
return (
|
|
29
29
|
blockType in editor.schema.blockSchema &&
|
|
@@ -34,10 +34,10 @@ export function checkDefaultBlockTypeInSchema<
|
|
|
34
34
|
export function checkDefaultInlineContentTypeInSchema<
|
|
35
35
|
InlineContentType extends keyof DefaultInlineContentSchema,
|
|
36
36
|
B extends BlockSchema,
|
|
37
|
-
S extends StyleSchema
|
|
37
|
+
S extends StyleSchema,
|
|
38
38
|
>(
|
|
39
39
|
inlineContentType: InlineContentType,
|
|
40
|
-
editor: BlockNoteEditor<B, any, S
|
|
40
|
+
editor: BlockNoteEditor<B, any, S>,
|
|
41
41
|
): editor is BlockNoteEditor<
|
|
42
42
|
B,
|
|
43
43
|
{ Type: DefaultInlineContentSchema[InlineContentType] },
|
|
@@ -53,11 +53,11 @@ export function checkDefaultInlineContentTypeInSchema<
|
|
|
53
53
|
export function checkBlockIsDefaultType<
|
|
54
54
|
BlockType extends keyof DefaultBlockSchema,
|
|
55
55
|
I extends InlineContentSchema,
|
|
56
|
-
S extends StyleSchema
|
|
56
|
+
S extends StyleSchema,
|
|
57
57
|
>(
|
|
58
58
|
blockType: BlockType,
|
|
59
59
|
block: Block<any, I, S>,
|
|
60
|
-
editor: BlockNoteEditor<any, I, S
|
|
60
|
+
editor: BlockNoteEditor<any, I, S>,
|
|
61
61
|
): block is BlockFromConfig<DefaultBlockSchema[BlockType], I, S> {
|
|
62
62
|
return (
|
|
63
63
|
block.type === blockType &&
|
|
@@ -69,10 +69,10 @@ export function checkBlockIsDefaultType<
|
|
|
69
69
|
export function checkBlockIsFileBlock<
|
|
70
70
|
B extends BlockSchema,
|
|
71
71
|
I extends InlineContentSchema,
|
|
72
|
-
S extends StyleSchema
|
|
72
|
+
S extends StyleSchema,
|
|
73
73
|
>(
|
|
74
74
|
block: Block<any, I, S>,
|
|
75
|
-
editor: BlockNoteEditor<B, I, S
|
|
75
|
+
editor: BlockNoteEditor<B, I, S>,
|
|
76
76
|
): block is BlockFromConfig<FileBlockConfig, I, S> {
|
|
77
77
|
return (
|
|
78
78
|
(block.type in editor.schema.blockSchema &&
|
|
@@ -84,10 +84,10 @@ export function checkBlockIsFileBlock<
|
|
|
84
84
|
export function checkBlockIsFileBlockWithPreview<
|
|
85
85
|
B extends BlockSchema,
|
|
86
86
|
I extends InlineContentSchema,
|
|
87
|
-
S extends StyleSchema
|
|
87
|
+
S extends StyleSchema,
|
|
88
88
|
>(
|
|
89
89
|
block: Block<any, I, S>,
|
|
90
|
-
editor: BlockNoteEditor<B, I, S
|
|
90
|
+
editor: BlockNoteEditor<B, I, S>,
|
|
91
91
|
): block is BlockFromConfig<
|
|
92
92
|
FileBlockConfig & {
|
|
93
93
|
propSchema: Required<FileBlockConfig["propSchema"]>;
|
|
@@ -106,7 +106,7 @@ export function checkBlockIsFileBlockWithPreview<
|
|
|
106
106
|
export function checkBlockIsFileBlockWithPlaceholder<
|
|
107
107
|
B extends BlockSchema,
|
|
108
108
|
I extends InlineContentSchema,
|
|
109
|
-
S extends StyleSchema
|
|
109
|
+
S extends StyleSchema,
|
|
110
110
|
>(block: Block<B, I, S>, editor: BlockNoteEditor<B, I, S>) {
|
|
111
111
|
const config = editor.schema.blockSchema[block.type];
|
|
112
112
|
return config.isFileBlock && !block.props.url;
|
|
@@ -115,11 +115,11 @@ export function checkBlockIsFileBlockWithPlaceholder<
|
|
|
115
115
|
export function checkBlockTypeHasDefaultProp<
|
|
116
116
|
Prop extends keyof typeof defaultProps,
|
|
117
117
|
I extends InlineContentSchema,
|
|
118
|
-
S extends StyleSchema
|
|
118
|
+
S extends StyleSchema,
|
|
119
119
|
>(
|
|
120
120
|
prop: Prop,
|
|
121
121
|
blockType: string,
|
|
122
|
-
editor: BlockNoteEditor<any, I, S
|
|
122
|
+
editor: BlockNoteEditor<any, I, S>,
|
|
123
123
|
): editor is BlockNoteEditor<
|
|
124
124
|
{
|
|
125
125
|
[BT in string]: {
|
|
@@ -143,11 +143,11 @@ export function checkBlockTypeHasDefaultProp<
|
|
|
143
143
|
export function checkBlockHasDefaultProp<
|
|
144
144
|
Prop extends keyof typeof defaultProps,
|
|
145
145
|
I extends InlineContentSchema,
|
|
146
|
-
S extends StyleSchema
|
|
146
|
+
S extends StyleSchema,
|
|
147
147
|
>(
|
|
148
148
|
prop: Prop,
|
|
149
149
|
block: Block<any, I, S>,
|
|
150
|
-
editor: BlockNoteEditor<any, I, S
|
|
150
|
+
editor: BlockNoteEditor<any, I, S>,
|
|
151
151
|
): block is BlockFromConfig<
|
|
152
152
|
{
|
|
153
153
|
type: string;
|
|
@@ -163,7 +163,7 @@ export function checkBlockHasDefaultProp<
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
export function isTableCellSelection(
|
|
166
|
-
selection: Selection
|
|
166
|
+
selection: Selection,
|
|
167
167
|
): selection is CellSelection {
|
|
168
168
|
return selection instanceof CellSelection;
|
|
169
169
|
}
|
|
@@ -78,7 +78,7 @@ export const defaultInlineContentSpecs = {
|
|
|
78
78
|
} satisfies InlineContentSpecs;
|
|
79
79
|
|
|
80
80
|
export const defaultInlineContentSchema = getInlineContentSchemaFromSpecs(
|
|
81
|
-
defaultInlineContentSpecs
|
|
81
|
+
defaultInlineContentSpecs,
|
|
82
82
|
);
|
|
83
83
|
|
|
84
84
|
// underscore is used that in case a user overrides DefaultInlineContentSchema,
|
|
@@ -89,11 +89,11 @@ export type DefaultInlineContentSchema = _DefaultInlineContentSchema;
|
|
|
89
89
|
export type PartialBlock<
|
|
90
90
|
BSchema extends BlockSchema = DefaultBlockSchema,
|
|
91
91
|
I extends InlineContentSchema = DefaultInlineContentSchema,
|
|
92
|
-
S extends StyleSchema = DefaultStyleSchema
|
|
92
|
+
S extends StyleSchema = DefaultStyleSchema,
|
|
93
93
|
> = PartialBlockNoDefaults<BSchema, I, S>;
|
|
94
94
|
|
|
95
95
|
export type Block<
|
|
96
96
|
BSchema extends BlockSchema = DefaultBlockSchema,
|
|
97
97
|
I extends InlineContentSchema = DefaultInlineContentSchema,
|
|
98
|
-
S extends StyleSchema = DefaultStyleSchema
|
|
98
|
+
S extends StyleSchema = DefaultStyleSchema,
|
|
99
99
|
> = BlockNoDefaults<BSchema, I, S>;
|
|
@@ -18,7 +18,7 @@ import { ThreadStoreAuth } from "./ThreadStoreAuth.js";
|
|
|
18
18
|
export class DefaultThreadStoreAuth extends ThreadStoreAuth {
|
|
19
19
|
constructor(
|
|
20
20
|
private readonly userId: string,
|
|
21
|
-
private readonly role: "comment" | "editor"
|
|
21
|
+
private readonly role: "comment" | "editor",
|
|
22
22
|
) {
|
|
23
23
|
super();
|
|
24
24
|
}
|
|
@@ -84,7 +84,7 @@ export class DefaultThreadStoreAuth extends ThreadStoreAuth {
|
|
|
84
84
|
|
|
85
85
|
return !comment.reactions.some(
|
|
86
86
|
(reaction) =>
|
|
87
|
-
reaction.emoji === emoji && reaction.userIds.includes(this.userId)
|
|
87
|
+
reaction.emoji === emoji && reaction.userIds.includes(this.userId),
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -100,7 +100,7 @@ export class DefaultThreadStoreAuth extends ThreadStoreAuth {
|
|
|
100
100
|
|
|
101
101
|
return comment.reactions.some(
|
|
102
102
|
(reaction) =>
|
|
103
|
-
reaction.emoji === emoji && reaction.userIds.includes(this.userId)
|
|
103
|
+
reaction.emoji === emoji && reaction.userIds.includes(this.userId),
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -129,6 +129,6 @@ export abstract class ThreadStore {
|
|
|
129
129
|
* @returns a function to unsubscribe from the thread store
|
|
130
130
|
*/
|
|
131
131
|
abstract subscribe(
|
|
132
|
-
cb: (threads: Map<string, ThreadData>) => void
|
|
132
|
+
cb: (threads: Map<string, ThreadData>) => void,
|
|
133
133
|
): () => void;
|
|
134
134
|
}
|
|
@@ -28,7 +28,7 @@ export class TiptapThreadStore extends ThreadStore {
|
|
|
28
28
|
constructor(
|
|
29
29
|
private readonly userId: string,
|
|
30
30
|
private readonly provider: TiptapCollabProvider,
|
|
31
|
-
auth: ThreadStoreAuth // TODO: use?
|
|
31
|
+
auth: ThreadStoreAuth, // TODO: use?
|
|
32
32
|
) {
|
|
33
33
|
super(auth);
|
|
34
34
|
}
|
|
@@ -80,7 +80,7 @@ export class TiptapThreadStore extends ThreadStore {
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
return this.tiptapCommentToCommentData(
|
|
83
|
-
thread.comments[thread.comments.length - 1]
|
|
83
|
+
thread.comments[thread.comments.length - 1],
|
|
84
84
|
);
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -98,7 +98,7 @@ export class TiptapThreadStore extends ThreadStore {
|
|
|
98
98
|
const comment = this.provider.getThreadComment(
|
|
99
99
|
options.threadId,
|
|
100
100
|
options.commentId,
|
|
101
|
-
true
|
|
101
|
+
true,
|
|
102
102
|
);
|
|
103
103
|
|
|
104
104
|
if (!comment) {
|
|
@@ -120,12 +120,12 @@ export class TiptapThreadStore extends ThreadStore {
|
|
|
120
120
|
for (const reaction of (comment.data?.reactions ||
|
|
121
121
|
[]) as ReactionAsTiptapData[]) {
|
|
122
122
|
const existingReaction = reactions.find(
|
|
123
|
-
(r) => r.emoji === reaction.emoji
|
|
123
|
+
(r) => r.emoji === reaction.emoji,
|
|
124
124
|
);
|
|
125
125
|
if (existingReaction) {
|
|
126
126
|
existingReaction.userIds.push(reaction.userId);
|
|
127
127
|
existingReaction.createdAt = new Date(
|
|
128
|
-
Math.min(existingReaction.createdAt.getTime(), reaction.createdAt)
|
|
128
|
+
Math.min(existingReaction.createdAt.getTime(), reaction.createdAt),
|
|
129
129
|
);
|
|
130
130
|
} else {
|
|
131
131
|
reactions.push({
|
|
@@ -153,7 +153,7 @@ export class TiptapThreadStore extends ThreadStore {
|
|
|
153
153
|
type: "thread",
|
|
154
154
|
id: thread.id,
|
|
155
155
|
comments: thread.comments.map((comment) =>
|
|
156
|
-
this.tiptapCommentToCommentData(comment)
|
|
156
|
+
this.tiptapCommentToCommentData(comment),
|
|
157
157
|
),
|
|
158
158
|
resolved: !!thread.resolvedAt,
|
|
159
159
|
metadata: thread.data?.metadata,
|
|
@@ -207,7 +207,7 @@ export class TiptapThreadStore extends ThreadStore {
|
|
|
207
207
|
const comment = this.provider.getThreadComment(
|
|
208
208
|
options.threadId,
|
|
209
209
|
options.commentId,
|
|
210
|
-
true
|
|
210
|
+
true,
|
|
211
211
|
);
|
|
212
212
|
|
|
213
213
|
if (!comment) {
|
|
@@ -242,7 +242,7 @@ export class TiptapThreadStore extends ThreadStore {
|
|
|
242
242
|
const comment = this.provider.getThreadComment(
|
|
243
243
|
options.threadId,
|
|
244
244
|
options.commentId,
|
|
245
|
-
true
|
|
245
|
+
true,
|
|
246
246
|
);
|
|
247
247
|
|
|
248
248
|
if (!comment) {
|
|
@@ -256,7 +256,7 @@ export class TiptapThreadStore extends ThreadStore {
|
|
|
256
256
|
(comment.data?.reactions || []) as ReactionAsTiptapData[]
|
|
257
257
|
).filter(
|
|
258
258
|
(reaction) =>
|
|
259
|
-
reaction.emoji !== options.emoji && reaction.userId !== this.userId
|
|
259
|
+
reaction.emoji !== options.emoji && reaction.userId !== this.userId,
|
|
260
260
|
),
|
|
261
261
|
},
|
|
262
262
|
});
|
|
@@ -276,7 +276,7 @@ export class TiptapThreadStore extends ThreadStore {
|
|
|
276
276
|
return new Map(
|
|
277
277
|
this.provider
|
|
278
278
|
.getThreads()
|
|
279
|
-
.map((thread) => [thread.id, this.tiptapThreadToThreadData(thread)])
|
|
279
|
+
.map((thread) => [thread.id, this.tiptapThreadToThreadData(thread)]),
|
|
280
280
|
);
|
|
281
281
|
}
|
|
282
282
|
|
|
@@ -22,7 +22,7 @@ export class RESTYjsThreadStore extends YjsThreadStoreBase {
|
|
|
22
22
|
private readonly BASE_URL: string,
|
|
23
23
|
private readonly headers: Record<string, string>,
|
|
24
24
|
threadsYMap: Y.Map<any>,
|
|
25
|
-
auth: ThreadStoreAuth
|
|
25
|
+
auth: ThreadStoreAuth,
|
|
26
26
|
) {
|
|
27
27
|
super(threadsYMap, auth);
|
|
28
28
|
}
|
|
@@ -102,7 +102,7 @@ export class RESTYjsThreadStore extends YjsThreadStoreBase {
|
|
|
102
102
|
const { threadId, commentId, ...rest } = options;
|
|
103
103
|
return this.doRequest(
|
|
104
104
|
`/${threadId}/comments/${commentId}?soft=${!!rest.softDelete}`,
|
|
105
|
-
"DELETE"
|
|
105
|
+
"DELETE",
|
|
106
106
|
);
|
|
107
107
|
};
|
|
108
108
|
|
|
@@ -127,7 +127,7 @@ export class RESTYjsThreadStore extends YjsThreadStoreBase {
|
|
|
127
127
|
return this.doRequest(
|
|
128
128
|
`/${threadId}/comments/${commentId}/reactions`,
|
|
129
129
|
"POST",
|
|
130
|
-
rest
|
|
130
|
+
rest,
|
|
131
131
|
);
|
|
132
132
|
};
|
|
133
133
|
|
|
@@ -138,7 +138,7 @@ export class RESTYjsThreadStore extends YjsThreadStoreBase {
|
|
|
138
138
|
}) => {
|
|
139
139
|
return this.doRequest(
|
|
140
140
|
`/${options.threadId}/comments/${options.commentId}/reactions/${options.emoji}`,
|
|
141
|
-
"DELETE"
|
|
141
|
+
"DELETE",
|
|
142
142
|
);
|
|
143
143
|
};
|
|
144
144
|
}
|
|
@@ -25,7 +25,7 @@ describe("YjsThreadStore", () => {
|
|
|
25
25
|
store = new YjsThreadStore(
|
|
26
26
|
"test-user",
|
|
27
27
|
threadsYMap,
|
|
28
|
-
new DefaultThreadStoreAuth("test-user", "editor")
|
|
28
|
+
new DefaultThreadStoreAuth("test-user", "editor"),
|
|
29
29
|
);
|
|
30
30
|
});
|
|
31
31
|
|
|
@@ -99,7 +99,7 @@ describe("YjsThreadStore", () => {
|
|
|
99
99
|
comment: {
|
|
100
100
|
body: "Test comment" as CommentBody,
|
|
101
101
|
},
|
|
102
|
-
})
|
|
102
|
+
}),
|
|
103
103
|
).rejects.toThrow("Thread not found");
|
|
104
104
|
});
|
|
105
105
|
});
|
|
@@ -26,13 +26,13 @@ export class YjsThreadStore extends YjsThreadStoreBase {
|
|
|
26
26
|
constructor(
|
|
27
27
|
private readonly userId: string,
|
|
28
28
|
threadsYMap: Y.Map<any>,
|
|
29
|
-
auth: ThreadStoreAuth
|
|
29
|
+
auth: ThreadStoreAuth,
|
|
30
30
|
) {
|
|
31
31
|
super(threadsYMap, auth);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
private transact = <T, R>(
|
|
35
|
-
fn: (options: T) => R
|
|
35
|
+
fn: (options: T) => R,
|
|
36
36
|
): ((options: T) => Promise<R>) => {
|
|
37
37
|
return async (options: T) => {
|
|
38
38
|
return this.threadsYMap.doc!.transact(() => {
|
|
@@ -79,7 +79,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {
|
|
|
79
79
|
this.threadsYMap.set(thread.id, threadToYMap(thread));
|
|
80
80
|
|
|
81
81
|
return thread;
|
|
82
|
-
}
|
|
82
|
+
},
|
|
83
83
|
);
|
|
84
84
|
|
|
85
85
|
// YjsThreadStore does not support addThreadToDocument
|
|
@@ -121,7 +121,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {
|
|
|
121
121
|
|
|
122
122
|
yThread.set("updatedAt", new Date().getTime());
|
|
123
123
|
return comment;
|
|
124
|
-
}
|
|
124
|
+
},
|
|
125
125
|
);
|
|
126
126
|
|
|
127
127
|
public updateComment = this.transact(
|
|
@@ -140,7 +140,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {
|
|
|
140
140
|
|
|
141
141
|
const yCommentIndex = yArrayFindIndex(
|
|
142
142
|
yThread.get("comments"),
|
|
143
|
-
(comment) => comment.get("id") === options.commentId
|
|
143
|
+
(comment) => comment.get("id") === options.commentId,
|
|
144
144
|
);
|
|
145
145
|
|
|
146
146
|
if (yCommentIndex === -1) {
|
|
@@ -156,7 +156,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {
|
|
|
156
156
|
yComment.set("body", options.comment.body);
|
|
157
157
|
yComment.set("updatedAt", new Date().getTime());
|
|
158
158
|
yComment.set("metadata", options.comment.metadata);
|
|
159
|
-
}
|
|
159
|
+
},
|
|
160
160
|
);
|
|
161
161
|
|
|
162
162
|
public deleteComment = this.transact(
|
|
@@ -172,7 +172,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {
|
|
|
172
172
|
|
|
173
173
|
const yCommentIndex = yArrayFindIndex(
|
|
174
174
|
yThread.get("comments"),
|
|
175
|
-
(comment) => comment.get("id") === options.commentId
|
|
175
|
+
(comment) => comment.get("id") === options.commentId,
|
|
176
176
|
);
|
|
177
177
|
|
|
178
178
|
if (yCommentIndex === -1) {
|
|
@@ -210,13 +210,13 @@ export class YjsThreadStore extends YjsThreadStoreBase {
|
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
yThread.set("updatedAt", new Date().getTime());
|
|
213
|
-
}
|
|
213
|
+
},
|
|
214
214
|
);
|
|
215
215
|
|
|
216
216
|
public deleteThread = this.transact((options: { threadId: string }) => {
|
|
217
217
|
if (
|
|
218
218
|
!this.auth.canDeleteThread(
|
|
219
|
-
yMapToThread(this.threadsYMap.get(options.threadId))
|
|
219
|
+
yMapToThread(this.threadsYMap.get(options.threadId)),
|
|
220
220
|
)
|
|
221
221
|
) {
|
|
222
222
|
throw new Error("Not authorized");
|
|
@@ -263,7 +263,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {
|
|
|
263
263
|
|
|
264
264
|
const yCommentIndex = yArrayFindIndex(
|
|
265
265
|
yThread.get("comments"),
|
|
266
|
-
(comment) => comment.get("id") === options.commentId
|
|
266
|
+
(comment) => comment.get("id") === options.commentId,
|
|
267
267
|
);
|
|
268
268
|
|
|
269
269
|
if (yCommentIndex === -1) {
|
|
@@ -292,7 +292,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {
|
|
|
292
292
|
reaction.set("userId", this.userId);
|
|
293
293
|
reactionsByUser.set(key, reaction);
|
|
294
294
|
}
|
|
295
|
-
}
|
|
295
|
+
},
|
|
296
296
|
);
|
|
297
297
|
|
|
298
298
|
public deleteReaction = this.transact(
|
|
@@ -304,7 +304,7 @@ export class YjsThreadStore extends YjsThreadStoreBase {
|
|
|
304
304
|
|
|
305
305
|
const yCommentIndex = yArrayFindIndex(
|
|
306
306
|
yThread.get("comments"),
|
|
307
|
-
(comment) => comment.get("id") === options.commentId
|
|
307
|
+
(comment) => comment.get("id") === options.commentId,
|
|
308
308
|
);
|
|
309
309
|
|
|
310
310
|
if (yCommentIndex === -1) {
|
|
@@ -324,13 +324,13 @@ export class YjsThreadStore extends YjsThreadStoreBase {
|
|
|
324
324
|
const reactionsByUser = yComment.get("reactionsByUser");
|
|
325
325
|
|
|
326
326
|
reactionsByUser.delete(key);
|
|
327
|
-
}
|
|
327
|
+
},
|
|
328
328
|
);
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
function yArrayFindIndex(
|
|
332
332
|
yArray: Y.Array<any>,
|
|
333
|
-
predicate: (item: any) => boolean
|
|
333
|
+
predicate: (item: any) => boolean,
|
|
334
334
|
) {
|
|
335
335
|
for (let i = 0; i < yArray.length; i++) {
|
|
336
336
|
if (predicate(yArray.get(i))) {
|
|
@@ -52,7 +52,7 @@ type SingleUserCommentReactionData = {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
export function yMapToReaction(
|
|
55
|
-
yMap: Y.Map<any
|
|
55
|
+
yMap: Y.Map<any>,
|
|
56
56
|
): SingleUserCommentReactionData {
|
|
57
57
|
return {
|
|
58
58
|
emoji: yMap.get("emoji"),
|
|
@@ -63,7 +63,7 @@ export function yMapToReaction(
|
|
|
63
63
|
|
|
64
64
|
function yMapToReactions(yMap: Y.Map<any>): CommentReactionData[] {
|
|
65
65
|
const flatReactions = [...yMap.values()].map((reaction: Y.Map<any>) =>
|
|
66
|
-
yMapToReaction(reaction)
|
|
66
|
+
yMapToReaction(reaction),
|
|
67
67
|
);
|
|
68
68
|
// combine reactions by the same emoji
|
|
69
69
|
return flatReactions.reduce(
|
|
@@ -74,8 +74,8 @@ function yMapToReactions(yMap: Y.Map<any>): CommentReactionData[] {
|
|
|
74
74
|
existingReaction.createdAt = new Date(
|
|
75
75
|
Math.min(
|
|
76
76
|
existingReaction.createdAt.getTime(),
|
|
77
|
-
reaction.createdAt.getTime()
|
|
78
|
-
)
|
|
77
|
+
reaction.createdAt.getTime(),
|
|
78
|
+
),
|
|
79
79
|
);
|
|
80
80
|
} else {
|
|
81
81
|
acc.push({
|
|
@@ -86,7 +86,7 @@ function yMapToReactions(yMap: Y.Map<any>): CommentReactionData[] {
|
|
|
86
86
|
}
|
|
87
87
|
return acc;
|
|
88
88
|
},
|
|
89
|
-
[] as CommentReactionData[]
|
|
89
|
+
[] as CommentReactionData[],
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -113,7 +113,7 @@ export function yMapToThread(yMap: Y.Map<any>): ThreadData {
|
|
|
113
113
|
createdAt: new Date(yMap.get("createdAt")),
|
|
114
114
|
updatedAt: new Date(yMap.get("updatedAt")),
|
|
115
115
|
comments: ((yMap.get("comments") as Y.Array<Y.Map<any>>) || []).map(
|
|
116
|
-
(comment) => yMapToComment(comment)
|
|
116
|
+
(comment) => yMapToComment(comment),
|
|
117
117
|
),
|
|
118
118
|
resolved: yMap.get("resolved"),
|
|
119
119
|
resolvedUpdatedAt: new Date(yMap.get("resolvedUpdatedAt")),
|
package/src/editor/Block.css
CHANGED
|
@@ -14,7 +14,6 @@ BASIC STYLES
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.bn-block-content {
|
|
17
|
-
display: flex;
|
|
18
17
|
padding: 3px 0;
|
|
19
18
|
transition: font-size 0.2s;
|
|
20
19
|
width: 100%;
|
|
@@ -24,6 +23,14 @@ BASIC STYLES
|
|
|
24
23
|
*/
|
|
25
24
|
}
|
|
26
25
|
|
|
26
|
+
/* We can't set `display: flex` on `.bn-block-content` while it has inline
|
|
27
|
+
content (see #1629). However, it's necessary to set alignment of blocks
|
|
28
|
+
without content as these can't use `text-align`, so this additional rule is
|
|
29
|
+
used. */
|
|
30
|
+
.bn-block-content:not(:has(.bn-inline-content)) {
|
|
31
|
+
display: flex;
|
|
32
|
+
}
|
|
33
|
+
|
|
27
34
|
.bn-block-content::before {
|
|
28
35
|
/* content: ""; */
|
|
29
36
|
transition: all 0.2s;
|
|
@@ -163,6 +170,7 @@ NESTED BLOCKS
|
|
|
163
170
|
.bn-block-content::before {
|
|
164
171
|
margin-right: 0;
|
|
165
172
|
content: "";
|
|
173
|
+
display: inline;
|
|
166
174
|
}
|
|
167
175
|
|
|
168
176
|
/* Ordered */
|
|
@@ -411,6 +419,7 @@ NESTED BLOCKS
|
|
|
411
419
|
display: flex;
|
|
412
420
|
align-items: center;
|
|
413
421
|
position: relative;
|
|
422
|
+
max-width: 100%;
|
|
414
423
|
}
|
|
415
424
|
|
|
416
425
|
[data-file-block] .bn-visual-media {
|