Files
plugi/plugi-core/dist/PageBuilderBody.js
T
deepDiverPaul 84545fc4a3 refactor pagebuilder asset bundling
Migrate pagebuilder and core dist assets from legacy bundled format to modern Vite/Rolldown output.

- Delete legacy pagebuilder app.css and app.js bundles in favor of per-module dist files.
- Update page-injection.js to use template literals and add source map reference.
- Refresh core dist files (PageBuilderBody, PageBuilderHead, WebsiteManager) with updated CSS/JS and remove UMD bundles.
2026-11-23 16:18:35 +01:00

2 lines
24 KiB
JavaScript

(function(){$(`.gjs-editor`).append($(`#toggle-sidebar`)),$(`.gjs-pn-panels`).prepend($(`#sidebar-header`)),$(`.gjs-pn-panels`).append($(`#sidebar-bottom-buttons`)),$(`#toggle-sidebar`).click(function(){$(`#gjs`).toggleClass(`sidebar-collapsed`),t()}),e(),window.editor.on(`run:open-sm`,function(e){$(`.gjs-trt-traits`).parent().parent().css(`display`,`none`),$(`.gjs-sm-sectors`).parent().parent().css(`display`,`block`),$(`#gjs-sm-advanced .gjs-sm-properties`).append($(`.gjs-clm-tags`))}),window.editor.on(`run:open-tm`,function(e){$(`.gjs-sm-sectors`).parent().parent().css(`display`,`none`),$(`.gjs-trt-traits`).parent().parent().css(`display`,`block`)}),window.editor.on(`block:drag:start`,function(t){e()}),window.editor.on(`rteToolbarPosUpdate`,function(e){window.editor&&window.editor.getSelected()&&window.editor.getSelected().getEl()&&setTimeout(function(){let t=$(`.gjs-rte-toolbar`).first();if(t.offset().top<e.elementTop+.5*e.elementHeight){let n=e.elementTop-t.height();n>0&&t.css(`top`,n+`px`)}},0)});function e(){$(window).width()<1e3&&($(`#gjs`).addClass(`sidebar-collapsed`),t())}function t(){window.editor.trigger(`change:canvasOffset canvasScroll`)}let n=!1;$(document).keydown(function(e){e.which===8&&(n=!0)}).keyup(function(e){e.which===8&&(n=!1)}),$(window).on(`beforeunload`,function(e){n&&e.preventDefault()});function r(){$(`.gjs-blocks-cs`).prepend($(`#block-search`))}window.addEventListener(`message`,i,!1);function i(e){e.data===`page-loaded`?($(`#phpb-loading`).addClass(`loaded`),r(),window.isLoaded=!0,$(window).trigger(`pagebuilder-page-loaded`)):e.data===`touch-start`&&window.touchStart()}$(document).on(`input`,`#block-search input`,function(){let e=$(this).val().toLowerCase();$(`.gjs-block-category`).each(function(){let t=!1;$(this).find(`.gjs-block`).each(function(){$(this).data(`original-html`)||$(this).data(`original-html`,$(this).html());let n=$(this).text();if(n.toLowerCase().includes(e)){$(this).removeClass(`d-none`),t=!0;let r=RegExp(`(`+e+`)`,`gi`),i=n.replace(r,`<b>$1</b>`);$(this).find(`.gjs-block-label`).html($(this).data(`original-html`).replace(n.trim(),i))}else $(this).addClass(`d-none`)}),$(this).removeClass(`d-none`),t||$(this).addClass(`d-none`)})}),window.customBuilderScripts={},window.editor.on(`component:create`,e=>{if(e.components().length){let t=e.components().models[e.components().length-1];if(t.attributes.type===`script`){let n=e.attributes.attributes[`block-id`];n===void 0&&(n=e.attributes.attributes.id);let r=t,i=!1;for(;r.parent();)if(r=r.parent(),r.attributes.attributes[`phpb-content-container`]){i=!0;break}i&&(window.customBuilderScripts[n]=t.toHTML(),t.remove())}}}),window.editor.on(`component:add`,function(e){if(e.attributes[`run-builder-script`]!==void 0){let t=customBuilderScripts;window.customBuilderScripts[e.attributes[`block-id`]]=customBuilderScripts[e.attributes[`run-builder-script`]],runScriptsOfComponentAndChildren(e),window.customBuilderScripts=t,delete e.attributes[`run-builder-script`]}}),window.editor.on(`sorter:drag:end`,function(e){let t=e.modelToDrop;t&&t.attributes&&(t.attributes[`block-id`]||t.attributes.id)&&window.runScriptsOfComponentAndChildren(t);for(let e in CKEDITOR.instances)CKEDITOR.instances[e].destroy(!0)}),window.runScriptsOfComponentAndChildren=function(e){a(e),e.components().each(function(e){runScriptsOfComponentAndChildren(e)})};function a(e){let t=e.attributes[`block-id`];if(t===void 0&&(t=e.attributes.attributes.id),t&&window.customBuilderScripts[t]!==void 0){let n=e.attributes[`style-identifier`],r=$(`<container>`).append(window.customBuilderScripts[t]);r.find(`script`).prepend(`let inPageBuilder = true;`),r.find(`script`).prepend(`let blockSelector = ".`+n+`";`),r.find(`script`).prepend(`let block = document.getElementsByClassName("`+n+`")[0];`),r.find(`script`).prepend(`(function(){`),r.find(`script`).append(`})();`);let i=document.createElement(`script`);i.type=`text/javascript`,i.innerHTML=r.find(`script`).html(),window.editor.Canvas.getDocument().body.appendChild(i)}}function o(){c();let e=document.createElement(`script`);e.type=`text/javascript`,e.src=window.injectionScriptUrl;let t=e.outerHTML+`<script>`+s.toString()+s.name+`()<\/script>`;window.initialComponents=window.initialComponents.replace(`</body>`,t+`</body>`),$.each(window.languages,(e,t)=>{window.pageBlocks[e]===null&&(window.pageBlocks[e]={})}),activateLanguage(window.currentLanguage)}function s(){let e=document.querySelectorAll(`script`);for(let t=0;t<e.length;t++){let n=e[t];if(n.innerHTML.startsWith(`var script`)){let e=n.innerHTML.split(`=`)[0],t=parseInt(e.replace(`var script`,``));if(Number.isInteger(t)){let e=`script`+t+`Start`;if(typeof window[e]==`function`)return t!==0&&window[e](),!1}}}}function c(){for(let e in window.themeBlocks){let t=window.themeBlocks[e],n=$(`<container>`).append(t.content);n.find(`[phpb-blocks-container]`).each(function(){$(this).html()!==``&&$(this).html().trim()===``&&$(this).html(``)}),window.themeBlocks[e].content=n.html(),t.content=n.html(),editor.BlockManager.add(e,t)}}$(`#language-selector select`).on(`change`,function(){let e=$(this).find(`option:selected`).val();window.switchLanguage(e,function(){activateLanguage(e)})}),window.activateLanguage=function(e){window.currentLanguage=e,window.editor.select(),window.editor.DomComponents.clear(),window.editor.DomComponents.componentsById=[],window.editor.UndoManager.clear(),window.editor.Canvas.getDocument().querySelectorAll(`script`).forEach(function(e){e.remove()}),window.editor.setComponents(window.initialComponents),u(editor.getWrapper()),window.editor.getWrapper().find(`[phpb-content-container]`).forEach((e,t)=>{e.set(`custom-name`,window.translations[`page-content`]),e.components(window.contentContainerComponents[t]),l(e),p(e)})},$(window).on(`pagebuilder-page-loaded`,function(e){window.editor.getWrapper().find(`[phpb-content-container]`).forEach(e=>{b(e),window.runScriptsOfComponentAndChildren(e)}),window.setWaiting(!1),setTimeout(function(){window.changesOffset=window.editor.getModel().get(`changesCount`),window.afterInitialRendering=!0},250)});function l(e){let t=e;if(e.get(`tagName`)===`phpb-block`){let n=e.attributes.attributes.id;window.pageBlocks[window.currentLanguage][n]!==void 0&&window.pageBlocks[window.currentLanguage][n].html!==void 0&&(t=e.replaceWith(window.pageBlocks[window.currentLanguage][n].html),window.pageBlocks[window.currentLanguage][n].html=``)}t.get(`components`).each(e=>l(e))}function u(e){`phpb-content-container`in e.attributes.attributes||(C(e),e.get(`components`).each(e=>u(e)))}window.editor.on(`component:selected`,function(e){f(e)?$(`.gjs-pn-buttons .gjs-pn-btn:nth-of-type(2)`).click():e.get(`type`)===``&&d(e)&&($(`.gjs-pn-buttons .gjs-pn-btn:nth-of-type(3)`).click(),$(`#gjs-sm-position`).hasClass(`gjs-sm-open`)&&$(`#gjs-sm-position`).find(`.gjs-sm-title`).click(),$(`#gjs-sm-background`).hasClass(`gjs-sm-open`)||$(`#gjs-sm-background`).find(`.gjs-sm-title`).click()),f(e)||setTimeout(function(){$(`.gjs-trt-traits`).html(`<p class="no-settings">`+window.translations[`trait-manager`][`no-settings`]+`</p>`)},0),setTimeout(function(){e.attributes.removable||$(`.gjs-toolbar .fa-trash-o.gjs-toolbar-item`).hide(),e.attributes.copyable||$(`.gjs-toolbar .fa-clone.gjs-toolbar-item`).hide(),e.attributes.draggable||$(`.gjs-toolbar .fa-arrows.gjs-toolbar-item`).hide(),e.attributes.removable||e.attributes.copyable||e.attributes.draggable||window.editor.select(e.parent());let t=e.attributes[`block-slug`];if(t){let e=window.themeBlocks[t].label.split(`</div>`);e.length>1&&$(`.gjs-toolbar`).attr(`title`,`Bloknaam: `+e[1])}},0)}),window.editor.on(`component:clone`,function(e){if(!_){let t=window.editor.getWrapper().find(`.`+e.attributes[`style-identifier`])[0];e.attributes[`style-identifier`]!==void 0&&e.attributes[`style-identifier`]!==``&&(e.removeClass(e.attributes[`style-identifier`]),delete e.attributes[`style-identifier`],S(e)),e.attributes[`block-id`]=e.attributes[`block-slug`],t&&window.customBuilderScripts[t.attributes[`block-id`]]!==void 0&&(e.attributes[`run-builder-script`]=t.attributes[`block-id`])}});function d(e){let t=!1,n=e.getEl();if(n&&n.style){let e=window.getComputedStyle(n);[`background`,`background-image`,`background-color`].forEach(n=>{let r=e.getPropertyValue(n);r!==void 0&&r!==``&&!r.includes(`none`)&&!r.includes(`rgba(0, 0, 0, 0)`)&&(t=!0)})}return t}function f(e){return e.attributes.traits.length>0}window.editor.on(`block:drag:stop`,function(e){if(!e||!e.attributes||!e.attributes.attributes)return;let t=T();e.attributes.attributes[`dropped-component-id`]=t;let n=e.parent();p(e),n.components().each(function(n){n.attributes[`dropped-component-id`]===t&&(delete n.attributes[`dropped-component-id`],e=n)}),b(e),window.runScriptsOfComponentAndChildren(e)});function p(e){if(e.attributes.tagName===`phpb-block`){let t=e.parent(),n=cloneComponent(e),r;e.attributes.attributes[`is-html`]===`false`?t.components().each(function(t){if(t.cid===e.cid){let t=`wrapper`in e.attributes.attributes?e.attributes.attributes.wrapper:`div`;r=e.replaceWith({tagName:t}),r.attributes[`is-style-wrapper`]=!0,n.components().each(function(e){r.append(cloneComponent(e))})}}):t.components().each(function(t){if(t.cid===e.cid){if(n.components().length===1){let t=cloneComponent(n.components().models[0]);r=e.replaceWith(t)}else r=e.replaceWith({tagName:`div`}),r.attributes[`is-style-wrapper`]=!0,n.components().each(function(e){r.append(cloneComponent(e))})}}),e.remove(),y(n,r,!0,!1),h(r),p(r)}else e.components().each(function(e){p(e)})}function m(e){let t=[],n=e,r=!1;for(;n.parent()&&n.parent().attributes.attributes[`phpb-blocks-container`]===void 0&&n.parent().attributes[`is-html`]!==`true`&&n.parent().attributes.attributes[`phpb-content-container`]===void 0;)n.parent().attributes[`is-html`]===`false`&&(r=!0),n.attributes[`block-id`]!==void 0&&t.push(n.attributes[`block-id`]),n=n.parent();let i=e.attributes[`block-id`];r?i=n.attributes[`block-id`]:t=[];let a=window.pageBlocks[window.currentLanguage][i];t.reverse().forEach(function(e){a=a===void 0||a.blocks===void 0||a.blocks[e]===void 0?{}:a.blocks[e]});let o={};return a!==void 0&&a.settings!==void 0&&a.settings.attributes!==void 0&&(o=a.settings.attributes),o}function h(e){if(window.blockSettings[e.attributes[`block-slug`]]===void 0)return;e.attributes.settings={};let t=m(e);t[`style-identifier`]!==void 0&&e.addClass(t[`style-identifier`]),e.attributes[`is-updating`]=!0,window.blockSettings[e.attributes[`block-slug`]].forEach(function(n){let r=e.addTrait(n);t[n.name]===void 0?n[`default-value`]!==void 0&&r[0].setTargetValue(n[`default-value`]):r[0].setTargetValue(t[n.name])}),e.attributes[`is-updating`]=!1}window.editor.on(`component:update`,function(e){if(window.isLoaded!==!0||e.attributes[`block-slug`]===void 0||e.attributes[`is-updating`]||e.changed.attributes===void 0||$(`.gjs-frame`).contents().find(`#`+e.ccid).length===0)return;let t=[],n=e,r=!1;for(;n.parent()&&n.parent().attributes.attributes[`phpb-blocks-container`]===void 0&&n.parent().attributes[`is-html`]!==`true`&&n.parent().attributes.attributes[`phpb-content-container`]===void 0;)n.parent().attributes[`is-html`]===`false`&&(r=!0),n.attributes[`block-id`]!==void 0&&t.push(n.attributes[`block-id`]),n=n.parent();r?e=n:t=[],e.attributes[`is-updating`]=!0,$(`.gjs-frame`).contents().find(`#`+e.ccid).addClass(`gjs-freezed`);let i=window.editor.getWrapper().find(`#`+e.ccid)[0].parent(),a=window.getComponentDataInStorageFormat(e);$.ajax({type:`POST`,url:window.renderBlockUrl,data:{data:JSON.stringify(a),language:window.currentLanguage},success:function(n){let r=$(n).attr(`block-id`);window.pageBlocks[window.currentLanguage][r]=a.blocks[r]===void 0?{}:a.blocks[r],e.replaceWith(n),l(i),p(i),b(i,!1,!1);let o=g(i,[r]);runScriptsOfComponentAndChildren(o),t.push(r);let s=g(i,t.reverse());window.editor.select(s)},error:function(){$(`.gjs-frame`).contents().find(`#`+e.ccid).removeClass(`gjs-freezed`),e.attributes[`is-updating`]=!1,window.toastr.error(window.translations[`toastr-component-update-failed`])}})});function g(e,t){if(t.length===0)return e;let n=null;return e.forEachChild(function(e){if(e.attributes[`block-id`]===t[0])return n=g(e,t.slice(1)),!1}),e.forEachChild(function(e){let r=g(e,t);if(r!==null)return n=r,!1}),n}let _=!1;window.cloneComponent=function(e){_=!0;let t=e.clone();return v(e,t),_=!1,t};function v(e,t){y(e,t,!1,!0);for(let n=0;n<e.components().length;n++)v(e.components().models[n],t.components().models[n])}function y(e,t,n,r){let i=e.attributes.attributes;for(let e in i)r&&(t.attributes.attributes[e]=i[e]),n&&(t.attributes[e]=i[e])}function b(e,t=!1,n=!0){if(C(e),e.attributes.attributes[`phpb-content-container`]!==void 0)e.set({droppable:!0,hoverable:!0});else if(e.attributes[`block-slug`]!==void 0){e.find(`[phpb-hide-if-not-editable]`).forEach(e=>{n||window.afterInitialRendering?e.addClass(`editable`):e.removeClass(`editable`)});let r={selectable:!0,hoverable:!0};t||(r={removable:!0,draggable:!0,copyable:!0,selectable:!0,hoverable:!0,stylable:!0},S(e)),e.attributes[`is-html`]===`true`?(t=!1,n=!0):(t=!0,n=!1,e.getEl().setAttribute(`data-cursor`,`default`)),e.set(r)}if(e.attributes.attributes[`data-raw-content`]!==void 0)e.set({editable:!0});else if(n&&(x(e),e.attributes[`made-text-editable`]===`true`)){e.attributes.attributes[`data-raw-content`]=`true`;let t=e.replaceWith(e.toHTML());[`block-id`,`block-slug`,`is-html`,`style-identifier`].forEach(n=>{t.attributes[n]=e.attributes[n]}),b(t)}else e.get(`components`).each(e=>b(e,t,n))}function x(e){let t=e.get(`tagName`),n=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`h7`,`p`,`small`,`b`,`strong`,`i`,`em`,`label`,`button`,`ol`,`ul`,`li`,`table`],r=[`img`],i={};`phpb-blocks-container`in e.attributes.attributes&&(i.hoverable=!0,i.selectable=!0,i.droppable=!0),n.includes(t)||`phpb-editable`in e.attributes.attributes?(i.editable=!0,e.attributes[`made-text-editable`]=`true`):r.includes(t)&&(i.editable=!0),d(e)&&(i.hoverable=!0,i.selectable=!0,i.stylable=!0),t===`a`&&(i.hoverable=!0,i.selectable=!0,i.stylable=!0,i.removable=!0),$.isEmptyObject(i)||(e.set(i),i.stylable!==void 0&&i.stylable&&S(e))}function S(e){let t=!1;e.getClasses().forEach(e=>{e.startsWith(`ID`)&&e.length>=16&&(t=e)}),e.attributes[`style-identifier`]===void 0&&(e.attributes[`style-identifier`]=t||T()),e.addClass(e.attributes[`style-identifier`])}function C(e){e.set({removable:!1,draggable:!1,droppable:!1,badgable:!1,stylable:!1,highlightable:!1,copyable:!1,resizable:!1,editable:!1,layerable:!1,selectable:!1,hoverable:!1})}let w=0;function T(){return`ID`+(Date.now().toString(36)+Math.random().toString(36).substr(2,5)+w++).toUpperCase()}function E(){window.grapesJSLoaded?o():setTimeout(E,100)}E(),window.pageData={},window.changesOffset=0,window.onbeforeunload=D;function D(){if(window.editor.getModel().get(`changesCount`)-window.changesOffset>0)return`Are you sure? There are unsaved changes.`}$(`#save-page`).click(function(){N()}),$(document).bind(`keydown`,function(e){if(e.ctrlKey&&e.which===83)return window.editor.store(),N(),e.preventDefault(),!1}),window.switchLanguage=function(e,t){window.setWaiting(!0),A(function(){O(e);let n=window.pageData;n.blocks={[e]:window.pageBlocks[e]},$.ajax({type:`POST`,url:window.renderLanguageVariantUrl,data:{data:JSON.stringify(n),language:e},success:function(n){n=JSON.parse(n),window.pageBlocks[e]=n.dynamicBlocks?n.dynamicBlocks:{},t(),window.setWaiting(!1)},error:function(e){t(),console.log(e);let n=e.statusText+` `+e.status;n=e.responseJSON.message?n+`: "`+e.responseJSON.message+`"`:n,window.toastr.error(n),window.toastr.error(window.translations[`toastr-switching-language-failed`])}})})};function O(e){let t=window.pageBlocks[e],n=window.pageBlocks[window.currentLanguage];if(t===void 0)t=n;else{k(n,t);for(let e in n)t[e]===void 0&&(t[e]=n[e])}for(let e in n){let r=$(`<container>`+n[e].html+`</container>`),i=$(`<container>`+t[e].html+`</container>`);r.find(`[phpb-blocks-container]`).each(function(e){let t=$(this).html();i.find(`[phpb-blocks-container]`).eq(e).html(t)}),t[e].html=i.html()}window.pageBlocks[e]=t}function k(e,t){for(let n in e)if(t[n]!==void 0)for(let r in e[n].blocks){let i=e[n].blocks[r],a=t[n].blocks[r];if(!i||!a)continue;let o=i.html.match(/phpb-blocks-container(.*)>(.*)</g),s=a.html.match(/phpb-blocks-container(.*)>(.*)</g);if(o&&s)for(let e=0;e<o.length;e++)t[n].blocks[r].html=t[n].blocks[r].html.replace(s[e],o[e])}}function A(e){setTimeout(function(){let t=window.pageData.css?window.pageData.css:window.initialCss;window.pageData={html:[],components:[],css:null,style:null},window.pageBlocks[window.currentLanguage]=[],window.editor.getWrapper().find(`[phpb-content-container]`).forEach((e,n)=>{let r=P(e);window.pageData.css=j(t,r.css),window.pageData.style=r.style,window.pageData.html[n]=r.html,window.pageData.components[n]=r.components,window.pageBlocks[window.currentLanguage]={...window.pageBlocks[window.currentLanguage],...r.blocks},window.contentContainerComponents[n]=r.components}),e&&e()},200)}function j(e,t){if(!e)return t;let n=JSON.stringify(window.pageBlocks),r=e.match(/* @__PURE__ */ RegExp(`\\.ID(.*?){(.*?)}`,`g`));return r&&r.forEach(function(e){let r=e.split(`{`)[0],i=r.replace(`.`,` `).trim();t.indexOf(r)===-1&&n.indexOf(i)>=0&&(t+=e)}),t}function M(e){let t=JSON.stringify(window.pageBlocks),n=[];return e.forEach(e=>{if(e.attributes.selectors.models.length){let r=e.attributes.selectors.models[0].id;t.includes(r)&&n.push(e)}}),n}function N(){B(),A(function(){$.each(window.languages,(e,t)=>{e!==window.currentLanguage&&O(e)});let e=window.pageData;e.style=M(e.style),e.blocks=window.pageBlocks,$.ajax({type:`POST`,url:$(`#save-page`).data(`url`),data:{data:JSON.stringify(e)},success:function(){B(),window.toastr.success(window.translations[`toastr-changes-saved`]),setTimeout(function(){window.changesOffset=window.editor.getModel().get(`changesCount`)},250)},error:function(e){B(),console.log(e);let t=e.statusText+` `+e.status;t=e.responseJSON.message?t+`: "`+e.responseJSON.message+`"`:t,window.toastr.error(t),window.toastr.error(window.translations[`toastr-saving-failed`])}})})}window.getComponentDataInStorageFormat=function(e){let t=window.cloneComponent(e.parent());console.log({container:t,componentParent:e.parent()});let n=e.attributes[`block-id`];return console.log(e.attributes[`block-id`]),t.components().forEach(e=>{console.log({c:e}),e?.attributes[`block-id`]!==n&&e?.remove()}),console.log({containerL:t.get(`components`).length,componentParentL:e.parent().get(`components`).length}),P(t)};function P(e){let t=window.editor.DomComponents.componentsById;window.editor.DomComponents.componentsById=[],e=window.cloneComponent(e);let n=L(e).blocks,r=window.html_beautify(F(e)),i=window.editor.getCss(),a=window.editor.getStyle(),o=JSON.parse(JSON.stringify(e.get(`components`)));return window.editor.DomComponents.componentsById=t,{html:r,css:i,components:o,blocks:n,style:a}}function F(e){let t=``;e.get(`components`).forEach(e=>t+=e.toHTML());let n=$(`<container>`+t+`</container>`);return n.find(`phpb-block`).each(function(){$(this).replaceWith(`[block slug="`+$(this).attr(`slug`)+`" id="`+$(this).attr(`id`)+`"]`)}),n.html()}function I(e){let t=$(`<container>`+e.toHTML()+`</container>`);return t.find(`phpb-block`).each(function(){$(this).replaceWith(`[block slug="`+$(this).attr(`slug`)+`" id="`+$(this).attr(`id`)+`"]`)}),t.html()}function L(e,t=!1,n=!1){let r={current_block:{settings:{},blocks:{},html:``,is_html:!1},blocks:{}},i=t,a=n;if(e.attributes[`block-id`]!==void 0&&(e.attributes[`is-html`]===`false`?(i=!0,a=!1):t&&(i=!1,a=!0)),e.get(`components`).forEach(function(e){let t=L(e,i,a);for(let e in t.current_block.blocks)r.current_block.blocks[e]=t.current_block.blocks[e];for(let e in t.blocks)r.blocks[e]=t.blocks[e]}),!e.parent()||e.attributes[`block-id`]===void 0)return r;if(e.attributes[`is-html`]===`true`){if(t)r.current_block.blocks[e.attributes[`block-id`]]={settings:{},blocks:{},html:window.html_beautify(I(e)),is_html:!0};else{e.attributes[`style-identifier`]!==void 0&&(r.current_block.settings.attributes={"style-identifier":e.attributes[`style-identifier`]});let t=e.attributes[`block-id`];e.attributes[`block-id`].startsWith(`ID`)||(t=z()),e.replaceWith({tagName:`phpb-block`,attributes:{slug:e.attributes[`block-slug`],id:t}}),r.blocks[t]={settings:r.current_block.settings,blocks:{},html:window.html_beautify(I(e)),is_html:!0},r.current_block={settings:{},blocks:{},html:``,is_html:!1}}}else{let n={};e.get(`traits`).each(function(e){n[e.get(`name`)]=e.getTargetValue()}),r.current_block.settings.attributes=n,e.attributes[`style-identifier`]!==void 0&&(r.current_block.settings.attributes[`style-identifier`]=e.attributes[`style-identifier`]);let i=e.attributes[`block-id`];if(e.attributes[`block-id`].startsWith(`ID`)||(i=z()),e.replaceWith({tagName:`phpb-block`,attributes:{slug:e.attributes[`block-slug`],id:i}}),t){let t={settings:{},blocks:{},html:``,is_html:!1};t.blocks[e.attributes[`block-id`]]=r.current_block,r.current_block=t}else r.blocks[i]=r.current_block,r.current_block={settings:{},blocks:{},html:``,is_html:!1}}return r}let R=0;function z(){return`ID`+(Date.now().toString(36)+Math.random().toString(36).substr(2,5)+R++).toUpperCase()}window.setWaiting=function(e){let t=window.editor.DomComponents.getWrapper();e?t.addClass(`gjs-waiting`):t.removeClass(`gjs-waiting`)};function B(){let e=$(`#save-page`);e.blur(),e.hasClass(`waiting`)?(e.attr(`disabled`,!1),e.removeClass(`waiting`),e.find(`.spinner-border`).addClass(`d-none`)):(e.attr(`disabled`,!0),e.addClass(`waiting`),e.find(`.spinner-border`).removeClass(`d-none`))}window.CKEDITOR.on(`instanceReady`,function(e){e.editor.on(`paste`,function(e){let t=e.data.dataValue;t=t.replace(/<(?!\/?(?:a|table|tr|td|th|thead|tbody|tfoot|caption|col|colgroup|p|ul|ol|li|br|strong|em|b|i|u|strike|sub|sup|h1|h2|h3|h4|h5|h6|blockquote|pre|hr)\b)[^>]+>/gm,``),t=t.replace(/<(a|table|tr|td|th|thead|tbody|tfoot|caption|col|colgroup|p|ul|ol|li|br|strong|em|b|i|u|strike|sub|sup|h1|h2|h3|h4|h5|h6|blockquote|pre|hr)\b[^>]*>/gm,function(e,t){if(t===`a`){let t=e.match(/href="([^"]*)"/);return t?`<a href="`+t[1]+`">`:e}if(`|table|tr|td|th|thead|tbody|tfoot|`.includes(`|`+t+`|`)){let n=e.match(/style="([^"]*)"/);return n?`<`+t+` style="`+n[1]+`">`:e}return`<`+t+`>`}),e.data.dataValue=t})}),window.CKEDITOR.on(`dialogDefinition`,function(e){let t=e.data.name,n=e.data.definition;if(t===`link`){let e=n.getContents(`info`);n.onLoad=function(){let e=CKEDITOR.dialog.getCurrent();e.getContentElement(`info`,`linkType`).getElement().hide(),e.getContentElement(`info`,`protocol`).getElement().hide(),e.getContentElement(`info`,`url`).getElement().hide()},e.add({type:`select`,id:`linktype-selector`,label:`Linktype`,default:``,items:[[window.translations.page,`page`],[`URL`,`url`]],onChange:function(e){let t=CKEDITOR.dialog.getCurrent();e.data.value===`page`?(t.getContentElement(`info`,`page-selector`).getElement().show(),t.getContentElement(`info`,`url-field`).getElement().hide()):(t.getContentElement(`info`,`page-selector`).getElement().hide(),t.getContentElement(`info`,`url-field`).getElement().show(),t.getContentElement(`info`,`url-field`).setValue(``))},setup:function(e){e.type===void 0||e.type===`url`&&e.url.url.startsWith(`[page id=`)?this.setValue(`page`):this.setValue(e.type)}}),e.add({type:`select`,id:`page-selector`,label:window.translations.page,default:``,items:window.pages,onChange:function(){let e=CKEDITOR.dialog.getCurrent(),t=`[page id=`+this.getValue()+`]`;e.setValueOf(`info`,`url`,t),e.setValueOf(`info`,`protocol`,``)},setup:function(e){this.allowOnChange=!1;let t=``;e.url&&(t=e.url.url.substr(9,e.url.url.length-10)),this.setValue(t),this.allowOnChange=!0}}),e.add({type:`text`,id:`url-field`,label:`URL`,default:``,onChange:function(){let e=CKEDITOR.dialog.getCurrent(),t=this.getValue();e.setValueOf(`info`,`url`,t)},setup:function(e){this.allowOnChange=!1;let t=``;e.url&&(t=e.url.url),this.setValue(t),this.allowOnChange=!0}})}}),window.touchStart=function(){$(`#gjs`).addClass(`sidebar-collapsed`)}})();
//# sourceMappingURL=PageBuilderBody.js.map