kritzel-stencil 0.1.78 → 0.1.80

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 (163) hide show
  1. package/dist/cjs/{index-BRZ6e6oa.js → index-CFnj_FXt.js} +36 -9
  2. package/dist/cjs/index.cjs.js +1 -1
  3. package/dist/cjs/kritzel-active-users_42.cjs.entry.js +333 -177
  4. package/dist/cjs/kritzel-brush-style.cjs.entry.js +1 -1
  5. package/dist/cjs/loader.cjs.js +2 -2
  6. package/dist/cjs/stencil.cjs.js +3 -3
  7. package/dist/cjs/{workspace.migrations-sUPrO23c.js → workspace.migrations-DUXtSb7C.js} +244 -197
  8. package/dist/collection/classes/core/core.class.js +39 -31
  9. package/dist/collection/classes/core/store.class.js +57 -16
  10. package/dist/collection/classes/core/viewport.class.js +12 -12
  11. package/dist/collection/classes/handlers/context-menu.handler.js +1 -1
  12. package/dist/collection/classes/handlers/line-handle.handler.js +7 -4
  13. package/dist/collection/classes/handlers/move.handler.js +11 -8
  14. package/dist/collection/classes/handlers/resize.handler.js +12 -3
  15. package/dist/collection/classes/handlers/rotation.handler.js +12 -3
  16. package/dist/collection/classes/handlers/selection.handler.js +20 -15
  17. package/dist/collection/classes/managers/anchor.manager.js +4 -4
  18. package/dist/collection/classes/objects/base-object.class.js +6 -6
  19. package/dist/collection/classes/objects/custom-element.class.js +2 -2
  20. package/dist/collection/classes/objects/group.class.js +10 -10
  21. package/dist/collection/classes/objects/image.class.js +2 -2
  22. package/dist/collection/classes/objects/line.class.js +7 -7
  23. package/dist/collection/classes/objects/path.class.js +5 -5
  24. package/dist/collection/classes/objects/selection-box.class.js +1 -1
  25. package/dist/collection/classes/objects/selection-group.class.js +16 -16
  26. package/dist/collection/classes/objects/shape.class.js +37 -31
  27. package/dist/collection/classes/objects/text.class.js +40 -32
  28. package/dist/collection/classes/structures/app-state-map.structure.js +18 -16
  29. package/dist/collection/classes/structures/object-map.structure.js +30 -27
  30. package/dist/collection/classes/tools/brush-tool.class.js +14 -14
  31. package/dist/collection/classes/tools/image-tool.class.js +1 -1
  32. package/dist/collection/classes/tools/line-tool.class.js +14 -14
  33. package/dist/collection/classes/tools/selection-tool.class.js +2 -2
  34. package/dist/collection/classes/tools/shape-tool.class.js +6 -6
  35. package/dist/collection/classes/tools/text-tool.class.js +2 -2
  36. package/dist/collection/collection-manifest.json +1 -1
  37. package/dist/collection/components/core/kritzel-awareness-cursors/kritzel-awareness-cursors.js +6 -6
  38. package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +2 -2
  39. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +70 -11
  40. package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +21 -1
  41. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +159 -60
  42. package/dist/collection/configs/default-engine-config.js +2 -2
  43. package/dist/collection/constants/version.js +1 -1
  44. package/dist/collection/helpers/keyboard.helper.js +15 -11
  45. package/dist/components/index.js +1 -1
  46. package/dist/components/kritzel-active-users.js +1 -1
  47. package/dist/components/kritzel-avatar.js +1 -1
  48. package/dist/components/kritzel-awareness-cursors.js +1 -1
  49. package/dist/components/kritzel-back-to-content.js +1 -1
  50. package/dist/components/kritzel-brush-style.js +1 -1
  51. package/dist/components/kritzel-button.js +1 -1
  52. package/dist/components/kritzel-color-palette.js +1 -1
  53. package/dist/components/kritzel-color.js +1 -1
  54. package/dist/components/kritzel-context-menu.js +1 -1
  55. package/dist/components/kritzel-controls.js +1 -1
  56. package/dist/components/kritzel-current-user-dialog.js +1 -1
  57. package/dist/components/kritzel-current-user.js +1 -1
  58. package/dist/components/kritzel-cursor-trail.js +1 -1
  59. package/dist/components/kritzel-dialog.js +1 -1
  60. package/dist/components/kritzel-dropdown.js +1 -1
  61. package/dist/components/kritzel-editor.js +1 -1
  62. package/dist/components/kritzel-engine.js +1 -1
  63. package/dist/components/kritzel-export.js +1 -1
  64. package/dist/components/kritzel-font-family.js +1 -1
  65. package/dist/components/kritzel-font-size.js +1 -1
  66. package/dist/components/kritzel-font.js +1 -1
  67. package/dist/components/kritzel-icon.js +1 -1
  68. package/dist/components/kritzel-input.js +1 -1
  69. package/dist/components/kritzel-line-endings.js +1 -1
  70. package/dist/components/kritzel-login-dialog.js +1 -1
  71. package/dist/components/kritzel-master-detail.js +1 -1
  72. package/dist/components/kritzel-menu-item.js +1 -1
  73. package/dist/components/kritzel-menu.js +1 -1
  74. package/dist/components/kritzel-more-menu.js +1 -1
  75. package/dist/components/kritzel-numeric-input.js +1 -1
  76. package/dist/components/kritzel-opacity-slider.js +1 -1
  77. package/dist/components/kritzel-pill-tabs.js +1 -1
  78. package/dist/components/kritzel-portal.js +1 -1
  79. package/dist/components/kritzel-settings.js +1 -1
  80. package/dist/components/kritzel-shape-fill.js +1 -1
  81. package/dist/components/kritzel-share-dialog.js +1 -1
  82. package/dist/components/kritzel-slide-toggle.js +1 -1
  83. package/dist/components/kritzel-split-button.js +1 -1
  84. package/dist/components/kritzel-stroke-size.js +1 -1
  85. package/dist/components/kritzel-tool-config.js +1 -1
  86. package/dist/components/kritzel-tooltip.js +1 -1
  87. package/dist/components/kritzel-utility-panel.js +1 -1
  88. package/dist/components/kritzel-workspace-manager.js +1 -1
  89. package/dist/components/{p-Md9Y-b3d.js → p-1ppb4M65.js} +1 -1
  90. package/dist/components/{p-KJ4dHzrS.js → p-7yR-sKH8.js} +1 -1
  91. package/dist/components/{p-CN8IxBlU.js → p-B-Gej_Ak.js} +1 -1
  92. package/dist/components/{p-76W5pG2O.js → p-B4F19Aqj.js} +1 -1
  93. package/dist/components/{p-BuI6Gkzg.js → p-B5WII1Lk.js} +1 -1
  94. package/dist/components/p-BWj1eE2b.js +1 -0
  95. package/dist/components/{p-ZC5YELQJ.js → p-BZ8bK8qT.js} +1 -1
  96. package/dist/components/{p-DkWWzVg8.js → p-BaaFG0p-.js} +1 -1
  97. package/dist/components/{p-6NFl6EB2.js → p-Bat829Bg.js} +1 -1
  98. package/dist/components/p-BcwZ36sO.js +1 -0
  99. package/dist/components/{p-53di1Zko.js → p-BjPmEs5A.js} +1 -1
  100. package/dist/components/{p-D5IhryUR.js → p-Brwz_Dpb.js} +1 -1
  101. package/dist/components/p-BzQmBVwr.js +9 -0
  102. package/dist/components/{p-C2l9mZ1P.js → p-C-MtTi6x.js} +1 -1
  103. package/dist/components/p-C8WnYSHi.js +1 -0
  104. package/dist/components/{p-BLsH_Oi0.js → p-C9zsWWH2.js} +1 -1
  105. package/dist/components/{p-ZQ2bKafG.js → p-CJKsuQun.js} +1 -1
  106. package/dist/components/{p-m1nVDC3G.js → p-CJzg_ejc.js} +1 -1
  107. package/dist/components/{p-Dte67BWd.js → p-CM7rYf9A.js} +1 -1
  108. package/dist/components/{p-Dr3-pKVg.js → p-CMGHx71q.js} +1 -1
  109. package/dist/components/{p-CI9Nbh-x.js → p-CNMpVlot.js} +1 -1
  110. package/dist/components/{p-DDKjsXCe.js → p-CS7r-zhx.js} +1 -1
  111. package/dist/components/{p-DaGZEV0R.js → p-C_fSm7T4.js} +1 -1
  112. package/dist/components/{p-Ck1dhpUQ.js → p-CfEGaTaV.js} +1 -1
  113. package/dist/components/{p-CWMFGEe0.js → p-CvyE2Wg-.js} +1 -1
  114. package/dist/components/{p-D3pNw-SV.js → p-D5BXoK9m.js} +1 -1
  115. package/dist/components/{p-DV7Z_qfa.js → p-D7pwbRUy.js} +1 -1
  116. package/dist/components/{p-CBslLN3-.js → p-DCH4Rlqx.js} +1 -1
  117. package/dist/components/{p-CYh7yV-K.js → p-DEOUiiyI.js} +1 -1
  118. package/dist/components/{p-pCC6t6BH.js → p-DKeBfe_l.js} +1 -1
  119. package/dist/components/{p-DWsCbu01.js → p-DUQmBcTy.js} +1 -1
  120. package/dist/components/{p-D14QNK3X.js → p-DUnKjQN7.js} +1 -1
  121. package/dist/components/{p-BrZ_gL8Q.js → p-DYcsC2zO.js} +1 -1
  122. package/dist/components/{p-D7yzmu1l.js → p-DkT0KZCm.js} +1 -1
  123. package/dist/components/{p-Cns7qSKS.js → p-DrsORMoT.js} +1 -1
  124. package/dist/components/{p-BueaqfA2.js → p-Dw0Obsn5.js} +1 -1
  125. package/dist/components/{p-DxzDda_J.js → p-Gm5hSQ-e.js} +1 -1
  126. package/dist/components/{p-C4fKLlrd.js → p-HK-6khHo.js} +1 -1
  127. package/dist/components/{p-_QEHfsIk.js → p-V3VW2JKl.js} +1 -1
  128. package/dist/components/{p-Lhyh6KeB.js → p-VxgCvVox.js} +1 -1
  129. package/dist/components/{p-l_YGO7RB.js → p-cjeDomsc.js} +1 -1
  130. package/dist/components/{p-gtQlsorg.js → p-rNu5JVNH.js} +1 -1
  131. package/dist/components/p-xYCbKFih.js +1 -0
  132. package/dist/esm/{index-BbOHefEf.js → index-D9HaikfQ.js} +36 -9
  133. package/dist/esm/index.js +1 -1
  134. package/dist/esm/kritzel-active-users_42.entry.js +333 -177
  135. package/dist/esm/kritzel-brush-style.entry.js +1 -1
  136. package/dist/esm/loader.js +3 -3
  137. package/dist/esm/stencil.js +4 -4
  138. package/dist/esm/{workspace.migrations-NhRgr2_H.js → workspace.migrations-OzSSw5kt.js} +244 -197
  139. package/dist/stencil/index.esm.js +1 -1
  140. package/dist/stencil/p-D9HaikfQ.js +2 -0
  141. package/dist/stencil/p-OzSSw5kt.js +1 -0
  142. package/dist/stencil/{p-98238bf9.entry.js → p-b0be4da1.entry.js} +1 -1
  143. package/dist/stencil/p-f7be06a8.entry.js +9 -0
  144. package/dist/stencil/stencil.esm.js +1 -1
  145. package/dist/types/classes/core/store.class.d.ts +23 -0
  146. package/dist/types/classes/objects/shape.class.d.ts +1 -0
  147. package/dist/types/classes/objects/text.class.d.ts +1 -0
  148. package/dist/types/classes/providers/hocuspocus-sync-provider.class.d.ts +1 -1
  149. package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +7 -5
  150. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +10 -4
  151. package/dist/types/components.d.ts +35 -13
  152. package/dist/types/constants/version.d.ts +1 -1
  153. package/dist/types/helpers/tool-config.helper.d.ts +1 -1
  154. package/dist/types/interfaces/engine-state.interface.d.ts +10 -10
  155. package/package.json +1 -1
  156. package/dist/components/p-Ban3OlgZ.js +0 -9
  157. package/dist/components/p-CGGiwvWZ.js +0 -1
  158. package/dist/components/p-CHY71o5B.js +0 -1
  159. package/dist/components/p-DXpYcAnT.js +0 -1
  160. package/dist/components/p-pGzF7PUB.js +0 -1
  161. package/dist/stencil/p-4a4b38e4.entry.js +0 -9
  162. package/dist/stencil/p-BbOHefEf.js +0 -2
  163. package/dist/stencil/p-NhRgr2_H.js +0 -1
