@collabchron/notiq 1.1.11 → 1.2.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.
Files changed (152) hide show
  1. package/dist/AICommandBarPlugin-ZEC755KY.mjs +27 -0
  2. package/dist/{AIDialog-2WZUFWSC.mjs → AIDialog-HJW6PQPR.mjs} +12 -13
  3. package/dist/{AudioComponent-CKLMLB5T.mjs → AudioComponent-W5XMZPQB.mjs} +10 -6
  4. package/dist/{DynamicBlockComponent-2LOADZUX.mjs → DynamicBlockComponent-CHRL2GAQ.mjs} +7 -6
  5. package/dist/{EquationComponent-4NFG55NQ.mjs → EquationComponent-GNQHG53L.mjs} +26 -7
  6. package/dist/{ExcalidrawComponent-SIMURTCA.mjs → ExcalidrawComponent-POMYXDSG.mjs} +34 -7
  7. package/dist/{FileComponent-Y56MX5QD.mjs → FileComponent-EOVCH4V5.mjs} +9 -5
  8. package/dist/{HintComponet-ET7M2Q7S.mjs → HintComponet-QXL5ESND.mjs} +32 -8
  9. package/dist/{InlineImageComponent-FVTA4LXZ.mjs → InlineImageComponent-KDN3VGZC.mjs} +8 -3
  10. package/dist/{StoryBuilderComponent-WQSNFPMM.mjs → StoryBuilderComponent-CBRFPFTR.mjs} +9 -10
  11. package/dist/{chunk-6UVNHT3T.mjs → chunk-4SYRK2NH.mjs} +23 -1
  12. package/dist/chunk-5CJZC5IB.mjs +9086 -0
  13. package/dist/{chunk-MW6MAUY3.mjs → chunk-6NK5DONB.mjs} +1 -1
  14. package/dist/{chunk-N6ILV6NF.mjs → chunk-ACW4DLVO.mjs} +21 -7
  15. package/dist/chunk-BCGD2YXP.mjs +574 -0
  16. package/dist/{chunk-TC3IISJZ.mjs → chunk-BTR3TPIN.mjs} +18 -5
  17. package/dist/{chunk-XAVQAXOJ.mjs → chunk-CQCS5YPS.mjs} +3 -5
  18. package/dist/{chunk-YTLUQJE2.mjs → chunk-D4UBNSUW.mjs} +1 -1
  19. package/dist/{chunk-KNW2CGIP.mjs → chunk-DBRZIA43.mjs} +4 -1
  20. package/dist/{chunk-CDAMHK63.mjs → chunk-GJK2L7ZM.mjs} +23 -2
  21. package/dist/{chunk-GYYLZ3MQ.mjs → chunk-IKYVBTCJ.mjs} +43 -20
  22. package/dist/chunk-IXRA5D53.mjs +10447 -0
  23. package/dist/{chunk-W6VQSFE5.mjs → chunk-J2CEQXG4.mjs} +1 -1
  24. package/dist/{chunk-43Z4Z2KD.mjs → chunk-JTNLN4JI.mjs} +1 -1
  25. package/dist/{chunk-OE5JRLCN.mjs → chunk-ONOHG5NB.mjs} +6 -4
  26. package/dist/{chunk-XZXGYNTY.mjs → chunk-OO42URWA.mjs} +27 -6
  27. package/dist/chunk-PBVRSNGU.mjs +129 -0
  28. package/dist/chunk-QCS57TIF.mjs +1794 -0
  29. package/dist/chunk-RNEIJRUS.mjs +60 -0
  30. package/dist/chunk-TJPTGECP.mjs +1556 -0
  31. package/dist/{chunk-XYMXGU4T.mjs → chunk-TMYRA2W4.mjs} +1 -1
  32. package/dist/{chunk-ZFV2HGD3.mjs → chunk-UNEFOZTS.mjs} +1 -1
  33. package/dist/chunk-X4NI7EQS.mjs +282 -0
  34. package/dist/chunk-XAJ4GACN.mjs +746 -0
  35. package/dist/{chunk-7QRJVZQY.mjs → chunk-YVUQRJVV.mjs} +63 -18
  36. package/dist/components/editor/Core.d.ts +15 -2
  37. package/dist/components/editor/index.d.ts +16 -5
  38. package/dist/components/editor/nodes/EquationNode/EquationNode.d.ts +1 -0
  39. package/dist/components/editor/nodes/Hint/index.d.ts +2 -1
  40. package/dist/components/editor/plugins/AICommandBarPlugin/index.d.ts +73 -1
  41. package/dist/components/editor/plugins/DraggableBlockPlugin/index.d.ts +25 -3
  42. package/dist/components/editor/plugins/InlineCopilotPlugin/index.d.ts +16 -3
  43. package/dist/components/editor/plugins/LinkWithMetaData/index.d.ts +20 -25
  44. package/dist/components/editor/plugins/MarkdownPastePlugin/index.d.ts +5 -0
  45. package/dist/components/editor/plugins/MarkdownTransformers/index.d.ts +2 -0
  46. package/dist/components/editor/plugins/SlashCommand/index.d.ts +18 -1
  47. package/dist/components/editor/plugins/SmartTypographyPlugin/index.d.ts +26 -0
  48. package/dist/components/editor/utils/aiStream.d.ts +27 -0
  49. package/dist/components/editor/utils/excalidrawDiagramBuilder.d.ts +29 -0
  50. package/dist/components/editor/utils/markdownTransformers.d.ts +4 -1
  51. package/dist/components/editor/utils/url.d.ts +16 -4
  52. package/dist/components/providers/AIContext.d.ts +8 -0
  53. package/dist/components/ui/equation/equationTypography.d.ts +23 -0
  54. package/dist/core/extension.d.ts +3 -1
  55. package/dist/core/extensions/blocks-kit.d.ts +22 -1
  56. package/dist/core/extensions/copilot-and-collab.d.ts +15 -1
  57. package/dist/core/index.d.ts +2 -1
  58. package/dist/core/react/NotiqContent.d.ts +4 -1
  59. package/dist/core/react/NotiqEditor.d.ts +8 -8
  60. package/dist/core/react/index.d.ts +1 -0
  61. package/dist/core/react/node-renderers.d.ts +73 -0
  62. package/dist/core/types.d.ts +1 -0
  63. package/dist/core.js +18136 -9084
  64. package/dist/core.mjs +58 -44
  65. package/dist/hooks/instructions-messages.d.ts +13 -4
  66. package/dist/{image-TPW7PZZK.mjs → image-AL6PHM2A.mjs} +18 -13
  67. package/dist/index.js +15180 -12858
  68. package/dist/index.mjs +121 -1641
  69. package/dist/{insert-audio-C66RZRKY.mjs → insert-audio-CRWR7EO5.mjs} +6 -8
  70. package/dist/{insert-file-3DTGRO7W.mjs → insert-file-I73AZW3L.mjs} +6 -8
  71. package/dist/{insert-gif-FIMCCBAI.mjs → insert-gif-KWRC3ACT.mjs} +4 -4
  72. package/dist/{insert-image-CZV6HWQZ.mjs → insert-image-XIY6BGW5.mjs} +6 -5
  73. package/dist/{insert-poll-6BCIFY5G.mjs → insert-poll-J5YVZNZ4.mjs} +4 -3
  74. package/dist/{insert-table-ZRJP6X52.mjs → insert-table-OIMJRFFK.mjs} +1 -1
  75. package/dist/{poll-component-VHMM5KKZ.mjs → poll-component-TVHXIKGQ.mjs} +3 -2
  76. package/dist/react.js +17933 -9531
  77. package/dist/react.mjs +41 -34
  78. package/dist/{stepper-4AO5XMO7.mjs → stepper-ILF7YXTO.mjs} +64 -74
  79. package/dist/styles/notiq.css +1 -1
  80. package/package.json +2 -2
  81. package/src/styles/notiq.css +20 -0
  82. package/dist/AICommandBarPlugin-TADJ3X2Y.mjs +0 -12
  83. package/dist/CodeActionMenuPlugin-MRKY67ED.mjs +0 -14
  84. package/dist/CollaborationPlugin-TIZOQBUT.mjs +0 -405
  85. package/dist/CollaboratorsBar-TMKBOBJI.mjs +0 -20
  86. package/dist/CommentsPlugin-5M4RD6YO.mjs +0 -19
  87. package/dist/ExcalidrawPlugin-2SGPIQ6U.mjs +0 -14
  88. package/dist/ExportPlugin-OKZOLBGS.mjs +0 -42
  89. package/dist/FloatingLinkEditorPlugin-MABB34L7.mjs +0 -12
  90. package/dist/FloatingTextFormatToolbarPlugin-SO5VON7Q.mjs +0 -45
  91. package/dist/InlineCopilotPlugin-PNS5Y6OO.mjs +0 -360
  92. package/dist/MobileToolbar-JKP2MLQJ.mjs +0 -984
  93. package/dist/SlashCommand-2TNOOUBM.mjs +0 -39
  94. package/dist/TableCellActionMenuPlugin-YWBA64J7.mjs +0 -838
  95. package/dist/TableHoverActionsPlugin-2EIXHEXN.mjs +0 -265
  96. package/dist/TemplatePlugin-HNTPEXBB.mjs +0 -9
  97. package/dist/ToolbarPlugin-IIAOU4P5.mjs +0 -35
  98. package/dist/VersionHistoryPlugin-23MAZB4G.mjs +0 -371
  99. package/dist/background-color-OZJCBYCT.mjs +0 -425
  100. package/dist/block-format-MTSIXWID.mjs +0 -14
  101. package/dist/chunk-2KESP7OU.mjs +0 -809
  102. package/dist/chunk-3AHNLIME.mjs +0 -1701
  103. package/dist/chunk-3IILA3IP.mjs +0 -28
  104. package/dist/chunk-4DVIYZVB.mjs +0 -193
  105. package/dist/chunk-4FFTOZGJ.mjs +0 -103
  106. package/dist/chunk-4UMUPCDK.mjs +0 -68
  107. package/dist/chunk-6D6QLRYR.mjs +0 -238
  108. package/dist/chunk-6SRMKQSD.mjs +0 -682
  109. package/dist/chunk-ACV47ZKE.mjs +0 -201
  110. package/dist/chunk-AYNKORDO.mjs +0 -6
  111. package/dist/chunk-BGV62GC2.mjs +0 -26
  112. package/dist/chunk-D3IOUQFR.mjs +0 -441
  113. package/dist/chunk-EEBA6OAH.mjs +0 -59
  114. package/dist/chunk-EIZMKFHF.mjs +0 -32
  115. package/dist/chunk-EVPWKNE4.mjs +0 -27
  116. package/dist/chunk-FMJ7DGWP.mjs +0 -144
  117. package/dist/chunk-FYLRS4BG.mjs +0 -88
  118. package/dist/chunk-HOZ4QRFV.mjs +0 -536
  119. package/dist/chunk-IAFCQV3Z.mjs +0 -349
  120. package/dist/chunk-IU2N42JJ.mjs +0 -1763
  121. package/dist/chunk-J6ZUY5BY.mjs +0 -202
  122. package/dist/chunk-K5OAFEVY.mjs +0 -191
  123. package/dist/chunk-KDA7ZYMJ.mjs +0 -431
  124. package/dist/chunk-KXRLARGI.mjs +0 -26
  125. package/dist/chunk-LAUAYRPC.mjs +0 -944
  126. package/dist/chunk-LLCP7NVE.mjs +0 -449
  127. package/dist/chunk-LU2XWLOE.mjs +0 -219
  128. package/dist/chunk-MPTE332I.mjs +0 -787
  129. package/dist/chunk-MTQZWJHR.mjs +0 -111
  130. package/dist/chunk-OXWTZV3U.mjs +0 -174
  131. package/dist/chunk-PD5K4AGP.mjs +0 -64
  132. package/dist/chunk-PFH63ZU4.mjs +0 -33
  133. package/dist/chunk-PHRVYPVM.mjs +0 -808
  134. package/dist/chunk-R7WFRENU.mjs +0 -262
  135. package/dist/chunk-RAVYEEIC.mjs +0 -36
  136. package/dist/chunk-RJQTA6HG.mjs +0 -358
  137. package/dist/chunk-SAOJHVPE.mjs +0 -153
  138. package/dist/chunk-VGAX6YEY.mjs +0 -399
  139. package/dist/chunk-W6GAJXUS.mjs +0 -334
  140. package/dist/chunk-XYDBUQ6Z.mjs +0 -1978
  141. package/dist/chunk-XYT6XM5S.mjs +0 -496
  142. package/dist/chunk-YDDBQZ77.mjs +0 -409
  143. package/dist/chunk-YE7M2VKR.mjs +0 -132
  144. package/dist/chunk-Z6JAFF55.mjs +0 -555
  145. package/dist/chunk-ZKZ7MLSS.mjs +0 -165
  146. package/dist/color-23323E3B.mjs +0 -13
  147. package/dist/font-IJKFR4BM.mjs +0 -12
  148. package/dist/font-size-GTL6UVQL.mjs +0 -15
  149. package/dist/insert-node-MA3FXEYN.mjs +0 -245
  150. package/dist/table-dropdown-4VCRSQB6.mjs +0 -391
  151. package/dist/text-align-CSDLJUDA.mjs +0 -121
  152. package/dist/text-format-6L5N3CHZ.mjs +0 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@collabchron/notiq",
