@useinsider/guido 1.0.0-beta.b8ba815 → 1.0.0-beta.c214e7f

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 (152) hide show
  1. package/README.md +24 -375
  2. package/dist/@types/generic.d.ts +0 -8
  3. package/dist/App.vue.d.ts +1 -1
  4. package/dist/components/Guido.vue.d.ts +3 -16
  5. package/dist/components/Guido.vue.js +8 -8
  6. package/dist/components/Guido.vue2.js +24 -57
  7. package/dist/components/organisms/base/ModalWrapper.vue.d.ts +72 -0
  8. package/dist/components/organisms/base/ModalWrapper.vue.js +19 -0
  9. package/dist/components/organisms/base/ModalWrapper.vue2.js +43 -0
  10. package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
  11. package/dist/components/organisms/header/LeftSlot.vue2.js +8 -10
  12. package/dist/components/organisms/header/MiddleSlot.vue.js +1 -1
  13. package/dist/components/organisms/header/RightSlot.vue.d.ts +1 -1
  14. package/dist/components/organisms/header/RightSlot.vue.js +1 -1
  15. package/dist/components/organisms/header/RightSlot.vue2.js +15 -27
  16. package/dist/components/organisms/header/ViewOptions.vue.d.ts +1 -1
  17. package/dist/components/organisms/header/version-history/RestoreButton.vue.d.ts +1 -1
  18. package/dist/components/organisms/header/version-history/VersionHistoryItem.vue.d.ts +1 -1
  19. package/dist/components/organisms/header/version-history/VersionHistoryItem.vue.js +1 -1
  20. package/dist/components/organisms/header/version-history/ViewOptions.vue.d.ts +1 -1
  21. package/dist/components/organisms/save-template/SaveTemplateModal.vue.d.ts +16 -0
  22. package/dist/components/organisms/save-template/SaveTemplateModal.vue.js +22 -0
  23. package/dist/components/organisms/save-template/SaveTemplateModal.vue2.js +86 -0
  24. package/dist/composables/useActionsApi.d.ts +0 -1
  25. package/dist/composables/useActionsApi.js +12 -14
  26. package/dist/composables/useExport.d.ts +1 -1
  27. package/dist/composables/useExport.js +20 -35
  28. package/dist/composables/useSaveAsTemplate.d.ts +17 -0
  29. package/dist/composables/useSaveAsTemplate.js +44 -0
  30. package/dist/composables/useStripo.js +29 -41
  31. package/dist/composables/useTemplateCategories.d.ts +35 -0
  32. package/dist/composables/useTemplateCategories.js +78 -0
  33. package/dist/composables/useTemplateNameValidation.d.ts +13 -0
  34. package/dist/composables/useTemplateNameValidation.js +57 -0
  35. package/dist/composables/useTemplates.d.ts +5 -0
  36. package/dist/composables/useTemplates.js +27 -0
  37. package/dist/guido.css +1 -1
  38. package/dist/services/stripoApi.d.ts +1 -2
  39. package/dist/services/stripoApi.js +7 -27
  40. package/dist/static/templates/default/index.html.js +5 -0
  41. package/dist/static/templates/default/style.css.js +119 -0
  42. package/dist/stores/editor.d.ts +1 -0
  43. package/dist/stores/editor.js +2 -1
  44. package/dist/utils/base64.d.ts +1 -0
  45. package/dist/utils/base64.js +14 -0
  46. package/package.json +5 -6
  47. package/dist/_virtual/AddCustomFont.js +0 -4
  48. package/dist/_virtual/AiAssistantValueType.js +0 -4
  49. package/dist/_virtual/BackgroundColorBuiltInControl.js +0 -4
  50. package/dist/_virtual/BackgroundImageBuiltInControl.js +0 -4
  51. package/dist/_virtual/Block.js +0 -4
  52. package/dist/_virtual/BlockAttributes.js +0 -4
  53. package/dist/_virtual/BlockCompositionType.js +0 -4
  54. package/dist/_virtual/BlockPaddingsBuiltInControl.js +0 -4
  55. package/dist/_virtual/BlockRenderer.js +0 -4
  56. package/dist/_virtual/BlockType.js +0 -4
  57. package/dist/_virtual/BlocksPanel.js +0 -4
  58. package/dist/_virtual/BuiltInControl.js +0 -4
  59. package/dist/_virtual/BuiltInControlTypes.js +0 -4
  60. package/dist/_virtual/ButtonBorderBuiltInControl.js +0 -4
  61. package/dist/_virtual/ButtonColorBuiltInControl.js +0 -4
  62. package/dist/_virtual/ButtonFontColorBuiltInControl.js +0 -4
  63. package/dist/_virtual/ButtonInternalIndentsBuiltInControl.js +0 -4
  64. package/dist/_virtual/ButtonTextBuiltInControl.js +0 -4
  65. package/dist/_virtual/ContextAction.js +0 -4
  66. package/dist/_virtual/ContextActionType.js +0 -4
  67. package/dist/_virtual/Control.js +0 -4
  68. package/dist/_virtual/EditorStatePropertyType.js +0 -4
  69. package/dist/_virtual/Extension.js +0 -4
  70. package/dist/_virtual/ExtensionBuilder.js +0 -4
  71. package/dist/_virtual/FontFamilyBuiltInControl.js +0 -4
  72. package/dist/_virtual/LinkColorBuiltInControl.js +0 -4
  73. package/dist/_virtual/ModificationDescription.js +0 -4
  74. package/dist/_virtual/PanelPosition.js +0 -4
  75. package/dist/_virtual/PreviewDeviceMode.js +0 -4
  76. package/dist/_virtual/SettingsPanelRegistry.js +0 -4
  77. package/dist/_virtual/SettingsPanelTab.js +0 -4
  78. package/dist/_virtual/SettingsTab.js +0 -4
  79. package/dist/_virtual/StructureBorderBuiltInControl.js +0 -4
  80. package/dist/_virtual/StructurePaddingsBuiltInControl.js +0 -4
  81. package/dist/_virtual/TextColorBuiltInControl.js +0 -4
  82. package/dist/_virtual/TextLineSpacingBuiltInControl.js +0 -4
  83. package/dist/_virtual/TextSizeBuiltInControl.js +0 -4
  84. package/dist/_virtual/TextStyleBuiltInControl.js +0 -4
  85. package/dist/_virtual/UIElement.js +0 -4
  86. package/dist/_virtual/UIElementTagRegistry.js +0 -4
  87. package/dist/_virtual/UIElementType.js +0 -4
  88. package/dist/_virtual/UIElementsAttributes.js +0 -4
  89. package/dist/_virtual/index.js +0 -5
  90. package/dist/_virtual/index2.js +0 -4
  91. package/dist/composables/useGuidoActions.d.ts +0 -46
  92. package/dist/composables/useGuidoActions.js +0 -37
  93. package/dist/composables/useHtmlCompiler.d.ts +0 -4
  94. package/dist/composables/useHtmlCompiler.js +0 -16
  95. package/dist/composables/useProvideInject.d.ts +0 -14
  96. package/dist/composables/useProvideInject.js +0 -17
  97. package/dist/config/compiler/htmlCompilerRules.d.ts +0 -2
  98. package/dist/config/compiler/htmlCompilerRules.js +0 -145
  99. package/dist/config/compiler/outlookCompilerRules.d.ts +0 -0
  100. package/dist/extensions/DynamicContent/dynamic-content-modal.d.ts +0 -6
  101. package/dist/extensions/DynamicContent/dynamic-content-modal.js +0 -27
  102. package/dist/extensions/DynamicContent/dynamic-content.css.js +0 -24
  103. package/dist/extensions/DynamicContent/dynamic-content.d.ts +0 -16
  104. package/dist/extensions/DynamicContent/dynamic-content.js +0 -63
  105. package/dist/extensions/DynamicContent/extension.d.ts +0 -2
  106. package/dist/extensions/DynamicContent/extension.js +0 -11
  107. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/Extension.js +0 -51
  108. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/ExtensionBuilder.js +0 -52
  109. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/blocks/Block.js +0 -41
  110. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/blocks/BlockRenderer.js +0 -18
  111. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/blocks/BlocksPanel.js +0 -32
  112. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/blocks/ContextAction.js +0 -18
  113. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/AddCustomFont.js +0 -8
  114. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/AiAssistantValueType.js +0 -13
  115. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockAttributes.js +0 -34
  116. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockCompositionType.js +0 -13
  117. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockType.js +0 -13
  118. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BuiltInControlTypes.js +0 -104
  119. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/ContextActionType.js +0 -13
  120. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/EditorStatePropertyType.js +0 -13
  121. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/PanelPosition.js +0 -13
  122. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/PreviewDeviceMode.js +0 -13
  123. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/SettingsTab.js +0 -13
  124. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementType.js +0 -13
  125. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementsAttributes.js +0 -45
  126. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/BackgroundColorBuiltInControl.js +0 -43
  127. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/BackgroundImageBuiltInControl.js +0 -46
  128. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/BlockPaddingsBuiltInControl.js +0 -44
  129. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/BuiltInControl.js +0 -22
  130. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/ButtonBorderBuiltInControl.js +0 -46
  131. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/ButtonColorBuiltInControl.js +0 -46
  132. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/ButtonFontColorBuiltInControl.js +0 -45
  133. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/ButtonInternalIndentsBuiltInControl.js +0 -45
  134. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/ButtonTextBuiltInControl.js +0 -45
  135. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/Control.js +0 -20
  136. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/FontFamilyBuiltInControl.js +0 -43
  137. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/LinkColorBuiltInControl.js +0 -45
  138. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/SettingsPanelRegistry.js +0 -18
  139. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/SettingsPanelTab.js +0 -32
  140. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/StructureBorderBuiltInControl.js +0 -46
  141. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/StructurePaddingsBuiltInControl.js +0 -44
  142. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/TextColorBuiltInControl.js +0 -43
  143. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/TextLineSpacingBuiltInControl.js +0 -43
  144. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/TextSizeBuiltInControl.js +0 -45
  145. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/TextStyleBuiltInControl.js +0 -43
  146. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/index.js +0 -266
  147. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/modifications/ModificationDescription.js +0 -26
  148. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/ui-elements/UIElement.js +0 -22
  149. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/ui-elements/UIElementTagRegistry.js +0 -18
  150. package/dist/utils/htmlCompiler.d.ts +0 -12
  151. package/dist/utils/htmlCompiler.js +0 -70
  152. /package/dist/mock/api/{default-template.d.ts → template-library.d.ts} +0 -0
