diff --git a/plugi-core/build.js b/plugi-core/build.js
index b78d448..1acec92 100644
--- a/plugi-core/build.js
+++ b/plugi-core/build.js
@@ -1,107 +1,299 @@
-import { build } from 'vite';
-import path from 'path';
-import { fileURLToPath } from 'url';
-import fs from 'fs';
+import fs from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { spawn } from 'node:child_process';
+import { rolldown } from 'rolldown';
+import * as sass from 'sass';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const isWatch = process.argv.includes('--watch') || process.argv.includes('-w');
+const isDev = isWatch || process.env.NODE_ENV === 'development';
-// libraries
-const libraries = [
- {
- entry: './src/Modules/WebsiteManager/resources/assets/entry.js',
- name: 'WebsiteManager',
- fileName: 'WebsiteManager',
- },
- {
- entry: './src/Modules/GrapesJS/resources/assets/entryHead.js',
- name: 'PageBuilderHead',
- fileName: 'PageBuilderHead',
- },
- {
- entry: './src/Modules/GrapesJS/resources/assets/entryBody.js',
- name: 'PageBuilderBody',
- fileName: 'PageBuilderBody',
- },
-];
+const GRAPES_JS_PATH = path.resolve(__dirname, 'node_modules/grapesjs/dist/grapes.min.js');
+const GRAPES_CSS_PATH = path.resolve(__dirname, 'node_modules/grapesjs/dist/css/grapes.min.css');
+const DIST_DIR = path.resolve(__dirname, 'dist');
+const DIST_PB_DIR = path.resolve(DIST_DIR, 'pagebuilder');
-// GrapesJS ships a pre-bundled Webpack bundle as its ESM entry (grapes.mjs).
-// Vite cannot re-bundle it correctly because the internal __webpack_require__
-// calls break when Vite replaces the module system. Use a custom plugin to
-// inject the raw GrapesJS UMD bundle and resolve the import to it.
-function grapesjsBundlePlugin() {
- const grapesMinPath = path.resolve(__dirname, 'node_modules/grapesjs/dist/grapes.min.js');
- const grapesMinContent = fs.readFileSync(grapesMinPath, 'utf-8');
-
- return [
- {
- name: 'grapesjs-resolve',
- resolveId(id, importer) {
- if (id === 'grapesjs') {
- return { id: '\0grapesjs-umd', moduleSideEffects: true };
- }
- return null;
- },
- load(id) {
- if (id === '\0grapesjs-umd') {
- // Return the UMD bundle as a raw module that sets window.grapesjs
- return `window.grapesjs = undefined;
-${grapesMinContent}
-var _grapesjs = window.grapesjs;
-export default _grapesjs;`;
- }
- return null;
- },
- // Prevent Rollup from trying to scan/transform this module
- moduleParsed(info) {
- if (info.id === '\0grapesjs-umd') {
- info.isEntry = false;
- }
- },
- },
- {
- name: 'grapesjs-output',
- renderChunk(code) {
- // The GrapesJS UMD bundle uses __webpack_modules__ which Rollup might rename.
- // We need to ensure the output preserves the Webpack bundle structure.
- return null;
- },
- },
- ];
+function ensureDirectories() {
+ fs.mkdirSync(DIST_DIR, { recursive: true });
+ fs.mkdirSync(DIST_PB_DIR, { recursive: true });
}
+function verifyPreconditions() {
+ if (!fs.existsSync(GRAPES_JS_PATH)) {
+ console.error(`\x1b[31mError:\x1b[0m GrapesJS JavaScript bundle not found at: ${GRAPES_JS_PATH}`);
+ console.error("Please run 'npm install' before building plugi-core.");
+ process.exit(1);
+ }
+ if (!fs.existsSync(GRAPES_CSS_PATH)) {
+ console.error(`\x1b[31mError:\x1b[0m GrapesJS CSS bundle not found at: ${GRAPES_CSS_PATH}`);
+ console.error("Please run 'npm install' before building plugi-core.");
+ process.exit(1);
+ }
+}
-// build
-libraries.forEach(async (libItem) => {
- await build({
- configFile: false,
- plugins: [grapesjsBundlePlugin()],
- build: {
- lib: libItem,
- emptyOutDir: false,
- minify: 'terser',
- terserOptions: {
- mangle: {
- // Reserve names that are used as globals in pagebuilder.php to prevent
- // the minifier from generating them as mangled variable names
- reserved: ['config', 'editor', 'window', 'document', 'console', 'CKEDITOR'],
- },
- compress: {
- // Preserve __webpack_* variable names used by the GrapesJS Webpack bundle
- keep_fargs: false,
- },
- format: {
- // Preserve __webpack_* variable names from being mangled
- keep_quoted_props: true,
- },
- },
- rollupOptions: {
- output: {
- assetFileNames: (assetInfo) => {
- if (assetInfo.name === 'style.css') return `${libItem.fileName}.css`;
- return assetInfo.name;
- },
- },
- },
- },
+function cleanObsoleteArtifacts() {
+ const obsoleteFiles = [
+ path.join(DIST_DIR, 'PageBuilderBody.css'),
+ path.join(DIST_DIR, 'PageBuilderBody.css.map'),
+ path.join(DIST_DIR, 'PageBuilderBody.umd.cjs'),
+ path.join(DIST_DIR, 'PageBuilderHead.umd.cjs'),
+ path.join(DIST_DIR, 'WebsiteManager.umd.cjs'),
+ path.join(DIST_PB_DIR, 'app.css'),
+ path.join(DIST_PB_DIR, 'app.css.map'),
+ path.join(DIST_PB_DIR, 'app.js'),
+ path.join(DIST_PB_DIR, 'app.js.map'),
+ ];
+
+ for (const file of obsoleteFiles) {
+ if (fs.existsSync(file)) {
+ try {
+ fs.unlinkSync(file);
+ } catch (e) {
+ // ignore
+ }
+ }
+ }
+}
+
+async function bundleJs(input, output, { minify = !isDev } = {}) {
+ const start = performance.now();
+ const bundle = await rolldown({ input });
+ await bundle.write({
+ file: output,
+ format: 'iife',
+ sourcemap: true,
+ minify,
});
-});
+ const duration = (performance.now() - start).toFixed(1);
+ const relOutput = path.relative(__dirname, output);
+ const size = (fs.statSync(output).size / 1024).toFixed(1);
+ console.log(` \x1b[32m✓\x1b[0m JS ${relOutput} (${size} kB, ${duration}ms)`);
+}
+
+function compileSass(input, output) {
+ const start = performance.now();
+ const result = sass.compile(input, {
+ style: 'compressed',
+ sourceMap: true,
+ });
+
+ let css = result.css;
+ const mapFileName = `${path.basename(output)}.map`;
+ css += `\n/*# sourceMappingURL=${mapFileName} */`;
+
+ fs.writeFileSync(output, css);
+ if (result.sourceMap) {
+ fs.writeFileSync(`${output}.map`, JSON.stringify(result.sourceMap));
+ }
+
+ const duration = (performance.now() - start).toFixed(1);
+ const relOutput = path.relative(__dirname, output);
+ const size = (fs.statSync(output).size / 1024).toFixed(1);
+ console.log(` \x1b[32m✓\x1b[0m Sass ${relOutput} (${size} kB, ${duration}ms)`);
+}
+
+function buildGrapesHead() {
+ const start = performance.now();
+
+ // 1. Copy GrapesJS minified script directly
+ const headJsOutput = path.join(DIST_DIR, 'PageBuilderHead.js');
+ fs.copyFileSync(GRAPES_JS_PATH, headJsOutput);
+
+ // 2. Concatenate GrapesJS core CSS and compiled custom SCSS
+ const headCssOutput = path.join(DIST_DIR, 'PageBuilderHead.css');
+ const grapesCss = fs.readFileSync(GRAPES_CSS_PATH, 'utf-8');
+ const customSassResult = sass.compile(
+ path.resolve(__dirname, 'src/Modules/GrapesJS/resources/assets/sass/app.scss'),
+ { style: 'compressed', sourceMap: true }
+ );
+
+ const combinedCss = `${grapesCss}\n${customSassResult.css}\n/*# sourceMappingURL=PageBuilderHead.css.map */`;
+ fs.writeFileSync(headCssOutput, combinedCss);
+
+ if (customSassResult.sourceMap) {
+ fs.writeFileSync(`${headCssOutput}.map`, JSON.stringify(customSassResult.sourceMap));
+ }
+
+ const duration = (performance.now() - start).toFixed(1);
+ const jsSize = (fs.statSync(headJsOutput).size / 1024).toFixed(1);
+ const cssSize = (fs.statSync(headCssOutput).size / 1024).toFixed(1);
+ console.log(` \x1b[32m✓\x1b[0m GJS dist/PageBuilderHead.js (${jsSize} kB) & .css (${cssSize} kB) (${duration}ms)`);
+}
+
+async function buildGrapesBody() {
+ await bundleJs(
+ path.resolve(__dirname, 'src/Modules/GrapesJS/resources/assets/js/app.js'),
+ path.join(DIST_DIR, 'PageBuilderBody.js'),
+ { minify: !isDev }
+ );
+}
+
+async function buildPageInjectionJs() {
+ await bundleJs(
+ path.resolve(__dirname, 'src/Modules/GrapesJS/resources/assets/js/page-injection.js'),
+ path.join(DIST_PB_DIR, 'page-injection.js'),
+ { minify: !isDev }
+ );
+}
+
+function buildPageInjectionCss() {
+ compileSass(
+ path.resolve(__dirname, 'src/Modules/GrapesJS/resources/assets/sass/page-injection.scss'),
+ path.join(DIST_PB_DIR, 'page-injection.css')
+ );
+}
+
+async function buildWebsiteManagerJs() {
+ await bundleJs(
+ path.resolve(__dirname, 'src/Modules/WebsiteManager/resources/assets/js/main.js'),
+ path.join(DIST_DIR, 'WebsiteManager.js'),
+ { minify: !isDev }
+ );
+}
+
+function runTailwindCli({ watch = false } = {}) {
+ const input = path.resolve(__dirname, 'src/Modules/WebsiteManager/resources/assets/css/style.css');
+ const output = path.join(DIST_DIR, 'WebsiteManager.css');
+ const tailwindBin = path.resolve(__dirname, 'node_modules/.bin/tailwindcss');
+
+ const args = ['-i', input, '-o', output];
+ if (!isDev) {
+ args.push('--minify');
+ }
+ if (watch) {
+ args.push('--watch');
+ }
+
+ if (watch) {
+ const child = spawn(tailwindBin, args, { stdio: 'inherit', cwd: __dirname });
+ return child;
+ }
+
+ return new Promise((resolve, reject) => {
+ const start = performance.now();
+ const child = spawn(tailwindBin, args, { stdio: 'pipe', cwd: __dirname });
+ let stderr = '';
+
+ child.stderr.on('data', (d) => {
+ stderr += d.toString();
+ });
+
+ child.on('close', (code) => {
+ if (code === 0) {
+ const duration = (performance.now() - start).toFixed(1);
+ const size = (fs.statSync(output).size / 1024).toFixed(1);
+ console.log(` \x1b[32m✓\x1b[0m CSS dist/WebsiteManager.css (${size} kB, ${duration}ms)`);
+ resolve();
+ } else {
+ console.error(`\x1b[31mError compiling Tailwind CSS:\x1b[0m\n${stderr}`);
+ reject(new Error(`Tailwind CLI exited with code ${code}`));
+ }
+ });
+ });
+}
+
+async function buildAll() {
+ const totalStart = performance.now();
+ console.log(`\n\x1b[1mBuilding plugi-core assets (${isDev ? 'development' : 'production'})...\x1b[0m`);
+
+ ensureDirectories();
+ verifyPreconditions();
+ cleanObsoleteArtifacts();
+
+ await Promise.all([
+ buildWebsiteManagerJs(),
+ runTailwindCli({ watch: false }),
+ buildGrapesHead(),
+ buildGrapesBody(),
+ buildPageInjectionJs(),
+ buildPageInjectionCss(),
+ ]);
+
+ const totalDuration = (performance.now() - totalStart).toFixed(1);
+ console.log(`\x1b[32m✨ Build finished successfully in ${totalDuration}ms.\x1b[0m\n`);
+}
+
+function startWatch() {
+ const tailwindProcess = runTailwindCli({ watch: true });
+
+ const srcDir = path.resolve(__dirname, 'src');
+ console.log(`\x1b[36mWatching for changes in ${srcDir}...\x1b[0m\n`);
+
+ let debounceTimer = null;
+ const changedPaths = new Set();
+
+ function triggerRebuild() {
+ const paths = Array.from(changedPaths);
+ changedPaths.clear();
+
+ const tasks = [];
+ let rebuildWmJs = false;
+ let rebuildPbBody = false;
+ let rebuildPbHead = false;
+ let rebuildInjJs = false;
+ let rebuildInjCss = false;
+
+ for (const p of paths) {
+ const normalized = p.replace(/\\/g, '/');
+ if (normalized.includes('WebsiteManager/resources/assets/js/')) {
+ rebuildWmJs = true;
+ }
+ if (normalized.includes('GrapesJS/resources/assets/js/page-injection.js')) {
+ rebuildInjJs = true;
+ } else if (normalized.includes('GrapesJS/resources/assets/js/')) {
+ rebuildPbBody = true;
+ }
+ if (normalized.includes('GrapesJS/resources/assets/sass/page-injection.scss')) {
+ rebuildInjCss = true;
+ } else if (normalized.includes('GrapesJS/resources/assets/sass/')) {
+ rebuildPbHead = true;
+ }
+ }
+
+ if (rebuildWmJs) tasks.push(buildWebsiteManagerJs());
+ if (rebuildPbBody) tasks.push(buildGrapesBody());
+ if (rebuildPbHead) tasks.push(Promise.resolve(buildGrapesHead()));
+ if (rebuildInjJs) tasks.push(buildPageInjectionJs());
+ if (rebuildInjCss) tasks.push(Promise.resolve(buildPageInjectionCss()));
+
+ if (tasks.length > 0) {
+ Promise.all(tasks).catch((err) => {
+ console.error('\x1b[31mRebuild error:\x1b[0m', err);
+ });
+ }
+ }
+
+ const watcher = fs.watch(srcDir, { recursive: true }, (eventType, filename) => {
+ if (!filename) return;
+ changedPaths.add(filename);
+ clearTimeout(debounceTimer);
+ debounceTimer = setTimeout(triggerRebuild, 50);
+ });
+
+ const cleanup = () => {
+ console.log('\nStopping watchers...');
+ if (tailwindProcess) tailwindProcess.kill();
+ watcher.close();
+ process.exit(0);
+ };
+
+ process.on('SIGINT', cleanup);
+ process.on('SIGTERM', cleanup);
+}
+
+if (isWatch) {
+ buildAll()
+ .then(() => {
+ startWatch();
+ })
+ .catch((err) => {
+ console.error('\x1b[31mBuild failed:\x1b[0m', err);
+ process.exit(1);
+ });
+} else {
+ buildAll().catch((err) => {
+ console.error('\x1b[31mBuild failed:\x1b[0m', err);
+ process.exit(1);
+ });
+}
diff --git a/plugi-core/dist/PageBuilderBody.css b/plugi-core/dist/PageBuilderBody.css
deleted file mode 100644
index 00edc56..0000000
--- a/plugi-core/dist/PageBuilderBody.css
+++ /dev/null
@@ -1 +0,0 @@
-html,body,#gjs{height:100%!important;margin:0;overflow:hidden}*{box-shadow:none!important}.form-control,.form-control:focus{color:#e1e1e1}.cursor-pointer{cursor:pointer}.gjs-editor{font-size:.9rem}.toast{opacity:1!important;border:none;right:15px;box-shadow:none}.toast.toast-success{background:#2dc837}#phpb-loading{position:absolute;height:100%;width:100%;background-color:#fff;z-index:10000;transition:opacity .3s,visibility .3s}#phpb-loading.loaded{visibility:hidden;opacity:0}#phpb-loading .circle{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:150px;height:150px}#phpb-loading .circle .text{font-size:20px;margin:20px -30px 0;text-align:center;color:#0091d1}#phpb-loading .loader{width:calc(100% + -0px);height:calc(100% + -0px);border:8px solid #0091d1;border-top:8px solid #004a6c;border-radius:50%;animation:rotate 5s linear infinite}@keyframes rotate{to{transform:rotate(360deg)}}.btn.focus,.btn:focus{box-shadow:none}.gjs-cv-canvas{height:100%;top:0;width:calc(100% - 325px)}.gjs-toolbar{z-index:100!important}.gjs-pn-panel{padding:0}.gjs-pn-panel .gjs-pn-buttons{justify-content:center}.gjs-pn-commands,.gjs-pn-options,.gjs-pn-devices-c{display:none}.gjs-devices-c{padding:0}.gjs-one-bg{background-color:#313844;border-bottom:none;color:#c4c7ce}.gjs-two-color,.gjs-four-color,.gjs-four-color-h:hover{color:#e1e1e1}.gjs-pn-commands{width:100%;box-shadow:none}::-webkit-scrollbar{width:7px;height:7px}::-webkit-scrollbar-track{background:#313844!important}::-webkit-scrollbar-thumb{background-color:#a5acb9!important;border-radius:3px}::-webkit-scrollbar-thumb:hover{background-color:#0091d1!important}.gjs-pn-views{top:40px}.gjs-pn-views .gjs-pn-btn{width:33.33%;margin-right:0;padding:16px 15px;border-radius:0;background:#3a3f4a;color:#e3e3e3;border-bottom:1px solid #3a3f4a;font-size:16px}.gjs-pn-views .gjs-pn-btn.gjs-pn-active{padding:15px;background-color:#515664;border-bottom-left-radius:unset;border-bottom-right-radius:unset;box-shadow:none;color:#fff;border-bottom:3px solid #0091d1}.gjs-pn-options{right:0}.gjs-pn-views,.gjs-pn-views-container{left:0;box-shadow:none;width:325px;padding-bottom:0;margin-bottom:0;margin-left:0;margin-right:0;padding-left:0;padding-right:0}.gjs-pn-views-container{padding-top:89px;background:#22272e;height:calc(100% - 40px);overflow:hidden}.gjs-pn-views-container>div:first-of-type{margin-top:44px}.gjs-pn-views-container>div{height:100%;overflow-y:auto}.gjs-pn-views-container>div>div{background:#22272e;border:none}.gjs-cv-canvas,.gjs-pn-devices-c{left:325px}.gjs-pn-panel #gjs-sm-caret{padding-right:0!important}.gjs-pn-panel .fa-caret-down{margin-right:5px!important}.gjs-pn-panel .fa-caret-right{margin-right:8px!important}.gjs-three-bg{background-color:#0091d1}.gjs-clm-tags #gjs-clm-close,.gjs-clm-tags #gjs-clm-checkbox{color:#fff}.gjs-field{background-color:#22272e;border-radius:0;padding:2px}.gjs-field input,.gjs-field select,.gjs-field textarea{padding:5px}.gjs-field .gjs-d-s-arrow{border-top:4px solid rgb(100,100,100)}#sidebar-header{position:absolute;box-shadow:none;width:325px;padding-bottom:0;margin-bottom:0;margin-left:0;margin-right:0;padding-left:0;padding-right:0;background:#22272e;height:40px;z-index:100}#sidebar-header #language-selector{float:right}#sidebar-header #language-selector .dropdown-item.active,#sidebar-header #language-selector .dropdown-item:active{background:#22272e!important}#sidebar-header #language-selector .dropdown-menu.show{padding:0}#sidebar-header #language-selector .dropdown-toggle{margin-top:2px;color:#fff!important;background:none!important;border:none;box-shadow:none;outline:none!important}#sidebar-header #language-selector .flag-icon{background-size:contain;background-position:50%;background-repeat:no-repeat;position:relative;display:inline-block;width:1.33333333em;height:12px;line-height:1em}#toggle-sidebar{position:absolute;left:0;top:0;z-index:100;color:#c4c7ce;background:#22272e;border-radius:0;transition-duration:unset}#block-search{position:fixed;background:#22272e;border-color:#3a3f4a;border-radius:0;width:325px;margin-top:-44px}#block-search i.fa-search{position:absolute;top:14px;left:9px;font-size:15px;color:#515664}#block-search input{background:#181b1e;padding:22px 20px 22px 30px;border-radius:0;border:none}#block-search input::-moz-placeholder{color:#515664}#block-search input::placeholder{color:#515664}.gjs-block{border:none;box-shadow:none;padding-bottom:8px;margin:5px;width:calc(50% - 10px)}.gjs-block.fa{padding:8px}.gjs-block:hover{color:#0091d1!important}.gjs-block .block-thumb{height:70px;overflow:hidden;margin-bottom:5px;opacity:.8}.gjs-block .block-thumb img{width:100%}.gjs-blocks-c{background:#22272e;padding:4px}.gjs-block-categories{background:#22272e;padding-bottom:45px}.gjs-block-label{font-size:.8rem;height:100%;display:grid}.gjs-block-label b{display:contents;font-weight:800}.gjs-block-category{background:#5a6371}.gjs-block-category.gjs-open{border-bottom:none!important;margin-bottom:10px}.gjs-blocks-cs{border-bottom:none!important}.gjs-layer .gjs-layer-title{background:#5a6371!important}.gjs-layer.gjs-selected .gjs-layer-title{background-color:#0091d1!important}.gjs-layer.gjs-hovered .gjs-layer-title{background-color:#0091d170!important}.gjs-category-title,.gjs-sm-sector .gjs-sm-title,.gjs-clm-tags .gjs-sm-title,.gjs-block-category .gjs-title,.gjs-layer-title{background:#424853!important;border-bottom:2px solid #363d48!important;letter-spacing:0;font-size:16px;font-weight:400}.gjs-sm-sector.gjs-sm-open .gjs-sm-title,.gjs-clm-tags.gjs-open .gjs-sm-title,.gjs-block-category.gjs-open .gjs-title{background:#545d6c!important}.gjs-layer-name{padding-top:2px;padding-bottom:13px}.gjs-layer-count{display:none}.gjs-layer-vis{padding-top:11px}.gjs-sm-sector.gjs-sm-open{border-bottom:1px solid rgba(0,0,0,.1)}.gjs-trt-trait{display:block}.gjs-trt-header{font-weight:400}.gjs-trt-trait .gjs-label,.gjs-trt-trait .gjs-field{width:100%}.gjs-field-checkbox{height:17px!important;width:17px!important}.gjs-traits-label{font-weight:400;font-size:16px;border-bottom:none}.gjs-sm-sector #gjs-sm-caret,.gjs-clm-tags #gjs-sm-caret{font-size:initial}.gjs-trt-traits .gjs-label-wrp{width:100%}.gjs-trt-traits p.no-settings{padding-top:10px;padding-bottom:10px}.gjs-trt-trait__wrp:first-of-type{padding-top:8px}.gjs-trt-trait__wrp:last-of-type{padding-bottom:8px}.gjs-trt-trait{padding-bottom:10px}.gjs-trt-trait .gjs-field-image{background:none;padding:0}.gjs-trt-trait .gjs-field-image .image__preview-container{text-align:center}.gjs-trt-trait .gjs-field-image .image__preview-container .image__remove-button{position:absolute;right:0;top:0;border-radius:0;background-color:#e9eef2;border-color:#e9eef2;color:#515664;padding:2px 6px}.gjs-trt-trait .gjs-field-image .image__preview-container img{max-width:100%;max-height:150px}#sidebar-bottom-buttons{position:absolute;left:0;bottom:0;height:40px;width:325px;margin:0;padding:0;box-shadow:none;background:#474c57;border-top:none}#sidebar-bottom-buttons button,#sidebar-bottom-buttons a{float:right;height:100%;width:33.33%;border-left:1px solid #343944;border-radius:0;color:#e3e3e3;font-size:15px;padding:8px 0}#sidebar-bottom-buttons button:hover,#sidebar-bottom-buttons a:hover{background:#017eb5;color:#fff}#sidebar-bottom-buttons button:last-child,#sidebar-bottom-buttons a:last-child{border-left:none}#sidebar-bottom-buttons button.waiting{background:#0091d1;color:#fff!important}#sidebar-bottom-buttons button.waiting i.fa{display:none}#sidebar-bottom-buttons #go-back:hover{background:#b03541}#sidebar-bottom-buttons #save-page:hover{background:#419147}.gjs-field{background-color:#22272e}.gjs-field select option{background-color:#fff;color:#000}.gjs-input-unit,.gjs-field-arrows,.gjs-sm-field select.gjs-input-unit{color:#e1e1e1}.gjs-sm-field select.gjs-input-unit option{background-color:#22272e;color:#fff}.gjs-field-arrow-d{border-top:4px solid #e1e1e1}.gjs-field-arrow-u{border-bottom:4px solid #e1e1e1}.gjs-field-radio{padding:0!important}.gjs-radio-item .gjs-radio-item-label{padding-top:10px;margin-bottom:0;padding-bottom:10px;width:100%}.gjs-radio-item input:checked+.gjs-radio-item-label{background-color:#545d6c}.gjs-sm-header,.gjs-trt-header{font-weight:400;color:#8c909d}.gjs-clm-tags{width:100%;padding-top:0;padding-bottom:0}.gjs-clm-tags #gjs-clm-status-c,.gjs-clm-tags #gjs-clm-sel-help{display:none}.gjs-clm-tags #gjs-clm-new{color:#e1e1e1}.gjs-clm-tags #gjs-clm-add-tag{background-color:#0091d1;border:none;box-shadow:1px 1px #fff3 inset;color:#fff}.gjs-clm-tags #gjs-clm-add-tag:hover{background-color:#004a6c}.gjs-sm-sectors .gjs-four-color,.gjs-sm-sectors .gjs-color-warn{color:#e1e1e1}.gjs-sm-sectors .gjs-sm-field.gjs-sm-composite{background-color:#c3e2ec24;border:1px solid rgba(121,147,155,.14)}.gjs-sm-sectors .gjs-sm-layers{background-color:#3a3f4a}.gjs-sm-sectors .gjs-sm-layers .gjs-sm-btn{background:#fff;color:#000;text-shadow:none}.gjs-sm-sectors .gjs-sm-layers .gjs-field{padding:0;background-color:#3a3f4a}.gjs-sm-sectors .gjs-sm-layers .gjs-field select{color:#fff;background:#424853}.gjs-sm-sectors .gjs-sm-stack #gjs-sm-add{color:#fff}.gjs-sm-sectors .gjs-sm-stack #gjs-sm-add:hover{color:#aaa}.gjs-am-assets-header{display:none}.gjs-am-assets-cont{background:none;padding-top:0}.gjs-am-assets{height:325px}.gjs-am-asset{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.gjs-btn-prim{display:inline-block;margin-top:10px;padding:.375rem .75rem;font-weight:400;text-align:center;vertical-align:middle;-webkit-user-select:none;-moz-user-select:none;user-select:none;font-size:1rem;line-height:1.5;border-radius:.25rem;transition:color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;color:#fff;border:1px solid #0091d1;background-color:#0091d1}.gjs-am-add-asset button{float:left;width:auto}.gjs-am-add-asset .gjs-am-add-field{width:100%}.gjs-am-file-uploader>form{background-color:#c3e2ec24;border:2px dashed rgb(189,194,200)}.gjs-am-file-uploader #gjs-am-title{color:#7e8793;text-shadow:none}.cke_dialog_body .cke_dialog_ui_vbox_child{padding:0}.cke_dialog_body input.cke_dialog_ui_input_text,.cke_dialog_body input.cke_dialog_ui_input_password,.cke_dialog_body input.cke_dialog_ui_input_tel,.cke_dialog_body textarea.cke_dialog_ui_input_textarea,.cke_dialog_body div.cke_dialog_ui_input_select{margin-bottom:10px}.cke_dialog_body .cke_dialog_ui_input_select{width:100%!important}.sidebar-collapsed .gjs-cv-canvas{width:calc(100% + -0px)}.sidebar-collapsed .gjs-pn-panels{display:none}.sidebar-collapsed .gjs-cv-canvas,.sidebar-collapsed .gjs-pn-devices-c{left:0}.sidebar-collapsed #toggle-sidebar{padding:14px 18px;font-size:18px;box-shadow:2px 3px 10px 2px #0000004d;border-bottom-right-radius:4px}html,body{overflow-x:initial!important}form{-webkit-margin-after:0;margin-block-end:0}[data-cursor=default]{cursor:default}[data-cursor=text]{cursor:text}span[draggable=true]{display:inline-flex}[phpb-hide-if-not-editable]{background:rgba(253,227,193,.4901960784);border:1px dashed rgba(185,142,87,.4901960784);padding:7px;font-size:1.1rem;font-style:italic;font-weight:400;text-align:center;color:#5e5e5e}[phpb-hide-if-not-editable]:not(.editable){display:none}[data-gjs-type].gjs-comp-selected{outline:1px solid #0091d1!important;outline-offset:0!important}div[data-gjs-type].gjs-comp-selected{outline:1px solid #0091d1!important;outline-offset:-1px!important}[phpb-content-container],[phpb-blocks-container]{min-height:50px;width:100%}[phpb-blocks-container]{border:1px dashed #0091d1}html ::-webkit-scrollbar,body ::-webkit-scrollbar{width:11px;height:11px}html ::-webkit-scrollbar-track,body ::-webkit-scrollbar-track{background:#f5f5f5}html ::-webkit-scrollbar-thumb,body ::-webkit-scrollbar-thumb{background-color:#ccc}html ::-webkit-scrollbar-thumb:hover,body ::-webkit-scrollbar-thumb:hover{background-color:#bbb}.gjs-waiting{opacity:.5;pointer-events:none}
diff --git a/plugi-core/dist/PageBuilderBody.js b/plugi-core/dist/PageBuilderBody.js
index e8959ec..f691c2a 100644
--- a/plugi-core/dist/PageBuilderBody.js
+++ b/plugi-core/dist/PageBuilderBody.js
@@ -1,1174 +1,2 @@
-$(".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");
- triggerEditorResize();
-});
-autoCollapseSidebar();
-window.editor.on("run:open-sm", function(editor2) {
- $(".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(editor2) {
- $(".gjs-sm-sectors").parent().parent().css("display", "none");
- $(".gjs-trt-traits").parent().parent().css("display", "block");
-});
-window.editor.on("block:drag:start", function(block) {
- autoCollapseSidebar();
-});
-window.editor.on("rteToolbarPosUpdate", function(toolbarPosition) {
- if (!window.editor || !window.editor.getSelected())
- return;
- let selectedDomComponent = window.editor.getSelected().getEl();
- if (!selectedDomComponent)
- return;
- setTimeout(function() {
- let $toolbar = $(".gjs-rte-toolbar").first();
- let toolbarInUpperHalf = $toolbar.offset().top < toolbarPosition.elementTop + 0.5 * toolbarPosition.elementHeight;
- if (toolbarInUpperHalf) {
- let newTop = toolbarPosition.elementTop - $toolbar.height();
- if (newTop > 0) {
- $toolbar.css("top", newTop + "px");
- }
- }
- }, 0);
-});
-function autoCollapseSidebar() {
- if ($(window).width() < 1e3) {
- $("#gjs").addClass("sidebar-collapsed");
- triggerEditorResize();
- }
-}
-function triggerEditorResize() {
- window.editor.trigger("change:canvasOffset canvasScroll");
-}
-let backspaceIsPressed = false;
-$(document).keydown(function(event) {
- if (event.which === 8)
- backspaceIsPressed = true;
-}).keyup(function(event) {
- if (event.which === 8)
- backspaceIsPressed = false;
-});
-$(window).on("beforeunload", function(event) {
- if (backspaceIsPressed)
- event.preventDefault();
-});
-function addBlockSearch() {
- $(".gjs-blocks-cs").prepend($("#block-search"));
-}
-window.addEventListener("message", onMessage, false);
-function onMessage(event) {
- if (event.data === "page-loaded") {
- $("#phpb-loading").addClass("loaded");
- addBlockSearch();
- window.isLoaded = true;
- $(window).trigger("pagebuilder-page-loaded");
- } else if (event.data === "touch-start") {
- window.touchStart();
- }
-}
-$(document).on("input", "#block-search input", function() {
- let term = $(this).val().toLowerCase();
- $(".gjs-block-category").each(function() {
- let atLeastOneMatch = false;
- $(this).find(".gjs-block").each(function() {
- if (!$(this).data("original-html")) {
- $(this).data("original-html", $(this).html());
- }
- let label = $(this).text();
- if (label.toLowerCase().includes(term)) {
- $(this).removeClass("d-none");
- atLeastOneMatch = true;
- let regEx = new RegExp("(" + term + ")", "gi");
- let highlightedText = label.replace(regEx, "$1");
- $(this).find(".gjs-block-label").html(
- $(this).data("original-html").replace(label.trim(), highlightedText)
- );
- } else {
- $(this).addClass("d-none");
- }
- });
- $(this).removeClass("d-none");
- if (!atLeastOneMatch) {
- $(this).addClass("d-none");
- }
- });
-});
-window.customBuilderScripts = {};
-window.editor.on("component:create", (component) => {
- if (component.components().length) {
- let lastChild = component.components().models[component.components().length - 1];
- if (lastChild.attributes.type === "script") {
- let blockId = component.attributes.attributes["block-id"];
- if (blockId === void 0) {
- blockId = component.attributes.attributes["id"];
- }
- let rootComponent = lastChild;
- let insideEditablePartOfPage = false;
- while (rootComponent.parent()) {
- rootComponent = rootComponent.parent();
- if (rootComponent.attributes.attributes["phpb-content-container"]) {
- insideEditablePartOfPage = true;
- break;
- }
- }
- if (insideEditablePartOfPage) {
- window.customBuilderScripts[blockId] = lastChild.toHTML();
- lastChild.remove();
- }
- }
- }
-});
-window.editor.on("component:add", function(component) {
- if (component.attributes["run-builder-script"] !== void 0) {
- let originalCustomBuilderScripts = customBuilderScripts;
- window.customBuilderScripts[component.attributes["block-id"]] = customBuilderScripts[component.attributes["run-builder-script"]];
- runScriptsOfComponentAndChildren(component);
- window.customBuilderScripts = originalCustomBuilderScripts;
- delete component.attributes["run-builder-script"];
- }
-});
-window.editor.on("sorter:drag:end", function(event) {
- let component = event.modelToDrop;
- if (component && component.attributes && (component.attributes["block-id"] || component.attributes["id"])) {
- window.runScriptsOfComponentAndChildren(component);
- }
- for (let instanceName in CKEDITOR.instances) {
- CKEDITOR.instances[instanceName].destroy(true);
- }
-});
-window.runScriptsOfComponentAndChildren = function(component) {
- runComponentScript(component);
- component.components().each(function(child) {
- runScriptsOfComponentAndChildren(child);
- });
-};
-function runComponentScript(component) {
- let blockId = component.attributes["block-id"];
- if (blockId === void 0) {
- blockId = component.attributes.attributes["id"];
- }
- if (blockId && window.customBuilderScripts[blockId] !== void 0) {
- let styleIdentifier = component.attributes["style-identifier"];
- let $scriptTag = $("").append(window.customBuilderScripts[blockId]);
- $scriptTag.find("script").prepend("let inPageBuilder = true;");
- $scriptTag.find("script").prepend('let blockSelector = ".' + styleIdentifier + '";');
- $scriptTag.find("script").prepend('let block = document.getElementsByClassName("' + styleIdentifier + '")[0];');
- $scriptTag.find("script").prepend("(function(){");
- $scriptTag.find("script").append("})();");
- let scriptTag = document.createElement("script");
- scriptTag.type = "text/javascript";
- scriptTag.innerHTML = $scriptTag.find("script").html();
- window.editor.Canvas.getDocument().body.appendChild(scriptTag);
- }
-}
-function afterGrapesJSLoaded() {
- addThemeBlocks();
- let scriptTag = document.createElement("script");
- scriptTag.type = "text/javascript";
- scriptTag.src = window.injectionScriptUrl;
- let fullScript = scriptTag.outerHTML + "';\n window.initialComponents = window.initialComponents.replace('