3
- "version": "1.1.11",
3
+ "version": "1.2.0",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -228,4 +228,4 @@
228
228
  "overrides": {
229
229
  "yjs": "13.6.33"
230
230
  }
231
- }
231
+ }
@@ -1313,3 +1313,23 @@ select {
1313
1313
  background-image: radial-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px);
1314
1314
  background-size: 24px 24px;
1315
1315
  }
1316
+
1317
+ /* AI In-Canvas Streaming Caret & Highlight */
1318
+ @keyframes notiq-ai-pulse {
1319
+ 0%, 100% {
1320
+ opacity: 1;
1321
+ transform: scale(1);
1322
+ }
1323
+ 50% {
1324
+ opacity: 0.35;
1325
+ transform: scale(0.82);
1326
+ }
1327
+ }
1328
+
1329
+ .notiq-ai-caret {
1330
+ display: inline-block;
1331
+ animation: notiq-ai-pulse 1s ease-in-out infinite;
1332
+ color: #7c3aed;
1333
+ margin-left: 3px;
1334
+ vertical-align: middle;
1335
+ }
@@ -1,12 +0,0 @@
1
- "use client";
2
- import {
3
- AICommandBarPlugin,
4
- OPEN_AI_COMMAND_BAR_COMMAND
5
- } from "./chunk-HOZ4QRFV.mjs";
6
- import "./chunk-OE5JRLCN.mjs";
7
- import "./chunk-JHXDLYEV.mjs";
8
- import "./chunk-WYCFGRFJ.mjs";
9
- export {
10
- OPEN_AI_COMMAND_BAR_COMMAND,
11
- AICommandBarPlugin as default
12
- };
@@ -1,14 +0,0 @@
1
- import {
2
- CodeActionMenuPlugin
3
- } from "./chunk-XYT6XM5S.mjs";
4
- import "./chunk-3IILA3IP.mjs";
5
- import "./chunk-EEBA6OAH.mjs";
6
- import "./chunk-LU2XWLOE.mjs";
7
- import "./chunk-H3P47YXJ.mjs";
8
- import "./chunk-OE5JRLCN.mjs";
9
- import "./chunk-IIVB6JNE.mjs";
10
- import "./chunk-JHXDLYEV.mjs";
11
- import "./chunk-WYCFGRFJ.mjs";
12
- export {
13
- CodeActionMenuPlugin as default
14
- };
@@ -1,405 +0,0 @@
1
- "use client";
2
- import {
3
- useCollab
4
- } from "./chunk-RJQTA6HG.mjs";
5
- import {
6
- __spreadProps,
7
- __spreadValues,
8
- init_react_shim
9
- } from "./chunk-WYCFGRFJ.mjs";
10
-
11
- // src/components/editor/plugins/CollaborationPlugin/index.tsx
12
- init_react_shim();
13
- import { useCallback, useEffect, useMemo, useRef } from "react";
14
- import { CollaborationPlugin as LexicalCollaborationPlugin } from "@lexical/react/LexicalCollaborationPlugin";
15
- import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
16
- import { CONNECTED_COMMAND } from "@lexical/yjs";
17
- import { COMMAND_PRIORITY_LOW } from "lexical";
18
- import { WebsocketProvider } from "y-websocket";
19
- import { IndexeddbPersistence } from "y-indexeddb";
20
- import { Doc } from "yjs";
21
- import { jsx } from "react/jsx-runtime";
22
- if (typeof globalThis !== "undefined") {
23
- globalThis["__ $YJS$ __"] = void 0;
24
- }
25
- var COLLAB_EXCLUDED_PROPERTIES = /* @__PURE__ */ new Map([
26
- ["stepper", /* @__PURE__ */ new Set(["__steps"])],
27
- ["hint", /* @__PURE__ */ new Set(["__caption"])],
28
- ["link-with-metadata", /* @__PURE__ */ new Set(["__editor", "__metadata"])],
29
- ["poll", /* @__PURE__ */ new Set(["__options"])],
30
- ["story-builder", /* @__PURE__ */ new Set(["__nodes"])],
31
- ["dynamic-block", /* @__PURE__ */ new Set(["__payload"])]
32
- ]);
33
- function safeDisconnect(provider) {
34
- var _a, _b;
35
- if (!provider) return;
36
- try {
37
- const ws = provider.ws;
38
- if (ws) {
39
- if (ws.readyState === 0) {
40
- ws.onopen = () => {
41
- try {
42
- ws.close(1e3, "Clean close");
43
- } catch (e) {
44
- }
45
- };
46
- ws.onclose = null;
47
- ws.onerror = () => {
48
- };
49
- provider.ws = null;
50
- provider.wsconnecting = false;
51
- return;
52
- }
53
- }
54
- (_b = (_a = provider.__rawDisconnect) == null ? void 0 : _a.call(provider)) != null ? _b : provider.destroy();
55
- } catch (e) {
56
- }
57
- }
58
- function CollaborationPluginWrapper({
59
- cursorsContainerRef,
60
- initialEditorState
61
- }) {
62
- const [editor] = useLexicalComposerContext();
63
- const {
64
- docId,
65
- serverUrl,
66
- username,
67
- cursorColor,
68
- avatar,
69
- offlinePersistence,
70
- setOfflineStorageStatus,
71
- setStatus,
72
- setUsers,
73
- setProvider,
74
- isOnline,
75
- setIsServerSynced,
76
- setPendingUpdatesCount,
77
- setLastSavedTimestamp,
78
- setReconnectCountdown
79
- } = useCollab();
80
- const providerRef = useRef(null);
81
- const idbRef = useRef(null);
82
- const isUnmountedRef = useRef(false);
83
- const destroyTimerRef = useRef(null);
84
- const serverUrlRef = useRef(serverUrl);
85
- serverUrlRef.current = serverUrl;
86
- const setStatusRef = useRef(setStatus);
87
- setStatusRef.current = setStatus;
88
- const setProviderRef = useRef(setProvider);
89
- setProviderRef.current = setProvider;
90
- const offlinePersistenceRef = useRef(offlinePersistence);
91
- offlinePersistenceRef.current = offlinePersistence;
92
- const setOfflineStorageStatusRef = useRef(setOfflineStorageStatus);
93
- setOfflineStorageStatusRef.current = setOfflineStorageStatus;
94
- const setIsServerSyncedRef = useRef(setIsServerSynced);
95
- setIsServerSyncedRef.current = setIsServerSynced;
96
- const setPendingUpdatesCountRef = useRef(setPendingUpdatesCount);
97
- setPendingUpdatesCountRef.current = setPendingUpdatesCount;
98
- const setLastSavedTimestampRef = useRef(setLastSavedTimestamp);
99
- setLastSavedTimestampRef.current = setLastSavedTimestamp;
100
- const setReconnectCountdownRef = useRef(setReconnectCountdown);
101
- setReconnectCountdownRef.current = setReconnectCountdown;
102
- useEffect(() => {
103
- isUnmountedRef.current = false;
104
- if (destroyTimerRef.current) {
105
- clearTimeout(destroyTimerRef.current);
106
- destroyTimerRef.current = null;
107
- }
108
- const ws = providerRef.current;
109
- if (ws && !ws.wsconnected && !ws.wsconnecting) {
110
- ws.connect();
111
- }
112
- return () => {
113
- isUnmountedRef.current = true;
114
- destroyTimerRef.current = setTimeout(() => {
115
- if (isUnmountedRef.current && providerRef.current) {
116
- safeDisconnect(providerRef.current);
117
- providerRef.current = null;
118
- }
119
- }, 150);
120
- };
121
- }, []);
122
- const memoizedAwarenessData = useMemo(
123
- () => ({
124
- name: username,
125
- color: cursorColor,
126
- avatar
127
- }),
128
- [username, cursorColor, avatar]
129
- );
130
- const normalizedInitialEditorState = useMemo(() => {
131
- if (!initialEditorState) return void 0;
132
- if (typeof initialEditorState === "string") return initialEditorState;
133
- if (typeof initialEditorState === "function") return initialEditorState;
134
- if (typeof initialEditorState.isEmpty === "function") {
135
- return initialEditorState;
136
- }
137
- try {
138
- return JSON.stringify(initialEditorState);
139
- } catch (e) {
140
- return void 0;
141
- }
142
- }, [initialEditorState]);
143
- const syncUsers = useCallback(
144
- (ws) => {
145
- if (!ws.awareness) return;
146
- const states = ws.awareness.getStates();
147
- const currentClientId = ws.awareness.clientID;
148
- const userList = [];
149
- states.forEach((state, clientId) => {
150
- var _a, _b, _c, _d;
151
- if (!state) return;
152
- const isSelf = clientId === currentClientId;
153
- const name = state.name || ((_a = state.awarenessData) == null ? void 0 : _a.name) || (isSelf ? username : `Collaborator #${clientId.toString().slice(-4)}`);
154
- const color = state.color || ((_b = state.awarenessData) == null ? void 0 : _b.color) || (isSelf ? cursorColor : "#3b82f6");
155
- const userAvatar = ((_c = state.awarenessData) == null ? void 0 : _c.avatar) || state.avatar;
156
- const isTyping = Boolean(state.isTyping || ((_d = state.awarenessData) == null ? void 0 : _d.isTyping));
157
- userList.push({
158
- clientId,
159
- name,
160
- color,
161
- avatar: userAvatar,
162
- isTyping,
163
- isSelf
164
- });
165
- });
166
- userList.sort((a, b) => a.isSelf ? -1 : b.isSelf ? 1 : 0);
167
- setUsers((prev) => {
168
- if (prev.length === userList.length && prev.every(
169
- (u, idx) => u.clientId === userList[idx].clientId && u.name === userList[idx].name && u.color === userList[idx].color && u.avatar === userList[idx].avatar && u.isTyping === userList[idx].isTyping && u.isSelf === userList[idx].isSelf
170
- )) {
171
- return prev;
172
- }
173
- return userList;
174
- });
175
- },
176
- [username, cursorColor, avatar, setUsers]
177
- );
178
- const syncUsersRef = useRef(syncUsers);
179
- syncUsersRef.current = syncUsers;
180
- const providerFactory = useCallback(
181
- (id, yjsDocMap) => {
182
- var _a;
183
- let doc = yjsDocMap.get(id);
184
- if (!doc) {
185
- doc = new Doc();
186
- yjsDocMap.set(id, doc);
187
- }
188
- if (offlinePersistenceRef.current && typeof window !== "undefined" && "indexedDB" in window && (!idbRef.current || idbRef.current.name !== id)) {
189
- try {
190
- if (idbRef.current) {
191
- idbRef.current.destroy();
192
- }
193
- const idb = new IndexeddbPersistence(id, doc);
194
- idbRef.current = idb;
195
- idb.on("synced", () => {
196
- setOfflineStorageStatusRef.current("synced");
197
- setLastSavedTimestampRef.current(Date.now());
198
- });
199
- } catch (e) {
200
- console.warn("[Notiq Collab] IndexedDB persistence unavailable:", e);
201
- setOfflineStorageStatusRef.current("error");
202
- }
203
- }
204
- const currentServer = (_a = providerRef.current) == null ? void 0 : _a.serverUrl;
205
- const isSameServer = currentServer === serverUrlRef.current;
206
- if (providerRef.current && providerRef.current.roomname === id && providerRef.current.doc === doc && isSameServer) {
207
- if (!providerRef.current.wsconnected && !providerRef.current.shouldConnect) {
208
- providerRef.current.connect();
209
- }
210
- return providerRef.current;
211
- }
212
- if (providerRef.current) {
213
- safeDisconnect(providerRef.current);
214
- providerRef.current = null;
215
- }
216
- if (!isSameServer && doc) {
217
- yjsDocMap.delete(id);
218
- doc = new Doc();
219
- yjsDocMap.set(id, doc);
220
- }
221
- const wsProvider = new WebsocketProvider(serverUrlRef.current, id, doc, {
222
- connect: true,
223
- resyncInterval: 1e4
224
- // Periodically request server sync every 10s
225
- });
226
- wsProvider.on("sync", (isSynced) => {
227
- setIsServerSyncedRef.current(isSynced);
228
- if (isSynced) {
229
- setPendingUpdatesCountRef.current(0);
230
- setLastSavedTimestampRef.current(Date.now());
231
- setReconnectCountdownRef.current(null);
232
- }
233
- });
234
- const handleDocUpdate = (_update, origin) => {
235
- setLastSavedTimestampRef.current(Date.now());
236
- if (origin !== wsProvider && origin !== idbRef.current) {
237
- if (!wsProvider.wsconnected) {
238
- setPendingUpdatesCountRef.current((prev) => prev + 1);
239
- }
240
- }
241
- };
242
- doc.on("update", handleDocUpdate);
243
- if (wsProvider._checkInterval) {
244
- clearInterval(wsProvider._checkInterval);
245
- wsProvider._checkInterval = null;
246
- }
247
- wsProvider.wsLastMessageReceived = Date.now();
248
- const rawDisconnect = wsProvider.disconnect.bind(wsProvider);
249
- wsProvider.__rawDisconnect = rawDisconnect;
250
- wsProvider.disconnect = () => {
251
- if (isUnmountedRef.current) {
252
- safeDisconnect(wsProvider);
253
- }
254
- };
255
- providerRef.current = wsProvider;
256
- setProviderRef.current(wsProvider);
257
- const handleStatus = ({ status }) => {
258
- if (status === "connected") {
259
- setStatusRef.current("connected");
260
- syncUsersRef.current(wsProvider);
261
- } else if (status === "connecting") {
262
- setStatusRef.current("connecting");
263
- } else if (status === "disconnected") {
264
- setStatusRef.current("disconnected");
265
- }
266
- };
267
- wsProvider.on("status", handleStatus);
268
- wsProvider.awareness.on("change", () => syncUsersRef.current(wsProvider));
269
- if (wsProvider.wsconnected) {
270
- setStatusRef.current("connected");
271
- syncUsersRef.current(wsProvider);
272
- }
273
- return wsProvider;
274
- },
275
- []
276
- // Empty deps ensures stable callback identity
277
- );
278
- useEffect(() => {
279
- let reconnectDelaySec = 4;
280
- let nextReconnectAt = 0;
281
- const interval = setInterval(() => {
282
- const ws = providerRef.current;
283
- if (!ws) return;
284
- if (!isOnline) {
285
- setStatus("offline");
286
- setReconnectCountdown(null);
287
- return;
288
- }
289
- if (ws.wsconnected) {
290
- setStatus((prev) => prev !== "connected" ? "connected" : prev);
291
- syncUsers(ws);
292
- setReconnectCountdown(null);
293
- reconnectDelaySec = 4;
294
- nextReconnectAt = 0;
295
- } else if (ws.wsconnecting) {
296
- setStatus((prev) => prev !== "connecting" ? "connecting" : prev);
297
- setReconnectCountdown(null);
298
- } else {
299
- setStatus((prev) => prev !== "disconnected" ? "disconnected" : prev);
300
- const now = Date.now();
301
- if (!nextReconnectAt) {
302
- nextReconnectAt = now + reconnectDelaySec * 1e3;
303
- }
304
- const remainingSec = Math.max(0, Math.ceil((nextReconnectAt - now) / 1e3));
305
- setReconnectCountdown(remainingSec);
306
- if (remainingSec === 0) {
307
- if (!ws.shouldConnect) {
308
- ws.shouldConnect = true;
309
- }
310
- ws.connect();
311
- reconnectDelaySec = Math.min(16, Math.round(reconnectDelaySec * 1.5));
312
- nextReconnectAt = now + reconnectDelaySec * 1e3;
313
- }
314
- }
315
- }, 500);
316
- return () => clearInterval(interval);
317
- }, [setStatus, syncUsers, isOnline, setReconnectCountdown]);
318
- useEffect(() => {
319
- return editor.registerCommand(
320
- CONNECTED_COMMAND,
321
- (isConnected) => {
322
- if (isConnected) {
323
- setStatus("connected");
324
- if (providerRef.current) {
325
- syncUsers(providerRef.current);
326
- }
327
- }
328
- return false;
329
- },
330
- COMMAND_PRIORITY_LOW
331
- );
332
- }, [editor, setStatus, syncUsers]);
333
- useEffect(() => {
334
- const ws = providerRef.current;
335
- if (!(ws == null ? void 0 : ws.awareness)) return;
336
- const currentLocalState = ws.awareness.getLocalState() || {};
337
- ws.awareness.setLocalState(__spreadProps(__spreadValues({}, currentLocalState), {
338
- name: username,
339
- color: cursorColor,
340
- awarenessData: __spreadProps(__spreadValues({}, currentLocalState.awarenessData || {}), {
341
- name: username,
342
- color: cursorColor,
343
- avatar
344
- })
345
- }));
346
- }, [username, cursorColor, avatar]);
347
- useEffect(() => {
348
- const keepalive = setInterval(() => {
349
- const ws = providerRef.current;
350
- if (ws == null ? void 0 : ws.wsconnected) {
351
- if (ws._checkInterval) {
352
- clearInterval(ws._checkInterval);
353
- ws._checkInterval = null;
354
- }
355
- ws.wsLastMessageReceived = Date.now();
356
- if (ws.awareness) {
357
- const localState = ws.awareness.getLocalState();
358
- if (localState) {
359
- ws.awareness.setLocalState(__spreadValues({}, localState));
360
- }
361
- }
362
- }
363
- }, 5e3);
364
- return () => clearInterval(keepalive);
365
- }, []);
366
- const typingTimeoutRef = useRef(null);
367
- useEffect(() => {
368
- return editor.registerUpdateListener(({ dirtyElements, dirtyLeaves }) => {
369
- if (dirtyElements.size === 0 && dirtyLeaves.size === 0) return;
370
- const ws = providerRef.current;
371
- if (!(ws == null ? void 0 : ws.awareness)) return;
372
- const localState = ws.awareness.getLocalState();
373
- if (!(localState == null ? void 0 : localState.isTyping)) {
374
- ws.awareness.setLocalStateField("isTyping", true);
375
- }
376
- if (typingTimeoutRef.current) {
377
- clearTimeout(typingTimeoutRef.current);
378
- }
379
- typingTimeoutRef.current = setTimeout(() => {
380
- const activeWs = providerRef.current;
381
- if (activeWs == null ? void 0 : activeWs.awareness) {
382
- activeWs.awareness.setLocalStateField("isTyping", false);
383
- }
384
- }, 1500);
385
- });
386
- }, [editor]);
387
- return /* @__PURE__ */ jsx(
388
- LexicalCollaborationPlugin,
389
- {
390
- id: docId,
391
- providerFactory,
392
- shouldBootstrap: true,
393
- username,
394
- cursorColor,
395
- cursorsContainerRef,
396
- initialEditorState: normalizedInitialEditorState,
397
- awarenessData: memoizedAwarenessData,
398
- excludedProperties: COLLAB_EXCLUDED_PROPERTIES
399
- },
400
- `${docId}-${serverUrl}`
401
- );
402
- }
403
- export {
404
- CollaborationPluginWrapper as default
405
- };
@@ -1,20 +0,0 @@
1
- "use client";
2
- import {
3
- AVATAR_PRESETS,
4
- CollaboratorsBar,
5
- OfflineBanner
6
- } from "./chunk-6SRMKQSD.mjs";
7
- import "./chunk-PFH63ZU4.mjs";
8
- import "./chunk-J6ZUY5BY.mjs";
9
- import "./chunk-R7WFRENU.mjs";
10
- import "./chunk-RJQTA6HG.mjs";
11
- import "./chunk-5NRAXWYA.mjs";
12
- import "./chunk-OE5JRLCN.mjs";
13
- import "./chunk-IIVB6JNE.mjs";
14
- import "./chunk-JHXDLYEV.mjs";
15
- import "./chunk-WYCFGRFJ.mjs";
16
- export {
17
- AVATAR_PRESETS,
18
- OfflineBanner,
19
- CollaboratorsBar as default
20
- };
@@ -1,19 +0,0 @@
1
- "use client";
2
- import {
3
- CommentsPlugin,
4
- INSERT_COMMENT_COMMAND,
5
- findDOMElementForQuote
6
- } from "./chunk-LAUAYRPC.mjs";
7
- import "./chunk-3JN6QEJR.mjs";
8
- import "./chunk-OXWTZV3U.mjs";
9
- import "./chunk-R7WFRENU.mjs";
10
- import "./chunk-RJQTA6HG.mjs";
11
- import "./chunk-6UVNHT3T.mjs";
12
- import "./chunk-OE5JRLCN.mjs";
13
- import "./chunk-JHXDLYEV.mjs";
14
- import "./chunk-WYCFGRFJ.mjs";
15
- export {
16
- INSERT_COMMENT_COMMAND,
17
- CommentsPlugin as default,
18
- findDOMElementForQuote
19
- };
@@ -1,14 +0,0 @@
1
- import {
2
- ExcalidrawPlugin,
3
- INSERT_EXCALIDRAW_COMMAND
4
- } from "./chunk-FYLRS4BG.mjs";
5
- import "./chunk-TC3IISJZ.mjs";
6
- import "./chunk-XZXGYNTY.mjs";
7
- import "./chunk-H3P47YXJ.mjs";
8
- import "./chunk-OE5JRLCN.mjs";
9
- import "./chunk-JHXDLYEV.mjs";
10
- import "./chunk-WYCFGRFJ.mjs";
11
- export {
12
- INSERT_EXCALIDRAW_COMMAND,
13
- ExcalidrawPlugin as default
14
- };
@@ -1,42 +0,0 @@
1
- import {
2
- EXPORT_HTML_COMMAND,
3
- EXPORT_JSON_COMMAND,
4
- EXPORT_MARKDOWN_COMMAND,
5
- EXPORT_PDF_COMMAND,
6
- EXPORT_TEXT_COMMAND,
7
- ExportPlugin,
8
- IMPORT_HTML_COMMAND,
9
- IMPORT_JSON_COMMAND,
10
- IMPORT_MARKDOWN_COMMAND,
11
- IMPORT_TEXT_COMMAND,
12
- OPEN_IMPORT_EXPORT_MODAL_COMMAND
13
- } from "./chunk-XYDBUQ6Z.mjs";
14
- import "./chunk-2KESP7OU.mjs";
15
- import "./chunk-VGAX6YEY.mjs";
16
- import "./chunk-N6ILV6NF.mjs";
17
- import "./chunk-YTLUQJE2.mjs";
18
- import "./chunk-43Z4Z2KD.mjs";
19
- import "./chunk-XYMXGU4T.mjs";
20
- import "./chunk-ZFV2HGD3.mjs";
21
- import "./chunk-6UVNHT3T.mjs";
22
- import "./chunk-NBE6FF6L.mjs";
23
- import "./chunk-GYYLZ3MQ.mjs";
24
- import "./chunk-XZXGYNTY.mjs";
25
- import "./chunk-OE5JRLCN.mjs";
26
- import "./chunk-KNW2CGIP.mjs";
27
- import "./chunk-7QRJVZQY.mjs";
28
- import "./chunk-JHXDLYEV.mjs";
29
- import "./chunk-WYCFGRFJ.mjs";
30
- export {
31
- EXPORT_HTML_COMMAND,
32
- EXPORT_JSON_COMMAND,
33
- EXPORT_MARKDOWN_COMMAND,
34
- EXPORT_PDF_COMMAND,
35
- EXPORT_TEXT_COMMAND,
36
- IMPORT_HTML_COMMAND,
37
- IMPORT_JSON_COMMAND,
38
- IMPORT_MARKDOWN_COMMAND,
39
- IMPORT_TEXT_COMMAND,
40
- OPEN_IMPORT_EXPORT_MODAL_COMMAND,
41
- ExportPlugin as default
42
- };
@@ -1,12 +0,0 @@
1
- import {
2
- FloatingLinkEditorPlugin
3
- } from "./chunk-D3IOUQFR.mjs";
4
- import "./chunk-KXRLARGI.mjs";
5
- import "./chunk-5NRAXWYA.mjs";
6
- import "./chunk-RAVYEEIC.mjs";
7
- import "./chunk-OE5JRLCN.mjs";
8
- import "./chunk-JHXDLYEV.mjs";
9
- import "./chunk-WYCFGRFJ.mjs";
10
- export {
11
- FloatingLinkEditorPlugin as default
12
- };
@@ -1,45 +0,0 @@
1
- import {
2
- FloatingTextFormatToolbarPlugin
3
- } from "./chunk-3AHNLIME.mjs";
4
- import "./chunk-MTQZWJHR.mjs";
5
- import "./chunk-SAOJHVPE.mjs";
6
- import "./chunk-YE7M2VKR.mjs";
7
- import "./chunk-XAVQAXOJ.mjs";
8
- import "./chunk-FMJ7DGWP.mjs";
9
- import "./chunk-LAUAYRPC.mjs";
10
- import "./chunk-3JN6QEJR.mjs";
11
- import "./chunk-KDA7ZYMJ.mjs";
12
- import "./chunk-4DVIYZVB.mjs";
13
- import "./chunk-6D6QLRYR.mjs";
14
- import "./chunk-OXWTZV3U.mjs";
15
- import "./chunk-PFH63ZU4.mjs";
16
- import "./chunk-BGV62GC2.mjs";
17
- import "./chunk-PD5K4AGP.mjs";
18
- import "./chunk-KXRLARGI.mjs";
19
- import "./chunk-K5OAFEVY.mjs";
20
- import "./chunk-2KESP7OU.mjs";
21
- import "./chunk-VGAX6YEY.mjs";
22
- import "./chunk-N6ILV6NF.mjs";
23
- import "./chunk-XYMXGU4T.mjs";
24
- import "./chunk-ZFV2HGD3.mjs";
25
- import "./chunk-LU2XWLOE.mjs";
26
- import "./chunk-4FFTOZGJ.mjs";
27
- import "./chunk-R7WFRENU.mjs";
28
- import "./chunk-RJQTA6HG.mjs";
29
- import "./chunk-6UVNHT3T.mjs";
30
- import "./chunk-5NRAXWYA.mjs";
31
- import "./chunk-CDAMHK63.mjs";
32
- import "./chunk-NBE6FF6L.mjs";
33
- import "./chunk-GYYLZ3MQ.mjs";
34
- import "./chunk-RAVYEEIC.mjs";
35
- import "./chunk-XZXGYNTY.mjs";
36
- import "./chunk-H3P47YXJ.mjs";
37
- import "./chunk-OE5JRLCN.mjs";
38
- import "./chunk-KNW2CGIP.mjs";
39
- import "./chunk-7QRJVZQY.mjs";
40
- import "./chunk-IIVB6JNE.mjs";
41
- import "./chunk-JHXDLYEV.mjs";
42
- import "./chunk-WYCFGRFJ.mjs";
43
- export {
44
- FloatingTextFormatToolbarPlugin as default
45
- };