@ohhwells/bridge 0.1.109 → 0.1.111
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 +50 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8251,6 +8251,7 @@ var FIELD_TYPES = [
|
|
|
8251
8251
|
var FIELD_ATTR = "data-ohw-form-field";
|
|
8252
8252
|
var FIELD_TYPE_ATTR = "data-ohw-field-type";
|
|
8253
8253
|
var PLACEHOLDER_EDIT_ATTR = "data-ohw-placeholder-edit";
|
|
8254
|
+
var seedFieldByForm = /* @__PURE__ */ new WeakMap();
|
|
8254
8255
|
function fieldsKey(formKey) {
|
|
8255
8256
|
return `${formKey}-fields`;
|
|
8256
8257
|
}
|
|
@@ -8336,7 +8337,11 @@ function markFormFields(form) {
|
|
|
8336
8337
|
ensureFieldLabel(wrapper, key);
|
|
8337
8338
|
syncRequiredMark(wrapper);
|
|
8338
8339
|
});
|
|
8339
|
-
|
|
8340
|
+
const wrappers = listFieldWrappers(form);
|
|
8341
|
+
if (wrappers.length > 0 && !seedFieldByForm.has(form)) {
|
|
8342
|
+
seedFieldByForm.set(form, wrappers[0].cloneNode(true));
|
|
8343
|
+
}
|
|
8344
|
+
return wrappers;
|
|
8340
8345
|
}
|
|
8341
8346
|
function readFieldsFromDom(form) {
|
|
8342
8347
|
return listFieldWrappers(form).map((wrapper) => {
|
|
@@ -8480,12 +8485,27 @@ function insertField(form, type) {
|
|
|
8480
8485
|
wrapper = source.cloneNode(true);
|
|
8481
8486
|
source.after(wrapper);
|
|
8482
8487
|
} else {
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8488
|
+
const seed = seedFieldByForm.get(form);
|
|
8489
|
+
if (seed) {
|
|
8490
|
+
wrapper = seed.cloneNode(true);
|
|
8491
|
+
} else {
|
|
8492
|
+
wrapper = document.createElement("div");
|
|
8493
|
+
const input2 = document.createElement("input");
|
|
8494
|
+
input2.style.width = "100%";
|
|
8495
|
+
input2.style.boxSizing = "border-box";
|
|
8496
|
+
input2.style.padding = "12px";
|
|
8497
|
+
input2.style.border = "1px solid color-mix(in srgb, currentColor 35%, transparent)";
|
|
8498
|
+
input2.style.borderRadius = "8px";
|
|
8499
|
+
input2.style.background = "#fff";
|
|
8500
|
+
input2.style.fontFamily = "inherit";
|
|
8501
|
+
input2.style.fontSize = "inherit";
|
|
8502
|
+
input2.style.color = "inherit";
|
|
8503
|
+
wrapper.append(input2);
|
|
8504
|
+
}
|
|
8487
8505
|
const submit = form.querySelector('button, input[type="submit"]');
|
|
8488
|
-
|
|
8506
|
+
let anchor = submit;
|
|
8507
|
+
while (anchor && anchor.parentElement !== form) anchor = anchor.parentElement;
|
|
8508
|
+
if (anchor) anchor.before(wrapper);
|
|
8489
8509
|
else form.appendChild(wrapper);
|
|
8490
8510
|
}
|
|
8491
8511
|
wrapper.setAttribute(FIELD_ATTR, key);
|
|
@@ -16920,6 +16940,10 @@ function getIframeVisibleClip(parentScroll) {
|
|
|
16920
16940
|
);
|
|
16921
16941
|
return { top: clipTop, bottom: Math.max(clipTop, clipBottom) };
|
|
16922
16942
|
}
|
|
16943
|
+
function isRectOutsideClip(rect, clip) {
|
|
16944
|
+
if (!clip) return false;
|
|
16945
|
+
return rect.bottom < clip.top || rect.top > clip.bottom;
|
|
16946
|
+
}
|
|
16923
16947
|
function applyVisibleViewport(el, parentScroll) {
|
|
16924
16948
|
const clip = getIframeVisibleClip(parentScroll);
|
|
16925
16949
|
const top = clip?.top ?? 0;
|
|
@@ -19659,8 +19683,10 @@ function OhhwellsBridge() {
|
|
|
19659
19683
|
crushed its fields together (OHH-490). Not media (image/bg-image/video/icon/map)
|
|
19660
19684
|
either: those can be their own flex containers centering fallback content (a
|
|
19661
19685
|
placeholder label, a mascot emoji) \u2014 forcing block broke that centering while the
|
|
19662
|
-
image was unset (OHH-758-ish).
|
|
19663
|
-
|
|
19686
|
+
image was unset (OHH-758-ish). Not inside a container that declares its editables
|
|
19687
|
+
inline (data-ohw-inline-editables): a row of inline links \u2014 a footer's legal line \u2014
|
|
19688
|
+
keeps its line; blockified labels put each link on its own row in the editor only. */
|
|
19689
|
+
[data-ohw-editable]:not([data-ohw-editable="form"]):not([data-ohw-editable="image"]):not([data-ohw-editable="bg-image"]):not([data-ohw-editable="video"]):not([data-ohw-editable="icon"]):not([data-ohw-editable="map"]):not([data-ohw-inline-editables] *) {
|
|
19664
19690
|
display: block;
|
|
19665
19691
|
}
|
|
19666
19692
|
/* The block-force above is an author rule, so it beats the browser's own
|
|
@@ -21403,6 +21429,7 @@ function OhhwellsBridge() {
|
|
|
21403
21429
|
applyMapQuery(el, val);
|
|
21404
21430
|
} else if (el.dataset.ohwEditable === "icon") {
|
|
21405
21431
|
applyIconMarkup(el, val);
|
|
21432
|
+
} else if (el.dataset.ohwEditable === "form") {
|
|
21406
21433
|
} else if (isIconMarkupValue(val)) {
|
|
21407
21434
|
} else {
|
|
21408
21435
|
el.innerHTML = val;
|
|
@@ -21412,6 +21439,9 @@ function OhhwellsBridge() {
|
|
|
21412
21439
|
}
|
|
21413
21440
|
applyLogoFromContent(content);
|
|
21414
21441
|
applyLogoSizes(content);
|
|
21442
|
+
document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
|
|
21443
|
+
reconcileFieldsFromContent(form, content);
|
|
21444
|
+
});
|
|
21415
21445
|
if (sectionsJson) {
|
|
21416
21446
|
initSectionsFromContent({ __ohw_sections: sectionsJson }, true);
|
|
21417
21447
|
sectionsLoadedRef.current = true;
|
|
@@ -22268,14 +22298,20 @@ function OhhwellsBridge() {
|
|
|
22268
22298
|
};
|
|
22269
22299
|
const applyToolbarPos = (rect) => {
|
|
22270
22300
|
const ps = parentScrollRef.current;
|
|
22301
|
+
const hidden = isRectOutsideClip(rect, getIframeVisibleClip(ps));
|
|
22271
22302
|
const measuredW = toolbarElRef.current?.offsetWidth || 330;
|
|
22272
22303
|
if (toolbarElRef.current) {
|
|
22273
|
-
|
|
22274
|
-
|
|
22275
|
-
|
|
22276
|
-
|
|
22304
|
+
toolbarElRef.current.style.display = hidden ? "none" : "";
|
|
22305
|
+
if (!hidden) {
|
|
22306
|
+
const { top, left, transform } = calcToolbarPos(rect, ps, measuredW);
|
|
22307
|
+
toolbarElRef.current.style.top = `${top}px`;
|
|
22308
|
+
toolbarElRef.current.style.left = `${left}px`;
|
|
22309
|
+
toolbarElRef.current.style.transform = transform;
|
|
22310
|
+
}
|
|
22277
22311
|
}
|
|
22278
22312
|
if (glowElRef.current) {
|
|
22313
|
+
glowElRef.current.style.display = hidden ? "none" : "";
|
|
22314
|
+
if (hidden) return;
|
|
22279
22315
|
const GAP = SELECTION_CHROME_GAP2;
|
|
22280
22316
|
glowElRef.current.style.top = `${rect.top - GAP}px`;
|
|
22281
22317
|
glowElRef.current.style.left = `${rect.left - GAP}px`;
|
|
@@ -22717,7 +22753,7 @@ function OhhwellsBridge() {
|
|
|
22717
22753
|
postToParent2({
|
|
22718
22754
|
type: "ow:ready",
|
|
22719
22755
|
version: "1",
|
|
22720
|
-
bridgeVersion: "0.1.
|
|
22756
|
+
bridgeVersion: "0.1.110",
|
|
22721
22757
|
path: pathname,
|
|
22722
22758
|
nodes: collectEditableNodes(editContentRef.current),
|
|
22723
22759
|
sections
|
|
@@ -23505,7 +23541,7 @@ function OhhwellsBridge() {
|
|
|
23505
23541
|
) : void 0
|
|
23506
23542
|
}
|
|
23507
23543
|
),
|
|
23508
|
-
toolbarRect && toolbarVariant === "rich-text" && !linkPopover && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
|
23544
|
+
toolbarRect && toolbarVariant === "rich-text" && !linkPopover && !isRectOutsideClip(toolbarRect, getIframeVisibleClip(parentScrollRef.current)) && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
|
23509
23545
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
23510
23546
|
EditGlowChrome,
|
|
23511
23547
|
{
|