@liveblocks/react-lexical 3.10.0 → 3.11.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/README.md ADDED
@@ -0,0 +1,67 @@
1
+ <p align="center">
2
+ <a href="https://liveblocks.io#gh-light-mode-only">
3
+ <img src="https://raw.githubusercontent.com/liveblocks/liveblocks/main/.github/assets/header-light.svg" alt="Liveblocks" />
4
+ </a>
5
+ <a href="https://liveblocks.io#gh-dark-mode-only">
6
+ <img src="https://raw.githubusercontent.com/liveblocks/liveblocks/main/.github/assets/header-dark.svg" alt="Liveblocks" />
7
+ </a>
8
+ </p>
9
+
10
+ # `@liveblocks/react-lexical`
11
+
12
+ <p>
13
+ <a href="https://npmjs.org/package/@liveblocks/react-lexical">
14
+ <img src="https://img.shields.io/npm/v/@liveblocks/react-lexical?style=flat&label=npm&color=c33" alt="NPM" />
15
+ </a>
16
+ <a href="https://bundlephobia.com/package/@liveblocks/react-lexical">
17
+ <img src="https://img.shields.io/bundlephobia/minzip/@liveblocks/react-lexical?style=flat&label=size&color=09f" alt="Size" />
18
+ </a>
19
+ <a href="https://github.com/liveblocks/liveblocks/blob/main/LICENSE">
20
+ <img src="https://img.shields.io/github/license/liveblocks/liveblocks?style=flat&label=license&color=f80" alt="License" />
21
+ </a>
22
+ </p>
23
+
24
+ `@liveblocks/react-lexical` provides [React](https://reactjs.org/) APIs to
25
+ integrate [Lexical](https://lexical.dev/) text editors with Liveblocks—a
26
+ platform to build, host, and scale collaborative applications with zero
27
+ configuration, no maintenance required.
28
+
29
+ ## Installation
30
+
31
+ ```
32
+ npm install @liveblocks/client @liveblocks/react @liveblocks/react-lexical
33
+ ```
34
+
35
+ ## Documentation
36
+
37
+ Read the
38
+ [documentation](https://liveblocks.io/docs/api-reference/liveblocks-react-lexical)
39
+ for guides and API references.
40
+
41
+ ## Examples
42
+
43
+ Explore our [collaborative examples](https://liveblocks.io/examples) to help you
44
+ get started.
45
+
46
+ > All examples are open-source and live in this repository, within
47
+ > [`/examples`](../../examples).
48
+
49
+ ## Releases
50
+
51
+ See the [latest changes](https://github.com/liveblocks/liveblocks/releases) or
52
+ learn more about
53
+ [upcoming releases](https://github.com/liveblocks/liveblocks/milestones).
54
+
55
+ ## Community
56
+
57
+ - [Discord](https://liveblocks.io/discord) - To get involved with the Liveblocks
58
+ community, ask questions and share tips.
59
+ - [X](https://x.com/liveblocks) - To receive updates, announcements, blog posts,
60
+ and general Liveblocks tips.
61
+
62
+ ## License
63
+
64
+ Licensed under the Apache License 2.0, Copyright © 2021-present
65
+ [Liveblocks](https://liveblocks.io).
66
+
67
+ See [LICENSE](../../LICENSE) for more information.
@@ -75,7 +75,7 @@ const LiveblocksPlugin = ({
75
75
  const self = react$1.useSelf();
76
76
  const providerFactory = react.useCallback(
77
77
  (id, yjsDocMap) => {
78
- const provider = yjs.getYjsProviderForRoom(room);
78
+ const provider = yjs.getYjsProviderForRoom(room, {}, true);
79
79
  yjsDocMap.set(id, provider.getYDoc());
80
80
  return provider;
81
81
  },
@@ -1 +1 @@
1
- {"version":3,"file":"liveblocks-plugin-provider.cjs","sources":["../src/liveblocks-plugin-provider.tsx"],"sourcesContent":["import { autoUpdate, useFloating } from \"@floating-ui/react-dom\";\nimport { CollaborationPlugin } from \"@lexical/react/LexicalCollaborationPlugin\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { Provider } from \"@lexical/yjs\";\nimport { TextEditorType } from \"@liveblocks/core\";\nimport { useRoom, useSelf } from \"@liveblocks/react\";\nimport {\n useLayoutEffect,\n useReportTextEditor,\n useResolveMentionSuggestions,\n useYjsProvider,\n} from \"@liveblocks/react/_private\";\nimport { getYjsProviderForRoom } from \"@liveblocks/yjs\";\nimport type { MutableRefObject, ReactNode } from \"react\";\nimport { useCallback, useEffect, useState, useSyncExternalStore } from \"react\";\nimport type { Doc } from \"yjs\";\n\nimport { CommentPluginProvider } from \"./comments/comment-plugin-provider\";\nimport { ThreadMarkNode } from \"./comments/thread-mark-node\";\nimport { GroupMentionNode } from \"./mentions/group-mention-node\";\nimport { MentionNode } from \"./mentions/mention-node\";\nimport { MentionPlugin } from \"./mentions/mention-plugin\";\nimport { useRootElement } from \"./use-root-element\";\n\n/**\n * Returns whether the editor has loaded the initial text contents from the\n * server and is ready to be used.\n */\nexport function useIsEditorReady(): boolean {\n const yjsProvider = useYjsProvider();\n\n const getSnapshot = useCallback(() => {\n const status = yjsProvider?.getStatus();\n return status === \"synchronizing\" || status === \"synchronized\";\n }, [yjsProvider]);\n\n const subscribe = useCallback(\n (callback: () => void) => {\n if (yjsProvider === undefined) return () => {};\n yjsProvider.on(\"status\", callback);\n return () => {\n yjsProvider.off(\"status\", callback);\n };\n },\n [yjsProvider]\n );\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\nexport type LiveblocksPluginProps = {\n children?: ReactNode;\n};\n\n/**\n * Liveblocks plugin for Lexical that adds collaboration to your editor.\n *\n * `LiveblocksPlugin` should always be nested inside `LexicalComposer`.\n *\n * @example\n *\n * import { LexicalComposer } from \"@lexical/react/LexicalComposer\";\n * import { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\n * import { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\n * import { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\n * import { liveblocksConfig, LiveblocksPlugin } from \"@liveblocks/react-lexical\";\n *\n * const initialConfig = liveblocksConfig({\n * namespace: \"MyEditor\",\n * theme: {},\n * nodes: [],\n * onError: (err) => console.error(err),\n * });\n *\n * function Editor() {\n * return (\n * <LexicalComposer initialConfig={initialConfig}>\n * <LiveblocksPlugin />\n * <RichTextPlugin\n * contentEditable={<ContentEditable />}\n * placeholder={<div>Enter some text...</div>}\n * ErrorBoundary={LexicalErrorBoundary}\n * />\n * </LexicalComposer>\n * );\n * }\n */\nexport const LiveblocksPlugin = ({\n children,\n}: LiveblocksPluginProps): JSX.Element => {\n const isResolveMentionSuggestionsDefined =\n useResolveMentionSuggestions() !== undefined;\n const [editor] = useLexicalComposerContext();\n const room = useRoom();\n\n if (!editor.hasNodes([ThreadMarkNode, MentionNode, GroupMentionNode])) {\n throw new Error(\n \"LiveblocksPlugin requires Lexical configuration to be wrapped in the `liveblocksConfig(options)` function. For more information: https://liveblocks.io/docs/api-reference/liveblocks-react-lexical#liveblocksConfig\"\n );\n }\n\n const [containerRef, setContainerRef] = useState<\n MutableRefObject<HTMLDivElement | null> | undefined\n >(undefined);\n\n const {\n refs: { setReference, setFloating },\n strategy,\n x,\n y,\n } = useFloating({\n strategy: \"fixed\",\n placement: \"bottom\",\n whileElementsMounted: (...args) => {\n return autoUpdate(...args, {\n animationFrame: true,\n });\n },\n });\n\n // Warn users if initialConfig.editorState, set on the composer, is not null\n useEffect(() => {\n // only in dev mode\n if (process.env.NODE_ENV !== \"production\") {\n // A user should not even be set an emptyState, but when passing null, getEditorState still has initial empty state\n if (!editor.getEditorState().isEmpty()) {\n console.warn(\n \"Warning: LiveblocksPlugin: editorState in initialConfig detected, but must be null.\"\n );\n }\n }\n\n // we know editor is already defined as we're inside LexicalComposer, and we only want this running the first time\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useReportTextEditor(TextEditorType.Lexical, \"root\");\n\n // Get user info or allow override from props\n const self = useSelf();\n\n const providerFactory = useCallback(\n (id: string, yjsDocMap: Map<string, Doc>): Provider => {\n const provider = getYjsProviderForRoom(room);\n yjsDocMap.set(id, provider.getYDoc());\n\n return provider as Provider;\n },\n [room]\n );\n\n const root = useRootElement();\n\n useLayoutEffect(() => {\n if (root === null) return;\n setReference({\n getBoundingClientRect: () => root.getBoundingClientRect(),\n });\n }, [setReference, root]);\n\n const handleFloatingRef = useCallback(\n (node: HTMLDivElement) => {\n setFloating(node);\n setContainerRef({ current: node });\n },\n [setFloating, setContainerRef]\n );\n\n return (\n <>\n <div\n ref={handleFloatingRef}\n className=\"lb-root lb-lexical-cursors\"\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\n {self && (\n <CollaborationPlugin\n // Setting the key allows us to reset the internal Y.doc used by useYjsCollaboration\n // without implementing `reload` event\n key={room.id}\n id={room.id}\n providerFactory={providerFactory}\n username={self.info?.name ?? \"\"} // use empty string to prevent random name\n cursorColor={self.info?.color as string | undefined}\n cursorsContainerRef={containerRef}\n shouldBootstrap={true}\n />\n )}\n\n {isResolveMentionSuggestionsDefined && <MentionPlugin />}\n <CommentPluginProvider>{children}</CommentPluginProvider>\n </>\n );\n};\n"],"names":["useYjsProvider","useCallback","useSyncExternalStore","useResolveMentionSuggestions","useLexicalComposerContext","useRoom","ThreadMarkNode","MentionNode","GroupMentionNode","useState","useFloating","autoUpdate","useEffect","useReportTextEditor","TextEditorType","useSelf","getYjsProviderForRoom","useRootElement","useLayoutEffect","jsxs","Fragment","jsx","CollaborationPlugin","MentionPlugin","CommentPluginProvider"],"mappings":";;;;;;;;;;;;;;;;;;AA4BO,SAAS,gBAA4B,GAAA;AAC1C,EAAA,MAAM,cAAcA,uBAAe,EAAA,CAAA;AAEnC,EAAM,MAAA,WAAA,GAAcC,kBAAY,MAAM;AACpC,IAAM,MAAA,MAAA,GAAS,aAAa,SAAU,EAAA,CAAA;AACtC,IAAO,OAAA,MAAA,KAAW,mBAAmB,MAAW,KAAA,cAAA,CAAA;AAAA,GAClD,EAAG,CAAC,WAAW,CAAC,CAAA,CAAA;AAEhB,EAAA,MAAM,SAAY,GAAAA,iBAAA;AAAA,IAChB,CAAC,QAAyB,KAAA;AACxB,MAAA,IAAI,WAAgB,KAAA,KAAA,CAAA;AAAW,QAAA,OAAO,MAAM;AAAA,SAAC,CAAA;AAC7C,MAAY,WAAA,CAAA,EAAA,CAAG,UAAU,QAAQ,CAAA,CAAA;AACjC,MAAA,OAAO,MAAM;AACX,QAAY,WAAA,CAAA,GAAA,CAAI,UAAU,QAAQ,CAA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;AAAA,QACL,SAAU,EAAA,4BAAA;AAAA,QACV,KAAO,EAAA;AAAA,UACL,QAAU,EAAA,QAAA;AAAA,UACV,GAAK,EAAA,CAAA;AAAA,UACL,IAAM,EAAA,CAAA;AAAA,UACN,SAAA,EAAW,CAAe,YAAA,EAAA,IAAA,CAAK,KAAM,CAAA,CAAC,CAAC,CAAO,IAAA,EAAA,IAAA,CAAK,KAAM,CAAA,CAAC,CAAC,CAAA,MAAA,CAAA;AAAA,UAC3D,QAAU,EAAA,aAAA;AAAA,SACZ;AAAA,OAAA;AAAA,KACF;AAAA,IAEC,IACC,oBAAAA,cAAA;AAAA,MAACC,8CAAA;AAAA,MAAA;AAAA,QAIC,IAAI,IAAK,CAAA,EAAA;AAAA,QACT,eAAA;AAAA,QACA,QAAA,EAAU,IAAK,CAAA,IAAA,EAAM,IAAQ,IAAA,EAAA;AAAA,QAC7B,WAAA,EAAa,KAAK,IAAM,EAAA,KAAA;AAAA,QACxB,mBAAqB,EAAA,YAAA;AAAA,QACrB,eAAiB,EAAA,IAAA;AAAA,OAAA;AAAA,MANZ,IAAK,CAAA,EAAA;AAAA,KAOZ;AAAA,IAGD,kCAAA,mCAAuCC,2BAAc,EAAA,EAAA,CAAA;AAAA,oBACtDF,cAAA,CAACG,+CAAuB,QAAS,EAAA,CAAA;AAAA,GACnC,EAAA,CAAA,CAAA;AAEJ;;;;;"}
1
+ {"version":3,"file":"liveblocks-plugin-provider.cjs","sources":["../src/liveblocks-plugin-provider.tsx"],"sourcesContent":["import { autoUpdate, useFloating } from \"@floating-ui/react-dom\";\nimport { CollaborationPlugin } from \"@lexical/react/LexicalCollaborationPlugin\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { Provider } from \"@lexical/yjs\";\nimport { TextEditorType } from \"@liveblocks/core\";\nimport { useRoom, useSelf } from \"@liveblocks/react\";\nimport {\n useLayoutEffect,\n useReportTextEditor,\n useResolveMentionSuggestions,\n useYjsProvider,\n} from \"@liveblocks/react/_private\";\nimport { getYjsProviderForRoom } from \"@liveblocks/yjs\";\nimport type { MutableRefObject, ReactNode } from \"react\";\nimport { useCallback, useEffect, useState, useSyncExternalStore } from \"react\";\nimport type { Doc } from \"yjs\";\n\nimport { CommentPluginProvider } from \"./comments/comment-plugin-provider\";\nimport { ThreadMarkNode } from \"./comments/thread-mark-node\";\nimport { GroupMentionNode } from \"./mentions/group-mention-node\";\nimport { MentionNode } from \"./mentions/mention-node\";\nimport { MentionPlugin } from \"./mentions/mention-plugin\";\nimport { useRootElement } from \"./use-root-element\";\n\n/**\n * Returns whether the editor has loaded the initial text contents from the\n * server and is ready to be used.\n */\nexport function useIsEditorReady(): boolean {\n const yjsProvider = useYjsProvider();\n\n const getSnapshot = useCallback(() => {\n const status = yjsProvider?.getStatus();\n return status === \"synchronizing\" || status === \"synchronized\";\n }, [yjsProvider]);\n\n const subscribe = useCallback(\n (callback: () => void) => {\n if (yjsProvider === undefined) return () => { };\n yjsProvider.on(\"status\", callback);\n return () => {\n yjsProvider.off(\"status\", callback);\n };\n },\n [yjsProvider]\n );\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\nexport type LiveblocksPluginProps = {\n children?: ReactNode;\n};\n\n/**\n * Liveblocks plugin for Lexical that adds collaboration to your editor.\n *\n * `LiveblocksPlugin` should always be nested inside `LexicalComposer`.\n *\n * @example\n *\n * import { LexicalComposer } from \"@lexical/react/LexicalComposer\";\n * import { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\n * import { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\n * import { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\n * import { liveblocksConfig, LiveblocksPlugin } from \"@liveblocks/react-lexical\";\n *\n * const initialConfig = liveblocksConfig({\n * namespace: \"MyEditor\",\n * theme: {},\n * nodes: [],\n * onError: (err) => console.error(err),\n * });\n *\n * function Editor() {\n * return (\n * <LexicalComposer initialConfig={initialConfig}>\n * <LiveblocksPlugin />\n * <RichTextPlugin\n * contentEditable={<ContentEditable />}\n * placeholder={<div>Enter some text...</div>}\n * ErrorBoundary={LexicalErrorBoundary}\n * />\n * </LexicalComposer>\n * );\n * }\n */\nexport const LiveblocksPlugin = ({\n children,\n}: LiveblocksPluginProps): JSX.Element => {\n const isResolveMentionSuggestionsDefined =\n useResolveMentionSuggestions() !== undefined;\n const [editor] = useLexicalComposerContext();\n const room = useRoom();\n\n if (!editor.hasNodes([ThreadMarkNode, MentionNode, GroupMentionNode])) {\n throw new Error(\n \"LiveblocksPlugin requires Lexical configuration to be wrapped in the `liveblocksConfig(options)` function. For more information: https://liveblocks.io/docs/api-reference/liveblocks-react-lexical#liveblocksConfig\"\n );\n }\n\n const [containerRef, setContainerRef] = useState<\n MutableRefObject<HTMLDivElement | null> | undefined\n >(undefined);\n\n const {\n refs: { setReference, setFloating },\n strategy,\n x,\n y,\n } = useFloating({\n strategy: \"fixed\",\n placement: \"bottom\",\n whileElementsMounted: (...args) => {\n return autoUpdate(...args, {\n animationFrame: true,\n });\n },\n });\n\n // Warn users if initialConfig.editorState, set on the composer, is not null\n useEffect(() => {\n // only in dev mode\n if (process.env.NODE_ENV !== \"production\") {\n // A user should not even be set an emptyState, but when passing null, getEditorState still has initial empty state\n if (!editor.getEditorState().isEmpty()) {\n console.warn(\n \"Warning: LiveblocksPlugin: editorState in initialConfig detected, but must be null.\"\n );\n }\n }\n\n // we know editor is already defined as we're inside LexicalComposer, and we only want this running the first time\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useReportTextEditor(TextEditorType.Lexical, \"root\");\n\n // Get user info or allow override from props\n const self = useSelf();\n\n const providerFactory = useCallback(\n (id: string, yjsDocMap: Map<string, Doc>): Provider => {\n const provider = getYjsProviderForRoom(room, {}, true);\n yjsDocMap.set(id, provider.getYDoc());\n\n\n return provider as Provider;\n },\n [room]\n );\n\n const root = useRootElement();\n\n useLayoutEffect(() => {\n if (root === null) return;\n setReference({\n getBoundingClientRect: () => root.getBoundingClientRect(),\n });\n }, [setReference, root]);\n\n const handleFloatingRef = useCallback(\n (node: HTMLDivElement) => {\n setFloating(node);\n setContainerRef({ current: node });\n },\n [setFloating, setContainerRef]\n );\n\n return (\n <>\n <div\n ref={handleFloatingRef}\n className=\"lb-root lb-lexical-cursors\"\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\n {self && (\n <CollaborationPlugin\n // Setting the key allows us to reset the internal Y.doc used by useYjsCollaboration\n // without implementing `reload` event\n key={room.id}\n id={room.id}\n providerFactory={providerFactory}\n username={self.info?.name ?? \"\"} // use empty string to prevent random name\n cursorColor={self.info?.color as string | undefined}\n cursorsContainerRef={containerRef}\n shouldBootstrap={true}\n />\n )}\n\n {isResolveMentionSuggestionsDefined && <MentionPlugin />}\n <CommentPluginProvider>{children}</CommentPluginProvider>\n </>\n );\n};\n"],"names":["useYjsProvider","useCallback","useSyncExternalStore","useResolveMentionSuggestions","useLexicalComposerContext","useRoom","ThreadMarkNode","MentionNode","GroupMentionNode","useState","useFloating","autoUpdate","useEffect","useReportTextEditor","TextEditorType","useSelf","getYjsProviderForRoom","useRootElement","useLayoutEffect","jsxs","Fragment","jsx","CollaborationPlugin","MentionPlugin","CommentPluginProvider"],"mappings":";;;;;;;;;;;;;;;;;;AA4BO,SAAS,gBAA4B,GAAA;AAC1C,EAAA,MAAM,cAAcA,uBAAe,EAAA,CAAA;AAEnC,EAAM,MAAA,WAAA,GAAcC,kBAAY,MAAM;AACpC,IAAM,MAAA,MAAA,GAAS,aAAa,SAAU,EAAA,CAAA;AACtC,IAAO,OAAA,MAAA,KAAW,mBAAmB,MAAW,KAAA,cAAA,CAAA;AAAA,GAClD,EAAG,CAAC,WAAW,CAAC,CAAA,CAAA;AAEhB,EAAA,MAAM,SAAY,GAAAA,iBAAA;AAAA,IAChB,CAAC,QAAyB,KAAA;AACxB,MAAA,IAAI,W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AM,CAAA,CAAA;AAAA,KACnC;AAAA,IACA,CAAC,aAAa,eAAe,CAAA;AAAA,GAC/B,CAAA;AAEA,EAAA,uBAEIkB,eAAA,CAAAC,mBAAA,EAAA,EAAA,QAAA,EAAA;AAAA,oBAAAC,cAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAK,EAAA,iBAAA;AAAA,QACL,SAAU,EAAA,4BAAA;AAAA,QACV,KAAO,EAAA;AAAA,UACL,QAAU,EAAA,QAAA;AAAA,UACV,GAAK,EAAA,CAAA;AAAA,UACL,IAAM,EAAA,CAAA;AAAA,UACN,SAAA,EAAW,CAAe,YAAA,EAAA,IAAA,CAAK,KAAM,CAAA,CAAC,CAAC,CAAO,IAAA,EAAA,IAAA,CAAK,KAAM,CAAA,CAAC,CAAC,CAAA,MAAA,CAAA;AAAA,UAC3D,QAAU,EAAA,aAAA;AAAA,SACZ;AAAA,OAAA;AAAA,KACF;AAAA,IAEC,IACC,oBAAAA,cAAA;AAAA,MAACC,8CAAA;AAAA,MAAA;AAAA,QAIC,IAAI,IAAK,CAAA,EAAA;AAAA,QACT,eAAA;AAAA,QACA,QAAA,EAAU,IAAK,CAAA,IAAA,EAAM,IAAQ,IAAA,EAAA;AAAA,QAC7B,WAAA,EAAa,KAAK,IAAM,EAAA,KAAA;AAAA,QACxB,mBAAqB,EAAA,YAAA;AAAA,QACrB,eAAiB,EAAA,IAAA;AAAA,OAAA;AAAA,MANZ,IAAK,CAAA,EAAA;AAAA,KAOZ;AAAA,IAGD,kCAAA,mCAAuCC,2BAAc,EAAA,EAAA,CAAA;AAAA,oBACtDF,cAAA,CAACG,+CAAuB,QAAS,EAAA,CAAA;AAAA,GACnC,EAAA,CAAA,CAAA;AAEJ;;;;;"}
@@ -73,7 +73,7 @@ const LiveblocksPlugin = ({
73
73
  const self = useSelf();
74
74
  const providerFactory = useCallback(
75
75
  (id, yjsDocMap) => {
76
- const provider = getYjsProviderForRoom(room);
76
+ const provider = getYjsProviderForRoom(room, {}, true);
77
77
  yjsDocMap.set(id, provider.getYDoc());
78
78
  return provider;
79
79
  },
@@ -1 +1 @@
1
- {"version":3,"file":"liveblocks-plugin-provider.js","sources":["../src/liveblocks-plugin-provider.tsx"],"sourcesContent":["import { autoUpdate, useFloating } from \"@floating-ui/react-dom\";\nimport { CollaborationPlugin } from \"@lexical/react/LexicalCollaborationPlugin\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { Provider } from \"@lexical/yjs\";\nimport { TextEditorType } from \"@liveblocks/core\";\nimport { useRoom, useSelf } from \"@liveblocks/react\";\nimport {\n useLayoutEffect,\n useReportTextEditor,\n useResolveMentionSuggestions,\n useYjsProvider,\n} from \"@liveblocks/react/_private\";\nimport { getYjsProviderForRoom } from \"@liveblocks/yjs\";\nimport type { MutableRefObject, ReactNode } from \"react\";\nimport { useCallback, useEffect, useState, useSyncExternalStore } from \"react\";\nimport type { Doc } from \"yjs\";\n\nimport { CommentPluginProvider } from \"./comments/comment-plugin-provider\";\nimport { ThreadMarkNode } from \"./comments/thread-mark-node\";\nimport { GroupMentionNode } from \"./mentions/group-mention-node\";\nimport { MentionNode } from \"./mentions/mention-node\";\nimport { MentionPlugin } from \"./mentions/mention-plugin\";\nimport { useRootElement } from \"./use-root-element\";\n\n/**\n * Returns whether the editor has loaded the initial text contents from the\n * server and is ready to be used.\n */\nexport function useIsEditorReady(): boolean {\n const yjsProvider = useYjsProvider();\n\n const getSnapshot = useCallback(() => {\n const status = yjsProvider?.getStatus();\n return status === \"synchronizing\" || status === \"synchronized\";\n }, [yjsProvider]);\n\n const subscribe = useCallback(\n (callback: () => void) => {\n if (yjsProvider === undefined) return () => {};\n yjsProvider.on(\"status\", callback);\n return () => {\n yjsProvider.off(\"status\", callback);\n };\n },\n [yjsProvider]\n );\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\nexport type LiveblocksPluginProps = {\n children?: ReactNode;\n};\n\n/**\n * Liveblocks plugin for Lexical that adds collaboration to your editor.\n *\n * `LiveblocksPlugin` should always be nested inside `LexicalComposer`.\n *\n * @example\n *\n * import { LexicalComposer } from \"@lexical/react/LexicalComposer\";\n * import { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\n * import { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\n * import { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\n * import { liveblocksConfig, LiveblocksPlugin } from \"@liveblocks/react-lexical\";\n *\n * const initialConfig = liveblocksConfig({\n * namespace: \"MyEditor\",\n * theme: {},\n * nodes: [],\n * onError: (err) => console.error(err),\n * });\n *\n * function Editor() {\n * return (\n * <LexicalComposer initialConfig={initialConfig}>\n * <LiveblocksPlugin />\n * <RichTextPlugin\n * contentEditable={<ContentEditable />}\n * placeholder={<div>Enter some text...</div>}\n * ErrorBoundary={LexicalErrorBoundary}\n * />\n * </LexicalComposer>\n * );\n * }\n */\nexport const LiveblocksPlugin = ({\n children,\n}: LiveblocksPluginProps): JSX.Element => {\n const isResolveMentionSuggestionsDefined =\n useResolveMentionSuggestions() !== undefined;\n const [editor] = useLexicalComposerContext();\n const room = useRoom();\n\n if (!editor.hasNodes([ThreadMarkNode, MentionNode, GroupMentionNode])) {\n throw new Error(\n \"LiveblocksPlugin requires Lexical configuration to be wrapped in the `liveblocksConfig(options)` function. For more information: https://liveblocks.io/docs/api-reference/liveblocks-react-lexical#liveblocksConfig\"\n );\n }\n\n const [containerRef, setContainerRef] = useState<\n MutableRefObject<HTMLDivElement | null> | undefined\n >(undefined);\n\n const {\n refs: { setReference, setFloating },\n strategy,\n x,\n y,\n } = useFloating({\n strategy: \"fixed\",\n placement: \"bottom\",\n whileElementsMounted: (...args) => {\n return autoUpdate(...args, {\n animationFrame: true,\n });\n },\n });\n\n // Warn users if initialConfig.editorState, set on the composer, is not null\n useEffect(() => {\n // only in dev mode\n if (process.env.NODE_ENV !== \"production\") {\n // A user should not even be set an emptyState, but when passing null, getEditorState still has initial empty state\n if (!editor.getEditorState().isEmpty()) {\n console.warn(\n \"Warning: LiveblocksPlugin: editorState in initialConfig detected, but must be null.\"\n );\n }\n }\n\n // we know editor is already defined as we're inside LexicalComposer, and we only want this running the first time\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useReportTextEditor(TextEditorType.Lexical, \"root\");\n\n // Get user info or allow override from props\n const self = useSelf();\n\n const providerFactory = useCallback(\n (id: string, yjsDocMap: Map<string, Doc>): Provider => {\n const provider = getYjsProviderForRoom(room);\n yjsDocMap.set(id, provider.getYDoc());\n\n return provider as Provider;\n },\n [room]\n );\n\n const root = useRootElement();\n\n useLayoutEffect(() => {\n if (root === null) return;\n setReference({\n getBoundingClientRect: () => root.getBoundingClientRect(),\n });\n }, [setReference, root]);\n\n const handleFloatingRef = useCallback(\n (node: HTMLDivElement) => {\n setFloating(node);\n setContainerRef({ current: node });\n },\n [setFloating, setContainerRef]\n );\n\n return (\n <>\n <div\n ref={handleFloatingRef}\n className=\"lb-root lb-lexical-cursors\"\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\n {self && (\n <CollaborationPlugin\n // Setting the key allows us to reset the internal Y.doc used by useYjsCollaboration\n // without implementing `reload` event\n key={room.id}\n id={room.id}\n providerFactory={providerFactory}\n username={self.info?.name ?? \"\"} // use empty string to prevent random name\n cursorColor={self.info?.color as string | undefined}\n cursorsContainerRef={containerRef}\n shouldBootstrap={true}\n />\n )}\n\n {isResolveMentionSuggestionsDefined && <MentionPlugin />}\n <CommentPluginProvider>{children}</CommentPluginProvider>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA4BO,SAAS,gBAA4B,GAAA;AAC1C,EAAA,MAAM,cAAc,cAAe,EAAA,CAAA;AAEnC,EAAM,MAAA,WAAA,GAAc,YAAY,MAAM;AACpC,IAAM,MAAA,MAAA,GAAS,aAAa,SAAU,EAA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{"version":3,"file":"liveblocks-plugin-provider.js","sources":["../src/liveblocks-plugin-provider.tsx"],"sourcesContent":["import { autoUpdate, useFloating } from \"@floating-ui/react-dom\";\nimport { CollaborationPlugin } from \"@lexical/react/LexicalCollaborationPlugin\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport type { Provider } from \"@lexical/yjs\";\nimport { TextEditorType } from \"@liveblocks/core\";\nimport { useRoom, useSelf } from \"@liveblocks/react\";\nimport {\n useLayoutEffect,\n useReportTextEditor,\n useResolveMentionSuggestions,\n useYjsProvider,\n} from \"@liveblocks/react/_private\";\nimport { getYjsProviderForRoom } from \"@liveblocks/yjs\";\nimport type { MutableRefObject, ReactNode } from \"react\";\nimport { useCallback, useEffect, useState, useSyncExternalStore } from \"react\";\nimport type { Doc } from \"yjs\";\n\nimport { CommentPluginProvider } from \"./comments/comment-plugin-provider\";\nimport { ThreadMarkNode } from \"./comments/thread-mark-node\";\nimport { GroupMentionNode } from \"./mentions/group-mention-node\";\nimport { MentionNode } from \"./mentions/mention-node\";\nimport { MentionPlugin } from \"./mentions/mention-plugin\";\nimport { useRootElement } from \"./use-root-element\";\n\n/**\n * Returns whether the editor has loaded the initial text contents from the\n * server and is ready to be used.\n */\nexport function useIsEditorReady(): boolean {\n const yjsProvider = useYjsProvider();\n\n const getSnapshot = useCallback(() => {\n const status = yjsProvider?.getStatus();\n return status === \"synchronizing\" || status === \"synchronized\";\n }, [yjsProvider]);\n\n const subscribe = useCallback(\n (callback: () => void) => {\n if (yjsProvider === undefined) return () => { };\n yjsProvider.on(\"status\", callback);\n return () => {\n yjsProvider.off(\"status\", callback);\n };\n },\n [yjsProvider]\n );\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\nexport type LiveblocksPluginProps = {\n children?: ReactNode;\n};\n\n/**\n * Liveblocks plugin for Lexical that adds collaboration to your editor.\n *\n * `LiveblocksPlugin` should always be nested inside `LexicalComposer`.\n *\n * @example\n *\n * import { LexicalComposer } from \"@lexical/react/LexicalComposer\";\n * import { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\n * import { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\n * import { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\n * import { liveblocksConfig, LiveblocksPlugin } from \"@liveblocks/react-lexical\";\n *\n * const initialConfig = liveblocksConfig({\n * namespace: \"MyEditor\",\n * theme: {},\n * nodes: [],\n * onError: (err) => console.error(err),\n * });\n *\n * function Editor() {\n * return (\n * <LexicalComposer initialConfig={initialConfig}>\n * <LiveblocksPlugin />\n * <RichTextPlugin\n * contentEditable={<ContentEditable />}\n * placeholder={<div>Enter some text...</div>}\n * ErrorBoundary={LexicalErrorBoundary}\n * />\n * </LexicalComposer>\n * );\n * }\n */\nexport const LiveblocksPlugin = ({\n children,\n}: LiveblocksPluginProps): JSX.Element => {\n const isResolveMentionSuggestionsDefined =\n useResolveMentionSuggestions() !== undefined;\n const [editor] = useLexicalComposerContext();\n const room = useRoom();\n\n if (!editor.hasNodes([ThreadMarkNode, MentionNode, GroupMentionNode])) {\n throw new Error(\n \"LiveblocksPlugin requires Lexical configuration to be wrapped in the `liveblocksConfig(options)` function. For more information: https://liveblocks.io/docs/api-reference/liveblocks-react-lexical#liveblocksConfig\"\n );\n }\n\n const [containerRef, setContainerRef] = useState<\n MutableRefObject<HTMLDivElement | null> | undefined\n >(undefined);\n\n const {\n refs: { setReference, setFloating },\n strategy,\n x,\n y,\n } = useFloating({\n strategy: \"fixed\",\n placement: \"bottom\",\n whileElementsMounted: (...args) => {\n return autoUpdate(...args, {\n animationFrame: true,\n });\n },\n });\n\n // Warn users if initialConfig.editorState, set on the composer, is not null\n useEffect(() => {\n // only in dev mode\n if (process.env.NODE_ENV !== \"production\") {\n // A user should not even be set an emptyState, but when passing null, getEditorState still has initial empty state\n if (!editor.getEditorState().isEmpty()) {\n console.warn(\n \"Warning: LiveblocksPlugin: editorState in initialConfig detected, but must be null.\"\n );\n }\n }\n\n // we know editor is already defined as we're inside LexicalComposer, and we only want this running the first time\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useReportTextEditor(TextEditorType.Lexical, \"root\");\n\n // Get user info or allow override from props\n const self = useSelf();\n\n const providerFactory = useCallback(\n (id: string, yjsDocMap: Map<string, Doc>): Provider => {\n const provider = getYjsProviderForRoom(room, {}, true);\n yjsDocMap.set(id, provider.getYDoc());\n\n\n return provider as Provider;\n },\n [room]\n );\n\n const root = useRootElement();\n\n useLayoutEffect(() => {\n if (root === null) return;\n setReference({\n getBoundingClientRect: () => root.getBoundingClientRect(),\n });\n }, [setReference, root]);\n\n const handleFloatingRef = useCallback(\n (node: HTMLDivElement) => {\n setFloating(node);\n setContainerRef({ current: node });\n },\n [setFloating, setContainerRef]\n );\n\n return (\n <>\n <div\n ref={handleFloatingRef}\n className=\"lb-root lb-lexical-cursors\"\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\n {self && (\n <CollaborationPlugin\n // Setting the key allows us to reset the internal Y.doc used by useYjsCollaboration\n // without implementing `reload` event\n key={room.id}\n id={room.id}\n providerFactory={providerFactory}\n username={self.info?.name ?? \"\"} // use empty string to prevent random name\n cursorColor={self.info?.color as string | undefined}\n cursorsContainerRef={containerRef}\n shouldBootstrap={true}\n />\n )}\n\n {isResolveMentionSuggestionsDefined && <MentionPlugin />}\n <CommentPluginProvider>{children}</CommentPluginProvider>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA4BO,SAAS,gBAA4B,GAAA;AAC1C,EAAA,MAAM,cAAc,cAAe,EAAA,CAAA;AAEnC,EAAM,MAAA,WAAA,GAAc,YAAY,MAAM;AACpC,IAAM,MAAA,MAAA,GAAS,aAAa,SAAU,EAAA,CAAA;AACtC,IAAO,OAAA,MAAA,KAAW,mBAAmB,MAAW,KAAA,cAAA,CAAA;AAAA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OM() {
46
46
  return false;
47
47
  }
48
- static importDom() {
48
+ static importDOM() {
49
49
  return {
50
50
  span: () => ({
51
51
  conversion: (element) => {
@@ -1 +1 @@
1
- {"version":3,"file":"group-mention-node.cjs","sources":["../../src/mentions/group-mention-node.tsx"],"sourcesContent":["import {\n createInboxNotificationId,\n type GroupMentionData,\n MENTION_CHARACTER,\n} from \"@liveblocks/core\";\nimport { Group } from \"@liveblocks/react-ui/_private\";\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\nimport type { JSX } from \"react\";\n\nimport { Mention } from \"./mention-component\";\n\nexport type SerializedGroupMentionNode = Spread<\n {\n groupId: string;\n userIds?: string[];\n },\n SerializedLexicalNode\n>;\n\nfunction GroupMention({\n mention,\n nodeKey,\n}: {\n mention: GroupMentionData;\n nodeKey: string;\n}) {\n return (\n <Mention nodeKey={nodeKey}>\n {MENTION_CHARACTER}\n <Group groupId={mention.id} />\n </Mention>\n );\n}\n\nexport class GroupMentionNode extends DecoratorNode<JSX.Element> {\n __id: string;\n __groupId: string;\n __userIds: string[] | undefined;\n\n constructor(\n id: string,\n groupId: string,\n userIds: string[] | undefined,\n key?: NodeKey\n ) {\n super(key);\n this.__id = id;\n this.__groupId = groupId;\n this.__userIds = userIds;\n }\n\n static getType(): string {\n return \"lb-group-mention\";\n }\n\n static clone(node: GroupMentionNode): GroupMentionNode {\n return new GroupMentionNode(\n node.__id,\n node.__groupId,\n node.__userIds,\n node.__key\n );\n }\n\n createDOM(): HTMLElement {\n const element = document.createElement(\"span\");\n element.style.display = \"inline-block\";\n element.style.userSelect = \"none\";\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n static importDom(): DOMConversionMap<HTMLElement> | null {\n return {\n span: () => ({\n conversion: (element) => {\n const groupId = element.getAttribute(\"data-lexical-lb-group-mention\");\n\n if (!groupId) {\n return null;\n }\n\n const userIdsAttribute = element.getAttribute(\n \"data-lexical-lb-user-ids\"\n );\n let userIds: string[] | undefined;\n\n if (userIdsAttribute) {\n try {\n const parsedUserIds = JSON.parse(userIdsAttribute) as string[];\n\n if (Array.isArray(parsedUserIds)) {\n userIds = parsedUserIds;\n }\n } catch {\n // Invalid userIds attribute\n }\n }\n\n const node = $createGroupMentionNode(groupId, userIds);\n return { node };\n },\n priority: 1,\n }),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement(\"span\");\n element.setAttribute(\"data-lexical-lb-group-mention\", this.getGroupId());\n element.setAttribute(\n \"data-lexical-lb-group-mention-users\",\n JSON.stringify(this.getUserIds())\n );\n element.textContent = this.getTextContent();\n return { element };\n }\n\n static importJSON(\n serializedNode: SerializedGroupMentionNode\n ): GroupMentionNode {\n const node = $createGroupMentionNode(\n serializedNode.groupId,\n serializedNode.userIds\n );\n return node;\n }\n\n exportJSON(): SerializedGroupMentionNode {\n return {\n groupId: this.__groupId,\n userIds: this.__userIds,\n type: \"lb-group-mention\",\n version: 1,\n };\n }\n\n getGroupId(): string {\n const self = this.getLatest();\n return self.__groupId;\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n getUserIds(): string[] | undefined {\n const self = this.getLatest();\n return self.__userIds;\n }\n\n decorate(): JSX.Element {\n const mention: GroupMentionData = {\n id: this.getGroupId(),\n kind: \"group\",\n userIds: this.getUserIds(),\n };\n\n return <GroupMention mention={mention} nodeKey={this.getKey()} />;\n }\n}\n\nexport function $isGroupMentionNode(\n node: LexicalNode | null | undefined\n): node is GroupMentionNode {\n return node instanceof GroupMentionNode;\n}\n\nexport function $createGroupMentionNode(\n groupId: string,\n userIds: string[] | undefined\n): GroupMentionNode {\n const node = new GroupMentionNode(\n createInboxNotificationId(),\n groupId,\n userIds\n );\n return $applyNodeReplacement(node);\n}\n"],"names":["jsxs","Mention","MENTION_CHARACTER","jsx","Group","DecoratorNode","createInboxNotificationId","$applyNodeReplacement"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d,IAC0B,EAAA;AAC1B,EAAA,OAAO,IAAgB,YAAA,gBAAA,CAAA;AACzB,CAAA;AAEgB,SAAA,uBAAA,CACd,SACA,OACkB,EAAA;AAClB,EAAA,MAAM,OAAO,IAAI,gBAAA;AAAA,IACfC,8BAA0B,EAAA;AAAA,IAC1B,OAAA;AAAA,IACA,OAAA;AAAA,GACF,CAAA;AACA,EAAA,OAAOC,8BAAsB,IAAI,CAAA,CAAA;AACnC;;;;;;"}
1
+ {"version":3,"file":"group-mention-node.cjs","sources":["../../src/mentions/group-mention-node.tsx"],"sourcesContent":["import {\n createInboxNotificationId,\n type GroupMentionData,\n MENTION_CHARACTER,\n} from \"@liveblocks/core\";\nimport { Group } from \"@liveblocks/react-ui/_private\";\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\nimport type { JSX } from \"react\";\n\nimport { Mention } from \"./mention-component\";\n\nexport type SerializedGroupMentionNode = Spread<\n {\n groupId: string;\n userIds?: string[];\n },\n SerializedLexicalNode\n>;\n\nfunction GroupMention({\n mention,\n nodeKey,\n}: {\n mention: GroupMentionData;\n nodeKey: string;\n}) {\n return (\n <Mention nodeKey={nodeKey}>\n {MENTION_CHARACTER}\n <Group groupId={mention.id} />\n </Mention>\n );\n}\n\nexport class GroupMentionNode extends DecoratorNode<JSX.Element> {\n __id: string;\n __groupId: string;\n __userIds: string[] | undefined;\n\n constructor(\n id: string,\n groupId: string,\n userIds: string[] | undefined,\n key?: NodeKey\n ) {\n super(key);\n this.__id = id;\n this.__groupId = groupId;\n this.__userIds = userIds;\n }\n\n static getType(): string {\n return \"lb-group-mention\";\n }\n\n static clone(node: GroupMentionNode): GroupMentionNode {\n return new GroupMentionNode(\n node.__id,\n node.__groupId,\n node.__userIds,\n node.__key\n );\n }\n\n createDOM(): HTMLElement {\n const element = document.createElement(\"span\");\n element.style.display = \"inline-block\";\n element.style.userSelect = \"none\";\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n static importDOM(): DOMConversionMap<HTMLElement> | null {\n return {\n span: () => ({\n conversion: (element) => {\n const groupId = element.getAttribute(\"data-lexical-lb-group-mention\");\n\n if (!groupId) {\n return null;\n }\n\n const userIdsAttribute = element.getAttribute(\n \"data-lexical-lb-user-ids\"\n );\n let userIds: string[] | undefined;\n\n if (userIdsAttribute) {\n try {\n const parsedUserIds = JSON.parse(userIdsAttribute) as string[];\n\n if (Array.isArray(parsedUserIds)) {\n userIds = parsedUserIds;\n }\n } catch {\n // Invalid userIds attribute\n }\n }\n\n const node = $createGroupMentionNode(groupId, userIds);\n return { node };\n },\n priority: 1,\n }),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement(\"span\");\n element.setAttribute(\"data-lexical-lb-group-mention\", this.getGroupId());\n element.setAttribute(\n \"data-lexical-lb-group-mention-users\",\n JSON.stringify(this.getUserIds())\n );\n element.textContent = this.getTextContent();\n return { element };\n }\n\n static importJSON(\n serializedNode: SerializedGroupMentionNode\n ): GroupMentionNode {\n const node = $createGroupMentionNode(\n serializedNode.groupId,\n serializedNode.userIds\n );\n return node;\n }\n\n exportJSON(): SerializedGroupMentionNode {\n return {\n groupId: this.__groupId,\n userIds: this.__userIds,\n type: \"lb-group-mention\",\n version: 1,\n };\n }\n\n getGroupId(): string {\n const self = this.getLatest();\n return self.__groupId;\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n getUserIds(): string[] | undefined {\n const self = this.getLatest();\n return self.__userIds;\n }\n\n decorate(): JSX.Element {\n const mention: GroupMentionData = {\n id: this.getGroupId(),\n kind: \"group\",\n userIds: this.getUserIds(),\n };\n\n return <GroupMention mention={mention} nodeKey={this.getKey()} />;\n }\n}\n\nexport function $isGroupMentionNode(\n node: LexicalNode | null | undefined\n): node is GroupMentionNode {\n return node instanceof GroupMentionNode;\n}\n\nexport function $createGroupMentionNode(\n groupId: string,\n userIds: string[] | undefined\n): GroupMentionNode {\n const node = new GroupMentionNode(\n createInboxNotificationId(),\n groupId,\n userIds\n );\n return $applyNodeReplacement(node);\n}\n"],"names":["jsxs","Mention","MENTION_CHARACTER","jsx","Group","DecoratorNode","createInboxNotificationId","$applyNodeReplacement"],"mappings":";;;;;;;;AA2BA,SAAS,YAAa,CAAA;AAAA,EACpB,OAAA;AAAA,EACA,OAAA;AACF,CAGG,EAAA;AACD,EACE,uBAAAA,eAAA,CAACC,4BAAQ,OACN,EAAA,QAAA,EAAA;AAAA,IAAAC,sBAAA;AAAA,oBACAC,cAAA,CAAAC,cAAA,EAAA,EAAM,OAAS,EAAA,OAAA,CAAQ,EAAI,EAAA,CAAA;AAAA,GAC9B,EAAA,CAAA,CAAA;AAEJ,CAAA;AAEO,MAAM,yBAAyBC,qBAA2B,CAAA;AAAA,EAC/D,IAAA,CAAA;AAAA,EACA,SAAA,CAAA;AAAA,EACA,SAAA,CAAA;AAAA,EAEA,WACE,CAAA,EAAA,EACA,OACA,EAAA,OAAA,EACA,GACA,EAAA;AACA,IAAA,KAAA,CAAM,GAAG,CAAA,CAAA;AACT,IAAA,IAAA,CAAK,IAAO,GAAA,EAAA,CAAA;AACZ,IAAA,IAAA,CAAK,SAAY,GAAA,OAAA,CAAA;AACjB,IAAA,IAAA,CAAK,SAAY,GAAA,OAAA,CAAA;AAAA,GACnB;AAAA,EAEA,OAAO,OAAkB,GAAA;AACvB,IAAO,OAAA,kBAAA,CAAA;AAAA,GACT;AAAA,EAEA,OAAO,MAAM,IAA0C,EAAA;AACrD,IAAA,OAAO,IAAI,gBAAA;AAAA,MACT,IAAK,CAAA,IAAA;AAAA,MACL,IAAK,CAAA,SAAA;AAAA,MACL,IAAK,CAAA,SAAA;AAAA,MACL,IAAK,CAAA,KAAA;AAAA,KACP,CAAA;AAAA,GACF;AAAA,EAEA,SAAyB,GAAA;AACvB,IAAM,MAAA,OAAA,GAAU,QAAS,CAAA,aAAA,CAAc,MAA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AAA,EAAS,KAAK,UAAW,EAAA;AAAA,KAC3B,CAAA;AAEA,IAAA,sCAAQ,YAAa,EAAA,EAAA,OAAA,EAAkB,OAAS,EAAA,IAAA,CAAK,QAAU,EAAA,CAAA,CAAA;AAAA,GACjE;AACF,CAAA;AAEO,SAAS,oBACd,IAC0B,EAAA;AAC1B,EAAA,OAAO,IAAgB,YAAA,gBAAA,CAAA;AACzB,CAAA;AAEgB,SAAA,uBAAA,CACd,SACA,OACkB,EAAA;AAClB,EAAA,MAAM,OAAO,IAAI,gBAAA;AAAA,IACfC,8BAA0B,EAAA;AAAA,IAC1B,OAAA;AAAA,IACA,OAAA;AAAA,GACF,CAAA;AACA,EAAA,OAAOC,8BAAsB,IAAI,CAAA,CAAA;AACnC;;;;;;"}
@@ -43,7 +43,7 @@ class GroupMentionNode extends DecoratorNode {
43
43
  updateDOM() {
44
44
  return false;
45
45
  }
46
- static importDom() {
46
+ static importDOM() {
47
47
  return {
48
48
  span: () => ({
49
49
  conversion: (element) => {
@@ -1 +1 @@
1
- {"version":3,"file":"group-mention-node.js","sources":["../../src/mentions/group-mention-node.tsx"],"sourcesContent":["import {\n createInboxNotificationId,\n type GroupMentionData,\n MENTION_CHARACTER,\n} from \"@liveblocks/core\";\nimport { Group } from \"@liveblocks/react-ui/_private\";\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\nimport type { JSX } from \"react\";\n\nimport { Mention } from \"./mention-component\";\n\nexport type SerializedGroupMentionNode = Spread<\n {\n groupId: string;\n userIds?: string[];\n },\n SerializedLexicalNode\n>;\n\nfunction GroupMention({\n mention,\n nodeKey,\n}: {\n mention: GroupMentionData;\n nodeKey: string;\n}) {\n return (\n <Mention nodeKey={nodeKey}>\n {MENTION_CHARACTER}\n <Group groupId={mention.id} />\n </Mention>\n );\n}\n\nexport class GroupMentionNode extends DecoratorNode<JSX.Element> {\n __id: string;\n __groupId: string;\n __userIds: string[] | undefined;\n\n constructor(\n id: string,\n groupId: string,\n userIds: string[] | undefined,\n key?: NodeKey\n ) {\n super(key);\n this.__id = id;\n this.__groupId = groupId;\n this.__userIds = userIds;\n }\n\n static getType(): string {\n return \"lb-group-mention\";\n }\n\n static clone(node: GroupMentionNode): GroupMentionNode {\n return new GroupMentionNode(\n node.__id,\n node.__groupId,\n node.__userIds,\n node.__key\n );\n }\n\n createDOM(): HTMLElement {\n const element = document.createElement(\"span\");\n element.style.display = \"inline-block\";\n element.style.userSelect = \"none\";\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n static importDom(): DOMConversionMap<HTMLElement> | null {\n return {\n span: () => ({\n conversion: (element) => {\n const groupId = element.getAttribute(\"data-lexical-lb-group-mention\");\n\n if (!groupId) {\n return null;\n }\n\n const userIdsAttribute = element.getAttribute(\n \"data-lexical-lb-user-ids\"\n );\n let userIds: string[] | undefined;\n\n if (userIdsAttribute) {\n try {\n const parsedUserIds = JSON.parse(userIdsAttribute) as string[];\n\n if (Array.isArray(parsedUserIds)) {\n userIds = parsedUserIds;\n }\n } catch {\n // Invalid userIds attribute\n }\n }\n\n const node = $createGroupMentionNode(groupId, userIds);\n return { node };\n },\n priority: 1,\n }),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement(\"span\");\n element.setAttribute(\"data-lexical-lb-group-mention\", this.getGroupId());\n element.setAttribute(\n \"data-lexical-lb-group-mention-users\",\n JSON.stringify(this.getUserIds())\n );\n element.textContent = this.getTextContent();\n return { element };\n }\n\n static importJSON(\n serializedNode: SerializedGroupMentionNode\n ): GroupMentionNode {\n const node = $createGroupMentionNode(\n serializedNode.groupId,\n serializedNode.userIds\n );\n return node;\n }\n\n exportJSON(): SerializedGroupMentionNode {\n return {\n groupId: this.__groupId,\n userIds: this.__userIds,\n type: \"lb-group-mention\",\n version: 1,\n };\n }\n\n getGroupId(): string {\n const self = this.getLatest();\n return self.__groupId;\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n getUserIds(): string[] | undefined {\n const self = this.getLatest();\n return self.__userIds;\n }\n\n decorate(): JSX.Element {\n const mention: GroupMentionData = {\n id: this.getGroupId(),\n kind: \"group\",\n userIds: this.getUserIds(),\n };\n\n return <GroupMention mention={mention} nodeKey={this.getKey()} />;\n }\n}\n\nexport function $isGroupMentionNode(\n node: LexicalNode | null | undefined\n): node is GroupMentionNode {\n return node instanceof GroupMentionNode;\n}\n\nexport function $createGroupMentionNode(\n groupId: string,\n userIds: string[] | undefined\n): GroupMentionNode {\n const node = new GroupMentionNode(\n createInboxNotificationId(),\n groupId,\n userIds\n );\n return $applyNodeReplacement(node);\n}\n"],"names":[],"mappings":";;;;;;AA2BA,SAAS,YAAa,CAAA;AAAA,EACpB,OAAA;AAAA,EACA,OAAA;AACF,CAGG,EAAA;AACD,EACE,uBAAA,IAAA,CAAC,WAAQ,OACN,EAAA,QAAA,EAAA;AAAA,IAAA,iBAAA;AAAA,oBACA,GAAA,CAAA,KAAA,EAAA,EAAM,OAAS,EAAA,OAAA,CAAQ,EAAI,EAAA,CAAA;AAAA,GAC9B,EAAA,CAAA,CAAA;AAEJ,CAAA;AAEO,MAAM,yBAAyB,aAA2B,CAAA;AAAA,EAC/D,IAAA,CAAA;AAAA,EACA,SAAA,CAAA;AAAA,EACA,SAAA,CAAA;AAAA,EAEA,WACE,CAAA,EAAA,EACA,OACA,EAAA,OAAA,EACA,GACA,EAAA;AACA,IAAA,KAAA,CAAM,GAAG,CAAA,CAAA;AACT,IAAA,IAAA,CAAK,IAAO,GAAA,EAAA,CAAA;AACZ,IAAA,IAAA,CAAK,SAAY,GAAA,OAAA,CAAA;AACjB,IAAA,IAAA,CAAK,SAAY,GAAA,OAAA,CAAA;AAAA,GACnB;AAAA,EAEA,OAAO,OAAkB,GAAA;AACvB,IAAO,OAAA,kBAAA,CAAA;AAAA,GACT;AAAA,EAEA,OAAO,MAAM,IAA0C,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,UAAmC,GAAA;AACjC,IAAM,MAAA,IAAA,GAAO,KAAK,SAAU,EAAA,CAAA;AAC5B,IAAA,OAAO,IAAK,CAAA,SAAA,CAAA;AAAA,GACd;AAAA,EAEA,QAAwB,GAAA;AACtB,IAAA,MAAM,OAA4B,GAAA;AAAA,MAChC,EAAA,EAAI,KAAK,UAAW,EAAA;AAAA,MACpB,IAAM,EAAA,OAAA;AAAA,MACN,OAAA,EAAS,KAAK,UAAW,EAAA;AAAA,KAC3B,CAAA;AAEA,IAAA,2BAAQ,YAAa,EAAA,EAAA,OAAA,EAAkB,OAAS,EAAA,IAAA,CAAK,QAAU,EAAA,CAAA,CAAA;AAAA,GACjE;AACF,CAAA;AAEO,SAAS,oBACd,IAC0B,EAAA;AAC1B,EAAA,OAAO,IAAgB,YAAA,gBAAA,CAAA;AACzB,CAAA;AAEgB,SAAA,uBAAA,CACd,SACA,OACkB,EAAA;AAClB,EAAA,MAAM,OAAO,IAAI,gBAAA;AAAA,IACf,yBAA0B,EAAA;AAAA,IAC1B,OAAA;AAAA,IACA,OAAA;AAAA,GACF,CAAA;AACA,EAAA,OAAO,sBAAsB,IAAI,CAAA,CAAA;AACnC;;;;"}
1
+ {"version":3,"file":"group-mention-node.js","sources":["../../src/mentions/group-mention-node.tsx"],"sourcesContent":["import {\n createInboxNotificationId,\n type GroupMentionData,\n MENTION_CHARACTER,\n} from \"@liveblocks/core\";\nimport { Group } from \"@liveblocks/react-ui/_private\";\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\nimport type { JSX } from \"react\";\n\nimport { Mention } from \"./mention-component\";\n\nexport type SerializedGroupMentionNode = Spread<\n {\n groupId: string;\n userIds?: string[];\n },\n SerializedLexicalNode\n>;\n\nfunction GroupMention({\n mention,\n nodeKey,\n}: {\n mention: GroupMentionData;\n nodeKey: string;\n}) {\n return (\n <Mention nodeKey={nodeKey}>\n {MENTION_CHARACTER}\n <Group groupId={mention.id} />\n </Mention>\n );\n}\n\nexport class GroupMentionNode extends DecoratorNode<JSX.Element> {\n __id: string;\n __groupId: string;\n __userIds: string[] | undefined;\n\n constructor(\n id: string,\n groupId: string,\n userIds: string[] | undefined,\n key?: NodeKey\n ) {\n super(key);\n this.__id = id;\n this.__groupId = groupId;\n this.__userIds = userIds;\n }\n\n static getType(): string {\n return \"lb-group-mention\";\n }\n\n static clone(node: GroupMentionNode): GroupMentionNode {\n return new GroupMentionNode(\n node.__id,\n node.__groupId,\n node.__userIds,\n node.__key\n );\n }\n\n createDOM(): HTMLElement {\n const element = document.createElement(\"span\");\n element.style.display = \"inline-block\";\n element.style.userSelect = \"none\";\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n static importDOM(): DOMConversionMap<HTMLElement> | null {\n return {\n span: () => ({\n conversion: (element) => {\n const groupId = element.getAttribute(\"data-lexical-lb-group-mention\");\n\n if (!groupId) {\n return null;\n }\n\n const userIdsAttribute = element.getAttribute(\n \"data-lexical-lb-user-ids\"\n );\n let userIds: string[] | undefined;\n\n if (userIdsAttribute) {\n try {\n const parsedUserIds = JSON.parse(userIdsAttribute) as string[];\n\n if (Array.isArray(parsedUserIds)) {\n userIds = parsedUserIds;\n }\n } catch {\n // Invalid userIds attribute\n }\n }\n\n const node = $createGroupMentionNode(groupId, userIds);\n return { node };\n },\n priority: 1,\n }),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement(\"span\");\n element.setAttribute(\"data-lexical-lb-group-mention\", this.getGroupId());\n element.setAttribute(\n \"data-lexical-lb-group-mention-users\",\n JSON.stringify(this.getUserIds())\n );\n element.textContent = this.getTextContent();\n return { element };\n }\n\n static importJSON(\n serializedNode: SerializedGroupMentionNode\n ): GroupMentionNode {\n const node = $createGroupMentionNode(\n serializedNode.groupId,\n serializedNode.userIds\n );\n return node;\n }\n\n exportJSON(): SerializedGroupMentionNode {\n return {\n groupId: this.__groupId,\n userIds: this.__userIds,\n type: \"lb-group-mention\",\n version: 1,\n };\n }\n\n getGroupId(): string {\n const self = this.getLatest();\n return self.__groupId;\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n getUserIds(): string[] | undefined {\n const self = this.getLatest();\n return self.__userIds;\n }\n\n decorate(): JSX.Element {\n const mention: GroupMentionData = {\n id: this.getGroupId(),\n kind: \"group\",\n userIds: this.getUserIds(),\n };\n\n return <GroupMention mention={mention} nodeKey={this.getKey()} />;\n }\n}\n\nexport function $isGroupMentionNode(\n node: LexicalNode | null | undefined\n): node is GroupMentionNode {\n return node instanceof GroupMentionNode;\n}\n\nexport function $createGroupMentionNode(\n groupId: string,\n userIds: string[] | undefined\n): GroupMentionNode {\n const node = new GroupMentionNode(\n createInboxNotificationId(),\n groupId,\n userIds\n );\n return $applyNodeReplacement(node);\n}\n"],"names":[],"mappings":";;;;;;AA2BA,SAAS,YAAa,CAAA;AAAA,EACpB,OAAA;AAAA,EACA,OAAA;AACF,CAGG,EAAA;AACD,EACE,uBAAA,IAAA,CAAC,WAAQ,OACN,EAAA,QAAA,EAAA;AAAA,IAAA,iBAAA;AAAA,oBACA,GAAA,CAAA,KAAA,EAAA,EAAM,OAAS,EAAA,OAAA,CAAQ,EAAI,EAAA,CAAA;AAAA,GAC9B,EAAA,CAAA,CAAA;AAEJ,CAAA;AAEO,MAAM,yBAAyB,aAA2B,CAAA;AAAA,EAC/D,IAAA,CAAA;AAAA,EACA,SAAA,CAAA;AAAA,EACA,SAAA,CAAA;AAAA,EAEA,WACE,CAAA,EAAA,EACA,OACA,EAAA,OAAA,EACA,GACA,EAAA;AACA,IAAA,KAAA,CAAM,GAAG,CAAA,CAAA;AACT,IAAA,IAAA,CAAK,IAAO,GAAA,EAAA,CAAA;AACZ,IAAA,IAAA,CAAK,SAAY,GAAA,OAAA,CAAA;AACjB,IAAA,IAAA,CAAK,SAAY,GAAA,OAAA,CAAA;AAAA,GACnB;AAAA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AAA,GAAO,KAAK,SAAU,EAAA,CAAA;AAC5B,IAAA,OAAO,IAAK,CAAA,IAAA,CAAA;AAAA,GACd;AAAA,EAEA,UAAmC,GAAA;AACjC,IAAM,MAAA,IAAA,GAAO,KAAK,SAAU,EAAA,CAAA;AAC5B,IAAA,OAAO,IAAK,CAAA,SAAA,CAAA;AAAA,GACd;AAAA,EAEA,QAAwB,GAAA;AACtB,IAAA,MAAM,OAA4B,GAAA;AAAA,MAChC,EAAA,EAAI,KAAK,UAAW,EAAA;AAAA,MACpB,IAAM,EAAA,OAAA;AAAA,MACN,OAAA,EAAS,KAAK,UAAW,EAAA;AAAA,KAC3B,CAAA;AAEA,IAAA,2BAAQ,YAAa,EAAA,EAAA,OAAA,EAAkB,OAAS,EAAA,IAAA,CAAK,QAAU,EAAA,CAAA,CAAA;AAAA,GACjE;AACF,CAAA;AAEO,SAAS,oBACd,IAC0B,EAAA;AAC1B,EAAA,OAAO,IAAgB,YAAA,gBAAA,CAAA;AACzB,CAAA;AAEgB,SAAA,uBAAA,CACd,SACA,OACkB,EAAA;AAClB,EAAA,MAAM,OAAO,IAAI,gBAAA;AAAA,IACf,yBAA0B,EAAA;AAAA,IAC1B,OAAA;AAAA,IACA,OAAA;AAAA,GACF,CAAA;AACA,EAAA,OAAO,sBAAsB,IAAI,CAAA,CAAA;AACnC;;;;"}
@@ -29,7 +29,7 @@ class MentionNode extends lexical.DecoratorNode {
29
29
  updateDOM() {
30
30
  return false;
31
31
  }
32
- static importDom() {
32
+ static importDOM() {
33
33
  return {
34
34
  span: () => ({
35
35
  conversion: (element) => {
@@ -1 +1 @@
1
- {"version":3,"file":"mention-node.cjs","sources":["../../src/mentions/mention-node.tsx"],"sourcesContent":["import { createInboxNotificationId, MENTION_CHARACTER } from \"@liveblocks/core\";\nimport { User } from \"@liveblocks/react-ui/_private\";\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\nimport type { JSX } from \"react\";\n\nimport { Mention } from \"./mention-component\";\n\nexport type SerializedMentionNode = Spread<\n {\n userId: string;\n },\n SerializedLexicalNode\n>;\nexport class MentionNode extends DecoratorNode<JSX.Element> {\n __id: string;\n __userId: string;\n\n constructor(id: string, userId: string, key?: NodeKey) {\n super(key);\n this.__id = id;\n this.__userId = userId;\n }\n\n static getType(): string {\n return \"lb-mention\";\n }\n\n static clone(node: MentionNode): MentionNode {\n return new MentionNode(node.__id, node.__userId, node.__key);\n }\n\n createDOM(): HTMLElement {\n const element = document.createElement(\"span\");\n element.style.display = \"inline-block\";\n element.style.userSelect = \"none\";\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n static importDom(): DOMConversionMap<HTMLElement> | null {\n return {\n span: () => ({\n conversion: (element) => {\n const userId = element.getAttribute(\"data-lexical-lb-mention\");\n\n if (!userId) {\n return null;\n }\n\n const node = $createMentionNode(userId);\n return { node };\n },\n priority: 1,\n }),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement(\"span\");\n element.setAttribute(\"data-lexical-lb-mention\", this.getUserId());\n element.textContent = this.getUserId();\n return { element };\n }\n\n static importJSON(serializedNode: SerializedMentionNode): MentionNode {\n const node = $createMentionNode(serializedNode.userId);\n return node;\n }\n\n exportJSON(): SerializedMentionNode {\n return {\n userId: this.__userId,\n type: \"lb-mention\",\n version: 1,\n };\n }\n\n getUserId(): string {\n const self = this.getLatest();\n return self.__userId;\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n decorate(): JSX.Element {\n return (\n <Mention nodeKey={this.getKey()}>\n <span className=\"lb-mention-symbol\">{MENTION_CHARACTER}</span>\n <User userId={this.getUserId()} />\n </Mention>\n );\n }\n\n getTextContent(): string {\n return MENTION_CHARACTER + this.getUserId();\n }\n}\n\nexport function $isMentionNode(\n node: LexicalNode | null | undefined\n): node is MentionNode {\n return node instanceof MentionNode;\n}\n\nexport function $createMentionNode(userId: string): MentionNode {\n const node = new MentionNode(createInboxNotificationId(), userId);\n return $applyNodeReplacement(node);\n}\n"],"names":["DecoratorNode","jsxs","Mention","jsx","MENTION_CHARACTER","User","createInboxNotificationId","$applyNodeReplacement"],"mappings":";;;;;;;;AAqBO,MAAM,oBAAoBA,qBAA2B,CAAA;AAAA,EAC1D,IAAA,CAAA;AAAA,EACA,QAAA,CAAA;AAAA,EAEA,WAAA,CAAY,EAAY,EAAA,MAAA,EAAgB,GAAe,EAAA;AACrD,IAAA,KAAA,CAAM,GAAG,CAAA,CAAA;AACT,IAAA,IAAA,CAAK,IAAO,GAAA,EAAA,CAAA;AACZ,IAAA,IAAA,CAAK,QAAW,GAAA,MAAA,CAAA;AAAA,GAClB;AAAA,EAEA,OAAO,OAAkB,GAAA;AACvB,IAAO,OAAA,YAAA,CAAA;AAAA,GACT;AAAA,EAEA,OAAO,MAAM,IAAgC,EAAA;AAC3C,IAAA,OAAO,IAAI,WAAY,CAAA,IAAA,CAAK,MAAM,IAAK,CAAA,QAAA,EAAU,KAAK,KAAK,CAAA,CAAA;AAAA,GAC7D;AAAA,EAEA,SAAyB,GAAA;AACvB,IAAM,MAAA,OAAA,GAAU,QAAS,CAAA,aAAA,CAAc,MAAM,CAAA,CAAA;AAC7C,IAAA,OAAA,CAAQ,MAAM,OAAU,GAAA,cAAA,CAAA;AACxB,IAAA,OAAA,CAAQ,MAAM,UAAa,GAAA,MAAA,CAAA;AAC3B,IAAO,OAAA,OAAA,CAAA;AAAA,GACT;AAAA,EAEA,SAAqB,GAAA;AACnB,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AAAA,EAEA,OAAO,SAAkD,GAAA;AACvD,IAAO,OAAA;AAAA,MACL,MAAM,OAAO;AAAA,QACX,UAAA,EAAY,CAAC,OAAY,KAAA;AACvB,UAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,YAAA,CAAa,yBAAyB,CAAA,CAAA;AAE7D,UAAA,IAAI,CAAC,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B,EAAA,QAAA,EAAA;AAAA,sBAACC,cAAA,CAAA,MAAA,EAAA,EAAK,SAAU,EAAA,mBAAA,EAAqB,QAAkB,EAAAC,sBAAA,EAAA,CAAA;AAAA,sBACtDD,cAAA,CAAAE,aAAA,EAAA,EAAK,MAAQ,EAAA,IAAA,CAAK,WAAa,EAAA,CAAA;AAAA,KAClC,EAAA,CAAA,CAAA;AAAA,GAEJ;AAAA,EAEA,cAAyB,GAAA;AACvB,IAAO,OAAAD,sBAAA,GAAoB,KAAK,SAAU,EAAA,CAAA;AAAA,GAC5C;AACF,CAAA;AAEO,SAAS,eACd,IACqB,EAAA;AACrB,EAAA,OAAO,IAAgB,YAAA,WAAA,CAAA;AACzB,CAAA;AAEO,SAAS,mBAAmB,MAA6B,EAAA;AAC9D,EAAA,MAAM,IAAO,GAAA,IAAI,WAAY,CAAAE,8BAAA,IAA6B,MAAM,CAAA,CAAA;AAChE,EAAA,OAAOC,8BAAsB,IAAI,CAAA,CAAA;AACnC;;;;;;"}
1
+ {"version":3,"file":"mention-node.cjs","sources":["../../src/mentions/mention-node.tsx"],"sourcesContent":["import { createInboxNotificationId, MENTION_CHARACTER } from \"@liveblocks/core\";\nimport { User } from \"@liveblocks/react-ui/_private\";\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\nimport type { JSX } from \"react\";\n\nimport { Mention } from \"./mention-component\";\n\nexport type SerializedMentionNode = Spread<\n {\n userId: string;\n },\n SerializedLexicalNode\n>;\nexport class MentionNode extends DecoratorNode<JSX.Element> {\n __id: string;\n __userId: string;\n\n constructor(id: string, userId: string, key?: NodeKey) {\n super(key);\n this.__id = id;\n this.__userId = userId;\n }\n\n static getType(): string {\n return \"lb-mention\";\n }\n\n static clone(node: MentionNode): MentionNode {\n return new MentionNode(node.__id, node.__userId, node.__key);\n }\n\n createDOM(): HTMLElement {\n const element = document.createElement(\"span\");\n element.style.display = \"inline-block\";\n element.style.userSelect = \"none\";\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n static importDOM(): DOMConversionMap<HTMLElement> | null {\n return {\n span: () => ({\n conversion: (element) => {\n const userId = element.getAttribute(\"data-lexical-lb-mention\");\n\n if (!userId) {\n return null;\n }\n\n const node = $createMentionNode(userId);\n return { node };\n },\n priority: 1,\n }),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement(\"span\");\n element.setAttribute(\"data-lexical-lb-mention\", this.getUserId());\n element.textContent = this.getUserId();\n return { element };\n }\n\n static importJSON(serializedNode: SerializedMentionNode): MentionNode {\n const node = $createMentionNode(serializedNode.userId);\n return node;\n }\n\n exportJSON(): SerializedMentionNode {\n return {\n userId: this.__userId,\n type: \"lb-mention\",\n version: 1,\n };\n }\n\n getUserId(): string {\n const self = this.getLatest();\n return self.__userId;\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n decorate(): JSX.Element {\n return (\n <Mention nodeKey={this.getKey()}>\n <span className=\"lb-mention-symbol\">{MENTION_CHARACTER}</span>\n <User userId={this.getUserId()} />\n </Mention>\n );\n }\n\n getTextContent(): string {\n return MENTION_CHARACTER + this.getUserId();\n }\n}\n\nexport function $isMentionNode(\n node: LexicalNode | null | undefined\n): node is MentionNode {\n return node instanceof MentionNode;\n}\n\nexport function $createMentionNode(userId: string): MentionNode {\n const node = new MentionNode(createInboxNotificationId(), userId);\n return $applyNodeReplacement(node);\n}\n"],"names":["DecoratorNode","jsxs","Mention","jsx","MENTION_CHARACTER","User","createInboxNotificationId","$applyNodeReplacement"],"mappings":";;;;;;;;AAqBO,MAAM,oBAAoBA,qBAA2B,CAAA;AAAA,EAC1D,IAAA,CAAA;AAAA,EACA,QAAA,CAAA;AAAA,EAEA,WAAA,CAAY,EAAY,EAAA,MAAA,EAAgB,GAAe,EAAA;AACrD,IAAA,KAAA,CAAM,GAAG,CAAA,CAAA;AACT,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AS,eACd,IACqB,EAAA;AACrB,EAAA,OAAO,IAAgB,YAAA,WAAA,CAAA;AACzB,CAAA;AAEO,SAAS,mBAAmB,MAA6B,EAAA;AAC9D,EAAA,MAAM,IAAO,GAAA,IAAI,WAAY,CAAAE,8BAAA,IAA6B,MAAM,CAAA,CAAA;AAChE,EAAA,OAAOC,8BAAsB,IAAI,CAAA,CAAA;AACnC;;;;;;"}
@@ -27,7 +27,7 @@ class MentionNode extends DecoratorNode {
27
27
  updateDOM() {
28
28
  return false;
29
29
  }
30
- static importDom() {
30
+ static importDOM() {
31
31
  return {
32
32
  span: () => ({
33
33
  conversion: (element) => {
@@ -1 +1 @@
1
- {"version":3,"file":"mention-node.js","sources":["../../src/mentions/mention-node.tsx"],"sourcesContent":["import { createInboxNotificationId, MENTION_CHARACTER } from \"@liveblocks/core\";\nimport { User } from \"@liveblocks/react-ui/_private\";\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\nimport type { JSX } from \"react\";\n\nimport { Mention } from \"./mention-component\";\n\nexport type SerializedMentionNode = Spread<\n {\n userId: string;\n },\n SerializedLexicalNode\n>;\nexport class MentionNode extends DecoratorNode<JSX.Element> {\n __id: string;\n __userId: string;\n\n constructor(id: string, userId: string, key?: NodeKey) {\n super(key);\n this.__id = id;\n this.__userId = userId;\n }\n\n static getType(): string {\n return \"lb-mention\";\n }\n\n static clone(node: MentionNode): MentionNode {\n return new MentionNode(node.__id, node.__userId, node.__key);\n }\n\n createDOM(): HTMLElement {\n const element = document.createElement(\"span\");\n element.style.display = \"inline-block\";\n element.style.userSelect = \"none\";\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n static importDom(): DOMConversionMap<HTMLElement> | null {\n return {\n span: () => ({\n conversion: (element) => {\n const userId = element.getAttribute(\"data-lexical-lb-mention\");\n\n if (!userId) {\n return null;\n }\n\n const node = $createMentionNode(userId);\n return { node };\n },\n priority: 1,\n }),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement(\"span\");\n element.setAttribute(\"data-lexical-lb-mention\", this.getUserId());\n element.textContent = this.getUserId();\n return { element };\n }\n\n static importJSON(serializedNode: SerializedMentionNode): MentionNode {\n const node = $createMentionNode(serializedNode.userId);\n return node;\n }\n\n exportJSON(): SerializedMentionNode {\n return {\n userId: this.__userId,\n type: \"lb-mention\",\n version: 1,\n };\n }\n\n getUserId(): string {\n const self = this.getLatest();\n return self.__userId;\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n decorate(): JSX.Element {\n return (\n <Mention nodeKey={this.getKey()}>\n <span className=\"lb-mention-symbol\">{MENTION_CHARACTER}</span>\n <User userId={this.getUserId()} />\n </Mention>\n );\n }\n\n getTextContent(): string {\n return MENTION_CHARACTER + this.getUserId();\n }\n}\n\nexport function $isMentionNode(\n node: LexicalNode | null | undefined\n): node is MentionNode {\n return node instanceof MentionNode;\n}\n\nexport function $createMentionNode(userId: string): MentionNode {\n const node = new MentionNode(createInboxNotificationId(), userId);\n return $applyNodeReplacement(node);\n}\n"],"names":[],"mappings":";;;;;;AAqBO,MAAM,oBAAoB,aAA2B,CAAA;AAAA,EAC1D,IAAA,CAAA;AAAA,EACA,QAAA,CAAA;AAAA,EAEA,WAAA,CAAY,EAAY,EAAA,MAAA,EAAgB,GAAe,EAAA;AACrD,IAAA,KAAA,CAAM,GAAG,CAAA,CAAA;AACT,IAAA,IAAA,CAAK,IAAO,GAAA,EAAA,CAAA;AACZ,IAAA,IAAA,CAAK,QAAW,GAAA,MAAA,CAAA;AAAA,GAClB;AAAA,EAEA,OAAO,OAAkB,GAAA;AACvB,IAAO,OAAA,YAAA,CAAA;AAAA,GACT;AAAA,EAEA,OAAO,MAAM,IAAgC,EAAA;AAC3C,IAAA,OAAO,IAAI,WAAY,CAAA,IAAA,CAAK,MAAM,IAAK,CAAA,QAAA,EAAU,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],"sourcesContent":["import { createInboxNotificationId, MENTION_CHARACTER } from \"@liveblocks/core\";\nimport { User } from \"@liveblocks/react-ui/_private\";\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\nimport type { JSX } from \"react\";\n\nimport { Mention } from \"./mention-component\";\n\nexport type SerializedMentionNode = Spread<\n {\n userId: string;\n },\n SerializedLexicalNode\n>;\nexport class MentionNode extends DecoratorNode<JSX.Element> {\n __id: string;\n __userId: string;\n\n constructor(id: string, userId: string, key?: NodeKey) {\n super(key);\n this.__id = id;\n this.__userId = userId;\n }\n\n static getType(): string {\n return \"lb-mention\";\n }\n\n static clone(node: MentionNode): MentionNode {\n return new MentionNode(node.__id, node.__userId, node.__key);\n }\n\n createDOM(): HTMLElement {\n const element = document.createElement(\"span\");\n element.style.display = \"inline-block\";\n element.style.userSelect = \"none\";\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n static importDOM(): DOMConversionMap<HTMLElement> | null {\n return {\n span: () => ({\n conversion: (element) => {\n const userId = element.getAttribute(\"data-lexical-lb-mention\");\n\n if (!userId) {\n return null;\n }\n\n const node = $createMentionNode(userId);\n return { node };\n },\n priority: 1,\n }),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement(\"span\");\n element.setAttribute(\"data-lexical-lb-mention\", this.getUserId());\n element.textContent = this.getUserId();\n return { element };\n }\n\n static importJSON(serializedNode: SerializedMentionNode): MentionNode {\n const node = $createMentionNode(serializedNode.userId);\n return node;\n }\n\n exportJSON(): SerializedMentionNode {\n return {\n userId: this.__userId,\n type: \"lb-mention\",\n version: 1,\n };\n }\n\n getUserId(): string {\n const self = this.getLatest();\n return self.__userId;\n }\n\n getId(): string {\n const self = this.getLatest();\n return self.__id;\n }\n\n decorate(): JSX.Element {\n return (\n <Mention nodeKey={this.getKey()}>\n <span className=\"lb-mention-symbol\">{MENTION_CHARACTER}</span>\n <User userId={this.getUserId()} />\n </Mention>\n );\n }\n\n getTextContent(): string {\n return MENTION_CHARACTER + this.getUserId();\n }\n}\n\nexport function $isMentionNode(\n node: LexicalNode | null | undefined\n): node is MentionNode {\n return node instanceof MentionNode;\n}\n\nexport function $createMentionNode(userId: string): MentionNode {\n const node = new MentionNode(createInboxNotificationId(), userId);\n return $applyNodeReplacement(node);\n}\n"],"names":[],"mappings":";;;;;;AAqBO,MAAM,oBAAoB,aAA2B,CAAA;AAAA,EAC1D,IAAA,CAAA;AAAA,EACA,QAAA,CAAA;AAAA,EAEA,WAAA,CAAY,EAAY,EAAA,MAAA,EAAgB,GAAe,EAAA;AACrD,IAAA,KAAA,CAAM,GAAG,CAAA,CAAA;AACT,IAAA,IAAA,CAAK,IAAO,GAAA,EAAA,CAAA;AACZ,IAAA,IAAA,CAAK,QAAW,GAAA,MAAA,CAAA;AAAA,GAClB;AAAA,EAEA,OAAO,OAAkB,GAAA;AACvB,IAAO,OAAA,YAAA,CAAA;AAAA,GACT;AAAA,EAEA,OAAO,MAAM,IAAgC,EAAA;AAC3C,IAAA,OAAO,IAAI,WAAY,CAAA,IAAA,CAAK,MAAM,IAAK,CAAA,QAAA,EAAU,KAAK,KAAK,CAAA,CAAA;AAAA,GAC7D;AAAA,EAEA,SAAyB,GAAA;AACvB,IAAM,MAAA,OAAA,GAAU,QAAS,CAAA,aAAA,CAAc,MAAM,CAAA,CAAA;AAC7C,IAAA,OAAA,CAAQ,MAAM,OAAU,GAAA,cAAA,CAAA;AACxB,IAAA,OAAA,CAAQ,MAAM,UAAa,GAAA,MAAA,CAAA;AAC3B,IAAO,OAAA,OAAA,CAAA;AAAA,GACT;AAAA,EAEA,SAAqB,GAAA;AACnB,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AAAA,EAEA,OAAO,SAAkD,GAAA;AACvD,IAAO,OAAA;AAAA,MACL,MAAM,OAAO;AAAA,QACX,UAAA,EAAY,CAAC,OAA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ACd;AAAA,EAEA,QAAwB,GAAA;AACtB,IAAA,uBACG,IAAA,CAAA,OAAA,EAAA,EAAQ,OAAS,EAAA,IAAA,CAAK,QACrB,EAAA,QAAA,EAAA;AAAA,sBAAC,GAAA,CAAA,MAAA,EAAA,EAAK,SAAU,EAAA,mBAAA,EAAqB,QAAkB,EAAA,iBAAA,EAAA,CAAA;AAAA,sBACtD,GAAA,CAAA,IAAA,EAAA,EAAK,MAAQ,EAAA,IAAA,CAAK,WAAa,EAAA,CAAA;AAAA,KAClC,EAAA,CAAA,CAAA;AAAA,GAEJ;AAAA,EAEA,cAAyB,GAAA;AACvB,IAAO,OAAA,iBAAA,GAAoB,KAAK,SAAU,EAAA,CAAA;AAAA,GAC5C;AACF,CAAA;AAEO,SAAS,eACd,IACqB,EAAA;AACrB,EAAA,OAAO,IAAgB,YAAA,WAAA,CAAA;AACzB,CAAA;AAEO,SAAS,mBAAmB,MAA6B,EAAA;AAC9D,EAAA,MAAM,IAAO,GAAA,IAAI,WAAY,CAAA,yBAAA,IAA6B,MAAM,CAAA,CAAA;AAChE,EAAA,OAAO,sBAAsB,IAAI,CAAA,CAAA;AACnC;;;;"}
package/dist/version.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const PKG_NAME = "@liveblocks/react-lexical";
4
- const PKG_VERSION = typeof "3.10.0" === "string" && "3.10.0";
4
+ const PKG_VERSION = typeof "3.11.0" === "string" && "3.11.0";
5
5
  const PKG_FORMAT = typeof "cjs" === "string" && "cjs";
6
6
 
7
7
  exports.PKG_FORMAT = PKG_FORMAT;
package/dist/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const PKG_NAME = "@liveblocks/react-lexical";
2
- const PKG_VERSION = typeof "3.10.0" === "string" && "3.10.0";
2
+ const PKG_VERSION = typeof "3.11.0" === "string" && "3.11.0";
3
3
  const PKG_FORMAT = typeof "esm" === "string" && "esm";
4
4
 
5
5
  export { PKG_FORMAT, PKG_NAME, PKG_VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/react-lexical",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "description": "An integration of Lexical + React to enable collaboration, comments, live cursors, and more with Liveblocks.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -43,24 +43,24 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@floating-ui/react-dom": "^2.1.1",
46
- "@liveblocks/client": "3.10.0",
47
- "@liveblocks/core": "3.10.0",
48
- "@liveblocks/react": "3.10.0",
49
- "@liveblocks/react-ui": "3.10.0",
50
- "@liveblocks/yjs": "3.10.0",
46
+ "@liveblocks/client": "3.11.0",
47
+ "@liveblocks/core": "3.11.0",
48
+ "@liveblocks/react": "3.11.0",
49
+ "@liveblocks/react-ui": "3.11.0",
50
+ "@liveblocks/yjs": "3.11.0",
51
51
  "@radix-ui/react-select": "^2.1.2",
52
52
  "@radix-ui/react-toggle": "^1.1.0",
53
53
  "yjs": "^13.6.18"
54
54
  },
55
55
  "peerDependencies": {
56
- "@lexical/react": "0.24.0",
57
- "@lexical/rich-text": "0.24.0",
58
- "@lexical/selection": "0.24.0",
59
- "@lexical/utils": "0.24.0",
60
- "@lexical/yjs": "0.24.0",
56
+ "@lexical/react": "0.35.0",
57
+ "@lexical/rich-text": "0.35.0",
58
+ "@lexical/selection": "0.35.0",
59
+ "@lexical/utils": "0.35.0",
60
+ "@lexical/yjs": "0.35.0",
61
61
  "@types/react": "*",
62
62
  "@types/react-dom": "*",
63
- "lexical": "0.24.0",
63
+ "lexical": "0.35.0",
64
64
  "react": "^18 || ^19 || ^19.0.0-rc",
65
65
  "react-dom": "^18 || ^19 || ^19.0.0-rc"
66
66
  },