sanity 6.8.0-next.2 → 6.8.0-next.21

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 (141) hide show
  1. package/lib/{AddonDatasetProvider-DKjnqxwO.js → AddonDatasetProvider-Cp0gK33v.js} +2 -2
  2. package/lib/{AddonDatasetProvider-DKjnqxwO.js.map → AddonDatasetProvider-Cp0gK33v.js.map} +1 -1
  3. package/lib/{CalendarFilter-B5Bb9eze.js → CalendarFilter-Cgz5picy.js} +3 -3
  4. package/lib/{CalendarFilter-B5Bb9eze.js.map → CalendarFilter-Cgz5picy.js.map} +1 -1
  5. package/lib/{CommandList-Q4ua5avE.js → CommandList-BeDeX_Tr.js} +23 -6
  6. package/lib/CommandList-BeDeX_Tr.js.map +1 -0
  7. package/lib/{CommentsDocumentLayout-Brt2OR56.js → CommentsDocumentLayout-BJMRXrxl.js} +2 -2
  8. package/lib/{CommentsDocumentLayout-Brt2OR56.js.map → CommentsDocumentLayout-BJMRXrxl.js.map} +1 -1
  9. package/lib/{CommentsField-Cmmta6uT.js → CommentsField-DV6bhirZ.js} +3 -3
  10. package/lib/{CommentsField-Cmmta6uT.js.map → CommentsField-DV6bhirZ.js.map} +1 -1
  11. package/lib/{CommentsInput-C7Kq5XMu.js → CommentsInput-DQ4WCdZJ.js} +5 -5
  12. package/lib/{CommentsInput-C7Kq5XMu.js.map → CommentsInput-DQ4WCdZJ.js.map} +1 -1
  13. package/lib/{CommentsInspector-H5CpN_XH.js → CommentsInspector-PkVZw8uv.js} +5 -5
  14. package/lib/{CommentsInspector-H5CpN_XH.js.map → CommentsInspector-PkVZw8uv.js.map} +1 -1
  15. package/lib/{CommentsListItem-x7FKz_CM.js → CommentsListItem-BjWNEXPU.js} +3 -3
  16. package/lib/{CommentsListItem-x7FKz_CM.js.map → CommentsListItem-BjWNEXPU.js.map} +1 -1
  17. package/lib/{CommentsSelectedPathProvider-Bt8q7wL8.js → CommentsSelectedPathProvider-x5f1q0eW.js} +3 -3
  18. package/lib/{CommentsSelectedPathProvider-Bt8q7wL8.js.map → CommentsSelectedPathProvider-x5f1q0eW.js.map} +1 -1
  19. package/lib/{CommentsStudioLayout-BTJ8Jz1o.js → CommentsStudioLayout-CxZq2lGu.js} +4 -4
  20. package/lib/{CommentsStudioLayout-BTJ8Jz1o.js.map → CommentsStudioLayout-CxZq2lGu.js.map} +1 -1
  21. package/lib/{PaneContainer-D8iNUpZk.js → PaneContainer-B_cWaSSe.js} +8 -8
  22. package/lib/{PaneContainer-D8iNUpZk.js.map → PaneContainer-B_cWaSSe.js.map} +1 -1
  23. package/lib/{PresentationToolGrantsCheck-CxqDuu8I.js → PresentationToolGrantsCheck-CITNu5DG.js} +14 -6
  24. package/lib/PresentationToolGrantsCheck-CITNu5DG.js.map +1 -0
  25. package/lib/{ReleasesMetadataProvider-CZ8jrkBT.js → ReleasesMetadataProvider-CpYsTC5J.js} +2 -2
  26. package/lib/{ReleasesMetadataProvider-CZ8jrkBT.js.map → ReleasesMetadataProvider-CpYsTC5J.js.map} +1 -1
  27. package/lib/{ReleasesNav-BmGRLcrk.js → ReleasesNav-BuqDytPb.js} +59 -19
  28. package/lib/ReleasesNav-BuqDytPb.js.map +1 -0
  29. package/lib/{ReleasesStudioLayout-6V5oDb3h.js → ReleasesStudioLayout-mJZnbUum.js} +8 -8
  30. package/lib/{ReleasesStudioLayout-6V5oDb3h.js.map → ReleasesStudioLayout-mJZnbUum.js.map} +1 -1
  31. package/lib/{ReleasesTool-CMABMGcE.js → ReleasesTool-BFOV2VEc.js} +14 -14
  32. package/lib/{ReleasesTool-CMABMGcE.js.map → ReleasesTool-BFOV2VEc.js.map} +1 -1
  33. package/lib/{SchedulePublishingStudioLayout-BJDA4FBy.js → SchedulePublishingStudioLayout-D2ptE43I.js} +3 -3
  34. package/lib/{SchedulePublishingStudioLayout-BJDA4FBy.js.map → SchedulePublishingStudioLayout-D2ptE43I.js.map} +1 -1
  35. package/lib/{SchedulePublishingUpsellProvider-DfmpnFZz.js → SchedulePublishingUpsellProvider-DvCfqtdZ.js} +2 -2
  36. package/lib/{SchedulePublishingUpsellProvider-DfmpnFZz.js.map → SchedulePublishingUpsellProvider-DvCfqtdZ.js.map} +1 -1
  37. package/lib/{ScheduledPublishingEnabledProvider-C2jEx3t4.js → ScheduledPublishingEnabledProvider-B5yA7hHi.js} +3 -3
  38. package/lib/{ScheduledPublishingEnabledProvider-C2jEx3t4.js.map → ScheduledPublishingEnabledProvider-B5yA7hHi.js.map} +1 -1
  39. package/lib/{SearchProvider-Dk7IfeRS.js → SearchProvider-Cpl3WUyR.js} +25 -25
  40. package/lib/SearchProvider-Cpl3WUyR.js.map +1 -0
  41. package/lib/{SingleDocReleaseLayout-DW02L2zA.js → SingleDocReleaseLayout-CfPCP1Ur.js} +2 -2
  42. package/lib/{SingleDocReleaseLayout-DW02L2zA.js.map → SingleDocReleaseLayout-CfPCP1Ur.js.map} +1 -1
  43. package/lib/{SingleDocReleaseUpsellProvider-9OXN223n.js → SingleDocReleaseUpsellProvider-4ib7kMdI.js} +4 -4
  44. package/lib/{SingleDocReleaseUpsellProvider-9OXN223n.js.map → SingleDocReleaseUpsellProvider-4ib7kMdI.js.map} +1 -1
  45. package/lib/{TasksStudioActiveToolLayout-grF1qQvq.js → TasksStudioActiveToolLayout-lrH8y1Kh.js} +11 -11
  46. package/lib/{TasksStudioActiveToolLayout-grF1qQvq.js.map → TasksStudioActiveToolLayout-lrH8y1Kh.js.map} +1 -1
  47. package/lib/{TasksStudioLayout-Dq72bdM2.js → TasksStudioLayout-CITzoP_1.js} +5 -5
  48. package/lib/{TasksStudioLayout-Dq72bdM2.js.map → TasksStudioLayout-CITzoP_1.js.map} +1 -1
  49. package/lib/{Tool-DNTYDreC.js → Tool-DxqXi1AF.js} +12 -12
  50. package/lib/{Tool-DNTYDreC.js.map → Tool-DxqXi1AF.js.map} +1 -1
  51. package/lib/{UnpublishVersionDialog-B0kX1dt6.js → UnpublishVersionDialog-VZflky9U.js} +4 -4
  52. package/lib/{UnpublishVersionDialog-B0kX1dt6.js.map → UnpublishVersionDialog-VZflky9U.js.map} +1 -1
  53. package/lib/{UpsellDialog-B3IbZqLA.js → UpsellDialog-BmQSjdJg.js} +2 -2
  54. package/lib/{UpsellDialog-B3IbZqLA.js.map → UpsellDialog-BmQSjdJg.js.map} +1 -1
  55. package/lib/{VariantsStudioNavbar-N-cvStJh.js → VariantsStudioNavbar-HsA97lVy.js} +7 -27
  56. package/lib/VariantsStudioNavbar-HsA97lVy.js.map +1 -0
  57. package/lib/{VariantsTool-Bj3RjgBN.js → VariantsTool-rOcVMkln.js} +7 -7
  58. package/lib/{VariantsTool-Bj3RjgBN.js.map → VariantsTool-rOcVMkln.js.map} +1 -1
  59. package/lib/{WorkspaceLoader-BZD0-fj6.js → WorkspaceLoader-kepBjrsn.js} +25 -25
  60. package/lib/{WorkspaceLoader-BZD0-fj6.js.map → WorkspaceLoader-kepBjrsn.js.map} +1 -1
  61. package/lib/_createContext.js +1 -1
  62. package/lib/_singletons.d.ts +1 -1
  63. package/lib/{buildTextSelectionFromFragment-BXiSMql4.js → buildTextSelectionFromFragment-Dj_WBTDa.js} +3 -3
  64. package/lib/{buildTextSelectionFromFragment-BXiSMql4.js.map → buildTextSelectionFromFragment-Dj_WBTDa.js.map} +1 -1
  65. package/lib/{datastores-CFWEadl-.js → datastores-CrRYBoDP.js} +12 -2
  66. package/lib/datastores-CrRYBoDP.js.map +1 -0
  67. package/lib/desk.d.ts +1 -1
  68. package/lib/desk.js +2 -2
  69. package/lib/{index-Dhee2Ms1.d.ts → index-Bic9X2KM.d.ts} +43 -11
  70. package/lib/index.d.ts +2 -2
  71. package/lib/index.js +642 -258
  72. package/lib/index.js.map +1 -1
  73. package/lib/{inputResolver-BHxsuFDP.js → inputResolver-Czq6o5Gh.js} +4 -4
  74. package/lib/{inputResolver-BHxsuFDP.js.map → inputResolver-Czq6o5Gh.js.map} +1 -1
  75. package/lib/{list-CwENPuWS.js → list-BgF8Q_09.js} +2 -2
  76. package/lib/{list-CwENPuWS.js.map → list-BgF8Q_09.js.map} +1 -1
  77. package/lib/{navigation.telemetry-C6drHR5a.js → navigation.telemetry-DSG23KnM.js} +7 -7
  78. package/lib/{navigation.telemetry-C6drHR5a.js.map → navigation.telemetry-DSG23KnM.js.map} +1 -1
  79. package/lib/pane-BXoiwAkI.js +2 -0
  80. package/lib/pane-W85qO-M2.js +2 -0
  81. package/lib/{plugin-Cr5EXfrh.js → plugin-CLeQ5x8I.js} +4 -4
  82. package/lib/{plugin-Cr5EXfrh.js.map → plugin-CLeQ5x8I.js.map} +1 -1
  83. package/lib/{plugin-C1y-_vWr.js → plugin-CgIJubgG.js} +3 -3
  84. package/lib/{plugin-C1y-_vWr.js.map → plugin-CgIJubgG.js.map} +1 -1
  85. package/lib/{plugin-BHRmn24Q.js → plugin-CqWxiAAn.js} +6 -6
  86. package/lib/{plugin-BHRmn24Q.js.map → plugin-CqWxiAAn.js.map} +1 -1
  87. package/lib/{plugin-DkiEMpfN.js → plugin-DkdjF8sO.js} +5 -5
  88. package/lib/{plugin-DkiEMpfN.js.map → plugin-DkdjF8sO.js.map} +1 -1
  89. package/lib/presentation.js +1 -1
  90. package/lib/{scheduleItem-u5-b4stD.js → scheduleItem-CqReiIMI.js} +8 -8
  91. package/lib/{scheduleItem-u5-b4stD.js.map → scheduleItem-CqReiIMI.js.map} +1 -1
  92. package/lib/{schedules-D0WwNN6x.js → schedules-DoZXofxj.js} +3 -3
  93. package/lib/{schedules-D0WwNN6x.js.map → schedules-DoZXofxj.js.map} +1 -1
  94. package/lib/structure.js +2 -2
  95. package/lib/{structureTool-BCCGiqpF.js → structureTool-By2eJI8F.js} +60 -49
  96. package/lib/structureTool-By2eJI8F.js.map +1 -0
  97. package/lib/{structureTool-B5ch7u4I.js → structureTool-UGWPEr2I.js} +6 -6
  98. package/lib/{structureTool-B5ch7u4I.js.map → structureTool-UGWPEr2I.js.map} +1 -1
  99. package/lib/{studioClient-DvoDxN44.js → studioClient-DqAy4dnu.js} +2 -2
  100. package/lib/{studioClient-DvoDxN44.js.map → studioClient-DqAy4dnu.js.map} +1 -1
  101. package/lib/{useBundleDocuments-CWvP-dZI.js → useBundleDocuments-Dyop3VGZ.js} +15 -13
  102. package/lib/useBundleDocuments-Dyop3VGZ.js.map +1 -0
  103. package/lib/{useComments-KoRXRvW7.js → useComments-CzNBSPgQ.js} +3 -3
  104. package/lib/{useComments-KoRXRvW7.js.map → useComments-CzNBSPgQ.js.map} +1 -1
  105. package/lib/{useCommentsTelemetry-LlKtxi5d.js → useCommentsTelemetry-CkplhYJa.js} +3 -3
  106. package/lib/{useCommentsTelemetry-LlKtxi5d.js.map → useCommentsTelemetry-CkplhYJa.js.map} +1 -1
  107. package/lib/{useDocumentPreviewValues-DcVumcdT.js → useDocumentPreviewValues-BPzq1mWh.js} +3 -3
  108. package/lib/{useDocumentPreviewValues-DcVumcdT.js.map → useDocumentPreviewValues-BPzq1mWh.js.map} +1 -1
  109. package/lib/{useFeatureEnabled-D7BsN6xF.js → useFeatureEnabled-B_ywe2up.js} +2 -2
  110. package/lib/{useFeatureEnabled-D7BsN6xF.js.map → useFeatureEnabled-B_ywe2up.js.map} +1 -1
  111. package/lib/{useFieldActions-NrjLdjo8.js → useFieldActions-DbRTTr6-.js} +2 -2
  112. package/lib/{useFieldActions-NrjLdjo8.js.map → useFieldActions-DbRTTr6-.js.map} +1 -1
  113. package/lib/{useReleasesToolAvailable-Cki52QI6.js → useReleasesToolAvailable-CUvya3HF.js} +3 -3
  114. package/lib/{useReleasesToolAvailable-Cki52QI6.js.map → useReleasesToolAvailable-CUvya3HF.js.map} +1 -1
  115. package/lib/{useScheduledDraftMenuActions-DIa5I8rU.js → useScheduledDraftMenuActions-BBEMJkNE.js} +5 -5
  116. package/lib/{useScheduledDraftMenuActions-DIa5I8rU.js.map → useScheduledDraftMenuActions-BBEMJkNE.js.map} +1 -1
  117. package/lib/{useSetVariant-MvLHJC9A.js → useSetVariant-Cz8brFbQ.js} +3 -3
  118. package/lib/{useSetVariant-MvLHJC9A.js.map → useSetVariant-Cz8brFbQ.js.map} +1 -1
  119. package/lib/{useStudioUrl-DN_xMGIS.js → useStudioUrl-DFAbTA0R.js} +5 -5
  120. package/lib/{useStudioUrl-DN_xMGIS.js.map → useStudioUrl-DFAbTA0R.js.map} +1 -1
  121. package/lib/{useTimeZone-B5fBFjsR.js → useTimeZone-CNjAZCdC.js} +2 -2
  122. package/lib/{useTimeZone-B5fBFjsR.js.map → useTimeZone-CNjAZCdC.js.map} +1 -1
  123. package/lib/{userComponent-BQj9BWzn.js → userComponent-MPULaxdQ.js} +2 -2
  124. package/lib/{userComponent-BQj9BWzn.js.map → userComponent-MPULaxdQ.js.map} +1 -1
  125. package/lib/{validationUtils-RTzFL-p1.js → validationUtils-C9y0bJZd.js} +4 -4
  126. package/lib/{validationUtils-RTzFL-p1.js.map → validationUtils-C9y0bJZd.js.map} +1 -1
  127. package/lib/{version-CY300aPw.js → version-BZCsk4ue.js} +2 -2
  128. package/lib/{version-CY300aPw.js.map → version-BZCsk4ue.js.map} +1 -1
  129. package/package.json +12 -11
  130. package/lib/CommandList-Q4ua5avE.js.map +0 -1
  131. package/lib/Delay-DjgiAi06.js +0 -21
  132. package/lib/Delay-DjgiAi06.js.map +0 -1
  133. package/lib/PresentationToolGrantsCheck-CxqDuu8I.js.map +0 -1
  134. package/lib/ReleasesNav-BmGRLcrk.js.map +0 -1
  135. package/lib/SearchProvider-Dk7IfeRS.js.map +0 -1
  136. package/lib/VariantsStudioNavbar-N-cvStJh.js.map +0 -1
  137. package/lib/datastores-CFWEadl-.js.map +0 -1
  138. package/lib/pane-CEegQ2Kh.js +0 -2
  139. package/lib/pane-DHrjuFiG.js +0 -2
  140. package/lib/structureTool-BCCGiqpF.js.map +0 -1
  141. package/lib/useBundleDocuments-CWvP-dZI.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"CommentsField-Cmmta6uT.js","names":["useContext","CommentsAuthoringPathContext","CommentsAuthoringPathContextValue","useCommentsAuthoringPath","value","Error","AddCommentIcon","CommentIcon","CurrentUser","PortableTextBlock","Button","SanityUIButton","Flex","Stack","Text","useClickOutsideEvent","useCallback","useMemo","useRef","useState","styled","Popover","Tooltip","UserListWithPermissionsHookValue","useTranslation","Translate","useAddonDataset","CommentInput","CommentInputHandle","hasCommentMessageValue","commentsLocaleNamespace","CommentMessage","ContentStack","CommentsFieldButtonProps","count","currentUser","fieldTitle","isCreatingDataset","mentionOptions","onChange","value","onClick","onClose","onCommentAdd","onDiscard","onInputKeyDown","event","React","KeyboardEvent","open","CommentsFieldButton","props","$","_c","t","error","addonDatasetError","popoverRef","addCommentButtonElement","setAddCommentButtonElement","commentInputHandle","hasComments","Boolean","t0","focus","closePopover","t1","nextValue","handleSubmit","t2","hasValue","t3","current","discardDialogController","startDiscard","t4","isDefaultPrevented","handleInputKeyDown","t5","Symbol","for","close","handleDiscardCancel","t6","handleDiscardConfirm","t7","event_0","key","preventDefault","stopPropagation","handlePopoverKeyDown","t8","t9","field","t10","placeholder","t11","content","t12","t13","t14","t15","t16","placement","t17","t18","hues","Path","PortableTextBlock","Stack","useBoundaryElement","PathUtils","uuid","AnimatePresence","motion","Variants","useCallback","useMemo","useRef","useState","css","styled","FieldProps","getSchemaTypeTitle","useCurrentUser","COMMENTS_HIGHLIGHT_HUE_KEY","isTextSelectionComment","parseCommentFieldPath","useComments","useCommentsAuthoringPath","useCommentsEnabled","applyCommentsFieldAttr","useCommentsScroll","useCommentsSelectedPath","useCommentsUpsell","CommentCreatePayload","CommentMessage","CommentsUIMode","CommentsFieldButton","messageCache","Map","EMPTY_ARRAY","HIGHLIGHT_BLOCK_VARIANTS","initial","opacity","animate","exit","CommentsField","props","$","_c","enabled","mode","t0","renderDefault","HighlightDiv","div","theme","radius","space","color","sanity","bg","dark","hex","FieldStack","CommentFieldInner","currentUser","element","boundaryElement","rootRef","comments","isCommentsOpen","isCreatingDataset","mentionOptions","onCommentsOpen","operation","setStatus","status","upsellData","handleOpenDialog","selectedPath","setSelectedPath","authoringPath","setAuthoringPath","scrollToGroup","t1","schemaType","fieldTitle","t2","path","toString","stringPath","t3","get","cachedValue","value","setValue","isOpen","t4","fieldPath","origin","belongsToField","t5","isSelected","threadId","t6","data","open","t7","c","filter","some","_temp","isInlineCommentThread","t8","c_0","commentsCount","map","reduce","_temp2","count","hasComments","Boolean","delete","resetMessageValue","t9","latestThread","find","c_1","handleClick","t10","nextValue","newThreadId","nextComment","type","message","parentCommentId","undefined","reactions","create","handleCommentAdd","t11","handleClose","t12","nextValue_0","set","handleOnChange","t13","Number","t14","button","isAddingComment","internalComments","t15","t16","__internal_comments","t17","t18","t19","acc","val","x","parentComment","commentFieldPath","startsWith"],"sources":["../src/core/comments/hooks/useCommentsAuthoringPath.ts","../src/core/comments/plugin/field/CommentsFieldButton.tsx","../src/core/comments/plugin/field/CommentsField.tsx"],"sourcesContent":["import {useContext} from 'react'\nimport {CommentsAuthoringPathContext} from 'sanity/_singletons'\n\nimport {type CommentsAuthoringPathContextValue} from '../context/authoring-path/types'\n\n/**\n * @beta\n * @hidden\n */\nexport function useCommentsAuthoringPath(): CommentsAuthoringPathContextValue {\n const value = useContext(CommentsAuthoringPathContext)\n\n if (!value) {\n throw new Error('useCommentsAuthoringPath: missing context value')\n }\n\n return value\n}\n","import {AddCommentIcon} from '@sanity/icons/AddComment'\nimport {CommentIcon} from '@sanity/icons/Comment'\nimport {type CurrentUser, type PortableTextBlock} from '@sanity/types'\nimport {\n // oxlint-disable-next-line no-restricted-imports\n Button as SanityUIButton,\n Flex,\n Stack,\n Text,\n useClickOutsideEvent,\n} from '@sanity/ui'\nimport {useCallback, useMemo, useRef, useState} from 'react'\nimport {styled} from 'styled-components'\n\nimport {Button} from '../../../../ui-components/button/Button'\nimport {Popover} from '../../../../ui-components/popover/Popover'\nimport {Tooltip} from '../../../../ui-components/tooltip/Tooltip'\nimport {type UserListWithPermissionsHookValue} from '../../../hooks/useUserListWithPermissions'\nimport {useTranslation} from '../../../i18n/hooks/useTranslation'\nimport {Translate} from '../../../i18n/Translate'\nimport {useAddonDataset} from '../../../studio/addonDataset/useAddonDataset'\nimport {\n CommentInput,\n type CommentInputHandle,\n} from '../../components/pte/comment-input/CommentInput'\nimport {hasCommentMessageValue} from '../../helpers'\nimport {commentsLocaleNamespace} from '../../i18n'\nimport {type CommentMessage} from '../../types'\n\nconst ContentStack = styled(Stack)`\n width: 320px;\n`\n\ninterface CommentsFieldButtonProps {\n count: number\n currentUser: CurrentUser\n fieldTitle: string\n isCreatingDataset: boolean\n mentionOptions: UserListWithPermissionsHookValue\n onChange: (value: PortableTextBlock[]) => void\n onClick?: () => void\n onClose: () => void\n onCommentAdd: (value: PortableTextBlock[]) => void\n onDiscard: () => void\n onInputKeyDown?: (event: React.KeyboardEvent) => void\n open: boolean\n value: CommentMessage\n}\n\nexport function CommentsFieldButton(props: CommentsFieldButtonProps) {\n const {\n count,\n currentUser,\n fieldTitle,\n isCreatingDataset,\n mentionOptions,\n onChange,\n onClick,\n onClose,\n onCommentAdd,\n onDiscard,\n onInputKeyDown,\n open,\n value,\n } = props\n const {t} = useTranslation(commentsLocaleNamespace)\n const {error: addonDatasetError} = useAddonDataset()\n const popoverRef = useRef<HTMLDivElement | null>(null)\n const [addCommentButtonElement, setAddCommentButtonElement] = useState<HTMLButtonElement | null>(\n null,\n )\n const commentInputHandle = useRef<CommentInputHandle | null>(null)\n const hasComments = Boolean(count > 0)\n\n const closePopover = useCallback(() => {\n if (!open) return\n onClose()\n addCommentButtonElement?.focus()\n }, [addCommentButtonElement, open, onClose])\n\n const handleSubmit = useCallback(\n (nextValue: PortableTextBlock[]) => {\n onCommentAdd(nextValue)\n closePopover()\n },\n [closePopover, onCommentAdd],\n )\n\n const hasValue = useMemo(() => hasCommentMessageValue(value), [value])\n\n const startDiscard = useCallback(() => {\n if (!hasValue) {\n closePopover()\n return\n }\n\n commentInputHandle.current?.discardDialogController.open()\n }, [closePopover, hasValue])\n\n const handleInputKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n // Don't act if the input already prevented this event\n if (event.isDefaultPrevented()) {\n return\n }\n\n // Call parent handler\n if (onInputKeyDown) onInputKeyDown(event)\n },\n [onInputKeyDown],\n )\n\n const handleDiscardCancel = useCallback(() => {\n commentInputHandle.current?.discardDialogController.close()\n }, [])\n\n const handleDiscardConfirm = useCallback(() => {\n commentInputHandle.current?.discardDialogController.close()\n closePopover()\n onDiscard()\n }, [closePopover, onDiscard])\n\n const handlePopoverKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n event.preventDefault()\n event.stopPropagation()\n startDiscard()\n }\n },\n [startDiscard],\n )\n\n useClickOutsideEvent(!open && startDiscard, () => [popoverRef.current])\n\n if (!hasComments) {\n const placeholder = (\n <Translate\n t={t}\n i18nKey=\"compose.add-comment-input-placeholder\"\n values={{field: fieldTitle}}\n />\n )\n\n const content = (\n <ContentStack padding={2} space={4}>\n <CommentInput\n currentUser={currentUser}\n focusLock\n focusOnMount\n mentionOptions={mentionOptions}\n onChange={onChange}\n onDiscardCancel={handleDiscardCancel}\n onDiscardConfirm={handleDiscardConfirm}\n onKeyDown={handleInputKeyDown}\n onSubmit={handleSubmit}\n placeholder={placeholder}\n readOnly={isCreatingDataset}\n ref={commentInputHandle}\n value={value}\n />\n </ContentStack>\n )\n\n return (\n <Popover\n constrainSize\n content={content}\n fallbackPlacements={['bottom-end']}\n open={open}\n placement=\"right-start\"\n portal\n ref={popoverRef}\n onKeyDown={handlePopoverKeyDown}\n >\n <div>\n <Button\n aria-label={t('field-button.aria-label-add')}\n disabled={isCreatingDataset || Boolean(addonDatasetError)}\n icon={AddCommentIcon}\n mode=\"bleed\"\n onClick={onClick}\n ref={setAddCommentButtonElement}\n selected={open}\n tooltipProps={{\n content: t('field-button.title'),\n placement: 'top',\n }}\n />\n </div>\n </Popover>\n )\n }\n\n return (\n <Tooltip portal placement=\"top\" content={t('field-button.content', {count})}>\n <SanityUIButton\n aria-label={t('field-button.aria-label-open')}\n mode=\"bleed\"\n onClick={onClick}\n padding={2}\n space={2}\n >\n <Flex align=\"center\" gap={2}>\n <Text size={1}>\n <CommentIcon />\n </Text>\n <Text size={0}>{count > 9 ? '9+' : count}</Text>\n </Flex>\n </SanityUIButton>\n </Tooltip>\n )\n}\n","import {hues} from '@sanity/color'\nimport {type Path, type PortableTextBlock} from '@sanity/types'\nimport {Stack, useBoundaryElement} from '@sanity/ui'\nimport * as PathUtils from '@sanity/util/paths'\nimport {uuid} from '@sanity/uuid'\nimport {AnimatePresence, motion, type Variants} from 'motion/react'\nimport {useCallback, useMemo, useRef, useState} from 'react'\nimport {css, styled} from 'styled-components'\n\nimport {type FieldProps} from '../../../form/types/fieldProps'\nimport {getSchemaTypeTitle} from '../../../schema/helpers'\nimport {useCurrentUser} from '../../../store/user/hooks'\nimport {COMMENTS_HIGHLIGHT_HUE_KEY} from '../../constants'\nimport {isTextSelectionComment, parseCommentFieldPath} from '../../helpers'\nimport {useComments} from '../../hooks/useComments'\nimport {useCommentsAuthoringPath} from '../../hooks/useCommentsAuthoringPath'\nimport {useCommentsEnabled} from '../../hooks/useCommentsEnabled'\nimport {applyCommentsFieldAttr, useCommentsScroll} from '../../hooks/useCommentsScroll'\nimport {useCommentsSelectedPath} from '../../hooks/useCommentsSelectedPath'\nimport {useCommentsUpsell} from '../../hooks/useCommentsUpsell'\nimport {type CommentCreatePayload, type CommentMessage, type CommentsUIMode} from '../../types'\nimport {CommentsFieldButton} from './CommentsFieldButton'\n\n// When the form is temporarily set to `readOnly` while reconnecting, the form\n// will be re-rendered and any comment that is being authored will be lost.\n// To avoid this, we cache the comment message in a map and restore it when the\n// field is re-rendered.\nconst messageCache = new Map<string, CommentMessage>()\n\nconst EMPTY_ARRAY: [] = []\n\nconst HIGHLIGHT_BLOCK_VARIANTS: Variants = {\n initial: {\n opacity: 0,\n },\n animate: {\n opacity: 1,\n },\n exit: {\n opacity: 0,\n },\n}\n\nexport function CommentsField(props: FieldProps) {\n const {enabled, mode} = useCommentsEnabled()\n\n if (!enabled) {\n return props.renderDefault(props)\n }\n\n return <CommentFieldInner {...props} mode={mode} />\n}\n\nconst HighlightDiv = styled(motion.div)(({theme}) => {\n const {radius, space, color} = theme.sanity\n const bg = hues[COMMENTS_HIGHLIGHT_HUE_KEY][color.dark ? 900 : 50].hex\n\n return css`\n mix-blend-mode: ${color.dark ? 'screen' : 'multiply'};\n border-radius: ${radius[3]}px;\n top: -${space[2]}px;\n left: -${space[2]}px;\n bottom: -${space[2]}px;\n right: -${space[2]}px;\n pointer-events: none;\n position: absolute;\n z-index: 1;\n width: calc(100% + ${space[2] * 2}px);\n height: calc(100% + ${space[2] * 2}px);\n background-color: ${bg};\n `\n})\n\nconst FieldStack = styled(Stack)`\n position: relative;\n\n // Hide when the field component renders nothing (e.g. a custom\n // field component that returns null) to avoid an empty wrapper\n // taking up space in the form.\n &:empty:not([hidden]) {\n display: none;\n }\n`\n\nfunction CommentFieldInner(\n props: FieldProps & {\n mode: CommentsUIMode\n },\n) {\n const {mode} = props\n\n const currentUser = useCurrentUser()\n const {element: boundaryElement} = useBoundaryElement()\n\n const rootRef = useRef<HTMLDivElement | null>(null)\n\n const {\n comments,\n isCommentsOpen,\n isCreatingDataset,\n mentionOptions,\n onCommentsOpen,\n operation,\n setStatus,\n status,\n } = useComments()\n const {upsellData, handleOpenDialog} = useCommentsUpsell()\n const {selectedPath, setSelectedPath} = useCommentsSelectedPath()\n const {authoringPath, setAuthoringPath} = useCommentsAuthoringPath()\n const {scrollToGroup} = useCommentsScroll({\n boundaryElement,\n })\n\n const fieldTitle = useMemo(() => getSchemaTypeTitle(props.schemaType), [props.schemaType])\n const stringPath = useMemo(() => PathUtils.toString(props.path), [props.path])\n\n // Use the cached value if it exists as the initial value\n const cachedValue = messageCache.get(stringPath) || null\n\n const [value, setValue] = useState<PortableTextBlock[] | null>(cachedValue)\n\n // If the path of the field matches the authoring path, the comment input should be open.\n const isOpen = useMemo(() => authoringPath === stringPath, [authoringPath, stringPath])\n\n // Determine if the current field is selected\n const isSelected = useMemo(() => {\n if (!isCommentsOpen) return false\n if (selectedPath?.origin === 'form' || selectedPath?.origin === 'url') return false\n return belongsToField(selectedPath?.fieldPath, props.path)\n }, [isCommentsOpen, selectedPath?.fieldPath, selectedPath?.origin, props.path])\n\n const isInlineCommentThread = useMemo(() => {\n return comments.data.open\n .filter((c) => c.threadId === selectedPath?.threadId)\n .some((x) => isTextSelectionComment(x.parentComment))\n }, [comments.data.open, selectedPath?.threadId])\n\n // Total number of comments for the current field, including comments on\n // blocks nested below it (container-nested and dialog-authored comments\n // store the block's data path as their `fieldPath`).\n const count = useMemo(() => {\n const commentsCount = comments.data.open\n .map((c) => (belongsToField(c.fieldPath, props.path) ? c.commentsCount : 0))\n .reduce((acc, val) => acc + val, 0)\n\n return commentsCount || 0\n }, [comments.data.open, props.path])\n\n const hasComments = Boolean(count > 0)\n\n const resetMessageValue = useCallback(() => {\n // Reset the value and remove the message from the cache\n setValue(null)\n messageCache.delete(stringPath)\n }, [stringPath])\n\n const handleClick = useCallback(() => {\n // When clicking a comment button when the field has comments, we want to:\n if (hasComments) {\n // 1. Change the status to 'open' if it's 'resolved'\n if (status === 'resolved') {\n setStatus('open')\n }\n\n // 2. Ensure that the authoring path is reset when clicking\n // the comment button when the field has comments.\n setAuthoringPath(null)\n\n // 3. Open the comments inspector\n onCommentsOpen?.()\n\n // 4. Find the latest comment thread for the current field\n const latestThread = comments.data.open.find((c) => belongsToField(c.fieldPath, props.path))\n\n // 5. Set the latest thread ID as the selected thread ID\n // and scroll to the it. The selected path carries the thread's own\n // `fieldPath`: the inspector marks a thread selected by comparing\n // against the stored path, which for nested threads is deeper than\n // this field's path.\n if (latestThread) {\n setSelectedPath({\n threadId: latestThread.threadId,\n origin: 'form',\n fieldPath: latestThread.fieldPath,\n })\n\n scrollToGroup(latestThread.threadId)\n }\n\n return\n }\n\n if (mode === 'upsell') {\n if (upsellData) {\n handleOpenDialog('field_action')\n } else {\n // Open the comments inspector\n onCommentsOpen?.()\n }\n return\n }\n\n // If the field is open (i.e. the authoring path is set to the current field)\n // we close the field by resetting the authoring path. If the field is not open,\n // we set the authoring path to the current field so that the comment form is opened.\n setAuthoringPath(isOpen ? null : stringPath)\n }, [\n comments.data.open,\n handleOpenDialog,\n hasComments,\n isOpen,\n mode,\n onCommentsOpen,\n props.path,\n scrollToGroup,\n setAuthoringPath,\n setSelectedPath,\n setStatus,\n status,\n stringPath,\n upsellData,\n ])\n\n const handleCommentAdd = useCallback(\n (nextValue: PortableTextBlock[]) => {\n if (nextValue) {\n // Since this is a new comment, we generate a new thread ID\n const newThreadId = uuid()\n\n // Construct the comment payload\n const nextComment: CommentCreatePayload = {\n type: 'field',\n fieldPath: PathUtils.toString(props.path),\n message: nextValue,\n parentCommentId: undefined,\n status: 'open',\n threadId: newThreadId,\n // New comments have no reactions\n reactions: EMPTY_ARRAY,\n }\n\n // Execute the create mutation\n void operation.create(nextComment)\n\n // If a comment is added to a field when viewing resolved comments, we switch\n // to open comments and scroll to the comment that was just added\n // Open the inspector when a new comment is added\n onCommentsOpen?.()\n\n if (status === 'resolved') {\n // Set the status to 'open' so that the comment is visible\n setStatus('open')\n }\n\n resetMessageValue()\n\n // Scroll to the thread\n setSelectedPath({\n threadId: newThreadId,\n origin: 'form',\n fieldPath: PathUtils.toString(props.path),\n })\n\n scrollToGroup(newThreadId)\n }\n },\n [\n onCommentsOpen,\n operation,\n props.path,\n resetMessageValue,\n scrollToGroup,\n setSelectedPath,\n setStatus,\n status,\n ],\n )\n\n const handleClose = useCallback(() => setAuthoringPath(null), [setAuthoringPath])\n\n const handleOnChange = useCallback(\n (nextValue: CommentMessage) => {\n setValue(nextValue)\n messageCache.set(stringPath, nextValue)\n },\n [stringPath],\n )\n\n const internalComments: FieldProps['__internal_comments'] = useMemo(\n () => ({\n button: currentUser && (\n <CommentsFieldButton\n count={Number(count)}\n currentUser={currentUser}\n fieldTitle={fieldTitle}\n isCreatingDataset={isCreatingDataset}\n mentionOptions={mentionOptions}\n onChange={handleOnChange}\n onClick={handleClick}\n onClose={handleClose}\n onCommentAdd={handleCommentAdd}\n onDiscard={resetMessageValue}\n open={isOpen}\n value={value}\n />\n ),\n hasComments,\n isAddingComment: isOpen,\n }),\n [\n currentUser,\n count,\n fieldTitle,\n isCreatingDataset,\n mentionOptions,\n handleOnChange,\n handleClick,\n handleClose,\n handleCommentAdd,\n resetMessageValue,\n isOpen,\n value,\n hasComments,\n ],\n )\n\n return (\n <FieldStack {...applyCommentsFieldAttr(PathUtils.toString(props.path))} ref={rootRef}>\n {props.renderDefault({\n ...props,\n __internal_comments: internalComments,\n })}\n\n <AnimatePresence>\n {isSelected && !isInlineCommentThread && (\n <HighlightDiv\n animate=\"animate\"\n exit=\"exit\"\n initial=\"initial\"\n variants={HIGHLIGHT_BLOCK_VARIANTS}\n />\n )}\n </AnimatePresence>\n </FieldStack>\n )\n}\n\n/**\n * Whether a comment's stored `fieldPath` sits at or below the field's path.\n */\nfunction belongsToField(fieldPath: string | null | undefined, path: Path): boolean {\n const commentFieldPath = parseCommentFieldPath(fieldPath)\n return commentFieldPath ? PathUtils.startsWith(path, commentFieldPath) : false\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,SAAOG,2BAAA;CACL,IAAAC,QAAcJ,WAAWC,4BAA4B;CAErD,IAAI,CAACG,OACH,MAAUC,MAAM,iDAAiD;CAClE,OAEMD;AAAK;ACad,MAAM4B,eAAeZ,OAAOP,KAAK,CAAC,CAAA,WAAA;;;;AAoBlC,SAAOqC,oBAAAC,OAAA;CAAA,IAAAC,IAAAC,EAAA,EAAA,GACL,EAAAnB,OAAAC,aAAAC,YAAAC,mBAAAC,gBAAAC,UAAAE,SAAAC,SAAAC,cAAAC,WAAAC,gBAAAI,MAAAT,UAcIW,OACJ,EAAAG,MAAY9B,eAAeM,uBAAuB,GAClD,EAAAyB,OAAAC,sBAAmC9B,gBAAgB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G,EAAA,QAAA4G,MACeC,MAAA7G,EAAA,OATlB6G,MAAA,oBAAC,iBAAD,EAAA,UACGD,IADa,CAAA,GASE5G,EAAA,MAAA4G,KAAA5G,EAAA,MAAA6G;CAAA,IAAAC;CACP,OADO9G,EAAA,QAAAyG,OAAAzG,EAAA,QAAA0G,OAAA1G,EAAA,QAAA6G,OAfpBC,MAAA,qBAAC,YAAD;EAAW,GAAKL;EAA6DpF,KAAAA;EAA7E,UAAA,CACGqF,KAKDG,GANS;KAgBE7G,EAAA,MAAAyG,KAAAzG,EAAA,MAAA0G,KAAA1G,EAAA,MAAA6G,KAAA7G,EAAA,MAAA8G,OAAAA,MAAA9G,EAAA,KAhBb8G;AAgBa;;;;AAnQjB,SAAAvC,OAAAwC,KAAAC,KAAA;CAAA,OA2D4BD,MAAMC;AAAG;AA3DrC,SAAAhD,MAAAiD,GAAA;CAAA,OAkDmBxI,uBAAuBwI,EAACC,aAAc;AAAC;AAwN1D,SAAS7D,eAAeF,WAAsCV,MAAqB;CACjF,IAAM0E,mBAAmBzI,sBAAsByE,SAAS;CACxD,OAAOgE,mBAAmBzJ,UAAU0J,WAAW3E,MAAM0E,gBAAgB,IAAI;AAC3E"}
