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,4 +1,4 @@
1
- import { t as SANITY_VERSION } from "./version-CY300aPw.js";
1
+ import { t as SANITY_VERSION } from "./version-BZCsk4ue.js";
2
2
  import { createContext } from "react";
3
3
  const MISSING_CONTEXT_HELP_URL = "https://www.sanity.io/help/missing-context-error";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { $n as SearchContextValue, $t as NavbarContextValue, AT as FieldPresenceData, Ah as MetadataWrapper, Av as Workspace, By as DocumentActionProps, C_ as TrackerContextStore, Cr as RouterHistory, Eg as ConnectorContextValue, Er as ResourceCache, Eu as VirtualizerScrollInstance, F_ as ActiveWorkspaceMatcherContextValue, GT as DocumentFieldAction$1, Ju as FormValueContextValue, Kg as CommentMessage, Lc as ReferenceInputOptions, Lg as CommentsEnabledContextValue, N_ as UpsellDialogViewedInfo, Np as StudioErrorHandler, P_ as AddonDatasetContextValue, Pt as VisibleWorkspacesContextValue, Py as DocumentActionDescription, Rf as UserColorManager, Rg as CommentsContextValue, Rn as CopyPasteContextType, S_ as TrackerContextGetSnapshot, Tm as ZIndexContextValue, Tv as Source$1, Wd as DocumentChangeContextInstance, Wg as CommentIntentGetter, XT as DocumentFieldActionNode$1, Xw as PerspectiveContextValue, Yf as FeedbackContextValue, al as ParseError, an as StudioAnnouncementsContextValue, au as PortableTextMemberItem, br as WorkspacesContextValue, dC as FieldCommentsProps, eS as StudioColorScheme, jT as FormNodePresence, ju as FormBuilderContextValue, mn as ConfigErrorClassification, nS as StudioThemeColorSchemeKey, rC as PortableTextMarker, tl as FormCallbacksValue, u_ as UserListWithPermissionsHookValue, uh as PreviewCardContextValue, up as DivergenceNavigator, ux as EventsStore, vc as EnhancedObjectDialogContextValue, vg as CommentsSelectedPathContextValue, xa as SchedulesContextValue, y_ as ChangeIndicatorTrackerContextValue, zS as Locale } from "./index-Dhee2Ms1.js";
1
+ import { $n as SearchContextValue, $t as NavbarContextValue, Ah as MetadataWrapper, BS as Locale, C_ as TrackerContextGetSnapshot, Cr as RouterHistory, Dg as ConnectorContextValue, Er as ResourceCache, Eu as VirtualizerScrollInstance, Ev as Source$1, F_ as AddonDatasetContextValue, Fy as DocumentActionDescription, Gg as CommentIntentGetter, I_ as ActiveWorkspaceMatcherContextValue, Ju as FormValueContextValue, KT as DocumentFieldAction$1, Lc as ReferenceInputOptions, MT as FormNodePresence, Np as StudioErrorHandler, P_ as UpsellDialogViewedInfo, Pt as VisibleWorkspacesContextValue, Rf as UserColorManager, Rg as CommentsEnabledContextValue, Rn as CopyPasteContextType, Tm as ZIndexContextValue, Vy as DocumentActionProps, Wd as DocumentChangeContextInstance, Yf as FeedbackContextValue, ZT as DocumentFieldActionNode$1, Zw as PerspectiveContextValue, al as ParseError, an as StudioAnnouncementsContextValue, au as PortableTextMemberItem, b_ as ChangeIndicatorTrackerContextValue, br as WorkspacesContextValue, d_ as UserListWithPermissionsHookValue, dx as EventsStore, fC as FieldCommentsProps, iC as PortableTextMarker, jT as FieldPresenceData, ju as FormBuilderContextValue, jv as Workspace, mn as ConfigErrorClassification, qg as CommentMessage, rS as StudioThemeColorSchemeKey, tS as StudioColorScheme, tl as FormCallbacksValue, uh as PreviewCardContextValue, up as DivergenceNavigator, vc as EnhancedObjectDialogContextValue, w_ as TrackerContextStore, xa as SchedulesContextValue, yg as CommentsSelectedPathContextValue, zg as CommentsContextValue } from "./index-Bic9X2KM.js";
2
2
  import { F as PaneLayoutContextValue, P as PaneContextValue, c as DocumentPaneInfoContextValue, i as PaneRouterContextValue, k as StructureToolContextValue, s as DocumentPaneContextValue, w as RouterPanes, y as PaneNode } from "./types-pSwINOjF.js";
3
3
  import { g as PresentationParamsContextValue, h as PresentationNavigateContextValue, m as PresentationContextValue, v as PresentationPluginOptions } from "./types-DdqcmD0r.js";
4
4
  import { _ as RouterContextValue } from "./types-DEfyw-7V.js";
@@ -1,5 +1,5 @@
1
- import { s as getValueAtPath } from "./useFieldActions-NrjLdjo8.js";
2
- import { f as isTextSelectionComment, n as COMMENTS_HIGHLIGHT_HUE_KEY, p as parseCommentFieldPath, v as applyInlineCommentIdAttr } from "./useComments-KoRXRvW7.js";
1
+ import { s as getValueAtPath } from "./useFieldActions-DbRTTr6-.js";
2
+ import { f as isTextSelectionComment, n as COMMENTS_HIGHLIGHT_HUE_KEY, p as parseCommentFieldPath, v as applyInlineCommentIdAttr } from "./useComments-CzNBSPgQ.js";
3
3
  import { forwardRef, memo, useEffect, useRef, useState } from "react";
4
4
  import { c } from "react/compiler-runtime";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -286,4 +286,4 @@ function findBlockByKey(arrays, key) {
286
286
  }
287
287
  export { CommentInlineHighlightSpan as a, buildRangeDecorationSelectionsFromComments as i, getCommentFieldPath as n, CommentDisabledIcon as o, buildCommentRangeDecorations as r, buildTextSelectionFromFragment as t };
288
288
 
