PluginProbe
Elementor Website Builder – more than just a page builder / 3.17.2
Elementor Website Builder – more than just a page builder v3.17.2
4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 All 455 releases
← All changes | assets/js/packages/editor-documents/editor-documents.js +262 -764 4.2.0-beta2 → 3.17.2 View file →
@@ -1,328 +1,113 @@
1 1 /******/ (function() { // webpackBootstrap
2 2 /******/ "use strict";
3 3 /******/ var __webpack_modules__ = ({
4 4
5 -/***/ "./packages/packages/core/editor-documents/src/components/logic-hooks.tsx":
6 -/*!********************************************************************************!*\
7 - !*** ./packages/packages/core/editor-documents/src/components/logic-hooks.tsx ***!
8 - \********************************************************************************/
9 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
5 +/***/ "react":
6 +/*!**************************!*\
7 + !*** external ["React"] ***!
8 + \**************************/
9 +/***/ (function(module) {
10 10
11 -__webpack_require__.r(__webpack_exports__);
12 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
13 -/* harmony export */ LogicHooks: function() { return /* binding */ LogicHooks; }
14 -/* harmony export */ });
15 -/* harmony import */ var _hooks_use_sync_document_title__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../hooks/use-sync-document-title */ "./packages/packages/core/editor-documents/src/hooks/use-sync-document-title.ts");
11 +module.exports = window["React"];
16 12
17 -function LogicHooks() {
18 - (0,_hooks_use_sync_document_title__WEBPACK_IMPORTED_MODULE_0__["default"])();
19 - return null;
20 -}
21 -
22 13 /***/ }),
23 14
24 -/***/ "./packages/packages/core/editor-documents/src/consts.ts":
25 -/*!***************************************************************!*\
26 - !*** ./packages/packages/core/editor-documents/src/consts.ts ***!
27 - \***************************************************************/
28 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
15 +/***/ "@elementor/editor-v1-adapters":
16 +/*!***************************************************!*\
17 + !*** external ["elementorV2","editorV1Adapters"] ***!
18 + \***************************************************/
19 +/***/ (function(module) {
29 20
30 -__webpack_require__.r(__webpack_exports__);
31 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
32 -/* harmony export */ COMPONENT_DOCUMENT_TYPE: function() { return /* binding */ COMPONENT_DOCUMENT_TYPE; }
33 -/* harmony export */ });
34 -const COMPONENT_DOCUMENT_TYPE = 'elementor_component';
21 +module.exports = window["elementorV2"]["editorV1Adapters"];
35 22
36 23 /***/ }),
37 24
38 -/***/ "./packages/packages/core/editor-documents/src/hooks/index.ts":
39 -/*!********************************************************************!*\
40 - !*** ./packages/packages/core/editor-documents/src/hooks/index.ts ***!
41 - \********************************************************************/
42 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
25 +/***/ "@elementor/store":
26 +/*!****************************************!*\
27 + !*** external ["elementorV2","store"] ***!
28 + \****************************************/
29 +/***/ (function(module) {
43 30
44 -__webpack_require__.r(__webpack_exports__);
45 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
46 -/* harmony export */ useActiveDocument: function() { return /* reexport safe */ _use_active_document__WEBPACK_IMPORTED_MODULE_0__["default"]; },
47 -/* harmony export */ useActiveDocumentActions: function() { return /* reexport safe */ _use_active_document_actions__WEBPACK_IMPORTED_MODULE_1__["default"]; },
48 -/* harmony export */ useHostDocument: function() { return /* reexport safe */ _use_host_document__WEBPACK_IMPORTED_MODULE_2__["default"]; },
49 -/* harmony export */ useNavigateToDocument: function() { return /* reexport safe */ _use_navigate_to_document__WEBPACK_IMPORTED_MODULE_3__["default"]; },
50 -/* harmony export */ useOpenDocumentInNewTab: function() { return /* reexport safe */ _use_open_document_in_new_tab__WEBPACK_IMPORTED_MODULE_4__["default"]; }
51 -/* harmony export */ });
52 -/* harmony import */ var _use_active_document__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./use-active-document */ "./packages/packages/core/editor-documents/src/hooks/use-active-document.ts");
53 -/* harmony import */ var _use_active_document_actions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./use-active-document-actions */ "./packages/packages/core/editor-documents/src/hooks/use-active-document-actions.ts");
54 -/* harmony import */ var _use_host_document__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./use-host-document */ "./packages/packages/core/editor-documents/src/hooks/use-host-document.ts");
55 -/* harmony import */ var _use_navigate_to_document__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./use-navigate-to-document */ "./packages/packages/core/editor-documents/src/hooks/use-navigate-to-document.ts");
56 -/* harmony import */ var _use_open_document_in_new_tab__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./use-open-document-in-new-tab */ "./packages/packages/core/editor-documents/src/hooks/use-open-document-in-new-tab.ts");
31 +module.exports = window["elementorV2"]["store"];
57 32
33 +/***/ })
58 34
59 -
60 -
61 -
62 -
63 -/***/ }),
64 -
65 -/***/ "./packages/packages/core/editor-documents/src/hooks/use-active-document-actions.ts":
66 -/*!******************************************************************************************!*\
67 - !*** ./packages/packages/core/editor-documents/src/hooks/use-active-document-actions.ts ***!
68 - \******************************************************************************************/
69 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
70 -
35 +/******/ });
36 +/************************************************************************/
37 +/******/ // The module cache
38 +/******/ var __webpack_module_cache__ = {};
39 +/******/
40 +/******/ // The require function
41 +/******/ function __webpack_require__(moduleId) {
42 +/******/ // Check if module is in cache
43 +/******/ var cachedModule = __webpack_module_cache__[moduleId];
44 +/******/ if (cachedModule !== undefined) {
45 +/******/ return cachedModule.exports;
46 +/******/ }
47 +/******/ // Create a new module (and put it into the cache)
48 +/******/ var module = __webpack_module_cache__[moduleId] = {
49 +/******/ // no module.id needed
50 +/******/ // no module.loaded needed
51 +/******/ exports: {}
52 +/******/ };
53 +/******/
54 +/******/ // Execute the module function
55 +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
56 +/******/
57 +/******/ // Return the exports of the module
58 +/******/ return module.exports;
59 +/******/ }
60 +/******/
61 +/************************************************************************/
62 +/******/ /* webpack/runtime/define property getters */
63 +/******/ !function() {
64 +/******/ // define getter functions for harmony exports
65 +/******/ __webpack_require__.d = function(exports, definition) {
66 +/******/ for(var key in definition) {
67 +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
68 +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
69 +/******/ }
70 +/******/ }
71 +/******/ };
72 +/******/ }();
73 +/******/
74 +/******/ /* webpack/runtime/hasOwnProperty shorthand */
75 +/******/ !function() {
76 +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
77 +/******/ }();
78 +/******/
79 +/******/ /* webpack/runtime/make namespace object */
80 +/******/ !function() {
81 +/******/ // define __esModule on exports
82 +/******/ __webpack_require__.r = function(exports) {
83 +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
84 +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
85 +/******/ }
86 +/******/ Object.defineProperty(exports, '__esModule', { value: true });
87 +/******/ };
88 +/******/ }();
89 +/******/
90 +/************************************************************************/
91 +var __webpack_exports__ = {};
92 +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
93 +!function() {
94 +/*!*****************************************************************!*\
95 + !*** ./node_modules/@elementor/editor-documents/dist/index.mjs ***!
96 + \*****************************************************************/
71 97 __webpack_require__.r(__webpack_exports__);
72 98 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
73 -/* harmony export */ "default": function() { return /* binding */ useActiveDocumentActions; }
99 +/* harmony export */ __useActiveDocument: function() { return /* binding */ useActiveDocument; },
100 +/* harmony export */ __useActiveDocumentActions: function() { return /* binding */ useActiveDocumentActions; },
101 +/* harmony export */ __useHostDocument: function() { return /* binding */ useHostDocument; },
102 +/* harmony export */ __useNavigateToDocument: function() { return /* binding */ useNavigateToDocument; }
74 103 /* harmony export */ });
75 -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
76 -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
104 +/* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @elementor/store */ "@elementor/store");
77 105 /* harmony import */ var _elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @elementor/editor-v1-adapters */ "@elementor/editor-v1-adapters");
78 -/* harmony import */ var _elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__);
79 -/* harmony import */ var _use_active_document__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./use-active-document */ "./packages/packages/core/editor-documents/src/hooks/use-active-document.ts");
106 +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ "react");
107 +// src/store/index.ts
80 108
81 -
82 -
83 -function useActiveDocumentActions() {
84 - const document = (0,_use_active_document__WEBPACK_IMPORTED_MODULE_2__["default"])();
85 - const permalink = document?.links?.permalink ?? '';
86 - const save = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.__privateRunCommand)('document/save/default'), []);
87 - const saveDraft = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.__privateRunCommand)('document/save/draft'), []);
88 - const saveTemplate = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.__privateOpenRoute)('library/save-template'), []);
89 - const copyAndShare = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => {
90 - navigator.clipboard.writeText(permalink);
91 - }, [permalink]);
92 - return {
93 - save,
94 - saveDraft,
95 - saveTemplate,
96 - copyAndShare
97 - };
98 -}
99 -
100 -/***/ }),
101 -
102 -/***/ "./packages/packages/core/editor-documents/src/hooks/use-active-document.ts":
103 -/*!**********************************************************************************!*\
104 - !*** ./packages/packages/core/editor-documents/src/hooks/use-active-document.ts ***!
105 - \**********************************************************************************/
106 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
107 -
108 -__webpack_require__.r(__webpack_exports__);
109 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
110 -/* harmony export */ "default": function() { return /* binding */ useActiveDocument; }
111 -/* harmony export */ });
112 -/* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @elementor/store */ "@elementor/store");
113 -/* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_elementor_store__WEBPACK_IMPORTED_MODULE_0__);
114 -/* harmony import */ var _store_selectors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../store/selectors */ "./packages/packages/core/editor-documents/src/store/selectors.ts");
115 -
116 -
117 -function useActiveDocument() {
118 - return (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__useSelector)(_store_selectors__WEBPACK_IMPORTED_MODULE_1__.selectActiveDocument);
119 -}
120 -
121 -/***/ }),
122 -
123 -/***/ "./packages/packages/core/editor-documents/src/hooks/use-host-document.ts":
124 -/*!********************************************************************************!*\
125 - !*** ./packages/packages/core/editor-documents/src/hooks/use-host-document.ts ***!
126 - \********************************************************************************/
127 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
128 -
129 -__webpack_require__.r(__webpack_exports__);
130 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
131 -/* harmony export */ "default": function() { return /* binding */ useHostDocument; }
132 -/* harmony export */ });
133 -/* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @elementor/store */ "@elementor/store");
134 -/* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_elementor_store__WEBPACK_IMPORTED_MODULE_0__);
135 -/* harmony import */ var _store_selectors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../store/selectors */ "./packages/packages/core/editor-documents/src/store/selectors.ts");
136 -
137 -
138 -function useHostDocument() {
139 - return (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__useSelector)(_store_selectors__WEBPACK_IMPORTED_MODULE_1__.selectHostDocument);
140 -}
141 -
142 -/***/ }),
143 -
144 -/***/ "./packages/packages/core/editor-documents/src/hooks/use-navigate-to-document.ts":
145 -/*!***************************************************************************************!*\
146 - !*** ./packages/packages/core/editor-documents/src/hooks/use-navigate-to-document.ts ***!
147 - \***************************************************************************************/
148 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
149 -
150 -__webpack_require__.r(__webpack_exports__);
151 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
152 -/* harmony export */ "default": function() { return /* binding */ useNavigateToDocument; }
153 -/* harmony export */ });
154 -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
155 -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
156 -/* harmony import */ var _sync_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sync/utils */ "./packages/packages/core/editor-documents/src/sync/utils.ts");
157 -/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ "./packages/packages/core/editor-documents/src/hooks/utils.ts");
158 -
159 -
160 -
161 -function useNavigateToDocument() {
162 - return (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async id => {
163 - const url = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getUpdateUrl)(id);
164 - await (0,_sync_utils__WEBPACK_IMPORTED_MODULE_1__.switchToDocument)(id, {
165 - setAsInitial: true
166 - });
167 - history.replaceState({}, '', url);
168 - }, []);
169 -}
170 -
171 -/***/ }),
172 -
173 -/***/ "./packages/packages/core/editor-documents/src/hooks/use-open-document-in-new-tab.ts":
174 -/*!*******************************************************************************************!*\
175 - !*** ./packages/packages/core/editor-documents/src/hooks/use-open-document-in-new-tab.ts ***!
176 - \*******************************************************************************************/
177 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
178 -
179 -__webpack_require__.r(__webpack_exports__);
180 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
181 -/* harmony export */ "default": function() { return /* binding */ useOpenDocumentInNewTab; }
182 -/* harmony export */ });
183 -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
184 -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
185 -/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./packages/packages/core/editor-documents/src/hooks/utils.ts");
186 -
187 -
188 -function useOpenDocumentInNewTab() {
189 - return (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(id => {
190 - const url = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.getUpdateUrl)(id);
191 - window.open(url.href);
192 - }, []);
193 -}
194 -
195 -/***/ }),
196 -
197 -/***/ "./packages/packages/core/editor-documents/src/hooks/use-sync-document-title.ts":
198 -/*!**************************************************************************************!*\
199 - !*** ./packages/packages/core/editor-documents/src/hooks/use-sync-document-title.ts ***!
200 - \**************************************************************************************/
201 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
202 -
203 -__webpack_require__.r(__webpack_exports__);
204 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
205 -/* harmony export */ "default": function() { return /* binding */ useSyncDocumentTitle; }
206 -/* harmony export */ });
207 -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
208 -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
209 -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
210 -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__);
211 -/* harmony import */ var _use_active_document__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./use-active-document */ "./packages/packages/core/editor-documents/src/hooks/use-active-document.ts");
212 -/* harmony import */ var _use_host_document__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./use-host-document */ "./packages/packages/core/editor-documents/src/hooks/use-host-document.ts");
213 -
214 -
215 -
216 -
217 -function useSyncDocumentTitle() {
218 - const activeDocument = (0,_use_active_document__WEBPACK_IMPORTED_MODULE_2__["default"])();
219 - const hostDocument = (0,_use_host_document__WEBPACK_IMPORTED_MODULE_3__["default"])();
220 - const document = activeDocument && activeDocument.type.value !== 'kit' ? activeDocument : hostDocument;
221 - (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
222 - // Allow empty string as title.
223 - if (document?.title === undefined) {
224 - return;
225 - }
226 -
227 - // translators: %s: Document title.
228 - const title = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Edit "%s" with Elementor', 'elementor').replace('%s', document.title);
229 - window.document.title = title;
230 - }, [document?.title]);
231 -}
232 -
233 -/***/ }),
234 -
235 -/***/ "./packages/packages/core/editor-documents/src/hooks/utils.ts":
236 -/*!********************************************************************!*\
237 - !*** ./packages/packages/core/editor-documents/src/hooks/utils.ts ***!
238 - \********************************************************************/
239 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
240 -
241 -__webpack_require__.r(__webpack_exports__);
242 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
243 -/* harmony export */ getUpdateUrl: function() { return /* binding */ getUpdateUrl; }
244 -/* harmony export */ });
245 -const getUpdateUrl = id => {
246 - const url = new URL(window.location.href);
247 - url.searchParams.set('post', id.toString());
248 - url.searchParams.delete('active-document');
249 - return url;
250 -};
251 -
252 -/***/ }),
253 -
254 -/***/ "./packages/packages/core/editor-documents/src/init.ts":
255 -/*!*************************************************************!*\
256 - !*** ./packages/packages/core/editor-documents/src/init.ts ***!
257 - \*************************************************************/
258 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
259 -
260 -__webpack_require__.r(__webpack_exports__);
261 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
262 -/* harmony export */ init: function() { return /* binding */ init; }
263 -/* harmony export */ });
264 -/* harmony import */ var _elementor_editor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @elementor/editor */ "@elementor/editor");
265 -/* harmony import */ var _elementor_editor__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_elementor_editor__WEBPACK_IMPORTED_MODULE_0__);
266 -/* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @elementor/store */ "@elementor/store");
267 -/* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_elementor_store__WEBPACK_IMPORTED_MODULE_1__);
268 -/* harmony import */ var _components_logic_hooks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/logic-hooks */ "./packages/packages/core/editor-documents/src/components/logic-hooks.tsx");
269 -/* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./store */ "./packages/packages/core/editor-documents/src/store/index.ts");
270 -/* harmony import */ var _sync__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sync */ "./packages/packages/core/editor-documents/src/sync/index.ts");
271 -
272 -
273 -
274 -
275 -
276 -function init() {
277 - initStore();
278 - (0,_elementor_editor__WEBPACK_IMPORTED_MODULE_0__.injectIntoLogic)({
279 - id: 'documents-hooks',
280 - component: _components_logic_hooks__WEBPACK_IMPORTED_MODULE_2__.LogicHooks
281 - });
282 -}
283 -function initStore() {
284 - (0,_elementor_store__WEBPACK_IMPORTED_MODULE_1__.__registerSlice)(_store__WEBPACK_IMPORTED_MODULE_3__.slice);
285 - (0,_sync__WEBPACK_IMPORTED_MODULE_4__.syncStore)();
286 -}
287 -
288 -/***/ }),
289 -
290 -/***/ "./packages/packages/core/editor-documents/src/store/get-current-document.ts":
291 -/*!***********************************************************************************!*\
292 - !*** ./packages/packages/core/editor-documents/src/store/get-current-document.ts ***!
293 - \***********************************************************************************/
294 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
295 -
296 -__webpack_require__.r(__webpack_exports__);
297 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
298 -/* harmony export */ getCurrentDocument: function() { return /* binding */ getCurrentDocument; }
299 -/* harmony export */ });
300 -/* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @elementor/store */ "@elementor/store");
301 -/* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_elementor_store__WEBPACK_IMPORTED_MODULE_0__);
302 -/* harmony import */ var _store_selectors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../store/selectors */ "./packages/packages/core/editor-documents/src/store/selectors.ts");
303 -
304 -
305 -function getCurrentDocument() {
306 - return (0,_store_selectors__WEBPACK_IMPORTED_MODULE_1__.selectActiveDocument)((0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__getState)());
307 -}
308 -
309 -/***/ }),
310 -
311 -/***/ "./packages/packages/core/editor-documents/src/store/index.ts":
312 -/*!********************************************************************!*\
313 - !*** ./packages/packages/core/editor-documents/src/store/index.ts ***!
314 - \********************************************************************/
315 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
316 -
317 -__webpack_require__.r(__webpack_exports__);
318 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
319 -/* harmony export */ slice: function() { return /* binding */ slice; }
320 -/* harmony export */ });
321 -/* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @elementor/store */ "@elementor/store");
322 -/* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_elementor_store__WEBPACK_IMPORTED_MODULE_0__);
323 -
324 -const initialState = {
109 +var initialState = {
325 110 entities: {},
326 111 activeId: null,
327 112 hostId: null
328 113 };
@@ -328,15 +113,13 @@
328 113 };
329 114 function hasActiveEntity(state) {
330 115 return !!(state.activeId && state.entities[state.activeId]);
331 116 }
332 -const slice = (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__createSlice)({
333 - name: 'documents',
117 +var slice = (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__createSlice)({
118 + name: "documents",
334 119 initialState,
335 120 reducers: {
336 - init(state, {
337 - payload
338 - }) {
121 + init(state, { payload }) {
339 122 state.entities = payload.entities;
340 123 state.hostId = payload.hostId;
341 124 state.activeId = payload.activeId;
342 125 },
@@ -367,9 +150,9 @@
367 150 isSaving: false
368 151 };
369 152 }
370 153 },
371 - startSavingDraft: state => {
154 + startSavingDraft: (state) => {
372 155 if (hasActiveEntity(state)) {
373 156 state.entities[state.activeId].isSavingDraft = true;
374 157 }
375 158 },
@@ -393,267 +176,24 @@
393 176 }
394 177 }
395 178 });
396 179
397 -/***/ }),
180 +// src/sync/sync-store.ts
398 181
399 -/***/ "./packages/packages/core/editor-documents/src/store/selectors.ts":
400 -/*!************************************************************************!*\
401 - !*** ./packages/packages/core/editor-documents/src/store/selectors.ts ***!
402 - \************************************************************************/
403 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
404 182
405 -__webpack_require__.r(__webpack_exports__);
406 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
407 -/* harmony export */ selectActiveDocument: function() { return /* binding */ selectActiveDocument; },
408 -/* harmony export */ selectHostDocument: function() { return /* binding */ selectHostDocument; }
409 -/* harmony export */ });
410 -/* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @elementor/store */ "@elementor/store");
411 -/* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_elementor_store__WEBPACK_IMPORTED_MODULE_0__);
412 -
413 -const selectEntities = state => state.documents.entities;
414 -const selectActiveId = state => state.documents.activeId;
415 -const selectHostId = state => state.documents.hostId;
416 -const selectActiveDocument = (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__createSelector)(selectEntities, selectActiveId, (entities, activeId) => activeId && entities[activeId] ? entities[activeId] : null);
417 -const selectHostDocument = (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__createSelector)(selectEntities, selectHostId, (entities, hostId) => hostId && entities[hostId] ? entities[hostId] : null);
418 -
419 -/***/ }),
420 -
421 -/***/ "./packages/packages/core/editor-documents/src/sync/index.ts":
422 -/*!*******************************************************************!*\
423 - !*** ./packages/packages/core/editor-documents/src/sync/index.ts ***!
424 - \*******************************************************************/
425 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
426 -
427 -__webpack_require__.r(__webpack_exports__);
428 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
429 -/* harmony export */ syncStore: function() { return /* reexport safe */ _sync_store__WEBPACK_IMPORTED_MODULE_0__.syncStore; }
430 -/* harmony export */ });
431 -/* harmony import */ var _sync_store__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sync-store */ "./packages/packages/core/editor-documents/src/sync/sync-store.ts");
432 -
433 -
434 -/***/ }),
435 -
436 -/***/ "./packages/packages/core/editor-documents/src/sync/sync-store.ts":
437 -/*!************************************************************************!*\
438 - !*** ./packages/packages/core/editor-documents/src/sync/sync-store.ts ***!
439 - \************************************************************************/
440 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
441 -
442 -__webpack_require__.r(__webpack_exports__);
443 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
444 -/* harmony export */ syncStore: function() { return /* binding */ syncStore; }
445 -/* harmony export */ });
446 -/* harmony import */ var _elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @elementor/editor-v1-adapters */ "@elementor/editor-v1-adapters");
447 -/* harmony import */ var _elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__);
448 -/* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @elementor/store */ "@elementor/store");
449 -/* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_elementor_store__WEBPACK_IMPORTED_MODULE_1__);
450 -/* harmony import */ var _elementor_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @elementor/utils */ "@elementor/utils");
451 -/* harmony import */ var _elementor_utils__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_elementor_utils__WEBPACK_IMPORTED_MODULE_2__);
452 -/* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../store */ "./packages/packages/core/editor-documents/src/store/index.ts");
453 -/* harmony import */ var _store_selectors__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../store/selectors */ "./packages/packages/core/editor-documents/src/store/selectors.ts");
454 -/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils */ "./packages/packages/core/editor-documents/src/sync/utils.ts");
455 -
456 -
457 -
458 -
459 -
460 -
461 -function syncStore() {
462 - syncInitialization();
463 - syncActiveDocument();
464 - syncOnDocumentSave();
465 - syncOnTitleChange();
466 - syncOnDocumentChange();
467 - syncOnExitToChange();
468 -}
469 -function syncInitialization() {
470 - const {
471 - init
472 - } = _store__WEBPACK_IMPORTED_MODULE_3__.slice.actions;
473 - (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.__privateListenTo)((0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.v1ReadyEvent)(), () => {
474 - const documentsManager = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.getV1DocumentsManager)();
475 - const entities = Object.entries(documentsManager.documents).reduce((acc, [id, document]) => {
476 - acc[id] = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.normalizeV1Document)(document);
477 - return acc;
478 - }, {});
479 - (0,_elementor_store__WEBPACK_IMPORTED_MODULE_1__.__dispatch)(init({
480 - entities,
481 - hostId: documentsManager.getInitialId(),
482 - activeId: documentsManager.getCurrentId()
483 - }));
484 - });
485 -}
486 -function syncActiveDocument() {
487 - const {
488 - activateDocument,
489 - setAsHost
490 - } = _store__WEBPACK_IMPORTED_MODULE_3__.slice.actions;
491 - (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.__privateListenTo)((0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.commandEndEvent)('editor/documents/open'), () => {
492 - const documentsManager = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.getV1DocumentsManager)();
493 - const currentDocument = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.normalizeV1Document)(documentsManager.getCurrent());
494 - (0,_elementor_store__WEBPACK_IMPORTED_MODULE_1__.__dispatch)(activateDocument(currentDocument));
495 - if (documentsManager.getInitialId() === currentDocument.id) {
496 - (0,_elementor_store__WEBPACK_IMPORTED_MODULE_1__.__dispatch)(setAsHost(currentDocument.id));
497 - }
498 - });
499 -}
500 -function syncOnDocumentSave() {
501 - const {
502 - startSaving,
503 - endSaving,
504 - startSavingDraft,
505 - endSavingDraft
506 - } = _store__WEBPACK_IMPORTED_MODULE_3__.slice.actions;
507 - const isDraft = e => {
508 - const event = e;
509 -
510 - /**
511 - * @see https://github.com/elementor/elementor/blob/5f815d40a/assets/dev/js/editor/document/save/hooks/ui/save/before.js#L18-L22
512 - */
513 - return event.args?.status === 'autosave';
514 - };
515 - (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.__privateListenTo)((0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.commandStartEvent)('document/save/save'), e => {
516 - if (isDraft(e)) {
517 - (0,_elementor_store__WEBPACK_IMPORTED_MODULE_1__.__dispatch)(startSavingDraft());
518 - return;
519 - }
520 - (0,_elementor_store__WEBPACK_IMPORTED_MODULE_1__.__dispatch)(startSaving());
521 - });
522 - (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.__privateListenTo)((0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.commandEndEvent)('document/save/save'), e => {
523 - const activeDocument = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.normalizeV1Document)((0,_utils__WEBPACK_IMPORTED_MODULE_5__.getV1DocumentsManager)().getCurrent());
524 - if (isDraft(e)) {
525 - (0,_elementor_store__WEBPACK_IMPORTED_MODULE_1__.__dispatch)(endSavingDraft(activeDocument));
526 - } else {
527 - (0,_elementor_store__WEBPACK_IMPORTED_MODULE_1__.__dispatch)(endSaving(activeDocument));
528 - }
529 - });
530 -}
531 -function syncOnTitleChange() {
532 - const {
533 - updateActiveDocument
534 - } = _store__WEBPACK_IMPORTED_MODULE_3__.slice.actions;
535 - const updateTitle = (0,_elementor_utils__WEBPACK_IMPORTED_MODULE_2__.debounce)(e => {
536 - const event = e;
537 - if (!('post_title' in event.args?.settings)) {
538 - return;
539 - }
540 - const currentDocument = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.getV1DocumentsManager)().getCurrent();
541 - const newTitle = currentDocument.container.settings.get('post_title');
542 - (0,_elementor_store__WEBPACK_IMPORTED_MODULE_1__.__dispatch)(updateActiveDocument({
543 - title: newTitle
544 - }));
545 - }, 400);
546 - (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.__privateListenTo)((0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.commandEndEvent)('document/elements/settings'), updateTitle);
547 -}
548 -function syncOnExitToChange() {
549 - const {
550 - updateActiveDocument
551 - } = _store__WEBPACK_IMPORTED_MODULE_3__.slice.actions;
552 - const updateExitTo = (0,_elementor_utils__WEBPACK_IMPORTED_MODULE_2__.debounce)(e => {
553 - const event = e;
554 - if (!('exit_to' in event.args?.settings)) {
555 - return;
556 - }
557 - const currentDocument = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.getV1DocumentsManager)().getCurrent();
558 - const newExitTo = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.getV1DocumentsExitTo)(currentDocument);
559 - const permalink = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.getV1DocumentPermalink)(currentDocument);
560 - const wpPreview = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.getV1DocumentWpPreview)(currentDocument);
561 - (0,_elementor_store__WEBPACK_IMPORTED_MODULE_1__.__dispatch)(updateActiveDocument({
562 - links: {
563 - platformEdit: newExitTo,
564 - permalink,
565 - wpPreview
566 - }
567 - }));
568 - }, 400);
569 - (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.__privateListenTo)((0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.commandEndEvent)('document/elements/settings'), updateExitTo);
570 -}
571 -function syncOnDocumentChange() {
572 - const {
573 - markAsDirty,
574 - markAsPristine
575 - } = _store__WEBPACK_IMPORTED_MODULE_3__.slice.actions;
576 - (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.__privateListenTo)((0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.commandEndEvent)('document/save/set-is-modified'), () => {
577 - // Skip the dirtiness check if the document is currently being saved, to prevent the UI
578 - // from showing a disabled publish button while there is a save process. The state will
579 - // be updated when the save process ends and the whole document state it normalized
580 - // (see `syncOnDocumentSave`)
581 - const isSaving = (0,_store_selectors__WEBPACK_IMPORTED_MODULE_4__.selectActiveDocument)((0,_elementor_store__WEBPACK_IMPORTED_MODULE_1__.__getState)())?.isSaving;
582 - if (isSaving) {
583 - return;
584 - }
585 - const currentDocument = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.getV1DocumentsManager)().getCurrent();
586 - if (currentDocument.editor.isChanged) {
587 - (0,_elementor_store__WEBPACK_IMPORTED_MODULE_1__.__dispatch)(markAsDirty());
588 - return;
589 - }
590 - (0,_elementor_store__WEBPACK_IMPORTED_MODULE_1__.__dispatch)(markAsPristine());
591 - });
592 -}
593 -
594 -/***/ }),
595 -
596 -/***/ "./packages/packages/core/editor-documents/src/sync/utils.ts":
597 -/*!*******************************************************************!*\
598 - !*** ./packages/packages/core/editor-documents/src/sync/utils.ts ***!
599 - \*******************************************************************/
600 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
601 -
602 -__webpack_require__.r(__webpack_exports__);
603 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
604 -/* harmony export */ getV1CurrentDocument: function() { return /* binding */ getV1CurrentDocument; },
605 -/* harmony export */ getV1DocumentPermalink: function() { return /* binding */ getV1DocumentPermalink; },
606 -/* harmony export */ getV1DocumentWpPreview: function() { return /* binding */ getV1DocumentWpPreview; },
607 -/* harmony export */ getV1DocumentsExitTo: function() { return /* binding */ getV1DocumentsExitTo; },
608 -/* harmony export */ getV1DocumentsManager: function() { return /* binding */ getV1DocumentsManager; },
609 -/* harmony export */ invalidateDocumentData: function() { return /* binding */ invalidateDocumentData; },
610 -/* harmony export */ isDocumentDirty: function() { return /* binding */ isDocumentDirty; },
611 -/* harmony export */ normalizeV1Document: function() { return /* binding */ normalizeV1Document; },
612 -/* harmony export */ reloadCurrentDocument: function() { return /* binding */ reloadCurrentDocument; },
613 -/* harmony export */ setDocumentModifiedStatus: function() { return /* binding */ setDocumentModifiedStatus; },
614 -/* harmony export */ switchToDocument: function() { return /* binding */ switchToDocument; }
615 -/* harmony export */ });
616 -/* harmony import */ var _elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @elementor/editor-v1-adapters */ "@elementor/editor-v1-adapters");
617 -/* harmony import */ var _elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__);
618 -/* harmony import */ var _store_get_current_document__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../store/get-current-document */ "./packages/packages/core/editor-documents/src/store/get-current-document.ts");
619 -
620 -
183 +// src/sync/utils.ts
621 184 function getV1DocumentsManager() {
622 185 const documentsManager = window.elementor?.documents;
623 186 if (!documentsManager) {
624 - throw new Error('Elementor Editor V1 documents manager not found');
187 + throw new Error("Elementor Editor V1 documents manager not found");
625 188 }
626 189 return documentsManager;
627 190 }
628 -function getV1DocumentsExitTo(documentData) {
629 - const exitPreference = window.elementor?.getPreferences?.('exit_to') || 'this_post';
630 - switch (exitPreference) {
631 - case 'dashboard':
632 - return documentData.config.urls.main_dashboard;
633 - case 'all_posts':
634 - return documentData.config.urls.all_post_type;
635 - case 'this_post':
636 - default:
637 - return documentData.config.urls.exit_to_dashboard;
638 - }
639 -}
640 -function getV1DocumentShowCopyAndShare(documentData) {
641 - return documentData?.config?.panel?.show_copy_and_share ?? false;
642 -}
643 -function getV1DocumentPermalink(documentData) {
644 - return documentData.config.urls.permalink ?? '';
645 -}
646 -function getV1DocumentWpPreview(documentData) {
647 - return documentData.config.urls.wp_preview ?? '';
648 -}
649 191 function normalizeV1Document(documentData) {
650 - // Draft or autosave.
651 192 const isUnpublishedRevision = documentData.config.revisions.current_id !== documentData.id;
652 - const exitToUrl = getV1DocumentsExitTo(documentData);
653 193 return {
654 194 id: documentData.id,
655 - title: documentData.container.settings.get('post_title'),
195 + title: documentData.container.settings.get("post_title"),
656 196 type: {
657 197 value: documentData.config.type,
658 198 label: documentData.config.panel.title
659 199 },
@@ -661,246 +201,204 @@
661 201 value: documentData.config.status.value,
662 202 label: documentData.config.status.label
663 203 },
664 204 links: {
665 - permalink: getV1DocumentPermalink(documentData),
666 - wpPreview: getV1DocumentWpPreview(documentData),
667 - platformEdit: exitToUrl
205 + platformEdit: documentData.config.urls.exit_to_dashboard
668 206 },
669 207 isDirty: documentData.editor.isChanged || isUnpublishedRevision,
670 208 isSaving: documentData.editor.isSaving,
671 209 isSavingDraft: false,
672 - permissions: {
673 - allowAddingWidgets: documentData.config.panel?.allow_adding_widgets ?? true,
674 - showCopyAndShare: getV1DocumentShowCopyAndShare(documentData)
675 - },
676 210 userCan: {
677 211 publish: documentData.config.user.can_publish
678 212 }
679 213 };
680 214 }
681 -function setDocumentModifiedStatus(status) {
682 - (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.__privateRunCommandSync)('document/save/set-is-modified', {
683 - status
684 - }, {
685 - internal: true
686 - });
215 +
216 +// src/sync/sync-store.ts
217 +
218 +function syncStore() {
219 + syncInitialization();
220 + syncActiveDocument();
221 + syncOnDocumentSave();
222 + syncOnTitleChange();
223 + syncOnDocumentChange();
687 224 }
688 -function getV1CurrentDocument() {
689 - return window.elementor?.documents?.getCurrent();
225 +function syncInitialization() {
226 + const { init: init2 } = slice.actions;
227 + (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.__privateListenTo)(
228 + (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.v1ReadyEvent)(),
229 + () => {
230 + const documentsManager = getV1DocumentsManager();
231 + const entities = Object.entries(documentsManager.documents).reduce((acc, [id, document]) => {
232 + acc[id] = normalizeV1Document(document);
233 + return acc;
234 + }, {});
235 + (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__dispatch)(init2({
236 + entities,
237 + hostId: documentsManager.getInitialId(),
238 + activeId: documentsManager.getCurrentId()
239 + }));
240 + }
241 + );
690 242 }
691 -function isDocumentDirty(document) {
692 - const isDraft = document.status.value === 'draft';
693 -
694 - // When the document is published, but have draft version.
695 - const hasAutosave = document.revisions?.current_id !== document.id;
696 - return isDraft || hasAutosave;
243 +function syncActiveDocument() {
244 + const { activateDocument, setAsHost } = slice.actions;
245 + (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.__privateListenTo)(
246 + (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.commandEndEvent)("editor/documents/open"),
247 + () => {
248 + const documentsManager = getV1DocumentsManager();
249 + const currentDocument = normalizeV1Document(documentsManager.getCurrent());
250 + (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__dispatch)(activateDocument(currentDocument));
251 + if (documentsManager.getInitialId() === currentDocument.id) {
252 + (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__dispatch)(setAsHost(currentDocument.id));
253 + }
254 + }
255 + );
697 256 }
698 -function invalidateDocumentData(documentId) {
699 - const documentsManager = getV1DocumentsManager();
700 - documentsManager.invalidateCache(documentId);
257 +function syncOnDocumentSave() {
258 + const { startSaving, endSaving, startSavingDraft, endSavingDraft } = slice.actions;
259 + const isDraft = (e) => {
260 + const event = e;
261 + return event.args?.status === "autosave";
262 + };
263 + (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.__privateListenTo)(
264 + (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.commandStartEvent)("document/save/save"),
265 + (e) => {
266 + if (isDraft(e)) {
267 + (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__dispatch)(startSavingDraft());
268 + return;
269 + }
270 + (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__dispatch)(startSaving());
271 + }
272 + );
273 + (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.__privateListenTo)(
274 + (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.commandEndEvent)("document/save/save"),
275 + (e) => {
276 + const activeDocument = normalizeV1Document(
277 + getV1DocumentsManager().getCurrent()
278 + );
279 + if (isDraft(e)) {
280 + (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__dispatch)(endSavingDraft(activeDocument));
281 + } else {
282 + (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__dispatch)(endSaving(activeDocument));
283 + }
284 + }
285 + );
701 286 }
702 -function reloadCurrentDocument() {
703 - const currentDocument = (0,_store_get_current_document__WEBPACK_IMPORTED_MODULE_1__.getCurrentDocument)();
704 - if (!currentDocument?.id) {
705 - return Promise.resolve();
706 - }
707 - getV1DocumentsManager().invalidateCache();
708 - return (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.__privateRunCommand)('editor/documents/switch', {
709 - id: currentDocument.id,
710 - shouldScroll: false,
711 - shouldNavigateToDefaultRoute: false
712 - });
287 +function syncOnTitleChange() {
288 + const { updateActiveDocument } = slice.actions;
289 + const updateTitle = debounce((e) => {
290 + const event = e;
291 + if (!("post_title" in event.args?.settings)) {
292 + return;
293 + }
294 + const currentDocument = getV1DocumentsManager().getCurrent();
295 + const newTitle = currentDocument.container.settings.get("post_title");
296 + (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__dispatch)(updateActiveDocument({ title: newTitle }));
297 + }, 400);
298 + (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.__privateListenTo)(
299 + (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.commandEndEvent)("document/elements/settings"),
300 + updateTitle
301 + );
713 302 }
714 -function switchToDocument(documentId, options) {
715 - return (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_0__.__privateRunCommand)('editor/documents/switch', {
716 - id: documentId,
717 - ...options
718 - });
303 +function syncOnDocumentChange() {
304 + const { markAsDirty, markAsPristine } = slice.actions;
305 + (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.__privateListenTo)(
306 + (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.commandEndEvent)("document/save/set-is-modified"),
307 + () => {
308 + const currentDocument = getV1DocumentsManager().getCurrent();
309 + if (currentDocument.editor.isChanged) {
310 + (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__dispatch)(markAsDirty());
311 + return;
312 + }
313 + (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__dispatch)(markAsPristine());
314 + }
315 + );
719 316 }
317 +function debounce(fn, timeout) {
318 + let timer;
319 + return (...args) => {
320 + clearTimeout(timer);
321 + timer = setTimeout(() => {
322 + fn(...args);
323 + }, timeout);
324 + };
325 +}
720 326
721 -/***/ }),
327 +// src/init.ts
722 328
723 -/***/ "./packages/packages/core/editor-documents/src/types.ts":
724 -/*!**************************************************************!*\
725 - !*** ./packages/packages/core/editor-documents/src/types.ts ***!
726 - \**************************************************************/
727 -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
329 +function init() {
330 + initStore();
331 +}
332 +function initStore() {
333 + (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__registerSlice)(slice);
334 + syncStore();
335 +}
728 336
729 -__webpack_require__.r(__webpack_exports__);
337 +// src/hooks/use-active-document.ts
730 338
731 339
732 -/***/ }),
340 +// src/store/selectors.ts
733 341
734 -/***/ "@elementor/editor":
735 -/*!*****************************************!*\
736 - !*** external ["elementorV2","editor"] ***!
737 - \*****************************************/
738 -/***/ (function(module) {
342 +var selectEntities = (state) => state.documents.entities;
343 +var selectActiveId = (state) => state.documents.activeId;
344 +var selectHostId = (state) => state.documents.hostId;
345 +var selectActiveDocument = (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__createSelector)(
346 + selectEntities,
347 + selectActiveId,
348 + (entities, activeId) => activeId && entities[activeId] ? entities[activeId] : null
349 +);
350 +var selectHostDocument = (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__createSelector)(
351 + selectEntities,
352 + selectHostId,
353 + (entities, hostId) => hostId && entities[hostId] ? entities[hostId] : null
354 +);
739 355
740 -module.exports = window["elementorV2"]["editor"];
356 +// src/hooks/use-active-document.ts
357 +function useActiveDocument() {
358 + return (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__useSelector)(selectActiveDocument);
359 +}
741 360
742 -/***/ }),
361 +// src/hooks/use-active-document-actions.ts
743 362
744 -/***/ "@elementor/editor-v1-adapters":
745 -/*!***************************************************!*\
746 - !*** external ["elementorV2","editorV1Adapters"] ***!
747 - \***************************************************/
748 -/***/ (function(module) {
749 363
750 -module.exports = window["elementorV2"]["editorV1Adapters"];
364 +function useActiveDocumentActions() {
365 + const save = (0,react__WEBPACK_IMPORTED_MODULE_2__.useCallback)(() => (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.__privateRunCommand)("document/save/default"), []);
366 + const saveDraft = (0,react__WEBPACK_IMPORTED_MODULE_2__.useCallback)(() => (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.__privateRunCommand)("document/save/draft"), []);
367 + const saveTemplate = (0,react__WEBPACK_IMPORTED_MODULE_2__.useCallback)(() => (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.__privateOpenRoute)("library/save-template"), []);
368 + return {
369 + save,
370 + saveDraft,
371 + saveTemplate
372 + };
373 +}
751 374
752 -/***/ }),
375 +// src/hooks/use-host-document.ts
753 376
754 -/***/ "@elementor/store":
755 -/*!****************************************!*\
756 - !*** external ["elementorV2","store"] ***!
757 - \****************************************/
758 -/***/ (function(module) {
377 +function useHostDocument() {
378 + return (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.__useSelector)(selectHostDocument);
379 +}
759 380
760 -module.exports = window["elementorV2"]["store"];
381 +// src/hooks/use-navigate-to-document.ts
761 382
762 -/***/ }),
763 383
764 -/***/ "@elementor/utils":
765 -/*!****************************************!*\
766 - !*** external ["elementorV2","utils"] ***!
767 - \****************************************/
768 -/***/ (function(module) {
384 +function useNavigateToDocument() {
385 + return (0,react__WEBPACK_IMPORTED_MODULE_2__.useCallback)(async (id) => {
386 + await (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.__privateRunCommand)("editor/documents/switch", {
387 + id,
388 + setAsInitial: true
389 + });
390 + const url = new URL(window.location.href);
391 + url.searchParams.set("post", id.toString());
392 + url.searchParams.delete("active-document");
393 + history.replaceState({}, "", url);
394 + }, []);
395 +}
769 396
770 -module.exports = window["elementorV2"]["utils"];
397 +// src/index.ts
398 +init();
771 399
772 -/***/ }),
773 -
774 -/***/ "@wordpress/i18n":
775 -/*!******************************!*\
776 - !*** external ["wp","i18n"] ***!
777 - \******************************/
778 -/***/ (function(module) {
779 -
780 -module.exports = window["wp"]["i18n"];
781 -
782 -/***/ }),
783 -
784 -/***/ "react":
785 -/*!**************************!*\
786 - !*** external ["React"] ***!
787 - \**************************/
788 -/***/ (function(module) {
789 -
790 -module.exports = window["React"];
791 -
792 -/***/ })
793 -
794 -/******/ });
795 -/************************************************************************/
796 -/******/ // The module cache
797 -/******/ var __webpack_module_cache__ = {};
798 -/******/
799 -/******/ // The require function
800 -/******/ function __webpack_require__(moduleId) {
801 -/******/ // Check if module is in cache
802 -/******/ var cachedModule = __webpack_module_cache__[moduleId];
803 -/******/ if (cachedModule !== undefined) {
804 -/******/ return cachedModule.exports;
805 -/******/ }
806 -/******/ // Create a new module (and put it into the cache)
807 -/******/ var module = __webpack_module_cache__[moduleId] = {
808 -/******/ // no module.id needed
809 -/******/ // no module.loaded needed
810 -/******/ exports: {}
811 -/******/ };
812 -/******/
813 -/******/ // Execute the module function
814 -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
815 -/******/
816 -/******/ // Return the exports of the module
817 -/******/ return module.exports;
818 -/******/ }
819 -/******/
820 -/************************************************************************/
821 -/******/ /* webpack/runtime/compat get default export */
822 -/******/ !function() {
823 -/******/ // getDefaultExport function for compatibility with non-harmony modules
824 -/******/ __webpack_require__.n = function(module) {
825 -/******/ var getter = module && module.__esModule ?
826 -/******/ function() { return module['default']; } :
827 -/******/ function() { return module; };
828 -/******/ __webpack_require__.d(getter, { a: getter });
829 -/******/ return getter;
830 -/******/ };
831 -/******/ }();
832 -/******/
833 -/******/ /* webpack/runtime/define property getters */
834 -/******/ !function() {
835 -/******/ // define getter functions for harmony exports
836 -/******/ __webpack_require__.d = function(exports, definition) {
837 -/******/ for(var key in definition) {
838 -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
839 -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
840 -/******/ }
841 -/******/ }
842 -/******/ };
843 -/******/ }();
844 -/******/
845 -/******/ /* webpack/runtime/hasOwnProperty shorthand */
846 -/******/ !function() {
847 -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
848 -/******/ }();
849 -/******/
850 -/******/ /* webpack/runtime/make namespace object */
851 -/******/ !function() {
852 -/******/ // define __esModule on exports
853 -/******/ __webpack_require__.r = function(exports) {
854 -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
855 -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
856 -/******/ }
857 -/******/ Object.defineProperty(exports, '__esModule', { value: true });
858 -/******/ };
859 -/******/ }();
860 -/******/
861 -/************************************************************************/
862 -var __webpack_exports__ = {};
863 -// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
864 -!function() {
865 -/*!**************************************************************!*\
866 - !*** ./packages/packages/core/editor-documents/src/index.ts ***!
867 - \**************************************************************/
868 -__webpack_require__.r(__webpack_exports__);
869 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
870 -/* harmony export */ COMPONENT_DOCUMENT_TYPE: function() { return /* reexport safe */ _consts__WEBPACK_IMPORTED_MODULE_5__.COMPONENT_DOCUMENT_TYPE; },
871 -/* harmony export */ __useActiveDocument: function() { return /* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_1__.useActiveDocument; },
872 -/* harmony export */ __useActiveDocumentActions: function() { return /* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_1__.useActiveDocumentActions; },
873 -/* harmony export */ __useHostDocument: function() { return /* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_1__.useHostDocument; },
874 -/* harmony export */ __useNavigateToDocument: function() { return /* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_1__.useNavigateToDocument; },
875 -/* harmony export */ __useOpenDocumentInNewTab: function() { return /* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_1__.useOpenDocumentInNewTab; },
876 -/* harmony export */ getCurrentDocument: function() { return /* reexport safe */ _store_get_current_document__WEBPACK_IMPORTED_MODULE_3__.getCurrentDocument; },
877 -/* harmony export */ getV1CurrentDocument: function() { return /* reexport safe */ _sync_utils__WEBPACK_IMPORTED_MODULE_4__.getV1CurrentDocument; },
878 -/* harmony export */ getV1DocumentsManager: function() { return /* reexport safe */ _sync_utils__WEBPACK_IMPORTED_MODULE_4__.getV1DocumentsManager; },
879 -/* harmony export */ init: function() { return /* reexport safe */ _init__WEBPACK_IMPORTED_MODULE_0__.init; },
880 -/* harmony export */ invalidateDocumentData: function() { return /* reexport safe */ _sync_utils__WEBPACK_IMPORTED_MODULE_4__.invalidateDocumentData; },
881 -/* harmony export */ isDocumentDirty: function() { return /* reexport safe */ _sync_utils__WEBPACK_IMPORTED_MODULE_4__.isDocumentDirty; },
882 -/* harmony export */ reloadCurrentDocument: function() { return /* reexport safe */ _sync_utils__WEBPACK_IMPORTED_MODULE_4__.reloadCurrentDocument; },
883 -/* harmony export */ setDocumentModifiedStatus: function() { return /* reexport safe */ _sync_utils__WEBPACK_IMPORTED_MODULE_4__.setDocumentModifiedStatus; },
884 -/* harmony export */ slice: function() { return /* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_2__.slice; },
885 -/* harmony export */ switchToDocument: function() { return /* reexport safe */ _sync_utils__WEBPACK_IMPORTED_MODULE_4__.switchToDocument; }
886 -/* harmony export */ });
887 -/* harmony import */ var _init__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./init */ "./packages/packages/core/editor-documents/src/init.ts");
888 -/* harmony import */ var _hooks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hooks */ "./packages/packages/core/editor-documents/src/hooks/index.ts");
889 -/* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./store */ "./packages/packages/core/editor-documents/src/store/index.ts");
890 -/* harmony import */ var _store_get_current_document__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./store/get-current-document */ "./packages/packages/core/editor-documents/src/store/get-current-document.ts");
891 -/* harmony import */ var _sync_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sync/utils */ "./packages/packages/core/editor-documents/src/sync/utils.ts");
892 -/* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./consts */ "./packages/packages/core/editor-documents/src/consts.ts");
893 -/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./types */ "./packages/packages/core/editor-documents/src/types.ts");
894 -
895 -
896 -
897 -
898 -
899 -
900 -
400 +//# sourceMappingURL=index.mjs.map
901 401 }();
902 402 (window.elementorV2 = window.elementorV2 || {}).editorDocuments = __webpack_exports__;
903 403 /******/ })()
904 -;
905 -window.elementorV2.editorDocuments?.init?.();
906 -//# sourceMappingURL=editor-documents.js.map
404 +;