@useinsider/guido 1.0.0-beta.dad21f4 → 1.0.0-beta.de03990

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.
Files changed (165) hide show
  1. package/README.md +353 -25
  2. package/dist/@types/generic.d.ts +30 -0
  3. package/dist/components/Guido.vue.d.ts +15 -2
  4. package/dist/components/Guido.vue.js +8 -8
  5. package/dist/components/Guido.vue2.js +75 -33
  6. package/dist/components/organisms/base/Toaster.vue.d.ts +2 -0
  7. package/dist/components/organisms/base/Toaster.vue.js +17 -0
  8. package/dist/components/organisms/base/Toaster.vue2.js +15 -0
  9. package/dist/components/organisms/email-preview/PreviewContainer.vue.d.ts +2 -0
  10. package/dist/components/organisms/email-preview/PreviewContainer.vue.js +19 -0
  11. package/dist/components/organisms/email-preview/PreviewContainer.vue2.js +19 -0
  12. package/dist/components/organisms/email-preview/amp/AmpErrorModal.vue.d.ts +4 -0
  13. package/dist/components/organisms/email-preview/amp/AmpErrorModal.vue.js +22 -0
  14. package/dist/components/organisms/email-preview/amp/AmpErrorModal.vue2.js +30 -0
  15. package/dist/components/organisms/email-preview/amp/AmpToggle.vue.d.ts +2 -0
  16. package/dist/components/organisms/email-preview/amp/AmpToggle.vue.js +19 -0
  17. package/dist/components/organisms/email-preview/amp/AmpToggle.vue2.js +29 -0
  18. package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.d.ts +2 -0
  19. package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +22 -0
  20. package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue2.js +31 -0
  21. package/dist/components/organisms/email-preview/desktop-preview/EmailHeaderInfo.vue.d.ts +2 -0
  22. package/dist/components/organisms/email-preview/desktop-preview/EmailHeaderInfo.vue.js +17 -0
  23. package/dist/components/organisms/email-preview/desktop-preview/EmailHeaderInfo.vue2.js +20 -0
  24. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.d.ts +2 -0
  25. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +18 -0
  26. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +25 -0
  27. package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.d.ts +4 -0
  28. package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +19 -0
  29. package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue2.js +23 -0
  30. package/dist/components/organisms/email-preview/mobile-preview/InboxView.vue.d.ts +4 -0
  31. package/dist/components/organisms/email-preview/mobile-preview/InboxView.vue.js +20 -0
  32. package/dist/components/organisms/email-preview/mobile-preview/InboxView.vue2.js +21 -0
  33. package/dist/components/organisms/email-preview/mobile-preview/MobilePreview.vue.d.ts +2 -0
  34. package/dist/components/organisms/email-preview/mobile-preview/MobilePreview.vue.js +17 -0
  35. package/dist/components/organisms/email-preview/mobile-preview/MobilePreview.vue2.js +22 -0
  36. package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
  37. package/dist/components/organisms/header/LeftSlot.vue2.js +10 -8
  38. package/dist/components/organisms/header/MiddleSlot.vue.js +9 -9
  39. package/dist/components/organisms/header/MiddleSlot.vue2.js +16 -17
  40. package/dist/components/organisms/header/RightSlot.vue.js +10 -9
  41. package/dist/components/organisms/header/RightSlot.vue2.js +32 -14
  42. package/dist/components/organisms/header/ViewOptions.vue.js +8 -8
  43. package/dist/components/organisms/header/ViewOptions.vue2.js +30 -10
  44. package/dist/components/organisms/header/version-history/ViewOptions.vue.js +3 -3
  45. package/dist/components/organisms/header/version-history/ViewOptions.vue2.js +34 -16
  46. package/dist/components/wrappers/WpModal.vue.d.ts +65 -0
  47. package/dist/components/wrappers/WpModal.vue.js +27 -0
  48. package/dist/components/wrappers/WpModal.vue2.js +22 -0
  49. package/dist/composables/useActionsApi.d.ts +2 -0
  50. package/dist/composables/useActionsApi.js +62 -36
  51. package/dist/composables/useCodeEditorApi.d.ts +4 -0
  52. package/dist/composables/useCodeEditorApi.js +11 -0
  53. package/dist/composables/useConfig.d.ts +4 -0
  54. package/dist/composables/useConfig.js +7 -0
  55. package/dist/composables/useDebounce.d.ts +4 -0
  56. package/dist/composables/useDebounce.js +12 -0
  57. package/dist/composables/useExport.d.ts +1 -1
  58. package/dist/composables/useExport.js +37 -22
  59. package/dist/composables/useGuidoActions.d.ts +46 -0
  60. package/dist/composables/useGuidoActions.js +37 -0
  61. package/dist/composables/useHtmlCompiler.d.ts +4 -0
  62. package/dist/composables/useHtmlCompiler.js +17 -0
  63. package/dist/composables/usePreviewMode.d.ts +5 -0
  64. package/dist/composables/usePreviewMode.js +31 -0
  65. package/dist/composables/useProvideInject.d.ts +14 -0
  66. package/dist/composables/useProvideInject.js +17 -0
  67. package/dist/composables/useResponsivePreview.d.ts +5 -0
  68. package/dist/composables/useResponsivePreview.js +86 -0
  69. package/dist/composables/useStripo.js +27 -20
  70. package/dist/composables/useToaster.d.ts +1 -16
  71. package/dist/composables/useToaster.js +23 -30
  72. package/dist/composables/useTranslations.js +3 -2
  73. package/dist/composables/useVersionHistoryApi.js +4 -4
  74. package/dist/config/compiler/htmlCompilerRules.d.ts +2 -0
  75. package/dist/config/compiler/htmlCompilerRules.js +145 -0
  76. package/dist/config/compiler/outlookCompilerRules.d.ts +0 -0
  77. package/dist/enums/defaults.js +14 -5
  78. package/dist/enums/preview.d.ts +13 -0
  79. package/dist/enums/preview.js +23 -0
  80. package/dist/extensions/DynamicContent/dynamic-content.js +13 -15
  81. package/dist/guido.css +1 -1
  82. package/dist/mock/api/default-template.d.ts +2 -0
  83. package/dist/node_modules/lodash-es/_Stack.js +18 -0
  84. package/dist/node_modules/lodash-es/_Uint8Array.js +5 -0
  85. package/dist/node_modules/lodash-es/_apply.js +16 -0
  86. package/dist/node_modules/lodash-es/_arrayLikeKeys.js +19 -0
  87. package/dist/node_modules/lodash-es/_assignMergeValue.js +8 -0
  88. package/dist/node_modules/lodash-es/_assignValue.js +10 -0
  89. package/dist/node_modules/lodash-es/_baseAssignValue.js +12 -0
  90. package/dist/node_modules/lodash-es/_baseCreate.js +17 -0
  91. package/dist/node_modules/lodash-es/_baseFor.js +5 -0
  92. package/dist/node_modules/lodash-es/_baseIsArguments.js +9 -0
  93. package/dist/node_modules/lodash-es/_baseIsTypedArray.js +12 -0
  94. package/dist/node_modules/lodash-es/_baseKeysIn.js +15 -0
  95. package/dist/node_modules/lodash-es/_baseMerge.js +20 -0
  96. package/dist/node_modules/lodash-es/_baseMergeDeep.js +31 -0
  97. package/dist/node_modules/lodash-es/_baseRest.js +9 -0
  98. package/dist/node_modules/lodash-es/_baseSetToString.js +14 -0
  99. package/dist/node_modules/lodash-es/_baseTimes.js +8 -0
  100. package/dist/node_modules/lodash-es/_baseUnary.js +8 -0
  101. package/dist/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
  102. package/dist/node_modules/lodash-es/_cloneBuffer.js +9 -0
  103. package/dist/node_modules/lodash-es/_cloneTypedArray.js +8 -0
  104. package/dist/node_modules/lodash-es/_copyArray.js +9 -0
  105. package/dist/node_modules/lodash-es/_copyObject.js +14 -0
  106. package/dist/node_modules/lodash-es/_createAssigner.js +15 -0
  107. package/dist/node_modules/lodash-es/_createBaseFor.js +13 -0
  108. package/dist/node_modules/lodash-es/_defineProperty.js +11 -0
  109. package/dist/node_modules/lodash-es/_getPrototype.js +5 -0
  110. package/dist/node_modules/lodash-es/_initCloneObject.js +9 -0
  111. package/dist/node_modules/lodash-es/_isIndex.js +8 -0
  112. package/dist/node_modules/lodash-es/_isIterateeCall.js +13 -0
  113. package/dist/node_modules/lodash-es/_isPrototype.js +8 -0
  114. package/dist/node_modules/lodash-es/_nativeKeysIn.js +10 -0
  115. package/dist/node_modules/lodash-es/_nodeUtil.js +11 -0
  116. package/dist/node_modules/lodash-es/_overArg.js +8 -0
  117. package/dist/node_modules/lodash-es/_overRest.js +15 -0
  118. package/dist/node_modules/lodash-es/_safeGet.js +7 -0
  119. package/dist/node_modules/lodash-es/_setToString.js +6 -0
  120. package/dist/node_modules/lodash-es/_shortOut.js +16 -0
  121. package/dist/node_modules/lodash-es/_stackClear.js +7 -0
  122. package/dist/node_modules/lodash-es/_stackDelete.js +7 -0
  123. package/dist/node_modules/lodash-es/_stackGet.js +6 -0
  124. package/dist/node_modules/lodash-es/_stackHas.js +6 -0
  125. package/dist/node_modules/lodash-es/_stackSet.js +17 -0
  126. package/dist/node_modules/lodash-es/constant.js +8 -0
  127. package/dist/node_modules/lodash-es/identity.js +6 -0
  128. package/dist/node_modules/lodash-es/isArguments.js +10 -0
  129. package/dist/node_modules/lodash-es/isArray.js +4 -0
  130. package/dist/node_modules/lodash-es/isArrayLike.js +8 -0
  131. package/dist/node_modules/lodash-es/isArrayLikeObject.js +8 -0
  132. package/dist/node_modules/lodash-es/isBuffer.js +6 -0
  133. package/dist/node_modules/lodash-es/isLength.js +7 -0
  134. package/dist/node_modules/lodash-es/isObjectLike.js +6 -0
  135. package/dist/node_modules/lodash-es/isPlainObject.js +16 -0
  136. package/dist/node_modules/lodash-es/isTypedArray.js +7 -0
  137. package/dist/node_modules/lodash-es/keysIn.js +9 -0
  138. package/dist/node_modules/lodash-es/merge.js +8 -0
  139. package/dist/node_modules/lodash-es/stubFalse.js +6 -0
  140. package/dist/node_modules/lodash-es/toPlainObject.js +8 -0
  141. package/dist/services/stripoApi.d.ts +2 -1
  142. package/dist/services/stripoApi.js +27 -7
  143. package/dist/static/assets/inbox-mockup.svg.js +4 -0
  144. package/dist/static/assets/phone-mockup.svg.js +4 -0
  145. package/dist/stores/dynamic-content.d.ts +27 -0
  146. package/dist/stores/dynamic-content.js +23 -0
  147. package/dist/stores/editor.d.ts +1 -0
  148. package/dist/stores/editor.js +3 -2
  149. package/dist/stores/preview.d.ts +46 -0
  150. package/dist/stores/preview.js +53 -0
  151. package/dist/stores/toaster.d.ts +25 -0
  152. package/dist/stores/toaster.js +28 -0
  153. package/dist/utils/arrayUtil.d.ts +1 -0
  154. package/dist/utils/arrayUtil.js +10 -0
  155. package/dist/utils/genericUtil.d.ts +2 -0
  156. package/dist/utils/genericUtil.js +7 -0
  157. package/dist/utils/htmlCompiler.d.ts +12 -0
  158. package/dist/utils/htmlCompiler.js +70 -0
  159. package/dist/utils/tooltipUtils.d.ts +2 -0
  160. package/dist/utils/tooltipUtils.js +11 -0
  161. package/package.json +2 -2
  162. package/dist/composables/useTemplates.d.ts +0 -5
  163. package/dist/composables/useTemplates.js +0 -27
  164. package/dist/static/templates/default/index.html.js +0 -5
  165. package/dist/static/templates/default/style.css.js +0 -119
