@servicetitan/dte-unlayer 0.126.0 → 0.128.0

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.
@@ -67,7 +67,7 @@ export const unlayerSupportedFonts = [
67
67
  {
68
68
  label: 'Sofia Pro',
69
69
  value: 'Sofia Pro',
70
- url: 'https://fonts.cdnfonts.com/css/sofia-pro',
70
+ url: 'https://fonts.googleapis.com/css2?family=Sofia+Sans:ital,wght@0,1..1000;1,1..1000&display=swap',
71
71
  },
72
72
  {
73
73
  label: 'Nunito',
package/src/store.ts CHANGED
@@ -65,11 +65,8 @@ const ensureChunksFonts = (data: any) => {
65
65
 
66
66
  data.chunks ??= {};
67
67
 
68
- const fontUrls = new Set<string>(
69
- Array.isArray(data.chunks.fonts)
70
- ? data.chunks.fonts.filter((url: unknown): url is string => typeof url === 'string')
71
- : [],
72
- );
68
+ const existingFonts: any[] = Array.isArray(data.chunks.fonts) ? data.chunks.fonts : [];
69
+ const existingLabels = new Set(existingFonts.map((f: any) => f.label));
73
70
 
74
71
  const usedFontTokens = new Set<string>();
75
72
  getDesignFontTokens(data.design, usedFontTokens);
@@ -77,21 +74,18 @@ const ensureChunksFonts = (data: any) => {
77
74
  const html = typeof data.html === 'string' ? data.html.toLowerCase() : '';
78
75
 
79
76
  for (const font of unlayerSupportedFonts) {
80
- if (!font.url) {
81
- continue;
82
- }
83
-
84
77
  const labelToken = normalizeFontToken(font.label);
85
78
  const valueToken = normalizeFontToken(font.value);
86
79
  const isUsedInDesign = usedFontTokens.has(labelToken) || usedFontTokens.has(valueToken);
87
80
  const isUsedInHtml = !!html && (html.includes(labelToken) || html.includes(valueToken));
88
81
 
89
- if (isUsedInDesign || isUsedInHtml) {
90
- fontUrls.add(font.url);
82
+ if ((isUsedInDesign || isUsedInHtml) && !existingLabels.has(font.label)) {
83
+ existingFonts.push(font);
84
+ existingLabels.add(font.label);
91
85
  }
92
86
  }
93
87
 
94
- data.chunks.fonts = Array.from(fontUrls);
88
+ data.chunks.fonts = existingFonts;
95
89
  return data;
96
90
  };
97
91