kritzel-stencil 0.4.4 → 0.4.6

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.
Files changed (128) hide show
  1. package/dist/cjs/kritzel-active-users_47.cjs.entry.js +79 -13
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/stencil.cjs.js +1 -1
  4. package/dist/collection/classes/core/viewport.class.js +14 -1
  5. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +48 -8
  6. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +84 -3
  7. package/dist/collection/constants/version.js +1 -1
  8. package/dist/components/index.js +1226 -1
  9. package/dist/components/kritzel-active-users.js +6 -1
  10. package/dist/components/kritzel-avatar.js +6 -1
  11. package/dist/components/kritzel-awareness-cursors.js +6 -1
  12. package/dist/components/kritzel-back-to-content.js +6 -1
  13. package/dist/components/kritzel-brush-style.js +64 -1
  14. package/dist/components/kritzel-button.js +6 -1
  15. package/dist/components/kritzel-color-palette.js +6 -1
  16. package/dist/components/kritzel-color.js +6 -1
  17. package/dist/components/kritzel-context-menu.js +6 -1
  18. package/dist/components/kritzel-controls.js +6 -1
  19. package/dist/components/kritzel-current-user-dialog.js +6 -1
  20. package/dist/components/kritzel-current-user.js +6 -1
  21. package/dist/components/kritzel-cursor-trail.js +6 -1
  22. package/dist/components/kritzel-dialog.js +6 -1
  23. package/dist/components/kritzel-dropdown.js +6 -1
  24. package/dist/components/kritzel-editor.js +4404 -1
  25. package/dist/components/kritzel-engine.js +6 -1
  26. package/dist/components/kritzel-export.js +6 -1
  27. package/dist/components/kritzel-font-family.js +6 -1
  28. package/dist/components/kritzel-font-size.js +6 -1
  29. package/dist/components/kritzel-font.js +6 -1
  30. package/dist/components/kritzel-icon.js +6 -1
  31. package/dist/components/kritzel-input.js +6 -1
  32. package/dist/components/kritzel-line-endings.js +6 -1
  33. package/dist/components/kritzel-loading-overlay.js +6 -1
  34. package/dist/components/kritzel-login-dialog.js +6 -1
  35. package/dist/components/kritzel-master-detail.js +6 -1
  36. package/dist/components/kritzel-menu-item.js +6 -1
  37. package/dist/components/kritzel-menu.js +6 -1
  38. package/dist/components/kritzel-more-menu.js +6 -1
  39. package/dist/components/kritzel-notification-card.js +6 -1
  40. package/dist/components/kritzel-numeric-input.js +6 -1
  41. package/dist/components/kritzel-opacity-slider.js +6 -1
  42. package/dist/components/kritzel-pill-tabs.js +6 -1
  43. package/dist/components/kritzel-portal.js +6 -1
  44. package/dist/components/kritzel-settings.js +6 -1
  45. package/dist/components/kritzel-shape-fill.js +6 -1
  46. package/dist/components/kritzel-share-dialog.js +6 -1
  47. package/dist/components/kritzel-slide-toggle.js +6 -1
  48. package/dist/components/kritzel-split-button.js +6 -1
  49. package/dist/components/kritzel-stroke-size.js +6 -1
  50. package/dist/components/kritzel-sync-indicator.js +6 -1
  51. package/dist/components/kritzel-tool-config.js +6 -1
  52. package/dist/components/kritzel-tooltip.js +6 -1
  53. package/dist/components/kritzel-utility-panel.js +6 -1
  54. package/dist/components/kritzel-watermark.js +6 -1
  55. package/dist/components/kritzel-workspace-manager.js +6 -1
  56. package/dist/components/kritzel-zoom-panel.js +6 -1
  57. package/dist/components/p-894OnDQV.js +39 -1
  58. package/dist/components/p-B43upypT.js +1500 -1
  59. package/dist/components/p-B5oHmPJb.js +97 -1
  60. package/dist/components/p-B6t5q-V4.js +63 -1
  61. package/dist/components/p-B8Xi4Clg.js +43 -1
  62. package/dist/components/p-BBmP8lVY.js +51726 -0
  63. package/dist/components/p-BDzlx2hB.js +135 -1
  64. package/dist/components/p-BFTU3MAI.js +7 -1
  65. package/dist/components/p-BFYtCsZu.js +56 -1
  66. package/dist/components/p-BI2ng9I_.js +62 -1
  67. package/dist/components/p-BTzlrIxe.js +194 -1
  68. package/dist/components/p-BmyTdQGy.js +1090 -1
  69. package/dist/components/p-BsANVili.js +150 -1
  70. package/dist/components/p-BxpKq94F.js +290 -1
  71. package/dist/components/p-C38P-Vd0.js +446 -1
  72. package/dist/components/p-C4NrrUfN.js +77 -1
  73. package/dist/components/p-CW-VyJgK.js +6 -1
  74. package/dist/components/p-CWRSGYOE.js +57 -1
  75. package/dist/components/p-CXpv9Rxe.js +106 -1
  76. package/dist/components/p-Ca-igU1f.js +320 -1
  77. package/dist/components/p-CdR76C4L.js +165 -1
  78. package/dist/components/p-Ch42cOeY.js +320 -0
  79. package/dist/components/p-ClFprFvz.js +209 -1
  80. package/dist/components/p-Cm33td2O.js +122 -1
  81. package/dist/components/p-CqLgB8JK.js +91 -1
  82. package/dist/components/p-Cr682JI_.js +156 -1
  83. package/dist/components/p-CsvMgk_f.js +62 -1
  84. package/dist/components/p-CwJwsRR3.js +277 -1
  85. package/dist/components/p-Cymum41a.js +88 -1
  86. package/dist/components/p-D09kgc5Q.js +94 -1
  87. package/dist/components/p-D30zs0kA.js +121 -1
  88. package/dist/components/p-D3y_Hauo.js +85 -1
  89. package/dist/components/p-D5jf8wAu.js +142 -1
  90. package/dist/components/p-D82VaHce.js +53 -1
  91. package/dist/components/p-DAwPPDMS.js +101 -1
  92. package/dist/components/p-DEBwmRTC.js +55 -1
  93. package/dist/components/p-DIazmg6w.js +52 -1
  94. package/dist/components/p-DJ88BrIW.js +70 -1
  95. package/dist/components/p-DJkKlUyZ.js +182 -1
  96. package/dist/components/p-DUYmwrWV.js +3267 -1
  97. package/dist/components/p-DX2nriaq.js +486 -1
  98. package/dist/components/p-Dd-pMvlr.js +20 -1
  99. package/dist/components/p-Df3BwVGy.js +299 -1
  100. package/dist/components/p-DgJ0ufzr.js +43 -1
  101. package/dist/components/p-DkUb2czk.js +70 -1
  102. package/dist/components/p-Dlp84thc.js +57 -1
  103. package/dist/components/p-JYj3Facr.js +431 -1
  104. package/dist/components/p-Ka7OWbnk.js +2304 -1
  105. package/dist/components/p-PSFAfAyd.js +49 -1
  106. package/dist/components/p-WUdQqYnu.js +118 -1
  107. package/dist/components/p-djJSnjAX.js +84 -1
  108. package/dist/components/p-e6Zpc9Vp.js +143 -1
  109. package/dist/components/p-jGOpkGDl.js +30 -1
  110. package/dist/components/p-pagW8YF7.js +99 -1
  111. package/dist/esm/kritzel-active-users_47.entry.js +79 -13
  112. package/dist/esm/loader.js +1 -1
  113. package/dist/esm/stencil.js +1 -1
  114. package/dist/stencil/index.esm.js +1172 -1
  115. package/dist/stencil/p-5b969a42.entry.js +36109 -0
  116. package/dist/stencil/p-DQuL1Twl.js +3 -1
  117. package/dist/stencil/p-Dhio9uis.js +1717 -2
  118. package/dist/stencil/p-fb32cd8f.entry.js +29 -1
  119. package/dist/stencil/p-uC7_X6yr.js +30737 -1
  120. package/dist/stencil/stencil.esm.js +21 -1
  121. package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +2 -0
  122. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +7 -0
  123. package/dist/types/components.d.ts +10 -0
  124. package/dist/types/constants/version.d.ts +1 -1
  125. package/package.json +1 -1
  126. package/dist/components/p--Oazz-BP.js +0 -9
  127. package/dist/components/p-Xsiz1D5Q.js +0 -1
  128. package/dist/stencil/p-9abc21b9.entry.js +0 -9
