kritzel-stencil 0.0.164 → 0.0.166
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-DJMYrkSu.js → default-line-tool.config-BNBO4I1t.js} +59 -36
- package/dist/cjs/default-line-tool.config-BNBO4I1t.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-color_22.cjs.entry.js +17 -8
- package/dist/collection/classes/core/core.class.js +9 -0
- package/dist/collection/classes/core/core.class.js.map +1 -1
- package/dist/collection/classes/objects/line.class.js +4 -3
- package/dist/collection/classes/objects/line.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +4 -1
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
- package/dist/collection/classes/tools/brush-tool.class.js +45 -30
- package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/selection-tool.class.js +4 -0
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +7 -7
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/components/index.js +3 -3
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-editor.js +3 -3
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/{p-Dz2XHHqa.js → p-Bwv1dxAB.js} +47 -32
- package/dist/components/{p-Dz2XHHqa.js.map → p-Bwv1dxAB.js.map} +1 -1
- package/dist/components/{p-DzUUppVL.js → p-CIXaR1a8.js} +31 -14
- package/dist/components/p-CIXaR1a8.js.map +1 -0
- package/dist/components/{p-tp96UZ0l.js → p-CRtmNOp1.js} +3 -3
- package/dist/components/{p-tp96UZ0l.js.map → p-CRtmNOp1.js.map} +1 -1
- package/dist/esm/{default-line-tool.config-C35P3XfD.js → default-line-tool.config-DJ488kil.js} +59 -36
- package/dist/{cjs/default-line-tool.config-DJMYrkSu.js.map → esm/default-line-tool.config-DJ488kil.js.map} +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/kritzel-color_22.entry.js +17 -8
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/{p-3e2b5c42.entry.js → p-3df115ed.entry.js} +3 -3
- package/dist/stencil/p-3df115ed.entry.js.map +1 -0
- package/dist/stencil/p-DJ488kil.js +2 -0
- package/dist/stencil/p-DJ488kil.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/objects/selection-group.class.d.ts +1 -0
- package/dist/types/classes/tools/brush-tool.class.d.ts +1 -0
- package/package.json +1 -1
- package/dist/components/p-DzUUppVL.js.map +0 -1
- package/dist/esm/default-line-tool.config-C35P3XfD.js.map +0 -1
- package/dist/stencil/p-3e2b5c42.entry.js.map +0 -1
- package/dist/stencil/p-C35P3XfD.js +0 -2
- package/dist/stencil/p-C35P3XfD.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { p as proxyCustomElement, H, c as createEvent, h, d as Host } from './p-CwkUrTy1.js';
|
|
2
2
|
import { K as KritzelMouseButton } from './p-D8W6LE-c.js';
|
|
3
|
-
import { e as KritzelBaseObject, f as KritzelGeometryHelper, g as KritzelBaseTool, h as KritzelEventHelper, i as KritzelToolRegistry, S as Schema, s as schema, j as addListNodes, E as EditorView, k as EditorState, l as keymap, T as TextSelection, d as KritzelKeyboardHelper, m as baseKeymap, c as KritzelTextTool, b as KritzelBrushTool, K as KritzelText, a as KritzelPath } from './p-
|
|
3
|
+
import { e as KritzelBaseObject, f as KritzelGeometryHelper, g as KritzelBaseTool, h as KritzelEventHelper, i as KritzelToolRegistry, S as Schema, s as schema, j as addListNodes, E as EditorView, k as EditorState, l as keymap, T as TextSelection, d as KritzelKeyboardHelper, m as baseKeymap, c as KritzelTextTool, b as KritzelBrushTool, K as KritzelText, a as KritzelPath } from './p-Bwv1dxAB.js';
|
|
4
4
|
import { K as KritzelContextMenu, d as defineCustomElement$3 } from './p-D1YAsWrL.js';
|
|
5
5
|
import { O as ObjectHelper } from './p-B0kd2rUI.js';
|
|
6
6
|
import { K as KritzelDevicesHelper } from './p-l10It7Nm.js';
|
|
@@ -195,20 +195,21 @@ class KritzelLine extends KritzelBaseObject {
|
|
|
195
195
|
this._core.store.state.objects.update(this);
|
|
196
196
|
}
|
|
197
197
|
hitTest(x, y) {
|
|
198
|
-
const
|
|
198
|
+
const strokeWidth = Math.max(this.strokeWidth, 10);
|
|
199
|
+
const halfStroke = strokeWidth / this.scale / 2;
|
|
199
200
|
if (this._adjustedPoints === null) {
|
|
200
201
|
this._adjustedPoints = this.computeAdjustedPoints();
|
|
201
202
|
}
|
|
202
203
|
// For curved lines, use distance to the Bezier curve
|
|
203
204
|
if (this.controlX !== undefined && this.controlY !== undefined) {
|
|
204
205
|
const distance = this.pointToBezierDistance(x, y);
|
|
205
|
-
return distance <= halfStroke
|
|
206
|
+
return distance <= halfStroke;
|
|
206
207
|
}
|
|
207
208
|
// For straight lines, use distance to line segment
|
|
208
209
|
const p1 = this._adjustedPoints[0];
|
|
209
210
|
const p2 = this._adjustedPoints[1];
|
|
210
211
|
const distance = this.pointToLineSegmentDistance(x, y, p1[0], p1[1], p2[0], p2[1]);
|
|
211
|
-
return distance <= halfStroke
|
|
212
|
+
return distance <= halfStroke;
|
|
212
213
|
}
|
|
213
214
|
hitTestPolygon(polygon) {
|
|
214
215
|
const halfStroke = this.strokeWidth / this.scale / 2;
|
|
@@ -693,7 +694,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
693
694
|
const deltaX = snapshot.translateX - this.translateX;
|
|
694
695
|
const deltaY = snapshot.translateY - this.translateY;
|
|
695
696
|
snapshot.translateX = x + deltaX;
|
|
696
|
-
snapshot.translateY =
|
|
697
|
+
snapshot.translateY = y + deltaY;
|
|
697
698
|
});
|
|
698
699
|
this.translateX = x;
|
|
699
700
|
this.translateY = y;
|
|
@@ -929,6 +930,9 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
929
930
|
const groupCenterY = this.translateY + this.totalHeight / this.scale / 2;
|
|
930
931
|
return objCenterY - groupCenterY;
|
|
931
932
|
}
|
|
933
|
+
hitTest(x, y) {
|
|
934
|
+
return this.objects.some(obj => obj.hitTest(x, y));
|
|
935
|
+
}
|
|
932
936
|
}
|
|
933
937
|
|
|
934
938
|
class KritzelLineTool extends KritzelBaseTool {
|
|
@@ -2603,6 +2607,10 @@ class KritzelSelectionTool extends KritzelBaseTool {
|
|
|
2603
2607
|
if (!object) {
|
|
2604
2608
|
return null;
|
|
2605
2609
|
}
|
|
2610
|
+
const { x, y } = this._core.getCanvasPoint(event);
|
|
2611
|
+
if (!object.hitTest(x, y)) {
|
|
2612
|
+
return null;
|
|
2613
|
+
}
|
|
2606
2614
|
if (object instanceof KritzelSelectionGroup) {
|
|
2607
2615
|
return object;
|
|
2608
2616
|
}
|
|
@@ -37688,6 +37696,9 @@ class KritzelCore {
|
|
|
37688
37696
|
const workspaces = this.loadWorkspacesFromAppState();
|
|
37689
37697
|
// Find most recently updated workspace or use provided/fallback
|
|
37690
37698
|
const mostRecentWorkspace = workspaces.length > 0 ? [...workspaces].sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime())[0] : null;
|
|
37699
|
+
// Check localStorage for last active workspace
|
|
37700
|
+
const lastActiveWorkspaceId = localStorage.getItem('kritzel-active-workspace-id');
|
|
37701
|
+
const lastActiveWorkspace = lastActiveWorkspaceId ? workspaces.find(w => w.id === lastActiveWorkspaceId) : null;
|
|
37691
37702
|
let activeWorkspace;
|
|
37692
37703
|
if (workspace) {
|
|
37693
37704
|
// Use provided workspace
|
|
@@ -37699,6 +37710,10 @@ class KritzelCore {
|
|
|
37699
37710
|
this.saveWorkspaceToAppState(activeWorkspace);
|
|
37700
37711
|
}
|
|
37701
37712
|
}
|
|
37713
|
+
else if (lastActiveWorkspace) {
|
|
37714
|
+
// Use last active workspace from localStorage
|
|
37715
|
+
activeWorkspace = lastActiveWorkspace;
|
|
37716
|
+
}
|
|
37702
37717
|
else if (mostRecentWorkspace) {
|
|
37703
37718
|
// Use most recent workspace
|
|
37704
37719
|
activeWorkspace = mostRecentWorkspace;
|
|
@@ -37709,6 +37724,8 @@ class KritzelCore {
|
|
|
37709
37724
|
activeWorkspace._core = this;
|
|
37710
37725
|
this.saveWorkspaceToAppState(activeWorkspace);
|
|
37711
37726
|
}
|
|
37727
|
+
// Save active workspace ID to localStorage
|
|
37728
|
+
localStorage.setItem('kritzel-active-workspace-id', activeWorkspace.id);
|
|
37712
37729
|
// Destroy old ObjectMap if switching workspaces
|
|
37713
37730
|
if (this._store.state.objects && this._store.state.objects.isReady) {
|
|
37714
37731
|
this._store.state.objects.destroy();
|
|
@@ -38630,16 +38647,16 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
38630
38647
|
pointerEvents: this.core.store.state.isScaling ? 'none' : 'auto',
|
|
38631
38648
|
} }, h("svg", { xmlns: "http://www.w3.org/2000/svg", id: object.id, class: "object", style: {
|
|
38632
38649
|
zIndex: object.zIndex.toString(),
|
|
38633
|
-
height: object?.totalHeight
|
|
38634
|
-
width: object?.totalWidth
|
|
38650
|
+
height: object?.totalHeight + 'px',
|
|
38651
|
+
width: object?.totalWidth + 'px',
|
|
38635
38652
|
left: '0',
|
|
38636
38653
|
top: '0',
|
|
38637
38654
|
position: 'absolute',
|
|
38638
|
-
transform: `rotate(${object.rotationDegrees}deg)
|
|
38639
|
-
transformOrigin: `${object.totalWidth / 2}px ${object.totalHeight / 2}px
|
|
38655
|
+
transform: object.rotationDegrees !== 0 ? `rotate(${object.rotationDegrees}deg)` : undefined,
|
|
38656
|
+
transformOrigin: object.rotationDegrees !== 0 ? `${object.totalWidth / 2}px ${object.totalHeight / 2}px` : undefined,
|
|
38640
38657
|
opacity: object.markedForRemoval ? '0.5' : object.opacity.toString(),
|
|
38641
38658
|
pointerEvents: object.markedForRemoval ? 'none' : 'auto',
|
|
38642
|
-
} }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (h("svg", { ref: el => object.mount(el), xmlns: "http://www.w3.org/2000/svg", style: { overflow: 'visible' }, viewBox: object?.viewBox }, h("path", { d: object?.d, fill: object.fill, stroke: object?.stroke, "shape-rendering": object.isLowRes() ? 'optimizeSpeed' : 'auto' }))), KritzelClassHelper.isInstanceOf(object, 'KritzelLine') && (h("svg", { ref: el => object.mount(el), xmlns: "http://www.w3.org/2000/svg", style: { overflow: 'visible' }, viewBox: object?.viewBox }, h("defs", null, object.hasStartArrow && (h("marker", { id: object.startMarkerId, markerWidth: object.getArrowSize('start'), markerHeight: object.getArrowSize('start'), refX: 0, refY: object.getArrowSize('start') / 2, orient: "auto-start-reverse", markerUnits: "userSpaceOnUse" }, h("path", { d: object.getArrowPath(object.arrows?.start?.style), fill: object.getArrowFill('start'), transform: `scale(${object.getArrowSize('start') / 10})` }))), object.hasEndArrow && (h("marker", { id: object.endMarkerId, markerWidth: object.getArrowSize('end'), markerHeight: object.getArrowSize('end'), refX: 0, refY: object.getArrowSize('end') / 2, orient: "auto", markerUnits: "userSpaceOnUse" }, h("path", { d: object.getArrowPath(object.arrows?.end?.style), fill: object.getArrowFill('end'), transform: `scale(${object.getArrowSize('end') / 10})` })))), h("path", { d: this.core.anchorManager.computeClippedLinePath(object), fill: "none", stroke: object?.stroke, "stroke-width": object?.strokeWidth, "stroke-linecap": "round", "marker-start": object.hasStartArrow ? `url(#${object.startMarkerId})` : undefined, "marker-end": object.hasEndArrow ? `url(#${object.endMarkerId})` : undefined }))), h("foreignObject", { x: "0", y: "0", width: object.totalWidth.toString(), height: object.totalHeight.toString(), style: {
|
|
38659
|
+
} }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (h("svg", { ref: el => object.mount(el), xmlns: "http://www.w3.org/2000/svg", style: { overflow: 'visible' }, viewBox: object?.viewBox }, h("path", { d: object?.d, fill: object.fill, stroke: object?.stroke, "shape-rendering": object.isLowRes() ? 'optimizeSpeed' : 'auto' }))), KritzelClassHelper.isInstanceOf(object, 'KritzelLine') && (h("svg", { ref: el => object.mount(el), xmlns: "http://www.w3.org/2000/svg", style: { overflow: 'visible' }, viewBox: object?.viewBox }, h("defs", null, object.hasStartArrow && (h("marker", { id: object.startMarkerId, markerWidth: object.getArrowSize('start'), markerHeight: object.getArrowSize('start'), refX: 0, refY: object.getArrowSize('start') / 2, orient: "auto-start-reverse", markerUnits: "userSpaceOnUse" }, h("path", { d: object.getArrowPath(object.arrows?.start?.style), fill: object.getArrowFill('start'), transform: `scale(${object.getArrowSize('start') / 10})` }))), object.hasEndArrow && (h("marker", { id: object.endMarkerId, markerWidth: object.getArrowSize('end'), markerHeight: object.getArrowSize('end'), refX: 0, refY: object.getArrowSize('end') / 2, orient: "auto", markerUnits: "userSpaceOnUse" }, h("path", { d: object.getArrowPath(object.arrows?.end?.style), fill: object.getArrowFill('end'), transform: `scale(${object.getArrowSize('end') / 10})` })))), h("path", { d: this.core.anchorManager.computeClippedLinePath(object), fill: "none", stroke: "transparent", "stroke-width": Math.max(object?.strokeWidth || 0, 10), "stroke-linecap": "round" }), h("path", { d: this.core.anchorManager.computeClippedLinePath(object), fill: "none", stroke: object?.stroke, "stroke-width": object?.strokeWidth, "stroke-linecap": "round", "marker-start": object.hasStartArrow ? `url(#${object.startMarkerId})` : undefined, "marker-end": object.hasEndArrow ? `url(#${object.endMarkerId})` : undefined }))), h("foreignObject", { x: "0", y: "0", width: object.totalWidth.toString(), height: object.totalHeight.toString(), style: {
|
|
38643
38660
|
minHeight: '0',
|
|
38644
38661
|
minWidth: '0',
|
|
38645
38662
|
backgroundColor: object.backgroundColor,
|
|
@@ -38869,7 +38886,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
38869
38886
|
stroke: 'var(--kritzel-snap-indicator-stroke, #3b82f6)',
|
|
38870
38887
|
strokeWidth: data.indicatorStrokeWidth,
|
|
38871
38888
|
} }))));
|
|
38872
|
-
})()), this.core.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: '
|
|
38889
|
+
})()), this.core.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: '70aefa0f3cf33036edb455dbe75448d2521e6dc9', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.core.store.state.contextMenuItems, objects: this.core.store.selectionGroup?.objects || [], style: {
|
|
38873
38890
|
position: 'fixed',
|
|
38874
38891
|
left: `${this.core.store.state.contextMenuX}px`,
|
|
38875
38892
|
top: `${this.core.store.state.contextMenuY}px`,
|
|
@@ -38880,7 +38897,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
38880
38897
|
y: (-this.core.store.state.translateY + this.core.store.state.contextMenuY) / this.core.store.state.scale,
|
|
38881
38898
|
}, this.core.store.selectionGroup?.objects);
|
|
38882
38899
|
this.hideContextMenu();
|
|
38883
|
-
}, onClose: () => this.hideContextMenu() })), this.core.store.state?.activeTool instanceof KritzelEraserTool && !this.core.store.state.isScaling && h("kritzel-cursor-trail", { key: '
|
|
38900
|
+
}, onClose: () => this.hideContextMenu() })), this.core.store.state?.activeTool instanceof KritzelEraserTool && !this.core.store.state.isScaling && h("kritzel-cursor-trail", { key: '68106a187ca81a38a819f1d52895b2858a8a28cb', core: this.core })));
|
|
38884
38901
|
}
|
|
38885
38902
|
static get watchers() { return {
|
|
38886
38903
|
"workspace": ["onWorkspaceChange"],
|
|
@@ -38964,6 +38981,6 @@ function defineCustomElement() {
|
|
|
38964
38981
|
}
|
|
38965
38982
|
|
|
38966
38983
|
export { isNode as A, min$2 as B, pow as C, HocuspocusProviderWebsocket as D, KritzelLine as E, KritzelLineTool as F, KritzelEraserTool as G, HocuspocusProvider as H, KritzelImageTool as I, KritzelCursorHelper as J, KritzelImage as K, KritzelSelectionTool as L, IndexedDBSyncProvider as M, KritzelAppStateMap as N, Observable$1 as O, KritzelAnchorManager as P, ABSOLUTE_SCALE_MAX as Q, ABSOLUTE_SCALE_MIN as R, ShapeType as S, KritzelShapeTool as T, defineCustomElement as U, KritzelEngine as V, writeVarUint8Array$2 as a, readVarUint8Array$2 as b, applyUpdate as c, encodeStateVector as d, encodeStateAsUpdate as e, createEncoder$1 as f, createDecoder$1 as g, create$8 as h, fromBase64 as i, toBase64 as j, createUint8ArrayFromArrayBuffer as k, offChange as l, readVarString$2 as m, floor$2 as n, onChange as o, getUnixTime$1 as p, equalityDeep$1 as q, readVarUint$2 as r, setIfUndefined$1 as s, toUint8Array$1 as t, writeVarString$2 as u, varStorage as v, writeVarUint$2 as w, map as x, ObservableV2 as y, length$3 as z };
|
|
38967
|
-
//# sourceMappingURL=p-
|
|
38984
|
+
//# sourceMappingURL=p-CIXaR1a8.js.map
|
|
38968
38985
|
|
|
38969
|
-
//# sourceMappingURL=p-
|
|
38986
|
+
//# sourceMappingURL=p-CIXaR1a8.js.map
|