kritzel-stencil 0.1.1 → 0.1.3
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.
- package/dist/cjs/{default-line-tool.config-SdMGkNhv.js → default-line-tool.config-MA02HCrH.js} +635 -118
- package/dist/cjs/{index-BeKMS-Zt.js → index-Bj0n7fQQ.js} +84 -7
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-brush-style.cjs.entry.js +1 -1
- package/dist/cjs/{kritzel-color_22.cjs.entry.js → kritzel-color_24.cjs.entry.js} +832 -771
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/stencil.cjs.js +3 -3
- package/dist/collection/classes/core/core.class.js +2 -0
- package/dist/collection/classes/objects/line.class.js +1 -0
- package/dist/collection/classes/objects/path.class.js +1 -0
- package/dist/collection/classes/objects/shape.class.js +1 -0
- package/dist/collection/classes/objects/text.class.js +4 -3
- package/dist/collection/classes/providers/indexeddb-sync-provider.class.js +0 -1
- package/dist/collection/classes/tools/brush-tool.class.js +5 -0
- package/dist/collection/classes/tools/line-tool.class.js +31 -1
- package/dist/collection/classes/tools/selection-tool.class.js +193 -0
- package/dist/collection/classes/tools/shape-tool.class.js +2 -0
- package/dist/collection/classes/tools/text-tool.class.js +3 -0
- package/dist/collection/collection-manifest.json +5 -3
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +3 -2
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +37 -19
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +108 -36
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js +2 -2
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.css +1 -1
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +24 -2
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js +1 -1
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.css +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.css +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +1 -1
- package/dist/collection/components/shared/kritzel-line-endings/kritzel-line-endings.css +60 -0
- package/dist/collection/components/shared/kritzel-line-endings/kritzel-line-endings.js +187 -0
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +15 -8
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +16 -9
- package/dist/collection/components/shared/kritzel-opacity-slider/kritzel-opacity-slider.css +85 -0
- package/dist/collection/components/shared/kritzel-opacity-slider/kritzel-opacity-slider.js +163 -0
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +1 -1
- package/dist/collection/components/shared/kritzel-shape-fill/kritzel-shape-fill.css +47 -0
- package/dist/collection/components/shared/kritzel-shape-fill/kritzel-shape-fill.js +93 -0
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +13 -7
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.css +11 -2
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +2 -2
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.css +1 -1
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +6 -4
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +6 -3
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +4 -4
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +95 -14
- package/dist/collection/components/ui/kritzel-tool-config/kritzel-tool-config.css +38 -0
- package/dist/collection/components/ui/kritzel-tool-config/kritzel-tool-config.js +321 -0
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +3 -2
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js +6 -3
- package/dist/collection/configs/default-brush-tool.config.js +2 -52
- package/dist/collection/configs/default-line-tool.config.js +2 -26
- package/dist/collection/configs/default-shape-tool.config.js +2 -15
- package/dist/collection/configs/default-text-tool.config.js +2 -26
- package/dist/collection/constants/color-palette.constants.js +30 -0
- package/dist/collection/helpers/color.helper.js +31 -0
- package/dist/collection/helpers/tool-config.helper.js +65 -0
- package/dist/collection/interfaces/tool-config.interface.js +1 -0
- package/dist/components/index.d.ts +8 -4
- package/dist/components/index.js +1 -1
- package/dist/components/kritzel-brush-style.js +1 -1
- package/dist/components/kritzel-color-palette.js +1 -1
- package/dist/components/kritzel-color.js +1 -1
- package/dist/components/kritzel-context-menu.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-cursor-trail.js +1 -1
- package/dist/components/kritzel-dropdown.js +1 -1
- package/dist/components/kritzel-editor.js +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-font-family.js +1 -1
- package/dist/components/kritzel-font-size.js +1 -1
- package/dist/components/kritzel-font.js +1 -1
- package/dist/components/kritzel-icon.js +1 -1
- package/dist/components/kritzel-line-endings.d.ts +11 -0
- package/dist/components/kritzel-line-endings.js +1 -0
- package/dist/components/kritzel-menu-item.js +1 -1
- package/dist/components/kritzel-menu.js +1 -1
- package/dist/components/kritzel-opacity-slider.d.ts +11 -0
- package/dist/components/kritzel-opacity-slider.js +1 -0
- package/dist/components/kritzel-portal.js +1 -1
- package/dist/components/kritzel-shape-fill.d.ts +11 -0
- package/dist/components/kritzel-shape-fill.js +1 -0
- package/dist/components/kritzel-split-button.js +1 -1
- package/dist/components/kritzel-stroke-size.js +1 -1
- package/dist/components/kritzel-tool-config.d.ts +11 -0
- package/dist/components/kritzel-tool-config.js +1 -0
- package/dist/components/kritzel-tooltip.js +1 -1
- package/dist/components/kritzel-utility-panel.js +1 -1
- package/dist/components/kritzel-workspace-manager.js +1 -1
- package/dist/components/p-83YX0-FS.js +1 -0
- package/dist/components/p-9XZbc_qK.js +1 -0
- package/dist/components/p-BVIY50lR.js +1 -0
- package/dist/components/{p-D1tfzpy8.js → p-BlUr7oVq.js} +1 -1
- package/dist/components/{p-Bj_Og27M.js → p-BxS4Pdpz.js} +1 -1
- package/dist/components/{p-g0N9j_uT.js → p-CCj8nmQH.js} +1 -1
- package/dist/components/{p-1z-ds26_.js → p-CLOnpu42.js} +1 -1
- package/dist/components/p-CNneo_RD.js +1 -0
- package/dist/components/p-CkpOndCn.js +1 -0
- package/dist/components/{p-IAqZFssU.js → p-Cnpk2hfo.js} +1 -1
- package/dist/components/{p-Cy77SpWt.js → p-Ctv4NAxk.js} +1 -1
- package/dist/components/p-CzjSdJio.js +1 -0
- package/dist/components/{p-XGgKC_Fe.js → p-DKgqzi2Y.js} +1 -1
- package/dist/components/{p-C4krHoUl.js → p-DLijNISu.js} +1 -1
- package/dist/components/p-DMJI6opm.js +1 -0
- package/dist/components/p-DOF5fWDU.js +1 -0
- package/dist/components/{p-4FEa4ADy.js → p-DV_h5Jo2.js} +1 -1
- package/dist/components/{p-DTezr6w9.js → p-DgCGSL2Q.js} +1 -1
- package/dist/components/p-DwJUC6cw.js +9 -0
- package/dist/components/p-FOxrXeq4.js +1 -0
- package/dist/components/p-S5GeUsJP.js +1 -0
- package/dist/components/{p-CXzfYQ_u.js → p-e1r5dgeP.js} +1 -1
- package/dist/components/p-pKbfOI5a.js +1 -0
- package/dist/components/{p-D5ZsALCP.js → p-wRXL928z.js} +1 -1
- package/dist/esm/{default-line-tool.config-Cw8mdDpt.js → default-line-tool.config-DLpNl6R9.js} +634 -110
- package/dist/esm/{index-BqhmuUH2.js → index-OLdaFN6W.js} +84 -7
- package/dist/esm/index.js +2 -2
- package/dist/esm/kritzel-brush-style.entry.js +1 -1
- package/dist/esm/{kritzel-color_22.entry.js → kritzel-color_24.entry.js} +821 -762
- package/dist/esm/loader.js +3 -3
- package/dist/esm/stencil.js +4 -4
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-361ebc7e.entry.js +9 -0
- package/dist/stencil/{p-09295079.entry.js → p-802bc7cf.entry.js} +1 -1
- package/dist/stencil/p-DLpNl6R9.js +1 -0
- package/dist/stencil/p-OLdaFN6W.js +2 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/objects/shape.class.d.ts +1 -0
- package/dist/types/classes/tools/brush-tool.class.d.ts +1 -0
- package/dist/types/classes/tools/line-tool.class.d.ts +2 -1
- package/dist/types/classes/tools/selection-tool.class.d.ts +22 -0
- package/dist/types/classes/tools/shape-tool.class.d.ts +1 -0
- package/dist/types/classes/tools/text-tool.class.d.ts +1 -0
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +2 -0
- package/dist/types/components/shared/kritzel-color-palette/kritzel-color-palette.d.ts +1 -0
- package/dist/types/components/shared/kritzel-line-endings/kritzel-line-endings.d.ts +23 -0
- package/dist/types/components/shared/kritzel-opacity-slider/kritzel-opacity-slider.d.ts +17 -0
- package/dist/types/components/shared/kritzel-shape-fill/kritzel-shape-fill.d.ts +10 -0
- package/dist/types/components/ui/kritzel-controls/kritzel-controls.d.ts +9 -0
- package/dist/types/components/ui/kritzel-tool-config/kritzel-tool-config.d.ts +25 -0
- package/dist/types/components.d.ts +235 -82
- package/dist/types/constants/color-palette.constants.d.ts +5 -0
- package/dist/types/helpers/color.helper.d.ts +9 -0
- package/dist/types/helpers/tool-config.helper.d.ts +4 -0
- package/dist/types/interfaces/line-options.interface.d.ts +1 -0
- package/dist/types/interfaces/path-options.interface.d.ts +1 -0
- package/dist/types/interfaces/tool-config.interface.d.ts +26 -0
- package/dist/types/stencil-public-runtime.d.ts +29 -0
- package/package.json +5 -3
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.css +0 -19
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +0 -134
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.css +0 -19
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +0 -114
- package/dist/components/kritzel-control-brush-config.d.ts +0 -11
- package/dist/components/kritzel-control-brush-config.js +0 -1
- package/dist/components/kritzel-control-text-config.d.ts +0 -11
- package/dist/components/kritzel-control-text-config.js +0 -1
- package/dist/components/p-BXaWhpO2.js +0 -1
- package/dist/components/p-BtuXeItZ.js +0 -1
- package/dist/components/p-C-d2IH4v.js +0 -1
- package/dist/components/p-C3UriJh7.js +0 -1
- package/dist/components/p-CF5L2Gdl.js +0 -1
- package/dist/components/p-CeKT_dTd.js +0 -1
- package/dist/components/p-Cp15toXH.js +0 -1
- package/dist/components/p-D4n7UbGY.js +0 -1
- package/dist/components/p-Du1vxHy8.js +0 -1
- package/dist/components/p-exWKDgI8.js +0 -9
- package/dist/stencil/p-BqhmuUH2.js +0 -2
- package/dist/stencil/p-Cw8mdDpt.js +0 -1
- package/dist/stencil/p-d21a009f.entry.js +0 -9
- package/dist/types/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.d.ts +0 -15
- package/dist/types/components/ui/kritzel-control-text-config/kritzel-control-text-config.d.ts +0 -12
package/dist/cjs/{default-line-tool.config-SdMGkNhv.js → default-line-tool.config-MA02HCrH.js}
RENAMED
|
@@ -14043,13 +14043,14 @@ class KritzelText extends KritzelBaseObject {
|
|
|
14043
14043
|
if (element === null || this.isInViewport() === false) {
|
|
14044
14044
|
return;
|
|
14045
14045
|
}
|
|
14046
|
+
element.style.fontFamily = this.fontFamily;
|
|
14047
|
+
element.style.fontSize = `${this.fontSize}pt`;
|
|
14048
|
+
element.style.color = this.fontColor;
|
|
14046
14049
|
if (this.isMounted && this.elementRef === element && this.editor.dom.parentElement === element) {
|
|
14050
|
+
requestAnimationFrame(() => this.adjustSizeOnInput());
|
|
14047
14051
|
return;
|
|
14048
14052
|
}
|
|
14049
14053
|
this.elementRef = element;
|
|
14050
|
-
this.elementRef.style.fontFamily = this.fontFamily;
|
|
14051
|
-
this.elementRef.style.fontSize = `${this.fontSize}pt`;
|
|
14052
|
-
this.elementRef.style.color = this.fontColor;
|
|
14053
14054
|
this.elementRef.style.whiteSpace = 'pre-wrap';
|
|
14054
14055
|
this.elementRef.style.wordWrap = 'break-word';
|
|
14055
14056
|
this.elementRef.innerHTML = '';
|
|
@@ -14290,6 +14291,7 @@ class KritzelPath extends KritzelBaseObject {
|
|
|
14290
14291
|
object.scale = options?.scale ?? 1;
|
|
14291
14292
|
object.strokeWidth = options?.strokeWidth ?? 8;
|
|
14292
14293
|
object.fill = options?.fill ?? '#000000';
|
|
14294
|
+
object.opacity = options?.opacity ?? 1;
|
|
14293
14295
|
object.zIndex = core.store.currentZIndex;
|
|
14294
14296
|
object.d = object.generateSvgPath();
|
|
14295
14297
|
object.updateDimensions();
|
|
@@ -14733,6 +14735,7 @@ class KritzelLine extends KritzelBaseObject {
|
|
|
14733
14735
|
object.scale = options?.scale ?? 1;
|
|
14734
14736
|
object.strokeWidth = options?.strokeWidth ?? 4;
|
|
14735
14737
|
object.stroke = options?.stroke ?? '#000000';
|
|
14738
|
+
object.opacity = options?.opacity ?? 1;
|
|
14736
14739
|
object.startAnchor = options?.startAnchor;
|
|
14737
14740
|
object.endAnchor = options?.endAnchor;
|
|
14738
14741
|
object.arrows = options?.arrows;
|
|
@@ -15775,6 +15778,7 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
15775
15778
|
type = 'pen';
|
|
15776
15779
|
color = '#000000';
|
|
15777
15780
|
size = 6;
|
|
15781
|
+
opacity = 1;
|
|
15778
15782
|
palettes = {
|
|
15779
15783
|
pen: ['#000000', '#FFFFFF', '#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF', '#808080', '#C0C0C0', '#800000', '#008000', '#000080', '#800080'],
|
|
15780
15784
|
highlighter: ['#ffff00', '#ffb347', '#b4ffb4'],
|
|
@@ -15799,6 +15803,7 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
15799
15803
|
scale: this._core.store.state.scale,
|
|
15800
15804
|
fill: this.color,
|
|
15801
15805
|
strokeWidth: this.size,
|
|
15806
|
+
opacity: this.opacity,
|
|
15802
15807
|
});
|
|
15803
15808
|
path.isCompleted = false;
|
|
15804
15809
|
this._currentPathId = path.id;
|
|
@@ -15818,6 +15823,7 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
15818
15823
|
scale: this._core.store.state.scale,
|
|
15819
15824
|
fill: this.color,
|
|
15820
15825
|
strokeWidth: this.size,
|
|
15826
|
+
opacity: this.opacity,
|
|
15821
15827
|
});
|
|
15822
15828
|
path.isCompleted = false;
|
|
15823
15829
|
this._currentPathId = path.id;
|
|
@@ -15843,6 +15849,7 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
15843
15849
|
scale: this._core.store.state.scale,
|
|
15844
15850
|
fill: this.color,
|
|
15845
15851
|
strokeWidth: this.size,
|
|
15852
|
+
opacity: this.opacity,
|
|
15846
15853
|
});
|
|
15847
15854
|
updatedPath.id = currentPath.id;
|
|
15848
15855
|
updatedPath.workspaceId = currentPath.workspaceId;
|
|
@@ -15868,6 +15875,7 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
15868
15875
|
scale: this._core.store.state.scale,
|
|
15869
15876
|
fill: this.color,
|
|
15870
15877
|
strokeWidth: this.size,
|
|
15878
|
+
opacity: this.opacity,
|
|
15871
15879
|
});
|
|
15872
15880
|
updatedPath.id = currentPath.id;
|
|
15873
15881
|
updatedPath.workspaceId = currentPath.workspaceId;
|
|
@@ -16250,7 +16258,33 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
16250
16258
|
class KritzelLineTool extends KritzelBaseTool {
|
|
16251
16259
|
color = '#000000';
|
|
16252
16260
|
size = 4;
|
|
16253
|
-
|
|
16261
|
+
opacity = 1;
|
|
16262
|
+
palette = [
|
|
16263
|
+
'#000000',
|
|
16264
|
+
'#ff5252',
|
|
16265
|
+
'#ffbc00',
|
|
16266
|
+
'#00c853',
|
|
16267
|
+
'#0000FF',
|
|
16268
|
+
'#d500f9',
|
|
16269
|
+
'#fafafa',
|
|
16270
|
+
'#a52714',
|
|
16271
|
+
'#ee8100',
|
|
16272
|
+
'#558b2f',
|
|
16273
|
+
'#01579b',
|
|
16274
|
+
'#8e24aa',
|
|
16275
|
+
'#90a4ae',
|
|
16276
|
+
'#ff4081',
|
|
16277
|
+
'#ff6e40',
|
|
16278
|
+
'#aeea00',
|
|
16279
|
+
'#304ffe',
|
|
16280
|
+
'#7c4dff',
|
|
16281
|
+
'#cfd8dc',
|
|
16282
|
+
'#f8bbd0',
|
|
16283
|
+
'#ffccbc',
|
|
16284
|
+
'#f0f4c3',
|
|
16285
|
+
'#9fa8da',
|
|
16286
|
+
'#d1c4e9',
|
|
16287
|
+
];
|
|
16254
16288
|
/** Arrow head configuration for lines created with this tool */
|
|
16255
16289
|
arrows;
|
|
16256
16290
|
_startX = 0;
|
|
@@ -16279,6 +16313,7 @@ class KritzelLineTool extends KritzelBaseTool {
|
|
|
16279
16313
|
scale: this._core.store.state.scale,
|
|
16280
16314
|
stroke: this.color,
|
|
16281
16315
|
strokeWidth: this.size,
|
|
16316
|
+
opacity: this.opacity,
|
|
16282
16317
|
arrows: this.arrows,
|
|
16283
16318
|
});
|
|
16284
16319
|
line.isCompleted = false;
|
|
@@ -16303,6 +16338,7 @@ class KritzelLineTool extends KritzelBaseTool {
|
|
|
16303
16338
|
scale: this._core.store.state.scale,
|
|
16304
16339
|
stroke: this.color,
|
|
16305
16340
|
strokeWidth: this.size,
|
|
16341
|
+
opacity: this.opacity,
|
|
16306
16342
|
arrows: this.arrows,
|
|
16307
16343
|
});
|
|
16308
16344
|
line.isCompleted = false;
|
|
@@ -16330,6 +16366,7 @@ class KritzelLineTool extends KritzelBaseTool {
|
|
|
16330
16366
|
scale: this._core.store.state.scale,
|
|
16331
16367
|
stroke: this.color,
|
|
16332
16368
|
strokeWidth: this.size,
|
|
16369
|
+
opacity: this.opacity,
|
|
16333
16370
|
arrows: this.arrows,
|
|
16334
16371
|
});
|
|
16335
16372
|
updatedLine.id = currentLine.id;
|
|
@@ -16357,6 +16394,7 @@ class KritzelLineTool extends KritzelBaseTool {
|
|
|
16357
16394
|
scale: this._core.store.state.scale,
|
|
16358
16395
|
stroke: this.color,
|
|
16359
16396
|
strokeWidth: this.size,
|
|
16397
|
+
opacity: this.opacity,
|
|
16360
16398
|
arrows: this.arrows,
|
|
16361
16399
|
});
|
|
16362
16400
|
updatedLine.id = currentLine.id;
|
|
@@ -16589,6 +16627,7 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
16589
16627
|
fontFamily = 'Arial';
|
|
16590
16628
|
fontSize = 16;
|
|
16591
16629
|
fontColor = '#000000';
|
|
16630
|
+
opacity = 1;
|
|
16592
16631
|
palette = [
|
|
16593
16632
|
'#000000',
|
|
16594
16633
|
'#FFFFFF',
|
|
@@ -16639,6 +16678,7 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
16639
16678
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
16640
16679
|
const text = KritzelText.create(this._core, this.fontSize, this.fontFamily);
|
|
16641
16680
|
text.fontColor = this.fontColor;
|
|
16681
|
+
text.opacity = this.opacity;
|
|
16642
16682
|
text.translateX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
16643
16683
|
text.translateY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
16644
16684
|
text.zIndex = this._core.store.currentZIndex;
|
|
@@ -16673,6 +16713,7 @@ class KritzelTextTool extends KritzelBaseTool {
|
|
|
16673
16713
|
const clientY = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
16674
16714
|
const text = KritzelText.create(this._core, this.fontSize, this.fontFamily);
|
|
16675
16715
|
text.fontColor = this.fontColor;
|
|
16716
|
+
text.opacity = this.opacity;
|
|
16676
16717
|
text.translateX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
16677
16718
|
text.translateY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
16678
16719
|
text.zIndex = this._core.store.currentZIndex;
|
|
@@ -18031,6 +18072,404 @@ class KritzelLineHandleHandler extends KritzelBaseHandler {
|
|
|
18031
18072
|
}
|
|
18032
18073
|
}
|
|
18033
18074
|
|
|
18075
|
+
exports.ShapeType = void 0;
|
|
18076
|
+
(function (ShapeType) {
|
|
18077
|
+
ShapeType["Rectangle"] = "rectangle";
|
|
18078
|
+
ShapeType["Ellipse"] = "ellipse";
|
|
18079
|
+
ShapeType["Triangle"] = "triangle";
|
|
18080
|
+
})(exports.ShapeType || (exports.ShapeType = {}));
|
|
18081
|
+
|
|
18082
|
+
class KritzelShape extends KritzelBaseObject {
|
|
18083
|
+
__class__ = 'KritzelShape';
|
|
18084
|
+
shapeType = exports.ShapeType.Rectangle;
|
|
18085
|
+
fillColor = 'transparent';
|
|
18086
|
+
strokeColor = '#000000';
|
|
18087
|
+
strokeWidth = 4;
|
|
18088
|
+
fontFamily = 'Arial';
|
|
18089
|
+
fontSize = 16;
|
|
18090
|
+
fontColor = '#000000';
|
|
18091
|
+
/** Screen-space x coordinate of the shape's top-left corner (like Path.x) */
|
|
18092
|
+
x = 0;
|
|
18093
|
+
/** Screen-space y coordinate of the shape's top-left corner (like Path.y) */
|
|
18094
|
+
y = 0;
|
|
18095
|
+
scale = 1;
|
|
18096
|
+
scaleFactor = 1;
|
|
18097
|
+
isDebugInfoVisible = true;
|
|
18098
|
+
isEditable = true;
|
|
18099
|
+
isEditing = false;
|
|
18100
|
+
editor = null;
|
|
18101
|
+
content = null;
|
|
18102
|
+
_schema = new Schema$1({
|
|
18103
|
+
nodes: addListNodes(schema.spec.nodes, 'paragraph block*', 'block'),
|
|
18104
|
+
marks: schema.spec.marks,
|
|
18105
|
+
});
|
|
18106
|
+
uneditedObject = null;
|
|
18107
|
+
/**
|
|
18108
|
+
* Returns the viewBox for the shape's SVG, using screen-space coordinates.
|
|
18109
|
+
* This follows the same pattern as KritzelPath.viewBox.
|
|
18110
|
+
*/
|
|
18111
|
+
get viewBox() {
|
|
18112
|
+
return `${this.x} ${this.y} ${this.width} ${this.height}`;
|
|
18113
|
+
}
|
|
18114
|
+
constructor(config) {
|
|
18115
|
+
super();
|
|
18116
|
+
if (config) {
|
|
18117
|
+
this.x = config.x ?? 0;
|
|
18118
|
+
this.y = config.y ?? 0;
|
|
18119
|
+
this.translateX = config.translateX ?? 0;
|
|
18120
|
+
this.translateY = config.translateY ?? 0;
|
|
18121
|
+
this.width = config.width ?? 100;
|
|
18122
|
+
this.height = config.height ?? 100;
|
|
18123
|
+
this.shapeType = config.shapeType ?? exports.ShapeType.Rectangle;
|
|
18124
|
+
this.fillColor = config.fillColor ?? 'transparent';
|
|
18125
|
+
this.strokeColor = config.strokeColor ?? '#000000';
|
|
18126
|
+
this.strokeWidth = config.strokeWidth ?? 4;
|
|
18127
|
+
this.fontSize = config.fontSize ?? 16;
|
|
18128
|
+
this.fontFamily = config.fontFamily ?? 'Arial';
|
|
18129
|
+
this.fontColor = config.fontColor ?? '#000000';
|
|
18130
|
+
this.scale = config.scale ?? 1;
|
|
18131
|
+
this.scaleFactor = config.scaleX ?? 1;
|
|
18132
|
+
}
|
|
18133
|
+
}
|
|
18134
|
+
/**
|
|
18135
|
+
* Creates a new KritzelShape with screen-space coordinates.
|
|
18136
|
+
* Following the same pattern as KritzelPath.create():
|
|
18137
|
+
* - x, y are screen-space coordinates of the shape's top-left corner
|
|
18138
|
+
* - translateX, translateY should be set to -viewportTranslateX, -viewportTranslateY
|
|
18139
|
+
* - width, height are in screen-space
|
|
18140
|
+
* - scale is the viewport scale at creation time
|
|
18141
|
+
*/
|
|
18142
|
+
static create(core, config) {
|
|
18143
|
+
const object = new KritzelShape();
|
|
18144
|
+
object._core = core;
|
|
18145
|
+
object.id = object.generateId();
|
|
18146
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
18147
|
+
object.x = config?.x ?? 0;
|
|
18148
|
+
object.y = config?.y ?? 0;
|
|
18149
|
+
object.translateX = config?.translateX ?? 0;
|
|
18150
|
+
object.translateY = config?.translateY ?? 0;
|
|
18151
|
+
object.width = config?.width ?? 100;
|
|
18152
|
+
object.height = config?.height ?? 100;
|
|
18153
|
+
object.shapeType = config?.shapeType ?? exports.ShapeType.Rectangle;
|
|
18154
|
+
object.fillColor = config?.fillColor ?? 'transparent';
|
|
18155
|
+
object.strokeColor = config?.strokeColor ?? '#000000';
|
|
18156
|
+
object.strokeWidth = config?.strokeWidth ?? 4;
|
|
18157
|
+
object.opacity = config?.opacity ?? 1;
|
|
18158
|
+
object.fontSize = config?.fontSize ?? 16;
|
|
18159
|
+
object.fontFamily = config?.fontFamily ?? 'Arial';
|
|
18160
|
+
object.fontColor = config?.fontColor ?? '#000000';
|
|
18161
|
+
object.backgroundColor = 'transparent';
|
|
18162
|
+
object.scaleFactor = 1;
|
|
18163
|
+
object.scale = core.store.state.scale;
|
|
18164
|
+
object.zIndex = core.store.currentZIndex;
|
|
18165
|
+
object.editor = object.createEditor();
|
|
18166
|
+
// Compute world-space translateX/Y from screen-space coordinates
|
|
18167
|
+
// This follows the same pattern as KritzelPath.updateDimensions()
|
|
18168
|
+
object.updateDimensions();
|
|
18169
|
+
return object;
|
|
18170
|
+
}
|
|
18171
|
+
/**
|
|
18172
|
+
* Updates the translateX/Y to world coordinates based on screen-space x, y.
|
|
18173
|
+
* This follows the same pattern as KritzelPath.updateDimensions().
|
|
18174
|
+
*
|
|
18175
|
+
* The formula: translateX = (x + initialTranslateX) / scale
|
|
18176
|
+
* where initialTranslateX was -viewportTranslateX
|
|
18177
|
+
*
|
|
18178
|
+
* This converts screen-space position to world coordinates.
|
|
18179
|
+
*/
|
|
18180
|
+
updateDimensions() {
|
|
18181
|
+
this.translateX = (this.x + this.translateX) / this.scale;
|
|
18182
|
+
this.translateY = (this.y + this.translateY) / this.scale;
|
|
18183
|
+
}
|
|
18184
|
+
mount(element) {
|
|
18185
|
+
if (element === null || this.isInViewport() === false) {
|
|
18186
|
+
return;
|
|
18187
|
+
}
|
|
18188
|
+
if (this.isMounted && this.elementRef === element && this.editor.dom.parentElement === element) {
|
|
18189
|
+
return;
|
|
18190
|
+
}
|
|
18191
|
+
this.elementRef = element;
|
|
18192
|
+
this.isMounted = true;
|
|
18193
|
+
}
|
|
18194
|
+
mountTextEditor(element) {
|
|
18195
|
+
if (element === null) {
|
|
18196
|
+
return;
|
|
18197
|
+
}
|
|
18198
|
+
if (this.editor.dom.parentElement === element) {
|
|
18199
|
+
return;
|
|
18200
|
+
}
|
|
18201
|
+
element.style.fontFamily = this.fontFamily;
|
|
18202
|
+
element.style.fontSize = `${this.fontSize}pt`;
|
|
18203
|
+
element.style.color = this.fontColor;
|
|
18204
|
+
element.style.whiteSpace = 'pre-wrap';
|
|
18205
|
+
element.style.wordWrap = 'break-word';
|
|
18206
|
+
element.innerHTML = '';
|
|
18207
|
+
element.appendChild(this.editor.dom);
|
|
18208
|
+
}
|
|
18209
|
+
createEditor() {
|
|
18210
|
+
const doc = this._schema.node('doc', null, [this._schema.node('paragraph')]);
|
|
18211
|
+
return new EditorView(null, {
|
|
18212
|
+
state: EditorState.create({
|
|
18213
|
+
doc: doc,
|
|
18214
|
+
plugins: [keymap(baseKeymap)],
|
|
18215
|
+
}),
|
|
18216
|
+
editable: () => false,
|
|
18217
|
+
dispatchTransaction: transaction => {
|
|
18218
|
+
const newState = this.editor.state.apply(transaction);
|
|
18219
|
+
this.editor.updateState(newState);
|
|
18220
|
+
if (transaction.docChanged) {
|
|
18221
|
+
this.content = newState.doc.toJSON();
|
|
18222
|
+
if (!transaction.getMeta('fromRemote')) {
|
|
18223
|
+
this._core.store.state.objects.update(this, { temporary: true });
|
|
18224
|
+
}
|
|
18225
|
+
}
|
|
18226
|
+
},
|
|
18227
|
+
});
|
|
18228
|
+
}
|
|
18229
|
+
setContent(content) {
|
|
18230
|
+
this.content = content;
|
|
18231
|
+
if (this.editor && content) {
|
|
18232
|
+
const newDoc = this.editor.state.schema.nodeFromJSON(content);
|
|
18233
|
+
const tr = this.editor.state.tr.replaceWith(0, this.editor.state.doc.content.size, newDoc.content);
|
|
18234
|
+
tr.setMeta('fromRemote', true);
|
|
18235
|
+
this.editor.dispatch(tr);
|
|
18236
|
+
}
|
|
18237
|
+
}
|
|
18238
|
+
resize(x, y, width, height) {
|
|
18239
|
+
if (width <= 1 || height <= 1) {
|
|
18240
|
+
return;
|
|
18241
|
+
}
|
|
18242
|
+
this.width = width;
|
|
18243
|
+
this.height = height;
|
|
18244
|
+
this.translateX = x;
|
|
18245
|
+
this.translateY = y;
|
|
18246
|
+
this._core.store.state.objects.update(this);
|
|
18247
|
+
}
|
|
18248
|
+
focus(coords) {
|
|
18249
|
+
if (this.editor) {
|
|
18250
|
+
const doc = this.editor.state.doc;
|
|
18251
|
+
if (coords?.x && coords?.y) {
|
|
18252
|
+
const pos = this.editor.posAtCoords({ left: coords.x, top: coords.y });
|
|
18253
|
+
if (pos) {
|
|
18254
|
+
this.editor.dispatch(this.editor.state.tr.setSelection(TextSelection.create(doc, pos.pos)));
|
|
18255
|
+
this.editor.focus();
|
|
18256
|
+
if (KritzelDevicesHelper.isIOS()) {
|
|
18257
|
+
this.scrollIntoViewOnIOS();
|
|
18258
|
+
}
|
|
18259
|
+
return;
|
|
18260
|
+
}
|
|
18261
|
+
}
|
|
18262
|
+
const end = Math.max(1, doc.content.size - 1);
|
|
18263
|
+
this.editor.dispatch(this.editor.state.tr.setSelection(TextSelection.create(doc, end)));
|
|
18264
|
+
this.editor.focus();
|
|
18265
|
+
if (KritzelDevicesHelper.isIOS()) {
|
|
18266
|
+
this.scrollIntoViewOnIOS();
|
|
18267
|
+
}
|
|
18268
|
+
}
|
|
18269
|
+
}
|
|
18270
|
+
scrollIntoViewOnIOS() {
|
|
18271
|
+
setTimeout(() => {
|
|
18272
|
+
if (this.editor && this.editor.dom) {
|
|
18273
|
+
this.editor.dom.scrollIntoView({
|
|
18274
|
+
behavior: 'smooth',
|
|
18275
|
+
block: 'center',
|
|
18276
|
+
inline: 'nearest',
|
|
18277
|
+
});
|
|
18278
|
+
}
|
|
18279
|
+
}, 300);
|
|
18280
|
+
}
|
|
18281
|
+
edit(event) {
|
|
18282
|
+
KritzelKeyboardHelper.disableInteractiveWidget();
|
|
18283
|
+
this.uneditedObject = this.clone();
|
|
18284
|
+
this._core.store.setState('activeTool', KritzelToolRegistry.getTool('shape'));
|
|
18285
|
+
this.editor.setProps({ editable: () => true });
|
|
18286
|
+
this.isEditing = true;
|
|
18287
|
+
this._core.rerender();
|
|
18288
|
+
this.focus({ x: event?.clientX, y: event?.clientY });
|
|
18289
|
+
KritzelKeyboardHelper.enableInteractiveWidget();
|
|
18290
|
+
}
|
|
18291
|
+
save() {
|
|
18292
|
+
this.content = this.editor.state.doc.toJSON();
|
|
18293
|
+
this.editor.setProps({ editable: () => false });
|
|
18294
|
+
this.editor.dom.blur();
|
|
18295
|
+
this.isEditing = false;
|
|
18296
|
+
this._core.store.state.objects.consolidateTemporaryItems();
|
|
18297
|
+
this._core.store.state.objects.update(this);
|
|
18298
|
+
this._core.engine.emitObjectsChange();
|
|
18299
|
+
}
|
|
18300
|
+
handlePointerDown(event) {
|
|
18301
|
+
if (!this.isEditing) {
|
|
18302
|
+
return;
|
|
18303
|
+
}
|
|
18304
|
+
event.stopPropagation();
|
|
18305
|
+
}
|
|
18306
|
+
handlePointerMove(event) {
|
|
18307
|
+
if (!this.isEditing) {
|
|
18308
|
+
return;
|
|
18309
|
+
}
|
|
18310
|
+
event.stopPropagation();
|
|
18311
|
+
}
|
|
18312
|
+
handlePointerUp(event) {
|
|
18313
|
+
if (!this.isEditing) {
|
|
18314
|
+
return;
|
|
18315
|
+
}
|
|
18316
|
+
event.stopPropagation();
|
|
18317
|
+
}
|
|
18318
|
+
copy() {
|
|
18319
|
+
const copiedObject = super.copy();
|
|
18320
|
+
copiedObject.editor = copiedObject.createEditor();
|
|
18321
|
+
if (this.content) {
|
|
18322
|
+
copiedObject.setContent(this.content);
|
|
18323
|
+
}
|
|
18324
|
+
return copiedObject;
|
|
18325
|
+
}
|
|
18326
|
+
serialize() {
|
|
18327
|
+
const { _core, _elementRef, _schema, element, totalWidth, totalHeight, editor, uneditedObject, ...remainingProps } = this;
|
|
18328
|
+
const clonedProps = structuredClone(remainingProps);
|
|
18329
|
+
if (element && typeof element === 'object' && 'nodeType' in element && element.nodeType === 1) {
|
|
18330
|
+
clonedProps.element = element.cloneNode(true);
|
|
18331
|
+
}
|
|
18332
|
+
return clonedProps;
|
|
18333
|
+
}
|
|
18334
|
+
deserialize(object) {
|
|
18335
|
+
super.deserialize(object);
|
|
18336
|
+
if (object.content) {
|
|
18337
|
+
this.setContent(object.content);
|
|
18338
|
+
}
|
|
18339
|
+
return this;
|
|
18340
|
+
}
|
|
18341
|
+
/**
|
|
18342
|
+
* Returns the clipping polygon for arrow intersection.
|
|
18343
|
+
* For ellipse: returns a many-sided polygon approximation
|
|
18344
|
+
* For triangle: returns the 3 corners
|
|
18345
|
+
* For rectangle: returns null (uses default rotatedPolygon)
|
|
18346
|
+
*
|
|
18347
|
+
* Includes padding for half the stroke width so arrow heads don't overlap the stroke.
|
|
18348
|
+
*/
|
|
18349
|
+
getClipPolygon() {
|
|
18350
|
+
// Calculate world-space center and dimensions
|
|
18351
|
+
const worldWidth = this.totalWidth / this.scale;
|
|
18352
|
+
const worldHeight = this.totalHeight / this.scale;
|
|
18353
|
+
const centerX = this.translateX + worldWidth / 2;
|
|
18354
|
+
const centerY = this.translateY + worldHeight / 2;
|
|
18355
|
+
// Add padding for stroke width so arrows don't overlap the stroke
|
|
18356
|
+
const strokePadding = (this.strokeWidth / this.scale) / 2;
|
|
18357
|
+
switch (this.shapeType) {
|
|
18358
|
+
case exports.ShapeType.Ellipse:
|
|
18359
|
+
// Return a 32-segment polygon approximation of the ellipse
|
|
18360
|
+
// Add stroke padding to radii
|
|
18361
|
+
return KritzelGeometryHelper.getEllipsePolygonApproximation(centerX, centerY, worldWidth / 2 + strokePadding, worldHeight / 2 + strokePadding, 32, this.rotation);
|
|
18362
|
+
case exports.ShapeType.Triangle:
|
|
18363
|
+
// Return the 3 corners of the triangle in world coordinates
|
|
18364
|
+
// Triangle: top-center, bottom-right, bottom-left
|
|
18365
|
+
// Expand each vertex outward from center by strokePadding
|
|
18366
|
+
const expandVertex = (vx, vy) => {
|
|
18367
|
+
const dx = vx - centerX;
|
|
18368
|
+
const dy = vy - centerY;
|
|
18369
|
+
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
18370
|
+
if (dist === 0)
|
|
18371
|
+
return { x: vx, y: vy };
|
|
18372
|
+
const scale = (dist + strokePadding) / dist;
|
|
18373
|
+
return {
|
|
18374
|
+
x: centerX + dx * scale,
|
|
18375
|
+
y: centerY + dy * scale
|
|
18376
|
+
};
|
|
18377
|
+
};
|
|
18378
|
+
const topX = this.translateX + worldWidth / 2;
|
|
18379
|
+
const topY = this.translateY;
|
|
18380
|
+
const bottomLeftX = this.translateX;
|
|
18381
|
+
const bottomLeftY = this.translateY + worldHeight;
|
|
18382
|
+
const bottomRightX = this.translateX + worldWidth;
|
|
18383
|
+
const bottomRightY = this.translateY + worldHeight;
|
|
18384
|
+
const expandedTop = expandVertex(topX, topY);
|
|
18385
|
+
const expandedBottomRight = expandVertex(bottomRightX, bottomRightY);
|
|
18386
|
+
const expandedBottomLeft = expandVertex(bottomLeftX, bottomLeftY);
|
|
18387
|
+
// Apply rotation around center if rotated
|
|
18388
|
+
if (this.rotation !== 0) {
|
|
18389
|
+
const cos = Math.cos(this.rotation);
|
|
18390
|
+
const sin = Math.sin(this.rotation);
|
|
18391
|
+
const rotate = (p) => {
|
|
18392
|
+
const dx = p.x - centerX;
|
|
18393
|
+
const dy = p.y - centerY;
|
|
18394
|
+
return {
|
|
18395
|
+
x: centerX + dx * cos - dy * sin,
|
|
18396
|
+
y: centerY + dx * sin + dy * cos
|
|
18397
|
+
};
|
|
18398
|
+
};
|
|
18399
|
+
return [
|
|
18400
|
+
rotate(expandedTop),
|
|
18401
|
+
rotate(expandedBottomRight),
|
|
18402
|
+
rotate(expandedBottomLeft)
|
|
18403
|
+
];
|
|
18404
|
+
}
|
|
18405
|
+
return [expandedTop, expandedBottomRight, expandedBottomLeft];
|
|
18406
|
+
case exports.ShapeType.Rectangle:
|
|
18407
|
+
default:
|
|
18408
|
+
// For rectangles, return null to use the default rotatedPolygon
|
|
18409
|
+
return null;
|
|
18410
|
+
}
|
|
18411
|
+
}
|
|
18412
|
+
/**
|
|
18413
|
+
* Returns the SVG path for rendering the shape.
|
|
18414
|
+
* The path uses screen-space coordinates relative to (x, y).
|
|
18415
|
+
*/
|
|
18416
|
+
getSvgPath() {
|
|
18417
|
+
const w = this.width;
|
|
18418
|
+
const h = this.height;
|
|
18419
|
+
switch (this.shapeType) {
|
|
18420
|
+
case exports.ShapeType.Rectangle:
|
|
18421
|
+
return `M ${this.x} ${this.y} L ${this.x + w} ${this.y} L ${this.x + w} ${this.y + h} L ${this.x} ${this.y + h} Z`;
|
|
18422
|
+
case exports.ShapeType.Ellipse:
|
|
18423
|
+
const cx = this.x + w / 2;
|
|
18424
|
+
const cy = this.y + h / 2;
|
|
18425
|
+
const rx = w / 2;
|
|
18426
|
+
const ry = h / 2;
|
|
18427
|
+
return `M ${cx - rx} ${cy} A ${rx} ${ry} 0 1 0 ${cx + rx} ${cy} A ${rx} ${ry} 0 1 0 ${cx - rx} ${cy}`;
|
|
18428
|
+
case exports.ShapeType.Triangle:
|
|
18429
|
+
const topX = this.x + w / 2;
|
|
18430
|
+
const topY = this.y;
|
|
18431
|
+
const bottomLeftX = this.x;
|
|
18432
|
+
const bottomLeftY = this.y + h;
|
|
18433
|
+
const bottomRightX = this.x + w;
|
|
18434
|
+
const bottomRightY = this.y + h;
|
|
18435
|
+
return `M ${topX} ${topY} L ${bottomRightX} ${bottomRightY} L ${bottomLeftX} ${bottomLeftY} Z`;
|
|
18436
|
+
default:
|
|
18437
|
+
return `M ${this.x} ${this.y} L ${this.x + w} ${this.y} L ${this.x + w} ${this.y + h} L ${this.x} ${this.y + h} Z`;
|
|
18438
|
+
}
|
|
18439
|
+
}
|
|
18440
|
+
}
|
|
18441
|
+
|
|
18442
|
+
/**
|
|
18443
|
+
* Default color palette shared across all tool configurations.
|
|
18444
|
+
* This ensures consistency in color options throughout the application.
|
|
18445
|
+
*/
|
|
18446
|
+
const DEFAULT_COLOR_PALETTE = [
|
|
18447
|
+
'#000000',
|
|
18448
|
+
'#ff5252',
|
|
18449
|
+
'#ffbc00',
|
|
18450
|
+
'#00c853',
|
|
18451
|
+
'#0000FF',
|
|
18452
|
+
'#d500f9',
|
|
18453
|
+
'#fafafa',
|
|
18454
|
+
'#a52714',
|
|
18455
|
+
'#ee8100',
|
|
18456
|
+
'#558b2f',
|
|
18457
|
+
'#01579b',
|
|
18458
|
+
'#8e24aa',
|
|
18459
|
+
'#90a4ae',
|
|
18460
|
+
'#ff4081',
|
|
18461
|
+
'#ff6e40',
|
|
18462
|
+
'#aeea00',
|
|
18463
|
+
'#304ffe',
|
|
18464
|
+
'#7c4dff',
|
|
18465
|
+
'#cfd8dc',
|
|
18466
|
+
'#f8bbd0',
|
|
18467
|
+
'#ffccbc',
|
|
18468
|
+
'#f0f4c3',
|
|
18469
|
+
'#9fa8da',
|
|
18470
|
+
'#d1c4e9',
|
|
18471
|
+
];
|
|
18472
|
+
|
|
18034
18473
|
class KritzelSelectionTool extends KritzelBaseTool {
|
|
18035
18474
|
selectionHandler;
|
|
18036
18475
|
moveHandler;
|
|
@@ -18038,6 +18477,193 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
18038
18477
|
resizeHandler;
|
|
18039
18478
|
rotationHandler;
|
|
18040
18479
|
lineHandleHandler;
|
|
18480
|
+
palette = [...DEFAULT_COLOR_PALETTE];
|
|
18481
|
+
/** Returns true if there are objects in the selection group */
|
|
18482
|
+
hasSelection() {
|
|
18483
|
+
return !!this._core.store.selectionGroup && this._core.store.selectionGroup.objects.length > 0;
|
|
18484
|
+
}
|
|
18485
|
+
/** Returns the selected objects or empty array */
|
|
18486
|
+
getSelectedObjects() {
|
|
18487
|
+
return this._core.store.selectionGroup?.objects ?? [];
|
|
18488
|
+
}
|
|
18489
|
+
flattenObjects(objects) {
|
|
18490
|
+
let result = [];
|
|
18491
|
+
for (const obj of objects) {
|
|
18492
|
+
if (obj instanceof KritzelGroup) {
|
|
18493
|
+
result = result.concat(this.flattenObjects(obj.children));
|
|
18494
|
+
}
|
|
18495
|
+
else {
|
|
18496
|
+
result.push(obj);
|
|
18497
|
+
}
|
|
18498
|
+
}
|
|
18499
|
+
return result;
|
|
18500
|
+
}
|
|
18501
|
+
get color() {
|
|
18502
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
18503
|
+
if (objects.length === 0)
|
|
18504
|
+
return '#000000';
|
|
18505
|
+
for (const obj of objects) {
|
|
18506
|
+
if (obj instanceof KritzelPath)
|
|
18507
|
+
return obj.fill;
|
|
18508
|
+
if (obj instanceof KritzelLine)
|
|
18509
|
+
return obj.stroke;
|
|
18510
|
+
if (obj instanceof KritzelText)
|
|
18511
|
+
return obj.fontColor;
|
|
18512
|
+
if (obj instanceof KritzelShape)
|
|
18513
|
+
return obj.strokeColor;
|
|
18514
|
+
}
|
|
18515
|
+
return '#000000';
|
|
18516
|
+
}
|
|
18517
|
+
set color(value) {
|
|
18518
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
18519
|
+
objects.forEach(obj => {
|
|
18520
|
+
if (obj instanceof KritzelPath)
|
|
18521
|
+
this._core.updateObject(obj, { fill: value });
|
|
18522
|
+
if (obj instanceof KritzelLine)
|
|
18523
|
+
this._core.updateObject(obj, { stroke: value });
|
|
18524
|
+
if (obj instanceof KritzelText)
|
|
18525
|
+
this._core.updateObject(obj, { fontColor: value });
|
|
18526
|
+
if (obj instanceof KritzelShape)
|
|
18527
|
+
this._core.updateObject(obj, { strokeColor: value });
|
|
18528
|
+
});
|
|
18529
|
+
this._core.rerender();
|
|
18530
|
+
}
|
|
18531
|
+
get opacity() {
|
|
18532
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
18533
|
+
if (objects.length === 0)
|
|
18534
|
+
return 1;
|
|
18535
|
+
return objects[0].opacity;
|
|
18536
|
+
}
|
|
18537
|
+
set opacity(value) {
|
|
18538
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
18539
|
+
objects.forEach(obj => this._core.updateObject(obj, { opacity: value }));
|
|
18540
|
+
this._core.rerender();
|
|
18541
|
+
}
|
|
18542
|
+
get size() {
|
|
18543
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
18544
|
+
if (objects.length === 0)
|
|
18545
|
+
return 1;
|
|
18546
|
+
for (const obj of objects) {
|
|
18547
|
+
if (obj instanceof KritzelPath)
|
|
18548
|
+
return obj.strokeWidth;
|
|
18549
|
+
if (obj instanceof KritzelLine)
|
|
18550
|
+
return obj.strokeWidth;
|
|
18551
|
+
if (obj instanceof KritzelText)
|
|
18552
|
+
return obj.fontSize;
|
|
18553
|
+
if (obj instanceof KritzelShape)
|
|
18554
|
+
return obj.strokeWidth;
|
|
18555
|
+
}
|
|
18556
|
+
return 1;
|
|
18557
|
+
}
|
|
18558
|
+
set size(value) {
|
|
18559
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
18560
|
+
objects.forEach(obj => {
|
|
18561
|
+
if (obj instanceof KritzelPath)
|
|
18562
|
+
this._core.updateObject(obj, { strokeWidth: value });
|
|
18563
|
+
if (obj instanceof KritzelLine)
|
|
18564
|
+
this._core.updateObject(obj, { strokeWidth: value });
|
|
18565
|
+
if (obj instanceof KritzelText)
|
|
18566
|
+
this._core.updateObject(obj, { fontSize: value });
|
|
18567
|
+
if (obj instanceof KritzelShape)
|
|
18568
|
+
this._core.updateObject(obj, { strokeWidth: value });
|
|
18569
|
+
});
|
|
18570
|
+
this._core.rerender();
|
|
18571
|
+
}
|
|
18572
|
+
get fillColor() {
|
|
18573
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
18574
|
+
for (const obj of objects) {
|
|
18575
|
+
if (obj instanceof KritzelShape)
|
|
18576
|
+
return obj.fillColor;
|
|
18577
|
+
}
|
|
18578
|
+
return 'transparent';
|
|
18579
|
+
}
|
|
18580
|
+
set fillColor(value) {
|
|
18581
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
18582
|
+
objects.forEach(obj => {
|
|
18583
|
+
if (obj instanceof KritzelShape) {
|
|
18584
|
+
this._core.updateObject(obj, { fillColor: value });
|
|
18585
|
+
// When switching to fill mode, also update stroke color to match
|
|
18586
|
+
if (value !== 'transparent') {
|
|
18587
|
+
this._core.updateObject(obj, { strokeColor: value });
|
|
18588
|
+
}
|
|
18589
|
+
}
|
|
18590
|
+
});
|
|
18591
|
+
this._core.rerender();
|
|
18592
|
+
}
|
|
18593
|
+
get fontFamily() {
|
|
18594
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
18595
|
+
for (const obj of objects) {
|
|
18596
|
+
if (obj instanceof KritzelText)
|
|
18597
|
+
return obj.fontFamily;
|
|
18598
|
+
if (obj instanceof KritzelShape)
|
|
18599
|
+
return obj.fontFamily;
|
|
18600
|
+
}
|
|
18601
|
+
return 'Arial';
|
|
18602
|
+
}
|
|
18603
|
+
set fontFamily(value) {
|
|
18604
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
18605
|
+
objects.forEach(obj => {
|
|
18606
|
+
if (obj instanceof KritzelText)
|
|
18607
|
+
this._core.updateObject(obj, { fontFamily: value });
|
|
18608
|
+
if (obj instanceof KritzelShape)
|
|
18609
|
+
this._core.updateObject(obj, { fontFamily: value });
|
|
18610
|
+
});
|
|
18611
|
+
this._core.rerender();
|
|
18612
|
+
}
|
|
18613
|
+
get arrows() {
|
|
18614
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
18615
|
+
for (const obj of objects) {
|
|
18616
|
+
if (obj instanceof KritzelLine)
|
|
18617
|
+
return obj.arrows;
|
|
18618
|
+
}
|
|
18619
|
+
return { start: { enabled: false }, end: { enabled: false } };
|
|
18620
|
+
}
|
|
18621
|
+
set arrows(value) {
|
|
18622
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
18623
|
+
objects.forEach(obj => {
|
|
18624
|
+
if (obj instanceof KritzelLine)
|
|
18625
|
+
this._core.updateObject(obj, { arrows: value });
|
|
18626
|
+
});
|
|
18627
|
+
this._core.rerender();
|
|
18628
|
+
}
|
|
18629
|
+
/** Returns the tool config for selected objects, or null if no selection */
|
|
18630
|
+
getToolConfig() {
|
|
18631
|
+
if (!this.hasSelection())
|
|
18632
|
+
return null;
|
|
18633
|
+
const objects = this.flattenObjects(this.getSelectedObjects());
|
|
18634
|
+
const controls = [];
|
|
18635
|
+
const hasShape = objects.some(o => o instanceof KritzelShape);
|
|
18636
|
+
const hasText = objects.some(o => o instanceof KritzelText);
|
|
18637
|
+
const hasLine = objects.some(o => o instanceof KritzelLine);
|
|
18638
|
+
const hasStroke = objects.some(o => o instanceof KritzelPath || o instanceof KritzelLine || o instanceof KritzelShape);
|
|
18639
|
+
if (hasText && !hasStroke) {
|
|
18640
|
+
controls.push({ type: 'font-size', propertyName: 'size' });
|
|
18641
|
+
controls.push({ type: 'font-family', propertyName: 'fontFamily' });
|
|
18642
|
+
}
|
|
18643
|
+
else if (hasStroke && !hasText) {
|
|
18644
|
+
controls.push({ type: 'stroke-size', propertyName: 'size' });
|
|
18645
|
+
}
|
|
18646
|
+
else {
|
|
18647
|
+
if (hasStroke)
|
|
18648
|
+
controls.push({ type: 'stroke-size', propertyName: 'size' });
|
|
18649
|
+
if (hasText)
|
|
18650
|
+
controls.push({ type: 'font-family', propertyName: 'fontFamily' });
|
|
18651
|
+
}
|
|
18652
|
+
if (hasLine) {
|
|
18653
|
+
controls.push({ type: 'line-endings', propertyName: 'arrows' });
|
|
18654
|
+
}
|
|
18655
|
+
if (hasShape) {
|
|
18656
|
+
controls.push({ type: 'shape-fill', propertyName: 'fillColor' });
|
|
18657
|
+
}
|
|
18658
|
+
return {
|
|
18659
|
+
type: 'selection',
|
|
18660
|
+
colorProperty: 'color',
|
|
18661
|
+
sizeProperty: 'size',
|
|
18662
|
+
opacityProperty: 'opacity',
|
|
18663
|
+
paletteSource: 'palette',
|
|
18664
|
+
controls,
|
|
18665
|
+
};
|
|
18666
|
+
}
|
|
18041
18667
|
constructor(core) {
|
|
18042
18668
|
super(core);
|
|
18043
18669
|
this.selectionHandler = new KritzelSelectionHandler(this._core);
|
|
@@ -31491,7 +32117,6 @@ class IndexedDBSyncProvider {
|
|
|
31491
32117
|
constructor(docName, doc, options) {
|
|
31492
32118
|
const dbName = options?.name || docName;
|
|
31493
32119
|
this.provider = new IndexeddbPersistence(dbName, doc);
|
|
31494
|
-
console.info(`IndexedDB Persistence initialized: ${dbName}`);
|
|
31495
32120
|
}
|
|
31496
32121
|
async connect() {
|
|
31497
32122
|
if (this.isConnected) {
|
|
@@ -35612,58 +36237,7 @@ const DEFAULT_BRUSH_CONFIG = {
|
|
|
35612
36237
|
color: '#000000',
|
|
35613
36238
|
size: 16,
|
|
35614
36239
|
palettes: {
|
|
35615
|
-
pen: [
|
|
35616
|
-
'#000000',
|
|
35617
|
-
'#ff5252',
|
|
35618
|
-
'#ffbc00',
|
|
35619
|
-
'#00c853',
|
|
35620
|
-
'#0000FF',
|
|
35621
|
-
'#d500f9',
|
|
35622
|
-
'#fafafa',
|
|
35623
|
-
'#a52714',
|
|
35624
|
-
'#ee8100',
|
|
35625
|
-
'#558b2f',
|
|
35626
|
-
'#01579b',
|
|
35627
|
-
'#8e24aa',
|
|
35628
|
-
'#90a4ae',
|
|
35629
|
-
'#ff4081',
|
|
35630
|
-
'#ff6e40',
|
|
35631
|
-
'#aeea00',
|
|
35632
|
-
'#304ffe',
|
|
35633
|
-
'#7c4dff',
|
|
35634
|
-
'#cfd8dc',
|
|
35635
|
-
'#f8bbd0',
|
|
35636
|
-
'#ffccbc',
|
|
35637
|
-
'#f0f4c3',
|
|
35638
|
-
'#9fa8da',
|
|
35639
|
-
'#d1c4e9',
|
|
35640
|
-
],
|
|
35641
|
-
highlighter: [
|
|
35642
|
-
'#0000006e',
|
|
35643
|
-
'#ff52526e',
|
|
35644
|
-
'#ffbb006e',
|
|
35645
|
-
'#00c8536e',
|
|
35646
|
-
'#0000FF6e',
|
|
35647
|
-
'#d500f96e',
|
|
35648
|
-
'#fafafa6e',
|
|
35649
|
-
'#a527146e',
|
|
35650
|
-
'#ee81006e',
|
|
35651
|
-
'#558b2f6e',
|
|
35652
|
-
'#01579b6e',
|
|
35653
|
-
'#8e24aa6e',
|
|
35654
|
-
'#90a4ae6e',
|
|
35655
|
-
'#ff40816e',
|
|
35656
|
-
'#ff6e406e',
|
|
35657
|
-
'#aeea006e',
|
|
35658
|
-
'#304ffe6e',
|
|
35659
|
-
'#7c4dff6e',
|
|
35660
|
-
'#cfd8dc6e',
|
|
35661
|
-
'#f8bbd06e',
|
|
35662
|
-
'#ffccbc6e',
|
|
35663
|
-
'#f0f4c36e',
|
|
35664
|
-
'#9fa8da6e',
|
|
35665
|
-
'#d1c4e96e',
|
|
35666
|
-
],
|
|
36240
|
+
pen: [...DEFAULT_COLOR_PALETTE],
|
|
35667
36241
|
},
|
|
35668
36242
|
};
|
|
35669
36243
|
|
|
@@ -35671,75 +36245,24 @@ const DEFAULT_TEXT_CONFIG = {
|
|
|
35671
36245
|
color: '#000000',
|
|
35672
36246
|
size: 8,
|
|
35673
36247
|
fontFamily: 'Arial',
|
|
35674
|
-
palette: [
|
|
35675
|
-
'#000000',
|
|
35676
|
-
'#ff5252',
|
|
35677
|
-
'#ffbc00',
|
|
35678
|
-
'#00c853',
|
|
35679
|
-
'#0000FF',
|
|
35680
|
-
'#d500f9',
|
|
35681
|
-
'#fafafa',
|
|
35682
|
-
'#a52714',
|
|
35683
|
-
'#ee8100',
|
|
35684
|
-
'#558b2f',
|
|
35685
|
-
'#01579b',
|
|
35686
|
-
'#8e24aa',
|
|
35687
|
-
'#90a4ae',
|
|
35688
|
-
'#ff4081',
|
|
35689
|
-
'#ff6e40',
|
|
35690
|
-
'#aeea00',
|
|
35691
|
-
'#304ffe',
|
|
35692
|
-
'#7c4dff',
|
|
35693
|
-
'#cfd8dc',
|
|
35694
|
-
'#f8bbd0',
|
|
35695
|
-
'#ffccbc',
|
|
35696
|
-
'#f0f4c3',
|
|
35697
|
-
'#9fa8da',
|
|
35698
|
-
'#d1c4e9',
|
|
35699
|
-
],
|
|
36248
|
+
palette: [...DEFAULT_COLOR_PALETTE],
|
|
35700
36249
|
};
|
|
35701
36250
|
|
|
35702
36251
|
const DEFAULT_LINE_TOOL_CONFIG = {
|
|
35703
36252
|
color: '#000000',
|
|
35704
36253
|
size: 4,
|
|
35705
|
-
palette: [
|
|
35706
|
-
'#000000',
|
|
35707
|
-
'#ff5252',
|
|
35708
|
-
'#ffbc00',
|
|
35709
|
-
'#00c853',
|
|
35710
|
-
'#0000FF',
|
|
35711
|
-
'#d500f9',
|
|
35712
|
-
'#fafafa',
|
|
35713
|
-
'#a52714',
|
|
35714
|
-
'#ee8100',
|
|
35715
|
-
'#558b2f',
|
|
35716
|
-
'#01579b',
|
|
35717
|
-
'#8e24aa',
|
|
35718
|
-
'#90a4ae',
|
|
35719
|
-
'#ff4081',
|
|
35720
|
-
'#ff6e40',
|
|
35721
|
-
'#aeea00',
|
|
35722
|
-
'#304ffe',
|
|
35723
|
-
'#7c4dff',
|
|
35724
|
-
'#cfd8dc',
|
|
35725
|
-
'#f8bbd0',
|
|
35726
|
-
'#ffccbc',
|
|
35727
|
-
'#f0f4c3',
|
|
35728
|
-
'#b3e5fc',
|
|
35729
|
-
'#e1bee7',
|
|
35730
|
-
],
|
|
36254
|
+
palette: [...DEFAULT_COLOR_PALETTE],
|
|
35731
36255
|
arrows: {
|
|
35732
36256
|
end: { enabled: true, style: 'triangle' },
|
|
35733
36257
|
},
|
|
35734
36258
|
};
|
|
35735
36259
|
|
|
35736
36260
|
exports.DEFAULT_BRUSH_CONFIG = DEFAULT_BRUSH_CONFIG;
|
|
36261
|
+
exports.DEFAULT_COLOR_PALETTE = DEFAULT_COLOR_PALETTE;
|
|
35737
36262
|
exports.DEFAULT_LINE_TOOL_CONFIG = DEFAULT_LINE_TOOL_CONFIG;
|
|
35738
36263
|
exports.DEFAULT_SYNC_CONFIG = DEFAULT_SYNC_CONFIG;
|
|
35739
36264
|
exports.DEFAULT_TEXT_CONFIG = DEFAULT_TEXT_CONFIG;
|
|
35740
36265
|
exports.Doc = Doc;
|
|
35741
|
-
exports.EditorState = EditorState;
|
|
35742
|
-
exports.EditorView = EditorView;
|
|
35743
36266
|
exports.HocuspocusProvider = HocuspocusProvider;
|
|
35744
36267
|
exports.HocuspocusProviderWebsocket = HocuspocusProviderWebsocket;
|
|
35745
36268
|
exports.IndexedDBSyncProvider = IndexedDBSyncProvider;
|
|
@@ -35754,7 +36277,6 @@ exports.KritzelCursorHelper = KritzelCursorHelper;
|
|
|
35754
36277
|
exports.KritzelDevicesHelper = KritzelDevicesHelper;
|
|
35755
36278
|
exports.KritzelEraserTool = KritzelEraserTool;
|
|
35756
36279
|
exports.KritzelEventHelper = KritzelEventHelper;
|
|
35757
|
-
exports.KritzelGeometryHelper = KritzelGeometryHelper;
|
|
35758
36280
|
exports.KritzelGroup = KritzelGroup;
|
|
35759
36281
|
exports.KritzelIconRegistry = KritzelIconRegistry;
|
|
35760
36282
|
exports.KritzelImage = KritzelImage;
|
|
@@ -35766,6 +36288,7 @@ exports.KritzelPath = KritzelPath;
|
|
|
35766
36288
|
exports.KritzelSelectionBox = KritzelSelectionBox;
|
|
35767
36289
|
exports.KritzelSelectionGroup = KritzelSelectionGroup;
|
|
35768
36290
|
exports.KritzelSelectionTool = KritzelSelectionTool;
|
|
36291
|
+
exports.KritzelShape = KritzelShape;
|
|
35769
36292
|
exports.KritzelText = KritzelText;
|
|
35770
36293
|
exports.KritzelTextTool = KritzelTextTool;
|
|
35771
36294
|
exports.KritzelToolRegistry = KritzelToolRegistry;
|
|
@@ -35773,12 +36296,8 @@ exports.KritzelWorkspace = KritzelWorkspace;
|
|
|
35773
36296
|
exports.ObjectHelper = ObjectHelper;
|
|
35774
36297
|
exports.Observable = Observable$1;
|
|
35775
36298
|
exports.ObservableV2 = ObservableV2;
|
|
35776
|
-
exports.Schema = Schema$1;
|
|
35777
|
-
exports.TextSelection = TextSelection;
|
|
35778
36299
|
exports.UndoManager = UndoManager;
|
|
35779
|
-
exports.addListNodes = addListNodes;
|
|
35780
36300
|
exports.applyUpdate = applyUpdate;
|
|
35781
|
-
exports.baseKeymap = baseKeymap;
|
|
35782
36301
|
exports.create = create$8;
|
|
35783
36302
|
exports.createDecoder = createDecoder$1;
|
|
35784
36303
|
exports.createEncoder = createEncoder$1;
|
|
@@ -35790,7 +36309,6 @@ exports.floor = floor$2;
|
|
|
35790
36309
|
exports.fromBase64 = fromBase64;
|
|
35791
36310
|
exports.getUnixTime = getUnixTime$1;
|
|
35792
36311
|
exports.isNode = isNode;
|
|
35793
|
-
exports.keymap = keymap;
|
|
35794
36312
|
exports.length = length$2;
|
|
35795
36313
|
exports.map = map;
|
|
35796
36314
|
exports.min = min$2;
|
|
@@ -35800,7 +36318,6 @@ exports.pow = pow;
|
|
|
35800
36318
|
exports.readVarString = readVarString$2;
|
|
35801
36319
|
exports.readVarUint = readVarUint$2;
|
|
35802
36320
|
exports.readVarUint8Array = readVarUint8Array$2;
|
|
35803
|
-
exports.schema = schema;
|
|
35804
36321
|
exports.setIfUndefined = setIfUndefined$1;
|
|
35805
36322
|
exports.toBase64 = toBase64;
|
|
35806
36323
|
exports.toUint8Array = toUint8Array$1;
|