useblocks 1.2.5 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/iframe/.vite/manifest.json +4 -4
  2. package/iframe/css/sandbox.css +19 -0
  3. package/iframe/{iframe-eblock.ad7a9d1f.html → iframe-eblock.122fb378.html} +2 -2
  4. package/iframe/{iframe.ad7a9d1f.html → iframe.122fb378.html} +2 -2
  5. package/iframe/js/elMarkupHelper.BWGQg2UC.js +278 -0
  6. package/iframe/js/iframe-eblock.body.122fb378.js +9 -0
  7. package/iframe/js/iframe-eblock.js +2 -2
  8. package/iframe/js/iframe.body.122fb378.js +129 -0
  9. package/iframe/js/iframe.js +2 -2
  10. package/package.json +1 -1
  11. package/runtime/react/index.js +1 -1
  12. package/static/core/{46b89e4e.js → 1494a3ca.js} +11 -11
  13. package/static/core/{35b68c2d.js → 1a2cf154.js} +3 -3
  14. package/static/core/{50843a12.js → 1cb6833d.js} +2 -2
  15. package/static/core/{581a610a.js → 303147e0.js} +1 -1
  16. package/static/core/{2d7469b5.js → 33bb736c.js} +1 -1
  17. package/static/core/{c5066b60.js → 38c11cae.js} +1 -1
  18. package/static/core/{d7c1e1d9.js → 49970755.js} +1 -1
  19. package/static/core/{bf98b554.js → 50e69160.js} +2 -2
  20. package/static/core/{d24bb113.js → 6b97c57a.js} +2 -2
  21. package/static/core/{51c86df3.js → 6e062715.js} +1 -1
  22. package/static/core/{91a70e6b.js → 7b1caa12.js} +1 -1
  23. package/static/core/{f369973d.js → 7b850506.js} +1 -1
  24. package/static/core/{55135cf2.js → 7bcaa58e.js} +1 -1
  25. package/static/core/{fb52c612.js → 7ddb2751.js} +1 -1
  26. package/static/core/{719c3c6f.js → 9f258580.js} +1 -1
  27. package/static/core/{220aeb6e.js → a264abc2.js} +1 -1
  28. package/static/core/{501559e1.js → a6303cb2.js} +1 -1
  29. package/static/core/{e22d6382.js → ad4d9ad8.js} +3 -3
  30. package/static/core/{8ddf51c0.js → af884fac.js} +1 -1
  31. package/static/core/c9158d6f.js +28 -0
  32. package/static/core/{e33e9a92.js → ccfcbbb9.js} +1 -1
  33. package/static/core/{76d7fc00.js → d5927dca.js} +1 -1
  34. package/static/core/{ac4fee3c.js → dfcf0815.js} +1 -1
  35. package/static/core/{9ec744ee.js → e5017aee.js} +1 -1
  36. package/static/core/{35aeebd4.js → f55b0a6d.js} +1 -1
  37. package/static/core/{25e324a7.js → f57609e6.js} +1 -1
  38. package/static/core/f6daf47a.js +2 -0
  39. package/static/core/{67bd2b51.js → f83e7853.js} +1 -1
  40. package/static/core/fac929ae.js +1 -0
  41. package/static/core/{49be45c4.js → ff7d14e8.js} +1 -1
  42. package/static/esm/{88c4c0b7.js → b49a4ecd.js} +1 -1
  43. package/static/umd-runtime/{runtime.CVHhHBC5.js → runtime.TNBSxHuX.js} +1 -1
  44. package/useblocks-core.122fb378.js +859 -0
  45. package/useblocks-esm.js +11 -11
  46. package/{useblocks-po.ad7a9d1f.js → useblocks-po.122fb378.js} +1 -1
  47. package/useblocks.js +12 -12
  48. package/vendor/useblocks-ui-kit/package.json +1 -1
  49. package/iframe/js/elMarkupHelper.vJSCLUyq.js +0 -278
  50. package/iframe/js/iframe-eblock.body.ad7a9d1f.js +0 -9
  51. package/iframe/js/iframe.body.ad7a9d1f.js +0 -129
  52. package/static/core/861ad8b1.js +0 -28
  53. package/static/core/8dc1398d.js +0 -1
  54. package/static/core/98e0618f.js +0 -2
  55. package/useblocks-core.ad7a9d1f.js +0 -859
