Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 71 additions & 12 deletions elements/hax-body/hax-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -2476,8 +2476,68 @@ class HaxBody extends I18NMixin(UndoManagerBehaviors(SimpleColors)) {

// If hax-body isn't the next parent
if(currentNode.parentNode && currentNode.parentNode !== bodyNode){
unwrap(currentNode.parentNode)
return currentNode.parentNode;
const parentNode = currentNode.parentNode;
const grandparentNode = currentNode.parentNode.parentNode;

if(currentNode.previousElementSibling){
const prevParent = parentNode.previousElementSibling;
// If the previous parent container is a matching list type, append to it in order
if(prevParent &&
prevParent.tagName === parentNode.tagName) {
let prevLI = parentNode.firstChild;
while(prevLI !== currentNode){
const isPrev = prevLI.nextElementSibling;
prevParent.appendChild(parentNode.firstChild);
prevLI = isPrev;
}
} else {
const beforeNodes = parentNode.cloneNode(false);
let prevLI = currentNode.previousElementSibling;
while(prevLI){
beforeNodes.prepend(prevLI)
const isPrev = prevLI.previousElementSibling;
prevLI = isPrev;
}
beforeNodes.removeAttribute("data-hax-active");
grandparentNode.insertBefore(beforeNodes, parentNode);
}
}

if(currentNode.nextElementSibling){
const nextParent = parentNode.nextElementSibling;
// If the next parent container is a matching list type, prepend to it in order
if(nextParent &&
nextParent.tagName === parentNode.tagName) {
let nextLI = parentNode.lastChild;
while(nextLI !== currentNode){
const isNext = nextLI.previousElementSibling;
nextParent.prepend(nextLI);
nextLI = isNext;
}
} else {
const afterNodes = parentNode.cloneNode(false);
let nextLI = currentNode.nextElementSibling;
while(nextLI){
const isNext = nextLI.nextElementSibling;
afterNodes.appendChild(nextLI)
nextLI = isNext;
}
afterNodes.removeAttribute("data-hax-active");
// If no nextSibling, nextParent is null and insertBefore acts like appendChild
grandparentNode.insertBefore(afterNodes, nextParent);
}
}
// Unwrap original UL/OL
unwrap(parentNode);

// If we're outdenting into a paragraph, the LI tag shouldn't be preserved
if(grandparentNode.tagName.toLowerCase() !== "ol" || grandparentNode.tagName.toLowerCase() !== "ul" ){
const strippedLI = globalThis.document.createElement("span");
strippedLI.innerHTML = currentNode.innerHTML.trim() + "<br/>"
currentNode.replaceWith(strippedLI)
};

return grandparentNode;
} else {
return this.haxChangeTagName(node, "p", true)
}
Expand All @@ -2497,12 +2557,11 @@ class HaxBody extends I18NMixin(UndoManagerBehaviors(SimpleColors)) {
)
) {
replacement.innerHTML =
"<li>" +
node.innerHTML
.trim()
.replace(/<br\/>/g, "</li>\n<li>")
.replace(/<br>/g, "</li>\n<li>") +
"</li>";
.replace(/<span>/g, "<li>")
.replace(/<br><\/span>/g, "</li>\n")
.replace(/<br\/><\/span>/g, "</li>\n");
}
// when converting to list, ensure slot is on the list, not the items
if (originalSlot) {
Expand All @@ -2521,12 +2580,12 @@ class HaxBody extends I18NMixin(UndoManagerBehaviors(SimpleColors)) {
node.tagName.toLowerCase() == "ol"
) {
// if we're coming from ul or ol strip out the li tags
replacement.innerHTML = replacement.innerHTML
.replace(/<ul>/g, "")
.replace(/<\/ul>/g, "")
.replace(/<li><\/li>/g, "")
.replace(/<li>/g, "")
.replace(/<\/li>/g, "<br/>");
const items = Array.from(node.children).map((child) => {
const tag = child.tagName.toLowerCase();
if(tag === "li") return "<span>" + child.innerHTML.trim() + "<br/></span>";
else if(tag === "ul" || tag === "ol") return child.outerHTML;
});
replacement.innerHTML = items.join("");
}
// Switch!
try {
Expand Down
6 changes: 2 additions & 4 deletions elements/haxcms-elements/lib/core/haxcms-site-editor-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2933,7 +2933,7 @@ class HAXCMSSiteEditorUI extends HAXCMSThemeParts(
class="top-bar-button"
id="manifestbtn"
?disabled="${this.editMode}"
?hidden="${this.editMode || !store.platformAllows("manifest")}"
?hidden="${this.editMode}"
label="${this.t.siteSettings} • Ctrl⇧5"
></simple-toolbar-button>
<slot name="haxcms-site-editor-ui-suffix-buttons"></slot>
Expand Down Expand Up @@ -4949,9 +4949,7 @@ class HAXCMSSiteEditorUI extends HAXCMSThemeParts(
);
} else {
// Non-edit mode: Site settings
if (store.platformAllows("manifest")) {
this._manifestButtonTap(e);
}
this._manifestButtonTap(e);
}
},
condition: () => store.isLoggedIn,
Expand Down
5 changes: 4 additions & 1 deletion elements/haxcms-elements/lib/core/haxcms-site-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,10 @@ class Store {
"styleGuide",
"outlineDesigner",
"insights",
"manifest",
"siteManifest",
"themeManifest",
"authorManifest",
"seoManifest",
"addBlock",
"contentMap",
"viewSource",
Expand Down
58 changes: 53 additions & 5 deletions elements/haxcms-elements/lib/core/ui/haxcms-site-platform-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const FEATURE_DEFS = [
icon: 'hax:add-page',
group: 'CMS',
},
{
key: 'saveAndEdit',
label: 'Save and continue',
icon: 'hax:add-page',
group: 'CMS',
},
{
key: 'deletePage',
label: 'Delete pages',
Expand All @@ -40,14 +46,32 @@ const FEATURE_DEFS = [
group: 'CMS',
},
{
key: 'manifest',
key: 'siteManifest',
label: 'Site settings',
icon: 'hax:home-edit',
group: 'CMS',
},
{
key: 'themeManifest',
label: 'Theme settings',
icon: 'hax:home-edit',
group: 'CMS',
},
{
key: 'authorManifest',
label: 'Author settings',
icon: 'hax:home-edit',
group: 'CMS',
},
{
key: 'seoManifest',
label: 'SEO settings',
icon: 'hax:home-edit',
group: 'CMS',
},
{
key: 'pageBreak',
label: 'Edit Page Details',
label: 'Edit page details',
icon: 'hax:page-edit',
group: 'CMS',
},
Expand All @@ -57,9 +81,21 @@ const FEATURE_DEFS = [
icon: 'hax:add-brick',
group: 'HAX',
},
{
key: 'popularGizmos',
label: 'Popular blocks section',
icon: 'hax:add-brick',
group: 'HAX',
},
{
key: 'recentGizmos',
label: 'Recent blocks section',
icon: 'hax:add-brick',
group: 'HAX',
},
{
key: 'contentMap',
label: 'Page structure (content map)',
label: 'Page content map',
icon: 'hax:newspaper',
group: 'HAX',
},
Expand All @@ -70,8 +106,20 @@ const FEATURE_DEFS = [
group: 'HAX',
},
{
key: 'onlineSearch',
label: 'Online search',
key: 'uploadMedia',
label: 'Upload media',
icon: 'hax:add-page',
group: 'HAX',
},
{
key: 'onlineMedia',
label: 'Online media search',
icon: 'hax:add-page',
group: 'HAX',
},
{
key: 'community',
label: 'Community outreach',
icon: 'hax:add-page',
group: 'HAX',
},
Expand Down
Loading