@liveblocks/react-lexical 2.18.2 → 2.18.4-uns1

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 (138) hide show
  1. package/dist/{classnames.mjs → classnames.cjs} +4 -2
  2. package/dist/{classnames.mjs.map → classnames.cjs.map} +1 -1
  3. package/dist/classnames.js +1 -3
  4. package/dist/classnames.js.map +1 -1
  5. package/dist/comments/{anchored-threads.mjs → anchored-threads.cjs} +44 -41
  6. package/dist/comments/{anchored-threads.mjs.map → anchored-threads.cjs.map} +1 -1
  7. package/dist/comments/anchored-threads.js +40 -43
  8. package/dist/comments/anchored-threads.js.map +1 -1
  9. package/dist/comments/{comment-plugin-provider.mjs → comment-plugin-provider.cjs} +62 -55
  10. package/dist/comments/{comment-plugin-provider.mjs.map → comment-plugin-provider.cjs.map} +1 -1
  11. package/dist/comments/comment-plugin-provider.js +54 -61
  12. package/dist/comments/comment-plugin-provider.js.map +1 -1
  13. package/dist/comments/{floating-composer.mjs → floating-composer.cjs} +68 -64
  14. package/dist/comments/{floating-composer.mjs.map → floating-composer.cjs.map} +1 -1
  15. package/dist/comments/floating-composer.js +63 -67
  16. package/dist/comments/floating-composer.js.map +1 -1
  17. package/dist/comments/{floating-threads.mjs → floating-threads.cjs} +51 -48
  18. package/dist/comments/{floating-threads.mjs.map → floating-threads.cjs.map} +1 -1
  19. package/dist/comments/floating-threads.js +47 -50
  20. package/dist/comments/floating-threads.js.map +1 -1
  21. package/dist/comments/get-thread-mark-ids.cjs +23 -0
  22. package/dist/comments/{get-thread-mark-ids.mjs.map → get-thread-mark-ids.cjs.map} +1 -1
  23. package/dist/comments/get-thread-mark-ids.js +6 -8
  24. package/dist/comments/get-thread-mark-ids.js.map +1 -1
  25. package/dist/comments/{thread-mark-node.mjs → thread-mark-node.cjs} +10 -6
  26. package/dist/comments/{thread-mark-node.mjs.map → thread-mark-node.cjs.map} +1 -1
  27. package/dist/comments/thread-mark-node.js +5 -9
  28. package/dist/comments/thread-mark-node.js.map +1 -1
  29. package/dist/comments/{unwrap-thread-mark-node.mjs → unwrap-thread-mark-node.cjs} +4 -2
  30. package/dist/comments/unwrap-thread-mark-node.cjs.map +1 -0
  31. package/dist/comments/unwrap-thread-mark-node.js +1 -3
  32. package/dist/comments/unwrap-thread-mark-node.js.map +1 -1
  33. package/dist/comments/{wrap-selection-in-thread-mark-node.mjs → wrap-selection-in-thread-mark-node.cjs} +12 -10
  34. package/dist/comments/{wrap-selection-in-thread-mark-node.mjs.map → wrap-selection-in-thread-mark-node.cjs.map} +1 -1
  35. package/dist/comments/wrap-selection-in-thread-mark-node.js +9 -11
  36. package/dist/comments/wrap-selection-in-thread-mark-node.js.map +1 -1
  37. package/dist/{create-dom-range.mjs → create-dom-range.cjs} +7 -5
  38. package/dist/{create-dom-range.mjs.map → create-dom-range.cjs.map} +1 -1
  39. package/dist/create-dom-range.js +4 -6
  40. package/dist/create-dom-range.js.map +1 -1
  41. package/dist/{create-rects-from-dom-range.mjs → create-rects-from-dom-range.cjs} +4 -2
  42. package/dist/{create-rects-from-dom-range.mjs.map → create-rects-from-dom-range.cjs.map} +1 -1
  43. package/dist/create-rects-from-dom-range.js +1 -3
  44. package/dist/create-rects-from-dom-range.js.map +1 -1
  45. package/dist/index.cjs +33 -0
  46. package/dist/{index.mjs.map → index.cjs.map} +1 -1
  47. package/dist/{index.d.mts → index.d.cts} +0 -1
  48. package/dist/index.d.ts +0 -1
  49. package/dist/index.js +14 -31
  50. package/dist/index.js.map +1 -1
  51. package/dist/{is-block-node-active.mjs → is-block-node-active.cjs} +12 -10
  52. package/dist/{is-block-node-active.mjs.map → is-block-node-active.cjs.map} +1 -1
  53. package/dist/is-block-node-active.js +9 -11
  54. package/dist/is-block-node-active.js.map +1 -1
  55. package/dist/is-command-registered.cjs +11 -0
  56. package/dist/{is-command-registered.mjs.map → is-command-registered.cjs.map} +1 -1
  57. package/dist/is-command-registered.js +3 -5
  58. package/dist/is-command-registered.js.map +1 -1
  59. package/dist/is-text-format-active.cjs +16 -0
  60. package/dist/{is-text-format-active.mjs.map → is-text-format-active.cjs.map} +1 -1
  61. package/dist/is-text-format-active.js +4 -6
  62. package/dist/is-text-format-active.js.map +1 -1
  63. package/dist/liveblocks-config.cjs +17 -0
  64. package/dist/{liveblocks-config.mjs.map → liveblocks-config.cjs.map} +1 -1
  65. package/dist/liveblocks-config.js +4 -6
  66. package/dist/liveblocks-config.js.map +1 -1
  67. package/dist/liveblocks-plugin-provider.cjs +151 -0
  68. package/dist/liveblocks-plugin-provider.cjs.map +1 -0
  69. package/dist/liveblocks-plugin-provider.js +45 -66
  70. package/dist/liveblocks-plugin-provider.js.map +1 -1
  71. package/dist/mentions/{avatar.mjs → avatar.cjs} +16 -14
  72. package/dist/mentions/avatar.cjs.map +1 -0
  73. package/dist/mentions/avatar.js +13 -15
  74. package/dist/mentions/avatar.js.map +1 -1
  75. package/dist/mentions/mention-component.cjs +51 -0
  76. package/dist/mentions/{mention-component.mjs.map → mention-component.cjs.map} +1 -1
  77. package/dist/mentions/mention-component.js +14 -16
  78. package/dist/mentions/mention-component.js.map +1 -1
  79. package/dist/mentions/{mention-node.mjs → mention-node.cjs} +17 -13
  80. package/dist/mentions/mention-node.cjs.map +1 -0
  81. package/dist/mentions/mention-node.js +12 -16
  82. package/dist/mentions/mention-node.js.map +1 -1
  83. package/dist/mentions/{mention-plugin.mjs → mention-plugin.cjs} +81 -78
  84. package/dist/mentions/{mention-plugin.mjs.map → mention-plugin.cjs.map} +1 -1
  85. package/dist/mentions/mention-plugin.js +77 -80
  86. package/dist/mentions/mention-plugin.js.map +1 -1
  87. package/dist/mentions/{suggestions.mjs → suggestions.cjs} +43 -37
  88. package/dist/mentions/{suggestions.mjs.map → suggestions.cjs.map} +1 -1
  89. package/dist/mentions/suggestions.js +36 -42
  90. package/dist/mentions/suggestions.js.map +1 -1
  91. package/dist/mentions/user.cjs +26 -0
  92. package/dist/mentions/{user.mjs.map → user.cjs.map} +1 -1
  93. package/dist/mentions/user.js +11 -13
  94. package/dist/mentions/user.js.map +1 -1
  95. package/dist/toolbar/{floating-toolbar.mjs → floating-toolbar.cjs} +73 -70
  96. package/dist/toolbar/{floating-toolbar.mjs.map → floating-toolbar.cjs.map} +1 -1
  97. package/dist/toolbar/floating-toolbar.js +69 -72
  98. package/dist/toolbar/floating-toolbar.js.map +1 -1
  99. package/dist/toolbar/shared.cjs +36 -0
  100. package/dist/toolbar/{shared.mjs.map → shared.cjs.map} +1 -1
  101. package/dist/toolbar/shared.js +12 -15
  102. package/dist/toolbar/shared.js.map +1 -1
  103. package/dist/toolbar/toolbar.cjs +433 -0
  104. package/dist/toolbar/{toolbar.mjs.map → toolbar.cjs.map} +1 -1
  105. package/dist/toolbar/toolbar.js +131 -156
  106. package/dist/toolbar/toolbar.js.map +1 -1
  107. package/dist/use-root-element.cjs +21 -0
  108. package/dist/use-root-element.cjs.map +1 -0
  109. package/dist/use-root-element.js +7 -9
  110. package/dist/use-root-element.js.map +1 -1
  111. package/dist/version-history/{history-version-preview.mjs → history-version-preview.cjs} +53 -50
  112. package/dist/version-history/history-version-preview.cjs.map +1 -0
  113. package/dist/version-history/history-version-preview.js +50 -51
  114. package/dist/version-history/history-version-preview.js.map +1 -1
  115. package/dist/version.cjs +10 -0
  116. package/dist/{version.mjs.map → version.cjs.map} +1 -1
  117. package/dist/version.js +3 -7
  118. package/dist/version.js.map +1 -1
  119. package/package.json +24 -23
  120. package/styles.css.d.cts +1 -0
  121. package/dist/comments/get-thread-mark-ids.mjs +0 -21
  122. package/dist/comments/unwrap-thread-mark-node.mjs.map +0 -1
  123. package/dist/index.mjs +0 -16
  124. package/dist/is-command-registered.mjs +0 -9
  125. package/dist/is-text-format-active.mjs +0 -14
  126. package/dist/liveblocks-config.mjs +0 -15
  127. package/dist/liveblocks-plugin-provider.mjs +0 -164
  128. package/dist/liveblocks-plugin-provider.mjs.map +0 -1
  129. package/dist/mentions/avatar.mjs.map +0 -1
  130. package/dist/mentions/mention-component.mjs +0 -49
  131. package/dist/mentions/mention-node.mjs.map +0 -1
  132. package/dist/mentions/user.mjs +0 -24
  133. package/dist/toolbar/shared.mjs +0 -33
  134. package/dist/toolbar/toolbar.mjs +0 -408
  135. package/dist/use-root-element.mjs +0 -19
  136. package/dist/use-root-element.mjs.map +0 -1
  137. package/dist/version-history/history-version-preview.mjs.map +0 -1
  138. package/dist/version.mjs +0 -6
