@forgeroute/ui 0.5.33 → 0.5.34
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.
|
@@ -1800,8 +1800,30 @@ const DEFAULT_EMAIL_TEMPLATE_VARIABLE_GROUPS = [{
|
|
|
1800
1800
|
}
|
|
1801
1801
|
]
|
|
1802
1802
|
}];
|
|
1803
|
-
function buildPreviewDocument(bodyHtml) {
|
|
1804
|
-
|
|
1803
|
+
function buildPreviewDocument(bodyHtml, brand) {
|
|
1804
|
+
const b = safePreviewBrand(brand);
|
|
1805
|
+
const font = b.fontFamily ?? "-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif";
|
|
1806
|
+
const head = b.logoUrl || b.companyName ? "<div class=\"brand-head\">" + (b.logoUrl ? `<img src="${escapeHtml(b.logoUrl)}" alt="">` : "") + (b.companyName ? `<span>${escapeHtml(b.companyName)}</span>` : "") + "</div>" : "";
|
|
1807
|
+
const foot = b.footerText ? `<div class="brand-foot">${escapeHtml(b.footerText).replace(/\r?\n/g, "<br>")}</div>` : "";
|
|
1808
|
+
return `<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src * data:; style-src 'unsafe-inline'; font-src data:"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html,body{margin:0}body{padding:24px 28px;font:15px/1.6 ${font};color:${b.textColor ?? "#1e293b"};${b.backgroundColor ? `background:${b.backgroundColor};` : ""}overflow-wrap:anywhere}p{margin:0 0 8px}img{max-width:100%}table{max-width:100%}a{color:${b.linkColor ?? "#3b82f6"}}.brand-head{display:flex;align-items:center;gap:12px;margin:0 0 16px;font-weight:600}.brand-head img{max-height:48px;width:auto}.brand-foot{margin:24px 0 0;padding-top:12px;border-top:1px solid rgba(100,116,139,.35);font-size:12px;line-height:1.5;color:#64748b}</style></head><body>${head}${bodyHtml}${foot}</body></html>`;
|
|
1809
|
+
}
|
|
1810
|
+
const BRAND_COLOR = /^(#[0-9a-f]{3,8}|[a-z]{3,20})$/i;
|
|
1811
|
+
const BRAND_FONT = /^[A-Za-z0-9 ,'_-]{1,200}$/;
|
|
1812
|
+
const BRAND_TEXT_MAX = 500;
|
|
1813
|
+
function safePreviewBrand(brand) {
|
|
1814
|
+
if (!brand) return {};
|
|
1815
|
+
const out = {};
|
|
1816
|
+
const color = (v) => typeof v === "string" && BRAND_COLOR.test(v.trim()) ? v.trim() : void 0;
|
|
1817
|
+
const text = (v) => typeof v === "string" && v.trim() ? v.trim().slice(0, BRAND_TEXT_MAX) : void 0;
|
|
1818
|
+
if (typeof brand.fontFamily === "string" && BRAND_FONT.test(brand.fontFamily.trim())) out.fontFamily = brand.fontFamily.trim();
|
|
1819
|
+
out.textColor = color(brand.textColor);
|
|
1820
|
+
out.linkColor = color(brand.linkColor);
|
|
1821
|
+
out.backgroundColor = color(brand.backgroundColor);
|
|
1822
|
+
if (typeof brand.logoUrl === "string" && isWebUrl(brand.logoUrl.trim())) out.logoUrl = brand.logoUrl.trim();
|
|
1823
|
+
out.companyName = text(brand.companyName);
|
|
1824
|
+
out.footerText = text(brand.footerText);
|
|
1825
|
+
for (const k of Object.keys(out)) if (out[k] === void 0) delete out[k];
|
|
1826
|
+
return out;
|
|
1805
1827
|
}
|
|
1806
1828
|
function localizedEmailVariableGroups() {
|
|
1807
1829
|
const label = {
|
|
@@ -1868,6 +1890,9 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
|
|
|
1868
1890
|
this.injector = inject(Injector);
|
|
1869
1891
|
this.template = input(null, ...ngDevMode ? [{ debugName: "template" }] : /* istanbul ignore next */ []);
|
|
1870
1892
|
this.categories = input([], ...ngDevMode ? [{ debugName: "categories" }] : /* istanbul ignore next */ []);
|
|
1893
|
+
this.showCategory = input(true, ...ngDevMode ? [{ debugName: "showCategory" }] : /* istanbul ignore next */ []);
|
|
1894
|
+
this.showActiveRange = input(true, ...ngDevMode ? [{ debugName: "showActiveRange" }] : /* istanbul ignore next */ []);
|
|
1895
|
+
this.previewBrand = input(null, ...ngDevMode ? [{ debugName: "previewBrand" }] : /* istanbul ignore next */ []);
|
|
1871
1896
|
this.categoryPlaceholderInput = input(null, {
|
|
1872
1897
|
...ngDevMode ? { debugName: "categoryPlaceholderInput" } : /* istanbul ignore next */ {},
|
|
1873
1898
|
alias: "categoryPlaceholder"
|
|
@@ -2070,7 +2095,7 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
|
|
|
2070
2095
|
this.serialized = computed(() => this.serialize(this.blocks()), ...ngDevMode ? [{ debugName: "serialized" }] : /* istanbul ignore next */ []);
|
|
2071
2096
|
this.previewHtml = this.serialized;
|
|
2072
2097
|
this.sanitizer = inject(DomSanitizer);
|
|
2073
|
-
this.previewDoc = computed(() => this.sanitizer.bypassSecurityTrustHtml(buildPreviewDocument(this.serialized())), ...ngDevMode ? [{ debugName: "previewDoc" }] : /* istanbul ignore next */ []);
|
|
2098
|
+
this.previewDoc = computed(() => this.sanitizer.bypassSecurityTrustHtml(buildPreviewDocument(this.serialized(), this.previewBrand())), ...ngDevMode ? [{ debugName: "previewDoc" }] : /* istanbul ignore next */ []);
|
|
2074
2099
|
this.bodyLength = computed(() => this.serialized().trim().length, ...ngDevMode ? [{ debugName: "bodyLength" }] : /* istanbul ignore next */ []);
|
|
2075
2100
|
this.bodyHasContent = computed(() => this.blocks().some((b) => blockHasContent(b.html)), ...ngDevMode ? [{ debugName: "bodyHasContent" }] : /* istanbul ignore next */ []);
|
|
2076
2101
|
this.bodyUnchanged = computed(() => this.loadedBody() !== null && !this.bodyEdited(), ...ngDevMode ? [{ debugName: "bodyUnchanged" }] : /* istanbul ignore next */ []);
|
|
@@ -2094,7 +2119,7 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
|
|
|
2094
2119
|
}) : "";
|
|
2095
2120
|
}, ...ngDevMode ? [{ debugName: "bodyError" }] : /* istanbul ignore next */ []);
|
|
2096
2121
|
this.datesError = computed(() => {
|
|
2097
|
-
if (this.useAllYear() || !this.activeFrom() || !this.activeTo()) return "";
|
|
2122
|
+
if (!this.showActiveRange() || this.useAllYear() || !this.activeFrom() || !this.activeTo()) return "";
|
|
2098
2123
|
return this.activeTo() < this.activeFrom() ? this.labels.t("emailTemplateEditor.datesOrder") : "";
|
|
2099
2124
|
}, ...ngDevMode ? [{ debugName: "datesError" }] : /* istanbul ignore next */ []);
|
|
2100
2125
|
this.submitAttempted = signal(false, ...ngDevMode ? [{ debugName: "submitAttempted" }] : /* istanbul ignore next */ []);
|
|
@@ -2242,9 +2267,9 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
|
|
|
2242
2267
|
subject: this.subject(),
|
|
2243
2268
|
body: keepStoredBody ? this.loadedBody() ?? "" : this.serialized(),
|
|
2244
2269
|
category: this.category(),
|
|
2245
|
-
useAllYear: this.useAllYear(),
|
|
2246
|
-
activeFrom: !this.useAllYear() && this.activeFrom() ? this.activeFrom() : null,
|
|
2247
|
-
activeTo: !this.useAllYear() && this.activeTo() ? this.activeTo() : null,
|
|
2270
|
+
useAllYear: this.showActiveRange() ? this.useAllYear() : true,
|
|
2271
|
+
activeFrom: this.showActiveRange() && !this.useAllYear() && this.activeFrom() ? this.activeFrom() : null,
|
|
2272
|
+
activeTo: this.showActiveRange() && !this.useAllYear() && this.activeTo() ? this.activeTo() : null,
|
|
2248
2273
|
videoId: this.videoId(),
|
|
2249
2274
|
assignments: this.assignmentState().filter((a) => a.assigned).map((a) => a.key)
|
|
2250
2275
|
});
|
|
@@ -2725,6 +2750,27 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
|
|
|
2725
2750
|
isRequired: false,
|
|
2726
2751
|
transformFunction: null
|
|
2727
2752
|
},
|
|
2753
|
+
showCategory: {
|
|
2754
|
+
classPropertyName: "showCategory",
|
|
2755
|
+
publicName: "showCategory",
|
|
2756
|
+
isSignal: true,
|
|
2757
|
+
isRequired: false,
|
|
2758
|
+
transformFunction: null
|
|
2759
|
+
},
|
|
2760
|
+
showActiveRange: {
|
|
2761
|
+
classPropertyName: "showActiveRange",
|
|
2762
|
+
publicName: "showActiveRange",
|
|
2763
|
+
isSignal: true,
|
|
2764
|
+
isRequired: false,
|
|
2765
|
+
transformFunction: null
|
|
2766
|
+
},
|
|
2767
|
+
previewBrand: {
|
|
2768
|
+
classPropertyName: "previewBrand",
|
|
2769
|
+
publicName: "previewBrand",
|
|
2770
|
+
isSignal: true,
|
|
2771
|
+
isRequired: false,
|
|
2772
|
+
transformFunction: null
|
|
2773
|
+
},
|
|
2728
2774
|
categoryPlaceholderInput: {
|
|
2729
2775
|
classPropertyName: "categoryPlaceholderInput",
|
|
2730
2776
|
publicName: "categoryPlaceholder",
|
|
@@ -2972,13 +3018,17 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
|
|
|
2972
3018
|
</ui-text-input>
|
|
2973
3019
|
</div>
|
|
2974
3020
|
|
|
2975
|
-
|
|
2976
|
-
<
|
|
2977
|
-
|
|
3021
|
+
@if (showCategory()) {
|
|
3022
|
+
<div class="form-field">
|
|
3023
|
+
<ui-select [label]="labels.t('emailTemplateEditor.category')" [options]="categories()" [placeholder]="categoryPlaceholder()" [(ngModel)]="category" [disabled]="!canWrite()" />
|
|
3024
|
+
</div>
|
|
3025
|
+
}
|
|
2978
3026
|
|
|
2979
|
-
|
|
3027
|
+
@if (showActiveRange()) {
|
|
3028
|
+
<ui-checkbox [label]="labels.t('emailTemplateEditor.useThisTemplateAllYear')" [(checked)]="useAllYear" [disabled]="!canWrite()" />
|
|
3029
|
+
}
|
|
2980
3030
|
|
|
2981
|
-
@if (!useAllYear()) {
|
|
3031
|
+
@if (showActiveRange() && !useAllYear()) {
|
|
2982
3032
|
<div class="form-row-dates" (focusout)="datesTouched.set(true)">
|
|
2983
3033
|
<ui-date-input [label]="labels.t('emailTemplateEditor.activeFrom')" [(ngModel)]="activeFrom" [disabled]="!canWrite()" />
|
|
2984
3034
|
<ui-date-input [label]="labels.t('emailTemplateEditor.activeTo')" [(ngModel)]="activeTo" [disabled]="!canWrite()" [min]="activeFrom()" [error]="datesError()" />
|
|
@@ -3755,13 +3805,17 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3755
3805
|
</ui-text-input>
|
|
3756
3806
|
</div>
|
|
3757
3807
|
|
|
3758
|
-
|
|
3759
|
-
<
|
|
3760
|
-
|
|
3808
|
+
@if (showCategory()) {
|
|
3809
|
+
<div class="form-field">
|
|
3810
|
+
<ui-select [label]="labels.t('emailTemplateEditor.category')" [options]="categories()" [placeholder]="categoryPlaceholder()" [(ngModel)]="category" [disabled]="!canWrite()" />
|
|
3811
|
+
</div>
|
|
3812
|
+
}
|
|
3761
3813
|
|
|
3762
|
-
|
|
3814
|
+
@if (showActiveRange()) {
|
|
3815
|
+
<ui-checkbox [label]="labels.t('emailTemplateEditor.useThisTemplateAllYear')" [(checked)]="useAllYear" [disabled]="!canWrite()" />
|
|
3816
|
+
}
|
|
3763
3817
|
|
|
3764
|
-
@if (!useAllYear()) {
|
|
3818
|
+
@if (showActiveRange() && !useAllYear()) {
|
|
3765
3819
|
<div class="form-row-dates" (focusout)="datesTouched.set(true)">
|
|
3766
3820
|
<ui-date-input [label]="labels.t('emailTemplateEditor.activeFrom')" [(ngModel)]="activeFrom" [disabled]="!canWrite()" />
|
|
3767
3821
|
<ui-date-input [label]="labels.t('emailTemplateEditor.activeTo')" [(ngModel)]="activeTo" [disabled]="!canWrite()" [min]="activeFrom()" [error]="datesError()" />
|
|
@@ -4172,6 +4226,30 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
4172
4226
|
required: false
|
|
4173
4227
|
}]
|
|
4174
4228
|
}],
|
|
4229
|
+
showCategory: [{
|
|
4230
|
+
type: i0.Input,
|
|
4231
|
+
args: [{
|
|
4232
|
+
isSignal: true,
|
|
4233
|
+
alias: "showCategory",
|
|
4234
|
+
required: false
|
|
4235
|
+
}]
|
|
4236
|
+
}],
|
|
4237
|
+
showActiveRange: [{
|
|
4238
|
+
type: i0.Input,
|
|
4239
|
+
args: [{
|
|
4240
|
+
isSignal: true,
|
|
4241
|
+
alias: "showActiveRange",
|
|
4242
|
+
required: false
|
|
4243
|
+
}]
|
|
4244
|
+
}],
|
|
4245
|
+
previewBrand: [{
|
|
4246
|
+
type: i0.Input,
|
|
4247
|
+
args: [{
|
|
4248
|
+
isSignal: true,
|
|
4249
|
+
alias: "previewBrand",
|
|
4250
|
+
required: false
|
|
4251
|
+
}]
|
|
4252
|
+
}],
|
|
4175
4253
|
categoryPlaceholderInput: [{
|
|
4176
4254
|
type: i0.Input,
|
|
4177
4255
|
args: [{
|
|
@@ -4541,6 +4619,6 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
4541
4619
|
args: [{ providedIn: "root" }]
|
|
4542
4620
|
}]
|
|
4543
4621
|
});
|
|
4544
|
-
export { DEFAULT_EMAIL_TEMPLATE_BLOCK_GROUPS, DEFAULT_EMAIL_TEMPLATE_VARIABLE_GROUPS, EMAIL_BLOCK_DRAG_TYPE, EMAIL_TEMPLATE_MAX_BODY, EMAIL_TEMPLATE_MAX_TEXT, EMAIL_TEMPLATE_START_TEXT, EmailTemplateEditorComponent, InspectionTemplatePrintService, MAX_EMAIL_ADDRESS_LENGTH, RICH_TEXT_OPTIONS, RichTextEditorComponent, blockHasContent, buildInspectionTemplateHtml, buildPreviewDocument, buildVideoBlockHtml, escapeHtml, formatCategoryLabel, formatVideoDuration, insideEditorBlock, inspectionTemplateStatusLabel, isBlockDrag, isValidEmailAddress, isWebUrl, localizedEmailBlockGroups, localizedEmailVariableGroups, plainTextToHtml, sanitizeRichTextHtml, serializedTextLength };
|
|
4622
|
+
export { DEFAULT_EMAIL_TEMPLATE_BLOCK_GROUPS, DEFAULT_EMAIL_TEMPLATE_VARIABLE_GROUPS, EMAIL_BLOCK_DRAG_TYPE, EMAIL_TEMPLATE_MAX_BODY, EMAIL_TEMPLATE_MAX_TEXT, EMAIL_TEMPLATE_START_TEXT, EmailTemplateEditorComponent, InspectionTemplatePrintService, MAX_EMAIL_ADDRESS_LENGTH, RICH_TEXT_OPTIONS, RichTextEditorComponent, blockHasContent, buildInspectionTemplateHtml, buildPreviewDocument, buildVideoBlockHtml, escapeHtml, formatCategoryLabel, formatVideoDuration, insideEditorBlock, inspectionTemplateStatusLabel, isBlockDrag, isValidEmailAddress, isWebUrl, localizedEmailBlockGroups, localizedEmailVariableGroups, plainTextToHtml, safePreviewBrand, sanitizeRichTextHtml, serializedTextLength };
|
|
4545
4623
|
|
|
4546
4624
|
//# sourceMappingURL=forgeroute-ui-editor.mjs.map
|