@blocknote/core 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.cjs +9 -9
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +2771 -2245
- package/dist/blocknote.js.map +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js.map +1 -1
- package/dist/{en-D4taoCs4.cjs → en-BXVKCwYt.cjs} +2 -2
- package/dist/en-BXVKCwYt.cjs.map +1 -0
- package/dist/{en-B7ycW7c8.js → en-qGo6sk9V.js} +2 -3
- package/dist/en-qGo6sk9V.js.map +1 -0
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +20 -39
- package/dist/locales.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +8 -7
- 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 +7 -8
- 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 +8 -8
- 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 +2816 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +200 -42
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +104 -34
- package/src/api/blockManipulation/getBlock/getBlock.ts +9 -9
- package/src/api/blockManipulation/insertContentAt.ts +1 -1
- package/src/api/blockManipulation/selections/selection.ts +59 -12
- package/src/api/blockManipulation/selections/{textCursorPosition/textCursorPosition.ts → textCursorPosition.ts} +13 -13
- 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 +31 -28
- package/src/api/nodeConversions/fragmentToBlocks.ts +1 -1
- package/src/api/nodeConversions/nodeToBlock.ts +240 -41
- 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 +7 -7
- 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 +18 -18
- 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 +6 -6
- 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 +37 -7
- 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 +35 -1
- package/src/editor/BlockNoteEditor.test.ts +10 -3
- package/src/editor/BlockNoteEditor.ts +95 -38
- package/src/editor/BlockNoteExtension.ts +26 -0
- package/src/editor/BlockNoteExtensions.ts +38 -22
- package/src/editor/BlockNoteSchema.ts +4 -4
- package/src/editor/BlockNoteTipTapEditor.ts +33 -12
- 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 +15 -9
- package/src/extensions/Collaboration/ForkYDocPlugin.test.ts +166 -0
- package/src/extensions/Collaboration/ForkYDocPlugin.ts +174 -0
- package/src/extensions/Collaboration/SyncPlugin.ts +7 -4
- package/src/extensions/Collaboration/UndoPlugin.ts +7 -4
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor-forked.json +30 -0
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor.json +30 -0
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-forked.html +1 -0
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap.html +1 -0
- package/src/extensions/Comments/CommentsPlugin.ts +80 -75
- package/src/extensions/Comments/userstore/UserStore.ts +2 -2
- package/src/extensions/FilePanel/FilePanelPlugin.ts +56 -55
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +60 -30
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +26 -26
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +33 -32
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +45 -42
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +113 -110
- package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +179 -170
- package/src/extensions/README.md +1 -1
- package/src/extensions/ShowSelection/ShowSelectionPlugin.ts +22 -19
- package/src/extensions/SideMenu/MultipleNodeSelection.ts +1 -1
- package/src/extensions/SideMenu/SideMenuPlugin.ts +49 -48
- package/src/extensions/SideMenu/dragging.ts +8 -8
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +176 -176
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +2 -2
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +16 -16
- package/src/extensions/Suggestions/SuggestionMarks.ts +175 -0
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +199 -195
- 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/ar.ts +0 -1
- package/src/i18n/locales/de.ts +0 -1
- package/src/i18n/locales/en.ts +0 -1
- package/src/i18n/locales/es.ts +0 -1
- package/src/i18n/locales/fr.ts +0 -1
- package/src/i18n/locales/hr.ts +0 -1
- package/src/i18n/locales/is.ts +0 -1
- package/src/i18n/locales/it.ts +0 -1
- package/src/i18n/locales/ja.ts +0 -1
- package/src/i18n/locales/ko.ts +0 -1
- package/src/i18n/locales/nl.ts +0 -1
- package/src/i18n/locales/no.ts +0 -1
- package/src/i18n/locales/pl.ts +0 -1
- package/src/i18n/locales/pt.ts +0 -1
- package/src/i18n/locales/ru.ts +0 -1
- package/src/i18n/locales/sk.ts +0 -1
- package/src/i18n/locales/uk.ts +0 -1
- package/src/i18n/locales/vi.ts +0 -1
- package/src/i18n/locales/zh-tw.ts +0 -1
- package/src/i18n/locales/zh.ts +0 -1
- package/src/index.ts +18 -8
- package/src/locales.ts +1 -1
- package/src/pm-nodes/BlockContainer.ts +1 -1
- package/src/pm-nodes/BlockGroup.ts +2 -2
- package/src/pm-nodes/Doc.ts +5 -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/api/blockManipulation/commands/insertBlocks/insertBlocks.d.ts +1 -1
- package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.d.ts +4 -0
- package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.d.ts +1 -0
- package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.d.ts +3 -1
- package/types/src/api/blockManipulation/selections/selection.d.ts +10 -0
- package/types/src/api/blockManipulation/selections/textCursorPosition.d.ts +5 -0
- package/types/src/api/blockManipulation/transactions.test.d.ts +0 -0
- package/types/src/api/clipboard/clipboardExternal.test.d.ts +1 -0
- package/types/src/api/clipboard/clipboardInternal.test.d.ts +1 -0
- package/types/src/api/clipboard/testUtil.d.ts +541 -0
- package/types/src/api/exporters/html/htmlConversion.test.d.ts +1 -0
- package/types/src/api/exporters/markdown/markdownExporter.test.d.ts +1 -0
- package/types/src/api/nodeConversions/nodeConversions.test.d.ts +1 -0
- package/types/src/api/nodeConversions/nodeToBlock.d.ts +39 -2
- package/types/src/api/parsers/html/parseHTML.test.d.ts +1 -0
- package/types/src/api/parsers/markdown/parseMarkdown.test.d.ts +1 -0
- package/types/src/api/pmUtil.d.ts +3 -3
- package/types/src/api/testUtil/cases/customBlocks.d.ts +670 -0
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +558 -0
- package/types/src/api/testUtil/cases/customStyles.d.ts +552 -0
- package/types/src/api/testUtil/cases/defaultSchema.d.ts +4 -0
- package/types/src/api/testUtil/index.d.ts +14 -0
- package/types/src/api/testUtil/partialBlockTestUtil.d.ts +9 -0
- package/types/src/api/testUtil/paste.d.ts +2 -0
- package/types/src/blocks/CodeBlockContent/defaultSupportedLanguages.d.ts +6 -0
- package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +9 -1
- package/types/src/editor/BlockNoteEditor.d.ts +58 -10
- package/types/src/editor/BlockNoteExtension.d.ts +9 -0
- package/types/src/editor/BlockNoteExtensions.d.ts +2 -2
- package/types/src/editor/BlockNoteTipTapEditor.d.ts +2 -2
- package/types/src/extensions/Collaboration/CursorPlugin.d.ts +3 -3
- package/types/src/extensions/Collaboration/ForkYDocPlugin.d.ts +41 -0
- package/types/src/extensions/Collaboration/ForkYDocPlugin.test.d.ts +1 -0
- package/types/src/extensions/Collaboration/SyncPlugin.d.ts +3 -3
- package/types/src/extensions/Collaboration/UndoPlugin.d.ts +3 -3
- package/types/src/extensions/Collaboration/createCollaborationExtensions.d.ts +17 -0
- package/types/src/extensions/Comments/CommentsPlugin.d.ts +2 -4
- package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +3 -4
- package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +5 -5
- package/types/src/extensions/LinkToolbar/LinkToolbarPlugin.d.ts +3 -4
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.d.ts +2 -3
- package/types/src/extensions/Placeholder/PlaceholderPlugin.d.ts +2 -3
- package/types/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.d.ts +2 -3
- package/types/src/extensions/ShowSelection/ShowSelectionPlugin.d.ts +2 -3
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +3 -4
- package/types/src/extensions/SuggestionMenu/SuggestionPlugin.d.ts +2 -4
- package/types/src/extensions/Suggestions/SuggestionMarks.d.ts +4 -0
- package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +5 -6
- package/types/src/i18n/locales/en.d.ts +0 -1
- package/types/src/i18n/locales/sk.d.ts +0 -1
- package/types/src/index.d.ts +15 -8
- package/dist/en-B7ycW7c8.js.map +0 -1
- package/dist/en-D4taoCs4.cjs.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/api/blockManipulation/selections/__snapshots__/selection.test.ts.snap +0 -844
- package/src/api/blockManipulation/selections/selection.test.ts +0 -72
- package/src/api/blockManipulation/selections/textCursorPosition/__snapshots__/textCursorPosition.test.ts.snap +0 -316
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts +0 -74
|
@@ -26,7 +26,7 @@ export function getListItemContent(
|
|
|
26
26
|
/**
|
|
27
27
|
* The name of the list item node.
|
|
28
28
|
*/
|
|
29
|
-
name: string
|
|
29
|
+
name: string,
|
|
30
30
|
): Fragment {
|
|
31
31
|
/**
|
|
32
32
|
* To actually implement this algorithm, we need to leverage ProseMirror's "fitting" algorithm.
|
|
@@ -70,8 +70,8 @@ export function getListItemContent(
|
|
|
70
70
|
// and continuing with the rest of the algorithm.
|
|
71
71
|
blockGroupNode = blockGroupNode.copy(
|
|
72
72
|
blockGroupNode.content.cut(
|
|
73
|
-
blockGroupNode.firstChild.firstChild.nodeSize + 2
|
|
74
|
-
)
|
|
73
|
+
blockGroupNode.firstChild.firstChild.nodeSize + 2,
|
|
74
|
+
),
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -90,14 +90,14 @@ export function getListItemContent(
|
|
|
90
90
|
// The remaining nodes in the `blockGroup` stay in-place.
|
|
91
91
|
const listItemNode = schema.nodes[name].create(
|
|
92
92
|
{},
|
|
93
|
-
listItemsFirstChild.content
|
|
93
|
+
listItemsFirstChild.content,
|
|
94
94
|
);
|
|
95
95
|
|
|
96
96
|
// We have `blockGroup<listItemsFirstChild, ...blockContainer<any>[]>`
|
|
97
97
|
// We want to extract out the rest of the nodes as `<...blockContainer<any>[]>`
|
|
98
98
|
const remainingListItemChildren = blockGroupNode.content.cut(
|
|
99
99
|
// +2 for the `blockGroup` node's start and end markers
|
|
100
|
-
listItemsFirstChild.nodeSize + 2
|
|
100
|
+
listItemsFirstChild.nodeSize + 2,
|
|
101
101
|
);
|
|
102
102
|
const hasRemainingListItemChildren = remainingListItemChildren.size > 0;
|
|
103
103
|
|
|
@@ -22,7 +22,7 @@ export const pageBreakRender = () => {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
export const pageBreakParse = (
|
|
25
|
-
element: HTMLElement
|
|
25
|
+
element: HTMLElement,
|
|
26
26
|
): Partial<Props<typeof pageBreakConfig.propSchema>> | undefined => {
|
|
27
27
|
if (element.tagName === "DIV" && element.hasAttribute("data-page-break")) {
|
|
28
28
|
return {
|
|
@@ -10,9 +10,9 @@ import { pageBreakSchema } from "./schema.js";
|
|
|
10
10
|
|
|
11
11
|
export function checkPageBreakBlocksInSchema<
|
|
12
12
|
I extends InlineContentSchema,
|
|
13
|
-
S extends StyleSchema
|
|
13
|
+
S extends StyleSchema,
|
|
14
14
|
>(
|
|
15
|
-
editor: BlockNoteEditor<any, I, S
|
|
15
|
+
editor: BlockNoteEditor<any, I, S>,
|
|
16
16
|
): editor is BlockNoteEditor<typeof pageBreakSchema.blockSchema, I, S> {
|
|
17
17
|
return (
|
|
18
18
|
"pageBreak" in editor.schema.blockSchema &&
|
|
@@ -24,7 +24,7 @@ export function checkPageBreakBlocksInSchema<
|
|
|
24
24
|
export function getPageBreakSlashMenuItems<
|
|
25
25
|
BSchema extends BlockSchema,
|
|
26
26
|
I extends InlineContentSchema,
|
|
27
|
-
S extends StyleSchema
|
|
27
|
+
S extends StyleSchema,
|
|
28
28
|
>(editor: BlockNoteEditor<BSchema, I, S>) {
|
|
29
29
|
const items: (Omit<DefaultSuggestionItem, "key"> & { key: "page_break" })[] =
|
|
30
30
|
[];
|
|
@@ -18,9 +18,9 @@ export const pageBreakSchema = BlockNoteSchema.create({
|
|
|
18
18
|
export const withPageBreak = <
|
|
19
19
|
B extends BlockSchema,
|
|
20
20
|
I extends InlineContentSchema,
|
|
21
|
-
S extends StyleSchema
|
|
21
|
+
S extends StyleSchema,
|
|
22
22
|
>(
|
|
23
|
-
schema: BlockNoteSchema<B, I, S
|
|
23
|
+
schema: BlockNoteSchema<B, I, S>,
|
|
24
24
|
) => {
|
|
25
25
|
return BlockNoteSchema.create({
|
|
26
26
|
blockSpecs: {
|
|
@@ -31,7 +31,7 @@ export const ParagraphBlockContent = createStronglyTypedTiptapNode({
|
|
|
31
31
|
updateBlockCommand(blockInfo.bnBlock.beforePos, {
|
|
32
32
|
type: "paragraph",
|
|
33
33
|
props: {},
|
|
34
|
-
})
|
|
34
|
+
}),
|
|
35
35
|
);
|
|
36
36
|
},
|
|
37
37
|
};
|
|
@@ -67,12 +67,12 @@ export const ParagraphBlockContent = createStronglyTypedTiptapNode({
|
|
|
67
67
|
...(this.options.domAttributes?.blockContent || {}),
|
|
68
68
|
...HTMLAttributes,
|
|
69
69
|
},
|
|
70
|
-
this.options.domAttributes?.inlineContent || {}
|
|
70
|
+
this.options.domAttributes?.inlineContent || {},
|
|
71
71
|
);
|
|
72
72
|
},
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
export const Paragraph = createBlockSpecFromStronglyTypedTiptapNode(
|
|
76
76
|
ParagraphBlockContent,
|
|
77
|
-
paragraphPropSchema
|
|
77
|
+
paragraphPropSchema,
|
|
78
78
|
);
|
|
@@ -36,7 +36,7 @@ export const QuoteBlockContent = createStronglyTypedTiptapNode({
|
|
|
36
36
|
updateBlockCommand(blockInfo.bnBlock.beforePos, {
|
|
37
37
|
type: "quote",
|
|
38
38
|
props: {},
|
|
39
|
-
})
|
|
39
|
+
}),
|
|
40
40
|
)
|
|
41
41
|
// Removes the ">" character used to set the list.
|
|
42
42
|
.deleteRange({ from: range.from, to: range.to });
|
|
@@ -59,7 +59,7 @@ export const QuoteBlockContent = createStronglyTypedTiptapNode({
|
|
|
59
59
|
return this.editor.commands.command(
|
|
60
60
|
updateBlockCommand(blockInfo.bnBlock.beforePos, {
|
|
61
61
|
type: "quote",
|
|
62
|
-
})
|
|
62
|
+
}),
|
|
63
63
|
);
|
|
64
64
|
},
|
|
65
65
|
};
|
|
@@ -88,12 +88,12 @@ export const QuoteBlockContent = createStronglyTypedTiptapNode({
|
|
|
88
88
|
...(this.options.domAttributes?.blockContent || {}),
|
|
89
89
|
...HTMLAttributes,
|
|
90
90
|
},
|
|
91
|
-
this.options.domAttributes?.inlineContent || {}
|
|
91
|
+
this.options.domAttributes?.inlineContent || {},
|
|
92
92
|
);
|
|
93
93
|
},
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
export const Quote = createBlockSpecFromStronglyTypedTiptapNode(
|
|
97
97
|
QuoteBlockContent,
|
|
98
|
-
quotePropSchema
|
|
98
|
+
quotePropSchema,
|
|
99
99
|
);
|
package/src/blocks/README.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { Node, mergeAttributes } from "@tiptap/core";
|
|
1
2
|
import { TableCell } from "@tiptap/extension-table-cell";
|
|
2
3
|
import { TableHeader } from "@tiptap/extension-table-header";
|
|
3
|
-
import { TableRow } from "@tiptap/extension-table-row";
|
|
4
4
|
import { DOMParser, Fragment, Node as PMNode, Schema } from "prosemirror-model";
|
|
5
5
|
import { TableView } from "prosemirror-tables";
|
|
6
|
-
|
|
7
6
|
import { NodeView } from "prosemirror-view";
|
|
8
7
|
import {
|
|
9
8
|
createBlockSpecFromStronglyTypedTiptapNode,
|
|
@@ -24,6 +23,7 @@ export const TableBlockContent = createStronglyTypedTiptapNode({
|
|
|
24
23
|
group: "blockContent",
|
|
25
24
|
tableRole: "table",
|
|
26
25
|
|
|
26
|
+
marks: "deletion insertion modification",
|
|
27
27
|
isolating: true,
|
|
28
28
|
|
|
29
29
|
parseHTML() {
|
|
@@ -42,7 +42,7 @@ export const TableBlockContent = createStronglyTypedTiptapNode({
|
|
|
42
42
|
...(this.options.domAttributes?.blockContent || {}),
|
|
43
43
|
...HTMLAttributes,
|
|
44
44
|
},
|
|
45
|
-
this.options.domAttributes?.inlineContent || {}
|
|
45
|
+
this.options.domAttributes?.inlineContent || {},
|
|
46
46
|
);
|
|
47
47
|
},
|
|
48
48
|
|
|
@@ -59,18 +59,18 @@ export const TableBlockContent = createStronglyTypedTiptapNode({
|
|
|
59
59
|
constructor(
|
|
60
60
|
public node: PMNode,
|
|
61
61
|
public cellMinWidth: number,
|
|
62
|
-
public blockContentHTMLAttributes: Record<string, string
|
|
62
|
+
public blockContentHTMLAttributes: Record<string, string>,
|
|
63
63
|
) {
|
|
64
64
|
super(node, cellMinWidth);
|
|
65
65
|
|
|
66
66
|
const blockContent = document.createElement("div");
|
|
67
67
|
blockContent.className = mergeCSSClasses(
|
|
68
68
|
"bn-block-content",
|
|
69
|
-
blockContentHTMLAttributes.class
|
|
69
|
+
blockContentHTMLAttributes.class,
|
|
70
70
|
);
|
|
71
71
|
blockContent.setAttribute("data-content-type", "table");
|
|
72
72
|
for (const [attribute, value] of Object.entries(
|
|
73
|
-
blockContentHTMLAttributes
|
|
73
|
+
blockContentHTMLAttributes,
|
|
74
74
|
)) {
|
|
75
75
|
if (attribute !== "class") {
|
|
76
76
|
blockContent.setAttribute(attribute, value);
|
|
@@ -152,6 +152,36 @@ const TableParagraph = createStronglyTypedTiptapNode({
|
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
|
+
* This extension allows you to create table rows.
|
|
156
|
+
* @see https://www.tiptap.dev/api/nodes/table-row
|
|
157
|
+
*/
|
|
158
|
+
export const TableRow = Node.create<{ HTMLAttributes: Record<string, any> }>({
|
|
159
|
+
name: "tableRow",
|
|
160
|
+
|
|
161
|
+
addOptions() {
|
|
162
|
+
return {
|
|
163
|
+
HTMLAttributes: {},
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
content: "(tableCell | tableHeader)+",
|
|
168
|
+
|
|
169
|
+
tableRole: "row",
|
|
170
|
+
marks: "deletion insertion modification",
|
|
171
|
+
parseHTML() {
|
|
172
|
+
return [{ tag: "tr" }];
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
renderHTML({ HTMLAttributes }) {
|
|
176
|
+
return [
|
|
177
|
+
"tr",
|
|
178
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
179
|
+
0,
|
|
180
|
+
];
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
/*
|
|
155
185
|
* This will flatten a node's content to fit into a table cell's paragraph.
|
|
156
186
|
*/
|
|
157
187
|
function parseTableContent(node: HTMLElement, schema: Schema) {
|
|
@@ -229,5 +259,5 @@ export const Table = createBlockSpecFromStronglyTypedTiptapNode(
|
|
|
229
259
|
},
|
|
230
260
|
}),
|
|
231
261
|
TableRow,
|
|
232
|
-
]
|
|
262
|
+
],
|
|
233
263
|
);
|
|
@@ -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
|
},
|
|
@@ -52,7 +52,7 @@ export const videoBlockConfig = {
|
|
|
52
52
|
|
|
53
53
|
export const videoRender = (
|
|
54
54
|
block: BlockFromConfig<typeof videoBlockConfig, any, any>,
|
|
55
|
-
editor: BlockNoteEditor<any, any, any
|
|
55
|
+
editor: BlockNoteEditor<any, any, any>,
|
|
56
56
|
) => {
|
|
57
57
|
const icon = document.createElement("div");
|
|
58
58
|
icon.innerHTML = FILE_VIDEO_ICON_SVG;
|
|
@@ -81,12 +81,12 @@ export const videoRender = (
|
|
|
81
81
|
{ dom: videoWrapper },
|
|
82
82
|
videoWrapper,
|
|
83
83
|
editor.dictionary.file_blocks.video.add_button_text,
|
|
84
|
-
icon.firstElementChild as HTMLElement
|
|
84
|
+
icon.firstElementChild as HTMLElement,
|
|
85
85
|
);
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
export const videoParse = (
|
|
89
|
-
element: HTMLElement
|
|
89
|
+
element: HTMLElement,
|
|
90
90
|
): Partial<Props<typeof videoBlockConfig.propSchema>> | undefined => {
|
|
91
91
|
if (element.tagName === "VIDEO") {
|
|
92
92
|
// Ignore if parent figure has already been parsed.
|
|
@@ -115,7 +115,7 @@ export const videoParse = (
|
|
|
115
115
|
};
|
|
116
116
|
|
|
117
117
|
export const videoToExternalHTML = (
|
|
118
|
-
block: BlockFromConfig<typeof videoBlockConfig, any, any
|
|
118
|
+
block: BlockFromConfig<typeof videoBlockConfig, any, any>,
|
|
119
119
|
) => {
|
|
120
120
|
if (!block.props.url) {
|
|
121
121
|
const div = document.createElement("p");
|
|
@@ -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
|
|
|
@@ -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
|
});
|