Powerful and easy to use cms to build websites, blogs or ecommerce stores.
HTML backendblogblog-engineblog-platformbloggingcmscontent-managementcontent-management-systemecommerceecommerce-platformno-codepage-builderphpphp-cmsphp7php8self-hostedshopping-cartweb-applicationwebsite-builder
VvvebJs updates
givanz91edd40adfd5
diff --git a/public/css/vvvebjs-editor-helpers.css b/public/css/vvvebjs-editor-helpers.cssindex 41ae782..dc67d44 100755--- a/public/css/vvvebjs-editor-helpers.css+++ b/public/css/vvvebjs-editor-helpers.css@@ -80,6 +80,39 @@ Prevents iframe mouse events that prevents clicking on the component.vvveb-hidden {display: none !important; }+body.vvveb-hidden {+ display: unset !important;+}+body.vvveb-hidden .vvveb-hidden, body.vvveb-hidden .d-none, body.vvveb-hidden .invisible {+ display: unset !important;+ visibility: visible !important;+ overflow: hidden;+ position: relative;+}+body.vvveb-hidden .vvveb-hidden::after, body.vvveb-hidden .d-none::after, body.vvveb-hidden .invisible::after {+ content: "Hidden";+ position: absolute;+ left: 0px;+ top: 0px;+ width: 100%;+ height: 100%;+ padding-top: 5px;+ font-weight: 600;+ font-size: 12px;+ text-align: center;+ background: rgba(252, 252, 252, 0.85);+ background: rgba(var(--bs-body-bg-rgb), 0.85);+ border: 1px dashed #999;+ border: 1px dashed var(--bs-border-color);+ overflow: hidden;+ display: flex;+ align-items: center;+ justify-content: center;+}+body.vvveb-hidden .vvveb-hidden:hover::after, body.vvveb-hidden .d-none:hover::after, body.vvveb-hidden .invisible:hover::after {+ display: none;+}+section .container div > .row > [class*="col-"]:empty,section .container div > .row > .col:empty,section .container > .row > [class*="col-"]:empty,@@ -91,7 +124,6 @@ section .container-fluid > .row > .col:empty {min-height: 200px;outline: 1px solid var(--bs-border-color);outline-offset: -0.5rem;- margin: 0.5rem;display: flex; }section .container div > .row > [class*="col-"]:empty:after,section .container div > .row > .col:empty:after,@@ -121,3 +153,43 @@ section:hover .container-fluid > .row > .col {.row:hover > .col {outline: 1px dashed rgba(var(--bs-success-rgb), 0.35);outline-offset: -2px; }+++#vvvebjs-new-section {+ background:rgba(248, 249, 250);+ background:var(--bs-tertiary-bg);+ display:block;+}++#vvvebjs-new-section .container,+#vvvebjs-new-section .row,+#vvvebjs-new-section .col {+ padding:1rem;+ justify-content: center;+}++#vvvebjs-new-section .col {+ justify-content: center;+ display:flex;+ flex-wrap: wrap;+ width:100%;+ background:#fff;+ background:var(--bs-body-bg);+ border:1px dashed #ccc;+}+++#vvvebjs-new-section button {+ margin: 0.5rem;+ background: #0030C0;+ padding: 0.4rem 2.5rem;+ color: #fff;+ font-size: 14px;+ border-radius: 3px;+ border-color: #0030C0;+ border-width: 1px;+}++#vvvebjs-new-section button:hover {+ /*background:#333;*/+}diff --git a/public/js/vvvebjs/builder.js b/public/js/vvvebjs/builder.jsindex 0351cf0..64ef842 100755--- a/public/js/vvvebjs/builder.js+++ b/public/js/vvvebjs/builder.js@@ -363,58 +363,17 @@ Vvveb.Components = {//return false;},- render: function(type, panel = false) {-- let component = this._components[type];- if (!component) return;-- if (!panel) {- //panel = document.querySelector(this.componentPropertiesElement);- panel = this.componentPropertiesElement;- }-- let defaultSection = this.componentPropertiesDefaultSection;- let componentsPanelSections = {};-- document.querySelectorAll(panel + " .tab-pane").forEach((el, i) => {- let sectionName = el.dataset.section;- componentsPanelSections[sectionName] = el;- for (const item of el.querySelectorAll(- 'label:not([data-header="default"]) + input,' +- 'label:not([data-header="default"]),' +- '.section:not([data-section="default"])'- )) {- item.remove();- }- });-- let section = componentsPanelSections[defaultSection].querySelector('.section[data-section="default"]');-- if (!(Vvveb.preservePropertySections && section)) {- let template = tmpl("vvveb-input-sectioninput", {key:"default", header:component.name});-- componentsPanelSections[defaultSection].replaceChildren();- componentsPanelSections[defaultSection].append(generateElements(template)[0]);-- section = componentsPanelSections[defaultSection].querySelector(".section");- }-- componentsPanelSections[defaultSection].querySelector('[data-header="default"] span').innerHTML = component.name;- section.replaceChildren();-- if (component.beforeInit) component.beforeInit(Vvveb.Builder.selectedEl);-- let element;-+ renderProperties: function(component, properties, componentsPanelSections, container) {let fn = function(component, property) {if (property.input) {property.input.addEventListener('propertyChange', (event) => {element = selectedElement = Vvveb.Builder.selectedEl;let value = event.detail.value, input = event.detail.input, origEvent = event.detail.origEvent;+ if (property.element) element = property.element;if (property.child) element = element.querySelector(property.child);if (property.parent) element = element.parent(property.parent);-+if (property.onChange) {let ret = property.onChange(element, value, input, component, origEvent);//if on change returns an object then is returning the dom node otherwise is returning the new value@@ -425,9 +384,11 @@ Vvveb.Components = {}}/* else */if (property.htmlAttr) {- oldValue = element.getAttribute(property.htmlAttr);+ let oldValue;if (property.htmlAttr == "class" && property.validValues) {+ oldValue = element.getAttribute(property.htmlAttr);+if (property.validValues) {element.classList.remove(...property.validValues.filter(v => v));}@@ -440,10 +401,16 @@ Vvveb.Components = {oldStyle = window.FrameDocument.getElementById("vvvebjs-styles").textContent;element = Vvveb.StyleManager.setStyle(element, property.key, value);} else if (property.htmlAttr == "innerHTML") {+ oldValue = element.innerHTML;element = Vvveb.ContentManager.setHtml(element, value);+ } else if (property.htmlAttr == "outerHTML") {+ oldValue = element.outerHTML;+ element = Vvveb.ContentManager.setHtml(element, value, true);} else if (property.htmlAttr == "innerText") {+ oldValue = element.innerText;element = Vvveb.ContentManager.setText(element, value);} else {+ oldValue = element.getAttribute(property.htmlAttr);//if value is empty then remove attribute useful for attributes without values like disabledif (value) {element.setAttribute(property.htmlAttr, value);@@ -467,12 +434,12 @@ Vvveb.Components = {target: element,attributeName: property.htmlAttr,oldValue: oldValue,- newValue: element.getAttribute(property.htmlAttr)+ newValue: value});}}- if (component.onChange) {+ if (component && component.onChange) {element = component.onChange(element, property, value, input);}@@ -487,19 +454,26 @@ Vvveb.Components = {}return property.input;- };-+ };++ let element;+ let defaultSection = this.componentPropertiesDefaultSection;+ let section;+ if (componentsPanelSections) {+ section = componentsPanelSections[defaultSection].querySelector('.section[data-section="default"]');+ }let nodeElement = Vvveb.Builder.selectedEl;-- for (let i in component.properties) {- let property = component.properties[i];++ for (let i in properties) {+ let property = properties[i];let element = nodeElement;if (property.beforeInit) property.beforeInit(element);+ if (property.element) element = property.element;if (property.child) element = element.querySelector(property.child) ?? element;if (property.parent) element = element.closest(property.parent) ?? element;-+if (property.data) {property.data["key"] = property.key;} else {@@ -520,6 +494,8 @@ Vvveb.Components = {} elseif (property.htmlAttr == "innerHTML") {value = Vvveb.ContentManager.getHtml(element);+ } else if (property.htmlAttr == "outerHTML") {+ value = Vvveb.ContentManager.getHtml(element, true);} else if (property.htmlAttr == "innerText") {value = Vvveb.ContentManager.getText(element);} else {@@ -572,7 +548,11 @@ Vvveb.Components = {else {let row = generateElements(tmpl('vvveb-property', property))[0];row.querySelector('.input').append(property.input);- section.append(row);+ if (container) {+ container.append(row);+ } else {+ section.append(row);+ }}if (property.inputtype.afterInit) {@@ -583,8 +563,52 @@ Vvveb.Components = {property.afterInit(element, property.input);}}+ },++ render: function(type, panel = false) {- if (component.init) component.init(nodeElement);+ let component = this._components[type];+ if (!component) return;++ if (!panel) {+ //panel = document.querySelector(this.componentPropertiesElement);+ panel = this.componentPropertiesElement;+ }++ let defaultSection = this.componentPropertiesDefaultSection;+ let componentsPanelSections = {};++ document.querySelectorAll(panel + " .tab-pane").forEach((el, i) => {+ let sectionName = el.dataset.section;+ componentsPanelSections[sectionName] = el;+ for (const item of el.querySelectorAll(+ 'label:not([data-header="default"]) + input,' ++ 'label:not([data-header="default"]),' ++ '.section:not([data-section="default"])'+ )) {+ item.remove();+ }+ });++ let section = componentsPanelSections[defaultSection].querySelector('.section[data-section="default"]');++ if (!(Vvveb.preservePropertySections && section)) {+ let template = tmpl("vvveb-input-sectioninput", {key:"default", header:component.name});++ componentsPanelSections[defaultSection].replaceChildren();+ componentsPanelSections[defaultSection].append(generateElements(template)[0]);++ section = componentsPanelSections[defaultSection].querySelector(".section");+ }++ componentsPanelSections[defaultSection].querySelector('[data-header="default"] span').innerHTML = component.name;+ section.replaceChildren();++ if (component.beforeInit) component.beforeInit(Vvveb.Builder.selectedEl);++ this.renderProperties(component, component.properties, componentsPanelSections);++ if (component.init) component.init(Vvveb.Builder.selectedEl);}};@@ -624,6 +648,14 @@ Vvveb.Styles = {get: function(type) {return this._styles[type];},++ getByStyle: function(style) {+ for (const name in this._styles) {+ if (this._styles[name].style == style) {+ return name;+ }+ }+ },add: function(type, data) {data.type = type;@@ -1057,10 +1089,10 @@ Vvveb.Builder = {for (i in styles) {const styleType = styles[i];- const style = Vvveb.Blocks.get(styleType);+ const style = Vvveb.Styles.get(styleType);if (style) {- item = generateElements(`<li data-section="${group}" data-drag-type="style" data-type="${styleType}" data-search="${style.name.toLowerCase()}">+ item = generateElements(`<li data-section="${group}" data-type="${styleType}" data-search="${style.name.toLowerCase()}"><span class="name">${style.name}</span><img class="preview" src="" loading="lazy"></li>`)[0];@@ -1173,6 +1205,8 @@ Vvveb.Builder = {window.dispatchEvent(new CustomEvent("vvveb.iframe.loaded", {detail: self.frameDoc}));document.querySelector(".loading-message").classList.remove("active");+ Vvveb.NewSection.init();+ Vvveb.StyleList.load(self.frameDoc);//enable save button only if changes are madelet setSaveButtonState = function (e) {@@ -1386,6 +1420,7 @@ Vvveb.Builder = {document.querySelector("#highlight-name .type").innerHTML = elementType[0];document.querySelector("#highlight-name .name").innerHTML = elementType[1];+ window.dispatchEvent(new CustomEvent("vvveb.Builder.selectNode", {detail: {target}}));},/* iframe highlight */@@ -1394,7 +1429,7 @@ Vvveb.Builder = {let self = Vvveb.Builder;let highlightMove = function(event) {- if (self.highlightEnabled == true && event.target && isElement(event.target)) {+ if (self.highlightEnabled == true && event.target/* && isElement(event.target)*/) {self.highlightEl = target = event.target;let pos = offset(target);@@ -1493,6 +1528,8 @@ Vvveb.Builder = {let parent = self.highlightEl;+ let isBlock = (window.getComputedStyle(parent).display == "block");+if (self.dragType == "section") {let closest = parent.closest("section, header, footer, body");if (closest) {@@ -1515,7 +1552,7 @@ Vvveb.Builder = {try {if ((pos.top < (y - halfHeight)) || (pos.left < (x - halfWidth))) {- if (noChildren[parentTagName] || isVattribute) {+ if (noChildren[parentTagName] || isBlock || isVattribute) {parent.after(self.dragElement);} else {if (parent == self.dragElement.parenNode) {@@ -1527,7 +1564,7 @@ Vvveb.Builder = {prepend = true;} else {- if (noChildren[parentTagName] || isVattribute) {+ if (noChildren[parentTagName] || isBlock || isVattribute) {parent.parentNode.insertBefore(self.dragElement, parent);} else {parent.prepend(self.dragElement);@@ -1598,7 +1635,8 @@ Vvveb.Builder = {if (self.dragMoveMutation === false) {if (self.component.dragHtml || Vvveb.dragHtml) { //if dragHtml is set for dragging then set real component htmlif (self.component) {- newElement = generateElements(self.component.html)[0];+ let html = self.component.html.replace('RANDOM_ID', Math.floor(Math.random() * 1000));+ newElement = generateElements(html)[0];self.dragElement.replaceWith(newElement);self.dragElement = newElement;}@@ -1640,7 +1678,7 @@ Vvveb.Builder = {let highlightDbClick = function(event) {- if (Vvveb.Builder.isPreview == false) {+ if (Vvveb.Builder.isPreview == false && Vvveb.Builder.highlightEnabled) {if (!Vvveb.WysiwygEditor.isActive) {self.selectPadding = 10;@@ -1679,7 +1717,7 @@ Vvveb.Builder = {let highlightClick = function(event) {- if (Vvveb.Builder.isPreview == false){+ if (Vvveb.Builder.isPreview == false && Vvveb.Builder.highlightEnabled){if (event.target) {if (Vvveb.WysiwygEditor.isActive ) {if (self.texteditEl.contains(event.target)) {@@ -1846,8 +1884,7 @@ Vvveb.Builder = {window.addEventListener("vvveb.ModalCodeEditor.save", onSave);document.getElementById("translate-code-btn")?.addEventListener("click", function(event) {- let selectedEl = Vvveb.Builder.selectedEl;- let text = selectedEl.innerHTML.trim();+ let text = Vvveb.Builder.selectedEl.innerHTML.trim();// uncomment to use outerHTML, not recommended//let text = selectedEl.outerHTML;@@ -1871,45 +1908,47 @@ Vvveb.Builder = {Vvveb.ModalTranslateEditor.show();Vvveb.ModalTranslateEditor.setValue(text);- let onSave = function(event) {- let data = Object.fromEntries(new FormData(document.getElementById("translateForm")));- data["csrf"] = document.getElementById('csrf')?.value;-- fetch(namespaceUrl + "/translate&action=save", {method: "POST", body: new URLSearchParams(data)})- .then((response) => {- if (!response.ok) { throw new Error(response) }- return response.json()- })- .then((data) => {- let bg = "success";-- if (data.success || text == "success") {- } else {- bg = "danger";- }-- displayToast(bg, "Save", data.message ?? data);- })- .catch(error => {- console.log(error.statusText);- displayToast("danger", "Error", "Error saving translations!");- });- /*- Vvveb.Builder.frameBody.querySelectorAll("form").forEach(f => {- console.log( JSON.stringify(Object.fromEntries(new FormData(f))) );- });- */- selectedEl.innerHTML = event.detail;- //selectedEl.outerHTML = text;- };-- window.removeEventListener("vvveb.ModalTranslateEditor.save", onSave);- window.addEventListener("vvveb.ModalTranslateEditor.save", onSave);-+event.preventDefault();return false;});+ let onTranslateSave = function(event) {+ let data = Object.fromEntries(new FormData(document.getElementById("translateForm")));+ data["csrf"] = document.getElementById('csrf')?.value;++ fetch(namespaceUrl + "/translate&action=save", {method: "POST", body: new URLSearchParams(data)})+ .then((response) => {+ if (!response.ok) { throw new Error(response) }+ return response.json()+ })+ .then((data) => {+ let bg = "success";++ if (data.success || text == "success") {+ } else {+ bg = "danger";+ }++ displayToast(bg, "Save", data.message ?? data);+ })+ .catch(error => {+ console.log(error.statusText);+ displayToast("danger", "Error", "Error saving translations!");+ });+ /*+ Vvveb.Builder.frameBody.querySelectorAll("form").forEach(f => {+ console.log( JSON.stringify(Object.fromEntries(new FormData(f))) );+ });+ */+ Vvveb.Builder.selectedEl.innerHTML = event.detail;+ //selectedEl.outerHTML = text;+ };++ //window.removeEventListener("vvveb.ModalTranslateEditor.save", onTranslateSave);+ window.addEventListener("vvveb.ModalTranslateEditor.save", onTranslateSave);++document.getElementById("delete-btn").addEventListener("click", function(event) {document.getElementById("select-box").style.display = "none";@@ -1929,12 +1968,13 @@ Vvveb.Builder = {});let addSectionBox = document.getElementById("add-section-box");- let addSectionElement = {};+ let addSectionElement;document.getElementById("add-section-btn").addEventListener("click", function(event) {addSectionElement = self.highlightEl;addSectionBox.style.display = "block";+ addSectionBox.classList.remove("only-base");let tagName = self.highlightEl.tagName.toLowerCase();let bsTab;if (["section", "footer", "header"].includes(tagName)) {@@ -1951,14 +1991,14 @@ Vvveb.Builder = {let left = ((pos.left + window.FrameWindow.pageXOffset + addSectionElement.clientLeft) - self.frameHtml.scrollLeft) + (addSectionElement.offsetWidth / 2) - (addSectionBox.offsetWidth / 2);let outerHeight = window.FrameWindow.innerHeight + self.frameHtml.scrollTop;+ if ((left + addSectionBox.offsetWidth) > self.frameHtml.offsetWidth) left = self.frameHtml.offsetWidth - addSectionBox.offsetWidth;+ if (((top + addSectionBox.offsetHeight) + self.frameHtml.scrollTop) > outerHeight) top = top - addSectionBox.offsetHeight;//check if box is out of viewport and move insideif (left < 0) left = 0;if (top < 0) top = 0;- if ((left + addSectionBox.offsetWidth) > self.frameHtml.offsetWidth) left = self.frameHtml.offsetWidth - addSectionBox.offsetWidth;- if (((top + addSectionBox.offsetHeight) + self.frameHtml.scrollTop) > outerHeight) top = top - addSectionBox.offsetHeight;addSectionBox.style.top = top + "px";- addSectionBox.style.left = left + "px";+ addSectionBox.style.left = left + "px";event.preventDefault();return false;@@ -1969,20 +2009,24 @@ Vvveb.Builder = {});function addSectionComponent(component, after = true) {- let node = generateElements(component.html)[0];+ let html = component.html.replace('RANDOM_ID', Math.floor(Math.random() * 1000))+ let node = generateElements(html)[0];let tagName = node.tagName.toLowerCase();let element = addSectionElement;//if section add after current section- if (["section", "footer", "header"].includes(tagName)) {- while (element = element.parentElement) {- tagName = element.tagName.toLowerCase();- if (["section", "footer", "header"].includes(tagName)) {- after = true;- break;- }-- }+ if (["section", "footer", "header", "nav"].includes(tagName)) {+ if (!element) {+ element = Vvveb.Builder.frameBody.querySelector(':scope > ' + tagName + ':last-of-type') || Vvveb.Builder.frameBody.querySelector(':scope > section:last-of-type') || Vvveb.Builder.frameBody.querySelector(':scope > header:last-of-type') || Vvveb.Builder.frameBody.querySelector(':scope > main') || Vvveb.Builder.frameBody.querySelector(':scope > footer:last-of-type');+ } else {+ while (element = element.parentElement) {+ tagName = element.tagName.toLowerCase();+ if (["section", "footer", "header", "nav"].includes(tagName)) {+ after = true;+ break;+ }+ }+ }if (!element) {element = addSectionElement;@@ -1998,8 +2042,8 @@ Vvveb.Builder = {if (component.afterDrop) {node = component.afterDrop(node);}-+ Vvveb.Server.renderComponents(node);self.selectNode(node);self.loadNodeComponent(node);Vvveb.TreeList.loadComponents();@@ -2014,32 +2058,22 @@ Vvveb.Builder = {}addSectionBox.addEventListener("click", function(event) {- let element = event.target.closest(".components-list li ol li");- if (element) {- let html = Vvveb.Components.get(element.dataset.type);-- addSectionComponent(html, (document.querySelector("[name='add-section-insert-mode']:checked").value == "after"));-- addSectionBox.style.display = "none";- }- });-- addSectionBox.addEventListener("click", function(event) {- let element = event.target.closest(".blocks-list li ol li");- if (element) {- let html = Vvveb.Blocks.get(element.dataset.type);-- addSectionComponent(html, (document.querySelector("[name='add-section-insert-mode']:checked").value == "after"));-- addSectionBox.style.display = "none";- }- });--- addSectionBox.addEventListener("click", function(event) {- let element = event.target.closest(".sections-list li ol li");+ let element = event.target.closest("ol li");if (element) {- let html = Vvveb.Sections.get(element.dataset.type);+ let itemType = element.dataset.dragType;+ let html;+ switch (itemType) {+ case 'component':+ html = Vvveb.Components.get(element.dataset.type);+ break;+ case 'block':+ html = Vvveb.Blocks.get(element.dataset.type);+ break;+ case 'section':+ html = Vvveb.Sections.get(element.dataset.type);+ break;+ }+addSectionComponent(html, (document.querySelector("[name='add-section-insert-mode']:checked").value == "after"));@@ -2079,7 +2113,7 @@ Vvveb.Builder = {} else if (Vvveb.dragHtml) {html = Vvveb.dragHtml;} else {- html = self.component.html;+ html = self.component.html.replace('RANDOM_ID', Math.floor(Math.random() * 1000));}self.dragElement = generateElements(html)[0];@@ -2164,6 +2198,7 @@ Vvveb.Builder = {removeHelpers: function (html, keepHelperAttributes = false) {//tags like stylesheets or scriptshtml = html.replace(/<[^>]+?data-vvveb-helpers.+?>/gi, "");+ html = html.replace(/<[^>]+?vvvebjs-new-section.+?>.+?<\/newsection>/gims, "");//attributesif (!keepHelperAttributes) {html = html.replace(/\s*data-vvveb-\w+(=["'].*?["'])?\s*/gi, "");@@ -2173,7 +2208,7 @@ Vvveb.Builder = {return html;},- getHtml: function(keepHelperAttributes = true) {+ getHtml: function(keepHelperAttributes = true, filter = true) {let doc = window.FrameDocument;let hasDoctpe = (doc.doctype !== null);let html = "";@@ -2186,24 +2221,27 @@ Vvveb.Builder = {// scroll page to top to avoid saving the page in a different state// like saving with sticky classes set for navbar etc// this.iframe.contentWindow.scrollTo(0,0);-- window.dispatchEvent(new CustomEvent("vvveb.getHtml.before", {detail: doc}));+ if (filter) {+ window.dispatchEvent(new CustomEvent("vvveb.getHtml.before", {detail: doc}));+ }if (hasDoctpe) html ="<!DOCTYPE "- + doc.doctype.name- + (doc.doctype.publicId ? ' PUBLIC "' + doc.doctype.publicId + '"' : '')- + (!doc.doctype.publicId && doc.doctype.systemId ? ' SYSTEM' : '')- + (doc.doctype.systemId ? ' "' + doc.doctype.systemId + '"' : '')- + ">\n";+ + doc.doctype.name+ + (doc.doctype.publicId ? ' PUBLIC "' + doc.doctype.publicId + '"' : '')+ + (!doc.doctype.publicId && doc.doctype.systemId ? ' SYSTEM' : '')+ + (doc.doctype.systemId ? ' "' + doc.doctype.systemId + '"' : '')+ + ">\n";- Vvveb.FontsManager.cleanUnusedFonts();+ Vvveb.FontsManager.cleanUnusedFonts();- html += doc.documentElement.outerHTML;- html = this.removeHelpers(html, keepHelperAttributes);-- window.dispatchEvent(new CustomEvent("vvveb.getHtml.after", {detail: doc}));- window.dispatchEvent(new CustomEvent("vvveb.getHtml.filter", {detail: html}));+ html += doc.documentElement.outerHTML;+ html = this.removeHelpers(html, keepHelperAttributes);++ if (filter) {+ window.dispatchEvent(new CustomEvent("vvveb.getHtml.after", {detail: doc}));+ window.dispatchEvent(new CustomEvent("vvveb.getHtml.filter", {detail: html}));+ }return html;},@@ -2293,15 +2331,21 @@ Vvveb.Builder = {});},- saveAjax: function(data, saveUrl, callback, error ) {- if (!data["file"]) {+ saveAjax: function(data, saveUrl, callback, error ) {+ if (!data) data = Vvveb.FileManager.getPageData();++ if (!data.hasOwnProperty("file")) {data["file"] = Vvveb.FileManager.getCurrentFileName();}+ if (!data.hasOwnProperty("url")) {+ data["url"] = Vvveb.FileManager.getPageData('url');+ }+data["elements"] = Vvveb.ChangeManager.getChangedElements();data["csrf"] = document.getElementById('csrf')?.value;- if (!data["startTemplateUrl"]) {+ if (!data.hasOwnProperty("startTemplateUrl")) {data["html"] = this.getHtml();}@@ -2313,23 +2357,37 @@ Vvveb.Builder = {body: nestedFormData(data)}).then((response) => {- if (!response.ok) { return Promise.reject(response); }+ if (!response.ok) {+ return Promise.resolve(response.text()).then((responseInText) => {+ return Promise.reject([response, responseInText]);+ });+ }return response.json();}).then((data) => {if (callback) callback(data);Vvveb.Undo.reset();document.querySelectorAll("#top-panel .save-btn").forEach(e => e.setAttribute("disabled", "true"));+ window.dispatchEvent(new CustomEvent("vvveb.Builder.saveAjax", {+ detail: data,+ }));}).catch((err) => {if (error) error(err);- let message = err?.statusText ?? "Error saving!";- displayToast("danger", "Error", message);++ let message = err;+ try {+ let [response, responseInText] = err;+ let message = responseInText ?? response.statusText ?? "Error uploading!";+ } catch (e) {+ }if (err.hasOwnProperty('text')) err.text().then( errorMessage => {let message = errorMessage.substr(0, 200);displayToast("danger", "Error", message);});++ displayToast("danger", "Error", message.substr(0, 200));});},@@ -2456,11 +2514,11 @@ Vvveb.CssEditor = {this.textarea = document.getElementById("css-editor")this.textarea.value = Vvveb.StyleManager.getCss();let self = this;-- document.querySelectorAll('[href="#css-tab"],[href="#configuration"]').forEach( t => t.addEventListener("click", e => {+ /*+ document.querySelectorAll('[href="#csscode-tab"]').forEach( t => t.addEventListener("click", e => {self.textarea.value = Vvveb.StyleManager.getCss();}));-+ */this.textarea.addEventListener("keyup", e => {delay(() => Vvveb.StyleManager.setCss(self.textarea.value), 1000);});@@ -2470,13 +2528,24 @@ Vvveb.CssEditor = {return this.textarea.value;},- setValue: function(value) {+ setValue: function(value, updateStyles = true) {this.textarea.value = value;- Vvveb.StyleManager.setCss(value);+ if (updateStyles) {+ Vvveb.StyleManager.setCss(value);+ }},destroy: function() {- }+ },++ toggle: function() {+ if (this.isActive != true) {+ this.isActive = true;+ return this.init();+ }+ this.isActive = false;+ this.destroy();+ }}function displayToast(type, title, message, position = 'bottom', id = null) {@@ -2550,6 +2619,10 @@ Vvveb.Gui = {case 'P':e.preventDefault();self.newPage();+ return;+ case 'S':+ e.preventDefault();+ self.newSection();return;}}@@ -2623,18 +2696,18 @@ Vvveb.Gui = {saveAjax : function (event, saveUrl = null, saveBtn = null) {let btn = saveBtn ?? this;saveUrl = saveUrl ?? this.dataset.vvvebUrl;- let file = Vvveb.FileManager.getPageData('file');+ let pageData = Vvveb.FileManager.getPageData();//if offcanvas check if user provided new template nameif (btn.classList.contains("save-offcanvas")) {if (document.querySelector("#save-offcanvas [name=template]:checked").value == "new") {- file = document.querySelector("#save-offcanvas [name=folder]").value + "/" + document.querySelector("#save-offcanvas [name=file]").value;+ pageData['file'] = document.querySelector("#save-offcanvas [name=folder]").value + "/" + document.querySelector("#save-offcanvas [name=file]").value;}}btn.querySelector(".loading").classList.remove("d-none");btn.querySelector(".button-text").classList.add("d-none");- return Vvveb.Builder.saveAjax({file}, saveUrl, (data) => {+ return Vvveb.Builder.saveAjax(pageData, saveUrl, (data) => {//use toast to show save statuslet bg = "success";@@ -2683,10 +2756,22 @@ Vvveb.Gui = {},viewport : function () {- document.getElementById("canvas").setAttribute("class", this.dataset.view);- document.getElementById("iframe1").removeAttribute("style");+ let breakpoint = this.dataset.view;+ document.getElementById("canvas").classList.remove("responsive");+ document.getElementById("iframe-wrapper").removeAttribute("style");document.querySelectorAll(".responsive-btns .active").forEach(e => e.classList.remove("active"));- if (this.dataset.view) this.classList.add("active");++ if (Vvveb.StyleManager.currentBreakpoint == breakpoint) {+ Vvveb.StyleManager.currentBreakpoint = "none";+ breakpoint = null;+ }++ if (breakpoint) {+ document.getElementById("canvas").classList.add("responsive");+ document.getElementById("iframe-wrapper").style.width = Vvveb.StyleManager.breakpoints[breakpoint].replace(".98", "");+ Vvveb.StyleManager.currentBreakpoint = breakpoint;+ this.classList.add("active");+ }},toggleEditor : function () {@@ -2694,9 +2779,15 @@ Vvveb.Gui = {document.getElementById("toggleEditorJsExecute").classList.toggle("d-none");//hide breadcrumb when showing the editordocument.querySelector(".breadcrumb-navigator .breadcrumb").classList.toggle("d-none");+ document.querySelector(".breadcrumb-navigator .nav-tabs").classList.toggle("d-none");Vvveb.CodeEditor.toggle();+ Vvveb.CssEditor.toggle();},+ toggleHidden : function () {+ Vvveb.Builder.frameBody.classList.toggle("vvveb-hidden");+ },+toggleEditorJsExecute : function () {Vvveb.Builder.runJsOnSetHtml = this.checked;},@@ -2729,15 +2820,21 @@ Vvveb.Gui = {}));},- expand : function (e) {- this.parentNode.parentNode.parentNode.querySelectorAll('input.header_check[type="checkbox"]').forEach(e => e.checked = true);- },+ toggleSections : function (e) {+ let icon = this.querySelector("i");+ let closed = (this.dataset.closed == "true");- collapse : function (e) {- this.parentNode.parentNode.parentNode.querySelectorAll('input.header_check[type="checkbox"]').forEach(e => e.checked = false);+ if (closed) {+ icon.setAttribute("class", "la la-minus");+ this.dataset.closed = "false";+ } else {+ icon.setAttribute("class", "la la-plus");+ this.dataset.closed = "true";+ }++ this.parentNode.parentNode.parentNode.querySelectorAll('input.header_check[type="checkbox"]').forEach(e => e.checked = closed);},-//Pages, file/components treenewPage : function () {@@ -2750,7 +2847,7 @@ Vvveb.Gui = {let submitForm = function(e) {let data = {};- this.querySelectorAll("input[type=text],input[type=checkbox]:checked,input[type=radio]:checked,input[name=image], select:not(:disabled)").forEach( (el, i) => {+ this.querySelectorAll("input[type=text],input[type=checkbox]:checked,input[type=radio]:checked,input[name=image],textarea,select:not(:disabled)").forEach( (el, i) => {if (el.offsetParent || el.name == 'image') data[el.name] = el.value;});@@ -2762,8 +2859,11 @@ Vvveb.Gui = {}data['url'] = data['folder'] + "/" + data['file'];data['url'] = Vvveb.themeBaseUrl + data['url'];+ } else {+ data['className'] = 'page';}+ data['file'] = data['file'] ? data['file'] : '';e.preventDefault();return Vvveb.Builder.saveAjax(data, this.action, function (savedData) {@@ -2777,7 +2877,8 @@ Vvveb.Gui = {data.title = savedData.title ?? data.title;}- let page = Vvveb.FileManager.addPage(data.name, data);+ delete data['startTemplateUrl'];+ let page = Vvveb.FileManager.addPage(data.name, data, false, false);Vvveb.FileManager.loadPage(data.name);Vvveb.FileManager.scrollToPage(page);bsModal.hide();@@ -2793,6 +2894,30 @@ Vvveb.Gui = {form.dataset.init = true;}},++ newSection : function (e, onlyBase = false) {++ let addSectionBox = document.getElementById("add-section-box");+ let addSectionElement = {};++ //addSectionElement = self.highlightEl;+ addSectionBox.style.display = "block";++ let bsTab;+ addSectionBox.classList.add("only-sections");+ if (onlyBase) {+ addSectionBox.classList.add("only-base");+ } else {+ addSectionBox.classList.remove("only-base");+ }++ bsTab = bootstrap.Tab.getOrCreateInstance(document.getElementById("box-sections-tab"));+ bsTab.show();++ event.preventDefault();+ return false;++ },setDesignerMode : function () {//aria-pressed attribute is updated after action is called and we check for false instead of true@@ -2898,12 +3023,18 @@ Vvveb.StyleManager = {styles:{},cssContainer:false,- mobileWidth: '320px',- tabletWidth: '768px',+ breakpoints: {+ 'sm':'575.98px',+ 'md':'767.98px',+ 'lg':'991.98px',+ 'xl':'1199.98px',+ 'xxl':'1399.98px'+ },doc:false,inlineCSS:false,currentElement:null,currentSelector:null,+ currentBreakpoint:"none",state:"",//hover, active etcinit: function(doc) {@@ -2943,13 +3074,21 @@ Vvveb.StyleManager = {let style = this.cssContainer.sheet;//if style exist then load all css styles for editorfor (let j = 0; j < style.cssRules.length; j++) {- const media = (typeof style.cssRules[j].media === "undefined") ?- "desktop" : (style.cssRules[j].media[0] === "screen and (max-width: 1220px)")- ? "tablet" : (style.cssRules[j].media[0] === "screen and (max-width: 320px)")- ? "mobile" : "desktop";+ let media = "none";- const selector = (media === "desktop") ? style.cssRules[j].selectorText : style.cssRules[j].cssRules[0].selectorText;- const styles = (media === "desktop") ? style.cssRules[j].style : style.cssRules[j].cssRules[0].style;+ if (style.cssRules[j].media) {+ for (breakpoint in this.breakpoints) {+ if (style.cssRules[j].media[0] === "@media (max-width: " + this.breakpoints[breakpoint] + ")") {+ media = breakpoint;+ break;+ }+ }+ }++ style.cssRules[j].media++ const selector = (media === "none") ? style.cssRules[j].selectorText : style.cssRules[j].cssRules[0].selectorText;+ const styles = (media === "none") ? style.cssRules[j].style : style.cssRules[j].cssRules[0].style;if (media) {this.styles[media] = this.styles[media] ?? {};@@ -3045,7 +3184,7 @@ Vvveb.StyleManager = {selector = this.addSelectorState(selector);- const media = document.getElementById("canvas").classList.contains("tablet") ? "tablet" : document.getElementById("canvas").classList.contains("mobile") ? "mobile" : "desktop";+ const media = this.currentBreakpoint;//styles[media][selector][styleProp] = valueif (!this.styles[media]) {@@ -3061,6 +3200,8 @@ Vvveb.StyleManager = {this.generateCss(media);+ window.dispatchEvent(new CustomEvent("vvveb.StyleManager.setStyle", {detail: {element, styleProp, value}}));+return element;//uncomment bellow code to set css in element's style attribute//return element.css(styleProp, value);@@ -3095,8 +3236,9 @@ Vvveb.StyleManager = {let css = "";for (media in this.styles) {- if (media === "tablet" || media === "mobile") {- css += `@media screen and (max-width: ${(media === 'tablet') ? this.tabletWidth : this.mobileWidth}){\n\n`+ if (media !== "none") {+ let width = this.breakpoints[media];+ css += `@media (max-width: ${width}){\n\n`}for (selector in this.styles[media]) {css += `${selector} {\n`;@@ -3106,7 +3248,7 @@ Vvveb.StyleManager = {}css += '}\n\n';}- if (media === "tablet" || media === "mobile") {+ if (media !== "none") {css += `}\n\n`}}@@ -3128,7 +3270,7 @@ Vvveb.StyleManager = {}selector = this.addSelectorState(selector);- media = document.getElementById("canvas").classList.contains("tablet") ? "tablet" : document.getElementById("canvas").classList.contains("mobile") ? "mobile" : "desktop";+ media = this.currentBreakpoint;if (el.style && el.style.length > 0 && el.style[styleProp]) {//check inlinevalue = el.style[styleProp];@@ -3161,12 +3303,27 @@ Vvveb.ContentManager = {return element.setAttribute(attrName, value);},- setHtml: function(element, html) {- return element.innerHTML = html;+ setHtml: function(element, html, outer = false) {+ if (outer) {+ const template = document.createElement('template');+ template.innerHTML = html.trim();+ let newelement = template.content.children[0];+ element.parentNode.replaceChild(newelement,element);+ element.remove();+ return newelement;+ } else {+ element.innerHTML = html;+ }++ return element;},- getHtml: function(element) {- return element.innerHTML;+ getHtml: function(element, outer = false) {+ if (outer) {+ return element.outerHTML;+ } else {+ return element.innerHTML;+ }},setText: function(element, text) {@@ -3441,6 +3598,8 @@ Vvveb.SectionList = {}//node.click();++ Vvveb.Server.renderComponents(node);Vvveb.Builder.selectNode(node);Vvveb.Builder.loadNodeComponent(node);/*@@ -3487,7 +3646,7 @@ Vvveb.SectionList = {sectionList.forEach(function (node, i) {let id = node.id ? node.id : (node.title ? node.title : node.ariaLabel ?? node.className);if (!id) {- id = 'section-' + Math.floor(Math.random() * 10000);+ id = 'section-' + Math.floor(Math.random() * 1000);}let section = {name: id.replace(/[^\w+]+/g,' '),@@ -3591,6 +3750,69 @@ Vvveb.SectionList = {},}+Vvveb.StyleList = {++ selector: '.sections-container',+ allowedComponents: {},++ applyStyle: function(style) {+ let doc = window.FrameDocument;+ let themeStyle = doc.getElementById("vvvebjs-theme-style");++ if (!style) {+ if (themeStyle) themeStyle.remove();+ return;+ }++ //if style element does not exist create it+ if (!themeStyle) {+ themeStyle = doc.createElement("link");+ themeStyle.id = "vvvebjs-theme-style";+ themeStyle.rel = "stylesheet";+ themeStyle.media = "screen";+ doc.head.append(themeStyle);+ }++ themeStyle.href = style;+ },++ load: function(doc) {+ let themeStyle = window.FrameDocument.getElementById("vvvebjs-theme-style");+ if (themeStyle) {+ let style = Vvveb.Styles.getByStyle(themeStyle.getAttribute("href"));+ if (style) {+ document.querySelector('.styles-list [data-type="' + style + '"]')?.classList.add("active");+ }+ }+ },++ init: function() {++ let self = this;+ document.querySelector(".styles-list").addEventListener("click", function (e) {+ let element = e.target.closest("li");+ if (element) {+ let style = Vvveb.Styles.get(element.dataset.type);++ if (element.classList.contains("active")) {+ element.classList.remove("active");+ style = "";//if already active remove current style+ } else {+ document.querySelector(".styles-list .active")?.classList.remove("active");+ element.classList.add("active");+ }++ self.applyStyle(style.style);++ console.log(style);++ e.preventDefault();+ }+ });++ }+}+Vvveb.TreeList = {selector: '#tree-list',@@ -3877,10 +4099,10 @@ Vvveb.FileManager = {newfile = page.file;}} else {- newfile = prompt(`Enter new file name for "${page.file}"`, name.toLowerCase());+ name = newfile = prompt(`Enter new file name for "${page.file}"`, name.toLowerCase());}- if (newfile || name) {+ if (newfile && name) {//allow event to change page or newfile or cancel by setting page to falsewindow.dispatchEvent(new CustomEvent("vvveb.FileManager.renamePage", {detail: {page, newfile}@@ -3946,7 +4168,7 @@ Vvveb.FileManager = {}},- addPage: function(name, data, afterPage = false) {+ addPage: function(name, data, afterPage = false, append = true) {//allow event to change name or cancel by setting name to falsewindow.dispatchEvent(new CustomEvent("vvveb.FileManager.addPage", {@@ -3975,7 +4197,11 @@ Vvveb.FileManager = {if (afterPage && (afterPage = folder.querySelector('[data-page="' + afterPage + '"]'))) {afterPage.after(page);} else {- folder.append(page);+ if (append) {+ folder.append(page);+ } else {+ folder.prepend(page);+ }}return page;@@ -4013,7 +4239,11 @@ Vvveb.FileManager = {getPageData: function(key) {if (this.currentPage) {- return this.pages[this.currentPage][key];+ if (key) {+ return this.pages[this.currentPage][key];+ } else {+ return this.pages[this.currentPage];+ }}},@@ -4174,6 +4404,11 @@ Vvveb.Revisions = {init: function () {let self = this;+ window.addEventListener("vvveb.Builder.saveAjax", function(event) {+ let data = event.detail;+ self.loadRevisions(data['file'] ?? false);+ });+window.addEventListener("vvveb.FileManager.loadPage", function(event) {let data = event.detail;self.loadRevisions(data['file'] ?? false);@@ -4261,6 +4496,127 @@ Vvveb.Revisions = {}}+Vvveb.Server = {+ url: "",+ component: "",+ index: 0,+ fullUpdate: false,+ userServerTemplate: false,++ ajax: function (callback) {+ let self = this;+ this.url = Vvveb.Builder.iframe.contentWindow.location.href;++ self.element.style.opacity = "0.85";+ self.element.style.transition = "min-height 0.25s ease-out";+ self.element.style.interpolateSize = "allow-keywords";++ let data = new FormData();+ data.append("_component_content", this.content);+ data.append("html", Vvveb.Builder.getHtml());+ data.append("csrf", document.getElementById('csrf')?.value);++ fetch(this.url + '&_component_ajax=' + this.component + '&_component_id=' + this.index + '&_server_template=' + this.userServerTemplate + '&r=true',{+ method: 'POST',+ body: data+ })+ .then((response) => {+ if (!response.ok) { throw new Error(response) }+ return response.text()+ })+ .then((data) => {+ if (data) {++ let newElement = generateElements(data)[0];+ //set fixed height for parent to avoid page flicker+ let parent = self.element.parentNode;++ parent.style.minHeight = parent.clientHeight + "px";+ //full update+ if (this.fullUpdate) {+ self.element.replaceWith(newElement);+ } else {+ self.element.innerHTML = newElement.innerHTML;+ self.element.style.minHeight = self.element.clientHeight + "px";+ }++ Vvveb.Builder.selectNode(self.element);++ setTimeout(function () {+ //if (this.fullUpdate)+ if (parent) parent.style.minHeight = "";+ self.element.style.minHeight = "";+ //self.element.click();+ Vvveb.Builder.selectNode(self.element);+ Vvveb.TreeList.loadComponents();+ }, 500);+ }++ self.element.removeAttribute("style");++ if (callback) callback(data);+ })+ .catch(error => {+ console.log(error.statusText);+ });+ },++ //render a single component+ renderComponent:function (element, component, index) {+ /*+ if (component) {+ this.component = component;+ this.index = index;+ } else {+ this.component = element.attributes[0].name.replace("data-v-component-", "");+ let selector = "[" + element.attributes[0] + "]";+ this.index = Array.prototype.indexOf.call(Vvveb.Builder.frameBody.querySelectorAll(selector), element);+ }*/++ for (attribute of element.attributes) {+ if (attribute.name.startsWith("data-v-component-")) {+ this.component = attribute.name.replace("data-v-component-","");+ break;+ }+ }++ if (this.content != element.outerHTML) {+ let itemClone = element.cloneNode(true);+ itemClone.querySelectorAll(".vvveb-hidden").forEach(e => e.classList.remove("vvveb-hidden"));++ this.content = itemClone.outerHTML;+ this.element = element;++ let self = this;+ this.throttle = setTimeout(function () {+ clearTimeout(this.throttle);+ self.ajax();+ }, 500);+ }++ return element;+ },++ //search for components inside element and render them all+ renderComponents(element) {+ const path = ".//*[ @*[starts-with(name(), 'data-v-component-')] ]";+ const elements = window.FrameDocument.evaluate(path, element ?? window.FrameDocument, null, XPathResult.ANY_TYPE, null);++ components = [];+ let currentComponent = elements.iterateNext();+ while (currentComponent) {+ components.push(currentComponent);+ currentComponent = elements.iterateNext();+ }++ for (const component of components) {+ this.renderComponent(component);+ }++ return components;+ }+}+Vvveb.FontsManager = {activeFonts:[],@@ -4466,6 +4822,61 @@ Vvveb.ColorPaletteManager = {};+Vvveb.NewSection = {+ container:null,+ template:`<newsection id="vvvebjs-new-section">+ <div class="container">+ <div class="row">+ <div class="col">+ <button id="new-blank-section">Blank section</button>+ <button id="new-section">Add section</button>+ </div>+ </div>+ </div>+ </newsection>`,++ init: function() {+ this.insert();++ this.container.onmouseout = function(event) {+ Vvveb.Builder.highlightEnabled = true;+ };++ this.container.onmouseover = function(event) {+ Vvveb.Builder.highlightEnabled = false;+ };++ this.container.onclick = function(event) {+ if (event.target.id == 'new-blank-section') {+ Vvveb.Gui.newSection(null,true);+ } else {+ if (event.target.id == 'new-section') {+ Vvveb.Gui.newSection(null,false);+ }+ }+ };+ },++ insert: function() {+ let position = 'before';+ let lastSection = Vvveb.Builder.frameBody.querySelector(':scope > footer:last-of-type');+ if (!lastSection) {+ position = 'after';+ lastSection = Vvveb.Builder.frameBody.querySelector(':scope > main:last-of-type') ||+ Vvveb.Builder.frameBody.querySelector(':scope > section:last-of-type');+ }++ this.container = generateElements(this.template)[0];+ if (position == 'after') {+ lastSection.after(this.container);+ } else {+ lastSection.before(this.container);+ }++ return this.container;+ }+}+Vvveb.Config = {components :[],blocks :[],diff --git a/public/js/vvvebjs/components-common.js b/public/js/vvvebjs/components-common.jsindex 44dd4b2..5d45c03 100755--- a/public/js/vvvebjs/components-common.js+++ b/public/js/vvvebjs/components-common.js@@ -1126,7 +1126,7 @@ Vvveb.Components.add("config/bootstrap", {//index: i - 1,columnNode: this,col:(value.type == "font" || value.type == "dimensions") ? 12 : 6,- inline:(value.type == "font" || value.type == "dimensions") ? false : true,+ inline:(value.type == "font" || value.type == "dimensions") ? false : false,section: advanced_section,inputtype: input,data: data,diff --git a/public/js/vvvebjs/components-ecommerce.js b/public/js/vvvebjs/components-ecommerce.jsindex 9ae8781..63e62c1 100755--- a/public/js/vvvebjs/components-ecommerce.js+++ b/public/js/vvvebjs/components-ecommerce.js@@ -21,7 +21,7 @@import {productComponent} from './ecommerce/products.js';import {productsComponent} from './ecommerce/products.js';-import {categoriesComponent} from './ecommerce/categories.js';+import {productCategoriesComponent} from './ecommerce/categories.js';import {manufacturersComponent} from './ecommerce/manufacturers.js';import {cartComponent} from './ecommerce/cart.js';import {checkoutComponent} from './ecommerce/checkout.js';@@ -30,7 +30,7 @@ import {filtersComponent} from './ecommerce/filters.js';Vvveb.Components.add("ecommerce/product", productComponent);Vvveb.Components.add("ecommerce/products", productsComponent);Vvveb.Components.add("ecommerce/productGallery", productGalleryComponent);-Vvveb.Components.add("ecommerce/categories", categoriesComponent);+Vvveb.Components.add("ecommerce/categories", productCategoriesComponent);Vvveb.Components.add("ecommerce/manufacturers", manufacturersComponent);Vvveb.Components.add("ecommerce/cart", cartComponent);Vvveb.Components.add("ecommerce/checkout", checkoutComponent);diff --git a/public/js/vvvebjs/components-elements.js b/public/js/vvvebjs/components-elements.jsold mode 100755new mode 100644index b68d0fc..911e5ea--- a/public/js/vvvebjs/components-elements.js+++ b/public/js/vvvebjs/components-elements.js@@ -29,7 +29,7 @@ Vvveb.ComponentsGroup['Elements'] = ["elements/accordion","elements/flip-box",//"elements/counter",-"elements/svg-icon",+"elements/svg-image","elements/figure",//"elements/testimonial","elements/social-icons",@@ -182,14 +182,19 @@ V.Resources.Icons =text: "Flipbox"}];*/-Vvveb.Components.extend("_base","elements/svg-icon", {+Vvveb.Components.extend("_base","elements/svg-image", {nodes: ["svg"],- name: "Svg Icon",+ name: "Svg Image",image: "icons/star.svg",html: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="64" height="64"><path d="M 30.335938 12.546875 L 20.164063 11.472656 L 16 2.132813 L 11.835938 11.472656 L 1.664063 12.546875 L 9.261719 19.394531 L 7.140625 29.398438 L 16 24.289063 L 24.859375 29.398438 L 22.738281 19.394531 Z"/></svg>`,properties: [{+ name: "Svg",+ key: "svg",+ htmlAttr: "innerHTML",+ inputtype: SvgInput+ }, {name: "Icon",key: "icon",inline:true,@@ -209,7 +214,7 @@ Vvveb.Components.extend("_base","elements/svg-icon", {element.replaceWith(newElement);return newElement;},- data: {+ data: {url: Vvveb.baseUrl + "../../resources/svg/icons/{value}/index.html",clickElement:"li",insertElement:"svg",@@ -332,16 +337,22 @@ Vvveb.Components.extend("_base","elements/svg-icon", {max: 512,min:1,step:1- }+ }+ }, {+ name: "Code",+ key: "code",+ inline:true,+ htmlAttr: "outerHTML",+ inputtype: TextareaInput+ }, {+ key: "svg_style_header",+ inputtype: SectionInput,+ name:false,+ //sort: base_sort++,+ section: style_section,+ data: {header:"Svg colors"},},{- key: "svg_style_header",- inputtype: SectionInput,- name:false,- //sort: base_sort++,- section: style_section,- data: {header:"Svg colors"},- },{- name: "Fill Color",+ name: "Fill",key: "fill",//sort: base_sort++,col:4,@@ -367,7 +378,7 @@ Vvveb.Components.extend("_base","elements/svg-icon", {section: style_section,htmlAttr: "stroke",inputtype: ColorInput,- }]+ }]});@@ -421,46 +432,58 @@ Vvveb.Components.add("elements/gallery", {attributes: ["data-component-gallery"],name: "Gallery",image: "icons/images.svg",- html: `- <div class="gallery masonry has-shadow" data-component-gallery>+ html: `<div class="gallery masonry has-shadow" data-component-gallery id="gallery-RANDOM_ID"><div class="item">- <a href="#">- <img src="../../media/posts/1.jpg">- </a>+ <figure>+ <img class="img-fluid" src="../../media/demo/posts/1.jpg" data-aos="fade-up">+ <figcaption></figcaption>+ <h3 class="title d-none"></h3>+ <div class="description d-none"></div>+ </figure></div><div class="item">- <a href="#">- <img src="../../media/posts/2.jpg">- </a>+ <figure>+ <img class="img-fluid" src="../../media/demo/posts/2.jpg" data-aos="fade-up" data-aos-delay="100">+ <figcaption></figcaption>+ <h3 class="title d-none"></h3>+ <div class="description d-none"></div>+ </figure></div><div class="item">- <a href="#">- <img src="../../media/posts/3.jpg">- </a>+ <figure>+ <img class="img-fluid" src="../../media/demo/posts/3.jpg" data-aos="fade-up" data-aos-delay="200">+ <figcaption></figcaption>+ <h3 class="title d-none"></h3>+ <div class="description d-none"></div>+ </figure></div><div class="item">- <a href="#">- <img src="../../media/posts/4.jpg">- </a>+ <figure>+ <img class="img-fluid" src="../../media/demo/posts/4.jpg" data-aos="fade-up" data-aos-delay="300">+ <figcaption></figcaption>+ <h3 class="title d-none"></h3>+ <div class="description d-none"></div>+ </figure></div><div class="item">- <a href="#">- <img src="../../media/posts/5.jpg">- </a>+ <figure>+ <img class="img-fluid" src="../../media/demo/posts/5.jpg" data-aos="fade-up" data-aos-delay="400">+ <figcaption></figcaption>+ <h3 class="title d-none"></h3>+ <div class="description d-none"></div>+ </figure></div><div class="item">- <a href="#">- <img src="../../media/posts/6.jpg">- </a>- </div>- <div class="item">- <a href="#">- <img src="../../media/posts/7.jpg">- </a>+ <figure>+ <img class="img-fluid" src="../../media/demo/posts/6.jpg" data-aos="fade-up" data-aos-delay="500">+ <figcaption></figcaption>+ <h3 class="title d-none"></h3>+ <div class="description d-none"></div>+ </figure></div></div>`,- properties: [{+ properties: [{name: "Masonry layout",key: "masonry",htmlAttr: "class",@@ -470,9 +493,39 @@ Vvveb.Components.add("elements/gallery", {on: "masonry",off: "flex"},++ name: false,+ key: "masonry",+ inputtype: RadioButtonInput,+ inline:false,+ col:12,+ htmlAttr:"class",+ validValues: ["masonry", "flex", "grid"],+ data: {+ inline: true,+ extraclass:"btn-group-fullwidth btn-group-sm",+ options: [{+ value: "masonry",+ //icon:"la la-cog",+ text: "Masonry",+ title: "Masonry",+ checked:true,+ },{+ value: "flex",+ text: "Flex",+ title: "Flex",+ //icon:"la la-search",+ },{+ value: "grid",+ text: "Grid",+ title: "Grid",+ //icon:"la la-search",+ }],+ },+setGroup: group => {document.querySelectorAll(".mb-2[data-group]").forEach(el => el.style.display = "none");- document.querySelector('.mb-2[data-group="'+ group + '"]').style.display = "";+ document.querySelectorAll('.mb-2[data-group="'+ group + '"]').forEach(el => el.style.display = "");},onChange : function(node, value, input) {this.setGroup(value);@@ -485,6 +538,16 @@ Vvveb.Components.add("elements/gallery", {return "flex";}},+ },{+ name: "Fit images",+ key: "cover",+ htmlAttr: "class",+ validValues: [ "", "cover"],+ inputtype: ToggleInput,+ data: {+ on: "cover",+ off: ""+ },},{name: "Image shadow",key: "shadow",@@ -495,6 +558,26 @@ Vvveb.Components.add("elements/gallery", {on: "has-shadow",off: ""},+ },{+ name: "Equal rows",+ key: "grid-auto-rows",+ group:"grid",+ htmlAttr: "style",+ inputtype: ToggleInput,+ data: {+ on: "1fr",+ off: ""+ },+ },{+ name: "Hover effect",+ key: "hover-effect",+ htmlAttr: "class",+ validValues: [ "", "hover-effect"],+ inputtype: ToggleInput,+ data: {+ on: "hover-effect",+ off: ""+ },},{name: "Horizontal gap",key: "column-gap",@@ -547,19 +630,94 @@ Vvveb.Components.add("elements/gallery", {return value;}- },{- name: "",- key: "addChild",- inputtype: ButtonInput,- data: {text:"Add image", icon:"la la-plus"},- onChange: function(node) {- node.append(generateElements('<div class="item"><a href="#"><img src="../../media/posts/1.jpg"></a></div>')[0]);-- //render component properties again to include the new image- //Vvveb.Components.render("ellements/gallery");-- return node;+ },{+ name: "Images per row grid",+ group:"grid",+ key: "grid-template-columns",+ //child: ".item",+ htmlAttr: "style",+ inputtype: RangeInput,+ data:{+ max: 12,+ min:1,+ step:1+ },+ onChange: function(node, value, input, component, inputElement) {+ return 'repeat(' + value + ', minmax(0, 1fr))';+ }+ },{+ name: "Images",+ key: "images",+ inputtype: ListInput,+ htmlAttr:"data-images",+ inline:true,+ data: {+ selector:".item",+ container:".gallery",+ prefix:"Image ",+ removeElement: true,//handle manually with removeSlide+ newElement: `<div class="item">+ <figure>+ <img class="img-fluid" src="../../media/demo/posts/1.jpg" data-aos="fade-up">+ <figcaption></figcaption>+ <h3 class="title d-none"></h3>+ <div class="description d-none"></div>+ </figure>+ </div>`,+ elementProperties:[{+ name: "Caption",+ key: "caption",+ child:"figcaption",+ htmlAttr: "innerHTML",+ inputtype: TextareaInput+ },{+ name: "Title",+ key: "title",+ child:".title",+ htmlAttr: "innerHTML",+ inputtype: TextInput+ },{+ name: "Description",+ key: "description",+ child:".description",+ htmlAttr: "innerHTML",+ inputtype: TextareaInput+ },{+ name: "Description position",+ key: "position",+ child:"img",+ htmlAttr: "data-desc-position",+ inline:false,+ inputtype: SelectInput,+ data: {+ options: [{+ value: "bottom",+ text: "Bottom"+ },{+ value: "top",+ text: "Top"+ },{+ value: "left",+ text: "Left"+ },{+ value: "right",+ text: "Right"+ }]+ }+ }]+ },+ onChange: function(node, value, input, component, event) {+ if (event.action) {+ if (event.action == "add") {+ //temporary solution to better update list+ Vvveb.Components.render("elements/gallery");+ }+ if (event.action == "remove") {+ } else if (event.action == "select") {+ }}+ return node;+ },}],init(node) {@@ -833,7 +991,7 @@ Vvveb.Components.add("elements/flip-box", {<div class="flip-box-inner"><div class="flip-box-front"><div class="card">- <img src="../../media/posts/1.jpg" class="card-img-top" alt="Post">+ <img src="../../media/demo/posts/1.jpg" class="card-img-top" alt="Post"><div class="card-body"><h5 class="card-title">Card title</h5><p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>@@ -845,7 +1003,7 @@ Vvveb.Components.add("elements/flip-box", {<div class="flip-box-back"><div class="d-flex align-items-center flex-column"><div class="flex-shrink-0">- <img src="../../media/posts/2.jpg" alt="Post">+ <img src="../../media/demo/posts/2.jpg" alt="Post"></div><div class="flex-grow-1 ms-3"><p>@@ -1089,10 +1247,10 @@ Vvveb.Components.add("elements/carousel", {html: `<div class="swiper" data-slides-per-view="3" data-draggable="true"><div class="swiper-wrapper">- <div class="swiper-slide"><img src="../../media/posts/1.jpg" class="img-fluid"><p>Slide 1</p></div>- <div class="swiper-slide"><img src="../../media/posts/2.jpg" class="img-fluid"><p>Slide 2</p></div>- <div class="swiper-slide"><img src="../../media/posts/3.jpg" class="img-fluid"><p>Slide 3</p></div>- <div class="swiper-slide"><img src="../../media/posts/4.jpg" class="img-fluid"><p>Slide 4</p></div>+ <div class="swiper-slide"><img src="../../media/demo/posts/1.jpg" class="img-fluid"><p>Slide 1</p></div>+ <div class="swiper-slide"><img src="../../media/demo/posts/2.jpg" class="img-fluid"><p>Slide 2</p></div>+ <div class="swiper-slide"><img src="../../media/demo/posts/3.jpg" class="img-fluid"><p>Slide 3</p></div>+ <div class="swiper-slide"><img src="../../media/demo/posts/4.jpg" class="img-fluid"><p>Slide 4</p></div></div><div class="swiper-pagination"></div>@@ -1129,7 +1287,7 @@ Vvveb.Components.add("elements/carousel", {container:".swiper-wrapper",prefix:"Slide ",removeElement: false,//handle manually with removeSlide- //"newElement": `<div class="swiper-slide"><img src="../../media/posts/1.jpg" class="img-fluid"><p>Slide 1</p></div>`+ //"newElement": `<div class="swiper-slide"><img src="../../media/demo/posts/1.jpg" class="img-fluid"><p>Slide 1</p></div>`},onChange: function(node, value, input, component, event) {let element = node;@@ -1142,7 +1300,7 @@ Vvveb.Components.add("elements/carousel", {if (event.action == "add") {let random = Math.floor(Math.random() * 6) + 1;let index = element.swiper.slides.length + 1;- element.swiper.appendSlide(generateElements(`<div class="swiper-slide"><img src="../../media/posts/${random}.jpg" class="img-fluid"><p>Slide ${index}</p></div>`)[0]);+ element.swiper.appendSlide(generateElements(`<div class="swiper-slide"><img src="../../media/demo/posts/${random}.jpg" class="img-fluid"><p>Slide ${index}</p></div>`)[0]);element.swiper.slideTo(index);//temporary solution to better update listVvveb.Components.render("elements/carousel");@@ -1197,65 +1355,65 @@ Vvveb.Components.add("elements/carousel", {htmlAttr:"data-simulate-touch",inputtype: CheckboxInput,inline:true,- col:4+ col:6},{name: "Autoplay",key: "autoplay",htmlAttr:"data-autoplay",inputtype: CheckboxInput,inline:true,- col:4+ col:6},{name: "Auto height",key: "autoHeight",htmlAttr:"data-auto-height",inputtype: CheckboxInput,inline:true,- col:4+ col:6},{name: "Centered slides",key: "centeredSlides",htmlAttr:"data-centered-slides",inputtype: CheckboxInput,inline:true,- col:4+ col:6},{ name: "Center insufficient",key: "centerInsufficientSlides",htmlAttr:"data-center-insufficient-slides",inputtype: CheckboxInput,inline:true,- col:4+ col:6},{ name: "Loop",key: "loop",htmlAttr:"data-loop",inputtype: CheckboxInput,inline:true,- col:4+ col:6},{ name: "Mouse wheel",key: "mousewheel",htmlAttr:"data-mousewheel",inputtype: CheckboxInput,inline:true,- col:4+ col:6},{name: "Pagination",key: "pagination",htmlAttr:"data-pagination",inputtype: CheckboxInput,inline:true,- col:4+ col:6},{ name: "Rewind",key: "rewind",htmlAttr:"data-rewind",inputtype: CheckboxInput,inline:true,- col:4+ col:6},{ name: "Scrollbar",key: "scrollbar",htmlAttr:"data-scrollbar",inputtype: CheckboxInput,inline:true,- col:4+ col:6},/*{name: "direction",key: "direction",@@ -1288,10 +1446,10 @@ Vvveb.Components.add("elements/slider", {html: `<div class="swiper" data-slides-per-view="1" data-draggable="true" data-navigation='{"nextEl": ".swiper-button-next","prevEl": ".swiper-button-prev"}'><div class="swiper-wrapper">- <div class="swiper-slide"><img src="../../media/posts/1.jpg" class="img-fluid"><p>Slider 1</p></div>- <div class="swiper-slide"><img src="../../media/posts/2.jpg" class="img-fluid"><p>Slider 2</p></div>- <div class="swiper-slide"><img src="../../media/posts/3.jpg" class="img-fluid"><p>Slider 3</p></div>- <div class="swiper-slide"><img src="../../media/posts/4.jpg" class="img-fluid"><p>Slider 4</p></div>+ <div class="swiper-slide"><img src="../../media/demo/posts/1.jpg" class="img-fluid"><p>Slider 1</p></div>+ <div class="swiper-slide"><img src="../../media/demo/posts/2.jpg" class="img-fluid"><p>Slider 2</p></div>+ <div class="swiper-slide"><img src="../../media/demo/posts/3.jpg" class="img-fluid"><p>Slider 3</p></div>+ <div class="swiper-slide"><img src="../../media/demo/posts/4.jpg" class="img-fluid"><p>Slider 4</p></div></div><div class="swiper-pagination"></div>diff --git a/public/js/vvvebjs/components-html.js b/public/js/vvvebjs/components-html.jsindex 662a790..88030e0 100755--- a/public/js/vvvebjs/components-html.js+++ b/public/js/vvvebjs/components-html.js@@ -67,8 +67,15 @@ Vvveb.Components.extend("_base", "html/heading", {value: "6",text: "Heading 6"}]- },- }]+ }+ },{+ name: "Text",+ key: "innerHTML",+ inline:false,+ sort:3,+ htmlAttr: "innerHTML",+ inputtype: TextareaInput+ }]});@@ -88,6 +95,7 @@ let linkComponentProperties = [inputtype: AutocompleteInput,data: {url: linkUrl,+ validSelection: false,allowFreeText: true,useKeyAsValue: true,}@@ -97,6 +105,12 @@ let linkComponentProperties = [sort:3,htmlAttr: "rel",inputtype: LinkInput+ },{+ name: "Text",+ key: "innerHTML",+ sort:3,+ htmlAttr: "innerHTML",+ inputtype: TextareaInput}, {name: "Target",key: "target",@@ -862,8 +876,8 @@ Vvveb.Components.extend("_base", "html/button", {Vvveb.Components.extend("_base", "html/paragraph", {nodes: ["p"],name: "Paragraph",- image: "icons/paragraph.svg",- html: '<p>Lorem ipsum</p>',+ image: "icons/paragraph.svg",+ html: '<p>Lorem ipsum</p>',properties: [{name: "Text align",key: "p-text-align",@@ -872,7 +886,7 @@ Vvveb.Components.extend("_base", "html/paragraph", {validValues: ["", "text-start", "text-center", "text-end"],inputtype: RadioButtonInput,data: {- extraclass:"btn-group-sm btn-group-fullwidth",+ extraclass:"btn-group-sm btn-group-fullwidth",options: [{value: "",icon:"la la-times",@@ -899,6 +913,13 @@ Vvveb.Components.extend("_base", "html/paragraph", {checked:false,}],},+ },{+ name: "Text",+ key: "innerHTML",+ sort:3,+ inline:false,+ htmlAttr: "innerHTML",+ inputtype: TextareaInput}]});diff --git a/public/js/vvvebjs/components/categories.js b/public/js/vvvebjs/components/categories.jsnew file mode 100644index 0000000..4504007--- /dev/null+++ b/public/js/vvvebjs/components/categories.js@@ -0,0 +1,253 @@+/**+ * Vvveb+ *+ * Copyright (C) 2021 Ziadin Givan+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import {ServerComponent} from './server-component.js';++let template = `+<div class="card categories-widget" data-v-categories data-v-type="categories">+ <h6 class="card-header">Categories</h6>+ <div class="card-body">+ <ul data-v-cats>+ <li data-v-cat>+ <a href="/cat/toys" data-v-cat-url data-v-cat-name>Toys</a>+ </li>++ <li data-v-cat>+ <a href="/cat/computers" data-v-cat-url data-v-cat-name>Computers</a>+ </li>++ <li data-v-cat>+ <a href="/cat/electronics" data-v-cat-url data-v-cat-name>Electronics</a>+ </li>++ <li data-v-cat>+ <a href="/cat/tablets" data-v-cat-url data-v-cat-name>Tablets</a>+ </li>++ <li data-v-cat>+ <a href="/cat/home-kitchen" data-v-cat-url data-v-cat-name>Home and Kitchen</a>+ </li>++ <li data-v-cat>+ <a href="/cat/books" data-v-cat-url data-v-cat-name>Books</a>+ </li>++ <li data-v-cat>+ <a href="/cat/category-1" data-v-cat-url data-v-cat-name>category 1</a>+ </li>+ </ul>+ </div>+</div>+`;++class CategoriesComponent extends ServerComponent{+ constructor ()+ {+ super();++ this.name = "Categories";+ this.attributes = ["data-v-component-categories"],++ this.image ="icons/categories.svg";+ this.html = template;++ this.properties = [/*{+ name: false,+ key: "source",+ inputtype: RadioButtonInput,+ inline:false,+ col:12,+ htmlAttr:"data-v-source",+ data: {+ inline: true,+ extraclass:"btn-group-fullwidth",+ options: [{+ value: "automatic",+ icon:"la la-cog",+ text: "Configuration",+ title: "Configuration",+ extraclass:"btn-sm",+ checked:true,+ },{+ value: "autocomplete",+ text: "Autocomplete",+ title: "Autocomplete",+ icon:"la la-search",+ extraclass:"btn-sm",+ }],+ },+ setGroup: group => {+ document.querySelectorAll('.mb-2[data-group]').forEach(e => e.classList.add("d-none"));+ document.querySelectorAll('.mb-2[data-group="'+ group + '"].d-none').forEach((el, i) => {+ el.classList.remove("d-none");+ });+ //return element;+ },+ onChange : function(element, value, input) {+ this.setGroup(input.value);+ return element;+ },+ init: function (node) {+ //this.setGroup(node.dataset.vType);+ //return 'autocomplete';+ return node.dataset.vSource ?? "automatic";+ },+ },*/{+ name: "Start from page",+ group:"automatic",+ col:6,+ inline:false,+ key: "page",+ htmlAttr:"data-v-page",+ data: {+ value: "1",//default+ min: "1",+ max: "1024",+ step: "1"+ },+ inputtype: NumberInput,+ },{+ name: "Nr. of categories",+ group:"automatic",+ col:6,+ inline:false,+ key: "limit",+ htmlAttr:"data-v-limit",+ inputtype: NumberInput,+ data: {+ value: "4",//default+ min: "1",+ max: "1024",+ step: "1"+ },+ },{+ name: "Order by",+ group:"automatic",+ key: "order",+ col:6,+ inline:false,+ htmlAttr:"data-v-order_by",+ inputtype: SelectInput,+ data: {+ options: [{+ value: "NULL",+ text: "Default"+ },{+ value: "created_at",+ text: "Date added"+ },{+ value: "updated_at",+ text: "Date modified"+ }/*, {+ value: "sales",+ text: "Sales"+ }*/]+ }+ },{+ name: "Order direction",+ group:"automatic",+ key: "order",+ col:6,+ inline:false,+ htmlAttr:"data-v-direction",+ inputtype: SelectInput,+ data: {+ options: [{+ value: "asc",+ text: "Ascending"+ },{+ value: "desc",+ text: "Descending"+ }]+ }+ }/*,{+ name: "Post type",+ group:"automatic",+ key: "order",+ col:6,+ inline:false,+ htmlAttr:"data-v-type",+ inputtype: SelectInput,+ data: {+ options: [{+ value: "",//post - default+ text: "Post"+ },{+ value: "page",+ text: "Page"+ }]+ }+ },{+ name: "Limit to categories",+ group:"automatic",+ key: "category",+ htmlAttr:"data-v-category",+ inline:false,+ col:12,+ inputtype: TagsInput,+ data: {+ url: window.location.pathname + "?module=editor/autocomplete&action=categories",+ },++ },{+ name: "Limit to manufacturers",+ group:"automatic",+ key: "manufacturer",+ htmlAttr:"data-v-manufacturer",+ inline:false,+ col:12,+ inputtype: TagsInput,+ data: {+ url: window.location.pathname + "?module=editor/autocomplete&action=manufacturers",+ }+ },{+ name: "Categories",+ key: "categories",+ group:"autocomplete",+ htmlAttr:"data-v-post_id",+ inline:false,+ col:12,+ inputtype: AutocompleteList,+ data: {+ url: window.location.pathname + "?module=editor/autocomplete&action=categories",+ },+ }*/];+ }+++ init(node) {+ document.querySelectorAll('.mb-2[data-group]').forEach((el, i) => {+ el.classList.add("d-none");+ });++ let source = node.dataset.vSource;+ if (!source) {+ source = "automatic";+ }++ document.querySelectorAll('.mb-2[data-group="' + source + '"]').forEach(e => e.classList.remove("d-none"));+ }+}++let categoriesComponent = new CategoriesComponent;++export {+ categoriesComponent, CategoriesComponent+};diff --git a/public/js/vvvebjs/components/content/categories.js b/public/js/vvvebjs/components/content/categories.jsindex e1575bd..5d9a7d6 100755--- a/public/js/vvvebjs/components/content/categories.js+++ b/public/js/vvvebjs/components/content/categories.js@@ -18,126 +18,78 @@**/-import {ServerComponent} from '../server-component.js';--let template = `-<div class="card categories-widget" data-v-categories data-v-type="categories">- <h6 class="card-header">Categories</h6>- <div class="card-body">- <ul data-v-cats>- <li data-v-cat>- <a href="/cat/toys" data-v-cat-url data-v-cat-name>Toys</a>- </li>-- <li data-v-cat>- <a href="/cat/computers" data-v-cat-url data-v-cat-name>Computers</a>- </li>-- <li data-v-cat>- <a href="/cat/electronics" data-v-cat-url data-v-cat-name>Electronics</a>- </li>-- <li data-v-cat>- <a href="/cat/tablets" data-v-cat-url data-v-cat-name>Tablets</a>- </li>-- <li data-v-cat>- <a href="/cat/home-kitchen" data-v-cat-url data-v-cat-name>Home and Kitchen</a>- </li>-- <li data-v-cat>- <a href="/cat/books" data-v-cat-url data-v-cat-name>Books</a>- </li>-- <li data-v-cat>- <a href="/cat/category-1" data-v-cat-url data-v-cat-name>category 1</a>- </li>- </ul>- </div>-</div>+import {CategoriesComponent} from '../categories.js';++let template =+`+<div data-v-component-product-categories>+<ul class="list-unstyled" data-v-cats>+ <li data-v-cat>+ <a href="/shop/computers" data-v-cat-url>+ <span data-v-cat-name>Computers</span>+ </a>+ </li>++ <li data-v-cat>+ <a href="/shop/electronics" data-v-cat-url>+ <span data-v-cat-name>Electronics</span>+ </a>+ </li>++ <li data-v-cat>+ <a href="/shop/tablets" data-v-cat-url>+ <span data-v-cat-name>Tablets</span>+ </a>+ </li>++ <li data-v-cat>+ <a href="/shop/toys" data-v-cat-url>+ <span data-v-cat-name>Toys</span>+ </a>+ </li>++ <li data-v-cat>+ <a href="/shop/home-kitchen" data-v-cat-url>+ <span data-v-cat-name>Home and Kitchen</span>+ </a>+ </li>++ <li data-v-cat>+ <a href="/shop/books" data-v-cat-url>+ <span data-v-cat-name>Books</span>+ </a>+ </li>++ <li data-v-cat>+ <a href="/shop/category-1" data-v-cat-url>+ <span data-v-cat-name>category 1</span>+ </a>+ </li>++ <li data-v-cat>+ <a href="/shop/category-2" data-v-cat-url>+ <span data-v-cat-name>category 2</span>+ </a>+ </li>+</ul>+</div>`;-class CategoriesComponent extends ServerComponent{+class ContentCategoriesComponent extends CategoriesComponent {constructor (){super();- this.name = "Categories";- this.attributes = ["data-v-component-categories"],+ this.name = "Content Categories";+ this.attributes = ["data-v-component-content-categories"],this.image ="icons/categories.svg";this.html = template;-- this.properties = [{- name: false,- key: "source",- inputtype: RadioButtonInput,- htmlAttr:"data-v-source",- data: {- inline: true,- extraclass:"btn-group-fullwidth",- options: [{- value: "autocomplete",- text: "Autocomplete",- title: "Autocomplete",- icon:"la la-search",- extraclass:"btn-sm",- checked:true,- },{- value: "automatic",- icon:"la la-cog",- text: "Configuration",- title: "Configuration",- extraclass:"btn-sm",- }],- },- setGroup: group => {- document.querySelectorAll('.mb-2[data-group]').forEach(e => e.classList.add("d-none"));- document.querySelectorAll('.mb-2[data-group="'+ group + '"].d-none').forEach((el, i) => {- el.classList.remove("d-none");- });- //return element;- },- onChange : function(element, value, input) {- this.setGroup(input.value);- return element;- },- init: function (node) {- //this.setGroup(node.dataset.vSource);- //return 'autocomplete';- return node.dataset.vSource;- },- },{- name: "Categories",- key: "categories",- group:"autocomplete",- htmlAttr:"data-v-post_id",- inline:false,- col:12,- inputtype: AutocompleteList,- data: {- url: window.location.pathname + "?module=editor/autocomplete&action=categories",- },- }];- }--- init(node) {- document.querySelectorAll('.mb-2[data-group]').forEach((el, i) => {- el.classList.add("d-none");- });-- let source = node.dataset.vSource;- if (!source) {- source = "automatic";- }-- document.querySelectorAll('.mb-2[data-group="' + source + '"]').forEach(e => e.classList.remove("d-none"));}}-let categoriesComponent = new CategoriesComponent;+let contentCategoriesComponent = new ContentCategoriesComponent;export {- categoriesComponent+ contentCategoriesComponent,ContentCategoriesComponent};diff --git a/public/js/vvvebjs/components/content/index.js b/public/js/vvvebjs/components/content/index.jsindex dcc08d4..7f40a6f 100755--- a/public/js/vvvebjs/components/content/index.js+++ b/public/js/vvvebjs/components/content/index.js@@ -20,7 +20,7 @@import {postsComponent} from './posts.js';import {postComponent} from './post.js';-import {categoriesComponent} from './categories.js';+import {contentCategoriesComponent} from './categories.js';import {archivesComponent} from './archives.js';import {recentPostsComponent} from './recentPosts.js';import {recentCommentsComponent} from './recentComments.js';@@ -34,7 +34,7 @@ import {currencyComponent} from './currency.js';Vvveb.Components.add("content/posts", postsComponent);Vvveb.Components.add("content/post", postComponent);-Vvveb.Components.add("content/categories", categoriesComponent);+Vvveb.Components.add("content/categories", contentCategoriesComponent);Vvveb.Components.add("content/archives", archivesComponent);//Vvveb.Components.add("content/recentPosts", recentPostsComponent);//Vvveb.Components.add("content/recentComments", recentCommentsComponent);diff --git a/public/js/vvvebjs/components/content/post.js b/public/js/vvvebjs/components/content/post.jsindex 870b5d9..e543503 100644--- a/public/js/vvvebjs/components/content/post.js+++ b/public/js/vvvebjs/components/content/post.js@@ -23,7 +23,7 @@ import {ServerComponent} from '../server-component.js';let template =`<div data-v-component-post="post" data-v-post_id="1"><h2 data-v-post-name>Post name</h2>- <img class="img-fluid" src="media/posts/6.jpg" alt="">+ <img class="img-fluid" src="media/demo/posts/6.jpg" alt="" data-v-post-image data-v-if="post.image"><div data-v-post-content>Post content</div></div>`;@@ -50,6 +50,31 @@ class PostComponent extends ServerComponent{url: window.location.pathname + "?module=editor/autocomplete&action=posts&type=",},+ },{+ name: "Image size",+ key: "image_size",+ col:6,+ inline:false,+ htmlAttr:"data-v-image_size",+ inputtype: SelectInput,+ data: {+ options: [{+ value: "",+ text: "Default"+ },{+ value: "thumb",+ text: "Thumb"+ },{+ value: "medium",+ text: "Medium"+ },{+ value: "large",+ text: "Large"+ },{+ value: "xlarge",+ text: "Extra large"+ }]+ }}];}diff --git a/public/js/vvvebjs/components/content/posts.js b/public/js/vvvebjs/components/content/posts.jsindex 668909d..ea87909 100755--- a/public/js/vvvebjs/components/content/posts.js+++ b/public/js/vvvebjs/components/content/posts.js@@ -30,7 +30,7 @@ let template =<article class="card"><div class="card-img-top">- <img src="../../media/posts/6.jpg" alt="" data-v-post-image="">+ <img src="../../media/demo/posts/6.jpg" alt="" data-v-post-image=""></div><div class="card-body">@@ -55,7 +55,7 @@ let template =<article class="card"><div class="card-img-top">- <img src="../../media/posts/5.jpg" alt="" data-v-post-image="">+ <img src="../../media/demo/posts/5.jpg" alt="" data-v-post-image=""></div><div class="card-body">@@ -80,7 +80,7 @@ let template =<article class="card"><div class="card-img-top">- <img src="../../media/posts/4.jpg" alt="" data-v-post-image="">+ <img src="../../media/demo/posts/4.jpg" alt="" data-v-post-image=""></div><div class="card-body">@@ -107,7 +107,7 @@ let template =<article class="card"><div class="card-img-top">- <img src="../../media/posts/3.jpg" alt="" data-v-post-image="">+ <img src="../../media/demo/posts/3.jpg" alt="" data-v-post-image=""></div><div class="card-body">@@ -211,6 +211,31 @@ class PostsComponent extends ServerComponent{max: "1024",step: "1"},+ },{+ name: "Image size",+ key: "image_size",+ col:6,+ inline:false,+ htmlAttr:"data-v-image_size",+ inputtype: SelectInput,+ data: {+ options: [{+ value: "",+ text: "Default"+ },{+ value: "thumb",+ text: "Thumb"+ },{+ value: "medium",+ text: "Medium"+ },{+ value: "large",+ text: "Large"+ },{+ value: "xlarge",+ text: "Extra large"+ }]+ }},{name: "Order by",group:"automatic",@@ -267,7 +292,41 @@ class PostsComponent extends ServerComponent{value: "page",text: "Page"}]- }+ }+ },{+ name: "Author",+ group:"automatic",+ key: "order",+ col:6,+ inline:false,+ htmlAttr:"data-v-admin_id",+ inputtype: SelectInput,+ data: {+ options: [{+ value: "",//post - default+ text: "Post"+ },{+ value: "page",+ text: "Page"+ }]+ }+ },{+ name: "Sticky",+ group:"automatic",+ key: "order",+ col:6,+ inline:false,+ htmlAttr:"data-v-sticky",+ inputtype: SelectInput,+ data: {+ options: [{+ value: "",//post - default+ text: "Exclude"+ },{+ value: "true",+ text: "Include"+ }]+ }},{name: "Limit to categories",group:"automatic",@@ -280,17 +339,30 @@ class PostsComponent extends ServerComponent{url: window.location.pathname + "?module=editor/autocomplete&action=categories",},- },{- name: "Limit to manufacturers",+ },{+ name: "Search",group:"automatic",- key: "manufacturer",- htmlAttr:"data-v-manufacturer",- inline:false,+ key: "search",col:12,- inputtype: TagsInput,- data: {- url: window.location.pathname + "?module=editor/autocomplete&action=manufacturers",- }+ inline:false,+ htmlAttr:"data-v-search",+ inputtype: TextInput,+ },{+ name: "Date format",+ group:"automatic",+ key: "date_format",+ col:6,+ inline:false,+ htmlAttr:"data-v-date_format",+ inputtype: TextInput,+ },{+ name: "Excerpt limit",+ group:"automatic",+ key: "excerpt_limit",+ col:6,+ inline:false,+ htmlAttr:"data-v-excerpt_limit",+ inputtype: NumberInput,},{name: "Posts",key: "posts",diff --git a/public/js/vvvebjs/components/ecommerce/categories.js b/public/js/vvvebjs/components/ecommerce/categories.jsindex 4077435..11ce1ba 100755--- a/public/js/vvvebjs/components/ecommerce/categories.js+++ b/public/js/vvvebjs/components/ecommerce/categories.js@@ -17,6 +17,9 @@* along with this program. If not, see <https://www.gnu.org/licenses/>.**/++import {CategoriesComponent} from '../categories.js';+let template =`<div data-v-component-product-categories>@@ -72,35 +75,21 @@ let template =</div>`;-class CategoriesComponent {+class ProductCategoriesComponent extends CategoriesComponent {constructor (){- this.name = "Categories";+ super();++ this.name = "Product Categories";this.attributes = ["data-v-component-product-categories"],this.image ="icons/categories.svg";this.html = template;-- this.properties = [];- }-- init(node)- {- document.querySelectorAll('.mb-2[data-group]').forEach((el, i) => {- el.classList.add("d-none");- });-- let source = node.dataset.vSource;- if (!source) {- source = "automatic";- }-- document.querySelectorAll('.mb-2[data-group="' + source + '"]').forEach(e => e.classList.remove("d-none"));}}-let categoriesComponent = new CategoriesComponent;-+let productCategoriesComponent = new ProductCategoriesComponent;+console.log('prod cat');export {- categoriesComponent+ productCategoriesComponent, ProductCategoriesComponent};diff --git a/public/js/vvvebjs/components/ecommerce/checkout.js b/public/js/vvvebjs/components/ecommerce/checkout.jsindex 36a20bf..1ea657e 100755--- a/public/js/vvvebjs/components/ecommerce/checkout.js+++ b/public/js/vvvebjs/components/ecommerce/checkout.js@@ -233,7 +233,7 @@ I agree to <a href="/page/terms-conditions" target="_blank" data-v-url="content/<tr data-v-cart-product="" data-product_id="19"><td class="text-center"><a href="/checkout?module=product&product_id=19" data-v-cart-product-url="">- <img src="/public/media/product/9-1.jpg" alt="iPhone" class="img-rounded" data-v-cart-product-image="" width="50">+ <img src="/public/media/demo/products/9-1.jpg" alt="iPhone" class="img-rounded" data-v-cart-product-image="" width="50"></a></td><td class="text-center">@@ -250,7 +250,7 @@ I agree to <a href="/page/terms-conditions" target="_blank" data-v-url="content/</tr><tr data-v-cart-product="" data-product_id="18"><td class="text-center"><a href="/checkout?module=product&product_id=18" data-v-cart-product-url="">- <img src="/public/media/product/8-1.jpg" alt="iPhone" class="img-rounded" data-v-cart-product-image="" width="50">+ <img src="/public/media/demo/products/8-1.jpg" alt="iPhone" class="img-rounded" data-v-cart-product-image="" width="50"></a></td><td class="text-center">diff --git a/public/js/vvvebjs/components/ecommerce/index.js b/public/js/vvvebjs/components/ecommerce/index.jsindex 7d31559..c68b88a 100755--- a/public/js/vvvebjs/components/ecommerce/index.js+++ b/public/js/vvvebjs/components/ecommerce/index.js@@ -20,7 +20,7 @@import {productComponent} from './product.js';import {productsComponent} from './products.js';-import {categoriesComponent} from './categories.js';+import {productCategoriesComponent} from './categories.js';import {productGalleryComponent} from './productGallery.js';import {manufacturersComponent} from './manufacturers.js';import {vendorsComponent} from './vendors.js';@@ -32,7 +32,7 @@ import {filtersComponent} from './filters.js';Vvveb.Components.add("ecommerce/product", productComponent);Vvveb.Components.add("ecommerce/products", productsComponent);Vvveb.Components.add("ecommerce/productGallery", productGalleryComponent);-Vvveb.Components.add("ecommerce/categories", categoriesComponent);+Vvveb.Components.add("ecommerce/categories", productCategoriesComponent);Vvveb.Components.add("ecommerce/manufacturers", manufacturersComponent);Vvveb.Components.add("ecommerce/vendors", vendorsComponent);Vvveb.Components.add("ecommerce/cart", cartComponent);@@ -42,7 +42,7 @@ Vvveb.Components.add("ecommerce/filters", filtersComponent);Vvveb.ComponentsGroup['Ecommerce'] = ["ecommerce/products","ecommerce/product",-// "ecommerce/categories",+ "ecommerce/categories","ecommerce/manufacturers","ecommerce/vendors","ecommerce/search",diff --git a/public/js/vvvebjs/components/ecommerce/product.js b/public/js/vvvebjs/components/ecommerce/product.jsindex 0da7e96..a9d5f3a 100755--- a/public/js/vvvebjs/components/ecommerce/product.js+++ b/public/js/vvvebjs/components/ecommerce/product.js@@ -312,6 +312,31 @@ class ProductComponent extends ServerComponent{url: window.location.pathname + "?module=editor/autocomplete&action=products&type=",},+ },{+ name: "Image size",+ key: "image_size",+ col:6,+ inline:false,+ htmlAttr:"data-v-image_size",+ inputtype: SelectInput,+ data: {+ options: [{+ value: "",+ text: "Default"+ },{+ value: "thumb",+ text: "Thumb"+ },{+ value: "medium",+ text: "Medium"+ },{+ value: "large",+ text: "Large"+ },{+ value: "xlarge",+ text: "Extra large"+ }]+ }}];}diff --git a/public/js/vvvebjs/components/ecommerce/products.js b/public/js/vvvebjs/components/ecommerce/products.jsindex 9afb209..0078cd2 100755--- a/public/js/vvvebjs/components/ecommerce/products.js+++ b/public/js/vvvebjs/components/ecommerce/products.js@@ -193,7 +193,32 @@ class ProductsComponent extends ServerComponent{text: "Sales"}*/]}- },{+ },{+ name: "Image size",+ key: "image_size",+ col:6,+ inline:false,+ htmlAttr:"data-v-image_size",+ inputtype: SelectInput,+ data: {+ options: [{+ value: "",+ text: "Default"+ },{+ value: "thumb",+ text: "Thumb"+ },{+ value: "medium",+ text: "Medium"+ },{+ value: "large",+ text: "Large"+ },{+ value: "xlarge",+ text: "Extra large"+ }]+ }+ },{name: "Product type",group:"automatic",key: "order",diff --git a/public/js/vvvebjs/elements-changes.js b/public/js/vvvebjs/elements-changes.jsold mode 100755new mode 100644index ce0dcbb..3e5a4cb--- a/public/js/vvvebjs/elements-changes.js+++ b/public/js/vvvebjs/elements-changes.js@@ -54,12 +54,22 @@ function getElements() {for (let i = 0; i < nodes.length; i++) {let node = nodes[i];- let type = "data-v-" + node.dataset.vType + "-";- let name = "";- let componentName = node.dataset.vComponent ?? node.dataset.vType;+ let componentName = node.dataset.vComponent ?? node.dataset.vType;+ if (!componentName) {+ for (attribute of node.attributes) {+ if (attribute.name.startsWith("data-v-component-")) {+ componentName = attribute.name.replace("data-v-component-","");+ break;+ }+ }+ }++ let type = "data-v-" + componentName + "-";+ let name = "";let fields = [];let fieldsNodes = getElementByXpath(".//*[ @*[starts-with(name(), 'data-v-')] ]", node);+ let duplicateFiels = [];for (let j = 0; j < fieldsNodes.length; j++) {let fieldNode = fieldsNodes[j];@@ -99,7 +109,10 @@ function getElements() {if (field) {- fields.push(field);+ if (!duplicateFiels.includes(field.name)) {//don't add duplicate or children fields+ fields.push(field);+ duplicateFiels.push(field.name);+ }}}diff --git a/public/js/vvvebjs/inputs.js b/public/js/vvvebjs/inputs.jsindex ec6d0cf..b323a32 100755--- a/public/js/vvvebjs/inputs.js+++ b/public/js/vvvebjs/inputs.js@@ -806,7 +806,24 @@ let ListInput = { ...Input, ...{data.elements = elements;this.data = data;- return this.render("listinput", data);+ let list = this.render("listinput", data);+ let items = list.querySelectorAll(".section-item");+ let i = 0;+ for (const item of items) {+ const container = item.querySelector(".tree") ?? item;+ let properties = {};+ if (data.elementProperties) {+ for (let prop in data.elementProperties) {+ properties[prop] = Object.assign({}, data.elementProperties[prop]);+ properties[prop].element = elements[i];+ }+ }++ Vvveb.Components.renderProperties(null, properties, null, container);+ i++;+ }++ return list;},}}@@ -815,6 +832,7 @@ let AutocompleteInput = { ...Input, ...{events: [["autocomplete.change", "onAutocompleteChange", "input"],+ ["input", "onAutocompleteChange", "input"],],onAutocompleteChange: function(event, node, input) {@@ -853,7 +871,7 @@ let AutocompleteList = { ...Input, ...{setValue: function(value) {if (this.element && value) {let input = this.element.querySelectorAll('input').forEach(e => e.value = value);- }+ }},init: function(data) {diff --git a/public/js/vvvebjs/plugin-codemirror.js b/public/js/vvvebjs/plugin-codemirror.jsindex 93f2651..1c4cd4a 100755--- a/public/js/vvvebjs/plugin-codemirror.js+++ b/public/js/vvvebjs/plugin-codemirror.js@@ -35,7 +35,7 @@ Vvveb.CodeEditor = {autofocus: true,lineWrapping: true,//viewportMargin:Infinity,- theme: 'material'+ theme: 'duotone-dark'});this.isActive = true;@@ -48,26 +48,38 @@ Vvveb.CodeEditor = {}, 1000);}});++ //load code on document changes+ Vvveb.Builder.frameBody.addEventListener("vvveb.undo.add", () => Vvveb.CodeEditor.setValue());+ Vvveb.Builder.frameBody.addEventListener("vvveb.undo.restore", () => Vvveb.CodeEditor.setValue());++ //load code when a new url is loaded+ Vvveb.Builder.documentFrame.addEventListener("load", () => Vvveb.CodeEditor.setValue());+ window.addEventListener("vvveb.Builder.selectNode", (e) => Vvveb.CodeEditor.setSelection(e));}-- //load code on document changes- Vvveb.Builder.frameBody.addEventListener("vvveb.undo.add", () => Vvveb.CodeEditor.setValue());- Vvveb.Builder.frameBody.addEventListener("vvveb.undo.restore", () => Vvveb.CodeEditor.setValue());-- //load code when a new url is loaded- Vvveb.Builder.documentFrame.addEventListener("load", () => Vvveb.CodeEditor.setValue());-this.isActive = true;this.setValue();return this.codemirror;},+ setSelection: function(e) {+ if (e.detail.target) {+ let value = e.detail.target.outerHTML;++ let cursor = this.codemirror.getSearchCursor(value/* , CodeMirror.Pos(this.codemirror.firstLine(), 0), {caseFold: true, multiline: true}*/);+ if(cursor.find(false)){ //move to that position.+ this.codemirror.setSelection(cursor.from(), cursor.to());+ this.codemirror.scrollIntoView({from: cursor.from(), to: cursor.to()}, 5);+ }+ }+ },+setValue: function(value) {if (this.isActive == true) {let scrollInfo = this.codemirror.getScrollInfo();- this.codemirror.setValue(Vvveb.Builder.getHtml());+ this.codemirror.setValue(Vvveb.Builder.getHtml(true, false));this.codemirror.scrollTo(scrollInfo.left, scrollInfo.top);let self = this;setTimeout(function() {@@ -83,6 +95,8 @@ Vvveb.CodeEditor = {this.codemirror = false;*/this.isActive = false;+ window.removeEventListener("vvveb.StyleManager.setStyle", Vvveb.CodeEditor.setStyle);+ window.removeEventListener("vvveb.Builder.selectNode", Vvveb.CodeEditor.setSelection);},toggle: function() {@@ -105,7 +119,7 @@ Vvveb.ModalCodeEditor.init = function (modal = false, editor = false) {autofocus: true,lineWrapping: true,//viewportMargin:Infinity,- theme: 'material'+ theme: 'duotone-dark'});let self = this;@@ -136,46 +150,84 @@ Vvveb.CssEditor = {oldValue: '',doc:false,textarea:false,- editor:false,+ codemirror:false,init: function(doc) {- this.textarea = document.getElementById("css-editor");- this.editor = CodeMirror.fromTextArea(this.textarea, {- mode: 'text/css',- lineNumbers: true,- autofocus: true,- lineWrapping: true,- //viewportMargin:Infinity,- theme: 'material'- });-- let self = this;-- document.querySelectorAll('[href="#css-tab"],[href="#configuration"]').forEach( t => t.addEventListener("click", e => {- self.setValue(Vvveb.StyleManager.getCss());- }));-- this.editor.getDoc().on("change", function (e, v) {- if (v.origin != "setValue")- delay(() => Vvveb.StyleManager.setCss(e.getValue()), 1000);- });+ if (this.codemirror == false) {+ this.textarea = document.getElementById("css-editor");+ this.codemirror = CodeMirror.fromTextArea(this.textarea, {+ mode: 'text/css',+ lineNumbers: true,+ autofocus: true,+ lineWrapping: true,+ //viewportMargin:Infinity,+ theme: 'duotone-dark'+ });++ this.codemirror.getDoc().on("change", function (e, v) {+ if (v.origin != "setValue")+ delay(() => Vvveb.StyleManager.setCss(e.getValue()), 1000);+ });++ window.addEventListener("vvveb.Builder.selectNode", (e) => Vvveb.CssEditor.setSelection(e));+ window.addEventListener("vvveb.StyleManager.setStyle", Vvveb.CssEditor.setStyle);+ }++ this.setValue(Vvveb.StyleManager.getCss());},getValue: function() {- return this.editor.getValue();+ return this.codemirror.getValue();},- setValue: function(value) {- let scrollInfo = this.editor.getScrollInfo();- this.editor.setValue(value);- this.editor.scrollTo(scrollInfo.left, scrollInfo.top);- let self = this;- setTimeout(function() {- self.editor.refresh();- }, 300);- //Vvveb.StyleManager.setCss(value);+ setValue: function(value, updateStyles = true) {+ if (value) {+ let scrollInfo = this.codemirror.getScrollInfo();+ this.codemirror.setValue(value);+ this.codemirror.scrollTo(scrollInfo.left, scrollInfo.top);+ let self = this;+ setTimeout(function() {+ self.codemirror.refresh();+ }, 300);++ if (updateStyles) {+ Vvveb.StyleManager.setCss(value);+ }+ }},+ setStyle: function(e) {+ Vvveb.CssEditor.setValue(Vvveb.StyleManager.getCss(), false);+ },++ setSelection: function(e) {+ if (e.detail.target) {+ let value = Vvveb.StyleManager.getSelectorForElement(e.detail.target);+ let cursor = this.codemirror.getSearchCursor(value/* , CodeMirror.Pos(this.codemirror.firstLine(), 0), {caseFold: true, multiline: true}*/);+ if(cursor.find(false)){ //move to that position.+ this.codemirror.setSelection(cursor.from(), cursor.to());+ this.codemirror.scrollIntoView({from: cursor.from(), to: cursor.to()}, 5);+ }+ }+ },+destroy: function(element) {+ /*+ //save memory by destroying but lose scroll on editor toggle+ this.codemirror.toTextArea();+ this.codemirror = false;+ */+ window.removeEventListener("vvveb.StyleManager.setStyle", Vvveb.CssEditor.setStyle);+ window.removeEventListener("vvveb.Builder.selectNode", Vvveb.CssEditor.setSelection);+ this.isActive = false;+ },++ toggle: function() {+ if (this.isActive != true) {+ this.isActive = true;+ return this.init();+ }+ this.isActive = false;+ this.destroy();}}diff --git a/public/js/vvvebjs/plugin-google-fonts.js b/public/js/vvvebjs/plugin-google-fonts.jsindex 1af99c6..884c7c3 100755--- a/public/js/vvvebjs/plugin-google-fonts.js+++ b/public/js/vvvebjs/plugin-google-fonts.js@@ -24,7 +24,7 @@ GoogleFontsManager = {activeFonts: [],updateFontList: function () {- let googleFontsLink = Vvveb.Builder.frameHead.querySelector("google-fonts-link");+ let googleFontsLink = Vvveb.Builder.frameHead.querySelector("#google-fonts-link");if (this.activeFonts.length == 0) {googleFontsLink.remove();diff --git a/public/js/vvvebjs/plugin-media.js b/public/js/vvvebjs/plugin-media.jsindex dedd755..f331da2 100755--- a/public/js/vvvebjs/plugin-media.js+++ b/public/js/vvvebjs/plugin-media.js@@ -62,7 +62,8 @@ ImageInput = { ...ImageInput, ...{//reselect image after loading to adjust highlight box sizelet onLoad = function () {if (Vvveb.Builder.selectedEl) {- Vvveb.Builder.selectedEl.click();+ Vvveb.Builder.selectNode(Vvveb.Builder.selectedEl);+ Vvveb.Builder.loadNodeComponent(Vvveb.Builder.selectedEl);}};@@ -100,3 +101,73 @@ VideoInput = { ...ImageInput, ...{},}}++SvgInput = { ...ImageInput, ...{+ tag:"svg",++ events: [+ ["change", "onChange", "input[type=text]"],+ ["click", "onClick", "button"],+ ["click", "onClick", "svg"],+ ],+++ init: function(data) {+ return this.render("svginput-gallery", data);+ },++ setValue: function(value) {+ if (this.element[0] && value) {+ let input = this.element[0].querySelector('svg');++ if (input) {+ input.innerHTML = value;+ }+ }+ },++ onChange: function(event, node, input) {+ if (event && event.target) {+ let self = this;+ let value = this.value;+ let src = mediaPath + value;+ let currentTarget = event.currentTarget;++ fetch(src)+ .then(res => res.text())+ .then(value => {+ //const e = new CustomEvent('propertyChange', { detail: {value, input: self, origEvent:event} });+ //currentTarget.dispatchEvent(e);++ let element = Vvveb.Builder.selectedEl;+ let newElement = generateElements(value)[0];+ let attributes = element.attributes;++ //keep old svg size and colors+ for (let i = 0; i < attributes.length; i++) {+ let attr = attributes[i];+ if (attr.name && attr.name != "viewBox") {+ newElement.setAttribute(attr.name, attr.value);+ }+ }++ element.replaceWith(newElement);+ Vvveb.Builder.selectedEl = newElement;++ if (Vvveb.Builder.selectedEl) {+ Vvveb.Builder.selectNode(Vvveb.Builder.selectedEl);+ let svg = node.querySelector('svg')+ svg.innerHTML = newElement.innerHTML;+ svg.setAttribute('viewBox', newElement.getAttribute('viewBox'));+ //Vvveb.Builder.loadNodeComponent(Vvveb.Builder.selectedEl);+ }+ })++ //event.data.element.trigger('propertyChange', [this.value, this, event]);+ }+ },++ onImageChange: function(event, node, input) {+ }+ }+}diff --git a/public/js/vvvebjs/section.js b/public/js/vvvebjs/section.jsold mode 100644new mode 100755index db6cf23..d6aec13--- a/public/js/vvvebjs/section.js+++ b/public/js/vvvebjs/section.js@@ -173,10 +173,11 @@ let SectionBackground = [{let img = node.querySelector(":scope > .background-container > img");let video = node.querySelector(":scope > .background-container > video");- if (img && (img.offsetParent || img.offsetHeight)) {+ if (img && (img.offsetParent || img.offsetHeight || !img.classList.contains("d-none"))) {selected = "bg-image";}- if (video && (img.offsetParent || video.offsetHeight)) {++ if (video && (img.offsetParent || video.offsetHeight || !video.classList.contains("d-none"))) {selected = "bg-video";}@@ -624,14 +625,15 @@ function componentsInit(node) {let separatorTop = node.querySelector(":scope > .separator.top");let separatorBottom = node.querySelector(":scope > .separator.bottom");let bg = "";-- if (img && (img.offsetParent || img.offsetHeight)) {++ if (img && (img.offsetParent || img.offsetHeight || !img.classList.contains("d-none"))) {bg = "bg-image";}- if (video && (img.offsetParent || video.offsetHeight)) {- bg = "bg-video";- }+ if (video && (img.offsetParent || video.offsetHeight || !video.classList.contains("d-none"))) {+ bg = "bg-video";+ }+let showSection = function (section) {document.querySelectorAll('.mb-2[data-group="' + section + '"]').forEach(e => e.classList.remove("d-none"));}diff --git a/public/js/vvvebjs/undo.js b/public/js/vvvebjs/undo.jsindex 5c6c4de..7c16c5f 100755--- a/public/js/vvvebjs/undo.js+++ b/public/js/vvvebjs/undo.js@@ -89,11 +89,17 @@ Vvveb.Undo = {case 'attributes':value = undo ? mutation.oldValue : mutation.newValue;- if (value || value === false || value === 0)- mutation.target.setAttribute(mutation.attributeName, value);- else- mutation.target.removeAttribute(mutation.attributeName);-+ if (mutation.attributeName == "innerHTML") {+ element = Vvveb.ContentManager.setHtml(mutation.target, value);+ } else if (mutation.attributeName == "innerText") {+ element = Vvveb.ContentManager.setText(mutation.target, value);+ } else {+ if (value || value === false || value === 0)+ mutation.target.setAttribute(mutation.attributeName, value);+ else+ mutation.target.removeAttribute(mutation.attributeName);+ }+break;}