@liveblocks/react-tiptap 2.16.0-toolbars4 → 2.17.0-channels1
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/LiveblocksExtension.js.map +1 -1
- package/dist/LiveblocksExtension.mjs.map +1 -1
- package/dist/comments/CommentsExtension.js +11 -20
- package/dist/comments/CommentsExtension.js.map +1 -1
- package/dist/comments/CommentsExtension.mjs +13 -22
- package/dist/comments/CommentsExtension.mjs.map +1 -1
- package/dist/comments/FloatingComposer.js +30 -27
- package/dist/comments/FloatingComposer.js.map +1 -1
- package/dist/comments/FloatingComposer.mjs +32 -29
- package/dist/comments/FloatingComposer.mjs.map +1 -1
- package/dist/index.d.mts +10 -254
- package/dist/index.d.ts +10 -254
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -2
- package/dist/index.mjs.map +1 -1
- package/dist/types.js +3 -7
- package/dist/types.js.map +1 -1
- package/dist/types.mjs +3 -6
- package/dist/types.mjs.map +1 -1
- package/dist/utils.js +0 -17
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +1 -16
- package/dist/utils.mjs.map +1 -1
- package/dist/version-history/HistoryVersionPreview.js +79 -79
- package/dist/version-history/HistoryVersionPreview.js.map +1 -1
- package/dist/version-history/HistoryVersionPreview.mjs +79 -79
- package/dist/version-history/HistoryVersionPreview.mjs.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +6 -8
- package/src/styles/constants.css +1 -2
- package/src/styles/index.css +6 -58
- package/src/styles/utils.css +0 -11
- package/styles.css +1 -1
- package/styles.css.map +1 -1
- package/dist/context.js +0 -24
- package/dist/context.js.map +0 -1
- package/dist/context.mjs +0 -21
- package/dist/context.mjs.map +0 -1
- package/dist/toolbar/FloatingToolbar.js +0 -321
- package/dist/toolbar/FloatingToolbar.js.map +0 -1
- package/dist/toolbar/FloatingToolbar.mjs +0 -318
- package/dist/toolbar/FloatingToolbar.mjs.map +0 -1
- package/dist/toolbar/Toolbar.js +0 -396
- package/dist/toolbar/Toolbar.js.map +0 -1
- package/dist/toolbar/Toolbar.mjs +0 -371
- package/dist/toolbar/Toolbar.mjs.map +0 -1
- package/dist/toolbar/shared.js +0 -39
- package/dist/toolbar/shared.js.map +0 -1
- package/dist/toolbar/shared.mjs +0 -36
- package/dist/toolbar/shared.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingComposer.js","sources":["../../src/comments/FloatingComposer.tsx"],"sourcesContent":["import {\n autoUpdate,\n flip,\n hide,\n
|
|
1
|
+
{"version":3,"file":"FloatingComposer.js","sources":["../../src/comments/FloatingComposer.tsx"],"sourcesContent":["import {\n autoUpdate,\n flip,\n hide,\n limitShift,\n offset,\n shift,\n size,\n useFloating,\n} from \"@floating-ui/react-dom\";\nimport type { BaseMetadata } from \"@liveblocks/client\";\nimport type { DM } from \"@liveblocks/core\";\nimport { useCreateThread } from \"@liveblocks/react\";\nimport { useLayoutEffect } from \"@liveblocks/react/_private\";\nimport type {\n ComposerProps,\n ComposerSubmitComment,\n} from \"@liveblocks/react-ui\";\nimport { Composer } from \"@liveblocks/react-ui\";\nimport { type Editor, useEditorState } from \"@tiptap/react\";\nimport type { ComponentRef, FormEvent, KeyboardEvent } from \"react\";\nimport { forwardRef, useCallback, useEffect } from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport type { CommentsExtensionStorage } from \"../types\";\n\nexport type FloatingComposerProps<M extends BaseMetadata = DM> = Omit<\n ComposerProps<M>,\n \"threadId\" | \"commentId\"\n> & {\n editor: Editor | null;\n};\n\ntype ComposerElement = ComponentRef<typeof Composer>;\n\nexport const FLOATING_COMPOSER_COLLISION_PADDING = 10;\n\nexport const FloatingComposer = forwardRef<\n ComposerElement,\n FloatingComposerProps\n>(function FloatingComposer(props, forwardedRef) {\n const createThread = useCreateThread();\n const { editor, onComposerSubmit, onKeyDown } = props;\n const { showComposer } = useEditorState({\n editor,\n selector: (ctx) => ({\n showComposer: !!(\n ctx.editor?.storage.liveblocksComments as\n | CommentsExtensionStorage\n | undefined\n )?.pendingComment && !editor?.state.selection.empty,\n }),\n equalityFn: (prev, next) => {\n if (!next) return false;\n return prev.showComposer === next.showComposer;\n },\n }) ?? { showComposer: false };\n\n const {\n refs: { setReference, setFloating },\n strategy,\n x,\n y,\n } = useFloating({\n strategy: \"fixed\",\n placement: \"bottom\",\n middleware: [\n flip({ padding: FLOATING_COMPOSER_COLLISION_PADDING, crossAxis: false }),\n offset(10),\n hide({ padding: FLOATING_COMPOSER_COLLISION_PADDING }),\n shift({\n padding: FLOATING_COMPOSER_COLLISION_PADDING,\n limiter: limitShift(),\n }),\n size({ padding: FLOATING_COMPOSER_COLLISION_PADDING }),\n ],\n whileElementsMounted: (...args) => {\n return autoUpdate(...args, {\n animationFrame: true,\n });\n },\n });\n\n const updateRef = useCallback(() => {\n if (!editor || !showComposer) {\n return;\n }\n const el = editor.view.dom.querySelector(\".lb-tiptap-active-selection\");\n if (el) {\n setReference(el);\n }\n }, [setReference, editor, showComposer]);\n\n // Remote cursor updates and other edits can cause the ref to break\n useEffect(() => {\n if (!editor || !showComposer) {\n return;\n }\n editor.on(\"transaction\", updateRef);\n return () => {\n editor.off(\"transaction\", updateRef);\n };\n }, [editor, updateRef, showComposer]);\n\n useLayoutEffect(updateRef, [updateRef]);\n\n // Submit a new thread and update the comment highlight to show a completed highlight\n const handleComposerSubmit = useCallback(\n (comment: ComposerSubmitComment, event: FormEvent<HTMLFormElement>) => {\n onComposerSubmit?.(comment, event);\n if (event.defaultPrevented) return;\n\n if (!editor) {\n return;\n }\n event.preventDefault();\n\n const thread = createThread({\n body: comment.body,\n attachments: comment.attachments,\n metadata: props.metadata ?? {},\n });\n editor.commands.addComment(thread.id);\n },\n [onComposerSubmit, editor, createThread, props.metadata]\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLFormElement>) => {\n if (event.key === \"Escape\" && editor) {\n editor.commands.focus();\n }\n onKeyDown?.(event);\n },\n [editor, onKeyDown]\n );\n\n if (!showComposer || !editor) {\n return null;\n }\n\n return createPortal(\n <div\n className=\"lb-root lb-portal lb-elevation lb-tiptap-floating lb-tiptap-floating-composer\"\n ref={setFloating}\n style={{\n position: strategy,\n top: 0,\n left: 0,\n transform: `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)`,\n minWidth: \"max-content\",\n }}\n >\n <Composer\n ref={forwardedRef}\n {...props}\n onKeyDown={handleKeyDown}\n onComposerSubmit={handleComposerSubmit}\n onClick={(e) => {\n // Don't send up a click event from emoji popout and close the composer\n e.stopPropagation();\n }}\n autoFocus={true}\n />\n </div>,\n document.body\n );\n});\n"],"names":["forwardRef","FloatingComposer","useCreateThread","useEditorState","useFloating","flip","offset","hide","shift","limitShift","size","autoUpdate","useCallback","useEffect","useLayoutEffect","createPortal","jsx","Composer"],"mappings":";;;;;;;;;;;AAmCO,MAAM,mCAAsC,GAAA,GAAA;AAE5C,MAAM,gBAAmB,GAAAA,gBAAA,CAG9B,SAASC,iBAAAA,CAAiB,OAAO,YAAc,EAAA;AAC/C,EAAA,MAAM,eAAeC,uBAAgB,EAAA,CAAA;AACrC,EAAA,MAAM,EAAE,MAAA,EAAQ,gBAAkB,EAAA,SAAA,EAAc,GAAA,KAAA,CAAA;AAChD,EAAM,MAAA,EAAE,YAAa,EAAA,GAAIC,sBAAe,CAAA;AAAA,IACtC,MAAA;AAAA,IACA,QAAA,EAAU,CAAC,GAAS,MAAA;AAAA,MAClB,YAAA,EAAc,CAAC,CACb,GAAI,CAAA,MAAA,EAAQ,OAAQ,CAAA,kBAAA,EAGnB,cAAkB,IAAA,CAAC,MAAQ,EAAA,KAAA,CAAM,SAAU,CAAA,KAAA;AAAA,KAChD,CAAA;AAAA,IACA,UAAA,EAAY,CAAC,IAAA,EAAM,IAAS,KAAA;AAC1B,MAAA,IAAI,CAAC,IAAA;AAAM,QAAO,OAAA,KAAA,CAAA;AAClB,MAA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AAA,IAAY,MAAQ,EAAA;AACpC,QAAA,MAAA,CAAO,SAAS,KAAM,EAAA,CAAA;AAAA,OACxB;AACA,MAAA,SAAA,GAAY,KAAK,CAAA,CAAA;AAAA,KACnB;AAAA,IACA,CAAC,QAAQ,SAAS,CAAA;AAAA,GACpB,CAAA;AAEA,EAAI,IAAA,CAAC,YAAgB,IAAA,CAAC,MAAQ,EAAA;AAC5B,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAO,OAAAG,uBAAA;AAAA,oBACJC,cAAA,CAAA,KAAA,EAAA;AAAA,MACC,SAAU,EAAA,+EAAA;AAAA,MACV,GAAK,EAAA,WAAA;AAAA,MACL,KAAO,EAAA;AAAA,QACL,QAAU,EAAA,QAAA;AAAA,QACV,GAAK,EAAA,CAAA;AAAA,QACL,IAAM,EAAA,CAAA;AAAA,QACN,SAAA,EAAW,eAAe,IAAK,CAAA,KAAA,CAAM,CAAC,CAAQ,CAAA,IAAA,EAAA,IAAA,CAAK,MAAM,CAAC,CAAA,CAAA,MAAA,CAAA;AAAA,QAC1D,QAAU,EAAA,aAAA;AAAA,OACZ;AAAA,MAEA,QAAC,kBAAAA,cAAA,CAAAC,gBAAA,EAAA;AAAA,QACC,GAAK,EAAA,YAAA;AAAA,QACJ,GAAG,KAAA;AAAA,QACJ,SAAW,EAAA,aAAA;AAAA,QACX,gBAAkB,EAAA,oBAAA;AAAA,QAClB,OAAA,EAAS,CAAC,CAAM,KAAA;AAEd,UAAA,CAAA,CAAE,eAAgB,EAAA,CAAA;AAAA,SACpB;AAAA,QACA,SAAW,EAAA,IAAA;AAAA,OACb,CAAA;AAAA,KACF,CAAA;AAAA,IACA,QAAS,CAAA,IAAA;AAAA,GACX,CAAA;AACF,CAAC;;;;;"}
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useFloating,
|
|
2
|
+
import { useFloating, flip, offset, hide, shift, limitShift, size, autoUpdate } from '@floating-ui/react-dom';
|
|
3
3
|
import { useCreateThread } from '@liveblocks/react';
|
|
4
4
|
import { useLayoutEffect } from '@liveblocks/react/_private';
|
|
5
5
|
import { Composer } from '@liveblocks/react-ui';
|
|
6
6
|
import { useEditorState } from '@tiptap/react';
|
|
7
|
-
import { forwardRef, useCallback } from 'react';
|
|
7
|
+
import { forwardRef, useCallback, useEffect } from 'react';
|
|
8
8
|
import { createPortal } from 'react-dom';
|
|
9
|
-
import { compareTextSelections, getDomRangeFromTextSelection } from '../utils.mjs';
|
|
10
9
|
|
|
11
10
|
const FLOATING_COMPOSER_COLLISION_PADDING = 10;
|
|
12
11
|
const FloatingComposer = forwardRef(function FloatingComposer2(props, forwardedRef) {
|
|
13
12
|
const createThread = useCreateThread();
|
|
14
13
|
const { editor, onComposerSubmit, onKeyDown } = props;
|
|
15
|
-
const
|
|
14
|
+
const { showComposer } = useEditorState({
|
|
16
15
|
editor,
|
|
17
|
-
selector: (ctx) => {
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
equalityFn:
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
selector: (ctx) => ({
|
|
17
|
+
showComposer: !!ctx.editor?.storage.liveblocksComments?.pendingComment && !editor?.state.selection.empty
|
|
18
|
+
}),
|
|
19
|
+
equalityFn: (prev, next) => {
|
|
20
|
+
if (!next)
|
|
21
|
+
return false;
|
|
22
|
+
return prev.showComposer === next.showComposer;
|
|
23
|
+
}
|
|
24
|
+
}) ?? { showComposer: false };
|
|
23
25
|
const {
|
|
24
26
|
refs: { setReference, setFloating },
|
|
25
27
|
strategy,
|
|
@@ -29,7 +31,6 @@ const FloatingComposer = forwardRef(function FloatingComposer2(props, forwardedR
|
|
|
29
31
|
strategy: "fixed",
|
|
30
32
|
placement: "bottom",
|
|
31
33
|
middleware: [
|
|
32
|
-
inline({ padding: FLOATING_COMPOSER_COLLISION_PADDING }),
|
|
33
34
|
flip({ padding: FLOATING_COMPOSER_COLLISION_PADDING, crossAxis: false }),
|
|
34
35
|
offset(10),
|
|
35
36
|
hide({ padding: FLOATING_COMPOSER_COLLISION_PADDING }),
|
|
@@ -45,20 +46,25 @@ const FloatingComposer = forwardRef(function FloatingComposer2(props, forwardedR
|
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
48
|
});
|
|
48
|
-
|
|
49
|
-
if (!editor || !
|
|
49
|
+
const updateRef = useCallback(() => {
|
|
50
|
+
if (!editor || !showComposer) {
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
const el = editor.view.dom.querySelector(".lb-tiptap-active-selection");
|
|
54
|
+
if (el) {
|
|
55
|
+
setReference(el);
|
|
56
|
+
}
|
|
57
|
+
}, [setReference, editor, showComposer]);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (!editor || !showComposer) {
|
|
60
|
+
return;
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
+
editor.on("transaction", updateRef);
|
|
63
|
+
return () => {
|
|
64
|
+
editor.off("transaction", updateRef);
|
|
65
|
+
};
|
|
66
|
+
}, [editor, updateRef, showComposer]);
|
|
67
|
+
useLayoutEffect(updateRef, [updateRef]);
|
|
62
68
|
const handleComposerSubmit = useCallback(
|
|
63
69
|
(comment, event) => {
|
|
64
70
|
onComposerSubmit?.(comment, event);
|
|
@@ -79,17 +85,14 @@ const FloatingComposer = forwardRef(function FloatingComposer2(props, forwardedR
|
|
|
79
85
|
);
|
|
80
86
|
const handleKeyDown = useCallback(
|
|
81
87
|
(event) => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (event.key === "Escape") {
|
|
87
|
-
editor.chain().closePendingComment().run();
|
|
88
|
+
if (event.key === "Escape" && editor) {
|
|
89
|
+
editor.commands.focus();
|
|
88
90
|
}
|
|
91
|
+
onKeyDown?.(event);
|
|
89
92
|
},
|
|
90
93
|
[editor, onKeyDown]
|
|
91
94
|
);
|
|
92
|
-
if (!
|
|
95
|
+
if (!showComposer || !editor) {
|
|
93
96
|
return null;
|
|
94
97
|
}
|
|
95
98
|
return createPortal(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingComposer.mjs","sources":["../../src/comments/FloatingComposer.tsx"],"sourcesContent":["import {\n autoUpdate,\n flip,\n hide,\n
|
|
1
|
+
{"version":3,"file":"FloatingComposer.mjs","sources":["../../src/comments/FloatingComposer.tsx"],"sourcesContent":["import {\n autoUpdate,\n flip,\n hide,\n limitShift,\n offset,\n shift,\n size,\n useFloating,\n} from \"@floating-ui/react-dom\";\nimport type { BaseMetadata } from \"@liveblocks/client\";\nimport type { DM } from \"@liveblocks/core\";\nimport { useCreateThread } from \"@liveblocks/react\";\nimport { useLayoutEffect } from \"@liveblocks/react/_private\";\nimport type {\n ComposerProps,\n ComposerSubmitComment,\n} from \"@liveblocks/react-ui\";\nimport { Composer } from \"@liveblocks/react-ui\";\nimport { type Editor, useEditorState } from \"@tiptap/react\";\nimport type { ComponentRef, FormEvent, KeyboardEvent } from \"react\";\nimport { forwardRef, useCallback, useEffect } from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport type { CommentsExtensionStorage } from \"../types\";\n\nexport type FloatingComposerProps<M extends BaseMetadata = DM> = Omit<\n ComposerProps<M>,\n \"threadId\" | \"commentId\"\n> & {\n editor: Editor | null;\n};\n\ntype ComposerElement = ComponentRef<typeof Composer>;\n\nexport const FLOATING_COMPOSER_COLLISION_PADDING = 10;\n\nexport const FloatingComposer = forwardRef<\n ComposerElement,\n FloatingComposerProps\n>(function FloatingComposer(props, forwardedRef) {\n const createThread = useCreateThread();\n const { editor, onComposerSubmit, onKeyDown } = props;\n const { showComposer } = useEditorState({\n editor,\n selector: (ctx) => ({\n showComposer: !!(\n ctx.editor?.storage.liveblocksComments as\n | CommentsExtensionStorage\n | undefined\n )?.pendingComment && !editor?.state.selection.empty,\n }),\n equalityFn: (prev, next) => {\n if (!next) return false;\n return prev.showComposer === next.showComposer;\n },\n }) ?? { showComposer: false };\n\n const {\n refs: { setReference, setFloating },\n strategy,\n x,\n y,\n } = useFloating({\n strategy: \"fixed\",\n placement: \"bottom\",\n middleware: [\n flip({ padding: FLOATING_COMPOSER_COLLISION_PADDING, crossAxis: false }),\n offset(10),\n hide({ padding: FLOATING_COMPOSER_COLLISION_PADDING }),\n shift({\n padding: FLOATING_COMPOSER_COLLISION_PADDING,\n limiter: limitShift(),\n }),\n size({ padding: FLOATING_COMPOSER_COLLISION_PADDING }),\n ],\n whileElementsMounted: (...args) => {\n return autoUpdate(...args, {\n animationFrame: true,\n });\n },\n });\n\n const updateRef = useCallback(() => {\n if (!editor || !showComposer) {\n return;\n }\n const el = editor.view.dom.querySelector(\".lb-tiptap-active-selection\");\n if (el) {\n setReference(el);\n }\n }, [setReference, editor, showComposer]);\n\n // Remote cursor updates and other edits can cause the ref to break\n useEffect(() => {\n if (!editor || !showComposer) {\n return;\n }\n editor.on(\"transaction\", updateRef);\n return () => {\n editor.off(\"transaction\", updateRef);\n };\n }, [editor, updateRef, showComposer]);\n\n useLayoutEffect(updateRef, [updateRef]);\n\n // Submit a new thread and update the comment highlight to show a completed highlight\n const handleComposerSubmit = useCallback(\n (comment: ComposerSubmitComment, event: FormEvent<HTMLFormElement>) => {\n onComposerSubmit?.(comment, event);\n if (event.defaultPrevented) return;\n\n if (!editor) {\n return;\n }\n event.preventDefault();\n\n const thread = createThread({\n body: comment.body,\n attachments: comment.attachments,\n metadata: props.metadata ?? {},\n });\n editor.commands.addComment(thread.id);\n },\n [onComposerSubmit, editor, createThread, props.metadata]\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLFormElement>) => {\n if (event.key === \"Escape\" && editor) {\n editor.commands.focus();\n }\n onKeyDown?.(event);\n },\n [editor, onKeyDown]\n );\n\n if (!showComposer || !editor) {\n return null;\n }\n\n return createPortal(\n <div\n className=\"lb-root lb-portal lb-elevation lb-tiptap-floating lb-tiptap-floating-composer\"\n ref={setFloating}\n style={{\n position: strategy,\n top: 0,\n left: 0,\n transform: `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)`,\n minWidth: \"max-content\",\n }}\n >\n <Composer\n ref={forwardedRef}\n {...props}\n onKeyDown={handleKeyDown}\n onComposerSubmit={handleComposerSubmit}\n onClick={(e) => {\n // Don't send up a click event from emoji popout and close the composer\n e.stopPropagation();\n }}\n autoFocus={true}\n />\n </div>,\n document.body\n );\n});\n"],"names":["FloatingComposer"],"mappings":";;;;;;;;;AAmCO,MAAM,mCAAsC,GAAA,GAAA;AAE5C,MAAM,gBAAmB,GAAA,UAAA,CAG9B,SAASA,iBAAAA,CAAiB,OAAO,YAAc,EAAA;AAC/C,EAAA,MAAM,eAAe,eAAgB,EAAA,CAAA;AACrC,EAAA,MAAM,EAAE,MAAA,EAAQ,gBAAkB,EAAA,SAAA,EAAc,GAAA,KAAA,CAAA;AAChD,EAAM,MAAA,EAAE,YAAa,EAAA,GAAI,cAAe,CAAA;AAAA,IACtC,MAAA;AAAA,IACA,QAAA,EAAU,CAAC,GAAS,MAAA;AAAA,MAClB,YAAA,EAAc,CAAC,CACb,GAAI,CAAA,MAAA,EAAQ,OAAQ,CAAA,kBAAA,EAGnB,cAAkB,IAAA,CAAC,MAAQ,EAAA,KAAA,CAAM,SAAU,CAAA,KAAA;AAAA,KAChD,CAAA;AAAA,IACA,UAAA,EAAY,CAAC,IAAA,EAAM,IAAS,KAAA;AAC1B,MAAA,IAAI,CAAC,IAAA;AAAM,QAAO,OAAA,KAAA,CAAA;AAClB,MAAO,OAAA,IAAA,CAAK,iBAAiB,IAAK,CAAA,YAAA,CAAA;AAAA,KACpC;AAAA,GACD,CAAA,IAAK,EAAE,YAAA,EAAc,KAAM,EAAA,CAAA;AAE5B,EAAM,MAAA;AAAA,IACJ,IAAA,EAAM,EAAE,YAAA,EAAc,WAAY,EAAA;AAAA,IAClC,QAAA;A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,EAAA;AAC5B,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAO,OAAA,YAAA;AAAA,oBACJ,GAAA,CAAA,KAAA,EAAA;AAAA,MACC,SAAU,EAAA,+EAAA;AAAA,MACV,GAAK,EAAA,WAAA;AAAA,MACL,KAAO,EAAA;AAAA,QACL,QAAU,EAAA,QAAA;AAAA,QACV,GAAK,EAAA,CAAA;AAAA,QACL,IAAM,EAAA,CAAA;AAAA,QACN,SAAA,EAAW,eAAe,IAAK,CAAA,KAAA,CAAM,CAAC,CAAQ,CAAA,IAAA,EAAA,IAAA,CAAK,MAAM,CAAC,CAAA,CAAA,MAAA,CAAA;AAAA,QAC1D,QAAU,EAAA,aAAA;AAAA,OACZ;AAAA,MAEA,QAAC,kBAAA,GAAA,CAAA,QAAA,EAAA;AAAA,QACC,GAAK,EAAA,YAAA;AAAA,QACJ,GAAG,KAAA;AAAA,QACJ,SAAW,EAAA,aAAA;AAAA,QACX,gBAAkB,EAAA,oBAAA;AAAA,QAClB,OAAA,EAAS,CAAC,CAAM,KAAA;AAEd,UAAA,CAAA,CAAE,eAAgB,EAAA,CAAA;AAAA,SACpB;AAAA,QACA,SAAW,EAAA,IAAA;AAAA,OACb,CAAA;AAAA,KACF,CAAA;AAAA,IACA,QAAS,CAAA,IAAA;AAAA,GACX,CAAA;AACF,CAAC;;;;"}
|
package/dist/index.d.mts
CHANGED
|
@@ -3,20 +3,10 @@ import { BaseMetadata, DM, ThreadData, HistoryVersion } from '@liveblocks/core';
|
|
|
3
3
|
import { ThreadProps, ComposerProps } from '@liveblocks/react-ui';
|
|
4
4
|
import { Editor } from '@tiptap/react';
|
|
5
5
|
import * as react from 'react';
|
|
6
|
-
import { ComponentPropsWithoutRef, ComponentType, HTMLAttributes
|
|
6
|
+
import { ComponentPropsWithoutRef, ComponentType, HTMLAttributes } from 'react';
|
|
7
7
|
import { BaseMetadata as BaseMetadata$1 } from '@liveblocks/client';
|
|
8
8
|
import { Extension, Content } from '@tiptap/core';
|
|
9
9
|
|
|
10
|
-
type FloatingPosition = "top" | "bottom";
|
|
11
|
-
type CommentsCommands<ReturnType> = {
|
|
12
|
-
/**
|
|
13
|
-
* Add a comment
|
|
14
|
-
*/
|
|
15
|
-
addComment: (id: string) => ReturnType;
|
|
16
|
-
selectThread: (id: string | null) => ReturnType;
|
|
17
|
-
addPendingComment: () => ReturnType;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
10
|
type AnchoredThreadsComponents = {
|
|
21
11
|
Thread: ComponentType<ThreadProps>;
|
|
22
12
|
};
|
|
@@ -36,9 +26,6 @@ interface AnchoredThreadsProps<M extends BaseMetadata = DM> extends Omit<Compone
|
|
|
36
26
|
}
|
|
37
27
|
declare function AnchoredThreads({ threads, components, className, style, editor, ...props }: AnchoredThreadsProps): react_jsx_runtime.JSX.Element | null;
|
|
38
28
|
|
|
39
|
-
type FloatingComposerProps<M extends BaseMetadata$1 = DM> = Omit<ComposerProps<M>, "threadId" | "commentId"> & {
|
|
40
|
-
editor: Editor | null;
|
|
41
|
-
};
|
|
42
29
|
declare const FloatingComposer: react.ForwardRefExoticComponent<Omit<ComposerProps<BaseMetadata$1>, "threadId" | "commentId"> & {
|
|
43
30
|
editor: Editor | null;
|
|
44
31
|
} & react.RefAttributes<HTMLFormElement>>;
|
|
@@ -77,244 +64,6 @@ type LiveblocksExtensionOptions = {
|
|
|
77
64
|
declare function useIsEditorReady(): boolean;
|
|
78
65
|
declare const useLiveblocksExtension: (opts?: LiveblocksExtensionOptions) => Extension;
|
|
79
66
|
|
|
80
|
-
interface ToolbarSlotProps {
|
|
81
|
-
editor: Editor;
|
|
82
|
-
}
|
|
83
|
-
type ToolbarSlot = ReactNode | ComponentType<ToolbarSlotProps>;
|
|
84
|
-
interface ToolbarProps extends Omit<ComponentProps<"div">, "children"> {
|
|
85
|
-
/**
|
|
86
|
-
* The Tiptap editor.
|
|
87
|
-
*/
|
|
88
|
-
editor: Editor | null;
|
|
89
|
-
/**
|
|
90
|
-
* The content of the toolbar, overriding the default content.
|
|
91
|
-
* Use the `before` and `after` props if you want to keep and extend the default content.
|
|
92
|
-
*/
|
|
93
|
-
children?: ToolbarSlot;
|
|
94
|
-
/**
|
|
95
|
-
* The content to display at the start of the toolbar.
|
|
96
|
-
*/
|
|
97
|
-
before?: ToolbarSlot;
|
|
98
|
-
/**
|
|
99
|
-
* The content to display at the end of the toolbar.
|
|
100
|
-
*/
|
|
101
|
-
after?: ToolbarSlot;
|
|
102
|
-
}
|
|
103
|
-
interface ToolbarButtonProps extends ComponentProps<"button"> {
|
|
104
|
-
/**
|
|
105
|
-
* The name of this button displayed in its tooltip.
|
|
106
|
-
*/
|
|
107
|
-
name: string;
|
|
108
|
-
/**
|
|
109
|
-
* An optional icon displayed in this button.
|
|
110
|
-
*/
|
|
111
|
-
icon?: ReactNode;
|
|
112
|
-
/**
|
|
113
|
-
* An optional keyboard shortcut displayed in this button's tooltip.
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* "Mod-Alt-B" → "⌘⌥B" in Apple environments, "⌃⌥B" otherwise
|
|
117
|
-
* "Ctrl-Shift-Escape" → "⌃⇧⎋"
|
|
118
|
-
* "Space" → "␣"
|
|
119
|
-
*/
|
|
120
|
-
shortcut?: string;
|
|
121
|
-
}
|
|
122
|
-
interface ToolbarToggleProps extends ToolbarButtonProps {
|
|
123
|
-
/**
|
|
124
|
-
* Whether the button is toggled.
|
|
125
|
-
*/
|
|
126
|
-
active: boolean;
|
|
127
|
-
}
|
|
128
|
-
interface ToolbarBlockSelectorItem {
|
|
129
|
-
/**
|
|
130
|
-
* The name of this block element, displayed as the label of this item.
|
|
131
|
-
*/
|
|
132
|
-
name: string;
|
|
133
|
-
/**
|
|
134
|
-
* Optionally replace the name used as the label of this item by any content.
|
|
135
|
-
*/
|
|
136
|
-
label?: ReactNode;
|
|
137
|
-
/**
|
|
138
|
-
* An optional icon displayed in this item.
|
|
139
|
-
*/
|
|
140
|
-
icon?: ReactNode;
|
|
141
|
-
/**
|
|
142
|
-
* Whether this block element is currently active.
|
|
143
|
-
* Set to `"default"` to display this item when no other item is active.
|
|
144
|
-
*/
|
|
145
|
-
isActive: ((editor: Editor) => boolean) | "default";
|
|
146
|
-
/**
|
|
147
|
-
* A callback invoked when this item is selected.
|
|
148
|
-
*/
|
|
149
|
-
setActive: (editor: Editor) => void;
|
|
150
|
-
}
|
|
151
|
-
interface ToolbarBlockSelectorProps extends ComponentProps<"button"> {
|
|
152
|
-
/**
|
|
153
|
-
* The items displayed in this block selector.
|
|
154
|
-
* When provided as an array, the default items are overridden. To avoid this,
|
|
155
|
-
* a function can be provided instead and it will receive the default items.
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* <Toolbar.BlockSelector
|
|
159
|
-
* items={[
|
|
160
|
-
* {
|
|
161
|
-
* name: "Text",
|
|
162
|
-
* isActive: "default",
|
|
163
|
-
* setActive: () => { ... },
|
|
164
|
-
* },
|
|
165
|
-
* {
|
|
166
|
-
* name: "Heading 1",
|
|
167
|
-
* isActive: () => { ... },
|
|
168
|
-
* setActive: () => { ... },
|
|
169
|
-
* },
|
|
170
|
-
* ]}
|
|
171
|
-
* />
|
|
172
|
-
*
|
|
173
|
-
* @example
|
|
174
|
-
* <Toolbar.BlockSelector
|
|
175
|
-
* items={(defaultItems) => [
|
|
176
|
-
* ...defaultItems,
|
|
177
|
-
* {
|
|
178
|
-
* name: "Custom block",
|
|
179
|
-
* isActive: () => { ... },
|
|
180
|
-
* setActive: () => { ... },
|
|
181
|
-
* },
|
|
182
|
-
* ]}
|
|
183
|
-
* />
|
|
184
|
-
*/
|
|
185
|
-
items?: ToolbarBlockSelectorItem[] | ((defaultItems: ToolbarBlockSelectorItem[]) => ToolbarBlockSelectorItem[]);
|
|
186
|
-
}
|
|
187
|
-
type ToolbarSeparatorProps = ComponentProps<"div">;
|
|
188
|
-
declare function ToolbarSectionHistory(): react_jsx_runtime.JSX.Element;
|
|
189
|
-
declare function ToolbarSectionInline(): react_jsx_runtime.JSX.Element;
|
|
190
|
-
declare function ToolbarSectionCollaboration(): react_jsx_runtime.JSX.Element;
|
|
191
|
-
/**
|
|
192
|
-
* A static toolbar containing actions and values related to the editor.
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* <Toolbar editor={editor} />
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* <Toolbar editor={editor}>
|
|
199
|
-
* <Toolbar.BlockSelector />
|
|
200
|
-
* <Toolbar.Separator />
|
|
201
|
-
* <Toolbar.SectionInline />
|
|
202
|
-
* <Toolbar.Separator />
|
|
203
|
-
* <Toolbar.Button name="Custom action" onClick={() => { ... }} icon={<Icon.QuestionMark />} />
|
|
204
|
-
* </Toolbar>
|
|
205
|
-
*/
|
|
206
|
-
declare const Toolbar: react.ForwardRefExoticComponent<Omit<ToolbarProps, "ref"> & react.RefAttributes<HTMLDivElement>> & {
|
|
207
|
-
/**
|
|
208
|
-
* A button for triggering actions.
|
|
209
|
-
*
|
|
210
|
-
* @example
|
|
211
|
-
* <Toolbar.Button name="Comment" shortcut="Mod-Shift-E" onClick={() => { ... }}>Comment</Toolbar.Button>
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* <Toolbar.Button name="Mention someone" icon={<Icon.Mention />} onClick={() => { ... }} />
|
|
215
|
-
*/
|
|
216
|
-
Button: react.ForwardRefExoticComponent<Omit<ToolbarButtonProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
217
|
-
/**
|
|
218
|
-
* A toggle button for values that can be active or inactive.
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* <Toolbar.Toggle name="Bold" active={isBold}>Bold</Toolbar.Toggle>
|
|
222
|
-
*
|
|
223
|
-
* @example
|
|
224
|
-
* <Toolbar.Toggle name="Italic" icon={<Icon.Italic />} shortcut="Mod-I" active={isItalic} onClick={() => { ... }} />
|
|
225
|
-
*/
|
|
226
|
-
Toggle: react.ForwardRefExoticComponent<Omit<ToolbarToggleProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
227
|
-
/**
|
|
228
|
-
* A dropdown selector to switch between different block types.
|
|
229
|
-
*
|
|
230
|
-
* @example
|
|
231
|
-
* <Toolbar.BlockSelector />
|
|
232
|
-
*/
|
|
233
|
-
BlockSelector: react.ForwardRefExoticComponent<Omit<ToolbarBlockSelectorProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
234
|
-
/**
|
|
235
|
-
* A visual (and accessible) separator to separate sections in a toolbar.
|
|
236
|
-
*/
|
|
237
|
-
Separator: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
238
|
-
/**
|
|
239
|
-
* A section containing history actions. (e.g. undo, redo)
|
|
240
|
-
*/
|
|
241
|
-
SectionHistory: typeof ToolbarSectionHistory;
|
|
242
|
-
/**
|
|
243
|
-
* A section containing inline formatting actions. (e.g. bold, italic, underline, ...)
|
|
244
|
-
*/
|
|
245
|
-
SectionInline: typeof ToolbarSectionInline;
|
|
246
|
-
/**
|
|
247
|
-
* A section containing collaborative actions. (e.g. adding a comment)
|
|
248
|
-
*/
|
|
249
|
-
SectionCollaboration: typeof ToolbarSectionCollaboration;
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
interface FloatingToolbarProps extends Omit<ComponentProps<"div">, "children"> {
|
|
253
|
-
/**
|
|
254
|
-
* The Tiptap editor.
|
|
255
|
-
*/
|
|
256
|
-
editor: Editor | null;
|
|
257
|
-
/**
|
|
258
|
-
* The vertical position of the floating toolbar.
|
|
259
|
-
*/
|
|
260
|
-
position?: FloatingPosition;
|
|
261
|
-
/**
|
|
262
|
-
* The vertical offset of the floating toolbar from the selection.
|
|
263
|
-
*/
|
|
264
|
-
offset?: number;
|
|
265
|
-
/**
|
|
266
|
-
* The content of the floating toolbar, overriding the default content.
|
|
267
|
-
* Use the `before` and `after` props if you want to keep and extend the default content.
|
|
268
|
-
*/
|
|
269
|
-
children?: ToolbarSlot;
|
|
270
|
-
/**
|
|
271
|
-
* The content to display at the start of the floating toolbar.
|
|
272
|
-
*/
|
|
273
|
-
before?: ToolbarSlot;
|
|
274
|
-
/**
|
|
275
|
-
* The content to display at the end of the floating toolbar.
|
|
276
|
-
*/
|
|
277
|
-
after?: ToolbarSlot;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* A floating toolbar attached to the selection and containing actions and values related to the editor.
|
|
281
|
-
*
|
|
282
|
-
* @example
|
|
283
|
-
* <FloatingToolbar editor={editor} />
|
|
284
|
-
*
|
|
285
|
-
* @example
|
|
286
|
-
* <FloatingToolbar editor={editor}>
|
|
287
|
-
* <Toolbar.BlockSelector />
|
|
288
|
-
* <Toolbar.Separator />
|
|
289
|
-
* <Toolbar.SectionInline />
|
|
290
|
-
* <Toolbar.Separator />
|
|
291
|
-
* <Toolbar.Button name="Custom action" onClick={() => { ... }} icon={<Icon.QuestionMark />} />
|
|
292
|
-
* </FloatingToolbar>
|
|
293
|
-
*/
|
|
294
|
-
declare const FloatingToolbar: react.ForwardRefExoticComponent<Omit<FloatingToolbarProps, "ref"> & react.RefAttributes<HTMLDivElement>> & {
|
|
295
|
-
/**
|
|
296
|
-
* A component that can be wrapped around elements which are rendered outside of the floating
|
|
297
|
-
* toolbar (e.g. portals) to prevent the toolbar from closing when clicking/focusing within them.
|
|
298
|
-
*
|
|
299
|
-
* @example
|
|
300
|
-
* <FloatingToolbar editor={editor}>
|
|
301
|
-
* <Popover.Root>
|
|
302
|
-
* <Popover.Trigger asChild>
|
|
303
|
-
* <Toolbar.Button>Open popover</Toolbar.Button>
|
|
304
|
-
* </Popover.Trigger>
|
|
305
|
-
* <Popover.Portal>
|
|
306
|
-
* <FloatingToolbar.External>
|
|
307
|
-
* <Popover.Content>
|
|
308
|
-
* This popover is rendered outside of the floating toolbar, but the toolbar will not close when clicking/focusing within it.
|
|
309
|
-
* </Popover.Content>
|
|
310
|
-
* </FloatingToolbar.External>
|
|
311
|
-
* </Popover.Portal>
|
|
312
|
-
* </Popover.Root>
|
|
313
|
-
* </FloatingToolbar>
|
|
314
|
-
*/
|
|
315
|
-
External: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
316
|
-
};
|
|
317
|
-
|
|
318
67
|
interface HistoryVersionPreviewProps extends ComponentPropsWithoutRef<"div"> {
|
|
319
68
|
version: HistoryVersion;
|
|
320
69
|
editor: Editor;
|
|
@@ -330,8 +79,15 @@ declare const HistoryVersionPreview: react.ForwardRefExoticComponent<HistoryVers
|
|
|
330
79
|
|
|
331
80
|
declare module "@tiptap/core" {
|
|
332
81
|
interface Commands<ReturnType> {
|
|
333
|
-
comments:
|
|
82
|
+
comments: {
|
|
83
|
+
/**
|
|
84
|
+
* Add a comment
|
|
85
|
+
*/
|
|
86
|
+
addComment: (id: string) => ReturnType;
|
|
87
|
+
selectThread: (id: string | null) => ReturnType;
|
|
88
|
+
addPendingComment: () => ReturnType;
|
|
89
|
+
};
|
|
334
90
|
}
|
|
335
91
|
}
|
|
336
92
|
|
|
337
|
-
export { AnchoredThreads,
|
|
93
|
+
export { AnchoredThreads, FloatingComposer, FloatingThreads, HistoryVersionPreview, useIsEditorReady, useLiveblocksExtension };
|