@templatical/editor 0.52.1 → 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.
- package/README.md +1 -1
- package/dist/AiAltTextPopover-NMJqQKvD.js +106 -0
- package/dist/{AiAltTextReview-9ySsXOTU.js → AiAltTextReview-Ci4zHwRc.js} +68 -66
- package/dist/AiChatPanel-C8SeEJRP.js +561 -0
- package/dist/{AiPanels-DqT4PgQ0.js → AiPanels-CR6zphjP.js} +6 -6
- package/dist/{AiRewriteMenu-28agTycW.js → AiRewriteMenu-CIHUnPud.js} +76 -105
- package/dist/BlockIssueBadge-DaPTq1RE.js +33 -0
- package/dist/BlockPreviewCanvas-B70RSavL.js +140 -0
- package/dist/{CloudHeaderExtras-QI82yF54.js → CloudHeaderExtras-XpjJjn3o.js} +4 -4
- package/dist/{CloudPanels-BKJaLkUN.js → CloudPanels-VpSQiLLL.js} +53 -53
- package/dist/CollaborationNotices-Cnx0XHzZ.js +65 -0
- package/dist/{CollaboratorBar-CXQqN3VP.js → CollaboratorBar-BaBoNhwB.js} +24 -24
- package/dist/CommentsPanel-Ck3QmqiC.js +16 -0
- package/dist/CommentsSidebar-CHknhOar.js +526 -0
- package/dist/{CountdownBlock-CU2yTWtF.js → CountdownBlock-BMezkFbJ.js} +15 -15
- package/dist/CountdownToolbar-CM4XNEuO.js +258 -0
- package/dist/IssuesPanel-1wGV0wiy.js +371 -0
- package/dist/LanguageMenu-d2GlX67r.js +403 -0
- package/dist/{LoadingTrack-DM4g6j7b.js → LoadingTrack-BG8cg9xi.js} +2 -2
- package/dist/LocaleNotices-WzsYtBRs.js +46 -0
- package/dist/LogicTagInsertButton-DgTJ6Lvx.js +1096 -0
- package/dist/{MediaEditModal-Dy08GEwE.js → MediaEditModal-C3U9Mi31.js} +451 -451
- package/dist/{MediaPanels-BgEp7iCp.js → MediaPanels-CGmk9ufe.js} +4 -4
- package/dist/{MergeTagInput-B9dtUthD.js → MergeTagInput-B_51YcQO.js} +30 -30
- package/dist/{MergeTagModeToggle-DxujhYJ4.js → MergeTagModeToggle-D3Q2z317.js} +49 -49
- package/dist/MergeTagTextarea-DZz1L9DE.js +126 -0
- package/dist/ParagraphEditor-CI68PYDL.js +825 -0
- package/dist/{RestoreVersionDialog-C4s_JYCx.js → RestoreVersionDialog-DcuhpOIz.js} +23 -23
- package/dist/{RichTextEditorContent-o6HmE8GR.js → RichTextEditorContent-Dstovi0m.js} +47 -47
- package/dist/{SaveBlockDialog-CWLrly6l.js → SaveBlockDialog-vuwvoi-d.js} +86 -86
- package/dist/{cdn/chunks/SavedBlocksBrowserModal-BPYcRoGa.js → SavedBlocksBrowserModal-DUJm0dOv.js} +135 -132
- package/dist/{SavedBlocksPanels-BE1N9rNZ.js → SavedBlocksPanels-BiMXQ5lY.js} +9 -9
- package/dist/{SavedBlocksPickBar-Dwl94xhP.js → SavedBlocksPickBar-CAstZfG7.js} +15 -15
- package/dist/TemplateSettings-Baar78_s.js +294 -0
- package/dist/TestEmailModal-Bl_GHdrN.js +212 -0
- package/dist/{TestEmailPanel-DaFjP9QK.js → TestEmailPanel-CpTBF7B5.js} +4 -4
- package/dist/TitleEditor-DkbEDAZB.js +202 -0
- package/dist/ToggleSwitch-R3wCCYE6.js +43 -0
- package/dist/Toolbar-bOZ_eq7X.js +3711 -0
- package/dist/{TplModal-DLMssVlt.js → TplModal-wk2gLa7_.js} +17 -17
- package/dist/{VersionHistoryMenu-BkbYUs0Q.js → VersionHistoryMenu-BnP0EyLl.js} +39 -39
- package/dist/{VersionHistoryPanels-DP7HaYWv.js → VersionHistoryPanels-Cq2rFKIX.js} +5 -5
- package/dist/VersionPreviewBanner-BPP939cD.js +37 -0
- package/dist/WrapperBlock-cWT_nZgQ.js +44 -0
- package/dist/{blockTypeIcons-BHjlPnPf.js → blockTypeIcons-BUyPZ7Su.js} +7 -7
- package/dist/bundle-stats.json +8 -8
- package/dist/{cdn/chunks/ca-CD-Kt1qz.js → ca-DOuIxWRv.js} +114 -2
- package/dist/cdn/chunks/AiAltTextPopover-Cnc_kUmb.js +107 -0
- package/dist/cdn/chunks/AiAltTextPopover-Cnc_kUmb.js.map +1 -0
- package/dist/cdn/chunks/{AiAltTextReview-BGLLSKLm.js → AiAltTextReview-DPeSY-7r.js} +70 -68
- package/dist/cdn/chunks/AiAltTextReview-DPeSY-7r.js.map +1 -0
- package/dist/cdn/chunks/AiChatPanel-By8Uo1nH.js +487 -0
- package/dist/cdn/chunks/AiChatPanel-By8Uo1nH.js.map +1 -0
- package/dist/cdn/chunks/{AiPanels-0wBarZSH.js → AiPanels-BblCSkQy.js} +11 -11
- package/dist/cdn/chunks/{AiPanels-0wBarZSH.js.map → AiPanels-BblCSkQy.js.map} +1 -1
- package/dist/cdn/chunks/{AiRewriteMenu-qf-cfEpy.js → AiRewriteMenu-C4btyN4W.js} +79 -79
- package/dist/cdn/chunks/AiRewriteMenu-C4btyN4W.js.map +1 -0
- package/dist/cdn/chunks/BlockIssueBadge-D3Plo_wt.js +34 -0
- package/dist/cdn/chunks/BlockIssueBadge-D3Plo_wt.js.map +1 -0
- package/dist/cdn/chunks/BlockPreviewCanvas-CTKmBPsq.js +142 -0
- package/dist/cdn/chunks/{BlockPreviewCanvas-DGBh6mqe.js.map → BlockPreviewCanvas-CTKmBPsq.js.map} +1 -1
- package/dist/cdn/chunks/{CloudHeaderExtras-BMNK_F9p.js → CloudHeaderExtras-BtqdN777.js} +4 -4
- package/dist/cdn/chunks/{CloudHeaderExtras-BMNK_F9p.js.map → CloudHeaderExtras-BtqdN777.js.map} +1 -1
- package/dist/cdn/chunks/{CloudPanels-JMWIoVWh.js → CloudPanels-COU26R83.js} +45 -45
- package/dist/cdn/chunks/{CloudPanels-JMWIoVWh.js.map → CloudPanels-COU26R83.js.map} +1 -1
- package/dist/cdn/chunks/CollaborationNotices-DraFUhyo.js +67 -0
- package/dist/cdn/chunks/CollaborationNotices-DraFUhyo.js.map +1 -0
- package/dist/cdn/chunks/{CollaboratorBar-CXByAoUz.js → CollaboratorBar-0OEH3hrj.js} +17 -17
- package/dist/cdn/chunks/{CollaboratorBar-CXByAoUz.js.map → CollaboratorBar-0OEH3hrj.js.map} +1 -1
- package/dist/cdn/chunks/CommentsPanel-tZZswofV.js +18 -0
- package/dist/cdn/chunks/{CommentsPanel-DoJnKLXI.js.map → CommentsPanel-tZZswofV.js.map} +1 -1
- package/dist/cdn/chunks/CommentsSidebar-7Hfl3Hdj.js +496 -0
- package/dist/cdn/chunks/CommentsSidebar-7Hfl3Hdj.js.map +1 -0
- package/dist/cdn/chunks/{CountdownBlock-BqRw147R.js → CountdownBlock-CjMhMhnv.js} +22 -22
- package/dist/cdn/chunks/{CountdownBlock-BqRw147R.js.map → CountdownBlock-CjMhMhnv.js.map} +1 -1
- package/dist/cdn/chunks/CountdownToolbar-CNgsNL5-.js +260 -0
- package/dist/cdn/chunks/CountdownToolbar-CNgsNL5-.js.map +1 -0
- package/dist/cdn/chunks/{IssuesPanel-C7LfxaAY.js → IssuesPanel-Duic0mIs.js} +133 -121
- package/dist/cdn/chunks/IssuesPanel-Duic0mIs.js.map +1 -0
- package/dist/cdn/chunks/LanguageMenu-B1Aue_lf.js +359 -0
- package/dist/cdn/chunks/LanguageMenu-B1Aue_lf.js.map +1 -0
- package/dist/cdn/chunks/{LoadingTrack-CZuLTazv.js → LoadingTrack-DUYcDHOV.js} +2 -2
- package/dist/cdn/chunks/{LoadingTrack-CZuLTazv.js.map → LoadingTrack-DUYcDHOV.js.map} +1 -1
- package/dist/cdn/chunks/LocaleNotices-8J2DRWeg.js +47 -0
- package/dist/cdn/chunks/LocaleNotices-8J2DRWeg.js.map +1 -0
- package/dist/{LogicTagInsertButton-CfscnwCn.js → cdn/chunks/LogicTagInsertButton-Bhvi0nWz.js} +422 -449
- package/dist/cdn/chunks/LogicTagInsertButton-Bhvi0nWz.js.map +1 -0
- package/dist/cdn/chunks/{MediaEditModal-Cpcod6_U.js → MediaEditModal-Dz972UFx.js} +421 -421
- package/dist/cdn/chunks/MediaEditModal-Dz972UFx.js.map +1 -0
- package/dist/cdn/chunks/{MediaPanels-BIdcW_1f.js → MediaPanels-C6Hqtp1H.js} +5 -5
- package/dist/cdn/chunks/{MediaPanels-BIdcW_1f.js.map → MediaPanels-C6Hqtp1H.js.map} +1 -1
- package/dist/cdn/chunks/{MergeTagInput-BvWg8o5E.js → MergeTagInput-CrhZm-AW.js} +28 -28
- package/dist/cdn/chunks/{MergeTagInput-BvWg8o5E.js.map → MergeTagInput-CrhZm-AW.js.map} +1 -1
- package/dist/cdn/chunks/{MergeTagModeToggle-BgKEVUtV.js → MergeTagModeToggle-CWVtXLYa.js} +52 -52
- package/dist/cdn/chunks/MergeTagModeToggle-CWVtXLYa.js.map +1 -0
- package/dist/cdn/chunks/MergeTagTextarea-hTIBwX0F.js +128 -0
- package/dist/cdn/chunks/MergeTagTextarea-hTIBwX0F.js.map +1 -0
- package/dist/cdn/chunks/ParagraphEditor-B2UU1Q5I.js +660 -0
- package/dist/cdn/chunks/ParagraphEditor-B2UU1Q5I.js.map +1 -0
- package/dist/cdn/chunks/{RestoreVersionDialog-CjOdD2xj.js → RestoreVersionDialog-C1Y5Ewo_.js} +22 -22
- package/dist/cdn/chunks/{RestoreVersionDialog-CjOdD2xj.js.map → RestoreVersionDialog-C1Y5Ewo_.js.map} +1 -1
- package/dist/cdn/chunks/{RichTextEditorContent-DNjR_sNN.js → RichTextEditorContent-up4AqL7D.js} +44 -44
- package/dist/cdn/chunks/{RichTextEditorContent-DNjR_sNN.js.map → RichTextEditorContent-up4AqL7D.js.map} +1 -1
- package/dist/cdn/chunks/{SaveBlockDialog-CUhpawq0.js → SaveBlockDialog-B9lwEP_T.js} +77 -77
- package/dist/cdn/chunks/{SaveBlockDialog-CUhpawq0.js.map → SaveBlockDialog-B9lwEP_T.js.map} +1 -1
- package/dist/{SavedBlocksBrowserModal-CE8n4EBS.js → cdn/chunks/SavedBlocksBrowserModal-fAeHUyxb.js} +103 -106
- package/dist/cdn/chunks/{SavedBlocksBrowserModal-BPYcRoGa.js.map → SavedBlocksBrowserModal-fAeHUyxb.js.map} +1 -1
- package/dist/cdn/chunks/{SavedBlocksPanels-C6--Bc81.js → SavedBlocksPanels-DRDTLDyZ.js} +9 -9
- package/dist/cdn/chunks/{SavedBlocksPanels-C6--Bc81.js.map → SavedBlocksPanels-DRDTLDyZ.js.map} +1 -1
- package/dist/cdn/chunks/{SavedBlocksPickBar-DUavxpbU.js → SavedBlocksPickBar-B6b5z-o3.js} +16 -16
- package/dist/cdn/chunks/{SavedBlocksPickBar-DUavxpbU.js.map → SavedBlocksPickBar-B6b5z-o3.js.map} +1 -1
- package/dist/cdn/chunks/TemplateSettings-CWUpUKJb.js +266 -0
- package/dist/cdn/chunks/TemplateSettings-CWUpUKJb.js.map +1 -0
- package/dist/cdn/chunks/TestEmailModal-DQxnW5Q5.js +212 -0
- package/dist/cdn/chunks/TestEmailModal-DQxnW5Q5.js.map +1 -0
- package/dist/cdn/chunks/{TestEmailPanel-CcUpEpAn.js → TestEmailPanel-BcO_-16H.js} +5 -5
- package/dist/cdn/chunks/{TestEmailPanel-CcUpEpAn.js.map → TestEmailPanel-BcO_-16H.js.map} +1 -1
- package/dist/cdn/chunks/TitleEditor-pmycpmTd.js +202 -0
- package/dist/cdn/chunks/TitleEditor-pmycpmTd.js.map +1 -0
- package/dist/cdn/chunks/ToggleSwitch-BSkySwA1.js +45 -0
- package/dist/cdn/chunks/ToggleSwitch-BSkySwA1.js.map +1 -0
- package/dist/cdn/chunks/Toolbar-BlWVQRcA.js +3626 -0
- package/dist/cdn/chunks/Toolbar-BlWVQRcA.js.map +1 -0
- package/dist/cdn/chunks/{TplModal-CFPDgbwQ.js → TplModal-ClSSGX7a.js} +20 -20
- package/dist/cdn/chunks/{TplModal-CFPDgbwQ.js.map → TplModal-ClSSGX7a.js.map} +1 -1
- package/dist/cdn/chunks/{VersionHistoryMenu-BYlLRvRJ.js → VersionHistoryMenu-CZury5gU.js} +33 -33
- package/dist/cdn/chunks/{VersionHistoryMenu-BYlLRvRJ.js.map → VersionHistoryMenu-CZury5gU.js.map} +1 -1
- package/dist/cdn/chunks/{VersionHistoryPanels-C6SOVoiT.js → VersionHistoryPanels-B8GPBKMq.js} +6 -6
- package/dist/cdn/chunks/{VersionHistoryPanels-C6SOVoiT.js.map → VersionHistoryPanels-B8GPBKMq.js.map} +1 -1
- package/dist/cdn/chunks/VersionPreviewBanner-C4Ji8nu4.js +39 -0
- package/dist/cdn/chunks/VersionPreviewBanner-C4Ji8nu4.js.map +1 -0
- package/dist/cdn/chunks/WrapperBlock-BoUflYwY.js +46 -0
- package/dist/cdn/chunks/WrapperBlock-BoUflYwY.js.map +1 -0
- package/dist/cdn/chunks/{blockTypeIcons-D7FW7Ypo.js → blockTypeIcons-Cc6RJ27V.js} +5 -5
- package/dist/cdn/chunks/{blockTypeIcons-D7FW7Ypo.js.map → blockTypeIcons-Cc6RJ27V.js.map} +1 -1
- package/dist/{ca-CD-Kt1qz.js → cdn/chunks/ca-DOuIxWRv.js} +116 -0
- package/dist/cdn/chunks/ca-DOuIxWRv.js.map +1 -0
- package/dist/cdn/chunks/composables-C1KU4ZHw.js +3039 -0
- package/dist/cdn/chunks/composables-C1KU4ZHw.js.map +1 -0
- package/dist/cdn/chunks/{createCloudRuntime-Cth2JCEh.js → createCloudRuntime-C2Zs5F1O.js} +75 -73
- package/dist/cdn/chunks/createCloudRuntime-C2Zs5F1O.js.map +1 -0
- package/dist/{de-CeFJ6wbM.js → cdn/chunks/de-DaOUfYBX.js} +116 -0
- package/dist/cdn/chunks/de-DaOUfYBX.js.map +1 -0
- package/dist/cdn/chunks/{dist-8ym3y-pH.js → dist-BzXULHvI.js} +48 -48
- package/dist/cdn/chunks/{dist-8ym3y-pH.js.map → dist-BzXULHvI.js.map} +1 -1
- package/dist/cdn/chunks/{dist-BMzNabtD.js → dist-DqGgijFI.js} +114 -114
- package/dist/cdn/chunks/{dist-BMzNabtD.js.map → dist-DqGgijFI.js.map} +1 -1
- package/dist/cdn/chunks/{draggable-Du8AUMFT.js → draggable-DepKdldn.js} +1491 -1486
- package/dist/cdn/chunks/draggable-DepKdldn.js.map +1 -0
- package/dist/cdn/chunks/{editor-modal-CyCe560f.js → editor-modal-erQEOHZN.js} +781 -781
- package/dist/cdn/chunks/{editor-modal-CyCe560f.js.map → editor-modal-erQEOHZN.js.map} +1 -1
- package/dist/cdn/chunks/en-B6tLGRHq.js +1 -0
- package/dist/{en-D14i5nFh.js → cdn/chunks/en-C0pHHMiR.js} +116 -0
- package/dist/cdn/chunks/en-C0pHHMiR.js.map +1 -0
- package/dist/{es-zDacbMhs.js → cdn/chunks/es-CxyEKr6n.js} +116 -0
- package/dist/cdn/chunks/es-CxyEKr6n.js.map +1 -0
- package/dist/cdn/chunks/{extensions-CFF2KWy-.js → extensions-DcMKZpzh.js} +59 -59
- package/dist/cdn/chunks/{extensions-CFF2KWy-.js.map → extensions-DcMKZpzh.js.map} +1 -1
- package/dist/{fr-CSgYtjOd.js → cdn/chunks/fr-CYbamiI6.js} +116 -0
- package/dist/cdn/chunks/fr-CYbamiI6.js.map +1 -0
- package/dist/cdn/chunks/{icons-okSPsLOa.js → icons-Da9GKjPx.js} +188 -147
- package/dist/cdn/chunks/icons-Da9GKjPx.js.map +1 -0
- package/dist/{ja-B7H3ID8O.js → cdn/chunks/ja-DfaIAoGI.js} +116 -0
- package/dist/cdn/chunks/ja-DfaIAoGI.js.map +1 -0
- package/dist/cdn/chunks/keys-CoQtCqNv.js +11 -0
- package/dist/cdn/chunks/keys-CoQtCqNv.js.map +1 -0
- package/dist/cdn/chunks/languageName-DEEOhDWI.js +12 -0
- package/dist/cdn/chunks/languageName-DEEOhDWI.js.map +1 -0
- package/dist/{nl-176ySmc5.js → cdn/chunks/nl-DkrB-VKZ.js} +116 -0
- package/dist/cdn/chunks/nl-DkrB-VKZ.js.map +1 -0
- package/dist/cdn/chunks/normalizeMergeTagMarkup-cC32Ox6A.js +290 -0
- package/dist/cdn/chunks/normalizeMergeTagMarkup-cC32Ox6A.js.map +1 -0
- package/dist/cdn/chunks/noticeTones-D7BPu-Le.js +16 -0
- package/dist/cdn/chunks/noticeTones-D7BPu-Le.js.map +1 -0
- package/dist/cdn/chunks/plural-CyxrJXL1.js +17 -0
- package/dist/cdn/chunks/plural-CyxrJXL1.js.map +1 -0
- package/dist/{preRenderCustomBlocks--_xc0XK3.js → cdn/chunks/preRenderCustomBlocks-f7GEKdvw.js} +5 -3
- package/dist/cdn/chunks/{preRenderCustomBlocks-BcXIz7oJ.js.map → preRenderCustomBlocks-f7GEKdvw.js.map} +1 -1
- package/dist/{pt-BR-dDlTwX18.js → cdn/chunks/pt-BR-CY5Ye7eP.js} +116 -0
- package/dist/cdn/chunks/pt-BR-CY5Ye7eP.js.map +1 -0
- package/dist/cdn/chunks/sanitizeHtml-WTfz9lZd.js +61 -0
- package/dist/cdn/chunks/sanitizeHtml-WTfz9lZd.js.map +1 -0
- package/dist/cdn/chunks/socialIcons-DeCYorUT.js +2638 -0
- package/dist/cdn/chunks/socialIcons-DeCYorUT.js.map +1 -0
- package/dist/cdn/chunks/{src-DEd87i_U.js → src-A_cKeTM_.js} +618 -461
- package/dist/cdn/chunks/src-A_cKeTM_.js.map +1 -0
- package/dist/cdn/chunks/src-BQUv2CYU.js +2606 -0
- package/dist/cdn/chunks/src-BQUv2CYU.js.map +1 -0
- package/dist/cdn/chunks/src-BWX_xVxO.js +671 -0
- package/dist/cdn/chunks/src-BWX_xVxO.js.map +1 -0
- package/dist/{styleConstants-B8xVRiwX.js → cdn/chunks/styleConstants-CgiNKdnc.js} +7 -5
- package/dist/cdn/chunks/styleConstants-CgiNKdnc.js.map +1 -0
- package/dist/cdn/chunks/templateSettingsFields-cjlP-jdw.js.map +1 -1
- package/dist/cdn/chunks/{tiptap-CbiTlECY.js → tiptap-Dipw_zOQ.js} +40 -40
- package/dist/cdn/chunks/{tiptap-CbiTlECY.js.map → tiptap-Dipw_zOQ.js.map} +1 -1
- package/dist/cdn/chunks/{useCloudI18n-DY8_-ETE.js → useCloudI18n-Cc5NZqiI.js} +3 -3
- package/dist/cdn/chunks/{useCloudI18n-DY8_-ETE.js.map → useCloudI18n-Cc5NZqiI.js.map} +1 -1
- package/dist/cdn/chunks/useEditorRoot-D_LuZ_hE.js +9 -0
- package/dist/cdn/chunks/{useEditorRoot-vjZJwKrV.js.map → useEditorRoot-D_LuZ_hE.js.map} +1 -1
- package/dist/cdn/chunks/{useI18n-D8pY4LTq.js → useI18n-BnJYydPv.js} +3 -3
- package/dist/cdn/chunks/{useI18n-D8pY4LTq.js.map → useI18n-BnJYydPv.js.map} +1 -1
- package/dist/cdn/chunks/useLocalizedDisplay-aGfnO90D.js +33 -0
- package/dist/cdn/chunks/useLocalizedDisplay-aGfnO90D.js.map +1 -0
- package/dist/cdn/chunks/{useLogicTag-DBJDtpKA.js → useLogicTag-DtYe8HIq.js} +5 -5
- package/dist/cdn/chunks/{useLogicTag-DBJDtpKA.js.map → useLogicTag-DtYe8HIq.js.map} +1 -1
- package/dist/cdn/chunks/{useMergeTag-B-aG--s1.js → useMergeTag-B8ULmsnp.js} +6 -6
- package/dist/cdn/chunks/{useMergeTag-B-aG--s1.js.map → useMergeTag-B8ULmsnp.js.map} +1 -1
- package/dist/cdn/chunks/usePopoverPosition-BWAXWeBv.js +78 -0
- package/dist/cdn/chunks/usePopoverPosition-BWAXWeBv.js.map +1 -0
- package/dist/cdn/chunks/{useScrollToBlock-vjQ0fe-L.js → useScrollToBlock-Ct1AwLD-.js} +5 -5
- package/dist/cdn/chunks/useScrollToBlock-Ct1AwLD-.js.map +1 -0
- package/dist/cdn/chunks/{withCurrentFont-hZTvYBHO.js → withCurrentFont-MK8ga9q9.js} +2 -2
- package/dist/cdn/chunks/{withCurrentFont-hZTvYBHO.js.map → withCurrentFont-MK8ga9q9.js.map} +1 -1
- package/dist/cdn/editor.css +1 -1
- package/dist/cdn/editor.js +2189 -1495
- package/dist/cdn/editor.js.map +1 -1
- package/dist/{check-BZ8o0eet.js → check-XMnOOIEC.js} +1 -1
- package/dist/{chevron-down-DfAAfILv.js → chevron-down-DmamTEWQ.js} +1 -1
- package/dist/{chevron-right-Bk4mGdr7.js → chevron-right-BEFXOH27.js} +1 -1
- package/dist/{chevron-up-MhUf_azW.js → chevron-up-Dw7woXj8.js} +1 -1
- package/dist/{circle-alert-CShJwVFv.js → circle-alert-BTKC9vkq.js} +1 -1
- package/dist/{clock-CTfD6OCt.js → clock-BVT5u2uG.js} +1 -1
- package/dist/composables-CMIrGXJ1.js +4517 -0
- package/dist/{createCloudRuntime-DCgO4A1r.js → createCloudRuntime-DGV5a5Af.js} +54 -52
- package/dist/{createLucideIcon-CvhTA2KG.js → createLucideIcon-CgDE3xAR.js} +16 -16
- package/dist/{cdn/chunks/de-CeFJ6wbM.js → de-DaOUfYBX.js} +114 -2
- package/dist/{dist-ByCWA2Tv.js → dist-0alKVRc_.js} +101 -101
- package/dist/{dist-Cy8I5scI.js → dist-54VCNoC0.js} +2 -2
- package/dist/dist-6DU0me3E.js +4 -0
- package/dist/{dist-p3wymUDt.js → dist-B8dY8drK.js} +2 -2
- package/dist/{dist-Dd5MU2Ev.js → dist-B9a7iVye.js} +2 -2
- package/dist/{dist-V7W1UhVr.js → dist-BWflWcpW.js} +2 -2
- package/dist/{dist-D6fZec6r.js → dist-C3hu_C3w.js} +2 -2
- package/dist/{dist-CVy-7PHQ.js → dist-CX7skkvG.js} +48 -48
- package/dist/dist-CcOn7WCo.js +4 -0
- package/dist/dist-Cdkm20M6.js +2542 -0
- package/dist/{dist-BS5uKktL.js → dist-ChOb5XHW.js} +2 -2
- package/dist/{dist-BF5zEHop.js → dist-DZ3X-uB8.js} +2 -2
- package/dist/{dist-CWSG7Kj0.js → dist-D_XrUEET.js} +5 -5
- package/dist/{dist-txQLT2sF.js → dist-TAv500j6.js} +2 -2
- package/dist/{dist-D6cMdrfG.js → dist-fqSers8_.js} +55 -55
- package/dist/{editor-modal-zaZHcmlO.js → editor-modal-BeX6otLk.js} +953 -952
- package/dist/{cdn/chunks/en-D14i5nFh.js → en-C0pHHMiR.js} +114 -2
- package/dist/en-Do0SU6tR.js +1 -0
- package/dist/{cdn/chunks/es-zDacbMhs.js → es-CxyEKr6n.js} +114 -2
- package/dist/{extensions-fo_c-vqf.js → extensions-BJ184osp.js} +173 -173
- package/dist/{eye-7W4t5e0Q.js → eye-ByMgHeA_.js} +1 -1
- package/dist/{cdn/chunks/fr-CSgYtjOd.js → fr-CYbamiI6.js} +114 -2
- package/dist/{image-BDiRFzSd.js → image-Ch8tR35K.js} +1 -1
- package/dist/index.d.ts +182 -14
- package/dist/{info-Cxi3-Kh9.js → info-DzSD-Wpk.js} +1 -1
- package/dist/{cdn/chunks/ja-B7H3ID8O.js → ja-DfaIAoGI.js} +114 -2
- package/dist/keys-BCqskl51.js +9 -0
- package/dist/languageName-DEEOhDWI.js +10 -0
- package/dist/{link-ju_2Cmir.js → link-oDn9AR2w.js} +1 -1
- package/dist/{list-DYZJf0aZ.js → list-C5t07dp8.js} +1 -1
- package/dist/{loader-circle-BZRD0a4I.js → loader-circle-k6xvKgUB.js} +1 -1
- package/dist/{message-circle-DuEw4Zfx.js → message-circle-C23R6OJR.js} +1 -1
- package/dist/{cdn/chunks/nl-176ySmc5.js → nl-DkrB-VKZ.js} +114 -2
- package/dist/normalizeMergeTagMarkup-CUCo7B5X.js +288 -0
- package/dist/noticeTones-D7BPu-Le.js +14 -0
- package/dist/{package-CePMr2kK.js → package-C90eQ7NU.js} +1 -1
- package/dist/{pencil-D3aFCL7c.js → pencil-BK7GrQuA.js} +1 -1
- package/dist/plural-CyxrJXL1.js +15 -0
- package/dist/plus-Cr0Mis63.js +13 -0
- package/dist/{cdn/chunks/preRenderCustomBlocks-BcXIz7oJ.js → preRenderCustomBlocks-Bs3N9no-.js} +4 -6
- package/dist/{cdn/chunks/pt-BR-dDlTwX18.js → pt-BR-CY5Ye7eP.js} +114 -2
- package/dist/{refresh-cw-xnro7_Sk.js → refresh-cw-_ZLOIEvA.js} +2 -12
- package/dist/rotate-ccw-CB5wsHwv.js +13 -0
- package/dist/{runtime-dom.esm-bundler-BURR-bj5.js → runtime-dom.esm-bundler-DlHp8xgy.js} +154 -154
- package/dist/sanitizeHtml-2rjV0r-6.js +962 -0
- package/dist/{search-CDrstRBv.js → search-BmrQNox8.js} +1 -1
- package/dist/{send-DROkPOaX.js → send-blAsIBBg.js} +1 -1
- package/dist/{smartphone-Bx6u_tjn.js → smartphone-BPpWYrwV.js} +1 -1
- package/dist/socialIcons-TFiOkpoU.js +2705 -0
- package/dist/{sparkles-CdaTtvoz.js → sparkles-OqIxrNp-.js} +1 -1
- package/dist/{square-BbCROH_f.js → square-BP-V7iT-.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/{cdn/chunks/styleConstants-B8xVRiwX.js → styleConstants-CgiNKdnc.js} +5 -7
- package/dist/templatical-editor.js +2438 -1752
- package/dist/{text-align-start-CGacJ9Vw.js → text-align-start-4mwX2o-F.js} +13 -13
- package/dist/{trash-DxCd7zIy.js → trash-B99WixTA.js} +1 -1
- package/dist/{triangle-alert-7_oaitpf.js → triangle-alert-CHMiDkHa.js} +1 -1
- package/dist/{upload-DuFEOi_0.js → upload-Cp8o-hrN.js} +1 -1
- package/dist/{useCloudI18n-DEMmUKuO.js → useCloudI18n-Dh2iydo1.js} +4 -4
- package/dist/useEditorRoot-DY3mgcHm.js +7 -0
- package/dist/{useI18n-BBrHTdu8.js → useI18n-CgtvtF4C.js} +4 -4
- package/dist/useLocalizedDisplay-DNNwDRxL.js +31 -0
- package/dist/{useLogicTag-ZPC39rfH.js → useLogicTag-BXXXQQmi.js} +4 -4
- package/dist/{useMergeTag-BQ4qqWpQ.js → useMergeTag-C9Okr87y.js} +5 -5
- package/dist/usePopoverPosition-VDQjyX_A.js +76 -0
- package/dist/{useScrollToBlock-BSyAV4pk.js → useScrollToBlock-B35ObCGK.js} +5 -5
- package/dist/{vue.runtime.esm-bundler-CnEeTfhs.js → vue.runtime.esm-bundler-BJXc_Mri.js} +1373 -1368
- package/dist/withCurrentFont-DJiQqZzL.js +18 -0
- package/dist/{x-BpfG7v9g.js → x-BIBStNMS.js} +1 -1
- package/package.json +21 -21
- package/dist/AiAltTextPopover-DawbUywc.js +0 -105
- package/dist/AiChatPanel-CupPhmsN.js +0 -548
- package/dist/BlockIssueBadge-BxpDy3u-.js +0 -33
- package/dist/BlockPreviewCanvas-B-4bmJ3t.js +0 -140
- package/dist/CollaborationNotices-CTw4JThq.js +0 -75
- package/dist/CommentsPanel-DwwFuh1h.js +0 -16
- package/dist/CommentsSidebar-9ZfiC2DO.js +0 -500
- package/dist/CountdownToolbar-BqoYzf_6.js +0 -197
- package/dist/IssuesPanel-4ykrf1ax.js +0 -359
- package/dist/MergeTagTextarea-CPFEjJZd.js +0 -69
- package/dist/ParagraphEditor-CWXfurGh.js +0 -796
- package/dist/TemplateSettings-CS0f1Ues.js +0 -236
- package/dist/TestEmailModal-DBD0X5nV.js +0 -209
- package/dist/TitleEditor-DSqtle77.js +0 -198
- package/dist/ToggleSwitch-JykPyD_8.js +0 -36
- package/dist/Toolbar-BZPFfKrf.js +0 -3145
- package/dist/VersionPreviewBanner-DECaBwLq.js +0 -37
- package/dist/WrapperBlock-BsJv_Fiw.js +0 -44
- package/dist/cdn/chunks/AiAltTextPopover-SEEjkd-I.js +0 -106
- package/dist/cdn/chunks/AiAltTextPopover-SEEjkd-I.js.map +0 -1
- package/dist/cdn/chunks/AiAltTextReview-BGLLSKLm.js.map +0 -1
- package/dist/cdn/chunks/AiChatPanel-DKDAaBNi.js +0 -474
- package/dist/cdn/chunks/AiChatPanel-DKDAaBNi.js.map +0 -1
- package/dist/cdn/chunks/AiRewriteMenu-qf-cfEpy.js.map +0 -1
- package/dist/cdn/chunks/BlockIssueBadge-jdf91-nk.js +0 -34
- package/dist/cdn/chunks/BlockIssueBadge-jdf91-nk.js.map +0 -1
- package/dist/cdn/chunks/BlockPreviewCanvas-DGBh6mqe.js +0 -142
- package/dist/cdn/chunks/CollaborationNotices-Bsf1rGW9.js +0 -77
- package/dist/cdn/chunks/CollaborationNotices-Bsf1rGW9.js.map +0 -1
- package/dist/cdn/chunks/CommentsPanel-DoJnKLXI.js +0 -18
- package/dist/cdn/chunks/CommentsSidebar-CUtgvdBC.js +0 -470
- package/dist/cdn/chunks/CommentsSidebar-CUtgvdBC.js.map +0 -1
- package/dist/cdn/chunks/CountdownToolbar-xobieKoU.js +0 -199
- package/dist/cdn/chunks/CountdownToolbar-xobieKoU.js.map +0 -1
- package/dist/cdn/chunks/IssuesPanel-C7LfxaAY.js.map +0 -1
- package/dist/cdn/chunks/LogicTagInsertButton-BIi05UQu.js +0 -1051
- package/dist/cdn/chunks/LogicTagInsertButton-BIi05UQu.js.map +0 -1
- package/dist/cdn/chunks/MediaEditModal-Cpcod6_U.js.map +0 -1
- package/dist/cdn/chunks/MergeTagModeToggle-BgKEVUtV.js.map +0 -1
- package/dist/cdn/chunks/MergeTagTextarea-tBz8McZf.js +0 -71
- package/dist/cdn/chunks/MergeTagTextarea-tBz8McZf.js.map +0 -1
- package/dist/cdn/chunks/ParagraphEditor-B3Rj_cWF.js +0 -631
- package/dist/cdn/chunks/ParagraphEditor-B3Rj_cWF.js.map +0 -1
- package/dist/cdn/chunks/TemplateSettings-CKtI-dof.js +0 -208
- package/dist/cdn/chunks/TemplateSettings-CKtI-dof.js.map +0 -1
- package/dist/cdn/chunks/TestEmailModal-CDQTgESD.js +0 -209
- package/dist/cdn/chunks/TestEmailModal-CDQTgESD.js.map +0 -1
- package/dist/cdn/chunks/TitleEditor-Cob7RLyK.js +0 -198
- package/dist/cdn/chunks/TitleEditor-Cob7RLyK.js.map +0 -1
- package/dist/cdn/chunks/ToggleSwitch-J7Vwhvha.js +0 -38
- package/dist/cdn/chunks/ToggleSwitch-J7Vwhvha.js.map +0 -1
- package/dist/cdn/chunks/Toolbar-CdpsvNOR.js +0 -3061
- package/dist/cdn/chunks/Toolbar-CdpsvNOR.js.map +0 -1
- package/dist/cdn/chunks/VersionPreviewBanner-Dvg0ZfAW.js +0 -39
- package/dist/cdn/chunks/VersionPreviewBanner-Dvg0ZfAW.js.map +0 -1
- package/dist/cdn/chunks/WrapperBlock-C7Md56IT.js +0 -46
- package/dist/cdn/chunks/WrapperBlock-C7Md56IT.js.map +0 -1
- package/dist/cdn/chunks/ca-CD-Kt1qz.js.map +0 -1
- package/dist/cdn/chunks/createCloudRuntime-Cth2JCEh.js.map +0 -1
- package/dist/cdn/chunks/de-CeFJ6wbM.js.map +0 -1
- package/dist/cdn/chunks/draggable-Du8AUMFT.js.map +0 -1
- package/dist/cdn/chunks/en-D14i5nFh.js.map +0 -1
- package/dist/cdn/chunks/en-TIqv4ag3.js +0 -1
- package/dist/cdn/chunks/es-zDacbMhs.js.map +0 -1
- package/dist/cdn/chunks/fr-CSgYtjOd.js.map +0 -1
- package/dist/cdn/chunks/icons-okSPsLOa.js.map +0 -1
- package/dist/cdn/chunks/ja-B7H3ID8O.js.map +0 -1
- package/dist/cdn/chunks/keys-CUj6UA38.js +0 -11
- package/dist/cdn/chunks/keys-CUj6UA38.js.map +0 -1
- package/dist/cdn/chunks/nl-176ySmc5.js.map +0 -1
- package/dist/cdn/chunks/normalizeMergeTagMarkup-C_KlfSW4.js +0 -198
- package/dist/cdn/chunks/normalizeMergeTagMarkup-C_KlfSW4.js.map +0 -1
- package/dist/cdn/chunks/pt-BR-dDlTwX18.js.map +0 -1
- package/dist/cdn/chunks/sanitizeHtml-CN85EDrO.js +0 -72
- package/dist/cdn/chunks/sanitizeHtml-CN85EDrO.js.map +0 -1
- package/dist/cdn/chunks/socialIcons-jsTDmkbb.js +0 -2008
- package/dist/cdn/chunks/socialIcons-jsTDmkbb.js.map +0 -1
- package/dist/cdn/chunks/src-C7bkofBL.js +0 -647
- package/dist/cdn/chunks/src-C7bkofBL.js.map +0 -1
- package/dist/cdn/chunks/src-DEd87i_U.js.map +0 -1
- package/dist/cdn/chunks/src-DwWrYnUj.js +0 -1404
- package/dist/cdn/chunks/src-DwWrYnUj.js.map +0 -1
- package/dist/cdn/chunks/styleConstants-B8xVRiwX.js.map +0 -1
- package/dist/cdn/chunks/useEditorCore-BrY66C2y.js +0 -2582
- package/dist/cdn/chunks/useEditorCore-BrY66C2y.js.map +0 -1
- package/dist/cdn/chunks/useEditorRoot-vjZJwKrV.js +0 -9
- package/dist/cdn/chunks/usePopoverPosition-DSMtmu2W.js +0 -70
- package/dist/cdn/chunks/usePopoverPosition-DSMtmu2W.js.map +0 -1
- package/dist/cdn/chunks/useScrollToBlock-vjQ0fe-L.js.map +0 -1
- package/dist/dist-CKi_npZM.js +0 -1344
- package/dist/dist-DyFArF_G.js +0 -4
- package/dist/dist-pA3ooG6N.js +0 -4
- package/dist/en-Db76vJbY.js +0 -1
- package/dist/keys-BgRERHzu.js +0 -9
- package/dist/normalizeMergeTagMarkup-CELnOlgK.js +0 -196
- package/dist/sanitizeHtml-BzfzpYJY.js +0 -942
- package/dist/socialIcons-D7MGsg0d.js +0 -2075
- package/dist/useEditorCore-BSo2sSID.js +0 -4059
- package/dist/useEditorRoot-BMcoCLBx.js +0 -7
- package/dist/usePopoverPosition-DV1PxL66.js +0 -68
- package/dist/withCurrentFont-B22FXAF5.js +0 -18
|
@@ -0,0 +1,2638 @@
|
|
|
1
|
+
import { $ as e, C as t, F as n, H as r, M as i, O as a, Q as o, X as s, Y as c, _ as l, at as u, b as d, ct as f, dt as p, et as m, lt as h, mt as g, ot as _, p as v, pt as y, q as b, rt as x, tt as S, u as C, x as w } from "./draggable-DepKdldn.js";
|
|
2
|
+
import { $t as T, A as E, At as D, Bt as O, Ft as k, Gt as A, Ht as j, It as M, Jt as N, Kt as ee, Mt as P, N as F, Nt as te, O as ne, Ot as re, P as I, Pt as L, Qt as R, Rt as z, Vt as ie, Xt as B, Yt as ae, Z as oe, Zt as V, en as H, jt as U, k as W, lt as se, n as ce, qt as le, r as ue, sn as de, tn as fe, vn as pe, xt as me, zt as he } from "./src-BQUv2CYU.js";
|
|
3
|
+
import { at as ge, s as _e } from "./icons-Da9GKjPx.js";
|
|
4
|
+
import { B as ve, C as ye, U as be, u as xe } from "./keys-CoQtCqNv.js";
|
|
5
|
+
import { t as Se } from "./useI18n-BnJYydPv.js";
|
|
6
|
+
import { r as Ce } from "./dist-DqGgijFI.js";
|
|
7
|
+
import { i as we, r as Te } from "./usePopoverPosition-BWAXWeBv.js";
|
|
8
|
+
// ../core/src/localized-edit.ts
|
|
9
|
+
var G = (e) => typeof e == "object" && !!e && !Array.isArray(e), Ee = (e) => Array.isArray(e) && e.length > 0 && e.every((e) => G(e) && typeof e.id == "string"), De = /* @__PURE__ */ new Set([
|
|
10
|
+
"id",
|
|
11
|
+
"type",
|
|
12
|
+
"children",
|
|
13
|
+
"columns",
|
|
14
|
+
"l10n",
|
|
15
|
+
"renderedHtml"
|
|
16
|
+
]);
|
|
17
|
+
function Oe(e, t, n) {
|
|
18
|
+
let r = /* @__PURE__ */ new Set();
|
|
19
|
+
for (let i of n) {
|
|
20
|
+
if (!O(i)) continue;
|
|
21
|
+
let n = i.split("."), a = n.pop(), o = n.join("."), s = N(e, i), c = t;
|
|
22
|
+
for (let [t, i] of n.entries()) {
|
|
23
|
+
let a = n.slice(0, t + 1).join(".");
|
|
24
|
+
s !== void 0 && G(c) && N(c, i) === void 0 && G(N(e, a)) && (c[i] = {}, r.add(a)), c = N(c, i);
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(c)) {
|
|
27
|
+
let e = c.findIndex((e) => G(e) && e.id === a);
|
|
28
|
+
if (e < 0) continue;
|
|
29
|
+
s === void 0 ? c.splice(e, 1) : c[e] = H(s);
|
|
30
|
+
} else G(c) && (s === void 0 ? delete c[a] : c[a] = H(s), o && Object.keys(c).length === 0 && N(e, o) === void 0 && Oe(e, t, [o]));
|
|
31
|
+
}
|
|
32
|
+
return r;
|
|
33
|
+
}
|
|
34
|
+
function K(e, t, n, r, i = !0, a = /* @__PURE__ */ new Set()) {
|
|
35
|
+
if (G(e) && G(t) && !a.has(n)) for (let o of /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)])) (n || !De.has(o)) && K(e[o], t[o], n ? `${n}.${o}` : o, r, i, a);
|
|
36
|
+
else if (i && Ee(e) && Ee(t)) for (let o of t) {
|
|
37
|
+
if (o.id.includes(".")) continue;
|
|
38
|
+
let t = e.find((e) => e.id === o.id);
|
|
39
|
+
t && K(t, o, `${n}.${o.id}`, r, i, a);
|
|
40
|
+
}
|
|
41
|
+
else T(e, t) || r.set(n, t);
|
|
42
|
+
}
|
|
43
|
+
function q(e, t, n, r = [], i = /* @__PURE__ */ new Set()) {
|
|
44
|
+
let a = /* @__PURE__ */ new Map();
|
|
45
|
+
K(e, t, "", a, e.type !== "custom", i);
|
|
46
|
+
let o = new Set(e.type === "custom" ? V(e, r) : []), s = {}, c = {};
|
|
47
|
+
for (let [t, r] of a) if ((e.type === "custom" ? o.has(t) : j(e.type, t)) && typeof r == "string" && N(e, t) !== void 0) {
|
|
48
|
+
let i = n?.text?.[t];
|
|
49
|
+
s[t] = i && i.value === r ? i : {
|
|
50
|
+
value: r,
|
|
51
|
+
sourceHash: B(String(N(e, t) ?? ""))
|
|
52
|
+
};
|
|
53
|
+
} else c[t] = r === void 0 ? null : r;
|
|
54
|
+
let l = {};
|
|
55
|
+
return Object.keys(s).length && (l.text = s), Object.keys(c).length && (l.set = c), n?.hidden && (l.hidden = !0), l;
|
|
56
|
+
}
|
|
57
|
+
function ke(e, t, n) {
|
|
58
|
+
let r = !1;
|
|
59
|
+
function i(e, t, n, a) {
|
|
60
|
+
let o = e[n], s = t[n], c = (e) => Array.isArray(e) && e.every((e) => G(e) && typeof e.id == "string");
|
|
61
|
+
if (c(o) && c(s) && (JSON.stringify(o.map((e) => e.id)) !== JSON.stringify(s.map((e) => e.id)) && (r = !0, e[n] = s.map((e) => H(o.find((t) => t.id === e.id) ?? e))), a)) for (let t of s) {
|
|
62
|
+
let r = e[n].find((e) => e.id === t.id);
|
|
63
|
+
r && i(r, t, a);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
let a = e, o = t;
|
|
67
|
+
if (e.type === "menu" && i(a, o, "items"), e.type === "table" && i(a, o, "rows", "cells"), e.type === "social" && i(a, o, "icons"), e.type === "section" && t.type === "section") {
|
|
68
|
+
let i = (e) => e.map((e) => e.map((e) => e.id));
|
|
69
|
+
(e.columns !== t.columns || JSON.stringify(i(e.children)) !== JSON.stringify(i(t.children))) && (r = !0, e.columns = t.columns, e.children = t.children.map((e) => e.map((e) => H(n(e.id) ?? e))));
|
|
70
|
+
}
|
|
71
|
+
return r;
|
|
72
|
+
}
|
|
73
|
+
function J(e, t, n) {
|
|
74
|
+
let r = (e) => {
|
|
75
|
+
let { locale: t, locales: n, l10n: r, ...i } = e;
|
|
76
|
+
return i;
|
|
77
|
+
}, i = /* @__PURE__ */ new Map();
|
|
78
|
+
K(r(e), r(t), "", i);
|
|
79
|
+
let a = {};
|
|
80
|
+
for (let [t, r] of i) if (M.includes(t) && typeof r == "string" && N(e, t) !== void 0) {
|
|
81
|
+
let i = n?.text?.[t];
|
|
82
|
+
(a.text ??= {})[t] = i?.value === r ? i : {
|
|
83
|
+
value: r,
|
|
84
|
+
sourceHash: B(String(N(e, t) ?? ""))
|
|
85
|
+
};
|
|
86
|
+
} else (a.set ??= {})[t] = r === void 0 ? null : r;
|
|
87
|
+
return a;
|
|
88
|
+
}
|
|
89
|
+
function Y(e, t, n, r, i, a = []) {
|
|
90
|
+
let o = H(e ?? {}), s = [.../* @__PURE__ */ new Set([...a, ...[.../* @__PURE__ */ new Set([
|
|
91
|
+
...Object.keys(t.text ?? {}),
|
|
92
|
+
...Object.keys(t.set ?? {}),
|
|
93
|
+
...Object.keys(n.text ?? {}),
|
|
94
|
+
...Object.keys(n.set ?? {})
|
|
95
|
+
])].filter((e) => !T(t.text?.[e], n.text?.[e]) || !T(t.set?.[e], n.set?.[e]))])], c = Object.keys(e?.set ?? {}).filter((e) => s.some((t) => t.startsWith(`${e}.`)));
|
|
96
|
+
for (let e of c) {
|
|
97
|
+
let t = N(i, e), n = s.filter((t) => t.startsWith(`${e}.`) && T(N(r, t), N(i, t)));
|
|
98
|
+
if (T(t, N(r, e))) delete o.set[e];
|
|
99
|
+
else if (n.length && G(N(r, e)) && G(t)) {
|
|
100
|
+
delete o.set[e];
|
|
101
|
+
let i = (e, t, a) => {
|
|
102
|
+
if (!n.some((t) => e === t || e.startsWith(`${t}.`))) {
|
|
103
|
+
if (G(t) && G(a)) for (let n of /* @__PURE__ */ new Set([...Object.keys(t), ...Object.keys(a)])) i(`${e}.${n}`, t[n], a[n]);
|
|
104
|
+
else if (G(r) && r.type !== "custom" && Ee(t) && Ee(a)) for (let n of a) i(`${e}.${n.id}`, t.find((e) => e.id === n.id), n);
|
|
105
|
+
else G(r) && typeof r.type == "string" && ie(r, e, a) || o.text?.[e] && o.text[e].value === a || ((o.set ??= {})[e] = a === void 0 ? null : H(a));
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
i(e, N(r, e), t);
|
|
109
|
+
} else o.set[e] = t === void 0 ? null : H(t);
|
|
110
|
+
for (let t of ["text", "set"]) for (let n of Object.keys(o[t] ?? {})) n.startsWith(`${e}.`) && (T(t === "text" ? o.text[n].value : o.set[n] ?? void 0, N(i, n)) || delete o[t][n]);
|
|
111
|
+
}
|
|
112
|
+
for (let e of s) if (!c.includes(e)) {
|
|
113
|
+
for (let t of ["text", "set"]) for (let n of Object.keys(o[t] ?? {})) (n === e || n.startsWith(`${e}.`)) && delete o[t][n];
|
|
114
|
+
n.text && Object.hasOwn(n.text, e) && ((o.text ??= {})[e] = n.text[e]), n.set && Object.hasOwn(n.set, e) && !c.some((t) => Object.hasOwn(o.set ?? {}, t) && e.startsWith(`${t}.`)) && ((o.set ??= {})[e] = n.set[e]);
|
|
115
|
+
}
|
|
116
|
+
return o.text && !Object.keys(o.text).length && delete o.text, o.set && !Object.keys(o.set).length && delete o.set, o;
|
|
117
|
+
}
|
|
118
|
+
// ../core/src/mutation-guard.ts
|
|
119
|
+
function Ae(e) {
|
|
120
|
+
return [
|
|
121
|
+
"addBlock",
|
|
122
|
+
"removeBlock",
|
|
123
|
+
"moveBlock",
|
|
124
|
+
"duplicateBlock"
|
|
125
|
+
].includes(e);
|
|
126
|
+
}
|
|
127
|
+
function je(e, t, n) {
|
|
128
|
+
if (e.canEdit && !e.canEdit()) return !1;
|
|
129
|
+
let r = t === "addBlock", i = t === "duplicateBlock", a = typeof n[0] == "string" ? n[0] : n[0].id, o = r ? n[0] : e.findBlock?.(a);
|
|
130
|
+
if (!r && e.findBlock && !o) return !1;
|
|
131
|
+
let s = r ? null : e.findBlockLocation?.(a);
|
|
132
|
+
if (!r && e.findBlockLocation && !s || !r && e.isBlockLocked(a, !0) || s?.targetSectionId && e.isBlockLocked(s.targetSectionId, !0)) return !1;
|
|
133
|
+
if (r && e.content) {
|
|
134
|
+
let t = {
|
|
135
|
+
...e.content(),
|
|
136
|
+
blocks: [o]
|
|
137
|
+
};
|
|
138
|
+
W(t), E(t);
|
|
139
|
+
}
|
|
140
|
+
if (t === "removeBlock") return !0;
|
|
141
|
+
let c = i && n[1] === void 0 && n[2] === void 0, l = c ? s?.targetSectionId : n[t === "moveBlock" ? 2 : 1], u = (c ? s?.columnIndex : n[t === "moveBlock" ? 3 : 2]) ?? 0;
|
|
142
|
+
if (l) {
|
|
143
|
+
if (e.isBlockLocked(l, !0) || o?.type === "section") return !1;
|
|
144
|
+
if (e.findBlock) {
|
|
145
|
+
let t = e.findBlock(l);
|
|
146
|
+
if (t?.type !== "section" || u < 0 || u >= k(t.columns)) return !1;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return t !== "moveBlock" || s?.targetSectionId !== l || (s?.columnIndex ?? 0) !== u || s?.index !== n[1];
|
|
150
|
+
}
|
|
151
|
+
var X = /* @__PURE__ */ new WeakMap();
|
|
152
|
+
function Me(e, t) {
|
|
153
|
+
X.set(e, t);
|
|
154
|
+
for (let n of Object.values(e)) typeof n == "function" && X.set(n, t);
|
|
155
|
+
}
|
|
156
|
+
function Ne(e, t) {
|
|
157
|
+
let n = X.get(e);
|
|
158
|
+
n && X.set(t, n);
|
|
159
|
+
}
|
|
160
|
+
function Z(e, t, n) {
|
|
161
|
+
let r = Reflect.get(e, t), i = X.get(e) ?? (typeof r == "function" ? X.get(r) : void 0);
|
|
162
|
+
if (i) return i(t, n);
|
|
163
|
+
if (!Ae(t)) return !0;
|
|
164
|
+
let a = Reflect.get(e, "isBlockLocked");
|
|
165
|
+
if (typeof a != "function") return !0;
|
|
166
|
+
let o = { isBlockLocked: (t, n) => a.call(e, t, n) }, c = Reflect.get(e, "content");
|
|
167
|
+
s(c) ? o.content = () => c.value : typeof c == "function" && (o.content = () => c.call(e));
|
|
168
|
+
for (let t of [
|
|
169
|
+
"canEdit",
|
|
170
|
+
"findBlock",
|
|
171
|
+
"findBlockLocation"
|
|
172
|
+
]) {
|
|
173
|
+
let n = Reflect.get(e, t);
|
|
174
|
+
typeof n == "function" && (o[t] = n.bind(e));
|
|
175
|
+
}
|
|
176
|
+
return je(o, t, n);
|
|
177
|
+
}
|
|
178
|
+
// ../core/src/error-reporting.ts
|
|
179
|
+
function Pe(e) {
|
|
180
|
+
return e instanceof Error ? e : Error(String(e), { cause: e });
|
|
181
|
+
}
|
|
182
|
+
function Q(e, t) {
|
|
183
|
+
try {
|
|
184
|
+
t();
|
|
185
|
+
} catch (t) {
|
|
186
|
+
e?.(Pe(t));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// ../core/src/editor.ts
|
|
190
|
+
function Fe(t) {
|
|
191
|
+
let n = t.content ?? se(t.defaultFontFamily, t.templateDefaults);
|
|
192
|
+
W(n), E(n);
|
|
193
|
+
let r = e({
|
|
194
|
+
template: null,
|
|
195
|
+
content: n,
|
|
196
|
+
activeLocale: null,
|
|
197
|
+
selectedBlockId: null,
|
|
198
|
+
viewport: "desktop",
|
|
199
|
+
darkMode: !1,
|
|
200
|
+
previewMode: !1,
|
|
201
|
+
isDirty: !1,
|
|
202
|
+
isSaving: !1,
|
|
203
|
+
isLoading: !1,
|
|
204
|
+
uiTheme: "auto"
|
|
205
|
+
}), i = u(r, "activeLocale"), a = [];
|
|
206
|
+
function o(e) {
|
|
207
|
+
let t = z(r.content);
|
|
208
|
+
if (e === t && (e = null), e !== null && !r.content.settings.locales?.includes(e)) throw new R(`This template has no "${e}" version.`, void 0, "unknown_locale");
|
|
209
|
+
i.value = e;
|
|
210
|
+
}
|
|
211
|
+
h(() => i.value ?? z(r.content), (e) => Q(t.onError, () => t.onLocaleChange?.(e))), h(() => r.content.settings.locales?.includes(i.value ?? ""), () => {
|
|
212
|
+
i.value && !r.content.settings.locales?.includes(i.value) && o(null);
|
|
213
|
+
});
|
|
214
|
+
function s() {
|
|
215
|
+
return i.value === null || t.localization === void 0 || t.localization.locales.includes(i.value);
|
|
216
|
+
}
|
|
217
|
+
function c(e) {
|
|
218
|
+
a = e;
|
|
219
|
+
}
|
|
220
|
+
function l(e) {
|
|
221
|
+
return L(r.content, e, a);
|
|
222
|
+
}
|
|
223
|
+
function d(e, n) {
|
|
224
|
+
if (!s()) return null;
|
|
225
|
+
if (e === "addLocale" && (!he(n) || t.localization && !t.localization.locales.includes(n))) throw new R(`Locale "${n}" is not enabled.`, void 0, "unknown_locale");
|
|
226
|
+
let i = H(r.content);
|
|
227
|
+
return te(i, [{
|
|
228
|
+
op: e,
|
|
229
|
+
locale: n
|
|
230
|
+
}]), T(i, r.content) ? null : i;
|
|
231
|
+
}
|
|
232
|
+
function f(e, t) {
|
|
233
|
+
let n = d(e, t);
|
|
234
|
+
n && (r.content = n, j());
|
|
235
|
+
}
|
|
236
|
+
function p(e) {
|
|
237
|
+
f("addLocale", e);
|
|
238
|
+
}
|
|
239
|
+
function g(e) {
|
|
240
|
+
f("removeLocale", e);
|
|
241
|
+
}
|
|
242
|
+
function _(e, t) {
|
|
243
|
+
let n = i.value;
|
|
244
|
+
Object.keys(t).length ? e.l10n = {
|
|
245
|
+
...e.l10n,
|
|
246
|
+
[n]: t
|
|
247
|
+
} : e.l10n && (delete e.l10n[n], Object.keys(e.l10n).length || delete e.l10n);
|
|
248
|
+
}
|
|
249
|
+
function v(e, t) {
|
|
250
|
+
let [n, o] = t;
|
|
251
|
+
if (!i.value || !s() || I(n)) return null;
|
|
252
|
+
let c = F(r.content.blocks, n);
|
|
253
|
+
if (!c) return null;
|
|
254
|
+
let l = c.l10n?.[i.value], u = A(c, i.value, z(r.content)), d = q(c, u, l, a), f = e === "resetLocaleFields" && Array.isArray(o) ? Oe(c, u, o) : void 0, p = e === "resetLocaleFields" ? Y(l, d, q(c, u, l, a, f), c, u, Array.isArray(o) ? o : []) : H(l ?? {});
|
|
255
|
+
if (e === "setBlockHidden") o ? p.hidden = !0 : delete p.hidden;
|
|
256
|
+
else if (e === "resetLocaleFields") o || (delete p.text, delete p.set, delete p.hidden);
|
|
257
|
+
else for (let e of o) {
|
|
258
|
+
let t = p.text?.[e];
|
|
259
|
+
t && (t.sourceHash = B(String(N(c, e) ?? "")));
|
|
260
|
+
}
|
|
261
|
+
return p.text && !Object.keys(p.text).length && delete p.text, p.set && !Object.keys(p.set).length && delete p.set, T(l ?? {}, p) ? null : {
|
|
262
|
+
block: c,
|
|
263
|
+
layer: p
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
function y(e, t) {
|
|
267
|
+
let n = v(e, t);
|
|
268
|
+
n && (_(n.block, n.layer), j());
|
|
269
|
+
}
|
|
270
|
+
function x(e, t) {
|
|
271
|
+
y("setBlockHidden", [e, t]);
|
|
272
|
+
}
|
|
273
|
+
function C(e, t) {
|
|
274
|
+
y("resetLocaleFields", [e, t]);
|
|
275
|
+
}
|
|
276
|
+
function w(e, t) {
|
|
277
|
+
y("keepTranslations", [e, t]);
|
|
278
|
+
}
|
|
279
|
+
let D = S(0), O = 0, k = 0;
|
|
280
|
+
function j() {
|
|
281
|
+
r.isDirty = !0, k++;
|
|
282
|
+
}
|
|
283
|
+
let M = b({
|
|
284
|
+
get: () => r.content,
|
|
285
|
+
set: (e) => {
|
|
286
|
+
r.content = e, j();
|
|
287
|
+
}
|
|
288
|
+
}), P = b(() => r.selectedBlockId ? F(r.content.blocks, r.selectedBlockId) : null);
|
|
289
|
+
function F(e, t) {
|
|
290
|
+
for (let n of e) {
|
|
291
|
+
if (n.id === t) return n;
|
|
292
|
+
if (n.type === "section") for (let e of n.children) {
|
|
293
|
+
let n = F(e, t);
|
|
294
|
+
if (n) return n;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
function ne(e, t) {
|
|
300
|
+
if (t.add(e.id), e.type === "section") for (let n of e.children) for (let e of n) ne(e, t);
|
|
301
|
+
}
|
|
302
|
+
function re(e, t, n = { blocks: e }) {
|
|
303
|
+
for (let r = 0; r < e.length; r++) {
|
|
304
|
+
let i = e[r];
|
|
305
|
+
if (i.id === t) return n;
|
|
306
|
+
if (i.type === "section") for (let e = 0; e < i.children.length; e++) {
|
|
307
|
+
let n = re(i.children[e], t, {
|
|
308
|
+
blocks: i.children[e],
|
|
309
|
+
sectionId: i.id,
|
|
310
|
+
columnIndex: e
|
|
311
|
+
});
|
|
312
|
+
if (n) return n;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
function I(e, n = !1) {
|
|
318
|
+
let r = i.value ?? t.lockLocale?.value ?? null;
|
|
319
|
+
for (let [i, a] of t.lockedBlocks?.value ?? []) {
|
|
320
|
+
let o = a;
|
|
321
|
+
if (o?.blockId === void 0) {
|
|
322
|
+
if (i === e) return !0;
|
|
323
|
+
} else if (o.blockId === e && o.holder?.sessionId !== t.lockSessionId && (n || r === null || o.locale == null || o.locale === r)) return !0;
|
|
324
|
+
}
|
|
325
|
+
return !1;
|
|
326
|
+
}
|
|
327
|
+
function ie(e) {
|
|
328
|
+
let t = re(r.content.blocks, e);
|
|
329
|
+
if (!t) return null;
|
|
330
|
+
let n = t.blocks.findIndex((t) => t.id === e);
|
|
331
|
+
return n === -1 ? null : {
|
|
332
|
+
targetSectionId: t.sectionId,
|
|
333
|
+
columnIndex: t.columnIndex,
|
|
334
|
+
index: n
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function oe(e, t = !0) {
|
|
338
|
+
W(e), E(e), r.content = e, t && j();
|
|
339
|
+
}
|
|
340
|
+
function V(e) {
|
|
341
|
+
e && I(e) || (r.selectedBlockId = e);
|
|
342
|
+
}
|
|
343
|
+
function U(e) {
|
|
344
|
+
r.viewport = e;
|
|
345
|
+
}
|
|
346
|
+
function ce(e) {
|
|
347
|
+
r.darkMode = e;
|
|
348
|
+
}
|
|
349
|
+
function ue(e) {
|
|
350
|
+
r.uiTheme = e;
|
|
351
|
+
}
|
|
352
|
+
function de(e) {
|
|
353
|
+
r.previewMode = e, e && (r.selectedBlockId = null);
|
|
354
|
+
}
|
|
355
|
+
function fe(e, t) {
|
|
356
|
+
if (!s()) return !1;
|
|
357
|
+
let n = F(r.content.blocks, e);
|
|
358
|
+
if (!n) return !1;
|
|
359
|
+
if ("l10n" in t) throw new R("l10n is immutable in updateBlock.", void 0, "invalid_operation");
|
|
360
|
+
let i = {
|
|
361
|
+
...n,
|
|
362
|
+
...t
|
|
363
|
+
};
|
|
364
|
+
return !I(e, ke(H(n), i, (e) => F(r.content.blocks, e)));
|
|
365
|
+
}
|
|
366
|
+
function pe(e, n) {
|
|
367
|
+
if (!fe(e, n)) return;
|
|
368
|
+
let o = F(r.content.blocks, e);
|
|
369
|
+
if (!o) return;
|
|
370
|
+
let s = i.value;
|
|
371
|
+
if (s) {
|
|
372
|
+
let i = A(o, s, z(r.content)), c = {
|
|
373
|
+
...i,
|
|
374
|
+
...n
|
|
375
|
+
}, l = H(o), u = ke(l, c, (e) => F(r.content.blocks, e));
|
|
376
|
+
if (I(e, u)) return;
|
|
377
|
+
u && t.onStructureChange?.();
|
|
378
|
+
let d = ee(l);
|
|
379
|
+
delete o.l10n, Object.assign(o, d), _(o, Y(o.l10n?.[s], q(o, i, o.l10n?.[s], a), q(o, c, o.l10n?.[s], a), o, c));
|
|
380
|
+
} else {
|
|
381
|
+
if (I(e, "children" in n || "columns" in n)) return;
|
|
382
|
+
let t = ee({
|
|
383
|
+
...o,
|
|
384
|
+
...n
|
|
385
|
+
});
|
|
386
|
+
delete o.l10n, Object.assign(o, t);
|
|
387
|
+
}
|
|
388
|
+
j();
|
|
389
|
+
}
|
|
390
|
+
function me(e) {
|
|
391
|
+
if ("locales" in e || "l10n" in e) throw new R("locales and l10n are immutable in updateSettings.", void 0, "invalid_operation");
|
|
392
|
+
if ("locale" in e && e.locale !== z(r.content) && r.content.settings.locales?.length) throw new R("The default locale can't change while language versions exist.", void 0, "invalid_operation");
|
|
393
|
+
}
|
|
394
|
+
function ge(e) {
|
|
395
|
+
if (!s()) return;
|
|
396
|
+
me(e);
|
|
397
|
+
let t = i.value;
|
|
398
|
+
if (!t) r.content.settings = le({
|
|
399
|
+
...r.content.settings,
|
|
400
|
+
...e
|
|
401
|
+
});
|
|
402
|
+
else {
|
|
403
|
+
let n = r.content.settings, i = ae(r.content, t).settings, a = {
|
|
404
|
+
...i,
|
|
405
|
+
locale: n.locale,
|
|
406
|
+
...e
|
|
407
|
+
}, o = n.l10n?.[t], s = Y(o, J(n, i, o), J(n, a, o), n, a);
|
|
408
|
+
Object.keys(s).length ? n.l10n = {
|
|
409
|
+
...n.l10n,
|
|
410
|
+
[t]: s
|
|
411
|
+
} : n.l10n && (delete n.l10n[t], Object.keys(n.l10n).length || delete n.l10n);
|
|
412
|
+
}
|
|
413
|
+
j();
|
|
414
|
+
}
|
|
415
|
+
let _e = {
|
|
416
|
+
canEdit: s,
|
|
417
|
+
content: () => r.content,
|
|
418
|
+
findBlock: (e) => F(r.content.blocks, e),
|
|
419
|
+
findBlockLocation: ie,
|
|
420
|
+
isBlockLocked: I
|
|
421
|
+
};
|
|
422
|
+
function ve(e, n, a = 0, o) {
|
|
423
|
+
if (je(_e, "addBlock", [
|
|
424
|
+
e,
|
|
425
|
+
n,
|
|
426
|
+
a,
|
|
427
|
+
o
|
|
428
|
+
])) {
|
|
429
|
+
if (n) {
|
|
430
|
+
let t = F(r.content.blocks, n);
|
|
431
|
+
if (t && t.type === "section") {
|
|
432
|
+
t.children[a] = t.children[a] || [];
|
|
433
|
+
let n = t.children[a];
|
|
434
|
+
o !== void 0 && o < n.length ? n.splice(o, 0, e) : n.push(e);
|
|
435
|
+
}
|
|
436
|
+
} else o !== void 0 && o < r.content.blocks.length ? r.content.blocks.splice(o, 0, e) : r.content.blocks.push(e);
|
|
437
|
+
i.value && t.onStructureChange?.(), j();
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
function ye(e) {
|
|
441
|
+
if (!je(_e, "removeBlock", [e])) return;
|
|
442
|
+
let n = re(r.content.blocks, e);
|
|
443
|
+
if (n) {
|
|
444
|
+
let a = n.blocks.findIndex((t) => t.id === e);
|
|
445
|
+
if (a !== -1) {
|
|
446
|
+
let [e] = n.blocks.splice(a, 1);
|
|
447
|
+
if (r.selectedBlockId) {
|
|
448
|
+
let t = /* @__PURE__ */ new Set();
|
|
449
|
+
ne(e, t), t.has(r.selectedBlockId) && (r.selectedBlockId = null);
|
|
450
|
+
}
|
|
451
|
+
i.value && t.onStructureChange?.(), j();
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
function be(e, n, a, o = 0) {
|
|
456
|
+
if (!je(_e, "moveBlock", [
|
|
457
|
+
e,
|
|
458
|
+
n,
|
|
459
|
+
a,
|
|
460
|
+
o
|
|
461
|
+
])) return;
|
|
462
|
+
let s = re(r.content.blocks, e), c = s.blocks.findIndex((t) => t.id === e), l;
|
|
463
|
+
if (a) {
|
|
464
|
+
let e = F(r.content.blocks, a);
|
|
465
|
+
e.children[o] = e.children[o] || [], l = e.children[o];
|
|
466
|
+
} else l = r.content.blocks;
|
|
467
|
+
let [u] = s.blocks.splice(c, 1);
|
|
468
|
+
l.splice(n, 0, u), i.value && t.onStructureChange?.(), j();
|
|
469
|
+
}
|
|
470
|
+
function xe() {
|
|
471
|
+
j();
|
|
472
|
+
}
|
|
473
|
+
function Se(e, t) {
|
|
474
|
+
throw new R(`[Templatical] Templates: ${e} ${t}`);
|
|
475
|
+
}
|
|
476
|
+
function Ce(e) {
|
|
477
|
+
Q(t.onError, e);
|
|
478
|
+
}
|
|
479
|
+
function we(e) {
|
|
480
|
+
let { templates: n } = t;
|
|
481
|
+
return n || Se(e, "needs a templates provider. Pass one as `init({ templates })` to enable saving and loading."), n;
|
|
482
|
+
}
|
|
483
|
+
function Te(e) {
|
|
484
|
+
r.template && (r.template = {
|
|
485
|
+
...r.template,
|
|
486
|
+
name: e
|
|
487
|
+
}, j());
|
|
488
|
+
}
|
|
489
|
+
async function G(e) {
|
|
490
|
+
let n = we("create()"), { create: i } = n;
|
|
491
|
+
typeof i != "function" && Se("create()", "is disabled by the provider — its `create` is `false`.");
|
|
492
|
+
let a, o = ++O;
|
|
493
|
+
r.isLoading = !0;
|
|
494
|
+
try {
|
|
495
|
+
e?.content && (r.content = e.content);
|
|
496
|
+
let t = k;
|
|
497
|
+
a = await i(e?.name === void 0 ? { content: r.content } : {
|
|
498
|
+
name: e.name,
|
|
499
|
+
content: r.content
|
|
500
|
+
}), r.template = a, k === t && (r.isDirty = !1), D.value++;
|
|
501
|
+
} catch (e) {
|
|
502
|
+
throw t.onError?.(e), e;
|
|
503
|
+
} finally {
|
|
504
|
+
O === o && (r.isLoading = !1);
|
|
505
|
+
}
|
|
506
|
+
return Ce(() => n.onCreated?.(a)), a;
|
|
507
|
+
}
|
|
508
|
+
async function Ee(e, n) {
|
|
509
|
+
let i = we("load()"), a, o = ++O;
|
|
510
|
+
r.isLoading = !0;
|
|
511
|
+
try {
|
|
512
|
+
if (a = await i.load(e), W(a.content), E(a.content), n && !n()) return a;
|
|
513
|
+
r.template = a, r.content = a.content, r.isDirty = !1, D.value++;
|
|
514
|
+
} catch (e) {
|
|
515
|
+
throw t.onError?.(e), e;
|
|
516
|
+
} finally {
|
|
517
|
+
O === o && (r.isLoading = !1);
|
|
518
|
+
}
|
|
519
|
+
return Ce(() => i.onLoaded?.(a)), a;
|
|
520
|
+
}
|
|
521
|
+
async function De(e = "api") {
|
|
522
|
+
let n = we("save()"), { save: i } = n;
|
|
523
|
+
typeof i != "function" && Se("save()", "is disabled by the provider — its `save` is `false`.");
|
|
524
|
+
let a = r.template;
|
|
525
|
+
a || Se("save()", "has no template loaded. Call create() or load() first.");
|
|
526
|
+
let o = a.name === void 0 ? { content: r.content } : {
|
|
527
|
+
name: a.name,
|
|
528
|
+
content: r.content
|
|
529
|
+
}, s;
|
|
530
|
+
r.isSaving = !0;
|
|
531
|
+
try {
|
|
532
|
+
let e = k;
|
|
533
|
+
if (s = await i(a.id, o), r.template?.id === a.id) {
|
|
534
|
+
let e = r.template.name;
|
|
535
|
+
r.template = e === a.name ? s : {
|
|
536
|
+
...s,
|
|
537
|
+
name: e
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
k === e && (r.isDirty = !1);
|
|
541
|
+
} catch (e) {
|
|
542
|
+
throw t.onError?.(e), e;
|
|
543
|
+
} finally {
|
|
544
|
+
r.isSaving = !1;
|
|
545
|
+
}
|
|
546
|
+
return Ce(() => n.onSaved?.(s, { trigger: e })), s;
|
|
547
|
+
}
|
|
548
|
+
function K() {
|
|
549
|
+
return r.template?.id !== void 0;
|
|
550
|
+
}
|
|
551
|
+
let X = {
|
|
552
|
+
state: m(r),
|
|
553
|
+
loadVersion: m(D),
|
|
554
|
+
content: M,
|
|
555
|
+
selectedBlock: P,
|
|
556
|
+
activeLocale: i,
|
|
557
|
+
setActiveLocale: o,
|
|
558
|
+
addLocale: p,
|
|
559
|
+
removeLocale: g,
|
|
560
|
+
setBlockHidden: x,
|
|
561
|
+
resetLocaleFields: C,
|
|
562
|
+
keepTranslations: w,
|
|
563
|
+
setCustomBlockDefinitions: c,
|
|
564
|
+
createSetDefaultLocaleOperation: l,
|
|
565
|
+
isBlockLocked: I,
|
|
566
|
+
setContent: oe,
|
|
567
|
+
selectBlock: V,
|
|
568
|
+
setViewport: U,
|
|
569
|
+
setDarkMode: ce,
|
|
570
|
+
setUiTheme: ue,
|
|
571
|
+
setPreviewMode: de,
|
|
572
|
+
updateBlock: pe,
|
|
573
|
+
updateSettings: ge,
|
|
574
|
+
addBlock: ve,
|
|
575
|
+
removeBlock: ye,
|
|
576
|
+
moveBlock: be,
|
|
577
|
+
markDirty: xe,
|
|
578
|
+
findBlockLocation: ie,
|
|
579
|
+
setName: Te,
|
|
580
|
+
create: G,
|
|
581
|
+
load: Ee,
|
|
582
|
+
save: De,
|
|
583
|
+
hasTemplate: K
|
|
584
|
+
};
|
|
585
|
+
return Me(X, (e, t) => Ae(e) ? je(_e, e, t) : s() ? e === "updateBlock" ? fe(t[0], t[1]) : (e === "updateSettings" && me(t[0]), e === "addLocale" || e === "removeLocale" ? d(e, t[0]) !== null : e === "setBlockHidden" || e === "resetLocaleFields" || e === "keepTranslations" ? v(e, t) !== null : !0) : !1), X;
|
|
586
|
+
}
|
|
587
|
+
// ../core/src/history.ts
|
|
588
|
+
var Ie = 50, Le = 300, Re = 1500;
|
|
589
|
+
function ze(e) {
|
|
590
|
+
let { content: t, setContent: n, maxSize: r = Ie } = e, i = S([]), a = S([]), o = S(!1), s = null, c = null, l = b(() => i.value.length > 0), u = b(() => a.value.length > 0);
|
|
591
|
+
function d() {
|
|
592
|
+
return H(t.value);
|
|
593
|
+
}
|
|
594
|
+
function f(e) {
|
|
595
|
+
i.value.push(e), i.value.length > r && i.value.splice(0, i.value.length - r);
|
|
596
|
+
}
|
|
597
|
+
function p() {
|
|
598
|
+
c &&= (clearTimeout(c.timeoutId), null);
|
|
599
|
+
}
|
|
600
|
+
function m() {
|
|
601
|
+
p(), f(d()), a.value = [];
|
|
602
|
+
}
|
|
603
|
+
function h(e) {
|
|
604
|
+
c && c.blockId === e ? (clearTimeout(c.timeoutId), c.timeoutId = setTimeout(() => {
|
|
605
|
+
c = null;
|
|
606
|
+
}, Le)) : (p(), f(d()), a.value = [], c = {
|
|
607
|
+
blockId: e,
|
|
608
|
+
timeoutId: setTimeout(() => {
|
|
609
|
+
c = null;
|
|
610
|
+
}, Le)
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
function g() {
|
|
614
|
+
o.value = !0, s && clearTimeout(s), s = setTimeout(() => {
|
|
615
|
+
o.value = !1, s = null;
|
|
616
|
+
}, Re);
|
|
617
|
+
}
|
|
618
|
+
function _() {
|
|
619
|
+
if (i.value.length === 0) return;
|
|
620
|
+
p();
|
|
621
|
+
let e = i.value.pop();
|
|
622
|
+
a.value.push(d()), n(e, !0), g();
|
|
623
|
+
}
|
|
624
|
+
function v() {
|
|
625
|
+
if (a.value.length === 0) return;
|
|
626
|
+
p();
|
|
627
|
+
let e = a.value.pop();
|
|
628
|
+
i.value.push(d()), n(e, !0), g();
|
|
629
|
+
}
|
|
630
|
+
function y() {
|
|
631
|
+
i.value = [], a.value = [], p();
|
|
632
|
+
}
|
|
633
|
+
function x() {
|
|
634
|
+
y(), s &&= (clearTimeout(s), null);
|
|
635
|
+
}
|
|
636
|
+
return {
|
|
637
|
+
canUndo: l,
|
|
638
|
+
canRedo: u,
|
|
639
|
+
isNavigating: o,
|
|
640
|
+
undo: _,
|
|
641
|
+
redo: v,
|
|
642
|
+
record: m,
|
|
643
|
+
recordDebounced: h,
|
|
644
|
+
clear: y,
|
|
645
|
+
destroy: x,
|
|
646
|
+
flushDebounce: p
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
// ../core/src/block-actions.ts
|
|
650
|
+
function Be(e) {
|
|
651
|
+
let { addBlock: t, removeBlock: n, updateBlock: r, selectBlock: i, findBlockLocation: a } = e;
|
|
652
|
+
function o(n, r, a) {
|
|
653
|
+
let o = typeof e.blockDefaults == "function" ? e.blockDefaults() : e.blockDefaults, s = I(n, o);
|
|
654
|
+
return t(s, r, a), i(s.id), s;
|
|
655
|
+
}
|
|
656
|
+
function s(e, n, r) {
|
|
657
|
+
let o = F(e);
|
|
658
|
+
if (!Z(t, "duplicateBlock", [
|
|
659
|
+
e,
|
|
660
|
+
n,
|
|
661
|
+
r
|
|
662
|
+
])) return o;
|
|
663
|
+
if (n !== void 0 || r !== void 0) t(o, n, r);
|
|
664
|
+
else {
|
|
665
|
+
let i = a?.(e.id) ?? null;
|
|
666
|
+
i ? t(o, i.targetSectionId, i.columnIndex, i.index + 1) : t(o, n, r);
|
|
667
|
+
}
|
|
668
|
+
return i(o.id), o;
|
|
669
|
+
}
|
|
670
|
+
function c(e) {
|
|
671
|
+
n(e);
|
|
672
|
+
}
|
|
673
|
+
function l(e, t, n) {
|
|
674
|
+
r(e, { [t]: n });
|
|
675
|
+
}
|
|
676
|
+
return {
|
|
677
|
+
createAndAddBlock: o,
|
|
678
|
+
duplicateBlock: s,
|
|
679
|
+
deleteBlock: c,
|
|
680
|
+
updateBlockProperty: l
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
// ../core/src/auto-save.ts
|
|
684
|
+
var Ve = 2e3;
|
|
685
|
+
function He(e) {
|
|
686
|
+
let { content: t, isDirty: n, onChange: r, debounce: i = Ve, enabled: a = !0 } = e, o = null, s = !1;
|
|
687
|
+
function c() {
|
|
688
|
+
return typeof a == "function" ? a() : a;
|
|
689
|
+
}
|
|
690
|
+
function l() {
|
|
691
|
+
s = !0, d();
|
|
692
|
+
}
|
|
693
|
+
function u() {
|
|
694
|
+
s = !1;
|
|
695
|
+
}
|
|
696
|
+
function d() {
|
|
697
|
+
o &&= (clearTimeout(o), null);
|
|
698
|
+
}
|
|
699
|
+
function f() {
|
|
700
|
+
d(), n() && r(JSON.parse(JSON.stringify(t.value)));
|
|
701
|
+
}
|
|
702
|
+
function p() {
|
|
703
|
+
c() && !s && (d(), o = setTimeout(() => {
|
|
704
|
+
o = null, c() && !s && n() && r(JSON.parse(JSON.stringify(t.value)));
|
|
705
|
+
}, i));
|
|
706
|
+
}
|
|
707
|
+
let m = h(t, () => {
|
|
708
|
+
p();
|
|
709
|
+
}, { deep: !0 });
|
|
710
|
+
function g() {
|
|
711
|
+
m(), d();
|
|
712
|
+
}
|
|
713
|
+
return {
|
|
714
|
+
flush: f,
|
|
715
|
+
cancel: d,
|
|
716
|
+
pause: l,
|
|
717
|
+
resume: u,
|
|
718
|
+
destroy: g
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
// ../core/src/condition-preview.ts
|
|
722
|
+
function Ue(t) {
|
|
723
|
+
let n = e(/* @__PURE__ */ new Set()), r = b(() => n.size > 0);
|
|
724
|
+
function i(e) {
|
|
725
|
+
return n.has(e);
|
|
726
|
+
}
|
|
727
|
+
function a(e) {
|
|
728
|
+
n.has(e) ? n.delete(e) : (n.add(e), t.state.selectedBlockId === e && t.selectBlock(null));
|
|
729
|
+
}
|
|
730
|
+
function o() {
|
|
731
|
+
n.clear();
|
|
732
|
+
}
|
|
733
|
+
return {
|
|
734
|
+
isHidden: i,
|
|
735
|
+
toggleBlock: a,
|
|
736
|
+
reset: o,
|
|
737
|
+
hasHiddenBlocks: r
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
// ../core/src/data-source-fetch.ts
|
|
741
|
+
function We(e) {
|
|
742
|
+
let t = S(!1), n = S(!1), r = b(() => !!e.definition.value?.dataSource), i = b(() => r.value && !e.block.value.dataSourceFetched);
|
|
743
|
+
async function a() {
|
|
744
|
+
let r = e.definition.value;
|
|
745
|
+
if (r?.dataSource) {
|
|
746
|
+
t.value = !0, n.value = !1;
|
|
747
|
+
try {
|
|
748
|
+
let t = await r.dataSource.onFetch({
|
|
749
|
+
fieldValues: { ...e.block.value.fieldValues },
|
|
750
|
+
blockId: e.block.value.id
|
|
751
|
+
});
|
|
752
|
+
if (t == null) return;
|
|
753
|
+
let n = { ...e.block.value.fieldValues };
|
|
754
|
+
for (let e of Object.keys(n)) e in t && (n[e] = t[e]);
|
|
755
|
+
e.onUpdate(n, !0);
|
|
756
|
+
} catch (e) {
|
|
757
|
+
console.warn("[Templatical] Data source fetch error:", e), n.value = !0;
|
|
758
|
+
} finally {
|
|
759
|
+
t.value = !1;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
return {
|
|
764
|
+
isFetching: t,
|
|
765
|
+
fetchError: n,
|
|
766
|
+
fetch: a,
|
|
767
|
+
hasDataSource: r,
|
|
768
|
+
needsFetch: i
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
// ../core/src/history-interceptor.ts
|
|
772
|
+
function Ge(e, t) {
|
|
773
|
+
e.activeLocale && h(e.activeLocale, () => t.flushDebounce?.());
|
|
774
|
+
for (let n of [
|
|
775
|
+
"addLocale",
|
|
776
|
+
"removeLocale",
|
|
777
|
+
"setBlockHidden",
|
|
778
|
+
"resetLocaleFields",
|
|
779
|
+
"keepTranslations"
|
|
780
|
+
]) {
|
|
781
|
+
let r = e[n];
|
|
782
|
+
r && (Object.assign(e, { [n]: (...i) => {
|
|
783
|
+
Z(e, n, i) && (["addLocale", "removeLocale"].includes(n) || !e.isBlockLocked(i[0])) && (t.record(), r(...i));
|
|
784
|
+
} }), Ne(r, e[n]));
|
|
785
|
+
}
|
|
786
|
+
let n = e.addBlock, r = e.removeBlock, i = e.moveBlock, a = e.updateBlock, o = e.updateSettings;
|
|
787
|
+
e.addBlock = (r, i, a, o) => {
|
|
788
|
+
Z(e, "addBlock", [
|
|
789
|
+
r,
|
|
790
|
+
i,
|
|
791
|
+
a,
|
|
792
|
+
o
|
|
793
|
+
]) && (t.record(), n(r, i, a, o));
|
|
794
|
+
}, e.removeBlock = (n) => {
|
|
795
|
+
Z(e, "removeBlock", [n]) && (t.record(), r(n));
|
|
796
|
+
}, e.moveBlock = (n, r, a, o) => {
|
|
797
|
+
Z(e, "moveBlock", [
|
|
798
|
+
n,
|
|
799
|
+
r,
|
|
800
|
+
a,
|
|
801
|
+
o
|
|
802
|
+
]) && (t.record(), i(n, r, a, o));
|
|
803
|
+
}, Ne(n, e.addBlock), Ne(r, e.removeBlock), Ne(i, e.moveBlock), e.updateBlock = (n, r) => {
|
|
804
|
+
Z(e, "updateBlock", [n, r]) && (e.isBlockLocked(n) || (t.recordDebounced(n), a(n, r)));
|
|
805
|
+
}, e.updateSettings = (n) => {
|
|
806
|
+
Z(e, "updateSettings", [n]) && (t.record(), o(n));
|
|
807
|
+
}, Ne(a, e.updateBlock), Ne(o, e.updateSettings);
|
|
808
|
+
}
|
|
809
|
+
// ../core/src/diff-content.ts
|
|
810
|
+
var Ke = "root", qe = /* @__PURE__ */ new Set([
|
|
811
|
+
"id",
|
|
812
|
+
"type",
|
|
813
|
+
"children",
|
|
814
|
+
"l10n"
|
|
815
|
+
]), Je = /* @__PURE__ */ new Set([
|
|
816
|
+
"id",
|
|
817
|
+
"type",
|
|
818
|
+
"children",
|
|
819
|
+
"columns",
|
|
820
|
+
"l10n"
|
|
821
|
+
]), Ye = /* @__PURE__ */ new Set(), Xe = /* @__PURE__ */ new Set(["locales", "l10n"]);
|
|
822
|
+
function Ze(e) {
|
|
823
|
+
return e === null ? Ke : JSON.stringify([e.sectionId, e.column]);
|
|
824
|
+
}
|
|
825
|
+
function Qe(e) {
|
|
826
|
+
let t = e.children;
|
|
827
|
+
return e.type === "section" && Array.isArray(t) ? t : [];
|
|
828
|
+
}
|
|
829
|
+
function $e(e) {
|
|
830
|
+
let t = /* @__PURE__ */ new Map(), n = (e, r) => {
|
|
831
|
+
e.forEach((e, i) => {
|
|
832
|
+
t.has(e.id) || t.set(e.id, {
|
|
833
|
+
block: e,
|
|
834
|
+
key: Ze(r),
|
|
835
|
+
index: i
|
|
836
|
+
}), Qe(e).forEach((t, r) => {
|
|
837
|
+
Array.isArray(t) && n(t, {
|
|
838
|
+
sectionId: e.id,
|
|
839
|
+
column: r
|
|
840
|
+
});
|
|
841
|
+
});
|
|
842
|
+
});
|
|
843
|
+
};
|
|
844
|
+
return n(e, null), t;
|
|
845
|
+
}
|
|
846
|
+
function et(e) {
|
|
847
|
+
let t = [], n = Array(e.length).fill(-1);
|
|
848
|
+
e.forEach((r, i) => {
|
|
849
|
+
let a = 0, o = t.length;
|
|
850
|
+
for (; a < o;) {
|
|
851
|
+
let n = a + o >> 1;
|
|
852
|
+
e[t[n]] < r ? a = n + 1 : o = n;
|
|
853
|
+
}
|
|
854
|
+
a > 0 && (n[i] = t[a - 1]), t[a] = i;
|
|
855
|
+
});
|
|
856
|
+
let r = /* @__PURE__ */ new Set(), i = t.length > 0 ? t[t.length - 1] : -1;
|
|
857
|
+
for (; i !== -1;) r.add(i), i = n[i];
|
|
858
|
+
return r;
|
|
859
|
+
}
|
|
860
|
+
function tt(e, t, n) {
|
|
861
|
+
let r = {}, i = [];
|
|
862
|
+
for (let i of Object.keys(t)) n.has(i) || t[i] === void 0 || T(e[i], t[i]) || (r[i] = H(t[i]));
|
|
863
|
+
for (let r of Object.keys(e)) n.has(r) || e[r] === void 0 || t[r] === void 0 && i.push(r);
|
|
864
|
+
return {
|
|
865
|
+
set: r,
|
|
866
|
+
unset: i
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
function nt(e = {}, t = {}) {
|
|
870
|
+
let n = tt(e.text ?? {}, t.text ?? {}, Ye), r = tt(e.set ?? {}, t.set ?? {}, Ye), i = [.../* @__PURE__ */ new Set([...n.unset, ...r.unset])];
|
|
871
|
+
return {
|
|
872
|
+
...Object.keys(n.set).length > 0 ? { text: n.set } : {},
|
|
873
|
+
...Object.keys(r.set).length > 0 ? { set: r.set } : {},
|
|
874
|
+
...i.length > 0 ? { unset: i } : {},
|
|
875
|
+
...e.hidden === t.hidden ? {} : { hidden: t.hidden === !0 }
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
function rt(e, t) {
|
|
879
|
+
if (e.settings.locale !== t.settings.locale && (e.settings.locales?.length || t.settings.locales?.length)) return [{
|
|
880
|
+
op: "setContent",
|
|
881
|
+
content: H(t)
|
|
882
|
+
}];
|
|
883
|
+
let n = $e(e.blocks), r = $e(t.blocks), i = [], a = (e) => {
|
|
884
|
+
let t = r.get(e), i = n.get(e);
|
|
885
|
+
return t !== void 0 && i !== void 0 && t.block.type !== i.block.type;
|
|
886
|
+
}, o = (e) => r.has(e.id) && !a(e.id), s = (e) => Qe(e).some((e) => Array.isArray(e) && e.some((e) => o(e) || !a(e.id) && s(e))), c = /* @__PURE__ */ new Set(), l = [], u = (e, t) => {
|
|
887
|
+
let n = "kept";
|
|
888
|
+
t === "dropped" ? (c.add(e.id), n = "dropped") : a(e.id) ? (i.push({
|
|
889
|
+
op: "deleteBlock",
|
|
890
|
+
blockId: e.id
|
|
891
|
+
}), c.add(e.id), n = "dropped") : r.has(e.id) || (t === "deferred" ? n = "deferred" : s(e) ? (l.push(e.id), n = "deferred") : (i.push({
|
|
892
|
+
op: "deleteBlock",
|
|
893
|
+
blockId: e.id
|
|
894
|
+
}), c.add(e.id), n = "dropped"));
|
|
895
|
+
for (let t of Qe(e)) if (Array.isArray(t)) for (let e of t) u(e, n);
|
|
896
|
+
};
|
|
897
|
+
for (let t of e.blocks) u(t, "kept");
|
|
898
|
+
let d = (e) => n.has(e) && !c.has(e), f = (e) => {
|
|
899
|
+
let t = H(e);
|
|
900
|
+
return t.type === "section" && (t.children = Qe(e).map((e) => Array.isArray(e) ? e.filter((e) => !d(e.id)).map((e) => H(e)) : e)), t;
|
|
901
|
+
}, p = (e, t, r) => {
|
|
902
|
+
let a = Ze(e), o = [], s = [];
|
|
903
|
+
t.forEach((e, t) => {
|
|
904
|
+
let r = n.get(e.id);
|
|
905
|
+
d(e.id) && r !== void 0 && r.key === a && (o.push(r.index), s.push(t));
|
|
906
|
+
});
|
|
907
|
+
let c = new Set([...et(o)].map((e) => s[e]));
|
|
908
|
+
t.forEach((n, a) => {
|
|
909
|
+
if (c.has(a) || r(n)) return;
|
|
910
|
+
let o = a > 0 ? t[a - 1].id : null;
|
|
911
|
+
i.push(d(n.id) ? {
|
|
912
|
+
op: "moveBlock",
|
|
913
|
+
blockId: n.id,
|
|
914
|
+
parent: e,
|
|
915
|
+
after: o
|
|
916
|
+
} : {
|
|
917
|
+
op: "addBlock",
|
|
918
|
+
block: f(n),
|
|
919
|
+
parent: e,
|
|
920
|
+
after: o
|
|
921
|
+
});
|
|
922
|
+
});
|
|
923
|
+
};
|
|
924
|
+
p(null, t.blocks, () => !1);
|
|
925
|
+
let m = t.blocks.filter((e) => e.type === "section"), h = /* @__PURE__ */ new Set(), g = (e) => {
|
|
926
|
+
for (let t of m) {
|
|
927
|
+
if (!d(t.id)) continue;
|
|
928
|
+
let r = Qe(n.get(t.id).block).length, a = Qe(t).length;
|
|
929
|
+
(e ? a > r : a < r) && (i.push({
|
|
930
|
+
op: "updateBlock",
|
|
931
|
+
blockId: t.id,
|
|
932
|
+
set: { columns: t.columns }
|
|
933
|
+
}), h.add(t.id));
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
g(!0);
|
|
937
|
+
for (let e of m) {
|
|
938
|
+
let t = !d(e.id);
|
|
939
|
+
Qe(e).forEach((n, r) => {
|
|
940
|
+
Array.isArray(n) && p({
|
|
941
|
+
sectionId: e.id,
|
|
942
|
+
column: r
|
|
943
|
+
}, n, (e) => t && !d(e.id));
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
g(!1);
|
|
947
|
+
for (let e of l) i.push({
|
|
948
|
+
op: "deleteBlock",
|
|
949
|
+
blockId: e
|
|
950
|
+
});
|
|
951
|
+
for (let [e, t] of r) {
|
|
952
|
+
if (!d(e)) continue;
|
|
953
|
+
let { set: r, unset: a } = tt(n.get(e).block, t.block, h.has(e) ? Je : qe);
|
|
954
|
+
(Object.keys(r).length !== 0 || a.length !== 0) && i.push({
|
|
955
|
+
op: "updateBlock",
|
|
956
|
+
blockId: e,
|
|
957
|
+
...Object.keys(r).length > 0 ? { set: r } : {},
|
|
958
|
+
...a.length > 0 ? { unset: a } : {}
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
let _ = tt(e.settings, t.settings, Xe);
|
|
962
|
+
(Object.keys(_.set).length > 0 || _.unset.length > 0) && i.push({
|
|
963
|
+
op: "updateSettings",
|
|
964
|
+
...Object.keys(_.set).length > 0 ? { set: _.set } : {},
|
|
965
|
+
..._.unset.length > 0 ? { unset: _.unset } : {}
|
|
966
|
+
});
|
|
967
|
+
let v = new Set(e.settings.locales ?? []), y = new Set(t.settings.locales ?? []);
|
|
968
|
+
for (let e of y) v.has(e) || i.push({
|
|
969
|
+
op: "addLocale",
|
|
970
|
+
locale: e
|
|
971
|
+
});
|
|
972
|
+
for (let [e, t] of r) {
|
|
973
|
+
if (!d(e)) continue;
|
|
974
|
+
let r = n.get(e).block.l10n ?? {}, a = t.block.l10n ?? {};
|
|
975
|
+
for (let t of /* @__PURE__ */ new Set([...Object.keys(r), ...Object.keys(a)])) {
|
|
976
|
+
if (!y.has(t)) continue;
|
|
977
|
+
let n = nt(r[t], a[t]);
|
|
978
|
+
Object.keys(n).length > 0 && i.push({
|
|
979
|
+
op: "updateBlockLocale",
|
|
980
|
+
blockId: e,
|
|
981
|
+
locale: t,
|
|
982
|
+
...n
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
let b = e.settings.l10n ?? {}, x = t.settings.l10n ?? {};
|
|
987
|
+
for (let e of /* @__PURE__ */ new Set([...Object.keys(b), ...Object.keys(x)])) {
|
|
988
|
+
if (!y.has(e)) continue;
|
|
989
|
+
let t = nt(b[e], x[e]);
|
|
990
|
+
Object.keys(t).length > 0 && i.push({
|
|
991
|
+
op: "updateSettingsLocale",
|
|
992
|
+
locale: e,
|
|
993
|
+
...t
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
for (let e of v) y.has(e) || i.push({
|
|
997
|
+
op: "removeLocale",
|
|
998
|
+
locale: e
|
|
999
|
+
});
|
|
1000
|
+
return i;
|
|
1001
|
+
}
|
|
1002
|
+
// ../core/src/localized-operations.ts
|
|
1003
|
+
function $(e) {
|
|
1004
|
+
let t = /* @__PURE__ */ new Map(), n = (e) => {
|
|
1005
|
+
t.set(e.id, e), e.type === "section" && e.children.flat().forEach(n);
|
|
1006
|
+
};
|
|
1007
|
+
return e.forEach(n), t;
|
|
1008
|
+
}
|
|
1009
|
+
function it(e, t) {
|
|
1010
|
+
if (t === null) return e.blocks;
|
|
1011
|
+
let n = $(e.blocks).get(t.sectionId);
|
|
1012
|
+
return n.type === "section" ? n.children[t.column] : [];
|
|
1013
|
+
}
|
|
1014
|
+
function at(e, t) {
|
|
1015
|
+
let n = (e, r) => {
|
|
1016
|
+
let i = e.findIndex((e) => e.id === t);
|
|
1017
|
+
if (i >= 0) return {
|
|
1018
|
+
parent: r,
|
|
1019
|
+
after: e[i - 1]?.id ?? null
|
|
1020
|
+
};
|
|
1021
|
+
for (let t of e) if (t.type === "section") for (let [e, r] of t.children.entries()) {
|
|
1022
|
+
let i = n(r, {
|
|
1023
|
+
sectionId: t.id,
|
|
1024
|
+
column: e
|
|
1025
|
+
});
|
|
1026
|
+
if (i) return i;
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
return n(e.blocks, null);
|
|
1030
|
+
}
|
|
1031
|
+
function ot(e, t, n, r, i) {
|
|
1032
|
+
if (r !== null) return r;
|
|
1033
|
+
let a = it(t, n).find((e) => e.id !== i), o = it(e, n).filter((e) => e.id !== i);
|
|
1034
|
+
return o[(a ? o.findIndex((e) => e.id === a.id) : o.length) - 1]?.id ?? null;
|
|
1035
|
+
}
|
|
1036
|
+
function st(e, t, n) {
|
|
1037
|
+
Object.keys(n).length ? (e.l10n ??= {})[t] = n : e.l10n && (delete e.l10n[t], Object.keys(e.l10n).length || delete e.l10n);
|
|
1038
|
+
}
|
|
1039
|
+
function ct(e) {
|
|
1040
|
+
let t = H(e);
|
|
1041
|
+
return delete t.l10n, t.type === "section" && (t.children = t.children.map((e) => e.map(ct))), t;
|
|
1042
|
+
}
|
|
1043
|
+
function lt(e, t, n, r) {
|
|
1044
|
+
let i = ae(e, t), a = H(e), o = H(i.settings), s = !1, c = /* @__PURE__ */ new Map(), l = (n, r) => {
|
|
1045
|
+
for (let [i, a] of $(n)) c.set(i, {
|
|
1046
|
+
initial: A(a, t, z(e)),
|
|
1047
|
+
added: r,
|
|
1048
|
+
changed: !1
|
|
1049
|
+
});
|
|
1050
|
+
};
|
|
1051
|
+
l(i.blocks, !1);
|
|
1052
|
+
let u = [], d = (e, t, n) => {
|
|
1053
|
+
if (t.some((e) => e?.op === "setDefaultLocale")) throw new U("invalid_operation", n, "Changing the default language isn't possible in a language view; switch to the default language.");
|
|
1054
|
+
if (t.some((e) => e?.op === "setContent")) throw new U("invalid_operation", n, "Replacing the whole template isn't possible in a language view; switch to the default language.");
|
|
1055
|
+
try {
|
|
1056
|
+
return P(e, t);
|
|
1057
|
+
} catch (e) {
|
|
1058
|
+
throw e instanceof U ? new U(e.code, n, e.message, e.blockId) : e;
|
|
1059
|
+
}
|
|
1060
|
+
}, f = (e, t) => {
|
|
1061
|
+
a = d(a, e, t), u.push(...e);
|
|
1062
|
+
}, p = (e, n) => {
|
|
1063
|
+
let o = c.get(e);
|
|
1064
|
+
if (!o?.changed) return;
|
|
1065
|
+
let s = $(a.blocks).get(e), l = $(i.blocks).get(e), u = H(a), d = it(u, at(u, e).parent), p = H(s);
|
|
1066
|
+
if (o.added) p = ct(l), p.type === "section" && s.type === "section" && (p.children = s.children, p.columns = s.columns);
|
|
1067
|
+
else {
|
|
1068
|
+
ke(p, p.type === "section" ? {
|
|
1069
|
+
...l,
|
|
1070
|
+
children: p.children,
|
|
1071
|
+
columns: p.columns
|
|
1072
|
+
} : l, (e) => $(a.blocks).get(e) ?? null), p = ee(p);
|
|
1073
|
+
let e = p.l10n?.[t];
|
|
1074
|
+
st(p, t, Y(e, q(p, o.initial, e, r), q(p, l, e, r), p, l));
|
|
1075
|
+
}
|
|
1076
|
+
d[d.findIndex((t) => t.id === e)] = p, f(rt(a, u), n), o.changed = !1;
|
|
1077
|
+
}, m = (e, t, n) => {
|
|
1078
|
+
let r = $(a.blocks).get(e.blockId), i = $(t.blocks).get(e.blockId);
|
|
1079
|
+
if (r.type !== "section" || i.type !== "section" || r.columns === i.columns) return;
|
|
1080
|
+
let o = i.children.length, s = r.children.slice(0, o), c = r.children.slice(o).flat(), l = [...s[o - 1] ?? [], ...c];
|
|
1081
|
+
for (let [e, t] of c.entries()) f([{
|
|
1082
|
+
op: "moveBlock",
|
|
1083
|
+
blockId: t.id,
|
|
1084
|
+
parent: {
|
|
1085
|
+
sectionId: r.id,
|
|
1086
|
+
column: o - 1
|
|
1087
|
+
},
|
|
1088
|
+
after: l[l.length - c.length + e - 1]?.id ?? null
|
|
1089
|
+
}], n);
|
|
1090
|
+
let u = $(a.blocks).get(e.blockId);
|
|
1091
|
+
f([{
|
|
1092
|
+
op: "updateBlock",
|
|
1093
|
+
blockId: e.blockId,
|
|
1094
|
+
set: { columns: i.columns },
|
|
1095
|
+
...e.expect ? { expect: Object.fromEntries(Object.keys(e.expect).map((e) => [e, N(u, e) ?? null])) } : {}
|
|
1096
|
+
}], n);
|
|
1097
|
+
};
|
|
1098
|
+
n.forEach((e, t) => {
|
|
1099
|
+
e?.op === "updateSettings" && (Object.hasOwn(e.set ?? {}, "locale") || Array.isArray(e.unset) && e.unset.includes("locale")) && d(a, [e], t);
|
|
1100
|
+
let n = d(i, [e], t);
|
|
1101
|
+
switch (e.op) {
|
|
1102
|
+
case "addBlock": {
|
|
1103
|
+
let n = ct(e.block);
|
|
1104
|
+
f([{
|
|
1105
|
+
...e,
|
|
1106
|
+
block: n,
|
|
1107
|
+
after: ot(a, i, e.parent, e.after)
|
|
1108
|
+
}], t), l([n], !0);
|
|
1109
|
+
break;
|
|
1110
|
+
}
|
|
1111
|
+
case "moveBlock":
|
|
1112
|
+
f([{
|
|
1113
|
+
...e,
|
|
1114
|
+
after: ot(a, i, e.parent, e.after, e.blockId),
|
|
1115
|
+
...e.expect ? { expect: at(a, e.blockId) } : {}
|
|
1116
|
+
}], t);
|
|
1117
|
+
break;
|
|
1118
|
+
case "deleteBlock": {
|
|
1119
|
+
let n = [...$([$(a.blocks).get(e.blockId)]).keys()];
|
|
1120
|
+
for (let e of n) p(e, t);
|
|
1121
|
+
f([{
|
|
1122
|
+
op: "deleteBlock",
|
|
1123
|
+
blockId: e.blockId
|
|
1124
|
+
}], t);
|
|
1125
|
+
for (let e of n) c.delete(e);
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1128
|
+
case "updateBlock":
|
|
1129
|
+
m(e, n, t), c.get(e.blockId).changed = !0;
|
|
1130
|
+
break;
|
|
1131
|
+
case "updateSettings":
|
|
1132
|
+
s = !0;
|
|
1133
|
+
break;
|
|
1134
|
+
default: f([e], t);
|
|
1135
|
+
}
|
|
1136
|
+
i = n;
|
|
1137
|
+
});
|
|
1138
|
+
for (let e of c.keys()) p(e, n.length - 1);
|
|
1139
|
+
if (s) {
|
|
1140
|
+
let e = H(a), r = e.settings.l10n?.[t];
|
|
1141
|
+
st(e.settings, t, Y(r, J(e.settings, o, r), J(e.settings, i.settings, r), e.settings, i.settings)), f(rt(a, e), n.length - 1);
|
|
1142
|
+
}
|
|
1143
|
+
return u;
|
|
1144
|
+
}
|
|
1145
|
+
var ut = 1e3, dt = 1e4, ft = [
|
|
1146
|
+
1e3,
|
|
1147
|
+
2e3,
|
|
1148
|
+
5e3,
|
|
1149
|
+
1e4,
|
|
1150
|
+
3e4
|
|
1151
|
+
], pt = 50, mt = 100, ht = /* @__PURE__ */ new Set([
|
|
1152
|
+
"block_exists",
|
|
1153
|
+
"block_missing",
|
|
1154
|
+
"anchor_missing",
|
|
1155
|
+
"precondition_failed",
|
|
1156
|
+
"lock_held",
|
|
1157
|
+
"locked_by_others",
|
|
1158
|
+
"invalid_operation",
|
|
1159
|
+
"lock_lost",
|
|
1160
|
+
"content_too_large"
|
|
1161
|
+
]);
|
|
1162
|
+
function gt(e, t) {
|
|
1163
|
+
return e.ops.some((e) => e.op === "setContent") ? e.view = t : delete e.view, e;
|
|
1164
|
+
}
|
|
1165
|
+
function _t(e) {
|
|
1166
|
+
let t = e?.code;
|
|
1167
|
+
return typeof t == "string" && ht.has(t) ? t : null;
|
|
1168
|
+
}
|
|
1169
|
+
function vt(e) {
|
|
1170
|
+
let t = e?.holder;
|
|
1171
|
+
return typeof t == "object" && t && typeof t.sessionId == "string" ? t : void 0;
|
|
1172
|
+
}
|
|
1173
|
+
function yt(e) {
|
|
1174
|
+
let t = e?.statusCode;
|
|
1175
|
+
return typeof t != "number" || t >= 500 || t === 408 || t === 429;
|
|
1176
|
+
}
|
|
1177
|
+
function bt(e, t) {
|
|
1178
|
+
return e.some((e) => {
|
|
1179
|
+
if (e.id === t) return !0;
|
|
1180
|
+
let n = e.children;
|
|
1181
|
+
return e.type === "section" && Array.isArray(n) && n.some((e) => Array.isArray(e) && bt(e, t));
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
function xt(e) {
|
|
1185
|
+
if (e.length === 1 && e[0].op === "updateSettings") return !0;
|
|
1186
|
+
let t = e[0];
|
|
1187
|
+
return t.op === "updateBlock" && e.every((e) => e.op === "updateBlock" && e.blockId === t.blockId) || t.op === "updateBlockLocale" && e.every((e) => e.op === "updateBlockLocale" && e.blockId === t.blockId && e.locale === t.locale);
|
|
1188
|
+
}
|
|
1189
|
+
function St(e) {
|
|
1190
|
+
return e.map((e) => {
|
|
1191
|
+
if (!("expect" in e)) return e;
|
|
1192
|
+
let { expect: t, ...n } = e;
|
|
1193
|
+
return n;
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
function Ct(e) {
|
|
1197
|
+
let { provider: t } = e, n = e.sessionId ?? crypto.randomUUID(), r = e.maxUndo ?? pt, i = typeof t.acquireLock == "function" && typeof t.renewLock == "function" && typeof t.releaseLock == "function", a = x([]), s = x(/* @__PURE__ */ new Map()), l = /* @__PURE__ */ new WeakSet(), u = /* @__PURE__ */ new WeakMap(), d = 0, f = S(null), p = S(null), m = S(0), g = S(0), _ = null, v = null, y = !1, C = !1, w = !1, E = !1, O = null, k = 0, A = !1, j = [], M = null, N = null, ee = Promise.resolve(), F = null, ne = b(() => (v?.undo.length ?? 0) > 0), re = b(() => (v?.redo.length ?? 0) > 0);
|
|
1198
|
+
function I(t) {
|
|
1199
|
+
e.onError?.(t instanceof Error ? t : Error(String(t)));
|
|
1200
|
+
}
|
|
1201
|
+
function L(t, n = v) {
|
|
1202
|
+
n !== v || A || e.onNotice?.(t);
|
|
1203
|
+
}
|
|
1204
|
+
function R() {
|
|
1205
|
+
return {
|
|
1206
|
+
locks: [...s.value.values()].map((e) => ({
|
|
1207
|
+
blockId: e.blockId,
|
|
1208
|
+
sessionId: e.holder.sessionId,
|
|
1209
|
+
locale: e.locale
|
|
1210
|
+
})),
|
|
1211
|
+
session: n
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
function z() {
|
|
1215
|
+
g.value++;
|
|
1216
|
+
}
|
|
1217
|
+
function ie(e, t) {
|
|
1218
|
+
e.push(t), e.length > r && e.splice(0, e.length - r);
|
|
1219
|
+
}
|
|
1220
|
+
function B(e) {
|
|
1221
|
+
if (!_ || y) return;
|
|
1222
|
+
C = !0;
|
|
1223
|
+
try {
|
|
1224
|
+
let t = _.content.value, n = rt(t, e);
|
|
1225
|
+
if (n.length > 0) try {
|
|
1226
|
+
te(t, n);
|
|
1227
|
+
} catch {
|
|
1228
|
+
_.setContent(H(e), !1);
|
|
1229
|
+
}
|
|
1230
|
+
T(_.content.value, e) || _.setContent(H(e), !1);
|
|
1231
|
+
} finally {
|
|
1232
|
+
C = !1;
|
|
1233
|
+
}
|
|
1234
|
+
let t = _.state.selectedBlockId;
|
|
1235
|
+
t && !bt(e.blocks, t) && _.selectBlock(null);
|
|
1236
|
+
}
|
|
1237
|
+
function ae() {
|
|
1238
|
+
C || E || (E = !0, queueMicrotask(() => {
|
|
1239
|
+
E = !1, V(!1);
|
|
1240
|
+
}));
|
|
1241
|
+
}
|
|
1242
|
+
function oe() {
|
|
1243
|
+
O &&= (clearTimeout(O), null);
|
|
1244
|
+
}
|
|
1245
|
+
function V(e, t = !1) {
|
|
1246
|
+
let n = v;
|
|
1247
|
+
if (!_ || !n || y || C || _.state.isLoading && !t || _.state.template?.id !== n.templateId) return;
|
|
1248
|
+
let r = rt(n.view, _.content.value);
|
|
1249
|
+
if (r.length === 0) oe();
|
|
1250
|
+
else {
|
|
1251
|
+
if (!e && xt(r)) {
|
|
1252
|
+
let e = Date.now();
|
|
1253
|
+
if (O === null && (k = e), e - k < 1e3) {
|
|
1254
|
+
O && clearTimeout(O), O = setTimeout(() => {
|
|
1255
|
+
O = null, V(!0);
|
|
1256
|
+
}, 300);
|
|
1257
|
+
return;
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
oe(), se(n, r);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
function W() {
|
|
1264
|
+
V(!0);
|
|
1265
|
+
}
|
|
1266
|
+
function se(e, t) {
|
|
1267
|
+
let n = t, r;
|
|
1268
|
+
try {
|
|
1269
|
+
r = P(e.view, n, R());
|
|
1270
|
+
} catch (n) {
|
|
1271
|
+
if (!(n instanceof U)) throw n;
|
|
1272
|
+
B(e.view);
|
|
1273
|
+
let r = n.blockId === void 0 ? void 0 : Ae(n.blockId).find((e) => {
|
|
1274
|
+
let r = t[n.opIndex];
|
|
1275
|
+
return r.op !== "updateBlockLocale" || e.locale == null || e.locale === r.locale;
|
|
1276
|
+
})?.holder;
|
|
1277
|
+
L({
|
|
1278
|
+
type: "editRefused",
|
|
1279
|
+
code: n.code,
|
|
1280
|
+
...r ? { holder: r } : {}
|
|
1281
|
+
}), n.code === "invalid_operation" && I(n);
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
let i = _.content.value;
|
|
1285
|
+
if (!T(r, i)) {
|
|
1286
|
+
I(/* @__PURE__ */ Error("[Templatical] Collaboration: a change couldn't be expressed as block operations, so the whole content was sent.")), n = [{
|
|
1287
|
+
op: "setContent",
|
|
1288
|
+
content: H(i)
|
|
1289
|
+
}];
|
|
1290
|
+
try {
|
|
1291
|
+
r = P(e.view, n, R());
|
|
1292
|
+
} catch (t) {
|
|
1293
|
+
if (!(t instanceof U)) throw t;
|
|
1294
|
+
B(e.view), L({
|
|
1295
|
+
type: "editRefused",
|
|
1296
|
+
code: t.code
|
|
1297
|
+
});
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
let a = gt({ ops: D(e.view, n) }, r);
|
|
1302
|
+
ie(e.undo, a), e.redo = [], z();
|
|
1303
|
+
let o = e.view;
|
|
1304
|
+
e.view = r, ce(e, n, "edit", a, o);
|
|
1305
|
+
}
|
|
1306
|
+
function ce(e, t, n, r, i) {
|
|
1307
|
+
let a = { dropped: !1 }, o = 0, s = i;
|
|
1308
|
+
do {
|
|
1309
|
+
let i = t.slice(o, o + mt);
|
|
1310
|
+
if (e.pending.push({
|
|
1311
|
+
batchId: crypto.randomUUID(),
|
|
1312
|
+
ops: i,
|
|
1313
|
+
origin: n,
|
|
1314
|
+
entry: r,
|
|
1315
|
+
group: a,
|
|
1316
|
+
sent: !1,
|
|
1317
|
+
revision: null,
|
|
1318
|
+
...s && i.some((e) => e.op === "setContent") ? { base: s } : {}
|
|
1319
|
+
}), o += mt, s && t.slice(o).some((e) => e.op === "setContent")) try {
|
|
1320
|
+
s = P(s, i);
|
|
1321
|
+
} catch {
|
|
1322
|
+
s = null;
|
|
1323
|
+
}
|
|
1324
|
+
} while (o < t.length);
|
|
1325
|
+
le(e);
|
|
1326
|
+
}
|
|
1327
|
+
function le(e) {
|
|
1328
|
+
if (e.inFlight || w) return;
|
|
1329
|
+
let t = e.pending.find((e) => !e.sent);
|
|
1330
|
+
t ? (t.sent = !0, e.inFlight = t, ue(e, t, 0)) : ge(e);
|
|
1331
|
+
}
|
|
1332
|
+
function ue(e, n, r) {
|
|
1333
|
+
t.submit(e.templateId, {
|
|
1334
|
+
batchId: n.batchId,
|
|
1335
|
+
baseRevision: n.baseRevision ??= e.revision,
|
|
1336
|
+
ops: n.ops,
|
|
1337
|
+
...n.origin === "ai" ? { origin: "ai" } : {}
|
|
1338
|
+
}).then(({ revision: t }) => {
|
|
1339
|
+
e.inFlight = null, de(e, n, t), le(e);
|
|
1340
|
+
}, (t) => {
|
|
1341
|
+
if (_t(t) !== null) e.inFlight = null, he(e, n, t), le(e);
|
|
1342
|
+
else if (yt(t)) {
|
|
1343
|
+
_e(e, t);
|
|
1344
|
+
let i = ft[Math.min(r, ft.length - 1)];
|
|
1345
|
+
setTimeout(() => {
|
|
1346
|
+
A || ue(e, n, r + 1);
|
|
1347
|
+
}, i);
|
|
1348
|
+
} else e.inFlight = null, I(t), he(e, n, t), le(e);
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
function de(e, t, n) {
|
|
1352
|
+
t.revision === null && (t.revision = n, n <= e.revision ? (fe(e, t), xe(e)) : (e.own.set(n, t), be(e)));
|
|
1353
|
+
}
|
|
1354
|
+
function fe(e, t) {
|
|
1355
|
+
e.pending = e.pending.filter((e) => e !== t), ge(e);
|
|
1356
|
+
}
|
|
1357
|
+
function pe(e, t) {
|
|
1358
|
+
if (t.entry) {
|
|
1359
|
+
for (let n of [e.undo, e.redo]) {
|
|
1360
|
+
let e = n.indexOf(t.entry);
|
|
1361
|
+
e !== -1 && n.splice(e, 1);
|
|
1362
|
+
}
|
|
1363
|
+
z();
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
function me(e, t) {
|
|
1367
|
+
let n = !t.group.dropped;
|
|
1368
|
+
return t.group.dropped = !0, e.pending = e.pending.filter((e) => e.group !== t.group || e.sent), n && pe(e, t), ge(e), n;
|
|
1369
|
+
}
|
|
1370
|
+
function he(e, t, n) {
|
|
1371
|
+
if (fe(e, t), me(e, t)) {
|
|
1372
|
+
let r = _t(n) ?? "invalid_operation";
|
|
1373
|
+
if (t.origin === "edit" || t.origin === "ai") {
|
|
1374
|
+
let t = vt(n);
|
|
1375
|
+
L({
|
|
1376
|
+
type: "editRefused",
|
|
1377
|
+
code: r,
|
|
1378
|
+
...t ? { holder: t } : {}
|
|
1379
|
+
}, e);
|
|
1380
|
+
} else L({
|
|
1381
|
+
type: "undoSkipped",
|
|
1382
|
+
code: r
|
|
1383
|
+
}, e);
|
|
1384
|
+
}
|
|
1385
|
+
xe(e), e === v && Te();
|
|
1386
|
+
}
|
|
1387
|
+
function ge(e) {
|
|
1388
|
+
if (!(e.pending.length > 0 || e.waiters.length === 0)) for (let t of e.waiters.splice(0)) t.resolve();
|
|
1389
|
+
}
|
|
1390
|
+
function _e(e, t) {
|
|
1391
|
+
let n = t instanceof Error ? t : Error(String(t));
|
|
1392
|
+
for (let t of e.waiters.splice(0)) t.reject(n);
|
|
1393
|
+
}
|
|
1394
|
+
function ve(e, t) {
|
|
1395
|
+
if (t.revision <= e.revision) return;
|
|
1396
|
+
let n = e.pending.find((e) => e.batchId === t.batchId);
|
|
1397
|
+
n ? de(e, n, t.revision) : (e.remote.set(t.revision, t), be(e));
|
|
1398
|
+
}
|
|
1399
|
+
function ye(t, n) {
|
|
1400
|
+
let r = n.ops;
|
|
1401
|
+
if (e.normalizeRemoteOperations) try {
|
|
1402
|
+
r = e.normalizeRemoteOperations(n.ops, t.confirmed);
|
|
1403
|
+
} catch (e) {
|
|
1404
|
+
I(e);
|
|
1405
|
+
}
|
|
1406
|
+
return St(r);
|
|
1407
|
+
}
|
|
1408
|
+
function be(t) {
|
|
1409
|
+
let n = [], r = !1;
|
|
1410
|
+
for (;;) {
|
|
1411
|
+
let e = t.revision + 1, i = t.remote.get(e), a = t.own.get(e);
|
|
1412
|
+
if (!i && !a) break;
|
|
1413
|
+
try {
|
|
1414
|
+
t.confirmed = P(t.confirmed, i ? ye(t, i) : a.ops);
|
|
1415
|
+
} catch {
|
|
1416
|
+
if (t.recovering) {
|
|
1417
|
+
t.remote.clear(), t.own.clear(), I(/* @__PURE__ */ Error("[Templatical] Collaboration: this editor can't follow the template's changes. Reload the page."));
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
G(t);
|
|
1421
|
+
return;
|
|
1422
|
+
}
|
|
1423
|
+
t.revision = e, i ? (t.remote.delete(e), n.push(i)) : (t.own.delete(e), a.group.dropped && (r = !0), fe(t, a));
|
|
1424
|
+
}
|
|
1425
|
+
if (t === v && (m.value = t.revision), t.remote.size > 0 || t.own.size > 0 ? Ce(t) : we(t), (n.length !== 0 || r) && (xe(t), t === v)) for (let t of n) try {
|
|
1426
|
+
e.onRemoteChange?.({
|
|
1427
|
+
actor: t.actor,
|
|
1428
|
+
ops: t.ops,
|
|
1429
|
+
locale: t.ops.find((e) => e.op !== "setDefaultLocale" && "locale" in e)?.locale ?? null
|
|
1430
|
+
});
|
|
1431
|
+
} catch (e) {
|
|
1432
|
+
I(e);
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
function xe(e) {
|
|
1436
|
+
let t = !w;
|
|
1437
|
+
w = !0;
|
|
1438
|
+
try {
|
|
1439
|
+
Se(e);
|
|
1440
|
+
} finally {
|
|
1441
|
+
t && (w = !1);
|
|
1442
|
+
}
|
|
1443
|
+
t && le(e);
|
|
1444
|
+
}
|
|
1445
|
+
function Se(e) {
|
|
1446
|
+
e === v && W();
|
|
1447
|
+
let t = e.confirmed;
|
|
1448
|
+
for (let n = 0; n < e.pending.length; n++) {
|
|
1449
|
+
let r = e.pending[n], i;
|
|
1450
|
+
if (r.base && !T(r.base, t)) i = "precondition_failed";
|
|
1451
|
+
else try {
|
|
1452
|
+
t = P(t, r.ops);
|
|
1453
|
+
continue;
|
|
1454
|
+
} catch (e) {
|
|
1455
|
+
i = e instanceof U ? e.code : "invalid_operation";
|
|
1456
|
+
}
|
|
1457
|
+
r.sent || (me(e, r) && L(r.origin === "edit" || r.origin === "ai" ? {
|
|
1458
|
+
type: "editRefused",
|
|
1459
|
+
code: i
|
|
1460
|
+
} : {
|
|
1461
|
+
type: "undoSkipped",
|
|
1462
|
+
code: i
|
|
1463
|
+
}, e), t = e.confirmed, n = -1);
|
|
1464
|
+
}
|
|
1465
|
+
e.view = t, ge(e), e === v && B(t);
|
|
1466
|
+
}
|
|
1467
|
+
function Ce(e) {
|
|
1468
|
+
e.gapTimer ||= setTimeout(() => {
|
|
1469
|
+
e.gapTimer = null, e === v && Te();
|
|
1470
|
+
}, ut);
|
|
1471
|
+
}
|
|
1472
|
+
function we(e) {
|
|
1473
|
+
e.gapTimer &&= (clearTimeout(e.gapTimer), null);
|
|
1474
|
+
}
|
|
1475
|
+
function Te() {
|
|
1476
|
+
let e = v;
|
|
1477
|
+
return e ? (e.catchingUp ||= (async () => {
|
|
1478
|
+
try {
|
|
1479
|
+
let n = await t.operationsAfter(e.templateId, e.revision);
|
|
1480
|
+
if (e.retired) return;
|
|
1481
|
+
if ("resync" in n) {
|
|
1482
|
+
await G(e);
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1485
|
+
for (let t of n.batches) ve(e, t);
|
|
1486
|
+
} catch (e) {
|
|
1487
|
+
I(e);
|
|
1488
|
+
} finally {
|
|
1489
|
+
e.catchingUp = null;
|
|
1490
|
+
}
|
|
1491
|
+
})(), e.catchingUp) : Promise.resolve();
|
|
1492
|
+
}
|
|
1493
|
+
async function G(t) {
|
|
1494
|
+
t.recovering = !0;
|
|
1495
|
+
try {
|
|
1496
|
+
let n = await e.loadTemplate(t.templateId);
|
|
1497
|
+
if (t.retired) return;
|
|
1498
|
+
let r = n.revision ?? t.revision;
|
|
1499
|
+
t.confirmed = H(n.content), t.revision = r, t.remote = new Map([...t.remote].filter(([e]) => e > r));
|
|
1500
|
+
for (let [e, n] of [...t.own]) e <= r && (t.own.delete(e), fe(t, n));
|
|
1501
|
+
t === v && (m.value = r), xe(t), be(t);
|
|
1502
|
+
} catch (e) {
|
|
1503
|
+
I(e);
|
|
1504
|
+
} finally {
|
|
1505
|
+
t.recovering = !1;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
function Ee(t) {
|
|
1509
|
+
let n = () => t === v && !t.retired;
|
|
1510
|
+
return {
|
|
1511
|
+
onBatch: (e) => {
|
|
1512
|
+
n() && ve(t, e);
|
|
1513
|
+
},
|
|
1514
|
+
onResync: (r, i) => {
|
|
1515
|
+
if (!(!n() || r <= t.revision)) {
|
|
1516
|
+
if (i) try {
|
|
1517
|
+
e.onRemoteResync?.({
|
|
1518
|
+
revision: r,
|
|
1519
|
+
actor: i
|
|
1520
|
+
});
|
|
1521
|
+
} catch (e) {
|
|
1522
|
+
I(e);
|
|
1523
|
+
}
|
|
1524
|
+
Te();
|
|
1525
|
+
}
|
|
1526
|
+
},
|
|
1527
|
+
onLock: (e) => {
|
|
1528
|
+
n() && X(e);
|
|
1529
|
+
},
|
|
1530
|
+
onUnlock: (e, t, r) => {
|
|
1531
|
+
n() && Me(e, t, r);
|
|
1532
|
+
},
|
|
1533
|
+
onMembers: (e) => {
|
|
1534
|
+
n() && Z(e);
|
|
1535
|
+
},
|
|
1536
|
+
onConnectionChange: (e) => {
|
|
1537
|
+
n() && q(t, e);
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1540
|
+
}
|
|
1541
|
+
function De(e, r) {
|
|
1542
|
+
let i = d;
|
|
1543
|
+
t.join(e.templateId, { sessionId: n }, Ee(e)).then((t) => {
|
|
1544
|
+
e.retired || e !== v ? r || t.leave() : (e.leave = t.leave, Ne(t.locks, !r, i), Z(t.members), t.members.length > 0 && (p.value = "connected"), t.revision > e.revision && Te(), r && Q());
|
|
1545
|
+
}, (e) => I(e));
|
|
1546
|
+
}
|
|
1547
|
+
function Oe(e) {
|
|
1548
|
+
let t = H(e.content), n = {
|
|
1549
|
+
templateId: e.id,
|
|
1550
|
+
confirmed: t,
|
|
1551
|
+
revision: e.revision ?? 0,
|
|
1552
|
+
pending: [],
|
|
1553
|
+
view: H(t),
|
|
1554
|
+
remote: /* @__PURE__ */ new Map(),
|
|
1555
|
+
own: /* @__PURE__ */ new Map(),
|
|
1556
|
+
inFlight: null,
|
|
1557
|
+
gapTimer: null,
|
|
1558
|
+
catchingUp: null,
|
|
1559
|
+
leave: null,
|
|
1560
|
+
retired: !1,
|
|
1561
|
+
recovering: !1,
|
|
1562
|
+
undo: [],
|
|
1563
|
+
redo: [],
|
|
1564
|
+
waiters: []
|
|
1565
|
+
};
|
|
1566
|
+
v = n, m.value = n.revision, z(), De(n, !1), _?.state.selectedBlockId && ze(_.state.selectedBlockId), ae();
|
|
1567
|
+
}
|
|
1568
|
+
function K(e) {
|
|
1569
|
+
e.retired = !0, we(e), e.leave?.(), e.leave = null, _e(e, /* @__PURE__ */ Error("[Templatical] The template was closed."));
|
|
1570
|
+
}
|
|
1571
|
+
function q(e, t) {
|
|
1572
|
+
let n = p.value;
|
|
1573
|
+
p.value = t, t === "connected" && n !== null && n !== "connected" && De(e, !0);
|
|
1574
|
+
}
|
|
1575
|
+
function ke(e) {
|
|
1576
|
+
v && v.templateId === e?.id || (v &&= (oe(), K(v), null), a.value = [], s.value = /* @__PURE__ */ new Map(), p.value = null, M = null, Q(), z(), e && Oe(e));
|
|
1577
|
+
}
|
|
1578
|
+
function J(e, t) {
|
|
1579
|
+
return `${e}\u0000${t ?? ""}`;
|
|
1580
|
+
}
|
|
1581
|
+
function Y(e, t, n) {
|
|
1582
|
+
return e.blockId === t && (n == null || e.locale == null || e.locale === n);
|
|
1583
|
+
}
|
|
1584
|
+
function Ae(e) {
|
|
1585
|
+
return [...s.value.values()].filter((t) => t.blockId === e);
|
|
1586
|
+
}
|
|
1587
|
+
function je(e) {
|
|
1588
|
+
e !== f.value && (W(), f.value = e, ze(_?.state.selectedBlockId ?? null));
|
|
1589
|
+
}
|
|
1590
|
+
function X(e, t = !1) {
|
|
1591
|
+
if (e.holder.sessionId === n) return;
|
|
1592
|
+
t ? l.add(e) : u.set(e, ++d);
|
|
1593
|
+
let r = new Map([...s.value].filter(([, t]) => t.holder.sessionId !== e.holder.sessionId));
|
|
1594
|
+
r.set(J(e.blockId, e.locale), e), s.value = r, _?.state.selectedBlockId === e.blockId && (f.value === null || e.locale == null || e.locale === f.value) && (_.selectBlock(null), L({
|
|
1595
|
+
type: "selectionRefused",
|
|
1596
|
+
blockId: e.blockId,
|
|
1597
|
+
holder: e.holder
|
|
1598
|
+
}));
|
|
1599
|
+
}
|
|
1600
|
+
function Me(e, t, n) {
|
|
1601
|
+
let r = J(e, n), i = new Map([...s.value].filter(([n, i]) => i.holder.sessionId !== t || n !== r && !(i.blockId === e && l.has(i))));
|
|
1602
|
+
i.size !== s.value.size && (s.value = i);
|
|
1603
|
+
}
|
|
1604
|
+
function Ne(e, t, r) {
|
|
1605
|
+
let i = new Map([...s.value].filter(([, e]) => !l.has(e) && (t || (u.get(e) ?? 0) > r))), a = [...i.values()];
|
|
1606
|
+
for (let t of e) if (t.holder.sessionId !== n && !a.some((e) => e.holder.sessionId === t.holder.sessionId || Y(e, t.blockId, t.locale))) {
|
|
1607
|
+
for (let [e, n] of i) n.holder.sessionId === t.holder.sessionId && i.delete(e);
|
|
1608
|
+
i.set(J(t.blockId, t.locale), t);
|
|
1609
|
+
}
|
|
1610
|
+
s.value = i;
|
|
1611
|
+
}
|
|
1612
|
+
function Z(e) {
|
|
1613
|
+
let t = new Set(e.map((e) => e.sessionId)), n = new Set(a.value.map((e) => e.sessionId).filter((e) => !t.has(e)));
|
|
1614
|
+
if (a.value = e, n.size === 0) return;
|
|
1615
|
+
let r = new Map([...s.value].filter(([, e]) => !n.has(e.holder.sessionId)));
|
|
1616
|
+
r.size !== s.value.size && (s.value = r);
|
|
1617
|
+
}
|
|
1618
|
+
function Pe(e) {
|
|
1619
|
+
ee = ee.then(e).catch(I);
|
|
1620
|
+
}
|
|
1621
|
+
function Q() {
|
|
1622
|
+
i && Pe(async () => {
|
|
1623
|
+
if (N && (M === null || N.templateId !== M.templateId || N.locale !== M.locale)) {
|
|
1624
|
+
let e = N;
|
|
1625
|
+
N = null, Re(), await t.releaseLock(e.templateId, e.blockId, e.locale);
|
|
1626
|
+
}
|
|
1627
|
+
let e = M;
|
|
1628
|
+
if (!(!e || N?.templateId === e.templateId && N.blockId === e.blockId && N.locale === e.locale)) try {
|
|
1629
|
+
let n = await t.acquireLock(e.templateId, e.blockId, e.locale);
|
|
1630
|
+
N = e, Le(), Fe(n.blockId, n.locale ?? null);
|
|
1631
|
+
} catch (n) {
|
|
1632
|
+
if (N?.templateId === e.templateId) {
|
|
1633
|
+
let e = N;
|
|
1634
|
+
N = null, Re(), await t.releaseLock(e.templateId, e.blockId, e.locale).catch(() => {});
|
|
1635
|
+
}
|
|
1636
|
+
if (M !== e) return;
|
|
1637
|
+
Ie(e.blockId, n);
|
|
1638
|
+
}
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
function Fe(e, t) {
|
|
1642
|
+
let n = new Map([...s.value].filter(([, n]) => !Y(n, e, t)));
|
|
1643
|
+
n.size !== s.value.size && (s.value = n);
|
|
1644
|
+
}
|
|
1645
|
+
function Ie(e, t) {
|
|
1646
|
+
let n = _t(t);
|
|
1647
|
+
if (n === "lock_held" || n === "block_missing") {
|
|
1648
|
+
M = null;
|
|
1649
|
+
let n = vt(t);
|
|
1650
|
+
n ? X({
|
|
1651
|
+
blockId: e,
|
|
1652
|
+
holder: n,
|
|
1653
|
+
expiresAt: ""
|
|
1654
|
+
}, !0) : _?.state.selectedBlockId === e && _.selectBlock(null);
|
|
1655
|
+
} else I(t), setTimeout(() => {
|
|
1656
|
+
M?.blockId === e && Q();
|
|
1657
|
+
}, ft[0]);
|
|
1658
|
+
}
|
|
1659
|
+
function Le() {
|
|
1660
|
+
F ||= setInterval(() => {
|
|
1661
|
+
Pe(async () => {
|
|
1662
|
+
let e = N;
|
|
1663
|
+
if (e) try {
|
|
1664
|
+
await t.renewLock(e.templateId, e.blockId, e.locale);
|
|
1665
|
+
} catch (e) {
|
|
1666
|
+
if (_t(e) === "lock_lost") {
|
|
1667
|
+
N = null, Re(), Q();
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1670
|
+
I(e);
|
|
1671
|
+
}
|
|
1672
|
+
});
|
|
1673
|
+
}, dt);
|
|
1674
|
+
}
|
|
1675
|
+
function Re() {
|
|
1676
|
+
F &&= (clearInterval(F), null);
|
|
1677
|
+
}
|
|
1678
|
+
function ze(e) {
|
|
1679
|
+
W(), v && (M = e ? {
|
|
1680
|
+
templateId: v.templateId,
|
|
1681
|
+
blockId: e,
|
|
1682
|
+
locale: f.value
|
|
1683
|
+
} : null, Q());
|
|
1684
|
+
}
|
|
1685
|
+
function Be() {
|
|
1686
|
+
W(), N && i && (t.releaseLock(N.templateId, N.blockId, N.locale).catch(() => {}), N = null, Re()), v?.leave?.(), v && (v.leave = null);
|
|
1687
|
+
}
|
|
1688
|
+
function Ve(e) {
|
|
1689
|
+
let t = v;
|
|
1690
|
+
if (!t || y) return;
|
|
1691
|
+
W();
|
|
1692
|
+
let n = (e === "undo" ? t.undo : t.redo).pop();
|
|
1693
|
+
if (!n) return;
|
|
1694
|
+
if (z(), n.view && !T(n.view, t.view)) {
|
|
1695
|
+
L({
|
|
1696
|
+
type: "undoSkipped",
|
|
1697
|
+
code: "precondition_failed"
|
|
1698
|
+
});
|
|
1699
|
+
return;
|
|
1700
|
+
}
|
|
1701
|
+
let r;
|
|
1702
|
+
try {
|
|
1703
|
+
r = P(t.view, n.ops, R());
|
|
1704
|
+
} catch (e) {
|
|
1705
|
+
if (!(e instanceof U)) throw e;
|
|
1706
|
+
L({
|
|
1707
|
+
type: "undoSkipped",
|
|
1708
|
+
code: e.code
|
|
1709
|
+
});
|
|
1710
|
+
return;
|
|
1711
|
+
}
|
|
1712
|
+
let i = gt({ ops: D(t.view, n.ops) }, r);
|
|
1713
|
+
ie(e === "undo" ? t.redo : t.undo, i);
|
|
1714
|
+
let a = t.view;
|
|
1715
|
+
t.view = r, B(r), _?.markDirty(), ce(t, n.ops, e, i, a);
|
|
1716
|
+
}
|
|
1717
|
+
function He(e, t) {
|
|
1718
|
+
let n = v;
|
|
1719
|
+
if (!_ || !n || y) return {
|
|
1720
|
+
applied: !1,
|
|
1721
|
+
error: new U("invalid_operation", 0, "No template is open for editing.")
|
|
1722
|
+
};
|
|
1723
|
+
if (t.origin === void 0) try {
|
|
1724
|
+
P(_.content.value, e, R());
|
|
1725
|
+
} catch (e) {
|
|
1726
|
+
if (e instanceof U) return {
|
|
1727
|
+
applied: !1,
|
|
1728
|
+
error: e
|
|
1729
|
+
};
|
|
1730
|
+
throw e;
|
|
1731
|
+
}
|
|
1732
|
+
W();
|
|
1733
|
+
let r, i;
|
|
1734
|
+
try {
|
|
1735
|
+
r = P(n.view, e, R()), i = D(n.view, e);
|
|
1736
|
+
} catch (e) {
|
|
1737
|
+
if (e instanceof U) return {
|
|
1738
|
+
applied: !1,
|
|
1739
|
+
error: e
|
|
1740
|
+
};
|
|
1741
|
+
throw e;
|
|
1742
|
+
}
|
|
1743
|
+
let a = n.undo.at(-1), o;
|
|
1744
|
+
if (t.origin === "ai" && t.turn !== void 0 && a && a.turn === t.turn) {
|
|
1745
|
+
let e = a.view !== void 0 && !T(a.view, n.view);
|
|
1746
|
+
a.ops = [...i, ...a.ops], o = e ? a : gt(a, r);
|
|
1747
|
+
} else o = gt({
|
|
1748
|
+
ops: i,
|
|
1749
|
+
...t.origin === "ai" && t.turn !== void 0 ? { turn: t.turn } : {}
|
|
1750
|
+
}, r), ie(n.undo, o);
|
|
1751
|
+
n.redo = [], z();
|
|
1752
|
+
let s = n.view;
|
|
1753
|
+
return n.view = r, B(r), _.markDirty(), ce(n, e, t.origin ?? "edit", o, s), {
|
|
1754
|
+
applied: !0,
|
|
1755
|
+
inverse: i
|
|
1756
|
+
};
|
|
1757
|
+
}
|
|
1758
|
+
function Ue(e) {
|
|
1759
|
+
_ = e;
|
|
1760
|
+
let t = e;
|
|
1761
|
+
if (t.moveBlock && t.findBlockLocation) {
|
|
1762
|
+
let n = t.moveBlock, r = (...r) => {
|
|
1763
|
+
let i = v, a = i && !y && !C && !e.state.isLoading && e.state.template?.id === i.templateId;
|
|
1764
|
+
if (a && V(!0), n(...r), !a || T(i.view, e.content.value)) return;
|
|
1765
|
+
let o = t.findBlockLocation(r[0]);
|
|
1766
|
+
if (!o) return;
|
|
1767
|
+
let s = o.targetSectionId ? {
|
|
1768
|
+
sectionId: o.targetSectionId,
|
|
1769
|
+
column: o.columnIndex ?? 0
|
|
1770
|
+
} : null, c = s ? e.content.value.blocks.find((e) => e.id === s.sectionId) : void 0;
|
|
1771
|
+
se(i, [{
|
|
1772
|
+
op: "moveBlock",
|
|
1773
|
+
blockId: r[0],
|
|
1774
|
+
parent: s,
|
|
1775
|
+
after: (s && c?.type === "section" ? c.children[s.column] : e.content.value.blocks)[o.index - 1]?.id ?? null
|
|
1776
|
+
}]);
|
|
1777
|
+
};
|
|
1778
|
+
t.moveBlock = r, j.push(() => {
|
|
1779
|
+
t.moveBlock === r && (t.moveBlock = n);
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
j.push(h(() => e.state.template, (e) => ke(e), { immediate: !0 }), h(() => e.content.value, ae, { deep: !0 }), h(() => e.state.selectedBlockId, ze), h(() => e.state.isLoading, (e) => e ? V(!0, !0) : ae())), typeof window < "u" && (window.addEventListener("pagehide", Be), window.addEventListener("blur", W)), c() && o(qe);
|
|
1783
|
+
}
|
|
1784
|
+
function We() {
|
|
1785
|
+
W();
|
|
1786
|
+
let e = v;
|
|
1787
|
+
return !e || e.pending.length === 0 ? Promise.resolve() : new Promise((t, n) => e.waiters.push({
|
|
1788
|
+
resolve: t,
|
|
1789
|
+
reject: n
|
|
1790
|
+
}));
|
|
1791
|
+
}
|
|
1792
|
+
function Ge() {
|
|
1793
|
+
W(), y = !0;
|
|
1794
|
+
}
|
|
1795
|
+
function Ke() {
|
|
1796
|
+
y = !1, v && B(v.view);
|
|
1797
|
+
}
|
|
1798
|
+
function qe() {
|
|
1799
|
+
if (!A) {
|
|
1800
|
+
W();
|
|
1801
|
+
for (let e of j.splice(0)) e();
|
|
1802
|
+
oe(), Be(), A = !0, v && K(v), v = null, Re(), typeof window < "u" && (window.removeEventListener("pagehide", Be), window.removeEventListener("blur", W));
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
return {
|
|
1806
|
+
sessionId: n,
|
|
1807
|
+
members: a,
|
|
1808
|
+
locks: s,
|
|
1809
|
+
locksOf: Ae,
|
|
1810
|
+
lockLocale: f,
|
|
1811
|
+
setLockLocale: je,
|
|
1812
|
+
connection: p,
|
|
1813
|
+
revision: m,
|
|
1814
|
+
canUndo: ne,
|
|
1815
|
+
canRedo: re,
|
|
1816
|
+
attach: Ue,
|
|
1817
|
+
undo: () => Ve("undo"),
|
|
1818
|
+
redo: () => Ve("redo"),
|
|
1819
|
+
clearHistory: () => {
|
|
1820
|
+
v && (v.undo = [], v.redo = [], z());
|
|
1821
|
+
},
|
|
1822
|
+
flush: W,
|
|
1823
|
+
settle: We,
|
|
1824
|
+
suspend: Ge,
|
|
1825
|
+
resume: Ke,
|
|
1826
|
+
catchUp: Te,
|
|
1827
|
+
hasConfirmedBlock: (e) => v ? bt(v.confirmed.blocks, e) : !1,
|
|
1828
|
+
applyOperations: He,
|
|
1829
|
+
destroy: qe
|
|
1830
|
+
};
|
|
1831
|
+
}
|
|
1832
|
+
// ../core/src/saved-blocks.ts
|
|
1833
|
+
function wt(e) {
|
|
1834
|
+
let { provider: t } = e, n = S([]), r = S(!1), i = v(() => {
|
|
1835
|
+
let e = /* @__PURE__ */ new Set();
|
|
1836
|
+
for (let t of n.value) {
|
|
1837
|
+
let n = t.category?.trim();
|
|
1838
|
+
n && e.add(n);
|
|
1839
|
+
}
|
|
1840
|
+
return [...e].sort((e, t) => e.localeCompare(t));
|
|
1841
|
+
}), a = v(() => typeof t.create == "function"), o = v(() => typeof t.update == "function"), s = v(() => typeof t.delete == "function");
|
|
1842
|
+
function c(e) {
|
|
1843
|
+
return o.value && e.canUpdate !== !1;
|
|
1844
|
+
}
|
|
1845
|
+
function l(e) {
|
|
1846
|
+
return s.value && e.canDelete !== !1;
|
|
1847
|
+
}
|
|
1848
|
+
function u(e, t) {
|
|
1849
|
+
throw new R(`[Templatical] Saved blocks: ${e} is ${t}. Check the capability before calling — the editor's own UI hides the action.`);
|
|
1850
|
+
}
|
|
1851
|
+
function d(t) {
|
|
1852
|
+
Q(e.onError, t);
|
|
1853
|
+
}
|
|
1854
|
+
async function f(i) {
|
|
1855
|
+
r.value = !0;
|
|
1856
|
+
try {
|
|
1857
|
+
n.value = await t.list(i);
|
|
1858
|
+
} catch (t) {
|
|
1859
|
+
throw e.onError?.(t), t;
|
|
1860
|
+
} finally {
|
|
1861
|
+
r.value = !1;
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
async function p(r, i, a) {
|
|
1865
|
+
let { create: o } = t;
|
|
1866
|
+
typeof o != "function" && u("create", "disabled by the provider");
|
|
1867
|
+
try {
|
|
1868
|
+
let e = await o(a ? {
|
|
1869
|
+
name: r,
|
|
1870
|
+
content: i,
|
|
1871
|
+
category: a
|
|
1872
|
+
} : {
|
|
1873
|
+
name: r,
|
|
1874
|
+
content: i
|
|
1875
|
+
});
|
|
1876
|
+
return n.value = [e, ...n.value], d(() => t.onCreated?.(e)), e;
|
|
1877
|
+
} catch (t) {
|
|
1878
|
+
throw e.onError?.(t), t;
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
async function m(r, i) {
|
|
1882
|
+
let { update: a } = t;
|
|
1883
|
+
typeof a != "function" && u("update", "disabled by the provider");
|
|
1884
|
+
let o = n.value.find((e) => e.id === r);
|
|
1885
|
+
o && o.canUpdate === !1 && u("update", `not permitted for entry "${r}"`);
|
|
1886
|
+
try {
|
|
1887
|
+
let e = await a(r, i);
|
|
1888
|
+
return n.value = n.value.map((t) => t.id === r ? e : t), d(() => t.onUpdated?.(e)), e;
|
|
1889
|
+
} catch (t) {
|
|
1890
|
+
throw e.onError?.(t), t;
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
async function h(r) {
|
|
1894
|
+
let { delete: i } = t;
|
|
1895
|
+
typeof i != "function" && u("delete", "disabled by the provider");
|
|
1896
|
+
let a = n.value.find((e) => e.id === r) ?? null;
|
|
1897
|
+
a && a.canDelete === !1 && u("delete", `not permitted for entry "${r}"`);
|
|
1898
|
+
try {
|
|
1899
|
+
await i(r), n.value = n.value.filter((e) => e.id !== r), a && d(() => t.onDeleted?.(a));
|
|
1900
|
+
} catch (t) {
|
|
1901
|
+
throw e.onError?.(t), t;
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
return {
|
|
1905
|
+
savedBlocks: n,
|
|
1906
|
+
isLoading: r,
|
|
1907
|
+
categories: i,
|
|
1908
|
+
canCreate: a,
|
|
1909
|
+
canUpdate: o,
|
|
1910
|
+
canDelete: s,
|
|
1911
|
+
canUpdateBlock: c,
|
|
1912
|
+
canDeleteBlock: l,
|
|
1913
|
+
load: f,
|
|
1914
|
+
create: p,
|
|
1915
|
+
update: m,
|
|
1916
|
+
remove: h
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
// ../core/src/saved-blocks-local.ts
|
|
1920
|
+
var Tt = "templatical:saved-blocks";
|
|
1921
|
+
function Et(e = {}) {
|
|
1922
|
+
let t = e.key ?? Tt;
|
|
1923
|
+
function n() {
|
|
1924
|
+
if (typeof localStorage > "u") throw Error("[Templatical] createLocalStorageSavedBlocksProvider requires a browser environment with localStorage. Supply your own SavedBlocksProvider for server-side or non-browser use.");
|
|
1925
|
+
return localStorage;
|
|
1926
|
+
}
|
|
1927
|
+
function r() {
|
|
1928
|
+
let e = n().getItem(t);
|
|
1929
|
+
if (!e) return [];
|
|
1930
|
+
try {
|
|
1931
|
+
let t = JSON.parse(e);
|
|
1932
|
+
return Array.isArray(t) ? t : [];
|
|
1933
|
+
} catch {
|
|
1934
|
+
return [];
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
function i(e) {
|
|
1938
|
+
n().setItem(t, JSON.stringify(e));
|
|
1939
|
+
}
|
|
1940
|
+
return {
|
|
1941
|
+
async list(e) {
|
|
1942
|
+
let t = r(), n = e?.search?.trim().toLowerCase(), i = e?.category?.trim();
|
|
1943
|
+
return t.filter((e) => !(n && !e.name.toLowerCase().includes(n) || i && e.category !== i));
|
|
1944
|
+
},
|
|
1945
|
+
async create(e) {
|
|
1946
|
+
let t = (/* @__PURE__ */ new Date()).toISOString(), n = {
|
|
1947
|
+
id: oe(),
|
|
1948
|
+
name: e.name,
|
|
1949
|
+
content: e.content,
|
|
1950
|
+
...e.category ? { category: e.category } : {},
|
|
1951
|
+
createdAt: t,
|
|
1952
|
+
updatedAt: t
|
|
1953
|
+
};
|
|
1954
|
+
return i([n, ...r()]), n;
|
|
1955
|
+
},
|
|
1956
|
+
async update(e, t) {
|
|
1957
|
+
let n = r(), a = n.findIndex((t) => t.id === e);
|
|
1958
|
+
if (a === -1) throw Error(`[Templatical] Saved block not found: ${e}`);
|
|
1959
|
+
let o = {
|
|
1960
|
+
...n[a],
|
|
1961
|
+
...t,
|
|
1962
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1963
|
+
}, s = [...n];
|
|
1964
|
+
return s[a] = o, i(s), o;
|
|
1965
|
+
},
|
|
1966
|
+
async delete(e) {
|
|
1967
|
+
let t = r();
|
|
1968
|
+
if (!t.some((t) => t.id === e)) throw Error(`[Templatical] Saved block not found: ${e}`);
|
|
1969
|
+
i(t.filter((t) => t.id !== e));
|
|
1970
|
+
}
|
|
1971
|
+
};
|
|
1972
|
+
}
|
|
1973
|
+
// ../core/src/media-local.ts
|
|
1974
|
+
var Dt = "templatical:media", Ot = 50;
|
|
1975
|
+
function kt(e = {}) {
|
|
1976
|
+
let t = e.key ?? Dt;
|
|
1977
|
+
function n() {
|
|
1978
|
+
if (typeof localStorage > "u") throw Error("[Templatical] createLocalStorageMediaProvider requires a browser environment with localStorage. Supply your own MediaProvider for server-side or non-browser use.");
|
|
1979
|
+
return localStorage;
|
|
1980
|
+
}
|
|
1981
|
+
function r() {
|
|
1982
|
+
let e = n().getItem(t);
|
|
1983
|
+
if (!e) return [];
|
|
1984
|
+
try {
|
|
1985
|
+
let t = JSON.parse(e);
|
|
1986
|
+
return Array.isArray(t) ? t : [];
|
|
1987
|
+
} catch {
|
|
1988
|
+
return [];
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
function i(e) {
|
|
1992
|
+
n().setItem(t, JSON.stringify(e));
|
|
1993
|
+
}
|
|
1994
|
+
function a(e) {
|
|
1995
|
+
return typeof FileReader > "u" ? Promise.reject(/* @__PURE__ */ Error("[Templatical] createLocalStorageMediaProvider requires a browser environment with FileReader.")) : new Promise((t, n) => {
|
|
1996
|
+
let r = new FileReader();
|
|
1997
|
+
r.onload = () => {
|
|
1998
|
+
typeof r.result == "string" ? t(r.result) : n(/* @__PURE__ */ Error("[Templatical] Failed to read file as a data URL."));
|
|
1999
|
+
}, r.onerror = () => {
|
|
2000
|
+
n(r.error ?? /* @__PURE__ */ Error("[Templatical] Failed to read file as a data URL."));
|
|
2001
|
+
}, r.readAsDataURL(e);
|
|
2002
|
+
});
|
|
2003
|
+
}
|
|
2004
|
+
return {
|
|
2005
|
+
async list(e) {
|
|
2006
|
+
let t = r(), n = e?.search?.trim().toLowerCase(), i = n ? t.filter((e) => {
|
|
2007
|
+
let t = e.filename?.toLowerCase() ?? "", r = e.alt?.toLowerCase() ?? "";
|
|
2008
|
+
return t.includes(n) || r.includes(n);
|
|
2009
|
+
}) : t, a = e?.cursor ? Number.parseInt(e.cursor, 10) : 0, o = Number.isFinite(a) && a > 0 ? a : 0, s = i.slice(o, o + Ot), c = { items: s }, l = o + s.length;
|
|
2010
|
+
return l < i.length && (c.nextCursor = String(l)), c;
|
|
2011
|
+
},
|
|
2012
|
+
async create(e) {
|
|
2013
|
+
let t = await a(e.file), n = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
2014
|
+
id: oe(),
|
|
2015
|
+
url: t,
|
|
2016
|
+
filename: e.filename || e.file.name,
|
|
2017
|
+
createdAt: n,
|
|
2018
|
+
updatedAt: n,
|
|
2019
|
+
size: e.file.size
|
|
2020
|
+
};
|
|
2021
|
+
return e.alt !== void 0 && (o.alt = e.alt), e.file.type && (o.mimeType = e.file.type), e.folderId !== void 0 && (o.folderId = e.folderId), i([o, ...r()]), o;
|
|
2022
|
+
},
|
|
2023
|
+
async update(e, t) {
|
|
2024
|
+
let n = r(), a = n.findIndex((t) => t.id === e);
|
|
2025
|
+
if (a === -1) throw Error(`[Templatical] Media asset not found: ${e}`);
|
|
2026
|
+
let o = n[a], s = {
|
|
2027
|
+
...o,
|
|
2028
|
+
...t,
|
|
2029
|
+
id: o.id,
|
|
2030
|
+
url: o.url,
|
|
2031
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2032
|
+
}, c = [...n];
|
|
2033
|
+
return c[a] = s, i(c), s;
|
|
2034
|
+
},
|
|
2035
|
+
async delete(e) {
|
|
2036
|
+
let t = r();
|
|
2037
|
+
for (let n of e) if (!t.some((e) => e.id === n)) throw Error(`[Templatical] Media asset not found: ${n}`);
|
|
2038
|
+
let n = new Set(e);
|
|
2039
|
+
i(t.filter((e) => !n.has(e.id)));
|
|
2040
|
+
},
|
|
2041
|
+
folders: !1,
|
|
2042
|
+
replace: !1,
|
|
2043
|
+
importFromUrl: !1,
|
|
2044
|
+
checkUsage: !1,
|
|
2045
|
+
frequentlyUsed: !1,
|
|
2046
|
+
storage: !1
|
|
2047
|
+
};
|
|
2048
|
+
}
|
|
2049
|
+
// ../core/src/version-history.ts
|
|
2050
|
+
function At(e) {
|
|
2051
|
+
let { provider: t, getTemplateId: n } = e, r = S([]), i = S(!1), a = S(void 0), o = S(!1), s = /* @__PURE__ */ new Map(), c = v(() => typeof t.create == "function"), l = v(() => typeof t.restore == "function");
|
|
2052
|
+
function u(e) {
|
|
2053
|
+
let t = n();
|
|
2054
|
+
if (!t) throw new R(`[Templatical] Version history: ${e} needs a template. Call create() or load() first.`);
|
|
2055
|
+
return t;
|
|
2056
|
+
}
|
|
2057
|
+
function d(e) {
|
|
2058
|
+
throw new R(`[Templatical] Version history: ${e} is disabled by the provider. Check the capability before calling — the editor's own UI hides the action.`);
|
|
2059
|
+
}
|
|
2060
|
+
function f(t) {
|
|
2061
|
+
Q(e.onError, t);
|
|
2062
|
+
}
|
|
2063
|
+
async function p(n) {
|
|
2064
|
+
let o = u("list");
|
|
2065
|
+
i.value = !0;
|
|
2066
|
+
try {
|
|
2067
|
+
let e = await t.list(o, n);
|
|
2068
|
+
r.value = e.versions, a.value = e.nextCursor;
|
|
2069
|
+
} catch (t) {
|
|
2070
|
+
throw e.onError?.(t), t;
|
|
2071
|
+
} finally {
|
|
2072
|
+
i.value = !1;
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
function m(e) {
|
|
2076
|
+
return e.content ?? s.get(e.id) ?? null;
|
|
2077
|
+
}
|
|
2078
|
+
async function h(n) {
|
|
2079
|
+
let r = m(n);
|
|
2080
|
+
if (r) return r;
|
|
2081
|
+
let i = u("get");
|
|
2082
|
+
try {
|
|
2083
|
+
let e = await t.get(i, n.id);
|
|
2084
|
+
return s.set(n.id, e), e;
|
|
2085
|
+
} catch (t) {
|
|
2086
|
+
throw e.onError?.(t), t;
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
async function g(n, i) {
|
|
2090
|
+
let { create: a } = t;
|
|
2091
|
+
typeof a != "function" && d("create");
|
|
2092
|
+
let o = u("create");
|
|
2093
|
+
try {
|
|
2094
|
+
let e = await a(o, n, i);
|
|
2095
|
+
return r.value = [e, ...r.value], f(() => t.onCreated?.(e)), e;
|
|
2096
|
+
} catch (t) {
|
|
2097
|
+
throw e.onError?.(t), t;
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
async function _(n) {
|
|
2101
|
+
let { restore: r } = t;
|
|
2102
|
+
typeof r != "function" && d("restore");
|
|
2103
|
+
let i = u("restore"), a;
|
|
2104
|
+
o.value = !0;
|
|
2105
|
+
try {
|
|
2106
|
+
a = await r(i, n);
|
|
2107
|
+
} catch (t) {
|
|
2108
|
+
throw e.onError?.(t), t;
|
|
2109
|
+
} finally {
|
|
2110
|
+
o.value = !1;
|
|
2111
|
+
}
|
|
2112
|
+
return f(() => t.onRestored?.(a)), a;
|
|
2113
|
+
}
|
|
2114
|
+
return {
|
|
2115
|
+
nextCursor: a,
|
|
2116
|
+
versions: r,
|
|
2117
|
+
isLoading: i,
|
|
2118
|
+
isRestoring: o,
|
|
2119
|
+
canCreate: c,
|
|
2120
|
+
canRestore: l,
|
|
2121
|
+
load: p,
|
|
2122
|
+
peekContent: m,
|
|
2123
|
+
resolveContent: h,
|
|
2124
|
+
create: g,
|
|
2125
|
+
restore: _
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
2128
|
+
// ../core/src/comments.ts
|
|
2129
|
+
function jt(e) {
|
|
2130
|
+
let { provider: t, getTemplateId: n, getUser: r } = e, i = S([]), a = S(!1), o = S(!1), s = v(() => typeof t.create == "function"), c = v(() => typeof t.update == "function"), l = v(() => typeof t.delete == "function"), u = v(() => typeof t.setResolved == "function"), d = v(() => i.value.reduce((e, t) => e + 1 + (t.replies?.length ?? 0), 0)), f = v(() => i.value.filter((e) => !e.resolvedAt).length), p = v(() => {
|
|
2131
|
+
let e = /* @__PURE__ */ new Map();
|
|
2132
|
+
for (let t of i.value) t.blockId && e.set(t.blockId, (e.get(t.blockId) ?? 0) + 1 + (t.replies?.length ?? 0));
|
|
2133
|
+
return e;
|
|
2134
|
+
});
|
|
2135
|
+
function m(e) {
|
|
2136
|
+
let t = n();
|
|
2137
|
+
if (!t) throw new R(`[Templatical] Comments: ${e} needs a template. Call create() or load() first.`);
|
|
2138
|
+
return t;
|
|
2139
|
+
}
|
|
2140
|
+
function h(e) {
|
|
2141
|
+
let t = r();
|
|
2142
|
+
if (!t) throw new R(`[Templatical] Comments: ${e} needs to know who is commenting. Pass init({ user: { id, name } }) — an unattributed comment is not written.`);
|
|
2143
|
+
return t;
|
|
2144
|
+
}
|
|
2145
|
+
function g(e) {
|
|
2146
|
+
throw new R(`[Templatical] Comments: ${e} is disabled by the provider. Check the capability before calling — the editor's own UI hides the action.`);
|
|
2147
|
+
}
|
|
2148
|
+
function _(e) {
|
|
2149
|
+
for (let t of i.value) {
|
|
2150
|
+
if (t.id === e) return t;
|
|
2151
|
+
for (let n of t.replies ?? []) if (n.id === e) return n;
|
|
2152
|
+
}
|
|
2153
|
+
return null;
|
|
2154
|
+
}
|
|
2155
|
+
function y(e) {
|
|
2156
|
+
let t = r();
|
|
2157
|
+
return t !== null && e.author.id === t.id;
|
|
2158
|
+
}
|
|
2159
|
+
function b(t) {
|
|
2160
|
+
let n = Pe(t);
|
|
2161
|
+
throw e.onError?.(n), n;
|
|
2162
|
+
}
|
|
2163
|
+
function x(t) {
|
|
2164
|
+
Q(e.onError, t);
|
|
2165
|
+
}
|
|
2166
|
+
function C(e, t, n) {
|
|
2167
|
+
return [
|
|
2168
|
+
...e.slice(0, t),
|
|
2169
|
+
n,
|
|
2170
|
+
...e.slice(t + 1)
|
|
2171
|
+
];
|
|
2172
|
+
}
|
|
2173
|
+
function w(e, t) {
|
|
2174
|
+
return e !== void 0 && JSON.stringify(e) === JSON.stringify(t);
|
|
2175
|
+
}
|
|
2176
|
+
function T(e) {
|
|
2177
|
+
if (e.parentId) {
|
|
2178
|
+
let t = !1, n = i.value.map((n) => {
|
|
2179
|
+
if (n.id !== e.parentId) return n;
|
|
2180
|
+
let r = n.replies ?? [], i = r.findIndex((t) => t.id === e.id);
|
|
2181
|
+
return i !== -1 && w(r[i], e) ? n : (t = !0, {
|
|
2182
|
+
...n,
|
|
2183
|
+
replies: i === -1 ? [...r, e] : C(r, i, e)
|
|
2184
|
+
});
|
|
2185
|
+
});
|
|
2186
|
+
return t && (i.value = n), t;
|
|
2187
|
+
}
|
|
2188
|
+
let t = i.value.findIndex((t) => t.id === e.id);
|
|
2189
|
+
if (t === -1) return i.value = [...i.value, e], !0;
|
|
2190
|
+
let n = {
|
|
2191
|
+
...e,
|
|
2192
|
+
replies: e.replies ?? i.value[t].replies
|
|
2193
|
+
};
|
|
2194
|
+
return !w(i.value[t], n) && (i.value = C(i.value, t, n), !0);
|
|
2195
|
+
}
|
|
2196
|
+
function E(e, t) {
|
|
2197
|
+
let n = _(e), r = t ?? n?.parentId ?? null;
|
|
2198
|
+
return r ? i.value = i.value.map((t) => t.id === r ? {
|
|
2199
|
+
...t,
|
|
2200
|
+
replies: (t.replies ?? []).filter((t) => t.id !== e)
|
|
2201
|
+
} : t) : i.value = i.value.filter((t) => t.id !== e), n;
|
|
2202
|
+
}
|
|
2203
|
+
async function D(e) {
|
|
2204
|
+
let n = m("list");
|
|
2205
|
+
a.value = !0;
|
|
2206
|
+
try {
|
|
2207
|
+
i.value = await t.list(n, e);
|
|
2208
|
+
} catch (e) {
|
|
2209
|
+
b(e);
|
|
2210
|
+
} finally {
|
|
2211
|
+
a.value = !1;
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
async function O(e) {
|
|
2215
|
+
let { create: n } = t;
|
|
2216
|
+
typeof n != "function" && g("create");
|
|
2217
|
+
let r = m("create");
|
|
2218
|
+
h("create"), o.value = !0;
|
|
2219
|
+
try {
|
|
2220
|
+
let i = await n(r, e);
|
|
2221
|
+
return T(i), x(() => t.onCreated?.(i, { origin: "local" })), i;
|
|
2222
|
+
} catch (e) {
|
|
2223
|
+
b(e);
|
|
2224
|
+
} finally {
|
|
2225
|
+
o.value = !1;
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
async function k(e, n) {
|
|
2229
|
+
let { update: r } = t;
|
|
2230
|
+
typeof r != "function" && g("update");
|
|
2231
|
+
let i = m("update");
|
|
2232
|
+
h("update"), o.value = !0;
|
|
2233
|
+
try {
|
|
2234
|
+
let a = await r(i, e, n);
|
|
2235
|
+
return T(a), x(() => t.onUpdated?.(a, { origin: "local" })), a;
|
|
2236
|
+
} catch (e) {
|
|
2237
|
+
b(e);
|
|
2238
|
+
} finally {
|
|
2239
|
+
o.value = !1;
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
async function A(e) {
|
|
2243
|
+
let { delete: n } = t;
|
|
2244
|
+
typeof n != "function" && g("delete");
|
|
2245
|
+
let r = m("delete");
|
|
2246
|
+
h("delete");
|
|
2247
|
+
let i = _(e);
|
|
2248
|
+
o.value = !0;
|
|
2249
|
+
try {
|
|
2250
|
+
await n(r, e), E(e), i && x(() => t.onDeleted?.(i, { origin: "local" }));
|
|
2251
|
+
} catch (e) {
|
|
2252
|
+
b(e);
|
|
2253
|
+
} finally {
|
|
2254
|
+
o.value = !1;
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
async function j(e, n) {
|
|
2258
|
+
let { setResolved: r } = t;
|
|
2259
|
+
typeof r != "function" && g("setResolved");
|
|
2260
|
+
let i = m("setResolved");
|
|
2261
|
+
h("setResolved"), o.value = !0;
|
|
2262
|
+
try {
|
|
2263
|
+
let a = await r(i, e, n);
|
|
2264
|
+
return T(a), x(() => (a.resolvedAt ? t.onResolved : t.onUnresolved)?.(a, { origin: "local" })), a;
|
|
2265
|
+
} catch (e) {
|
|
2266
|
+
b(e);
|
|
2267
|
+
} finally {
|
|
2268
|
+
o.value = !1;
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
function M(e) {
|
|
2272
|
+
T(e) && x(() => t.onCreated?.(e, { origin: "remote" }));
|
|
2273
|
+
}
|
|
2274
|
+
function N(e) {
|
|
2275
|
+
T(e) && x(() => (e.resolvedAt ? t.onResolved : t.onUpdated)?.(e, { origin: "remote" }));
|
|
2276
|
+
}
|
|
2277
|
+
function ee(e, n) {
|
|
2278
|
+
let r = E(e, n);
|
|
2279
|
+
r && x(() => t.onDeleted?.(r, { origin: "remote" }));
|
|
2280
|
+
}
|
|
2281
|
+
return {
|
|
2282
|
+
comments: i,
|
|
2283
|
+
isLoading: a,
|
|
2284
|
+
isSubmitting: o,
|
|
2285
|
+
canCreate: s,
|
|
2286
|
+
canUpdate: c,
|
|
2287
|
+
canDelete: l,
|
|
2288
|
+
canResolve: u,
|
|
2289
|
+
totalCount: d,
|
|
2290
|
+
unresolvedCount: f,
|
|
2291
|
+
commentCountByBlock: p,
|
|
2292
|
+
load: D,
|
|
2293
|
+
create: O,
|
|
2294
|
+
update: k,
|
|
2295
|
+
remove: A,
|
|
2296
|
+
setResolved: j,
|
|
2297
|
+
find: _,
|
|
2298
|
+
isOwn: y,
|
|
2299
|
+
applyRemoteCreate: M,
|
|
2300
|
+
applyRemoteUpdate: N,
|
|
2301
|
+
applyRemoteDelete: ee
|
|
2302
|
+
};
|
|
2303
|
+
}
|
|
2304
|
+
function Mt(e) {
|
|
2305
|
+
let { comments: t, provider: n, getTemplateId: i } = e, { subscribe: a } = n;
|
|
2306
|
+
if (typeof a != "function") return;
|
|
2307
|
+
let s = null;
|
|
2308
|
+
function c() {
|
|
2309
|
+
s?.(), s = null;
|
|
2310
|
+
}
|
|
2311
|
+
r(() => i(), (e) => {
|
|
2312
|
+
c(), e && (s = a(e, (e) => {
|
|
2313
|
+
switch (e.type) {
|
|
2314
|
+
case "created":
|
|
2315
|
+
t.applyRemoteCreate(e.comment);
|
|
2316
|
+
break;
|
|
2317
|
+
case "updated":
|
|
2318
|
+
t.applyRemoteUpdate(e.comment);
|
|
2319
|
+
break;
|
|
2320
|
+
case "deleted": t.applyRemoteDelete(e.commentId, e.parentId);
|
|
2321
|
+
}
|
|
2322
|
+
}));
|
|
2323
|
+
}, { immediate: !0 }), o(c);
|
|
2324
|
+
}
|
|
2325
|
+
// src/constants/timeouts.ts
|
|
2326
|
+
var Nt = 1e4;
|
|
2327
|
+
// src/composables/useImageUrlResolver.ts
|
|
2328
|
+
function Pt(t) {
|
|
2329
|
+
let n = e(/* @__PURE__ */ new Map()), r = /* @__PURE__ */ new Set();
|
|
2330
|
+
function i(e) {
|
|
2331
|
+
return n.get(e);
|
|
2332
|
+
}
|
|
2333
|
+
function a(e) {
|
|
2334
|
+
return n.has(e) || r.has(e);
|
|
2335
|
+
}
|
|
2336
|
+
function o(e) {
|
|
2337
|
+
if (a(e)) return;
|
|
2338
|
+
let i;
|
|
2339
|
+
try {
|
|
2340
|
+
i = t(e);
|
|
2341
|
+
} catch {
|
|
2342
|
+
n.set(e, null);
|
|
2343
|
+
return;
|
|
2344
|
+
}
|
|
2345
|
+
i === null || typeof i == "string" ? n.set(e, i) : (r.add(e), Promise.resolve(i).then((t) => {
|
|
2346
|
+
n.set(e, typeof t == "string" ? t : null);
|
|
2347
|
+
}, () => {
|
|
2348
|
+
n.set(e, null);
|
|
2349
|
+
}).finally(() => r.delete(e)));
|
|
2350
|
+
}
|
|
2351
|
+
return {
|
|
2352
|
+
get: i,
|
|
2353
|
+
has: a,
|
|
2354
|
+
lookup: o
|
|
2355
|
+
};
|
|
2356
|
+
}
|
|
2357
|
+
function Ft(e) {
|
|
2358
|
+
let t = a(ye, null), n = v(e);
|
|
2359
|
+
if (!t) return n;
|
|
2360
|
+
let i;
|
|
2361
|
+
function s() {
|
|
2362
|
+
i !== void 0 && (clearTimeout(i), i = void 0);
|
|
2363
|
+
}
|
|
2364
|
+
c() && o(s);
|
|
2365
|
+
let l = !0;
|
|
2366
|
+
return r(n, (e) => {
|
|
2367
|
+
s();
|
|
2368
|
+
let n = l;
|
|
2369
|
+
l = !1, e && !t.has(e) && (n ? t.lookup(e) : i = setTimeout(() => {
|
|
2370
|
+
i = void 0, t.lookup(e);
|
|
2371
|
+
}, 300));
|
|
2372
|
+
}, { immediate: !0 }), v(() => {
|
|
2373
|
+
let e = n.value;
|
|
2374
|
+
if (!e) return e;
|
|
2375
|
+
let r = t.get(e);
|
|
2376
|
+
return typeof r == "string" && r.length > 0 ? r : e;
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2379
|
+
function It(e, t) {
|
|
2380
|
+
if (!e || !t) return t;
|
|
2381
|
+
let n = e.get(t);
|
|
2382
|
+
return typeof n == "string" && n.length > 0 ? n : t;
|
|
2383
|
+
}
|
|
2384
|
+
function Lt(e, t) {
|
|
2385
|
+
return typeof e?.url == "string" && ue(e.url, t);
|
|
2386
|
+
}
|
|
2387
|
+
function Rt(e, t) {
|
|
2388
|
+
let n = e?.url;
|
|
2389
|
+
if (typeof n == "string" && n.trim() !== "") return ue(n, t) ? void 0 : n;
|
|
2390
|
+
}
|
|
2391
|
+
function zt(e) {
|
|
2392
|
+
let t = a(ve, ce.liquid), n = Ft(() => Rt(e(), t));
|
|
2393
|
+
return v(() => Lt(e(), t) ? null : n.value);
|
|
2394
|
+
}
|
|
2395
|
+
function Bt(e, t, n) {
|
|
2396
|
+
return Lt(t, n) ? null : It(e, Rt(t, n));
|
|
2397
|
+
}
|
|
2398
|
+
// src/utils/blockTypeLabels.ts
|
|
2399
|
+
function Vt(e, t) {
|
|
2400
|
+
return t.blocks[e] ?? e;
|
|
2401
|
+
}
|
|
2402
|
+
function Ht(e, t, n = []) {
|
|
2403
|
+
if (e.type !== "custom") return Vt(e.type, t);
|
|
2404
|
+
let { customType: r } = e;
|
|
2405
|
+
return n.find((e) => e.type === r)?.name ?? r;
|
|
2406
|
+
}
|
|
2407
|
+
// src/utils/resolveFieldColors.ts
|
|
2408
|
+
function Ut(e, t) {
|
|
2409
|
+
let n = we({ presets: e.presets }, Te), r = n.presets.length === 0;
|
|
2410
|
+
return {
|
|
2411
|
+
presets: r ? t.presets : n.presets,
|
|
2412
|
+
allowCustom: t.allowCustom === !1 ? !1 : e.allowCustom ?? t.allowCustom,
|
|
2413
|
+
invalidPresets: n.invalidPresets,
|
|
2414
|
+
emptyPresets: e.presets !== void 0 && e.presets.length === 0,
|
|
2415
|
+
presetsInherited: r,
|
|
2416
|
+
allowCustomIgnored: e.allowCustom === !0 && t.allowCustom === !1
|
|
2417
|
+
};
|
|
2418
|
+
}
|
|
2419
|
+
// src/utils/imageNaturalSize.ts
|
|
2420
|
+
function Wt(e) {
|
|
2421
|
+
return typeof e == "number" && Number.isFinite(e) && e > 0;
|
|
2422
|
+
}
|
|
2423
|
+
function Gt(e, t) {
|
|
2424
|
+
return Wt(e) && Wt(t) ? {
|
|
2425
|
+
width: e,
|
|
2426
|
+
height: t
|
|
2427
|
+
} : null;
|
|
2428
|
+
}
|
|
2429
|
+
function Kt(e) {
|
|
2430
|
+
return Gt(e.naturalWidth, e.naturalHeight);
|
|
2431
|
+
}
|
|
2432
|
+
function qt(e) {
|
|
2433
|
+
return e ? {
|
|
2434
|
+
naturalWidth: e.width,
|
|
2435
|
+
naturalHeight: e.height
|
|
2436
|
+
} : {
|
|
2437
|
+
naturalWidth: void 0,
|
|
2438
|
+
naturalHeight: void 0
|
|
2439
|
+
};
|
|
2440
|
+
}
|
|
2441
|
+
function Jt(e, t) {
|
|
2442
|
+
if (typeof Image > "u") return t(null), () => {};
|
|
2443
|
+
let n = new Image(), r = () => {
|
|
2444
|
+
n.onload = null, n.onerror = null;
|
|
2445
|
+
};
|
|
2446
|
+
return n.onload = () => {
|
|
2447
|
+
r(), t(Gt(n.naturalWidth, n.naturalHeight));
|
|
2448
|
+
}, n.onerror = () => {
|
|
2449
|
+
r(), t(null);
|
|
2450
|
+
}, n.src = e, r;
|
|
2451
|
+
}
|
|
2452
|
+
function Yt(e) {
|
|
2453
|
+
return new Promise((t) => {
|
|
2454
|
+
let n = setTimeout(() => {
|
|
2455
|
+
r(), t(null);
|
|
2456
|
+
}, Nt), r = Jt(e, (e) => {
|
|
2457
|
+
clearTimeout(n), t(e);
|
|
2458
|
+
});
|
|
2459
|
+
});
|
|
2460
|
+
}
|
|
2461
|
+
// src/components/MediaDropOverlay.vue
|
|
2462
|
+
var Xt = /* @__PURE__ */ t({
|
|
2463
|
+
__name: "MediaDropOverlay",
|
|
2464
|
+
props: {
|
|
2465
|
+
uploading: { type: Boolean },
|
|
2466
|
+
size: { default: "field" }
|
|
2467
|
+
},
|
|
2468
|
+
setup(e) {
|
|
2469
|
+
let t = e, { t: r } = Se(), i = {
|
|
2470
|
+
field: {
|
|
2471
|
+
gap: "tpl:gap-1.5",
|
|
2472
|
+
icon: 18,
|
|
2473
|
+
veil: "90%"
|
|
2474
|
+
},
|
|
2475
|
+
canvas: {
|
|
2476
|
+
gap: "tpl:gap-2",
|
|
2477
|
+
icon: 20,
|
|
2478
|
+
veil: "85%"
|
|
2479
|
+
}
|
|
2480
|
+
}, a = v(() => i[t.size]);
|
|
2481
|
+
return (t, i) => (n(), l("div", {
|
|
2482
|
+
class: p(["tpl:pointer-events-none tpl:absolute tpl:inset-0 tpl:z-10 tpl:flex tpl:flex-col tpl:items-center tpl:justify-center tpl:rounded tpl:border-2 tpl:border-dashed tpl:text-xs tpl:font-medium tpl:border-[var(--tpl-primary)] tpl:text-[var(--tpl-primary)]", a.value.gap]),
|
|
2483
|
+
style: y({ backgroundColor: `color-mix(in srgb, var(--tpl-bg) ${a.value.veil}, transparent)` })
|
|
2484
|
+
}, [e.uploading ? (n(), l(C, { key: 0 }, [w(f(ge), {
|
|
2485
|
+
class: "tpl-spinner",
|
|
2486
|
+
size: a.value.icon,
|
|
2487
|
+
"stroke-width": 2
|
|
2488
|
+
}, null, 8, ["size"]), d(" " + g(f(r).image.uploading), 1)], 64)) : (n(), l(C, { key: 1 }, [w(f(_e), {
|
|
2489
|
+
size: a.value.icon,
|
|
2490
|
+
"stroke-width": 1.5
|
|
2491
|
+
}, null, 8, ["size"]), d(" " + g(f(r).image.dropToUpload), 1)], 64))], 6));
|
|
2492
|
+
}
|
|
2493
|
+
});
|
|
2494
|
+
// src/composables/useAliveFlag.ts
|
|
2495
|
+
function Zt() {
|
|
2496
|
+
let e = { alive: !0 };
|
|
2497
|
+
return i(() => {
|
|
2498
|
+
e.alive = !1;
|
|
2499
|
+
}), e;
|
|
2500
|
+
}
|
|
2501
|
+
// src/composables/useImageDrop.ts
|
|
2502
|
+
var Qt = "image/";
|
|
2503
|
+
function $t(e) {
|
|
2504
|
+
let { target: t, onFiles: n, enabled: r } = e, i = () => r === void 0 || _(r), { isOverDropZone: a } = Ce(t, {
|
|
2505
|
+
preventDefaultForUnhandled: !0,
|
|
2506
|
+
onDrop: (e) => {
|
|
2507
|
+
if (!i()) return;
|
|
2508
|
+
let t = (e ?? []).filter((e) => e.type.startsWith(Qt));
|
|
2509
|
+
t.length > 0 && n([t[0]]);
|
|
2510
|
+
}
|
|
2511
|
+
});
|
|
2512
|
+
return { isOver: v(() => i() && a.value) };
|
|
2513
|
+
}
|
|
2514
|
+
// src/composables/useMediaDropField.ts
|
|
2515
|
+
function en(e) {
|
|
2516
|
+
let { target: t, blocked: n, apply: r } = e, i = a(be, null), o = a(xe, null), s = Zt();
|
|
2517
|
+
async function c() {
|
|
2518
|
+
let e = await i?.({ accept: ["images"] });
|
|
2519
|
+
s.alive && e && r(e);
|
|
2520
|
+
}
|
|
2521
|
+
let l = S(!1), u = v(() => (o?.value ?? !!i) && !l.value && !_(n));
|
|
2522
|
+
async function d(e) {
|
|
2523
|
+
if (i) {
|
|
2524
|
+
l.value = !0;
|
|
2525
|
+
try {
|
|
2526
|
+
let t = await i({
|
|
2527
|
+
accept: ["images"],
|
|
2528
|
+
files: e
|
|
2529
|
+
});
|
|
2530
|
+
if (!s.alive) return;
|
|
2531
|
+
t && r(t);
|
|
2532
|
+
} finally {
|
|
2533
|
+
s.alive && (l.value = !1);
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
let { isOver: f } = $t({
|
|
2538
|
+
target: t,
|
|
2539
|
+
enabled: u,
|
|
2540
|
+
onFiles: d
|
|
2541
|
+
}), p = v(() => u.value && f.value || l.value);
|
|
2542
|
+
return {
|
|
2543
|
+
canBrowse: !!i,
|
|
2544
|
+
dropEnabled: u,
|
|
2545
|
+
isUploading: l,
|
|
2546
|
+
showOverlay: p,
|
|
2547
|
+
openMediaBrowser: c
|
|
2548
|
+
};
|
|
2549
|
+
}
|
|
2550
|
+
function tn(e, t = "desktop") {
|
|
2551
|
+
return t === "mobile" ? 375 : e?.width ?? 600;
|
|
2552
|
+
}
|
|
2553
|
+
var nn = "width 300ms cubic-bezier(0.34, 1.56, 0.64, 1)", rn = {
|
|
2554
|
+
1: [100],
|
|
2555
|
+
2: [50, 50],
|
|
2556
|
+
3: [
|
|
2557
|
+
33.33,
|
|
2558
|
+
33.33,
|
|
2559
|
+
33.34
|
|
2560
|
+
],
|
|
2561
|
+
"1-2": [33.33, 66.67],
|
|
2562
|
+
"2-1": [66.67, 33.33]
|
|
2563
|
+
};
|
|
2564
|
+
function an(e, t) {
|
|
2565
|
+
let n = (e) => Math.trunc(e ?? 0), r = (e) => pe(e) === null ? 0 : Math.trunc(e.width);
|
|
2566
|
+
return n(e?.left) + n(e?.right) + r(t?.left) + r(t?.right);
|
|
2567
|
+
}
|
|
2568
|
+
function on(e, t) {
|
|
2569
|
+
return Math.floor(e) - an(t);
|
|
2570
|
+
}
|
|
2571
|
+
function sn(e, t) {
|
|
2572
|
+
let n = "border" in e ? e.border : void 0;
|
|
2573
|
+
return Math.floor(t) - an(e.styles.padding, n);
|
|
2574
|
+
}
|
|
2575
|
+
function* cn(e, t) {
|
|
2576
|
+
for (let n of e) re(n) ? yield* cn(n.children, on(t, n.styles.padding)) : yield {
|
|
2577
|
+
block: n,
|
|
2578
|
+
bandWidth: me(n) && n.wrapper ? on(t, n.wrapper.padding) : t
|
|
2579
|
+
};
|
|
2580
|
+
}
|
|
2581
|
+
function ln(e, t, n = z(e)) {
|
|
2582
|
+
if (!t) return e;
|
|
2583
|
+
try {
|
|
2584
|
+
return ne(ae(t, n, { missing: "default" }), e);
|
|
2585
|
+
} catch {
|
|
2586
|
+
return e;
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
function un(e, t, n, r) {
|
|
2590
|
+
let i = ln(e, n, r);
|
|
2591
|
+
for (let { block: e, bandWidth: n } of cn(i.blocks, i.settings.width)) if (me(e)) {
|
|
2592
|
+
let r = de(e)?.applied ? void 0 : e.border, i = Math.floor(n) - an(e.styles.padding, r), a = rn[e.columns] ?? [100];
|
|
2593
|
+
for (let n = 0; n < e.children.length; n++) {
|
|
2594
|
+
let r = Math.floor(i * (a[n] ?? 100) / 100), o = e.children[n].find((e) => e.id === t);
|
|
2595
|
+
if (o) return sn(o, r);
|
|
2596
|
+
}
|
|
2597
|
+
} else if (e.id === t) return sn(e, n);
|
|
2598
|
+
return null;
|
|
2599
|
+
}
|
|
2600
|
+
function dn(e, t, n, r) {
|
|
2601
|
+
let i = ln(e, n, r);
|
|
2602
|
+
for (let { block: e, bandWidth: n } of cn(i.blocks, i.settings.width)) if (e.id === t) return Math.floor(n);
|
|
2603
|
+
return null;
|
|
2604
|
+
}
|
|
2605
|
+
function fn(e) {
|
|
2606
|
+
let t = me(e) ? de(e) : null;
|
|
2607
|
+
return !!t?.applied && t.height === "image";
|
|
2608
|
+
}
|
|
2609
|
+
function pn(e, t, n, r) {
|
|
2610
|
+
if (fn(e)) return (t ? dn(t, e.id, n, r) : null) ?? tn(t?.settings);
|
|
2611
|
+
}
|
|
2612
|
+
// src/constants/socialIcons.ts
|
|
2613
|
+
var mn = fe, hn = {
|
|
2614
|
+
small: 24,
|
|
2615
|
+
medium: 32,
|
|
2616
|
+
large: 48
|
|
2617
|
+
}, gn = [
|
|
2618
|
+
"facebook",
|
|
2619
|
+
"twitter",
|
|
2620
|
+
"instagram",
|
|
2621
|
+
"linkedin",
|
|
2622
|
+
"youtube",
|
|
2623
|
+
"tiktok",
|
|
2624
|
+
"pinterest",
|
|
2625
|
+
"email",
|
|
2626
|
+
"website",
|
|
2627
|
+
"whatsapp",
|
|
2628
|
+
"telegram",
|
|
2629
|
+
"discord",
|
|
2630
|
+
"snapchat",
|
|
2631
|
+
"reddit",
|
|
2632
|
+
"github",
|
|
2633
|
+
"dribbble",
|
|
2634
|
+
"behance"
|
|
2635
|
+
];
|
|
2636
|
+
export { Et as A, ze as B, Bt as C, jt as D, Mt as E, We as F, Ue as I, Ve as L, Ct as M, lt as N, At as O, Ge as P, He as R, Rt as S, Ft as T, Fe as V, Gt as _, fn as a, Vt as b, nn as c, Zt as d, Xt as f, Kt as g, qt as h, un as i, wt as j, kt as k, tn as l, Yt as m, mn as n, pn as o, Jt as p, gn as r, dn as s, hn as t, en as u, Ut as v, zt as w, Pt as x, Ht as y, Be as z };
|
|
2637
|
+
|
|
2638
|
+
//# sourceMappingURL=socialIcons-DeCYorUT.js.map
|