PluginProbe
Elementor Website Builder – more than just a page builder / 3.30.2
Elementor Website Builder – more than just a page builder v3.30.2
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 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / assets / js / gutenberg.js

gutenberg.js in Elementor Website Builder – more than just a page builder 3.30.2, at assets/js/gutenberg.js

198 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*! elementor - v3.30.0 - 09-07-2025 */
2 /******/ (() => { // webpackBootstrap
3 /******/ "use strict";
4 /******/ var __webpack_modules__ = ({
5
6 /***/ "@wordpress/i18n":
7 /*!**************************!*\
8 !*** external "wp.i18n" ***!
9 \**************************/
10 /***/ ((module) => {
11
12 module.exports = wp.i18n;
13
14 /***/ })
15
16 /******/ });
17 /************************************************************************/
18 /******/ // The module cache
19 /******/ var __webpack_module_cache__ = {};
20 /******/
21 /******/ // The require function
22 /******/ function __webpack_require__(moduleId) {
23 /******/ // Check if module is in cache
24 /******/ var cachedModule = __webpack_module_cache__[moduleId];
25 /******/ if (cachedModule !== undefined) {
26 /******/ return cachedModule.exports;
27 /******/ }
28 /******/ // Create a new module (and put it into the cache)
29 /******/ var module = __webpack_module_cache__[moduleId] = {
30 /******/ // no module.id needed
31 /******/ // no module.loaded needed
32 /******/ exports: {}
33 /******/ };
34 /******/
35 /******/ // Execute the module function
36 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
37 /******/
38 /******/ // Return the exports of the module
39 /******/ return module.exports;
40 /******/ }
41 /******/
42 /************************************************************************/
43 // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
44 (() => {
45 /*!*******************************************!*\
46 !*** ../assets/dev/js/admin/gutenberg.js ***!
47 \*******************************************/
48 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
49
50
51 /* global ElementorGutenbergSettings */
52 (function ($) {
53 'use strict';
54
55 var ElementorGutenbergApp = {
56 cacheElements: function cacheElements() {
57 var self = this;
58 self.isElementorMode = ElementorGutenbergSettings.isElementorMode;
59 self.cache = {};
60 self.cache.$gutenberg = $('#editor');
61 self.cache.$switchMode = $($('#elementor-gutenberg-button-switch-mode').html());
62 self.cache.$switchModeButton = self.cache.$switchMode.find('#elementor-switch-mode-button');
63 self.bindEvents();
64 self.toggleStatus();
65 wp.data.subscribe(function () {
66 setTimeout(function () {
67 self.buildPanel();
68 }, 1);
69 });
70 },
71 buildPanel: function buildPanel() {
72 var self = this;
73 if (!self.cache.$gutenberg.find('#elementor-switch-mode').length) {
74 self.cache.$gutenberg.find('.edit-post-header-toolbar').append(self.cache.$switchMode);
75 }
76 if (this.hasIframe()) {
77 this.handleIframe();
78 }
79 if (!$('#elementor-editor').length) {
80 self.cache.$editorPanel = $($('#elementor-gutenberg-panel').html());
81 var editorButtonParent = self.cache.$gutenberg.find('.block-editor-writing-flow');
82 if (!editorButtonParent.length) {
83 editorButtonParent = self.cache.$gutenberg.find('.is-desktop-preview');
84 }
85 self.cache.$gurenbergBlockList = editorButtonParent;
86 self.cache.$gurenbergBlockList.append(self.cache.$editorPanel);
87 self.cache.$editorPanelButton = self.cache.$editorPanel.find('#elementor-go-to-edit-page-link');
88 self.cache.$editorPanelButton.on('click', function (event) {
89 event.preventDefault();
90 self.handleEditButtonClick();
91 });
92 }
93 },
94 handleIframe: function handleIframe() {
95 this.hideIframeContent();
96 this.buildPanelTopBar();
97 },
98 // Sometimes Gutenberg uses iframe instead of div.
99 hasIframe: function hasIframe() {
100 return !!this.cache.$gutenberg.find('iframe[name="editor-canvas"]').length;
101 },
102 hideIframeContent: function hideIframeContent() {
103 if (!this.isElementorMode) {
104 return;
105 }
106 var style = "<style>\n\t\t\t\t.editor-post-text-editor,\n\t\t\t\t.block-editor-block-list__layout {\n\t\t\t\t\tdisplay: none;\n\t\t\t\t}\n\n\t\t\t\tbody {\n\t\t\t\t\tpadding: 0 !important;\n\t\t\t\t}\n\t\t\t</style>";
107 this.cache.$gutenberg.find('iframe[name="editor-canvas"]').contents().find('body').append(style);
108 },
109 buildPanelTopBar: function buildPanelTopBar() {
110 var self = this;
111 if (!$('#elementor-edit-mode-button').length && this.isElementorMode) {
112 self.cache.$editorBtnTop = $($('#elementor-gutenberg-button-tmpl').html());
113 self.cache.$gutenberg.find('.edit-post-header-toolbar').append(self.cache.$editorBtnTop);
114 $('#elementor-edit-mode-button').on('click', function (event) {
115 event.preventDefault();
116 self.handleEditButtonClick(false);
117 });
118 }
119 },
120 handleEditButtonClick: function handleEditButtonClick() {
121 var withAnimation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
122 var self = this;
123 if (withAnimation) {
124 self.animateLoader();
125 }
126
127 // A new post is initialized as an 'auto-draft'.
128 // if the post is not a new post it should not save it to avoid some saving conflict between elementor and gutenberg.
129 var isNewPost = 'auto-draft' === wp.data.select('core/editor').getCurrentPost().status;
130 if (isNewPost) {
131 var documentTitle = wp.data.select('core/editor').getEditedPostAttribute('title');
132 if (!documentTitle) {
133 wp.data.dispatch('core/editor').editPost({
134 title: 'Elementor #' + $('#post_ID').val()
135 });
136 }
137 wp.data.dispatch('core/editor').savePost();
138 }
139 self.redirectWhenSave();
140 },
141 bindEvents: function bindEvents() {
142 var self = this;
143 self.cache.$switchModeButton.on('click', function () {
144 if (self.isElementorMode) {
145 elementorCommon.dialogsManager.createWidget('confirm', {
146 message: __('Please note that you are switching to WordPress default editor. Your current layout, design and content might break.', 'elementor'),
147 headerMessage: __('Back to WordPress Editor', 'elementor'),
148 strings: {
149 confirm: __('Continue', 'elementor'),
150 cancel: __('Cancel', 'elementor')
151 },
152 defaultOption: 'confirm',
153 onConfirm: function onConfirm() {
154 var wpEditor = wp.data.dispatch('core/editor');
155 wpEditor.editPost({
156 gutenberg_elementor_mode: false
157 });
158 wpEditor.savePost();
159 self.isElementorMode = !self.isElementorMode;
160 self.toggleStatus();
161 }
162 }).show();
163 } else {
164 self.isElementorMode = !self.isElementorMode;
165 self.toggleStatus();
166 self.cache.$editorPanelButton.trigger('click');
167 }
168 });
169 },
170 redirectWhenSave: function redirectWhenSave() {
171 var self = this;
172 setTimeout(function () {
173 if (wp.data.select('core/editor').isSavingPost()) {
174 self.redirectWhenSave();
175 } else {
176 location.href = ElementorGutenbergSettings.editLink;
177 }
178 }, 300);
179 },
180 animateLoader: function animateLoader() {
181 this.cache.$editorPanelButton.addClass('elementor-animate');
182 },
183 toggleStatus: function toggleStatus() {
184 jQuery('body').toggleClass('elementor-editor-active', this.isElementorMode).toggleClass('elementor-editor-inactive', !this.isElementorMode);
185 },
186 init: function init() {
187 this.cacheElements();
188 }
189 };
190 $(function () {
191 ElementorGutenbergApp.init();
192 });
193 })(jQuery);
194 })();
195
196 /******/ })()
197 ;
198 //# sourceMappingURL=gutenberg.js.map