@templatical/editor 0.53.0 → 0.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/dist/{AiChatPanel-DdhtfsmO.js → AiChatPanel-C8SeEJRP.js} +8 -8
  2. package/dist/{AiPanels-HBx7xoJR.js → AiPanels-CR6zphjP.js} +1 -1
  3. package/dist/{AiRewriteMenu-DPzSekZt.js → AiRewriteMenu-CIHUnPud.js} +6 -6
  4. package/dist/{BlockIssueBadge-eIXZJ9M3.js → BlockIssueBadge-DaPTq1RE.js} +2 -2
  5. package/dist/{BlockPreviewCanvas-DO-2TP_6.js → BlockPreviewCanvas-B70RSavL.js} +3 -3
  6. package/dist/{CloudPanels-i2kZdrdP.js → CloudPanels-VpSQiLLL.js} +3 -3
  7. package/dist/{CollaborationNotices-DANsjl7c.js → CollaborationNotices-Cnx0XHzZ.js} +1 -1
  8. package/dist/{CollaboratorBar-CbbAA0m1.js → CollaboratorBar-BaBoNhwB.js} +1 -1
  9. package/dist/{CommentsPanel-CYW3LWis.js → CommentsPanel-Ck3QmqiC.js} +1 -1
  10. package/dist/{CommentsSidebar-CcF4ISMi.js → CommentsSidebar-CHknhOar.js} +10 -10
  11. package/dist/{CountdownToolbar-D3Lv74kU.js → CountdownToolbar-CM4XNEuO.js} +3 -3
  12. package/dist/{IssuesPanel-BMAG9042.js → IssuesPanel-1wGV0wiy.js} +8 -8
  13. package/dist/{LanguageMenu-FlP_Jbup.js → LanguageMenu-d2GlX67r.js} +8 -8
  14. package/dist/{LocaleNotices-DAnVszWu.js → LocaleNotices-WzsYtBRs.js} +2 -2
  15. package/dist/{LogicTagInsertButton-BjYs-UQX.js → LogicTagInsertButton-DgTJ6Lvx.js} +3 -3
  16. package/dist/{MediaEditModal-LnG-cF_S.js → MediaEditModal-C3U9Mi31.js} +1 -1
  17. package/dist/{MediaPanels-C2r5fiFo.js → MediaPanels-CGmk9ufe.js} +1 -1
  18. package/dist/{MergeTagInput-BsnogCeY.js → MergeTagInput-B_51YcQO.js} +1 -1
  19. package/dist/{MergeTagModeToggle-DiufIQ-_.js → MergeTagModeToggle-D3Q2z317.js} +3 -3
  20. package/dist/{MergeTagTextarea-BweI-Xsi.js → MergeTagTextarea-DZz1L9DE.js} +2 -2
  21. package/dist/{ParagraphEditor-qgBp5yIB.js → ParagraphEditor-CI68PYDL.js} +12 -12
  22. package/dist/{RestoreVersionDialog-DdYUrFiK.js → RestoreVersionDialog-DcuhpOIz.js} +3 -3
  23. package/dist/{RichTextEditorContent-C5MAzx3E.js → RichTextEditorContent-Dstovi0m.js} +4 -4
  24. package/dist/{SaveBlockDialog-eK6fjtTy.js → SaveBlockDialog-vuwvoi-d.js} +7 -7
  25. package/dist/{SavedBlocksBrowserModal-D2QHd2Yp.js → SavedBlocksBrowserModal-DUJm0dOv.js} +9 -9
  26. package/dist/{SavedBlocksPanels-Cl61f4Mf.js → SavedBlocksPanels-BiMXQ5lY.js} +1 -1
  27. package/dist/{SavedBlocksPickBar-CXP2dkeB.js → SavedBlocksPickBar-CAstZfG7.js} +2 -2
  28. package/dist/{TemplateSettings-BKJrdZcH.js → TemplateSettings-Baar78_s.js} +6 -6
  29. package/dist/{TestEmailModal-DQotJg6g.js → TestEmailModal-Bl_GHdrN.js} +6 -6
  30. package/dist/{TestEmailPanel-CwiTzJsh.js → TestEmailPanel-CpTBF7B5.js} +1 -1
  31. package/dist/{TitleEditor-CzSvsPAn.js → TitleEditor-DkbEDAZB.js} +6 -6
  32. package/dist/{Toolbar-Cd75ci5W.js → Toolbar-bOZ_eq7X.js} +27 -27
  33. package/dist/{TplModal-ZoXu40T9.js → TplModal-wk2gLa7_.js} +1 -1
  34. package/dist/{VersionHistoryMenu-BvhN-Ofk.js → VersionHistoryMenu-BnP0EyLl.js} +5 -5
  35. package/dist/{VersionHistoryPanels-DPWMnYbd.js → VersionHistoryPanels-Cq2rFKIX.js} +1 -1
  36. package/dist/{VersionPreviewBanner-CuJnasxH.js → VersionPreviewBanner-BPP939cD.js} +1 -1
  37. package/dist/{WrapperBlock-D4fPwO0t.js → WrapperBlock-cWT_nZgQ.js} +2 -2
  38. package/dist/{blockTypeIcons-BXMxu86H.js → blockTypeIcons-BUyPZ7Su.js} +3 -3
  39. package/dist/bundle-stats.json +4 -4
  40. package/dist/cdn/chunks/{AiAltTextPopover-ByZ0FEqI.js → AiAltTextPopover-Cnc_kUmb.js} +2 -2
  41. package/dist/cdn/chunks/{AiAltTextPopover-ByZ0FEqI.js.map → AiAltTextPopover-Cnc_kUmb.js.map} +1 -1
  42. package/dist/cdn/chunks/{AiAltTextReview-Dtm3A2cD.js → AiAltTextReview-DPeSY-7r.js} +2 -2
  43. package/dist/cdn/chunks/{AiAltTextReview-Dtm3A2cD.js.map → AiAltTextReview-DPeSY-7r.js.map} +1 -1
  44. package/dist/cdn/chunks/{AiChatPanel-DciEt27y.js → AiChatPanel-By8Uo1nH.js} +2 -2
  45. package/dist/cdn/chunks/{AiChatPanel-DciEt27y.js.map → AiChatPanel-By8Uo1nH.js.map} +1 -1
  46. package/dist/cdn/chunks/{AiPanels-BV5D1itk.js → AiPanels-BblCSkQy.js} +2 -2
  47. package/dist/cdn/chunks/{AiPanels-BV5D1itk.js.map → AiPanels-BblCSkQy.js.map} +1 -1
  48. package/dist/cdn/chunks/{AiRewriteMenu-D3jkh6Xb.js → AiRewriteMenu-C4btyN4W.js} +6 -6
  49. package/dist/cdn/chunks/{AiRewriteMenu-D3jkh6Xb.js.map → AiRewriteMenu-C4btyN4W.js.map} +1 -1
  50. package/dist/cdn/chunks/{BlockIssueBadge-DyEgBZtR.js → BlockIssueBadge-D3Plo_wt.js} +2 -2
  51. package/dist/cdn/chunks/{BlockIssueBadge-DyEgBZtR.js.map → BlockIssueBadge-D3Plo_wt.js.map} +1 -1
  52. package/dist/cdn/chunks/{BlockPreviewCanvas-RQFilqXC.js → BlockPreviewCanvas-CTKmBPsq.js} +7 -7
  53. package/dist/cdn/chunks/{BlockPreviewCanvas-RQFilqXC.js.map → BlockPreviewCanvas-CTKmBPsq.js.map} +1 -1
  54. package/dist/cdn/chunks/{CloudPanels-BSJ-Z5Hw.js → CloudPanels-COU26R83.js} +3 -3
  55. package/dist/cdn/chunks/{CloudPanels-BSJ-Z5Hw.js.map → CloudPanels-COU26R83.js.map} +1 -1
  56. package/dist/cdn/chunks/{CollaborationNotices-BS7xrlPE.js → CollaborationNotices-DraFUhyo.js} +2 -2
  57. package/dist/cdn/chunks/{CollaborationNotices-BS7xrlPE.js.map → CollaborationNotices-DraFUhyo.js.map} +1 -1
  58. package/dist/cdn/chunks/{CollaboratorBar-Bc9914Az.js → CollaboratorBar-0OEH3hrj.js} +2 -2
  59. package/dist/cdn/chunks/{CollaboratorBar-Bc9914Az.js.map → CollaboratorBar-0OEH3hrj.js.map} +1 -1
  60. package/dist/cdn/chunks/{CommentsPanel-DbR9phAk.js → CommentsPanel-tZZswofV.js} +2 -2
  61. package/dist/cdn/chunks/{CommentsPanel-DbR9phAk.js.map → CommentsPanel-tZZswofV.js.map} +1 -1
  62. package/dist/cdn/chunks/{CommentsSidebar-BD4--XP2.js → CommentsSidebar-7Hfl3Hdj.js} +2 -2
  63. package/dist/cdn/chunks/{CommentsSidebar-BD4--XP2.js.map → CommentsSidebar-7Hfl3Hdj.js.map} +1 -1
  64. package/dist/cdn/chunks/{CountdownToolbar-DxwYBw-d.js → CountdownToolbar-CNgsNL5-.js} +5 -5
  65. package/dist/cdn/chunks/{CountdownToolbar-DxwYBw-d.js.map → CountdownToolbar-CNgsNL5-.js.map} +1 -1
  66. package/dist/cdn/chunks/{IssuesPanel-CUmI4HMm.js → IssuesPanel-Duic0mIs.js} +4 -4
  67. package/dist/cdn/chunks/{IssuesPanel-CUmI4HMm.js.map → IssuesPanel-Duic0mIs.js.map} +1 -1
  68. package/dist/cdn/chunks/{LanguageMenu-3ydCozQJ.js → LanguageMenu-B1Aue_lf.js} +11 -11
  69. package/dist/cdn/chunks/{LanguageMenu-3ydCozQJ.js.map → LanguageMenu-B1Aue_lf.js.map} +1 -1
  70. package/dist/cdn/chunks/{LocaleNotices-BfoH6gST.js → LocaleNotices-8J2DRWeg.js} +2 -2
  71. package/dist/cdn/chunks/{LocaleNotices-BfoH6gST.js.map → LocaleNotices-8J2DRWeg.js.map} +1 -1
  72. package/dist/cdn/chunks/{LogicTagInsertButton-5Z3fFzjc.js → LogicTagInsertButton-Bhvi0nWz.js} +5 -5
  73. package/dist/cdn/chunks/{LogicTagInsertButton-5Z3fFzjc.js.map → LogicTagInsertButton-Bhvi0nWz.js.map} +1 -1
  74. package/dist/cdn/chunks/{MediaEditModal-DDCIwr9U.js → MediaEditModal-Dz972UFx.js} +2 -2
  75. package/dist/cdn/chunks/{MediaEditModal-DDCIwr9U.js.map → MediaEditModal-Dz972UFx.js.map} +1 -1
  76. package/dist/cdn/chunks/{MediaPanels-Dz79oy8P.js → MediaPanels-C6Hqtp1H.js} +2 -2
  77. package/dist/cdn/chunks/{MediaPanels-Dz79oy8P.js.map → MediaPanels-C6Hqtp1H.js.map} +1 -1
  78. package/dist/cdn/chunks/{MergeTagInput-CIWy-cXf.js → MergeTagInput-CrhZm-AW.js} +2 -2
  79. package/dist/cdn/chunks/{MergeTagInput-CIWy-cXf.js.map → MergeTagInput-CrhZm-AW.js.map} +1 -1
  80. package/dist/cdn/chunks/{MergeTagModeToggle-BrP5GR-x.js → MergeTagModeToggle-CWVtXLYa.js} +3 -3
  81. package/dist/cdn/chunks/{MergeTagModeToggle-BrP5GR-x.js.map → MergeTagModeToggle-CWVtXLYa.js.map} +1 -1
  82. package/dist/cdn/chunks/{MergeTagTextarea-D3nNDlhV.js → MergeTagTextarea-hTIBwX0F.js} +7 -7
  83. package/dist/cdn/chunks/{MergeTagTextarea-D3nNDlhV.js.map → MergeTagTextarea-hTIBwX0F.js.map} +1 -1
  84. package/dist/cdn/chunks/{ParagraphEditor-DDolH_Pf.js → ParagraphEditor-B2UU1Q5I.js} +15 -15
  85. package/dist/cdn/chunks/{ParagraphEditor-DDolH_Pf.js.map → ParagraphEditor-B2UU1Q5I.js.map} +1 -1
  86. package/dist/cdn/chunks/{RestoreVersionDialog-Crj1DBqC.js → RestoreVersionDialog-C1Y5Ewo_.js} +3 -3
  87. package/dist/cdn/chunks/{RestoreVersionDialog-Crj1DBqC.js.map → RestoreVersionDialog-C1Y5Ewo_.js.map} +1 -1
  88. package/dist/cdn/chunks/{RichTextEditorContent-rCCqFlwJ.js → RichTextEditorContent-up4AqL7D.js} +4 -4
  89. package/dist/cdn/chunks/{RichTextEditorContent-rCCqFlwJ.js.map → RichTextEditorContent-up4AqL7D.js.map} +1 -1
  90. package/dist/cdn/chunks/{SaveBlockDialog-C34RW1aM.js → SaveBlockDialog-B9lwEP_T.js} +6 -6
  91. package/dist/cdn/chunks/{SaveBlockDialog-C34RW1aM.js.map → SaveBlockDialog-B9lwEP_T.js.map} +1 -1
  92. package/dist/cdn/chunks/{SavedBlocksBrowserModal-CJnwWPT-.js → SavedBlocksBrowserModal-fAeHUyxb.js} +6 -6
  93. package/dist/cdn/chunks/{SavedBlocksBrowserModal-CJnwWPT-.js.map → SavedBlocksBrowserModal-fAeHUyxb.js.map} +1 -1
  94. package/dist/cdn/chunks/{SavedBlocksPanels-CA2PqXIH.js → SavedBlocksPanels-DRDTLDyZ.js} +2 -2
  95. package/dist/cdn/chunks/{SavedBlocksPanels-CA2PqXIH.js.map → SavedBlocksPanels-DRDTLDyZ.js.map} +1 -1
  96. package/dist/cdn/chunks/{SavedBlocksPickBar-Dj3ortee.js → SavedBlocksPickBar-B6b5z-o3.js} +3 -3
  97. package/dist/cdn/chunks/{SavedBlocksPickBar-Dj3ortee.js.map → SavedBlocksPickBar-B6b5z-o3.js.map} +1 -1
  98. package/dist/cdn/chunks/{TemplateSettings-sW0ZlDl1.js → TemplateSettings-CWUpUKJb.js} +6 -6
  99. package/dist/cdn/chunks/{TemplateSettings-sW0ZlDl1.js.map → TemplateSettings-CWUpUKJb.js.map} +1 -1
  100. package/dist/cdn/chunks/{TestEmailModal-BXeCtTjU.js → TestEmailModal-DQxnW5Q5.js} +7 -7
  101. package/dist/cdn/chunks/{TestEmailModal-BXeCtTjU.js.map → TestEmailModal-DQxnW5Q5.js.map} +1 -1
  102. package/dist/cdn/chunks/{TestEmailPanel-CpZcpB9D.js → TestEmailPanel-BcO_-16H.js} +2 -2
  103. package/dist/cdn/chunks/{TestEmailPanel-CpZcpB9D.js.map → TestEmailPanel-BcO_-16H.js.map} +1 -1
  104. package/dist/cdn/chunks/{TitleEditor-Bv3SmSO6.js → TitleEditor-pmycpmTd.js} +5 -5
  105. package/dist/cdn/chunks/{TitleEditor-Bv3SmSO6.js.map → TitleEditor-pmycpmTd.js.map} +1 -1
  106. package/dist/cdn/chunks/{Toolbar-BJKpJ2Mg.js → Toolbar-BlWVQRcA.js} +571 -571
  107. package/dist/cdn/chunks/{Toolbar-BJKpJ2Mg.js.map → Toolbar-BlWVQRcA.js.map} +1 -1
  108. package/dist/cdn/chunks/{TplModal-DDDUDMYC.js → TplModal-ClSSGX7a.js} +2 -2
  109. package/dist/cdn/chunks/{TplModal-DDDUDMYC.js.map → TplModal-ClSSGX7a.js.map} +1 -1
  110. package/dist/cdn/chunks/{VersionHistoryMenu-DSElv3Sv.js → VersionHistoryMenu-CZury5gU.js} +4 -4
  111. package/dist/cdn/chunks/{VersionHistoryMenu-DSElv3Sv.js.map → VersionHistoryMenu-CZury5gU.js.map} +1 -1
  112. package/dist/cdn/chunks/{VersionHistoryPanels-H2nuik1l.js → VersionHistoryPanels-B8GPBKMq.js} +2 -2
  113. package/dist/cdn/chunks/{VersionHistoryPanels-H2nuik1l.js.map → VersionHistoryPanels-B8GPBKMq.js.map} +1 -1
  114. package/dist/cdn/chunks/{VersionPreviewBanner-Whwxh55w.js → VersionPreviewBanner-C4Ji8nu4.js} +2 -2
  115. package/dist/cdn/chunks/{VersionPreviewBanner-Whwxh55w.js.map → VersionPreviewBanner-C4Ji8nu4.js.map} +1 -1
  116. package/dist/cdn/chunks/{WrapperBlock-jTqsuLnS.js → WrapperBlock-BoUflYwY.js} +4 -4
  117. package/dist/cdn/chunks/{WrapperBlock-jTqsuLnS.js.map → WrapperBlock-BoUflYwY.js.map} +1 -1
  118. package/dist/cdn/chunks/{blockTypeIcons-DMgLcuI8.js → blockTypeIcons-Cc6RJ27V.js} +2 -2
  119. package/dist/cdn/chunks/{blockTypeIcons-DMgLcuI8.js.map → blockTypeIcons-Cc6RJ27V.js.map} +1 -1
  120. package/dist/cdn/chunks/{composables-D0UYam2P.js → composables-C1KU4ZHw.js} +117 -117
  121. package/dist/cdn/chunks/{composables-D0UYam2P.js.map → composables-C1KU4ZHw.js.map} +1 -1
  122. package/dist/cdn/chunks/{createCloudRuntime-BdsclY8_.js → createCloudRuntime-C2Zs5F1O.js} +3 -3
  123. package/dist/cdn/chunks/{createCloudRuntime-BdsclY8_.js.map → createCloudRuntime-C2Zs5F1O.js.map} +1 -1
  124. package/dist/cdn/chunks/{editor-modal-CPbgthOv.js → editor-modal-erQEOHZN.js} +90 -90
  125. package/dist/cdn/chunks/{editor-modal-CPbgthOv.js.map → editor-modal-erQEOHZN.js.map} +1 -1
  126. package/dist/cdn/chunks/en-B6tLGRHq.js +1 -0
  127. package/dist/cdn/chunks/{extensions-Uh9vuFfK.js → extensions-DcMKZpzh.js} +4 -4
  128. package/dist/cdn/chunks/{extensions-Uh9vuFfK.js.map → extensions-DcMKZpzh.js.map} +1 -1
  129. package/dist/cdn/chunks/{icons-CSSMtbGK.js → icons-Da9GKjPx.js} +42 -42
  130. package/dist/cdn/chunks/{icons-CSSMtbGK.js.map → icons-Da9GKjPx.js.map} +1 -1
  131. package/dist/cdn/chunks/{normalizeMergeTagMarkup-oGhwVscw.js → normalizeMergeTagMarkup-cC32Ox6A.js} +23 -23
  132. package/dist/cdn/chunks/{normalizeMergeTagMarkup-oGhwVscw.js.map → normalizeMergeTagMarkup-cC32Ox6A.js.map} +1 -1
  133. package/dist/cdn/chunks/{preRenderCustomBlocks-C8k7tw98.js → preRenderCustomBlocks-f7GEKdvw.js} +4 -4
  134. package/dist/cdn/chunks/{preRenderCustomBlocks-C8k7tw98.js.map → preRenderCustomBlocks-f7GEKdvw.js.map} +1 -1
  135. package/dist/cdn/chunks/{sanitizeHtml-DYklmvgX.js → sanitizeHtml-WTfz9lZd.js} +2 -2
  136. package/dist/cdn/chunks/{sanitizeHtml-DYklmvgX.js.map → sanitizeHtml-WTfz9lZd.js.map} +1 -1
  137. package/dist/cdn/chunks/{socialIcons-BAiuHyJs.js → socialIcons-DeCYorUT.js} +493 -493
  138. package/dist/cdn/chunks/{socialIcons-BAiuHyJs.js.map → socialIcons-DeCYorUT.js.map} +1 -1
  139. package/dist/cdn/chunks/{src-DheBmnvF.js → src-A_cKeTM_.js} +263 -263
  140. package/dist/cdn/chunks/{src-DheBmnvF.js.map → src-A_cKeTM_.js.map} +1 -1
  141. package/dist/cdn/chunks/{src-CACM3o--.js → src-BQUv2CYU.js} +152 -152
  142. package/dist/cdn/chunks/{src-CACM3o--.js.map → src-BQUv2CYU.js.map} +1 -1
  143. package/dist/cdn/chunks/{src-Ddpm4HsS.js → src-BWX_xVxO.js} +237 -179
  144. package/dist/cdn/chunks/src-BWX_xVxO.js.map +1 -0
  145. package/dist/cdn/chunks/useLocalizedDisplay-aGfnO90D.js +33 -0
  146. package/dist/cdn/chunks/{useLocalizedDisplay-yXbRKNrs.js.map → useLocalizedDisplay-aGfnO90D.js.map} +1 -1
  147. package/dist/cdn/chunks/{useLogicTag-B7RpqVFQ.js → useLogicTag-DtYe8HIq.js} +2 -2
  148. package/dist/cdn/chunks/{useLogicTag-B7RpqVFQ.js.map → useLogicTag-DtYe8HIq.js.map} +1 -1
  149. package/dist/cdn/chunks/{useMergeTag-C-32ETjj.js → useMergeTag-B8ULmsnp.js} +2 -2
  150. package/dist/cdn/chunks/{useMergeTag-C-32ETjj.js.map → useMergeTag-B8ULmsnp.js.map} +1 -1
  151. package/dist/cdn/chunks/{withCurrentFont-D33ZXoWp.js → withCurrentFont-MK8ga9q9.js} +2 -2
  152. package/dist/cdn/chunks/{withCurrentFont-D33ZXoWp.js.map → withCurrentFont-MK8ga9q9.js.map} +1 -1
  153. package/dist/cdn/editor.js +262 -262
  154. package/dist/cdn/editor.js.map +1 -1
  155. package/dist/{check-ChQ0l8EQ.js → check-XMnOOIEC.js} +1 -1
  156. package/dist/{chevron-down-Bh6cp6PI.js → chevron-down-DmamTEWQ.js} +1 -1
  157. package/dist/{chevron-right-LUgdqdoW.js → chevron-right-BEFXOH27.js} +1 -1
  158. package/dist/{chevron-up-XsDeJxQN.js → chevron-up-Dw7woXj8.js} +1 -1
  159. package/dist/{circle-alert-lODfDsrj.js → circle-alert-BTKC9vkq.js} +1 -1
  160. package/dist/{clock-DrqFEZkT.js → clock-BVT5u2uG.js} +1 -1
  161. package/dist/{composables-BOP3ERRP.js → composables-CMIrGXJ1.js} +13 -13
  162. package/dist/{createLucideIcon-Dw5e5gVE.js → createLucideIcon-CgDE3xAR.js} +5 -5
  163. package/dist/{editor-modal-B_2EAOjN.js → editor-modal-BeX6otLk.js} +15 -15
  164. package/dist/en-Do0SU6tR.js +1 -0
  165. package/dist/{extensions-DOLZkLzV.js → extensions-BJ184osp.js} +1 -1
  166. package/dist/{eye-DChfk0gi.js → eye-ByMgHeA_.js} +1 -1
  167. package/dist/{image--Hj2by1G.js → image-Ch8tR35K.js} +1 -1
  168. package/dist/{info-BbXgy82f.js → info-DzSD-Wpk.js} +1 -1
  169. package/dist/{link-C2_8yJno.js → link-oDn9AR2w.js} +1 -1
  170. package/dist/{list-DLGs2n0V.js → list-C5t07dp8.js} +1 -1
  171. package/dist/{loader-circle-BbDItE_O.js → loader-circle-k6xvKgUB.js} +1 -1
  172. package/dist/{message-circle-NAModq0p.js → message-circle-C23R6OJR.js} +1 -1
  173. package/dist/{package-BuzsfRyH.js → package-C90eQ7NU.js} +1 -1
  174. package/dist/{pencil-BTUUECH4.js → pencil-BK7GrQuA.js} +1 -1
  175. package/dist/{plus-Dm7DN65T.js → plus-Cr0Mis63.js} +1 -1
  176. package/dist/{refresh-cw-xMURqGWi.js → refresh-cw-_ZLOIEvA.js} +1 -1
  177. package/dist/{rotate-ccw-DqVcEIn5.js → rotate-ccw-CB5wsHwv.js} +1 -1
  178. package/dist/{sanitizeHtml-mKgNUdME.js → sanitizeHtml-2rjV0r-6.js} +1 -1
  179. package/dist/{search-Cfr3W44N.js → search-BmrQNox8.js} +1 -1
  180. package/dist/{send-CH1SrvyB.js → send-blAsIBBg.js} +1 -1
  181. package/dist/{smartphone-pAkvzjdI.js → smartphone-BPpWYrwV.js} +1 -1
  182. package/dist/{socialIcons-Dqr4DJOz.js → socialIcons-TFiOkpoU.js} +3 -3
  183. package/dist/{sparkles-CRO0cCnp.js → sparkles-OqIxrNp-.js} +1 -1
  184. package/dist/{square-CaQWMntx.js → square-BP-V7iT-.js} +1 -1
  185. package/dist/templatical-editor.js +29 -29
  186. package/dist/{text-align-start-BQ39AaRK.js → text-align-start-4mwX2o-F.js} +13 -13
  187. package/dist/{trash-BL5gEFHN.js → trash-B99WixTA.js} +1 -1
  188. package/dist/{triangle-alert-BYbKu7zZ.js → triangle-alert-CHMiDkHa.js} +1 -1
  189. package/dist/{upload-BhmL4Vqx.js → upload-Cp8o-hrN.js} +1 -1
  190. package/dist/{useScrollToBlock-C0Kapxdh.js → useScrollToBlock-B35ObCGK.js} +1 -1
  191. package/dist/{x-B7NZYzhx.js → x-BIBStNMS.js} +1 -1
  192. package/package.json +8 -8
  193. package/dist/cdn/chunks/en-IYVryJRl.js +0 -1
  194. package/dist/cdn/chunks/src-Ddpm4HsS.js.map +0 -1
  195. package/dist/cdn/chunks/useLocalizedDisplay-yXbRKNrs.js +0 -33
  196. package/dist/en-DTtwco2Q.js +0 -1
