← All changes
|
assets/js/packages/editor-documents/editor-documents.min.js
+1
-1
4.2.1
→
4.3.2
View file →
| @@ -1 +1 @@ | ||
| 1 | -!function(){"use strict";var t={5527:function(t){t.exports=window.elementorV2.editorV1Adapters},22444:function(t){t.exports=window.elementorV2.utils},22504:function(t){t.exports=window.elementorV2.editor},23887:function(t,e,n){var i,o=Object.defineProperty,a=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,r={};((t,e)=>{for(var n in e)o(t,n,{get:e[n],enumerable:!0})})(r,{COMPONENT_DOCUMENT_TYPE:()=>b,__useActiveDocument:()=>useActiveDocument,__useActiveDocumentActions:()=>useActiveDocumentActions,__useHostDocument:()=>useHostDocument,__useNavigateToDocument:()=>useNavigateToDocument,__useOpenDocumentInNewTab:()=>useOpenDocumentInNewTab,getCurrentDocument:()=>getCurrentDocument,getV1CurrentDocument:()=>getV1CurrentDocument,getV1DocumentsManager:()=>getV1DocumentsManager,init:()=>init,invalidateDocumentData:()=>invalidateDocumentData,isDocumentDirty:()=>isDocumentDirty,reloadCurrentDocument:()=>reloadCurrentDocument,setDocumentModifiedStatus:()=>setDocumentModifiedStatus,slice:()=>f,switchToDocument:()=>switchToDocument}),t.exports=(i=r,((t,e,n,i)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let r of s(e))c.call(t,r)||r===n||o(t,r,{get:()=>e[r],enumerable:!(i=a(e,r))||i.enumerable});return t})(o({},"__esModule",{value:!0}),i));var u=n(22504),d=n(56384),m=n(97557),l=n(27723),v=n(56384),g=n(56384),selectEntities=t=>t.documents.entities,_=(0,g.__createSelector)(selectEntities,t=>t.documents.activeId,(t,e)=>e&&t[e]?t[e]:null),p=(0,g.__createSelector)(selectEntities,t=>t.documents.hostId,(t,e)=>e&&t[e]?t[e]:null);function useActiveDocument(){return(0,v.__useSelector)(_)}var D=n(56384);function useHostDocument(){return(0,D.__useSelector)(p)}function LogicHooks(){return function useSyncDocumentTitle(){const t=useActiveDocument(),e=useHostDocument(),n=t&&"kit"!==t.type.value?t:e;(0,m.useEffect)(()=>{if(void 0===n?.title)return;const t=(0,l.__)('Edit "%s" with Elementor',"elementor").replace("%s",n.title);window.document.title=t},[n?.title])}(),null}function hasActiveEntity(t){return!(!t.activeId||!t.entities[t.activeId])}var f=(0,n(56384).__createSlice)({name:"documents",initialState:{entities:{},activeId:null,hostId:null},reducers:{init(t,{payload:e}){t.entities=e.entities,t.hostId=e.hostId,t.activeId=e.activeId},activateDocument(t,e){t.entities[e.payload.id]=e.payload,t.activeId=e.payload.id},setAsHost(t,e){t.hostId=e.payload},updateActiveDocument(t,e){hasActiveEntity(t)&&(t.entities[t.activeId]={...t.entities[t.activeId],...e.payload})},startSaving(t){hasActiveEntity(t)&&(t.entities[t.activeId].isSaving=!0)},endSaving(t,e){hasActiveEntity(t)&&(t.entities[t.activeId]={...e.payload,isSaving:!1})},startSavingDraft:t=>{hasActiveEntity(t)&&(t.entities[t.activeId].isSavingDraft=!0)},endSavingDraft(t,e){hasActiveEntity(t)&&(t.entities[t.activeId]={...e.payload,isSavingDraft:!1})},markAsDirty(t){hasActiveEntity(t)&&(t.entities[t.activeId].isDirty=!0)},markAsPristine(t){hasActiveEntity(t)&&(t.entities[t.activeId].isDirty=!1)}}}),w=n(5527),h=n(56384),y=n(22444),S=n(5527),C=n(56384);function getCurrentDocument(){return _((0,C.__getState)())}function getV1DocumentsManager(){const t=window.elementor?.documents;if(!t)throw new Error("Elementor Editor V1 documents manager not found");return t}function getV1DocumentsExitTo(t){switch(window.elementor?.getPreferences?.("exit_to")||"this_post"){case"dashboard":return t.config.urls.main_dashboard;case"all_posts":return t.config.urls.all_post_type;default:return t.config.urls.exit_to_dashboard}}function getV1DocumentShowCopyAndShare(t){return t?.config?.panel?.show_copy_and_share??!1}function getV1DocumentPermalink(t){return t.config.urls.permalink??""}function getV1DocumentWpPreview(t){return t.config.urls.wp_preview??""}function normalizeV1Document(t){const e=t.config.revisions.current_id!==t.id,n=getV1DocumentsExitTo(t);return{id:t.id,title:t.container.settings.get("post_title"),type:{value:t.config.type,label:t.config.panel.title},status:{value:t.config.status.value,label:t.config.status.label},links:{permalink:getV1DocumentPermalink(t),wpPreview:getV1DocumentWpPreview(t),platformEdit:n},isDirty:t.editor.isChanged||e,isSaving:t.editor.isSaving,isSavingDraft:!1,permissions:{allowAddingWidgets:t.config.panel?.allow_adding_widgets??!0,showCopyAndShare:getV1DocumentShowCopyAndShare(t)},userCan:{publish:t.config.user.can_publish}}}function setDocumentModifiedStatus(t){(0,S.__privateRunCommandSync)("document/save/set-is-modified",{status:t},{internal:!0})}function getV1CurrentDocument(){return window.elementor?.documents?.getCurrent()}function isDocumentDirty(t){const e="draft"===t.status.value,n=t.revisions?.current_id!==t.id;return e||n}function invalidateDocumentData(t){getV1DocumentsManager().invalidateCache(t)}function reloadCurrentDocument(){const t=getCurrentDocument();return t?.id?(getV1DocumentsManager().invalidateCache(),(0,S.__privateRunCommand)("editor/documents/switch",{id:t.id,shouldScroll:!1,shouldNavigateToDefaultRoute:!1})):Promise.resolve()}function switchToDocument(t,e){return(0,S.__privateRunCommand)("editor/documents/switch",{id:t,...e})}function syncStore(){!function syncInitialization(){const{init:t}=f.actions;(0,w.__privateListenTo)((0,w.v1ReadyEvent)(),()=>{const e=getV1DocumentsManager(),n=Object.entries(e.documents).reduce((t,[e,n])=>(t[e]=normalizeV1Document(n),t),{});(0,h.__dispatch)(t({entities:n,hostId:e.getInitialId(),activeId:e.getCurrentId()}))})}(),function syncActiveDocument(){const{activateDocument:t,setAsHost:e}=f.actions;(0,w.__privateListenTo)((0,w.commandEndEvent)("editor/documents/open"),()=>{const n=getV1DocumentsManager(),i=normalizeV1Document(n.getCurrent());(0,h.__dispatch)(t(i)),n.getInitialId()===i.id&&(0,h.__dispatch)(e(i.id))})}(),function syncOnDocumentSave(){const{startSaving:t,endSaving:e,startSavingDraft:n,endSavingDraft:i}=f.actions,isDraft=t=>{const e=t;return"autosave"===e.args?.status};(0,w.__privateListenTo)((0,w.commandStartEvent)("document/save/save"),e=>{isDraft(e)?(0,h.__dispatch)(n()):(0,h.__dispatch)(t())}),(0,w.__privateListenTo)((0,w.commandEndEvent)("document/save/save"),t=>{const n=normalizeV1Document(getV1DocumentsManager().getCurrent());isDraft(t)?(0,h.__dispatch)(i(n)):(0,h.__dispatch)(e(n))})}(),function syncOnTitleChange(){const{updateActiveDocument:t}=f.actions,e=(0,y.debounce)(e=>{const n=e;if(!("post_title"in n.args?.settings))return;const i=getV1DocumentsManager().getCurrent().container.settings.get("post_title");(0,h.__dispatch)(t({title:i}))},400);(0,w.__privateListenTo)((0,w.commandEndEvent)("document/elements/settings"),e)}(),function syncOnDocumentChange(){const{markAsDirty:t,markAsPristine:e}=f.actions;(0,w.__privateListenTo)((0,w.commandEndEvent)("document/save/set-is-modified"),()=>{const n=_((0,h.__getState)())?.isSaving;if(n)return;getV1DocumentsManager().getCurrent().editor.isChanged?(0,h.__dispatch)(t()):(0,h.__dispatch)(e())})}(),function syncOnExitToChange(){const{updateActiveDocument:t}=f.actions,e=(0,y.debounce)(e=>{const n=e;if(!("exit_to"in n.args?.settings))return;const i=getV1DocumentsManager().getCurrent(),o=getV1DocumentsExitTo(i),a=getV1DocumentPermalink(i),s=getV1DocumentWpPreview(i);(0,h.__dispatch)(t({links:{platformEdit:o,permalink:a,wpPreview:s}}))},400);(0,w.__privateListenTo)((0,w.commandEndEvent)("document/elements/settings"),e)}()}function init(){!function initStore(){(0,d.__registerSlice)(f),syncStore()}(),(0,u.injectIntoLogic)({id:"documents-hooks",component:LogicHooks})}var V=n(97557),A=n(5527);function useActiveDocumentActions(){const t=useActiveDocument(),e=t?.links?.permalink??"";return{save:(0,V.useCallback)(()=>(0,A.__privateRunCommand)("document/save/default"),[]),saveDraft:(0,V.useCallback)(()=>(0,A.__privateRunCommand)("document/save/draft"),[]),saveTemplate:(0,V.useCallback)(()=>(0,A.__privateOpenRoute)("library/save-template"),[]),copyAndShare:(0,V.useCallback)(()=>{navigator.clipboard.writeText(e)},[e])}}var E=n(97557),getUpdateUrl=t=>{const e=new URL(window.location.href);return e.searchParams.set("post",t.toString()),e.searchParams.delete("active-document"),e};function useNavigateToDocument(){return(0,E.useCallback)(async t=>{const e=getUpdateUrl(t);await switchToDocument(t,{setAsInitial:!0}),history.replaceState({},"",e)},[])}var I=n(97557);function useOpenDocumentInNewTab(){return(0,I.useCallback)(t=>{const e=getUpdateUrl(t);window.open(e.href)},[])}var b="elementor_component"},27723:function(t){t.exports=window.wp.i18n},56384:function(t){t.exports=window.elementorV2.store},97557:function(t){t.exports=window.React}},e={};var n=function __webpack_require__(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n](o,o.exports,__webpack_require__),o.exports}(23887);(window.elementorV2=window.elementorV2||{}).editorDocuments=n}(),window.elementorV2.editorDocuments?.init?.(); | |
| 1 | +(function(){var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,__commonJSMin=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),__copyProps=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},__toESM=(n,r,a)=>(a=n==null?{}:e(i(n)),__copyProps(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),o=__toESM(__commonJSMin(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},__copyProps=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},__toCommonJS=e=>__copyProps(n({},`__esModule`,{value:!0}),e),o={};__export(o,{COMPONENT_DOCUMENT_TYPE:()=>O,__useActiveDocument:()=>useActiveDocument,__useActiveDocumentActions:()=>useActiveDocumentActions,__useHostDocument:()=>useHostDocument,__useNavigateToDocument:()=>useNavigateToDocument,__useOpenDocumentInNewTab:()=>useOpenDocumentInNewTab,getCurrentDocument:()=>getCurrentDocument,getV1CurrentDocument:()=>getV1CurrentDocument,getV1DocumentsManager:()=>getV1DocumentsManager,init:()=>init,invalidateDocumentData:()=>invalidateDocumentData,isDocumentDirty:()=>isDocumentDirty,reloadCurrentDocument:()=>reloadCurrentDocument,setDocumentModifiedStatus:()=>setDocumentModifiedStatus,slice:()=>v,switchToDocument:()=>switchToDocument}),t.exports=__toCommonJS(o);var s=globalThis.elementorV2.editor,c=globalThis.elementorV2.store,l=globalThis.React,u=globalThis.wp.i18n,d=globalThis.elementorV2.store,f=globalThis.elementorV2.store,selectEntities=e=>e.documents.entities,selectActiveId=e=>e.documents.activeId,selectHostId=e=>e.documents.hostId,p=(0,f.__createSelector)(selectEntities,selectActiveId,(e,t)=>t&&e[t]?e[t]:null),m=(0,f.__createSelector)(selectEntities,selectHostId,(e,t)=>t&&e[t]?e[t]:null);function useActiveDocument(){return(0,d.__useSelector)(p)}var h=globalThis.elementorV2.store;function useHostDocument(){return(0,h.__useSelector)(m)}function useSyncDocumentTitle(){let e=useActiveDocument(),t=useHostDocument(),n=e&&e.type.value!==`kit`?e:t;(0,l.useEffect)(()=>{if(n?.title===void 0)return;let e=(0,u.__)(`Edit "%s" with Elementor`,`elementor`).replace(`%s`,n.title);window.document.title=e},[n?.title])}function LogicHooks(){return useSyncDocumentTitle(),null}var g=globalThis.elementorV2.store,_={entities:{},activeId:null,hostId:null};function hasActiveEntity(e){return!!(e.activeId&&e.entities[e.activeId])}var v=(0,g.__createSlice)({name:`documents`,initialState:_,reducers:{init(e,{payload:t}){e.entities=t.entities,e.hostId=t.hostId,e.activeId=t.activeId},activateDocument(e,t){e.entities[t.payload.id]=t.payload,e.activeId=t.payload.id},setAsHost(e,t){e.hostId=t.payload},updateActiveDocument(e,t){hasActiveEntity(e)&&(e.entities[e.activeId]={...e.entities[e.activeId],...t.payload})},startSaving(e){hasActiveEntity(e)&&(e.entities[e.activeId].isSaving=!0)},endSaving(e,t){hasActiveEntity(e)&&(e.entities[e.activeId]={...t.payload,isSaving:!1})},startSavingDraft:e=>{hasActiveEntity(e)&&(e.entities[e.activeId].isSavingDraft=!0)},endSavingDraft(e,t){hasActiveEntity(e)&&(e.entities[e.activeId]={...t.payload,isSavingDraft:!1})},markAsDirty(e){hasActiveEntity(e)&&(e.entities[e.activeId].isDirty=!0)},markAsPristine(e){hasActiveEntity(e)&&(e.entities[e.activeId].isDirty=!1)}}}),y=globalThis.elementorV2.editorV1Adapters,b=globalThis.elementorV2.store,x=globalThis.elementorV2.utils,S=globalThis.elementorV2.editorV1Adapters,C=globalThis.elementorV2.store;function getCurrentDocument(){return p((0,C.__getState)())}function getV1DocumentsManager(){let e=window.elementor?.documents;if(!e)throw Error(`Elementor Editor V1 documents manager not found`);return e}function getV1DocumentsExitTo(e){switch(window.elementor?.getPreferences?.(`exit_to`)||`this_post`){case`dashboard`:return e.config.urls.main_dashboard;case`all_posts`:return e.config.urls.all_post_type;default:return e.config.urls.exit_to_dashboard}}function getV1DocumentShowCopyAndShare(e){return e?.config?.panel?.show_copy_and_share??!1}function getV1DocumentPermalink(e){return e.config.urls.permalink??``}function getV1DocumentWpPreview(e){return e.config.urls.wp_preview??``}function normalizeV1Document(e){let t=e.config.revisions.current_id!==e.id,n=getV1DocumentsExitTo(e);return{id:e.id,title:e.container.settings.get(`post_title`),type:{value:e.config.type,label:e.config.panel.title},status:{value:e.config.status.value,label:e.config.status.label},links:{permalink:getV1DocumentPermalink(e),wpPreview:getV1DocumentWpPreview(e),platformEdit:n},isDirty:e.editor.isChanged||t,isSaving:e.editor.isSaving,isSavingDraft:!1,permissions:{allowAddingWidgets:e.config.panel?.allow_adding_widgets??!0,showCopyAndShare:getV1DocumentShowCopyAndShare(e)},userCan:{publish:e.config.user.can_publish}}}function setDocumentModifiedStatus(e){(0,S.__privateRunCommandSync)(`document/save/set-is-modified`,{status:e},{internal:!0})}function getV1CurrentDocument(){return window.elementor?.documents?.getCurrent()}function isDocumentDirty(e){let t=e.status.value===`draft`,n=e.revisions?.current_id!==e.id;return t||n}function invalidateDocumentData(e){getV1DocumentsManager().invalidateCache(e)}function reloadCurrentDocument(){let e=getCurrentDocument();return e?.id?(getV1DocumentsManager().invalidateCache(),(0,S.__privateRunCommand)(`editor/documents/switch`,{id:e.id,shouldScroll:!1,shouldNavigateToDefaultRoute:!1})):Promise.resolve()}function switchToDocument(e,t){return(0,S.__privateRunCommand)(`editor/documents/switch`,{id:e,...t})}function syncStore(){syncInitialization(),syncActiveDocument(),syncOnDocumentSave(),syncOnTitleChange(),syncOnDocumentChange(),syncOnExitToChange()}function syncInitialization(){let{init:e}=v.actions;(0,y.__privateListenTo)((0,y.v1ReadyEvent)(),()=>{let t=getV1DocumentsManager(),n=Object.entries(t.documents).reduce((e,[t,n])=>(e[t]=normalizeV1Document(n),e),{});(0,b.__dispatch)(e({entities:n,hostId:t.getInitialId(),activeId:t.getCurrentId()}))})}function syncActiveDocument(){let{activateDocument:e,setAsHost:t}=v.actions;(0,y.__privateListenTo)((0,y.commandEndEvent)(`editor/documents/open`),()=>{let n=getV1DocumentsManager(),r=normalizeV1Document(n.getCurrent());(0,b.__dispatch)(e(r)),n.getInitialId()===r.id&&(0,b.__dispatch)(t(r.id))})}function syncOnDocumentSave(){let{startSaving:e,endSaving:t,startSavingDraft:n,endSavingDraft:r}=v.actions,isDraft=e=>e.args?.status===`autosave`;(0,y.__privateListenTo)((0,y.commandStartEvent)(`document/save/save`),t=>{if(isDraft(t)){(0,b.__dispatch)(n());return}(0,b.__dispatch)(e())}),(0,y.__privateListenTo)((0,y.commandEndEvent)(`document/save/save`),e=>{let n=normalizeV1Document(getV1DocumentsManager().getCurrent());isDraft(e)?(0,b.__dispatch)(r(n)):(0,b.__dispatch)(t(n))})}function syncOnTitleChange(){let{updateActiveDocument:e}=v.actions,t=(0,x.debounce)(t=>{if(!(`post_title`in t.args?.settings))return;let n=getV1DocumentsManager().getCurrent().container.settings.get(`post_title`);(0,b.__dispatch)(e({title:n}))},400);(0,y.__privateListenTo)((0,y.commandEndEvent)(`document/elements/settings`),t)}function syncOnExitToChange(){let{updateActiveDocument:e}=v.actions,t=(0,x.debounce)(t=>{if(!(`exit_to`in t.args?.settings))return;let n=getV1DocumentsManager().getCurrent(),r=getV1DocumentsExitTo(n),i=getV1DocumentPermalink(n),a=getV1DocumentWpPreview(n);(0,b.__dispatch)(e({links:{platformEdit:r,permalink:i,wpPreview:a}}))},400);(0,y.__privateListenTo)((0,y.commandEndEvent)(`document/elements/settings`),t)}function syncOnDocumentChange(){let{markAsDirty:e,markAsPristine:t}=v.actions;(0,y.__privateListenTo)((0,y.commandEndEvent)(`document/save/set-is-modified`),()=>{if(!p((0,b.__getState)())?.isSaving){if(getV1DocumentsManager().getCurrent().editor.isChanged){(0,b.__dispatch)(e());return}(0,b.__dispatch)(t())}})}function init(){initStore(),(0,s.injectIntoLogic)({id:`documents-hooks`,component:LogicHooks})}function initStore(){(0,c.__registerSlice)(v),syncStore()}var w=globalThis.React,T=globalThis.elementorV2.editorV1Adapters;function useActiveDocumentActions(){let e=useActiveDocument()?.links?.permalink??``;return{save:(0,w.useCallback)(()=>(0,T.__privateRunCommand)(`document/save/default`),[]),saveDraft:(0,w.useCallback)(()=>(0,T.__privateRunCommand)(`document/save/draft`),[]),saveTemplate:(0,w.useCallback)(()=>(0,T.__privateOpenRoute)(`library/save-template`),[]),copyAndShare:(0,w.useCallback)(()=>{navigator.clipboard.writeText(e)},[e])}}var E=globalThis.React,getUpdateUrl=e=>{let t=new URL(window.location.href);return t.searchParams.set(`post`,e.toString()),t.searchParams.delete(`active-document`),t};function useNavigateToDocument(){return(0,E.useCallback)(async e=>{let t=getUpdateUrl(e);await switchToDocument(e,{setAsInitial:!0}),history.replaceState({},``,t)},[])}var D=globalThis.React;function useOpenDocumentInNewTab(){return(0,D.useCallback)(e=>{let t=getUpdateUrl(e);window.open(t.href)},[])}var O=`elementor_component`;0&&(t.exports={COMPONENT_DOCUMENT_TYPE:O,__useActiveDocument,__useActiveDocumentActions,__useHostDocument,__useNavigateToDocument,__useOpenDocumentInNewTab,getCurrentDocument,getV1CurrentDocument,getV1DocumentsManager,init,invalidateDocumentData,isDocumentDirty,reloadCurrentDocument,setDocumentModifiedStatus,slice:v,switchToDocument})}))());(window.elementorV2=window.elementorV2||{}).editorDocuments=o})(),window.elementorV2.editorDocuments?.init?.(); | |