@ohhwells/bridge 0.1.61-next.172 → 0.1.62-next.174
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +21 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/pages.d.cts +0 -45
- package/dist/pages.d.ts +0 -45
package/dist/index.cjs
CHANGED
|
@@ -380,6 +380,19 @@ var SECTION_ATTRS = {
|
|
|
380
380
|
spacing: "data-ohw-style-spacing"
|
|
381
381
|
};
|
|
382
382
|
var NODE_WROTE_ATTR = "data-ohw-style-node";
|
|
383
|
+
var NODE_PROPS = ["color", "font-size", "background"];
|
|
384
|
+
function saveInline(el, prop) {
|
|
385
|
+
const attr = `data-ohw-style-prev-${prop}`;
|
|
386
|
+
if (!el.hasAttribute(attr)) el.setAttribute(attr, el.style.getPropertyValue(prop));
|
|
387
|
+
}
|
|
388
|
+
function restoreInline(el, prop) {
|
|
389
|
+
const attr = `data-ohw-style-prev-${prop}`;
|
|
390
|
+
if (!el.hasAttribute(attr)) return;
|
|
391
|
+
const prev = el.getAttribute(attr) ?? "";
|
|
392
|
+
if (prev) el.style.setProperty(prop, prev);
|
|
393
|
+
else el.style.removeProperty(prop);
|
|
394
|
+
el.removeAttribute(attr);
|
|
395
|
+
}
|
|
383
396
|
function ensureStyleSheet() {
|
|
384
397
|
let el = document.getElementById(STYLE_SHEET_ID);
|
|
385
398
|
if (!el) {
|
|
@@ -395,17 +408,14 @@ function clearSectionAttrs(root) {
|
|
|
395
408
|
for (const el of Array.from(root.querySelectorAll(`[${attr}]`))) el.removeAttribute(attr);
|
|
396
409
|
}
|
|
397
410
|
for (const el of Array.from(root.querySelectorAll("[data-ohw-style-bgcolor]"))) {
|
|
398
|
-
;
|
|
399
|
-
el.style.removeProperty("background");
|
|
411
|
+
restoreInline(el, "background");
|
|
400
412
|
el.removeAttribute("data-ohw-style-bgcolor");
|
|
401
413
|
}
|
|
402
414
|
}
|
|
403
415
|
function clearNodeProps(root) {
|
|
404
416
|
for (const el of Array.from(root.querySelectorAll(`[${NODE_WROTE_ATTR}]`))) {
|
|
405
417
|
const h = el;
|
|
406
|
-
|
|
407
|
-
h.style.removeProperty("font-size");
|
|
408
|
-
h.style.removeProperty("background");
|
|
418
|
+
for (const prop of NODE_PROPS) restoreInline(h, prop);
|
|
409
419
|
h.removeAttribute(NODE_WROTE_ATTR);
|
|
410
420
|
}
|
|
411
421
|
}
|
|
@@ -429,6 +439,7 @@ function applyStylesToDom(store) {
|
|
|
429
439
|
section.setAttribute(attr, String(value).replace(":", "-"));
|
|
430
440
|
}
|
|
431
441
|
if (override.sectionBackgroundColor !== void 0) {
|
|
442
|
+
saveInline(section, "background");
|
|
432
443
|
section.style.setProperty("background", override.sectionBackgroundColor, "important");
|
|
433
444
|
section.setAttribute("data-ohw-style-bgcolor", "");
|
|
434
445
|
}
|
|
@@ -438,19 +449,23 @@ function applyStylesToDom(store) {
|
|
|
438
449
|
const nodes = document.querySelectorAll(`[data-ohw-key="${CSS.escape(key)}"]`);
|
|
439
450
|
for (const el of Array.from(nodes)) {
|
|
440
451
|
if (override.color !== void 0) {
|
|
452
|
+
saveInline(el, "color");
|
|
441
453
|
el.style.setProperty("color", override.color, "important");
|
|
442
454
|
el.setAttribute(NODE_WROTE_ATTR, "");
|
|
443
455
|
}
|
|
444
456
|
if (override.fontSize !== void 0) {
|
|
457
|
+
saveInline(el, "font-size");
|
|
445
458
|
el.style.setProperty("font-size", `${override.fontSize}px`, "important");
|
|
446
459
|
el.setAttribute(NODE_WROTE_ATTR, "");
|
|
447
460
|
}
|
|
448
461
|
if (override.buttonBackground !== void 0 || override.buttonText !== void 0) {
|
|
449
462
|
const surface = buttonSurfaceOf(el);
|
|
450
463
|
if (override.buttonBackground !== void 0) {
|
|
464
|
+
saveInline(surface, "background");
|
|
451
465
|
surface.style.setProperty("background", override.buttonBackground, "important");
|
|
452
466
|
}
|
|
453
467
|
if (override.buttonText !== void 0) {
|
|
468
|
+
saveInline(surface, "color");
|
|
454
469
|
surface.style.setProperty("color", override.buttonText, "important");
|
|
455
470
|
}
|
|
456
471
|
surface.setAttribute(NODE_WROTE_ATTR, "");
|
|
@@ -18536,7 +18551,7 @@ function OhhwellsBridge() {
|
|
|
18536
18551
|
postToParent2({
|
|
18537
18552
|
type: "ow:ready",
|
|
18538
18553
|
version: "1",
|
|
18539
|
-
bridgeVersion: "0.1.
|
|
18554
|
+
bridgeVersion: "0.1.62",
|
|
18540
18555
|
path: pathname,
|
|
18541
18556
|
nodes: collectEditableNodes(editContentRef.current),
|
|
18542
18557
|
sections
|