@@ -1,11 +1,11 @@
1
- import { $t as e, At as t, Qt as n, Yt as r, a as i, i as a, jt as o, m as s, qt as c, r as l } from "./src-CACM3o--.js";
1
+ import { $t as e, Jt as t, Mt as n, Xt as r, a as i, en as a, i as o, jt as s, m as c, r as l } from "./src-BQUv2CYU.js";
2
2
  // src/utils/normalizeMergeTagMarkup.ts
3
3
  function u(e) {
4
4
  let t = e.flags.includes("g") ? e.flags : `${e.flags}g`;
5
5
  return new RegExp(e.source, t);
6
6
  }
7
7
  function d(e, t, n) {
8
- let r = [], o = (t, n, i) => {
8
+ let r = [], a = (t, n, i) => {
9
9
  let a = u(t), o = a.exec(e);
10
10
  for (; o !== null;) {
11
11
  let t = o.index, s = t + o[0].length;
@@ -18,7 +18,7 @@ function d(e, t, n) {
18
18
  }), o = a.exec(e);
19
19
  }
20
20
  };
21
- return o(n.logic, "data-logic-merge-tag", (e) => a(e, n)), o(n.value, "data-merge-tag", (e) => i(e, t)), r.sort((e, t) => e.start - t.start);
21
+ return a(n.logic, "data-logic-merge-tag", (e) => o(e, n)), a(n.value, "data-merge-tag", (e) => i(e, t)), r.sort((e, t) => e.start - t.start);
22
22
  }
