From 6f921efddc9ef17f688ddebcb05b2ec08fbaa40f Mon Sep 17 00:00:00 2001 From: Paul Spenke Date: Sun, 2 Jul 2023 21:39:02 +0800 Subject: [PATCH] origin commit 23d8e32 --- plugi-core/dist/PageBuilderBody.js | 4 ++-- plugi-core/dist/PageBuilderBody.umd.cjs | 2 +- .../src/Modules/GrapesJS/resources/assets/js/save-page.js | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugi-core/dist/PageBuilderBody.js b/plugi-core/dist/PageBuilderBody.js index fc3ca89..69a6c6c 100644 --- a/plugi-core/dist/PageBuilderBody.js +++ b/plugi-core/dist/PageBuilderBody.js @@ -495,8 +495,8 @@ function I(t) { function z(t, e) { if (!t) return e; - let i = JSON.stringify(window.pageBlocks), n = "\\.ID(.*?){(.*?)}"; - return t.match(new RegExp(n, "g")).forEach(function(s) { + let i = JSON.stringify(window.pageBlocks), n = "\\.ID(.*?){(.*?)}", a = t.match(new RegExp(n, "g")); + return a && a.forEach(function(s) { let l = s.split("{")[0], r = l.replace(".", " ").trim(); e.indexOf(l) === -1 && i.indexOf(r) >= 0 && (e += s); }), e; diff --git a/plugi-core/dist/PageBuilderBody.umd.cjs b/plugi-core/dist/PageBuilderBody.umd.cjs index 857387f..28172fb 100644 --- a/plugi-core/dist/PageBuilderBody.umd.cjs +++ b/plugi-core/dist/PageBuilderBody.umd.cjs @@ -1 +1 @@ -(function(d){typeof define=="function"&&define.amd?define(d):d()})(function(){"use strict";$(".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"),m()}),d(),window.editor.on("run:open-sm",function(t){$(".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(t){$(".gjs-sm-sectors").parent().parent().css("display","none"),$(".gjs-trt-traits").parent().parent().css("display","block")}),window.editor.on("block:drag:start",function(t){d()}),window.editor.on("rteToolbarPosUpdate",function(t){!window.editor||!window.editor.getSelected()||!window.editor.getSelected().getEl()||setTimeout(function(){let i=$(".gjs-rte-toolbar").first();if(i.offset().top0&&i.css("top",a+"px")}},0)});function d(){$(window).width()<1e3&&($("#gjs").addClass("sidebar-collapsed"),m())}function m(){window.editor.trigger("change:canvasOffset canvasScroll")}let g=!1;$(document).keydown(function(t){t.which===8&&(g=!0)}).keyup(function(t){t.which===8&&(g=!1)}),$(window).on("beforeunload",function(t){g&&t.preventDefault()});function _(){$(".gjs-blocks-cs").prepend($("#block-search"))}window.addEventListener("message",A,!1);function A(t){t.data==="page-loaded"?($("#phpb-loading").addClass("loaded"),_(),window.isLoaded=!0,$(window).trigger("pagebuilder-page-loaded")):t.data==="touch-start"&&window.touchStart()}$(document).on("input","#block-search input",function(){let t=$(this).val().toLowerCase();$(".gjs-block-category").each(function(){let e=!1;$(this).find(".gjs-block").each(function(){$(this).data("original-html")||$(this).data("original-html",$(this).html());let i=$(this).text();if(i.toLowerCase().includes(t)){$(this).removeClass("d-none"),e=!0;let n=new RegExp("("+t+")","gi"),a=i.replace(n,"$1");$(this).find(".gjs-block-label").html($(this).data("original-html").replace(i.trim(),a))}else $(this).addClass("d-none")}),$(this).removeClass("d-none"),e||$(this).addClass("d-none")})}),window.customBuilderScripts={},window.editor.on("component:create",t=>{if(t.components().length){let e=t.components().models[t.components().length-1];if(e.attributes.type==="script"){let i=t.attributes.attributes["block-id"];i===void 0&&(i=t.attributes.attributes.id);let n=e,a=!1;for(;n.parent();)if(n=n.parent(),n.attributes.attributes["phpb-content-container"]){a=!0;break}a&&(window.customBuilderScripts[i]=e.toHTML(),e.remove())}}}),window.editor.on("component:add",function(t){if(t.attributes["run-builder-script"]!==void 0){let e=customBuilderScripts;window.customBuilderScripts[t.attributes["block-id"]]=customBuilderScripts[t.attributes["run-builder-script"]],runScriptsOfComponentAndChildren(t),window.customBuilderScripts=e,delete t.attributes["run-builder-script"]}}),window.editor.on("sorter:drag:end",function(t){let e=t.modelToDrop;e&&e.attributes&&(e.attributes["block-id"]||e.attributes.id)&&window.runScriptsOfComponentAndChildren(e);for(let i in CKEDITOR.instances)CKEDITOR.instances[i].destroy(!0)}),window.runScriptsOfComponentAndChildren=function(t){V(t),t.components().each(function(e){runScriptsOfComponentAndChildren(e)})};function V(t){let e=t.attributes["block-id"];if(e===void 0&&(e=t.attributes.attributes.id),e&&window.customBuilderScripts[e]!==void 0){let i=t.attributes["style-identifier"],n=$("").append(window.customBuilderScripts[e]);n.find("script").prepend("let inPageBuilder = true;"),n.find("script").prepend('let blockSelector = ".'+i+'";'),n.find("script").prepend('let block = document.getElementsByClassName("'+i+'")[0];'),n.find("script").prepend("(function(){"),n.find("script").append("})();");let a=document.createElement("script");a.type="text/javascript",a.innerHTML=n.find("script").html(),window.editor.Canvas.getDocument().body.appendChild(a)}}function x(){H();let t=document.createElement("script");t.type="text/javascript",t.src=window.injectionScriptUrl;let e=t.outerHTML+"