@useinsider/guido 1.4.4 → 2.0.0-beta.061e9c9
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 +297 -664
- package/dist/@types/config/defaults.js +44 -0
- package/dist/@types/config/schemas.js +233 -0
- package/dist/@types/config/validator.js +56 -0
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +64 -88
- package/dist/components/organisms/email-preview/desktop-preview/EmailHeaderInfo.vue2.js +13 -13
- package/dist/components/organisms/email-preview/mobile-preview/InboxView.vue.js +5 -5
- package/dist/components/organisms/email-preview/mobile-preview/InboxView.vue2.js +13 -13
- package/dist/components/organisms/header/LeftSlot.vue.js +1 -1
- package/dist/components/organisms/header/LeftSlot.vue2.js +18 -15
- package/dist/components/organisms/header/RightSlot.vue.js +10 -10
- package/dist/components/organisms/onboarding/NewVersionPopup.vue2.js +22 -19
- package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue.js +4 -4
- package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue2.js +8 -8
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.js +3 -3
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue2.js +17 -17
- package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue.js +10 -10
- package/dist/composables/useActionsApi.js +42 -25
- package/dist/composables/useBlocksConfig.js +23 -20
- package/dist/composables/useConfig.js +51 -5
- package/dist/composables/useHtmlCompiler.js +20 -19
- package/dist/composables/useHtmlValidator.js +41 -41
- package/dist/composables/usePartner.js +19 -9
- package/dist/composables/useStripo.js +58 -57
- package/dist/composables/useTimerClone.js +53 -0
- package/dist/composables/useTranslations.js +3 -2
- package/dist/config/compiler/unsubscribeCompilerRules.js +1 -1
- package/dist/enums/defaults.js +4 -67
- package/dist/enums/unsubscribe.js +23 -20
- package/dist/extensions/Blocks/CouponBlock/constants.js +4 -0
- package/dist/extensions/Blocks/CouponBlock/controls/index.js +29 -0
- package/dist/extensions/Blocks/CouponBlock/extension.js +5 -4
- package/dist/extensions/Blocks/CouponBlock/settingsPanel.js +20 -14
- package/dist/extensions/Blocks/CouponBlock/template.js +22 -11
- package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +158 -68
- package/dist/extensions/Blocks/Recommendation/constants.js +10 -1
- package/dist/extensions/Blocks/Recommendation/control.js +74 -59
- package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +68 -0
- package/dist/extensions/Blocks/Recommendation/controls/index.js +272 -0
- package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +74 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscountTextAfterControl.js +71 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscountTextBeforeControl.js +71 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPriceTextAfterControl.js +71 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPriceTextBeforeControl.js +71 -0
- package/dist/extensions/Blocks/Recommendation/controls/priceHideControl.js +60 -0
- package/dist/extensions/Blocks/Recommendation/controls/priceInlineLayoutControl.js +160 -0
- package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +188 -0
- package/dist/extensions/Blocks/Recommendation/extension.js +16 -40
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +124 -71
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +12 -11
- package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +89 -65
- package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +56 -19
- package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +74 -45
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +25 -0
- package/dist/extensions/Blocks/controlFactories.js +124 -113
- package/dist/guido.css +1 -1
- package/dist/library.js +12 -2
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +14 -14
- package/dist/node_modules/lodash-es/_arrayLikeKeys.js +10 -10
- package/dist/node_modules/valibot/dist/index.js +476 -103
- package/dist/services/stripoApi.js +11 -16
- package/dist/services/templateLibraryApi.js +18 -18
- package/dist/src/@types/config/defaults.d.ts +68 -0
- package/dist/src/@types/config/index.d.ts +14 -0
- package/dist/src/@types/config/schemas.d.ts +513 -0
- package/dist/src/@types/config/types.d.ts +142 -0
- package/dist/src/@types/config/validator.d.ts +119 -0
- package/dist/src/@types/generic.d.ts +4 -45
- package/dist/src/components/Guido.vue.d.ts +13 -12
- package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
- package/dist/src/composables/useActionsApi.d.ts +2 -0
- package/dist/src/composables/useConfig.d.ts +188 -2
- package/dist/src/composables/usePartner.d.ts +8 -0
- package/dist/src/composables/useTimerClone.d.ts +6 -0
- package/dist/src/enums/defaults.d.ts +5 -6
- package/dist/src/enums/unsubscribe.d.ts +5 -1
- package/dist/src/extensions/Blocks/CouponBlock/constants.d.ts +14 -0
- package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +108 -0
- package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/cardCompositionControl.d.ts +54 -3
- package/dist/src/extensions/Blocks/Recommendation/constants.d.ts +41 -1
- package/dist/src/extensions/Blocks/Recommendation/control.d.ts +5 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.d.ts +25 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +654 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +16 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextAfterControl.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextBeforeControl.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextAfterControl.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextBeforeControl.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/priceHideControl.d.ts +16 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/priceInlineLayoutControl.d.ts +50 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/spacingControl.d.ts +60 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +3 -3
- package/dist/src/extensions/Blocks/Recommendation/templates/migrationTemplate.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +15 -7
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +19 -0
- package/dist/src/extensions/Blocks/controlFactories.d.ts +30 -7
- package/dist/src/library.d.ts +3 -1
- package/dist/src/stores/config.d.ts +1581 -102
- package/dist/static/styles/components/narrow-panel.css.js +0 -10
- package/dist/static/styles/components/wide-panel.css.js +0 -4
- package/dist/static/styles/customEditorStyle.css.js +13 -0
- package/dist/stores/config.js +141 -9
- package/package.json +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/button/align.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/border.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/borderRadius.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/color.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/fitToContent.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/fontFamily.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/margins.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/paddings.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/text.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/textSize.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/button/textStyleAndFontColor.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/image/margins.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/image/size.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/align.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/background.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/color.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/fontFamily.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/paddings.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/size.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/name/style.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/align.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/background.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/color.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/fontFamily.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/paddings.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/size.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/style.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/align.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/background.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/color.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/fontFamily.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/paddings.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/size.js +0 -13
- package/dist/extensions/Blocks/Recommendation/controls/price/style.js +0 -13
- package/dist/node_modules/lodash-es/_apply.js +0 -16
- package/dist/node_modules/lodash-es/_assignMergeValue.js +0 -8
- package/dist/node_modules/lodash-es/_assignValue.js +0 -10
- package/dist/node_modules/lodash-es/_baseAssignValue.js +0 -12
- package/dist/node_modules/lodash-es/_baseCreate.js +0 -17
- package/dist/node_modules/lodash-es/_baseKeysIn.js +0 -15
- package/dist/node_modules/lodash-es/_baseMerge.js +0 -20
- package/dist/node_modules/lodash-es/_baseMergeDeep.js +0 -31
- package/dist/node_modules/lodash-es/_baseRest.js +0 -9
- package/dist/node_modules/lodash-es/_baseSetToString.js +0 -14
- package/dist/node_modules/lodash-es/_cloneArrayBuffer.js +0 -8
- package/dist/node_modules/lodash-es/_cloneBuffer.js +0 -9
- package/dist/node_modules/lodash-es/_cloneTypedArray.js +0 -8
- package/dist/node_modules/lodash-es/_copyArray.js +0 -9
- package/dist/node_modules/lodash-es/_copyObject.js +0 -14
- package/dist/node_modules/lodash-es/_createAssigner.js +0 -15
- package/dist/node_modules/lodash-es/_defineProperty.js +0 -11
- package/dist/node_modules/lodash-es/_getPrototype.js +0 -5
- package/dist/node_modules/lodash-es/_initCloneObject.js +0 -9
- package/dist/node_modules/lodash-es/_nativeKeysIn.js +0 -10
- package/dist/node_modules/lodash-es/_overRest.js +0 -15
- package/dist/node_modules/lodash-es/_safeGet.js +0 -7
- package/dist/node_modules/lodash-es/_setToString.js +0 -6
- package/dist/node_modules/lodash-es/_shortOut.js +0 -16
- package/dist/node_modules/lodash-es/constant.js +0 -8
- package/dist/node_modules/lodash-es/isArrayLikeObject.js +0 -8
- package/dist/node_modules/lodash-es/isPlainObject.js +0 -16
- package/dist/node_modules/lodash-es/keysIn.js +0 -9
- package/dist/node_modules/lodash-es/merge.js +0 -8
- package/dist/node_modules/lodash-es/toPlainObject.js +0 -8
- package/dist/src/extensions/Blocks/Recommendation/controls/button/align.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/border.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/borderRadius.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/color.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/fitToContent.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/fontFamily.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/margins.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/paddings.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/text.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/textSize.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/button/textStyleAndFontColor.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/image/margins.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/image/size.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/align.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/background.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/color.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/fontFamily.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/paddings.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/size.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/name/style.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/align.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/background.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/color.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/fontFamily.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/paddings.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/size.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/style.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/align.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/background.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/color.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/fontFamily.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/paddings.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/size.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/price/style.d.ts +0 -5
package/README.md
CHANGED
|
@@ -4,789 +4,422 @@
|
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
# @useinsider/guido
|
|
9
8
|
|
|
10
|
-
Guido is a Vue 2 + TypeScript wrapper for the Stripo Email Editor plugin. Easily embed the professional email editor in your Vue applications with a clean,
|
|
9
|
+
Guido is a Vue 2 + TypeScript wrapper for the Stripo Email Editor plugin. Easily embed the professional email editor in your Vue applications with a clean, type-safe configuration.
|
|
11
10
|
|
|
12
|
-
##
|
|
11
|
+
## Installation
|
|
13
12
|
|
|
14
13
|
```bash
|
|
15
14
|
npm install @useinsider/guido
|
|
16
15
|
```
|
|
16
|
+
|
|
17
17
|
### Prerequisites
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
// ... Upcoming Configs
|
|
42
|
-
```
|
|
18
|
+
|
|
19
|
+
Your project needs:
|
|
20
|
+
- Vue 2.7+
|
|
21
|
+
- Pinia (state management)
|
|
22
|
+
|
|
23
|
+
Add these to your bundler config to optimize dependencies:
|
|
24
|
+
|
|
25
|
+
**Webpack** (`webpack.config.js` or `vue.config.js`):
|
|
26
|
+
```js
|
|
27
|
+
shared: {
|
|
28
|
+
vue: { singleton: true },
|
|
29
|
+
pinia: { singleton: true },
|
|
30
|
+
},
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Vite** (`vite.config.js`):
|
|
34
|
+
```js
|
|
35
|
+
resolve: {
|
|
36
|
+
dedupe: ['vue', 'pinia'],
|
|
37
|
+
},
|
|
38
|
+
```
|
|
39
|
+
|
|
43
40
|
---
|
|
44
|
-
## 🚀 Usage
|
|
45
41
|
|
|
46
|
-
|
|
42
|
+
## Quick Start
|
|
47
43
|
|
|
48
|
-
```
|
|
44
|
+
```vue
|
|
49
45
|
<template>
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
:html="initialHtml"
|
|
58
|
-
:css="initialCss"
|
|
59
|
-
@dynamic-content:open="handleDynamicContentOpen"
|
|
60
|
-
@back="handleBack"
|
|
61
|
-
@save:start="handleSaveStart"
|
|
62
|
-
@save:complete="handleSaveComplete"
|
|
63
|
-
/>
|
|
64
|
-
</div>
|
|
46
|
+
<Guido
|
|
47
|
+
ref="guidoRef"
|
|
48
|
+
:config="config"
|
|
49
|
+
@ready="onReady"
|
|
50
|
+
@dynamic-content:open="onDynamicContentOpen"
|
|
51
|
+
@save:complete="onSaveComplete"
|
|
52
|
+
/>
|
|
65
53
|
</template>
|
|
66
54
|
|
|
67
|
-
<script lang="ts">
|
|
55
|
+
<script setup lang="ts">
|
|
56
|
+
import { ref } from 'vue';
|
|
68
57
|
import { Guido } from '@useinsider/guido';
|
|
58
|
+
import type { GuidoConfigInput } from '@useinsider/guido';
|
|
59
|
+
|
|
60
|
+
const guidoRef = ref<InstanceType<typeof Guido> | null>(null);
|
|
69
61
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
const config = ref<GuidoConfigInput>({
|
|
63
|
+
identity: {
|
|
64
|
+
templateId: 'template-123',
|
|
65
|
+
userId: 'user-456',
|
|
73
66
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
templateId: 'template-123',
|
|
77
|
-
userId: 'user-456',
|
|
78
|
-
migrationDate: 1699488000,
|
|
79
|
-
initialHtml: '<p>Initial HTML content</p>',
|
|
80
|
-
initialCss: 'p { color: #333; }',
|
|
81
|
-
guidoConfig: {
|
|
82
|
-
translationsPath: 'window.trans.en',
|
|
83
|
-
htmlCompilerRules: [],
|
|
84
|
-
ignoreDefaultHtmlCompilerRules: false,
|
|
85
|
-
backButtonLabel?: "Back to Design",
|
|
86
|
-
features: {
|
|
87
|
-
dynamicContent: true,
|
|
88
|
-
saveAsTemplate: true,
|
|
89
|
-
versionHistory: true,
|
|
90
|
-
testMessage: true
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
dynamicContentModalVisible: false
|
|
94
|
-
};
|
|
67
|
+
partner: {
|
|
68
|
+
name: 'your-partner-name',
|
|
95
69
|
},
|
|
70
|
+
template: {
|
|
71
|
+
html: '<p>Initial content</p>',
|
|
72
|
+
css: '',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
96
75
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
this.dynamicContentModalVisible = true;
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
handleBack() {
|
|
104
|
-
console.log('User clicked back button');
|
|
105
|
-
// Handle navigation back
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
handleSaveStart() {
|
|
109
|
-
console.log('Save process started');
|
|
110
|
-
// Show loading indicator
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
handleSaveComplete(template) {
|
|
114
|
-
console.log('Save completed:', template);
|
|
115
|
-
// Handle saved template data
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
// ⚠️ Your own Dynamic Content Modal should have this id: #guido-dynamic-content-modal
|
|
119
|
-
handleDynamicContentInsert() {
|
|
120
|
-
this.$refs.guidoEditor?.dynamicContent.insert({
|
|
121
|
-
text: 'Display Text',
|
|
122
|
-
value: 'actual-value',
|
|
123
|
-
fallback: 'Fallback Text'
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
this.dynamicContentModalVisible = false;
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
// ⚠️ It's mandatory. There is no way to understand if user closes the modal without selection.
|
|
130
|
-
handleDynamicContentClose() {
|
|
131
|
-
this.$refs.guidoEditor?.dynamicContent.close();
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
// If you need to trigger save manually like leave modal cases, you can use this method.
|
|
135
|
-
save () {
|
|
136
|
-
this.$refs.guidoEditor?.saveSilent();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
};
|
|
76
|
+
const onReady = () => console.log('Editor ready');
|
|
77
|
+
const onDynamicContentOpen = () => console.log('Dynamic content requested');
|
|
78
|
+
const onSaveComplete = (template) => console.log('Saved:', template);
|
|
140
79
|
</script>
|
|
141
80
|
```
|
|
142
81
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
### Guido Component Props
|
|
82
|
+
---
|
|
146
83
|
|
|
147
|
-
|
|
148
|
-
|------|------|----------|---------|-------------|
|
|
149
|
-
| `templateId` | `string` | ✅ | - | Unique identifier for the email template |
|
|
150
|
-
| `userId` | `string` | ✅ | - | Unique identifier for the user |
|
|
151
|
-
| `guidoConfig` | `GuidoConfig` | ✅ | - | Configuration object for the editor |
|
|
152
|
-
| `migrationDate` | `number` | ✅ | - | Stripo migration date in Unix timestamp (seconds). Retrieved from backend `/partner-settings` endpoint as `migrationDate`. Used for onboarding process |
|
|
153
|
-
| `partnerName` | `string` | ⚪ | From URL host | Partner identifier |
|
|
154
|
-
| `productType` | `string` | ⚪ | From URL path | Product type identifier |
|
|
155
|
-
| `username` | `string` | ⚪ | `'Guido User'` | Display name for the user |
|
|
156
|
-
| `html` | `string` | ⚪ | `''` | Initial HTML content for the template |
|
|
157
|
-
| `css` | `string` | ⚪ | `''` | Initial CSS styles for the template |
|
|
84
|
+
## Configuration
|
|
158
85
|
|
|
159
|
-
|
|
86
|
+
Guido uses a single, validated `config` prop organized by domain:
|
|
160
87
|
|
|
161
|
-
| Event | Payload | Description |
|
|
162
|
-
|-------|---------|-------------|
|
|
163
|
-
| `dynamic-content:open` | `DynamicContent \| null` | Fired when user requests to insert dynamic content |
|
|
164
|
-
| `back` | - | Fired when user clicks the back button |
|
|
165
|
-
| `save:start` | - | Fired when the save process begins |
|
|
166
|
-
| `save:complete` | `Omit<Template, 'forceRecreate'>` | Fired when template is successfully saved |
|
|
167
|
-
| `on-change` | void | It Fires once for managing leave modal etc. |
|
|
168
|
-
| `ready` | void | Fired when the editor is ready and template is loaded |
|
|
169
|
-
| `onboarding-finished` | void | Fired when the onboarding popup is dismissed or completed, allowing parent applications to track onboarding state |
|
|
170
|
-
| `test-email:click` | - | Fired when user clicks the test email button in the header |
|
|
171
|
-
|
|
172
|
-
### Guido Exposed Methods
|
|
173
88
|
```typescript
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
89
|
+
import type { GuidoConfigInput } from '@useinsider/guido';
|
|
90
|
+
|
|
91
|
+
const config: GuidoConfigInput = {
|
|
92
|
+
// Required: Identity
|
|
93
|
+
identity: {
|
|
94
|
+
templateId: string, // Required - Template identifier
|
|
95
|
+
userId: string, // Required - User identifier
|
|
96
|
+
variationId?: string, // Optional - A/B test variation
|
|
97
|
+
},
|
|
180
98
|
|
|
181
|
-
|
|
182
|
-
interface GuidoConfig {
|
|
183
|
-
translationsPath: string;
|
|
184
|
-
htmlCompilerRules?: CompilerRule[];
|
|
185
|
-
ignoreDefaultHtmlCompilerRules?: boolean;
|
|
186
|
-
useHeader: boolean
|
|
187
|
-
emailHeader: {
|
|
188
|
-
senderName: string;
|
|
189
|
-
subject: string;
|
|
190
|
-
};
|
|
99
|
+
// Required: Partner
|
|
191
100
|
partner: {
|
|
192
|
-
|
|
193
|
-
productType:
|
|
194
|
-
messageType:
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
dynamicContent: boolean;
|
|
198
|
-
saveAsTemplate: boolean;
|
|
199
|
-
versionHistory: boolean;
|
|
200
|
-
testMessage: boolean;
|
|
201
|
-
displayConditions: boolean;
|
|
202
|
-
};
|
|
203
|
-
blocks?: {
|
|
204
|
-
excludeDefaults?: GuidoBlockType[];
|
|
205
|
-
includeCustoms?: GuidoCustomBlockType[];
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
```
|
|
101
|
+
name: string, // Required - Partner name
|
|
102
|
+
productType?: number, // Optional - Default: 60 (Email)
|
|
103
|
+
messageType?: number, // Optional - Default: 1 (Promotional)
|
|
104
|
+
username?: string, // Optional - Default: 'Guido User'
|
|
105
|
+
},
|
|
209
106
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
| `features.saveAsTemplate` | `boolean` | `true` | Enable save as template feature |
|
|
219
|
-
| `features.versionHistory` | `boolean` | `true` | Enable version history feature |
|
|
220
|
-
| `features.displayConditions` | `boolean` | `true` | Enable display conditions |
|
|
221
|
-
| `blocks` | `BlocksConfig` | `{ excludeDefaults: [], includeCustoms: [] }` | Block configuration for excluding default blocks and including custom blocks. See [Blocks Configuration](#-blocks-configuration) section below |
|
|
222
|
-
| `blocks.excludeDefaults` | `GuidoBlockType[]` | `[]` | Array of default Stripo blocks to exclude from the editor |
|
|
223
|
-
| `blocks.includeCustoms` | `GuidoCustomBlockType[]` | `[]` | Array of custom blocks to include in the editor |
|
|
107
|
+
// Optional: Template content
|
|
108
|
+
template?: {
|
|
109
|
+
html?: string,
|
|
110
|
+
css?: string,
|
|
111
|
+
preselectedDynamicContent?: DynamicContent[],
|
|
112
|
+
selectedUnsubscribePages?: number[],
|
|
113
|
+
forceRecreate?: boolean, // Default: false - Force recreate template in Stripo storage
|
|
114
|
+
},
|
|
224
115
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
116
|
+
// Optional: Editor settings
|
|
117
|
+
editor?: {
|
|
118
|
+
locale?: string, // Default: 'en'
|
|
119
|
+
translationsPath?: string, // Default: 'window.trans.en'
|
|
120
|
+
migrationDate?: number, // Stripo migration timestamp
|
|
121
|
+
emailHeader?: {
|
|
122
|
+
senderName?: string,
|
|
123
|
+
subject?: string,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
233
126
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
127
|
+
// Optional: UI settings
|
|
128
|
+
ui?: {
|
|
129
|
+
showHeader?: boolean, // Default: true
|
|
130
|
+
backButtonLabel?: string,
|
|
131
|
+
},
|
|
239
132
|
|
|
240
|
-
|
|
133
|
+
// Optional: Feature toggles
|
|
134
|
+
features?: {
|
|
135
|
+
dynamicContent?: boolean, // Default: true
|
|
136
|
+
saveAsTemplate?: boolean, // Default: true
|
|
137
|
+
versionHistory?: boolean, // Default: true
|
|
138
|
+
testMessage?: boolean, // Default: true
|
|
139
|
+
displayConditions?: boolean, // Default: true
|
|
140
|
+
unsubscribe?: boolean, // Default: true
|
|
141
|
+
modulesDisabled?: boolean, // Default: false - Disable modules panel
|
|
142
|
+
},
|
|
241
143
|
|
|
242
|
-
|
|
144
|
+
// Optional: Block configuration
|
|
145
|
+
blocks?: {
|
|
146
|
+
excludeDefaults?: DefaultBlockType[],
|
|
147
|
+
includeCustoms?: CustomBlockType[],
|
|
148
|
+
},
|
|
243
149
|
|
|
244
|
-
|
|
150
|
+
// Optional: HTML compiler
|
|
151
|
+
compiler?: {
|
|
152
|
+
customRules?: CompilerRule[],
|
|
153
|
+
ignoreDefaultRules?: boolean, // Default: false
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
```
|
|
245
157
|
|
|
246
|
-
|
|
158
|
+
---
|
|
247
159
|
|
|
248
|
-
|
|
160
|
+
## Events
|
|
249
161
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
| 'social-block' // Social media links
|
|
261
|
-
| 'spacer-block' // Vertical spacing
|
|
262
|
-
| 'text-block' // Text content
|
|
263
|
-
| 'timer-block' // Countdown timer
|
|
264
|
-
| 'video-block' // Video embeds
|
|
265
|
-
```
|
|
162
|
+
| Event | Payload | Description |
|
|
163
|
+
|-------|---------|-------------|
|
|
164
|
+
| `ready` | - | Editor is loaded and ready |
|
|
165
|
+
| `dynamic-content:open` | `DynamicContent \| null` | User wants to insert dynamic content |
|
|
166
|
+
| `back` | - | Back button clicked |
|
|
167
|
+
| `save:start` | - | Save process started |
|
|
168
|
+
| `save:complete` | `Template` | Save completed successfully |
|
|
169
|
+
| `on-change` | - | Template was modified |
|
|
170
|
+
| `test-email:click` | - | Test email button clicked |
|
|
171
|
+
| `onboarding-finished` | - | Onboarding popup dismissed |
|
|
266
172
|
|
|
267
|
-
|
|
173
|
+
---
|
|
268
174
|
|
|
269
|
-
|
|
175
|
+
## Exposed Methods
|
|
270
176
|
|
|
271
177
|
```typescript
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
178
|
+
const guidoRef = ref<InstanceType<typeof Guido> | null>(null);
|
|
179
|
+
|
|
180
|
+
// Insert dynamic content
|
|
181
|
+
guidoRef.value?.dynamicContent.insert({
|
|
182
|
+
text: 'Display Name',
|
|
183
|
+
value: 'variable_name',
|
|
184
|
+
fallback: 'Default Value',
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// Close dynamic content modal
|
|
188
|
+
guidoRef.value?.dynamicContent.close();
|
|
189
|
+
|
|
190
|
+
// Silent save (no UI feedback)
|
|
191
|
+
guidoRef.value?.saveSilent();
|
|
280
192
|
```
|
|
281
193
|
|
|
282
|
-
|
|
194
|
+
---
|
|
283
195
|
|
|
284
|
-
|
|
196
|
+
## Block Configuration
|
|
285
197
|
|
|
286
|
-
|
|
198
|
+
### Default Blocks (can be excluded)
|
|
287
199
|
|
|
288
200
|
```typescript
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
- All custom blocks are disabled.
|
|
201
|
+
type DefaultBlockType =
|
|
202
|
+
| 'amp-accordion'
|
|
203
|
+
| 'amp-carousel'
|
|
204
|
+
| 'amp-form-controls'
|
|
205
|
+
| 'banner-block'
|
|
206
|
+
| 'button-block'
|
|
207
|
+
| 'html-block'
|
|
208
|
+
| 'image-block'
|
|
209
|
+
| 'menu-block'
|
|
210
|
+
| 'social-block'
|
|
211
|
+
| 'spacer-block'
|
|
212
|
+
| 'text-block'
|
|
213
|
+
| 'timer-block'
|
|
214
|
+
| 'video-block';
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Custom Blocks (opt-in)
|
|
307
218
|
|
|
308
|
-
|
|
219
|
+
```typescript
|
|
220
|
+
type CustomBlockType =
|
|
221
|
+
| 'dynamic-content'
|
|
222
|
+
| 'checkbox-block'
|
|
223
|
+
| 'radio-button-block'
|
|
224
|
+
| 'recommendation-block'
|
|
225
|
+
| 'unsubscribe-block'
|
|
226
|
+
| 'coupon-block'
|
|
227
|
+
| 'items-block';
|
|
228
|
+
```
|
|
309
229
|
|
|
310
|
-
|
|
230
|
+
### Examples
|
|
311
231
|
|
|
312
232
|
```typescript
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
testMessage: true
|
|
233
|
+
// Exclude specific default blocks
|
|
234
|
+
const config: GuidoConfigInput = {
|
|
235
|
+
identity: { templateId: 'tpl-123', userId: 'user-456' },
|
|
236
|
+
partner: { name: 'partner' },
|
|
237
|
+
blocks: {
|
|
238
|
+
excludeDefaults: ['timer-block', 'video-block'],
|
|
320
239
|
},
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// Include custom blocks
|
|
243
|
+
const config: GuidoConfigInput = {
|
|
244
|
+
identity: { templateId: 'tpl-123', userId: 'user-456' },
|
|
245
|
+
partner: { name: 'partner' },
|
|
321
246
|
blocks: {
|
|
322
|
-
includeCustoms: ['
|
|
323
|
-
}
|
|
247
|
+
includeCustoms: ['recommendation-block', 'coupon-block', 'dynamic-content'],
|
|
248
|
+
},
|
|
324
249
|
};
|
|
325
250
|
```
|
|
326
251
|
|
|
327
|
-
|
|
328
|
-
- All default blocks enabled
|
|
329
|
-
- Only Coupon and Recommendation extensions enabled.
|
|
330
|
-
- Other custom blocks are disabled
|
|
252
|
+
---
|
|
331
253
|
|
|
332
|
-
|
|
254
|
+
## HTML Compiler Rules
|
|
333
255
|
|
|
334
|
-
|
|
256
|
+
Add custom rules to transform HTML during export:
|
|
335
257
|
|
|
336
258
|
```typescript
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
259
|
+
const config: GuidoConfigInput = {
|
|
260
|
+
identity: { templateId: 'tpl-123', userId: 'user-456' },
|
|
261
|
+
partner: { name: 'partner' },
|
|
262
|
+
compiler: {
|
|
263
|
+
customRules: [
|
|
264
|
+
// Replace rule
|
|
265
|
+
{
|
|
266
|
+
id: 'replace-domain',
|
|
267
|
+
type: 'replace',
|
|
268
|
+
search: 'old-domain.com',
|
|
269
|
+
replacement: 'new-domain.com',
|
|
270
|
+
priority: 10,
|
|
271
|
+
},
|
|
272
|
+
// Regex rule
|
|
273
|
+
{
|
|
274
|
+
id: 'remove-comments',
|
|
275
|
+
type: 'regex',
|
|
276
|
+
pattern: '<!--.*?-->',
|
|
277
|
+
replacement: '',
|
|
278
|
+
flags: 'g',
|
|
279
|
+
priority: 20,
|
|
280
|
+
},
|
|
281
|
+
// Custom processor
|
|
282
|
+
{
|
|
283
|
+
id: 'add-tracking',
|
|
284
|
+
type: 'custom',
|
|
285
|
+
processor: (html) => html.replace('</body>', '<img src="track.gif"/></body>'),
|
|
286
|
+
priority: 30,
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
ignoreDefaultRules: false, // Set true to skip built-in rules
|
|
344
290
|
},
|
|
345
|
-
// No blocks config
|
|
346
291
|
};
|
|
347
292
|
```
|
|
348
293
|
|
|
349
|
-
|
|
350
|
-
- All 13 default Stripo blocks enabled
|
|
351
|
-
- All custom blocks are disabled.
|
|
352
|
-
|
|
353
|
-
### Block Configuration Interface
|
|
354
|
-
|
|
355
|
-
```typescript
|
|
356
|
-
interface BlocksConfig {
|
|
357
|
-
excludeDefaults?: GuidoBlockType[];
|
|
358
|
-
includeCustoms?: GuidoCustomBlockType[];
|
|
359
|
-
}
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
### TypeScript Types
|
|
294
|
+
---
|
|
363
295
|
|
|
364
|
-
|
|
296
|
+
## TypeScript Exports
|
|
365
297
|
|
|
366
298
|
```typescript
|
|
367
|
-
//
|
|
299
|
+
// Component
|
|
368
300
|
import { Guido } from '@useinsider/guido';
|
|
369
301
|
|
|
370
302
|
// Types
|
|
371
|
-
import type {
|
|
372
|
-
|
|
303
|
+
import type {
|
|
304
|
+
GuidoConfig,
|
|
305
|
+
GuidoConfigInput,
|
|
306
|
+
IdentityConfig,
|
|
307
|
+
PartnerConfig,
|
|
308
|
+
TemplateConfig,
|
|
309
|
+
EditorConfig,
|
|
310
|
+
UIConfig,
|
|
311
|
+
FeaturesConfig,
|
|
312
|
+
BlocksConfig,
|
|
313
|
+
CompilerConfig,
|
|
314
|
+
DynamicContent,
|
|
315
|
+
DefaultBlockType,
|
|
316
|
+
CustomBlockType,
|
|
317
|
+
} from '@useinsider/guido';
|
|
318
|
+
|
|
319
|
+
// Utilities
|
|
320
|
+
import {
|
|
321
|
+
validateConfig,
|
|
322
|
+
parseConfig,
|
|
323
|
+
MessageType,
|
|
324
|
+
ProductType,
|
|
325
|
+
} from '@useinsider/guido';
|
|
326
|
+
|
|
327
|
+
// Styles
|
|
328
|
+
import '@useinsider/guido/style';
|
|
373
329
|
```
|
|
374
330
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
Guido includes a powerful HTML compiler system that allows you to transform HTML content with custom rules. You can define additional rules and optionally ignore the default rules.
|
|
378
|
-
|
|
379
|
-
### Rule Types
|
|
380
|
-
|
|
381
|
-
There are 4 types of compiler rules:
|
|
331
|
+
---
|
|
382
332
|
|
|
383
|
-
|
|
384
|
-
Replace specific strings in HTML content.
|
|
333
|
+
## Constants
|
|
385
334
|
|
|
386
335
|
```typescript
|
|
387
|
-
{
|
|
388
|
-
id: 'fix-encoding',
|
|
389
|
-
description: 'Fix URL encoding issues',
|
|
390
|
-
type: 'replace',
|
|
391
|
-
search: '{%22', // String to find
|
|
392
|
-
replacement: '%7B%22', // String to replace with
|
|
393
|
-
replaceAll: true, // Replace all occurrences (default: true)
|
|
394
|
-
priority: 10 // Execution priority (lower = earlier)
|
|
395
|
-
}
|
|
396
|
-
```
|
|
336
|
+
import { MessageType, ProductType } from '@useinsider/guido';
|
|
397
337
|
|
|
398
|
-
|
|
399
|
-
|
|
338
|
+
MessageType.PROMOTIONAL // 1
|
|
339
|
+
MessageType.TRANSACTIONAL // 2
|
|
400
340
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
description: 'Remove HTML comments',
|
|
405
|
-
type: 'regex',
|
|
406
|
-
pattern: '<!--.*?-->', // Regex pattern
|
|
407
|
-
replacement: '', // Replacement string
|
|
408
|
-
flags: 'g', // Regex flags (default: 'g')
|
|
409
|
-
priority: 20
|
|
410
|
-
}
|
|
341
|
+
ProductType.EMAIL // 60
|
|
342
|
+
ProductType.ARCHITECT // 49
|
|
343
|
+
ProductType.UNSUBSCRIBE_PAGES // 97
|
|
411
344
|
```
|
|
412
345
|
|
|
413
|
-
|
|
414
|
-
Remove specific strings or patterns from HTML content.
|
|
346
|
+
---
|
|
415
347
|
|
|
416
|
-
|
|
417
|
-
{
|
|
418
|
-
id: 'cleanup-scripts',
|
|
419
|
-
description: 'Remove unwanted script tags',
|
|
420
|
-
type: 'remove',
|
|
421
|
-
targets: [ // Array of strings or RegExp objects
|
|
422
|
-
'<script src="unwanted.js"></script>',
|
|
423
|
-
/onclick="[^"]*"/g
|
|
424
|
-
],
|
|
425
|
-
priority: 30
|
|
426
|
-
}
|
|
427
|
-
```
|
|
348
|
+
## Dynamic Content Modal
|
|
428
349
|
|
|
429
|
-
|
|
430
|
-
Define complex transformation logic with a custom processor function.
|
|
350
|
+
When the `dynamic-content:open` event fires, show your custom modal and call the insert method:
|
|
431
351
|
|
|
432
|
-
```
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
description: 'Add custom meta tags to head',
|
|
436
|
-
type: 'custom',
|
|
437
|
-
processor: (html: string): string => {
|
|
438
|
-
// Custom transformation logic
|
|
439
|
-
const metaTags = '<meta name="custom" content="value">';
|
|
440
|
-
return html.replace('</head>', `${metaTags}</head>`);
|
|
441
|
-
},
|
|
442
|
-
priority: 40
|
|
443
|
-
}
|
|
444
|
-
```
|
|
352
|
+
```vue
|
|
353
|
+
<template>
|
|
354
|
+
<Guido ref="guidoRef" :config="config" @dynamic-content:open="showModal = true" />
|
|
445
355
|
|
|
446
|
-
|
|
356
|
+
<!-- Your modal must have id="guido-dynamic-content-modal" -->
|
|
357
|
+
<YourModal v-if="showModal" id="guido-dynamic-content-modal" @select="insertContent" @close="closeModal" />
|
|
358
|
+
</template>
|
|
447
359
|
|
|
448
|
-
|
|
360
|
+
<script setup>
|
|
361
|
+
const showModal = ref(false);
|
|
449
362
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
testMessage: true
|
|
458
|
-
},
|
|
459
|
-
htmlCompilerRules: [
|
|
460
|
-
{
|
|
461
|
-
id: 'replace-domain',
|
|
462
|
-
description: 'Replace old domain with new one',
|
|
463
|
-
type: 'replace',
|
|
464
|
-
search: 'old-domain.com',
|
|
465
|
-
replacement: 'new-domain.com',
|
|
466
|
-
replaceAll: true,
|
|
467
|
-
priority: 10
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
id: 'remove-tracking',
|
|
471
|
-
description: 'Remove tracking pixels',
|
|
472
|
-
type: 'regex',
|
|
473
|
-
pattern: '<img[^>]*tracking[^>]*>',
|
|
474
|
-
replacement: '',
|
|
475
|
-
flags: 'gi',
|
|
476
|
-
priority: 20
|
|
477
|
-
}
|
|
478
|
-
]
|
|
363
|
+
const insertContent = (content) => {
|
|
364
|
+
guidoRef.value?.dynamicContent.insert({
|
|
365
|
+
text: content.label,
|
|
366
|
+
value: content.value,
|
|
367
|
+
fallback: content.fallback || '',
|
|
368
|
+
});
|
|
369
|
+
showModal.value = false;
|
|
479
370
|
};
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
#### Ignoring Default Rules
|
|
483
371
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
features: {
|
|
488
|
-
dynamicContent: true,
|
|
489
|
-
saveAsTemplate: true,
|
|
490
|
-
versionHistory: true,
|
|
491
|
-
testMessage: true
|
|
492
|
-
},
|
|
493
|
-
ignoreDefaultHtmlCompilerRules: true, // Skip all default rules
|
|
494
|
-
htmlCompilerRules: [
|
|
495
|
-
// Only your custom rules will be applied
|
|
496
|
-
{
|
|
497
|
-
id: 'custom-transformation',
|
|
498
|
-
type: 'replace',
|
|
499
|
-
search: 'old-text',
|
|
500
|
-
replacement: 'new-text',
|
|
501
|
-
priority: 1
|
|
502
|
-
}
|
|
503
|
-
]
|
|
372
|
+
const closeModal = () => {
|
|
373
|
+
guidoRef.value?.dynamicContent.close();
|
|
374
|
+
showModal.value = false;
|
|
504
375
|
};
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
### Rule Execution Order
|
|
508
|
-
|
|
509
|
-
Rules are executed in priority order (lower numbers first). Rules with the same priority are executed in array order.
|
|
510
|
-
|
|
511
|
-
- **Priority 1-99**: Reserved for critical transformations
|
|
512
|
-
- **Priority 100-999**: Standard transformations
|
|
513
|
-
- **Priority 1000+**: Additional custom rules (automatically assigned)
|
|
514
|
-
|
|
515
|
-
### Default Rules
|
|
516
|
-
|
|
517
|
-
Guido includes several default rules for common email HTML optimizations:
|
|
518
|
-
|
|
519
|
-
- **URL encoding fixes**: Fixes malformed URL encoding in dynamic content
|
|
520
|
-
- **Template tag restoration**: Restores `{{}}` template tags that got URL encoded
|
|
521
|
-
- **HTML entity decoding**: Converts `<` and `>` back to `<` and `>`
|
|
522
|
-
- **Cleanup rules**: Removes unwanted iframe and style elements
|
|
523
|
-
- **MSO conditions**: Manages Outlook-specific conditional comments
|
|
524
|
-
- **Domain replacement**: Updates old image domains to current ones
|
|
525
|
-
|
|
526
|
-
You can view all default rules in: `src/config/compiler/htmlCompilerRules.ts`
|
|
527
|
-
|
|
528
|
-
### CompilerRule Interface
|
|
529
|
-
|
|
530
|
-
```typescript
|
|
531
|
-
type CompilerRuleType = 'replace' | 'regex' | 'remove' | 'custom';
|
|
532
|
-
|
|
533
|
-
interface BaseCompilerRule {
|
|
534
|
-
id: string;
|
|
535
|
-
description?: string;
|
|
536
|
-
priority: number;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
interface ReplaceRule extends BaseCompilerRule {
|
|
540
|
-
type: 'replace';
|
|
541
|
-
search: string;
|
|
542
|
-
replacement: string;
|
|
543
|
-
replaceAll?: boolean; // Default: true
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
interface RegexRule extends BaseCompilerRule {
|
|
547
|
-
type: 'regex';
|
|
548
|
-
pattern: string;
|
|
549
|
-
replacement: string;
|
|
550
|
-
flags?: string; // Default: 'g'
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
interface RemoveRule extends BaseCompilerRule {
|
|
554
|
-
type: 'remove';
|
|
555
|
-
targets: (string | RegExp)[]; // Array of strings or RegExp objects
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
interface CustomRule extends BaseCompilerRule {
|
|
559
|
-
type: 'custom';
|
|
560
|
-
processor: (html: string) => string;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
type CompilerRule = ReplaceRule | RegexRule | RemoveRule | CustomRule;
|
|
376
|
+
</script>
|
|
564
377
|
```
|
|
565
378
|
|
|
566
379
|
---
|
|
567
380
|
|
|
568
|
-
##
|
|
569
|
-
|
|
570
|
-
### Prerequisites
|
|
571
|
-
|
|
572
|
-
- 🧄 `Bun` (strongly recommended)
|
|
573
|
-
or
|
|
574
|
-
- NodeJS 18+ & `npm`
|
|
575
|
-
|
|
576
|
-
### Setup
|
|
381
|
+
## Development
|
|
577
382
|
|
|
578
383
|
```bash
|
|
579
|
-
# Install
|
|
384
|
+
# Install
|
|
580
385
|
bun install
|
|
581
386
|
|
|
582
|
-
# Start
|
|
387
|
+
# Start dev server
|
|
583
388
|
bun start
|
|
584
389
|
|
|
585
|
-
# Build
|
|
390
|
+
# Build
|
|
586
391
|
bun run build
|
|
587
392
|
|
|
588
|
-
#
|
|
589
|
-
bun run type-check
|
|
590
|
-
|
|
591
|
-
# Linting
|
|
393
|
+
# Lint & type-check
|
|
592
394
|
bun run lint
|
|
593
395
|
```
|
|
594
396
|
|
|
595
397
|
### Environment Variables
|
|
596
398
|
|
|
597
|
-
Create a `.env` file with the following variables: (You can get env variables from your senior)
|
|
598
|
-
|
|
599
399
|
```env
|
|
600
400
|
VITE_STRIPO_PLUGIN_ID=your_plugin_id
|
|
601
401
|
VITE_STRIPO_SECRET_KEY=your_secret_key
|
|
602
402
|
VITE_STRIPO_ROLE=your_role
|
|
603
|
-
|
|
604
|
-
# Playwright Test Configuration (Optional - for local debugging only)
|
|
605
|
-
HEADED=false # Set to 'true' to run tests with visible browser
|
|
606
|
-
```
|
|
607
|
-
|
|
608
|
-
### Project Structure
|
|
609
|
-
|
|
610
|
-
```
|
|
611
|
-
src/
|
|
612
|
-
├── components/ # Vue components
|
|
613
|
-
├── composables/ # Vue composables & business logic
|
|
614
|
-
├── services/ # API layer
|
|
615
|
-
├── stores/ # State management
|
|
616
|
-
├── @types/ # TypeScript definitions
|
|
617
|
-
├── static/ # Static assets & templates
|
|
618
|
-
├── utils/ # Utility functions
|
|
619
|
-
├── enums/ # Constants & enums
|
|
620
|
-
├── mock/ # Mock data for development
|
|
621
|
-
├── plugins/ # Vue plugins
|
|
622
|
-
└── library.ts # Main export
|
|
623
|
-
```
|
|
624
|
-
|
|
625
|
-
## 🔌 Provide/Inject Utilities
|
|
626
|
-
|
|
627
|
-
Guido includes type-safe utilities for Vue's provide/inject system to facilitate dependency injection between components.
|
|
628
|
-
|
|
629
|
-
### useProvideInject
|
|
630
|
-
|
|
631
|
-
The `useProvideInject` composable provides two helper functions for type-safe dependency injection:
|
|
632
|
-
|
|
633
|
-
#### Basic Usage
|
|
634
|
-
|
|
635
|
-
```typescript
|
|
636
|
-
// Parent component
|
|
637
|
-
import { provideValue } from '@useinsider/guido';
|
|
638
|
-
import { InjectionKey } from 'vue';
|
|
639
|
-
|
|
640
|
-
// Define a typed injection key
|
|
641
|
-
const MyServiceKey: InjectionKey<MyService> = Symbol('MyService');
|
|
642
|
-
|
|
643
|
-
// Provide the value
|
|
644
|
-
const myService = new MyService();
|
|
645
|
-
provideValue(MyServiceKey, myService);
|
|
646
|
-
|
|
647
|
-
// Child component
|
|
648
|
-
import { useInjectedValue } from '@useinsider/guido';
|
|
649
|
-
|
|
650
|
-
// Inject the value with type safety
|
|
651
|
-
const myService = useInjectedValue(MyServiceKey);
|
|
652
|
-
```
|
|
653
|
-
|
|
654
|
-
#### With Default Value
|
|
655
|
-
|
|
656
|
-
```typescript
|
|
657
|
-
// Inject with a fallback value
|
|
658
|
-
const myService = useInjectedValue(MyServiceKey, new DefaultService());
|
|
659
403
|
```
|
|
660
404
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
The `useInjectedValue` function will throw a descriptive error if no provider is found and no default value is provided:
|
|
664
|
-
|
|
665
|
-
```typescript
|
|
666
|
-
// This will throw an error if no provider exists
|
|
667
|
-
try {
|
|
668
|
-
const myService = useInjectedValue(MyServiceKey);
|
|
669
|
-
} catch (error) {
|
|
670
|
-
console.error('No provider found for MyService');
|
|
671
|
-
}
|
|
672
|
-
```
|
|
673
|
-
|
|
674
|
-
### API Reference
|
|
675
|
-
|
|
676
|
-
#### `provideValue`
|
|
677
|
-
|
|
678
|
-
```typescript
|
|
679
|
-
provideValue<T>(key: InjectionKey<T>, value: T): void
|
|
680
|
-
```
|
|
681
|
-
|
|
682
|
-
Provides a value using Vue's provide system with type safety.
|
|
683
|
-
|
|
684
|
-
| Parameter | Type | Description |
|
|
685
|
-
|-----------|------|-------------|
|
|
686
|
-
| `key` | `InjectionKey<T>` | The typed injection key |
|
|
687
|
-
| `value` | `T` | The value to provide |
|
|
688
|
-
|
|
689
|
-
#### `useInjectedValue`
|
|
690
|
-
|
|
691
|
-
```typescript
|
|
692
|
-
useInjectedValue<T>(key: InjectionKey<T>, defaultValue?: T): T
|
|
693
|
-
```
|
|
694
|
-
|
|
695
|
-
Injects a value using Vue's inject system with type safety and error handling.
|
|
696
|
-
|
|
697
|
-
| Parameter | Type | Required | Description |
|
|
698
|
-
|-----------|------|----------|-------------|
|
|
699
|
-
| `key` | `InjectionKey<T>` | ✅ | The typed injection key |
|
|
700
|
-
| `defaultValue` | `T` | ⚪ | Optional fallback value |
|
|
701
|
-
|
|
702
|
-
**Returns:** `T` - The injected value
|
|
703
|
-
|
|
704
|
-
**Throws:** `Error` - When no provider is found and no default value is provided
|
|
705
|
-
|
|
706
|
-
## 🌐 i18n
|
|
707
|
-
Before running the project, it sends to request to inone.useinsider.com/translations and writes the JSON file into - [trans.json](src/mock/responses/trans.json).
|
|
708
|
-
It allows to use production or local translations on your code. 🚀
|
|
709
|
-
Example usage:
|
|
710
|
-
```js
|
|
711
|
-
import { useTranslations } from '@@/Composables/useTranslations';
|
|
712
|
-
|
|
713
|
-
const trans = useTranslations();
|
|
714
|
-
|
|
715
|
-
// use everywhere like this:
|
|
716
|
-
trans('foo.bar')
|
|
717
|
-
```
|
|
405
|
+
---
|
|
718
406
|
|
|
719
|
-
##
|
|
407
|
+
## Local Testing
|
|
720
408
|
|
|
721
|
-
|
|
722
|
-
|
|
409
|
+
```bash
|
|
410
|
+
# Build the package
|
|
723
411
|
bun run build
|
|
724
|
-
```
|
|
725
412
|
|
|
726
|
-
|
|
727
|
-
```sh
|
|
413
|
+
# Create tarball
|
|
728
414
|
npm pack
|
|
729
|
-
```
|
|
730
|
-
|
|
731
|
-
It'll crate like `useinsider-guido-1.0.0.tgz` file.
|
|
732
415
|
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
416
|
+
# Install in your project
|
|
417
|
+
cd ../your-project
|
|
418
|
+
npm install ../guido/useinsider-guido-1.0.0.tgz
|
|
736
419
|
```
|
|
737
420
|
|
|
738
|
-
Install the file to your project:
|
|
739
|
-
```sh
|
|
740
|
-
npm i ./useinsider-guido-1.0.0.tgz
|
|
741
|
-
```
|
|
742
|
-
|
|
743
|
-
Then you just need to rebuild to your project or restart the Container. 🎉
|
|
744
|
-
|
|
745
|
-
For Future, we can create a shell script for it. Feel free to help 🙃
|
|
746
|
-
|
|
747
|
-
## 📦 Build Output
|
|
748
|
-
|
|
749
|
-
The library builds to multiple formats:
|
|
750
|
-
|
|
751
|
-
- **ES Module**: `dist/library.js` (recommended)
|
|
752
|
-
- **CSS**: `dist/guido.css` (custom styles)
|
|
753
|
-
|
|
754
|
-
### Package Exports
|
|
755
|
-
|
|
756
|
-
```json
|
|
757
|
-
{
|
|
758
|
-
"exports": {
|
|
759
|
-
".": {
|
|
760
|
-
"import": "./dist/library.js",
|
|
761
|
-
"types": "./dist/components/Guido.vue.d.ts",
|
|
762
|
-
"require": "./dist/components/Guido.vue.js"
|
|
763
|
-
},
|
|
764
|
-
"./style": "./dist/guido.css"
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
```
|
|
768
|
-
|
|
769
|
-
## 🤝 Contributing
|
|
770
|
-
- PR Titles should be structured like `TASK-ID | 🔥 | Some Clear Task Descriptions`
|
|
771
|
-
- PR Labels should be filled.
|
|
772
|
-
- PR Assignee required.
|
|
773
|
-
- Tests should be covered.
|
|
774
|
-
- All required checks should be passed before sending review request.
|
|
775
|
-
|
|
776
|
-
## 📄 License
|
|
777
|
-
|
|
778
|
-
ISC License
|
|
779
|
-
|
|
780
421
|
---
|
|
781
422
|
|
|
782
|
-
##
|
|
423
|
+
## License
|
|
783
424
|
|
|
784
|
-
|
|
785
|
-
- [@useinsider/design-system-vue](https://github.com/useinsider/design-system-vue) - Insider's Vue design system
|
|
786
|
-
|
|
787
|
-
## 🎯 TODO:
|
|
788
|
-
- CSS part should be optimized with variables & `sass-loader`.
|
|
789
|
-
- Master Version Generator should be fixed.
|
|
790
|
-
- Playwright integrationBoilerplate/control.ts
|
|
791
|
-
- Commitlint & Precommit Hooks integration
|
|
792
|
-
- Get Pre-built display conditions from API
|
|
425
|
+
ISC License
|