@@ -1 +1,182 @@
1
- const t="__kritzelFontRegistry__",e="kritzel-font-registry-change",s=t=>t.trim().toLocaleLowerCase();class n{static get _fonts(){return(()=>{const e=globalThis,s=e[t];if(s)return s;const n={fonts:new Map};return e[t]=n,n})().fonts}static getFontFaceSet(){return"undefined"!=typeof document&&document.fonts?document.fonts:null}static toCssFontFace(t){return t.includes(" ")?`"${t.replaceAll('"','\\"')}"`:t}static getRegisteredFontFamilies(t){return[...new Set(Object.values(t).map((t=>"string"==typeof t?t:t.family)).map((t=>t.trim())).filter(Boolean))]}static register(t,e){const s=((t,e)=>"string"==typeof e?{key:t,family:e,label:e,cssFontFamily:e}:{key:t,family:e.family,label:e.label??e.family,cssFontFamily:e.cssFontFamily??e.family,source:e.source})(t,e);this._fonts.has(t)&&console.warn(`[FontRegistry] Font "${t}" is already registered. It will be overwritten.`),this._fonts.set(t,s),this.emitChange()}static registerFonts(t){for(const[e,s]of Object.entries(t))this.register(e,s)}static injectFontStylesheets(t){if("undefined"==typeof document)return Promise.resolve([]);const e=[];for(const[s,n]of Object.entries(t)){if("string"==typeof n||!n.source)continue;const t=n.source,i=`kritzel-font-stylesheet-${s}`;if(document.getElementById(i))continue;const o=document.createElement("link");o.id=i,o.rel="stylesheet",o.href=t;const r=new Promise((e=>{o.onload=()=>e(),o.onerror=()=>{console.warn(`[FontRegistry] Failed to load stylesheet for font "${s}": ${t}`),e()}}));document.head.appendChild(o),e.push(r)}return Promise.all(e)}static async waitForFonts(t){await this.injectFontStylesheets(t);const e=this.getFontFaceSet(),s=this.getRegisteredFontFamilies(t);e&&0!==s.length&&(await Promise.allSettled(s.map((t=>e.load(`1em ${this.toCssFontFace(t)}`)))),await e.ready)}static get(t){return this._fonts.get(t)}static has(t){return this._fonts.has(t)}static unregister(t){const e=this._fonts.delete(t);return e&&this.emitChange(),e}static list(){return[...this._fonts.values()]}static resolveCssFontFamily(t){const e=s(t),n=this.list().find((t=>s(t.family)===e||t.key.trim().toLocaleLowerCase()===e));return n?.cssFontFamily??t}static toRegisteredFont(t){return"string"==typeof t?{key:t,family:t,label:t,cssFontFamily:t}:{key:t.family,family:t.family,label:t.label??t.family,cssFontFamily:t.cssFontFamily??t.family,source:t.source}}static emitChange(){const t=globalThis;"function"==typeof t.dispatchEvent&&"undefined"!=typeof CustomEvent&&t.dispatchEvent(new CustomEvent(e))}static get changeEventName(){return e}}const i=["Arial","Verdana","Helvetica","Tahoma","Trebuchet MS","Times New Roman","Georgia","Garamond","Courier New","Brush Script MT"],o=t=>t&&0!==t.length?[...t]:[...i];export{i as D,n as K,o as r}
1
+ const KRITZEL_FONT_REGISTRY_KEY = '__kritzelFontRegistry__';
2
+ const KRITZEL_FONT_REGISTRY_EVENT = 'kritzel-font-registry-change';
3
+ const getGlobalRegistryStore = () => {
4
+ const globalScope = globalThis;
5
+ const existing = globalScope[KRITZEL_FONT_REGISTRY_KEY];
6
+ if (existing) {
7
+ return existing;
8
+ }
9
+ const created = {
10
+ fonts: new Map(),
11
+ };
12
+ globalScope[KRITZEL_FONT_REGISTRY_KEY] = created;
13
+ return created;
14
+ };
15
+ const normalizeFontRegistration = (key, registration) => {
16
+ if (typeof registration === 'string') {
17
+ return {
18
+ key,
19
+ family: registration,
20
+ label: registration,
21
+ cssFontFamily: registration,
22
+ };
23
+ }
24
+ return {
25
+ key,
26
+ family: registration.family,
27
+ label: registration.label ?? registration.family,
28
+ cssFontFamily: registration.cssFontFamily ?? registration.family,
29
+ source: registration.source,
30
+ };
31
+ };
32
+ const normalizeKey = (value) => value.trim().toLocaleLowerCase();
33
+ const normalizeFamily = (value) => value.trim().toLocaleLowerCase();
34
+ class KritzelFontRegistry {
35
+ static get _fonts() {
36
+ return getGlobalRegistryStore().fonts;
37
+ }
38
+ static getFontFaceSet() {
39
+ if (typeof document === 'undefined' || !document.fonts) {
40
+ return null;
41
+ }
42
+ return document.fonts;
43
+ }
44
+ static toCssFontFace(fontFamily) {
45
+ return fontFamily.includes(' ')
46
+ ? `"${fontFamily.replaceAll('"', '\\"')}"`
47
+ : fontFamily;
48
+ }
49
+ static getRegisteredFontFamilies(fonts) {
50
+ return [...new Set(Object.values(fonts)
51
+ .map(registration => (typeof registration === 'string' ? registration : registration.family))
52
+ .map(family => family.trim())
53
+ .filter(Boolean))];
54
+ }
55
+ static register(key, registration) {
56
+ const normalized = normalizeFontRegistration(key, registration);
57
+ if (this._fonts.has(key)) {
58
+ console.warn(`[FontRegistry] Font "${key}" is already registered. It will be overwritten.`);
59
+ }
60
+ this._fonts.set(key, normalized);
61
+ this.emitChange();
62
+ }
63
+ static registerFonts(fonts) {
64
+ for (const [key, registration] of Object.entries(fonts)) {
65
+ this.register(key, registration);
66
+ }
67
+ }
68
+ static injectFontStylesheets(fonts) {
69
+ if (typeof document === 'undefined') {
70
+ return Promise.resolve([]);
71
+ }
72
+ const loadPromises = [];
73
+ for (const [key, registration] of Object.entries(fonts)) {
74
+ if (typeof registration === 'string' || !registration.source) {
75
+ continue;
76
+ }
77
+ const sourceUrl = registration.source;
78
+ const linkId = `kritzel-font-stylesheet-${key}`;
79
+ if (document.getElementById(linkId)) {
80
+ continue;
81
+ }
82
+ const link = document.createElement('link');
83
+ link.id = linkId;
84
+ link.rel = 'stylesheet';
85
+ link.href = sourceUrl;
86
+ const promise = new Promise((resolve) => {
87
+ link.onload = () => resolve();
88
+ link.onerror = () => {
89
+ console.warn(`[FontRegistry] Failed to load stylesheet for font "${key}": ${sourceUrl}`);
90
+ resolve(); // Resolve anyway so we don't hang startup on external failures
91
+ };
92
+ });
93
+ document.head.appendChild(link);
94
+ loadPromises.push(promise);
95
+ }
96
+ return Promise.all(loadPromises);
97
+ }
98
+ static async waitForFonts(fonts) {
99
+ await this.injectFontStylesheets(fonts);
100
+ const fontFaceSet = this.getFontFaceSet();
101
+ const registeredFontFamilies = this.getRegisteredFontFamilies(fonts);
102
+ if (!fontFaceSet || registeredFontFamilies.length === 0) {
103
+ return;
104
+ }
105
+ await Promise.allSettled(registeredFontFamilies.map(fontFamily => fontFaceSet.load(`1em ${this.toCssFontFace(fontFamily)}`)));
106
+ await fontFaceSet.ready;
107
+ }
108
+ static get(key) {
109
+ return this._fonts.get(key);
110
+ }
111
+ static has(key) {
112
+ return this._fonts.has(key);
113
+ }
114
+ static unregister(key) {
115
+ const deleted = this._fonts.delete(key);
116
+ if (deleted) {
117
+ this.emitChange();
118
+ }
119
+ return deleted;
120
+ }
121
+ static list() {
122
+ return [...this._fonts.values()];
123
+ }
124
+ static resolveCssFontFamily(fontFamily) {
125
+ const normalizedFamily = normalizeFamily(fontFamily);
126
+ const match = this.list().find(font => {
127
+ if (normalizeFamily(font.family) === normalizedFamily) {
128
+ return true;
129
+ }
130
+ return normalizeKey(font.key) === normalizedFamily;
131
+ });
132
+ return match?.cssFontFamily ?? fontFamily;
133
+ }
134
+ static toRegisteredFont(registration) {
135
+ if (typeof registration === 'string') {
136
+ return {
137
+ key: registration,
138
+ family: registration,
139
+ label: registration,
140
+ cssFontFamily: registration,
141
+ };
142
+ }
143
+ return {
144
+ key: registration.family,
145
+ family: registration.family,
146
+ label: registration.label ?? registration.family,
147
+ cssFontFamily: registration.cssFontFamily ?? registration.family,
148
+ source: registration.source,
149
+ };
150
+ }
151
+ static emitChange() {
152
+ const eventTarget = globalThis;
153
+ if (typeof eventTarget.dispatchEvent !== 'function' || typeof CustomEvent === 'undefined') {
154
+ return;
155
+ }
156
+ eventTarget.dispatchEvent(new CustomEvent(KRITZEL_FONT_REGISTRY_EVENT));
157
+ }
158
+ static get changeEventName() {
159
+ return KRITZEL_FONT_REGISTRY_EVENT;
160
+ }
161
+ }
162
+
163
+ const DEFAULT_TEXT_TOOL_AVAILABLE_FONTS = [
164
+ 'Arial',
165
+ 'Verdana',
166
+ 'Helvetica',
167
+ 'Tahoma',
168
+ 'Trebuchet MS',
169
+ 'Times New Roman',
170
+ 'Georgia',
171
+ 'Garamond',
172
+ 'Courier New',
173
+ 'Brush Script MT',
174
+ ];
175
+ const resolveTextToolAvailableFonts = (availableFonts) => {
176
+ if (!availableFonts || availableFonts.length === 0) {
177
+ return [...DEFAULT_TEXT_TOOL_AVAILABLE_FONTS];
178
+ }
179
+ return [...availableFonts];
180
+ };
181
+
182
+ export { DEFAULT_TEXT_TOOL_AVAILABLE_FONTS as D, KritzelFontRegistry as K, resolveTextToolAvailableFonts as r };