package/README.md CHANGED
@@ -27,10 +27,15 @@ npm install @useinsider/guido
27
27
  <div>
28
28
  <Guido
29
29
  ref="guidoEditor"
30
- :email-id="emailId"
30
+ :template-id="templateId"
31
31
  :user-id="userId"
32
32
  :guido-config="guidoConfig"
33
+ :html="initialHtml"
34
+ :css="initialCss"
33
35
  @dynamic-content:open="handleDynamicContentOpen"
36
+ @back="handleBack"
37
+ @save:start="handleSaveStart"
38
+ @save:complete="handleSaveComplete"
34
39
  />
35
40
  </div>
36
41
  </template>
@@ -44,28 +49,59 @@ export default {
44
49
  },
45
50
  data() {
46
51
  return {
47
- emailId: 'abc123',
48
- userId: '12345',
52
+ templateId: 'template-123',
53
+ userId: 'user-456',
54
+ initialHtml: '<p>Initial HTML content</p>',
55
+ initialCss: 'p { color: #333; }',
49
56
  guidoConfig: {
50
- translationsPath: 'window.trans.en'
51
- }
57
+ translationsPath: 'window.trans.en',
58
+ htmlCompilerRules: [],
59
+ ignoreDefaultHtmlCompilerRules: false,
60
+ features: {
61
+ dynamicContent: true,
62
+ saveAsTemplate: true,
63
+ versionHistory: true
64
+ }
65
+ },
52
66
  dynamicContentModalVisible: false
53
67
  };