package/README.md CHANGED
@@ -14,10 +14,7 @@ Guido is a Vue 2 + TypeScript wrapper for the Stripo Email Editor plugin. Easily
14
14
  ```bash
15
15
  npm install @useinsider/guido
16
16
  ```
17
- ### Prerequisites
18
- 🍍 Your project should have `pinia`
19
17
 
20
- ---
21
18
  ## 🚀 Usage
22
19
 
23
20
  ### Basic Usage
@@ -26,16 +23,9 @@ npm install @useinsider/guido
26
23
  <template>
27
24
  <div>
28
25
  <Guido
29
- ref="guidoEditor"
30
- :template-id="templateId"
26
+ :email-id="emailId"
31
27
  :user-id="userId"
32
28
  :guido-config="guidoConfig"
33
- :html="initialHtml"
34
- :css="initialCss"
35
- @dynamic-content:open="handleDynamicContentOpen"
36
- @back="handleBack"
37
- @save:start="handleSaveStart"
38
- @save:complete="handleSaveComplete"
39
29
  />
40
30
  </div>
41
31
  </template>
@@ -49,55 +39,12 @@ export default {
49
39
  },
50
40
  data() {
51
41
  return {
52
- templateId: 'template-123',
53
- userId: 'user-456',
54
- initialHtml: '<p>Initial HTML content</p>',
55
- initialCss: 'p { color: #333; }',
42
+ emailId: 'abc123',
43
+ userId: '12345',
56
44
  guidoConfig: {
57
- translationsPath: 'window.trans.en',
58
- htmlCompilerRules: [],
59
- ignoreDefaultHtmlCompilerRules: false,
60
- },
61
- dynamicContentModalVisible: false
45
+ translationsPath: 'window.trans.en'
46
+ }
62
47
  };