@@ -1 +0,0 @@
1
- __useblocks__.define("static/core/8dc1398d.js",["require","exports","module","static/core/2ff39ddf.js","static/core/cf7d1dd7.js","static/core/4265d23e.js","react","react/jsx-runtime","__delivery__/libs"],function(E,re,ye){const x=E("./2ff39ddf.js"),ce=E("./cf7d1dd7.js"),e=E("./4265d23e.js");let n=E("react");n=x.__toESM(n);let C=E("react/jsx-runtime"),R=E("__delivery__/libs");var a=x.__toESM(e.require_prop_types()),G=new WeakMap;function le(t,B){const S=(G.get(t)??Promise.resolve()).then(B,B);return G.set(t,S.catch(()=>{})),S}var b=({block:t=null,isEditableRights:B,rightCol:S,autoSaveBlockResult:de,disabled:ue,ownsDocument:H=!1})=>{const{__:c}=e.useI18n(),{blockId:V}=e.useRouteParams(),I=e.useEditorProjectId();let fe=e.useSelector(e.selectIsCodeMode$1),_e=e.useSelector(e.selectIsCodeMode$1),me=e.useDispatch();const r=e.useNotification(),m=e.useContentReader(),{document:M}=e.useDocumentSessionContext(),$=e.useStore(),U=e.useSendPostMessage(),[Y,Q]=(0,n.useState)(!1),[pe,ge]=(0,n.useState)(null),[Ee,l]=(0,n.useState)(!1),[p,j]=(0,n.useState)(!1),Se=e.usePushToDataLayer(),q=e.useEventEmitter(ce.events.ON_BLOCK_SAVEBUTTON_CLICK_ID),k=e.useAppConfig().saveHotkeyEnabled!==!1;(0,n.useEffect)(()=>{window?.navigator?.userAgent.includes("Macintosh")&&ge(!0)},[]);const{data:L,refetch:F}=e.useGetProjectQuery(+I,{skip:!+I}),[W]=e.useAddTermMutation(),[P,w]=e.useEditBlockMutation(),[X,v]=e.useAddBlockMutation(),[z]=e.useEditProjectMutation(),{data:J}=e.useGetTermsQuery({project:L,kind:e.BLOCK_TAGS},{skip:!L?.id}),A=(0,n.useCallback)(o=>{if(l(!0),!B&&t.lock&&p){r.error({id:"BLOCK_ACCESS_TO_LOCKED_ERROR",title:c("No access to edit the letter."),data:e.getBlockDesc(t)}),l(!1);return}if((t.tags?.length||t.blocktags?.length)>10&&p){r.error({id:"BLOCK_TOO_MANY_TAGS_ERROR",title:c("Maximum 10 tags available."),data:e.getBlockDesc(t)}),l(!1);return}if(t.type===""){r.error({title:c("Set the type"),description:c("Please set the 'Type' field in the Settings section.")}),l(!1);return}const d=h=>{const ee=t.tags?.map(i=>{const g=J?.find(u=>u.name===i);return g?g.id:W({project:L,kind:e.BLOCK_TAGS,name:i,parent:h}).then(({error:u,data:y})=>{if(u?.status===400)return e.existingTermIdFromError(u);if(y)return y.id;u&&(r.fromError("TAG_CREATING_ERROR",i,u),l(!1))})}),f=H&&M?M:void 0,te=(i=null)=>{let g=null;const u=f?.get().version,y=f?f.get().serverId==null:!!t?.isNew,oe=f?.get().serverId??t?.id,ne=s=>{const _=s?.id;f&&u!==void 0&&f.markSaved(u,y&&_!=null?String(_):void 0),$.dispatch(e.taxonomiesApi.endpoints.getTerms.initiate({project:L,kind:e.BLOCK_TAGS})),F(),s.global_block&&s.id&&U({operation:e.EVENT_TYPES.SANDBOX_EBLOCK_SET_EM_BLOCK_ID,settings:{emBlockId:String(s.id),...g?{emBlockVersion:g}:{}}}),p&&(r.success({id:"BLOCK_EDITING_SUCCESS",title:c("The block was successfully saved."),data:e.getBlockDesc(t)}),l(!1)),fetch(e.blockPreviewHref(e.BLOCK,I,s.id,s.modified),{mode:"no-cors"}).then(()=>{})},ie=e.getTaxonomy(t,e.EMAIL_TAGS).filter(s=>(i||t.blocktags).includes(s.id)).map(s=>s.name);if(y){if(v.status!=="pending")return X({source:o,title:t.title===null?c("New block title"):t.title,project:t.project,type:t.type?t.type:"Other",description:t.description,html:m(),blocktags:i?i.join(","):t.blocktags,tags:ie,...e.hasOwnMeta(t)?{meta:t.meta}:{}}).then(async({data:s,error:_})=>{if(_)r.fromError("BLOCK_CREATING_ERROR",{title:t.title,html:m()},_),l(!1);else{let N=s;const T=m();if(s?.global_block&&s?.id&&T){const O=new Date,ae=e.injectEmBlockIdIntoBlockHtml(T,String(s.id),O);if(g=e.formatEmBlockVersion(O),ae!==T){const K=await P({blockId:s.id,html:ae});!K.error&&K.data&&(N=K.data)}}ne(N)}})}else if(w.status!=="pending"){const s=m(),_=new Date,N=t.global_block?e.injectEmBlockIdIntoBlockHtml(s,String(oe),_):s;return t.global_block&&(g=e.formatEmBlockVersion(_)),P({blockId:oe,source:o,title:t.title,project:t.project,type:t.type?t.type:"Other",description:t.description,html:N,blocktags:i||t.blocktags,tags:ie,...e.hasOwnMeta(t)?{meta:t.meta}:{}}).then(({data:T,error:O})=>{O&&p?(r.fromError("BLOCK_EDITING_ERROR",e.getBlockDesc(t),O),l(!1)):ne(T)})}return Promise.resolve()},se=i=>f?le(f,()=>te(i)):te(i);ee?Promise.all(ee).then(i=>se(i)):se(null)};l(!0),d(void 0)},[v.status,X,w.status,P,t,B,W,z,I,c,p,m,r,J,F,$,U,H,M]);(0,n.useEffect)(()=>{if(p){const o=A;q.fire({...t,html:m()}).then(d=>{d.every(h=>h!==!1)&&o()}).catch(d=>r.fromError("SAVE_BUTTON_CLICK_EVENT_ERROR",e.getBlockDesc(t),d,!0)),j(!1)}},[p,A,q,t,m,r]);const D=(0,n.useCallback)(o=>{(o.ctrlKey||o.metaKey)&&o.keyCode===83&&(o.preventDefault(),k&&j(!0))},[k]);(0,n.useEffect)(()=>(document.addEventListener("keydown",D),()=>{document.removeEventListener("keydown",D)}),[D]);const ve=(0,n.useCallback)(o=>{const d=o.data.operation,h=o.data.action;d===e.EVENT_TYPES.APPLICATION_ACTION&&h==="save_email"&&k&&j(!0)},[k]);e.useListenPostMessage(ve),(0,n.useEffect)(()=>{v.isError&&(l(!1),r.error(v))},[me,v]),(0,n.useEffect)(()=>{const o=setTimeout(()=>{Q(!0)},1e4);return()=>{clearTimeout(o)}},[]),(0,n.useEffect)(()=>{t.isNew&&!V&&Y&&(A(),Q(!1))},[Y,t,A,V]);const Be=w.isLoading||z.isLoading||v.isLoading||Ee,Z=!!de?.isLoading,he=Be||Z;return(0,C.jsx)(R.ui_kit$Tooltip,{title:c(pe?"Save by ⌘S":"Save by Ctrl+S"),placement:S?"right":"bottomRight",children:(0,C.jsx)("span",{className:"em-analytics__block-save-tooltip-target",children:(0,C.jsx)(R.ui_kit$Button,{type:"primary",block:S,disabled:ue||Z,className:"em-analytics__block-save",icon:(0,C.jsx)(e.EmIcons,{icon:"SaveOutlined",component:R.icons$SaveOutlined}),onClick:o=>{const d=o.currentTarget;Se({event:"click",action:"save_block"}),j(!0);try{d?.blur?.()}catch{}},loading:he,children:S||fe||_e?"":c("Save")})})})};b.propTypes={block:a.default.shape({id:a.default.string,isNew:a.default.bool,lock:a.default.bool,type:a.default.string,html:a.default.string,description:a.default.string,project:a.default.number,title:a.default.string}),isEditableRights:a.default.bool.isRequired,ownsDocument:a.default.bool},Object.defineProperty(re,"SaveBlockBtn",{enumerable:!0,get:function(){return b}})});
@@ -1,2 +0,0 @@
1
- (function(){try{if(typeof document<"u"){var o=".blocks-app .block-page-header__dropdown-menu{top:10px}.blocks-app .anticon.anticon-edit.block-page-header__icon-edit{color:#8c8c8c;margin-left:6px;font-size:16px}.blocks-app .ant-typography-edit:hover .anticon.anticon-edit.block-page-header__icon-edit{color:var(--ub-colorPrimaryHover)}.blocks-app .ant-page-header.block-page-header{margin-bottom:20px;padding-left:0;padding-right:0}@media (width<=1450px){.blocks-app .ant-page-header.block-page-header{padding-left:12px;padding-right:12px}}.blocks-app .block-page-header .ant-page-header-heading-left{flex-grow:1;overflow:visible}.blocks-app .block-page-header .ant-page-header-back{align-self:flex-start;margin-left:12px;margin-right:0;padding-top:12px}.blocks-app .block-page-header .ant-page-header-heading-title{white-space:pre-wrap;flex-grow:1;font-weight:500;overflow:visible}.blocks-app .block-page-header .ant-typography{margin-bottom:0;padding:4px 12px}.blocks-app .block-page-header .ant-typography-edit-content{margin-top:0;padding:0;left:auto}.blocks-app .block-page-header .ant-input{font-size:inherit;font-weight:inherit}.blocks-app .block-page-header .ant-page-header-heading-extra>*{margin-left:8px}.blocks-app .block-page-header .ant-btn.block-page-header__btn_extra,.blocks-app header .ant-btn.block-page-header__btn_extra{width:32px;padding:0}.blocks-app .block-page__row{margin-bottom:60px}@media (width>=1700px){.blocks-app .block-page__row{margin-right:-60px}}",e=window.__useblocks_styles__||(window.__useblocks_styles__={sheets:{},order:[]}),n=o;if(!e.sheets[n]){var a=null;try{typeof CSSStyleSheet=="function"&&"replaceSync"in CSSStyleSheet.prototype&&(a=new CSSStyleSheet,a.replaceSync(o))}catch{a=null}if(a){if(!e.host||!e.host.isConnected||!e.host.sheet){var t=document.createElement("style");t.setAttribute("data-useblocks","true"),document.head.appendChild(t),e.host=t}for(var c=e.host.sheet,l=0;l<a.cssRules.length;l++)try{c.insertRule(a.cssRules[l].cssText,c.cssRules.length)}catch{}(e.texts||(e.texts=[])).push(o),(e.listeners||[]).forEach(function(p){try{p(o)}catch{}})}else{var t=document.createElement("style");t.setAttribute("data-useblocks","true"),t.appendChild(document.createTextNode(o)),document.head.appendChild(t)}e.sheets[n]=!0,e.order.push(n)}}}catch(p){console.error("vite-plugin-css-injected-by-js",p)}})();
2
- __useblocks__.define("static/core/98e0618f.js",["require","exports","module","static/core/2ff39ddf.js","static/core/cf7d1dd7.js","static/core/4265d23e.js","static/core/be5dc8a7.js","static/core/8dc1398d.js","react","react/jsx-runtime","__delivery__/libs","classnames"],function(f,te,le){const J=f("./2ff39ddf.js"),U=f("./cf7d1dd7.js"),e=f("./4265d23e.js"),A=f("./be5dc8a7.js"),oe=f("./8dc1398d.js");let l=f("react");l=J.__toESM(l);let o=f("react/jsx-runtime"),i=f("__delivery__/libs"),V=f("classnames");V=J.__toESM(V);var q=({block:t,autoSaveBlockResult:p})=>{const{__:c,_x:u}=e.useI18n();e.useDispatch();const b=e.useEmailAttributesWriter(),d=e.useAppNavigate(),E=e.useCurrentUser(),{modal:y}=i.ui_kit$App.useApp(),m=e.useNotification(),{confirm:$}=y,{token:Y}=(0,i.ui_kit$useToken)(),F=e.useAppConfig(),K=e.useContainer(),C=()=>{e.leaveBlock(K)},I=e.useSelector(e.selectCodeModeDirection),v=t.hasOwnProperty("type")?e.BLOCK:e.EMAIL,x=e.useSelector(e.selectElementSettings$1),G=e.useSelector(e.selectElementSettings),_=v==="email"?x:G,O=e.useSelector(e.selectIsCodeMode),z=()=>(_?.type===e.ELEMENT_TYPES.TEXT||_?.type===e.ELEMENT_TYPES.LINK||_.type===e.ELEMENT_TYPES.BUTTON)&&O&&I!=="bottom",r=e.useProjectData(),{owner:w,admin:B}=e.useMyRoles(),Q=e.useStore(),N=(s,g)=>Q.dispatch(e.blocksApi.endpoints.deleteBlock.initiate(s.id)).then(k=>{k.error&&m.fromError("BLOCK_REMOVING_ERROR",e.getBlockDesc(s),k.error),C(),g(`/projects/${s.project}/blocks`),m.success({id:"BLOCK_REMOVING_SUCCESS",title:c("The block “")+k.data.title+u("” was successfully removed.","block"),data:e.getBlockDesc(s)})}),S=(s,g)=>{$({mask:{closable:!0},centered:!0,title:u("Are you sure you want to delete the “","block")+s.title+c("” block?"),icon:(0,o.jsx)(e.EmIcons,{icon:"DeleteOutlined",component:i.icons$DeleteOutlined,size:22,style:{color:i.ui_kit$iconColors.danger,marginInlineEnd:12,flexShrink:0}}),okText:c("Yes"),cancelText:c("No"),onOk:()=>N(s,g)})},T=()=>{C(),d(`/projects/${r.id}/blocks`)},L=s=>{b({title:s})},[W,P]=e.useAddBlockMutation(),X=e.useContentReader(),D=()=>{t.isNew?t.isNew?m.warning({id:"COPY_NOT_SAVED",payload:t,title:c("To create a copy, you need to save the block.")}):W({title:e.generateCopyTitle(t.title),blocktags:t.blocktags,project:r.id,subject:t.subject,description:t.description,html:X(),type:t.type?t.type:"Other"}).then(s=>{if(s.error){m.error({id:"BLOCK_CLONING_ERROR",data:e.getBlockDesc(t),innerException:s.error,title:s.error.data.code,description:s.error.data.message});return}d(`/projects/${r.id}/blocks/${s.data.id}`),m.success({id:"BLOCK_CLONING_SUCCESS",data:e.getBlockDesc(t),title:c("The copy of block “")+t.title+u("” was successfully created.","block")})}):e.getEmitter(K,U.events.ON_BLOCK_CLONE_ID).fire(t)},M=()=>{t.isNew?(C(),d(`/projects/${r.id}/blocks`),m.success({id:"BLOCK_REMOVING_SUCCESS",title:c("The draft of the block has been deleted."),data:e.getBlockDesc(t)})):S(t,d)};let h=[];h.push({label:c("Clone"),icon:(0,o.jsx)(e.EmIcons,{icon:"CopyOutlined",component:i.icons$CopyOutlined,size:16}),key:"Clone",className:"em-analytics__block-clone",disabled:P.isLoading,onClick:D}),(w||B||E.id?.toString()===t.author?.toString())&&h.push({label:(0,o.jsx)(e.SwitchLockBtn,{element:t},"Lock"),icon:t.lock?(0,o.jsx)(e.EmIcons,{icon:"UnlockOutlined",component:i.icons$UnlockOutlined,style:{fontSize:"16px"}}):(0,o.jsx)(e.EmIcons,{icon:"LockOutlined",component:i.icons$LockOutlined,style:{fontSize:"16px"}}),disabled:t.isNew},{label:c("Remove"),icon:(0,o.jsx)(e.EmIcons,{icon:"DeleteOutlined",component:i.icons$DeleteOutlined,size:16}),key:"Remove",className:"em-analytics__block-remove",onClick:M,style:{color:"#ff4d4f"}}),e.useSetTitle(t.title===null?c("New block title"):t.title);const R=(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)(i.ui_kit$Space,{size:10,children:[F.headerArrowBackVisible&&(0,o.jsx)(i.ui_kit$Tooltip,{title:c("Back"),placement:"left",children:(0,o.jsx)(i.ui_kit$Button,{type:"text",icon:(0,o.jsx)(e.EmIcons,{icon:"ArrowLeftOutlined",component:i.icons$ArrowLeftOutlined}),onClick:T,shape:"circle"})}),(0,o.jsx)(i.ui_kit$Paragraph,{className:"ant-page-header-heading-title",editable:{triggerType:["text","icon"],icon:(0,o.jsx)(e.EmIcons,{icon:"EditOutlined",component:i.icons$EditOutlined,className:"email-page-header__icon-edit"}),onChange:L},children:t.title===null?c("New block title"):t.title})]})}),n=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(A.EmailPreviewMenu,{emailElement:t}),t.lock?(0,o.jsx)(e.EmIcons,{icon:"LockOutlined",component:i.icons$LockOutlined,className:(0,V.default)("lock-icon",{"lock-icon__disabled":!(w||B||E.id?.toString()===t.author?.toString())}),style:{color:Y.colorPrimary,fontSize:"16px"}},"Lock"):null,(0,o.jsx)(i.ui_kit$Dropdown,{arrow:"true",menu:{items:h},children:(0,o.jsx)(i.ui_kit$Button,{className:"block-page-header__btn block-page-header__btn_extra",onClick:()=>{},children:(0,o.jsx)(e.EmIcons,{icon:"EllipsisOutlined",component:i.icons$EllipsisOutlined})})},"Actions"),(0,o.jsx)(oe.SaveBlockBtn,{className:"em-analytics__block-save",block:t,isEditableRights:w||B||E.id?.toString()===t.author?.toString(),autoSaveBlockResult:p,ownsDocument:!0},"Save")]}),a=F.commandButtonsEnabled?n:(0,o.jsx)(A.EmailPreviewMenu,{emailElement:t});return(0,o.jsx)(e.Header,{leftBlock:R,rightBlock:a,className:"header_blocks",isHeaderCodeMenuOpen:z()})};q.propTypes={};function ee(t=document){const p=t.getElementById("email_iframe_slot");return{slot:p,area:p?.closest("[data-scroll-area]")??null}}function ne(t){if(t)return t.renderGuid??(t.id!=null?String(t.id):void 0)}function se(t,p={}){const c=e.useStore(),u=p.key??ne(t),b=p.recovery===!0,d=(0,l.useMemo)(()=>{if(u===void 0)return;const m=e.getEmailDocuments(U.getContainer(c));return b?t?.id!=null?m.open(String(t.id),{email:t}):m.openDraft(t):m.openBlock(u,t)},[u,c,b]),E=t?.modified,y=t?.lock;return(0,l.useEffect)(()=>{e.writeSourceReport(d,e.fromServerFacts({modified:E,lock:y}))},[d,E,y]),d}var{Content:re}=i.ui_kit$Layout,ie=({session:t})=>{const{__:p}=e.useI18n(),c=e.useSendPostMessage(),{blockId:u,projectId:b}=e.useRouteParams(),d=e.useDispatch();e.useAppNavigate();const E=e.useCookieManager();e.useSelector(e.selectMonacoFocusing),e.useSelector(e.selectIsPanelHistoryCollapsed),e.useAppConfig();const y=E.get(e.APP_COOKIES.em_new_block),{isSuccess:m,data:$}=e.useGetBlockQuery(+y,{skip:!!t||!y}),[Y,F]=(0,l.useState)(!1),{isLoading:K,isSuccess:C,isError:I,error:v,data:x}=e.useGetBlockQuery(u,{skip:!!t||!u});(0,l.useEffect)(()=>{I&&v&&e.reportEntityLoadError("block",u,v)},[I,v,u]);const G=y?m:C,_=C&&x?.id?x:m&&$,O=t?t.block:_,z=se(t?void 0:_||void 0,{key:!t&&_?.id!=null?e.blockSessionKey(_.id):void 0}),r=t?t.document:z,w=e.useDocumentAttributes(r),B=(0,l.useMemo)(()=>r?e.resolveOpenEmail({attributes:w,readContent:()=>r.getContent(),docId:r.get().docId,hasSession:!0,serverId:r.get().serverId,show:void 0}):O,[w,r,O]),Q=e.useStore(),N=e.getEmailDocuments(U.getContainer(Q)).history();e.usePublishDocumentSession(r,N);const S=e.useUserUndo({document:r,history:N}),T=(0,l.useCallback)(()=>{S.undo()},[S]),L=(0,l.useCallback)(()=>{S.redo()},[S]),W=(0,l.useCallback)(()=>S.clear(),[S]);e.useEditorUiReset(r?.get().docId,W);const P=(0,l.useCallback)(n=>{(window.navigator.appVersion.indexOf("Mac")&&n.metaKey||n.ctrlKey)&&(n.code==="KeyZ"?(n.preventDefault(),n.shiftKey?L():T()):n.code==="KeyY"&&!n.shiftKey&&(n.preventDefault(),L()))},[T,L]);(0,l.useEffect)(()=>(document.body.classList.add("editor"),()=>{d(e.resetPanes()),d(e.closeModal$1()),d(e.resetElementHistorySlice()),d(e.setActiveSettingsTab(e.BUILD))}),[d]);const X=n=>{const a=n.data.operation,s=n.data.action,g=document.getElementById("iframe-scroll-top"),k=document.getElementById("iframe-scroll-bottom");if(a===e.EVENT_TYPES.APPLICATION_ACTION&&(s==="undo"?T():s==="redo"&&L()),a===e.EVENT_TYPES.APPLICATION_SCROLL_BLOCK_SHOW){const{slot:Z}=ee(),H=document.body.getBoundingClientRect().height,j=Z?.getClientRects()[0];if(!j||!g||!k)return;j.top<0&&(g.style.display="block"),j.top+j.height>H&&(k.style.display="block")}a===e.EVENT_TYPES.APPLICATION_SCROLL_BLOCK_HIDE&&g&&k&&(g.style.display="none",k.style.display="none")};e.useListenPostMessage(X);const D=(0,l.useCallback)(n=>{n.target?.closest?.(".file-manager, .ant-modal.file-manager")||(n.preventDefault(),n.target&&c({operation:e.EVENT_TYPES.SANDBOX_DRAG_CANCEL}))},[c]),M=(0,l.useCallback)(()=>{},[]),h=(0,l.useCallback)(n=>{if(n.preventDefault(),n.target?.closest?.(".file-manager, .ant-modal.file-manager"))return;const a=document.getElementById("iframe-scroll-top"),s=document.getElementById("iframe-scroll-bottom"),{slot:g,area:k}=ee();if(!g||!a||!s)return;const{height:Z,top:H}=g.getBoundingClientRect(),j=document.body.getBoundingClientRect().height;H>1?a.style.display==="block"&&(a.style.display="none"):a.style.display==="none"&&(a.style.display="block"),Z-j+H<1?s.style.display==="block"&&(s.style.display="none"):s.style.display==="none"&&(s.style.display="block"),n.target===a&&k?.scrollBy(0,-20),n.target===s&&k?.scrollBy(0,20)},[]),R=(0,l.useCallback)(()=>{const n=document.getElementById("iframe-scroll-top"),a=document.getElementById("iframe-scroll-bottom");n&&a&&(n.style.display="none",a.style.display="none")},[]);return(0,l.useEffect)(()=>(window.addEventListener("dragstart",M),window.addEventListener("drop",D),window.addEventListener("dragend",R),window.addEventListener("dragover",h),window.addEventListener("keydown",P),()=>{window.removeEventListener("dragstart",M),window.removeEventListener("drop",D),window.removeEventListener("dragover",h),window.removeEventListener("dragend",R),window.removeEventListener("keydown",P)}),[P,M,D,R,h]),(0,o.jsx)(e.DocumentSessionProvider,{document:r,history:N,children:(0,o.jsxs)(i.ui_kit$Layout,{className:"block-page",children:[O&&(0,o.jsx)(q,{block:B}),K&&(0,o.jsx)(i.ui_kit$PageLoader,{}),I&&v&&!1,t?O&&(0,o.jsx)(A.EmailPane_default,{emailElement:B,kind:"block",isSuccess:!0}):(!u&&(y?Y&&$:!0)||C&&x)&&(0,o.jsx)(A.EmailPane_default,{emailElement:B,kind:"block",isSuccess:G})]})})},ce=()=>{const{document:t,email:p}=e.useOpenEmail(),c=(0,l.useMemo)(()=>({document:t,block:p}),[t,p]);return(0,o.jsx)(ie,{session:c})};te.default=ce});