@veltdev/react 1.0.117 → 1.0.119

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.
@@ -51,6 +51,7 @@ export interface IVeltCommentsProps extends React.DetailedHTMLProps<React.HTMLAt
51
51
  pinShadowDom?: boolean;
52
52
  dialogShadowDom?: boolean;
53
53
  shadowDom?: boolean;
54
+ changeDetectionInCommentMode?: boolean;
54
55
  allowedElementIds?: string[];
55
56
  allowedElementClassNames?: string[];
56
57
  allowedElementQuerySelectors?: string[];
@@ -33,4 +33,7 @@ export declare function useEditorAccessRequestHandler(): {
33
33
  /**
34
34
  * @beta This hook is in beta
35
35
  */
36
- export declare function useLiveState<T>(liveStateDataId: string, initialValue?: any, debounceTime?: number): [T, (value: T) => void];
36
+ export declare function useLiveState<T>(liveStateDataId: string, initialValue?: any, options?: {
37
+ syncDuration?: number;
38
+ resetLiveState?: boolean;
39
+ }): [T, (value: T) => void];
package/esm/index.js CHANGED
@@ -225,76 +225,126 @@ var SnippylyCommentBubble = function (props) {
225
225
  };
226
226
 
227
227
  var SnippylyComments = function (props) {
228
- var autoCategorize = props.autoCategorize, streamViewContainerId = props.streamViewContainerId, onSignIn = props.onSignIn, onUpgrade = props.onUpgrade, textMode = props.textMode, popoverMode = props.popoverMode, popoverTriangleComponent = props.popoverTriangleComponent, floatingCommentDialog = props.floatingCommentDialog, moderatorMode = props.moderatorMode, streamMode = props.streamMode, signInButton = props.signInButton, upgradeButton = props.upgradeButton, attachments = props.attachments, recordings = props.recordings, reactions = props.reactions, deviceInfo = props.deviceInfo, commentIndex = props.commentIndex, dialogOnHover = props.dialogOnHover, dialogOnTargetElementClick = props.dialogOnTargetElementClick, priority = props.priority, inboxMode = props.inboxMode, suggestionMode = props.suggestionMode, mobileMode = props.mobileMode, inlineCommentMode = props.inlineCommentMode, privateCommentMode = props.privateCommentMode, minimap = props.minimap, persistentCommentMode = props.persistentCommentMode, ghostComments = props.ghostComments, ghostCommentsIndicator = props.ghostCommentsIndicator, commentsOnDom = props.commentsOnDom, commentTool = props.commentTool, sidebarButtonOnCommentDialog = props.sidebarButtonOnCommentDialog, deviceIndicatorOnCommentPins = props.deviceIndicatorOnCommentPins, scrollToComment = props.scrollToComment, userMentions = props.userMentions, deleteOnBackspace = props.deleteOnBackspace, hotkey = props.hotkey, recordingSummary = props.recordingSummary, recordingCountdown = props.recordingCountdown, unreadIndicatorMode = props.unreadIndicatorMode, pinShadowDom = props.pinShadowDom, dialogShadowDom = props.dialogShadowDom, shadowDom = props.shadowDom, allowedElementIds = props.allowedElementIds, allowedElementClassNames = props.allowedElementClassNames, allowedElementQuerySelectors = props.allowedElementQuerySelectors, onCommentAdd = props.onCommentAdd, onCommentUpdate = props.onCommentUpdate, onCommentAccept = props.onCommentAccept, onCommentReject = props.onCommentReject, onSidebarButtonOnCommentDialogClick = props.onSidebarButtonOnCommentDialogClick, customStatus = props.customStatus, customPriority = props.customPriority, customCategory = props.customCategory, status = props.status, resolveButton = props.resolveButton, darkMode = props.darkMode, onCustomPinInject = props.onCustomPinInject, children = props.children;
228
+ var autoCategorize = props.autoCategorize, streamViewContainerId = props.streamViewContainerId, onSignIn = props.onSignIn, onUpgrade = props.onUpgrade, textMode = props.textMode, popoverMode = props.popoverMode, popoverTriangleComponent = props.popoverTriangleComponent, floatingCommentDialog = props.floatingCommentDialog, moderatorMode = props.moderatorMode, streamMode = props.streamMode, signInButton = props.signInButton, upgradeButton = props.upgradeButton, attachments = props.attachments, recordings = props.recordings, reactions = props.reactions, deviceInfo = props.deviceInfo, commentIndex = props.commentIndex, dialogOnHover = props.dialogOnHover, dialogOnTargetElementClick = props.dialogOnTargetElementClick, priority = props.priority, inboxMode = props.inboxMode, suggestionMode = props.suggestionMode, mobileMode = props.mobileMode, inlineCommentMode = props.inlineCommentMode, privateCommentMode = props.privateCommentMode, minimap = props.minimap, persistentCommentMode = props.persistentCommentMode, ghostComments = props.ghostComments, ghostCommentsIndicator = props.ghostCommentsIndicator, commentsOnDom = props.commentsOnDom, commentTool = props.commentTool, sidebarButtonOnCommentDialog = props.sidebarButtonOnCommentDialog, deviceIndicatorOnCommentPins = props.deviceIndicatorOnCommentPins, scrollToComment = props.scrollToComment, userMentions = props.userMentions, deleteOnBackspace = props.deleteOnBackspace, hotkey = props.hotkey, recordingSummary = props.recordingSummary, recordingCountdown = props.recordingCountdown, unreadIndicatorMode = props.unreadIndicatorMode, pinShadowDom = props.pinShadowDom, dialogShadowDom = props.dialogShadowDom, shadowDom = props.shadowDom, changeDetectionInCommentMode = props.changeDetectionInCommentMode, allowedElementIds = props.allowedElementIds, allowedElementClassNames = props.allowedElementClassNames, allowedElementQuerySelectors = props.allowedElementQuerySelectors, onCommentAdd = props.onCommentAdd, onCommentUpdate = props.onCommentUpdate, onCommentAccept = props.onCommentAccept, onCommentReject = props.onCommentReject, onSidebarButtonOnCommentDialogClick = props.onSidebarButtonOnCommentDialogClick, customStatus = props.customStatus, customPriority = props.customPriority, customCategory = props.customCategory, status = props.status, resolveButton = props.resolveButton, darkMode = props.darkMode, onCustomPinInject = props.onCustomPinInject, children = props.children;
229
229
  var ref = useRef();
230
+ var onSignInRef = useRef(onSignIn);
231
+ var onUpgradeRef = useRef(onUpgrade);
232
+ var onCommentAddRef = useRef(onCommentAdd);
233
+ var onCommentUpdateRef = useRef(onCommentUpdate);
234
+ var onCommentAcceptRef = useRef(onCommentAccept);
235
+ var onCommentRejectRef = useRef(onCommentReject);
236
+ var onSidebarButtonOnCommentDialogClickRef = useRef(onSidebarButtonOnCommentDialogClick);
237
+ var onCustomPinInjectRef = useRef(onCustomPinInject);
238
+ // Update the ref to always point to the latest callback function
239
+ useEffect(function () {
240
+ onSignInRef.current = onSignIn;
241
+ }, [onSignIn]);
242
+ useEffect(function () {
243
+ onUpgradeRef.current = onUpgrade;
244
+ }, [onUpgrade]);
245
+ useEffect(function () {
246
+ onCommentAddRef.current = onCommentAdd;
247
+ }, [onCommentAdd]);
248
+ useEffect(function () {
249
+ onCommentUpdateRef.current = onCommentUpdate;
250
+ }, [onCommentUpdate]);
251
+ useEffect(function () {
252
+ onCommentAcceptRef.current = onCommentAccept;
253
+ }, [onCommentAccept]);
254
+ useEffect(function () {
255
+ onCommentRejectRef.current = onCommentReject;
256
+ }, [onCommentReject]);
257
+ useEffect(function () {
258
+ onSidebarButtonOnCommentDialogClickRef.current = onSidebarButtonOnCommentDialogClick;
259
+ }, [onSidebarButtonOnCommentDialogClick]);
260
+ useEffect(function () {
261
+ onCustomPinInjectRef.current = onCustomPinInject;
262
+ }, [onCustomPinInject]);
230
263
  useEffect(function () {
231
264
  if (ref.current) {
232
265
  var element = ref.current;
233
266
  element.addEventListener('onSignIn', function (event) {
234
- if (onSignIn) {
235
- onSignIn(event === null || event === void 0 ? void 0 : event.detail);
267
+ if (onSignInRef.current) {
268
+ onSignInRef.current(event === null || event === void 0 ? void 0 : event.detail);
236
269
  }
237
270
  });
238
271
  element.addEventListener('onUpgrade', function (event) {
239
- if (onUpgrade) {
240
- onUpgrade(event === null || event === void 0 ? void 0 : event.detail);
272
+ if (onUpgradeRef.current) {
273
+ onUpgradeRef.current(event === null || event === void 0 ? void 0 : event.detail);
241
274
  }
242
275
  });
243
276
  element.addEventListener('onCommentAdd', function (event) {
244
- if (onCommentAdd) {
245
- onCommentAdd(event === null || event === void 0 ? void 0 : event.detail);
277
+ if (onCommentAddRef.current) {
278
+ onCommentAddRef.current(event === null || event === void 0 ? void 0 : event.detail);
246
279
  }
247
280
  });
248
281
  element.addEventListener('onCommentUpdate', function (event) {
249
- if (onCommentUpdate) {
250
- onCommentUpdate(event === null || event === void 0 ? void 0 : event.detail);
282
+ if (onCommentUpdateRef.current) {
283
+ onCommentUpdateRef.current(event === null || event === void 0 ? void 0 : event.detail);
251
284
  }
252
285
  });
253
286
  element.addEventListener('onCommentAccept', function (event) {
254
- if (onCommentAccept) {
255
- onCommentAccept(event === null || event === void 0 ? void 0 : event.detail);
287
+ if (onCommentAcceptRef.current) {
288
+ onCommentAcceptRef.current(event === null || event === void 0 ? void 0 : event.detail);
256
289
  }
257
290
  });
258
291
  element.addEventListener('onCommentReject', function (event) {
259
- if (onCommentReject) {
260
- onCommentReject(event === null || event === void 0 ? void 0 : event.detail);
292
+ if (onCommentRejectRef.current) {
293
+ onCommentRejectRef.current(event === null || event === void 0 ? void 0 : event.detail);
261
294
  }
262
295
  });
263
296
  element.addEventListener('onSidebarButtonOnCommentDialogClick', function (event) {
264
- if (onSidebarButtonOnCommentDialogClick) {
265
- onSidebarButtonOnCommentDialogClick(event === null || event === void 0 ? void 0 : event.detail);
297
+ if (onSidebarButtonOnCommentDialogClickRef.current) {
298
+ onSidebarButtonOnCommentDialogClickRef.current(event === null || event === void 0 ? void 0 : event.detail);
266
299
  }
267
300
  });
268
301
  element.addEventListener('onCustomPinInject', function (event) {
269
- if (onCustomPinInject) {
270
- onCustomPinInject(event === null || event === void 0 ? void 0 : event.detail);
302
+ if (onCustomPinInjectRef.current) {
303
+ onCustomPinInjectRef.current(event === null || event === void 0 ? void 0 : event.detail);
271
304
  }
272
305
  });
273
306
  }
274
307
  }, []);
275
- return (React.createElement("velt-comments", { ref: ref, "auto-categorize": [true, false].includes(autoCategorize) ? (autoCategorize ? 'true' : 'false') : undefined, "data-stream-view-container-id": streamViewContainerId, "text-mode": [true, false].includes(textMode) ? (textMode ? 'true' : 'false') : undefined, "popover-mode": [true, false].includes(popoverMode) ? (popoverMode ? 'true' : 'false') : undefined, "popover-triangle-component": [true, false].includes(popoverTriangleComponent) ? (popoverTriangleComponent ? 'true' : 'false') : undefined, "floating-comment-dialog": [true, false].includes(floatingCommentDialog) ? (floatingCommentDialog ? 'true' : 'false') : undefined, "moderator-mode": [true, false].includes(moderatorMode) ? (moderatorMode ? 'true' : 'false') : undefined, "stream-mode": [true, false].includes(streamMode) ? (streamMode ? 'true' : 'false') : undefined, "sign-in-button": [true, false].includes(signInButton) ? (signInButton ? 'true' : 'false') : undefined, "upgrade-button": [true, false].includes(upgradeButton) ? (upgradeButton ? 'true' : 'false') : undefined, attachments: [true, false].includes(attachments) ? (attachments ? 'true' : 'false') : undefined, recordings: recordings, reactions: [true, false].includes(reactions) ? (reactions ? 'true' : 'false') : undefined, "device-info": [true, false].includes(deviceInfo) ? (deviceInfo ? 'true' : 'false') : undefined, "comment-index": [true, false].includes(commentIndex) ? (commentIndex ? 'true' : 'false') : undefined, "dialog-on-hover": [true, false].includes(dialogOnHover) ? (dialogOnHover ? 'true' : 'false') : undefined, "dialog-on-target-element-click": [true, false].includes(dialogOnTargetElementClick) ? (dialogOnTargetElementClick ? 'true' : 'false') : undefined, priority: [true, false].includes(priority) ? (priority ? 'true' : 'false') : undefined, status: [true, false].includes(status) ? (status ? 'true' : 'false') : undefined, "resolve-button": [true, false].includes(resolveButton) ? (resolveButton ? 'true' : 'false') : undefined, "inbox-mode": [true, false].includes(inboxMode) ? (inboxMode ? 'true' : 'false') : undefined, "suggestion-mode": [true, false].includes(suggestionMode) ? (suggestionMode ? 'true' : 'false') : undefined, "mobile-mode": [true, false].includes(mobileMode) ? (mobileMode ? 'true' : 'false') : undefined, "inline-comment-mode": [true, false].includes(inlineCommentMode) ? (inlineCommentMode ? 'true' : 'false') : undefined, "private-comment-mode": [true, false].includes(privateCommentMode) ? (privateCommentMode ? 'true' : 'false') : undefined, minimap: [true, false].includes(minimap) ? (minimap ? 'true' : 'false') : undefined, "persistent-comment-mode": [true, false].includes(persistentCommentMode) ? (persistentCommentMode ? 'true' : 'false') : undefined, "ghost-comments": [true, false].includes(ghostComments) ? (ghostComments ? 'true' : 'false') : undefined, "ghost-comments-indicator": [true, false].includes(ghostCommentsIndicator) ? (ghostCommentsIndicator ? 'true' : 'false') : undefined, "comments-on-dom": [true, false].includes(commentsOnDom) ? (commentsOnDom ? 'true' : 'false') : undefined, "comment-tool": [true, false].includes(commentTool) ? (commentTool ? 'true' : 'false') : undefined, "sidebar-button-on-comment-dialog": [true, false].includes(sidebarButtonOnCommentDialog) ? (sidebarButtonOnCommentDialog ? 'true' : 'false') : undefined, "device-indicator-on-comment-pins": [true, false].includes(deviceIndicatorOnCommentPins) ? (deviceIndicatorOnCommentPins ? 'true' : 'false') : undefined, "scroll-to-comment": [true, false].includes(scrollToComment) ? (scrollToComment ? 'true' : 'false') : undefined, "user-mentions": [true, false].includes(userMentions) ? (userMentions ? 'true' : 'false') : undefined, "delete-on-backspace": [true, false].includes(deleteOnBackspace) ? (deleteOnBackspace ? 'true' : 'false') : undefined, hotkey: [true, false].includes(hotkey) ? (hotkey ? 'true' : 'false') : undefined, "recording-summary": [true, false].includes(recordingSummary) ? (recordingSummary ? 'true' : 'false') : undefined, "recording-countdown": [true, false].includes(recordingCountdown) ? (recordingCountdown ? 'true' : 'false') : undefined, "unread-indicator-mode": unreadIndicatorMode, "pin-shadow-dom": [true, false].includes(pinShadowDom) ? (pinShadowDom ? 'true' : 'false') : undefined, "dialog-shadow-dom": [true, false].includes(dialogShadowDom) ? (dialogShadowDom ? 'true' : 'false') : undefined, "shadow-dom": [true, false].includes(shadowDom) ? (shadowDom ? 'true' : 'false') : undefined, "allowed-element-ids": JSON.stringify(allowedElementIds), "allowed-element-class-names": JSON.stringify(allowedElementClassNames), "allowed-element-query-selectors": JSON.stringify(allowedElementQuerySelectors), "custom-status": JSON.stringify(customStatus), "custom-priority": JSON.stringify(customPriority), "custom-category": JSON.stringify(customCategory), "dark-mode": [true, false].includes(darkMode) ? (darkMode ? 'true' : 'false') : undefined }, children));
308
+ return (React.createElement("velt-comments", { ref: ref, "auto-categorize": [true, false].includes(autoCategorize) ? (autoCategorize ? 'true' : 'false') : undefined, "data-stream-view-container-id": streamViewContainerId, "text-mode": [true, false].includes(textMode) ? (textMode ? 'true' : 'false') : undefined, "popover-mode": [true, false].includes(popoverMode) ? (popoverMode ? 'true' : 'false') : undefined, "popover-triangle-component": [true, false].includes(popoverTriangleComponent) ? (popoverTriangleComponent ? 'true' : 'false') : undefined, "floating-comment-dialog": [true, false].includes(floatingCommentDialog) ? (floatingCommentDialog ? 'true' : 'false') : undefined, "moderator-mode": [true, false].includes(moderatorMode) ? (moderatorMode ? 'true' : 'false') : undefined, "stream-mode": [true, false].includes(streamMode) ? (streamMode ? 'true' : 'false') : undefined, "sign-in-button": [true, false].includes(signInButton) ? (signInButton ? 'true' : 'false') : undefined, "upgrade-button": [true, false].includes(upgradeButton) ? (upgradeButton ? 'true' : 'false') : undefined, attachments: [true, false].includes(attachments) ? (attachments ? 'true' : 'false') : undefined, recordings: recordings, reactions: [true, false].includes(reactions) ? (reactions ? 'true' : 'false') : undefined, "device-info": [true, false].includes(deviceInfo) ? (deviceInfo ? 'true' : 'false') : undefined, "comment-index": [true, false].includes(commentIndex) ? (commentIndex ? 'true' : 'false') : undefined, "dialog-on-hover": [true, false].includes(dialogOnHover) ? (dialogOnHover ? 'true' : 'false') : undefined, "dialog-on-target-element-click": [true, false].includes(dialogOnTargetElementClick) ? (dialogOnTargetElementClick ? 'true' : 'false') : undefined, priority: [true, false].includes(priority) ? (priority ? 'true' : 'false') : undefined, status: [true, false].includes(status) ? (status ? 'true' : 'false') : undefined, "resolve-button": [true, false].includes(resolveButton) ? (resolveButton ? 'true' : 'false') : undefined, "inbox-mode": [true, false].includes(inboxMode) ? (inboxMode ? 'true' : 'false') : undefined, "suggestion-mode": [true, false].includes(suggestionMode) ? (suggestionMode ? 'true' : 'false') : undefined, "mobile-mode": [true, false].includes(mobileMode) ? (mobileMode ? 'true' : 'false') : undefined, "inline-comment-mode": [true, false].includes(inlineCommentMode) ? (inlineCommentMode ? 'true' : 'false') : undefined, "private-comment-mode": [true, false].includes(privateCommentMode) ? (privateCommentMode ? 'true' : 'false') : undefined, minimap: [true, false].includes(minimap) ? (minimap ? 'true' : 'false') : undefined, "persistent-comment-mode": [true, false].includes(persistentCommentMode) ? (persistentCommentMode ? 'true' : 'false') : undefined, "ghost-comments": [true, false].includes(ghostComments) ? (ghostComments ? 'true' : 'false') : undefined, "ghost-comments-indicator": [true, false].includes(ghostCommentsIndicator) ? (ghostCommentsIndicator ? 'true' : 'false') : undefined, "comments-on-dom": [true, false].includes(commentsOnDom) ? (commentsOnDom ? 'true' : 'false') : undefined, "comment-tool": [true, false].includes(commentTool) ? (commentTool ? 'true' : 'false') : undefined, "sidebar-button-on-comment-dialog": [true, false].includes(sidebarButtonOnCommentDialog) ? (sidebarButtonOnCommentDialog ? 'true' : 'false') : undefined, "device-indicator-on-comment-pins": [true, false].includes(deviceIndicatorOnCommentPins) ? (deviceIndicatorOnCommentPins ? 'true' : 'false') : undefined, "scroll-to-comment": [true, false].includes(scrollToComment) ? (scrollToComment ? 'true' : 'false') : undefined, "user-mentions": [true, false].includes(userMentions) ? (userMentions ? 'true' : 'false') : undefined, "delete-on-backspace": [true, false].includes(deleteOnBackspace) ? (deleteOnBackspace ? 'true' : 'false') : undefined, hotkey: [true, false].includes(hotkey) ? (hotkey ? 'true' : 'false') : undefined, "recording-summary": [true, false].includes(recordingSummary) ? (recordingSummary ? 'true' : 'false') : undefined, "recording-countdown": [true, false].includes(recordingCountdown) ? (recordingCountdown ? 'true' : 'false') : undefined, "unread-indicator-mode": unreadIndicatorMode, "pin-shadow-dom": [true, false].includes(pinShadowDom) ? (pinShadowDom ? 'true' : 'false') : undefined, "dialog-shadow-dom": [true, false].includes(dialogShadowDom) ? (dialogShadowDom ? 'true' : 'false') : undefined, "shadow-dom": [true, false].includes(shadowDom) ? (shadowDom ? 'true' : 'false') : undefined, "change-detection-in-comment-mode": [true, false].includes(changeDetectionInCommentMode) ? (changeDetectionInCommentMode ? 'true' : 'false') : undefined, "allowed-element-ids": JSON.stringify(allowedElementIds), "allowed-element-class-names": JSON.stringify(allowedElementClassNames), "allowed-element-query-selectors": JSON.stringify(allowedElementQuerySelectors), "custom-status": JSON.stringify(customStatus), "custom-priority": JSON.stringify(customPriority), "custom-category": JSON.stringify(customCategory), "dark-mode": [true, false].includes(darkMode) ? (darkMode ? 'true' : 'false') : undefined }, children));
276
309
  };
277
310
 
278
311
  var SnippylyCommentsSidebar = function (props) {
279
312
  var embedMode = props.embedMode, enableUrlNavigation = props.enableUrlNavigation, urlNavigation = props.urlNavigation, pageMode = props.pageMode, currentLocationSuffix = props.currentLocationSuffix, sortData = props.sortData, filterConfig = props.filterConfig, groupConfig = props.groupConfig, filters = props.filters, variant = props.variant, pageModeComposerVariant = props.pageModeComposerVariant, dialogVariant = props.dialogVariant, shadowDom = props.shadowDom, openSidebar = props.openSidebar, onSidebarOpen = props.onSidebarOpen, onSidebarCommentClick = props.onSidebarCommentClick, onCommentClick = props.onCommentClick;
280
313
  var ref = useRef();
314
+ var openSidebarRef = useRef(openSidebar);
315
+ var onSidebarOpenRef = useRef(onSidebarOpen);
316
+ var onSidebarCommentClickRef = useRef(onSidebarCommentClick);
317
+ var onCommentClickRef = useRef(onCommentClick);
318
+ // Update the ref to always point to the latest callback function
319
+ useEffect(function () {
320
+ openSidebarRef.current = openSidebar;
321
+ }, [openSidebar]);
322
+ useEffect(function () {
323
+ onSidebarOpenRef.current = onSidebarOpen;
324
+ }, [onSidebarOpen]);
325
+ useEffect(function () {
326
+ onSidebarCommentClickRef.current = onSidebarCommentClick;
327
+ }, [onSidebarCommentClick]);
328
+ useEffect(function () {
329
+ onCommentClickRef.current = onCommentClick;
330
+ }, [onCommentClick]);
281
331
  useEffect(function () {
282
332
  if (ref.current) {
283
333
  var element = ref.current;
284
334
  element.addEventListener('onSidebarOpen', function (event) {
285
- if (openSidebar) {
286
- openSidebar(event === null || event === void 0 ? void 0 : event.detail);
335
+ if (openSidebarRef.current) {
336
+ openSidebarRef.current(event === null || event === void 0 ? void 0 : event.detail);
287
337
  }
288
- if (onSidebarOpen) {
289
- onSidebarOpen(event === null || event === void 0 ? void 0 : event.detail);
338
+ if (onSidebarOpenRef.current) {
339
+ onSidebarOpenRef.current(event === null || event === void 0 ? void 0 : event.detail);
290
340
  }
291
341
  });
292
342
  element.addEventListener('onSidebarCommentClick', function (event) {
293
- if (onSidebarCommentClick) {
294
- onSidebarCommentClick(event === null || event === void 0 ? void 0 : event.detail);
343
+ if (onSidebarCommentClickRef.current) {
344
+ onSidebarCommentClickRef.current(event === null || event === void 0 ? void 0 : event.detail);
295
345
  }
296
- if (onCommentClick) {
297
- onCommentClick(event === null || event === void 0 ? void 0 : event.detail);
346
+ if (onCommentClickRef.current) {
347
+ onCommentClickRef.current(event === null || event === void 0 ? void 0 : event.detail);
298
348
  }
299
349
  });
300
350
  }
@@ -305,12 +355,17 @@ var SnippylyCommentsSidebar = function (props) {
305
355
  var SnippylyCommentTool = function (props) {
306
356
  var targetCommentElementId = props.targetCommentElementId, onCommentModeChange = props.onCommentModeChange, children = props.children, darkMode = props.darkMode, variant = props.variant;
307
357
  var ref = useRef();
358
+ var onCommentModeChangeRef = useRef(onCommentModeChange);
359
+ // Update the ref to always point to the latest callback function
360
+ useEffect(function () {
361
+ onCommentModeChangeRef.current = onCommentModeChange;
362
+ }, [onCommentModeChange]);
308
363
  useEffect(function () {
309
364
  if (ref.current) {
310
365
  var element = ref.current;
311
366
  element.addEventListener('onCommentModeChange', function (event) {
312
- if (onCommentModeChange) {
313
- onCommentModeChange(event === null || event === void 0 ? void 0 : event.detail);
367
+ if (onCommentModeChangeRef.current) {
368
+ onCommentModeChangeRef.current(event === null || event === void 0 ? void 0 : event.detail);
314
369
  }
315
370
  });
316
371
  }
@@ -321,15 +376,24 @@ var SnippylyCommentTool = function (props) {
321
376
  var SnippylyCursor = function (props) {
322
377
  var allowedElementIds = props.allowedElementIds, avatarMode = props.avatarMode, inactivityTime = props.inactivityTime, onCursorUsersChanged = props.onCursorUsersChanged, onCursorUserChange = props.onCursorUserChange, children = props.children;
323
378
  var ref = useRef();
379
+ var onCursorUsersChangedRef = useRef(onCursorUsersChanged);
380
+ var onCursorUserChangeRef = useRef(onCursorUserChange);
381
+ // Update the ref to always point to the latest callback function
382
+ useEffect(function () {
383
+ onCursorUsersChangedRef.current = onCursorUsersChanged;
384
+ }, [onCursorUsersChanged]);
385
+ useEffect(function () {
386
+ onCursorUserChangeRef.current = onCursorUserChange;
387
+ }, [onCursorUserChange]);
324
388
  useEffect(function () {
325
389
  if (ref.current) {
326
390
  var element = ref.current;
327
391
  element.addEventListener('onCursorUserChange', function (event) {
328
- if (onCursorUsersChanged) {
329
- onCursorUsersChanged(event === null || event === void 0 ? void 0 : event.detail);
392
+ if (onCursorUsersChangedRef.current) {
393
+ onCursorUsersChangedRef.current(event === null || event === void 0 ? void 0 : event.detail);
330
394
  }
331
- if (onCursorUserChange) {
332
- onCursorUserChange(event === null || event === void 0 ? void 0 : event.detail);
395
+ if (onCursorUserChangeRef.current) {
396
+ onCursorUserChangeRef.current(event === null || event === void 0 ? void 0 : event.detail);
333
397
  }
334
398
  });
335
399
  }
@@ -350,25 +414,42 @@ var SnippylyHuddleTool = function (props) {
350
414
  var SnippylyPresence = function (props) {
351
415
  var maxUsers = props.maxUsers, inactivityTime = props.inactivityTime, documentParams = props.documentParams, location = props.location, self = props.self, onPresenceUserClick = props.onPresenceUserClick, onUsersChanged = props.onUsersChanged, onPresenceUserChange = props.onPresenceUserChange, disableFlockNavigation = props.disableFlockNavigation, defaultFlockNavigation = props.defaultFlockNavigation, onNavigate = props.onNavigate, flockMode = props.flockMode;
352
416
  var ref = useRef();
417
+ var onUsersChangedRef = useRef(onUsersChanged);
418
+ var onPresenceUserChangeRef = useRef(onPresenceUserChange);
419
+ var onNavigateRef = useRef(onNavigate);
420
+ var onPresenceUserClickRef = useRef(onPresenceUserClick);
421
+ // Update the ref to always point to the latest callback function
422
+ useEffect(function () {
423
+ onUsersChangedRef.current = onUsersChanged;
424
+ }, [onUsersChanged]);
425
+ useEffect(function () {
426
+ onPresenceUserChangeRef.current = onPresenceUserChange;
427
+ }, [onPresenceUserChange]);
428
+ useEffect(function () {
429
+ onNavigateRef.current = onNavigate;
430
+ }, [onNavigate]);
431
+ useEffect(function () {
432
+ onPresenceUserClickRef.current = onPresenceUserClick;
433
+ }, [onPresenceUserClick]);
353
434
  useEffect(function () {
354
435
  if (ref.current) {
355
436
  var element = ref.current;
356
437
  element.addEventListener('onPresenceUserChange', function (event) {
357
- if (onUsersChanged) {
358
- onUsersChanged(event === null || event === void 0 ? void 0 : event.detail);
438
+ if (onUsersChangedRef.current) {
439
+ onUsersChangedRef.current(event === null || event === void 0 ? void 0 : event.detail);
359
440
  }
360
- if (onPresenceUserChange) {
361
- onPresenceUserChange(event === null || event === void 0 ? void 0 : event.detail);
441
+ if (onPresenceUserChangeRef.current) {
442
+ onPresenceUserChangeRef.current(event === null || event === void 0 ? void 0 : event.detail);
362
443
  }
363
444
  });
364
445
  element.addEventListener('onNavigate', function (event) {
365
- if (onNavigate) {
366
- onNavigate(event === null || event === void 0 ? void 0 : event.detail);
446
+ if (onNavigateRef.current) {
447
+ onNavigateRef.current(event === null || event === void 0 ? void 0 : event.detail);
367
448
  }
368
449
  });
369
450
  element.addEventListener('onPresenceUserClick', function (event) {
370
- if (onPresenceUserClick) {
371
- onPresenceUserClick(event === null || event === void 0 ? void 0 : event.detail);
451
+ if (onPresenceUserClickRef.current) {
452
+ onPresenceUserClickRef.current(event === null || event === void 0 ? void 0 : event.detail);
372
453
  }
373
454
  });
374
455
  }
@@ -379,12 +460,17 @@ var SnippylyPresence = function (props) {
379
460
  var SnippylyRecorderControlPanel = function (props) {
380
461
  var mode = props.mode, panelId = props.panelId, onRecordedData = props.onRecordedData;
381
462
  var ref = useRef();
463
+ var onRecordedDataRef = useRef(onRecordedData);
464
+ // Update the ref to always point to the latest callback function
465
+ useEffect(function () {
466
+ onRecordedDataRef.current = onRecordedData;
467
+ }, [onRecordedData]);
382
468
  useEffect(function () {
383
469
  if (ref.current) {
384
470
  var element = ref.current;
385
471
  element.addEventListener('onRecordedData', function (event) {
386
- if (onRecordedData) {
387
- onRecordedData(event === null || event === void 0 ? void 0 : event.detail);
472
+ if (onRecordedDataRef.current) {
473
+ onRecordedDataRef.current(event === null || event === void 0 ? void 0 : event.detail);
388
474
  }
389
475
  });
390
476
  }
@@ -399,12 +485,17 @@ var SnippylyRecorderNotes = function (props) {
399
485
  var SnippylyRecorderPlayer = function (props) {
400
486
  var recorderId = props.recorderId, onDelete = props.onDelete, showSummary = props.showSummary, summary = props.summary;
401
487
  var ref = useRef();
488
+ var onDeleteRef = useRef(onDelete);
489
+ // Update the ref to always point to the latest callback function
490
+ useEffect(function () {
491
+ onDeleteRef.current = onDelete;
492
+ }, [onDelete]);
402
493
  useEffect(function () {
403
494
  if (ref.current) {
404
495
  var element = ref.current;
405
496
  element === null || element === void 0 ? void 0 : element.addEventListener('onDelete', function (event) {
406
- if (onDelete) {
407
- onDelete(event === null || event === void 0 ? void 0 : event.detail);
497
+ if (onDeleteRef.current) {
498
+ onDeleteRef.current(event === null || event === void 0 ? void 0 : event.detail);
408
499
  }
409
500
  });
410
501
  }
@@ -454,12 +545,17 @@ var SnippylyUserRequestTool = function (props) {
454
545
  var VeltCommentPlayerTimeline = function (props) {
455
546
  var totalMediaLength = props.totalMediaLength, onCommentClick = props.onCommentClick;
456
547
  var ref = useRef();
548
+ var onCommentClickRef = useRef(onCommentClick);
549
+ // Update the ref to always point to the latest callback function
550
+ useEffect(function () {
551
+ onCommentClickRef.current = onCommentClick;
552
+ }, [onCommentClick]);
457
553
  useEffect(function () {
458
554
  if (ref.current) {
459
555
  var element = ref.current;
460
556
  element.addEventListener('onCommentClick', function (event) {
461
- if (onCommentClick) {
462
- onCommentClick(event === null || event === void 0 ? void 0 : event.detail);
557
+ if (onCommentClickRef.current) {
558
+ onCommentClickRef.current(event === null || event === void 0 ? void 0 : event.detail);
463
559
  }
464
560
  });
465
561
  }
@@ -485,12 +581,17 @@ var VeltCommentThread = function (props) {
485
581
  var VeltNotificationsTool = function (props) {
486
582
  var children = props.children, darkMode = props.darkMode, onNotificationClick = props.onNotificationClick;
487
583
  var ref = useRef();
584
+ var onNotificationClickRef = useRef(onNotificationClick);
585
+ // Update the ref to always point to the latest callback function
586
+ useEffect(function () {
587
+ onNotificationClickRef.current = onNotificationClick;
588
+ }, [onNotificationClick]);
488
589
  useEffect(function () {
489
590
  if (ref.current) {
490
591
  var element = ref.current;
491
592
  element.addEventListener('onNotificationClick', function (event) {
492
- if (onNotificationClick) {
493
- onNotificationClick(event === null || event === void 0 ? void 0 : event.detail);
593
+ if (onNotificationClickRef.current) {
594
+ onNotificationClickRef.current(event === null || event === void 0 ? void 0 : event.detail);
494
595
  }
495
596
  });
496
597
  }
@@ -501,12 +602,17 @@ var VeltNotificationsTool = function (props) {
501
602
  var VeltNotificationsPanel = function (props) {
502
603
  var darkMode = props.darkMode, onNotificationClick = props.onNotificationClick;
503
604
  var ref = useRef();
605
+ var onNotificationClickRef = useRef(onNotificationClick);
606
+ // Update the ref to always point to the latest callback function
607
+ useEffect(function () {
608
+ onNotificationClickRef.current = onNotificationClick;
609
+ }, [onNotificationClick]);
504
610
  useEffect(function () {
505
611
  if (ref.current) {
506
612
  var element = ref.current;
507
613
  element.addEventListener('onNotificationClick', function (event) {
508
- if (onNotificationClick) {
509
- onNotificationClick(event === null || event === void 0 ? void 0 : event.detail);
614
+ if (onNotificationClickRef.current) {
615
+ onNotificationClickRef.current(event === null || event === void 0 ? void 0 : event.detail);
510
616
  }
511
617
  });
512
618
  }
@@ -517,12 +623,17 @@ var VeltNotificationsPanel = function (props) {
517
623
  var VeltNotificationsHistoryPanel = function (props) {
518
624
  var embedMode = props.embedMode, darkMode = props.darkMode, onNotificationClick = props.onNotificationClick;
519
625
  var ref = useRef();
626
+ var onNotificationClickRef = useRef(onNotificationClick);
627
+ // Update the ref to always point to the latest callback function
628
+ useEffect(function () {
629
+ onNotificationClickRef.current = onNotificationClick;
630
+ }, [onNotificationClick]);
520
631
  useEffect(function () {
521
632
  if (ref.current) {
522
633
  var element = ref.current;
523
634
  element.addEventListener('onNotificationClick', function (event) {
524
- if (onNotificationClick) {
525
- onNotificationClick(event === null || event === void 0 ? void 0 : event.detail);
635
+ if (onNotificationClickRef.current) {
636
+ onNotificationClickRef.current(event === null || event === void 0 ? void 0 : event.detail);
526
637
  }
527
638
  });
528
639
  }
@@ -1873,18 +1984,45 @@ function useEditorAccessRequestHandler() {
1873
1984
  /**
1874
1985
  * @beta This hook is in beta
1875
1986
  */
1876
- function useLiveState(liveStateDataId, initialValue, debounceTime) {
1877
- if (debounceTime === void 0) { debounceTime = 50; }
1987
+ function useLiveState(liveStateDataId, initialValue, options) {
1878
1988
  var liveStateSyncElement = useLiveStateSyncUtils();
1879
- var _a = React.useState(initialValue), data = _a[0], setData = _a[1];
1989
+ var client = useVeltClient().client;
1990
+ var _a = React.useState(null), documentId = _a[0], setDocumentId = _a[1];
1991
+ var _b = React.useState(null), user = _b[0], setUser = _b[1];
1992
+ var _c = React.useState(initialValue), data = _c[0], setData = _c[1];
1993
+ useEffect(function () {
1994
+ resetLiveStateData();
1995
+ }, [documentId, user]);
1996
+ var resetLiveStateData = function () {
1997
+ if (user && documentId) {
1998
+ liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.setLiveStateData(liveStateDataId, data);
1999
+ }
2000
+ };
1880
2001
  useEffect(function () {
1881
2002
  if (!(liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.getLiveStateData))
1882
2003
  return;
2004
+ var documentPathsSubscription, userSubscription;
2005
+ if (options === null || options === void 0 ? void 0 : options.resetLiveState) {
2006
+ documentPathsSubscription = client.docService.getDocumentPaths$().subscribe(function (paths) {
2007
+ if (paths) {
2008
+ setDocumentId(paths === null || paths === void 0 ? void 0 : paths.documentId);
2009
+ documentPathsSubscription === null || documentPathsSubscription === void 0 ? void 0 : documentPathsSubscription.unsubscribe();
2010
+ }
2011
+ });
2012
+ userSubscription = client.authService.getUser$().subscribe(function (user) {
2013
+ if (user) {
2014
+ setUser(user);
2015
+ userSubscription === null || userSubscription === void 0 ? void 0 : userSubscription.unsubscribe();
2016
+ }
2017
+ });
2018
+ }
1883
2019
  var subscription = liveStateSyncElement.getLiveStateData(liveStateDataId).subscribe(function (res) {
1884
2020
  setData(res);
1885
2021
  });
1886
2022
  return function () {
1887
2023
  subscription.unsubscribe();
2024
+ documentPathsSubscription === null || documentPathsSubscription === void 0 ? void 0 : documentPathsSubscription.unsubscribe();
2025
+ userSubscription === null || userSubscription === void 0 ? void 0 : userSubscription.unsubscribe();
1888
2026
  };
1889
2027
  }, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.getLiveStateData]);
1890
2028
  var useDebounce = function (callback) {
@@ -1905,7 +2043,7 @@ function useLiveState(liveStateDataId, initialValue, debounceTime) {
1905
2043
  };
1906
2044
  var setDataFunction = function (value) {
1907
2045
  setData(value);
1908
- debouncedOnInput(value, debounceTime); // default 50ms debounce time
2046
+ debouncedOnInput(value, (options === null || options === void 0 ? void 0 : options.syncDuration) >= 0 ? options === null || options === void 0 ? void 0 : options.syncDuration : 50); // default 50ms debounce time
1909
2047
  };
1910
2048
  var debouncedOnInput = useDebounce(function (value) {
1911
2049
  if (liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.setLiveStateData) {