63
- },
64
-
65
- methods: {
66
- handleDynamicContentOpen(detail) {
67
- console.log('Dynamic content requested:', detail);
68
- this.dynamicContentModalVisible = true;
69
- },
70
-
71
- handleBack() {
72
- console.log('User clicked back button');
73
- // Handle navigation back
74
- },
75
-
76
- handleSaveStart() {
77
- console.log('Save process started');
78
- // Show loading indicator
79
- },
80
-
81
- handleSaveComplete(template) {
82
- console.log('Save completed:', template);
83
- // Handle saved template data
84
- },
85
-
86
- // ⚠️ Your own Dynamic Content Modal should have this id: #guido-dynamic-content-modal
87
- handleDynamicContentInsert() {
88
- this.$refs.guidoEditor?.dynamicContent.insert({
89
- text: 'Display Text',
90
- value: 'actual-value',
91
- fallback: 'Fallback Text'
92
- });
93
-
94
- this.dynamicContentModalVisible = false;
95
- },
96
-
97
- // ⚠️ It's mandatory. There is no way to understand if user closes the modal without selection.
98
- handleDynamicContentClose() {
99
- this.$refs.guidoEditor?.dynamicContent.close();
100
- }
101
48
  }
102
49
  };
103
50
  </script>
@@ -109,51 +56,24 @@ export default {
109
56
 
110
57
  | Prop | Type | Required | Default | Description |
111
58
  |------|------|----------|---------|-------------|
112
- | `templateId` | `string` | ✅ | - | Unique identifier for the email template |
113
- | `userId` | `string` | ✅ | - | Unique identifier for the user |
59
+ | `emailId` | `string` | ✅ | - | Unique identifier for the email draft |
60
+ | `userId` | `string` | ✅ | - | Unique identifier for the user draft |
61
+ | `username` | `string` | ⚪ | Guido User | User name |
62
+ | `partnerName` | `string` | ⚪ | Getting from URL host | Unique identifier for the partner draft |
63
+ | `productType` | `string` | ⚪ | Getting from URL path | Unique identifier for the product draft |
114
64
  | `guidoConfig` | `GuidoConfig` | ✅ | - | Configuration object for the editor |
115
- | `partnerName` | `string` | ⚪ | From URL host | Partner identifier |
116
- | `productType` | `string` | ⚪ | From URL path | Product type identifier |
117
- | `username` | `string` | ⚪ | `'Guido User'` | Display name for the user |
118
- | `html` | `string` | ⚪ | `''` | Initial HTML content for the template |
119
- | `css` | `string` | ⚪ | `''` | Initial CSS styles for the template |
120
65
 
121
- ### Guido Exposed Methods
122
- ```typescript
123
- dynamicContent.insert(DynamicContent);
124
- dynamicContent.close();
125
- ```
126
-
127
- ### Guido Interfaces
66
+ ### GuidoConfig Interface
128
67
 
129
68
  ```typescript
130
69
  interface GuidoConfig {
131
70
  translationsPath: string;
132
- htmlCompilerRules: CompilerRule[];
133
- ignoreDefaultHtmlCompilerRules: boolean;
134
71
  }
135
72
  ```
136
73
 
137
74
  | Property | Type | Default | Description |
138
75
  |----------|------|---------|-------------|
139
76
  | `translationsPath` | `string` | `'window.trans.en'` | JavaScript path to the translations object |
140
- | `htmlCompilerRules` | `CompilerRule[]` | `[]` | Additional compiler rules to apply to HTML content. See [HTML Compiler Rules](#-html-compiler-rules) section below |
141
- | `ignoreDefaultHtmlCompilerRules` | `boolean` | `false` | Skip default compiler rules and only use custom rules. Default rules: `src/config/compiler/htmlCompilerRules.ts` |
142
-
143
- ```typescript
144
- interface DynamicContent {
145
- value: string;
146
- text: string;
147
- fallback?: string;
148
- }
149
- ```
150
- ---
151
-
152
- | Property | Type | Default | Description |
153
- |----------|------|---------|-------------|
154
- | `value` | `string` | '' | Value of the dynamic content |
155
- | `text` | `string` | '' | Visible value of the dynamic content |
156
- | `fallback?` | `string` | '' | Fallback value of the dynamic content. Optional |
157
77
 
158
78
  ### TypeScript Types
159
79
 
@@ -168,183 +88,17 @@ import type { GuidoConfig } from '@useinsider/guido';
168
88
  import type { StripoEventType } from '@useinsider/guido';
169
89
  ```
170
90
 
171
- ## 🔨 HTML Compiler Rules
172
-
173
- 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.
174
-
175
- ### Rule Types
176
-
177
- There are 4 types of compiler rules:
178
-
179
- #### 1. Replace Rule
180
- Replace specific strings in HTML content.
181
-
182
- ```typescript
183
- {
184
- id: 'fix-encoding',
185
- description: 'Fix URL encoding issues',
186
- type: 'replace',
187
- search: '{%22', // String to find
188
- replacement: '%7B%22', // String to replace with
189
- replaceAll: true, // Replace all occurrences (default: true)
190
- priority: 10 // Execution priority (lower = earlier)
191
- }
192
- ```
193
-
194
- #### 2. Regex Rule
195
- Use regular expressions for complex pattern matching and replacement.
91
+ ### StripoEventType
196
92
 
197
93
  ```typescript
198
- {
199
- id: 'remove-comments',
200
- description: 'Remove HTML comments',
201
- type: 'regex',
202
- pattern: '<!--.*?-->', // Regex pattern
203
- replacement: '', // Replacement string
204
- flags: 'g', // Regex flags (default: 'g')
205
- priority: 20
206
- }
207
- ```
208
-
209
- #### 3. Remove Rule
210
- Remove specific strings or patterns from HTML content.
211
-
212
- ```typescript
213
- {
214
- id: 'cleanup-scripts',
215
- description: 'Remove unwanted script tags',
216
- type: 'remove',
217
- targets: [ // Array of strings or RegExp objects
218
- '<script src="unwanted.js"></script>',
219
- /onclick="[^"]*"/g
220
- ],
221
- priority: 30
222
- }
223
- ```
224
-
225
- #### 4. Custom Rule
226
- Define complex transformation logic with a custom processor function.
227
-
228
- ```typescript
229
- {
230
- id: 'add-meta-tags',
231
- description: 'Add custom meta tags to head',
232
- type: 'custom',
233
- processor: (html: string): string => {
234
- // Custom transformation logic
235
- const metaTags = '<meta name="custom" content="value">';
236
- return html.replace('</head>', `${metaTags}</head>`);
237
- },
238
- priority: 40
239
- }
240
- ```
241
-
242
- ### Using HTML Compiler Rules
243
-
244
- #### Basic Usage with Custom Rules
245
-
246
- ```typescript
247
- const guidoConfig = {
248
- translationsPath: 'window.trans.en',
249
- htmlCompilerRules: [
250
- {
251
- id: 'replace-domain',
252
- description: 'Replace old domain with new one',
253
- type: 'replace',
254
- search: 'old-domain.com',
255
- replacement: 'new-domain.com',
256
- replaceAll: true,
257
- priority: 10
258
- },
259
- {
260
- id: 'remove-tracking',
261
- description: 'Remove tracking pixels',
262
- type: 'regex',
263
- pattern: '<img[^>]*tracking[^>]*>',
264
- replacement: '',
265
- flags: 'gi',
266
- priority: 20
267
- }
268
- ]
269
- };
270
- ```
271
-
272
- #### Ignoring Default Rules
273
-
274
- ```typescript
275
- const guidoConfig = {
276
- translationsPath: 'window.trans.en',
277
- ignoreDefaultHtmlCompilerRules: true, // Skip all default rules
278
- htmlCompilerRules: [
279
- // Only your custom rules will be applied
280
- {
281
- id: 'custom-transformation',
282
- type: 'replace',
283
- search: 'old-text',
284
- replacement: 'new-text',
285
- priority: 1
286
- }
287
- ]
288
- };
289
- ```
290
-
291
- ### Rule Execution Order
292
-
293
- Rules are executed in priority order (lower numbers first). Rules with the same priority are executed in array order.
294
-
295
- - **Priority 1-99**: Reserved for critical transformations
296
- - **Priority 100-999**: Standard transformations
297
- - **Priority 1000+**: Additional custom rules (automatically assigned)
298
-
299
- ### Default Rules
300
-
301
- Guido includes several default rules for common email HTML optimizations:
302
-
303
- - **URL encoding fixes**: Fixes malformed URL encoding in dynamic content
304
- - **Template tag restoration**: Restores `{{}}` template tags that got URL encoded
305
- - **HTML entity decoding**: Converts `&lt;` and `&gt;` back to `<` and `>`
306
- - **Cleanup rules**: Removes unwanted iframe and style elements
307
- - **MSO conditions**: Manages Outlook-specific conditional comments
308
- - **Domain replacement**: Updates old image domains to current ones
309
-
310
- You can view all default rules in: `src/config/compiler/htmlCompilerRules.ts`
311
-
312
- ### CompilerRule Interface
313
-
314
- ```typescript
315
- type CompilerRuleType = 'replace' | 'regex' | 'remove' | 'custom';
316
-
317
- interface BaseCompilerRule {
318
- id: string;
319
- description?: string;
320
- priority: number;
321
- }
322
-
323
- interface ReplaceRule extends BaseCompilerRule {
324
- type: 'replace';
325
- search: string;
326
- replacement: string;
327
- replaceAll?: boolean; // Default: true
328
- }
329
-
330
- interface RegexRule extends BaseCompilerRule {
331
- type: 'regex';
332
- pattern: string;
333
- replacement: string;
334
- flags?: string; // Default: 'g'
335
- }
336
-
337
- interface RemoveRule extends BaseCompilerRule {
338
- type: 'remove';
339
- targets: (string | RegExp)[]; // Array of strings or RegExp objects
340
- }
341
-
342
- interface CustomRule extends BaseCompilerRule {
343
- type: 'custom';
344
- processor: (html: string) => string;
345
- }
346
-
347
- type CompilerRule = ReplaceRule | RegexRule | RemoveRule | CustomRule;
94
+ type StripoEventType =
95
+ | 'save'
96
+ | 'export'
97
+ | 'close'
98
+ | 'autosave'
99
+ | 'publish'
100
+ | 'export:requested'
101
+ | 'export:ready';
348
102
  ```
349
103
 
350
104
  ---
@@ -403,87 +157,6 @@ src/
403
157
  └── library.ts # Main export
404
158
  ```
405
159
 
406
- ## 🔌 Provide/Inject Utilities
407
-
408
- Guido includes type-safe utilities for Vue's provide/inject system to facilitate dependency injection between components.
409
-
410
- ### useProvideInject
411
-
412
- The `useProvideInject` composable provides two helper functions for type-safe dependency injection:
413
-
414
- #### Basic Usage
415
-
416
- ```typescript
417
- // Parent component
418
- import { provideValue } from '@useinsider/guido';
419
- import { InjectionKey } from 'vue';
420
-
421
- // Define a typed injection key
422
- const MyServiceKey: InjectionKey<MyService> = Symbol('MyService');
423
-
424
- // Provide the value
425
- const myService = new MyService();
426
- provideValue(MyServiceKey, myService);
427
-
428
- // Child component
429
- import { useInjectedValue } from '@useinsider/guido';
430
-
431
- // Inject the value with type safety
432
- const myService = useInjectedValue(MyServiceKey);
433
- ```
434
-
435
- #### With Default Value
436
-
437
- ```typescript
438
- // Inject with a fallback value
439
- const myService = useInjectedValue(MyServiceKey, new DefaultService());
440
- ```
441
-
442
- #### Error Handling
443
-
444
- The `useInjectedValue` function will throw a descriptive error if no provider is found and no default value is provided:
445
-
446
- ```typescript
447
- // This will throw an error if no provider exists
448
- try {
449
- const myService = useInjectedValue(MyServiceKey);
450
- } catch (error) {
451
- console.error('No provider found for MyService');
452
- }
453
- ```
454
-
455
- ### API Reference
456
-
457
- #### `provideValue`
458
-
459
- ```typescript
460
- provideValue<T>(key: InjectionKey<T>, value: T): void
461
- ```
462
-
463
- Provides a value using Vue's provide system with type safety.
464
-
465
- | Parameter | Type | Description |
466
- |-----------|------|-------------|
467
- | `key` | `InjectionKey<T>` | The typed injection key |
468
- | `value` | `T` | The value to provide |
469
-
470
- #### `useInjectedValue`
471
-
472
- ```typescript
473
- useInjectedValue<T>(key: InjectionKey<T>, defaultValue?: T): T
474
- ```
475
-
476
- Injects a value using Vue's inject system with type safety and error handling.
477
-
478
- | Parameter | Type | Required | Description |
479
- |-----------|------|----------|-------------|
480
- | `key` | `InjectionKey<T>` | ✅ | The typed injection key |
481
- | `defaultValue` | `T` | ⚪ | Optional fallback value |
482
-
483
- **Returns:** `T` - The injected value
484
-
485
- **Throws:** `Error` - When no provider is found and no default value is provided
486
-
487
160
  ## 🌐 i18n
488
161
  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).