@@ -69,8 +69,8 @@ export class KritzelLineTool extends KritzelBaseTool {
69
69
  });
70
70
  line.isCompleted = false;
71
71
  this._currentLineId = line.id;
72
- this._core.store.state.objects.insert(line);
73
- this._core.store.state.objects?.setActiveDrawingObject(line.id);
72
+ this._core.store.objects.insert(line);
73
+ this._core.store.objects?.setActiveDrawingObject(line.id);
74
74
  }
75
75
  }
76
76
  if (event.pointerType === 'touch' || event.pointerType === 'pen') {
@@ -99,8 +99,8 @@ export class KritzelLineTool extends KritzelBaseTool {
99
99
  });
100
100
  line.isCompleted = false;
101
101
  this._currentLineId = line.id;
102
- this._core.store.state.objects.insert(line);
103
- this._core.store.state.objects?.setActiveDrawingObject(line.id);
102
+ this._core.store.objects.insert(line);
103
+ this._core.store.objects?.setActiveDrawingObject(line.id);
104
104
  }
105
105
  }
106
106
  }
@@ -116,7 +116,7 @@ export class KritzelLineTool extends KritzelBaseTool {
116
116
  }
117
117
  if (event.pointerType === 'mouse') {
118
118
  if (this._core.store.state.isDrawing && this._currentLineId) {
119
- const currentLine = this._core.store.state.objects.findById(this._currentLineId);
119
+ const currentLine = this._core.store.objects.findById(this._currentLineId);
120
120
  if (currentLine) {
121
121
  const viewportScale = this._core.store.state.scale;
122
122
  const lockScale = this._core.store.state.lockDrawingScale;
@@ -140,14 +140,14 @@ export class KritzelLineTool extends KritzelBaseTool {
140
140
  updatedLine.workspaceId = currentLine.workspaceId;
141
141
  updatedLine.zIndex = currentLine.zIndex;
142
142
  updatedLine.isCompleted = false;
143
- this._core.store.state.objects.update(updatedLine);
143
+ this._core.store.objects.update(updatedLine);
144
144
  }
145
145
  }
146
146
  }
147
147
  if (event.pointerType === 'touch' || event.pointerType === 'pen') {
148
148
  const activePointers = Array.from(this._core.store.state.pointers.values());
149
149
  if (activePointers.length === 1 && this._currentLineId) {
150
- const currentLine = this._core.store.state.objects.findById(this._currentLineId);
150
+ const currentLine = this._core.store.objects.findById(this._currentLineId);
151
151
  if (currentLine) {
152
152
  const viewportScale = this._core.store.state.scale;
153
153
  const lockScale = this._core.store.state.lockDrawingScale;
@@ -171,7 +171,7 @@ export class KritzelLineTool extends KritzelBaseTool {
171
171
  updatedLine.workspaceId = currentLine.workspaceId;
172
172
  updatedLine.zIndex = currentLine.zIndex;
173
173
  updatedLine.isCompleted = false;
174
- this._core.store.state.objects.update(updatedLine);
174
+ this._core.store.objects.update(updatedLine);
175
175
  }
176
176
  }
177
177
  }
@@ -190,16 +190,16 @@ export class KritzelLineTool extends KritzelBaseTool {
190
190
  if (this._core.store.state.isDrawing) {
191
191
  this._core.store.state.isDrawing = false;
192
192
  if (this._currentLineId) {
193
- const currentLine = this._core.store.state.objects.findById(this._currentLineId);
193
+ const currentLine = this._core.store.objects.findById(this._currentLineId);
194
194
  if (currentLine) {
195
195
  currentLine.isCompleted = true;
196
- this._core.store.state.objects.update(currentLine);
196
+ this._core.store.objects.update(currentLine);
197
197
  this._core.engine.emitObjectsChange();
198
198
  this._core.engine.emitObjectsAdded([currentLine]);
199
199
  // Switch to selection tool and select the drawn line
200
200
  this.selectLineAndSwitchTool(currentLine);
201
201
  }
202
- this._core.store.state.objects?.setActiveDrawingObject(null);
202
+ this._core.store.objects?.setActiveDrawingObject(null);
203
203
  this._currentLineId = null;
204
204
  }
205
205
  }
@@ -208,16 +208,16 @@ export class KritzelLineTool extends KritzelBaseTool {
208
208
  if (this._core.store.state.isDrawing) {
209
209
  this._core.store.state.isDrawing = false;
210
210
  if (this._currentLineId) {
211
- const currentLine = this._core.store.state.objects.findById(this._currentLineId);
211
+ const currentLine = this._core.store.objects.findById(this._currentLineId);
212
212
  if (currentLine) {
213
213
  currentLine.isCompleted = true;
214
- this._core.store.state.objects.update(currentLine);
214
+ this._core.store.objects.update(currentLine);
215
215
  this._core.engine.emitObjectsChange();
216
216
  this._core.engine.emitObjectsAdded([currentLine]);
217
217
  // Switch to selection tool and select the drawn line
218
218
  this.selectLineAndSwitchTool(currentLine);
219
219
  }
220
- this._core.store.state.objects?.setActiveDrawingObject(null);
220
+ this._core.store.objects?.setActiveDrawingObject(null);
221
221
  this._currentLineId = null;
222
222
  }
223
223
  }
@@ -234,7 +234,7 @@ export class KritzelSelectionTool extends KritzelBaseTool {
234
234
  const objects = this.flattenObjects(this.getSelectedObjects());
235
235
  for (const obj of objects) {
236
236
  if (obj instanceof KritzelLine)
237
- return obj.arrows;
237
+ return obj.arrows ?? { start: { enabled: false }, end: { enabled: false } };
238
238
  }
239
239
  return { start: { enabled: false }, end: { enabled: false } };
240
240
  }
@@ -476,7 +476,7 @@ export class KritzelSelectionTool extends KritzelBaseTool {
476
476
  getSelectedObject(event) {
477
477
  const path = event.composedPath().slice(1);
478
478
  const objectElement = path.find(element => element.classList && element.classList.contains('object'));
479
- const object = this._core.findObjectById(objectElement?.id);
479
+ const object = objectElement?.id ? this._core.findObjectById(objectElement.id) : null;
480
480
  if (!object) {
481
481
  return null;
482
482
  }
@@ -178,8 +178,8 @@ export class KritzelShapeTool extends KritzelBaseTool {
178
178
  fontFamily: this.fontFamily,
179
179
  scale: lockScale ? 1 : viewportScale,
180
180
  });
181
- this._core.store.state.objects.insert(this.currentShape);
182
- this._core.store.state.objects?.setActiveDrawingObject(this.currentShape.id);
181
+ this._core.store.objects.insert(this.currentShape);
182
+ this._core.store.objects?.setActiveDrawingObject(this.currentShape.id);
183
183
  this._core.rerender();
184
184
  }
185
185
  /**
@@ -213,7 +213,7 @@ export class KritzelShapeTool extends KritzelBaseTool {
213
213
  this.currentShape.translateX = -this._core.store.state.translateX / divider;
214
214
  this.currentShape.translateY = -this._core.store.state.translateY / divider;
215
215
  this.currentShape.updateDimensions();
216
- this._core.store.state.objects.update(this.currentShape);
216
+ this._core.store.objects.update(this.currentShape);
217
217
  }
218
218
  /**
219
219
  * Completes the shape drawing process.
@@ -229,18 +229,18 @@ export class KritzelShapeTool extends KritzelBaseTool {
229
229
  // Compare in screen space
230
230
  if (this.currentShape.width < 10 && this.currentShape.height < 10) {
231
231
  const shapeId = this.currentShape.id;
232
- this._core.store.state.objects.remove(o => o.id === shapeId);
232
+ this._core.store.objects.remove(o => o.id === shapeId);
233
233
  }
234
234
  else {
235
235
  this.currentShape.zIndex = this._core.store.currentZIndex;
236
- this._core.store.state.objects.update(this.currentShape);
236
+ this._core.store.objects.update(this.currentShape);
237
237
  this._core.engine.emitObjectsChange();
238
238
  this._core.engine.emitObjectsAdded([this.currentShape]);
239
239
  this._core.selectObjects([this.currentShape]);
240
240
  this._core.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
241
241
  }
242
242
  this.isDrawing = false;
243
- this._core.store.state.objects?.setActiveDrawingObject(null);
243
+ this._core.store.objects?.setActiveDrawingObject(null);
244
244
  this.currentShape = null;
245
245
  this._core.rerender();
246
246
  }
@@ -71,7 +71,7 @@ export class KritzelTextTool extends KritzelBaseTool {
71
71
  text.translateX = (clientX - this._core.store.state.translateX) / viewportScale;
72
72
  text.translateY = (clientY - this._core.store.state.translateY) / viewportScale;
73
73
  text.zIndex = this._core.store.currentZIndex;
74
- this._core.store.state.objects.insert(text);
74
+ this._core.store.objects.insert(text);
75
75
  this._core.rerender();
76
76
  text.edit(event);
77
77
  }
@@ -108,7 +108,7 @@ export class KritzelTextTool extends KritzelBaseTool {
108
108
  text.translateX = (clientX - this._core.store.state.translateX) / viewportScale;
109
109
  text.translateY = (clientY - this._core.store.state.translateY) / viewportScale;
110
110
  text.zIndex = this._core.store.currentZIndex;
111
- this._core.store.state.objects.insert(text);
111
+ this._core.store.objects.insert(text);
112
112
  this._core.rerender();
113
113
  text.edit(event);
114
114
  }
@@ -47,7 +47,7 @@
47
47
  "mixins": [],
48
48
  "compiler": {
49
49
  "name": "@stencil/core",
50
- "version": "4.43.3",
50
+ "version": "4.43.4",
51
51
  "typescriptVersion": "5.8.3"
52
52
  },
53
53
  "collections": [],
@@ -13,10 +13,10 @@ export class KritzelAwarenessCursors {
13
13
  cleanupIntervalId;
14
14
  objectChangeRafId = null;
15
15
  componentDidLoad() {
16
- this.core.store.state.objects?.onAwarenessChange(states => {
16
+ this.core.store.objects?.onAwarenessChange(states => {
17
17
  this.handleAwarenessChange(states);
18
18
  });
19
- this.core.store.state.objects?.onObjectsChange(() => {
19
+ this.core.store.objects?.onObjectsChange(() => {
20
20
  this.handleRemoteObjectChange();
21
21
  });
22
22
  this.cleanupIntervalId = setInterval(() => {
@@ -32,7 +32,7 @@ export class KritzelAwarenessCursors {
32
32
  }
33
33
  }
34
34
  handleAwarenessChange(states) {
35
- const localClientId = this.core.store.state.objects?.localClientId;
35
+ const localClientId = this.core.store.objects?.localClientId;
36
36
  const now = Date.now();
37
37
  const updated = new Map(this.remoteCursors);
38
38
  // Track which clientIds are still present
@@ -108,7 +108,7 @@ export class KritzelAwarenessCursors {
108
108
  });
109
109
  }
110
110
  getActiveObjectTip(objectId) {
111
- const obj = this.core.store.state.objects?.findById(objectId);
111
+ const obj = this.core.store.objects?.findById(objectId);
112
112
  if (!obj)
113
113
  return null;
114
114
  if (obj instanceof KritzelPath && !obj.isCompleted) {
@@ -185,7 +185,7 @@ export class KritzelAwarenessCursors {
185
185
  void _ty;
186
186
  void this.objectVersion;
187
187
  const cursors = Array.from(this.remoteCursors.values());
188
- return (h(Host, { key: '5a28def6e024249c4309c087502cde9f219f5421' }, cursors.map(remoteCursor => {
188
+ return (h(Host, { key: '1743084eadda932b5aaf89552f500b90e194a79f' }, cursors.map(remoteCursor => {
189
189
  if (!remoteCursor.cursor)
190
190
  return null;
191
191
  // When a remote user is actively drawing, derive cursor position from
@@ -295,7 +295,7 @@ export class KritzelAwarenessCursors {
295
295
  }
296
296
  }
297
297
  },
298
- "required": false,
298
+ "required": true,
299
299
  "optional": false,
300
300
  "docs": {
301
301
  "tags": [],
@@ -63,7 +63,7 @@ export class KritzelCursorTrail {
63
63
  }
64
64
  }
65
65
  render() {
66
- return (h(Host, { key: 'b6a9e84ce49dd72f353e0b87ae0bc02b0e5aeb1e' }, this.cursorTrailPoints.length > 1 && (h("svg", { key: '238ea314a937d556c75ae080495c2e6559340c6f', class: "cursor-trail-svg", xmlns: "http://www.w3.org/2000/svg", style: {
66
+ return (h(Host, { key: 'b0f5c795c4803e27a49d7f76f3fedea818967049' }, this.cursorTrailPoints.length > 1 && (h("svg", { key: '6ff883be1aecfb302bc9ecb3b7562617d753d5ba', class: "cursor-trail-svg", xmlns: "http://www.w3.org/2000/svg", style: {
67
67
  position: 'absolute',
68
68
  left: '0',
69
69
  top: '0',
@@ -112,7 +112,7 @@ export class KritzelCursorTrail {
112
112
  }
113
113
  }
114
114
  },
115
- "required": false,
115
+ "required": true,
116
116
  "optional": false,
117
117
  "docs": {
118
118
  "tags": [],
@@ -193,6 +193,8 @@ export class KritzelEditor {
193
193
  }
194
194
  ]
195
195
  };
196
+ /** Whether the editor is in a loading state. When true, a loading overlay is displayed. */
197
+ isLoading = false;
196
198
  /** Optional unique identifier for namespacing storage keys across multiple editor instances. */
197
199
  editorId;
198
200
  /** Optional workspace ID to set as active. If provided, the editor will automatically activate the workspace with this ID. */
@@ -232,9 +234,10 @@ export class KritzelEditor {
232
234
  }
233
235
  }
234
236
  onWorkspacesChange(newWorkspaces) {
235
- if (this.activeWorkspace) {
236
- const updatedActiveWorkspace = newWorkspaces.find(ws => ws.id === this.activeWorkspace.id);
237
- if (updatedActiveWorkspace && updatedActiveWorkspace !== this.activeWorkspace) {
237
+ const activeWorkspace = this.activeWorkspace;
238
+ if (activeWorkspace) {
239
+ const updatedActiveWorkspace = newWorkspaces.find(ws => ws.id === activeWorkspace.id);
240
+ if (updatedActiveWorkspace && updatedActiveWorkspace !== activeWorkspace) {
238
241
  this.activeWorkspace = updatedActiveWorkspace;
239
242
  }
240
243
  }
@@ -461,7 +464,7 @@ export class KritzelEditor {
461
464
  await customElements.whenDefined('kritzel-workspace-manager');
462
465
  await customElements.whenDefined('kritzel-controls');
463
466
  await customElements.whenDefined('kritzel-engine');
464
- if (!this.isEngineReady || !this.isControlsReady || !this.isWorkspaceManagerReady) {
467
+ if (!this.isEngineReady || !this.isControlsReady || !this.isWorkspaceManagerReady || !this.activeWorkspace) {
465
468
  return;
466
469
  }
467
470
  const { id, name, isPublic, createdAt, updatedAt } = this.activeWorkspace;
@@ -480,6 +483,9 @@ export class KritzelEditor {
480
483
  }
481
484
  async onEngineReady(event) {
482
485
  this.isEngineReady = true;
486
+ if (!event.detail.activeWorkspace) {
487
+ return;
488
+ }
483
489
  this.activeWorkspace = event.detail.activeWorkspace;
484
490
  this.workspaces = event.detail.workspaces;
485
491
  this.currentIsPublic = await this.engineRef.getIsPublic();
@@ -562,7 +568,7 @@ export class KritzelEditor {
562
568
  icon: 'upload',
563
569
  action: async () => {
564
570
  const preview = await this.engineRef.getScreenshot('png');
565
- this.exportRef.open(preview);
571
+ this.exportRef.open(preview ?? undefined);
566
572
  },
567
573
  },
568
574
  {
@@ -593,7 +599,7 @@ export class KritzelEditor {
593
599
  activeWorkspace.isPublic = isPublic;
594
600
  await this.engineRef.updateWorkspace(activeWorkspace);
595
601
  this.activeWorkspace = activeWorkspace.clone();
596
- this.isPublicChange.emit({ isPublic, workspaceId: this.activeWorkspace?.id });
602
+ this.isPublicChange.emit({ isPublic, workspaceId: activeWorkspace.id });
597
603
  };
598
604
  /**
599
605
  * Updates the currentIsPublic state from the active workspace and emits the isPublicChange event.
@@ -602,6 +608,9 @@ export class KritzelEditor {
602
608
  const isPublic = this.activeWorkspace?.isPublic ?? false;
603
609
  const workspaceId = this.activeWorkspace?.id;
604
610
  this.currentIsPublic = isPublic;
611
+ if (!workspaceId) {
612
+ return;
613
+ }
605
614
  this.isPublicChange.emit({ isPublic, workspaceId });
606
615
  }
607
616
  handleProviderLogin = (event) => {
@@ -706,7 +715,31 @@ export class KritzelEditor {
706
715
  const isLoggedIn = this.isLoggedIn;
707
716
  const shouldShowCurrentUser = isLoggedIn;
708
717
  const shouldShowLoginButton = !!this.loginConfig && !isLoggedIn;
709
- return (h(Host, { key: '6dbc3a8c64dd097ba82e46341b3fb97cbd0194db' }, h("div", { key: '26ceb62f59ad830fd651a1712f57e5d711e7c6f4', class: "top-left-buttons" }, h("kritzel-workspace-manager", { key: 'afb4f5b87c5dc0a673444fb27930e43994df4e02', workspaces: this.workspaces, activeWorkspace: this.activeWorkspace, onWorkspaceChange: event => (this.activeWorkspace = event.detail), onIsWorkspaceManagerReady: () => (this.isWorkspaceManagerReady = true) }), h("kritzel-back-to-content", { key: 'f3c0f31841cb819917c3277852bc9b5ce291c09a', visible: this.isBackToContentButtonVisible, onBackToContent: () => this.backToContent() })), h("kritzel-engine", { key: '8a9e57132e6b74ec812ee516dc7f0d5fc6c8a2e1', ref: el => (this.engineRef = el), workspace: this.activeWorkspace, activeWorkspaceId: this.activeWorkspaceId, editorId: this.editorId, syncConfig: this.syncConfig, user: this.user, scaleMax: this.scaleMax, lockDrawingScale: this.lockDrawingScale, scaleMin: this.scaleMin, viewportBoundaryLeft: this.viewportBoundaryLeft, viewportBoundaryRight: this.viewportBoundaryRight, viewportBoundaryTop: this.viewportBoundaryTop, viewportBoundaryBottom: this.viewportBoundaryBottom, wheelEnabled: this.wheelEnabled, theme: this.currentTheme, debugInfo: this.debugInfo, globalContextMenuItems: this.globalContextMenuItems, objectContextMenuItems: this.objectContextMenuItems, onIsEngineReady: event => this.onEngineReady(event), onWorkspacesChange: event => this.handleWorkspacesChange(event), onActiveWorkspaceChange: event => this.handleActiveWorkspaceChange(event), onObjectsChange: event => this.handleObjectsChange(event), onObjectsAdded: event => this.handleObjectsAdded(event), onObjectsRemoved: event => this.handleObjectsRemoved(event), onObjectsUpdated: event => this.handleObjectsUpdated(event), onUndoStateChange: event => this.handleUndoStateChange(event), onObjectsInViewportChange: event => this.handleObjectsInViewportChange(event), onViewportChange: event => this.handleViewportChange(event), onAwarenessChange: event => this.handleAwarenessChange(event) }), h("kritzel-controls", { key: '6caadf512a0208fecdb18b6d68b17daa522161a3', class: { 'keyboard-open': this.isVirtualKeyboardOpen }, style: { display: this.isControlsVisible ? 'flex' : 'none' }, ref: el => (this.controlsRef = el), controls: this.controls, isUtilityPanelVisible: this.isUtilityPanelVisible, undoState: this.undoState, theme: this.currentTheme, onIsControlsReady: () => (this.isControlsReady = true) }), h("div", { key: 'e27e5f3965be2fd15c83b91470ef87c4031dd7a2', class: "top-right-buttons" }, h("kritzel-settings", { key: '57f8e75287402aecbb7740d46dfa15839de2169f', ref: el => (this.settingsRef = el), shortcuts: this.shortcuts, editorId: this.editorId, onSettingsChange: event => this.handleSettingsChange(event) }), h("kritzel-export", { key: '5ccf176d4fe1221c5d7597bd1c8537cf3324d3ee', ref: el => (this.exportRef = el), workspaceName: this.activeWorkspace?.name || 'workspace', onExportPng: () => this.engineRef.exportViewportAsPng(), onExportSvg: () => this.engineRef.exportViewportAsSvg(), onExportJson: event => this.engineRef.downloadAsJson(event.detail) }), h("kritzel-active-users", { key: '44a334b808706e11163e89b91074ca4ea8ab4b18', users: this.activeUsers }), shouldShowCurrentUser && h("kritzel-current-user", { key: 'bcb3c966e630b1a8fc4ccd438fc8fbb11cd2b167', user: this.user }), shouldShowLoginButton && h("kritzel-button", { key: 'f1957e56257b7c565311e41b770579f7e2bb910d', onButtonClick: () => this.loginDialogRef?.open() }, "Sign in"), h("kritzel-more-menu", { key: 'd8c1d1b51cf87725d68aaf4457b88828986a40dc', items: this.moreMenuItems }), h("kritzel-share-dialog", { key: 'f5840e7f56cf6897ec28b0f28d9b204037bf3348', ref: el => (this.shareDialogRef = el), isPublic: this.currentIsPublic, workspaceId: this.activeWorkspace?.id, onToggleIsPublic: this.handleToggleIsPublic }), this.loginConfig && (h("kritzel-login-dialog", { key: 'cfdcc3d5e7a5e29b0a352f0d4423ae79195dbf69', ref: el => (this.loginDialogRef = el), providers: this.loginConfig.providers, dialogTitle: this.loginConfig.title, subtitle: this.loginConfig.subtitle, onProviderLogin: this.handleProviderLogin })))));
718
+ return (h(Host, { key: '1e3c220506d14f276ca246365c2bda79110c6c35' }, h("div", { key: '154b45141b995f749adb52a11dc3363ab2989475', class: "top-left-buttons" }, h("kritzel-workspace-manager", { key: '22519269ea7227a1a7a05d2f282bbcd2466edf5d', workspaces: this.workspaces, activeWorkspace: this.activeWorkspace, onWorkspaceChange: event => (this.activeWorkspace = event.detail), onIsWorkspaceManagerReady: () => (this.isWorkspaceManagerReady = true) }), h("kritzel-back-to-content", { key: 'e89f0609dfd031cb040fd80a1f60ecb56d56734c', visible: this.isBackToContentButtonVisible, onBackToContent: () => this.backToContent() })), h("kritzel-engine", { key: '0b3acdf827d48c9589fb8170b49a602beb273684', ref: el => {
719
+ if (el) {
720
+ this.engineRef = el;
721
+ }
722
+ }, workspace: this.activeWorkspace, activeWorkspaceId: this.activeWorkspaceId, editorId: this.editorId, syncConfig: this.syncConfig, user: this.user, scaleMax: this.scaleMax, lockDrawingScale: this.lockDrawingScale, scaleMin: this.scaleMin, isLoading: this.isLoading, viewportBoundaryLeft: this.viewportBoundaryLeft, viewportBoundaryRight: this.viewportBoundaryRight, viewportBoundaryTop: this.viewportBoundaryTop, viewportBoundaryBottom: this.viewportBoundaryBottom, wheelEnabled: this.wheelEnabled, theme: this.currentTheme, debugInfo: this.debugInfo, globalContextMenuItems: this.globalContextMenuItems, objectContextMenuItems: this.objectContextMenuItems, onIsEngineReady: event => this.onEngineReady(event), onWorkspacesChange: event => this.handleWorkspacesChange(event), onActiveWorkspaceChange: event => this.handleActiveWorkspaceChange(event), onObjectsChange: event => this.handleObjectsChange(event), onObjectsAdded: event => this.handleObjectsAdded(event), onObjectsRemoved: event => this.handleObjectsRemoved(event), onObjectsUpdated: event => this.handleObjectsUpdated(event), onUndoStateChange: event => this.handleUndoStateChange(event), onObjectsInViewportChange: event => this.handleObjectsInViewportChange(event), onViewportChange: event => this.handleViewportChange(event), onAwarenessChange: event => this.handleAwarenessChange(event) }), h("kritzel-controls", { key: '324ba00f982938abc7a3f4dc47368f3b9bad665e', class: { 'keyboard-open': this.isVirtualKeyboardOpen }, style: { display: this.isControlsVisible ? 'flex' : 'none' }, ref: el => {
723
+ if (el) {
724
+ this.controlsRef = el;
725
+ }
726
+ }, controls: this.controls, isUtilityPanelVisible: this.isUtilityPanelVisible, undoState: this.undoState ?? undefined, theme: this.currentTheme, onIsControlsReady: () => (this.isControlsReady = true) }), h("div", { key: '0c4662e92cbe90a958f8704e6db0375915d9c634', class: "top-right-buttons" }, h("kritzel-settings", { key: 'e0422c1a02bc895bafd4b777d4d593afcfdf335b', ref: el => {
727
+ if (el) {
728
+ this.settingsRef = el;
729
+ }
730
+ }, shortcuts: this.shortcuts, editorId: this.editorId, onSettingsChange: event => this.handleSettingsChange(event) }), h("kritzel-export", { key: '72f59ec2eab76d753bb64475f199f0fa33e935d4', ref: el => {
731
+ if (el) {
732
+ this.exportRef = el;
733
+ }
734
+ }, workspaceName: this.activeWorkspace?.name || 'workspace', onExportPng: () => this.engineRef.exportViewportAsPng(), onExportSvg: () => this.engineRef.exportViewportAsSvg(), onExportJson: event => this.engineRef.downloadAsJson(event.detail) }), h("kritzel-active-users", { key: 'c60411370947fc408b5e9d7adade3e28210b8d47', users: this.activeUsers }), shouldShowCurrentUser && h("kritzel-current-user", { key: '4783940d3d4f9c2a7e8156c0713f29cb8b043125', user: this.user }), shouldShowLoginButton && h("kritzel-button", { key: 'bdb727d5641f8cda3711856086e1b9aa8533a5a6', onButtonClick: () => this.loginDialogRef?.open() }, "Sign in"), h("kritzel-more-menu", { key: '3afa57ea46636c92cc7232dfe22a27cace85766e', items: this.moreMenuItems }), h("kritzel-share-dialog", { key: '852f9980fa3b89ceb5b6d8bde1bdd5598d3dc6e4', ref: el => {
735
+ if (el) {
736
+ this.shareDialogRef = el;
737
+ }
738
+ }, isPublic: this.currentIsPublic, workspaceId: this.activeWorkspace?.id, onToggleIsPublic: this.handleToggleIsPublic }), this.loginConfig && (h("kritzel-login-dialog", { key: 'cdccbb7ef0b9932c0747545a18071f22e5683d8c', ref: el => {
739
+ if (el) {
740
+ this.loginDialogRef = el;
741
+ }
742
+ }, providers: this.loginConfig.providers, dialogTitle: this.loginConfig.title, subtitle: this.loginConfig.subtitle, onProviderLogin: this.handleProviderLogin })))));
710
743
  }
711
744
  static get is() { return "kritzel-editor"; }
712
745
  static get originalStyleUrls() {
@@ -1142,6 +1175,26 @@ export class KritzelEditor {
1142
1175
  "setter": false,
1143
1176
  "defaultValue": "{\r\n providers: [\r\n {\r\n label: 'Sign in with Google',\r\n icon: 'google',\r\n name: 'Google',\r\n }\r\n ]\r\n }"
1144
1177
  },
1178
+ "isLoading": {
1179
+ "type": "boolean",
1180
+ "mutable": false,
1181
+ "complexType": {
1182
+ "original": "boolean",
1183
+ "resolved": "boolean",
1184
+ "references": {}
1185
+ },
1186
+ "required": false,
1187
+ "optional": false,
1188
+ "docs": {
1189
+ "tags": [],
1190
+ "text": "Whether the editor is in a loading state. When true, a loading overlay is displayed."
1191
+ },
1192
+ "getter": false,
1193
+ "setter": false,
1194
+ "reflect": false,
1195
+ "attribute": "is-loading",
1196
+ "defaultValue": "false"
1197
+ },
1145
1198
  "editorId": {
1146
1199
  "type": "string",
1147
1200
  "mutable": false,
@@ -2103,7 +2156,7 @@ export class KritzelEditor {
2103
2156
  },
2104
2157
  "registerTool": {
2105
2158
  "complexType": {
2106
- "signature": "(toolName: string, toolClass: any, toolConfig?: KritzelTextToolConfig | KritzelBrushToolConfig | KritzelLineToolConfig | KritzelShapeToolConfig) => Promise<KritzelBaseTool>",
2159
+ "signature": "(toolName: string, toolClass: any, toolConfig?: KritzelTextToolConfig | KritzelBrushToolConfig | KritzelLineToolConfig | KritzelShapeToolConfig) => Promise<KritzelBaseTool | null>",
2107
2160
  "parameters": [{
2108
2161
  "name": "toolName",
2109
2162
  "type": "string",
@@ -2485,7 +2538,7 @@ export class KritzelEditor {
2485
2538
  },
2486
2539
  "getScreenshot": {
2487
2540
  "complexType": {
2488
- "signature": "(format?: \"png\" | \"svg\") => Promise<string>",
2541
+ "signature": "(format?: \"png\" | \"svg\") => Promise<string | null>",
2489
2542
  "parameters": [{
2490
2543
  "name": "format",
2491
2544
  "type": "\"svg\" | \"png\"",
@@ -2643,10 +2696,10 @@ export class KritzelEditor {
2643
2696
  },
2644
2697
  "findObjects": {
2645
2698
  "complexType": {
2646
- "signature": "<T extends KritzelBaseObject>(predicate: (obj: KritzelBaseObject) => boolean) => Promise<T[]>",
2699
+ "signature": "<T extends KritzelBaseObject>(predicate: (obj: KritzelBaseObject<Element>) => boolean) => Promise<T[]>",
2647
2700
  "parameters": [{
2648
2701
  "name": "predicate",
2649
- "type": "(obj: KritzelBaseObject<HTMLElement | SVGElement>) => boolean",
2702
+ "type": "(obj: KritzelBaseObject<Element>) => boolean",
2650
2703
  "docs": ""
2651
2704
  }],
2652
2705
  "references": {
@@ -2663,6 +2716,12 @@ export class KritzelEditor {
2663
2716
  "path": "../../../classes/objects/base-object.class",
2664
2717
  "id": "src/classes/objects/base-object.class.ts::KritzelBaseObject",
2665
2718
  "referenceLocation": "KritzelBaseObject"
2719
+ },
2720
+ "Element": {
2721
+ "location": "import",
2722
+ "path": "@stencil/core",
2723
+ "id": "../../node_modules/@stencil/core/internal/stencil-core/index.d.ts::Element",
2724
+ "referenceLocation": "Element"
2666
2725
  }
2667
2726
  },
2668
2727
  "return": "Promise<T[]>"
@@ -29,14 +29,34 @@ p, h1, h2, h3, h4, h5, h6, blockquote, pre {
29
29
  display: flex;
30
30
  align-items: center;
31
31
  justify-content: center;
32
+ gap: 10px;
32
33
  background-color: var(--kritzel-loading-overlay-background, rgba(255, 255, 255, 0.6));
33
34
  color: var(--kritzel-loading-overlay-color, #333);
35
+ font-family: var(--kritzel-font-family, sans-serif);
34
36
  font-size: 1.25rem;
35
37
  pointer-events: all;
36
- animation: workspace-loading-fade-in var(--kritzel-loading-overlay-delay, 300ms) ease-out forwards;
38
+ animation: workspace-loading-fade-in 200ms ease-out var(--kritzel-loading-overlay-delay, 300ms) forwards;
37
39
  opacity: 0;
38
40
  }
39
41
 
42
+ .workspace-loading-spinner {
43
+ width: 20px;
44
+ height: 20px;
45
+ box-sizing: border-box;
46
+ display: block;
47
+ flex-shrink: 0;
48
+ border: 2px solid var(--kritzel-loading-overlay-spinner-color, #cccccc);
49
+ border-top-color: var(--kritzel-loading-overlay-spinner-active-color, #333333);
50
+ border-radius: 50%;
51
+ animation: workspace-loading-spin 0.6s linear infinite;
52
+ }
53
+
54
+ @keyframes workspace-loading-spin {
55
+ to {
56
+ transform: rotate(360deg);
57
+ }
58
+ }
59
+
40
60
  @keyframes workspace-loading-fade-in {
41
61
  to {
42
62
  opacity: 1;