289
- //# sourceMappingURL=buildTextSelectionFromFragment-BXiSMql4.js.map
289
+ //# sourceMappingURL=buildTextSelectionFromFragment-Dj_WBTDa.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildTextSelectionFromFragment-BXiSMql4.js","names":["forwardRef","Ref","SVGProps","CommentDisabledIcon","Icon","props","ref","$","_c","t0","t1","Symbol","for","t2","hues","Theme","forwardRef","css","styled","COMMENTS_HIGHLIGHT_HUE_KEY","HighlightSpan","span","theme","isDark","sanity","v2","color","_dark","addedBg","hex","addedBorder","addedHoverBg","addedHoverBorder","addedNestedBg","addedNesterBorder","authoringBg","authoringBorder","CommentInlineHighlightSpanProps","children","React","ReactNode","isAdded","isAuthoring","isHovered","isNested","CommentInlineHighlightSpan","props","ref","$","_c","rest","state","undefined","t0","t1","t2","RangeDecoration","applyPatches","cleanupEfficiency","Diff","DIFF_DELETE","DIFF_EQUAL","DIFF_INSERT","makeDiff","makePatches","Patch","isPortableTextSpan","isPortableTextTextBlock","Path","PortableTextBlock","PortableTextTextBlock","PathUtils","getValueAtPath","isTextSelectionComment","parseCommentFieldPath","CommentDocument","CommentsTextSelectionItem","DMP_MARGIN","diffText","current","next","diff","diffs","levenshtein","diffsLevenshtein","patches","margin","diffApply","allowExceedingIndices","CHILD_SYMBOL","toPlainTextWithChildSeparators","inputBlock","children","map","child","text","replaceAll","join","COMMENT_INDICATORS","COMMENT_INDICATORS_REGEX","RegExp","EMPTY_ARRAY","BuildCommentsRangeDecorationsProps","value","comments","documentValue","basePath","BuildCommentsRangeDecorationsResultItem","selection","comment","range","buildRangeDecorationSelectionsFromComments","props","length","textSelections","filter","decorators","forEach","relative","undefined","fieldPath","target","path","field","startsWith","slice","selectionMember","matchedBlock","_key","find","block","selectionText","textWithChildSeparators","diffedText","startIndex","indexOf","endIndex","textWithoutCommentTags","oldCommentedText","newCommentedText","threshold","Math","round","nullSelection","childIndexAnchor","anchorOffset","childIndexFocus","focusOffset","i","push","anchor","offset","focus","ValidateTextSelectionCommentProps","validateTextSelectionComment","selections","insertions","deletions","x","op","data","max","RangeDecoration","RangeDecorationOnMovedDetails","Path","PortableTextBlock","memo","useCallback","useEffect","useRef","useState","CommentInlineHighlightSpan","applyInlineCommentIdAttr","CommentDocument","buildRangeDecorationSelectionsFromComments","CommentRangeDecorationProps","children","React","ReactNode","commentId","currentHoveredCommentId","onClick","onHoverEnd","onHoverStart","selectedThreadId","threadId","CommentRangeDecoration","props","$","_c","decoratorRef","isNested","setIsNested","parentCommentId","setParentCommentId","t0","t1","Symbol","for","prevEl","current","previousSibling","HTMLElement","nextEl","nextSibling","key","Object","keys","prevId","getAttribute","nextId","isEqual","isNestedDecorator","Boolean","t2","handleMouseEnter","t3","handleMouseLeave","t4","handleClick","hovered","selected","t5","t6","t7","displayName","BuildRangeDecorationsProps","comments","onDecorationClick","onDecorationHoverEnd","onDecorationHoverStart","onDecorationMoved","details","value","documentValue","basePath","buildCommentRangeDecorations","rangeSelections","decorations","map","selection","comment","range","decoration","component","_id","onMoved","payload","EditorSelection","toPlainText","isPortableTextSpan","isPortableTextTextBlock","Path","PortableTextBlock","PortableTextTextBlock","PathUtils","getValueAtPath","CommentTextSelection","COMMENT_INDICATORS","BuildSelectionFromFragmentProps","fragment","documentValue","basePath","selection","buildTextSelectionFromFragment","props","Error","normalizedSelection","backward","anchor","focus","block","anchorBlock","path","anchorBlockPath","findEnclosingTextBlock","focusBlock","focusBlockPath","containingArrays","Array","blockPath","containingArray","slice","isArray","includes","push","textSelection","type","value","map","fragmentBlock","originalBlock","findBlockByKey","_key","text","anchorBlockKey","focusBlockKey","fragmentBlockText","fragmentStartSpan","children","undefined","fragmentEndSpan","length","originalTextBeforeSelection","startChildIndex","child","Math","max","offset","originalTextAfterSelection","reverse","getCommentFieldPath","selectionPath","enclosingBlockPath","toString","end","relative","candidate","arrays","key","array"],"sources":["../src/core/comments/components/icons/CommentDisabledIcon.tsx","../src/core/comments/components/pte/CommentInlineHighlightSpan.tsx","../src/core/comments/utils/inline-comments/buildRangeDecorationSelectionsFromComments.ts","../src/core/comments/utils/inline-comments/buildCommentRangeDecorations.tsx","../src/core/comments/utils/inline-comments/buildTextSelectionFromFragment.ts"],"sourcesContent":["import {forwardRef, type Ref, type SVGProps} from 'react'\n\n/**\n * @internal\n */\nexport const CommentDisabledIcon = forwardRef(function Icon(\n props: SVGProps<SVGSVGElement>,\n ref: Ref<SVGSVGElement>,\n) {\n return (\n <svg\n data-sanity-icon=\"comment-disabled\"\n width=\"1em\"\n height=\"1em\"\n ref={ref}\n viewBox=\"0 0 25 25\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n {...props}\n >\n <path\n d=\"M5.92627 14.5381H7.92627V18.5381L11.9263 14.5381H15.9263C17.0308 14.5381 17.9263 13.6427 17.9263 12.5381V6.53809C17.9263 5.43352 17.0308 4.53809 15.9263 4.53809H5.92627C4.8217 4.53809 3.92627 5.43352 3.92627 6.53809V12.5381C3.92627 13.6427 4.8217 14.5381 5.92627 14.5381Z\"\n stroke=\"currentColor\"\n strokeWidth=\"1.2\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M2.77256 2.66835C2.54413 2.51319 2.23317 2.57259 2.07802 2.80103L1.40378 3.7937C1.32927 3.9034 1.30139 4.0382 1.32627 4.16845C1.35115 4.29871 1.42676 4.41374 1.53646 4.48825L19.5861 16.7479C19.8146 16.903 20.1255 16.8436 20.2807 16.6152L20.9549 15.6225C21.0294 15.5128 21.0573 15.378 21.0324 15.2478C21.0076 15.1175 20.9319 15.0025 20.8222 14.928L2.77256 2.66835Z\"\n fill=\"currentColor\"\n strokeLinejoin=\"round\"\n />\n </svg>\n )\n})\n","import {hues} from '@sanity/color'\nimport {type Theme} from '@sanity/ui'\nimport {forwardRef} from 'react'\nimport {css, styled} from 'styled-components'\n\nimport {COMMENTS_HIGHLIGHT_HUE_KEY} from '../../constants'\n\nconst HighlightSpan = styled.span(({theme}: {theme: Theme}) => {\n const isDark = theme.sanity.v2?.color._dark\n\n // Colors used when a comment is added\n const addedBg = hues[COMMENTS_HIGHLIGHT_HUE_KEY][isDark ? 800 : 100].hex\n const addedBorder = hues[COMMENTS_HIGHLIGHT_HUE_KEY][isDark ? 700 : 300].hex\n\n const addedHoverBg = hues[COMMENTS_HIGHLIGHT_HUE_KEY][isDark ? 700 : 200].hex\n const addedHoverBorder = hues[COMMENTS_HIGHLIGHT_HUE_KEY][isDark ? 600 : 400].hex\n\n // Colors used when a comment is added and it is a nested comment\n const addedNestedBg = hues[COMMENTS_HIGHLIGHT_HUE_KEY][isDark ? 700 : 200].hex\n const addedNesterBorder = hues[COMMENTS_HIGHLIGHT_HUE_KEY][isDark ? 600 : 400].hex\n\n // Colors used when a comment is being authored.\n // For now, we use the same colors as when a comment is added.\n const authoringBg = addedBg\n const authoringBorder = addedBorder\n\n return css`\n box-sizing: border-box;\n transition:\n background-color 100ms ease,\n border-color 100ms ease;\n\n // Make sure that child elements appropriately blend with the\n // background of the highlight span\n * {\n mix-blend-mode: ${isDark ? 'screen' : 'multiply'};\n }\n\n &[data-inline-comment-state='added'][data-inline-comment-nested='false'] {\n background-color: ${addedBg};\n border-bottom: 2px solid ${addedBorder};\n }\n\n &[data-inline-comment-state='added'][data-inline-comment-nested='true'] {\n background-color: ${addedNestedBg};\n border-bottom: 2px solid ${addedNesterBorder};\n }\n\n &[data-inline-comment-state='added'][data-inline-comment-nested='false'][data-hovered='true'] {\n background-color: ${addedHoverBg};\n border-bottom: 2px solid ${addedHoverBorder};\n }\n\n &[data-inline-comment-state='authoring'] {\n background-color: ${authoringBg};\n border-bottom: 2px solid ${authoringBorder};\n }\n `\n})\n\ninterface CommentInlineHighlightSpanProps {\n children: React.ReactNode\n isAdded?: boolean\n isAuthoring?: boolean\n isHovered?: boolean\n isNested?: boolean\n}\n\n/**\n * @internal\n */\nexport const CommentInlineHighlightSpan = forwardRef(function CommentInlineHighlightSpan(\n props: CommentInlineHighlightSpanProps & React.HTMLProps<HTMLSpanElement>,\n ref: React.Ref<HTMLSpanElement>,\n) {\n const {children, isAdded, isAuthoring, isHovered, isNested, ...rest} = props\n\n const state = isAdded ? 'added' : isAuthoring ? 'authoring' : undefined\n\n return (\n <HighlightSpan\n {...rest}\n data-hovered={isHovered ? 'true' : 'false'}\n data-inline-comment-nested={isNested ? 'true' : 'false'}\n data-inline-comment-state={state}\n ref={ref}\n >\n {children}\n </HighlightSpan>\n )\n})\n","import {type RangeDecoration} from '@portabletext/editor'\nimport {\n applyPatches,\n cleanupEfficiency,\n type Diff,\n DIFF_DELETE,\n DIFF_EQUAL,\n DIFF_INSERT,\n makeDiff,\n makePatches,\n type Patch,\n} from '@sanity/diff-match-patch'\nimport {\n isPortableTextSpan,\n isPortableTextTextBlock,\n type Path,\n type PortableTextBlock,\n type PortableTextTextBlock,\n} from '@sanity/types'\nimport * as PathUtils from '@sanity/util/paths'\n\nimport {getValueAtPath} from '../../../field/paths/helpers'\nimport {isTextSelectionComment, parseCommentFieldPath} from '../../helpers'\nimport {type CommentDocument, type CommentsTextSelectionItem} from '../../types'\n\n// This must be set high to avoid false positives\n// (for example, when there are multiple occurrences of the same word, and you delete the original commented word)\n// Don't set it above 15, as it will cause performance issues\nconst DMP_MARGIN = 15\n\nfunction diffText(current: string, next: string) {\n const diff = makeDiff(current, next)\n const diffs = cleanupEfficiency(diff)\n const levenshtein = diffsLevenshtein(diffs)\n return {patches: makePatches(current, diffs, {margin: DMP_MARGIN}), levenshtein}\n}\n\nfunction diffApply(current: string, patches: Patch[]) {\n return applyPatches(patches, current, {\n allowExceedingIndices: true,\n margin: DMP_MARGIN,\n })[0]\n}\n\nconst CHILD_SYMBOL = '\\uF0D0'\nfunction toPlainTextWithChildSeparators(inputBlock: PortableTextTextBlock) {\n return inputBlock.children\n .map((child) => (isPortableTextSpan(child) ? child.text.replaceAll(CHILD_SYMBOL, ' ') : ''))\n .join(CHILD_SYMBOL)\n}\n\nexport const COMMENT_INDICATORS = ['\\uF000', '\\uF001']\nconst COMMENT_INDICATORS_REGEX = new RegExp(`[${COMMENT_INDICATORS.join('')}]`, 'g')\n\nconst EMPTY_ARRAY: [] = []\n\n/**\n * @internal\n */\nexport interface BuildCommentsRangeDecorationsProps {\n value: PortableTextBlock[] | undefined\n comments: CommentDocument[]\n /**\n * Document value the stored `field` paths resolve against. Falls back to a\n * top-level `value.find` on the editor slice when absent.\n */\n documentValue?: unknown\n /** The editor's own document path. */\n basePath?: Path\n}\n\n/**\n * @internal\n */\nexport interface BuildCommentsRangeDecorationsResultItem {\n selection: RangeDecoration['selection']\n comment: CommentDocument\n range: CommentsTextSelectionItem\n}\n\n/**\n * A function that builds range decoration selections from comments and their associated text.\n * @internal\n */\nexport function buildRangeDecorationSelectionsFromComments(\n props: BuildCommentsRangeDecorationsProps,\n): BuildCommentsRangeDecorationsResultItem[] {\n const {value, comments, documentValue, basePath} = props\n\n if (!value || value.length === 0) return EMPTY_ARRAY\n\n const textSelections = comments.filter(isTextSelectionComment)\n const decorators: BuildCommentsRangeDecorationsResultItem[] = []\n\n textSelections.forEach((comment) => {\n let relative: Path = []\n if (documentValue !== undefined && basePath) {\n const fieldPath = parseCommentFieldPath(comment.target.path?.field)\n if (!fieldPath) {\n // A comment without a parseable `field` cannot resolve to a block.\n return\n }\n if (!PathUtils.startsWith(basePath, fieldPath)) return\n relative = fieldPath.slice(basePath.length)\n }\n\n comment.target.path?.selection?.value.forEach((selectionMember) => {\n const matchedBlock =\n documentValue !== undefined && basePath\n ? (getValueAtPath(documentValue, [\n ...basePath,\n ...relative,\n {_key: selectionMember._key},\n ]) as PortableTextBlock | undefined)\n : value.find((block) => block._key === selectionMember._key)\n if (!matchedBlock || !isPortableTextTextBlock(matchedBlock)) {\n return\n }\n const selectionText = selectionMember.text.replaceAll(COMMENT_INDICATORS_REGEX, '')\n const textWithChildSeparators = toPlainTextWithChildSeparators(matchedBlock)\n const {patches} = diffText(selectionText, selectionMember.text)\n const diffedText = diffApply(textWithChildSeparators, patches)\n const startIndex = diffedText.indexOf(COMMENT_INDICATORS[0])\n const endIndex = diffedText\n .replaceAll(COMMENT_INDICATORS[0], '')\n .indexOf(COMMENT_INDICATORS[1])\n const textWithoutCommentTags = diffedText.replaceAll(COMMENT_INDICATORS_REGEX, '')\n const oldCommentedText = selectionMember.text.slice(\n selectionMember.text.indexOf(COMMENT_INDICATORS[0]) + 1,\n selectionMember.text.indexOf(COMMENT_INDICATORS[1]),\n )\n const newCommentedText = textWithoutCommentTags.slice(startIndex, endIndex)\n const {levenshtein} = diffText(newCommentedText, oldCommentedText)\n const threshold = Math.round(newCommentedText.length + oldCommentedText.length / 2)\n\n let nullSelection = false\n\n if (newCommentedText.length === 0) {\n nullSelection = true\n }\n\n if (levenshtein > threshold) {\n nullSelection = true\n }\n\n // If there no longer is any text within the range, we don't need to create a decoration\n if (startIndex + 1 === endIndex) {\n nullSelection = true\n }\n\n if (startIndex !== -1 && endIndex !== -1) {\n let childIndexAnchor = 0\n let anchorOffset = 0\n let childIndexFocus = 0\n let focusOffset = 0\n for (let i = 0; i < textWithoutCommentTags.length; i++) {\n if (textWithoutCommentTags[i] === CHILD_SYMBOL) {\n if (i <= startIndex) {\n anchorOffset = -1\n childIndexAnchor++\n }\n focusOffset = -1\n childIndexFocus++\n }\n if (i < startIndex) {\n anchorOffset++\n }\n if (i < startIndex + newCommentedText.length) {\n focusOffset++\n }\n if (i === startIndex + newCommentedText.length) {\n break\n }\n }\n\n decorators.push({\n selection: {\n anchor: {\n path: [\n ...relative,\n {_key: matchedBlock._key},\n 'children',\n {_key: matchedBlock.children[childIndexAnchor]._key},\n ],\n offset: anchorOffset,\n },\n focus: {\n path: [\n ...relative,\n {_key: matchedBlock._key},\n 'children',\n {_key: matchedBlock.children[childIndexFocus]._key},\n ],\n offset: focusOffset,\n },\n },\n comment,\n range: {_key: matchedBlock._key, text: nullSelection ? '' : diffedText},\n })\n }\n })\n })\n if (decorators.length === 0) return EMPTY_ARRAY\n return decorators\n}\n\ninterface ValidateTextSelectionCommentProps {\n comment: CommentDocument\n value: PortableTextBlock[]\n}\n\nfunction validateTextSelectionComment(props: ValidateTextSelectionCommentProps): boolean {\n const {comment, value} = props\n if (!isTextSelectionComment(comment)) return false\n\n const selections = buildRangeDecorationSelectionsFromComments({comments: [comment], value})\n\n return selections.length > 0\n}\n\nfunction diffsLevenshtein(diffs: Diff[]): number {\n let levenshtein = 0\n let insertions = 0\n let deletions = 0\n for (let x = 0; x < diffs.length; x++) {\n const op = diffs[x][0]\n const data = diffs[x][1]\n switch (op) {\n case DIFF_INSERT:\n insertions += data.length\n break\n case DIFF_DELETE:\n deletions += data.length\n break\n case DIFF_EQUAL:\n // A deletion and an insertion is one substitution.\n levenshtein += Math.max(insertions, deletions)\n insertions = 0\n deletions = 0\n break\n default:\n // Do nothing\n }\n }\n levenshtein += Math.max(insertions, deletions)\n return levenshtein\n}\n","import {type RangeDecoration, type RangeDecorationOnMovedDetails} from '@portabletext/editor'\nimport {type Path, type PortableTextBlock} from '@sanity/types'\nimport {memo, useCallback, useEffect, useRef, useState} from 'react'\n\nimport {CommentInlineHighlightSpan} from '../../components/pte/CommentInlineHighlightSpan'\nimport {applyInlineCommentIdAttr} from '../../hooks/useCommentsScroll'\nimport {type CommentDocument} from '../../types'\nimport {buildRangeDecorationSelectionsFromComments} from './buildRangeDecorationSelectionsFromComments'\n\ninterface CommentRangeDecorationProps {\n children: React.ReactNode\n commentId: string\n currentHoveredCommentId: string | null\n onClick: (commentId: string) => void\n onHoverEnd: (commentId: null) => void\n onHoverStart: (commentId: string) => void\n selectedThreadId: string | null\n threadId: string\n}\n\nconst CommentRangeDecoration = memo(function CommentRangeDecoration(\n props: CommentRangeDecorationProps,\n) {\n const {\n children,\n commentId,\n currentHoveredCommentId,\n onClick,\n onHoverEnd,\n onHoverStart,\n selectedThreadId,\n threadId,\n } = props\n const decoratorRef = useRef<HTMLSpanElement | null>(null)\n const [isNested, setIsNested] = useState(false)\n const [parentCommentId, setParentCommentId] = useState<string | null>(null)\n\n useEffect(() => {\n // Get the previous and next sibling of the decorator element\n const prevEl = decoratorRef.current?.previousSibling as HTMLElement | null\n const nextEl = decoratorRef.current?.nextSibling as HTMLElement | null\n\n // If there is no previous or next sibling, then the decorator is not nested\n if (!prevEl || !nextEl) {\n setIsNested(false)\n return\n }\n\n // We use the `applyInlineCommentIdAttr` to get the key of the data attribute\n // used for the inline comment id on the decorator element.\n const [key] = Object.keys(applyInlineCommentIdAttr(''))\n\n const prevId = prevEl.getAttribute(key)\n const nextId = nextEl.getAttribute(key)\n\n const isEqual = prevId === nextId\n\n const isNestedDecorator = Boolean(prevId && nextId && isEqual)\n setParentCommentId(isNestedDecorator ? prevId : null)\n\n setIsNested(isNestedDecorator)\n }, [])\n\n const handleMouseEnter = useCallback(() => onHoverStart(commentId), [commentId, onHoverStart])\n const handleMouseLeave = useCallback(() => onHoverEnd(null), [onHoverEnd])\n const handleClick = useCallback(() => onClick(commentId), [commentId, onClick])\n\n const hovered =\n currentHoveredCommentId === commentId ||\n (currentHoveredCommentId === parentCommentId && isNested)\n\n const selected = selectedThreadId === threadId\n\n return (\n <CommentInlineHighlightSpan\n isAdded\n isHovered={hovered || selected}\n isNested={isNested}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n ref={decoratorRef}\n {...applyInlineCommentIdAttr(threadId)}\n >\n {children}\n </CommentInlineHighlightSpan>\n )\n})\nCommentRangeDecoration.displayName = 'Memo(CommentRangeDecoration)'\n\ninterface BuildRangeDecorationsProps {\n comments: CommentDocument[]\n currentHoveredCommentId: string | null\n onDecorationClick: (commentId: string) => void\n onDecorationHoverEnd: (commentId: null) => void\n onDecorationHoverStart: (commentId: string) => void\n onDecorationMoved: (details: RangeDecorationOnMovedDetails) => void\n selectedThreadId: string | null\n value: PortableTextBlock[] | undefined\n documentValue?: unknown\n basePath?: Path\n}\n\n/**\n * @internal\n */\nexport function buildCommentRangeDecorations(props: BuildRangeDecorationsProps) {\n const {\n comments,\n currentHoveredCommentId,\n onDecorationClick,\n onDecorationHoverEnd,\n onDecorationHoverStart,\n onDecorationMoved,\n selectedThreadId,\n value,\n documentValue,\n basePath,\n } = props\n const rangeSelections = buildRangeDecorationSelectionsFromComments({\n comments,\n value,\n documentValue,\n basePath,\n })\n\n const decorations = rangeSelections.map(({selection, comment, range}) => {\n const decoration: RangeDecoration = {\n component: ({children}) => (\n <CommentRangeDecoration\n commentId={comment._id}\n currentHoveredCommentId={currentHoveredCommentId}\n onClick={onDecorationClick}\n onHoverEnd={onDecorationHoverEnd}\n onHoverStart={onDecorationHoverStart}\n selectedThreadId={selectedThreadId}\n threadId={comment.threadId}\n >\n {children}\n </CommentRangeDecoration>\n ),\n onMoved: onDecorationMoved,\n selection,\n payload: {\n commentId: comment._id,\n range,\n },\n }\n return decoration\n })\n return decorations\n}\n","import {type EditorSelection} from '@portabletext/editor'\nimport {toPlainText} from '@portabletext/react'\nimport {\n isPortableTextSpan,\n isPortableTextTextBlock,\n type Path,\n type PortableTextBlock,\n type PortableTextTextBlock,\n} from '@sanity/types'\nimport * as PathUtils from '@sanity/util/paths'\n\nimport {getValueAtPath} from '../../../field/paths/helpers'\nimport {type CommentTextSelection} from '../../types'\nimport {COMMENT_INDICATORS} from './buildRangeDecorationSelectionsFromComments'\n\ninterface BuildSelectionFromFragmentProps {\n fragment: PortableTextBlock[]\n documentValue: unknown\n basePath: Path\n selection: EditorSelection\n}\n\n/**\n * @internal\n */\nexport function buildTextSelectionFromFragment(\n props: BuildSelectionFromFragmentProps,\n): CommentTextSelection {\n const {fragment, documentValue, basePath, selection} = props\n if (!selection) {\n throw new Error('Selection is required')\n }\n const normalizedSelection: EditorSelection = selection.backward\n ? {backward: false, anchor: selection.focus, focus: selection.anchor}\n : selection\n\n const {block: anchorBlock, path: anchorBlockPath} =\n findEnclosingTextBlock(documentValue, basePath, normalizedSelection.anchor.path) ?? {}\n const {block: focusBlock, path: focusBlockPath} =\n findEnclosingTextBlock(documentValue, basePath, normalizedSelection.focus.path) ?? {}\n\n // A selection spanning three or more blocks has fragment blocks that are\n // neither the anchor nor the focus block. They live in the same containing\n // arrays, so resolve every fragment block by `_key` within those arrays.\n const containingArrays: Array<Array<unknown>> = []\n for (const blockPath of [anchorBlockPath, focusBlockPath]) {\n if (!blockPath) continue\n const containingArray = getValueAtPath(documentValue, [...basePath, ...blockPath.slice(0, -1)])\n if (Array.isArray(containingArray) && !containingArrays.includes(containingArray)) {\n containingArrays.push(containingArray)\n }\n }\n\n const textSelection: CommentTextSelection = {\n type: 'text',\n value: fragment.map((fragmentBlock) => {\n const originalBlock = findBlockByKey(containingArrays, fragmentBlock._key)\n if (!isPortableTextTextBlock(originalBlock)) {\n return {\n _key: fragmentBlock._key,\n text: '',\n }\n }\n const anchorBlockKey = anchorBlock?._key\n const focusBlockKey = focusBlock?._key\n const fragmentBlockText = toPlainText([fragmentBlock])\n const fragmentStartSpan = isPortableTextTextBlock(fragmentBlock)\n ? fragmentBlock.children[0]\n : undefined\n const fragmentEndSpan = isPortableTextTextBlock(fragmentBlock)\n ? fragmentBlock.children[fragmentBlock.children.length - 1]\n : undefined\n let originalTextBeforeSelection = ''\n let startChildIndex = -1\n if (anchorBlockKey === originalBlock._key) {\n for (const child of originalBlock.children) {\n startChildIndex++\n if (child._key === fragmentStartSpan?._key) {\n originalTextBeforeSelection +=\n (isPortableTextSpan(child) &&\n child.text.slice(0, Math.max(0, normalizedSelection.anchor.offset))) ||\n ''\n break\n }\n originalTextBeforeSelection += child.text\n }\n }\n let originalTextAfterSelection = ''\n if (focusBlockKey === originalBlock._key) {\n for (const child of originalBlock.children.slice(startChildIndex).reverse()) {\n if (child._key === fragmentEndSpan?._key) {\n originalTextAfterSelection =\n ((isPortableTextSpan(child) &&\n child.text.slice(normalizedSelection.focus.offset, child.text.length)) ||\n '') + originalTextAfterSelection\n break\n }\n originalTextAfterSelection = child.text + originalTextAfterSelection\n }\n }\n return {\n _key: originalBlock._key,\n text: `${originalTextBeforeSelection}${COMMENT_INDICATORS[0]}${fragmentBlockText}${COMMENT_INDICATORS[1]}${originalTextAfterSelection}`,\n }\n }),\n }\n\n return textSelection\n}\n\n/**\n * The data path to the block's containing array. Returns `undefined` if no\n * enclosing text block exists at the selection path.\n *\n * @internal\n */\nexport function getCommentFieldPath(\n documentValue: unknown,\n basePath: Path,\n selectionPath: Path,\n): string | undefined {\n const enclosingBlockPath = findEnclosingTextBlock(documentValue, basePath, selectionPath)?.path\n if (!enclosingBlockPath) return undefined\n return PathUtils.toString([...basePath, ...enclosingBlockPath.slice(0, -1)])\n}\n\n/**\n * Walk `path` up to root against the document value from `basePath`, returning\n * the deepest enclosing text block and the segments (relative to `basePath`)\n * that reach it. Selection paths from PTE are editor-relative.\n */\nfunction findEnclosingTextBlock(\n documentValue: unknown,\n basePath: Path,\n path: Path,\n): {block: PortableTextTextBlock; path: Path} | undefined {\n for (let end = path.length; end > 0; end--) {\n const relative = path.slice(0, end)\n const candidate = getValueAtPath(documentValue, [...basePath, ...relative])\n if (isPortableTextTextBlock(candidate)) {\n return {block: candidate, path: relative}\n }\n }\n return undefined\n}\n\nfunction findBlockByKey(\n arrays: Array<Array<unknown>>,\n key: string,\n): PortableTextTextBlock | undefined {\n for (const array of arrays) {\n for (const block of array) {\n if (isPortableTextTextBlock(block) && block._key === key) {\n return block\n }\n }\n }\n return undefined\n}\n"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,eACAC,UACAW,MACwD;CACxD,KAAK,IAAI0C,MAAM1C,KAAK6B,QAAQa,MAAM,GAAGA,OAAO;EAC1C,IAAMC,WAAW3C,KAAKS,MAAM,GAAGiC,GAAG,GAC5BE,YAAY7D,eAAeK,eAAe,CAAC,GAAGC,UAAU,GAAGsD,QAAQ,CAAC;EAC1E,IAAIjE,wBAAwBkE,SAAS,GACnC,OAAO;GAAC9C,OAAO8C;GAAW5C,MAAM2C;EAAQ;CAE5C;AAEF;AAEA,SAASxB,eACP0B,QACAC,KACmC;CACnC,KAAK,IAAMC,SAASF,QAClB,KAAK,IAAM/C,SAASiD,OAClB,IAAIrE,wBAAwBoB,KAAK,KAAKA,MAAMsB,SAAS0B,KACnD,OAAOhD;AAKf"}
1
+ {"version":3,"file":"buildTextSelectionFromFragment-Dj_WBTDa.js","names":["forwardRef","Ref","SVGProps","CommentDisabledIcon","Icon","props","ref","$","_c","t0","t1","Symbol","for","t2","hues","Theme","forwardRef","css","styled","COMMENTS_HIGHLIGHT_HUE_KEY","HighlightSpan","span","theme","isDark","sanity","v2","color","_dark","addedBg","hex","addedBorder","addedHoverBg","addedHoverBorder","addedNestedBg","addedNesterBorder","authoringBg","authoringBorder","CommentInlineHighlightSpanProps","children","React","ReactNode","isAdded","isAuthoring","isHovered","isNested","CommentInlineHighlightSpan","props","ref","$","_c","rest","state","undefined","t0","t1","t2","RangeDecoration","applyPatches","cleanupEfficiency","Diff","DIFF_DELETE","DIFF_EQUAL","DIFF_INSERT","makeDiff","makePatches","Patch","isPortableTextSpan","isPortableTextTextBlock","Path","PortableTextBlock","PortableTextTextBlock","PathUtils","getValueAtPath","isTextSelectionComment","parseCommentFieldPath","CommentDocument","CommentsTextSelectionItem","DMP_MARGIN","diffText","current","next","diff","diffs","levenshtein","diffsLevenshtein","patches","margin","diffApply","allowExceedingIndices","CHILD_SYMBOL","toPlainTextWithChildSeparators","inputBlock","children","map","child","text","replaceAll","join","COMMENT_INDICATORS","COMMENT_INDICATORS_REGEX","RegExp","EMPTY_ARRAY","BuildCommentsRangeDecorationsProps","value","comments","documentValue","basePath","BuildCommentsRangeDecorationsResultItem","selection","comment","range","buildRangeDecorationSelectionsFromComments","props","length","textSelections","filter","decorators","forEach","relative","undefined","fieldPath","target","path","field","startsWith","slice","selectionMember","matchedBlock","_key","find","block","selectionText","textWithChildSeparators","diffedText","startIndex","indexOf","endIndex","textWithoutCommentTags","oldCommentedText","newCommentedText","threshold","Math","round","nullSelection","childIndexAnchor","anchorOffset","childIndexFocus","focusOffset","i","push","anchor","offset","focus","ValidateTextSelectionCommentProps","validateTextSelectionComment","selections","insertions","deletions","x","op","data","max","RangeDecoration","RangeDecorationOnMovedDetails","Path","PortableTextBlock","memo","useCallback","useEffect","useRef","useState","CommentInlineHighlightSpan","applyInlineCommentIdAttr","CommentDocument","buildRangeDecorationSelectionsFromComments","CommentRangeDecorationProps","children","React","ReactNode","commentId","currentHoveredCommentId","onClick","onHoverEnd","onHoverStart","selectedThreadId","threadId","CommentRangeDecoration","props","$","_c","decoratorRef","isNested","setIsNested","parentCommentId","setParentCommentId","t0","t1","Symbol","for","prevEl","current","previousSibling","HTMLElement","nextEl","nextSibling","key","Object","keys","prevId","getAttribute","nextId","isEqual","isNestedDecorator","Boolean","t2","handleMouseEnter","t3","handleMouseLeave","t4","handleClick","hovered","selected","t5","t6","t7","displayName","BuildRangeDecorationsProps","comments","onDecorationClick","onDecorationHoverEnd","onDecorationHoverStart","onDecorationMoved","details","value","documentValue","basePath","buildCommentRangeDecorations","rangeSelections","decorations","map","selection","comment","range","decoration","component","_id","onMoved","payload","EditorSelection","toPlainText","isPortableTextSpan","isPortableTextTextBlock","Path","PortableTextBlock","PortableTextTextBlock","PathUtils","getValueAtPath","CommentTextSelection","COMMENT_INDICATORS","BuildSelectionFromFragmentProps","fragment","documentValue","basePath","selection","buildTextSelectionFromFragment","props","Error","normalizedSelection","backward","anchor","focus","block","anchorBlock","path","anchorBlockPath","findEnclosingTextBlock","focusBlock","focusBlockPath","containingArrays","Array","blockPath","containingArray","slice","isArray","includes","push","textSelection","type","value","map","fragmentBlock","originalBlock","findBlockByKey","_key","text","anchorBlockKey","focusBlockKey","fragmentBlockText","fragmentStartSpan","children","undefined","fragmentEndSpan","length","originalTextBeforeSelection","startChildIndex","child","Math","max","offset","originalTextAfterSelection","reverse","getCommentFieldPath","selectionPath","enclosingBlockPath","toString","end","relative","candidate","arrays","key","array"],"sources":["../src/core/comments/components/icons/CommentDisabledIcon.tsx","../src/core/comments/components/pte/CommentInlineHighlightSpan.tsx","../src/core/comments/utils/inline-comments/buildRangeDecorationSelectionsFromComments.ts","../src/core/comments/utils/inline-comments/buildCommentRangeDecorations.tsx","../src/core/comments/utils/inline-comments/buildTextSelectionFromFragment.ts"],"sourcesContent":["import {forwardRef, type Ref, type SVGProps} from 'react'\n\n/**\n * @internal\n */\nexport const CommentDisabledIcon = forwardRef(function Icon(\n props: SVGProps<SVGSVGElement>,\n ref: Ref<SVGSVGElement>,\n) {\n return (\n <svg\n data-sanity-icon=\"comment-disabled\"\n width=\"1em\"\n height=\"1em\"\n ref={ref}\n viewBox=\"0 0 25 25\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n {...props}\n >\n <path\n d=\"M5.92627 14.5381H7.92627V18.5381L11.9263 14.5381H15.9263C17.0308 14.5381 17.9263 13.6427 17.9263 12.5381V6.53809C17.9263 5.43352 17.0308 4.53809 15.9263 4.53809H5.92627C4.8217 4.53809 3.92627 5.43352 3.92627 6.53809V12.5381C3.92627 13.6427 4.8217 14.5381 5.92627 14.5381Z\"\n stroke=\"currentColor\"\n strokeWidth=\"1.2\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M2.77256 2.66835C2.54413 2.51319 2.23317 2.57259 2.07802 2.80103L1.40378 3.7937C1.32927 3.9034 1.30139 4.0382 1.32627 4.16845C1.35115 4.29871 1.42676 4.41374 1.53646 4.48825L19.5861 16.7479C19.8146 16.903 20.1255 16.8436 20.2807 16.6152L20.9549 15.6225C21.0294 15.5128 21.0573 15.378 21.0324 15.2478C21.0076 15.1175 20.9319 15.0025 20.8222 14.928L2.77256 2.66835Z\"\n fill=\"currentColor\"\n strokeLinejoin=\"round\"\n />\n </svg>\n )\n})\n","import {hues} from '@sanity/color'\nimport {type Theme} from '@sanity/ui'\nimport {forwardRef} from 'react'\nimport {css, styled} from 'styled-components'\n\nimport {COMMENTS_HIGHLIGHT_HUE_KEY} from '../../constants'\n\nconst HighlightSpan = styled.span(({theme}: {theme: Theme}) => {\n const isDark = theme.sanity.v2?.color._dark\n\n // Colors used when a comment is added\n const addedBg = hues[COMMENTS_HIGHLIGHT_HUE_KEY][isDark ? 800 : 100].hex\n const addedBorder = hues[COMMENTS_HIGHLIGHT_HUE_KEY][isDark ? 700 : 300].hex\n\n const addedHoverBg = hues[COMMENTS_HIGHLIGHT_HUE_KEY][isDark ? 700 : 200].hex\n const addedHoverBorder = hues[COMMENTS_HIGHLIGHT_HUE_KEY][isDark ? 600 : 400].hex\n\n // Colors used when a comment is added and it is a nested comment\n const addedNestedBg = hues[COMMENTS_HIGHLIGHT_HUE_KEY][isDark ? 700 : 200].hex\n const addedNesterBorder = hues[COMMENTS_HIGHLIGHT_HUE_KEY][isDark ? 600 : 400].hex\n\n // Colors used when a comment is being authored.\n // For now, we use the same colors as when a comment is added.\n const authoringBg = addedBg\n const authoringBorder = addedBorder\n\n return css`\n box-sizing: border-box;\n transition:\n background-color 100ms ease,\n border-color 100ms ease;\n\n // Make sure that child elements appropriately blend with the\n // background of the highlight span\n * {\n mix-blend-mode: ${isDark ? 'screen' : 'multiply'};\n }\n\n &[data-inline-comment-state='added'][data-inline-comment-nested='false'] {\n background-color: ${addedBg};\n border-bottom: 2px solid ${addedBorder};\n }\n\n &[data-inline-comment-state='added'][data-inline-comment-nested='true'] {\n background-color: ${addedNestedBg};\n border-bottom: 2px solid ${addedNesterBorder};\n }\n\n &[data-inline-comment-state='added'][data-inline-comment-nested='false'][data-hovered='true'] {\n background-color: ${addedHoverBg};\n border-bottom: 2px solid ${addedHoverBorder};\n }\n\n &[data-inline-comment-state='authoring'] {\n background-color: ${authoringBg};\n border-bottom: 2px solid ${authoringBorder};\n }\n `\n})\n\ninterface CommentInlineHighlightSpanProps {\n children: React.ReactNode\n isAdded?: boolean\n isAuthoring?: boolean\n isHovered?: boolean\n isNested?: boolean\n}\n\n/**\n * @internal\n */\nexport const CommentInlineHighlightSpan = forwardRef(function CommentInlineHighlightSpan(\n props: CommentInlineHighlightSpanProps & React.HTMLProps<HTMLSpanElement>,\n ref: React.Ref<HTMLSpanElement>,\n) {\n const {children, isAdded, isAuthoring, isHovered, isNested, ...rest} = props\n\n const state = isAdded ? 'added' : isAuthoring ? 'authoring' : undefined\n\n return (\n <HighlightSpan\n {...rest}\n data-hovered={isHovered ? 'true' : 'false'}\n data-inline-comment-nested={isNested ? 'true' : 'false'}\n data-inline-comment-state={state}\n ref={ref}\n >\n {children}\n </HighlightSpan>\n )\n})\n","import {type RangeDecoration} from '@portabletext/editor'\nimport {\n applyPatches,\n cleanupEfficiency,\n type Diff,\n DIFF_DELETE,\n DIFF_EQUAL,\n DIFF_INSERT,\n makeDiff,\n makePatches,\n type Patch,\n} from '@sanity/diff-match-patch'\nimport {\n isPortableTextSpan,\n isPortableTextTextBlock,\n type Path,\n type PortableTextBlock,\n type PortableTextTextBlock,\n} from '@sanity/types'\nimport * as PathUtils from '@sanity/util/paths'\n\nimport {getValueAtPath} from '../../../field/paths/helpers'\nimport {isTextSelectionComment, parseCommentFieldPath} from '../../helpers'\nimport {type CommentDocument, type CommentsTextSelectionItem} from '../../types'\n\n// This must be set high to avoid false positives\n// (for example, when there are multiple occurrences of the same word, and you delete the original commented word)\n// Don't set it above 15, as it will cause performance issues\nconst DMP_MARGIN = 15\n\nfunction diffText(current: string, next: string) {\n const diff = makeDiff(current, next)\n const diffs = cleanupEfficiency(diff)\n const levenshtein = diffsLevenshtein(diffs)\n return {patches: makePatches(current, diffs, {margin: DMP_MARGIN}), levenshtein}\n}\n\nfunction diffApply(current: string, patches: Patch[]) {\n return applyPatches(patches, current, {\n allowExceedingIndices: true,\n margin: DMP_MARGIN,\n })[0]\n}\n\nconst CHILD_SYMBOL = '\\uF0D0'\nfunction toPlainTextWithChildSeparators(inputBlock: PortableTextTextBlock) {\n return inputBlock.children\n .map((child) => (isPortableTextSpan(child) ? child.text.replaceAll(CHILD_SYMBOL, ' ') : ''))\n .join(CHILD_SYMBOL)\n}\n\nexport const COMMENT_INDICATORS = ['\\uF000', '\\uF001']\nconst COMMENT_INDICATORS_REGEX = new RegExp(`[${COMMENT_INDICATORS.join('')}]`, 'g')\n\nconst EMPTY_ARRAY: [] = []\n\n/**\n * @internal\n */\nexport interface BuildCommentsRangeDecorationsProps {\n value: PortableTextBlock[] | undefined\n comments: CommentDocument[]\n /**\n * Document value the stored `field` paths resolve against. Falls back to a\n * top-level `value.find` on the editor slice when absent.\n */\n documentValue?: unknown\n /** The editor's own document path. */\n basePath?: Path\n}\n\n/**\n * @internal\n */\nexport interface BuildCommentsRangeDecorationsResultItem {\n selection: RangeDecoration['selection']\n comment: CommentDocument\n range: CommentsTextSelectionItem\n}\n\n/**\n * A function that builds range decoration selections from comments and their associated text.\n * @internal\n */\nexport function buildRangeDecorationSelectionsFromComments(\n props: BuildCommentsRangeDecorationsProps,\n): BuildCommentsRangeDecorationsResultItem[] {\n const {value, comments, documentValue, basePath} = props\n\n if (!value || value.length === 0) return EMPTY_ARRAY\n\n const textSelections = comments.filter(isTextSelectionComment)\n const decorators: BuildCommentsRangeDecorationsResultItem[] = []\n\n textSelections.forEach((comment) => {\n let relative: Path = []\n if (documentValue !== undefined && basePath) {\n const fieldPath = parseCommentFieldPath(comment.target.path?.field)\n if (!fieldPath) {\n // A comment without a parseable `field` cannot resolve to a block.\n return\n }\n if (!PathUtils.startsWith(basePath, fieldPath)) return\n relative = fieldPath.slice(basePath.length)\n }\n\n comment.target.path?.selection?.value.forEach((selectionMember) => {\n const matchedBlock =\n documentValue !== undefined && basePath\n ? (getValueAtPath(documentValue, [\n ...basePath,\n ...relative,\n {_key: selectionMember._key},\n ]) as PortableTextBlock | undefined)\n : value.find((block) => block._key === selectionMember._key)\n if (!matchedBlock || !isPortableTextTextBlock(matchedBlock)) {\n return\n }\n const selectionText = selectionMember.text.replaceAll(COMMENT_INDICATORS_REGEX, '')\n const textWithChildSeparators = toPlainTextWithChildSeparators(matchedBlock)\n const {patches} = diffText(selectionText, selectionMember.text)\n const diffedText = diffApply(textWithChildSeparators, patches)\n const startIndex = diffedText.indexOf(COMMENT_INDICATORS[0])\n const endIndex = diffedText\n .replaceAll(COMMENT_INDICATORS[0], '')\n .indexOf(COMMENT_INDICATORS[1])\n const textWithoutCommentTags = diffedText.replaceAll(COMMENT_INDICATORS_REGEX, '')\n const oldCommentedText = selectionMember.text.slice(\n selectionMember.text.indexOf(COMMENT_INDICATORS[0]) + 1,\n selectionMember.text.indexOf(COMMENT_INDICATORS[1]),\n )\n const newCommentedText = textWithoutCommentTags.slice(startIndex, endIndex)\n const {levenshtein} = diffText(newCommentedText, oldCommentedText)\n const threshold = Math.round(newCommentedText.length + oldCommentedText.length / 2)\n\n let nullSelection = false\n\n if (newCommentedText.length === 0) {\n nullSelection = true\n }\n\n if (levenshtein > threshold) {\n nullSelection = true\n }\n\n // If there no longer is any text within the range, we don't need to create a decoration\n if (startIndex + 1 === endIndex) {\n nullSelection = true\n }\n\n if (startIndex !== -1 && endIndex !== -1) {\n let childIndexAnchor = 0\n let anchorOffset = 0\n let childIndexFocus = 0\n let focusOffset = 0\n for (let i = 0; i < textWithoutCommentTags.length; i++) {\n if (textWithoutCommentTags[i] === CHILD_SYMBOL) {\n if (i <= startIndex) {\n anchorOffset = -1\n childIndexAnchor++\n }\n focusOffset = -1\n childIndexFocus++\n }\n if (i < startIndex) {\n anchorOffset++\n }\n if (i < startIndex + newCommentedText.length) {\n focusOffset++\n }\n if (i === startIndex + newCommentedText.length) {\n break\n }\n }\n\n decorators.push({\n selection: {\n anchor: {\n path: [\n ...relative,\n {_key: matchedBlock._key},\n 'children',\n {_key: matchedBlock.children[childIndexAnchor]._key},\n ],\n offset: anchorOffset,\n },\n focus: {\n path: [\n ...relative,\n {_key: matchedBlock._key},\n 'children',\n {_key: matchedBlock.children[childIndexFocus]._key},\n ],\n offset: focusOffset,\n },\n },\n comment,\n range: {_key: matchedBlock._key, text: nullSelection ? '' : diffedText},\n })\n }\n })\n })\n if (decorators.length === 0) return EMPTY_ARRAY\n return decorators\n}\n\ninterface ValidateTextSelectionCommentProps {\n comment: CommentDocument\n value: PortableTextBlock[]\n}\n\nfunction validateTextSelectionComment(props: ValidateTextSelectionCommentProps): boolean {\n const {comment, value} = props\n if (!isTextSelectionComment(comment)) return false\n\n const selections = buildRangeDecorationSelectionsFromComments({comments: [comment], value})\n\n return selections.length > 0\n}\n\nfunction diffsLevenshtein(diffs: Diff[]): number {\n let levenshtein = 0\n let insertions = 0\n let deletions = 0\n for (let x = 0; x < diffs.length; x++) {\n const op = diffs[x][0]\n const data = diffs[x][1]\n switch (op) {\n case DIFF_INSERT:\n insertions += data.length\n break\n case DIFF_DELETE:\n deletions += data.length\n break\n case DIFF_EQUAL:\n // A deletion and an insertion is one substitution.\n levenshtein += Math.max(insertions, deletions)\n insertions = 0\n deletions = 0\n break\n default:\n // Do nothing\n }\n }\n levenshtein += Math.max(insertions, deletions)\n return levenshtein\n}\n","import {type RangeDecoration, type RangeDecorationOnMovedDetails} from '@portabletext/editor'\nimport {type Path, type PortableTextBlock} from '@sanity/types'\nimport {memo, useCallback, useEffect, useRef, useState} from 'react'\n\nimport {CommentInlineHighlightSpan} from '../../components/pte/CommentInlineHighlightSpan'\nimport {applyInlineCommentIdAttr} from '../../hooks/useCommentsScroll'\nimport {type CommentDocument} from '../../types'\nimport {buildRangeDecorationSelectionsFromComments} from './buildRangeDecorationSelectionsFromComments'\n\ninterface CommentRangeDecorationProps {\n children: React.ReactNode\n commentId: string\n currentHoveredCommentId: string | null\n onClick: (commentId: string) => void\n onHoverEnd: (commentId: null) => void\n onHoverStart: (commentId: string) => void\n selectedThreadId: string | null\n threadId: string\n}\n\nconst CommentRangeDecoration = memo(function CommentRangeDecoration(\n props: CommentRangeDecorationProps,\n) {\n const {\n children,\n commentId,\n currentHoveredCommentId,\n onClick,\n onHoverEnd,\n onHoverStart,\n selectedThreadId,\n threadId,\n } = props\n const decoratorRef = useRef<HTMLSpanElement | null>(null)\n const [isNested, setIsNested] = useState(false)\n const [parentCommentId, setParentCommentId] = useState<string | null>(null)\n\n useEffect(() => {\n // Get the previous and next sibling of the decorator element\n const prevEl = decoratorRef.current?.previousSibling as HTMLElement | null\n const nextEl = decoratorRef.current?.nextSibling as HTMLElement | null\n\n // If there is no previous or next sibling, then the decorator is not nested\n if (!prevEl || !nextEl) {\n setIsNested(false)\n return\n }\n\n // We use the `applyInlineCommentIdAttr` to get the key of the data attribute\n // used for the inline comment id on the decorator element.\n const [key] = Object.keys(applyInlineCommentIdAttr(''))\n\n const prevId = prevEl.getAttribute(key)\n const nextId = nextEl.getAttribute(key)\n\n const isEqual = prevId === nextId\n\n const isNestedDecorator = Boolean(prevId && nextId && isEqual)\n setParentCommentId(isNestedDecorator ? prevId : null)\n\n setIsNested(isNestedDecorator)\n }, [])\n\n const handleMouseEnter = useCallback(() => onHoverStart(commentId), [commentId, onHoverStart])\n const handleMouseLeave = useCallback(() => onHoverEnd(null), [onHoverEnd])\n const handleClick = useCallback(() => onClick(commentId), [commentId, onClick])\n\n const hovered =\n currentHoveredCommentId === commentId ||\n (currentHoveredCommentId === parentCommentId && isNested)\n\n const selected = selectedThreadId === threadId\n\n return (\n <CommentInlineHighlightSpan\n isAdded\n isHovered={hovered || selected}\n isNested={isNested}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n ref={decoratorRef}\n {...applyInlineCommentIdAttr(threadId)}\n >\n {children}\n </CommentInlineHighlightSpan>\n )\n})\nCommentRangeDecoration.displayName = 'Memo(CommentRangeDecoration)'\n\ninterface BuildRangeDecorationsProps {\n comments: CommentDocument[]\n currentHoveredCommentId: string | null\n onDecorationClick: (commentId: string) => void\n onDecorationHoverEnd: (commentId: null) => void\n onDecorationHoverStart: (commentId: string) => void\n onDecorationMoved: (details: RangeDecorationOnMovedDetails) => void\n selectedThreadId: string | null\n value: PortableTextBlock[] | undefined\n documentValue?: unknown\n basePath?: Path\n}\n\n/**\n * @internal\n */\nexport function buildCommentRangeDecorations(props: BuildRangeDecorationsProps) {\n const {\n comments,\n currentHoveredCommentId,\n onDecorationClick,\n onDecorationHoverEnd,\n onDecorationHoverStart,\n onDecorationMoved,\n selectedThreadId,\n value,\n documentValue,\n basePath,\n } = props\n const rangeSelections = buildRangeDecorationSelectionsFromComments({\n comments,\n value,\n documentValue,\n basePath,\n })\n\n const decorations = rangeSelections.map(({selection, comment, range}) => {\n const decoration: RangeDecoration = {\n component: ({children}) => (\n <CommentRangeDecoration\n commentId={comment._id}\n currentHoveredCommentId={currentHoveredCommentId}\n onClick={onDecorationClick}\n onHoverEnd={onDecorationHoverEnd}\n onHoverStart={onDecorationHoverStart}\n selectedThreadId={selectedThreadId}\n threadId={comment.threadId}\n >\n {children}\n </CommentRangeDecoration>\n ),\n onMoved: onDecorationMoved,\n selection,\n payload: {\n commentId: comment._id,\n range,\n },\n }\n return decoration\n })\n return decorations\n}\n","import {type EditorSelection} from '@portabletext/editor'\nimport {toPlainText} from '@portabletext/react'\nimport {\n isPortableTextSpan,\n isPortableTextTextBlock,\n type Path,\n type PortableTextBlock,\n type PortableTextTextBlock,\n} from '@sanity/types'\nimport * as PathUtils from '@sanity/util/paths'\n\nimport {getValueAtPath} from '../../../field/paths/helpers'\nimport {type CommentTextSelection} from '../../types'\nimport {COMMENT_INDICATORS} from './buildRangeDecorationSelectionsFromComments'\n\ninterface BuildSelectionFromFragmentProps {\n fragment: PortableTextBlock[]\n documentValue: unknown\n basePath: Path\n selection: EditorSelection\n}\n\n/**\n * @internal\n */\nexport function buildTextSelectionFromFragment(\n props: BuildSelectionFromFragmentProps,\n): CommentTextSelection {\n const {fragment, documentValue, basePath, selection} = props\n if (!selection) {\n throw new Error('Selection is required')\n }\n const normalizedSelection: EditorSelection = selection.backward\n ? {backward: false, anchor: selection.focus, focus: selection.anchor}\n : selection\n\n const {block: anchorBlock, path: anchorBlockPath} =\n findEnclosingTextBlock(documentValue, basePath, normalizedSelection.anchor.path) ?? {}\n const {block: focusBlock, path: focusBlockPath} =\n findEnclosingTextBlock(documentValue, basePath, normalizedSelection.focus.path) ?? {}\n\n // A selection spanning three or more blocks has fragment blocks that are\n // neither the anchor nor the focus block. They live in the same containing\n // arrays, so resolve every fragment block by `_key` within those arrays.\n const containingArrays: Array<Array<unknown>> = []\n for (const blockPath of [anchorBlockPath, focusBlockPath]) {\n if (!blockPath) continue\n const containingArray = getValueAtPath(documentValue, [...basePath, ...blockPath.slice(0, -1)])\n if (Array.isArray(containingArray) && !containingArrays.includes(containingArray)) {\n containingArrays.push(containingArray)\n }\n }\n\n const textSelection: CommentTextSelection = {\n type: 'text',\n value: fragment.map((fragmentBlock) => {\n const originalBlock = findBlockByKey(containingArrays, fragmentBlock._key)\n if (!isPortableTextTextBlock(originalBlock)) {\n return {\n _key: fragmentBlock._key,\n text: '',\n }\n }\n const anchorBlockKey = anchorBlock?._key\n const focusBlockKey = focusBlock?._key\n const fragmentBlockText = toPlainText([fragmentBlock])\n const fragmentStartSpan = isPortableTextTextBlock(fragmentBlock)\n ? fragmentBlock.children[0]\n : undefined\n const fragmentEndSpan = isPortableTextTextBlock(fragmentBlock)\n ? fragmentBlock.children[fragmentBlock.children.length - 1]\n : undefined\n let originalTextBeforeSelection = ''\n let startChildIndex = -1\n if (anchorBlockKey === originalBlock._key) {\n for (const child of originalBlock.children) {\n startChildIndex++\n if (child._key === fragmentStartSpan?._key) {\n originalTextBeforeSelection +=\n (isPortableTextSpan(child) &&\n child.text.slice(0, Math.max(0, normalizedSelection.anchor.offset))) ||\n ''\n break\n }\n originalTextBeforeSelection += child.text\n }\n }\n let originalTextAfterSelection = ''\n if (focusBlockKey === originalBlock._key) {\n for (const child of originalBlock.children.slice(startChildIndex).reverse()) {\n if (child._key === fragmentEndSpan?._key) {\n originalTextAfterSelection =\n ((isPortableTextSpan(child) &&\n child.text.slice(normalizedSelection.focus.offset, child.text.length)) ||\n '') + originalTextAfterSelection\n break\n }\n originalTextAfterSelection = child.text + originalTextAfterSelection\n }\n }\n return {\n _key: originalBlock._key,\n text: `${originalTextBeforeSelection}${COMMENT_INDICATORS[0]}${fragmentBlockText}${COMMENT_INDICATORS[1]}${originalTextAfterSelection}`,\n }\n }),\n }\n\n return textSelection\n}\n\n/**\n * The data path to the block's containing array. Returns `undefined` if no\n * enclosing text block exists at the selection path.\n *\n * @internal\n */\nexport function getCommentFieldPath(\n documentValue: unknown,\n basePath: Path,\n selectionPath: Path,\n): string | undefined {\n const enclosingBlockPath = findEnclosingTextBlock(documentValue, basePath, selectionPath)?.path\n if (!enclosingBlockPath) return undefined\n return PathUtils.toString([...basePath, ...enclosingBlockPath.slice(0, -1)])\n}\n\n/**\n * Walk `path` up to root against the document value from `basePath`, returning\n * the deepest enclosing text block and the segments (relative to `basePath`)\n * that reach it. Selection paths from PTE are editor-relative.\n */\nfunction findEnclosingTextBlock(\n documentValue: unknown,\n basePath: Path,\n path: Path,\n): {block: PortableTextTextBlock; path: Path} | undefined {\n for (let end = path.length; end > 0; end--) {\n const relative = path.slice(0, end)\n const candidate = getValueAtPath(documentValue, [...basePath, ...relative])\n if (isPortableTextTextBlock(candidate)) {\n return {block: candidate, path: relative}\n }\n }\n return undefined\n}\n\nfunction findBlockByKey(\n arrays: Array<Array<unknown>>,\n key: string,\n): PortableTextTextBlock | undefined {\n for (const array of arrays) {\n for (const block of array) {\n if (isPortableTextTextBlock(block) && block._key === key) {\n return block\n }\n }\n }\n return undefined\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,MAAaG,sBAAsBH,WAAW,SAAAI,KAAAC,OA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GAAGA,OAAO;EAC1C,IAAMC,WAAW3C,KAAKS,MAAM,GAAGiC,GAAG,GAC5BE,YAAY7D,eAAeK,eAAe,CAAC,GAAGC,UAAU,GAAGsD,QAAQ,CAAC;EAC1E,IAAIjE,wBAAwBkE,SAAS,GACnC,OAAO;GAAC9C,OAAO8C;GAAW5C,MAAM2C;EAAQ;CAE5C;AAEF;AAEA,SAASxB,eACP0B,QACAC,KACmC;CACnC,KAAK,IAAMC,SAASF,QAClB,KAAK,IAAM/C,SAASiD,OAClB,IAAIrE,wBAAwBoB,KAAK,KAAKA,MAAMsB,SAAS0B,KACnD,OAAOhD;AAKf"}
@@ -1,5 +1,5 @@
1
1
  import { S as isNonNullable$1, c as getIdPair, d as getVersionId, f as idMatchesPerspective, l as getPublishedId$1, m as isDraftId$1, o as documentIdEquals, s as getDraftId, u as getVersionFromId$1, v as isVersionId$1 } from "./draftUtils-C1C4OKjo.js";
2
- import { c as useWorkspace, i as useClient, n as DEFAULT_STUDIO_CLIENT_OPTIONS, o as useSource, r as versionedClient, t as DEFAULT_STUDIO_CLIENT_HEADERS } from "./studioClient-DvoDxN44.js";
2
+ import { c as useWorkspace, i as useClient, n as DEFAULT_STUDIO_CLIENT_OPTIONS, o as useSource, r as versionedClient, t as DEFAULT_STUDIO_CLIENT_HEADERS } from "./studioClient-DqAy4dnu.js";
3
3
  import { t as useTranslation } from "./useTranslation-Cqs6Itwv.js";
4
4
  import { i as isStaticResourceBundle, r as defineLocalesResources, t as defineLocale } from "./helpers-ClQf2qOB.js";
5
5
  import { useContext, useMemo, useState } from "react";
@@ -3801,6 +3801,16 @@ const studioLocaleNamespace = "studio", feedbackLocaleNamespace = "feedback", co
3801
3801
  /** --- Document group --- */
3802
3802
  /** The label given to a document group's base variant */
3803
3803
  "document-group.base-variant": "All users (Default)",
3804
+ /** The header label for the variant creation flow before a variant definition has been selected */
3805
+ "document-group.create-variant": "Create variant",
3806
+ /** The header label for the variant creation flow once a variant definition has been selected */
3807
+ "document-group.create-variant.for-target": "Create variant for {{variantDefinitionName}}",
3808
+ /** The heading for the option to create a variant as a draft */
3809
+ "document-group.create-variant.target-drafts": "As a draft",
3810
+ /** The label for the list of releases a variant can be created in */
3811
+ "document-group.create-variant.target-releases": "Into a release",
3812
+ /** The label for the list of existing variants that can be viewed instead of creating a new one */
3813
+ "document-group.create-variant.view-existing-variants": "Or view existing variants",
3804
3814
  /** The text in the "Cancel" button in the confirm delete dialog that cancels the action */
3805
3815
  "document-group.delete.cancel-button.text": "Cancel",
3806
3816
  /** Used in `document-group.delete.cdr-summary.title` */
@@ -8063,4 +8073,4 @@ function useComlinkStore() {
8063
8073
  }
8064
8074
  export { feedbackLocaleNamespace as $, fieldNeedsEscape as $t, wrapValue as A, checkoutPair as At, RESOLVE_INITIAL_VALUE_TIMEOUT_MS as B, createRequestErrorChannel as Bt, createKeyValueStore as C, VARIANTS_STUDIO_CLIENT_OPTIONS as Ct, TimelineController as D, memoizedPair as Dt, removeMissingReferences as E, snapshotPair as Et, createDocumentStore as F, CONNECTING as Ft, validateTemplates as G, isNetworkError as Gt, resolveInitialObjectValue as H, classifyConfigError as Ht, normalizeDocumentPairTarget as I, createConnectionStatusStore as It, validateDocumentWithReferences as J, getApiErrorCode as Jt, postTask as K, isTimeoutError as Kt, listenQuery as L, onRetry as Lt, isProd as M, createBufferedDocument as Mt, createGrantsStore as N, createObservableBufferedDocument as Nt, getJsonStream as O, memoizeKeyGen as Ot, grantsPermissionOn as P, getDocumentVariantType as Pt, usEnglishLocale as Q, escapeField as Qt, getInitialValueStream as R, catchWithCount as Rt, createPresenceStore as S, isReleaseBundle as St, createHistoryStore as T, VARIANT_DOCUMENT_TYPE as Tt, resolveInitialValue as U, classifyRequestError as Ut, isBuilder as V, passthroughErrorHandler as Vt, resolveInitialValueForType as W, isClientRequestError as Wt, validateItem as X, isUnauthorizedError as Xt, validateDocument as Y, isInvalidSessionError as Yt, defaultLocale as Z, createDocumentPreviewStore as Zt, useResourceCache as _, getVariantDescription as _t, useGrantsStore as a, createPathObserver as an, editState as at, getProjectGrants as b, getVariantTitle as bt, usePresenceStore as c, createSWR as cn, getReleaseIdFromReleaseDocumentId as ct, useUserStore as d, useSchema as dn, emitOperation as dt, joinPath as en, studioLocaleNamespace as et, createUserStore as f, operationEvents as ft, ResourceCacheProvider as g, getVariantConditionsText as gt, createHookFromObservableFactory as h, filterVariantsForSearch as ht, useDocumentStore as i, getPreviewPaths as in, pathToString as it, isDev as j, getPairListener as jt, Timeline as k, memoize$1 as kt, useProjectStore as l, isRecord$4 as ln, RELEASE_DOCUMENTS_PATH as lt, useUser as m, decodeVariantIdFromRoute as mt, useConnectionStatusStore as n, isReleasePerspective as nn, inferFromSchema as nt, useHistoryStore as o, applyMendozaPatch as on, measureFirstEmission as ot, useCurrentUser as p, variantsClient as pt, validation as q, parseRetryAfter as qt, useDocumentPreviewStore as r, prepareForPreview as rn, Rule$1 as rt, useKeyValueStore as s, DOCUMENT_SYSTEM_FIELD as sn, measureFirstMatch as st, useComlinkStore as t, RELEASES_STUDIO_CLIENT_OPTIONS as tn, resolveConditionalProperty as tt, useRenderingContextStore as u, useTemplates as un, RELEASE_DOCUMENT_TYPE as ut, createMultiKeyWeakMap as v, getVariantId as vt, supportsLocalStorage as w, VARIANT_DOCUMENTS_PATH as wt, SESSION_ID as x, isPublishedBundleId as xt, createProjectStore as y, getVariantIdFromDocument as yt, DEFAULT_MAX_RECURSION_DEPTH as z, useStudioErrorHandler as zt };
8065
8075
 
8066
- //# sourceMappingURL=datastores-CFWEadl-.js.map
8076
+ //# sourceMappingURL=datastores-CrRYBoDP.js.map