@kopexa/tiptap 17.8.0 → 17.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -183,6 +183,7 @@ function CollaborationProvider({
183
183
  }
184
184
  const ydoc = ydocRef.current;
185
185
  const localRef = (0, import_react3.useRef)(null);
186
+ const destroyTimeoutRef = (0, import_react3.useRef)(null);
186
187
  const [status, setStatus] = (0, import_react3.useState)("connecting");
187
188
  const [remoteSynced, setRemoteSynced] = (0, import_react3.useState)(false);
188
189
  const [localSynced, setLocalSynced] = (0, import_react3.useState)(!enableLocalPersistence);
@@ -206,9 +207,13 @@ function CollaborationProvider({
206
207
  }
207
208
  const provider = remoteRef.current;
208
209
  (0, import_react3.useEffect)(() => {
210
+ if (destroyTimeoutRef.current) {
211
+ clearTimeout(destroyTimeoutRef.current);
212
+ destroyTimeoutRef.current = null;
213
+ }
209
214
  const remote = remoteRef.current;
210
215
  if (!remote) return;
211
- if (enableLocalPersistence) {
216
+ if (enableLocalPersistence && !localRef.current) {
212
217
  const local = new import_y_indexeddb.IndexeddbPersistence(documentId, ydoc);
213
218
  local.on("synced", () => setLocalSynced(true));
214
219
  localRef.current = local;
@@ -255,17 +260,21 @@ function CollaborationProvider({
255
260
  remote.connect();
256
261
  setReady(true);
257
262
  return () => {
258
- var _a;
259
263
  if (awareness && updateUsers) {
260
264
  awareness.off("change", updateUsers);
261
265
  }
262
266
  remote.off("authenticationFailed", onAuthFailed);
263
267
  remote.off("synced", onSynced);
264
268
  remote.off("status", onStatus);
265
- remote.destroy();
266
- (_a = localRef.current) == null ? void 0 : _a.destroy();
267
- localRef.current = null;
268
- remoteRef.current = null;
269
+ remote.disconnect();
270
+ const localPersistence = localRef.current;
271
+ destroyTimeoutRef.current = setTimeout(() => {
272
+ localPersistence == null ? void 0 : localPersistence.destroy();
273
+ localRef.current = null;
274
+ remote.destroy();
275
+ remoteRef.current = null;
276
+ destroyTimeoutRef.current = null;
277
+ }, 0);
269
278
  };
270
279
  }, [documentId, ydoc, enableLocalPersistence]);
271
280
  (0, import_react3.useEffect)(() => {
package/dist/index.mjs CHANGED
@@ -128,6 +128,7 @@ function CollaborationProvider({
128
128
  }
129
129
  const ydoc = ydocRef.current;
130
130
  const localRef = useRef2(null);
131
+ const destroyTimeoutRef = useRef2(null);
131
132
  const [status, setStatus] = useState2("connecting");
132
133
  const [remoteSynced, setRemoteSynced] = useState2(false);
133
134
  const [localSynced, setLocalSynced] = useState2(!enableLocalPersistence);
@@ -151,9 +152,13 @@ function CollaborationProvider({
151
152
  }
152
153
  const provider = remoteRef.current;
153
154
  useEffect2(() => {
155
+ if (destroyTimeoutRef.current) {
156
+ clearTimeout(destroyTimeoutRef.current);
157
+ destroyTimeoutRef.current = null;
158
+ }
154
159
  const remote = remoteRef.current;
155
160
  if (!remote) return;
156
- if (enableLocalPersistence) {
161
+ if (enableLocalPersistence && !localRef.current) {
157
162
  const local = new IndexeddbPersistence(documentId, ydoc);
158
163
  local.on("synced", () => setLocalSynced(true));
159
164
  localRef.current = local;
@@ -200,17 +205,21 @@ function CollaborationProvider({
200
205
  remote.connect();
201
206
  setReady(true);
202
207
  return () => {
203
- var _a;
204
208
  if (awareness && updateUsers) {
205
209
  awareness.off("change", updateUsers);
206
210
  }
207
211
  remote.off("authenticationFailed", onAuthFailed);
208
212
  remote.off("synced", onSynced);
209
213
  remote.off("status", onStatus);
210
- remote.destroy();
211
- (_a = localRef.current) == null ? void 0 : _a.destroy();
212
- localRef.current = null;
213
- remoteRef.current = null;
214
+ remote.disconnect();
215
+ const localPersistence = localRef.current;
216
+ destroyTimeoutRef.current = setTimeout(() => {
217
+ localPersistence == null ? void 0 : localPersistence.destroy();
218
+ localRef.current = null;
219
+ remote.destroy();
220
+ remoteRef.current = null;
221
+ destroyTimeoutRef.current = null;
222
+ }, 0);
214
223
  };
215
224
  }, [documentId, ydoc, enableLocalPersistence]);
216
225
  useEffect2(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kopexa/tiptap",
3
- "version": "17.8.0",
3
+ "version": "17.8.2",
4
4
  "description": "our tiptap components",
5
5
  "keywords": [
6
6
  "tiptap"
@@ -28,7 +28,7 @@
28
28
  "motion": ">=12.23.6",
29
29
  "react": ">=19.0.0-rc.0",
30
30
  "react-dom": ">=19.0.0-rc.0",
31
- "@kopexa/theme": "17.23.0"
31
+ "@kopexa/theme": "17.23.2"
32
32
  },
33
33
  "dependencies": {
34
34
  "@floating-ui/dom": "^1.7.4",
@@ -66,29 +66,29 @@
66
66
  "react-intl": "^7.1.14",
67
67
  "y-indexeddb": "^9.0.12",
68
68
  "yjs": "^13.6.0",
69
- "@kopexa/button": "17.0.49",
70
- "@kopexa/chip": "17.1.46",
71
- "@kopexa/callout": "17.0.49",
72
- "@kopexa/dialog": "17.2.14",
73
- "@kopexa/dropdown-menu": "17.0.49",
74
- "@kopexa/editor-utils": "17.1.0",
75
- "@kopexa/extension-code": "17.0.49",
76
- "@kopexa/extension-table": "17.1.1",
69
+ "@kopexa/button": "17.0.51",
70
+ "@kopexa/callout": "17.0.51",
71
+ "@kopexa/dialog": "17.2.16",
72
+ "@kopexa/dropdown-menu": "17.0.51",
73
+ "@kopexa/chip": "17.1.48",
74
+ "@kopexa/editor-utils": "17.1.2",
75
+ "@kopexa/extension-code": "17.0.51",
77
76
  "@kopexa/extension-pages": "17.0.45",
78
- "@kopexa/extension-controlref": "17.1.31",
79
- "@kopexa/icons": "17.7.14",
80
- "@kopexa/input": "17.0.49",
81
- "@kopexa/popover": "17.2.14",
82
- "@kopexa/switch": "17.2.14",
83
- "@kopexa/select": "17.2.14",
84
- "@kopexa/label": "17.0.49",
85
- "@kopexa/shared-utils": "17.0.49",
86
- "@kopexa/separator": "17.0.49",
87
- "@kopexa/react-utils": "17.0.49",
88
- "@kopexa/tabs": "17.0.49",
89
- "@kopexa/toolbar": "17.2.14",
90
- "@kopexa/use-composed-ref": "17.0.49",
91
- "@kopexa/use-is-mobile": "17.0.49"
77
+ "@kopexa/extension-table": "17.1.3",
78
+ "@kopexa/extension-controlref": "17.1.33",
79
+ "@kopexa/input": "17.0.51",
80
+ "@kopexa/icons": "17.7.16",
81
+ "@kopexa/popover": "17.2.16",
82
+ "@kopexa/select": "17.2.16",
83
+ "@kopexa/switch": "17.2.16",
84
+ "@kopexa/separator": "17.0.51",
85
+ "@kopexa/label": "17.0.51",
86
+ "@kopexa/react-utils": "17.0.51",
87
+ "@kopexa/shared-utils": "17.0.51",
88
+ "@kopexa/tabs": "17.0.51",
89
+ "@kopexa/toolbar": "17.2.16",
90
+ "@kopexa/use-is-mobile": "17.0.51",
91
+ "@kopexa/use-composed-ref": "17.0.51"
92
92
  },
93
93
  "clean-package": "../../../clean-package.config.json",
94
94
  "module": "dist/index.mjs",