@useinsider/guido 1.0.0-beta.dad21f4 → 1.0.0-beta.dbd0bad
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 +199 -7
- package/dist/@types/generic.d.ts +9 -0
- package/dist/components/Guido.vue.d.ts +4 -1
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +28 -25
- package/dist/components/organisms/header/MiddleSlot.vue.js +7 -7
- package/dist/components/organisms/header/MiddleSlot.vue2.js +15 -17
- package/dist/components/organisms/header/RightSlot.vue.js +7 -7
- package/dist/components/organisms/header/RightSlot.vue2.js +16 -14
- package/dist/composables/useExport.d.ts +1 -1
- package/dist/composables/useExport.js +35 -20
- package/dist/composables/useHtmlCompiler.d.ts +4 -0
- package/dist/composables/useHtmlCompiler.js +16 -0
- package/dist/config/compiler/htmlCompilerRules.d.ts +2 -0
- package/dist/config/compiler/htmlCompilerRules.js +145 -0
- package/dist/config/compiler/outlookCompilerRules.d.ts +0 -0
- package/dist/guido.css +1 -1
- package/dist/stores/editor.d.ts +1 -0
- package/dist/stores/editor.js +3 -2
- package/dist/utils/htmlCompiler.d.ts +12 -0
- package/dist/utils/htmlCompiler.js +70 -0
- package/dist/utils/tooltipUtils.d.ts +2 -0
- package/dist/utils/tooltipUtils.js +9 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -47,7 +47,9 @@ export default {
|
|
|
47
47
|
emailId: 'abc123',
|
|
48
48
|
userId: '12345',
|
|
49
49
|
guidoConfig: {
|
|
50
|
-
translationsPath: 'window.trans.en'
|
|
50
|
+
translationsPath: 'window.trans.en',
|
|
51
|
+
htmlCompilerRules: [],
|
|
52
|
+
ignoreDefaultHtmlCompilerRules: false,
|
|
51
53
|
}
|
|
52
54
|
dynamicContentModalVisible: false
|
|
53
55
|
};
|
|
@@ -58,15 +60,20 @@ export default {
|
|
|
58
60
|
this.dynamicContentModalVisible = true;
|
|
59
61
|
}
|
|
60
62
|
// ⚠️ Your own Dynamic Content Modal should have this id: #guido-dynamic-content-modal
|
|
61
|
-
|
|
62
|
-
this.$ref.guidoEditor.
|
|
63
|
+
handleDynamicContentInsert() {
|
|
64
|
+
this.$ref.guidoEditor?.dynamicContent.insert({
|
|
63
65
|
text: 'Text',
|
|
64
66
|
value: 'Value',
|
|
65
67
|
fallback: 'Fallback'
|
|
66
68
|
});
|
|
67
69
|
|
|
68
70
|
this.dynamicContentModalVisible = false;
|
|
71
|
+
},
|
|
72
|
+
// ⚠️ It's mandatory. There is no way to understand if user closes the modal without selection.
|
|
73
|
+
handleDynamicContentClose() {
|
|
74
|
+
this.$ref.guidoEditor?.dynamicContent.close();
|
|
69
75
|
}
|
|
76
|
+
|
|
70
77
|
}
|
|
71
78
|
};
|
|
72
79
|
</script>
|
|
@@ -87,7 +94,8 @@ export default {
|
|
|
87
94
|
|
|
88
95
|
### Guido Exposed Methods
|
|
89
96
|
```typescript
|
|
90
|
-
|
|
97
|
+
dynamicContent.insert(DynamicContent);
|
|
98
|
+
dynamicContent.close();
|
|
91
99
|
```
|
|
92
100
|
|
|
93
101
|
### Guido Interfaces
|
|
@@ -95,12 +103,16 @@ applyDynamicContent(DynamicContent);
|
|
|
95
103
|
```typescript
|
|
96
104
|
interface GuidoConfig {
|
|
97
105
|
translationsPath: string;
|
|
106
|
+
htmlCompilerRules: CompilerRule[];
|
|
107
|
+
ignoreDefaultHtmlCompilerRules: boolean;
|
|
98
108
|
}
|
|
99
109
|
```
|
|
100
110
|
|
|
101
111
|
| Property | Type | Default | Description |
|
|
102
112
|
|----------|------|---------|-------------|
|
|
103
113
|
| `translationsPath` | `string` | `'window.trans.en'` | JavaScript path to the translations object |
|
|
114
|
+
| `htmlCompilerRules` | `CompilerRule[]` | `[]` | Additional compiler rules to apply to HTML content. See [HTML Compiler Rules](#-html-compiler-rules) section below |
|
|
115
|
+
| `ignoreDefaultHtmlCompilerRules` | `boolean` | `false` | Skip default compiler rules and only use custom rules. Default rules: `src/config/compiler/htmlCompilerRules.ts` |
|
|
104
116
|
|
|
105
117
|
```typescript
|
|
106
118
|
interface DynamicContent {
|
|
@@ -109,6 +121,7 @@ interface DynamicContent {
|
|
|
109
121
|
fallback?: string;
|
|
110
122
|
}
|
|
111
123
|
```
|
|
124
|
+
---
|
|
112
125
|
|
|
113
126
|
| Property | Type | Default | Description |
|
|
114
127
|
|----------|------|---------|-------------|
|
|
@@ -129,6 +142,185 @@ import type { GuidoConfig } from '@useinsider/guido';
|
|
|
129
142
|
import type { StripoEventType } from '@useinsider/guido';
|
|
130
143
|
```
|
|
131
144
|
|
|
145
|
+
## 🔨 HTML Compiler Rules
|
|
146
|
+
|
|
147
|
+
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.
|
|
148
|
+
|
|
149
|
+
### Rule Types
|
|
150
|
+
|
|
151
|
+
There are 4 types of compiler rules:
|
|
152
|
+
|
|
153
|
+
#### 1. Replace Rule
|
|
154
|
+
Replace specific strings in HTML content.
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
{
|
|
158
|
+
id: 'fix-encoding',
|
|
159
|
+
description: 'Fix URL encoding issues',
|
|
160
|
+
type: 'replace',
|
|
161
|
+
search: '{%22', // String to find
|
|
162
|
+
replacement: '%7B%22', // String to replace with
|
|
163
|
+
replaceAll: true, // Replace all occurrences (default: true)
|
|
164
|
+
priority: 10 // Execution priority (lower = earlier)
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
#### 2. Regex Rule
|
|
169
|
+
Use regular expressions for complex pattern matching and replacement.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
{
|
|
173
|
+
id: 'remove-comments',
|
|
174
|
+
description: 'Remove HTML comments',
|
|
175
|
+
type: 'regex',
|
|
176
|
+
pattern: '<!--.*?-->', // Regex pattern
|
|
177
|
+
replacement: '', // Replacement string
|
|
178
|
+
flags: 'g', // Regex flags (default: 'g')
|
|
179
|
+
priority: 20
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
#### 3. Remove Rule
|
|
184
|
+
Remove specific strings or patterns from HTML content.
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
{
|
|
188
|
+
id: 'cleanup-scripts',
|
|
189
|
+
description: 'Remove unwanted script tags',
|
|
190
|
+
type: 'remove',
|
|
191
|
+
targets: [ // Array of strings or RegExp objects
|
|
192
|
+
'<script src="unwanted.js"></script>',
|
|
193
|
+
/onclick="[^"]*"/g
|
|
194
|
+
],
|
|
195
|
+
priority: 30
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### 4. Custom Rule
|
|
200
|
+
Define complex transformation logic with a custom processor function.
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
{
|
|
204
|
+
id: 'add-meta-tags',
|
|
205
|
+
description: 'Add custom meta tags to head',
|
|
206
|
+
type: 'custom',
|
|
207
|
+
processor: (html: string): string => {
|
|
208
|
+
// Custom transformation logic
|
|
209
|
+
const metaTags = '<meta name="custom" content="value">';
|
|
210
|
+
return html.replace('</head>', `${metaTags}</head>`);
|
|
211
|
+
},
|
|
212
|
+
priority: 40
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Using HTML Compiler Rules
|
|
217
|
+
|
|
218
|
+
#### Basic Usage with Custom Rules
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
const guidoConfig = {
|
|
222
|
+
translationsPath: 'window.trans.en',
|
|
223
|
+
htmlCompilerRules: [
|
|
224
|
+
{
|
|
225
|
+
id: 'replace-domain',
|
|
226
|
+
description: 'Replace old domain with new one',
|
|
227
|
+
type: 'replace',
|
|
228
|
+
search: 'old-domain.com',
|
|
229
|
+
replacement: 'new-domain.com',
|
|
230
|
+
replaceAll: true,
|
|
231
|
+
priority: 10
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
id: 'remove-tracking',
|
|
235
|
+
description: 'Remove tracking pixels',
|
|
236
|
+
type: 'regex',
|
|
237
|
+
pattern: '<img[^>]*tracking[^>]*>',
|
|
238
|
+
replacement: '',
|
|
239
|
+
flags: 'gi',
|
|
240
|
+
priority: 20
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
};
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
#### Ignoring Default Rules
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
const guidoConfig = {
|
|
250
|
+
translationsPath: 'window.trans.en',
|
|
251
|
+
ignoreDefaultHtmlCompilerRules: true, // Skip all default rules
|
|
252
|
+
htmlCompilerRules: [
|
|
253
|
+
// Only your custom rules will be applied
|
|
254
|
+
{
|
|
255
|
+
id: 'custom-transformation',
|
|
256
|
+
type: 'replace',
|
|
257
|
+
search: 'old-text',
|
|
258
|
+
replacement: 'new-text',
|
|
259
|
+
priority: 1
|
|
260
|
+
}
|
|
261
|
+
]
|
|
262
|
+
};
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Rule Execution Order
|
|
266
|
+
|
|
267
|
+
Rules are executed in priority order (lower numbers first). Rules with the same priority are executed in array order.
|
|
268
|
+
|
|
269
|
+
- **Priority 1-99**: Reserved for critical transformations
|
|
270
|
+
- **Priority 100-999**: Standard transformations
|
|
271
|
+
- **Priority 1000+**: Additional custom rules (automatically assigned)
|
|
272
|
+
|
|
273
|
+
### Default Rules
|
|
274
|
+
|
|
275
|
+
Guido includes several default rules for common email HTML optimizations:
|
|
276
|
+
|
|
277
|
+
- **URL encoding fixes**: Fixes malformed URL encoding in dynamic content
|
|
278
|
+
- **Template tag restoration**: Restores `{{}}` template tags that got URL encoded
|
|
279
|
+
- **HTML entity decoding**: Converts `<` and `>` back to `<` and `>`
|
|
280
|
+
- **Cleanup rules**: Removes unwanted iframe and style elements
|
|
281
|
+
- **MSO conditions**: Manages Outlook-specific conditional comments
|
|
282
|
+
- **Domain replacement**: Updates old image domains to current ones
|
|
283
|
+
|
|
284
|
+
You can view all default rules in: `src/config/compiler/htmlCompilerRules.ts`
|
|
285
|
+
|
|
286
|
+
### CompilerRule Interface
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
type CompilerRuleType = 'replace' | 'regex' | 'remove' | 'custom';
|
|
290
|
+
|
|
291
|
+
interface BaseCompilerRule {
|
|
292
|
+
id: string;
|
|
293
|
+
description?: string;
|
|
294
|
+
priority: number;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
interface ReplaceRule extends BaseCompilerRule {
|
|
298
|
+
type: 'replace';
|
|
299
|
+
search: string;
|
|
300
|
+
replacement: string;
|
|
301
|
+
replaceAll?: boolean; // Default: true
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
interface RegexRule extends BaseCompilerRule {
|
|
305
|
+
type: 'regex';
|
|
306
|
+
pattern: string;
|
|
307
|
+
replacement: string;
|
|
308
|
+
flags?: string; // Default: 'g'
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
interface RemoveRule extends BaseCompilerRule {
|
|
312
|
+
type: 'remove';
|
|
313
|
+
targets: (string | RegExp)[]; // Array of strings or RegExp objects
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
interface CustomRule extends BaseCompilerRule {
|
|
317
|
+
type: 'custom';
|
|
318
|
+
processor: (html: string) => string;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
type CompilerRule = ReplaceRule | RegexRule | RemoveRule | CustomRule;
|
|
322
|
+
```
|
|
323
|
+
|
|
132
324
|
---
|
|
133
325
|
|
|
134
326
|
## 🔧 Development
|
|
@@ -210,16 +402,16 @@ Since bun does not have packaging yet, use npm here: 🥲
|
|
|
210
402
|
npm pack
|
|
211
403
|
```
|
|
212
404
|
|
|
213
|
-
It'll crate like `useinsider-guido-1.0.0.
|
|
405
|
+
It'll crate like `useinsider-guido-1.0.0.tgz` file.
|
|
214
406
|
|
|
215
407
|
Move this file to your project path like: `email-fe` via:
|
|
216
408
|
```sh
|
|
217
|
-
cp useinsider-guido-1.0.0.
|
|
409
|
+
cp useinsider-guido-1.0.0.tgz ../email-fe
|
|
218
410
|
```
|
|
219
411
|
|
|
220
412
|
Install the file to your project:
|
|
221
413
|
```sh
|
|
222
|
-
npm i ./useinsider-guido-1.0.0.
|
|
414
|
+
npm i ./useinsider-guido-1.0.0.tgz
|
|
223
415
|
```
|
|
224
416
|
|
|
225
417
|
Then you just need to rebuild to your project or restart the Container. 🎉
|
package/dist/@types/generic.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
import type { CompilerRule } from './html-compiler';
|
|
1
2
|
export type GuidoConfig = {
|
|
2
3
|
translationsPath: string;
|
|
4
|
+
htmlCompilerRules?: CompilerRule[];
|
|
5
|
+
ignoreDefaultHtmlCompilerRules?: boolean;
|
|
3
6
|
};
|
|
4
7
|
export type DynamicContent = {
|
|
5
8
|
value: string;
|
|
6
9
|
text: string;
|
|
7
10
|
fallback?: string;
|
|
8
11
|
};
|
|
12
|
+
export interface TooltipOptions {
|
|
13
|
+
id: string;
|
|
14
|
+
dynamicPosition: boolean;
|
|
15
|
+
staticPosition: string;
|
|
16
|
+
iconStatus: boolean;
|
|
17
|
+
}
|
|
@@ -8,7 +8,10 @@ type __VLS_Props = {
|
|
|
8
8
|
guidoConfig: GuidoConfig;
|
|
9
9
|
};
|
|
10
10
|
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_Props>, {
|
|
11
|
-
|
|
11
|
+
dynamicContent: {
|
|
12
|
+
insert: (data: DynamicContent) => void;
|
|
13
|
+
close: () => void;
|
|
14
|
+
};
|
|
12
15
|
}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {
|
|
13
16
|
"dynamic-content:open": (detail: DynamicContent | null) => void;
|
|
14
17
|
}, string, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_Props>>>, {}>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { usePartner as
|
|
3
|
-
import { useStripo as
|
|
4
|
-
import { useTemplates as
|
|
5
|
-
import { DefaultUsername as
|
|
6
|
-
import
|
|
7
|
-
const
|
|
1
|
+
import { defineComponent as v, onMounted as w } from "vue";
|
|
2
|
+
import { usePartner as h } from "../composables/usePartner.js";
|
|
3
|
+
import { useStripo as D } from "../composables/useStripo.js";
|
|
4
|
+
import { useTemplates as E } from "../composables/useTemplates.js";
|
|
5
|
+
import { DefaultUsername as _, DefaultGuidoConfig as b } from "../enums/defaults.js";
|
|
6
|
+
import T from "./organisms/header/HeaderWrapper.vue.js";
|
|
7
|
+
const W = /* @__PURE__ */ v({
|
|
8
8
|
__name: "Guido",
|
|
9
9
|
props: {
|
|
10
10
|
emailId: null,
|
|
@@ -15,28 +15,28 @@ const x = /* @__PURE__ */ C({
|
|
|
15
15
|
guidoConfig: null
|
|
16
16
|
},
|
|
17
17
|
emits: ["dynamic-content:open"],
|
|
18
|
-
setup(g, { expose:
|
|
19
|
-
const
|
|
18
|
+
setup(g, { expose: C, emit: n }) {
|
|
19
|
+
const t = g, { getPartnerName: o, getProductType: c } = h(), {
|
|
20
20
|
emailId: i,
|
|
21
21
|
userId: a,
|
|
22
|
-
guidoConfig:
|
|
23
|
-
partnerName: s =
|
|
24
|
-
productType:
|
|
25
|
-
username:
|
|
26
|
-
} =
|
|
22
|
+
guidoConfig: r,
|
|
23
|
+
partnerName: s = o(),
|
|
24
|
+
productType: d = c(),
|
|
25
|
+
username: u = _
|
|
26
|
+
} = t;
|
|
27
27
|
window.GuidoConfig = {
|
|
28
|
-
...
|
|
29
|
-
...
|
|
28
|
+
...b,
|
|
29
|
+
...r
|
|
30
30
|
};
|
|
31
|
-
const { initPlugin: m } =
|
|
32
|
-
console.debug("dynamic-content:close", e), document.dispatchEvent(new CustomEvent("dynamic-content:close", {
|
|
33
|
-
|
|
34
|
-
}));
|
|
31
|
+
const { initPlugin: m } = D({ emailId: i, userId: a, username: u, partnerName: s, productType: d }), { getDefaultTemplate: l } = E(), p = (e) => {
|
|
32
|
+
console.debug("dynamic-content:close", e), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: e }));
|
|
33
|
+
}, y = () => {
|
|
34
|
+
console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
|
|
35
35
|
};
|
|
36
36
|
return w(async () => {
|
|
37
37
|
console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow");
|
|
38
38
|
try {
|
|
39
|
-
const e = await
|
|
39
|
+
const e = await l();
|
|
40
40
|
await m(e);
|
|
41
41
|
} catch (e) {
|
|
42
42
|
console.error("Failed to initialize Stripo editor:", e);
|
|
@@ -45,11 +45,14 @@ const x = /* @__PURE__ */ C({
|
|
|
45
45
|
const f = e;
|
|
46
46
|
console.debug("dynamic-content:open", f.detail), n("dynamic-content:open", f.detail);
|
|
47
47
|
});
|
|
48
|
-
}),
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
}), C({
|
|
49
|
+
dynamicContent: {
|
|
50
|
+
insert: p,
|
|
51
|
+
close: y
|
|
52
|
+
}
|
|
53
|
+
}), { __sfc: !0, props: t, getPartnerName: o, getProductType: c, emailId: i, userId: a, guidoConfig: r, partnerName: s, productType: d, username: u, emit: n, initPlugin: m, getDefaultTemplate: l, insertDynamicContent: p, closeDynamicContent: y, HeaderWrapper: T };
|
|
51
54
|
}
|
|
52
55
|
});
|
|
53
56
|
export {
|
|
54
|
-
|
|
57
|
+
W as default
|
|
55
58
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import i from "./MiddleSlot.vue2.js";
|
|
2
|
+
import s from "../../../_virtual/_plugin-vue2_normalizer.js";
|
|
3
3
|
var n = function() {
|
|
4
4
|
var e = this, o = e._self._c, t = e._self._setupProxy;
|
|
5
|
-
return t.editorStore.isVersionHistoryOpen ? o("div", { staticClass: "d-f" }, [o(t.VersionHistory), o(t.VersionHistoryViewOptions)], 1) : o("div", { staticClass: "d-f" }, [o(t.InButtonV2, { attrs: { id: "guido__undo-button", "left-icon": "line-undo", styling: "ghost", type: "secondary", "label-text-status": !1 } }), o(t.InButtonV2, { attrs: { id: "guido__redo-button", "left-icon": "line-redo", styling: "ghost", type: "secondary", "label-text-status": !1 } }), o(t.InButtonV2, { attrs: { id: "guido__code-button", "left-icon": "line-code", styling: "ghost",
|
|
6
|
-
}, l = [], r = /* @__PURE__ */
|
|
7
|
-
|
|
5
|
+
return t.editorStore.isVersionHistoryOpen ? o("div", { staticClass: "d-f" }, [o(t.VersionHistory), o(t.VersionHistoryViewOptions)], 1) : o("div", { staticClass: "d-f" }, [o(t.InButtonV2, { attrs: { id: "guido__undo-button", "left-icon": "line-undo", styling: "ghost", type: "secondary", "label-text-status": !1, "tooltip-options": t.getTooltipOptions("guido__undo-button"), "tooltip-text": t.trans("action-builder.undo") } }), o(t.InButtonV2, { attrs: { id: "guido__redo-button", "left-icon": "line-redo", styling: "ghost", type: "secondary", "label-text-status": !1, "tooltip-options": t.getTooltipOptions("guido__redo-button"), "tooltip-text": t.trans("action-builder.redo") } }), o(t.InButtonV2, { attrs: { id: "guido__code-button", "data-testid": "Code Editor", "left-icon": "line-code", styling: "ghost", type: "secondary", "label-text-status": !1, "selected-status": t.editorStore.isCodeEditorOpen, "tooltip-options": t.getTooltipOptions("guido__code-button"), "tooltip-text": t.codeEditorTooltipText } }), o(t.InButtonV2, { attrs: { id: "guido__preview-button", "left-icon": "line-show-on", styling: "ghost", type: "secondary", "label-text-status": !1, "selected-status": t.editorStore.isPreviewModeOpen, "tooltip-options": t.getTooltipOptions("guido__preview-button"), "tooltip-text": t.previewTooltipText }, on: { click: t.handlePreview } }), o(t.ViewOptions, { staticClass: "ml-3" })], 1);
|
|
6
|
+
}, l = [], r = /* @__PURE__ */ s(
|
|
7
|
+
i,
|
|
8
8
|
n,
|
|
9
9
|
l,
|
|
10
10
|
!1,
|
|
11
11
|
null,
|
|
12
12
|
null
|
|
13
13
|
);
|
|
14
|
-
const
|
|
14
|
+
const u = r.exports;
|
|
15
15
|
export {
|
|
16
|
-
|
|
16
|
+
u as default
|
|
17
17
|
};
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useTranslations as
|
|
3
|
-
import { useEditorStore as
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
1
|
+
import { defineComponent as s, computed as t } from "vue";
|
|
2
|
+
import { useTranslations as n } from "../../../composables/useTranslations.js";
|
|
3
|
+
import { useEditorStore as p } from "../../../stores/editor.js";
|
|
4
|
+
import { getTooltipOptions as m } from "../../../utils/tooltipUtils.js";
|
|
5
|
+
import { InButtonV2 as l } from "@useinsider/design-system-vue";
|
|
6
|
+
import d from "./version-history/VersionHistory.vue.js";
|
|
7
|
+
import w from "./version-history/ViewOptions.vue.js";
|
|
8
|
+
import c from "./ViewOptions.vue.js";
|
|
9
|
+
const M = /* @__PURE__ */ s({
|
|
9
10
|
__name: "MiddleSlot",
|
|
10
|
-
setup(
|
|
11
|
-
const o = n(), t =
|
|
12
|
-
return { __sfc: !0, editorStore:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
staticPosition: "bottom center",
|
|
16
|
-
iconStatus: !1
|
|
17
|
-
}), InButtonV2: e, VersionHistory: m, VersionHistoryViewOptions: p, ViewOptions: f };
|
|
11
|
+
setup(f) {
|
|
12
|
+
const e = p(), o = n(), r = t(() => e.isCodeEditorOpen ? o("newsletter.close-html-editor") : o("newsletter.html-editor")), i = t(() => e.isPreviewModeOpen ? o("newsletter.close-email-preview") : o("newsletter.email-preview"));
|
|
13
|
+
return { __sfc: !0, editorStore: e, trans: o, codeEditorTooltipText: r, previewTooltipText: i, handlePreview: () => {
|
|
14
|
+
e.isPreviewModeOpen = !e.isPreviewModeOpen;
|
|
15
|
+
}, getTooltipOptions: m, InButtonV2: l, VersionHistory: d, VersionHistoryViewOptions: w, ViewOptions: c };
|
|
18
16
|
}
|
|
19
17
|
});
|
|
20
18
|
export {
|
|
21
|
-
|
|
19
|
+
M as default
|
|
22
20
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import s from "./RightSlot.vue2.js";
|
|
2
2
|
import i from "../../../_virtual/_plugin-vue2_normalizer.js";
|
|
3
3
|
var n = function() {
|
|
4
|
-
var
|
|
5
|
-
return
|
|
6
|
-
}, r = [],
|
|
7
|
-
|
|
4
|
+
var e = this, o = e._self._c, t = e._self._setupProxy;
|
|
5
|
+
return o("div", { staticClass: "d-f" }, [o(t.InButtonV2, { attrs: { id: "guido__history-button", "left-icon": "line-architect-version-history", styling: "ghost", type: "secondary", "label-text-status": !1, "selected-status": t.editorStore.isVersionHistoryOpen, "tooltip-options": t.getTooltipOptions("guido__history-button"), "tooltip-text": t.versionHistoryTooltipText }, on: { click: t.handleVersionHistory } }), o(t.InButtonV2, { attrs: { id: "guido__export-button", "left-icon": "line-export", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isVersionHistoryOpen, "label-text-status": !1, "tooltip-options": t.getTooltipOptions("guido__export-button"), "tooltip-text": t.trans("newsletter.export") }, on: { click: t.exportHtml } }), o(t.InButtonV2, { attrs: { id: "guido__save-as-button", "left-icon": "line-newsletter-save-as-template", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isVersionHistoryOpen, "label-text-status": !1, "tooltip-options": t.getTooltipOptions("guido__save-as-button"), "tooltip-text": t.trans("newsletter.save-templates") } }), o(t.InButtonV2, { attrs: { id: "guido__test-button", "left-icon": "line-architect-test-journey", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isVersionHistoryOpen, "label-text-status": !1, "tooltip-options": t.getTooltipOptions("guido__test-button"), "tooltip-text": t.trans("newsletter.test-email") } }), o(t.InButtonV2, { staticClass: "ml-3", attrs: { id: "guido__save-button", "label-text": "Save", "disabled-status": t.editorStore.isVersionHistoryOpen } })], 1);
|
|
6
|
+
}, r = [], l = /* @__PURE__ */ i(
|
|
7
|
+
s,
|
|
8
8
|
n,
|
|
9
9
|
r,
|
|
10
10
|
!1,
|
|
11
11
|
null,
|
|
12
12
|
null
|
|
13
13
|
);
|
|
14
|
-
const
|
|
14
|
+
const d = l.exports;
|
|
15
15
|
export {
|
|
16
|
-
|
|
16
|
+
d as default
|
|
17
17
|
};
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useExport as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { defineComponent as p, computed as m } from "vue";
|
|
2
|
+
import { useExport as c } from "../../../composables/useExport.js";
|
|
3
|
+
import { useTranslations as f } from "../../../composables/useTranslations.js";
|
|
4
|
+
import { useVersionHistoryApi as l } from "../../../composables/useVersionHistoryApi.js";
|
|
5
|
+
import { useEditorStore as u } from "../../../stores/editor.js";
|
|
6
|
+
import { getTooltipOptions as y } from "../../../utils/tooltipUtils.js";
|
|
7
|
+
import { InButtonV2 as a } from "@useinsider/design-system-vue";
|
|
8
|
+
const O = /* @__PURE__ */ p({
|
|
7
9
|
__name: "RightSlot",
|
|
8
|
-
setup(
|
|
9
|
-
const { exportHtml: e } =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
r();
|
|
10
|
+
setup(H) {
|
|
11
|
+
const { exportHtml: e } = c(), { openVersionHistory: r, closeVersionHistory: s } = l(), o = u(), t = f(), i = () => {
|
|
12
|
+
if (o.isVersionHistoryOpen) {
|
|
13
|
+
s();
|
|
13
14
|
return;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
},
|
|
16
|
+
r();
|
|
17
|
+
}, n = m(() => o.isVersionHistoryOpen ? t("newsletter.close-version-history") : t("newsletter.version-history"));
|
|
18
|
+
return { __sfc: !0, exportHtml: e, openVersionHistory: r, closeVersionHistory: s, editorStore: o, trans: t, handleVersionHistory: i, versionHistoryTooltipText: n, getTooltipOptions: y, InButtonV2: a };
|
|
17
19
|
}
|
|
18
20
|
});
|
|
19
21
|
export {
|
|
20
|
-
|
|
22
|
+
O as default
|
|
21
23
|
};
|
|
@@ -1,30 +1,45 @@
|
|
|
1
1
|
import { useActionsApi as l } from "./useActionsApi.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { useHtmlCompiler as m } from "./useHtmlCompiler.js";
|
|
3
|
+
import { useToaster as d } from "./useToaster.js";
|
|
4
|
+
const h = () => {
|
|
5
|
+
const a = (s, o, r) => {
|
|
6
|
+
const i = new Blob([s], { type: r }), t = URL.createObjectURL(i), e = document.createElement("a");
|
|
7
|
+
e.href = t, e.download = o, document.body.appendChild(e), e.click(), document.body.removeChild(e), URL.revokeObjectURL(t);
|
|
8
|
+
}, c = (s) => {
|
|
9
|
+
const o = /* @__PURE__ */ new Date(), r = String(o.getDate()).padStart(2, "0"), i = String(o.getMonth() + 1).padStart(2, "0"), t = o.getFullYear(), e = String(o.getHours()).padStart(2, "0"), n = String(o.getMinutes()).padStart(2, "0");
|
|
10
|
+
return `${s}_${r}-${i}-${t}_${e}-${n}.html`;
|
|
10
11
|
};
|
|
11
|
-
return { exportHtml: async () => {
|
|
12
|
-
const { getCompiledEmail:
|
|
12
|
+
return { exportHtml: async (s = !0) => {
|
|
13
|
+
const { getCompiledEmail: o } = l(), { showToaster: r } = d(), { compileHtml: i } = m();
|
|
13
14
|
try {
|
|
14
|
-
const { html:
|
|
15
|
-
|
|
15
|
+
const { html: t } = await o();
|
|
16
|
+
if (t) {
|
|
17
|
+
let e = t;
|
|
18
|
+
if (s) {
|
|
19
|
+
const n = i(t);
|
|
20
|
+
e = n.compiledHtml, console.debug("HTML Compilation Stats:", {
|
|
21
|
+
originalSize: n.stats.originalSize,
|
|
22
|
+
compiledSize: n.stats.compiledSize,
|
|
23
|
+
reduction: `${n.stats.reductionPercentage.toFixed(2)}%`,
|
|
24
|
+
appliedRules: n.appliedRules,
|
|
25
|
+
executionTime: `${n.stats.executionTime.toFixed(2)}ms`
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
a(e, c("HTML"), "text/html");
|
|
29
|
+
} else
|
|
30
|
+
r({
|
|
31
|
+
type: "error",
|
|
32
|
+
message: "No HTML content to download"
|
|
33
|
+
});
|
|
34
|
+
} catch (t) {
|
|
35
|
+
const e = t instanceof Error ? t.message : String(t);
|
|
36
|
+
r({
|
|
16
37
|
type: "error",
|
|
17
|
-
message:
|
|
18
|
-
});
|
|
19
|
-
} catch (e) {
|
|
20
|
-
const n = e instanceof Error ? e.message : String(e);
|
|
21
|
-
t({
|
|
22
|
-
type: "error",
|
|
23
|
-
message: `Error compiling email: ${n}`
|
|
38
|
+
message: `Error compiling email: ${e}`
|
|
24
39
|
});
|
|
25
40
|
}
|
|
26
41
|
} };
|
|
27
42
|
};
|
|
28
43
|
export {
|
|
29
|
-
|
|
44
|
+
h as useExport
|
|
30
45
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defaultHtmlCompilerRules as r } from "../config/compiler/htmlCompilerRules.js";
|
|
2
|
+
import { createHtmlCompiler as p } from "../utils/htmlCompiler.js";
|
|
3
|
+
const a = () => {
|
|
4
|
+
const e = typeof window < "u" ? window.GuidoConfig : void 0, l = (e == null ? void 0 : e.htmlCompilerRules) || [], t = [
|
|
5
|
+
...!!(e != null && e.ignoreDefaultHtmlCompilerRules) ? [] : r,
|
|
6
|
+
...l.map((o, m) => ({
|
|
7
|
+
...o,
|
|
8
|
+
priority: o.priority + 1e3 + m
|
|
9
|
+
// Ensure additional rules run after default rules
|
|
10
|
+
}))
|
|
11
|
+
], i = p(t);
|
|
12
|
+
return { compileHtml: (o) => i.compile(o) };
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
a as useHtmlCompiler
|
|
16
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
const a = [
|
|
2
|
+
{
|
|
3
|
+
id: "fix-url-encoding-start",
|
|
4
|
+
description: "Replace {%22 with %7B%22 to fix URL encoding",
|
|
5
|
+
type: "replace",
|
|
6
|
+
search: "{%22",
|
|
7
|
+
replacement: "%7B%22",
|
|
8
|
+
replaceAll: !0,
|
|
9
|
+
priority: 10
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
id: "fix-url-encoding-end",
|
|
13
|
+
description: "Replace %22} with %22%7D to fix URL encoding",
|
|
14
|
+
type: "replace",
|
|
15
|
+
search: "%22}",
|
|
16
|
+
replacement: "%22%7D",
|
|
17
|
+
replaceAll: !0,
|
|
18
|
+
priority: 10
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "fix-tags-start",
|
|
22
|
+
description: "Replace %7B%7B with {{ to fix URL encoding",
|
|
23
|
+
type: "replace",
|
|
24
|
+
search: "%7B%7B",
|
|
25
|
+
replacement: "{{",
|
|
26
|
+
replaceAll: !0,
|
|
27
|
+
priority: 11
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "fix-tags-end",
|
|
31
|
+
description: "Replace %7D%7D with }} to fix URL encoding",
|
|
32
|
+
type: "replace",
|
|
33
|
+
search: "%7D%7D",
|
|
34
|
+
replacement: "}}",
|
|
35
|
+
replaceAll: !0,
|
|
36
|
+
priority: 12
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "unescape-inequality-operators-start",
|
|
40
|
+
description: "Replace < with < to fix URL encoding",
|
|
41
|
+
type: "replace",
|
|
42
|
+
search: "<",
|
|
43
|
+
replacement: "<",
|
|
44
|
+
replaceAll: !0,
|
|
45
|
+
priority: 13
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "unescape-inequality-operators-end",
|
|
49
|
+
description: "Replace > with > to fix URL encoding",
|
|
50
|
+
type: "replace",
|
|
51
|
+
search: ">",
|
|
52
|
+
replacement: ">",
|
|
53
|
+
replaceAll: !0,
|
|
54
|
+
priority: 14
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "remove-apty-iframe",
|
|
58
|
+
description: "Cleanup Apty Iframe Code",
|
|
59
|
+
type: "remove",
|
|
60
|
+
targets: [
|
|
61
|
+
'<iframe src="about:blank" id="letznav-iframe-script" allowtransparency="true" style="width:1px;height:1px"></iframe>',
|
|
62
|
+
'src="about:blank" id="letznav-iframe-script" allowtransparency="true" style="width:1px;height:1px"></iframe>'
|
|
63
|
+
],
|
|
64
|
+
priority: 20
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: "remove-apty-styles",
|
|
68
|
+
description: "Removing Apty Styles",
|
|
69
|
+
type: "regex",
|
|
70
|
+
pattern: '<styles*data-styles="apty_styles"s* type="text/css"s*>((s|.)*?)</style>',
|
|
71
|
+
replacement: "",
|
|
72
|
+
flags: "g",
|
|
73
|
+
priority: 21
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: "remove-mso-conditions",
|
|
77
|
+
description: "Removing MSO Conditions",
|
|
78
|
+
type: "remove",
|
|
79
|
+
targets: [
|
|
80
|
+
/<!--\[if\s\(mso 16\)\]>\s*<style\s*\S*>\s*a\s*\{\s*text-decoration\s*:\s*none\s*;*\s*\}\s*<\/style>\s*<!\[endif\]-->/g,
|
|
81
|
+
/<!--\[if\sgte mso 9\]>\s*<style\s*\S*>\s*sup\s*\{\s*font-size\s*:\s*100%\s*!important\s*;*\s*\}\s*<\/style>\s*<!\[endif\]-->/g,
|
|
82
|
+
/<!--\[if\sgte mso 9\]>\s*<noscript>\s*<xml>\s*<o:OfficeDocumentSettings>\s*<o:AllowPNG>\s*<\/o:AllowPNG>\s*<o:PixelsPerInch>\d+<\/o:PixelsPerInch>\s*<\/o:OfficeDocumentSettings>\s*<\/xml>\s*<\/noscript>\s*<!\[endif\]-->/g,
|
|
83
|
+
/<!--\[if mso\]>\s*<xml>\s*<w:WordDocument\s+xmlns:w="urn:schemas-microsoft-com:office:word">\s*<w:DontUseAdvancedTypographyReadingMail><\/w:DontUseAdvancedTypographyReadingMail>\s*<\/w:WordDocument>\s*<\/xml>\s*<!\[endif\]-->/g,
|
|
84
|
+
/<\!--\[if \!mso\]><\!--\s*\d*\s*-->\s*<\!--\[if \!mso\]><\!--\s*\d*\s*-->\s*<\!--<!\[endif\]-->/g,
|
|
85
|
+
/<!--\[if\s\!mso\]>\s*<!-- \d -->/g
|
|
86
|
+
],
|
|
87
|
+
priority: 22
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: "add-mso-conditions",
|
|
91
|
+
description: "Adding MSO Conditions",
|
|
92
|
+
type: "custom",
|
|
93
|
+
processor: (e) => {
|
|
94
|
+
const t = [
|
|
95
|
+
`<!--[if gte mso 9]>
|
|
96
|
+
<style>sup {
|
|
97
|
+
font-size: 100% !important;
|
|
98
|
+
}</style><![endif]-->`,
|
|
99
|
+
`<!--[if gte mso 9]>
|
|
100
|
+
<noscript>
|
|
101
|
+
<xml>
|
|
102
|
+
<o:OfficeDocumentSettings>
|
|
103
|
+
<o:AllowPNG></o:AllowPNG>
|
|
104
|
+
<o:PixelsPerInch>96</o:PixelsPerInch>
|
|
105
|
+
</o:OfficeDocumentSettings>
|
|
106
|
+
</xml>
|
|
107
|
+
</noscript><![endif]-->`,
|
|
108
|
+
`<!--[if mso]>
|
|
109
|
+
<xml>
|
|
110
|
+
<w:WordDocument xmlns:w="urn:schemas-microsoft-com:office:word">
|
|
111
|
+
<w:DontUseAdvancedTypographyReadingMail></w:DontUseAdvancedTypographyReadingMail>
|
|
112
|
+
</w:WordDocument>
|
|
113
|
+
</xml><![endif]-->`
|
|
114
|
+
], s = /<head>([\S\s]*)<\/head>/, o = new RegExp(s);
|
|
115
|
+
if (!e.match(o))
|
|
116
|
+
return e;
|
|
117
|
+
let i = e;
|
|
118
|
+
return t.forEach((r) => {
|
|
119
|
+
i = i.replace("</head>", `${r}</head>`);
|
|
120
|
+
}), i;
|
|
121
|
+
},
|
|
122
|
+
priority: 30
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: "replace-old-image-domain",
|
|
126
|
+
description: "Replacing old image domains",
|
|
127
|
+
type: "replace",
|
|
128
|
+
search: "stripo-editor-image.s3-eu-west-1.amazonaws.com",
|
|
129
|
+
replacement: "email-static.useinsider.com",
|
|
130
|
+
replaceAll: !0,
|
|
131
|
+
priority: 40
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: "replace-old-v2-image-domain",
|
|
135
|
+
description: "Replacing old image domains",
|
|
136
|
+
type: "replace",
|
|
137
|
+
search: "email.static.useinsider.com",
|
|
138
|
+
replacement: "email-static.useinsider.com",
|
|
139
|
+
replaceAll: !0,
|
|
140
|
+
priority: 41
|
|
141
|
+
}
|
|
142
|
+
];
|
|
143
|
+
export {
|
|
144
|
+
a as defaultHtmlCompilerRules
|
|
145
|
+
};
|
|
File without changes
|
package/dist/guido.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.version-history-item[data-v-ee4b9c3f]{flex-basis:200px}.version-history-wrapper[data-v-52a77eec]{gap:8px}[data-v-6a2bde67] .guido__verion-history-view-option-selection-desktop svg,[data-v-6a2bde67] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-6a2bde67] .in-segments-wrapper__button_selected,[data-v-6a2bde67] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-0fff376c] .guido__view-option-selection-desktop svg,[data-v-0fff376c] .guido__view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-0fff376c] .in-segments-wrapper__button_selected,[data-v-0fff376c] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}.guido-editor__wrapper[data-v-
|
|
1
|
+
.version-history-item[data-v-ee4b9c3f]{flex-basis:200px}.version-history-wrapper[data-v-52a77eec]{gap:8px}[data-v-6a2bde67] .guido__verion-history-view-option-selection-desktop svg,[data-v-6a2bde67] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-6a2bde67] .in-segments-wrapper__button_selected,[data-v-6a2bde67] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-0fff376c] .guido__view-option-selection-desktop svg,[data-v-0fff376c] .guido__view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-0fff376c] .in-segments-wrapper__button_selected,[data-v-0fff376c] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}.guido-editor__wrapper[data-v-89423288],.guido-editor__container[data-v-89423288]{width:100%;height:calc(100vh - 75px)}
|
package/dist/stores/editor.d.ts
CHANGED
package/dist/stores/editor.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { defineStore as e } from "pinia";
|
|
2
|
-
const
|
|
2
|
+
const i = e("editor", {
|
|
3
3
|
state: () => ({
|
|
4
4
|
isCodeEditorOpen: !1,
|
|
5
5
|
isVersionHistoryOpen: !1,
|
|
6
|
+
isPreviewModeOpen: !1,
|
|
6
7
|
editorVisualMode: "desktop"
|
|
7
8
|
})
|
|
8
9
|
});
|
|
9
10
|
export {
|
|
10
|
-
|
|
11
|
+
i as useEditorStore
|
|
11
12
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CompilerRule, CompilationResult, HtmlCompiler } from '@@/Types/html-compiler';
|
|
2
|
+
export declare class HtmlCompilerEngine implements HtmlCompiler {
|
|
3
|
+
private rules;
|
|
4
|
+
constructor(rules?: CompilerRule[]);
|
|
5
|
+
compile(html: string, rules?: CompilerRule[]): CompilationResult;
|
|
6
|
+
private applyRule;
|
|
7
|
+
private applyReplaceRule;
|
|
8
|
+
private applyRegexRule;
|
|
9
|
+
private applyRemoveRule;
|
|
10
|
+
private applyCustomRule;
|
|
11
|
+
}
|
|
12
|
+
export declare const createHtmlCompiler: (rules?: CompilerRule[]) => HtmlCompiler;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var y = Object.defineProperty;
|
|
2
|
+
var g = (p, e, r) => e in p ? y(p, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : p[e] = r;
|
|
3
|
+
var u = (p, e, r) => g(p, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { useToaster as m } from "../composables/useToaster.js";
|
|
5
|
+
class d {
|
|
6
|
+
constructor(e = []) {
|
|
7
|
+
u(this, "rules");
|
|
8
|
+
this.rules = e;
|
|
9
|
+
}
|
|
10
|
+
compile(e, r) {
|
|
11
|
+
const l = performance.now(), t = e, o = e.length;
|
|
12
|
+
let s = e;
|
|
13
|
+
const a = [];
|
|
14
|
+
(r || this.rules).sort((n, c) => n.priority - c.priority).forEach((n) => {
|
|
15
|
+
const c = s.length;
|
|
16
|
+
s = this.applyRule(s, n), s.length !== c && a.push(n.id);
|
|
17
|
+
});
|
|
18
|
+
const i = s.length, R = o > 0 ? (o - i) / o * 100 : 0;
|
|
19
|
+
return {
|
|
20
|
+
originalHtml: t,
|
|
21
|
+
compiledHtml: s,
|
|
22
|
+
appliedRules: a,
|
|
23
|
+
// TODO: We can use stats for monitoring in the future
|
|
24
|
+
stats: {
|
|
25
|
+
originalSize: o,
|
|
26
|
+
compiledSize: i,
|
|
27
|
+
reductionPercentage: R,
|
|
28
|
+
executionTime: performance.now() - l
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
applyRule(e, r) {
|
|
33
|
+
try {
|
|
34
|
+
switch (r.type) {
|
|
35
|
+
case "replace":
|
|
36
|
+
return this.applyReplaceRule(e, r);
|
|
37
|
+
case "regex":
|
|
38
|
+
return this.applyRegexRule(e, r);
|
|
39
|
+
case "remove":
|
|
40
|
+
return this.applyRemoveRule(e, r);
|
|
41
|
+
case "custom":
|
|
42
|
+
return this.applyCustomRule(e, r);
|
|
43
|
+
default:
|
|
44
|
+
return e;
|
|
45
|
+
}
|
|
46
|
+
} catch (l) {
|
|
47
|
+
const { handleError: t } = m();
|
|
48
|
+
return t(l, `Failed to apply rule ${r.id}:`), e;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
applyReplaceRule(e, r) {
|
|
52
|
+
const { search: l, replacement: t, replaceAll: o = !0 } = r;
|
|
53
|
+
return o ? e.replaceAll(l, t) : e.replace(l, t);
|
|
54
|
+
}
|
|
55
|
+
applyRegexRule(e, r) {
|
|
56
|
+
const { pattern: l, replacement: t, flags: o = "g" } = r, s = new RegExp(l, o);
|
|
57
|
+
return e.replace(s, t);
|
|
58
|
+
}
|
|
59
|
+
applyRemoveRule(e, r) {
|
|
60
|
+
return r.targets.reduce((l, t) => t instanceof RegExp ? l.replace(t, "") : l.replaceAll(t, ""), e);
|
|
61
|
+
}
|
|
62
|
+
applyCustomRule(e, r) {
|
|
63
|
+
return r.processor(e);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const A = (p = []) => new d(p);
|
|
67
|
+
export {
|
|
68
|
+
d as HtmlCompilerEngine,
|
|
69
|
+
A as createHtmlCompiler
|
|
70
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.dbd0bad",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"start": "vite",
|
|
22
22
|
"build": "vite build && vue-tsc --declaration --emitDeclarationOnly --project tsconfig.app.json",
|
|
23
23
|
"preview": "vite preview",
|
|
24
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
25
24
|
"lint": "NODE_OPTIONS=--max-old-space-size=2048 eslint ./ && bun run type-check",
|
|
26
25
|
"lint:fix": "NODE_OPTIONS=--max-old-space-size=2048 eslint --fix ./",
|
|
27
26
|
"type-check": "vue-tsc --noEmit --project tsconfig.config.json && vue-tsc --noEmit --project tsconfig.app.json"
|
|
@@ -43,6 +42,7 @@
|
|
|
43
42
|
"@cspell/eslint-plugin": "8.17.5",
|
|
44
43
|
"@eslint/eslintrc": "3.3.0",
|
|
45
44
|
"@eslint/js": "8.57.1",
|
|
45
|
+
"@playwright/test": "^1.54.2",
|
|
46
46
|
"@stylistic/eslint-plugin": "3.1.0",
|
|
47
47
|
"@stylistic/eslint-plugin-migrate": "3.1.0",
|
|
48
48
|
"@types/eslint": "8.56.12",
|