23
23
  function f(e) {
24
24
  let t = e.createTreeWalker(e.body, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, { acceptNode(e) {
@@ -131,13 +131,13 @@ function g(e, t, n) {
131
131
  } : e;
132
132
  }
133
133
  function _(e, t) {
134
- return g(y(e), t?.tags ?? [], s(t?.syntax));
134
+ return g(y(e), t?.tags ?? [], c(t?.syntax));
135
135
  }
136
136
  function v(e, t) {
137
- return h(e, t?.tags ?? [], s(t?.syntax));
137
+ return h(e, t?.tags ?? [], c(t?.syntax));
138
138
  }
139
- function y(t) {
140
- return typeof t == "object" && t ? e(t) : t;
139
+ function y(e) {
140
+ return typeof e == "object" && e ? a(e) : e;
141
141
  }
142
142
  function b(e, t) {
143
143
  return {
@@ -184,14 +184,14 @@ function C(e, t) {
184
184
  let r = e.type === "section" ? n.flat() : n;
185
185
  for (let e of r) e && typeof e == "object" && C(e, t);
186
186
  }
187
- function w(i, a, l) {
188
- let u = l?.tags ?? [], d = s(l?.syntax), f = /* @__PURE__ */ new Map(), _ = i.some((e) => e.op === "updateBlockLocale"), v = e(a), y = e(a), b = (e, n, r) => {
187
+ function w(i, o, l) {
188
+ let u = l?.tags ?? [], d = c(l?.syntax), f = /* @__PURE__ */ new Map(), _ = i.some((e) => e.op === "updateBlockLocale"), v = a(o), y = a(o), b = (e, t, r) => {
189
189
  try {
190
- if (!("expect" in n)) return o(e, [n]);
191
- let { expect: t, ...r } = n;
192
- return o(e, [r]);
190
+ if (!("expect" in t)) return n(e, [t]);
191
+ let { expect: r, ...i } = t;
192
+ return n(e, [i]);
193
193
  } catch (e) {
194
- throw e instanceof t ? new t(e.code, r, e.message, e.blockId) : e;
194
+ throw e instanceof s ? new s(e.code, r, e.message, e.blockId) : e;
195
195
  }
196
196
  }, x = (e, t) => {
197
197
  let n = (e) => {
@@ -203,21 +203,21 @@ function w(i, a, l) {
203
203
  }
204
204
  };
205
205
  return n(e?.blocks);
206
- }, w = (e, t, i, a) => {
207
- if (!e) return e;
208
- let o = e;
209
- for (let [s, l] of Object.entries(e)) {
206
+ }, w = (n, i, a, o) => {
207
+ if (!n) return n;
208
+ let s = n;
209
+ for (let [c, l] of Object.entries(n)) {
210
210
  if (!l) continue;
211
- let e = a ? t?.l10n?.[a]?.text?.[s] : void 0, u = a ? i?.l10n?.[a]?.text?.[s] : void 0, d = c(t, s), f = c(i, s), p = e && u && n(l, e) ? u.sourceHash : typeof d == "string" && typeof f == "string" && l.sourceHash === r(d) ? r(f) : l.sourceHash;
212
- p !== l.sourceHash && (o = {
213
- ...o,
214
- [s]: {
211
+ let n = o ? i?.l10n?.[o]?.text?.[c] : void 0, u = o ? a?.l10n?.[o]?.text?.[c] : void 0, d = t(i, c), f = t(a, c), p = n && u && e(l, n) ? u.sourceHash : typeof d == "string" && typeof f == "string" && l.sourceHash === r(d) ? r(f) : l.sourceHash;
212
+ p !== l.sourceHash && (s = {
213
+ ...s,
214
+ [c]: {
215
215
  ...l,
216
216
  sourceHash: p
217
217
  }
218
218
  });
219
219
  }
220
- return o;
220
+ return s;
221
221
  }, T = !1, E = (e) => {
222
222
  if (e.op === "addBlock") {
223
223
  if (!e.block || typeof e.block != "object") return e;
@@ -287,4 +287,4 @@ function w(i, a, l) {
287
287
  }
288
288
  export { b as a, w as i, _ as n, x as o, p as r, v as t };
289
289
 
290
- //# sourceMappingURL=normalizeMergeTagMarkup-oGhwVscw.js.map
290
+ //# sourceMappingURL=normalizeMergeTagMarkup-cC32Ox6A.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeMergeTagMarkup-oGhwVscw.js","names":["safeClone","OperationError","deepEqual","sourceHash","getMergeTagLabel","getLogicMergeTagKeyword","applyOperations","resolveSyntax","readPath","containsMergeTag","globalRegex","flags","pattern","collectHits","hits","scan","regex","match","text","start","end","hit","label","syntax","value","mergeTags","a","b","collectNormalizableTextNodes","walker","doc","node","el","nodes","current","normalizeMergeTagsInHtml","html","replacements","fragment","cursor","span","normalizeLocaleText","blockType","entry","normalizeBlock","l10n","block","changed","next","locale","layer","children","column","columnChanged","normalized","child","content","before","after","restamped","normalizeMergeTagMarkup","blocks","normalizeContentForConfig","copyIncomingContent","normalizeBlockForConfig","withNormalizedContentWrites","editor","markDirty","withNormalizedTemplateLoads","provider","template","id","blockTypeOf","found","collectBlockTypes","into","nested","normalizeRemoteOperations","tags","added","needsLocaleState","ops","op","original","normalizedState","advance","state","_expect","unguarded","error","index","blockIn","find","restamp","entries","result","path","oldEntry","newEntry","oldBase","newBase","hash","normalizeOne","type","expectText","expect","normalizeField","fields","set","nextOriginal","nextNormalized"],"sources":["../../../src/utils/normalizeMergeTagMarkup.ts"],"sourcesContent":["import type { Ref } from \"vue\";\nimport type {\n Block,\n MergeTag,\n LocalizedText,\n MergeTagsConfig,\n Operation,\n SectionBlock,\n SyntaxPreset,\n TemplateContent,\n TemplatesProvider,\n WrapperBlock,\n} from \"@templatical/types\";\nimport {\n sourceHash,\n readPath,\n deepEqual,\n applyOperations,\n containsMergeTag,\n getLogicMergeTagKeyword,\n getMergeTagLabel,\n OperationError,\n resolveSyntax,\n safeClone,\n} from \"@templatical/types\";\n\n/**\n * Convert bare merge-tag tokens in rich-text HTML into the `<span\n * data-merge-tag>` nodes the editor understands.\n *\n * A tag reaches stored content in one of two physical shapes. Anything a user\n * types or pastes is already a node, because `MergeTagNode`'s input and paste\n * rules convert it on the spot. What stays a bare token is content that never\n * passed through that pipeline — `init({ content })`, `setContent()`, a\n * template loaded from a store, or one produced by the `@templatical/import-*`\n * converters. A bare token renders as literal text: no label, no highlight, no\n * `sample` substitution, and it cannot be selected or deleted as a unit.\n *\n * Three properties of this implementation are load-bearing:\n *\n * 1. **It walks text nodes, never markup.** A token in attribute position —\n * `<a href=\"{{unsubscribe_url}}\">` is the common one — must be left exactly\n * as it is; wrapping it injects an element into an attribute value and\n * corrupts the document. A `TreeWalker` over text nodes cannot reach an\n * attribute at all, so this holds by construction rather than by guard.\n * A regex cannot do this job. Guarding with a `(?<!data-merge-tag=\")`\n * lookbehind protects the attribute of an already-converted span and\n * nothing else, so `<a href=\"{{unsubscribe_url}}\">` becomes an anchor whose\n * href contains a `<span>`. Telling text position from attribute position\n * needs parsing; no amount of lookbehind substitutes for it.\n *\n * 2. **It is idempotent structurally.** The walk rejects the whole subtree of\n * any element already carrying `data-merge-tag` / `data-logic-merge-tag`,\n * so an existing span's inner text is unreachable no matter what it says.\n * That covers the case where a tag's label *is* its value.\n *\n * 3. **It never builds markup by concatenation.** A consumer may configure a\n * syntax whose delimiters contain `<` / `>` — Smarty-style `<% $email %>` —\n * so a template string would emit an attribute no scanner could re-read.\n * Spans are created as elements and filled via `setAttribute` /\n * `textContent`, which leaves escaping to the serializer.\n *\n * Matching is driven by `syntax`, not by the declared tag list, so a template\n * migrated from another ESP has all of its tags made atomic rather than only\n * the handful the consumer has declared so far. An undeclared token falls back\n * to showing its raw value as the label, which `getMergeTagLabel` already does.\n * This mirrors typing: the input and paste rules are registered unconditionally\n * and match on syntax alone.\n */\n\ninterface TagHit {\n start: number;\n end: number;\n attr: string;\n value: string;\n label: string;\n}\n\nfunction globalRegex(pattern: RegExp): RegExp {\n const flags = pattern.flags.includes(\"g\")\n ? pattern.flags\n : `${pattern.flags}g`;\n return new RegExp(pattern.source, flags);\n}\n\nfunction collectHits(\n text: string,\n mergeTags: MergeTag[],\n syntax: SyntaxPreset,\n): TagHit[] {\n const hits: TagHit[] = [];\n\n const scan = (\n pattern: RegExp,\n attr: string,\n label: (match: string) => string,\n ): void => {\n const regex = globalRegex(pattern);\n let match = regex.exec(text);\n while (match !== null) {\n const start = match.index;\n const end = start + match[0].length;\n // A zero-length match would spin `exec` forever on the same index.\n if (match[0].length === 0) {\n regex.lastIndex++;\n } else if (!hits.some((hit) => start < hit.end && end > hit.start)) {\n hits.push({\n start,\n end,\n attr,\n value: match[0],\n label: label(match[0]),\n });\n }\n match = regex.exec(text);\n }\n };\n\n // Logic first, so it wins any overlap. Some syntaxes' value regex is liberal\n // enough to also match a logic tag — handlebars' `{{.+?}}` swallows\n // `{{#each items}}` — and `isMergeTagValue` resolves that same way.\n scan(syntax.logic, \"data-logic-merge-tag\", (value) =>\n getLogicMergeTagKeyword(value, syntax),\n );\n scan(syntax.value, \"data-merge-tag\", (value) =>\n getMergeTagLabel(value, mergeTags),\n );\n\n return hits.sort((a, b) => a.start - b.start);\n}\n\n/** Text nodes not already inside a merge-tag span, in document order. */\nfunction collectNormalizableTextNodes(doc: Document): Text[] {\n const walker = doc.createTreeWalker(\n doc.body,\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,\n {\n acceptNode(node: Node): number {\n if (node.nodeType !== 1) return NodeFilter.FILTER_ACCEPT;\n const el = node as Element;\n // REJECT (not SKIP) prunes the subtree, which is what makes a second\n // pass unable to see an existing span's inner text.\n return el.hasAttribute(\"data-merge-tag\") ||\n el.hasAttribute(\"data-logic-merge-tag\")\n ? NodeFilter.FILTER_REJECT\n : NodeFilter.FILTER_SKIP;\n },\n },\n );\n\n // Collected up front: replacing a node mid-walk invalidates the walker.\n const nodes: Text[] = [];\n let current = walker.nextNode();\n while (current !== null) {\n nodes.push(current as Text);\n current = walker.nextNode();\n }\n return nodes;\n}\n\nexport function normalizeMergeTagsInHtml(\n html: string,\n mergeTags: MergeTag[],\n syntax: SyntaxPreset,\n): string {\n if (!html) return html;\n // Cheap reject before paying for a parse. A token that exists only in an\n // attribute still gets past this, and is then caught by the zero-replacement\n // short-circuit below.\n if (!containsMergeTag(html, syntax)) return html;\n if (typeof DOMParser === \"undefined\") return html;\n\n const doc = new DOMParser().parseFromString(\n `<!doctype html><body>${html}</body>`,\n \"text/html\",\n );\n\n let replacements = 0;\n for (const node of collectNormalizableTextNodes(doc)) {\n const text = node.data;\n const hits = collectHits(text, mergeTags, syntax);\n if (hits.length === 0) continue;\n\n const fragment = doc.createDocumentFragment();\n let cursor = 0;\n for (const hit of hits) {\n if (hit.start > cursor) {\n fragment.appendChild(\n doc.createTextNode(text.substring(cursor, hit.start)),\n );\n }\n const span = doc.createElement(\"span\");\n span.setAttribute(hit.attr, hit.value);\n span.textContent = hit.label;\n fragment.appendChild(span);\n cursor = hit.end;\n }\n if (cursor < text.length) {\n fragment.appendChild(doc.createTextNode(text.substring(cursor)));\n }\n\n node.parentNode?.replaceChild(fragment, node);\n replacements += hits.length;\n }\n\n // Nothing matched in text position, so return the input verbatim rather than\n // a re-serialization of it — otherwise content with no tags at all would be\n // rewritten (`<br/>` → `<br>`, attribute quoting, entity encoding) for no\n // reason. Where a replacement does happen some churn is unavoidable, and the\n // renderer accepts both shapes.\n if (replacements === 0) return html;\n\n return doc.body.innerHTML;\n}\n\n/** Normalize localized rich content without changing source hashes or caller-owned objects. */\nfunction normalizeLocaleText<T extends LocalizedText | null>(\n blockType: string | undefined,\n text: Record<string, T> | undefined,\n mergeTags: MergeTag[],\n syntax: SyntaxPreset,\n): Record<string, T> | undefined {\n if (\n (blockType !== \"title\" &&\n blockType !== \"paragraph\" &&\n blockType !== \"html\") ||\n typeof text?.content?.value !== \"string\"\n )\n return text;\n const entry = text.content;\n const value = normalizeMergeTagsInHtml(entry.value, mergeTags, syntax);\n return value === entry.value\n ? text\n : { ...text, content: { ...entry, value } };\n}\n\n/**\n * Localized layers normalize only content on titles, paragraphs and HTML\n * blocks. Among base fields, only title and paragraph rich text is normalized. Every other merge-tag-bearing field —\n * `ButtonBlock.text`/`url`, `ImageBlock.alt`, `HtmlBlock.content`, custom-block\n * `fieldValues`, `settings.preheaderText` — is a plain string rendered as text,\n * so a span written into one would be displayed literally on the canvas and\n * emitted into a `url=` attribute by the renderer.\n *\n * `TableCellData.content` is span-bearing to the renderer but is deliberately\n * excluded: `TableBlock.vue` hydrates a cell with `textContent` and writes\n * `innerText` back on blur, so the first focus-and-leave on a normalized cell\n * would persist the literal markup into stored content as text. The\n * editor/renderer asymmetry there is a separate, pre-existing gap.\n */\nfunction normalizeBlock(\n block: Block,\n mergeTags: MergeTag[],\n syntax: SyntaxPreset,\n): Block {\n const l10n = block.l10n;\n if (l10n) {\n let changed = false;\n const next = Object.fromEntries(\n Object.entries(l10n).map(([locale, layer]) => {\n const text = normalizeLocaleText(\n block.type,\n layer.text,\n mergeTags,\n syntax,\n );\n if (text === layer.text) return [locale, layer];\n changed = true;\n return [locale, { ...layer, text }];\n }),\n );\n if (changed) block = { ...block, l10n: next };\n }\n if (block.type === \"section\") {\n if (!Array.isArray(block.children)) return block;\n let changed = false;\n const children = block.children.map((column) => {\n if (!Array.isArray(column)) return column;\n let columnChanged = false;\n const next = column.map((child) => {\n const normalized = normalizeBlock(child, mergeTags, syntax);\n if (normalized !== child) columnChanged = true;\n return normalized;\n });\n if (!columnChanged) return column;\n changed = true;\n return next;\n });\n return changed ? ({ ...block, children } as SectionBlock) : block;\n }\n\n if (block.type === \"wrapper\") {\n if (!Array.isArray(block.children)) return block;\n let changed = false;\n const children = block.children.map((child) => {\n const normalized = normalizeBlock(child, mergeTags, syntax);\n if (normalized !== child) changed = true;\n return normalized;\n });\n return changed ? ({ ...block, children } as WrapperBlock) : block;\n }\n\n if (block.type !== \"title\" && block.type !== \"paragraph\") return block;\n if (typeof block.content !== \"string\") return block;\n\n const content = normalizeMergeTagsInHtml(block.content, mergeTags, syntax);\n if (content === block.content) return block;\n const before = sourceHash(block.content);\n const after = sourceHash(content);\n const restamped =\n block.l10n &&\n Object.fromEntries(\n Object.entries(block.l10n).map(([locale, layer]) => {\n const entry = layer.text?.content;\n return [\n locale,\n entry?.sourceHash === before\n ? {\n ...layer,\n text: {\n ...layer.text,\n content: { ...entry, sourceHash: after },\n },\n }\n : layer,\n ];\n }),\n );\n return { ...block, content, ...(restamped ? { l10n: restamped } : {}) };\n}\n\n/**\n * Normalize every rich-text field in a template. Returns the input reference\n * unchanged when nothing matched, so a template with no bare tokens costs no\n * allocation and keeps its object identity; otherwise returns a copy, leaving\n * the caller's content untouched.\n *\n * Shape is checked rather than trusted at every level. `TemplateContent` types\n * `blocks` as required and `SectionBlock.children` as a `Block[][]`, but this\n * runs at the SDK's entry points on an object the consumer hands us — a partial\n * or hand-rolled template must come back untouched, not turn a working `init()`\n * into a `TypeError`.\n */\nexport function normalizeMergeTagMarkup(\n content: TemplateContent,\n mergeTags: MergeTag[],\n syntax: SyntaxPreset,\n): TemplateContent {\n if (!content || !Array.isArray(content.blocks)) return content;\n\n let changed = false;\n const blocks = content.blocks.map((block) => {\n const normalized = normalizeBlock(block, mergeTags, syntax);\n if (normalized !== block) changed = true;\n return normalized;\n });\n\n return changed ? { ...content, blocks } : content;\n}\n\n/**\n * `normalizeMergeTagMarkup` bound to the editor's own config shape, so the hook\n * sites don't each resolve tags and syntax themselves.\n *\n * An absent `mergeTags` still normalizes, under the liquid default. That is not\n * an oversight: `MergeTagNode`'s input and paste rules are registered\n * unconditionally with the same default, so a consumer who configured nothing\n * already gets a node the instant a user types `{{x}}`. Loading the same text\n * and leaving it inert would be the inconsistency.\n *\n * It always returns a copy. Every content-in path runs through here, and the\n * editor edits the object it holds in place, so holding the caller's own one\n * leaks each edit into it, and one that another Vue made reactive or that a\n * store froze hides edits from the editor's bundled Vue or throws on the first.\n */\nexport function normalizeContentForConfig(\n content: TemplateContent,\n mergeTags: MergeTagsConfig | undefined,\n): TemplateContent {\n return normalizeMergeTagMarkup(\n copyIncomingContent(content),\n mergeTags?.tags ?? [],\n resolveSyntax(mergeTags?.syntax),\n );\n}\n\n/** {@link normalizeContentForConfig} for a single block. */\nexport function normalizeBlockForConfig(\n block: Block,\n mergeTags: MergeTagsConfig | undefined,\n): Block {\n return normalizeBlock(\n block,\n mergeTags?.tags ?? [],\n resolveSyntax(mergeTags?.syntax),\n );\n}\n\n/**\n * A non-object passes through: `normalizeMergeTagMarkup` already hands back\n * whatever is not shaped like content, and `safeClone(undefined)` would throw.\n */\nfunction copyIncomingContent(content: TemplateContent): TemplateContent {\n return typeof content === \"object\" && content !== null\n ? safeClone(content)\n : content;\n}\n\n/**\n * Wrap a `TemplatesProvider` so content arriving from the store is normalized\n * before the editor ever sees it.\n *\n * Only `load` is wrapped. `save` sends content *out*, and what it sends is\n * already-normalized editor state; rewriting it here would change what the\n * store keeps for no benefit. `create` likewise carries content outward, and\n * the template it returns supplies identity and timestamps rather than the\n * content the editor goes on to edit.\n *\n * Wrapping the provider — rather than normalizing after `load()` resolves —\n * is what keeps Q4 true: core assigns already-normalized content to its state\n * and observes no mutation, so there is no dirty flag to suppress and no\n * autosave tick to swallow.\n */\n/**\n * The slice of the editor a content-restoring feature consumes. Structural on\n * purpose: it matches `useVersionHistoryFeature`'s own `VersionHistoryEditor`\n * without importing it, so this util keeps no dependency on a composable.\n */\ninterface ContentWritingEditor {\n state: {\n readonly template?: { id: string } | null;\n readonly isDirty: boolean;\n };\n content: Ref<TemplateContent>;\n setContent: (content: TemplateContent, markDirty?: boolean) => void;\n}\n\n/**\n * Wrap an editor so content written through `setContent` is normalized first.\n *\n * This is how version history is covered. Its content reaches the canvas by\n * three routes — `version.content` off a hydrated list, a `fetched` cache, and\n * `provider.get()` — so wrapping the *provider*, the way the `templates` path\n * does, would miss two of them. `setContent` is the one chokepoint they share.\n *\n * A version is not guaranteed to hold normalized content just because a save\n * produced it: a store carries whatever was written to it, and a backend may\n * version a template it imported rather than one the editor round-tripped.\n * Previewing such a version without this would put bare tokens back on a canvas\n * where every other tag is a chip.\n *\n * `markDirty` is forwarded untouched: every version-history write passes\n * `false`, and swallowing that would turn opening a preview into an unsaved\n * change. `setContent` is resolved per call rather than captured, so a\n * wrapper installed on the editor later still sees every write.\n */\nexport function withNormalizedContentWrites<T extends ContentWritingEditor>(\n editor: T,\n mergeTags: MergeTagsConfig | undefined,\n): ContentWritingEditor {\n return {\n get state() {\n return editor.state;\n },\n get content() {\n return editor.content;\n },\n setContent: (content: TemplateContent, markDirty?: boolean) =>\n editor.setContent(\n normalizeContentForConfig(content, mergeTags),\n markDirty,\n ),\n };\n}\n\nexport function withNormalizedTemplateLoads(\n provider: TemplatesProvider,\n mergeTags: MergeTagsConfig | undefined,\n): TemplatesProvider {\n return {\n ...provider,\n async load(id: string) {\n const template = await provider.load(id);\n return {\n ...template,\n content: normalizeContentForConfig(template.content, mergeTags),\n };\n },\n };\n}\n\n/**\n * The type of the block `id` names — at the top level, in a section's columns\n * or inside a wrapper — or `undefined` when no block has that id.\n */\nfunction blockTypeOf(blocks: unknown, id: string): string | undefined {\n if (!Array.isArray(blocks)) return undefined;\n for (const block of blocks as Block[]) {\n if (!block || typeof block !== \"object\") continue;\n if (block.id === id) return block.type;\n const children = (block as { children?: unknown }).children;\n if (block.type === \"section\" && Array.isArray(children)) {\n for (const column of children) {\n const found = blockTypeOf(column, id);\n if (found) return found;\n }\n } else if (block.type === \"wrapper\") {\n const found = blockTypeOf(children, id);\n if (found) return found;\n }\n }\n return undefined;\n}\n\n/** Every block id in `block`, a section's or a wrapper's children included, with its type. */\nfunction collectBlockTypes(block: Block, into: Map<string, string>): void {\n if (typeof block.id === \"string\") into.set(block.id, block.type);\n const children = (block as { children?: unknown }).children;\n if (!Array.isArray(children)) return;\n const nested =\n block.type === \"section\" ? (children as unknown[]).flat() : children;\n for (const child of nested) {\n if (child && typeof child === \"object\") {\n collectBlockTypes(child as Block, into);\n }\n }\n}\n\n/**\n * Normalize the merge tags in a batch another session made, before the editor\n * applies it — the collaboration counterpart of {@link withNormalizedTemplateLoads}.\n * An agent writes `{{first_name}}` as text and a headless write stores it bare;\n * both arrive as operations, and normalizing them on arrival turns each token\n * into a tag at once. Nothing is sent back for it: the canvas and the\n * controller's copy of the backend's content change together.\n *\n * The rich-text fields only, as for loads: an `addBlock`'s block (a section's\n * children included), an `updateBlock`'s `set.content` when the block it names\n * is a title or a paragraph, its `expect.content`, and a deletion’s `expect.block` — found in `content`, or among the blocks the batch\n * itself added — and a `setContent`'s content. Returns `ops` itself when\n * nothing matched, and never changes it.\n */\nexport function normalizeRemoteOperations(\n ops: readonly Operation[],\n content: TemplateContent,\n mergeTags: MergeTagsConfig | undefined,\n): Operation[] {\n const tags = mergeTags?.tags ?? [];\n const syntax = resolveSyntax(mergeTags?.syntax);\n const added = new Map<string, string>();\n // Markup-only normalization also supports partial input and layout wrappers.\n // Locale hashes require engine-valid, evolving simulation states.\n const needsLocaleState = ops.some((op) => op.op === \"updateBlockLocale\");\n let original = safeClone(content);\n let normalizedState = safeClone(content);\n const advance = (\n state: TemplateContent,\n op: Operation,\n index: number,\n ): TemplateContent => {\n try {\n if (!(\"expect\" in op)) return applyOperations(state, [op]);\n // The backend already checked guards against its raw representation.\n const { expect: _expect, ...unguarded } = op;\n return applyOperations(state, [unguarded as Operation]);\n } catch (error) {\n if (!(error instanceof OperationError)) throw error;\n throw new OperationError(error.code, index, error.message, error.blockId);\n }\n };\n const blockIn = (state: TemplateContent, id: string): Block | undefined => {\n const find = (blocks: unknown): Block | undefined => {\n if (!Array.isArray(blocks)) return undefined;\n for (const block of blocks) {\n if (!block || typeof block !== \"object\") continue;\n if (block.id === id) return block;\n const children = block.children;\n const found = find(\n block.type === \"section\" && Array.isArray(children)\n ? children.flat()\n : children,\n );\n if (found) return found;\n }\n };\n return find(state?.blocks);\n };\n const restamp = <T extends LocalizedText | null>(\n entries: Record<string, T> | undefined,\n before: Block | undefined,\n after: Block | undefined,\n locale?: string,\n ): Record<string, T> | undefined => {\n if (!entries) return entries;\n let result = entries;\n for (const [path, entry] of Object.entries(entries)) {\n if (!entry) continue;\n const oldEntry = locale\n ? before?.l10n?.[locale]?.text?.[path]\n : undefined;\n const newEntry = locale ? after?.l10n?.[locale]?.text?.[path] : undefined;\n const oldBase = readPath(before, path);\n const newBase = readPath(after, path);\n const hash =\n oldEntry && newEntry && deepEqual(entry, oldEntry)\n ? newEntry.sourceHash\n : typeof oldBase === \"string\" &&\n typeof newBase === \"string\" &&\n entry.sourceHash === sourceHash(oldBase)\n ? sourceHash(newBase)\n : entry.sourceHash;\n if (hash !== entry.sourceHash)\n result = { ...result, [path]: { ...entry, sourceHash: hash } };\n }\n return result;\n };\n let changed = false;\n\n const normalizeOne = (op: Operation): Operation => {\n if (op.op === \"addBlock\") {\n if (!op.block || typeof op.block !== \"object\") return op;\n collectBlockTypes(op.block, added);\n const block = normalizeBlock(op.block, tags, syntax);\n if (block === op.block) return op;\n changed = true;\n return { ...op, block };\n }\n if (op.op === \"deleteBlock\" && op.expect?.block) {\n const block = normalizeBlock(op.expect.block, tags, syntax);\n if (block === op.expect.block) return op;\n changed = true;\n return { ...op, expect: { ...op.expect, block } };\n }\n if (op.op === \"updateBlockLocale\") {\n const type =\n added.get(op.blockId) ?? blockTypeOf(original?.blocks, op.blockId);\n const before = blockIn(original, op.blockId);\n const after = blockIn(normalizedState, op.blockId);\n const text = normalizeLocaleText(\n type,\n restamp(op.text, before, after),\n tags,\n syntax,\n );\n const expectText = normalizeLocaleText(\n type,\n restamp(op.expect?.text, before, after, op.locale),\n tags,\n syntax,\n );\n const expect =\n op.expect && expectText !== op.expect.text\n ? { ...op.expect, text: expectText }\n : op.expect;\n if (text === op.text && expect === op.expect) return op;\n changed = true;\n return {\n ...op,\n ...(text ? { text } : {}),\n ...(expect ? { expect } : {}),\n };\n }\n if (op.op === \"updateBlock\") {\n const type =\n added.get(op.blockId) ?? blockTypeOf(original?.blocks, op.blockId);\n if (type !== \"title\" && type !== \"paragraph\") return op;\n const normalizeField = (fields: Record<string, unknown> | undefined) => {\n if (typeof fields?.content !== \"string\") return fields;\n const normalized = normalizeMergeTagsInHtml(\n fields.content,\n tags,\n syntax,\n );\n return normalized === fields.content\n ? fields\n : { ...fields, content: normalized };\n };\n const set = normalizeField(op.set);\n const expect = normalizeField(op.expect);\n if (set === op.set && expect === op.expect) return op;\n changed = true;\n return { ...op, ...(set ? { set } : {}), ...(expect ? { expect } : {}) };\n }\n if (op.op === \"setContent\") {\n added.clear();\n const normalized = normalizeMergeTagMarkup(op.content, tags, syntax);\n if (normalized === op.content) return op;\n changed = true;\n return { ...op, content: normalized };\n }\n return op;\n };\n const next = ops.map((op, index) => {\n const normalized = normalizeOne(op);\n if (needsLocaleState) {\n // Fail before returning any batch if either state cannot advance. The\n // collaboration caller reports the error and applies its existing fallback.\n const nextOriginal = advance(original, op, index);\n const nextNormalized = advance(normalizedState, normalized, index);\n original = nextOriginal;\n normalizedState = nextNormalized;\n } else if (op.op === \"setContent\") {\n // Keep type lookup current without imposing engine validation on the\n // existing markup-only path. Added blocks are tracked in `added`.\n original = op.content;\n }\n return normalized;\n });\n\n return changed ? next : (ops as Operation[]);\n}\n"],"mappings":";;AA8EA,SAASU,EAAY,GAAyB;CAC5C,IAAMC,IAAQC,EAAQ,MAAM,SAAS,GAAG,IACpCA,EAAQ,QACR,GAAGA,EAAQ,MAAM;CACrB,OAAO,IAAI,OAAOA,EAAQ,QAAQD,CAAK;AACzC;AAEA,SAASE,EACP,GACA,GACA,GACU;CACV,IAAMC,IAAiB,CAAC,GAElBC,KACJ,GACA,GACA,MACS;EACT,IAAMC,IAAQN,EAAYE,CAAO,GAC7BK,IAAQD,EAAM,KAAKE,CAAI;EAC3B,OAAOD,MAAU,OAAM;GACrB,IAAME,IAAQF,EAAM,OACdG,IAAMD,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B,CAAE;EAClC,IAAIF,GAAkB;GAGpB,IAAM6B,IAAexB,EAAQF,GAAUD,GAAIQ,CAAK,GAC1CoB,IAAiBzB,EAAQD,GAAiB9B,GAAYoC,CAAK;GAEjE,AADA,IAAWmB,GACX,IAAkBC;EACpB,OAAO,AAAI5B,EAAG,OAAO,iBAGnB,IAAWA,EAAG;EAEhB,OAAO5B;CACT,CAAC;CAED,OAAOP,IAAUC,IAAQiC;AAC3B"}
1
+ {"version":3,"file":"normalizeMergeTagMarkup-cC32Ox6A.js","names":["deepEqual","readPath","applyOperations","sourceHash","getMergeTagLabel","safeClone","getLogicMergeTagKeyword","OperationError","resolveSyntax","containsMergeTag","globalRegex","flags","pattern","collectHits","hits","scan","regex","match","text","start","end","hit","label","syntax","value","mergeTags","a","b","collectNormalizableTextNodes","walker","doc","node","el","nodes","current","normalizeMergeTagsInHtml","html","replacements","fragment","cursor","span","normalizeLocaleText","blockType","entry","normalizeBlock","l10n","block","changed","next","locale","layer","children","column","columnChanged","normalized","child","content","before","after","restamped","normalizeMergeTagMarkup","blocks","normalizeContentForConfig","copyIncomingContent","normalizeBlockForConfig","withNormalizedContentWrites","editor","markDirty","withNormalizedTemplateLoads","provider","template","id","blockTypeOf","found","collectBlockTypes","into","nested","normalizeRemoteOperations","tags","added","needsLocaleState","ops","op","original","normalizedState","advance","state","_expect","unguarded","error","index","blockIn","find","restamp","entries","result","path","oldEntry","newEntry","oldBase","newBase","hash","normalizeOne","type","expectText","expect","normalizeField","fields","set","nextOriginal","nextNormalized"],"sources":["../../../src/utils/normalizeMergeTagMarkup.ts"],"sourcesContent":["import type { Ref } from \"vue\";\nimport type {\n Block,\n MergeTag,\n LocalizedText,\n MergeTagsConfig,\n Operation,\n SectionBlock,\n SyntaxPreset,\n TemplateContent,\n TemplatesProvider,\n WrapperBlock,\n} from \"@templatical/types\";\nimport {\n sourceHash,\n readPath,\n deepEqual,\n applyOperations,\n containsMergeTag,\n getLogicMergeTagKeyword,\n getMergeTagLabel,\n OperationError,\n resolveSyntax,\n safeClone,\n} from \"@templatical/types\";\n\n/**\n * Convert bare merge-tag tokens in rich-text HTML into the `<span\n * data-merge-tag>` nodes the editor understands.\n *\n * A tag reaches stored content in one of two physical shapes. Anything a user\n * types or pastes is already a node, because `MergeTagNode`'s input and paste\n * rules convert it on the spot. What stays a bare token is content that never\n * passed through that pipeline — `init({ content })`, `setContent()`, a\n * template loaded from a store, or one produced by the `@templatical/import-*`\n * converters. A bare token renders as literal text: no label, no highlight, no\n * `sample` substitution, and it cannot be selected or deleted as a unit.\n *\n * Three properties of this implementation are load-bearing:\n *\n * 1. **It walks text nodes, never markup.** A token in attribute position —\n * `<a href=\"{{unsubscribe_url}}\">` is the common one — must be left exactly\n * as it is; wrapping it injects an element into an attribute value and\n * corrupts the document. A `TreeWalker` over text nodes cannot reach an\n * attribute at all, so this holds by construction rather than by guard.\n * A regex cannot do this job. Guarding with a `(?<!data-merge-tag=\")`\n * lookbehind protects the attribute of an already-converted span and\n * nothing else, so `<a href=\"{{unsubscribe_url}}\">` becomes an anchor whose\n * href contains a `<span>`. Telling text position from attribute position\n * needs parsing; no amount of lookbehind substitutes for it.\n *\n * 2. **It is idempotent structurally.** The walk rejects the whole subtree of\n * any element already carrying `data-merge-tag` / `data-logic-merge-tag`,\n * so an existing span's inner text is unreachable no matter what it says.\n * That covers the case where a tag's label *is* its value.\n *\n * 3. **It never builds markup by concatenation.** A consumer may configure a\n * syntax whose delimiters contain `<` / `>` — Smarty-style `<% $email %>` —\n * so a template string would emit an attribute no scanner could re-read.\n * Spans are created as elements and filled via `setAttribute` /\n * `textContent`, which leaves escaping to the serializer.\n *\n * Matching is driven by `syntax`, not by the declared tag list, so a template\n * migrated from another ESP has all of its tags made atomic rather than only\n * the handful the consumer has declared so far. An undeclared token falls back\n * to showing its raw value as the label, which `getMergeTagLabel` already does.\n * This mirrors typing: the input and paste rules are registered unconditionally\n * and match on syntax alone.\n */\n\ninterface TagHit {\n start: number;\n end: number;\n attr: string;\n value: string;\n label: string;\n}\n\nfunction globalRegex(pattern: RegExp): RegExp {\n const flags = pattern.flags.includes(\"g\")\n ? pattern.flags\n : `${pattern.flags}g`;\n return new RegExp(pattern.source, flags);\n}\n\nfunction collectHits(\n text: string,\n mergeTags: MergeTag[],\n syntax: SyntaxPreset,\n): TagHit[] {\n const hits: TagHit[] = [];\n\n const scan = (\n pattern: RegExp,\n attr: string,\n label: (match: string) => string,\n ): void => {\n const regex = globalRegex(pattern);\n let match = regex.exec(text);\n while (match !== null) {\n const start = match.index;\n const end = start + match[0].length;\n // A zero-length match would spin `exec` forever on the same index.\n if (match[0].length === 0) {\n regex.lastIndex++;\n } else if (!hits.some((hit) => start < hit.end && end > hit.start)) {\n hits.push({\n start,\n end,\n attr,\n value: match[0],\n label: label(match[0]),\n });\n }\n match = regex.exec(text);\n }\n };\n\n // Logic first, so it wins any overlap. Some syntaxes' value regex is liberal\n // enough to also match a logic tag — handlebars' `{{.+?}}` swallows\n // `{{#each items}}` — and `isMergeTagValue` resolves that same way.\n scan(syntax.logic, \"data-logic-merge-tag\", (value) =>\n getLogicMergeTagKeyword(value, syntax),\n );\n scan(syntax.value, \"data-merge-tag\", (value) =>\n getMergeTagLabel(value, mergeTags),\n );\n\n return hits.sort((a, b) => a.start - b.start);\n}\n\n/** Text nodes not already inside a merge-tag span, in document order. */\nfunction collectNormalizableTextNodes(doc: Document): Text[] {\n const walker = doc.createTreeWalker(\n doc.body,\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,\n {\n acceptNode(node: Node): number {\n if (node.nodeType !== 1) return NodeFilter.FILTER_ACCEPT;\n const el = node as Element;\n // REJECT (not SKIP) prunes the subtree, which is what makes a second\n // pass unable to see an existing span's inner text.\n return el.hasAttribute(\"data-merge-tag\") ||\n el.hasAttribute(\"data-logic-merge-tag\")\n ? NodeFilter.FILTER_REJECT\n : NodeFilter.FILTER_SKIP;\n },\n },\n );\n\n // Collected up front: replacing a node mid-walk invalidates the walker.\n const nodes: Text[] = [];\n let current = walker.nextNode();\n while (current !== null) {\n nodes.push(current as Text);\n current = walker.nextNode();\n }\n return nodes;\n}\n\nexport function normalizeMergeTagsInHtml(\n html: string,\n mergeTags: MergeTag[],\n syntax: SyntaxPreset,\n): string {\n if (!html) return html;\n // Cheap reject before paying for a parse. A token that exists only in an\n // attribute still gets past this, and is then caught by the zero-replacement\n // short-circuit below.\n if (!containsMergeTag(html, syntax)) return html;\n if (typeof DOMParser === \"undefined\") return html;\n\n const doc = new DOMParser().parseFromString(\n `<!doctype html><body>${html}</body>`,\n \"text/html\",\n );\n\n let replacements = 0;\n for (const node of collectNormalizableTextNodes(doc)) {\n const text = node.data;\n const hits = collectHits(text, mergeTags, syntax);\n if (hits.length === 0) continue;\n\n const fragment = doc.createDocumentFragment();\n let cursor = 0;\n for (const hit of hits) {\n if (hit.start > cursor) {\n fragment.appendChild(\n doc.createTextNode(text.substring(cursor, hit.start)),\n );\n }\n const span = doc.createElement(\"span\");\n span.setAttribute(hit.attr, hit.value);\n span.textContent = hit.label;\n fragment.appendChild(span);\n cursor = hit.end;\n }\n if (cursor < text.length) {\n fragment.appendChild(doc.createTextNode(text.substring(cursor)));\n }\n\n node.parentNode?.replaceChild(fragment, node);\n replacements += hits.length;\n }\n\n // Nothing matched in text position, so return the input verbatim rather than\n // a re-serialization of it — otherwise content with no tags at all would be\n // rewritten (`<br/>` → `<br>`, attribute quoting, entity encoding) for no\n // reason. Where a replacement does happen some churn is unavoidable, and the\n // renderer accepts both shapes.\n if (replacements === 0) return html;\n\n return doc.body.innerHTML;\n}\n\n/** Normalize localized rich content without changing source hashes or caller-owned objects. */\nfunction normalizeLocaleText<T extends LocalizedText | null>(\n blockType: string | undefined,\n text: Record<string, T> | undefined,\n mergeTags: MergeTag[],\n syntax: SyntaxPreset,\n): Record<string, T> | undefined {\n if (\n (blockType !== \"title\" &&\n blockType !== \"paragraph\" &&\n blockType !== \"html\") ||\n typeof text?.content?.value !== \"string\"\n )\n return text;\n const entry = text.content;\n const value = normalizeMergeTagsInHtml(entry.value, mergeTags, syntax);\n return value === entry.value\n ? text\n : { ...text, content: { ...entry, value } };\n}\n\n/**\n * Localized layers normalize only content on titles, paragraphs and HTML\n * blocks. Among base fields, only title and paragraph rich text is normalized. Every other merge-tag-bearing field —\n * `ButtonBlock.text`/`url`, `ImageBlock.alt`, `HtmlBlock.content`, custom-block\n * `fieldValues`, `settings.preheaderText` — is a plain string rendered as text,\n * so a span written into one would be displayed literally on the canvas and\n * emitted into a `url=` attribute by the renderer.\n *\n * `TableCellData.content` is span-bearing to the renderer but is deliberately\n * excluded: `TableBlock.vue` hydrates a cell with `textContent` and writes\n * `innerText` back on blur, so the first focus-and-leave on a normalized cell\n * would persist the literal markup into stored content as text. The\n * editor/renderer asymmetry there is a separate, pre-existing gap.\n */\nfunction normalizeBlock(\n block: Block,\n mergeTags: MergeTag[],\n syntax: SyntaxPreset,\n): Block {\n const l10n = block.l10n;\n if (l10n) {\n let changed = false;\n const next = Object.fromEntries(\n Object.entries(l10n).map(([locale, layer]) => {\n const text = normalizeLocaleText(\n block.type,\n layer.text,\n mergeTags,\n syntax,\n );\n if (text === layer.text) return [locale, layer];\n changed = true;\n return [locale, { ...layer, text }];\n }),\n );\n if (changed) block = { ...block, l10n: next };\n }\n if (block.type === \"section\") {\n if (!Array.isArray(block.children)) return block;\n let changed = false;\n const children = block.children.map((column) => {\n if (!Array.isArray(column)) return column;\n let columnChanged = false;\n const next = column.map((child) => {\n const normalized = normalizeBlock(child, mergeTags, syntax);\n if (normalized !== child) columnChanged = true;\n return normalized;\n });\n if (!columnChanged) return column;\n changed = true;\n return next;\n });\n return changed ? ({ ...block, children } as SectionBlock) : block;\n }\n\n if (block.type === \"wrapper\") {\n if (!Array.isArray(block.children)) return block;\n let changed = false;\n const children = block.children.map((child) => {\n const normalized = normalizeBlock(child, mergeTags, syntax);\n if (normalized !== child) changed = true;\n return normalized;\n });\n return changed ? ({ ...block, children } as WrapperBlock) : block;\n }\n\n if (block.type !== \"title\" && block.type !== \"paragraph\") return block;\n if (typeof block.content !== \"string\") return block;\n\n const content = normalizeMergeTagsInHtml(block.content, mergeTags, syntax);\n if (content === block.content) return block;\n const before = sourceHash(block.content);\n const after = sourceHash(content);\n const restamped =\n block.l10n &&\n Object.fromEntries(\n Object.entries(block.l10n).map(([locale, layer]) => {\n const entry = layer.text?.content;\n return [\n locale,\n entry?.sourceHash === before\n ? {\n ...layer,\n text: {\n ...layer.text,\n content: { ...entry, sourceHash: after },\n },\n }\n : layer,\n ];\n }),\n );\n return { ...block, content, ...(restamped ? { l10n: restamped } : {}) };\n}\n\n/**\n * Normalize every rich-text field in a template. Returns the input reference\n * unchanged when nothing matched, so a template with no bare tokens costs no\n * allocation and keeps its object identity; otherwise returns a copy, leaving\n * the caller's content untouched.\n *\n * Shape is checked rather than trusted at every level. `TemplateContent` types\n * `blocks` as required and `SectionBlock.children` as a `Block[][]`, but this\n * runs at the SDK's entry points on an object the consumer hands us — a partial\n * or hand-rolled template must come back untouched, not turn a working `init()`\n * into a `TypeError`.\n */\nexport function normalizeMergeTagMarkup(\n content: TemplateContent,\n mergeTags: MergeTag[],\n syntax: SyntaxPreset,\n): TemplateContent {\n if (!content || !Array.isArray(content.blocks)) return content;\n\n let changed = false;\n const blocks = content.blocks.map((block) => {\n const normalized = normalizeBlock(block, mergeTags, syntax);\n if (normalized !== block) changed = true;\n return normalized;\n });\n\n return changed ? { ...content, blocks } : content;\n}\n\n/**\n * `normalizeMergeTagMarkup` bound to the editor's own config shape, so the hook\n * sites don't each resolve tags and syntax themselves.\n *\n * An absent `mergeTags` still normalizes, under the liquid default. That is not\n * an oversight: `MergeTagNode`'s input and paste rules are registered\n * unconditionally with the same default, so a consumer who configured nothing\n * already gets a node the instant a user types `{{x}}`. Loading the same text\n * and leaving it inert would be the inconsistency.\n *\n * It always returns a copy. Every content-in path runs through here, and the\n * editor edits the object it holds in place, so holding the caller's own one\n * leaks each edit into it, and one that another Vue made reactive or that a\n * store froze hides edits from the editor's bundled Vue or throws on the first.\n */\nexport function normalizeContentForConfig(\n content: TemplateContent,\n mergeTags: MergeTagsConfig | undefined,\n): TemplateContent {\n return normalizeMergeTagMarkup(\n copyIncomingContent(content),\n mergeTags?.tags ?? [],\n resolveSyntax(mergeTags?.syntax),\n );\n}\n\n/** {@link normalizeContentForConfig} for a single block. */\nexport function normalizeBlockForConfig(\n block: Block,\n mergeTags: MergeTagsConfig | undefined,\n): Block {\n return normalizeBlock(\n block,\n mergeTags?.tags ?? [],\n resolveSyntax(mergeTags?.syntax),\n );\n}\n\n/**\n * A non-object passes through: `normalizeMergeTagMarkup` already hands back\n * whatever is not shaped like content, and `safeClone(undefined)` would throw.\n */\nfunction copyIncomingContent(content: TemplateContent): TemplateContent {\n return typeof content === \"object\" && content !== null\n ? safeClone(content)\n : content;\n}\n\n/**\n * Wrap a `TemplatesProvider` so content arriving from the store is normalized\n * before the editor ever sees it.\n *\n * Only `load` is wrapped. `save` sends content *out*, and what it sends is\n * already-normalized editor state; rewriting it here would change what the\n * store keeps for no benefit. `create` likewise carries content outward, and\n * the template it returns supplies identity and timestamps rather than the\n * content the editor goes on to edit.\n *\n * Wrapping the provider — rather than normalizing after `load()` resolves —\n * is what keeps Q4 true: core assigns already-normalized content to its state\n * and observes no mutation, so there is no dirty flag to suppress and no\n * autosave tick to swallow.\n */\n/**\n * The slice of the editor a content-restoring feature consumes. Structural on\n * purpose: it matches `useVersionHistoryFeature`'s own `VersionHistoryEditor`\n * without importing it, so this util keeps no dependency on a composable.\n */\ninterface ContentWritingEditor {\n state: {\n readonly template?: { id: string } | null;\n readonly isDirty: boolean;\n };\n content: Ref<TemplateContent>;\n setContent: (content: TemplateContent, markDirty?: boolean) => void;\n}\n\n/**\n * Wrap an editor so content written through `setContent` is normalized first.\n *\n * This is how version history is covered. Its content reaches the canvas by\n * three routes — `version.content` off a hydrated list, a `fetched` cache, and\n * `provider.get()` — so wrapping the *provider*, the way the `templates` path\n * does, would miss two of them. `setContent` is the one chokepoint they share.\n *\n * A version is not guaranteed to hold normalized content just because a save\n * produced it: a store carries whatever was written to it, and a backend may\n * version a template it imported rather than one the editor round-tripped.\n * Previewing such a version without this would put bare tokens back on a canvas\n * where every other tag is a chip.\n *\n * `markDirty` is forwarded untouched: every version-history write passes\n * `false`, and swallowing that would turn opening a preview into an unsaved\n * change. `setContent` is resolved per call rather than captured, so a\n * wrapper installed on the editor later still sees every write.\n */\nexport function withNormalizedContentWrites<T extends ContentWritingEditor>(\n editor: T,\n mergeTags: MergeTagsConfig | undefined,\n): ContentWritingEditor {\n return {\n get state() {\n return editor.state;\n },\n get content() {\n return editor.content;\n },\n setContent: (content: TemplateContent, markDirty?: boolean) =>\n editor.setContent(\n normalizeContentForConfig(content, mergeTags),\n markDirty,\n ),\n };\n}\n\nexport function withNormalizedTemplateLoads(\n provider: TemplatesProvider,\n mergeTags: MergeTagsConfig | undefined,\n): TemplatesProvider {\n return {\n ...provider,\n async load(id: string) {\n const template = await provider.load(id);\n return {\n ...template,\n content: normalizeContentForConfig(template.content, mergeTags),\n };\n },\n };\n}\n\n/**\n * The type of the block `id` names — at the top level, in a section's columns\n * or inside a wrapper — or `undefined` when no block has that id.\n */\nfunction blockTypeOf(blocks: unknown, id: string): string | undefined {\n if (!Array.isArray(blocks)) return undefined;\n for (const block of blocks as Block[]) {\n if (!block || typeof block !== \"object\") continue;\n if (block.id === id) return block.type;\n const children = (block as { children?: unknown }).children;\n if (block.type === \"section\" && Array.isArray(children)) {\n for (const column of children) {\n const found = blockTypeOf(column, id);\n if (found) return found;\n }\n } else if (block.type === \"wrapper\") {\n const found = blockTypeOf(children, id);\n if (found) return found;\n }\n }\n return undefined;\n}\n\n/** Every block id in `block`, a section's or a wrapper's children included, with its type. */\nfunction collectBlockTypes(block: Block, into: Map<string, string>): void {\n if (typeof block.id === \"string\") into.set(block.id, block.type);\n const children = (block as { children?: unknown }).children;\n if (!Array.isArray(children)) return;\n const nested =\n block.type === \"section\" ? (children as unknown[]).flat() : children;\n for (const child of nested) {\n if (child && typeof child === \"object\") {\n collectBlockTypes(child as Block, into);\n }\n }\n}\n\n/**\n * Normalize the merge tags in a batch another session made, before the editor\n * applies it — the collaboration counterpart of {@link withNormalizedTemplateLoads}.\n * An agent writes `{{first_name}}` as text and a headless write stores it bare;\n * both arrive as operations, and normalizing them on arrival turns each token\n * into a tag at once. Nothing is sent back for it: the canvas and the\n * controller's copy of the backend's content change together.\n *\n * The rich-text fields only, as for loads: an `addBlock`'s block (a section's\n * children included), an `updateBlock`'s `set.content` when the block it names\n * is a title or a paragraph, its `expect.content`, and a deletion’s `expect.block` — found in `content`, or among the blocks the batch\n * itself added — and a `setContent`'s content. Returns `ops` itself when\n * nothing matched, and never changes it.\n */\nexport function normalizeRemoteOperations(\n ops: readonly Operation[],\n content: TemplateContent,\n mergeTags: MergeTagsConfig | undefined,\n): Operation[] {\n const tags = mergeTags?.tags ?? [];\n const syntax = resolveSyntax(mergeTags?.syntax);\n const added = new Map<string, string>();\n // Markup-only normalization also supports partial input and layout wrappers.\n // Locale hashes require engine-valid, evolving simulation states.\n const needsLocaleState = ops.some((op) => op.op === \"updateBlockLocale\");\n let original = safeClone(content);\n let normalizedState = safeClone(content);\n const advance = (\n state: TemplateContent,\n op: Operation,\n index: number,\n ): TemplateContent => {\n try {\n if (!(\"expect\" in op)) return applyOperations(state, [op]);\n // The backend already checked guards against its raw representation.\n const { expect: _expect, ...unguarded } = op;\n return applyOperations(state, [unguarded as Operation]);\n } catch (error) {\n if (!(error instanceof OperationError)) throw error;\n throw new OperationError(error.code, index, error.message, error.blockId);\n }\n };\n const blockIn = (state: TemplateContent, id: string): Block | undefined => {\n const find = (blocks: unknown): Block | undefined => {\n if (!Array.isArray(blocks)) return undefined;\n for (const block of blocks) {\n if (!block || typeof block !== \"object\") continue;\n if (block.id === id) return block;\n const children = block.children;\n const found = find(\n block.type === \"section\" && Array.isArray(children)\n ? children.flat()\n : children,\n );\n if (found) return found;\n }\n };\n return find(state?.blocks);\n };\n const restamp = <T extends LocalizedText | null>(\n entries: Record<string, T> | undefined,\n before: Block | undefined,\n after: Block | undefined,\n locale?: string,\n ): Record<string, T> | undefined => {\n if (!entries) return entries;\n let result = entries;\n for (const [path, entry] of Object.entries(entries)) {\n if (!entry) continue;\n const oldEntry = locale\n ? before?.l10n?.[locale]?.text?.[path]\n : undefined;\n const newEntry = locale ? after?.l10n?.[locale]?.text?.[path] : undefined;\n const oldBase = readPath(before, path);\n const newBase = readPath(after, path);\n const hash =\n oldEntry && newEntry && deepEqual(entry, oldEntry)\n ? newEntry.sourceHash\n : typeof oldBase === \"string\" &&\n typeof newBase === \"string\" &&\n entry.sourceHash === sourceHash(oldBase)\n ? sourceHash(newBase)\n : entry.sourceHash;\n if (hash !== entry.sourceHash)\n result = { ...result, [path]: { ...entry, sourceHash: hash } };\n }\n return result;\n };\n let changed = false;\n\n const normalizeOne = (op: Operation): Operation => {\n if (op.op === \"addBlock\") {\n if (!op.block || typeof op.block !== \"object\") return op;\n collectBlockTypes(op.block, added);\n const block = normalizeBlock(op.block, tags, syntax);\n if (block === op.block) return op;\n changed = true;\n return { ...op, block };\n }\n if (op.op === \"deleteBlock\" && op.expect?.block) {\n const block = normalizeBlock(op.expect.block, tags, syntax);\n if (block === op.expect.block) return op;\n changed = true;\n return { ...op, expect: { ...op.expect, block } };\n }\n if (op.op === \"updateBlockLocale\") {\n const type =\n added.get(op.blockId) ?? blockTypeOf(original?.blocks, op.blockId);\n const before = blockIn(original, op.blockId);\n const after = blockIn(normalizedState, op.blockId);\n const text = normalizeLocaleText(\n type,\n restamp(op.text, before, after),\n tags,\n syntax,\n );\n const expectText = normalizeLocaleText(\n type,\n restamp(op.expect?.text, before, after, op.locale),\n tags,\n syntax,\n );\n const expect =\n op.expect && expectText !== op.expect.text\n ? { ...op.expect, text: expectText }\n : op.expect;\n if (text === op.text && expect === op.expect) return op;\n changed = true;\n return {\n ...op,\n ...(text ? { text } : {}),\n ...(expect ? { expect } : {}),\n };\n }\n if (op.op === \"updateBlock\") {\n const type =\n added.get(op.blockId) ?? blockTypeOf(original?.blocks, op.blockId);\n if (type !== \"title\" && type !== \"paragraph\") return op;\n const normalizeField = (fields: Record<string, unknown> | undefined) => {\n if (typeof fields?.content !== \"string\") return fields;\n const normalized = normalizeMergeTagsInHtml(\n fields.content,\n tags,\n syntax,\n );\n return normalized === fields.content\n ? fields\n : { ...fields, content: normalized };\n };\n const set = normalizeField(op.set);\n const expect = normalizeField(op.expect);\n if (set === op.set && expect === op.expect) return op;\n changed = true;\n return { ...op, ...(set ? { set } : {}), ...(expect ? { expect } : {}) };\n }\n if (op.op === \"setContent\") {\n added.clear();\n const normalized = normalizeMergeTagMarkup(op.content, tags, syntax);\n if (normalized === op.content) return op;\n changed = true;\n return { ...op, content: normalized };\n }\n return op;\n };\n const next = ops.map((op, index) => {\n const normalized = normalizeOne(op);\n if (needsLocaleState) {\n // Fail before returning any batch if either state cannot advance. The\n // collaboration caller reports the error and applies its existing fallback.\n const nextOriginal = advance(original, op, index);\n const nextNormalized = advance(normalizedState, normalized, index);\n original = nextOriginal;\n normalizedState = nextNormalized;\n } else if (op.op === \"setContent\") {\n // Keep type lookup current without imposing engine validation on the\n // existing markup-only path. Added blocks are tracked in `added`.\n original = op.content;\n }\n return normalized;\n });\n\n return changed ? next : (ops as Operation[]);\n}\n"],"mappings":";;AA8EA,SAASU,EAAY,GAAyB;CAC5C,IAAMC,IAAQC,EAAQ,MAAM,SAAS,GAAG,IACpCA,EAAQ,QACR,GAAGA,EAAQ,MAAM;CACrB,OAAO,IAAI,OAAOA,EAAQ,QAAQD,CAAK;AACzC;AAEA,SAASE,EACP,GACA,GACA,GACU;CACV,IAAMC,IAAiB,CAAC,GAElBC,KACJ,GACA,GACA,MACS;EACT,IAAMC,IAAQN,EAAYE,CAAO,GAC7BK,IAAQD,EAAM,KAAKE,CAAI;EAC3B,OAAOD,MAAU,OAAM;GACrB,IAAME,IAAQF,EAAM,OACdG,IAAMD,IAAQF,EAAM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,IAAIF,GAAkB;GAGpB,IAAM6B,IAAexB,EAAQF,GAAUD,GAAIQ,CAAK,GAC1CoB,IAAiBzB,EAAQD,GAAiB9B,GAAYoC,CAAK;GAEjE,AADA,IAAWmB,GACX,IAAkBC;EACpB,OAAO,AAAI5B,EAAG,OAAO,iBAGnB,IAAWA,EAAG;EAEhB,OAAO5B;CACT,CAAC;CAED,OAAOP,IAAUC,IAAQiC;AAC3B"}
@@ -1,8 +1,8 @@
1
- import { Dt as e, bt as t, mt as n } from "./src-CACM3o--.js";
1
+ import { Ot as e, ht as t, xt as n } from "./src-BQUv2CYU.js";
2
2
  // src/utils/preRenderCustomBlocks.ts
3
3
  async function r(r, i) {
4
4
  let a = async (r) => {
5
- if (n(r)) {
5
+ if (t(r)) {
6
6
  let e = r;
7
7
  try {
8
8
  e.renderedHtml = await i.renderCustomBlock(e);
@@ -12,11 +12,11 @@ async function r(r, i) {
12
12
  let t = i.getCustomBlockStylesheet(e.customType);
13
13
  t?.trim() ? e.renderedStylesheet = t : delete e.renderedStylesheet;
14
14
  }
15
- if (t(r)) for (let e of r.children) for (let t of e) await a(t);
15
+ if (n(r)) for (let e of r.children) for (let t of e) await a(t);
16
16
  else if (e(r)) for (let e of r.children) await a(e);
17
17
  };
18
18
  for (let e of r.blocks) await a(e);
19
19
  }
20
20
  export { r as t };
21
21
 
22
- //# sourceMappingURL=preRenderCustomBlocks-C8k7tw98.js.map
22
+ //# sourceMappingURL=preRenderCustomBlocks-f7GEKdvw.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preRenderCustomBlocks-C8k7tw98.js","names":["isWrapper","isSection","isCustomBlock","preRenderCustomBlocks","renderBlock","block","customBlock","registry","stylesheet","column","child","content"],"sources":["../../../src/utils/preRenderCustomBlocks.ts"],"sourcesContent":["import type { Block, CustomBlock, TemplateContent } from \"@templatical/types\";\nimport { isCustomBlock, isSection, isWrapper } from \"@templatical/types\";\n\n/**\n * The only things this needs from the block registry. Named as a slice rather\n * than taking `UseBlockRegistryReturn` so the render-payload builder can supply\n * the editor instance's own methods without reaching for the registry.\n */\nexport interface CustomBlockResolver {\n renderCustomBlock: (block: CustomBlock) => Promise<string>;\n getCustomBlockStylesheet: (customType: string) => string | undefined;\n}\n\n/**\n * Renders every custom block in the content tree to its HTML representation\n * and stores the result on `block.renderedHtml`, with the definition's\n * stylesheet on `block.renderedStylesheet`.\n *\n * **A contract obligation of every render, not a save-path detail.** A renderer\n * handed a custom block with neither a resolver nor `renderedHtml` omits it from\n * the output silently, and a backend has no way to resolve one: the HTML comes\n * from the consumer's liquid template plus the block's field values, and the\n * definition is registered in the browser. So this runs before a\n * `RenderProvider` sees the content, and before Cloud persists it.\n *\n * Failures per-block are swallowed (and replaced with a comment placeholder)\n * so one broken block doesn't block the save of the rest.\n */\nexport async function preRenderCustomBlocks(\n content: TemplateContent,\n registry: CustomBlockResolver,\n): Promise<void> {\n const renderBlock = async (block: Block): Promise<void> => {\n if (isCustomBlock(block)) {\n const customBlock = block as CustomBlock;\n try {\n customBlock.renderedHtml =\n await registry.renderCustomBlock(customBlock);\n } catch {\n customBlock.renderedHtml = `<!-- Custom block render error: ${customBlock.customType} -->`;\n }\n // Removed when the definition has none, so a copy written before its\n // stylesheet was deleted doesn't outlive it.\n const stylesheet = registry.getCustomBlockStylesheet(\n customBlock.customType,\n );\n if (stylesheet?.trim()) customBlock.renderedStylesheet = stylesheet;\n else delete customBlock.renderedStylesheet;\n }\n\n if (isSection(block)) {\n for (const column of block.children) {\n for (const child of column) {\n await renderBlock(child);\n }\n }\n } else if (isWrapper(block)) {\n for (const child of block.children) {\n await renderBlock(child);\n }\n }\n };\n\n for (const block of content.blocks) {\n await renderBlock(block);\n }\n}\n"],"mappings":";;AA4BA,eAAsBG,EACpB,GACA,GACe;CACf,IAAMC,IAAc,OAAO,MAAgC;EACzD,IAAIF,EAAcG,CAAK,GAAG;GACxB,IAAMC,IAAcD;GACpB,IAAI;IACF,EAAY,eACV,MAAME,EAAS,kBAAkBD,CAAW;GAChD,QAAQ;IACN,EAAY,eAAe,mCAAmCA,EAAY,WAAW;GACvF;GAGA,IAAME,IAAaD,EAAS,yBAC1BD,EAAY,UACd;GACA,AAAIE,GAAY,KAAK,IAAG,EAAY,qBAAqBA,IACpD,OAAOF,EAAY;EAC1B;EAEA,IAAIL,EAAUI,CAAK,GACjB,KAAK,IAAMI,KAAUJ,EAAM,UACzB,KAAK,IAAMK,KAASD,GAClB,MAAML,EAAYM,CAAK;OAGtB,IAAIV,EAAUK,CAAK,GACxB,KAAK,IAAMK,KAASL,EAAM,UACxB,MAAMD,EAAYM,CAAK;CAG7B;CAEA,KAAK,IAAML,KAASM,EAAQ,QAC1B,MAAMP,EAAYC,CAAK;AAE3B"}
1
+ {"version":3,"file":"preRenderCustomBlocks-f7GEKdvw.js","names":["isWrapper","isCustomBlock","isSection","preRenderCustomBlocks","renderBlock","block","customBlock","registry","stylesheet","column","child","content"],"sources":["../../../src/utils/preRenderCustomBlocks.ts"],"sourcesContent":["import type { Block, CustomBlock, TemplateContent } from \"@templatical/types\";\nimport { isCustomBlock, isSection, isWrapper } from \"@templatical/types\";\n\n/**\n * The only things this needs from the block registry. Named as a slice rather\n * than taking `UseBlockRegistryReturn` so the render-payload builder can supply\n * the editor instance's own methods without reaching for the registry.\n */\nexport interface CustomBlockResolver {\n renderCustomBlock: (block: CustomBlock) => Promise<string>;\n getCustomBlockStylesheet: (customType: string) => string | undefined;\n}\n\n/**\n * Renders every custom block in the content tree to its HTML representation\n * and stores the result on `block.renderedHtml`, with the definition's\n * stylesheet on `block.renderedStylesheet`.\n *\n * **A contract obligation of every render, not a save-path detail.** A renderer\n * handed a custom block with neither a resolver nor `renderedHtml` omits it from\n * the output silently, and a backend has no way to resolve one: the HTML comes\n * from the consumer's liquid template plus the block's field values, and the\n * definition is registered in the browser. So this runs before a\n * `RenderProvider` sees the content, and before Cloud persists it.\n *\n * Failures per-block are swallowed (and replaced with a comment placeholder)\n * so one broken block doesn't block the save of the rest.\n */\nexport async function preRenderCustomBlocks(\n content: TemplateContent,\n registry: CustomBlockResolver,\n): Promise<void> {\n const renderBlock = async (block: Block): Promise<void> => {\n if (isCustomBlock(block)) {\n const customBlock = block as CustomBlock;\n try {\n customBlock.renderedHtml =\n await registry.renderCustomBlock(customBlock);\n } catch {\n customBlock.renderedHtml = `<!-- Custom block render error: ${customBlock.customType} -->`;\n }\n // Removed when the definition has none, so a copy written before its\n // stylesheet was deleted doesn't outlive it.\n const stylesheet = registry.getCustomBlockStylesheet(\n customBlock.customType,\n );\n if (stylesheet?.trim()) customBlock.renderedStylesheet = stylesheet;\n else delete customBlock.renderedStylesheet;\n }\n\n if (isSection(block)) {\n for (const column of block.children) {\n for (const child of column) {\n await renderBlock(child);\n }\n }\n } else if (isWrapper(block)) {\n for (const child of block.children) {\n await renderBlock(child);\n }\n }\n };\n\n for (const block of content.blocks) {\n await renderBlock(block);\n }\n}\n"],"mappings":";;AA4BA,eAAsBG,EACpB,GACA,GACe;CACf,IAAMC,IAAc,OAAO,MAAgC;EACzD,IAAIH,EAAcI,CAAK,GAAG;GACxB,IAAMC,IAAcD;GACpB,IAAI;IACF,EAAY,eACV,MAAME,EAAS,kBAAkBD,CAAW;GAChD,QAAQ;IACN,EAAY,eAAe,mCAAmCA,EAAY,WAAW;GACvF;GAGA,IAAME,IAAaD,EAAS,yBAC1BD,EAAY,UACd;GACA,AAAIE,GAAY,KAAK,IAAG,EAAY,qBAAqBA,IACpD,OAAOF,EAAY;EAC1B;EAEA,IAAIJ,EAAUG,CAAK,GACjB,KAAK,IAAMI,KAAUJ,EAAM,UACzB,KAAK,IAAMK,KAASD,GAClB,MAAML,EAAYM,CAAK;OAGtB,IAAIV,EAAUK,CAAK,GACxB,KAAK,IAAMK,KAASL,EAAM,UACxB,MAAMD,EAAYM,CAAK;CAG7B;CAEA,KAAK,IAAML,KAASM,EAAQ,QAC1B,MAAMP,EAAYC,CAAK;AAE3B"}
@@ -1,4 +1,4 @@
1
- import { C as e, D as t, T as n, w as r } from "./src-CACM3o--.js";
1
+ import { C as e, D as t, T as n, w as r } from "./src-BQUv2CYU.js";
2
2
  import { t as i } from "./dompurify-JVtr5-B1.js";
3
3
  // src/utils/sanitizeHtml.ts
4
4
  var a = new Set(r), o = [...e], s = RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))`, "i"), c = [
@@ -58,4 +58,4 @@ function p(e) {
58
58
  }
59
59
  export { p as n, f as t };
60
60
 
61
- //# sourceMappingURL=sanitizeHtml-DYklmvgX.js.map
61
+ //# sourceMappingURL=sanitizeHtml-WTfz9lZd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizeHtml-DYklmvgX.js","names":["DOMPurify","HTML_FORBIDDEN_ATTRIBUTES","isSafeHtmlUrl","SAFE_LINK_SCHEMES","HTML_URL_ATTRIBUTES","purify_default","URL_ATTRIBUTES","FORBID_ATTRIBUTES","ALLOWED_URI_REGEXP","FORBID_TAGS","HTML_CONFIG","SVG_CONFIG","name","data","node","escapeHtmlText","value","sanitizeHtml","html","sanitizeSvg","svg"],"sources":["../../../src/utils/sanitizeHtml.ts"],"sourcesContent":["import DOMPurify from \"dompurify\";\nimport {\n SAFE_LINK_SCHEMES,\n HTML_URL_ATTRIBUTES,\n HTML_FORBIDDEN_ATTRIBUTES,\n isSafeHtmlUrl,\n} from \"@templatical/types\";\n\nconst URL_ATTRIBUTES = new Set<string>(HTML_URL_ATTRIBUTES);\nconst FORBID_ATTRIBUTES = [...HTML_FORBIDDEN_ATTRIBUTES];\n\n// DOMPurify applies this to URL-bearing attributes beyond our explicit hook.\n// Build the scheme portion from the shared policy. The suffix accepts relative\n// URLs and fragments, as DOMPurify's default URI expression does.\nconst ALLOWED_URI_REGEXP = new RegExp(\n `^(?:(?:${SAFE_LINK_SCHEMES.join(\"|\")}):|[^a-z]|[a-z+.\\\\-]+(?:[^a-z+.\\\\-:]|$))`,\n \"i\",\n);\n\nconst FORBID_TAGS = [\n \"style\",\n \"form\",\n \"iframe\",\n \"object\",\n \"embed\",\n \"link\",\n \"meta\",\n \"base\",\n \"noscript\",\n \"template\",\n \"script\",\n];\n\nconst HTML_CONFIG = {\n FORBID_TAGS,\n ADD_FORBID_CONTENTS: FORBID_TAGS,\n FORBID_ATTR: FORBID_ATTRIBUTES,\n ALLOWED_URI_REGEXP,\n ADD_ATTR: [\"target\"],\n};\n\nconst SVG_CONFIG = {\n USE_PROFILES: { svg: true, svgFilters: true },\n FORBID_TAGS: [\n \"script\",\n \"foreignObject\",\n \"animate\",\n \"set\",\n \"animateMotion\",\n \"animateTransform\",\n ],\n ADD_FORBID_CONTENTS: [\n \"script\",\n \"foreignObject\",\n \"animate\",\n \"set\",\n \"animateMotion\",\n \"animateTransform\",\n ],\n FORBID_ATTR: FORBID_ATTRIBUTES,\n ALLOWED_URI_REGEXP,\n};\n\nif (DOMPurify.isSupported) {\n DOMPurify.addHook(\"uponSanitizeAttribute\", (node, data) => {\n const name = data.attrName.toLowerCase();\n if (name === \"contenteditable\") {\n if (node.getAttribute(data.attrName) === \"false\") {\n data.forceKeepAttr = true;\n } else {\n data.keepAttr = false;\n }\n } else if (name.startsWith(\"on\") || name === \"srcdoc\") {\n data.keepAttr = false;\n } else if (\n URL_ATTRIBUTES.has(name) &&\n !isSafeHtmlUrl(data.attrValue, name)\n ) {\n data.keepAttr = false;\n }\n });\n}\n\nfunction escapeHtmlText(value: string): string {\n return value\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#39;\");\n}\n\n/** Sanitize a rich-text fragment before inserting it into a live canvas. */\nexport function sanitizeHtml(html: string): string {\n if (!DOMPurify.isSupported) return escapeHtmlText(html);\n return DOMPurify.sanitize(html, HTML_CONFIG);\n}\n\n/** Sanitize an integrator-supplied inline SVG icon. */\nexport function sanitizeSvg(svg: string): string {\n if (!DOMPurify.isSupported) return escapeHtmlText(svg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IADNI,EAAeK,CAAG;AAEvD"}
1
+ {"version":3,"file":"sanitizeHtml-WTfz9lZd.js","names":["DOMPurify","HTML_FORBIDDEN_ATTRIBUTES","isSafeHtmlUrl","SAFE_LINK_SCHEMES","HTML_URL_ATTRIBUTES","purify_default","URL_ATTRIBUTES","FORBID_ATTRIBUTES","ALLOWED_URI_REGEXP","FORBID_TAGS","HTML_CONFIG","SVG_CONFIG","name","data","node","escapeHtmlText","value","sanitizeHtml","html","sanitizeSvg","svg"],"sources":["../../../src/utils/sanitizeHtml.ts"],"sourcesContent":["import DOMPurify from \"dompurify\";\nimport {\n SAFE_LINK_SCHEMES,\n HTML_URL_ATTRIBUTES,\n HTML_FORBIDDEN_ATTRIBUTES,\n isSafeHtmlUrl,\n} from \"@templatical/types\";\n\nconst URL_ATTRIBUTES = new Set<string>(HTML_URL_ATTRIBUTES);\nconst FORBID_ATTRIBUTES = [...HTML_FORBIDDEN_ATTRIBUTES];\n\n// DOMPurify applies this to URL-bearing attributes beyond our explicit hook.\n// Build the scheme portion from the shared policy. The suffix accepts relative\n// URLs and fragments, as DOMPurify's default URI expression does.\nconst ALLOWED_URI_REGEXP = new RegExp(\n `^(?:(?:${SAFE_LINK_SCHEMES.join(\"|\")}):|[^a-z]|[a-z+.\\\\-]+(?:[^a-z+.\\\\-:]|$))`,\n \"i\",\n);\n\nconst FORBID_TAGS = [\n \"style\",\n \"form\",\n \"iframe\",\n \"object\",\n \"embed\",\n \"link\",\n \"meta\",\n \"base\",\n \"noscript\",\n \"template\",\n \"script\",\n];\n\nconst HTML_CONFIG = {\n FORBID_TAGS,\n ADD_FORBID_CONTENTS: FORBID_TAGS,\n FORBID_ATTR: FORBID_ATTRIBUTES,\n ALLOWED_URI_REGEXP,\n ADD_ATTR: [\"target\"],\n};\n\nconst SVG_CONFIG = {\n USE_PROFILES: { svg: true, svgFilters: true },\n FORBID_TAGS: [\n \"script\",\n \"foreignObject\",\n \"animate\",\n \"set\",\n \"animateMotion\",\n \"animateTransform\",\n ],\n ADD_FORBID_CONTENTS: [\n \"script\",\n \"foreignObject\",\n \"animate\",\n \"set\",\n \"animateMotion\",\n \"animateTransform\",\n ],\n FORBID_ATTR: FORBID_ATTRIBUTES,\n ALLOWED_URI_REGEXP,\n};\n\nif (DOMPurify.isSupported) {\n DOMPurify.addHook(\"uponSanitizeAttribute\", (node, data) => {\n const name = data.attrName.toLowerCase();\n if (name === \"contenteditable\") {\n if (node.getAttribute(data.attrName) === \"false\") {\n data.forceKeepAttr = true;\n } else {\n data.keepAttr = false;\n }\n } else if (name.startsWith(\"on\") || name === \"srcdoc\") {\n data.keepAttr = false;\n } else if (\n URL_ATTRIBUTES.has(name) &&\n !isSafeHtmlUrl(data.attrValue, name)\n ) {\n data.keepAttr = false;\n }\n });\n}\n\nfunction escapeHtmlText(value: string): string {\n return value\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#39;\");\n}\n\n/** Sanitize a rich-text fragment before inserting it into a live canvas. */\nexport function sanitizeHtml(html: string): string {\n if (!DOMPurify.isSupported) return escapeHtmlText(html);\n return DOMPurify.sanitize(html, HTML_CONFIG);\n}\n\n/** Sanitize an integrator-supplied inline SVG icon. */\nexport function sanitizeSvg(svg: string): string {\n if (!DOMPurify.isSupported) return escapeHtmlText(svg);\n return DOMPurify.sanitize(svg, SVG_CONFIG);\n}\n"],"mappings":";;;AAQA,IAAMM,IAAiB,IAAI,IAAYF,CAAmB,GACpDG,IAAoB,CAAC,GAAGN,CAAyB,GAKjDO,IAAyB,OAC7B,UAAUL,EAAkB,KAAK,GAAG,EAAE,2CACtC,GACF,GAEMM,IAAc;CAClB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEMC,IAAc;CAClB;CACA,qBAAqBD;CACrB,aAAaF;CACb;CACA,UAAU,CAAC,QAAQ;AACrB,GAEMI,IAAa;CACjB,cAA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