@@ -1,20 +1,18 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var LexicalComposer = require('@lexical/react/LexicalComposer');
5
- var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
6
- var LexicalContentEditable = require('@lexical/react/LexicalContentEditable');
7
- var LexicalEditorRefPlugin = require('@lexical/react/LexicalEditorRefPlugin');
8
- var LexicalErrorBoundary = require('@lexical/react/LexicalErrorBoundary');
9
- var LexicalRichTextPlugin = require('@lexical/react/LexicalRichTextPlugin');
10
- var yjs = require('@lexical/yjs');
11
- var react$1 = require('@liveblocks/react');
12
- var reactUi = require('@liveblocks/react-ui');
13
- var _private = require('@liveblocks/react-ui/_private');
14
- var react = require('react');
15
- var yjs$1 = require('yjs');
16
- var classnames = require('../classnames.js');
17
- var liveblocksConfig = require('../liveblocks-config.js');
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { LexicalComposer } from '@lexical/react/LexicalComposer';
3
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
4
+ import { ContentEditable } from '@lexical/react/LexicalContentEditable';
5
+ import { EditorRefPlugin } from '@lexical/react/LexicalEditorRefPlugin';
6
+ import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
7
+ import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
8
+ import { syncLexicalUpdateToYjs, syncYjsChangesToLexical, createBinding } from '@lexical/yjs';
9
+ import { useHistoryVersionData } from '@liveblocks/react';
10
+ import { useOverrides } from '@liveblocks/react-ui';
11
+ import { SpinnerIcon, List, User, Button, RestoreIcon } from '@liveblocks/react-ui/_private';
12
+ import { forwardRef, useRef, useMemo, useEffect, useCallback } from 'react';
13
+ import { Doc, applyUpdate } from 'yjs';
14
+ import { classNames } from '../classnames.js';
15
+ import { liveblocksConfig } from '../liveblocks-config.js';
18
16
 
19
17
  const AUTHORS_TRUNCATE = 3;
