kritzel-stencil 0.0.114 → 0.0.116
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/{index-C2M4eyxF.js → index-aaWestcD.js} +177 -2
- package/dist/cjs/index-aaWestcD.js.map +1 -0
- package/dist/cjs/index.cjs.js +3 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +76 -222
- package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stencil.cjs.js +1 -1
- package/dist/collection/classes/objects/base-object.class.js +3 -0
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/path.class.js +2 -2
- package/dist/collection/classes/objects/path.class.js.map +1 -1
- package/dist/collection/classes/registries/icon-registry.class.js +18 -18
- package/dist/collection/classes/registries/icon-registry.class.js.map +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +54 -2
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +51 -25
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.css +1 -1
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.css +1 -1
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.css +3 -3
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +3 -4
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.css +2 -2
- package/dist/collection/configs/default-engine-state.js +1 -0
- package/dist/collection/configs/default-engine-state.js.map +1 -1
- package/dist/collection/helpers/class.helper.js +6 -0
- package/dist/collection/helpers/class.helper.js.map +1 -0
- package/dist/collection/index.js +2 -0
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
- package/dist/collection/interfaces/object.interface.js.map +1 -1
- package/dist/components/index.js +2 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/kritzel-brush-style.js +1 -1
- package/dist/components/kritzel-context-menu.js +1 -1
- package/dist/components/kritzel-control-brush-config.js +1 -1
- package/dist/components/kritzel-control-text-config.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-dropdown.js +1 -1
- package/dist/components/kritzel-editor.js +25 -15
- package/dist/components/kritzel-editor.js.map +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-font-family.js +1 -1
- package/dist/components/kritzel-icon.js +1 -1
- package/dist/components/kritzel-tooltip.js +1 -1
- package/dist/components/kritzel-utility-panel.js +1 -1
- package/dist/components/{p-DLV-5gE_.js → p-B8nuvSxt.js} +5 -5
- package/dist/components/{p-DLV-5gE_.js.map → p-B8nuvSxt.js.map} +1 -1
- package/dist/components/{p-aZgXbW1r.js → p-BAWNhoRC.js} +72 -56
- package/dist/components/{p-aZgXbW1r.js.map → p-BAWNhoRC.js.map} +1 -1
- package/dist/components/{p-C9ZagG9K.js → p-BBIuV3j1.js} +3 -3
- package/dist/components/{p-C9ZagG9K.js.map → p-BBIuV3j1.js.map} +1 -1
- package/dist/components/{p-BH1Tkwyh.js → p-BV9-NuyD.js} +4 -4
- package/dist/components/{p-BH1Tkwyh.js.map → p-BV9-NuyD.js.map} +1 -1
- package/dist/components/p-C6kzcN4b.js +90 -0
- package/dist/components/p-C6kzcN4b.js.map +1 -0
- package/dist/components/{p-CRiUM-tD.js → p-CYnE3twZ.js} +4 -4
- package/dist/components/p-CYnE3twZ.js.map +1 -0
- package/dist/components/{p-C9FTWNZY.js → p-CtNzxQ7T.js} +3 -3
- package/dist/components/p-CtNzxQ7T.js.map +1 -0
- package/dist/components/{p-BIlVkMTU.js → p-DRuQsvUx.js} +8 -5
- package/dist/components/p-DRuQsvUx.js.map +1 -0
- package/dist/components/{p-BtjtAfGW.js → p-JQA2FRVr.js} +5 -5
- package/dist/components/{p-BtjtAfGW.js.map → p-JQA2FRVr.js.map} +1 -1
- package/dist/components/{p-h3bqYufZ.js → p-LIijWPsT.js} +3 -3
- package/dist/components/p-LIijWPsT.js.map +1 -0
- package/dist/components/{p-B94Na1ee.js → p-eBBOf568.js} +4 -4
- package/dist/components/p-eBBOf568.js.map +1 -0
- package/dist/components/{p-mz1ayKXG.js → p-o2f4ejEa.js} +12 -12
- package/dist/components/p-o2f4ejEa.js.map +1 -0
- package/dist/esm/{index-rckCSz7Y.js → index-Dn7aP72S.js} +176 -3
- package/dist/esm/index-Dn7aP72S.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-brush-style_18.entry.js +69 -215
- package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/stencil.js +1 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-Dn7aP72S.js +2 -0
- package/dist/stencil/p-Dn7aP72S.js.map +1 -0
- package/dist/stencil/p-b626c6a2.entry.js +2 -0
- package/dist/stencil/p-b626c6a2.entry.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/objects/base-object.class.d.ts +1 -0
- package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +4 -1
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +2 -1
- package/dist/types/components.d.ts +20 -2
- package/dist/types/helpers/class.helper.d.ts +3 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/interfaces/engine-state.interface.d.ts +1 -0
- package/dist/types/interfaces/object.interface.d.ts +1 -0
- package/package.json +4 -7
- package/dist/cjs/index-C2M4eyxF.js.map +0 -1
- package/dist/components/p-B94Na1ee.js.map +0 -1
- package/dist/components/p-BIlVkMTU.js.map +0 -1
- package/dist/components/p-C9FTWNZY.js.map +0 -1
- package/dist/components/p-CRiUM-tD.js.map +0 -1
- package/dist/components/p-h3bqYufZ.js.map +0 -1
- package/dist/components/p-ksTCzgsY.js +0 -90
- package/dist/components/p-ksTCzgsY.js.map +0 -1
- package/dist/components/p-mz1ayKXG.js.map +0 -1
- package/dist/esm/index-rckCSz7Y.js.map +0 -1
- package/dist/stencil/p-9394d74e.entry.js +0 -2
- package/dist/stencil/p-9394d74e.entry.js.map +0 -1
- package/dist/stencil/p-rckCSz7Y.js +0 -2
- package/dist/stencil/p-rckCSz7Y.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-CGHvfMWF.js';
|
|
2
|
-
import { K as
|
|
2
|
+
import { K as KritzelBaseTool, a as KritzelEventHelper, b as KritzelPath, A as AddObjectCommand, c as KritzelTextTool, d as KritzelMouseButton, e as KritzelBaseCommand, f as KritzelBaseObject, g as KritzelImage, h as KritzelText, O as ObjectHelper, i as KritzelToolRegistry, j as KritzelKeyboardHelper } from './index-Dn7aP72S.js';
|
|
3
3
|
|
|
4
4
|
const kritzelBrushStyleCss = ":host{display:flex;align-items:flex-start;gap:8px;padding:8px;box-sizing:border-box;width:100%}.brush-style-button{display:flex;justify-content:center;align-items:center;width:42px;height:32px;padding:0;border:none;outline:none;background:none;cursor:default;border-radius:0;color:var(--control-text-color);font-weight:bold;-webkit-tap-highlight-color:transparent}.font-style-button:not(:last-child){border-right:1px solid #333333}.font-style-button:hover{background-color:var(--control-hover-bg)}.font-style-button:active{background-color:var(--control-active-bg)}.font-style-button.selected,.font-style-button.selected:hover,.font-style-button.selected:active{background-color:var(--control-selected-bg);color:var(--control-selected-color)}";
|
|
5
5
|
|
|
@@ -120,7 +120,7 @@ const KritzelColorPalette = class {
|
|
|
120
120
|
};
|
|
121
121
|
KritzelColorPalette.style = kritzelColorPaletteCss;
|
|
122
122
|
|
|
123
|
-
const kritzelContextMenuCss = ":host{display:block}.menu-container{display:flex;flex-direction:column;background-color:var(--kritzel-context-menu-background-color, #ffffff);border-radius:var(--kritzel-context-menu-border-radius,
|
|
123
|
+
const kritzelContextMenuCss = ":host{display:block}.menu-container{display:flex;flex-direction:column;background-color:var(--kritzel-context-menu-background-color, #ffffff);border-radius:var(--kritzel-context-menu-border-radius, 12px);box-shadow:var(--kritzel-context-menu-box-shadow, 0 1px 6px rgba(0, 0, 0, 0.12));border:var(--kritzel-context-menu-border, 1px solid #f0f0f0);padding:var(--kritzel-context-menu-padding,4px)}.menu-item{display:flex;align-items:center;gap:var(--kritzel-context-menu-item-gap, 8px);background:none;border:none;text-align:left;padding:var(--kritzel-context-menu-item-padding, 8px);border-radius:var(--kritzel-context-menu-item-border-radius, 12px);cursor:pointer;font-size:var(--kritzel-context-menu-item-font-size, 14px);color:var(--kritzel-context-menu-item-color, #333333);white-space:nowrap;-webkit-tap-highlight-color:transparent}.menu-item:not(.disabled):hover{background-color:var(--kritzel-context-menu-item-hover-background-color, hsl(0, 0%, 0%, 4.3%))}.menu-item:not(.disabled):active{background-color:var(--kritzel-context-menu-item-active-background-color, hsl(0, 0%, 0%, 8.6%))}.menu-item.disabled{color:var(--kritzel-context-menu-item-disabled-color, #aaaaaa);cursor:default}.menu-item kritzel-icon{opacity:0.8;flex-shrink:0}.menu-item.disabled kritzel-icon{opacity:0.4}.label{flex-grow:1}";
|
|
124
124
|
|
|
125
125
|
const KritzelContextMenu = class {
|
|
126
126
|
constructor(hostRef) {
|
|
@@ -224,145 +224,6 @@ const KritzelControlTextConfig = class {
|
|
|
224
224
|
};
|
|
225
225
|
KritzelControlTextConfig.style = kritzelControlTextConfigCss;
|
|
226
226
|
|
|
227
|
-
var cjs = {};
|
|
228
|
-
|
|
229
|
-
var hasRequiredCjs;
|
|
230
|
-
|
|
231
|
-
function requireCjs () {
|
|
232
|
-
if (hasRequiredCjs) return cjs;
|
|
233
|
-
hasRequiredCjs = 1;
|
|
234
|
-
(function (exports) {
|
|
235
|
-
var pe=Object.defineProperty;var ge=e=>pe(e,"__esModule",{value:true});var de=(e,t)=>{ge(e);for(var s in t)pe(e,s,{get:t[s],enumerable:true});};de(exports,{default:()=>ve,getStroke:()=>ne,getStrokeOutlinePoints:()=>te,getStrokePoints:()=>re});function $(e,t,s,x=h=>h){return e*x(.5-t*(.5-s))}function ce(e){return [-e[0],-e[1]]}function l(e,t){return [e[0]+t[0],e[1]+t[1]]}function a(e,t){return [e[0]-t[0],e[1]-t[1]]}function b(e,t){return [e[0]*t,e[1]*t]}function xe(e,t){return [e[0]/t,e[1]/t]}function R(e){return [e[1],-e[0]]}function B(e,t){return e[0]*t[0]+e[1]*t[1]}function me(e,t){return e[0]===t[0]&&e[1]===t[1]}function Se(e){return Math.hypot(e[0],e[1])}function Pe(e){return e[0]*e[0]+e[1]*e[1]}function A(e,t){return Pe(a(e,t))}function G(e){return xe(e,Se(e))}function ae(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function L(e,t,s){let x=Math.sin(s),h=Math.cos(s),y=e[0]-t[0],n=e[1]-t[1],f=y*h-n*x,d=y*x+n*h;return [f+t[0],d+t[1]]}function K(e,t,s){return l(e,b(a(t,e),s))}function ee(e,t,s){return l(e,b(t,s))}var{min:C,PI:ke}=Math,le=.275,V=ke+1e-4;function te(e,t={}){let{size:s=16,smoothing:x=.5,thinning:h=.5,simulatePressure:y=true,easing:n=r=>r,start:f={},end:d={},last:D=false}=t,{cap:S=true,easing:j=r=>r*(2-r)}=f,{cap:q=true,easing:c=r=>--r*r*r+1}=d;if(e.length===0||s<=0)return [];let p=e[e.length-1].runningLength,g=f.taper===false?0:f.taper===true?Math.max(s,p):f.taper,T=d.taper===false?0:d.taper===true?Math.max(s,p):d.taper,oe=Math.pow(s*x,2),_=[],M=[],H=e.slice(0,10).reduce((r,i)=>{let o=i.pressure;if(y){let u=C(1,i.distance/s),W=C(1,1-u);o=C(1,r+(W-r)*(u*le));}return (r+o)/2},e[0].pressure),m=$(s,h,e[e.length-1].pressure,n),U,X=e[0].vector,z=e[0].point,F=z,O=z,E=F,J=false;for(let r=0;r<e.length;r++){let{pressure:i}=e[r],{point:o,vector:u,distance:W,runningLength:I}=e[r];if(r<e.length-1&&p-I<3)continue;if(h){if(y){let v=C(1,W/s),Z=C(1,1-v);i=C(1,H+(Z-H)*(v*le));}m=$(s,h,i,n);}else m=s/2;U===void 0&&(U=m);let fe=I<g?j(I/g):1,be=p-I<T?c((p-I)/T):1;m=Math.max(.01,m*Math.min(fe,be));let se=(r<e.length-1?e[r+1]:e[r]).vector,Y=r<e.length-1?B(u,se):1,he=B(u,X)<0&&!J,ue=Y!==null&&Y<0;if(he||ue){let v=b(R(X),m);for(let Z=1/13,w=0;w<=1;w+=Z)O=L(a(o,v),o,V*w),_.push(O),E=L(l(o,v),o,V*-w),M.push(E);z=O,F=E,ue&&(J=true);continue}if(J=false,r===e.length-1){let v=b(R(u),m);_.push(a(o,v)),M.push(l(o,v));continue}let ie=b(R(K(se,u,Y)),m);O=a(o,ie),(r<=1||A(z,O)>oe)&&(_.push(O),z=O),E=l(o,ie),(r<=1||A(F,E)>oe)&&(M.push(E),F=E),H=i,X=u;}let P=e[0].point.slice(0,2),k=e.length>1?e[e.length-1].point.slice(0,2):l(e[0].point,[1,1]),Q=[],N=[];if(e.length===1){if(!(g||T)||D){let r=ee(P,G(R(a(P,k))),-(U||m)),i=[];for(let o=1/13,u=o;u<=1;u+=o)i.push(L(r,P,V*2*u));return i}}else {if(!(g||T&&e.length===1))if(S)for(let i=1/13,o=i;o<=1;o+=i){let u=L(M[0],P,V*o);Q.push(u);}else {let i=a(_[0],M[0]),o=b(i,.5),u=b(i,.51);Q.push(a(P,o),a(P,u),l(P,u),l(P,o));}let r=R(ce(e[e.length-1].vector));if(T||g&&e.length===1)N.push(k);else if(q){let i=ee(k,r,m);for(let o=1/29,u=o;u<1;u+=o)N.push(L(i,k,V*3*u));}else N.push(l(k,b(r,m)),l(k,b(r,m*.99)),a(k,b(r,m*.99)),a(k,b(r,m)));}return _.concat(N,M.reverse(),Q)}function re(e,t={}){var q;let{streamline:s=.5,size:x=16,last:h=false}=t;if(e.length===0)return [];let y=.15+(1-s)*.85,n=Array.isArray(e[0])?e:e.map(({x:c,y:p,pressure:g=.5})=>[c,p,g]);if(n.length===2){let c=n[1];n=n.slice(0,-1);for(let p=1;p<5;p++)n.push(K(n[0],c,p/4));}n.length===1&&(n=[...n,[...l(n[0],[1,1]),...n[0].slice(2)]]);let f=[{point:[n[0][0],n[0][1]],pressure:n[0][2]>=0?n[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],d=false,D=0,S=f[0],j=n.length-1;for(let c=1;c<n.length;c++){let p=h&&c===j?n[c].slice(0,2):K(S.point,n[c],y);if(me(S.point,p))continue;let g=ae(p,S.point);if(D+=g,c<j&&!d){if(D<x)continue;d=true;}S={point:p,pressure:n[c][2]>=0?n[c][2]:.5,vector:G(a(S.point,p)),distance:g,runningLength:D},f.push(S);}return f[0].vector=((q=f[1])==null?void 0:q.vector)||[0,0],f}function ne(e,t={}){return te(re(e,t),t)}var ve=ne;
|
|
236
|
-
} (cjs));
|
|
237
|
-
return cjs;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
var cjsExports = requireCjs();
|
|
241
|
-
|
|
242
|
-
class KritzelMathHelper {
|
|
243
|
-
static average(a, b) {
|
|
244
|
-
return (a + b) / 2;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
class KritzelPath extends KritzelBaseObject {
|
|
249
|
-
constructor() {
|
|
250
|
-
super(...arguments);
|
|
251
|
-
this.__class__ = 'KritzelPath';
|
|
252
|
-
this.stroke = 'none';
|
|
253
|
-
this.lineSlack = 0.5;
|
|
254
|
-
this.x = 0;
|
|
255
|
-
this.y = 0;
|
|
256
|
-
this.height = 0;
|
|
257
|
-
this.width = 0;
|
|
258
|
-
this.scale = 1;
|
|
259
|
-
this.visible = true;
|
|
260
|
-
this.debugInfoVisible = true;
|
|
261
|
-
}
|
|
262
|
-
get viewBox() {
|
|
263
|
-
return `${this.x} ${this.y} ${this.width} ${this.height}`;
|
|
264
|
-
}
|
|
265
|
-
static create(store, options) {
|
|
266
|
-
var _a, _b, _c, _d, _e, _f;
|
|
267
|
-
const object = new KritzelPath();
|
|
268
|
-
object._store = store;
|
|
269
|
-
object.id = object.generateId();
|
|
270
|
-
object.options = options;
|
|
271
|
-
object.points = (_a = options === null || options === void 0 ? void 0 : options.points) !== null && _a !== void 0 ? _a : [];
|
|
272
|
-
object.translateX = (_b = options === null || options === void 0 ? void 0 : options.translateX) !== null && _b !== void 0 ? _b : 0;
|
|
273
|
-
object.translateY = (_c = options === null || options === void 0 ? void 0 : options.translateY) !== null && _c !== void 0 ? _c : 0;
|
|
274
|
-
object.scale = (_d = options === null || options === void 0 ? void 0 : options.scale) !== null && _d !== void 0 ? _d : 1;
|
|
275
|
-
object.strokeWidth = (_e = options === null || options === void 0 ? void 0 : options.strokeWidth) !== null && _e !== void 0 ? _e : 8;
|
|
276
|
-
object.fill = (_f = options === null || options === void 0 ? void 0 : options.fill) !== null && _f !== void 0 ? _f : '#000000';
|
|
277
|
-
object.zIndex = store.currentZIndex;
|
|
278
|
-
object.d = object.generateSvgPath();
|
|
279
|
-
object.updateDimensions();
|
|
280
|
-
return object;
|
|
281
|
-
}
|
|
282
|
-
resize(x, y, width, height) {
|
|
283
|
-
if (width <= 1 || height <= 1) {
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
const scaleX = width / this.width;
|
|
287
|
-
const scaleY = height / this.height;
|
|
288
|
-
this.width = width;
|
|
289
|
-
this.height = height;
|
|
290
|
-
this.points = this.points.map(([x, y]) => [x * scaleX, y * scaleY]);
|
|
291
|
-
this.d = this.generateSvgPath();
|
|
292
|
-
this.width = Math.max(...this.points.map(p => p[0])) - Math.min(...this.points.map(p => p[0])) + this.strokeWidth;
|
|
293
|
-
this.height = Math.max(...this.points.map(p => p[1])) - Math.min(...this.points.map(p => p[1])) + this.strokeWidth;
|
|
294
|
-
this.x = Math.min(...this.points.map(p => p[0])) - this.strokeWidth / 2;
|
|
295
|
-
this.y = Math.min(...this.points.map(p => p[1])) - this.strokeWidth / 2;
|
|
296
|
-
this.translateX = x;
|
|
297
|
-
this.translateY = y;
|
|
298
|
-
}
|
|
299
|
-
rotate(value) {
|
|
300
|
-
super.rotate(value);
|
|
301
|
-
this.updateDimensions();
|
|
302
|
-
}
|
|
303
|
-
updateDimensions() {
|
|
304
|
-
const rotatedPoints = this.points.map(([x, y]) => {
|
|
305
|
-
const rotatedX = x * Math.cos(this.rotation) - y * Math.sin(this.rotation);
|
|
306
|
-
const rotatedY = x * Math.sin(this.rotation) + y * Math.cos(this.rotation);
|
|
307
|
-
return [rotatedX, rotatedY];
|
|
308
|
-
});
|
|
309
|
-
const minX = Math.min(...rotatedPoints.map(p => p[0] - this.strokeWidth / 2));
|
|
310
|
-
const minY = Math.min(...rotatedPoints.map(p => p[1] - this.strokeWidth / 2));
|
|
311
|
-
const maxX = Math.max(...rotatedPoints.map(p => p[0] + this.strokeWidth / 2));
|
|
312
|
-
const maxY = Math.max(...rotatedPoints.map(p => p[1] + this.strokeWidth / 2));
|
|
313
|
-
this.width = maxX - minX + this.lineSlack; // Add 0.5 to avoid rounding issues
|
|
314
|
-
this.height = maxY - minY + this.lineSlack; // Add 0.5 to avoid rounding issues
|
|
315
|
-
this.x = minX;
|
|
316
|
-
this.y = minY;
|
|
317
|
-
this.translateX = (this.x + this.translateX) / this.scale;
|
|
318
|
-
this.translateY = (this.y + this.translateY) / this.scale;
|
|
319
|
-
}
|
|
320
|
-
generateSvgPath() {
|
|
321
|
-
const stroke = this.getStrokeFromPoints(this.points, this.strokeWidth);
|
|
322
|
-
return this.getSvgPathFromStroke(stroke);
|
|
323
|
-
}
|
|
324
|
-
getStrokeFromPoints(points, strokeWidth) {
|
|
325
|
-
return cjsExports.getStroke(points, {
|
|
326
|
-
size: strokeWidth,
|
|
327
|
-
thinning: 0.5,
|
|
328
|
-
smoothing: 0.5,
|
|
329
|
-
streamline: 0.5,
|
|
330
|
-
easing: t => t,
|
|
331
|
-
simulatePressure: true,
|
|
332
|
-
last: true,
|
|
333
|
-
start: {
|
|
334
|
-
cap: true,
|
|
335
|
-
taper: 0,
|
|
336
|
-
easing: t => t,
|
|
337
|
-
},
|
|
338
|
-
end: {
|
|
339
|
-
cap: true,
|
|
340
|
-
taper: 0,
|
|
341
|
-
easing: t => t,
|
|
342
|
-
},
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
getSvgPathFromStroke(points, closed = true) {
|
|
346
|
-
const len = points.length;
|
|
347
|
-
if (len < 4) {
|
|
348
|
-
return ``;
|
|
349
|
-
}
|
|
350
|
-
let a = points[0];
|
|
351
|
-
let b = points[1];
|
|
352
|
-
const c = points[2];
|
|
353
|
-
let result = `M${a[0].toFixed(2)},${a[1].toFixed(2)} Q${b[0].toFixed(2)},${b[1].toFixed(2)} ${KritzelMathHelper.average(b[0], c[0]).toFixed(2)},${KritzelMathHelper.average(b[1], c[1]).toFixed(2)} T`;
|
|
354
|
-
for (let i = 2, max = len - 1; i < max; i++) {
|
|
355
|
-
a = points[i];
|
|
356
|
-
b = points[i + 1];
|
|
357
|
-
result += `${KritzelMathHelper.average(a[0], b[0]).toFixed(2)},${KritzelMathHelper.average(a[1], b[1]).toFixed(2)} `;
|
|
358
|
-
}
|
|
359
|
-
if (closed) {
|
|
360
|
-
result += 'Z';
|
|
361
|
-
}
|
|
362
|
-
return result;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
227
|
class KritzelBrushTool extends KritzelBaseTool {
|
|
367
228
|
constructor(store) {
|
|
368
229
|
super(store);
|
|
@@ -481,7 +342,7 @@ class KritzelDevicesHelper {
|
|
|
481
342
|
}
|
|
482
343
|
}
|
|
483
344
|
|
|
484
|
-
const kritzelControlsCss = ":host{display:flex;flex-direction:column;user-select:none}.kritzel-controls{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:var(--kritzel-controls-gap, 8px);height:100%;padding:var(--kritzel-controls-padding, 8px);background-color:var(--kritzel-controls-background-color, #ffffff);border-radius:var(--kritzel-controls-border-radius,
|
|
345
|
+
const kritzelControlsCss = ":host{display:flex;flex-direction:column;user-select:none}.kritzel-controls{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:var(--kritzel-controls-gap, 8px);height:100%;padding:var(--kritzel-controls-padding, 8px);background-color:var(--kritzel-controls-background-color, #ffffff);border-radius:var(--kritzel-controls-border-radius, 16px);box-shadow:var(--kritzel-controls-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));border:var(--kritzel-controls-border, 1px solid #f0f0f0);z-index:10000;position:relative}.kritzel-control{display:flex;justify-content:center;align-items:center;color:var(--kritzel-controls-control-color, #000000);border-radius:var(--kritzel-controls-control-border-radius, 12px);padding:var(--kritzel-controls-control-padding, 8px);border:none;outline:none;background:none;cursor:pointer;-webkit-tap-highlight-color:transparent;font-weight:bold}.kritzel-control:hover{background-color:var(--kritzel-controls-control-hover-background-color, hsl(0, 0%, 0%, 4.3%))}:host(.mobile) .kritzel-control:hover{background-color:unset}.kritzel-control:active{background-color:var(--kritzel-controls-control-active-background-color, hsl(0, 0%, 0%, 8.6%))}:host(.mobile) .kritzel-control:active{background-color:unset}.kritzel-control.selected,.kritzel-control.selected:hover,.kritzel-control.selected:active{background-color:var(--kritzel-controls-control-selected-background-color, #0E1111) !important;color:var(--kritzel-controls-control-selected-color, #ffffff) !important}.kritzel-divider{width:var(--kritzel-controls-divider-width, 1px);height:var(--kritzel-controls-divider-height, 24px);background-color:var(--kritzel-controls-divider-background-color, hsl(0, 0%, 0%, 4.3%))}.kritzel-config-container{position:relative;display:flex;justify-content:center;align-items:center;width:40px;height:40px;box-sizing:border-box;-webkit-tap-highlight-color:transparent}.kritzel-config{display:flex;justify-content:center;align-items:center;cursor:pointer}.color-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #f0f0f0)}.font-container{display:flex;justify-content:center;align-items:center;width:32px;height:32px;border-radius:50%;cursor:pointer;border:2px solid transparent;box-sizing:border-box;background-color:var(--kritzel-color-palette-hover-background-color, #f0f0f0)}.no-config{height:24px;width:24px;border-radius:50%;border:1px dashed gray}kritzel-tooltip{position:fixed;bottom:66px;left:50%;transform:translateX(-50%);z-index:10001}";
|
|
485
346
|
|
|
486
347
|
const KritzelControls = class {
|
|
487
348
|
constructor(hostRef) {
|
|
@@ -693,7 +554,7 @@ const KritzelCursorTrail = class {
|
|
|
693
554
|
};
|
|
694
555
|
KritzelCursorTrail.style = kritzelCursorTrailCss;
|
|
695
556
|
|
|
696
|
-
const kritzelDropdownCss = ":host{display:inline-flex;vertical-align:middle;width:100%;}.dropdown-wrapper{display:flex;align-items:center;border:1px solid #333333;border-radius:var(--kritzel-controls-control-border-radius,
|
|
557
|
+
const kritzelDropdownCss = ":host{display:inline-flex;vertical-align:middle;width:100%;}.dropdown-wrapper{display:flex;align-items:center;border:1px solid #333333;border-radius:var(--kritzel-controls-control-border-radius, 12px);overflow:hidden;height:32px;width:100%}.custom-select{padding:0 8px;padding-right:30px;height:100%;width:100%;box-sizing:border-box;border-radius:0;border:none;background-color:#fff;cursor:pointer;outline:none;font-size:inherit;color:var(--kritzel-controls-text-color, #333333);-webkit-tap-highlight-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"%23333333\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"6 9 12 15 18 9\"/></svg>');background-size:16px 16px;background-repeat:no-repeat;background-position:right 8px center}.custom-select.has-suffix-border{border-right:1px solid #333333}.custom-select.has-prefix-border{border-left:1px solid #333333}::slotted(*){height:100%;box-sizing:border-box}";
|
|
697
558
|
|
|
698
559
|
const KritzelDropdown = class {
|
|
699
560
|
constructor(hostRef) {
|
|
@@ -806,24 +667,24 @@ class KritzelIconRegistry {
|
|
|
806
667
|
}
|
|
807
668
|
KritzelIconRegistry.registry = new Map();
|
|
808
669
|
KritzelIconRegistry.registerIcons({
|
|
809
|
-
'cursor': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
810
|
-
'pen': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
811
|
-
'highlighter': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
812
|
-
'eraser': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
813
|
-
'type': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
814
|
-
'image': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
815
|
-
'chevron-down': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
816
|
-
'chevron-up': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
817
|
-
'copy': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
818
|
-
'paste': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
819
|
-
'cut': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
820
|
-
'delete': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
821
|
-
'bring-to-front': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
822
|
-
'send-to-back': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
823
|
-
'select-all': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
824
|
-
'download': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
825
|
-
'undo': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
826
|
-
'redo': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
670
|
+
'cursor': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"/></svg>',
|
|
671
|
+
'pen': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/></svg>',
|
|
672
|
+
'highlighter': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-highlighter-icon lucide-highlighter"><path d="m9 11-6 6v3h9l3-3"/><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"/></svg>',
|
|
673
|
+
'eraser': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg>',
|
|
674
|
+
'type': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 7 4 4 20 4 20 7"/><line x1="9" x2="15" y1="20" y2="20"/><line x1="12" x2="12" y1="4" y2="20"/></svg>',
|
|
675
|
+
'image': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>',
|
|
676
|
+
'chevron-down': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>',
|
|
677
|
+
'chevron-up': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>',
|
|
678
|
+
'copy': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy-icon lucide-copy"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',
|
|
679
|
+
'paste': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-clipboard-paste-icon lucide-clipboard-paste"><path d="M11 14h10"/><path d="M16 4h2a2 2 0 0 1 2 2v1.344"/><path d="m17 18 4-4-4-4"/><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>',
|
|
680
|
+
'cut': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-scissors-icon lucide-scissors"><circle cx="6" cy="6" r="3"/><path d="M8.12 8.12 12 12"/><path d="M20 4 8.12 15.88"/><circle cx="6" cy="18" r="3"/><path d="M14.8 14.8 20 20"/></svg>',
|
|
681
|
+
'delete': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash2-icon lucide-trash-2"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/></svg>',
|
|
682
|
+
'bring-to-front': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-up-to-line-icon lucide-arrow-up-to-line"><path d="M5 3h14"/><path d="m18 13-6-6-6 6"/><path d="M12 7v14"/></svg>',
|
|
683
|
+
'send-to-back': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-down-to-line-icon lucide-arrow-down-to-line"><path d="M12 17V3"/><path d="m6 11 6 6 6-6"/><path d="M19 21H5"/></svg>',
|
|
684
|
+
'select-all': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square-mouse-pointer-icon lucide-square-mouse-pointer"><path d="M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"/><path d="M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"/></svg>',
|
|
685
|
+
'download': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-download-icon lucide-download"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>',
|
|
686
|
+
'undo': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-undo-icon lucide-undo"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/></svg>',
|
|
687
|
+
'redo': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-redo-icon lucide-redo"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"/></svg>'
|
|
827
688
|
});
|
|
828
689
|
|
|
829
690
|
class BatchCommand extends KritzelBaseCommand {
|
|
@@ -931,37 +792,6 @@ class KritzelEraserTool extends KritzelBaseTool {
|
|
|
931
792
|
}
|
|
932
793
|
}
|
|
933
794
|
|
|
934
|
-
class KritzelImage extends KritzelBaseObject {
|
|
935
|
-
constructor() {
|
|
936
|
-
super(...arguments);
|
|
937
|
-
this.__class__ = 'KritzelImage';
|
|
938
|
-
this.src = '';
|
|
939
|
-
this.debugInfoVisible = true;
|
|
940
|
-
}
|
|
941
|
-
static create(store) {
|
|
942
|
-
const object = new KritzelImage();
|
|
943
|
-
object._store = store;
|
|
944
|
-
object.id = object.generateId();
|
|
945
|
-
object.x = 0;
|
|
946
|
-
object.y = 0;
|
|
947
|
-
object.translateX = 0;
|
|
948
|
-
object.translateY = 0;
|
|
949
|
-
object.scale = object._store.state.scale;
|
|
950
|
-
object.zIndex = store.currentZIndex;
|
|
951
|
-
return object;
|
|
952
|
-
}
|
|
953
|
-
resize(x, y, width, height) {
|
|
954
|
-
if (width <= 1 || height <= 1) {
|
|
955
|
-
return;
|
|
956
|
-
}
|
|
957
|
-
const scaleFactor = height / this.height;
|
|
958
|
-
this.width = this.width * scaleFactor;
|
|
959
|
-
this.height = this.height * scaleFactor;
|
|
960
|
-
this.translateX = x;
|
|
961
|
-
this.translateY = y;
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
|
|
965
795
|
class RemoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
966
796
|
constructor(store, initiator) {
|
|
967
797
|
super(store, initiator);
|
|
@@ -2284,6 +2114,7 @@ const kritzelEditorCss = "kritzel-editor{display:flex;margin:0;position:relative
|
|
|
2284
2114
|
const KritzelEditor = class {
|
|
2285
2115
|
constructor(hostRef) {
|
|
2286
2116
|
registerInstance(this, hostRef);
|
|
2117
|
+
this.isReady = createEvent(this, "isReady");
|
|
2287
2118
|
this.controls = DEFAULT_KRITZEL_CONTROLS;
|
|
2288
2119
|
this.customSvgIcons = {};
|
|
2289
2120
|
this.hideControls = false;
|
|
@@ -2300,6 +2131,9 @@ const KritzelEditor = class {
|
|
|
2300
2131
|
async removeObject(object) {
|
|
2301
2132
|
return this.engineRef.removeObject(object);
|
|
2302
2133
|
}
|
|
2134
|
+
async getSelectedObjects() {
|
|
2135
|
+
return this.engineRef.getSelectedObjects();
|
|
2136
|
+
}
|
|
2303
2137
|
async selectObjects(objects) {
|
|
2304
2138
|
return this.engineRef.selectObjects(objects);
|
|
2305
2139
|
}
|
|
@@ -2321,8 +2155,13 @@ const KritzelEditor = class {
|
|
|
2321
2155
|
(_a = this.controlsRef) === null || _a === void 0 ? void 0 : _a.closeTooltip();
|
|
2322
2156
|
}
|
|
2323
2157
|
}
|
|
2324
|
-
|
|
2158
|
+
async onEngineReady() {
|
|
2159
|
+
await customElements.whenDefined('kritzel-editor');
|
|
2160
|
+
await customElements.whenDefined('kritzel-controls');
|
|
2161
|
+
await customElements.whenDefined('kritzel-engine');
|
|
2325
2162
|
this.registerCustomSvgIcons();
|
|
2163
|
+
console.log('Editor in stencil is read');
|
|
2164
|
+
this.isReady.emit();
|
|
2326
2165
|
}
|
|
2327
2166
|
registerCustomSvgIcons() {
|
|
2328
2167
|
for (const [name, svg] of Object.entries(this.customSvgIcons)) {
|
|
@@ -2330,7 +2169,7 @@ const KritzelEditor = class {
|
|
|
2330
2169
|
}
|
|
2331
2170
|
}
|
|
2332
2171
|
render() {
|
|
2333
|
-
return (h(Host, { key: '
|
|
2172
|
+
return (h(Host, { key: '83aa8122498b051ab605dcbfeadb2a2595324ef2' }, h("kritzel-engine", { key: '4ba9ac23b99e0d42d65badc8ddc6be603857267c', ref: el => (this.engineRef = el), onIsEngineReady: () => this.onEngineReady() }), h("kritzel-controls", { key: '2eb28eed27ebec46dc37221b75f888f8bfe7ffbc', ref: el => (this.controlsRef = el), controls: this.controls, style: this.hideControls ? { display: 'none' } : { display: 'flex' } })));
|
|
2334
2173
|
}
|
|
2335
2174
|
get host() { return getElement(this); }
|
|
2336
2175
|
};
|
|
@@ -2757,6 +2596,7 @@ const DEFAULT_ENGINE_STATE = {
|
|
|
2757
2596
|
selectionGroup: null,
|
|
2758
2597
|
resizeHandleType: null,
|
|
2759
2598
|
hasViewportChanged: false,
|
|
2599
|
+
isReady: false,
|
|
2760
2600
|
isEnabled: true,
|
|
2761
2601
|
isScaling: false,
|
|
2762
2602
|
isPanning: false,
|
|
@@ -3169,6 +3009,12 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
|
3169
3009
|
}
|
|
3170
3010
|
}
|
|
3171
3011
|
|
|
3012
|
+
class KritzelClassHelper {
|
|
3013
|
+
static isInstanceOf(object, className) {
|
|
3014
|
+
return object.__class__ === className;
|
|
3015
|
+
}
|
|
3016
|
+
}
|
|
3017
|
+
|
|
3172
3018
|
const kritzelEngineCss = ":host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}textarea{all:unset;box-sizing:border-box;outline:none !important;border:none !important;overflow:visible}.resize-handle-overlay.top-left,.resize-handle-overlay.bottom-right{cursor:nwse-resize}.resize-handle-overlay.top-right,.resize-handle-overlay.bottom-left{cursor:nesw-resize}.rotation-handle-overlay{cursor:grab}";
|
|
3173
3019
|
|
|
3174
3020
|
const KritzelEngine = class {
|
|
@@ -3180,7 +3026,7 @@ const KritzelEngine = class {
|
|
|
3180
3026
|
}
|
|
3181
3027
|
constructor(hostRef) {
|
|
3182
3028
|
registerInstance(this, hostRef);
|
|
3183
|
-
this.
|
|
3029
|
+
this.isEngineReady = createEvent(this, "isEngineReady");
|
|
3184
3030
|
this.activeToolChange = createEvent(this, "activeToolChange");
|
|
3185
3031
|
this.globalContextMenuItems = [
|
|
3186
3032
|
{
|
|
@@ -3232,7 +3078,10 @@ const KritzelEngine = class {
|
|
|
3232
3078
|
}
|
|
3233
3079
|
componentDidLoad() {
|
|
3234
3080
|
this.viewport = new KritzelViewport(this.store, this.host);
|
|
3235
|
-
this.
|
|
3081
|
+
if (this.store.state.isReady === false) {
|
|
3082
|
+
this.store.state.isReady = true;
|
|
3083
|
+
this.isEngineReady.emit();
|
|
3084
|
+
}
|
|
3236
3085
|
}
|
|
3237
3086
|
handleWheel(ev) {
|
|
3238
3087
|
var _a, _b;
|
|
@@ -3395,6 +3244,7 @@ const KritzelEngine = class {
|
|
|
3395
3244
|
this.store.deselectAllObjects();
|
|
3396
3245
|
object.id = object.generateId();
|
|
3397
3246
|
object._store = this.store;
|
|
3247
|
+
object.scale = object.scale ? object.scale : this.store.state.scale;
|
|
3398
3248
|
object.zIndex = this.store.currentZIndex;
|
|
3399
3249
|
const command = new AddObjectCommand(this.store, this, object);
|
|
3400
3250
|
this.store.history.executeCommand(command);
|
|
@@ -3412,12 +3262,16 @@ const KritzelEngine = class {
|
|
|
3412
3262
|
this.store.history.executeCommand(command);
|
|
3413
3263
|
return object;
|
|
3414
3264
|
}
|
|
3265
|
+
async getSelectedObjects() {
|
|
3266
|
+
return this.store.state.selectionGroup ? this.store.state.selectionGroup.objects : [];
|
|
3267
|
+
}
|
|
3415
3268
|
async selectObjects(objects) {
|
|
3416
3269
|
var _a;
|
|
3417
3270
|
(_a = this.store.state.activeTool) === null || _a === void 0 ? void 0 : _a.onDeactivate();
|
|
3418
3271
|
this.store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
3419
3272
|
this.store.deselectAllObjects();
|
|
3420
3273
|
this.store.selectObjects(objects);
|
|
3274
|
+
console.log('Selected objects:', objects);
|
|
3421
3275
|
}
|
|
3422
3276
|
async selectAllObjectsInViewport() {
|
|
3423
3277
|
var _a;
|
|
@@ -3435,15 +3289,15 @@ const KritzelEngine = class {
|
|
|
3435
3289
|
const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
|
|
3436
3290
|
const baseHandleSize = parseFloat(baseHandleSizePx);
|
|
3437
3291
|
const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
|
|
3438
|
-
return (h(Host, { key: '
|
|
3439
|
-
_a.translateX), h("div", { key: '
|
|
3440
|
-
_b.translateY), h("div", { key: '
|
|
3441
|
-
_c.viewportWidth), h("div", { key: '
|
|
3442
|
-
_d.viewportHeight), h("div", { key: '
|
|
3443
|
-
_e.scale), h("div", { key: '
|
|
3444
|
-
_g.name), h("div", { key: '
|
|
3445
|
-
_m.cursorX), h("div", { key: '
|
|
3446
|
-
_o.cursorY)), h("div", { key: '
|
|
3292
|
+
return (h(Host, { key: 'b45e4ad6645643d642c94a91cafaa49a75bb3505' }, h("div", { key: 'c87b2fc89aae574b79b304299383e220a0c80ed2', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, h("div", { key: '09e6308374584f5e454abe11cd219370c9920f78' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
|
|
3293
|
+
_a.translateX), h("div", { key: 'df5b645b782fdce83c54361aca038a5a638183cd' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
|
|
3294
|
+
_b.translateY), h("div", { key: '12c251313bac25cf0d99090306e269e81949e168' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
|
|
3295
|
+
_c.viewportWidth), h("div", { key: '48bcc8b9318e9ff1ad97ac34c6a1b7bca6b23443' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
|
|
3296
|
+
_d.viewportHeight), h("div", { key: '81d47be11636989548b5b593368e74342abe655d' }, "ObjectsInViewport. ", this.store.objects.length), h("div", { key: '48313baf47c284b3780bf789fa15daee8b06027a' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
|
|
3297
|
+
_e.scale), h("div", { key: '8e7a32e747f85612cb9a405d596cc39c41048667' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
|
|
3298
|
+
_g.name), h("div", { key: '2c80e5568525c9852cc34f3ac0ffdbc20676feab' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), h("div", { key: 'db6d20659f7ab19baf63842f402018f3e5816e85' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), h("div", { key: '243e6aab8b40c08a4e4d278e1c915b7cd82ffafc' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), h("div", { key: '183bccbf711ae3e29474152e01a77fcfaf29130c' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), h("div", { key: 'c520ed2a0afb60e7fd73be7006e7fdef4d306df1' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), h("div", { key: '9e52bfec4a1ea0ad4ae09f3d006ae8689140da4a' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", { key: 'f917c984963ff98a99068c0286a74fd3910fa2f2' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", { key: '5811fa41a32f84aa38b76958e39b8529edc222ee' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", { key: '56e074738abaea466381c1a6aa219476dd4eaa89' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", { key: '9a9fb9893bec08bb88d9c95a80b9df646ad803ec' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), h("div", { key: 'bfee6adc9b6638a294924051a508c7c75e44aa51' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), h("div", { key: 'c70e2e780804ce63a3ee3839e5da8a6edf0c8f85' }, "CursorX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
|
|
3299
|
+
_m.cursorX), h("div", { key: '434f4eafc7182f48bf90390ae719ddc46d3bec48' }, "CursorY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
|
|
3300
|
+
_o.cursorY)), h("div", { key: '7997269880dab3dbc8b920f340a3ed01127bd5bf', class: "origin", style: {
|
|
3447
3301
|
transform: `matrix(${(_p = this.store.state) === null || _p === void 0 ? void 0 : _p.scale}, 0, 0, ${(_q = this.store.state) === null || _q === void 0 ? void 0 : _q.scale}, ${(_r = this.store.state) === null || _r === void 0 ? void 0 : _r.translateX}, ${(_s = this.store.state) === null || _s === void 0 ? void 0 : _s.translateY})`,
|
|
3448
3302
|
} }, (_t = this.store.objects) === null || _t === void 0 ? void 0 :
|
|
3449
3303
|
_t.map(object => {
|
|
@@ -3467,17 +3321,17 @@ const KritzelEngine = class {
|
|
|
3467
3321
|
borderStyle: 'solid',
|
|
3468
3322
|
padding: object.padding + 'px',
|
|
3469
3323
|
overflow: 'visible',
|
|
3470
|
-
} }, object
|
|
3324
|
+
} }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (h("svg", { ref: el => object.mount(el), xmlns: "http://www.w3.org/2000/svg", style: {
|
|
3471
3325
|
height: object === null || object === void 0 ? void 0 : object.height.toString(),
|
|
3472
3326
|
width: object === null || object === void 0 ? void 0 : object.width.toString(),
|
|
3473
3327
|
position: 'absolute',
|
|
3474
3328
|
overflow: 'visible',
|
|
3475
|
-
}, viewBox: object === null || object === void 0 ? void 0 : object.viewBox }, h("path", { d: object === null || object === void 0 ? void 0 : object.d, fill: object.fill, stroke: object === null || object === void 0 ? void 0 : object.stroke }))), object
|
|
3329
|
+
}, viewBox: object === null || object === void 0 ? void 0 : object.viewBox }, h("path", { d: object === null || object === void 0 ? void 0 : object.d, fill: object.fill, stroke: object === null || object === void 0 ? void 0 : object.stroke }))), KritzelClassHelper.isInstanceOf(object, 'KritzelImage') && (h("img", { ref: el => object.mount(el), src: object.src, style: {
|
|
3476
3330
|
width: '100%',
|
|
3477
3331
|
height: '100%',
|
|
3478
3332
|
userSelect: 'none',
|
|
3479
3333
|
pointerEvents: 'none',
|
|
3480
|
-
}, draggable: false, onDragStart: e => e.preventDefault() })), object
|
|
3334
|
+
}, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelText') && (h("textarea", { ref: el => object.mount(el), value: object.value, onKeyDown: event => object.handleKeyDown(event), onInput: event => object.handleInput(event), rows: object.rows, style: {
|
|
3481
3335
|
width: '100%',
|
|
3482
3336
|
height: '100%',
|
|
3483
3337
|
color: object.fontColor,
|
|
@@ -3493,10 +3347,10 @@ const KritzelEngine = class {
|
|
|
3493
3347
|
pointerEvents: object.isReadonly ? 'none' : 'auto',
|
|
3494
3348
|
cursor: object.isReadonly ? 'default' : 'text',
|
|
3495
3349
|
caretColor: object.isReadonly ? 'transparent' : 'auto',
|
|
3496
|
-
} })), object
|
|
3350
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionGroup') && (h("div", { ref: el => object.mount(el), style: {
|
|
3497
3351
|
width: '100%',
|
|
3498
3352
|
height: '100%',
|
|
3499
|
-
} })), object
|
|
3353
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KrtizelSelectionBox') && (h("div", { ref: el => object.mount(el), style: {
|
|
3500
3354
|
width: '100%',
|
|
3501
3355
|
height: '100%',
|
|
3502
3356
|
} }))), h("line", { x1: "0", y1: "0", x2: object.totalWidth, y2: "0", style: {
|
|
@@ -3540,7 +3394,7 @@ const KritzelEngine = class {
|
|
|
3540
3394
|
fill: 'transparent',
|
|
3541
3395
|
cursor: 'grab',
|
|
3542
3396
|
}, visibility: object.selected && !this.isSelecting ? 'visible' : 'hidden' }), h("g", { style: { display: this.store.state.debugInfo.showObjectInfo ? 'block' : 'none', pointerEvents: 'none' } }, h("foreignObject", { x: object.totalWidth.toString(), y: "0", width: "400px", height: "160px", style: { minHeight: '0', minWidth: '0', display: object.debugInfoVisible ? 'block' : 'none' } }, h("div", { style: { width: '100%', height: '100%' } }, h("div", { style: { whiteSpace: 'nowrap' } }, "zIndex: ", object.zIndex), h("div", { style: { whiteSpace: 'nowrap' } }, "translateX: ", object.translateX), h("div", { style: { whiteSpace: 'nowrap' } }, "translateY: ", object.translateY), h("div", { style: { whiteSpace: 'nowrap' } }, "width: ", object.width), h("div", { style: { whiteSpace: 'nowrap' } }, "height: ", object.height), h("div", { style: { whiteSpace: 'nowrap' } }, "scale: ", object.scale), h("div", { style: { whiteSpace: 'nowrap' } }, "rotation: ", object.rotation)))))));
|
|
3543
|
-
}), h("svg", { key: '
|
|
3397
|
+
}), h("svg", { key: '637b9098b88f3ecc36794d64bb205a3f26500598', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
3544
3398
|
height: (_u = this.store.state.currentPath) === null || _u === void 0 ? void 0 : _u.height.toString(),
|
|
3545
3399
|
width: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.width.toString(),
|
|
3546
3400
|
left: '0',
|
|
@@ -3550,12 +3404,12 @@ const KritzelEngine = class {
|
|
|
3550
3404
|
transform: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.transformationMatrix,
|
|
3551
3405
|
transformOrigin: 'top left',
|
|
3552
3406
|
overflow: 'visible',
|
|
3553
|
-
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, h("path", { key: '
|
|
3407
|
+
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, h("path", { key: '0f44d2551774e94a74e4d6f5a0e1812baf05bdfb', d: (_z = this.store.state.currentPath) === null || _z === void 0 ? void 0 : _z.d, fill: (_0 = this.store.state.currentPath) === null || _0 === void 0 ? void 0 : _0.fill, stroke: (_1 = this.store.state.currentPath) === null || _1 === void 0 ? void 0 : _1.stroke }))), this.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: '3c74a2d2cc100a2957f3065388f15238cbf0f92c', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, style: {
|
|
3554
3408
|
position: 'fixed',
|
|
3555
3409
|
left: `${this.store.state.contextMenuX}px`,
|
|
3556
3410
|
top: `${this.store.state.contextMenuY}px`,
|
|
3557
3411
|
zIndex: '10000',
|
|
3558
|
-
}, onActionSelected: event => this.handleContextMenuAction(event) })), ((_2 = this.store.state) === null || _2 === void 0 ? void 0 : _2.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && h("kritzel-cursor-trail", { key: '
|
|
3412
|
+
}, onActionSelected: event => this.handleContextMenuAction(event) })), ((_2 = this.store.state) === null || _2 === void 0 ? void 0 : _2.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && h("kritzel-cursor-trail", { key: '8ede38f5f2eff63fc7647836778e3b428106bca5', store: this.store })));
|
|
3559
3413
|
}
|
|
3560
3414
|
get host() { return getElement(this); }
|
|
3561
3415
|
};
|
|
@@ -3688,7 +3542,7 @@ const KritzelStrokeSize = class {
|
|
|
3688
3542
|
};
|
|
3689
3543
|
KritzelStrokeSize.style = kritzelStrokeSizeCss;
|
|
3690
3544
|
|
|
3691
|
-
const kritzelTooltipCss = ":host{width:auto}.tooltip-content{position:relative;padding:8px 12px;border-radius:4px;width:fit-content;background-color:var(--kritzel-controls-tooltip-background-color, #ffffff);color:var(--kritzel-controls-tooltip-color, #000000);padding:var(--kritzel-controls-tooltip-padding, 8px);border-radius:var(--kritzel-controls-tooltip-border-radius,
|
|
3545
|
+
const kritzelTooltipCss = ":host{width:auto}.tooltip-content{position:relative;padding:8px 12px;border-radius:4px;width:fit-content;background-color:var(--kritzel-controls-tooltip-background-color, #ffffff);color:var(--kritzel-controls-tooltip-color, #000000);padding:var(--kritzel-controls-tooltip-padding, 8px);border-radius:var(--kritzel-controls-tooltip-border-radius, 16px);white-space:nowrap;box-shadow:var(--kritzel-controls-tooltip-box-shadow, 0 1px 6px rgba(0, 0, 0, 0.12))}";
|
|
3692
3546
|
|
|
3693
3547
|
const MOBILE_BREAKPOINT = 768;
|
|
3694
3548
|
const KritzelTooltip = class {
|
|
@@ -3757,7 +3611,7 @@ const KritzelTooltip = class {
|
|
|
3757
3611
|
};
|
|
3758
3612
|
KritzelTooltip.style = kritzelTooltipCss;
|
|
3759
3613
|
|
|
3760
|
-
const kritzelUtilityPanelCss = ":host{display:flex;flex-direction:row;align-items:center;padding:4px;gap:8px;border-top-left-radius:
|
|
3614
|
+
const kritzelUtilityPanelCss = ":host{display:flex;flex-direction:row;align-items:center;padding:4px;gap:8px;border-top-left-radius:12px;border-top-right-radius:12px;background-color:rgb(226, 226, 226);width:fit-content;user-select:none}.utility-button{display:flex;justify-content:center;align-items:center;width:28px;height:28px;padding:8px 4px;border:none;outline:none;background:none;cursor:pointer;color:#333333;-webkit-tap-highlight-color:transparent}.utility-separator{width:1px;height:16px;background-color:hsl(0, 0%, 0%, 4.3%)}";
|
|
3761
3615
|
|
|
3762
3616
|
const KritzelUtilityPanel = class {
|
|
3763
3617
|
constructor(hostRef) {
|