@liveblocks/react-tiptap 2.17.0-channels1 → 2.17.0-usrnotsettings1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/LiveblocksExtension.js +0 -4
  2. package/dist/LiveblocksExtension.js.map +1 -1
  3. package/dist/LiveblocksExtension.mjs +2 -6
  4. package/dist/LiveblocksExtension.mjs.map +1 -1
  5. package/dist/comments/CommentsExtension.js +6 -2
  6. package/dist/comments/CommentsExtension.js.map +1 -1
  7. package/dist/comments/CommentsExtension.mjs +7 -3
  8. package/dist/comments/CommentsExtension.mjs.map +1 -1
  9. package/dist/comments/FloatingComposer.js +29 -30
  10. package/dist/comments/FloatingComposer.js.map +1 -1
  11. package/dist/comments/FloatingComposer.mjs +31 -32
  12. package/dist/comments/FloatingComposer.mjs.map +1 -1
  13. package/dist/context.js +24 -0
  14. package/dist/context.js.map +1 -0
  15. package/dist/context.mjs +21 -0
  16. package/dist/context.mjs.map +1 -0
  17. package/dist/index.d.mts +254 -10
  18. package/dist/index.d.ts +254 -10
  19. package/dist/index.js +4 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +2 -0
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/toolbar/FloatingToolbar.js +321 -0
  24. package/dist/toolbar/FloatingToolbar.js.map +1 -0
  25. package/dist/toolbar/FloatingToolbar.mjs +318 -0
  26. package/dist/toolbar/FloatingToolbar.mjs.map +1 -0
  27. package/dist/toolbar/Toolbar.js +397 -0
  28. package/dist/toolbar/Toolbar.js.map +1 -0
  29. package/dist/toolbar/Toolbar.mjs +372 -0
  30. package/dist/toolbar/Toolbar.mjs.map +1 -0
  31. package/dist/toolbar/shared.js +36 -0
  32. package/dist/toolbar/shared.js.map +1 -0
  33. package/dist/toolbar/shared.mjs +33 -0
  34. package/dist/toolbar/shared.mjs.map +1 -0
  35. package/dist/types.js +7 -3
  36. package/dist/types.js.map +1 -1
  37. package/dist/types.mjs +6 -3
  38. package/dist/types.mjs.map +1 -1
  39. package/dist/utils.js +17 -0
  40. package/dist/utils.js.map +1 -1
  41. package/dist/utils.mjs +16 -1
  42. package/dist/utils.mjs.map +1 -1
  43. package/dist/version-history/HistoryVersionPreview.js +79 -79
  44. package/dist/version-history/HistoryVersionPreview.js.map +1 -1
  45. package/dist/version-history/HistoryVersionPreview.mjs +79 -79
  46. package/dist/version-history/HistoryVersionPreview.mjs.map +1 -1
  47. package/dist/version.js +1 -1
  48. package/dist/version.js.map +1 -1
  49. package/dist/version.mjs +1 -1
  50. package/dist/version.mjs.map +1 -1
  51. package/package.json +8 -6
  52. package/src/styles/constants.css +2 -1
  53. package/src/styles/index.css +58 -6
  54. package/src/styles/utils.css +11 -0
  55. package/styles.css +1 -1
  56. package/styles.css.map +1 -1
@@ -1,27 +1,27 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { useFloating, flip, offset, hide, shift, limitShift, size, autoUpdate } from '@floating-ui/react-dom';
2
+ import { useFloating, inline, 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, useEffect } from 'react';
7
+ import { forwardRef, useCallback } from 'react';
8
8
  import { createPortal } from 'react-dom';
9
+ import { compareSelections, getDomRangeFromSelection } from '../utils.mjs';
9
10
 
10
11
  const FLOATING_COMPOSER_COLLISION_PADDING = 10;