489
162
  It allows to use production or local translations on your code. 🚀
@@ -497,34 +170,6 @@ const trans = useTranslations();
497
170
  trans('foo.bar')
498
171
  ```
499
172
 
500
- ## 📦 Local Building (Recommended)
501
-
502
- Run this commands if you want to test the package on your local before sending to NPM.
503
- ```sh
504
- bun run build
505
- ```
506
-
507
- Since bun does not have packaging yet, use npm here: 🥲
508
- ```sh
509
- npm pack
510
- ```
511
-
512
- It'll crate like `useinsider-guido-1.0.0.tgz` file.
513
-
514
- Move this file to your project path like: `email-fe` via:
515
- ```sh
516
- cp useinsider-guido-1.0.0.tgz ../email-fe
517
- ```
518
-
519
- Install the file to your project:
520
- ```sh
521
- npm i ./useinsider-guido-1.0.0.tgz
522
- ```
523
-
524
- Then you just need to rebuild to your project or restart the Container. 🎉
525
-
526
- For Future, we can create a shell script for it. Feel free to help 🙃
527
-
528
173
  ## 📦 Build Output
529
174
 
530
175
  The library builds to multiple formats:
@@ -570,4 +215,8 @@ ISC License
570
215
  - Master Version Generator should be fixed.
571
216
  - Playwright integration
572
217
  - Commitlint & Precommit Hooks integration
218
+ - We need to emit save event and we should return template config to it
219
+ - Default template should be same with production
220
+ - Open Guido with saved template
221
+ - Get User ID, Email and Unique Template ID as dynamic from props
573
222
  - Get Pre-built display conditions from API
@@ -1,11 +1,3 @@
1
- import type { CompilerRule } from './html-compiler';
2
1
  export type GuidoConfig = {
3
2
  translationsPath: string;
4
- htmlCompilerRules?: CompilerRule[];
5
- ignoreDefaultHtmlCompilerRules?: boolean;
6
- };
7
- export type DynamicContent = {
8
- value: string;
9
- text: string;
10
- fallback?: string;
11
3
  };
package/dist/App.vue.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import '../node_modules/@useinsider/design-system-vue/dist/design-system-vue.css';
2
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
2
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
3
3
  export default _default;
@@ -1,26 +1,13 @@
1
- import type { DynamicContent, GuidoConfig } from '@@/Types/generic';
2
- import type { Template } from '@@/Types/stripo';
1
+ import type { GuidoConfig } from '@@/Types/generic';
3
2
  type __VLS_Props = {
4
- templateId: string;
3
+ emailId: string;
5
4
  userId: string;
6
5
  partnerName?: string;
7
6
  productType?: string;
8
7
  username?: string;
9
- html?: string;
10
- css?: string;
11
8
  guidoConfig: GuidoConfig;
12
9
  };
13
- declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {
14
- dynamicContent: {
15
- insert: (data: DynamicContent) => void;
16
- close: () => void;
17
- };
18
- }, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {
19
- "dynamic-content:open": (detail: DynamicContent | null) => void;
20
- back: () => void;
21
- "save:start": () => void;
22
- "save:complete": (template: Omit<Template, "forceRecreate">) => void;
23
- }, string, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}>;
10
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {}, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}>;
24
11
  export default _default;
25
12
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
26
13
  type __VLS_TypePropsToOption<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 a 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 t = this, e = t._self._c, r = t._self._setupProxy;
6
+ return e("div", { staticClass: "guido-editor__wrapper" }, [e(r.HeaderWrapper), e("div", { staticClass: "guido-editor__container", attrs: { id: "guido-editor" } }), e(r.SaveTemplateModal, { attrs: { "is-open": r.editorStore.isSaveTemplateModalOpen }, on: { close: r.handleCloseSaveTemplateModal } })], 1);
7
+ }, i = [], n = /* @__PURE__ */ a(
8
8
  o,
9
9
  s,
10
- _,
10
+ i,
11
11
  !1,
12
12
  null,
13
- "89bedf08"
13
+ "69c35c60"
14
14
  );
15
- const f = a.exports;
15
+ const c = n.exports;
16
16
  export {
17
- f as default
17
+ c as default
18
18
  };
@@ -1,80 +1,47 @@
1
- import { defineComponent as h, onMounted as w } from "vue";
2
- import { provideGuidoActions as D } from "../composables/useGuidoActions.js";
3
- import { usePartner as E } from "../composables/usePartner.js";
4
- import { useStripo as S } from "../composables/useStripo.js";
5
- import { DefaultUsername as _, DefaultGuidoConfig as G } from "../enums/defaults.js";
1
+ import { defineComponent as g, onMounted as T } from "vue";
2
+ import { usePartner as S } from "../composables/usePartner.js";
3
+ import { useStripo as C } from "../composables/useStripo.js";
4
+ import { useTemplates as _ } from "../composables/useTemplates.js";
5
+ import { DefaultUsername as y, DefaultGuidoConfig as w } from "../enums/defaults.js";
6
6
  import I from "./organisms/header/HeaderWrapper.vue.js";
7
- import { useStripoApi as k } from "../services/stripoApi.js";
8
- const B = /* @__PURE__ */ h({
7
+ import M from "./organisms/save-template/SaveTemplateModal.vue.js";
8
+ import { useEditorStore as P } from "../stores/editor.js";
9
+ const F = /* @__PURE__ */ g({
9
10
  __name: "Guido",
10
11
  props: {
11
- templateId: null,
12
+ emailId: null,
12
13
  userId: null,
13
14
  partnerName: null,
14
15
  productType: null,
15
16
  username: null,
16
- html: null,
17
- css: null,
18
17
  guidoConfig: null
19
18
  },
20
- emits: ["dynamic-content:open", "back", "save:start", "save:complete"],
21
- setup(C, { expose: b, emit: t }) {
22
- const o = C, { getPartnerName: n, getProductType: a } = E(), {
23
- templateId: c,
24
- userId: s,
19
+ setup(f) {
20
+ const o = f, { getPartnerName: t, getProductType: r } = S(), {
21
+ emailId: a,
22
+ userId: n,
25
23
  guidoConfig: i,
26
- html: r = "",
27
- css: l = "",
28
- partnerName: d = n(),
29
- productType: u = a(),
30
- username: m = _
24
+ partnerName: l = t(),
25
+ productType: m = r(),
26
+ username: p = y
31
27
  } = o;
32
28
  window.GuidoConfig = {
33
- ...G,
29
+ ...w,
34
30
  ...i
35
31
  };
36
- const { initPlugin: p } = S({ emailId: c, userId: s, username: m, partnerName: d, productType: u }), { getDefaultTemplate: g } = k();
37
- D({
38
- onBack: () => {
39
- console.debug("guido:back"), t("back");
40
- },
41
- onSaveStart: () => {
42
- console.debug("guido:save:start"), t("save:start");
43
- },
44
- onSaveComplete: (e) => {
45
- console.debug("guido:save:complete", e), t("save:complete", e);
46
- }
47
- });
48
- const f = (e) => {
49
- console.debug("dynamic-content:close", e), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: e }));
50
- }, y = () => {
51
- console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
32
+ const { initPlugin: u } = C({ emailId: a, userId: n, username: p, partnerName: l, productType: m }), { getDefaultTemplate: s } = _(), d = P(), c = () => {
33
+ d.isSaveTemplateModalOpen = !1;
52
34
  };
53
- return w(async () => {
54
- console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow");
35
+ return T(async () => {
55
36
  try {
56
- let e = {
57
- html: r,
58
- css: l,
59
- forceRecreate: !0
60
- // TODO: It should be false for old templates. We will communicate with Stripo
61
- };
62
- e.html || (e = await g()), await p(e);
37
+ const e = await s();
38
+ await u(e);
63
39
  } catch (e) {
64
40
  console.error("Failed to initialize Stripo editor:", e);
65
41
  }
66
- document.addEventListener("dynamic-content:open", (e) => {
67
- const v = e;
68
- console.debug("dynamic-content:open", v.detail), t("dynamic-content:open", v.detail);
69
- });
70
- }), b({
71
- dynamicContent: {
72
- insert: f,
73
- close: y
74
- }
75
- }), { __sfc: !0, props: o, getPartnerName: n, getProductType: a, templateId: c, userId: s, guidoConfig: i, html: r, css: l, partnerName: d, productType: u, username: m, emit: t, initPlugin: p, getDefaultTemplate: g, insertDynamicContent: f, closeDynamicContent: y, HeaderWrapper: I };
42
+ }), { __sfc: !0, props: o, getPartnerName: t, getProductType: r, emailId: a, userId: n, guidoConfig: i, partnerName: l, productType: m, username: p, initPlugin: u, getDefaultTemplate: s, editorStore: d, handleCloseSaveTemplateModal: c, HeaderWrapper: I, SaveTemplateModal: M };
76
43
  }
77
44
  });
78
45
  export {
79
- B as default
46
+ F as default
80
47
  };