1
+ {"version":3,"file":"CommentsField-DV6bhirZ.js","names":["useContext","CommentsAuthoringPathContext","CommentsAuthoringPathContextValue","useCommentsAuthoringPath","value","Error","AddCommentIcon","CommentIcon","CurrentUser","PortableTextBlock","Button","SanityUIButton","Flex","Stack","Text","useClickOutsideEvent","useCallback","useMemo","useRef","useState","styled","Popover","Tooltip","UserListWithPermissionsHookValue","useTranslation","Translate","useAddonDataset","CommentInput","CommentInputHandle","hasCommentMessageValue","commentsLocaleNamespace","CommentMessage","ContentStack","CommentsFieldButtonProps","count","currentUser","fieldTitle","isCreatingDataset","mentionOptions","onChange","value","onClick","onClose","onCommentAdd","onDiscard","onInputKeyDown","event","React","KeyboardEvent","open","CommentsFieldButton","props","$","_c","t","error","addonDatasetError","popoverRef","addCommentButtonElement","setAddCommentButtonElement","commentInputHandle","hasComments","Boolean","t0","focus","closePopover","t1","nextValue","handleSubmit","t2","hasValue","t3","current","discardDialogController","startDiscard","t4","isDefaultPrevented","handleInputKeyDown","t5","Symbol","for","close","handleDiscardCancel","t6","handleDiscardConfirm","t7","event_0","key","preventDefault","stopPropagation","handlePopoverKeyDown","t8","t9","field","t10","placeholder","t11","content","t12","t13","t14","t15","t16","placement","t17","t18","hues","Path","PortableTextBlock","Stack","useBoundaryElement","PathUtils","uuid","AnimatePresence","motion","Variants","useCallback","useMemo","useRef","useState","css","styled","FieldProps","getSchemaTypeTitle","useCurrentUser","COMMENTS_HIGHLIGHT_HUE_KEY","isTextSelectionComment","parseCommentFieldPath","useComments","useCommentsAuthoringPath","useCommentsEnabled","applyCommentsFieldAttr","useCommentsScroll","useCommentsSelectedPath","useCommentsUpsell","CommentCreatePayload","CommentMessage","CommentsUIMode","CommentsFieldButton","messageCache","Map","EMPTY_ARRAY","HIGHLIGHT_BLOCK_VARIANTS","initial","opacity","animate","exit","CommentsField","props","$","_c","enabled","mode","t0","renderDefault","HighlightDiv","div","theme","radius","space","color","sanity","bg","dark","hex","FieldStack","CommentFieldInner","currentUser","element","boundaryElement","rootRef","comments","isCommentsOpen","isCreatingDataset","mentionOptions","onCommentsOpen","operation","setStatus","status","upsellData","handleOpenDialog","selectedPath","setSelectedPath","authoringPath","setAuthoringPath","scrollToGroup","t1","schemaType","fieldTitle","t2","path","toString","stringPath","t3","get","cachedValue","value","setValue","isOpen","t4","fieldPath","origin","belongsToField","t5","isSelected","threadId","t6","data","open","t7","c","filter","some","_temp","isInlineCommentThread","t8","c_0","commentsCount","map","reduce","_temp2","count","hasComments","Boolean","delete","resetMessageValue","t9","latestThread","find","c_1","handleClick","t10","nextValue","newThreadId","nextComment","type","message","parentCommentId","undefined","reactions","create","handleCommentAdd","t11","handleClose","t12","nextValue_0","set","handleOnChange","t13","Number","t14","button","isAddingComment","internalComments","t15","t16","__internal_comments","t17","t18","t19","acc","val","x","parentComment","commentFieldPath","startsWith"],"sources":["../src/core/comments/hooks/useCommentsAuthoringPath.ts","../src/core/comments/plugin/field/CommentsFieldButton.tsx","../src/core/comments/plugin/field/CommentsField.tsx"],"sourcesContent":["import {useContext} from 'react'\nimport {CommentsAuthoringPathContext} from 'sanity/_singletons'\n\nimport {type CommentsAuthoringPathContextValue} from '../context/authoring-path/types'\n\n/**\n * @beta\n * @hidden\n */\nexport function useCommentsAuthoringPath(): CommentsAuthoringPathContextValue {\n const value = useContext(CommentsAuthoringPathContext)\n\n if (!value) {\n throw new Error('useCommentsAuthoringPath: missing context value')\n }\n\n return value\n}\n","import {AddCommentIcon} from '@sanity/icons/AddComment'\nimport {CommentIcon} from '@sanity/icons/Comment'\nimport {type CurrentUser, type PortableTextBlock} from '@sanity/types'\nimport {\n // oxlint-disable-next-line no-restricted-imports\n Button as SanityUIButton,\n Flex,\n Stack,\n Text,\n useClickOutsideEvent,\n} from '@sanity/ui'\nimport {useCallback, useMemo, useRef, useState} from 'react'\nimport {styled} from 'styled-components'\n\nimport {Button} from '../../../../ui-components/button/Button'\nimport {Popover} from '../../../../ui-components/popover/Popover'\nimport {Tooltip} from '../../../../ui-components/tooltip/Tooltip'\nimport {type UserListWithPermissionsHookValue} from '../../../hooks/useUserListWithPermissions'\nimport {useTranslation} from '../../../i18n/hooks/useTranslation'\nimport {Translate} from '../../../i18n/Translate'\nimport {useAddonDataset} from '../../../studio/addonDataset/useAddonDataset'\nimport {\n CommentInput,\n type CommentInputHandle,\n} from '../../components/pte/comment-input/CommentInput'\nimport {hasCommentMessageValue} from '../../helpers'\nimport {commentsLocaleNamespace} from '../../i18n'\nimport {type CommentMessage} from '../../types'\n\nconst ContentStack = styled(Stack)`\n width: 320px;\n`\n\ninterface CommentsFieldButtonProps {\n count: number\n currentUser: CurrentUser\n fieldTitle: string\n isCreatingDataset: boolean\n mentionOptions: UserListWithPermissionsHookValue\n onChange: (value: PortableTextBlock[]) => void\n onClick?: () => void\n onClose: () => void\n onCommentAdd: (value: PortableTextBlock[]) => void\n onDiscard: () => void\n onInputKeyDown?: (event: React.KeyboardEvent) => void\n open: boolean\n value: CommentMessage\n}\n\nexport function CommentsFieldButton(props: CommentsFieldButtonProps) {\n const {\n count,\n currentUser,\n fieldTitle,\n isCreatingDataset,\n mentionOptions,\n onChange,\n onClick,\n onClose,\n onCommentAdd,\n onDiscard,\n onInputKeyDown,\n open,\n value,\n } = props\n const {t} = useTranslation(commentsLocaleNamespace)\n const {error: addonDatasetError} = useAddonDataset()\n const popoverRef = useRef<HTMLDivElement | null>(null)\n const [addCommentButtonElement, setAddCommentButtonElement] = useState<HTMLButtonElement | null>(\n null,\n )\n const commentInputHandle = useRef<CommentInputHandle | null>(null)\n const hasComments = Boolean(count > 0)\n\n const closePopover = useCallback(() => {\n if (!open) return\n onClose()\n addCommentButtonElement?.focus()\n }, [addCommentButtonElement, open, onClose])\n\n const handleSubmit = useCallback(\n (nextValue: PortableTextBlock[]) => {\n onCommentAdd(nextValue)\n closePopover()\n },\n [closePopover, onCommentAdd],\n )\n\n const hasValue = useMemo(() => hasCommentMessageValue(value), [value])\n\n const startDiscard = useCallback(() => {\n if (!hasValue) {\n closePopover()\n return\n }\n\n commentInputHandle.current?.discardDialogController.open()\n }, [closePopover, hasValue])\n\n const handleInputKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n // Don't act if the input already prevented this event\n if (event.isDefaultPrevented()) {\n return\n }\n\n // Call parent handler\n if (onInputKeyDown) onInputKeyDown(event)\n },\n [onInputKeyDown],\n )\n\n const handleDiscardCancel = useCallback(() => {\n commentInputHandle.current?.discardDialogController.close()\n }, [])\n\n const handleDiscardConfirm = useCallback(() => {\n commentInputHandle.current?.discardDialogController.close()\n closePopover()\n onDiscard()\n }, [closePopover, onDiscard])\n\n const handlePopoverKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n event.preventDefault()\n event.stopPropagation()\n startDiscard()\n }\n },\n [startDiscard],\n )\n\n useClickOutsideEvent(!open && startDiscard, () => [popoverRef.current])\n\n if (!hasComments) {\n const placeholder = (\n <Translate\n t={t}\n i18nKey=\"compose.add-comment-input-placeholder\"\n values={{field: fieldTitle}}\n />\n )\n\n const content = (\n <ContentStack padding={2} space={4}>\n <CommentInput\n currentUser={currentUser}\n focusLock\n focusOnMount\n mentionOptions={mentionOptions}\n onChange={onChange}\n onDiscardCancel={handleDiscardCancel}\n onDiscardConfirm={handleDiscardConfirm}\n onKeyDown={handleInputKeyDown}\n onSubmit={handleSubmit}\n placeholder={placeholder}\n readOnly={isCreatingDataset}\n ref={commentInputHandle}\n value={value}\n />\n </ContentStack>\n )\n\n return (\n <Popover\n constrainSize\n content={content}\n fallbackPlacements={['bottom-end']}\n open={open}\n placement=\"right-start\"\n portal\n ref={popoverRef}\n onKeyDown={handlePopoverKeyDown}\n >\n <div>\n <Button\n aria-label={t('field-button.aria-label-add')}\n disabled={isCreatingDataset || Boolean(addonDatasetError)}\n icon={AddCommentIcon}\n mode=\"bleed\"\n onClick={onClick}\n ref={setAddCommentButtonElement}\n selected={open}\n tooltipProps={{\n content: t('field-button.title'),\n placement: 'top',\n }}\n />\n </div>\n </Popover>\n )\n }\n\n return (\n <Tooltip portal placement=\"top\" content={t('field-button.content', {count})}>\n <SanityUIButton\n aria-label={t('field-button.aria-label-open')}\n mode=\"bleed\"\n onClick={onClick}\n padding={2}\n space={2}\n >\n <Flex align=\"center\" gap={2}>\n <Text size={1}>\n <CommentIcon />\n </Text>\n <Text size={0}>{count > 9 ? '9+' : count}</Text>\n </Flex>\n </SanityUIButton>\n </Tooltip>\n )\n}\n","import {hues} from '@sanity/color'\nimport {type Path, type PortableTextBlock} from '@sanity/types'\nimport {Stack, useBoundaryElement} from '@sanity/ui'\nimport * as PathUtils from '@sanity/util/paths'\nimport {uuid} from '@sanity/uuid'\nimport {AnimatePresence, motion, type Variants} from 'motion/react'\nimport {useCallback, useMemo, useRef, useState} from 'react'\nimport {css, styled} from 'styled-components'\n\nimport {type FieldProps} from '../../../form/types/fieldProps'\nimport {getSchemaTypeTitle} from '../../../schema/helpers'\nimport {useCurrentUser} from '../../../store/user/hooks'\nimport {COMMENTS_HIGHLIGHT_HUE_KEY} from '../../constants'\nimport {isTextSelectionComment, parseCommentFieldPath} from '../../helpers'\nimport {useComments} from '../../hooks/useComments'\nimport {useCommentsAuthoringPath} from '../../hooks/useCommentsAuthoringPath'\nimport {useCommentsEnabled} from '../../hooks/useCommentsEnabled'\nimport {applyCommentsFieldAttr, useCommentsScroll} from '../../hooks/useCommentsScroll'\nimport {useCommentsSelectedPath} from '../../hooks/useCommentsSelectedPath'\nimport {useCommentsUpsell} from '../../hooks/useCommentsUpsell'\nimport {type CommentCreatePayload, type CommentMessage, type CommentsUIMode} from '../../types'\nimport {CommentsFieldButton} from './CommentsFieldButton'\n\n// When the form is temporarily set to `readOnly` while reconnecting, the form\n// will be re-rendered and any comment that is being authored will be lost.\n// To avoid this, we cache the comment message in a map and restore it when the\n// field is re-rendered.\nconst messageCache = new Map<string, CommentMessage>()\n\nconst EMPTY_ARRAY: [] = []\n\nconst HIGHLIGHT_BLOCK_VARIANTS: Variants = {\n initial: {\n opacity: 0,\n },\n animate: {\n opacity: 1,\n },\n exit: {\n opacity: 0,\n },\n}\n\nexport function CommentsField(props: FieldProps) {\n const {enabled, mode} = useCommentsEnabled()\n\n if (!enabled) {\n return props.renderDefault(props)\n }\n\n return <CommentFieldInner {...props} mode={mode} />\n}\n\nconst HighlightDiv = styled(motion.div)(({theme}) => {\n const {radius, space, color} = theme.sanity\n const bg = hues[COMMENTS_HIGHLIGHT_HUE_KEY][color.dark ? 900 : 50].hex\n\n return css`\n mix-blend-mode: ${color.dark ? 'screen' : 'multiply'};\n border-radius: ${radius[3]}px;\n top: -${space[2]}px;\n left: -${space[2]}px;\n bottom: -${space[2]}px;\n right: -${space[2]}px;\n pointer-events: none;\n position: absolute;\n z-index: 1;\n width: calc(100% + ${space[2] * 2}px);\n height: calc(100% + ${space[2] * 2}px);\n background-color: ${bg};\n `\n})\n\nconst FieldStack = styled(Stack)`\n position: relative;\n\n // Hide when the field component renders nothing (e.g. a custom\n // field component that returns null) to avoid an empty wrapper\n // taking up space in the form.\n &:empty:not([hidden]) {\n display: none;\n }\n`\n\nfunction CommentFieldInner(\n props: FieldProps & {\n mode: CommentsUIMode\n },\n) {\n const {mode} = props\n\n const currentUser = useCurrentUser()\n const {element: boundaryElement} = useBoundaryElement()\n\n const rootRef = useRef<HTMLDivElement | null>(null)\n\n const {\n comments,\n isCommentsOpen,\n isCreatingDataset,\n mentionOptions,\n onCommentsOpen,\n operation,\n setStatus,\n status,\n } = useComments()\n const {upsellData, handleOpenDialog} = useCommentsUpsell()\n const {selectedPath, setSelectedPath} = useCommentsSelectedPath()\n const {authoringPath, setAuthoringPath} = useCommentsAuthoringPath()\n const {scrollToGroup} = useCommentsScroll({\n boundaryElement,\n })\n\n const fieldTitle = useMemo(() => getSchemaTypeTitle(props.schemaType), [props.schemaType])\n const stringPath = useMemo(() => PathUtils.toString(props.path), [props.path])\n\n // Use the cached value if it exists as the initial value\n const cachedValue = messageCache.get(stringPath) || null\n\n const [value, setValue] = useState<PortableTextBlock[] | null>(cachedValue)\n\n // If the path of the field matches the authoring path, the comment input should be open.\n const isOpen = useMemo(() => authoringPath === stringPath, [authoringPath, stringPath])\n\n // Determine if the current field is selected\n const isSelected = useMemo(() => {\n if (!isCommentsOpen) return false\n if (selectedPath?.origin === 'form' || selectedPath?.origin === 'url') return false\n return belongsToField(selectedPath?.fieldPath, props.path)\n }, [isCommentsOpen, selectedPath?.fieldPath, selectedPath?.origin, props.path])\n\n const isInlineCommentThread = useMemo(() => {\n return comments.data.open\n .filter((c) => c.threadId === selectedPath?.threadId)\n .some((x) => isTextSelectionComment(x.parentComment))\n }, [comments.data.open, selectedPath?.threadId])\n\n // Total number of comments for the current field, including comments on\n // blocks nested below it (container-nested and dialog-authored comments\n // store the block's data path as their `fieldPath`).\n const count = useMemo(() => {\n const commentsCount = comments.data.open\n .map((c) => (belongsToField(c.fieldPath, props.path) ? c.commentsCount : 0))\n .reduce((acc, val) => acc + val, 0)\n\n return commentsCount || 0\n }, [comments.data.open, props.path])\n\n const hasComments = Boolean(count > 0)\n\n const resetMessageValue = useCallback(() => {\n // Reset the value and remove the message from the cache\n setValue(null)\n messageCache.delete(stringPath)\n }, [stringPath])\n\n const handleClick = useCallback(() => {\n // When clicking a comment button when the field has comments, we want to:\n if (hasComments) {\n // 1. Change the status to 'open' if it's 'resolved'\n if (status === 'resolved') {\n setStatus('open')\n }\n\n // 2. Ensure that the authoring path is reset when clicking\n // the comment button when the field has comments.\n setAuthoringPath(null)\n\n // 3. Open the comments inspector\n onCommentsOpen?.()\n\n // 4. Find the latest comment thread for the current field\n const latestThread = comments.data.open.find((c) => belongsToField(c.fieldPath, props.path))\n\n // 5. Set the latest thread ID as the selected thread ID\n // and scroll to the it. The selected path carries the thread's own\n // `fieldPath`: the inspector marks a thread selected by comparing\n // against the stored path, which for nested threads is deeper than\n // this field's path.\n if (latestThread) {\n setSelectedPath({\n threadId: latestThread.threadId,\n origin: 'form',\n fieldPath: latestThread.fieldPath,\n })\n\n scrollToGroup(latestThread.threadId)\n }\n\n return\n }\n\n if (mode === 'upsell') {\n if (upsellData) {\n handleOpenDialog('field_action')\n } else {\n // Open the comments inspector\n onCommentsOpen?.()\n }\n return\n }\n\n // If the field is open (i.e. the authoring path is set to the current field)\n // we close the field by resetting the authoring path. If the field is not open,\n // we set the authoring path to the current field so that the comment form is opened.\n setAuthoringPath(isOpen ? null : stringPath)\n }, [\n comments.data.open,\n handleOpenDialog,\n hasComments,\n isOpen,\n mode,\n onCommentsOpen,\n props.path,\n scrollToGroup,\n setAuthoringPath,\n setSelectedPath,\n setStatus,\n status,\n stringPath,\n upsellData,\n ])\n\n const handleCommentAdd = useCallback(\n (nextValue: PortableTextBlock[]) => {\n if (nextValue) {\n // Since this is a new comment, we generate a new thread ID\n const newThreadId = uuid()\n\n // Construct the comment payload\n const nextComment: CommentCreatePayload = {\n type: 'field',\n fieldPath: PathUtils.toString(props.path),\n message: nextValue,\n parentCommentId: undefined,\n status: 'open',\n threadId: newThreadId,\n // New comments have no reactions\n reactions: EMPTY_ARRAY,\n }\n\n // Execute the create mutation\n void operation.create(nextComment)\n\n // If a comment is added to a field when viewing resolved comments, we switch\n // to open comments and scroll to the comment that was just added\n // Open the inspector when a new comment is added\n onCommentsOpen?.()\n\n if (status === 'resolved') {\n // Set the status to 'open' so that the comment is visible\n setStatus('open')\n }\n\n resetMessageValue()\n\n // Scroll to the thread\n setSelectedPath({\n threadId: newThreadId,\n origin: 'form',\n fieldPath: PathUtils.toString(props.path),\n })\n\n scrollToGroup(newThreadId)\n }\n },\n [\n onCommentsOpen,\n operation,\n props.path,\n resetMessageValue,\n scrollToGroup,\n setSelectedPath,\n setStatus,\n status,\n ],\n )\n\n const handleClose = useCallback(() => setAuthoringPath(null), [setAuthoringPath])\n\n const handleOnChange = useCallback(\n (nextValue: CommentMessage) => {\n setValue(nextValue)\n messageCache.set(stringPath, nextValue)\n },\n [stringPath],\n )\n\n const internalComments: FieldProps['__internal_comments'] = useMemo(\n () => ({\n button: currentUser && (\n <CommentsFieldButton\n count={Number(count)}\n currentUser={currentUser}\n fieldTitle={fieldTitle}\n isCreatingDataset={isCreatingDataset}\n mentionOptions={mentionOptions}\n onChange={handleOnChange}\n onClick={handleClick}\n onClose={handleClose}\n onCommentAdd={handleCommentAdd}\n onDiscard={resetMessageValue}\n open={isOpen}\n value={value}\n />\n ),\n hasComments,\n isAddingComment: isOpen,\n }),\n [\n currentUser,\n count,\n fieldTitle,\n isCreatingDataset,\n mentionOptions,\n handleOnChange,\n handleClick,\n handleClose,\n handleCommentAdd,\n resetMessageValue,\n isOpen,\n value,\n hasComments,\n ],\n )\n\n return (\n <FieldStack {...applyCommentsFieldAttr(PathUtils.toString(props.path))} ref={rootRef}>\n {props.renderDefault({\n ...props,\n __internal_comments: internalComments,\n })}\n\n <AnimatePresence>\n {isSelected && !isInlineCommentThread && (\n <HighlightDiv\n animate=\"animate\"\n exit=\"exit\"\n initial=\"initial\"\n variants={HIGHLIGHT_BLOCK_VARIANTS}\n />\n )}\n </AnimatePresence>\n </FieldStack>\n )\n}\n\n/**\n * Whether a comment's stored `fieldPath` sits at or below the field's path.\n */\nfunction belongsToField(fieldPath: string | null | undefined, path: Path): boolean {\n const commentFieldPath = parseCommentFieldPath(fieldPath)\n return commentFieldPath ? PathUtils.startsWith(path, commentFieldPath) : false\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,SAAOG,2BAAA;CACL,IAAAC,QAAcJ,WAAWC,4BAA4B;CAErD,IAAI,CAACG,OACH,MAAUC,MAAM,iDAAiD;CAClE,OAEMD;AAAK;ACad,MAAM4B,eAAeZ,OAAOP,KAAK,CAAC,CAAA,WAAA;;;;AAoBlC,SAAOqC,oBAAAC,OAAA;CAAA,IAAAC,IAAAC,EAAA,EAAA,GACL,EAAAnB,OAAAC,aAAAC,YAAAC,mBAAAC,gBAAAC,UAAAE,SAAAC,SAAAC,cAAAC,WAAAC,gBAAAI,MAAAT,UAcIW,OACJ,EAAAG,MAAY9B,eAAeM,uBAAuB,GAClD,EAAAyB,OAAAC,sBAAmC9B,gBAAgB,GACnD+B,aAAmBvC,OAA8B,IAAI,GACrD,CAAAwC,yBAAAC,8BAA8DxC,SAC5D,IACF,GACAyC,qBAA2B1C,OAAkC,IAAI,GACjE2C,cAA4B3B,QAAQ,GAAE6B;CAAA,AAAAX,EAAA,OAAAM,2BAAAN,EAAA,OAAAV,WAAAU,EAAA,OAAAH,QAELc,WAAA;EAC1Bd,SACLP,QAAQ,GACRgB,yBAAuBM,MAAQ;CAAC,GACjCZ,EAAA,KAAAM,yBAAAN,EAAA,KAAAV,SAAAU,EAAA,KAAAH,MAAAG,EAAA,KAAAW,MAAAA,KAAAX,EAAA;CAJD,IAAAa,eAAqBF,IAIuBG;CAAA,AAAAd,EAAA,O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;AAgBa;;;;AAnQjB,SAAAvC,OAAAwC,KAAAC,KAAA;CAAA,OA2D4BD,MAAMC;AAAG;AA3DrC,SAAAhD,MAAAiD,GAAA;CAAA,OAkDmBxI,uBAAuBwI,EAACC,aAAc;AAAC;AAwN1D,SAAS7D,eAAeF,WAAsCV,MAAqB;CACjF,IAAM0E,mBAAmBzI,sBAAsByE,SAAS;CACxD,OAAOgE,mBAAmBzJ,UAAU0J,WAAW3E,MAAM0E,gBAAgB,IAAI;AAC3E"}
@@ -1,10 +1,10 @@
1
1
  import { r as Popover$1 } from "./ConfirmPopover-CEELgHMw.js";
2
2
  import { a as Button$1 } from "./MenuItem-B0ry3E4J.js";
3
- import { p as useCurrentUser } from "./datastores-CFWEadl-.js";
3
+ import { p as useCurrentUser } from "./datastores-CrRYBoDP.js";
4
4
  import { t as useTranslation } from "./useTranslation-Cqs6Itwv.js";
5
- import { r as useFormValue, t as useFieldActions } from "./useFieldActions-NrjLdjo8.js";
6
- import { b as commentsLocaleNamespace, d as hasCommentMessageValue, f as isTextSelectionComment, o as CommentInput, p as parseCommentFieldPath, t as useComments, y as useCommentsScroll } from "./useComments-KoRXRvW7.js";
7
- import { a as CommentInlineHighlightSpan, i as buildRangeDecorationSelectionsFromComments, n as getCommentFieldPath, o as CommentDisabledIcon, r as buildCommentRangeDecorations, t as buildTextSelectionFromFragment } from "./buildTextSelectionFromFragment-BXiSMql4.js";
5
+ import { r as useFormValue, t as useFieldActions } from "./useFieldActions-DbRTTr6-.js";
6
+ import { b as commentsLocaleNamespace, d as hasCommentMessageValue, f as isTextSelectionComment, o as CommentInput, p as parseCommentFieldPath, t as useComments, y as useCommentsScroll } from "./useComments-CzNBSPgQ.js";
7
+ import { a as CommentInlineHighlightSpan, i as buildRangeDecorationSelectionsFromComments, n as getCommentFieldPath, o as CommentDisabledIcon, r as buildCommentRangeDecorations, t as buildTextSelectionFromFragment } from "./buildTextSelectionFromFragment-Dj_WBTDa.js";
8
8
  import { t as useAddonDataset } from "./useAddonDataset-BvCgByG6.js";
9
9
  import { t as useCommentsEnabled } from "./useCommentsEnabled-BPc3788v.js";
10
10
  import { t as useCommentsSelectedPath } from "./useCommentsSelectedPath-D5HXM3NF.js";
@@ -511,4 +511,4 @@ function CommentsInput(props) {
511
511
  }
512
512
  export { CommentsInput };
513
513
 
514
- //# sourceMappingURL=CommentsInput-C7Kq5XMu.js.map
514
+ //# sourceMappingURL=CommentsInput-DQ4WCdZJ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommentsInput-C7Kq5XMu.js","names":["useEffect","useMemo","useState","createDomRectFromElements","elements","Element","DOMRect","length","rects","map","el","getBoundingClientRect","minX","Math","min","r","x","minY","y","maxRight","max","right","maxBottom","bottom","width","height","top","left","RectFromElementsHookOptions","scrollElement","HTMLElement","disabled","selector","useRectFromElements","props","$","_c","rect","setRect","t0","t1","handleSetRect","document","querySelectorAll","nextRect","Array","from","addEventListener","removeEventListener","ReferenceElementHookOptions","useAuthoringReferenceElement","bb0","t2","element","getSelectionBoundingRect","selection","window","getSelection","range","rangeCount","getRangeAt","AddCommentIcon","useClickOutsideEvent","motion","Variants","useRef","styled","Button","Popover","PopoverProps","useTranslation","CommentDisabledIcon","commentsLocaleNamespace","MotionPopover","create","POPOVER_FALLBACK_PLACEMENTS","VARIANTS","hidden","opacity","y","visible","FloatingButtonPopoverProps","disabled","onClick","onClickOutside","e","MouseEvent","referenceElement","FloatingButtonPopover","props","$","_c","buttonRef","t","t0","Symbol","for","current","t1","disabledText","t2","enabledText","text","t3","t4","content","t5","CurrentUser","Stack","useClickOutsideEvent","useCallback","useRef","styled","Popover","PopoverProps","CommentInput","CommentInputHandle","CommentInputProps","hasCommentMessageValue","POPOVER_FALLBACK_PLACEMENTS","RootStack","InlineCommentInputPopoverProps","currentUser","mentionOptions","onChange","onClickOutside","onDiscardConfirm","onSubmit","referenceElement","HTMLElement","value","InlineCommentInputPopover","props","$","_c","commentInputRef","contentElementRef","t0","current","discardDialogController","close","handleDiscardConfirm","t1","Symbol","for","handleDiscardCancel","t2","hasValue","open","t3","t4","content","t5","EditorSelection","PortableTextBlock","PortableTextEditor","RangeDecoration","RangeDecorationOnMovedDetails","isPortableTextTextBlock","BoundaryElementProvider","Stack","usePortal","PathUtils","uuid","debounce","isEqual","AnimatePresence","memo","startTransition","useCallback","useEffect","useLayoutEffect","useMemo","useRef","useState","useFormValue","useFieldActions","EditorChange","PortableTextInputProps","useCurrentUser","useAddonDataset","CommentInlineHighlightSpan","isTextSelectionComment","parseCommentFieldPath","useComments","useCommentsEnabled","useCommentsScroll","useCommentsSelectedPath","useCommentsUpsell","CommentDocument","CommentMessage","CommentsTextSelectionItem","CommentsUIMode","CommentUpdatePayload","buildCommentRangeDecorations","buildRangeDecorationSelectionsFromComments","buildTextSelectionFromFragment","getCommentFieldPath","getSelectionBoundingRect","useAuthoringReferenceElement","FloatingButtonPopover","InlineCommentInputPopover","EMPTY_ARRAY","AI_ASSIST_TYPE","CommentsPortableTextInput","props","$","_c","enabled","mode","fieldActions","isAiAssist","schemaType","name","isCommentsEnabledInField","Boolean","__internal_comments","t0","renderDefault","CommentsPortableTextInputInner","currentUser","portal","comments","getComment","mentionOptions","onCommentsOpen","operation","setStatus","status","error","addonDatasetError","setSelectedPath","selectedPath","scrollToComment","scrollToGroup","handleOpenDialog","mousePressed","setMousePressed","editorRef","Symbol","for","documentValue","documentValueRef","t1","t2","current","authoringDecorationElement","setAuthoringDecorationElement","nextCommentValue","setNextCommentValue","nextCommentSelection","setNextCommentSelection","currentSelection","setCurrentSelection","currentSelectionRect","setCurrenSelectionRect","currentHoveredCommentId","setCurrentHoveredCommentId","canSubmit","setCanSubmit","rootElement","setRootElement","isFullScreen","setIsFullScreen","addedCommentsDecorations","setAddedCommentsDecorations","fragment","setFragment","t3","getFragment","t4","rect","handleSetCurrentSelectionRect","t5","resetStates","t6","currentFragment","handleSelectCurrentSelection","t7","handleCommentDiscardConfirm","t8","data","open","path","t9","c_0","fieldPath","c","startsWith","filter","_temp","map","_temp2","textComments","nextValue","normalizedSelection","backward","anchor","focus","fieldPath_0","textSelection","selection","basePath","threadId","create","type","contentSnapshot","message","parentCommentId","undefined","reactions","origin","handleSubmit","t10","commentId","comment","target","field","_id","handleDecoratorClick","blurred","t11","isRangeSelected","offset","selectedFragment","isValidSelection","every","handleSelectionChange","debounceSelectionChange","useDebounceSelectionChange","t12","handleMouseDown","t13","handleMouseUp","t14","details","rangeDecoration","newSelection","commentId_0","payload","prev","next","p","nextDecoration","dirty","handleRangeDecorationMoved","t15","decoratorsToUpdate","_temp3","length","forEach","decorator_0","commentId_1","decorator","comment_0","editorValue","getValue","updatedDecoration","value","nextRange","range","nextValue_0","r","_key","concat","flat","sort","_temp4","nextComment","hasChanged","update","prev_0","next_0","p_0","isDirty","find","d","nextDecoration_0","_temp5","updateCommentRange","t16","commentsToDecorate","editorValue_0","onDecorationClick","onDecorationHoverEnd","onDecorationHoverStart","onDecorationMoved","selectedThreadId","handleBuildRangeDecorations","t17","change","onEditorChange","t18","bb0","t19","t20","children","component","authoringDecoration","rangeDecorations","currentSelectionIsOverlapping","setCurrentSelectionIsOverlapping","t21","t22","some","d_0","testA","isSelectionsOverlapping","testB","scrollElement","document","body","elements","documentScrollElement","boundaryElement","t23","t24","disabled","selector","popoverAuthoringReferenceElement","t25","bb1","t26","getBoundingClientRect","HTMLElement","selectionReferenceElement","t27","addEventListener","removeEventListener","t28","t29","nextDecorations","nextDecoration_1","prevDecoration","p_2","showFloatingButton","showFloatingInput","t30","t31","t32","t33","t34","t35","RenderDefaultCommentsPortableTextInputInner","React","ComponentProps","parentComment","c_1","a","b","localeCompare","p_1","isArrayOfBlocksSchemaType","InputProps","PortableTextInputProps","CommentsPortableTextInput","isPortableTextInputProps","inputProps","Omit","schemaType","CommentsInput","props","$","_c","t0","renderDefault"],"sources":["../src/core/comments/plugin/input/helpers.ts","../src/core/comments/plugin/input/components/FloatingButtonPopover.tsx","../src/core/comments/plugin/input/components/InlineCommentInputPopover.tsx","../src/core/comments/plugin/input/components/CommentsPortableTextInput.tsx","../src/core/comments/plugin/input/CommentsInput.tsx"],"sourcesContent":["import {useEffect, useMemo, useState} from 'react'\n\n/**\n * A function that creates a DOMRect from an array of elements.\n */\nfunction createDomRectFromElements(elements: Element[]): DOMRect | null {\n if (!elements || !elements.length) return null\n\n const rects = elements.map((el) => el.getBoundingClientRect())\n\n const minX = Math.min(...rects.map((r) => r.x)) || 0\n const minY = Math.min(...rects.map((r) => r.y)) || 0\n const maxRight = Math.max(...rects.map((r) => r.right)) || 0\n const maxBottom = Math.max(...rects.map((r) => r.bottom)) || 0\n\n return {\n x: minX,\n y: minY,\n width: maxRight - minX,\n height: maxBottom - minY,\n top: minY,\n right: maxRight,\n bottom: maxBottom,\n left: minX,\n } as DOMRect\n}\n\ninterface RectFromElementsHookOptions {\n scrollElement: HTMLElement | null\n disabled: boolean\n selector: string\n}\n\n/**\n * A hook that returns a DOMRect from an array of elements.\n * This is needed because the Range Decoration API might render se\n */\nfunction useRectFromElements(props: RectFromElementsHookOptions): DOMRect | null {\n const {scrollElement, disabled, selector} = props\n const [rect, setRect] = useState<DOMRect | null>(null)\n\n useEffect(() => {\n if (disabled) return undefined\n\n const handleSetRect = () => {\n const elements = document?.querySelectorAll(selector)\n if (!elements) return\n\n const nextRect = createDomRectFromElements(Array.from(elements))\n\n setRect(nextRect)\n }\n\n handleSetRect()\n\n if (!scrollElement) return undefined\n\n scrollElement.addEventListener('wheel', handleSetRect)\n\n return () => {\n scrollElement.removeEventListener('wheel', handleSetRect)\n }\n }, [scrollElement, disabled, selector])\n\n return rect\n}\n\nexport interface ReferenceElementHookOptions {\n scrollElement: HTMLElement | null\n disabled: boolean\n selector: string\n}\n\n/**\n * A hook that returns a reference element that can be used to position a popover.\n */\nexport function useAuthoringReferenceElement(\n props: ReferenceElementHookOptions,\n): HTMLElement | null {\n const {scrollElement, disabled, selector} = props\n\n const rect = useRectFromElements({\n scrollElement,\n disabled,\n selector,\n })\n\n const element = useMemo((): HTMLElement | null => {\n if (!rect) return null\n\n return {\n getBoundingClientRect: () => rect,\n } as HTMLElement\n }, [rect])\n\n return element\n}\n\nexport function getSelectionBoundingRect(): DOMRect | null {\n const selection = window.getSelection()\n let range = null\n\n if (selection && selection.rangeCount > 0) {\n range = selection.getRangeAt(0)\n }\n const rect = range?.getBoundingClientRect()\n\n return rect || null\n}\n","import {AddCommentIcon} from '@sanity/icons/AddComment'\nimport {useClickOutsideEvent} from '@sanity/ui'\nimport {motion, type Variants} from 'motion/react'\nimport {useRef} from 'react'\nimport {styled} from 'styled-components'\n\nimport {Button} from '../../../../../ui-components/button/Button'\nimport {Popover, type PopoverProps} from '../../../../../ui-components/popover/Popover'\nimport {useTranslation} from '../../../../i18n/hooks/useTranslation'\nimport {CommentDisabledIcon} from '../../../components/icons/CommentDisabledIcon'\nimport {commentsLocaleNamespace} from '../../../i18n'\n\nconst MotionPopover = styled(motion.create(Popover))`\n user-select: none;\n`\n\nconst POPOVER_FALLBACK_PLACEMENTS: PopoverProps['fallbackPlacements'] = ['bottom', 'top']\n\nconst VARIANTS: Variants = {\n hidden: {opacity: 0, y: -4},\n visible: {opacity: 1, y: 0},\n}\n\ninterface FloatingButtonPopoverProps {\n disabled: boolean\n onClick: () => void\n onClickOutside: (e: MouseEvent) => void\n referenceElement: PopoverProps['referenceElement']\n}\n\nexport function FloatingButtonPopover(props: FloatingButtonPopoverProps) {\n const {disabled, onClick, onClickOutside, referenceElement} = props\n const buttonRef = useRef<HTMLButtonElement | null>(null)\n const {t} = useTranslation(commentsLocaleNamespace)\n\n useClickOutsideEvent(onClickOutside, () => [buttonRef.current])\n\n const disabledText = t('inline-add-comment-button.disabled-overlap-title')\n const enabledText = t('inline-add-comment-button.title')\n const text = disabled ? disabledText : enabledText\n\n const content = (\n <Button\n data-testid=\"inline-comment-button\"\n disabled={disabled}\n icon={disabled ? CommentDisabledIcon : AddCommentIcon}\n mode=\"bleed\"\n onClick={onClick}\n ref={buttonRef}\n text={text}\n />\n )\n\n return (\n <MotionPopover\n animate=\"visible\"\n content={content}\n contentEditable={false}\n fallbackPlacements={POPOVER_FALLBACK_PLACEMENTS}\n initial=\"hidden\"\n open\n padding={1}\n placement=\"bottom\"\n portal\n referenceElement={referenceElement}\n variants={VARIANTS}\n />\n )\n}\n","import {type CurrentUser} from '@sanity/types'\nimport {Stack, useClickOutsideEvent} from '@sanity/ui'\nimport {useCallback, useRef} from 'react'\nimport {styled} from 'styled-components'\n\nimport {Popover, type PopoverProps} from '../../../../../ui-components/popover/Popover'\nimport {\n CommentInput,\n type CommentInputHandle,\n type CommentInputProps,\n} from '../../../components/pte/comment-input/CommentInput'\nimport {hasCommentMessageValue} from '../../../helpers'\n\nconst POPOVER_FALLBACK_PLACEMENTS: PopoverProps['fallbackPlacements'] = ['bottom', 'top']\n\nconst RootStack = styled(Stack)`\n width: 250px;\n`\n\ninterface InlineCommentInputPopoverProps {\n currentUser: CurrentUser\n mentionOptions: CommentInputProps['mentionOptions']\n onChange: CommentInputProps['onChange']\n onClickOutside: () => void\n onDiscardConfirm: CommentInputProps['onDiscardConfirm']\n onSubmit: CommentInputProps['onSubmit']\n referenceElement?: HTMLElement | null\n value: CommentInputProps['value']\n}\n\nexport function InlineCommentInputPopover(props: InlineCommentInputPopoverProps) {\n const {\n currentUser,\n mentionOptions,\n onChange,\n onClickOutside,\n onDiscardConfirm,\n onSubmit,\n referenceElement,\n value,\n } = props\n\n const commentInputRef = useRef<CommentInputHandle | null>(null)\n const contentElementRef = useRef<HTMLDivElement | null>(null)\n\n const handleDiscardConfirm = useCallback(() => {\n commentInputRef.current?.discardDialogController.close()\n onDiscardConfirm()\n }, [onDiscardConfirm])\n\n const handleDiscardCancel = useCallback(() => {\n commentInputRef.current?.discardDialogController.close()\n }, [])\n\n useClickOutsideEvent(\n () => {\n const hasValue = hasCommentMessageValue(value)\n\n if (hasValue) {\n commentInputRef.current?.discardDialogController.open()\n return\n }\n\n onClickOutside()\n },\n () => [contentElementRef.current],\n )\n\n const content = (\n <RootStack padding={2} ref={contentElementRef}>\n <CommentInput\n currentUser={currentUser}\n focusLock\n focusOnMount\n mentionOptions={mentionOptions}\n onChange={onChange}\n onDiscardCancel={handleDiscardCancel}\n onDiscardConfirm={handleDiscardConfirm}\n onSubmit={onSubmit}\n ref={commentInputRef}\n value={value}\n />\n </RootStack>\n )\n\n return (\n <Popover\n content={content}\n data-ui=\"InlineCommentInputPopover\"\n fallbackPlacements={POPOVER_FALLBACK_PLACEMENTS}\n open\n placement=\"bottom\"\n portal\n referenceElement={referenceElement}\n />\n )\n}\n","import {\n type EditorSelection,\n type PortableTextBlock,\n PortableTextEditor,\n type RangeDecoration,\n type RangeDecorationOnMovedDetails,\n} from '@portabletext/editor'\nimport {isPortableTextTextBlock} from '@sanity/types'\nimport {BoundaryElementProvider, Stack, usePortal} from '@sanity/ui'\nimport * as PathUtils from '@sanity/util/paths'\nimport {uuid} from '@sanity/uuid'\nimport debounce from 'lodash-es/debounce.js'\nimport isEqual from 'lodash-es/isEqual.js'\nimport {AnimatePresence} from 'motion/react'\nimport {\n memo,\n startTransition,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\n\nimport {useFormValue} from '../../../../form/contexts/FormValue'\nimport {useFieldActions} from '../../../../form/field/actions/useFieldActions'\nimport {type EditorChange, type PortableTextInputProps} from '../../../../form/types/inputProps'\nimport {useCurrentUser} from '../../../../store/user/hooks'\nimport {useAddonDataset} from '../../../../studio/addonDataset/useAddonDataset'\nimport {CommentInlineHighlightSpan} from '../../../components/pte/CommentInlineHighlightSpan'\nimport {isTextSelectionComment, parseCommentFieldPath} from '../../../helpers'\nimport {useComments} from '../../../hooks/useComments'\nimport {useCommentsEnabled} from '../../../hooks/useCommentsEnabled'\nimport {useCommentsScroll} from '../../../hooks/useCommentsScroll'\nimport {useCommentsSelectedPath} from '../../../hooks/useCommentsSelectedPath'\nimport {useCommentsUpsell} from '../../../hooks/useCommentsUpsell'\nimport {\n type CommentDocument,\n type CommentMessage,\n type CommentsTextSelectionItem,\n type CommentsUIMode,\n type CommentUpdatePayload,\n} from '../../../types'\nimport {buildCommentRangeDecorations} from '../../../utils/inline-comments/buildCommentRangeDecorations'\nimport {buildRangeDecorationSelectionsFromComments} from '../../../utils/inline-comments/buildRangeDecorationSelectionsFromComments'\nimport {\n buildTextSelectionFromFragment,\n getCommentFieldPath,\n} from '../../../utils/inline-comments/buildTextSelectionFromFragment'\nimport {getSelectionBoundingRect, useAuthoringReferenceElement} from '../helpers'\nimport {FloatingButtonPopover} from './FloatingButtonPopover'\nimport {InlineCommentInputPopover} from './InlineCommentInputPopover'\n\nconst EMPTY_ARRAY: [] = []\n\nconst AI_ASSIST_TYPE = 'sanity.assist.instruction.prompt'\n\nexport function CommentsPortableTextInput(props: PortableTextInputProps) {\n const {enabled, mode} = useCommentsEnabled()\n const fieldActions = useFieldActions()\n\n // This is a workaround solution to disable comments for the AI assist type.\n // The AI assist uses the official PTE input which is composed from the\n // Form Components API for the authoring of the prompt. Consequently, the input\n // will get the comments functionality as well, which we don't want.\n // Therefore we disable the comments for the AI assist type.\n const isAiAssist = props.schemaType.name === AI_ASSIST_TYPE\n /**\n * Comments can be disabled at field level by passing the `__internal_comments: undefined` prop to the field.\n * Even though is not recommended and tagged as internal, it works for all type of fields.\n * This adds the same ability to disable inline comments in the Portable Text editor.\n */\n const isCommentsEnabledInField = Boolean(fieldActions.__internal_comments)\n if (!enabled || isAiAssist || !isCommentsEnabledInField) {\n return props.renderDefault(props)\n }\n\n return <CommentsPortableTextInputInner {...props} mode={mode} />\n}\n\nconst CommentsPortableTextInputInner = memo(function CommentsPortableTextInputInner(\n props: PortableTextInputProps & {mode: CommentsUIMode},\n) {\n const {mode} = props\n const currentUser = useCurrentUser()\n const portal = usePortal()\n\n const {comments, getComment, mentionOptions, onCommentsOpen, operation, setStatus, status} =\n useComments()\n const {error: addonDatasetError} = useAddonDataset()\n const {setSelectedPath, selectedPath} = useCommentsSelectedPath()\n const {scrollToComment, scrollToGroup} = useCommentsScroll()\n const {handleOpenDialog} = useCommentsUpsell()\n const [mousePressed, setMousePressed] = useState<boolean>(false)\n\n const editorRef = useRef<PortableTextEditor | null>(null)\n\n // Read through a ref because `useFormValue([])` changes identity on every\n // keystroke: keeping it out of dependency arrays keeps decoration rebuilds\n // keyed on comment changes. The layout effect updates the ref synchronously\n // with the commit, so event handlers never observe a stale value.\n const documentValue = useFormValue([])\n const documentValueRef = useRef(documentValue)\n useLayoutEffect(() => {\n documentValueRef.current = documentValue\n }, [documentValue])\n\n // A reference to the authoring decoration element that highlights the selected text\n // when starting to author a comment.\n const [authoringDecorationElement, setAuthoringDecorationElement] =\n useState<HTMLSpanElement | null>(null)\n\n const [nextCommentValue, setNextCommentValue] = useState<CommentMessage | null>(null)\n const [nextCommentSelection, setNextCommentSelection] = useState<EditorSelection | null>(null)\n\n const [currentSelection, setCurrentSelection] = useState<EditorSelection | null>(null)\n const [currentSelectionRect, setCurrenSelectionRect] = useState<DOMRect | null>(null)\n\n const [currentHoveredCommentId, setCurrentHoveredCommentId] = useState<string | null>(null)\n\n const [canSubmit, setCanSubmit] = useState<boolean>(false)\n\n const [rootElement, setRootElement] = useState<HTMLDivElement | null>(null)\n const [isFullScreen, setIsFullScreen] = useState<boolean>(false)\n const [addedCommentsDecorations, setAddedCommentsDecorations] =\n useState<RangeDecoration[]>(EMPTY_ARRAY)\n\n const [fragment, setFragment] = useState<PortableTextBlock[] | null>(null)\n\n const getFragment = useCallback(() => {\n if (!editorRef.current) return EMPTY_ARRAY\n return PortableTextEditor.getFragment(editorRef.current)\n }, [])\n\n const handleSetCurrentSelectionRect = useCallback(() => {\n const rect = getSelectionBoundingRect()\n setCurrenSelectionRect(rect)\n }, [])\n\n const resetStates = useCallback(() => {\n setCurrentSelection(null)\n setCurrenSelectionRect(null)\n setNextCommentSelection(null)\n setNextCommentValue(null)\n setCanSubmit(false)\n setAuthoringDecorationElement(null)\n setFragment(null)\n }, [])\n\n // Set the next comment selection to the current selection so that we can\n // render the comment input popover on the current selection using a range decoration.\n const handleSelectCurrentSelection = useCallback(() => {\n // When trying to add a comment in \"upsell\" mode, we want to\n // display the upsell dialog instead of the comment input popover.\n if (mode === 'upsell') {\n handleOpenDialog('pte')\n return\n }\n const currentFragment = getFragment() || null\n setFragment(currentFragment)\n setNextCommentSelection(currentSelection)\n }, [currentSelection, getFragment, handleOpenDialog, mode])\n\n // Clear the selection and close the popover when discarding the comment\n const handleCommentDiscardConfirm = useCallback(() => {\n resetStates()\n }, [resetStates])\n\n const textComments = useMemo(() => {\n return comments.data.open\n .filter((c) => isTextSelectionComment(c.parentComment))\n .filter((c) => {\n // Keep the per-editor work proportional to the editor's own comments.\n const fieldPath = parseCommentFieldPath(c.fieldPath)\n return fieldPath ? PathUtils.startsWith(props.path, fieldPath) : false\n })\n .map((c) => c.parentComment)\n }, [comments.data.open, props.path])\n\n const handleSubmit = useCallback(\n (nextValue: CommentMessage) => {\n if (!nextCommentSelection || !editorRef.current) return\n\n const normalizedSelection = nextCommentSelection.backward\n ? {backward: false, anchor: nextCommentSelection.focus, focus: nextCommentSelection.anchor}\n : nextCommentSelection\n\n const fieldPath = getCommentFieldPath(\n documentValueRef.current,\n props.path,\n normalizedSelection.focus.path,\n )\n if (!fieldPath) return\n\n const textSelection = buildTextSelectionFromFragment({\n fragment: fragment || EMPTY_ARRAY,\n selection: normalizedSelection,\n documentValue: documentValueRef.current,\n basePath: props.path,\n })\n\n const threadId = uuid()\n\n void operation.create({\n type: 'field',\n contentSnapshot: fragment,\n fieldPath,\n message: nextValue,\n parentCommentId: undefined,\n reactions: EMPTY_ARRAY,\n selection: textSelection,\n status: 'open',\n threadId,\n })\n\n // Open the inspector when a new comment is added\n onCommentsOpen?.()\n\n // Set the status to 'open' so that the comment is visible\n if (status === 'resolved') {\n setStatus('open')\n }\n\n // Set the selected path to the new comment\n setSelectedPath({\n fieldPath,\n threadId,\n origin: 'form',\n })\n\n // Scroll to the comment\n scrollToGroup(threadId)\n\n resetStates()\n },\n [\n nextCommentSelection,\n operation,\n props.path,\n onCommentsOpen,\n status,\n setSelectedPath,\n scrollToGroup,\n resetStates,\n setStatus,\n fragment,\n ],\n )\n\n const handleDecoratorClick = useCallback(\n (commentId: string) => {\n const comment = getComment(commentId)\n if (!comment) return\n\n setSelectedPath({\n fieldPath: comment.target.path?.field || '',\n threadId: comment.threadId,\n origin: 'form',\n })\n\n onCommentsOpen?.()\n\n scrollToComment(comment._id)\n },\n [getComment, onCommentsOpen, scrollToComment, setSelectedPath],\n )\n\n const blurred = useRef<boolean>(false)\n\n const handleSelectionChange = useCallback(\n (selection: EditorSelection | null) => {\n const isRangeSelected = selection?.anchor.offset !== selection?.focus.offset\n\n const selectedFragment = getFragment()\n const isValidSelection = selectedFragment?.every(isPortableTextTextBlock)\n\n if (!isValidSelection || !isRangeSelected) {\n setCanSubmit(false)\n return\n }\n /**\n * When the portable text editor loses focus we will save the blurred.current to true.\n * Later, when it restores focus the editor will emit a selection change event, but we don't want to immediately show the comment input\n * instead, we want to wait until the user selects a new range.\n */\n if (blurred.current) {\n blurred.current = false\n return\n }\n // If the mouse is not down, we want to set the current selection rect\n // when the selection changes. Otherwise, we want to wait until the mouse\n // is up to set the current selection rect (see `handleMouseUp`).\n if (!mousePressed) {\n handleSetCurrentSelectionRect()\n }\n\n setCurrentSelection(selection)\n setCanSubmit(true)\n },\n [getFragment, handleSetCurrentSelectionRect, mousePressed],\n )\n\n const debounceSelectionChange = useDebounceSelectionChange(handleSelectionChange)\n\n const handleMouseDown = useCallback(() => {\n startTransition(() => setMousePressed(true))\n }, [])\n\n const handleMouseUp = useCallback(() => {\n startTransition(() => setMousePressed(false))\n\n // When the mouse is up, we want to set the current selection rect.\n handleSetCurrentSelectionRect()\n }, [handleSetCurrentSelectionRect])\n\n const handleRangeDecorationMoved = useCallback((details: RangeDecorationOnMovedDetails) => {\n const {rangeDecoration, newSelection} = details\n\n const commentId = rangeDecoration.payload?.commentId as undefined | string\n\n // Update the range decoration with the new selection.\n setAddedCommentsDecorations((prev) => {\n const next = prev.map((p) => {\n if (p.payload?.commentId === commentId) {\n const nextDecoration: RangeDecoration = {\n ...rangeDecoration,\n selection: newSelection,\n payload: {...rangeDecoration.payload, dirty: true},\n }\n return nextDecoration\n }\n return p\n })\n return next\n })\n }, [])\n\n const updateCommentRange = useCallback(() => {\n const decoratorsToUpdate = addedCommentsDecorations.filter(\n (decorator) => decorator.payload?.dirty,\n )\n if (decoratorsToUpdate.length === 0) return\n\n decoratorsToUpdate.forEach((decorator) => {\n const commentId = decorator.payload?.commentId as undefined | string\n const comment = getComment(commentId || '')\n\n // If the comment no longer exists, remove the range decoration.\n if (!comment) {\n return\n }\n\n // The below code will update the comment object to reflect the new selection\n if (!editorRef.current) return\n const editorValue = PortableTextEditor.getValue(editorRef.current) || EMPTY_ARRAY\n\n const [updatedDecoration] = buildRangeDecorationSelectionsFromComments({\n comments: [comment],\n value: editorValue,\n documentValue: documentValueRef.current,\n basePath: props.path,\n })\n\n const nextRange = updatedDecoration?.range ? [updatedDecoration.range] : EMPTY_ARRAY\n\n const nextValue: CommentsTextSelectionItem[] = updatedDecoration\n ? [\n ...(comment.target.path?.selection?.value\n .filter((r) => r._key !== nextRange[0]?._key)\n .concat(nextRange)\n .flat()\n .sort((a, b) => a._key.localeCompare(b._key)) || EMPTY_ARRAY),\n ]\n : EMPTY_ARRAY\n\n const nextComment: CommentUpdatePayload = {\n target: {\n ...comment.target,\n path: {\n ...comment.target?.path,\n field: comment.target.path?.field || '',\n selection: {\n type: 'text',\n value: nextValue,\n },\n },\n },\n }\n\n const hasChanged = !isEqual(comment.target, nextComment.target)\n\n if (hasChanged) {\n void operation.update(comment._id, nextComment)\n }\n })\n\n // Mark the range decorations as not dirty\n setAddedCommentsDecorations((prev) => {\n const next = prev.map((p) => {\n const isDirty = decoratorsToUpdate.find(\n (d) => d.payload?.commentId === p.payload?.commentId,\n )?.payload?.dirty\n\n if (isDirty) {\n const nextDecoration: RangeDecoration = {\n ...p,\n payload: {...p.payload, dirty: false},\n }\n return nextDecoration\n }\n return p\n })\n return next.filter((p) => p.selection !== null)\n })\n }, [addedCommentsDecorations, getComment, operation, props.path])\n\n const handleBuildRangeDecorations = useCallback(\n (commentsToDecorate: CommentDocument[]) => {\n if (!editorRef.current) return EMPTY_ARRAY\n const editorValue = PortableTextEditor.getValue(editorRef.current) || EMPTY_ARRAY\n\n return buildCommentRangeDecorations({\n comments: commentsToDecorate,\n currentHoveredCommentId,\n onDecorationClick: handleDecoratorClick,\n onDecorationHoverEnd: setCurrentHoveredCommentId,\n onDecorationHoverStart: setCurrentHoveredCommentId,\n onDecorationMoved: handleRangeDecorationMoved,\n selectedThreadId: selectedPath?.threadId || null,\n value: editorValue,\n documentValue: documentValueRef.current,\n basePath: props.path,\n })\n },\n [\n currentHoveredCommentId,\n handleDecoratorClick,\n handleRangeDecorationMoved,\n props.path,\n selectedPath?.threadId,\n ],\n )\n\n const onEditorChange = useCallback(\n (change: EditorChange) => {\n if (change.type === 'mutation') {\n updateCommentRange()\n }\n if (change.type === 'blur') {\n blurred.current = true\n }\n if (change.type === 'selection') {\n debounceSelectionChange(change.selection)\n }\n },\n [debounceSelectionChange, updateCommentRange],\n )\n\n // The range decoration for the comment input. This is used to position the\n // comment input popover on the current selection and to highlight the\n // selected text.\n const authoringDecoration = useMemo((): RangeDecoration | null => {\n if (!nextCommentSelection) return null\n\n return {\n component: ({children}) => (\n <CommentInlineHighlightSpan isAuthoring ref={setAuthoringDecorationElement}>\n {children}\n </CommentInlineHighlightSpan>\n ),\n selection: nextCommentSelection,\n }\n }, [nextCommentSelection])\n\n // All the range decorations\n const rangeDecorations: RangeDecoration[] = [\n // Existing range decorations\n ...(props?.rangeDecorations || EMPTY_ARRAY),\n // The range decoration when adding a comment\n ...(authoringDecoration ? [authoringDecoration] : EMPTY_ARRAY),\n // The range decorations for existing comments\n ...addedCommentsDecorations,\n ]\n\n const [currentSelectionIsOverlapping, setCurrentSelectionIsOverlapping] = useState<boolean>(false)\n useEffect(() => {\n startTransition(() =>\n setCurrentSelectionIsOverlapping(() => {\n if (!currentSelection || addedCommentsDecorations.length === 0) return false\n\n return addedCommentsDecorations.some((d) => {\n if (!editorRef.current) return false\n\n const testA = PortableTextEditor.isSelectionsOverlapping(\n editorRef.current,\n currentSelection,\n d.selection,\n )\n\n const testB = PortableTextEditor.isSelectionsOverlapping(\n editorRef.current,\n d.selection,\n currentSelection,\n )\n\n return testA || testB\n })\n }),\n )\n }, [addedCommentsDecorations, currentSelection])\n\n // The scroll element used to update the reference element for the\n // popover on scroll.\n const scrollElement = isFullScreen\n ? document.body\n : portal.elements?.documentScrollElement || document.body\n\n // The boundary element used to position the popover properly\n // inside the editor.\n const boundaryElement = isFullScreen\n ? portal.elements?.documentScrollElement || document.body\n : rootElement\n\n const popoverAuthoringReferenceElement = useAuthoringReferenceElement({\n scrollElement,\n disabled: !nextCommentSelection || !authoringDecorationElement,\n selector: '[data-inline-comment-state=\"authoring\"]',\n })\n\n const selectionReferenceElement = useMemo(() => {\n if (!currentSelectionRect) return null\n\n return {\n getBoundingClientRect: () => currentSelectionRect,\n } as HTMLElement\n }, [currentSelectionRect])\n\n // This effect is needed to update the reference element for the popover\n // when the current selection changes so that it is always positioned\n // on the current selection.\n useEffect(() => {\n if (!currentSelection) return undefined\n scrollElement?.addEventListener('wheel', handleSetCurrentSelectionRect)\n\n return () => {\n scrollElement?.removeEventListener('wheel', handleSetCurrentSelectionRect)\n }\n }, [currentSelection, scrollElement, handleSetCurrentSelectionRect])\n\n // This is effect is needed to handle remote changes to the comments.\n // That is, when another user adds, updates or deletes a comment, we need\n // to update the range decorations to reflect these changes in the UI.\n useEffect(() => {\n const nextDecorations = handleBuildRangeDecorations(textComments)\n\n // The `dirty` flag is used to keep track of range decorations that\n // have been moved. When a range decoration is moved, we need to update\n // the comment document. However, when receiving updates from the server,\n // the `dirty` flag will be removed. Therefore, we need to make sure\n // that the `dirty` flag is preserved so that we can update the comment.\n startTransition(() =>\n setAddedCommentsDecorations((current) => {\n return nextDecorations.map((nextDecoration) => {\n const prevDecoration = current.find(\n (p) => p.payload?.commentId === nextDecoration.payload?.commentId,\n )\n\n if (prevDecoration?.payload?.dirty) {\n return {\n ...nextDecoration,\n payload: {...nextDecoration.payload, dirty: prevDecoration.payload.dirty},\n }\n }\n\n return nextDecoration\n })\n }),\n )\n }, [handleBuildRangeDecorations, textComments])\n\n const showFloatingButton = Boolean(\n currentSelection && canSubmit && selectionReferenceElement && !mousePressed,\n )\n const showFloatingInput = Boolean(nextCommentSelection && popoverAuthoringReferenceElement)\n\n return (\n <>\n <BoundaryElementProvider element={boundaryElement}>\n {showFloatingInput && currentUser && (\n <InlineCommentInputPopover\n currentUser={currentUser}\n mentionOptions={mentionOptions}\n onChange={setNextCommentValue}\n onClickOutside={resetStates}\n onDiscardConfirm={handleCommentDiscardConfirm}\n onSubmit={handleSubmit}\n referenceElement={popoverAuthoringReferenceElement}\n value={nextCommentValue}\n />\n )}\n <AnimatePresence>\n {showFloatingButton && !showFloatingInput && (\n <FloatingButtonPopover\n disabled={currentSelectionIsOverlapping || Boolean(addonDatasetError)}\n onClick={handleSelectCurrentSelection}\n onClickOutside={resetStates}\n referenceElement={selectionReferenceElement}\n />\n )}\n </AnimatePresence>\n </BoundaryElementProvider>\n\n <Stack ref={setRootElement} onMouseDown={handleMouseDown} onMouseUp={handleMouseUp}>\n <RenderDefaultCommentsPortableTextInputInner\n {...props}\n onEditorChange={onEditorChange}\n editorRef={editorRef}\n rangeDecorations={rangeDecorations}\n onFullScreenChange={setIsFullScreen}\n />\n </Stack>\n </>\n )\n})\n\n// Workaround for react compiler restrictions on refs triggered by the debounce wrapper\nfunction useDebounceSelectionChange(\n handleSelectionChange: (selection: EditorSelection | null) => void,\n) {\n return useMemo(() => debounce(handleSelectionChange, 200), [handleSelectionChange])\n}\n// Used to workaround restrictions on passing refs to functions in react compiler\nfunction RenderDefaultCommentsPortableTextInputInner(\n props: React.ComponentProps<typeof CommentsPortableTextInputInner>,\n) {\n return props.renderDefault(props)\n}\n","import {isArrayOfBlocksSchemaType} from '@sanity/types'\n\nimport {type InputProps, type PortableTextInputProps} from '../../../form/types/inputProps'\nimport {CommentsPortableTextInput} from './components/CommentsPortableTextInput'\n\nfunction isPortableTextInputProps(\n inputProps: InputProps | Omit<InputProps, 'renderDefault'>,\n): inputProps is PortableTextInputProps {\n return isArrayOfBlocksSchemaType(inputProps.schemaType)\n}\n\nexport function CommentsInput(props: InputProps) {\n if (isPortableTextInputProps(props)) {\n return <CommentsPortableTextInput {...props} />\n }\n\n return props.renderDefault(props)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAASG,0BAA0BC,UAAqC;CACtE,IAAI,CAACA,YAAY,CAACA,SAASG,QAAQ,OAAO;CAE1C,IAAMC,QAAQJ,SAASK,KAAKC,OAAOA,GAAGC,sBAAsB,CAAC,GAEvDC,OAAOC,KAAKC,IAAI,GAAGN,MAAMC,KAAKM,MAAMA,EAAEC,CAAC,CAAC,KAAK,GAC7CC,OAAOJ,KAAKC,IAAI,GAAGN,MAAMC,KAAKM,MAAMA,EAAEG,CAAC,CAAC,KAAK,GAC7CC,WAAWN,KAAKO,IAAI,GAAGZ,MAAMC,KAAKM,MAAMA,EAAEM,KAAK,CAAC,KAAK,GACrDC,YAAYT,KAAKO,IAAI,GAAGZ,MAAMC,KAAKM,MAAMA,EAAEQ,MAAM,CAAC,KAAK;CAE7D,OAAO;EACLP,GAAGJ;EACHM,GAAGD;EACHO,OAAOL,WAAWP;EAClBa,QAAQH,YAAYL;EACpBS,KAAKT;EACLI,OAAOF;EACPI,QAAQD;EACRK,MAAMf;CACR;AACF;;;;;AAYA,SAAAqB,oBAAAC,OAAA;CAAA,IAAAC,IAAAC,EAAA,CAAA,GACE,EAAAP,eAAAE,UAAAC,aAA4CE,OAC5C,CAAAG,MAAAC,WAAwBpC,SAAyB,IAAI,GAACqC,IAAAC;CAuBf,OAvBeL,EAAA,OAA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,KAAA;CAAA,OA4UZ7G,IAACzC,cAAe;AAAI;ACxZpD,SAAS2J,yBACPC,YACsC;CACtC,OAAOL,0BAA0BK,WAAWE,UAAU;AACxD;AAEA,SAAOC,cAAAC,OAAA;CAAA,IAAAC,IAAAC,EAAA,CAAA;CACL,IAAIP,yBAAyBK,KAAK,GAAC;EAAA,IAAAG;EACc,OADdF,EAAA,OAAAD,QACcG,KAAAF,EAAA,MAAxCE,KAAA,oBAAC,2BAAD,EAA0B,GAAKH,MAAK,CAAA,GAAIC,EAAA,KAAAD,OAAAC,EAAA,KAAAE,KAAxCA;CAAwC;CAChD,IAAAA;CAEgC,OAFhCF,EAAA,OAAAD,QAEgCG,KAAAF,EAAA,MAA1BE,KAAAH,MAAKI,cAAeJ,KAAK,GAACC,EAAA,KAAAD,OAAAC,EAAA,KAAAE,KAA1BA;AAA0B"}
1
+ {"version":3,"file":"CommentsInput-DQ4WCdZJ.js","names":["useEffect","useMemo","useState","createDomRectFromElements","elements","Element","DOMRect","length","rects","map","el","getBoundingClientRect","minX","Math","min","r","x","minY","y","maxRight","max","right","maxBottom","bottom","width","height","top","left","RectFromElementsHookOptions","scrollElement","HTMLElement","disabled","selector","useRectFromElements","props","$","_c","rect","setRect","t0","t1","handleSetRect","document","querySelectorAll","nextRect","Array","from","addEventListener","removeEventListener","ReferenceElementHookOptions","useAuthoringReferenceElement","bb0","t2","element","getSelectionBoundingRect","selection","window","getSelection","range","rangeCount","getRangeAt","AddCommentIcon","useClickOutsideEvent","motion","Variants","useRef","styled","Button","Popover","PopoverProps","useTranslation","CommentDisabledIcon","commentsLocaleNamespace","MotionPopover","create","POPOVER_FALLBACK_PLACEMENTS","VARIANTS","hidden","opacity","y","visible","FloatingButtonPopoverProps","disabled","onClick","onClickOutside","e","MouseEvent","referenceElement","FloatingButtonPopover","props","$","_c","buttonRef","t","t0","Symbol","for","current","t1","disabledText","t2","enabledText","text","t3","t4","content","t5","CurrentUser","Stack","useClickOutsideEvent","useCallback","useRef","styled","Popover","PopoverProps","CommentInput","CommentInputHandle","CommentInputProps","hasCommentMessageValue","POPOVER_FALLBACK_PLACEMENTS","RootStack","InlineCommentInputPopoverProps","currentUser","mentionOptions","onChange","onClickOutside","onDiscardConfirm","onSubmit","referenceElement","HTMLElement","value","InlineCommentInputPopover","props","$","_c","commentInputRef","contentElementRef","t0","current","discardDialogController","close","handleDiscardConfirm","t1","Symbol","for","handleDiscardCancel","t2","hasValue","open","t3","t4","content","t5","EditorSelection","PortableTextBlock","PortableTextEditor","RangeDecoration","RangeDecorationOnMovedDetails","isPortableTextTextBlock","BoundaryElementProvider","Stack","usePortal","PathUtils","uuid","debounce","isEqual","AnimatePresence","memo","startTransition","useCallback","useEffect","useLayoutEffect","useMemo","useRef","useState","useFormValue","useFieldActions","EditorChange","PortableTextInputProps","useCurrentUser","useAddonDataset","CommentInlineHighlightSpan","isTextSelectionComment","parseCommentFieldPath","useComments","useCommentsEnabled","useCommentsScroll","useCommentsSelectedPath","useCommentsUpsell","CommentDocument","CommentMessage","CommentsTextSelectionItem","CommentsUIMode","CommentUpdatePayload","buildCommentRangeDecorations","buildRangeDecorationSelectionsFromComments","buildTextSelectionFromFragment","getCommentFieldPath","getSelectionBoundingRect","useAuthoringReferenceElement","FloatingButtonPopover","InlineCommentInputPopover","EMPTY_ARRAY","AI_ASSIST_TYPE","CommentsPortableTextInput","props","$","_c","enabled","mode","fieldActions","isAiAssist","schemaType","name","isCommentsEnabledInField","Boolean","__internal_comments","t0","renderDefault","CommentsPortableTextInputInner","currentUser","portal","comments","getComment","mentionOptions","onCommentsOpen","operation","setStatus","status","error","addonDatasetError","setSelectedPath","selectedPath","scrollToComment","scrollToGroup","handleOpenDialog","mousePressed","setMousePressed","editorRef","Symbol","for","documentValue","documentValueRef","t1","t2","current","authoringDecorationElement","setAuthoringDecorationElement","nextCommentValue","setNextCommentValue","nextCommentSelection","setNextCommentSelection","currentSelection","setCurrentSelection","currentSelectionRect","setCurrenSelectionRect","currentHoveredCommentId","setCurrentHoveredCommentId","canSubmit","setCanSubmit","rootElement","setRootElement","isFullScreen","setIsFullScreen","addedCommentsDecorations","setAddedCommentsDecorations","fragment","setFragment","t3","getFragment","t4","rect","handleSetCurrentSelectionRect","t5","resetStates","t6","currentFragment","handleSelectCurrentSelection","t7","handleCommentDiscardConfirm","t8","data","open","path","t9","c_0","fieldPath","c","startsWith","filter","_temp","map","_temp2","textComments","nextValue","normalizedSelection","backward","anchor","focus","fieldPath_0","textSelection","selection","basePath","threadId","create","type","contentSnapshot","message","parentCommentId","undefined","reactions","origin","handleSubmit","t10","commentId","comment","target","field","_id","handleDecoratorClick","blurred","t11","isRangeSelected","offset","selectedFragment","isValidSelection","every","handleSelectionChange","debounceSelectionChange","useDebounceSelectionChange","t12","handleMouseDown","t13","handleMouseUp","t14","details","rangeDecoration","newSelection","commentId_0","payload","prev","next","p","nextDecoration","dirty","handleRangeDecorationMoved","t15","decoratorsToUpdate","_temp3","length","forEach","decorator_0","commentId_1","decorator","comment_0","editorValue","getValue","updatedDecoration","value","nextRange","range","nextValue_0","r","_key","concat","flat","sort","_temp4","nextComment","hasChanged","update","prev_0","next_0","p_0","isDirty","find","d","nextDecoration_0","_temp5","updateCommentRange","t16","commentsToDecorate","editorValue_0","onDecorationClick","onDecorationHoverEnd","onDecorationHoverStart","onDecorationMoved","selectedThreadId","handleBuildRangeDecorations","t17","change","onEditorChange","t18","bb0","t19","t20","children","component","authoringDecoration","rangeDecorations","currentSelectionIsOverlapping","setCurrentSelectionIsOverlapping","t21","t22","some","d_0","testA","isSelectionsOverlapping","testB","scrollElement","document","body","elements","documentScrollElement","boundaryElement","t23","t24","disabled","selector","popoverAuthoringReferenceElement","t25","bb1","t26","getBoundingClientRect","HTMLElement","selectionReferenceElement","t27","addEventListener","removeEventListener","t28","t29","nextDecorations","nextDecoration_1","prevDecoration","p_2","showFloatingButton","showFloatingInput","t30","t31","t32","t33","t34","t35","RenderDefaultCommentsPortableTextInputInner","React","ComponentProps","parentComment","c_1","a","b","localeCompare","p_1","isArrayOfBlocksSchemaType","InputProps","PortableTextInputProps","CommentsPortableTextInput","isPortableTextInputProps","inputProps","Omit","schemaType","CommentsInput","props","$","_c","t0","renderDefault"],"sources":["../src/core/comments/plugin/input/helpers.ts","../src/core/comments/plugin/input/components/FloatingButtonPopover.tsx","../src/core/comments/plugin/input/components/InlineCommentInputPopover.tsx","../src/core/comments/plugin/input/components/CommentsPortableTextInput.tsx","../src/core/comments/plugin/input/CommentsInput.tsx"],"sourcesContent":["import {useEffect, useMemo, useState} from 'react'\n\n/**\n * A function that creates a DOMRect from an array of elements.\n */\nfunction createDomRectFromElements(elements: Element[]): DOMRect | null {\n if (!elements || !elements.length) return null\n\n const rects = elements.map((el) => el.getBoundingClientRect())\n\n const minX = Math.min(...rects.map((r) => r.x)) || 0\n const minY = Math.min(...rects.map((r) => r.y)) || 0\n const maxRight = Math.max(...rects.map((r) => r.right)) || 0\n const maxBottom = Math.max(...rects.map((r) => r.bottom)) || 0\n\n return {\n x: minX,\n y: minY,\n width: maxRight - minX,\n height: maxBottom - minY,\n top: minY,\n right: maxRight,\n bottom: maxBottom,\n left: minX,\n } as DOMRect\n}\n\ninterface RectFromElementsHookOptions {\n scrollElement: HTMLElement | null\n disabled: boolean\n selector: string\n}\n\n/**\n * A hook that returns a DOMRect from an array of elements.\n * This is needed because the Range Decoration API might render se\n */\nfunction useRectFromElements(props: RectFromElementsHookOptions): DOMRect | null {\n const {scrollElement, disabled, selector} = props\n const [rect, setRect] = useState<DOMRect | null>(null)\n\n useEffect(() => {\n if (disabled) return undefined\n\n const handleSetRect = () => {\n const elements = document?.querySelectorAll(selector)\n if (!elements) return\n\n const nextRect = createDomRectFromElements(Array.from(elements))\n\n setRect(nextRect)\n }\n\n handleSetRect()\n\n if (!scrollElement) return undefined\n\n scrollElement.addEventListener('wheel', handleSetRect)\n\n return () => {\n scrollElement.removeEventListener('wheel', handleSetRect)\n }\n }, [scrollElement, disabled, selector])\n\n return rect\n}\n\nexport interface ReferenceElementHookOptions {\n scrollElement: HTMLElement | null\n disabled: boolean\n selector: string\n}\n\n/**\n * A hook that returns a reference element that can be used to position a popover.\n */\nexport function useAuthoringReferenceElement(\n props: ReferenceElementHookOptions,\n): HTMLElement | null {\n const {scrollElement, disabled, selector} = props\n\n const rect = useRectFromElements({\n scrollElement,\n disabled,\n selector,\n })\n\n const element = useMemo((): HTMLElement | null => {\n if (!rect) return null\n\n return {\n getBoundingClientRect: () => rect,\n } as HTMLElement\n }, [rect])\n\n return element\n}\n\nexport function getSelectionBoundingRect(): DOMRect | null {\n const selection = window.getSelection()\n let range = null\n\n if (selection && selection.rangeCount > 0) {\n range = selection.getRangeAt(0)\n }\n const rect = range?.getBoundingClientRect()\n\n return rect || null\n}\n","import {AddCommentIcon} from '@sanity/icons/AddComment'\nimport {useClickOutsideEvent} from '@sanity/ui'\nimport {motion, type Variants} from 'motion/react'\nimport {useRef} from 'react'\nimport {styled} from 'styled-components'\n\nimport {Button} from '../../../../../ui-components/button/Button'\nimport {Popover, type PopoverProps} from '../../../../../ui-components/popover/Popover'\nimport {useTranslation} from '../../../../i18n/hooks/useTranslation'\nimport {CommentDisabledIcon} from '../../../components/icons/CommentDisabledIcon'\nimport {commentsLocaleNamespace} from '../../../i18n'\n\nconst MotionPopover = styled(motion.create(Popover))`\n user-select: none;\n`\n\nconst POPOVER_FALLBACK_PLACEMENTS: PopoverProps['fallbackPlacements'] = ['bottom', 'top']\n\nconst VARIANTS: Variants = {\n hidden: {opacity: 0, y: -4},\n visible: {opacity: 1, y: 0},\n}\n\ninterface FloatingButtonPopoverProps {\n disabled: boolean\n onClick: () => void\n onClickOutside: (e: MouseEvent) => void\n referenceElement: PopoverProps['referenceElement']\n}\n\nexport function FloatingButtonPopover(props: FloatingButtonPopoverProps) {\n const {disabled, onClick, onClickOutside, referenceElement} = props\n const buttonRef = useRef<HTMLButtonElement | null>(null)\n const {t} = useTranslation(commentsLocaleNamespace)\n\n useClickOutsideEvent(onClickOutside, () => [buttonRef.current])\n\n const disabledText = t('inline-add-comment-button.disabled-overlap-title')\n const enabledText = t('inline-add-comment-button.title')\n const text = disabled ? disabledText : enabledText\n\n const content = (\n <Button\n data-testid=\"inline-comment-button\"\n disabled={disabled}\n icon={disabled ? CommentDisabledIcon : AddCommentIcon}\n mode=\"bleed\"\n onClick={onClick}\n ref={buttonRef}\n text={text}\n />\n )\n\n return (\n <MotionPopover\n animate=\"visible\"\n content={content}\n contentEditable={false}\n fallbackPlacements={POPOVER_FALLBACK_PLACEMENTS}\n initial=\"hidden\"\n open\n padding={1}\n placement=\"bottom\"\n portal\n referenceElement={referenceElement}\n variants={VARIANTS}\n />\n )\n}\n","import {type CurrentUser} from '@sanity/types'\nimport {Stack, useClickOutsideEvent} from '@sanity/ui'\nimport {useCallback, useRef} from 'react'\nimport {styled} from 'styled-components'\n\nimport {Popover, type PopoverProps} from '../../../../../ui-components/popover/Popover'\nimport {\n CommentInput,\n type CommentInputHandle,\n type CommentInputProps,\n} from '../../../components/pte/comment-input/CommentInput'\nimport {hasCommentMessageValue} from '../../../helpers'\n\nconst POPOVER_FALLBACK_PLACEMENTS: PopoverProps['fallbackPlacements'] = ['bottom', 'top']\n\nconst RootStack = styled(Stack)`\n width: 250px;\n`\n\ninterface InlineCommentInputPopoverProps {\n currentUser: CurrentUser\n mentionOptions: CommentInputProps['mentionOptions']\n onChange: CommentInputProps['onChange']\n onClickOutside: () => void\n onDiscardConfirm: CommentInputProps['onDiscardConfirm']\n onSubmit: CommentInputProps['onSubmit']\n referenceElement?: HTMLElement | null\n value: CommentInputProps['value']\n}\n\nexport function InlineCommentInputPopover(props: InlineCommentInputPopoverProps) {\n const {\n currentUser,\n mentionOptions,\n onChange,\n onClickOutside,\n onDiscardConfirm,\n onSubmit,\n referenceElement,\n value,\n } = props\n\n const commentInputRef = useRef<CommentInputHandle | null>(null)\n const contentElementRef = useRef<HTMLDivElement | null>(null)\n\n const handleDiscardConfirm = useCallback(() => {\n commentInputRef.current?.discardDialogController.close()\n onDiscardConfirm()\n }, [onDiscardConfirm])\n\n const handleDiscardCancel = useCallback(() => {\n commentInputRef.current?.discardDialogController.close()\n }, [])\n\n useClickOutsideEvent(\n () => {\n const hasValue = hasCommentMessageValue(value)\n\n if (hasValue) {\n commentInputRef.current?.discardDialogController.open()\n return\n }\n\n onClickOutside()\n },\n () => [contentElementRef.current],\n )\n\n const content = (\n <RootStack padding={2} ref={contentElementRef}>\n <CommentInput\n currentUser={currentUser}\n focusLock\n focusOnMount\n mentionOptions={mentionOptions}\n onChange={onChange}\n onDiscardCancel={handleDiscardCancel}\n onDiscardConfirm={handleDiscardConfirm}\n onSubmit={onSubmit}\n ref={commentInputRef}\n value={value}\n />\n </RootStack>\n )\n\n return (\n <Popover\n content={content}\n data-ui=\"InlineCommentInputPopover\"\n fallbackPlacements={POPOVER_FALLBACK_PLACEMENTS}\n open\n placement=\"bottom\"\n portal\n referenceElement={referenceElement}\n />\n )\n}\n","import {\n type EditorSelection,\n type PortableTextBlock,\n PortableTextEditor,\n type RangeDecoration,\n type RangeDecorationOnMovedDetails,\n} from '@portabletext/editor'\nimport {isPortableTextTextBlock} from '@sanity/types'\nimport {BoundaryElementProvider, Stack, usePortal} from '@sanity/ui'\nimport * as PathUtils from '@sanity/util/paths'\nimport {uuid} from '@sanity/uuid'\nimport debounce from 'lodash-es/debounce.js'\nimport isEqual from 'lodash-es/isEqual.js'\nimport {AnimatePresence} from 'motion/react'\nimport {\n memo,\n startTransition,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\n\nimport {useFormValue} from '../../../../form/contexts/FormValue'\nimport {useFieldActions} from '../../../../form/field/actions/useFieldActions'\nimport {type EditorChange, type PortableTextInputProps} from '../../../../form/types/inputProps'\nimport {useCurrentUser} from '../../../../store/user/hooks'\nimport {useAddonDataset} from '../../../../studio/addonDataset/useAddonDataset'\nimport {CommentInlineHighlightSpan} from '../../../components/pte/CommentInlineHighlightSpan'\nimport {isTextSelectionComment, parseCommentFieldPath} from '../../../helpers'\nimport {useComments} from '../../../hooks/useComments'\nimport {useCommentsEnabled} from '../../../hooks/useCommentsEnabled'\nimport {useCommentsScroll} from '../../../hooks/useCommentsScroll'\nimport {useCommentsSelectedPath} from '../../../hooks/useCommentsSelectedPath'\nimport {useCommentsUpsell} from '../../../hooks/useCommentsUpsell'\nimport {\n type CommentDocument,\n type CommentMessage,\n type CommentsTextSelectionItem,\n type CommentsUIMode,\n type CommentUpdatePayload,\n} from '../../../types'\nimport {buildCommentRangeDecorations} from '../../../utils/inline-comments/buildCommentRangeDecorations'\nimport {buildRangeDecorationSelectionsFromComments} from '../../../utils/inline-comments/buildRangeDecorationSelectionsFromComments'\nimport {\n buildTextSelectionFromFragment,\n getCommentFieldPath,\n} from '../../../utils/inline-comments/buildTextSelectionFromFragment'\nimport {getSelectionBoundingRect, useAuthoringReferenceElement} from '../helpers'\nimport {FloatingButtonPopover} from './FloatingButtonPopover'\nimport {InlineCommentInputPopover} from './InlineCommentInputPopover'\n\nconst EMPTY_ARRAY: [] = []\n\nconst AI_ASSIST_TYPE = 'sanity.assist.instruction.prompt'\n\nexport function CommentsPortableTextInput(props: PortableTextInputProps) {\n const {enabled, mode} = useCommentsEnabled()\n const fieldActions = useFieldActions()\n\n // This is a workaround solution to disable comments for the AI assist type.\n // The AI assist uses the official PTE input which is composed from the\n // Form Components API for the authoring of the prompt. Consequently, the input\n // will get the comments functionality as well, which we don't want.\n // Therefore we disable the comments for the AI assist type.\n const isAiAssist = props.schemaType.name === AI_ASSIST_TYPE\n /**\n * Comments can be disabled at field level by passing the `__internal_comments: undefined` prop to the field.\n * Even though is not recommended and tagged as internal, it works for all type of fields.\n * This adds the same ability to disable inline comments in the Portable Text editor.\n */\n const isCommentsEnabledInField = Boolean(fieldActions.__internal_comments)\n if (!enabled || isAiAssist || !isCommentsEnabledInField) {\n return props.renderDefault(props)\n }\n\n return <CommentsPortableTextInputInner {...props} mode={mode} />\n}\n\nconst CommentsPortableTextInputInner = memo(function CommentsPortableTextInputInner(\n props: PortableTextInputProps & {mode: CommentsUIMode},\n) {\n const {mode} = props\n const currentUser = useCurrentUser()\n const portal = usePortal()\n\n const {comments, getComment, mentionOptions, onCommentsOpen, operation, setStatus, status} =\n useComments()\n const {error: addonDatasetError} = useAddonDataset()\n const {setSelectedPath, selectedPath} = useCommentsSelectedPath()\n const {scrollToComment, scrollToGroup} = useCommentsScroll()\n const {handleOpenDialog} = useCommentsUpsell()\n const [mousePressed, setMousePressed] = useState<boolean>(false)\n\n const editorRef = useRef<PortableTextEditor | null>(null)\n\n // Read through a ref because `useFormValue([])` changes identity on every\n // keystroke: keeping it out of dependency arrays keeps decoration rebuilds\n // keyed on comment changes. The layout effect updates the ref synchronously\n // with the commit, so event handlers never observe a stale value.\n const documentValue = useFormValue([])\n const documentValueRef = useRef(documentValue)\n useLayoutEffect(() => {\n documentValueRef.current = documentValue\n }, [documentValue])\n\n // A reference to the authoring decoration element that highlights the selected text\n // when starting to author a comment.\n const [authoringDecorationElement, setAuthoringDecorationElement] =\n useState<HTMLSpanElement | null>(null)\n\n const [nextCommentValue, setNextCommentValue] = useState<CommentMessage | null>(null)\n const [nextCommentSelection, setNextCommentSelection] = useState<EditorSelection | null>(null)\n\n const [currentSelection, setCurrentSelection] = useState<EditorSelection | null>(null)\n const [currentSelectionRect, setCurrenSelectionRect] = useState<DOMRect | null>(null)\n\n const [currentHoveredCommentId, setCurrentHoveredCommentId] = useState<string | null>(null)\n\n const [canSubmit, setCanSubmit] = useState<boolean>(false)\n\n const [rootElement, setRootElement] = useState<HTMLDivElement | null>(null)\n const [isFullScreen, setIsFullScreen] = useState<boolean>(false)\n const [addedCommentsDecorations, setAddedCommentsDecorations] =\n useState<RangeDecoration[]>(EMPTY_ARRAY)\n\n const [fragment, setFragment] = useState<PortableTextBlock[] | null>(null)\n\n const getFragment = useCallback(() => {\n if (!editorRef.current) return EMPTY_ARRAY\n return PortableTextEditor.getFragment(editorRef.current)\n }, [])\n\n const handleSetCurrentSelectionRect = useCallback(() => {\n const rect = getSelectionBoundingRect()\n setCurrenSelectionRect(rect)\n }, [])\n\n const resetStates = useCallback(() => {\n setCurrentSelection(null)\n setCurrenSelectionRect(null)\n setNextCommentSelection(null)\n setNextCommentValue(null)\n setCanSubmit(false)\n setAuthoringDecorationElement(null)\n setFragment(null)\n }, [])\n\n // Set the next comment selection to the current selection so that we can\n // render the comment input popover on the current selection using a range decoration.\n const handleSelectCurrentSelection = useCallback(() => {\n // When trying to add a comment in \"upsell\" mode, we want to\n // display the upsell dialog instead of the comment input popover.\n if (mode === 'upsell') {\n handleOpenDialog('pte')\n return\n }\n const currentFragment = getFragment() || null\n setFragment(currentFragment)\n setNextCommentSelection(currentSelection)\n }, [currentSelection, getFragment, handleOpenDialog, mode])\n\n // Clear the selection and close the popover when discarding the comment\n const handleCommentDiscardConfirm = useCallback(() => {\n resetStates()\n }, [resetStates])\n\n const textComments = useMemo(() => {\n return comments.data.open\n .filter((c) => isTextSelectionComment(c.parentComment))\n .filter((c) => {\n // Keep the per-editor work proportional to the editor's own comments.\n const fieldPath = parseCommentFieldPath(c.fieldPath)\n return fieldPath ? PathUtils.startsWith(props.path, fieldPath) : false\n })\n .map((c) => c.parentComment)\n }, [comments.data.open, props.path])\n\n const handleSubmit = useCallback(\n (nextValue: CommentMessage) => {\n if (!nextCommentSelection || !editorRef.current) return\n\n const normalizedSelection = nextCommentSelection.backward\n ? {backward: false, anchor: nextCommentSelection.focus, focus: nextCommentSelection.anchor}\n : nextCommentSelection\n\n const fieldPath = getCommentFieldPath(\n documentValueRef.current,\n props.path,\n normalizedSelection.focus.path,\n )\n if (!fieldPath) return\n\n const textSelection = buildTextSelectionFromFragment({\n fragment: fragment || EMPTY_ARRAY,\n selection: normalizedSelection,\n documentValue: documentValueRef.current,\n basePath: props.path,\n })\n\n const threadId = uuid()\n\n void operation.create({\n type: 'field',\n contentSnapshot: fragment,\n fieldPath,\n message: nextValue,\n parentCommentId: undefined,\n reactions: EMPTY_ARRAY,\n selection: textSelection,\n status: 'open',\n threadId,\n })\n\n // Open the inspector when a new comment is added\n onCommentsOpen?.()\n\n // Set the status to 'open' so that the comment is visible\n if (status === 'resolved') {\n setStatus('open')\n }\n\n // Set the selected path to the new comment\n setSelectedPath({\n fieldPath,\n threadId,\n origin: 'form',\n })\n\n // Scroll to the comment\n scrollToGroup(threadId)\n\n resetStates()\n },\n [\n nextCommentSelection,\n operation,\n props.path,\n onCommentsOpen,\n status,\n setSelectedPath,\n scrollToGroup,\n resetStates,\n setStatus,\n fragment,\n ],\n )\n\n const handleDecoratorClick = useCallback(\n (commentId: string) => {\n const comment = getComment(commentId)\n if (!comment) return\n\n setSelectedPath({\n fieldPath: comment.target.path?.field || '',\n threadId: comment.threadId,\n origin: 'form',\n })\n\n onCommentsOpen?.()\n\n scrollToComment(comment._id)\n },\n [getComment, onCommentsOpen, scrollToComment, setSelectedPath],\n )\n\n const blurred = useRef<boolean>(false)\n\n const handleSelectionChange = useCallback(\n (selection: EditorSelection | null) => {\n const isRangeSelected = selection?.anchor.offset !== selection?.focus.offset\n\n const selectedFragment = getFragment()\n const isValidSelection = selectedFragment?.every(isPortableTextTextBlock)\n\n if (!isValidSelection || !isRangeSelected) {\n setCanSubmit(false)\n return\n }\n /**\n * When the portable text editor loses focus we will save the blurred.current to true.\n * Later, when it restores focus the editor will emit a selection change event, but we don't want to immediately show the comment input\n * instead, we want to wait until the user selects a new range.\n */\n if (blurred.current) {\n blurred.current = false\n return\n }\n // If the mouse is not down, we want to set the current selection rect\n // when the selection changes. Otherwise, we want to wait until the mouse\n // is up to set the current selection rect (see `handleMouseUp`).\n if (!mousePressed) {\n handleSetCurrentSelectionRect()\n }\n\n setCurrentSelection(selection)\n setCanSubmit(true)\n },\n [getFragment, handleSetCurrentSelectionRect, mousePressed],\n )\n\n const debounceSelectionChange = useDebounceSelectionChange(handleSelectionChange)\n\n const handleMouseDown = useCallback(() => {\n startTransition(() => setMousePressed(true))\n }, [])\n\n const handleMouseUp = useCallback(() => {\n startTransition(() => setMousePressed(false))\n\n // When the mouse is up, we want to set the current selection rect.\n handleSetCurrentSelectionRect()\n }, [handleSetCurrentSelectionRect])\n\n const handleRangeDecorationMoved = useCallback((details: RangeDecorationOnMovedDetails) => {\n const {rangeDecoration, newSelection} = details\n\n const commentId = rangeDecoration.payload?.commentId as undefined | string\n\n // Update the range decoration with the new selection.\n setAddedCommentsDecorations((prev) => {\n const next = prev.map((p) => {\n if (p.payload?.commentId === commentId) {\n const nextDecoration: RangeDecoration = {\n ...rangeDecoration,\n selection: newSelection,\n payload: {...rangeDecoration.payload, dirty: true},\n }\n return nextDecoration\n }\n return p\n })\n return next\n })\n }, [])\n\n const updateCommentRange = useCallback(() => {\n const decoratorsToUpdate = addedCommentsDecorations.filter(\n (decorator) => decorator.payload?.dirty,\n )\n if (decoratorsToUpdate.length === 0) return\n\n decoratorsToUpdate.forEach((decorator) => {\n const commentId = decorator.payload?.commentId as undefined | string\n const comment = getComment(commentId || '')\n\n // If the comment no longer exists, remove the range decoration.\n if (!comment) {\n return\n }\n\n // The below code will update the comment object to reflect the new selection\n if (!editorRef.current) return\n const editorValue = PortableTextEditor.getValue(editorRef.current) || EMPTY_ARRAY\n\n const [updatedDecoration] = buildRangeDecorationSelectionsFromComments({\n comments: [comment],\n value: editorValue,\n documentValue: documentValueRef.current,\n basePath: props.path,\n })\n\n const nextRange = updatedDecoration?.range ? [updatedDecoration.range] : EMPTY_ARRAY\n\n const nextValue: CommentsTextSelectionItem[] = updatedDecoration\n ? [\n ...(comment.target.path?.selection?.value\n .filter((r) => r._key !== nextRange[0]?._key)\n .concat(nextRange)\n .flat()\n .sort((a, b) => a._key.localeCompare(b._key)) || EMPTY_ARRAY),\n ]\n : EMPTY_ARRAY\n\n const nextComment: CommentUpdatePayload = {\n target: {\n ...comment.target,\n path: {\n ...comment.target?.path,\n field: comment.target.path?.field || '',\n selection: {\n type: 'text',\n value: nextValue,\n },\n },\n },\n }\n\n const hasChanged = !isEqual(comment.target, nextComment.target)\n\n if (hasChanged) {\n void operation.update(comment._id, nextComment)\n }\n })\n\n // Mark the range decorations as not dirty\n setAddedCommentsDecorations((prev) => {\n const next = prev.map((p) => {\n const isDirty = decoratorsToUpdate.find(\n (d) => d.payload?.commentId === p.payload?.commentId,\n )?.payload?.dirty\n\n if (isDirty) {\n const nextDecoration: RangeDecoration = {\n ...p,\n payload: {...p.payload, dirty: false},\n }\n return nextDecoration\n }\n return p\n })\n return next.filter((p) => p.selection !== null)\n })\n }, [addedCommentsDecorations, getComment, operation, props.path])\n\n const handleBuildRangeDecorations = useCallback(\n (commentsToDecorate: CommentDocument[]) => {\n if (!editorRef.current) return EMPTY_ARRAY\n const editorValue = PortableTextEditor.getValue(editorRef.current) || EMPTY_ARRAY\n\n return buildCommentRangeDecorations({\n comments: commentsToDecorate,\n currentHoveredCommentId,\n onDecorationClick: handleDecoratorClick,\n onDecorationHoverEnd: setCurrentHoveredCommentId,\n onDecorationHoverStart: setCurrentHoveredCommentId,\n onDecorationMoved: handleRangeDecorationMoved,\n selectedThreadId: selectedPath?.threadId || null,\n value: editorValue,\n documentValue: documentValueRef.current,\n basePath: props.path,\n })\n },\n [\n currentHoveredCommentId,\n handleDecoratorClick,\n handleRangeDecorationMoved,\n props.path,\n selectedPath?.threadId,\n ],\n )\n\n const onEditorChange = useCallback(\n (change: EditorChange) => {\n if (change.type === 'mutation') {\n updateCommentRange()\n }\n if (change.type === 'blur') {\n blurred.current = true\n }\n if (change.type === 'selection') {\n debounceSelectionChange(change.selection)\n }\n },\n [debounceSelectionChange, updateCommentRange],\n )\n\n // The range decoration for the comment input. This is used to position the\n // comment input popover on the current selection and to highlight the\n // selected text.\n const authoringDecoration = useMemo((): RangeDecoration | null => {\n if (!nextCommentSelection) return null\n\n return {\n component: ({children}) => (\n <CommentInlineHighlightSpan isAuthoring ref={setAuthoringDecorationElement}>\n {children}\n </CommentInlineHighlightSpan>\n ),\n selection: nextCommentSelection,\n }\n }, [nextCommentSelection])\n\n // All the range decorations\n const rangeDecorations: RangeDecoration[] = [\n // Existing range decorations\n ...(props?.rangeDecorations || EMPTY_ARRAY),\n // The range decoration when adding a comment\n ...(authoringDecoration ? [authoringDecoration] : EMPTY_ARRAY),\n // The range decorations for existing comments\n ...addedCommentsDecorations,\n ]\n\n const [currentSelectionIsOverlapping, setCurrentSelectionIsOverlapping] = useState<boolean>(false)\n useEffect(() => {\n startTransition(() =>\n setCurrentSelectionIsOverlapping(() => {\n if (!currentSelection || addedCommentsDecorations.length === 0) return false\n\n return addedCommentsDecorations.some((d) => {\n if (!editorRef.current) return false\n\n const testA = PortableTextEditor.isSelectionsOverlapping(\n editorRef.current,\n currentSelection,\n d.selection,\n )\n\n const testB = PortableTextEditor.isSelectionsOverlapping(\n editorRef.current,\n d.selection,\n currentSelection,\n )\n\n return testA || testB\n })\n }),\n )\n }, [addedCommentsDecorations, currentSelection])\n\n // The scroll element used to update the reference element for the\n // popover on scroll.\n const scrollElement = isFullScreen\n ? document.body\n : portal.elements?.documentScrollElement || document.body\n\n // The boundary element used to position the popover properly\n // inside the editor.\n const boundaryElement = isFullScreen\n ? portal.elements?.documentScrollElement || document.body\n : rootElement\n\n const popoverAuthoringReferenceElement = useAuthoringReferenceElement({\n scrollElement,\n disabled: !nextCommentSelection || !authoringDecorationElement,\n selector: '[data-inline-comment-state=\"authoring\"]',\n })\n\n const selectionReferenceElement = useMemo(() => {\n if (!currentSelectionRect) return null\n\n return {\n getBoundingClientRect: () => currentSelectionRect,\n } as HTMLElement\n }, [currentSelectionRect])\n\n // This effect is needed to update the reference element for the popover\n // when the current selection changes so that it is always positioned\n // on the current selection.\n useEffect(() => {\n if (!currentSelection) return undefined\n scrollElement?.addEventListener('wheel', handleSetCurrentSelectionRect)\n\n return () => {\n scrollElement?.removeEventListener('wheel', handleSetCurrentSelectionRect)\n }\n }, [currentSelection, scrollElement, handleSetCurrentSelectionRect])\n\n // This is effect is needed to handle remote changes to the comments.\n // That is, when another user adds, updates or deletes a comment, we need\n // to update the range decorations to reflect these changes in the UI.\n useEffect(() => {\n const nextDecorations = handleBuildRangeDecorations(textComments)\n\n // The `dirty` flag is used to keep track of range decorations that\n // have been moved. When a range decoration is moved, we need to update\n // the comment document. However, when receiving updates from the server,\n // the `dirty` flag will be removed. Therefore, we need to make sure\n // that the `dirty` flag is preserved so that we can update the comment.\n startTransition(() =>\n setAddedCommentsDecorations((current) => {\n return nextDecorations.map((nextDecoration) => {\n const prevDecoration = current.find(\n (p) => p.payload?.commentId === nextDecoration.payload?.commentId,\n )\n\n if (prevDecoration?.payload?.dirty) {\n return {\n ...nextDecoration,\n payload: {...nextDecoration.payload, dirty: prevDecoration.payload.dirty},\n }\n }\n\n return nextDecoration\n })\n }),\n )\n }, [handleBuildRangeDecorations, textComments])\n\n const showFloatingButton = Boolean(\n currentSelection && canSubmit && selectionReferenceElement && !mousePressed,\n )\n const showFloatingInput = Boolean(nextCommentSelection && popoverAuthoringReferenceElement)\n\n return (\n <>\n <BoundaryElementProvider element={boundaryElement}>\n {showFloatingInput && currentUser && (\n <InlineCommentInputPopover\n currentUser={currentUser}\n mentionOptions={mentionOptions}\n onChange={setNextCommentValue}\n onClickOutside={resetStates}\n onDiscardConfirm={handleCommentDiscardConfirm}\n onSubmit={handleSubmit}\n referenceElement={popoverAuthoringReferenceElement}\n value={nextCommentValue}\n />\n )}\n <AnimatePresence>\n {showFloatingButton && !showFloatingInput && (\n <FloatingButtonPopover\n disabled={currentSelectionIsOverlapping || Boolean(addonDatasetError)}\n onClick={handleSelectCurrentSelection}\n onClickOutside={resetStates}\n referenceElement={selectionReferenceElement}\n />\n )}\n </AnimatePresence>\n </BoundaryElementProvider>\n\n <Stack ref={setRootElement} onMouseDown={handleMouseDown} onMouseUp={handleMouseUp}>\n <RenderDefaultCommentsPortableTextInputInner\n {...props}\n onEditorChange={onEditorChange}\n editorRef={editorRef}\n rangeDecorations={rangeDecorations}\n onFullScreenChange={setIsFullScreen}\n />\n </Stack>\n </>\n )\n})\n\n// Workaround for react compiler restrictions on refs triggered by the debounce wrapper\nfunction useDebounceSelectionChange(\n handleSelectionChange: (selection: EditorSelection | null) => void,\n) {\n return useMemo(() => debounce(handleSelectionChange, 200), [handleSelectionChange])\n}\n// Used to workaround restrictions on passing refs to functions in react compiler\nfunction RenderDefaultCommentsPortableTextInputInner(\n props: React.ComponentProps<typeof CommentsPortableTextInputInner>,\n) {\n return props.renderDefault(props)\n}\n","import {isArrayOfBlocksSchemaType} from '@sanity/types'\n\nimport {type InputProps, type PortableTextInputProps} from '../../../form/types/inputProps'\nimport {CommentsPortableTextInput} from './components/CommentsPortableTextInput'\n\nfunction isPortableTextInputProps(\n inputProps: InputProps | Omit<InputProps, 'renderDefault'>,\n): inputProps is PortableTextInputProps {\n return isArrayOfBlocksSchemaType(inputProps.schemaType)\n}\n\nexport function CommentsInput(props: InputProps) {\n if (isPortableTextInputProps(props)) {\n return <CommentsPortableTextInput {...props} />\n }\n\n return props.renderDefault(props)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAASG,0BAA0BC,UAAqC;CACtE,IAAI,CAACA,YAAY,CAACA,SAASG,QAAQ,OAAO;CAE1C,IAAMC,QAAQJ,SAASK,KAAKC,OAAOA,GAAGC,sBAAsB,CAAC,GAEvDC,OAAOC,KAAKC,IAAI,GAAGN,MAAMC,KAAKM,MAAMA,EAAEC,CAAC,CAAC,KAAK,GAC7CC,OAAOJ,KAAKC,IAAI,GAAGN,MAAMC,KAAKM,MAAMA,EAAEG,CAAC,CAAC,KAAK,GAC7CC,WAAWN,KAAKO,IAAI,GAAGZ,MAAMC,KAAKM,MAAMA,EAAEM,KAAK,CAAC,KAAK,GACrDC,YAAYT,KAAKO,IAAI,GAAGZ,MAAMC,KAAKM,MAAMA,EAAEQ,MAAM,CAAC,KAAK;CAE7D,OAAO;EACLP,GAAGJ;EACHM,GAAGD;EACHO,OAAOL,WAAWP;EAClBa,QAAQH,YAAYL;EACpBS,KAA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FhB,SAAA1J,OAAA2J,KAAA;CAAA,OAgG1BhK,IAAC+J;AAAc;AAhGW,SAAAlG,OAAAK,WAAA;CAAA,OAmQvBA,UAASd,SAAeK;AAAA;AAnQD,SAAAuB,OAAAiF,GAAAC,GAAA;CAAA,OAmSdD,EAACrF,KAAKuF,cAAeD,EAACtF,IAAK;AAAC;AAnSd,SAAAe,OAAAyE,KAAA;CAAA,OA4UZ7G,IAACzC,cAAe;AAAI;ACxZpD,SAAS2J,yBACPC,YACsC;CACtC,OAAOL,0BAA0BK,WAAWE,UAAU;AACxD;AAEA,SAAOC,cAAAC,OAAA;CAAA,IAAAC,IAAAC,EAAA,CAAA;CACL,IAAIP,yBAAyBK,KAAK,GAAC;EAAA,IAAAG;EACc,OADdF,EAAA,OAAAD,QACcG,KAAAF,EAAA,MAAxCE,KAAA,oBAAC,2BAAD,EAA0B,GAAKH,MAAK,CAAA,GAAIC,EAAA,KAAAD,OAAAC,EAAA,KAAAE,KAAxCA;CAAwC;CAChD,IAAAA;CAEgC,OAFhCF,EAAA,OAAAD,QAEgCG,KAAAF,EAAA,MAA1BE,KAAAH,MAAKI,cAAeJ,KAAK,GAACC,EAAA,KAAAD,OAAAC,EAAA,KAAAE,KAA1BA;AAA0B"}
@@ -1,10 +1,10 @@
1
1
  import { r as Popover$1 } from "./ConfirmPopover-CEELgHMw.js";
2
2
  import { a as Button$1, r as MenuButton$1, t as MenuItem$1 } from "./MenuItem-B0ry3E4J.js";
3
- import { p as useCurrentUser } from "./datastores-CFWEadl-.js";
3
+ import { p as useCurrentUser } from "./datastores-CrRYBoDP.js";
4
4
  import { t as useTranslation } from "./useTranslation-Cqs6Itwv.js";
5
- import { b as commentsLocaleNamespace, f as isTextSelectionComment, t as useComments, y as useCommentsScroll } from "./useComments-KoRXRvW7.js";
6
- import { r as CommentDeleteDialog } from "./CommentsListItem-x7FKz_CM.js";
7
- import { n as CommentsList, t as useCommentsTelemetry } from "./useCommentsTelemetry-LlKtxi5d.js";
5
+ import { b as commentsLocaleNamespace, f as isTextSelectionComment, t as useComments, y as useCommentsScroll } from "./useComments-CzNBSPgQ.js";
6
+ import { r as CommentDeleteDialog } from "./CommentsListItem-BjWNEXPU.js";
7
+ import { n as CommentsList, t as useCommentsTelemetry } from "./useCommentsTelemetry-CkplhYJa.js";
8
8
  import { t as useAddonDataset } from "./useAddonDataset-BvCgByG6.js";
9
9
  import { t as useCommentsEnabled } from "./useCommentsEnabled-BPc3788v.js";
10
10
  import { t as useCommentsSelectedPath } from "./useCommentsSelectedPath-D5HXM3NF.js";
@@ -486,4 +486,4 @@ function _temp(x) {
486
486
  }
487
487
  export { CommentsInspector };
488
488
 
489
- //# sourceMappingURL=CommentsInspector-H5CpN_XH.js.map
489
+ //# sourceMappingURL=CommentsInspector-PkVZw8uv.js.map