@useinsider/guido 1.0.0-beta.30f3236 → 1.0.0-beta.35d2ac4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +203 -28
- package/dist/@types/generic.d.ts +9 -0
- package/dist/App.vue.d.ts +1 -1
- package/dist/_virtual/AddCustomFont.js +4 -0
- package/dist/_virtual/AiAssistantValueType.js +4 -0
- package/dist/_virtual/BackgroundColorBuiltInControl.js +4 -0
- package/dist/_virtual/BackgroundImageBuiltInControl.js +4 -0
- package/dist/_virtual/Block.js +4 -0
- package/dist/_virtual/BlockAttributes.js +4 -0
- package/dist/_virtual/BlockCompositionType.js +4 -0
- package/dist/_virtual/BlockPaddingsBuiltInControl.js +4 -0
- package/dist/_virtual/BlockRenderer.js +4 -0
- package/dist/_virtual/BlockType.js +4 -0
- package/dist/_virtual/BlocksPanel.js +4 -0
- package/dist/_virtual/BuiltInControl.js +4 -0
- package/dist/_virtual/BuiltInControlTypes.js +4 -0
- package/dist/_virtual/ButtonBorderBuiltInControl.js +4 -0
- package/dist/_virtual/ButtonColorBuiltInControl.js +4 -0
- package/dist/_virtual/ButtonFontColorBuiltInControl.js +4 -0
- package/dist/_virtual/ButtonInternalIndentsBuiltInControl.js +4 -0
- package/dist/_virtual/ButtonTextBuiltInControl.js +4 -0
- package/dist/_virtual/ContextAction.js +4 -0
- package/dist/_virtual/ContextActionType.js +4 -0
- package/dist/_virtual/Control.js +4 -0
- package/dist/_virtual/EditorStatePropertyType.js +4 -0
- package/dist/_virtual/Extension.js +4 -0
- package/dist/_virtual/ExtensionBuilder.js +4 -0
- package/dist/_virtual/FontFamilyBuiltInControl.js +4 -0
- package/dist/_virtual/LinkColorBuiltInControl.js +4 -0
- package/dist/_virtual/ModificationDescription.js +4 -0
- package/dist/_virtual/PanelPosition.js +4 -0
- package/dist/_virtual/PreviewDeviceMode.js +4 -0
- package/dist/_virtual/SettingsPanelRegistry.js +4 -0
- package/dist/_virtual/SettingsPanelTab.js +4 -0
- package/dist/_virtual/SettingsTab.js +4 -0
- package/dist/_virtual/StructureBorderBuiltInControl.js +4 -0
- package/dist/_virtual/StructurePaddingsBuiltInControl.js +4 -0
- package/dist/_virtual/TextColorBuiltInControl.js +4 -0
- package/dist/_virtual/TextLineSpacingBuiltInControl.js +4 -0
- package/dist/_virtual/TextSizeBuiltInControl.js +4 -0
- package/dist/_virtual/TextStyleBuiltInControl.js +4 -0
- package/dist/_virtual/UIElement.js +4 -0
- package/dist/_virtual/UIElementTagRegistry.js +4 -0
- package/dist/_virtual/UIElementType.js +4 -0
- package/dist/_virtual/UIElementsAttributes.js +4 -0
- package/dist/_virtual/index.js +5 -0
- package/dist/_virtual/index2.js +4 -0
- package/dist/components/Guido.vue.d.ts +17 -3
- package/dist/components/Guido.vue.js +8 -8
- package/dist/components/Guido.vue2.js +64 -24
- package/dist/components/organisms/design-preview/AmpErrorModal.vue.d.ts +16 -0
- package/dist/components/organisms/design-preview/AmpErrorModal.vue.js +21 -0
- package/dist/components/organisms/design-preview/AmpErrorModal.vue2.js +30 -0
- package/dist/components/organisms/design-preview/DesktopPreview.vue.d.ts +16 -0
- package/dist/components/organisms/design-preview/DesktopPreview.vue.js +22 -0
- package/dist/components/organisms/design-preview/DesktopPreview.vue2.js +43 -0
- package/dist/components/organisms/design-preview/EmailPreview.vue.d.ts +16 -0
- package/dist/components/organisms/design-preview/EmailPreview.vue.js +17 -0
- package/dist/components/organisms/design-preview/EmailPreview.vue2.js +33 -0
- package/dist/components/organisms/design-preview/EmailView.vue.d.ts +18 -0
- package/dist/components/organisms/design-preview/EmailView.vue.js +19 -0
- package/dist/components/organisms/design-preview/EmailView.vue2.js +24 -0
- package/dist/components/organisms/design-preview/InboxView.vue.d.ts +17 -0
- package/dist/components/organisms/design-preview/InboxView.vue.js +19 -0
- package/dist/components/organisms/design-preview/InboxView.vue2.js +23 -0
- package/dist/components/organisms/design-preview/MobilePreview.vue.d.ts +17 -0
- package/dist/components/organisms/design-preview/MobilePreview.vue.js +17 -0
- package/dist/components/organisms/design-preview/MobilePreview.vue2.js +23 -0
- package/dist/components/organisms/header/AmpToggle.vue.d.ts +2 -0
- package/dist/components/organisms/header/AmpToggle.vue.js +17 -0
- package/dist/components/organisms/header/AmpToggle.vue2.js +48 -0
- package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
- package/dist/components/organisms/header/LeftSlot.vue2.js +10 -8
- package/dist/components/organisms/header/MiddleSlot.vue.js +4 -4
- package/dist/components/organisms/header/MiddleSlot.vue2.js +17 -14
- package/dist/components/organisms/header/RightSlot.vue.d.ts +1 -1
- package/dist/components/organisms/header/RightSlot.vue.js +1 -1
- package/dist/components/organisms/header/RightSlot.vue2.js +28 -14
- package/dist/components/organisms/header/ViewOptions.vue.d.ts +1 -1
- package/dist/components/organisms/header/ViewOptions.vue.js +6 -6
- package/dist/components/organisms/header/version-history/RestoreButton.vue.d.ts +1 -1
- package/dist/components/organisms/header/version-history/VersionHistoryItem.vue.d.ts +1 -1
- package/dist/components/organisms/header/version-history/VersionHistoryItem.vue.js +1 -1
- package/dist/components/organisms/header/version-history/ViewOptions.vue.d.ts +1 -1
- package/dist/composables/useActionsApi.d.ts +3 -0
- package/dist/composables/useActionsApi.js +47 -34
- package/dist/composables/useDebounce.d.ts +4 -0
- package/dist/composables/useDebounce.js +12 -0
- package/dist/composables/useGuidoActions.d.ts +46 -0
- package/dist/composables/useGuidoActions.js +37 -0
- package/dist/composables/useMobileGmailFit.d.ts +5 -0
- package/dist/composables/useMobileGmailFit.js +69 -0
- package/dist/composables/useProvideInject.d.ts +14 -0
- package/dist/composables/useProvideInject.js +17 -0
- package/dist/composables/useStripo.js +41 -29
- package/dist/config/compiler/htmlCompilerRules.js +6 -6
- package/dist/enums/emailPreview.d.ts +3 -0
- package/dist/enums/emailPreview.js +6 -0
- package/dist/enums/gmailMobilePreview.d.ts +7 -0
- package/dist/enums/gmailMobilePreview.js +17 -0
- package/dist/extensions/DynamicContent/dynamic-content-modal.d.ts +6 -0
- package/dist/extensions/DynamicContent/dynamic-content-modal.js +27 -0
- package/dist/extensions/DynamicContent/dynamic-content.css.js +24 -0
- package/dist/extensions/DynamicContent/dynamic-content.d.ts +16 -0
- package/dist/extensions/DynamicContent/dynamic-content.js +63 -0
- package/dist/extensions/DynamicContent/extension.d.ts +2 -0
- package/dist/extensions/DynamicContent/extension.js +11 -0
- package/dist/guido.css +1 -1
- package/dist/inbox-mockup.svg +39 -0
- package/dist/mock/api/default-template.d.ts +2 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/Extension.js +51 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/ExtensionBuilder.js +52 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/blocks/Block.js +41 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/blocks/BlockRenderer.js +18 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/blocks/BlocksPanel.js +32 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/blocks/ContextAction.js +18 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/AddCustomFont.js +8 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/AiAssistantValueType.js +13 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockAttributes.js +34 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockCompositionType.js +13 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockType.js +13 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BuiltInControlTypes.js +104 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/ContextActionType.js +13 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/EditorStatePropertyType.js +13 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/PanelPosition.js +13 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/PreviewDeviceMode.js +13 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/SettingsTab.js +13 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementType.js +13 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementsAttributes.js +45 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/BackgroundColorBuiltInControl.js +43 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/BackgroundImageBuiltInControl.js +46 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/BlockPaddingsBuiltInControl.js +44 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/BuiltInControl.js +22 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/ButtonBorderBuiltInControl.js +46 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/ButtonColorBuiltInControl.js +46 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/ButtonFontColorBuiltInControl.js +45 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/ButtonInternalIndentsBuiltInControl.js +45 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/ButtonTextBuiltInControl.js +45 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/Control.js +20 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/FontFamilyBuiltInControl.js +43 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/LinkColorBuiltInControl.js +45 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/SettingsPanelRegistry.js +18 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/SettingsPanelTab.js +32 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/StructureBorderBuiltInControl.js +46 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/StructurePaddingsBuiltInControl.js +44 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/TextColorBuiltInControl.js +43 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/TextLineSpacingBuiltInControl.js +43 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/TextSizeBuiltInControl.js +45 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/TextStyleBuiltInControl.js +43 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/index.js +266 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/modifications/ModificationDescription.js +26 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/ui-elements/UIElement.js +22 -0
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/ui-elements/UIElementTagRegistry.js +18 -0
- package/dist/phone-mockup.svg +31 -0
- package/dist/services/stripoApi.d.ts +2 -1
- package/dist/services/stripoApi.js +27 -7
- package/dist/stores/editor.d.ts +4 -0
- package/dist/stores/editor.js +7 -3
- package/package.json +2 -1
- package/dist/composables/useTemplates.d.ts +0 -5
- package/dist/composables/useTemplates.js +0 -27
- package/dist/static/templates/default/index.html.js +0 -5
- 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
|
-
|
|
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,14 +49,55 @@ export default {
|
|
|
39
49
|
},
|
|
40
50
|
data() {
|
|
41
51
|
return {
|
|
42
|
-
|
|
43
|
-
userId: '
|
|
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'
|
|
57
|
+
translationsPath: 'window.trans.en',
|
|
46
58
|
htmlCompilerRules: [],
|
|
47
59
|
ignoreDefaultHtmlCompilerRules: false,
|
|
48
|
-
}
|
|
60
|
+
},
|
|
61
|
+
dynamicContentModalVisible: false
|
|
49
62
|
};
|
|
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
|
+
}
|
|
50
101
|
}
|
|
51
102
|
};
|
|
52
103
|
</script>
|
|
@@ -58,14 +109,31 @@ export default {
|
|
|
58
109
|
|
|
59
110
|
| Prop | Type | Required | Default | Description |
|
|
60
111
|
|------|------|----------|---------|-------------|
|
|
61
|
-
| `
|
|
62
|
-
| `userId` | `string` | ✅ | - | Unique identifier for the user
|
|
63
|
-
| `username` | `string` | ⚪ | Guido User | User name |
|
|
64
|
-
| `partnerName` | `string` | ⚪ | Getting from URL host | Unique identifier for the partner draft |
|
|
65
|
-
| `productType` | `string` | ⚪ | Getting from URL path | Unique identifier for the product draft |
|
|
112
|
+
| `templateId` | `string` | ✅ | - | Unique identifier for the email template |
|
|
113
|
+
| `userId` | `string` | ✅ | - | Unique identifier for the user |
|
|
66
114
|
| `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
|
+
|
|
121
|
+
### Guido Component Events
|
|
122
|
+
|
|
123
|
+
| Event | Payload | Description |
|
|
124
|
+
|-------|---------|-------------|
|
|
125
|
+
| `dynamic-content:open` | `DynamicContent \| null` | Fired when user requests to insert dynamic content |
|
|
126
|
+
| `back` | - | Fired when user clicks the back button |
|
|
127
|
+
| `save:start` | - | Fired when the save process begins |
|
|
128
|
+
| `save:complete` | `Omit<Template, 'forceRecreate'>` | Fired when template is successfully saved |
|
|
129
|
+
|
|
130
|
+
### Guido Exposed Methods
|
|
131
|
+
```typescript
|
|
132
|
+
dynamicContent.insert(DynamicContent);
|
|
133
|
+
dynamicContent.close();
|
|
134
|
+
```
|
|
67
135
|
|
|
68
|
-
###
|
|
136
|
+
### Guido Interfaces
|
|
69
137
|
|
|
70
138
|
```typescript
|
|
71
139
|
interface GuidoConfig {
|
|
@@ -81,6 +149,21 @@ interface GuidoConfig {
|
|
|
81
149
|
| `htmlCompilerRules` | `CompilerRule[]` | `[]` | Additional compiler rules to apply to HTML content. See [HTML Compiler Rules](#-html-compiler-rules) section below |
|
|
82
150
|
| `ignoreDefaultHtmlCompilerRules` | `boolean` | `false` | Skip default compiler rules and only use custom rules. Default rules: `src/config/compiler/htmlCompilerRules.ts` |
|
|
83
151
|
|
|
152
|
+
```typescript
|
|
153
|
+
interface DynamicContent {
|
|
154
|
+
value: string;
|
|
155
|
+
text: string;
|
|
156
|
+
fallback?: string;
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
| Property | Type | Default | Description |
|
|
162
|
+
|----------|------|---------|-------------|
|
|
163
|
+
| `value` | `string` | '' | Value of the dynamic content |
|
|
164
|
+
| `text` | `string` | '' | Visible value of the dynamic content |
|
|
165
|
+
| `fallback?` | `string` | '' | Fallback value of the dynamic content. Optional |
|
|
166
|
+
|
|
84
167
|
### TypeScript Types
|
|
85
168
|
|
|
86
169
|
The library exports the following TypeScript types:
|
|
@@ -94,19 +177,6 @@ import type { GuidoConfig } from '@useinsider/guido';
|
|
|
94
177
|
import type { StripoEventType } from '@useinsider/guido';
|
|
95
178
|
```
|
|
96
179
|
|
|
97
|
-
### StripoEventType
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
type StripoEventType =
|
|
101
|
-
| 'save'
|
|
102
|
-
| 'export'
|
|
103
|
-
| 'close'
|
|
104
|
-
| 'autosave'
|
|
105
|
-
| 'publish'
|
|
106
|
-
| 'export:requested'
|
|
107
|
-
| 'export:ready';
|
|
108
|
-
```
|
|
109
|
-
|
|
110
180
|
## 🔨 HTML Compiler Rules
|
|
111
181
|
|
|
112
182
|
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.
|
|
@@ -342,6 +412,87 @@ src/
|
|
|
342
412
|
└── library.ts # Main export
|
|
343
413
|
```
|
|
344
414
|
|
|
415
|
+
## 🔌 Provide/Inject Utilities
|
|
416
|
+
|
|
417
|
+
Guido includes type-safe utilities for Vue's provide/inject system to facilitate dependency injection between components.
|
|
418
|
+
|
|
419
|
+
### useProvideInject
|
|
420
|
+
|
|
421
|
+
The `useProvideInject` composable provides two helper functions for type-safe dependency injection:
|
|
422
|
+
|
|
423
|
+
#### Basic Usage
|
|
424
|
+
|
|
425
|
+
```typescript
|
|
426
|
+
// Parent component
|
|
427
|
+
import { provideValue } from '@useinsider/guido';
|
|
428
|
+
import { InjectionKey } from 'vue';
|
|
429
|
+
|
|
430
|
+
// Define a typed injection key
|
|
431
|
+
const MyServiceKey: InjectionKey<MyService> = Symbol('MyService');
|
|
432
|
+
|
|
433
|
+
// Provide the value
|
|
434
|
+
const myService = new MyService();
|
|
435
|
+
provideValue(MyServiceKey, myService);
|
|
436
|
+
|
|
437
|
+
// Child component
|
|
438
|
+
import { useInjectedValue } from '@useinsider/guido';
|
|
439
|
+
|
|
440
|
+
// Inject the value with type safety
|
|
441
|
+
const myService = useInjectedValue(MyServiceKey);
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
#### With Default Value
|
|
445
|
+
|
|
446
|
+
```typescript
|
|
447
|
+
// Inject with a fallback value
|
|
448
|
+
const myService = useInjectedValue(MyServiceKey, new DefaultService());
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
#### Error Handling
|
|
452
|
+
|
|
453
|
+
The `useInjectedValue` function will throw a descriptive error if no provider is found and no default value is provided:
|
|
454
|
+
|
|
455
|
+
```typescript
|
|
456
|
+
// This will throw an error if no provider exists
|
|
457
|
+
try {
|
|
458
|
+
const myService = useInjectedValue(MyServiceKey);
|
|
459
|
+
} catch (error) {
|
|
460
|
+
console.error('No provider found for MyService');
|
|
461
|
+
}
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### API Reference
|
|
465
|
+
|
|
466
|
+
#### `provideValue`
|
|
467
|
+
|
|
468
|
+
```typescript
|
|
469
|
+
provideValue<T>(key: InjectionKey<T>, value: T): void
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
Provides a value using Vue's provide system with type safety.
|
|
473
|
+
|
|
474
|
+
| Parameter | Type | Description |
|
|
475
|
+
|-----------|------|-------------|
|
|
476
|
+
| `key` | `InjectionKey<T>` | The typed injection key |
|
|
477
|
+
| `value` | `T` | The value to provide |
|
|
478
|
+
|
|
479
|
+
#### `useInjectedValue`
|
|
480
|
+
|
|
481
|
+
```typescript
|
|
482
|
+
useInjectedValue<T>(key: InjectionKey<T>, defaultValue?: T): T
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
Injects a value using Vue's inject system with type safety and error handling.
|
|
486
|
+
|
|
487
|
+
| Parameter | Type | Required | Description |
|
|
488
|
+
|-----------|------|----------|-------------|
|
|
489
|
+
| `key` | `InjectionKey<T>` | ✅ | The typed injection key |
|
|
490
|
+
| `defaultValue` | `T` | ⚪ | Optional fallback value |
|
|
491
|
+
|
|
492
|
+
**Returns:** `T` - The injected value
|
|
493
|
+
|
|
494
|
+
**Throws:** `Error` - When no provider is found and no default value is provided
|
|
495
|
+
|
|
345
496
|
## 🌐 i18n
|
|
346
497
|
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).
|
|
347
498
|
It allows to use production or local translations on your code. 🚀
|
|
@@ -355,6 +506,34 @@ const trans = useTranslations();
|
|
|
355
506
|
trans('foo.bar')
|
|
356
507
|
```
|
|
357
508
|
|
|
509
|
+
## 📦 Local Building (Recommended)
|
|
510
|
+
|
|
511
|
+
Run this commands if you want to test the package on your local before sending to NPM.
|
|
512
|
+
```sh
|
|
513
|
+
bun run build
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
Since bun does not have packaging yet, use npm here: 🥲
|
|
517
|
+
```sh
|
|
518
|
+
npm pack
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
It'll crate like `useinsider-guido-1.0.0.tgz` file.
|
|
522
|
+
|
|
523
|
+
Move this file to your project path like: `email-fe` via:
|
|
524
|
+
```sh
|
|
525
|
+
cp useinsider-guido-1.0.0.tgz ../email-fe
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
Install the file to your project:
|
|
529
|
+
```sh
|
|
530
|
+
npm i ./useinsider-guido-1.0.0.tgz
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
Then you just need to rebuild to your project or restart the Container. 🎉
|
|
534
|
+
|
|
535
|
+
For Future, we can create a shell script for it. Feel free to help 🙃
|
|
536
|
+
|
|
358
537
|
## 📦 Build Output
|
|
359
538
|
|
|
360
539
|
The library builds to multiple formats:
|
|
@@ -400,8 +579,4 @@ ISC License
|
|
|
400
579
|
- Master Version Generator should be fixed.
|
|
401
580
|
- Playwright integration
|
|
402
581
|
- Commitlint & Precommit Hooks integration
|
|
403
|
-
- We need to emit save event and we should return template config to it
|
|
404
|
-
- Default template should be same with production
|
|
405
|
-
- Open Guido with saved template
|
|
406
|
-
- Get User ID, Email and Unique Template ID as dynamic from props
|
|
407
582
|
- Get Pre-built display conditions from API
|
package/dist/@types/generic.d.ts
CHANGED
|
@@ -4,3 +4,12 @@ export type GuidoConfig = {
|
|
|
4
4
|
htmlCompilerRules?: CompilerRule[];
|
|
5
5
|
ignoreDefaultHtmlCompilerRules?: boolean;
|
|
6
6
|
};
|
|
7
|
+
export type DynamicContent = {
|
|
8
|
+
value: string;
|
|
9
|
+
text: string;
|
|
10
|
+
fallback?: string;
|
|
11
|
+
};
|
|
12
|
+
export interface EmailData {
|
|
13
|
+
senderName: string;
|
|
14
|
+
subject: string;
|
|
15
|
+
}
|
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").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
|
|
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<{}>>, {}>;
|
|
3
3
|
export default _default;
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
import type { GuidoConfig } from '@@/Types/generic';
|
|
1
|
+
import type { DynamicContent, GuidoConfig, EmailData } from '@@/Types/generic';
|
|
2
|
+
import type { Template } from '@@/Types/stripo';
|
|
2
3
|
type __VLS_Props = {
|
|
3
|
-
|
|
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;
|
|
8
11
|
guidoConfig: GuidoConfig;
|
|
12
|
+
emailData?: EmailData;
|
|
9
13
|
};
|
|
10
|
-
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {
|
|
14
|
+
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {
|
|
15
|
+
dynamicContent: {
|
|
16
|
+
insert: (data: DynamicContent) => void;
|
|
17
|
+
close: () => void;
|
|
18
|
+
};
|
|
19
|
+
}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {
|
|
20
|
+
"dynamic-content:open": (detail: DynamicContent | null) => void;
|
|
21
|
+
back: () => void;
|
|
22
|
+
"save:start": () => void;
|
|
23
|
+
"save:complete": (template: Omit<Template, "forceRecreate">) => void;
|
|
24
|
+
}, string, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}>;
|
|
11
25
|
export default _default;
|
|
12
26
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
13
27
|
type __VLS_TypePropsToOption<T> = {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import o from "./Guido.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
|
-
import
|
|
3
|
+
import t from "../_virtual/_plugin-vue2_normalizer.js";
|
|
4
4
|
var s = function() {
|
|
5
|
-
var
|
|
6
|
-
return r("div", { staticClass: "guido-editor__wrapper" }, [r(
|
|
7
|
-
},
|
|
5
|
+
var i = this, r = i._self._c, e = i._self._setupProxy;
|
|
6
|
+
return r("div", { staticClass: "guido-editor__wrapper" }, [r(e.HeaderWrapper), r(e.EmailPreview, { directives: [{ name: "show", rawName: "v-show", value: e.editorStore.isPreviewModeOpen, expression: "editorStore.isPreviewModeOpen" }], attrs: { "email-data": i.emailData, "is-visible": e.editorStore.isPreviewModeOpen } }), r("div", { directives: [{ name: "show", rawName: "v-show", value: !e.editorStore.isPreviewModeOpen, expression: "!editorStore.isPreviewModeOpen" }], staticClass: "guido-editor__container", attrs: { id: "guido-editor" } })], 1);
|
|
7
|
+
}, a = [], d = /* @__PURE__ */ t(
|
|
8
8
|
o,
|
|
9
9
|
s,
|
|
10
|
-
|
|
10
|
+
a,
|
|
11
11
|
!1,
|
|
12
12
|
null,
|
|
13
|
-
"
|
|
13
|
+
"7836f831"
|
|
14
14
|
);
|
|
15
|
-
const
|
|
15
|
+
const m = d.exports;
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
m as default
|
|
18
18
|
};
|