@ohhwells/bridge 0.1.62-next.174 → 0.1.64-next.176
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 +33 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -3
- package/dist/index.js.map +1 -1
- package/dist/pages.d.cts +45 -0
- package/dist/pages.d.ts +45 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -252,7 +252,10 @@ var BRAND_VAR_PREFIX = "--ohw-brand-";
|
|
|
252
252
|
var BRAND_VAR_NAMES = ["primary", "accent", "light", "dark", "surface", "border", "muted"].map(
|
|
253
253
|
(role) => `${BRAND_VAR_PREFIX}${role}`
|
|
254
254
|
);
|
|
255
|
-
var FONT_VARS = {
|
|
255
|
+
var FONT_VARS = {
|
|
256
|
+
heading: ["--font-heading", "--font-display", "--brand-font-heading"],
|
|
257
|
+
body: ["--font-body", "--brand-font-body"]
|
|
258
|
+
};
|
|
256
259
|
var BRAND_FONT_LINK_ID = "ohw-brand-fonts";
|
|
257
260
|
function brandColorVars(kit) {
|
|
258
261
|
const { dark, primary, accent, light } = kit.palette;
|
|
@@ -372,6 +375,25 @@ function styleSheetCss() {
|
|
|
372
375
|
}
|
|
373
376
|
return rules.join("\n");
|
|
374
377
|
}
|
|
378
|
+
var STYLE_FONT_LINK_ID = "ohw-style-fonts";
|
|
379
|
+
function loadStyleFonts(families) {
|
|
380
|
+
const unique = [...new Set(families.map((f) => f.trim()).filter(Boolean))];
|
|
381
|
+
const existing = document.getElementById(STYLE_FONT_LINK_ID);
|
|
382
|
+
if (unique.length === 0) {
|
|
383
|
+
existing?.remove();
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
const spec = unique.map((f) => `${f.replace(/ /g, "+")}:400,500,600,700`).join("|");
|
|
387
|
+
const href = `https://fonts.googleapis.com/css?family=${spec}&display=swap`;
|
|
388
|
+
let link = existing;
|
|
389
|
+
if (!link) {
|
|
390
|
+
link = document.createElement("link");
|
|
391
|
+
link.id = STYLE_FONT_LINK_ID;
|
|
392
|
+
link.rel = "stylesheet";
|
|
393
|
+
document.head.appendChild(link);
|
|
394
|
+
}
|
|
395
|
+
if (link.href !== href) link.href = href;
|
|
396
|
+
}
|
|
375
397
|
var SECTION_ATTRS = {
|
|
376
398
|
sectionBackground: "data-ohw-style-bg",
|
|
377
399
|
textDistribution: "data-ohw-style-distribution",
|
|
@@ -380,7 +402,7 @@ var SECTION_ATTRS = {
|
|
|
380
402
|
spacing: "data-ohw-style-spacing"
|
|
381
403
|
};
|
|
382
404
|
var NODE_WROTE_ATTR = "data-ohw-style-node";
|
|
383
|
-
var NODE_PROPS = ["color", "font-size", "background"];
|
|
405
|
+
var NODE_PROPS = ["color", "font-family", "font-size", "background"];
|
|
384
406
|
function saveInline(el, prop) {
|
|
385
407
|
const attr = `data-ohw-style-prev-${prop}`;
|
|
386
408
|
if (!el.hasAttribute(attr)) el.setAttribute(attr, el.style.getPropertyValue(prop));
|
|
@@ -426,6 +448,9 @@ function applyStylesToDom(store) {
|
|
|
426
448
|
ensureStyleSheet();
|
|
427
449
|
clearSectionAttrs(document);
|
|
428
450
|
clearNodeProps(document);
|
|
451
|
+
loadStyleFonts(
|
|
452
|
+
store ? Object.values(store.nodes).flatMap((n) => n.fontFamily ? [n.fontFamily] : []) : []
|
|
453
|
+
);
|
|
429
454
|
if (!store) return;
|
|
430
455
|
for (const [sectionId, override] of Object.entries(store.sections)) {
|
|
431
456
|
const sections = document.querySelectorAll(
|
|
@@ -453,6 +478,11 @@ function applyStylesToDom(store) {
|
|
|
453
478
|
el.style.setProperty("color", override.color, "important");
|
|
454
479
|
el.setAttribute(NODE_WROTE_ATTR, "");
|
|
455
480
|
}
|
|
481
|
+
if (override.fontFamily !== void 0) {
|
|
482
|
+
saveInline(el, "font-family");
|
|
483
|
+
el.style.setProperty("font-family", `'${override.fontFamily}'`, "important");
|
|
484
|
+
el.setAttribute(NODE_WROTE_ATTR, "");
|
|
485
|
+
}
|
|
456
486
|
if (override.fontSize !== void 0) {
|
|
457
487
|
saveInline(el, "font-size");
|
|
458
488
|
el.style.setProperty("font-size", `${override.fontSize}px`, "important");
|
|
@@ -18551,7 +18581,7 @@ function OhhwellsBridge() {
|
|
|
18551
18581
|
postToParent2({
|
|
18552
18582
|
type: "ow:ready",
|
|
18553
18583
|
version: "1",
|
|
18554
|
-
bridgeVersion: "0.1.
|
|
18584
|
+
bridgeVersion: "0.1.64",
|
|
18555
18585
|
path: pathname,
|
|
18556
18586
|
nodes: collectEditableNodes(editContentRef.current),
|
|
18557
18587
|
sections
|