@useinsider/guido 1.0.0-beta.3bcd23c → 1.0.0-beta.3e6a15c

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