54
68
  },
55
69
 
56
70
  methods: {
57
- handleDynamicContentOpen() {
71
+ handleDynamicContentOpen(detail) {
72
+ console.log('Dynamic content requested:', detail);
58
73
  this.dynamicContentModalVisible = true;
59
- }
74
+ },
75
+
76
+ handleBack() {
77
+ console.log('User clicked back button');
78
+ // Handle navigation back
79
+ },
80
+
81
+ handleSaveStart() {
82
+ console.log('Save process started');
83
+ // Show loading indicator
84
+ },
85
+
86
+ handleSaveComplete(template) {
87
+ console.log('Save completed:', template);
88
+ // Handle saved template data
89
+ },
90
+
60
91
  // ⚠️ Your own Dynamic Content Modal should have this id: #guido-dynamic-content-modal
61
- handleDynamicContentApply() {
62
- this.$ref.guidoEditor.applyDynamicContent({
63
- text: 'Text',
64
- value: 'Value',
65
- fallback: 'Fallback'
92
+ handleDynamicContentInsert() {
93
+ this.$refs.guidoEditor?.dynamicContent.insert({
94
+ text: 'Display Text',
95
+ value: 'actual-value',
96
+ fallback: 'Fallback Text'
66
97
  });
67
98
 
68
99
  this.dynamicContentModalVisible = false;
100
+ },
101
+
102
+ // ⚠️ It's mandatory. There is no way to understand if user closes the modal without selection.
103
+ handleDynamicContentClose() {
104
+ this.$refs.guidoEditor?.dynamicContent.close();
69
105
  }
70
106
  }
71
107
  };
@@ -78,16 +114,28 @@ export default {
78
114
 
79
115
  | Prop | Type | Required | Default | Description |
80
116
  |------|------|----------|---------|-------------|
81
- | `emailId` | `string` | ✅ | - | Unique identifier for the email draft |
82
- | `userId` | `string` | ✅ | - | Unique identifier for the user draft |
83
- | `username` | `string` | ⚪ | Guido User | User name |
84
- | `partnerName` | `string` | ⚪ | Getting from URL host | Unique identifier for the partner draft |
85
- | `productType` | `string` | ⚪ | Getting from URL path | Unique identifier for the product draft |
117
+ | `templateId` | `string` | ✅ | - | Unique identifier for the email template |
118
+ | `userId` | `string` | ✅ | - | Unique identifier for the user |
86
119
  | `guidoConfig` | `GuidoConfig` | ✅ | - | Configuration object for the editor |
120
+ | `partnerName` | `string` | ⚪ | From URL host | Partner identifier |
121
+ | `productType` | `string` | ⚪ | From URL path | Product type identifier |
122
+ | `username` | `string` | ⚪ | `'Guido User'` | Display name for the user |
123
+ | `html` | `string` | ⚪ | `''` | Initial HTML content for the template |
124
+ | `css` | `string` | ⚪ | `''` | Initial CSS styles for the template |
125
+
126
+ ### Guido Component Events
127
+
128
+ | Event | Payload | Description |
129
+ |-------|---------|-------------|
130
+ | `dynamic-content:open` | `DynamicContent \| null` | Fired when user requests to insert dynamic content |
131
+ | `back` | - | Fired when user clicks the back button |
132
+ | `save:start` | - | Fired when the save process begins |
133
+ | `save:complete` | `Omit<Template, 'forceRecreate'>` | Fired when template is successfully saved |
87
134
 
88
135
  ### Guido Exposed Methods
89
136
  ```typescript
90
- applyDynamicContent(DynamicContent);
137
+ dynamicContent.insert(DynamicContent);
138
+ dynamicContent.close();
91
139
  ```
92
140
 
93
141
  ### Guido Interfaces
@@ -95,12 +143,25 @@ applyDynamicContent(DynamicContent);
95
143
  ```typescript
96
144
  interface GuidoConfig {
97
145
  translationsPath: string;
146
+ htmlCompilerRules?: CompilerRule[];
147
+ ignoreDefaultHtmlCompilerRules?: boolean;
148
+ features: {
149
+ dynamicContent: boolean;
150
+ saveAsTemplate: boolean;
151
+ versionHistory: boolean;
152
+ };
98
153
  }
99
154
  ```
100
155
 
101
156
  | Property | Type | Default | Description |
102
157
  |----------|------|---------|-------------|
103
158
  | `translationsPath` | `string` | `'window.trans.en'` | JavaScript path to the translations object |
159
+ | `htmlCompilerRules` | `CompilerRule[]` | `[]` | Additional compiler rules to apply to HTML content. See [HTML Compiler Rules](#-html-compiler-rules) section below |
160
+ | `ignoreDefaultHtmlCompilerRules` | `boolean` | `false` | Skip default compiler rules and only use custom rules. Default rules: `src/config/compiler/htmlCompilerRules.ts` |
161
+ | `features` | `Features` | `{ dynamicContent: true, saveAsTemplate: true, versionHistory: true }` | Feature flags to enable/disable editor functionality |
162
+ | `features.dynamicContent` | `boolean` | `true` | Enable dynamic content insertion feature |
163
+ | `features.saveAsTemplate` | `boolean` | `true` | Enable save as template feature |
164
+ | `features.versionHistory` | `boolean` | `true` | Enable version history feature |
104
165
 
105
166
  ```typescript
106
167
  interface DynamicContent {
@@ -109,6 +170,7 @@ interface DynamicContent {
109
170
  fallback?: string;
110
171
  }
111
172
  ```
173
+ ---
112
174
 
113
175
  | Property | Type | Default | Description |
114
176
  |----------|------|---------|-------------|
@@ -129,6 +191,195 @@ import type { GuidoConfig } from '@useinsider/guido';
129
191
  import type { StripoEventType } from '@useinsider/guido';
130
192
  ```
131
193
 
194
+ ## 🔨 HTML Compiler Rules
195
+
196
+ 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.
197
+
198
+ ### Rule Types
199
+
200
+ There are 4 types of compiler rules:
201
+
202
+ #### 1. Replace Rule
203
+ Replace specific strings in HTML content.
204
+
205
+ ```typescript
206
+ {
207
+ id: 'fix-encoding',
208
+ description: 'Fix URL encoding issues',
209
+ type: 'replace',
210
+ search: '{%22', // String to find
211
+ replacement: '%7B%22', // String to replace with
212
+ replaceAll: true, // Replace all occurrences (default: true)
213
+ priority: 10 // Execution priority (lower = earlier)
214
+ }
215
+ ```
216
+
217
+ #### 2. Regex Rule
218
+ Use regular expressions for complex pattern matching and replacement.
219
+
220
+ ```typescript
221
+ {
222
+ id: 'remove-comments',
223
+ description: 'Remove HTML comments',
224
+ type: 'regex',
225
+ pattern: '<!--.*?-->', // Regex pattern
226
+ replacement: '', // Replacement string
227
+ flags: 'g', // Regex flags (default: 'g')
228
+ priority: 20
229
+ }
230
+ ```
231
+
232
+ #### 3. Remove Rule
233
+ Remove specific strings or patterns from HTML content.
234
+
235
+ ```typescript
236
+ {
237
+ id: 'cleanup-scripts',
238
+ description: 'Remove unwanted script tags',
239
+ type: 'remove',
240
+ targets: [ // Array of strings or RegExp objects
241
+ '<script src="unwanted.js"></script>',
242
+ /onclick="[^"]*"/g
243
+ ],
244
+ priority: 30
245
+ }
246
+ ```
247
+
248
+ #### 4. Custom Rule
249
+ Define complex transformation logic with a custom processor function.
250
+
251
+ ```typescript
252
+ {
253
+ id: 'add-meta-tags',
254
+ description: 'Add custom meta tags to head',
255
+ type: 'custom',
256
+ processor: (html: string): string => {
257
+ // Custom transformation logic
258
+ const metaTags = '<meta name="custom" content="value">';
259
+ return html.replace('</head>', `${metaTags}</head>`);
260
+ },
261
+ priority: 40
262
+ }
263
+ ```
264
+
265
+ ### Using HTML Compiler Rules
266
+
267
+ #### Basic Usage with Custom Rules
268
+
269
+ ```typescript
270
+ const guidoConfig = {
271
+ translationsPath: 'window.trans.en',
272
+ features: {
273
+ dynamicContent: true,
274
+ saveAsTemplate: true,
275
+ versionHistory: false // Disable version history
276
+ },
277
+ htmlCompilerRules: [
278
+ {
279
+ id: 'replace-domain',
280
+ description: 'Replace old domain with new one',
281
+ type: 'replace',
282
+ search: 'old-domain.com',
283
+ replacement: 'new-domain.com',
284
+ replaceAll: true,
285
+ priority: 10
286
+ },
287
+ {
288
+ id: 'remove-tracking',
289
+ description: 'Remove tracking pixels',
290
+ type: 'regex',
291
+ pattern: '<img[^>]*tracking[^>]*>',
292
+ replacement: '',
293
+ flags: 'gi',
294
+ priority: 20
295
+ }
296
+ ]
297
+ };
298
+ ```
299
+
300
+ #### Ignoring Default Rules
301
+
302
+ ```typescript
303
+ const guidoConfig = {
304
+ translationsPath: 'window.trans.en',
305
+ features: {
306
+ dynamicContent: true,
307
+ saveAsTemplate: true,
308
+ versionHistory: true
309
+ },
310
+ ignoreDefaultHtmlCompilerRules: true, // Skip all default rules
311
+ htmlCompilerRules: [
312
+ // Only your custom rules will be applied
313
+ {
314
+ id: 'custom-transformation',
315
+ type: 'replace',
316
+ search: 'old-text',
317
+ replacement: 'new-text',
318
+ priority: 1
319
+ }
320
+ ]
321
+ };
322
+ ```
323
+
324
+ ### Rule Execution Order
325
+
326
+ Rules are executed in priority order (lower numbers first). Rules with the same priority are executed in array order.
327
+
328
+ - **Priority 1-99**: Reserved for critical transformations
329
+ - **Priority 100-999**: Standard transformations
330
+ - **Priority 1000+**: Additional custom rules (automatically assigned)
331
+
332
+ ### Default Rules
333
+
334
+ Guido includes several default rules for common email HTML optimizations:
335
+
336
+ - **URL encoding fixes**: Fixes malformed URL encoding in dynamic content
337
+ - **Template tag restoration**: Restores `{{}}` template tags that got URL encoded
338
+ - **HTML entity decoding**: Converts `&lt;` and `&gt;` back to `<` and `>`
339
+ - **Cleanup rules**: Removes unwanted iframe and style elements
340
+ - **MSO conditions**: Manages Outlook-specific conditional comments
341
+ - **Domain replacement**: Updates old image domains to current ones
342
+
343
+ You can view all default rules in: `src/config/compiler/htmlCompilerRules.ts`
344
+
345
+ ### CompilerRule Interface
346
+
347
+ ```typescript
348
+ type CompilerRuleType = 'replace' | 'regex' | 'remove' | 'custom';
349
+
350
+ interface BaseCompilerRule {
351
+ id: string;
352
+ description?: string;
353
+ priority: number;
354
+ }
355
+
356
+ interface ReplaceRule extends BaseCompilerRule {
357
+ type: 'replace';
358
+ search: string;
359
+ replacement: string;
360
+ replaceAll?: boolean; // Default: true
361
+ }
362
+
363
+ interface RegexRule extends BaseCompilerRule {
364
+ type: 'regex';
365
+ pattern: string;
366
+ replacement: string;
367
+ flags?: string; // Default: 'g'
368
+ }
369
+
370
+ interface RemoveRule extends BaseCompilerRule {
371
+ type: 'remove';
372
+ targets: (string | RegExp)[]; // Array of strings or RegExp objects
373
+ }
374
+
375
+ interface CustomRule extends BaseCompilerRule {
376
+ type: 'custom';
377
+ processor: (html: string) => string;
378
+ }
379
+
380
+ type CompilerRule = ReplaceRule | RegexRule | RemoveRule | CustomRule;
381
+ ```
382
+
132
383
  ---
133
384
 
134
385
  ## 🔧 Development
@@ -185,6 +436,87 @@ src/
185
436
  └── library.ts # Main export
186
437
  ```
187
438
 
439
+ ## 🔌 Provide/Inject Utilities
440
+
441
+ Guido includes type-safe utilities for Vue's provide/inject system to facilitate dependency injection between components.
442
+
443
+ ### useProvideInject
444
+
445
+ The `useProvideInject` composable provides two helper functions for type-safe dependency injection:
446
+
447
+ #### Basic Usage
448
+
449
+ ```typescript
450
+ // Parent component
451
+ import { provideValue } from '@useinsider/guido';
452
+ import { InjectionKey } from 'vue';
453
+
454
+ // Define a typed injection key
455
+ const MyServiceKey: InjectionKey<MyService> = Symbol('MyService');
456
+
457
+ // Provide the value
458
+ const myService = new MyService();
459
+ provideValue(MyServiceKey, myService);
460
+
461
+ // Child component
462
+ import { useInjectedValue } from '@useinsider/guido';
463
+
464
+ // Inject the value with type safety
465
+ const myService = useInjectedValue(MyServiceKey);
466
+ ```
467
+
468
+ #### With Default Value
469
+
470
+ ```typescript
471
+ // Inject with a fallback value
472
+ const myService = useInjectedValue(MyServiceKey, new DefaultService());
473
+ ```
474
+
475
+ #### Error Handling
476
+
477
+ The `useInjectedValue` function will throw a descriptive error if no provider is found and no default value is provided:
478
+
479
+ ```typescript
480
+ // This will throw an error if no provider exists
481
+ try {
482
+ const myService = useInjectedValue(MyServiceKey);
483
+ } catch (error) {
484
+ console.error('No provider found for MyService');
485
+ }
486
+ ```
487
+
488
+ ### API Reference
489
+
490
+ #### `provideValue`
491
+
492
+ ```typescript
493
+ provideValue<T>(key: InjectionKey<T>, value: T): void
494
+ ```
495
+
496
+ Provides a value using Vue's provide system with type safety.
497
+
498
+ | Parameter | Type | Description |
499
+ |-----------|------|-------------|
500
+ | `key` | `InjectionKey<T>` | The typed injection key |
501
+ | `value` | `T` | The value to provide |
502
+
503
+ #### `useInjectedValue`
504
+
505
+ ```typescript
506
+ useInjectedValue<T>(key: InjectionKey<T>, defaultValue?: T): T
507
+ ```
508
+
509
+ Injects a value using Vue's inject system with type safety and error handling.
510
+
511
+ | Parameter | Type | Required | Description |
512
+ |-----------|------|----------|-------------|
513
+ | `key` | `InjectionKey<T>` | ✅ | The typed injection key |
514
+ | `defaultValue` | `T` | ⚪ | Optional fallback value |
515
+
516
+ **Returns:** `T` - The injected value
517
+
518
+ **Throws:** `Error` - When no provider is found and no default value is provided
519
+
188
520
  ## 🌐 i18n
189
521
  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).
190
522
  It allows to use production or local translations on your code. 🚀
@@ -210,16 +542,16 @@ Since bun does not have packaging yet, use npm here: 🥲
210
542
  npm pack
211
543
  ```
212
544
 
213
- It'll crate like `useinsider-guido-1.0.0.gz` file.
545
+ It'll crate like `useinsider-guido-1.0.0.tgz` file.
214
546
 
215
547
  Move this file to your project path like: `email-fe` via:
216
548
  ```sh
217
- cp useinsider-guido-1.0.0.gz ../email-fe
549
+ cp useinsider-guido-1.0.0.tgz ../email-fe
218
550
  ```
219
551
 
220
552
  Install the file to your project:
221
553
  ```sh
222
- npm i ./useinsider-guido-1.0.0.gz
554
+ npm i ./useinsider-guido-1.0.0.tgz
223
555
  ```
224
556
 
225
557
  Then you just need to rebuild to your project or restart the Container. 🎉
@@ -271,8 +603,4 @@ ISC License
271
603
  - Master Version Generator should be fixed.
272
604
  - Playwright integration
273
605
  - Commitlint & Precommit Hooks integration
274
- - We need to emit save event and we should return template config to it
275
- - Default template should be same with production
276
- - Open Guido with saved template
277
- - Get User ID, Email and Unique Template ID as dynamic from props
278
606
  - Get Pre-built display conditions from API
@@ -1,8 +1,38 @@
1
+ import type { CompilerRule } from './html-compiler';
2
+ type Features = {
3
+ dynamicContent?: boolean;
4
+ saveAsTemplate?: boolean;
5
+ versionHistory?: boolean;
6
+ };
1
7
  export type GuidoConfig = {
2
8
  translationsPath: string;
9
+ htmlCompilerRules?: CompilerRule[];
10
+ ignoreDefaultHtmlCompilerRules?: boolean;
11
+ emailHeader: EmailHeader;
12
+ features?: Features;
3
13
  };
4
14
  export type DynamicContent = {
5
15
  value: string;
6
16
  text: string;
7
17
  fallback?: string;
8
18
  };
19
+ export interface EmailHeader {
20
+ senderName: string;
21
+ subject: string;
22
+ }
23
+ export interface TooltipOptions {
24
+ id: string;
25
+ dynamicPosition: boolean;
26
+ staticPosition: 'top center' | 'top left' | 'top right' | 'bottom center' | 'bottom left' | 'bottom right' | 'right center' | 'right top' | 'right bottom' | 'left center' | 'left top' | 'left bottom';
27
+ iconStatus: boolean;
28
+ offset?: {
29
+ x: number;
30
+ y: number;
31
+ };
32
+ preventXss?: boolean;
33
+ }
34
+ export type MergeTag = {
35
+ label: string;
36
+ value: string;
37
+ };
38
+ export {};
@@ -1,16 +1,29 @@
1
1
  import type { DynamicContent, GuidoConfig } from '@@/Types/generic';
2
+ import type { Template } from '@@/Types/stripo';
2
3
  type __VLS_Props = {
3
- emailId: string;
4
+ templateId: string;
4
5
  userId: string;
5
6
  partnerName?: string;
6
7
  productType?: string;
7
8
  username?: string;
9
+ html?: string;
10
+ css?: string;
11
+ preselectedDynamicContentList: DynamicContent[];
8
12
  guidoConfig: GuidoConfig;
9
13
  };
10
14
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {
11
- applyDynamicContent: (data: DynamicContent) => void;
15
+ dynamicContent: {
16
+ insert: (data: DynamicContent) => void;
17
+ close: () => void;
18
+ };
12
19
  }, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {
13
20
  "dynamic-content:open": (detail: DynamicContent | null) => void;
21
+ back: () => void;
22
+ "save:start": () => void;
23
+ "save:complete": (data: {
24
+ template: Omit<Template, "forceRecreate">;
25
+ dynamicContentList: DynamicContent[];
26
+ }) => void;
14
27
  }, string, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}>;
15
28
  export default _default;
16
29
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
@@ -1,18 +1,18 @@
1
1
  import o from "./Guido.vue2.js";
2
2
  /* empty css */
3
- import i from "../_virtual/_plugin-vue2_normalizer.js";
3
+ import t from "../_virtual/_plugin-vue2_normalizer.js";
4
4
  var s = function() {
5
- var e = this, r = e._self._c, t = e._self._setupProxy;
6
- return r("div", { staticClass: "guido-editor__wrapper" }, [r(t.HeaderWrapper), r("div", { staticClass: "guido-editor__container", attrs: { id: "guido-editor" } })], 1);
7
- }, _ = [], a = /* @__PURE__ */ i(
5
+ var i = this, e = i._self._c, r = i._self._setupProxy;
6
+ return e("div", { staticClass: "guido-editor__wrapper" }, [e(r.HeaderWrapper), r.previewStore.isPreviewModeOpen ? e(r.PreviewContainer) : i._e(), e("div", { directives: [{ name: "show", rawName: "v-show", value: !r.previewStore.isPreviewModeOpen, expression: "!previewStore.isPreviewModeOpen" }], staticClass: "guido-editor__container", attrs: { id: "guido-editor" } }), e(r.Toaster)], 1);
7
+ }, a = [], n = /* @__PURE__ */ t(
8
8
  o,
9
9
  s,
10
- _,
10
+ a,
11
11
  !1,
12
12
  null,
13
- "1d1d2b7c"
13
+ "09c28ccc"
14
14
  );
15
- const f = a.exports;
15
+ const v = n.exports;
16
16
  export {
17
- f as default
17
+ v as default
18
18
  };