auto-cms-server
Advanced tools
Comparing version 0.5.2 to 0.5.3
{ | ||
"name": "auto-cms-server", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "Auto turn any webpage into editable CMS without coding.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -61,2 +61,3 @@ "use strict"; | ||
doc.querySelector("auto-cms-menu")?.remove(); | ||
doc.querySelector("style[auto-cms]")?.remove(); | ||
let lines = doc.body.innerHTML.split("\n"); | ||
@@ -94,4 +95,19 @@ for (; lines.length > 0; ) { | ||
} | ||
function getHighestZIndex() { | ||
let max = 0; | ||
function walk(element) { | ||
let current = +getComputedStyle(element).zIndex; | ||
if (current > max) { | ||
max = current; | ||
} | ||
for (let child of element.children) { | ||
walk(child); | ||
} | ||
} | ||
walk(document.body); | ||
return max; | ||
} | ||
var AutoCMSMenu = class _AutoCMSMenu extends HTMLElement { | ||
static instance; | ||
shadowRoot; | ||
target; | ||
@@ -101,15 +117,7 @@ confirmRemoveItem; | ||
super(); | ||
} | ||
connectedCallback() { | ||
const target = this.target; | ||
if (!target) | ||
return; | ||
window.addEventListener("click", this.handleWindowClick, { | ||
capture: true, | ||
passive: false | ||
}); | ||
this.innerHTML = /* html */ | ||
this.shadowRoot = this.attachShadow({ mode: "open" }); | ||
let style = document.createElement("style"); | ||
style.innerHTML = /* css */ | ||
` | ||
<style> | ||
auto-cms-menu { | ||
:host { | ||
position: fixed; | ||
@@ -119,3 +127,6 @@ border: 1px solid black; | ||
background-color: white; | ||
color: black; | ||
overflow: hidden; | ||
z-index: ${getHighestZIndex() + 1}; | ||
overflow: auto; | ||
} | ||
@@ -142,4 +153,16 @@ .auto-cms-menu--section { | ||
} | ||
</style> | ||
`; | ||
this.appendChild(style); | ||
} | ||
appendChild(node) { | ||
return this.shadowRoot.appendChild(node); | ||
} | ||
connectedCallback() { | ||
const target = this.target; | ||
if (!target) | ||
return; | ||
window.addEventListener("click", this.handleWindowClick, { | ||
capture: true, | ||
passive: false | ||
}); | ||
let updateSection = this.addSection("Update"); | ||
@@ -362,5 +385,9 @@ if (target.children.length == 0 && target.innerText) { | ||
if (event.y < window.innerHeight / 2) { | ||
this.style.top = `calc(${event.y}px + 1rem)`; | ||
let top = `${event.y}px + 1rem`; | ||
this.style.top = `calc(${top})`; | ||
this.style.maxHeight = `calc(100dvh - (${top}))`; | ||
} else { | ||
this.style.bottom = `calc(${window.innerHeight - event.y}px + 1rem)`; | ||
let bottom = `${window.innerHeight - event.y}px + 1rem`; | ||
this.style.bottom = `calc(${bottom})`; | ||
this.style.maxHeight = `calc(100dvh - (${bottom}))`; | ||
} | ||
@@ -397,2 +424,3 @@ if (event.x < window.innerWidth / 2) { | ||
user-select: none; | ||
color: black; | ||
} | ||
@@ -406,2 +434,13 @@ </style> | ||
document.body.appendChild(new AutoCMSStatus()); | ||
{ | ||
let style = document.createElement("style"); | ||
style.setAttribute("auto-cms", ""); | ||
style.innerHTML = /* css */ | ||
` | ||
[hidden] { | ||
display: none !important; | ||
} | ||
`; | ||
document.body.appendChild(style); | ||
} | ||
})(); |
@@ -16,6 +16,9 @@ # auto-cms | ||
- video | ||
- [x] media management | ||
- view | ||
- upload | ||
- delete | ||
- [ ] media management | ||
- [x] view | ||
- [x] upload | ||
- [x] delete | ||
- [ ] see which pages are using the media | ||
- [x] support image | ||
- [ ] support video / audio | ||
- [ ] style editing | ||
@@ -31,2 +34,4 @@ - text alignment | ||
- [x] Save changes to file | ||
- [ ] Multi-language support | ||
- [ ] Auto scan 404 | ||
@@ -33,0 +38,0 @@ ## Usage |
38768
695
61