@useinsider/guido 3.6.0-beta.596b70e → 3.6.0-beta.5cbaa8f
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/extensions/Blocks/Recommendation/controls/main/index.js +12 -10
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +32 -24
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +40 -34
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +338 -310
- package/dist/extensions/Blocks/Recommendation/extension.js +5 -6
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +2 -3
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +146 -117
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -49
- package/dist/extensions/Blocks/Recommendation/templates/index.js +8 -9
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +83 -110
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -31
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +54 -90
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +19 -24
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +16 -20
- package/dist/extensions/Blocks/Unsubscribe/block.js +122 -72
- package/dist/extensions/Blocks/controlFactories.js +133 -159
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +47 -20
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +2 -3
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +11 -127
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -15
- package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +9 -20
- package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +9 -0
- package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -11
- package/package.json +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +0 -139
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.test.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.test.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.test.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +0 -44
- package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.test.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.test.d.ts +0 -1
|
@@ -23,7 +23,7 @@ export declare function resolveProductAttrValue(attrName: string, filterList: Fi
|
|
|
23
23
|
* @param productAttrValue - The resolved `product-attr` value (e.g., "brand" or "product_attribute.rating_star")
|
|
24
24
|
* @param content - The display content for the cell
|
|
25
25
|
*/
|
|
26
|
-
export type CustomCellHtmlGetter = (productAttrValue: string, content: string
|
|
26
|
+
export type CustomCellHtmlGetter = (productAttrValue: string, content: string) => string;
|
|
27
27
|
/**
|
|
28
28
|
* Symbol key for embedding custom attribute HTML in an ElementRenderer.
|
|
29
29
|
* Grid and list renderers store their custom-attribute cell template under this key
|
|
@@ -46,70 +46,10 @@ export declare const CUSTOM_CELL_HTML: unique symbol;
|
|
|
46
46
|
*/
|
|
47
47
|
export declare function buildElementRenderer(baseRenderer: ElementRenderer, composition: string[], filterList?: FiltersResponse): ElementRenderer;
|
|
48
48
|
export type Orientation = 'list' | 'grid';
|
|
49
|
-
/**
|
|
50
|
-
* A captured "style template" for one text attribute, used to bake user-applied
|
|
51
|
-
* styling back into regenerated HTML in a SINGLE setInnerHtml/apply pass.
|
|
52
|
-
*
|
|
53
|
-
* Stripo applies inline formats as TAGS (`<strong>`, `<em>`, `<s>`), not CSS, so we
|
|
54
|
-
* preserve the actual wrapper tags around the text — re-emitting `text-decoration`
|
|
55
|
-
* CSS would render a strike that Stripo's own toggle can't detect. `pStyle` carries
|
|
56
|
-
* the `<p>`-level inline CSS (font-size/color/align/etc.).
|
|
57
|
-
*/
|
|
58
|
-
export interface AttributeStyleTemplate {
|
|
59
|
-
/** Raw inline style for the `<p>`, e.g. "font-size: 18px; color: #111;" */
|
|
60
|
-
pStyle?: string;
|
|
61
|
-
/** Opening inline-format tags captured around the text (or button label), e.g. "<strong><em>" */
|
|
62
|
-
openTags?: string;
|
|
63
|
-
/** Matching closing tags in reverse order, e.g. "</em></strong>" */
|
|
64
|
-
closeTags?: string;
|
|
65
|
-
/** Button: inline style of the `<span class="es-button-border">` (background/border/radius). */
|
|
66
|
-
buttonBorderStyle?: string;
|
|
67
|
-
/** Button: inline style of the `<a class="es-button">` (color/background/font/padding/width). */
|
|
68
|
-
buttonAnchorStyle?: string;
|
|
69
|
-
/** Button: whether "Fit to Container" is on (the `es-fw` class on the border span). */
|
|
70
|
-
buttonFitToContainer?: boolean;
|
|
71
|
-
/** Image: inline style of the `<img>` (width/height/max-width/border-radius/margin). */
|
|
72
|
-
imgStyle?: string;
|
|
73
|
-
}
|
|
74
|
-
/** Per-attribute style templates keyed by ATTR_PRODUCT_* composition key. */
|
|
75
|
-
export type AttributeStyleTemplates = Record<string, AttributeStyleTemplate>;
|
|
76
|
-
/** Per-attribute "Block Background Color" values keyed by ATTR_PRODUCT_* composition key. */
|
|
77
|
-
export type CellBackgroundColors = Record<string, string>;
|
|
78
|
-
/**
|
|
79
|
-
* Per-cell rendering context passed to each ElementRenderer function so a single
|
|
80
|
-
* regeneration can bake column spacing and preserved styles directly into the HTML.
|
|
81
|
-
*/
|
|
82
|
-
export interface CellRenderOptions {
|
|
83
|
-
/** Column-spacing padding for the attribute cell, e.g. "0 7px". Falls back to DEFAULT_CELL_PADDING. */
|
|
84
|
-
cellPadding?: string;
|
|
85
|
-
/** Captured style template for this attribute (preserves user bold/italic/strike + p-style). */
|
|
86
|
-
styleTemplate?: AttributeStyleTemplate;
|
|
87
|
-
/** Card background color baked onto the `.product-card-segment` of every cell. */
|
|
88
|
-
cardBackgroundColor?: string;
|
|
89
|
-
/** This text attribute's "Block Background Color", baked onto its `[esd-extension-block-id]` cell. */
|
|
90
|
-
cellBackgroundColor?: string;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Spacing + preserved-style values baked into generated HTML so a regeneration
|
|
94
|
-
* needs only a single setInnerHtml/apply (no deferred reapply pass). Shared by the
|
|
95
|
-
* grid and list layout generators and by `PrepareProductRowsOptions`.
|
|
96
|
-
*/
|
|
97
|
-
export interface RenderOptions {
|
|
98
|
-
/** Column-spacing padding baked into product cells (grid) or the card wrapper (list), e.g. "0 7px". */
|
|
99
|
-
cellPadding?: string;
|
|
100
|
-
/** Row-spacing height in px baked into spacer rows between product rows. */
|
|
101
|
-
rowSpacingPx?: number;
|
|
102
|
-
/** Per-attribute captured style templates to preserve user styling across regeneration. */
|
|
103
|
-
styleTemplates?: AttributeStyleTemplates;
|
|
104
|
-
/** Card background color baked into the card containers (`.product-card-segment` / `.product-card-wrapper`). */
|
|
105
|
-
cardBackgroundColor?: string;
|
|
106
|
-
/** Per-attribute "Block Background Color" values baked onto each text cell across regeneration. */
|
|
107
|
-
cellBackgroundColors?: CellBackgroundColors;
|
|
108
|
-
}
|
|
109
49
|
/**
|
|
110
50
|
* Options for prepareProductRows unified function
|
|
111
51
|
*/
|
|
112
|
-
export interface PrepareProductRowsOptions
|
|
52
|
+
export interface PrepareProductRowsOptions {
|
|
113
53
|
/** Number of products per row (only for grid layout, defaults to 3) */
|
|
114
54
|
productsPerRow?: number;
|
|
115
55
|
/** Number of products per row on mobile (only for grid layout, defaults to 1) */
|
|
@@ -127,15 +67,15 @@ export interface PrepareProductRowsOptions extends RenderOptions {
|
|
|
127
67
|
* for custom attributes — used by `buildElementRenderer` to create custom entries.
|
|
128
68
|
*/
|
|
129
69
|
export interface ElementRenderer {
|
|
130
|
-
[ATTR_PRODUCT_IMAGE]: (product: RecommendationProduct
|
|
131
|
-
[ATTR_PRODUCT_NAME]: (product: RecommendationProduct
|
|
132
|
-
[ATTR_PRODUCT_PRICE]: (product: RecommendationProduct
|
|
133
|
-
[ATTR_PRODUCT_OLD_PRICE]: (product: RecommendationProduct
|
|
134
|
-
[ATTR_PRODUCT_OMNIBUS_PRICE]: (product: RecommendationProduct
|
|
135
|
-
[ATTR_PRODUCT_OMNIBUS_DISCOUNT]: (product: RecommendationProduct
|
|
136
|
-
[ATTR_PRODUCT_BUTTON]: (product: RecommendationProduct
|
|
70
|
+
[ATTR_PRODUCT_IMAGE]: (product: RecommendationProduct) => string;
|
|
71
|
+
[ATTR_PRODUCT_NAME]: (product: RecommendationProduct) => string;
|
|
72
|
+
[ATTR_PRODUCT_PRICE]: (product: RecommendationProduct) => string;
|
|
73
|
+
[ATTR_PRODUCT_OLD_PRICE]: (product: RecommendationProduct) => string;
|
|
74
|
+
[ATTR_PRODUCT_OMNIBUS_PRICE]: (product: RecommendationProduct) => string;
|
|
75
|
+
[ATTR_PRODUCT_OMNIBUS_DISCOUNT]: (product: RecommendationProduct) => string;
|
|
76
|
+
[ATTR_PRODUCT_BUTTON]: (product: RecommendationProduct) => string;
|
|
137
77
|
[CUSTOM_CELL_HTML]?: CustomCellHtmlGetter;
|
|
138
|
-
[key: string]: (product: RecommendationProduct
|
|
78
|
+
[key: string]: (product: RecommendationProduct) => string;
|
|
139
79
|
}
|
|
140
80
|
/**
|
|
141
81
|
* Product card getter function type
|
|
@@ -148,63 +88,7 @@ export declare const DEFAULTS: {
|
|
|
148
88
|
};
|
|
149
89
|
export declare const DEFAULT_CARD_COMPOSITION: string[];
|
|
150
90
|
export declare const DEFAULT_CARD_VISIBILITY: Record<string, boolean>;
|
|
151
|
-
|
|
152
|
-
export declare const DEFAULT_ROW_SPACING_PX = 10;
|
|
153
|
-
/**
|
|
154
|
-
* Builds a spacer row with the given height. Baking row spacing into the HTML lets
|
|
155
|
-
* regeneration use a single setInnerHtml/apply instead of a deferred reapply pass.
|
|
156
|
-
*/
|
|
157
|
-
export declare function buildSpacer(heightPx?: number): string;
|
|
158
|
-
export declare const spacer: string;
|
|
159
|
-
/**
|
|
160
|
-
* Resolves the `<p>` inline style for a text cell. When a captured template exists,
|
|
161
|
-
* it wins (even when empty — meaning the user cleared the style); otherwise the
|
|
162
|
-
* renderer's default style is used.
|
|
163
|
-
*/
|
|
164
|
-
export declare function resolvePStyle(defaultPStyle: string, template?: AttributeStyleTemplate): string;
|
|
165
|
-
/**
|
|
166
|
-
* Renders `<p>…text…</p>` for a text attribute, preserving captured inline-format
|
|
167
|
-
* tags (`<strong>`/`<em>`/`<s>`) and p-style when a template is supplied, or falling
|
|
168
|
-
* back to the renderer defaults. A present-but-empty template faithfully drops the
|
|
169
|
-
* default wrapper (e.g. the user removed bold).
|
|
170
|
-
*/
|
|
171
|
-
export declare function renderStyledParagraph(text: string, defaults: {
|
|
172
|
-
pStyle: string;
|
|
173
|
-
openTags: string;
|
|
174
|
-
closeTags: string;
|
|
175
|
-
}, template?: AttributeStyleTemplate): string;
|
|
176
|
-
/**
|
|
177
|
-
* Builds the inline style for a card container (`.product-card-segment` in grid,
|
|
178
|
-
* `.product-card-wrapper` in list), appending the captured card background color to any
|
|
179
|
-
* base style. Returns '' when there is nothing to set.
|
|
180
|
-
*/
|
|
181
|
-
export declare function resolveSegmentBgStyle(baseStyle: string, cardBackgroundColor?: string): string;
|
|
182
|
-
/**
|
|
183
|
-
* Builds the ` style="background-color: …"` attribute for a text attribute's
|
|
184
|
-
* `[esd-extension-block-id]` cell, baking in the captured "Block Background Color".
|
|
185
|
-
* Returns '' when there is nothing to set (the cell otherwise carries no inline style).
|
|
186
|
-
*/
|
|
187
|
-
export declare function cellBgStyleAttr(cellBackgroundColor?: string): string;
|
|
188
|
-
/**
|
|
189
|
-
* Wraps a button label in the captured inline-format tags (bold/italic), or returns it
|
|
190
|
-
* plain. Mirrors text wrapper preservation for the button's `<a>` content.
|
|
191
|
-
*/
|
|
192
|
-
export declare function renderButtonLabel(label: string, template?: AttributeStyleTemplate): string;
|
|
193
|
-
/**
|
|
194
|
-
* Resolves the `<span class="es-button-border">` class, adding `es-fw` (full-width)
|
|
195
|
-
* when the captured template had "Fit to Container" on. Stripo applies fit via this
|
|
196
|
-
* class, not inline width, so we preserve the class across regeneration.
|
|
197
|
-
*/
|
|
198
|
-
export declare function resolveButtonBorderClass(template?: AttributeStyleTemplate): string;
|
|
199
|
-
/** Default inline style for the product image `<img>` (used when nothing is captured). */
|
|
200
|
-
export declare const DEFAULT_IMG_STYLE = "display: block; max-width: 100%; height: auto;";
|
|
201
|
-
/** Default inline style for the button `<span class="es-button-border">`. */
|
|
202
|
-
export declare const DEFAULT_BUTTON_BORDER_STYLE: string;
|
|
203
|
-
/**
|
|
204
|
-
* Default inline style for the button `<a class="es-button">`. The list layout appends its
|
|
205
|
-
* own `padding: 5px 30px;` on top of this shared base.
|
|
206
|
-
*/
|
|
207
|
-
export declare const DEFAULT_BUTTON_ANCHOR_STYLE: string;
|
|
91
|
+
export declare const spacer = "\n <tr>\n <td class=\"spacer\" style=\"height: 10px;\"></td>\n </tr>\n";
|
|
208
92
|
export declare const PLACEHOLDER_IMAGE = "https://email-static.useinsider.com/stripo/modules/email-recommendation-v3/assets/images/image-placeholder.png";
|
|
209
93
|
/**
|
|
210
94
|
* Sanitizes product image URLs for consistent rendering
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
2
|
-
/**
|
|
3
|
-
* Extracts the nested inline-format wrapper tags around text content, outermost first.
|
|
4
|
-
*
|
|
5
|
-
* Stripo applies bold/italic/underline/strike as tags (`<strong>/<em>/<u>/<s>`), so to
|
|
6
|
-
* preserve user formatting across a text swap or block regeneration we capture the actual
|
|
7
|
-
* wrapper tags rather than CSS.
|
|
8
|
-
* @example
|
|
9
|
-
* // '<strong><em>Hi</em></strong>' → { openTags: '<strong><em>', closeTags: '</em></strong>' }
|
|
10
|
-
* @param html - The inner HTML to parse
|
|
11
|
-
* @returns The concatenated opening tags and matching closing tags (empty strings if none)
|
|
12
|
-
*/
|
|
13
|
-
export declare function extractWrapperTags(html: string): {
|
|
14
|
-
openTags: string;
|
|
15
|
-
closeTags: string;
|
|
16
|
-
};
|
|
17
2
|
/**
|
|
18
3
|
* Preserves existing style tags when updating text content
|
|
19
4
|
*
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Style Preserver Utility
|
|
3
|
+
*
|
|
4
|
+
* Captures and restores element styles during block regeneration.
|
|
5
|
+
* This ensures user styling is preserved when:
|
|
6
|
+
* - Layout changes (grid <-> list)
|
|
7
|
+
* - Cards per row changes
|
|
8
|
+
* - Composition order changes
|
|
9
|
+
*
|
|
10
|
+
* Works with the node config system to provide complete style persistence.
|
|
11
|
+
*/
|
|
12
|
+
import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
13
|
+
import { ModificationDescription } from '@stripoinc/ui-editor-extensions';
|
|
14
|
+
/**
|
|
15
|
+
* Style properties that can be captured for text elements
|
|
16
|
+
*/
|
|
17
|
+
export interface TextElementStyles {
|
|
18
|
+
fontSize?: string;
|
|
19
|
+
fontFamily?: string;
|
|
20
|
+
fontWeight?: string;
|
|
21
|
+
fontStyle?: string;
|
|
22
|
+
color?: string;
|
|
23
|
+
textAlign?: string;
|
|
24
|
+
lineHeight?: string;
|
|
25
|
+
textDecoration?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Style properties for button elements
|
|
29
|
+
*/
|
|
30
|
+
export interface ButtonElementStyles extends TextElementStyles {
|
|
31
|
+
backgroundColor?: string;
|
|
32
|
+
borderRadius?: string;
|
|
33
|
+
border?: string;
|
|
34
|
+
padding?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Style properties for image elements
|
|
38
|
+
*/
|
|
39
|
+
export interface ImageElementStyles {
|
|
40
|
+
width?: string;
|
|
41
|
+
height?: string;
|
|
42
|
+
maxWidth?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Complete captured styles for a recommendation block
|
|
46
|
+
*/
|
|
47
|
+
export interface CapturedStyles {
|
|
48
|
+
/** Product name text styles */
|
|
49
|
+
name: TextElementStyles;
|
|
50
|
+
/** Current price text styles */
|
|
51
|
+
price: TextElementStyles;
|
|
52
|
+
/** Original/old price text styles */
|
|
53
|
+
oldPrice: TextElementStyles;
|
|
54
|
+
/** Omnibus price text styles */
|
|
55
|
+
omnibusPrice: TextElementStyles;
|
|
56
|
+
/** Omnibus discount text styles */
|
|
57
|
+
omnibusDiscount: TextElementStyles;
|
|
58
|
+
/** CTA button styles */
|
|
59
|
+
button: ButtonElementStyles;
|
|
60
|
+
/** Product image styles */
|
|
61
|
+
image: ImageElementStyles;
|
|
62
|
+
/** Card background color */
|
|
63
|
+
cardBackgroundColor: string | null;
|
|
64
|
+
/** Column spacing in pixels */
|
|
65
|
+
columnSpacing: number;
|
|
66
|
+
/** Row spacing in pixels */
|
|
67
|
+
rowSpacing: number;
|
|
68
|
+
/** Element composition order */
|
|
69
|
+
composition: string[];
|
|
70
|
+
/** Element visibility flags */
|
|
71
|
+
visibility: Record<string, boolean>;
|
|
72
|
+
}
|
|
73
|
+
type DocumentModifier = {
|
|
74
|
+
modifyHtml: (node: ImmutableHtmlNode) => {
|
|
75
|
+
setStyle: (prop: string, value: string) => DocumentModifier;
|
|
76
|
+
};
|
|
77
|
+
apply: (description: ModificationDescription) => void;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Capture all styles from a recommendation block
|
|
81
|
+
*
|
|
82
|
+
* Call this BEFORE any operation that regenerates the block HTML.
|
|
83
|
+
* The captured styles can then be restored after regeneration.
|
|
84
|
+
* @example
|
|
85
|
+
* // Before layout change
|
|
86
|
+
* const styles = captureStyles(this.currentNode);
|
|
87
|
+
*
|
|
88
|
+
* // ... regenerate block HTML ...
|
|
89
|
+
*
|
|
90
|
+
* // After regeneration
|
|
91
|
+
* restoreStyles(this.currentNode, this.api.getDocumentModifier(), styles);
|
|
92
|
+
* @param node - The block node to capture styles from
|
|
93
|
+
* @returns Complete captured styles object
|
|
94
|
+
*/
|
|
95
|
+
export declare function captureStyles(node: ImmutableHtmlNode | null | undefined): CapturedStyles;
|
|
96
|
+
/**
|
|
97
|
+
* Restore captured styles to a regenerated block
|
|
98
|
+
*
|
|
99
|
+
* Call this AFTER regenerating block HTML to reapply user styling.
|
|
100
|
+
* @example
|
|
101
|
+
* restoreStyles(this.currentNode, this.api.getDocumentModifier(), capturedStyles);
|
|
102
|
+
* @param node - The block node to restore styles to
|
|
103
|
+
* @param modifier - Document modifier for applying changes
|
|
104
|
+
* @param styles - Previously captured styles
|
|
105
|
+
*/
|
|
106
|
+
export declare function restoreStyles(node: ImmutableHtmlNode | null | undefined, modifier: DocumentModifier, styles: CapturedStyles): void;
|
|
107
|
+
/**
|
|
108
|
+
* Check if styles have meaningful content worth restoring
|
|
109
|
+
* @param styles - Captured styles to check
|
|
110
|
+
* @returns True if styles contain restorable content
|
|
111
|
+
*/
|
|
112
|
+
export declare function hasRestorableStyles(styles: CapturedStyles): boolean;
|
|
113
|
+
export {};
|
|
@@ -5,18 +5,14 @@
|
|
|
5
5
|
* Handles both standard DOM properties and Stripo's custom methods.
|
|
6
6
|
*/
|
|
7
7
|
import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
8
|
+
/** Interface for nodes with standard tagName property */
|
|
9
|
+
interface NodeWithTagName {
|
|
10
|
+
tagName: string;
|
|
11
|
+
}
|
|
8
12
|
/** Interface for nodes with getStyle method */
|
|
9
13
|
export interface NodeWithGetStyle {
|
|
10
14
|
getStyle: (property: string) => string | null | undefined;
|
|
11
15
|
}
|
|
12
|
-
/** Interface for nodes with getComputedStyle method */
|
|
13
|
-
export interface NodeWithGetComputedStyle {
|
|
14
|
-
getComputedStyle: (property: string) => string | null | undefined;
|
|
15
|
-
}
|
|
16
|
-
/** Interface for nodes with getAttribute method */
|
|
17
|
-
export interface NodeWithGetAttribute {
|
|
18
|
-
getAttribute: (name: string) => string | null;
|
|
19
|
-
}
|
|
20
16
|
/** Interface for nodes with parent method */
|
|
21
17
|
export interface NodeWithParent {
|
|
22
18
|
parent: () => ImmutableHtmlNode | null;
|
|
@@ -27,23 +23,15 @@ export interface NodeWithParent {
|
|
|
27
23
|
*/
|
|
28
24
|
export declare function hasGetStyle(node: unknown): node is NodeWithGetStyle;
|
|
29
25
|
/**
|
|
30
|
-
* Type guard to check if a node has
|
|
31
|
-
* This is the only read that sees a background applied by Stripo's built-in
|
|
32
|
-
* "Block Background Color" control — it writes neither an inline style nor a
|
|
33
|
-
* queryable stylesheet rule, but the computed value is still resolvable.
|
|
34
|
-
* @param node - The node to check
|
|
35
|
-
*/
|
|
36
|
-
export declare function hasGetComputedStyle(node: unknown): node is NodeWithGetComputedStyle;
|
|
37
|
-
/**
|
|
38
|
-
* Type guard to check if a node has getAttribute method
|
|
26
|
+
* Type guard to check if a node has parent method
|
|
39
27
|
* @param node - The node to check
|
|
40
28
|
*/
|
|
41
|
-
export declare function
|
|
29
|
+
export declare function hasParent(node: unknown): node is NodeWithParent;
|
|
42
30
|
/**
|
|
43
|
-
* Type guard to check if a node
|
|
31
|
+
* Type guard to check if a node is a TD element
|
|
44
32
|
* @param node - The node to check
|
|
45
33
|
*/
|
|
46
|
-
export declare function
|
|
34
|
+
export declare function isTdNode(node: unknown): node is ImmutableHtmlNode & NodeWithTagName;
|
|
47
35
|
/**
|
|
48
36
|
* Safely retrieves a style value from a node
|
|
49
37
|
* @param node - The node to get the style from
|
|
@@ -86,3 +74,4 @@ export declare function isTableCellNode(node: ImmutableHtmlNode | null | undefin
|
|
|
86
74
|
* @returns The CSS display value ('table-cell' or 'table-row')
|
|
87
75
|
*/
|
|
88
76
|
export declare function getTableDisplayValue(node: ImmutableHtmlNode | null | undefined): 'table-cell' | 'table-row';
|
|
77
|
+
export {};
|
|
@@ -6,6 +6,7 @@ export declare class UnsubscribeBlock extends Block {
|
|
|
6
6
|
private cancelEventListener;
|
|
7
7
|
private currentNode?;
|
|
8
8
|
private linkStateByBlockId;
|
|
9
|
+
private guardAttemptsByBlockId;
|
|
9
10
|
constructor();
|
|
10
11
|
getId(): string;
|
|
11
12
|
getIcon(): string;
|
|
@@ -15,9 +16,17 @@ export declare class UnsubscribeBlock extends Block {
|
|
|
15
16
|
getTemplate(): string;
|
|
16
17
|
getContextActionsIds(): string[];
|
|
17
18
|
onSelect(node: ImmutableHtmlElementNode): void;
|
|
19
|
+
onCreated(node: ImmutableHtmlNode): void;
|
|
20
|
+
onDocumentInit(): void;
|
|
18
21
|
onDocumentChanged(node: ImmutableHtmlNode): void;
|
|
19
22
|
onDelete(node: ImmutableHtmlElementNode): void;
|
|
20
23
|
onDestroy(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Guarantees a plain-text node before the link's wrapper inside the <p>.
|
|
26
|
+
* Without it the only caret position left of the link is inside the anchor,
|
|
27
|
+
* so anything typed there becomes part of the link (SD-143097).
|
|
28
|
+
*/
|
|
29
|
+
private _ensureLeadingTextGuard;
|
|
21
30
|
private _hasUnsubscribeLink;
|
|
22
31
|
private _readBlockId;
|
|
23
32
|
/**
|
|
@@ -280,21 +280,11 @@ export declare function createButtonTextStyleAndFontColorControl(controlId: stri
|
|
|
280
280
|
new (): {
|
|
281
281
|
getId(): string;
|
|
282
282
|
getTargetNodes(root: ImmutableHtmlNode): ImmutableHtmlNode[];
|
|
283
|
-
/**
|
|
284
|
-
* Propagates Bold/Italic to ALL product buttons, not just the focused one.
|
|
285
|
-
*
|
|
286
|
-
* Stripo's built-in applies font-color/size to every target node but writes
|
|
287
|
-
* the text-style (font-weight/font-style) only to the selected button. Bold/italic
|
|
288
|
-
* are plain inline CSS on the `<a class="es-button">` (no tags), so we mirror them
|
|
289
|
-
* onto every button's anchor. The toggle state comes from the control's form
|
|
290
|
-
* (`buttonTextStyleForm.{bold,italic}`) because the patched node isn't updated yet
|
|
291
|
-
* when this runs. Returned modifications are merged into the parent control's patch.
|
|
292
|
-
*/
|
|
293
|
-
getAdditionalModifications(root: ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
|
|
294
283
|
getParentControlId(): string;
|
|
295
284
|
getLabels(): import("@stripoinc/ui-editor-extensions").ButtonTextStyleAndFontColorControlLabels | undefined;
|
|
296
285
|
api: import("@stripoinc/ui-editor-extensions").ControlApi;
|
|
297
286
|
getModificationDescription(): import("@stripoinc/ui-editor-extensions").ModificationDescription | undefined;
|
|
287
|
+
getAdditionalModifications(_root: ImmutableHtmlNode): import("@stripoinc/ui-editor-extensions").TemplateModifier<import("@stripoinc/ui-editor-extensions").HtmlNodeModifier, import("@stripoinc/ui-editor-extensions").CssNodeModifier> | undefined;
|
|
298
288
|
isVisible(_node: ImmutableHtmlNode): boolean;
|
|
299
289
|
};
|
|
300
290
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.6.0-beta.
|
|
3
|
+
"version": "3.6.0-beta.5cbaa8f",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { RecommendationBlockId as i } from "../constants/blockIds.js";
|
|
2
|
-
import { DESKTOP_CONTAINER_SELECTOR as S, ATTR_PRODUCT_NAME as _, ATTR_PRODUCT_PRICE as C, ATTR_PRODUCT_OLD_PRICE as I, ATTR_PRODUCT_OMNIBUS_PRICE as O, ATTR_PRODUCT_OMNIBUS_DISCOUNT as k, ATTR_PRODUCT_BUTTON as A, ATTR_PRODUCT_IMAGE as E } from "../constants/selectors.js";
|
|
3
|
-
import { extractWrapperTags as g } from "./preserveTextStyles.js";
|
|
4
|
-
import { hasGetStyle as f, hasGetAttribute as P, hasGetComputedStyle as h } from "./tagName.js";
|
|
5
|
-
const c = [
|
|
6
|
-
"font-size",
|
|
7
|
-
"font-family",
|
|
8
|
-
"font-weight",
|
|
9
|
-
"font-style",
|
|
10
|
-
"color",
|
|
11
|
-
"text-align",
|
|
12
|
-
"line-height",
|
|
13
|
-
"text-decoration"
|
|
14
|
-
], B = [
|
|
15
|
-
"background",
|
|
16
|
-
"background-color",
|
|
17
|
-
"border-width",
|
|
18
|
-
"border-color",
|
|
19
|
-
"border-style",
|
|
20
|
-
"border-radius"
|
|
21
|
-
], N = [
|
|
22
|
-
...c,
|
|
23
|
-
"background",
|
|
24
|
-
"background-color",
|
|
25
|
-
"padding",
|
|
26
|
-
"width",
|
|
27
|
-
"mso-border-alt",
|
|
28
|
-
"mso-padding-alt"
|
|
29
|
-
], U = [
|
|
30
|
-
"display",
|
|
31
|
-
"width",
|
|
32
|
-
"height",
|
|
33
|
-
"max-width",
|
|
34
|
-
"border-radius",
|
|
35
|
-
"margin"
|
|
36
|
-
], l = /* @__PURE__ */ new Set(["transparent", "rgba(0, 0, 0, 0)"]), q = [
|
|
37
|
-
{ attrKey: _, blockId: i.NAME, kind: "text" },
|
|
38
|
-
{ attrKey: C, blockId: i.PRICE, kind: "text" },
|
|
39
|
-
{ attrKey: I, blockId: i.OLD_PRICE, kind: "text" },
|
|
40
|
-
{ attrKey: O, blockId: i.OMNIBUS_PRICE, kind: "text" },
|
|
41
|
-
{ attrKey: k, blockId: i.OMNIBUS_DISCOUNT, kind: "text" },
|
|
42
|
-
{ attrKey: A, blockId: i.BUTTON, kind: "button" },
|
|
43
|
-
{ attrKey: E, blockId: i.IMAGE, kind: "image" }
|
|
44
|
-
];
|
|
45
|
-
function y(t) {
|
|
46
|
-
return t && "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML().trim() : "";
|
|
47
|
-
}
|
|
48
|
-
function a(t, r, e) {
|
|
49
|
-
!r || !f(r) || e.forEach((o) => {
|
|
50
|
-
const n = r.getStyle(o);
|
|
51
|
-
n && n !== "inherit" && n !== "initial" && (t[o] = n);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function b(t) {
|
|
55
|
-
return Object.entries(t).map(([r, e]) => `${r}: ${e};`).join(" ");
|
|
56
|
-
}
|
|
57
|
-
function p(t) {
|
|
58
|
-
if (!t || !f(t))
|
|
59
|
-
return;
|
|
60
|
-
const r = t.getStyle("background-color") || t.getStyle("background");
|
|
61
|
-
return r && !l.has(r) ? r : void 0;
|
|
62
|
-
}
|
|
63
|
-
function d(t, r) {
|
|
64
|
-
const e = {};
|
|
65
|
-
return a(e, t, r), b(e);
|
|
66
|
-
}
|
|
67
|
-
function M(t) {
|
|
68
|
-
const r = t.querySelector("p"), e = {};
|
|
69
|
-
a(e, t, c), a(e, r, c), a(e, t.querySelector("strong"), c), a(e, t.querySelector("em"), c), a(e, t.querySelector("s"), c);
|
|
70
|
-
const o = b(e), { openTags: n, closeTags: u } = g(y(r));
|
|
71
|
-
return !o && !n ? null : { pStyle: o || void 0, openTags: n, closeTags: u };
|
|
72
|
-
}
|
|
73
|
-
function x(t) {
|
|
74
|
-
const r = t.querySelector(".es-button-border"), e = t.querySelector("a.es-button") ?? t.querySelector("a"), o = d(r, B), n = d(e, N), u = r && "getAttribute" in r ? r.getAttribute("class") ?? "" : "", s = /\bes-fw\b/.test(u), { openTags: T, closeTags: R } = g(y(e));
|
|
75
|
-
return !o && !n && !s && !T ? null : {
|
|
76
|
-
buttonBorderStyle: o || void 0,
|
|
77
|
-
buttonAnchorStyle: n || void 0,
|
|
78
|
-
buttonFitToContainer: s || void 0,
|
|
79
|
-
openTags: T,
|
|
80
|
-
closeTags: R
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function D(t) {
|
|
84
|
-
const r = d(t.querySelector("img"), U);
|
|
85
|
-
return r ? { imgStyle: r } : null;
|
|
86
|
-
}
|
|
87
|
-
function v(t, r) {
|
|
88
|
-
return r === "button" ? x(t) : r === "image" ? D(t) : M(t);
|
|
89
|
-
}
|
|
90
|
-
function m(t, r) {
|
|
91
|
-
if (!t || !("querySelector" in t))
|
|
92
|
-
return;
|
|
93
|
-
const e = t.querySelector(S) ?? t;
|
|
94
|
-
q.forEach(({ attrKey: o, blockId: n, kind: u }) => {
|
|
95
|
-
const s = e.querySelector(`[esd-extension-block-id="${n}"]`);
|
|
96
|
-
s && r(s, o, u);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
function F(t) {
|
|
100
|
-
const r = {};
|
|
101
|
-
return m(t, (e, o, n) => {
|
|
102
|
-
if (!("querySelector" in e))
|
|
103
|
-
return;
|
|
104
|
-
const u = v(e, n);
|
|
105
|
-
u && (r[o] = u);
|
|
106
|
-
}), r;
|
|
107
|
-
}
|
|
108
|
-
function $(t) {
|
|
109
|
-
if (!t || !("querySelector" in t))
|
|
110
|
-
return;
|
|
111
|
-
const r = t.querySelector(S) ?? t, e = r.querySelector(".product-card-segment") ?? r.querySelector(".product-card-wrapper");
|
|
112
|
-
return p(e);
|
|
113
|
-
}
|
|
114
|
-
function K(t) {
|
|
115
|
-
if (!t)
|
|
116
|
-
return;
|
|
117
|
-
const r = P(t) ? t.getAttribute("bgcolor") : null;
|
|
118
|
-
if (r && !l.has(r))
|
|
119
|
-
return r;
|
|
120
|
-
const e = p(t);
|
|
121
|
-
if (e)
|
|
122
|
-
return e;
|
|
123
|
-
const o = h(t) ? t.getComputedStyle("background-color") : void 0;
|
|
124
|
-
return o && !l.has(o) ? o : void 0;
|
|
125
|
-
}
|
|
126
|
-
function j(t) {
|
|
127
|
-
const r = {};
|
|
128
|
-
return m(t, (e, o, n) => {
|
|
129
|
-
if (n !== "text")
|
|
130
|
-
return;
|
|
131
|
-
const u = K(e);
|
|
132
|
-
u && (r[o] = u);
|
|
133
|
-
}), r;
|
|
134
|
-
}
|
|
135
|
-
export {
|
|
136
|
-
F as captureAttributeStyleTemplates,
|
|
137
|
-
$ as captureCardBackgroundColor,
|
|
138
|
-
j as captureCellBackgroundColors
|
|
139
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Capture Style Templates
|
|
3
|
-
*
|
|
4
|
-
* Reads the user-applied styling of each text attribute from the LIVE block DOM
|
|
5
|
-
* and turns it into per-attribute `AttributeStyleTemplate`s that the template
|
|
6
|
-
* renderers bake straight into regenerated HTML.
|
|
7
|
-
*
|
|
8
|
-
* Why this exists: a full regeneration replaces product cells via `setInnerHtml`.
|
|
9
|
-
* Querying the new cells to re-apply styles after `apply()` requires a second
|
|
10
|
-
* (deferred) commit, and multiple commits corrupt Stripo's selection tracking
|
|
11
|
-
* (the `textContent` crash). Baking the captured styles into the HTML keeps the
|
|
12
|
-
* whole regeneration a SINGLE `setInnerHtml` + SINGLE `apply()`.
|
|
13
|
-
*
|
|
14
|
-
* Inline formats (bold/italic/strike) are captured as TAGS (`<strong>/<em>/<s>`),
|
|
15
|
-
* not CSS, because Stripo applies and detects them as tags — re-emitting
|
|
16
|
-
* `text-decoration` CSS would render a strike its own toggle can't see.
|
|
17
|
-
*/
|
|
18
|
-
import type { AttributeStyleTemplates } from '../templates/utils';
|
|
19
|
-
import type { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
20
|
-
/**
|
|
21
|
-
* Captures per-attribute style templates (text + button + image) from the block's desktop
|
|
22
|
-
* container. Scoped to desktop so the mobile container's duplicate block ids aren't read.
|
|
23
|
-
* Returns only the attributes that actually have styling worth preserving.
|
|
24
|
-
*/
|
|
25
|
-
export declare function captureAttributeStyleTemplates(node: ImmutableHtmlNode | null | undefined): AttributeStyleTemplates;
|
|
26
|
-
/**
|
|
27
|
-
* Captures the card background color (the "Styles" tab control) from the first card
|
|
28
|
-
* container — `.product-card-segment` in grid, `.product-card-wrapper` in list. Returns
|
|
29
|
-
* undefined when unset/transparent so the renderer keeps its (bg-less) default.
|
|
30
|
-
*/
|
|
31
|
-
export declare function captureCardBackgroundColor(node: ImmutableHtmlNode | null | undefined): string | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Captures each text attribute's "Block Background Color" (Styles tab) from the block's
|
|
34
|
-
* desktop container, keyed by ATTR_PRODUCT_* composition key. The renderers bake these
|
|
35
|
-
* straight onto the regenerated `[esd-extension-block-id]` cell so the bg survives a full
|
|
36
|
-
* regeneration — unlike the card background, the text-cell bg lives on the attribute cell
|
|
37
|
-
* itself and is only readable via `getComputedStyle` (see `readCellBackground`). Returns
|
|
38
|
-
* only the attributes that actually carry a non-transparent background.
|
|
39
|
-
*
|
|
40
|
-
* Scope note: custom attributes (`customAttr:*`) share the single CUSTOM_ATTRIBUTE block id
|
|
41
|
-
* and aren't in `CAPTURE_TARGETS`, so their bg is applied live but not preserved here — same
|
|
42
|
-
* boundary as `captureAttributeStyleTemplates`.
|
|
43
|
-
*/
|
|
44
|
-
export declare function captureCellBackgroundColors(node: ImmutableHtmlNode | null | undefined): Record<string, string>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|