@useinsider/guido 1.0.3-beta.ea69f4a → 1.0.3-beta.f2389d0
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/README.md +3 -0
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/organisms/LoadingWrapper.vue.js +1 -1
- package/dist/components/organisms/header/RightSlot.vue2.js +13 -13
- package/dist/composables/useActionsApi.js +23 -32
- package/dist/composables/useStripo.js +46 -48
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +25 -25
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +92 -0
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +94 -90
- package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
- package/dist/extensions/Blocks/Items/enums/productEnums.js +3 -2
- package/dist/extensions/Blocks/Items/enums/settingsEnums.js +3 -2
- package/dist/extensions/Blocks/Items/extension.js +7 -6
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +2 -2
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +17 -5
- package/dist/extensions/Blocks/Items/settingsPanel.js +25 -24
- package/dist/extensions/Blocks/Items/store/items-block.js +8 -4
- package/dist/extensions/Blocks/Items/template.js +65 -59
- package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +35 -26
- package/dist/extensions/Blocks/Items/utils/updateAttributes.js +29 -27
- package/dist/extensions/Blocks/Unsubscribe/block.js +34 -30
- package/dist/guido.css +1 -1
- package/dist/src/composables/useActionsApi.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +15 -0
- package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/enums/settingsEnums.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +2 -0
- package/dist/src/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.d.ts +6 -0
- package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +3 -4
- package/package.json +3 -1
- package/dist/composables/useTimerClone.js +0 -67
- package/dist/src/composables/useTimerClone.d.ts +0 -5
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (n, i, e) =>
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var _ = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
|
|
3
|
+
var u = (n, i, e) => _(n, typeof i != "symbol" ? i + "" : i, e);
|
|
4
4
|
import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
|
|
5
5
|
import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
|
|
6
|
-
import { Block as
|
|
7
|
-
import { getDefaultTemplate as
|
|
6
|
+
import { Block as h, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
|
+
import { getDefaultTemplate as L } from "./template.js";
|
|
8
8
|
import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
|
|
9
|
-
import { parsePageList as
|
|
10
|
-
const
|
|
9
|
+
import { parsePageList as p } from "./utils/utils.js";
|
|
10
|
+
const g = "unsubscribe-block", v = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", B = "{{ins-unsubscribe-link}}", T = {
|
|
11
11
|
[E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
|
|
12
12
|
[E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
|
|
13
13
|
};
|
|
14
|
-
class
|
|
14
|
+
class R extends h {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
17
|
u(this, "selectEventListener", null);
|
|
@@ -19,13 +19,13 @@ class D extends d {
|
|
|
19
19
|
u(this, "currentNode");
|
|
20
20
|
}
|
|
21
21
|
getId() {
|
|
22
|
-
return
|
|
22
|
+
return g;
|
|
23
23
|
}
|
|
24
24
|
getIcon() {
|
|
25
25
|
return "unsubscribe-icon";
|
|
26
26
|
}
|
|
27
27
|
getBlockCompositionType() {
|
|
28
|
-
return
|
|
28
|
+
return S.BLOCK;
|
|
29
29
|
}
|
|
30
30
|
getName() {
|
|
31
31
|
return this.api.translate("Unsubscribe Block");
|
|
@@ -34,13 +34,10 @@ class D extends d {
|
|
|
34
34
|
return this.api.translate("Unsubscribe Block Description");
|
|
35
35
|
}
|
|
36
36
|
getTemplate() {
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
onCreated(e) {
|
|
40
|
-
"getOuterHTML" in e && !e.getOuterHTML() || "getAttribute" in e && e.getAttribute("data-migration") || (this.currentNode = e, this._resetStoreState(), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
|
|
37
|
+
return L();
|
|
41
38
|
}
|
|
42
39
|
onSelect(e) {
|
|
43
|
-
this.currentNode = e, this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener();
|
|
40
|
+
this.currentNode = e, !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
|
|
44
41
|
}
|
|
45
42
|
onDelete(e) {
|
|
46
43
|
this._removeEventListeners(), this._removeBlockTemplatesFromStore(e), this._resetStoreState();
|
|
@@ -66,7 +63,13 @@ class D extends d {
|
|
|
66
63
|
this.cancelEventListener && (document.removeEventListener(a.CANCEL, this.cancelEventListener), this.cancelEventListener = null);
|
|
67
64
|
}
|
|
68
65
|
_handleCancel() {
|
|
69
|
-
|
|
66
|
+
try {
|
|
67
|
+
if (!this.currentNode)
|
|
68
|
+
return;
|
|
69
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).delete().apply(new b("Removed unsubscribe block due to cancel"));
|
|
70
|
+
} catch (e) {
|
|
71
|
+
console.warn("[UnsubscribeBlock] Failed to remove unsubscribe block:", e);
|
|
72
|
+
}
|
|
70
73
|
}
|
|
71
74
|
_removeEventListeners() {
|
|
72
75
|
this._removeSelectEventListener(), this._removeCancelEventListener();
|
|
@@ -74,26 +77,27 @@ class D extends d {
|
|
|
74
77
|
_updateBlock(e, s) {
|
|
75
78
|
if (!this.currentNode || !("querySelector" in this.currentNode))
|
|
76
79
|
return;
|
|
77
|
-
const t = this.currentNode.querySelector(
|
|
80
|
+
const t = this.currentNode.querySelector(v);
|
|
78
81
|
if (!t)
|
|
79
82
|
return;
|
|
80
83
|
const r = this._getMergeTag(e);
|
|
81
84
|
this.api.getDocumentModifier().modifyHtml(t).setAttribute("href", r).apply(new b(`Updated unsubscribe link to ${r}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, s).apply(new b("Updated unsubscribe block metadata"));
|
|
82
85
|
}
|
|
83
86
|
_getMergeTag(e) {
|
|
84
|
-
return
|
|
87
|
+
return T[e] ?? B;
|
|
85
88
|
}
|
|
86
89
|
_openDrawer() {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
|
|
91
|
+
try {
|
|
92
|
+
const e = c();
|
|
93
|
+
e.typeSelectionDrawerStatus = !0;
|
|
94
|
+
} catch (e) {
|
|
95
|
+
console.error("[UnsubscribeBlock] Failed to open drawer:", e);
|
|
96
|
+
}
|
|
93
97
|
}
|
|
94
98
|
_checkExistingBlocks() {
|
|
95
99
|
const e = c();
|
|
96
|
-
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(
|
|
100
|
+
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((t) => {
|
|
97
101
|
if ("getAttribute" in t) {
|
|
98
102
|
const r = t.getAttribute(o.PAGE_TYPE);
|
|
99
103
|
if (r) {
|
|
@@ -109,8 +113,8 @@ class D extends d {
|
|
|
109
113
|
const s = e.getAttribute(o.PAGE_TYPE), t = e.getAttribute(o.PAGE_LIST);
|
|
110
114
|
if (!s || !t)
|
|
111
115
|
return;
|
|
112
|
-
const r = c(), l = Number(s),
|
|
113
|
-
r.setCollectionWithoutAutoSelection(l), r.loadSelectedTemplates(
|
|
116
|
+
const r = c(), l = Number(s), m = p(t);
|
|
117
|
+
r.setCollectionWithoutAutoSelection(l), r.loadSelectedTemplates(m);
|
|
114
118
|
}
|
|
115
119
|
_resetStoreState() {
|
|
116
120
|
c().$reset();
|
|
@@ -121,11 +125,11 @@ class D extends d {
|
|
|
121
125
|
const s = e.getAttribute(o.PAGE_LIST);
|
|
122
126
|
if (!s)
|
|
123
127
|
return;
|
|
124
|
-
const t = c(), r =
|
|
128
|
+
const t = c(), r = p(s);
|
|
125
129
|
t.removeUnsubscribePages(r);
|
|
126
130
|
}
|
|
127
131
|
}
|
|
128
132
|
export {
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
g as UNSUBSCRIBE_BLOCK_ID,
|
|
134
|
+
R as UnsubscribeBlock
|
|
131
135
|
};
|
package/dist/guido.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.gap-16[data-v-6562e38c],.gap-16[data-v-1ccb6d4a]{gap:16px}[data-v-0502bceb] .in-button-v2__wrapper{line-height:0}[data-v-b5997368] .in-segments-wrapper .in-tooltip-wrapper__box{text-align:left}.version-history-item[data-v-ee4b9c3f]{flex-basis:200px}.version-history-wrapper[data-v-52a77eec]{gap:8px}.view-options-wrapper[data-v-d405ca59]{position:relative;display:inline-block}.new-tag[data-v-d405ca59]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-d405ca59] .guido__verion-history-view-option-selection-desktop svg,[data-v-d405ca59] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-d405ca59] .in-segments-wrapper__button_selected,[data-v-d405ca59] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-d405ca59] .in-tooltip-wrapper__icon{cursor:pointer}.view-options-wrapper[data-v-195ab6d4]{position:relative;display:inline-block}.new-tag[data-v-195ab6d4]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-195ab6d4] .guido__view-option-selection-desktop svg,[data-v-195ab6d4] .guido__view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-195ab6d4] .in-segments-wrapper__button_selected,[data-v-195ab6d4] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-195ab6d4] .in-tooltip-wrapper__icon{cursor:pointer}.guido-loading__wrapper[data-v-
|
|
1
|
+
.gap-16[data-v-6562e38c],.gap-16[data-v-1ccb6d4a]{gap:16px}[data-v-0502bceb] .in-button-v2__wrapper{line-height:0}[data-v-b5997368] .in-segments-wrapper .in-tooltip-wrapper__box{text-align:left}.version-history-item[data-v-ee4b9c3f]{flex-basis:200px}.version-history-wrapper[data-v-52a77eec]{gap:8px}.view-options-wrapper[data-v-d405ca59]{position:relative;display:inline-block}.new-tag[data-v-d405ca59]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-d405ca59] .guido__verion-history-view-option-selection-desktop svg,[data-v-d405ca59] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-d405ca59] .in-segments-wrapper__button_selected,[data-v-d405ca59] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-d405ca59] .in-tooltip-wrapper__icon{cursor:pointer}.view-options-wrapper[data-v-195ab6d4]{position:relative;display:inline-block}.new-tag[data-v-195ab6d4]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-195ab6d4] .guido__view-option-selection-desktop svg,[data-v-195ab6d4] .guido__view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-195ab6d4] .in-segments-wrapper__button_selected,[data-v-195ab6d4] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-195ab6d4] .in-tooltip-wrapper__icon{cursor:pointer}.guido-loading__wrapper[data-v-07c4b2d8]{height:100%;top:75px!important;bottom:0!important}.guido-editor__wrapper[data-v-98181b5a]{position:relative;width:100%;height:calc(100vh - 128px)}.guido-editor__container[data-v-98181b5a]{width:100%;height:calc(100vh - 128px)}.guido-editor__no-header[data-v-98181b5a]{height:calc(100vh - 75px)}[data-v-70835920] .in-breadcrumb-wrapper__links{cursor:pointer}.templates-wrapper[data-v-a86fc486]{gap:16px;grid-template-columns:repeat(3,1fr)}.templates-wrapper .template-wrapper[data-v-a86fc486]{cursor:pointer}.templates-wrapper .template-wrapper .template-container[data-v-a86fc486]{height:274px;padding:2px;transition:none}.templates-wrapper .template-wrapper .template-container.selected[data-v-a86fc486]{padding:1px}.templates-wrapper .template-wrapper .template-container .thumbnail[data-v-a86fc486]{object-fit:cover;transform:scale(1)}[data-v-dd57102d] .guido__verion-history-view-option-selection-desktop svg,[data-v-dd57102d] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-dd57102d] .in-segments-wrapper__button_selected,[data-v-dd57102d] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}.error-list[data-v-7a09985c]{gap:16px}[data-v-c2adc57d] .in-progress-wrapper__progress p span:last-child{display:none!important}.desktop-preview-container[data-v-2dd60b0c],[data-v-2dd60b0c] .desktop-preview-container .in-container{min-height:720px!important;height:100%}.cropped-text[data-v-f20b3a9b]{width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}[data-v-d3c52b44] .vueperslides__bullets,[data-v-dd1a237a] .vueperslides__bullets{pointer-events:none!important}[data-v-dd1a237a] .vueperslides__parallax-wrapper{height:110px!important}[data-v-a408dcea] .vueperslides__bullets{pointer-events:none!important}[data-v-a408dcea] .vueperslides__parallax-wrapper{height:110px!important}
|
|
@@ -5,5 +5,4 @@ export declare const useActionsApi: () => {
|
|
|
5
5
|
getTemplateData: () => Promise<TemplateData>;
|
|
6
6
|
activateCustomViewStyles: (isActive?: boolean) => void;
|
|
7
7
|
getPreviewData: (options?: CompileEmailOptions) => Promise<CompiledEmailResult>;
|
|
8
|
-
updateTimerInClonedTemplate: () => Promise<string | null>;
|
|
9
8
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
2
|
+
import { CommonControl } from '../../../common-control';
|
|
3
|
+
import { ItemsBlockControlId } from '../../enums/controlEnums';
|
|
4
|
+
export declare const CONTROL_BLOCK_ID = ItemsBlockControlId.PRICE_ORIENTATION;
|
|
5
|
+
export declare class PriceOrientationControl extends CommonControl {
|
|
6
|
+
private store;
|
|
7
|
+
getId(): string;
|
|
8
|
+
getTemplate(): string;
|
|
9
|
+
onRender(): void;
|
|
10
|
+
onTemplateNodeUpdated(node: ImmutableHtmlNode): void;
|
|
11
|
+
_onPriceOrientationChange(value: string): void;
|
|
12
|
+
private _updateHorizontalLayout;
|
|
13
|
+
private _updateVerticalLayout;
|
|
14
|
+
_getPriceOrientation(): string;
|
|
15
|
+
}
|
|
@@ -44,6 +44,7 @@ export declare enum ItemsBlockControlId {
|
|
|
44
44
|
PRICE_FORMATTED_PRICE = "items-block-price-formatted-price-control",
|
|
45
45
|
PRICE_CURRENCY_SYMBOL = "items-block-price-currency-symbol-control",
|
|
46
46
|
PRICE_CURRENCY_LOCATION = "items-block-price-currency-location-control",
|
|
47
|
+
PRICE_ORIENTATION = "items-block-price-orientation-control",
|
|
47
48
|
NAME_ALIGN = "items-block-name-align-control",
|
|
48
49
|
NAME_COLOR = "items-block-name-color-control",
|
|
49
50
|
NAME_SIZE = "items-block-name-size-control",
|
|
@@ -8,6 +8,7 @@ export declare const configAttributes: {
|
|
|
8
8
|
PRODUCT_PRICE_FORMATTED: string;
|
|
9
9
|
PRODUCT_PRICE_CURRENCY_SYMBOL: string;
|
|
10
10
|
PRODUCT_PRICE_CURRENCY_LOCATION: string;
|
|
11
|
+
PRODUCT_ORIGINAL_PRICE_CONTROL_ORIENTATION: string;
|
|
11
12
|
PRODUCT_BUTTON_LINK: string;
|
|
12
13
|
PRODUCT_IMAGE_LINK: string;
|
|
13
14
|
PRODUCT_NAME_CONTROL_VALUE: string;
|
|
@@ -10,6 +10,7 @@ interface ItemsBlockState {
|
|
|
10
10
|
currencySymbol: string;
|
|
11
11
|
currencyLocation: string;
|
|
12
12
|
formattedPrice: boolean;
|
|
13
|
+
priceOrientation: 'vertical' | 'horizontal';
|
|
13
14
|
templateData: {
|
|
14
15
|
imageSrc: string;
|
|
15
16
|
name: string;
|
|
@@ -30,6 +31,7 @@ export declare const useItemsBlockStore: import("pinia").StoreDefinition<"guidoI
|
|
|
30
31
|
setCurrencySymbol(currencySymbol: string): void;
|
|
31
32
|
setCurrencyLocation(currencyLocation: string): void;
|
|
32
33
|
setFormattedPrice(formattedPrice: boolean): void;
|
|
34
|
+
setPriceOrientation(priceOrientation: "vertical" | "horizontal"): void;
|
|
33
35
|
setTemplateData(templateData: ItemsBlockState["templateData"]): void;
|
|
34
36
|
updateFromAttributes(attributes: {
|
|
35
37
|
itemsType?: string;
|
|
@@ -42,3 +42,9 @@ export declare function syncButtonLinkFromAttributes(currentNode: ImmutableHtmlN
|
|
|
42
42
|
* @param currentNode - The current node from the control (usually this.currentNode)
|
|
43
43
|
*/
|
|
44
44
|
export declare function syncImageLinkFromAttributes(currentNode: ImmutableHtmlNode | undefined): void;
|
|
45
|
+
/**
|
|
46
|
+
* Reads price orientation value from esd-config-block attribute and updates the store.
|
|
47
|
+
* This makes the price orientation value mutable by syncing it from the DOM.
|
|
48
|
+
* @param currentNode - The current node from the control (usually this.currentNode)
|
|
49
|
+
*/
|
|
50
|
+
export declare function syncPriceOrientationFromAttributes(currentNode: ImmutableHtmlNode | undefined): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ImmutableHtmlElementNode } from '@stripoinc/ui-editor-extensions';
|
|
2
2
|
import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
|
|
3
3
|
export declare const UNSUBSCRIBE_BLOCK_ID = "unsubscribe-block";
|
|
4
4
|
export declare class UnsubscribeBlock extends Block {
|
|
@@ -12,9 +12,8 @@ export declare class UnsubscribeBlock extends Block {
|
|
|
12
12
|
getName(): string;
|
|
13
13
|
getDescription(): string;
|
|
14
14
|
getTemplate(): string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
onDelete(node: ImmutableHtmlNode): undefined;
|
|
15
|
+
onSelect(node: ImmutableHtmlElementNode): void;
|
|
16
|
+
onDelete(node: ImmutableHtmlElementNode): void;
|
|
18
17
|
onDestroy(): void;
|
|
19
18
|
private _setupSelectEventListener;
|
|
20
19
|
private _removeSelectEventListener;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "1.0.3-beta.
|
|
3
|
+
"version": "1.0.3-beta.f2389d0",
|
|
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",
|
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
"vue": "2.7.14"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
+
"@commitlint/cli": "20.2.0",
|
|
45
|
+
"@commitlint/config-conventional": "20.2.0",
|
|
44
46
|
"@cspell/eslint-plugin": "8.17.5",
|
|
45
47
|
"@eslint/eslintrc": "3.3.0",
|
|
46
48
|
"@eslint/js": "8.57.1",
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { useToaster as I } from "./useToaster.js";
|
|
2
|
-
const M = () => {
|
|
3
|
-
const { handleError: d } = I(), a = (n) => /esd-timer-id="(\d+)"/.test(n), c = async (n, s) => {
|
|
4
|
-
try {
|
|
5
|
-
console.debug("[TIMER CLONE] Calling Stripo API to clone timers...");
|
|
6
|
-
const e = await fetch("https://plugins.stripo.email/api/v1/timers/clone", {
|
|
7
|
-
method: "POST",
|
|
8
|
-
headers: {
|
|
9
|
-
"ES-PLUGIN-AUTH": `Bearer ${s}`,
|
|
10
|
-
"Content-Type": "application/json"
|
|
11
|
-
},
|
|
12
|
-
body: JSON.stringify({ html: n })
|
|
13
|
-
});
|
|
14
|
-
if (console.debug("[TIMER CLONE] API response status:", e.status), !e.ok) {
|
|
15
|
-
const r = await e.text();
|
|
16
|
-
throw console.debug("[TIMER CLONE] API error:", r), new Error(`Stripo API error: ${e.status} ${e.statusText}`);
|
|
17
|
-
}
|
|
18
|
-
const t = await e.json();
|
|
19
|
-
return console.debug("[TIMER CLONE] Timers cloned successfully. Map:", t.timersMap), console.debug("[TIMER CLONE] Old HTML length:", n.length), console.debug("[TIMER CLONE] New HTML length:", t.html.length), t.html;
|
|
20
|
-
} catch (e) {
|
|
21
|
-
return console.debug("[TIMER CLONE] Error:", e), d(e, "Failed to clone timer IDs"), null;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
return {
|
|
25
|
-
hasTimerBlocks: a,
|
|
26
|
-
cloneTimersInHtml: c,
|
|
27
|
-
updateTimersOnLoad: async (n) => {
|
|
28
|
-
var s, e, t, r, l, u;
|
|
29
|
-
try {
|
|
30
|
-
console.debug("[TIMER CLONE] Starting timer update on template load...");
|
|
31
|
-
const o = (e = (s = window.UIEditor) == null ? void 0 : s.getHtml) == null ? void 0 : e.call(s);
|
|
32
|
-
if (!o) {
|
|
33
|
-
console.debug("[TIMER CLONE] No HTML found, skipping timer update");
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const E = a(o);
|
|
37
|
-
if (console.debug("[TIMER CLONE] Has timer blocks?", E), !E)
|
|
38
|
-
return;
|
|
39
|
-
const T = o.match(/esd-timer-id="(\d+)"/g);
|
|
40
|
-
console.debug("[TIMER CLONE] Current timer IDs:", T), console.debug("[TIMER CLONE] Getting auth token...");
|
|
41
|
-
const p = await n();
|
|
42
|
-
if (!p) {
|
|
43
|
-
console.debug("[TIMER CLONE] No auth token available, skipping timer update");
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const i = await c(o, p);
|
|
47
|
-
if (!i) {
|
|
48
|
-
console.debug("[TIMER CLONE] API returned no updated HTML");
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
if (i === o) {
|
|
52
|
-
console.debug("[TIMER CLONE] HTML unchanged, no update needed");
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const m = i.match(/esd-timer-id="(\d+)"/g);
|
|
56
|
-
console.debug("[TIMER CLONE] New timer IDs:", m);
|
|
57
|
-
const g = ((r = (t = window.UIEditor) == null ? void 0 : t.getCss) == null ? void 0 : r.call(t)) || "";
|
|
58
|
-
console.debug("[TIMER CLONE] Updating editor with new HTML..."), (u = (l = window.StripoEditorApi) == null ? void 0 : l.actionsApi) != null && u.updateHtmlAndCss ? (window.StripoEditorApi.actionsApi.updateHtmlAndCss(i, g), console.debug("[TIMER CLONE] ✅ Editor updated successfully!")) : console.debug("[TIMER CLONE] updateHtmlAndCss method not available");
|
|
59
|
-
} catch (o) {
|
|
60
|
-
console.debug("[TIMER CLONE] Error updating timers:", o), d(o, "Failed to update timer blocks");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
export {
|
|
66
|
-
M as useTimerClone
|
|
67
|
-
};
|