@ohhwells/bridge 0.1.146 → 0.1.147
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 +92 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +91 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -469,6 +469,13 @@ interface AiSectionsState {
|
|
|
469
469
|
}
|
|
470
470
|
/** Parse a persisted value defensively — malformed state renders nothing, never throws. */
|
|
471
471
|
declare function parseAiSectionsState(raw: string | null | undefined): AiSectionsState;
|
|
472
|
+
/**
|
|
473
|
+
* Drop every `text-align` declaration from the inline style attributes in one content string,
|
|
474
|
+
* removing a style attribute that carried nothing else. Regex rather than DOMParser so the fold
|
|
475
|
+
* stays pure and usable outside a browser; the only authors of these attributes are the bridge's
|
|
476
|
+
* own `sanitizeHtml` and the model's alignment wraps, which both emit double-quoted attributes.
|
|
477
|
+
*/
|
|
478
|
+
declare function stripTextAlignCss(html: string): string;
|
|
472
479
|
/**
|
|
473
480
|
* Fold alignment overrides that target GENERATED sections into their trees, where alignment is
|
|
474
481
|
* first-class data (block.align) that persists with the rest of the tree. A node override
|
|
@@ -867,4 +874,4 @@ declare function useOhwCarousel(key: string, initial: CarouselSlide[]): {
|
|
|
867
874
|
bind: Record<string, string>;
|
|
868
875
|
};
|
|
869
876
|
|
|
870
|
-
export { AI_DEFAULT_BRAND, AI_FOOTER_KEY, AI_TREE_SCHEMA_VERSIONS, AI_TREE_TOKENS, type AiBlockNode, type AiBrandKit, type AiFooterBottomBar, type AiFooterColumn, type AiFooterLayoutTree, AiFooterRenderer, type AiFooterRendererProps, type AiLayoutTree, AiTreeRenderer, type AiTreeRendererProps, type CarouselSlide, CustomToolbar, CustomToolbarButton, CustomToolbarDivider, DragHandle, DropIndicator, type DropIndicatorProps, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, EmptySection, type EmptySectionProps, FOOTER_COLUMN_BLOCKS, FOOTER_COLUMN_SPANS, FOOTER_SOCIAL_PLATFORMS, ItemActionToolbar, type ItemActionToolbarProps, ItemInteractionLayer, type ItemInteractionLayerProps, type ItemInteractionState, LinkEditorPanel, type LinkModalMode, type LinkModalProps, type LinkPage, LinkPopover, type LinkSection, OhhwellsBridge, SchedulingWidget, type SectionScaffold, type SiteLegalLinks, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, addFooterLinkColumn, appendFooterSocial, buildDefaultFooterTree, buildTarget, dropIndicatorVariants, ensureFooterTree, filterAvailablePages, foldAlignIntoTrees, getEditModeInitialState, insertFooterHours, isEditSessionActive, isRenderableFooterTree, isRenderableTree, isValidUrl, nextViableSlide, parseAiFooterState, parseAiSectionsState, parseTarget, removeFooterBlock, resolveFooterCopyright, serializeAiFooterState, stepViableSlide, toggleVariants, useOhwCarousel, validateUrlInput, viableSlides };
|
|
877
|
+
export { AI_DEFAULT_BRAND, AI_FOOTER_KEY, AI_TREE_SCHEMA_VERSIONS, AI_TREE_TOKENS, type AiBlockNode, type AiBrandKit, type AiFooterBottomBar, type AiFooterColumn, type AiFooterLayoutTree, AiFooterRenderer, type AiFooterRendererProps, type AiLayoutTree, AiTreeRenderer, type AiTreeRendererProps, type CarouselSlide, CustomToolbar, CustomToolbarButton, CustomToolbarDivider, DragHandle, DropIndicator, type DropIndicatorProps, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, EmptySection, type EmptySectionProps, FOOTER_COLUMN_BLOCKS, FOOTER_COLUMN_SPANS, FOOTER_SOCIAL_PLATFORMS, ItemActionToolbar, type ItemActionToolbarProps, ItemInteractionLayer, type ItemInteractionLayerProps, type ItemInteractionState, LinkEditorPanel, type LinkModalMode, type LinkModalProps, type LinkPage, LinkPopover, type LinkSection, OhhwellsBridge, SchedulingWidget, type SectionScaffold, type SiteLegalLinks, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, addFooterLinkColumn, appendFooterSocial, buildDefaultFooterTree, buildTarget, dropIndicatorVariants, ensureFooterTree, filterAvailablePages, foldAlignIntoTrees, getEditModeInitialState, insertFooterHours, isEditSessionActive, isRenderableFooterTree, isRenderableTree, isValidUrl, nextViableSlide, parseAiFooterState, parseAiSectionsState, parseTarget, removeFooterBlock, resolveFooterCopyright, serializeAiFooterState, stepViableSlide, stripTextAlignCss, toggleVariants, useOhwCarousel, validateUrlInput, viableSlides };
|
package/dist/index.d.ts
CHANGED
|
@@ -469,6 +469,13 @@ interface AiSectionsState {
|
|
|
469
469
|
}
|
|
470
470
|
/** Parse a persisted value defensively — malformed state renders nothing, never throws. */
|
|
471
471
|
declare function parseAiSectionsState(raw: string | null | undefined): AiSectionsState;
|
|
472
|
+
/**
|
|
473
|
+
* Drop every `text-align` declaration from the inline style attributes in one content string,
|
|
474
|
+
* removing a style attribute that carried nothing else. Regex rather than DOMParser so the fold
|
|
475
|
+
* stays pure and usable outside a browser; the only authors of these attributes are the bridge's
|
|
476
|
+
* own `sanitizeHtml` and the model's alignment wraps, which both emit double-quoted attributes.
|
|
477
|
+
*/
|
|
478
|
+
declare function stripTextAlignCss(html: string): string;
|
|
472
479
|
/**
|
|
473
480
|
* Fold alignment overrides that target GENERATED sections into their trees, where alignment is
|
|
474
481
|
* first-class data (block.align) that persists with the rest of the tree. A node override
|
|
@@ -867,4 +874,4 @@ declare function useOhwCarousel(key: string, initial: CarouselSlide[]): {
|
|
|
867
874
|
bind: Record<string, string>;
|
|
868
875
|
};
|
|
869
876
|
|
|
870
|
-
export { AI_DEFAULT_BRAND, AI_FOOTER_KEY, AI_TREE_SCHEMA_VERSIONS, AI_TREE_TOKENS, type AiBlockNode, type AiBrandKit, type AiFooterBottomBar, type AiFooterColumn, type AiFooterLayoutTree, AiFooterRenderer, type AiFooterRendererProps, type AiLayoutTree, AiTreeRenderer, type AiTreeRendererProps, type CarouselSlide, CustomToolbar, CustomToolbarButton, CustomToolbarDivider, DragHandle, DropIndicator, type DropIndicatorProps, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, EmptySection, type EmptySectionProps, FOOTER_COLUMN_BLOCKS, FOOTER_COLUMN_SPANS, FOOTER_SOCIAL_PLATFORMS, ItemActionToolbar, type ItemActionToolbarProps, ItemInteractionLayer, type ItemInteractionLayerProps, type ItemInteractionState, LinkEditorPanel, type LinkModalMode, type LinkModalProps, type LinkPage, LinkPopover, type LinkSection, OhhwellsBridge, SchedulingWidget, type SectionScaffold, type SiteLegalLinks, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, addFooterLinkColumn, appendFooterSocial, buildDefaultFooterTree, buildTarget, dropIndicatorVariants, ensureFooterTree, filterAvailablePages, foldAlignIntoTrees, getEditModeInitialState, insertFooterHours, isEditSessionActive, isRenderableFooterTree, isRenderableTree, isValidUrl, nextViableSlide, parseAiFooterState, parseAiSectionsState, parseTarget, removeFooterBlock, resolveFooterCopyright, serializeAiFooterState, stepViableSlide, toggleVariants, useOhwCarousel, validateUrlInput, viableSlides };
|
|
877
|
+
export { AI_DEFAULT_BRAND, AI_FOOTER_KEY, AI_TREE_SCHEMA_VERSIONS, AI_TREE_TOKENS, type AiBlockNode, type AiBrandKit, type AiFooterBottomBar, type AiFooterColumn, type AiFooterLayoutTree, AiFooterRenderer, type AiFooterRendererProps, type AiLayoutTree, AiTreeRenderer, type AiTreeRendererProps, type CarouselSlide, CustomToolbar, CustomToolbarButton, CustomToolbarDivider, DragHandle, DropIndicator, type DropIndicatorProps, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, EmptySection, type EmptySectionProps, FOOTER_COLUMN_BLOCKS, FOOTER_COLUMN_SPANS, FOOTER_SOCIAL_PLATFORMS, ItemActionToolbar, type ItemActionToolbarProps, ItemInteractionLayer, type ItemInteractionLayerProps, type ItemInteractionState, LinkEditorPanel, type LinkModalMode, type LinkModalProps, type LinkPage, LinkPopover, type LinkSection, OhhwellsBridge, SchedulingWidget, type SectionScaffold, type SiteLegalLinks, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, addFooterLinkColumn, appendFooterSocial, buildDefaultFooterTree, buildTarget, dropIndicatorVariants, ensureFooterTree, filterAvailablePages, foldAlignIntoTrees, getEditModeInitialState, insertFooterHours, isEditSessionActive, isRenderableFooterTree, isRenderableTree, isValidUrl, nextViableSlide, parseAiFooterState, parseAiSectionsState, parseTarget, removeFooterBlock, resolveFooterCopyright, serializeAiFooterState, stepViableSlide, stripTextAlignCss, toggleVariants, useOhwCarousel, validateUrlInput, viableSlides };
|
package/dist/index.js
CHANGED
|
@@ -6172,6 +6172,26 @@ function applyTreeToState(state, payload) {
|
|
|
6172
6172
|
const others = state.sections.filter((existing) => existing.id !== entry.id);
|
|
6173
6173
|
return { ...state, v: 1, sections: [...others, entry] };
|
|
6174
6174
|
}
|
|
6175
|
+
function stripTextAlignCss(html) {
|
|
6176
|
+
return html.replace(/\sstyle="([^"]*)"/gi, (whole, value) => {
|
|
6177
|
+
if (!/text-align\s*:/i.test(value)) return whole;
|
|
6178
|
+
const kept = value.split(";").map((decl) => decl.trim()).filter((decl) => decl && !/^text-align\s*:/i.test(decl)).join("; ");
|
|
6179
|
+
return kept ? ` style="${kept}"` : "";
|
|
6180
|
+
});
|
|
6181
|
+
}
|
|
6182
|
+
function stripTextAlignInValue(value) {
|
|
6183
|
+
if (typeof value === "string") return stripTextAlignCss(value);
|
|
6184
|
+
if (Array.isArray(value)) return value.map(stripTextAlignInValue);
|
|
6185
|
+
if (value && typeof value === "object") {
|
|
6186
|
+
return Object.fromEntries(
|
|
6187
|
+
Object.entries(value).map(([key, inner]) => [
|
|
6188
|
+
key,
|
|
6189
|
+
stripTextAlignInValue(inner)
|
|
6190
|
+
])
|
|
6191
|
+
);
|
|
6192
|
+
}
|
|
6193
|
+
return value;
|
|
6194
|
+
}
|
|
6175
6195
|
function foldAlignIntoTrees(state, store) {
|
|
6176
6196
|
const byId = new Map(state.sections.map((entry) => [entry.id, entry]));
|
|
6177
6197
|
const nextTrees = /* @__PURE__ */ new Map();
|
|
@@ -6194,6 +6214,12 @@ function foldAlignIntoTrees(state, store) {
|
|
|
6194
6214
|
return stripChildAligns(rest);
|
|
6195
6215
|
})
|
|
6196
6216
|
} : node;
|
|
6217
|
+
const stripContentAligns = (node) => ({
|
|
6218
|
+
...node,
|
|
6219
|
+
...node.slots ? { slots: stripTextAlignInValue(node.slots) } : {},
|
|
6220
|
+
...node.children ? { children: node.children.map(stripContentAligns) } : {}
|
|
6221
|
+
});
|
|
6222
|
+
const authoritative = (block) => stripChildAligns(stripContentAligns(block));
|
|
6197
6223
|
const nodes = {};
|
|
6198
6224
|
for (const [key, override] of Object.entries(store.nodes)) {
|
|
6199
6225
|
const match = override.align !== void 0 && key.startsWith(AI_SLOT_KEY_PREFIX) ? key.match(/^ai\.(.+?)\.r(\d+)\.b(\d+)(?:\.|$)/) : null;
|
|
@@ -6205,7 +6231,7 @@ function foldAlignIntoTrees(state, store) {
|
|
|
6205
6231
|
nodes[key] = override;
|
|
6206
6232
|
continue;
|
|
6207
6233
|
}
|
|
6208
|
-
row.blocks[blockIdx] = { ...
|
|
6234
|
+
row.blocks[blockIdx] = { ...authoritative(block), align: override.align };
|
|
6209
6235
|
const rest = { ...override };
|
|
6210
6236
|
delete rest.align;
|
|
6211
6237
|
if (Object.keys(rest).length > 0) nodes[key] = rest;
|
|
@@ -6218,7 +6244,7 @@ function foldAlignIntoTrees(state, store) {
|
|
|
6218
6244
|
continue;
|
|
6219
6245
|
}
|
|
6220
6246
|
for (const row of tree.rows) {
|
|
6221
|
-
row.blocks = row.blocks.map((block) => ({ ...
|
|
6247
|
+
row.blocks = row.blocks.map((block) => ({ ...authoritative(block), align: override.align }));
|
|
6222
6248
|
}
|
|
6223
6249
|
const rest = { ...override };
|
|
6224
6250
|
delete rest.align;
|
|
@@ -30124,14 +30150,73 @@ function OhhwellsBridge() {
|
|
|
30124
30150
|
value = JSON.stringify(foldedHeight.store);
|
|
30125
30151
|
}
|
|
30126
30152
|
}
|
|
30153
|
+
const restoreNodes = e.data.restoreNodes;
|
|
30154
|
+
const restored = [];
|
|
30155
|
+
if (restoreNodes && typeof restoreNodes === "object") {
|
|
30156
|
+
for (const [key, html] of Object.entries(restoreNodes)) {
|
|
30157
|
+
if (typeof html !== "string") continue;
|
|
30158
|
+
const els = document.querySelectorAll(`[data-ohw-key="${CSS.escape(key)}"]`);
|
|
30159
|
+
if (els.length === 0) continue;
|
|
30160
|
+
for (const el of Array.from(els)) el.innerHTML = html;
|
|
30161
|
+
editContentRef.current = { ...editContentRef.current, [key]: html };
|
|
30162
|
+
restored.push({ key, text: html });
|
|
30163
|
+
}
|
|
30164
|
+
}
|
|
30165
|
+
const previousNodes = {};
|
|
30166
|
+
const strippedNodes = [];
|
|
30167
|
+
if (!restoreNodes) {
|
|
30168
|
+
const aligned = parseStyleStore(value);
|
|
30169
|
+
const prior = parseStyleStore(previous);
|
|
30170
|
+
const keys = /* @__PURE__ */ new Set();
|
|
30171
|
+
if (aligned) {
|
|
30172
|
+
for (const [key, override] of Object.entries(aligned.nodes)) {
|
|
30173
|
+
if (override.align === void 0) continue;
|
|
30174
|
+
if (prior?.nodes[key]?.align === override.align) continue;
|
|
30175
|
+
keys.add(key);
|
|
30176
|
+
}
|
|
30177
|
+
for (const [sectionId, override] of Object.entries(aligned.sections)) {
|
|
30178
|
+
if (override.align === void 0) continue;
|
|
30179
|
+
if (prior?.sections[sectionId]?.align === override.align) continue;
|
|
30180
|
+
const escaped = CSS.escape(sectionId);
|
|
30181
|
+
const markers = document.querySelectorAll(
|
|
30182
|
+
`[data-ohw-instance="${escaped}"], [data-ohw-section="${escaped}"]`
|
|
30183
|
+
);
|
|
30184
|
+
for (const marker of Array.from(markers)) {
|
|
30185
|
+
const editables = marker.querySelectorAll(
|
|
30186
|
+
'[data-ohw-key][data-ohw-editable="text"], [data-ohw-key][data-ohw-editable="plain"]'
|
|
30187
|
+
);
|
|
30188
|
+
for (const el of Array.from(editables)) {
|
|
30189
|
+
const key = el.getAttribute("data-ohw-key");
|
|
30190
|
+
if (key) keys.add(key);
|
|
30191
|
+
}
|
|
30192
|
+
}
|
|
30193
|
+
}
|
|
30194
|
+
}
|
|
30195
|
+
for (const key of keys) {
|
|
30196
|
+
if (key.startsWith(AI_SLOT_KEY_PREFIX) || key.startsWith("__ohw_")) continue;
|
|
30197
|
+
const els = document.querySelectorAll(`[data-ohw-key="${CSS.escape(key)}"]`);
|
|
30198
|
+
if (els.length === 0) continue;
|
|
30199
|
+
const before = sanitizeHtml(els[0].innerHTML);
|
|
30200
|
+
const after = stripTextAlignCss(before);
|
|
30201
|
+
if (after === before) continue;
|
|
30202
|
+
for (const el of Array.from(els)) el.innerHTML = after;
|
|
30203
|
+
previousNodes[key] = before;
|
|
30204
|
+
editContentRef.current = { ...editContentRef.current, [key]: after };
|
|
30205
|
+
strippedNodes.push({ key, text: after });
|
|
30206
|
+
}
|
|
30207
|
+
}
|
|
30127
30208
|
stylesRef.current = value;
|
|
30128
30209
|
applyStylesToDom(parseStyleStore(value));
|
|
30129
|
-
postToParentRef.current({
|
|
30210
|
+
postToParentRef.current({
|
|
30211
|
+
type: "ow:change",
|
|
30212
|
+
nodes: [{ key: STYLE_STORE_KEY, text: value }, ...strippedNodes, ...restored]
|
|
30213
|
+
});
|
|
30130
30214
|
postToParentRef.current({
|
|
30131
30215
|
type: "ow:ai-styles-applied",
|
|
30132
30216
|
previous,
|
|
30133
30217
|
value,
|
|
30134
|
-
...previousSections !== void 0 ? { previousSections } : {}
|
|
30218
|
+
...previousSections !== void 0 ? { previousSections } : {},
|
|
30219
|
+
...Object.keys(previousNodes).length > 0 ? { previousNodes } : {}
|
|
30135
30220
|
});
|
|
30136
30221
|
};
|
|
30137
30222
|
window.addEventListener("message", handleAiSetStyles);
|
|
@@ -31476,7 +31561,7 @@ function OhhwellsBridge() {
|
|
|
31476
31561
|
postToParent2({
|
|
31477
31562
|
type: "ow:ready",
|
|
31478
31563
|
version: "1",
|
|
31479
|
-
bridgeVersion: "0.1.
|
|
31564
|
+
bridgeVersion: "0.1.146",
|
|
31480
31565
|
path: pathname,
|
|
31481
31566
|
nodes: collectEditableNodes(editContentRef.current),
|
|
31482
31567
|
sections
|
|
@@ -32706,6 +32791,7 @@ export {
|
|
|
32706
32791
|
resolveFooterCopyright,
|
|
32707
32792
|
serializeAiFooterState,
|
|
32708
32793
|
stepViableSlide,
|
|
32794
|
+
stripTextAlignCss,
|
|
32709
32795
|
toggleVariants,
|
|
32710
32796
|
useOhwCarousel,
|
|
32711
32797
|
validateUrlInput,
|