diff --git a/build.js b/build.js index 0b56c0a..db66585 100644 --- a/build.js +++ b/build.js @@ -8,9 +8,14 @@ const libraries = [ fileName: 'WebsiteManager', }, { - entry: './src/Modules/GrapesJS/resources/assets/entry.js', - name: 'GrapesJS', - fileName: 'GrapesJS', + entry: './src/Modules/GrapesJS/resources/assets/entryHead.js', + name: 'PageBuilderHead', + fileName: 'PageBuilderHead', + }, + { + entry: './src/Modules/GrapesJS/resources/assets/entryBody.js', + name: 'PageBuilderBody', + fileName: 'PageBuilderBody', }, ]; diff --git a/dist/GrapesJS.js b/dist/GrapesJS.js deleted file mode 100644 index 21ceb48..0000000 --- a/dist/GrapesJS.js +++ /dev/null @@ -1,689 +0,0 @@ -$(document).ready(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"), f(); - }), w(), window.editor.on("run:open-sm", function(u) { - $(".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(u) { - $(".gjs-sm-sectors").parent().parent().css("display", "none"), $(".gjs-trt-traits").parent().parent().css("display", "block"); - }), window.editor.on("block:drag:start", function(u) { - w(); - }), window.editor.on("rteToolbarPosUpdate", function(u) { - !window.editor || !window.editor.getSelected() || !window.editor.getSelected().getEl() || setTimeout(function() { - let b = $(".gjs-rte-toolbar").first(); - if (b.offset().top < u.elementTop + 0.5 * u.elementHeight) { - let C = u.elementTop - b.height(); - C > 0 && b.css("top", C + "px"); - } - }, 0); - }); - function w() { - $(window).width() < 1e3 && ($("#gjs").addClass("sidebar-collapsed"), f()); - } - function f() { - window.editor.trigger("change:canvasOffset canvasScroll"); - } - let d = !1; - $(document).keydown(function(u) { - u.which === 8 && (d = !0); - }).keyup(function(u) { - u.which === 8 && (d = !1); - }), $(window).on("beforeunload", function(u) { - d && u.preventDefault(); - }); -}); -function I() { - $(".gjs-blocks-cs").prepend($("#block-search")); -} -window.addEventListener("message", W, !1); -function W(w) { - w.data === "page-loaded" ? ($("#phpb-loading").addClass("loaded"), I(), window.isLoaded = !0, $(window).trigger("pagebuilder-page-loaded")) : w.data === "touch-start" && window.touchStart(); -} -$(document).on("input", "#block-search input", function() { - let w = $(this).val().toLowerCase(); - $(".gjs-block-category").each(function() { - let f = !1; - $(this).find(".gjs-block").each(function() { - $(this).data("original-html") || $(this).data("original-html", $(this).html()); - let d = $(this).text(); - if (d.toLowerCase().includes(w)) { - $(this).removeClass("d-none"), f = !0; - let u = new RegExp("(" + w + ")", "gi"), o = d.replace(u, "$1"); - $(this).find(".gjs-block-label").html( - $(this).data("original-html").replace(d.trim(), o) - ); - } else - $(this).addClass("d-none"); - }), $(this).removeClass("d-none"), f || $(this).addClass("d-none"); - }); -}); -(function() { - window.customBuilderScripts = {}, window.editor.on("component:create", (f) => { - if (f.components().length) { - let d = f.components().models[f.components().length - 1]; - if (d.attributes.type === "script") { - let u = f.attributes.attributes["block-id"]; - u === void 0 && (u = f.attributes.attributes.id); - let o = d, b = !1; - for (; o.parent(); ) - if (o = o.parent(), o.attributes.attributes["phpb-content-container"]) { - b = !0; - break; - } - b && (window.customBuilderScripts[u] = d.toHTML(), d.remove()); - } - } - }), window.editor.on("component:add", function(f) { - if (f.attributes["run-builder-script"] !== void 0) { - let d = customBuilderScripts; - window.customBuilderScripts[f.attributes["block-id"]] = customBuilderScripts[f.attributes["run-builder-script"]], runScriptsOfComponentAndChildren(f), window.customBuilderScripts = d, delete f.attributes["run-builder-script"]; - } - }), window.editor.on("sorter:drag:end", function(f) { - let d = f.modelToDrop; - d && d.attributes && (d.attributes["block-id"] || d.attributes.id) && window.runScriptsOfComponentAndChildren(d); - for (let u in CKEDITOR.instances) - CKEDITOR.instances[u].destroy(!0); - }), window.runScriptsOfComponentAndChildren = function(f) { - w(f), f.components().each(function(d) { - runScriptsOfComponentAndChildren(d); - }); - }; - function w(f) { - let d = f.attributes["block-id"]; - if (d === void 0 && (d = f.attributes.attributes.id), d && window.customBuilderScripts[d] !== void 0) { - let u = f.attributes["style-identifier"], o = $("").append(window.customBuilderScripts[d]); - o.find("script").prepend("let inPageBuilder = true;"), o.find("script").prepend('let blockSelector = ".' + u + '";'), o.find("script").prepend('let block = document.getElementsByClassName("' + u + '")[0];'), o.find("script").prepend("(function(){"), o.find("script").append("})();"); - let b = document.createElement("script"); - b.type = "text/javascript", b.innerHTML = o.find("script").html(), window.editor.Canvas.getDocument().body.appendChild(b); - } - } -})(); -(function() { - function w() { - d(); - let t = document.createElement("script"); - t.type = "text/javascript", t.src = window.injectionScriptUrl; - let e = t.outerHTML + " - + customStyle(); ?> - @@ -30,7 +29,7 @@ require __DIR__ . '/pagebuilder.php'; ?> - + customScripts('body'); ?>