11
12
  const FloatingComposer = forwardRef(function FloatingComposer2(props, forwardedRef) {
12
13
  const createThread = useCreateThread();
13
14
  const { editor, onComposerSubmit, onKeyDown } = props;
14
- const { showComposer } = useEditorState({
15
+ const pendingCommentSelection = useEditorState({
15
16
  editor,
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 };
17
+ selector: (ctx) => {
18
+ if (!ctx.editor)
19
+ return;
20
+ return ctx.editor.storage.liveblocksComments?.pendingComment && !ctx.editor.state.selection.empty ? ctx.editor.state.selection : void 0;
21
+ },
22
+ equalityFn: compareSelections
23
+ }) ?? void 0;
24
+ const isOpen = pendingCommentSelection !== void 0;
25
25
  const {
26
26
  refs: { setReference, setFloating },
27
27
  strategy,
@@ -31,6 +31,7 @@ const FloatingComposer = forwardRef(function FloatingComposer2(props, forwardedR
31
31
  strategy: "fixed",
32
32
  placement: "bottom",
33
33
  middleware: [
34
+ inline({ padding: FLOATING_COMPOSER_COLLISION_PADDING }),
34
35
  flip({ padding: FLOATING_COMPOSER_COLLISION_PADDING, crossAxis: false }),
35
36
  offset(10),
36
37
  hide({ padding: FLOATING_COMPOSER_COLLISION_PADDING }),
@@ -46,25 +47,20 @@ const FloatingComposer = forwardRef(function FloatingComposer2(props, forwardedR
46
47
  });
47
48
  }
48
49
  });
49
- const updateRef = useCallback(() => {
50
- if (!editor || !showComposer) {
50
+ useLayoutEffect(() => {
51
+ if (!editor || !isOpen) {
51
52
  return;
52
53
  }
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;
54
+ if (!pendingCommentSelection) {
55
+ setReference(null);
56
+ } else {
57
+ const domRange = getDomRangeFromSelection(
58
+ pendingCommentSelection,
59
+ editor
60
+ );
61
+ setReference(domRange);
61
62
  }
62
- editor.on("transaction", updateRef);
63
- return () => {
64
- editor.off("transaction", updateRef);
65
- };
66
- }, [editor, updateRef, showComposer]);
67
- useLayoutEffect(updateRef, [updateRef]);
63
+ }, [pendingCommentSelection, editor, isOpen, setReference]);
68
64
  const handleComposerSubmit = useCallback(
69
65
  (comment, event) => {
70
66
  onComposerSubmit?.(comment, event);
@@ -85,14 +81,17 @@ const FloatingComposer = forwardRef(function FloatingComposer2(props, forwardedR
85
81
  );
86
82
  const handleKeyDown = useCallback(
87
83
  (event) => {
88
- if (event.key === "Escape" && editor) {
89
- editor.commands.focus();
90
- }
91
84
  onKeyDown?.(event);
85
+ if (event.isDefaultPrevented() || !editor) {
86
+ return;
87
+ }
88
+ if (event.key === "Escape") {
89
+ editor.chain().closePendingComment().run();
90
+ }
92
91
  },
93
92
  [editor, onKeyDown]
94
93
  );
95
- if (!showComposer || !editor) {
94
+ if (!isOpen || !editor) {
96
95
  return null;
97
96
  }
98
97
  return createPortal(
@@ -1 +1 @@
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,CAA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AA,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,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;;;;"}
1
+ {"version":3,"file":"FloatingComposer.mjs","sources":["../../src/comments/FloatingComposer.tsx"],"sourcesContent":["import {\n autoUpdate,\n flip,\n hide,\n inline,\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 } from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport type {\n CommentsExtensionStorage,\n ExtendedChainedCommands,\n} from \"../types\";\nimport { compareSelections, getDomRangeFromSelection } from \"../utils\";\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 pendingCommentSelection =\n useEditorState({\n editor,\n selector: (ctx) => {\n if (!ctx.editor) return;\n\n return (\n ctx.editor.storage.liveblocksComments as\n | CommentsExtensionStorage\n | undefined\n )?.pendingComment && !ctx.editor.state.selection.empty\n ? ctx.editor.state.selection\n : undefined;\n },\n equalityFn: compareSelections,\n }) ?? undefined;\n const isOpen = pendingCommentSelection !== undefined;\n const {\n refs: { setReference, setFloating },\n strategy,\n x,\n y,\n } = useFloating({\n strategy: \"fixed\",\n placement: \"bottom\",\n middleware: [\n inline({ padding: FLOATING_COMPOSER_COLLISION_PADDING }),\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 useLayoutEffect(() => {\n if (!editor || !isOpen) {\n return;\n }\n\n if (!pendingCommentSelection) {\n setReference(null);\n } else {\n const domRange = getDomRangeFromSelection(\n pendingCommentSelection,\n editor\n );\n\n setReference(domRange);\n }\n }, [pendingCommentSelection, editor, isOpen, setReference]);\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 onKeyDown?.(event);\n\n if (event.isDefaultPrevented() || !editor) {\n return;\n }\n\n if (event.key === \"Escape\") {\n (editor.chain() as ExtendedChainedCommands<\"closePendingComment\">)\n .closePendingComment()\n .run();\n }\n },\n [editor, onKeyDown]\n );\n\n if (!isOpen || !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":";;;;;;;;;;AAwCO,MAAM,mCAAsC,GAAA,GAAA;AAE5C,MAAM,gBAAm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A,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;;;;"}
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var core = require('@liveblocks/core');
5
+ var react = require('react');
6
+
7
+ const EditorContext = react.createContext(null);
8
+ function EditorProvider({
9
+ editor,
10
+ children
11
+ }) {
12
+ return /* @__PURE__ */ jsxRuntime.jsx(EditorContext.Provider, {
13
+ value: editor,
14
+ children
15
+ });
16
+ }
17
+ function useCurrentEditor(source, parent) {
18
+ const currentEditor = react.useContext(EditorContext);
19
+ return core.nn(currentEditor, `${source} can\u2019t be used outside of ${parent}.`);
20
+ }
21
+
22
+ exports.EditorProvider = EditorProvider;
23
+ exports.useCurrentEditor = useCurrentEditor;
24
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sources":["../src/context.tsx"],"sourcesContent":["import { nn } from \"@liveblocks/core\";\nimport type { Editor } from \"@tiptap/react\";\nimport type { PropsWithChildren } from \"react\";\nimport { createContext, useContext } from \"react\";\n\nconst EditorContext = createContext<Editor | null>(null);\n\nexport function EditorProvider({\n editor,\n children,\n}: PropsWithChildren<{ editor: Editor }>) {\n return (\n <EditorContext.Provider value={editor}>{children}</EditorContext.Provider>\n );\n}\n\n/**\n * @tiptap/react already offers a `useCurrentEditor` hook but our components might\n * not live under `EditorProvider` or `EditorContent` so we create our own to reduce\n * repetition within our own nested components.\n *\n * @example\n * <Toolbar editor={editor}> // `editor` is required here\n * <ToolbarSectionInline /> // But it isn't there, because `Toolbar` uses our own `EditorProvider`\n * </Toolbar>\n */\nexport function useCurrentEditor(source: string, parent: string) {\n const currentEditor = useContext(EditorContext);\n\n return nn(currentEditor, `${source} can’t be used outside of ${parent}.`);\n}\n"],"names":["createContext","jsx","useContext","nn"],"mappings":";;;;;;AAKA,MAAM,aAAA,GAAgBA,oBAA6B,IAAI,CAAA,CAAA;AAEhD,SAAS,cAAe,CAAA;AAAA,EAC7B,MAAA;AAAA,EACA,QAAA;AACF,CAA0C,EAAA;AACxC,EACE,uBAAAC,cAAA,CAAC,cAAc,QAAd,EAAA;AAAA,IAAuB,KAAO,EAAA,MAAA;AAAA,IAAS,QAAA;AAAA,GAAS,CAAA,CAAA;AAErD,CAAA;AAYgB,SAAA,gBAAA,CAAiB,QAAgB,MAAgB,EAAA;AAC/D,EAAM,MAAA,aAAA,GAAgBC,iBAAW,aAAa,CAAA,CAAA;AAE9C,EAAA,OAAOC,OAAG,CAAA,aAAA,EAAe,CAAG,EAAA,MAAA,CAAA,+BAAA,EAAmC,MAAS,CAAA,CAAA,CAAA,CAAA,CAAA;AAC1E;;;;;"}
@@ -0,0 +1,21 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { nn } from '@liveblocks/core';
3
+ import { createContext, useContext } from 'react';
4
+
5
+ const EditorContext = createContext(null);
6
+ function EditorProvider({
7
+ editor,
8
+ children
9
+ }) {
10
+ return /* @__PURE__ */ jsx(EditorContext.Provider, {
11
+ value: editor,
12
+ children
13
+ });
14
+ }
15
+ function useCurrentEditor(source, parent) {
16
+ const currentEditor = useContext(EditorContext);
17
+ return nn(currentEditor, `${source} can\u2019t be used outside of ${parent}.`);
18
+ }
19
+
20
+ export { EditorProvider, useCurrentEditor };
21
+ //# sourceMappingURL=context.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.mjs","sources":["../src/context.tsx"],"sourcesContent":["import { nn } from \"@liveblocks/core\";\nimport type { Editor } from \"@tiptap/react\";\nimport type { PropsWithChildren } from \"react\";\nimport { createContext, useContext } from \"react\";\n\nconst EditorContext = createContext<Editor | null>(null);\n\nexport function EditorProvider({\n editor,\n children,\n}: PropsWithChildren<{ editor: Editor }>) {\n return (\n <EditorContext.Provider value={editor}>{children}</EditorContext.Provider>\n );\n}\n\n/**\n * @tiptap/react already offers a `useCurrentEditor` hook but our components might\n * not live under `EditorProvider` or `EditorContent` so we create our own to reduce\n * repetition within our own nested components.\n *\n * @example\n * <Toolbar editor={editor}> // `editor` is required here\n * <ToolbarSectionInline /> // But it isn't there, because `Toolbar` uses our own `EditorProvider`\n * </Toolbar>\n */\nexport function useCurrentEditor(source: string, parent: string) {\n const currentEditor = useContext(EditorContext);\n\n return nn(currentEditor, `${source} can’t be used outside of ${parent}.`);\n}\n"],"names":[],"mappings":";;;;AAKA,MAAM,aAAA,GAAgB,cAA6B,IAAI,CAAA,CAAA;AAEhD,SAAS,cAAe,CAAA;AAAA,EAC7B,MAAA;AAAA,EACA,QAAA;AACF,CAA0C,EAAA;AACxC,EACE,uBAAA,GAAA,CAAC,cAAc,QAAd,EAAA;AAAA,IAAuB,KAAO,EAAA,MAAA;AAAA,IAAS,QAAA;AAAA,GAAS,CAAA,CAAA;AAErD,CAAA;AAYgB,SAAA,gBAAA,CAAiB,QAAgB,MAAgB,EAAA;AAC/D,EAAM,MAAA,aAAA,GAAgB,WAAW,aAAa,CAAA,CAAA;AAE9C,EAAA,OAAO,EAAG,CAAA,aAAA,EAAe,CAAG,EAAA,MAAA,CAAA,+BAAA,EAAmC,MAAS,CAAA,CAAA,CAAA,CAAA,CAAA;AAC1E;;;;"}
package/dist/index.d.mts CHANGED
@@ -3,10 +3,20 @@ 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 } from 'react';
6
+ import { ComponentPropsWithoutRef, ComponentType, HTMLAttributes, ComponentProps, ReactNode } 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
+
10
20
  type AnchoredThreadsComponents = {
11
21
  Thread: ComponentType<ThreadProps>;
12
22
  };
@@ -26,6 +36,9 @@ interface AnchoredThreadsProps<M extends BaseMetadata = DM> extends Omit<Compone
26
36
  }
27
37
  declare function AnchoredThreads({ threads, components, className, style, editor, ...props }: AnchoredThreadsProps): react_jsx_runtime.JSX.Element | null;
28
38
 
39
+ type FloatingComposerProps<M extends BaseMetadata$1 = DM> = Omit<ComposerProps<M>, "threadId" | "commentId"> & {
40
+ editor: Editor | null;
41
+ };
29
42
  declare const FloatingComposer: react.ForwardRefExoticComponent<Omit<ComposerProps<BaseMetadata$1>, "threadId" | "commentId"> & {
30
43
  editor: Editor | null;
31
44
  } & react.RefAttributes<HTMLFormElement>>;
@@ -64,6 +77,244 @@ type LiveblocksExtensionOptions = {
64
77
  declare function useIsEditorReady(): boolean;
65
78
  declare const useLiveblocksExtension: (opts?: LiveblocksExtensionOptions) => Extension;
66
79
 
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={() => { ... }} />
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} />
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
+
67
318
  interface HistoryVersionPreviewProps extends ComponentPropsWithoutRef<"div"> {
68
319
  version: HistoryVersion;
69
320
  editor: Editor;
@@ -79,15 +330,8 @@ declare const HistoryVersionPreview: react.ForwardRefExoticComponent<HistoryVers
79
330
 
80
331
  declare module "@tiptap/core" {
81
332
  interface Commands<ReturnType> {
82
- comments: {
83
- /**
84
- * Add a comment
85
- */
86
- addComment: (id: string) => ReturnType;
87
- selectThread: (id: string | null) => ReturnType;
88
- addPendingComment: () => ReturnType;
89
- };
333
+ comments: CommentsCommands<ReturnType>;
90
334
  }
91
335
  }
92
336
 
93
- export { AnchoredThreads, FloatingComposer, FloatingThreads, HistoryVersionPreview, useIsEditorReady, useLiveblocksExtension };
337
+ export { AnchoredThreads, AnchoredThreadsProps, FloatingComposer, FloatingComposerProps, FloatingThreads, FloatingThreadsProps, FloatingToolbar, FloatingToolbarProps, HistoryVersionPreview, HistoryVersionPreviewProps, Toolbar, ToolbarBlockSelectorItem, ToolbarBlockSelectorProps, ToolbarButtonProps, ToolbarProps, ToolbarSeparatorProps, ToolbarToggleProps, useIsEditorReady, useLiveblocksExtension };