diff --git a/css/editor.css b/css/editor.css index 8603023..69f8702 100644 --- a/css/editor.css +++ b/css/editor.css @@ -17793,7 +17793,7 @@ https://github.com/givanz/VvvebJs .tree > ol li.file:hover .file-actions { display: block; } .tree > ol li.file > label { - background: url(../libs/builder/icons/file.svg); + background-image: url(../libs/builder/icons/file.svg); background-position: 8px 4px; background-size: 19px 19px; background-repeat: no-repeat; @@ -18867,7 +18867,7 @@ li[data-type] { .sections-container > div.section-item .controls .info .type { font-size: 12px; } .sections-container > div.section-item .controls .buttons { - margin-right: 2rem; + margin-right: 1.3rem; margin-top: 0.2rem; } .sections-container > div.section-item .controls .buttons a { padding: 0.3rem 0.5rem 0.3rem; diff --git a/demo/landing b/demo/landing index 3096991..550cab8 160000 --- a/demo/landing +++ b/demo/landing @@ -1 +1 @@ -Subproject commit 3096991d336d9eac9171c06acfc43f8537c7b171 +Subproject commit 550cab8df8c5eb092f0291d7d0528987552099d4 diff --git a/libs/builder/components-common.js b/libs/builder/components-common.js index b195d95..adc214a 100755 --- a/libs/builder/components-common.js +++ b/libs/builder/components-common.js @@ -59,10 +59,10 @@ function changeNodeName(node, newNodeName) { newNode.setAttribute(attributes[i].nodeName, attributes[i].nodeValue); } - for (e of node.childNodes) { - newNode.append(e); + while (node.hasChildNodes()) { + newNode.appendChild(node.removeChild(node.firstChild)) } - + node.replaceWith(newNode); return newNode; diff --git a/libs/builder/components-html.js b/libs/builder/components-html.js index a91c877..4674e17 100755 --- a/libs/builder/components-html.js +++ b/libs/builder/components-html.js @@ -900,10 +900,65 @@ Vvveb.Components.extend("_base", "html/list", { name: "List", image: "icons/list.svg", html: ``, + properties: [{ + name: "Type", + key: "type", + inputtype: SelectInput, + + onChange: function(node, value) { + return changeNodeName(node, value); + }, + + init: function(node) { + return node.nodeName.toLowerCase() + }, + + data:{ + options: [{ + value: "ul", + text: "Unorderd" + }, { + value: "ol", + text: "Ordered" + }] + }, + },{ + name: "Items", + key: "items", + inputtype: ListInput, + htmlAttr:"data-slides-per-view", + inline:true, + data: { + selector:"li", + container:"", + prefix:"Item ", + removeElement: true, + "newElement": `
  • Do everything quickly and well.
  • ` + }, + onChange: function(node, value, input, component, event) { + let element = node; + + if (event.action) { + if (event.action == "add") { + //node.append(generateElements(`
  • List item
  • `)[0]); + + //temporary solution to better update list + Vvveb.Components.render("html/list"); + } + if (event.action == "remove") { + } else if (event.action == "select") { + } + } + + return node; + }, + }] }); Vvveb.Components.extend("_base", "html/preformatted", { diff --git a/libs/builder/inputs.js b/libs/builder/inputs.js index cc9df50..56b5277 100755 --- a/libs/builder/inputs.js +++ b/libs/builder/inputs.js @@ -732,7 +732,11 @@ let ListInput = { ...Input, ...{ let data = input.data; if (data.removeElement) { - input.node.querySelector(data.container + " " + data.selector + ":nth-child(" + (index + 1) + ")").remove(); + let container = input.node; + if (data.container) { + container.querySelector(data.container); + } + container.querySelector(data.selector + ":nth-child(" + (index + 1) + ")").remove(); } sectionItem.remove(); @@ -746,7 +750,11 @@ let ListInput = { ...Input, ...{ add: function(event, node, input) { let newElement = input.data.newElement ?? false; if (newElement) { - event.data.input.node.querySelector(input.data.container).append(generateElements(newElement)[0]); + let container = input.node; + if (data.container) { + container.querySelector(data.container); + } + container.append(generateElements(newElement)[0]); } event.action = "add"; @@ -782,7 +790,7 @@ let ListInput = { ...Input, ...{ if (data.nameElement) { element = element.querySelector(data.nameElement); } - let name = (data.name = "text" ? element.textContent : element.id); + let name = (data.name = "text" ? element.textContent.substr(0, 15) : element.id); options.push({ name: name, type: (data.prefix ?? "") + (i + 1) + (data.suffix ?? ""), diff --git a/scss/_builder.scss b/scss/_builder.scss index 55c0138..31d88e5 100644 --- a/scss/_builder.scss +++ b/scss/_builder.scss @@ -1760,7 +1760,7 @@ width:100%; } .buttons { - margin-right:2rem; + margin-right:1.3rem; margin-top:0.2rem; //align-self: flex-end;