20
18
  function createNoOpProvider() {
@@ -23,6 +21,7 @@ function createNoOpProvider() {
23
21
  return {
24
22
  awareness: {
25
23
  getLocalState: () => null,
24
+ setLocalStateField: emptyFunction,
26
25
  getStates: () => /* @__PURE__ */ new Map(),
27
26
  off: emptyFunction,
28
27
  on: emptyFunction,
@@ -45,7 +44,7 @@ function registerCollaborationListeners(editor, provider, binding) {
45
44
  tags
46
45
  }) => {
47
46
  if (tags.has("skip-collab") === false) {
48
- yjs.syncLexicalUpdateToYjs(
47
+ syncLexicalUpdateToYjs(
49
48
  binding,
50
49
  provider,
51
50
  prevEditorState,
@@ -60,7 +59,7 @@ function registerCollaborationListeners(editor, provider, binding) {
60
59
  );
61
60
  const observer = (events, transaction) => {
62
61
  if (transaction.origin !== binding) {
63
- yjs.syncYjsChangesToLexical(binding, provider, events, false);
62
+ syncYjsChangesToLexical(binding, provider, events, false);
64
63
  }
65
64
  };
66
65
  binding.root.getSharedType().observeDeep(observer);
@@ -69,14 +68,14 @@ function registerCollaborationListeners(editor, provider, binding) {
69
68
  binding.root.getSharedType().unobserveDeep(observer);
70
69
  };
71
70
  }
72
- const HistoryVersionPreview = react.forwardRef(({ version, onVersionRestore, className, ...props }, forwardedRef) => {
73
- const [parentEditor, parentContext] = LexicalComposerContext.useLexicalComposerContext();
74
- const editor = react.useRef();
75
- const $ = reactUi.useOverrides();
76
- const { isLoading, data, error } = react$1.useHistoryVersionData(version.id);
77
- const initialConfig = react.useMemo(() => {
71
+ const HistoryVersionPreview = forwardRef(({ version, onVersionRestore, className, ...props }, forwardedRef) => {
72
+ const [parentEditor, parentContext] = useLexicalComposerContext();
73
+ const editor = useRef();
74
+ const $ = useOverrides();
75
+ const { isLoading, data, error } = useHistoryVersionData(version.id);
76
+ const initialConfig = useMemo(() => {
78
77
  const nodes = Array.from(parentEditor._nodes.values()).map((n) => n.klass);
79
- return liveblocksConfig.liveblocksConfig({
78
+ return liveblocksConfig({
80
79
  namespace: "VersionPreview",
81
80
  theme: parentContext.getTheme() || {},
82
81
  nodes,
@@ -84,14 +83,14 @@ const HistoryVersionPreview = react.forwardRef(({ version, onVersionRestore, cla
84
83
  onError: (err) => console.error(err)
85
84
  });
86
85
  }, [parentEditor, parentContext]);
87
- react.useEffect(() => {
86
+ useEffect(() => {
88
87
  if (error || !data || !editor.current || !data.length) {
89
88
  return;
90
89
  }
91
- const doc = new yjs$1.Doc();
90
+ const doc = new Doc();
92
91
  const docMap = /* @__PURE__ */ new Map([[version.id, doc]]);
93
92
  const provider = createNoOpProvider();
94
- const binding = yjs.createBinding(
93
+ const binding = createBinding(
95
94
  editor.current,
96
95
  provider,
97
96
  version.id,
@@ -104,60 +103,60 @@ const HistoryVersionPreview = react.forwardRef(({ version, onVersionRestore, cla
104
103
  binding
105
104
  );
106
105
  try {
107
- yjs$1.applyUpdate(doc, data);
106
+ applyUpdate(doc, data);
108
107
  } catch (err) {
109
108
  console.warn(err);
110
109
  }
111
110
  return unsubscribe;
112
111
  }, [data, version.id, isLoading, error]);
113
- const restore = react.useCallback(() => {
112
+ const restore = useCallback(() => {
114
113
  if (!editor.current || !parentEditor) {
115
114
  return;
116
115
  }
117
116
  parentEditor.setEditorState(editor.current.getEditorState());
118
117
  onVersionRestore?.(version);
119
118
  }, [parentEditor, onVersionRestore, version]);
120
- return /* @__PURE__ */ jsxRuntime.jsxs("div", {
119
+ return /* @__PURE__ */ jsxs("div", {
121
120
  ...props,
122
- className: classnames.classNames(
121
+ className: classNames(
123
122
  "lb-root lb-history-version-preview lb-lexical-version-preview",
124
123
  className
125
124
  ),
126
125
  ref: forwardedRef,
127
126
  children: [
128
- isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", {
127
+ isLoading ? /* @__PURE__ */ jsx("div", {
129
128
  className: "lb-loading lb-history-version-preview-loading",
130
- children: /* @__PURE__ */ jsxRuntime.jsx(_private.SpinnerIcon, {})
131
- }) : error ? /* @__PURE__ */ jsxRuntime.jsx("div", {
129
+ children: /* @__PURE__ */ jsx(SpinnerIcon, {})
130
+ }) : error ? /* @__PURE__ */ jsx("div", {
132
131
  className: "lb-error lb-history-version-preview-error",
133
132
  children: $.HISTORY_VERSION_PREVIEW_ERROR(error)
134
- }) : /* @__PURE__ */ jsxRuntime.jsx("div", {
133
+ }) : /* @__PURE__ */ jsx("div", {
135
134
  className: "lb-history-version-preview-content lb-lexical-editor-container lb-lexical-version-preview-editor-container",
136
- children: /* @__PURE__ */ jsxRuntime.jsxs(LexicalComposer.LexicalComposer, {
135
+ children: /* @__PURE__ */ jsxs(LexicalComposer, {
137
136
  initialConfig,
138
137
  children: [
139
- /* @__PURE__ */ jsxRuntime.jsx(LexicalEditorRefPlugin.EditorRefPlugin, {
138
+ /* @__PURE__ */ jsx(EditorRefPlugin, {
140
139
  editorRef: editor
141
140
  }),
142
- /* @__PURE__ */ jsxRuntime.jsx(LexicalRichTextPlugin.RichTextPlugin, {
143
- contentEditable: /* @__PURE__ */ jsxRuntime.jsx(LexicalContentEditable.ContentEditable, {}),
144
- placeholder: /* @__PURE__ */ jsxRuntime.jsx("div", {
141
+ /* @__PURE__ */ jsx(RichTextPlugin, {
142
+ contentEditable: /* @__PURE__ */ jsx(ContentEditable, {}),
143
+ placeholder: /* @__PURE__ */ jsx("div", {
145
144
  className: "lb-empty lb-history-version-preview-empty",
146
145
  children: $.HISTORY_VERSION_PREVIEW_EMPTY
147
146
  }),
148
- ErrorBoundary: LexicalErrorBoundary.LexicalErrorBoundary
147
+ ErrorBoundary: LexicalErrorBoundary
149
148
  })
150
149
  ]
151
150
  })
152
151
  }),
153
- /* @__PURE__ */ jsxRuntime.jsxs("div", {
152
+ /* @__PURE__ */ jsxs("div", {
154
153
  className: "lb-history-version-preview-footer",
155
154
  children: [
156
- /* @__PURE__ */ jsxRuntime.jsx("span", {
155
+ /* @__PURE__ */ jsx("span", {
157
156
  className: "lb-history-version-preview-authors",
158
157
  children: $.HISTORY_VERSION_PREVIEW_AUTHORS_LIST(
159
- /* @__PURE__ */ jsxRuntime.jsx(_private.List, {
160
- values: version.authors.map((author) => /* @__PURE__ */ jsxRuntime.jsx(_private.User, {
158
+ /* @__PURE__ */ jsx(List, {
159
+ values: version.authors.map((author) => /* @__PURE__ */ jsx(User, {
161
160
  userId: author.id,
162
161
  replaceSelf: true
163
162
  }, author.id)),
@@ -167,15 +166,15 @@ const HistoryVersionPreview = react.forwardRef(({ version, onVersionRestore, cla
167
166
  })
168
167
  )
169
168
  }),
170
- /* @__PURE__ */ jsxRuntime.jsx("div", {
169
+ /* @__PURE__ */ jsx("div", {
171
170
  className: "lb-history-version-preview-actions",
172
- children: /* @__PURE__ */ jsxRuntime.jsx(_private.Button, {
171
+ children: /* @__PURE__ */ jsx(Button, {
173
172
  onClick: restore,
174
173
  disabled: !data || !parentEditor,
175
174
  variant: "primary",
176
175
  size: "large",
177
176
  className: "lb-history-version-preview-action",
178
- icon: /* @__PURE__ */ jsxRuntime.jsx(_private.RestoreIcon, {}),
177
+ icon: /* @__PURE__ */ jsx(RestoreIcon, {}),
179
178
  children: $.HISTORY_VERSION_PREVIEW_RESTORE
180
179
  })
181
180
  })
@@ -185,5 +184,5 @@ const HistoryVersionPreview = react.forwardRef(({ version, onVersionRestore, cla
185
184
  });
186
185
  });
187
186
 
188
- exports.HistoryVersionPreview = HistoryVersionPreview;
187
+ export { HistoryVersionPreview };
189
188
  //# sourceMappingURL=history-version-preview.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"history-version-preview.js","sources":["../../src/version-history/history-version-preview.tsx"],"sourcesContent":["import { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport { EditorRefPlugin } from \"@lexical/react/LexicalEditorRefPlugin\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport type { Binding, Provider } from \"@lexical/yjs\";\nimport {\n createBinding,\n syncLexicalUpdateToYjs,\n syncYjsChangesToLexical,\n} from \"@lexical/yjs\";\nimport type { HistoryVersion } from \"@liveblocks/core\";\nimport { useHistoryVersionData } from \"@liveblocks/react\";\nimport { useOverrides } from \"@liveblocks/react-ui\";\nimport {\n Button,\n List,\n RestoreIcon,\n SpinnerIcon,\n User,\n} from \"@liveblocks/react-ui/_private\";\nimport type { LexicalEditor } from \"lexical\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport { forwardRef, useCallback, useEffect, useMemo, useRef } from \"react\";\nimport type { Transaction, YEvent } from \"yjs\";\nimport { applyUpdate, Doc } from \"yjs\";\n\nimport { classNames } from \"../classnames\";\nimport { liveblocksConfig } from \"../liveblocks-config\";\n\nconst AUTHORS_TRUNCATE = 3;\n\nexport interface HistoryVersionPreviewProps\n extends ComponentPropsWithoutRef<\"div\"> {\n version: HistoryVersion;\n onVersionRestore?: (version: HistoryVersion) => void;\n}\n\nfunction createNoOpProvider(): Provider {\n const emptyFunction = () => {};\n\n return {\n awareness: {\n getLocalState: () => null,\n getStates: () => new Map(),\n off: emptyFunction,\n on: emptyFunction,\n setLocalState: emptyFunction,\n },\n connect: emptyFunction,\n disconnect: emptyFunction,\n off: emptyFunction,\n on: emptyFunction,\n };\n}\n\nfunction registerCollaborationListeners(\n editor: LexicalEditor,\n provider: Provider,\n binding: Binding\n): () => void {\n const unsubscribeUpdateListener = editor.registerUpdateListener(\n ({\n dirtyElements,\n dirtyLeaves,\n editorState,\n normalizedNodes,\n prevEditorState,\n tags,\n }) => {\n if (tags.has(\"skip-collab\") === false) {\n syncLexicalUpdateToYjs(\n binding,\n provider,\n prevEditorState,\n editorState,\n dirtyElements,\n dirtyLeaves,\n normalizedNodes,\n tags\n );\n }\n }\n );\n\n const observer = (events: Array<YEvent<any>>, transaction: Transaction) => {\n if (transaction.origin !== binding) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n syncYjsChangesToLexical(binding, provider, events, false);\n }\n };\n\n binding.root.getSharedType().observeDeep(observer);\n\n return () => {\n unsubscribeUpdateListener();\n binding.root.getSharedType().unobserveDeep(observer);\n };\n}\n\n/**\n * Displays a specific version of the current Lexical document.\n *\n * @example\n * <HistoryVersionPreview version={version} />\n */\nexport const HistoryVersionPreview = forwardRef<\n HTMLDivElement,\n HistoryVersionPreviewProps\n>(({ version, onVersionRestore, className, ...props }, forwardedRef) => {\n const [parentEditor, parentContext] = useLexicalComposerContext();\n const editor = useRef<LexicalEditor>();\n const $ = useOverrides();\n const { isLoading, data, error } = useHistoryVersionData(version.id);\n\n const initialConfig = useMemo(() => {\n const nodes = Array.from(parentEditor._nodes.values()).map((n) => n.klass);\n\n return liveblocksConfig({\n namespace: \"VersionPreview\",\n theme: parentContext.getTheme() || {},\n nodes,\n editable: false,\n onError: (err) => console.error(err),\n });\n }, [parentEditor, parentContext]);\n\n useEffect(() => {\n if (error || !data || !editor.current || !data.length) {\n return;\n }\n const doc = new Doc();\n const docMap = new Map([[version.id, doc]]);\n const provider = createNoOpProvider();\n const binding = createBinding(\n editor.current,\n provider,\n version.id,\n doc,\n docMap\n );\n const unsubscribe = registerCollaborationListeners(\n editor.current,\n provider,\n binding\n );\n\n try {\n applyUpdate(doc, data);\n } catch (err) {\n console.warn(err);\n }\n\n return unsubscribe;\n }, [data, version.id, isLoading, error]);\n\n const restore = useCallback(() => {\n if (!editor.current || !parentEditor) {\n return;\n }\n\n parentEditor.setEditorState(editor.current.getEditorState());\n onVersionRestore?.(version);\n }, [parentEditor, onVersionRestore, version]);\n\n return (\n <div\n {...props}\n className={classNames(\n \"lb-root lb-history-version-preview lb-lexical-version-preview\",\n className\n )}\n ref={forwardedRef}\n >\n {isLoading ? (\n <div className=\"lb-loading lb-history-version-preview-loading\">\n <SpinnerIcon />\n </div>\n ) : error ? (\n <div className=\"lb-error lb-history-version-preview-error\">\n {$.HISTORY_VERSION_PREVIEW_ERROR(error)}\n </div>\n ) : (\n <div className=\"lb-history-version-preview-content lb-lexical-editor-container lb-lexical-version-preview-editor-container\">\n <LexicalComposer initialConfig={initialConfig}>\n <EditorRefPlugin editorRef={editor} />\n <RichTextPlugin\n contentEditable={<ContentEditable />}\n placeholder={\n <div className=\"lb-empty lb-history-version-preview-empty\">\n {$.HISTORY_VERSION_PREVIEW_EMPTY}\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n </LexicalComposer>\n </div>\n )}\n <div className=\"lb-history-version-preview-footer\">\n <span className=\"lb-history-version-preview-authors\">\n {$.HISTORY_VERSION_PREVIEW_AUTHORS_LIST(\n <List\n values={version.authors.map((author) => (\n <User key={author.id} userId={author.id} replaceSelf />\n ))}\n formatRemaining={$.LIST_REMAINING_USERS}\n truncate={AUTHORS_TRUNCATE}\n locale={$.locale}\n />\n )}\n </span>\n <div className=\"lb-history-version-preview-actions\">\n <Button\n onClick={restore}\n disabled={!data || !parentEditor}\n variant=\"primary\"\n size=\"large\"\n className=\"lb-history-version-preview-action\"\n icon={<RestoreIcon />}\n >\n {$.HISTORY_VERSION_PREVIEW_RESTORE}\n </Button>\n </div>\n </div>\n </div>\n );\n});\n"],"names":["syncLexicalUpdateToYjs","syncYjsChangesToLexical","forwardRef","useLexicalComposerContext","useRef","useOverrides","useHistoryVersionData","useMemo","liveblocksConfig","useEffect","Doc","createBinding","applyUpdate","useCallback","jsxs","classNames","jsx","SpinnerIcon","LexicalComposer","EditorRefPlugin","RichTextPlugin","ContentEditable","LexicalErrorBoundary","List","User","Button","RestoreIcon"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,MAAM,gBAAmB,GAAA,CAAA,CAAA;AAQzB,SAAS,kBAA+B,GAAA;AACtC,EAAA,MA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AQ,GAAI,CAAA,CAAC,2BAC1BP,cAAA,CAAAQ,aAAA,EAAA;AAAA,kBAAqB,QAAQ,MAAO,CAAA,EAAA;AAAA,kBAAI,WAAW,EAAA,IAAA;AAAA,iBAAzC,EAAA,MAAA,CAAO,EAAmC,CACtD,CAAA;AAAA,gBACD,iBAAiB,CAAE,CAAA,oBAAA;AAAA,gBACnB,QAAU,EAAA,gBAAA;AAAA,gBACV,QAAQ,CAAE,CAAA,MAAA;AAAA,eACZ,CAAA;AAAA,aACF;AAAA,WACF,CAAA;AAAA,0BACCR,cAAA,CAAA,KAAA,EAAA;AAAA,YAAI,SAAU,EAAA,oCAAA;AAAA,YACb,QAAC,kBAAAA,cAAA,CAAAS,eAAA,EAAA;AAAA,cACC,OAAS,EAAA,OAAA;AAAA,cACT,QAAA,EAAU,CAAC,IAAA,IAAQ,CAAC,YAAA;AAAA,cACpB,OAAQ,EAAA,SAAA;AAAA,cACR,IAAK,EAAA,OAAA;AAAA,cACL,SAAU,EAAA,mCAAA;AAAA,cACV,IAAA,iCAAOC,oBAAY,EAAA,EAAA,CAAA;AAAA,cAElB,QAAE,EAAA,CAAA,CAAA,+BAAA;AAAA,aACL,CAAA;AAAA,WACF,CAAA;AAAA,SAAA;AAAA,OACF,CAAA;AAAA,KAAA;AAAA,GACF,CAAA,CAAA;AAEJ,CAAC;;;;"}
1
+ {"version":3,"file":"history-version-preview.js","sources":["../../src/version-history/history-version-preview.tsx"],"sourcesContent":["import { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport { EditorRefPlugin } from \"@lexical/react/LexicalEditorRefPlugin\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport type { Binding, Provider } from \"@lexical/yjs\";\nimport {\n createBinding,\n syncLexicalUpdateToYjs,\n syncYjsChangesToLexical,\n} from \"@lexical/yjs\";\nimport type { HistoryVersion } from \"@liveblocks/core\";\nimport { useHistoryVersionData } from \"@liveblocks/react\";\nimport { useOverrides } from \"@liveblocks/react-ui\";\nimport {\n Button,\n List,\n RestoreIcon,\n SpinnerIcon,\n User,\n} from \"@liveblocks/react-ui/_private\";\nimport type { LexicalEditor } from \"lexical\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport { forwardRef, useCallback, useEffect, useMemo, useRef } from \"react\";\nimport type { Transaction, YEvent } from \"yjs\";\nimport { applyUpdate, Doc } from \"yjs\";\n\nimport { classNames } from \"../classnames\";\nimport { liveblocksConfig } from \"../liveblocks-config\";\n\nconst AUTHORS_TRUNCATE = 3;\n\nexport interface HistoryVersionPreviewProps\n extends ComponentPropsWithoutRef<\"div\"> {\n version: HistoryVersion;\n onVersionRestore?: (version: HistoryVersion) => void;\n}\n\nfunction createNoOpProvider(): Provider {\n const emptyFunction = () => {};\n\n return {\n awareness: {\n getLocalState: () => null,\n setLocalStateField: emptyFunction,\n getStates: () => new Map(),\n off: emptyFunction,\n on: emptyFunction,\n setLocalState: emptyFunction,\n },\n connect: emptyFunction,\n disconnect: emptyFunction,\n off: emptyFunction,\n on: emptyFunction,\n };\n}\n\nfunction registerCollaborationListeners(\n editor: LexicalEditor,\n provider: Provider,\n binding: Binding\n): () => void {\n const unsubscribeUpdateListener = editor.registerUpdateListener(\n ({\n dirtyElements,\n dirtyLeaves,\n editorState,\n normalizedNodes,\n prevEditorState,\n tags,\n }) => {\n if (tags.has(\"skip-collab\") === false) {\n syncLexicalUpdateToYjs(\n binding,\n provider,\n prevEditorState,\n editorState,\n dirtyElements,\n dirtyLeaves,\n normalizedNodes,\n tags\n );\n }\n }\n );\n\n const observer = (events: Array<YEvent<any>>, transaction: Transaction) => {\n if (transaction.origin !== binding) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n syncYjsChangesToLexical(binding, provider, events, false);\n }\n };\n\n binding.root.getSharedType().observeDeep(observer);\n\n return () => {\n unsubscribeUpdateListener();\n binding.root.getSharedType().unobserveDeep(observer);\n };\n}\n\n/**\n * Displays a specific version of the current Lexical document.\n *\n * @example\n * <HistoryVersionPreview version={version} />\n */\nexport const HistoryVersionPreview = forwardRef<\n HTMLDivElement,\n HistoryVersionPreviewProps\n>(({ version, onVersionRestore, className, ...props }, forwardedRef) => {\n const [parentEditor, parentContext] = useLexicalComposerContext();\n const editor = useRef<LexicalEditor>();\n const $ = useOverrides();\n const { isLoading, data, error } = useHistoryVersionData(version.id);\n\n const initialConfig = useMemo(() => {\n const nodes = Array.from(parentEditor._nodes.values()).map((n) => n.klass);\n\n return liveblocksConfig({\n namespace: \"VersionPreview\",\n theme: parentContext.getTheme() || {},\n nodes,\n editable: false,\n onError: (err) => console.error(err),\n });\n }, [parentEditor, parentContext]);\n\n useEffect(() => {\n if (error || !data || !editor.current || !data.length) {\n return;\n }\n const doc = new Doc();\n const docMap = new Map([[version.id, doc]]);\n const provider = createNoOpProvider();\n const binding = createBinding(\n editor.current,\n provider,\n version.id,\n doc,\n docMap\n );\n const unsubscribe = registerCollaborationListeners(\n editor.current,\n provider,\n binding\n );\n\n try {\n applyUpdate(doc, data);\n } catch (err) {\n console.warn(err);\n }\n\n return unsubscribe;\n }, [data, version.id, isLoading, error]);\n\n const restore = useCallback(() => {\n if (!editor.current || !parentEditor) {\n return;\n }\n\n parentEditor.setEditorState(editor.current.getEditorState());\n onVersionRestore?.(version);\n }, [parentEditor, onVersionRestore, version]);\n\n return (\n <div\n {...props}\n className={classNames(\n \"lb-root lb-history-version-preview lb-lexical-version-preview\",\n className\n )}\n ref={forwardedRef}\n >\n {isLoading ? (\n <div className=\"lb-loading lb-history-version-preview-loading\">\n <SpinnerIcon />\n </div>\n ) : error ? (\n <div className=\"lb-error lb-history-version-preview-error\">\n {$.HISTORY_VERSION_PREVIEW_ERROR(error)}\n </div>\n ) : (\n <div className=\"lb-history-version-preview-content lb-lexical-editor-container lb-lexical-version-preview-editor-container\">\n <LexicalComposer initialConfig={initialConfig}>\n <EditorRefPlugin editorRef={editor} />\n <RichTextPlugin\n contentEditable={<ContentEditable />}\n placeholder={\n <div className=\"lb-empty lb-history-version-preview-empty\">\n {$.HISTORY_VERSION_PREVIEW_EMPTY}\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n </LexicalComposer>\n </div>\n )}\n <div className=\"lb-history-version-preview-footer\">\n <span className=\"lb-history-version-preview-authors\">\n {$.HISTORY_VERSION_PREVIEW_AUTHORS_LIST(\n <List\n values={version.authors.map((author) => (\n <User key={author.id} userId={author.id} replaceSelf />\n ))}\n formatRemaining={$.LIST_REMAINING_USERS}\n truncate={AUTHORS_TRUNCATE}\n locale={$.locale}\n />\n )}\n </span>\n <div className=\"lb-history-version-preview-actions\">\n <Button\n onClick={restore}\n disabled={!data || !parentEditor}\n variant=\"primary\"\n size=\"large\"\n className=\"lb-history-version-preview-action\"\n icon={<RestoreIcon />}\n >\n {$.HISTORY_VERSION_PREVIEW_RESTORE}\n </Button>\n </div>\n </div>\n </div>\n );\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA+BA,MAAM,gBAAmB,GAAA,CAAA,CAAA;AAQzB,SAAS,kBAA+B,GAAA;AACtC,EAAA,MAAM,gBAAgB,MAAM;AAAA,GAAC,CAAA;AAE7B,EAAO,OAAA;AAAA,IACL,SAAW,EAAA;AAAA,MACT,eAAe,MAAM,IAAA;AAAA,MACrB,kBAAoB,EAAA,aAAA;AAAA,MACpB,SAAA,EAAW,sBAAM,IAAI,GAAI,EAAA;AAAA,MACzB,GAAK,EAAA,aAAA;AAAA,MACL,EAAI,EAAA,aAAA;AAAA,MACJ,aAAe,EAAA,aAAA;AAAA,KACjB;AAAA,IACA,OAAS,EAAA,aAAA;AAAA,IACT,UAAY,EAAA,aAAA;AAAA,IACZ,GAAK,EAAA,aAAA;AAAA,IACL,EAAI,EAAA,aAAA;AAAA,GACN,CAAA;AACF,CAAA;AA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A,cACC,OAAS,EAAA,OAAA;AAAA,cACT,QAAA,EAAU,CAAC,IAAA,IAAQ,CAAC,YAAA;AAAA,cACpB,OAAQ,EAAA,SAAA;AAAA,cACR,IAAK,EAAA,OAAA;AAAA,cACL,SAAU,EAAA,mCAAA;AAAA,cACV,IAAA,sBAAO,WAAY,EAAA,EAAA,CAAA;AAAA,cAElB,QAAE,EAAA,CAAA,CAAA,+BAAA;AAAA,aACL,CAAA;AAAA,WACF,CAAA;AAAA,SAAA;AAAA,OACF,CAAA;AAAA,KAAA;AAAA,GACF,CAAA,CAAA;AAEJ,CAAC;;;;"}
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ const PKG_NAME = "@liveblocks/react-lexical";
4
+ const PKG_VERSION = typeof "2.18.4-uns1" === "string" && "2.18.4-uns1";
5
+ const PKG_FORMAT = typeof "cjs" === "string" && "cjs";
6
+
7
+ exports.PKG_FORMAT = PKG_FORMAT;
8
+ exports.PKG_NAME = PKG_NAME;
9
+ exports.PKG_VERSION = PKG_VERSION;
10
+ //# sourceMappingURL=version.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-lexical\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":"AAGO,MAAM,QAAW,GAAA,4BAAA;AACX,MAAA,WAAA,GAAc,OAAO,QAAA,KAAgB,QAAY,IAAA,SAAA;AACjD,MAAA,UAAA,GAAa,OAAO,KAAA,KAAkB,QAAY,IAAA;;;;"}
1
+ {"version":3,"file":"version.cjs","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-lexical\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":";;AAGO,MAAM,QAAW,GAAA,4BAAA;AACX,MAAA,WAAA,GAAc,OAAO,aAAA,KAAgB,QAAY,IAAA,cAAA;AACjD,MAAA,UAAA,GAAa,OAAO,KAAA,KAAkB,QAAY,IAAA;;;;;;"}
package/dist/version.js CHANGED
@@ -1,10 +1,6 @@
1
- 'use strict';
2
-
3
1
  const PKG_NAME = "@liveblocks/react-lexical";
4
- const PKG_VERSION = typeof "2.18.2" === "string" && "2.18.2";
5
- const PKG_FORMAT = typeof "cjs" === "string" && "cjs";
2
+ const PKG_VERSION = typeof "2.18.4-uns1" === "string" && "2.18.4-uns1";
3
+ const PKG_FORMAT = typeof "esm" === "string" && "esm";
6
4
 
7
- exports.PKG_FORMAT = PKG_FORMAT;
8
- exports.PKG_NAME = PKG_NAME;
9
- exports.PKG_VERSION = PKG_VERSION;
5
+ export { PKG_FORMAT, PKG_NAME, PKG_VERSION };
10
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-lexical\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":";;AAGO,MAAM,QAAW,GAAA,4BAAA;AACX,MAAA,WAAA,GAAc,OAAO,QAAA,KAAgB,QAAY,IAAA,SAAA;AACjD,MAAA,UAAA,GAAa,OAAO,KAAA,KAAkB,QAAY,IAAA;;;;;;"}
1
+ {"version":3,"file":"version.js","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-lexical\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":"AAGO,MAAM,QAAW,GAAA,4BAAA;AACX,MAAA,WAAA,GAAc,OAAO,aAAA,KAAgB,QAAY,IAAA,cAAA;AACjD,MAAA,UAAA,GAAa,OAAO,KAAA,KAAkB,QAAY,IAAA;;;;"}
package/package.json CHANGED
@@ -1,38 +1,39 @@
1
1
  {
2
2
  "name": "@liveblocks/react-lexical",
3
- "version": "2.18.2",
3
+ "version": "2.18.4-uns1",
4
4
  "description": "A lexical react plugin to enable collaboration, comments, live cursors, and more.",
5
5
  "license": "Apache-2.0",
6
- "type": "commonjs",
7
- "main": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "types": "./dist/index.d.cts",
9
9
  "exports": {
10
10
  ".": {
11
11
  "import": {
12
- "types": "./dist/index.d.mts",
13
- "default": "./dist/index.mjs"
14
- },
15
- "require": {
16
12
  "types": "./dist/index.d.ts",
17
- "module": "./dist/index.mjs",
18
13
  "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "module": "./dist/index.js",
18
+ "default": "./dist/index.cjs"
19
19
  }
20
20
  },
21
21
  "./styles.css": {
22
- "types": "./styles.css.d.ts",
22
+ "types": "./styles.css.d.cts",
23
23
  "default": "./styles.css"
24
24
  }
25
25
  },
26
26
  "files": [
27
27
  "dist/**",
28
28
  "**/*.css",
29
+ "**/*.css.d.cts",
29
30
  "**/*.css.d.ts",
30
31
  "**/*.css.map",
31
32
  "README.md"
32
33
  ],
33
34
  "scripts": {
34
- "dev": "rollup --config rollup.config.mjs --watch",
35
- "build": "rollup --config rollup.config.mjs",
35
+ "dev": "rollup --config rollup.config.js --watch",
36
+ "build": "rollup --config rollup.config.js",
36
37
  "format": "eslint --fix src/; stylelint --fix src/styles/; prettier --write src/",
37
38
  "lint": "eslint src/; stylelint src/styles/",
38
39
  "lint:package": "publint --strict && attw --pack",
@@ -42,22 +43,22 @@
42
43
  },
43
44
  "dependencies": {
44
45
  "@floating-ui/react-dom": "^2.1.1",
45
- "@liveblocks/client": "2.18.2",
46
- "@liveblocks/core": "2.18.2",
47
- "@liveblocks/react": "2.18.2",
48
- "@liveblocks/react-ui": "2.18.2",
49
- "@liveblocks/yjs": "2.18.2",
46
+ "@liveblocks/client": "2.18.4-uns1",
47
+ "@liveblocks/core": "2.18.4-uns1",
48
+ "@liveblocks/react": "2.18.4-uns1",
49
+ "@liveblocks/react-ui": "2.18.4-uns1",
50
+ "@liveblocks/yjs": "2.18.4-uns1",
50
51
  "@radix-ui/react-select": "^2.1.2",
51
52
  "@radix-ui/react-toggle": "^1.1.0",
52
53
  "yjs": "^13.6.18"
53
54
  },
54
55
  "peerDependencies": {
55
- "@lexical/react": "0.16.1",
56
- "@lexical/rich-text": "0.16.1",
57
- "@lexical/selection": "0.16.1",
58
- "@lexical/utils": "0.16.1",
59
- "@lexical/yjs": "0.16.1",
60
- "lexical": "0.16.1",
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",
61
+ "lexical": "0.24.0",
61
62
  "react": "^18 || ^19 || ^19.0.0-rc",
62
63
  "react-dom": "^18 || ^19 || ^19.0.0-rc"
63
64
  },
@@ -0,0 +1 @@
1
+ declare module "@liveblocks/react-lexical/styles.css";
@@ -1,21 +0,0 @@
1
- import { $isTextNode } from 'lexical';
2
- import { $isThreadMarkNode } from './thread-mark-node.mjs';
3
-
4
- function $getThreadMarkIds(node, offset) {
5
- let currentNode = node;
6
- while (currentNode !== null) {
7
- if ($isThreadMarkNode(currentNode)) {
8
- return currentNode.getIDs();
9
- } else if ($isTextNode(currentNode) && offset === currentNode.getTextContentSize()) {
10
- const nextSibling = currentNode.getNextSibling();
11
- if ($isThreadMarkNode(nextSibling)) {
12
- return nextSibling.getIDs();
13
- }
14
- }
15
- currentNode = currentNode.getParent();
16
- }
17
- return null;
18
- }
19
-
20
- export { $getThreadMarkIds as default };
21
- //# sourceMappingURL=get-thread-mark-ids.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unwrap-thread-mark-node.mjs","sources":["../../src/comments/unwrap-thread-mark-node.ts"],"sourcesContent":["import type { ThreadMarkNode } from \"./thread-mark-node\";\n\nexport default function $unwrapThreadMarkNode(node: ThreadMarkNode): void {\n const children = node.getChildren();\n let target = null;\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (target === null) {\n node.insertBefore(child);\n } else {\n target.insertAfter(child);\n }\n target = child;\n }\n node.remove();\n}\n"],"names":[],"mappings":"AAEA,SAAwB,sBAAsB,IAA4B,EAAA;AACxE,EAAM,MAAA,QAAA,GAAW,KAAK,WAAY,EAAA,CAAA;AAClC,EAAA,IAAI,MAAS,GAAA,IAAA,CAAA;AACb,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,QAAA,CAAS,QAAQ,CAAK,EAAA,EAAA;AACxC,IAAA,MAAM,QAAQ,QAAS,CAAA,CAAA,CAAA,CAAA;AACvB,IAAA,IAAI,WAAW,IAAM,EAAA;AACnB,MAAA,IAAA,CAAK,aAAa,KAAK,CAAA,CAAA;AAAA,KAClB,MAAA;AACL,MAAA,MAAA,CAAO,YAAY,KAAK,CAAA,CAAA;AAAA,KAC1B;AACA,IAAS,MAAA,GAAA,KAAA,CAAA;AAAA,GACX;AACA,EAAA,IAAA,CAAK,MAAO,EAAA,CAAA;AACd;;;;"}
package/dist/index.mjs DELETED
@@ -1,16 +0,0 @@
1
- import { detectDupes } from '@liveblocks/core';
2
- import { PKG_NAME, PKG_VERSION, PKG_FORMAT } from './version.mjs';
3
- export { AnchoredThreads } from './comments/anchored-threads.mjs';
4
- export { useIsThreadActive } from './comments/comment-plugin-provider.mjs';
5
- export { FloatingComposer, OPEN_FLOATING_COMPOSER_COMMAND } from './comments/floating-composer.mjs';
6
- export { FloatingThreads } from './comments/floating-threads.mjs';
7
- export { isBlockNodeActive } from './is-block-node-active.mjs';
8
- export { isTextFormatActive } from './is-text-format-active.mjs';
9
- export { liveblocksConfig } from './liveblocks-config.mjs';
10
- export { LiveblocksPlugin, useEditorStatus, useIsEditorReady } from './liveblocks-plugin-provider.mjs';
11
- export { FloatingToolbar } from './toolbar/floating-toolbar.mjs';
12
- export { Toolbar } from './toolbar/toolbar.mjs';
13
- export { HistoryVersionPreview } from './version-history/history-version-preview.mjs';
14
-
15
- detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
16
- //# sourceMappingURL=index.mjs.map
@@ -1,9 +0,0 @@
1
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
2
-
3
- function useIsCommandRegistered(command) {
4
- const [editor] = useLexicalComposerContext();
5
- return editor._commands.has(command);
6
- }
7
-
8
- export { useIsCommandRegistered };
9
- //# sourceMappingURL=is-command-registered.mjs.map
@@ -1,14 +0,0 @@
1
- import { $getSelection, $isRangeSelection } from 'lexical';
2
-
3
- function isTextFormatActive(editor, format) {
4
- return editor.getEditorState().read(() => {
5
- const selection = $getSelection();
6
- if (!$isRangeSelection(selection) || selection.isCollapsed()) {
7
- return false;
8
- }
9
- return selection.hasFormat(format);
10
- });
11
- }
12
-
13
- export { isTextFormatActive };
14
- //# sourceMappingURL=is-text-format-active.mjs.map
@@ -1,15 +0,0 @@
1
- import { ThreadMarkNode } from './comments/thread-mark-node.mjs';
2
- import { MentionNode } from './mentions/mention-node.mjs';
3
-
4
- function liveblocksConfig(editorConfig) {
5
- const nodes = [...editorConfig.nodes ?? []];
6
- nodes.push(ThreadMarkNode, MentionNode);
7
- return {
8
- ...editorConfig,
9
- nodes,
10
- editorState: null
11
- };
12
- }
13
-
14
- export { liveblocksConfig };
15
- //# sourceMappingURL=liveblocks-config.mjs.map
@@ -1,164 +0,0 @@
1
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
- import { useFloating, autoUpdate } from '@floating-ui/react-dom';
3
- import { CollaborationPlugin } from '@lexical/react/LexicalCollaborationPlugin';
4
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
5
- import { TextEditorType, nn } from '@liveblocks/core';
6
- import { useRoom, useSelf } from '@liveblocks/react';
7
- import { useYjsProvider, useResolveMentionSuggestions, useReportTextEditor, useLayoutEffect } from '@liveblocks/react/_private';
8
- import { LiveblocksYjsProvider } from '@liveblocks/yjs';
9
- import { useCallback, useSyncExternalStore, useRef, useState, useEffect } from 'react';
10
- import { Doc } from 'yjs';
11
- import { CommentPluginProvider } from './comments/comment-plugin-provider.mjs';
12
- import { ThreadMarkNode } from './comments/thread-mark-node.mjs';
13
- import { MentionNode } from './mentions/mention-node.mjs';
14
- import { MentionPlugin } from './mentions/mention-plugin.mjs';
15
- import { useRootElement } from './use-root-element.mjs';
16
-
17
- const providersMap = /* @__PURE__ */ new Map();
18
- function useEditorStatus() {
19
- const provider = useYjsProvider();
20
- const subscribe = useCallback(
21
- (onStoreChange) => {
22
- if (provider === void 0)
23
- return () => {
24
- };
25
- provider.on("status", onStoreChange);
26
- return () => {
27
- provider.off("status", onStoreChange);
28
- };
29
- },
30
- [provider]
31
- );
32
- const getSnapshot = useCallback(() => {
33
- if (provider === void 0) {
34
- return "not-loaded";
35
- }
36
- return provider.getStatus();
37
- }, [provider]);
38
- return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
39
- }
40
- function useIsEditorReady() {
41
- const yjsProvider = useYjsProvider();
42
- const getSnapshot = useCallback(() => {
43
- const status = yjsProvider?.getStatus();
44
- return status === "synchronizing" || status === "synchronized";
45
- }, [yjsProvider]);
46
- const subscribe = useCallback(
47
- (callback) => {
48
- if (yjsProvider === void 0)
49
- return () => {
50
- };
51
- yjsProvider.on("status", callback);
52
- return () => {
53
- yjsProvider.off("status", callback);
54
- };
55
- },
56
- [yjsProvider]
57
- );
58
- return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
59
- }
60
- const LiveblocksPlugin = ({
61
- children
62
- }) => {
63
- const isResolveMentionSuggestionsDefined = useResolveMentionSuggestions() !== void 0;
64
- const [editor] = useLexicalComposerContext();
65
- const room = useRoom();
66
- const previousRoomIdRef = useRef(null);
67
- if (!editor.hasNodes([ThreadMarkNode, MentionNode])) {
68
- throw new Error(
69
- "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"
70
- );
71
- }
72
- const [containerRef, setContainerRef] = useState(void 0);
73
- const {
74
- refs: { setReference, setFloating },
75
- strategy,
76
- x,
77
- y
78
- } = useFloating({
79
- strategy: "fixed",
80
- placement: "bottom",
81
- whileElementsMounted: (...args) => {
82
- return autoUpdate(...args, {
83
- animationFrame: true
84
- });
85
- }
86
- });
87
- useEffect(() => {
88
- if (process.env.NODE_ENV !== "production") {
89
- if (!editor.getEditorState().isEmpty()) {
90
- console.warn(
91
- "Warning: LiveblocksPlugin: editorState in initialConfig detected, but must be null."
92
- );
93
- }
94
- }
95
- }, []);
96
- useReportTextEditor(TextEditorType.Lexical, "root");
97
- const self = useSelf();
98
- const providerFactory = useCallback(
99
- (id, yjsDocMap) => {
100
- if (previousRoomIdRef.current !== null && previousRoomIdRef.current !== id) {
101
- const previousProvider = providersMap.get(id);
102
- if (previousProvider !== void 0) {
103
- previousProvider.destroy();
104
- }
105
- }
106
- let doc = yjsDocMap.get(id);
107
- if (doc === void 0) {
108
- doc = new Doc();
109
- const provider = new LiveblocksYjsProvider(room, doc);
110
- yjsDocMap.set(id, doc);
111
- providersMap.set(id, provider);
112
- }
113
- return nn(
114
- providersMap.get(id),
115
- "Internal error. Should never happen"
116
- );
117
- },
118
- [room]
119
- );
120
- const root = useRootElement();
121
- useLayoutEffect(() => {
122
- if (root === null)
123
- return;
124
- setReference({
125
- getBoundingClientRect: () => root.getBoundingClientRect()
126
- });
127
- }, [setReference, root]);
128
- const handleFloatingRef = useCallback(
129
- (node) => {
130
- setFloating(node);
131
- setContainerRef({ current: node });
132
- },
133
- [setFloating, setContainerRef]
134
- );
135
- return /* @__PURE__ */ jsxs(Fragment, {
136
- children: [
137
- /* @__PURE__ */ jsx("div", {
138
- ref: handleFloatingRef,
139
- style: {
140
- position: strategy,
141
- top: 0,
142
- left: 0,
143
- transform: `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)`,
144
- minWidth: "max-content"
145
- }
146
- }),
147
- self && /* @__PURE__ */ jsx(CollaborationPlugin, {
148
- id: room.id,
149
- providerFactory,
150
- username: self.info?.name ?? "",
151
- cursorColor: self.info?.color,
152
- cursorsContainerRef: containerRef,
153
- shouldBootstrap: true
154
- }, room.id),
155
- isResolveMentionSuggestionsDefined && /* @__PURE__ */ jsx(MentionPlugin, {}),
156
- /* @__PURE__ */ jsx(CommentPluginProvider, {
157
- children
158
- })
159
- ]
160
- });
161
- };
162
-
163
- export { LiveblocksPlugin, useEditorStatus, useIsEditorReady };
164
- //# sourceMappingURL=liveblocks-plugin-provider.mjs.map