@forgeroute/ui 0.5.35 → 0.5.37

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.
@@ -1827,6 +1827,9 @@ function safePreviewBrand(brand) {
1827
1827
  return out;
1828
1828
  }
1829
1829
  const VARIABLE_TOKEN = /\{\{\s*([A-Za-z0-9_]+)\s*\}\}/g;
1830
+ function isVariableAddress(value) {
1831
+ return /^\{\{\s*[A-Za-z0-9_]+\s*\}\}$/.test(value.trim());
1832
+ }
1830
1833
  function usedVariableKeys(...texts) {
1831
1834
  const keys = [];
1832
1835
  for (const text of texts) for (const m of text.matchAll(VARIABLE_TOKEN)) if (!keys.includes(m[1])) keys.push(m[1]);
@@ -2179,11 +2182,12 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2179
2182
  this.normalizedLink = computed(() => {
2180
2183
  const url = this.linkUrl().trim();
2181
2184
  if (!url) return "";
2182
- return url.startsWith("http://") || url.startsWith("https://") || url.startsWith("mailto:") ? url : "https://" + url;
2185
+ return isVariableAddress(url) || url.startsWith("http://") || url.startsWith("https://") || url.startsWith("mailto:") ? url : "https://" + url;
2183
2186
  }, ...ngDevMode ? [{ debugName: "normalizedLink" }] : /* istanbul ignore next */ []);
2184
2187
  this.linkUrlError = computed(() => {
2185
2188
  const url = this.normalizedLink();
2186
2189
  if (!url) return "";
2190
+ if (isVariableAddress(url)) return "";
2187
2191
  if (url.startsWith("mailto:")) return /^mailto:[^\s@"<>]+@[^\s@"<>]+\.[^\s@"<>]+$/.test(url) ? "" : this.labels.t("emailTemplateEditor.validEmail");
2188
2192
  return isWebUrl(url) ? "" : this.labels.t("emailTemplateEditor.validWebAddress");
2189
2193
  }, ...ngDevMode ? [{ debugName: "linkUrlError" }] : /* istanbul ignore next */ []);
@@ -2632,6 +2636,14 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2632
2636
  } : b));
2633
2637
  if (changed) this.bodyEdited.set(true);
2634
2638
  }
2639
+ anchorAtSelection() {
2640
+ const sel = window.getSelection();
2641
+ if (!sel || sel.rangeCount === 0) return null;
2642
+ const range = sel.getRangeAt(0);
2643
+ const anchorOf = (node) => (node instanceof Element ? node : node.parentElement)?.closest("a") ?? null;
2644
+ const start = anchorOf(range.startContainer);
2645
+ return start && start === anchorOf(range.endContainer) && insideEditorBlock(start) ? start : null;
2646
+ }
2635
2647
  openLinkDialog() {
2636
2648
  if (!this.canWrite()) return;
2637
2649
  this.saveSelection();
@@ -2646,6 +2658,16 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2646
2658
  this.bodyEdited.set(true);
2647
2659
  const url = this.normalizedLink();
2648
2660
  this.restoreSelection();
2661
+ const existing = this.anchorAtSelection();
2662
+ if (existing) {
2663
+ existing.setAttribute("href", url);
2664
+ existing.setAttribute("target", "_blank");
2665
+ this.syncBlock();
2666
+ this.showLinkDialog.set(false);
2667
+ this.linkUrl.set("");
2668
+ this.linkText.set("");
2669
+ return;
2670
+ }
2649
2671
  const sel = window.getSelection();
2650
2672
  if (sel && sel.rangeCount > 0 && !sel.isCollapsed) {
2651
2673
  document.execCommand("createLink", false, url);
@@ -3702,6 +3724,7 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3702
3724
  inputs: [
3703
3725
  "placeholder",
3704
3726
  "ariaLabel",
3727
+ "width",
3705
3728
  "value",
3706
3729
  "maxlength",
3707
3730
  "endpoint",
@@ -4752,6 +4775,6 @@ i0.ɵɵngDeclareClassMetadata({
4752
4775
  args: [{ providedIn: "root" }]
4753
4776
  }]
4754
4777
  });
4755
- 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, fillSampleVariables, findEmailChecks, formatCategoryLabel, formatVideoDuration, insideEditorBlock, inspectionTemplateStatusLabel, isBlockDrag, isValidEmailAddress, isWebUrl, localizedEmailBlockGroups, localizedEmailVariableGroups, plainTextToHtml, safePreviewBrand, sanitizeRichTextHtml, serializedTextLength, usedVariableKeys };
4778
+ 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, fillSampleVariables, findEmailChecks, formatCategoryLabel, formatVideoDuration, insideEditorBlock, inspectionTemplateStatusLabel, isBlockDrag, isValidEmailAddress, isVariableAddress, isWebUrl, localizedEmailBlockGroups, localizedEmailVariableGroups, plainTextToHtml, safePreviewBrand, sanitizeRichTextHtml, serializedTextLength, usedVariableKeys };
4756
4779
 
4757
4780
  //# sourceMappingURL=forgeroute-ui-editor.mjs.map