kritzel-stencil 0.0.115 → 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,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-CXT94beA.js');
|
|
4
|
-
var index$1 = require('./index-
|
|
4
|
+
var index$1 = require('./index-aaWestcD.js');
|
|
5
5
|
|
|
6
6
|
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)}";
|
|
7
7
|
|
|
@@ -122,7 +122,7 @@ const KritzelColorPalette = class {
|
|
|
122
122
|
};
|
|
123
123
|
KritzelColorPalette.style = kritzelColorPaletteCss;
|
|
124
124
|
|
|
125
|
-
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,
|
|
125
|
+
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}";
|
|
126
126
|
|
|
127
127
|
const KritzelContextMenu = class {
|
|
128
128
|
constructor(hostRef) {
|
|
@@ -226,145 +226,6 @@ const KritzelControlTextConfig = class {
|
|
|
226
226
|
};
|
|
227
227
|
KritzelControlTextConfig.style = kritzelControlTextConfigCss;
|
|
228
228
|
|
|
229
|
-
var cjs = {};
|
|
230
|
-
|
|
231
|
-
var hasRequiredCjs;
|
|
232
|
-
|
|
233
|
-
function requireCjs () {
|
|
234
|
-
if (hasRequiredCjs) return cjs;
|
|
235
|
-
hasRequiredCjs = 1;
|
|
236
|
-
(function (exports) {
|
|
237
|
-
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;
|
|
238
|
-
} (cjs));
|
|
239
|
-
return cjs;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
var cjsExports = requireCjs();
|
|
243
|
-
|
|
244
|
-
class KritzelMathHelper {
|
|
245
|
-
static average(a, b) {
|
|
246
|
-
return (a + b) / 2;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
class KritzelPath extends index$1.KritzelBaseObject {
|
|
251
|
-
constructor() {
|
|
252
|
-
super(...arguments);
|
|
253
|
-
this.__class__ = 'KritzelPath';
|
|
254
|
-
this.stroke = 'none';
|
|
255
|
-
this.lineSlack = 0.5;
|
|
256
|
-
this.x = 0;
|
|
257
|
-
this.y = 0;
|
|
258
|
-
this.height = 0;
|
|
259
|
-
this.width = 0;
|
|
260
|
-
this.scale = 1;
|
|
261
|
-
this.visible = true;
|
|
262
|
-
this.debugInfoVisible = true;
|
|
263
|
-
}
|
|
264
|
-
get viewBox() {
|
|
265
|
-
return `${this.x} ${this.y} ${this.width} ${this.height}`;
|
|
266
|
-
}
|
|
267
|
-
static create(store, options) {
|
|
268
|
-
var _a, _b, _c, _d, _e, _f;
|
|
269
|
-
const object = new KritzelPath();
|
|
270
|
-
object._store = store;
|
|
271
|
-
object.id = object.generateId();
|
|
272
|
-
object.options = options;
|
|
273
|
-
object.points = (_a = options === null || options === void 0 ? void 0 : options.points) !== null && _a !== void 0 ? _a : [];
|
|
274
|
-
object.translateX = (_b = options === null || options === void 0 ? void 0 : options.translateX) !== null && _b !== void 0 ? _b : 0;
|
|
275
|
-
object.translateY = (_c = options === null || options === void 0 ? void 0 : options.translateY) !== null && _c !== void 0 ? _c : 0;
|
|
276
|
-
object.scale = (_d = options === null || options === void 0 ? void 0 : options.scale) !== null && _d !== void 0 ? _d : 1;
|
|
277
|
-
object.strokeWidth = (_e = options === null || options === void 0 ? void 0 : options.strokeWidth) !== null && _e !== void 0 ? _e : 8;
|
|
278
|
-
object.fill = (_f = options === null || options === void 0 ? void 0 : options.fill) !== null && _f !== void 0 ? _f : '#000000';
|
|
279
|
-
object.zIndex = store.currentZIndex;
|
|
280
|
-
object.d = object.generateSvgPath();
|
|
281
|
-
object.updateDimensions();
|
|
282
|
-
return object;
|
|
283
|
-
}
|
|
284
|
-
resize(x, y, width, height) {
|
|
285
|
-
if (width <= 1 || height <= 1) {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
const scaleX = width / this.width;
|
|
289
|
-
const scaleY = height / this.height;
|
|
290
|
-
this.width = width;
|
|
291
|
-
this.height = height;
|
|
292
|
-
this.points = this.points.map(([x, y]) => [x * scaleX, y * scaleY]);
|
|
293
|
-
this.d = this.generateSvgPath();
|
|
294
|
-
this.width = Math.max(...this.points.map(p => p[0])) - Math.min(...this.points.map(p => p[0])) + this.strokeWidth;
|
|
295
|
-
this.height = Math.max(...this.points.map(p => p[1])) - Math.min(...this.points.map(p => p[1])) + this.strokeWidth;
|
|
296
|
-
this.x = Math.min(...this.points.map(p => p[0])) - this.strokeWidth / 2;
|
|
297
|
-
this.y = Math.min(...this.points.map(p => p[1])) - this.strokeWidth / 2;
|
|
298
|
-
this.translateX = x;
|
|
299
|
-
this.translateY = y;
|
|
300
|
-
}
|
|
301
|
-
rotate(value) {
|
|
302
|
-
super.rotate(value);
|
|
303
|
-
this.updateDimensions();
|
|
304
|
-
}
|
|
305
|
-
updateDimensions() {
|
|
306
|
-
const rotatedPoints = this.points.map(([x, y]) => {
|
|
307
|
-
const rotatedX = x * Math.cos(this.rotation) - y * Math.sin(this.rotation);
|
|
308
|
-
const rotatedY = x * Math.sin(this.rotation) + y * Math.cos(this.rotation);
|
|
309
|
-
return [rotatedX, rotatedY];
|
|
310
|
-
});
|
|
311
|
-
const minX = Math.min(...rotatedPoints.map(p => p[0] - this.strokeWidth / 2));
|
|
312
|
-
const minY = Math.min(...rotatedPoints.map(p => p[1] - this.strokeWidth / 2));
|
|
313
|
-
const maxX = Math.max(...rotatedPoints.map(p => p[0] + this.strokeWidth / 2));
|
|
314
|
-
const maxY = Math.max(...rotatedPoints.map(p => p[1] + this.strokeWidth / 2));
|
|
315
|
-
this.width = maxX - minX + this.lineSlack; // Add 0.5 to avoid rounding issues
|
|
316
|
-
this.height = maxY - minY + this.lineSlack; // Add 0.5 to avoid rounding issues
|
|
317
|
-
this.x = minX;
|
|
318
|
-
this.y = minY;
|
|
319
|
-
this.translateX = (this.x + this.translateX) / this.scale;
|
|
320
|
-
this.translateY = (this.y + this.translateY) / this.scale;
|
|
321
|
-
}
|
|
322
|
-
generateSvgPath() {
|
|
323
|
-
const stroke = this.getStrokeFromPoints(this.points, this.strokeWidth);
|
|
324
|
-
return this.getSvgPathFromStroke(stroke);
|
|
325
|
-
}
|
|
326
|
-
getStrokeFromPoints(points, strokeWidth) {
|
|
327
|
-
return cjsExports.getStroke(points, {
|
|
328
|
-
size: strokeWidth,
|
|
329
|
-
thinning: 0.5,
|
|
330
|
-
smoothing: 0.5,
|
|
331
|
-
streamline: 0.5,
|
|
332
|
-
easing: t => t,
|
|
333
|
-
simulatePressure: true,
|
|
334
|
-
last: true,
|
|
335
|
-
start: {
|
|
336
|
-
cap: true,
|
|
337
|
-
taper: 0,
|
|
338
|
-
easing: t => t,
|
|
339
|
-
},
|
|
340
|
-
end: {
|
|
341
|
-
cap: true,
|
|
342
|
-
taper: 0,
|
|
343
|
-
easing: t => t,
|
|
344
|
-
},
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
getSvgPathFromStroke(points, closed = true) {
|
|
348
|
-
const len = points.length;
|
|
349
|
-
if (len < 4) {
|
|
350
|
-
return ``;
|
|
351
|
-
}
|
|
352
|
-
let a = points[0];
|
|
353
|
-
let b = points[1];
|
|
354
|
-
const c = points[2];
|
|
355
|
-
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`;
|
|
356
|
-
for (let i = 2, max = len - 1; i < max; i++) {
|
|
357
|
-
a = points[i];
|
|
358
|
-
b = points[i + 1];
|
|
359
|
-
result += `${KritzelMathHelper.average(a[0], b[0]).toFixed(2)},${KritzelMathHelper.average(a[1], b[1]).toFixed(2)} `;
|
|
360
|
-
}
|
|
361
|
-
if (closed) {
|
|
362
|
-
result += 'Z';
|
|
363
|
-
}
|
|
364
|
-
return result;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
229
|
class KritzelBrushTool extends index$1.KritzelBaseTool {
|
|
369
230
|
constructor(store) {
|
|
370
231
|
super(store);
|
|
@@ -385,7 +246,7 @@ class KritzelBrushTool extends index$1.KritzelBaseTool {
|
|
|
385
246
|
this._store.state.isDrawing = true;
|
|
386
247
|
const x = event.clientX - this._store.offsetX;
|
|
387
248
|
const y = event.clientY - this._store.offsetY;
|
|
388
|
-
this._store.state.currentPath = KritzelPath.create(this._store, {
|
|
249
|
+
this._store.state.currentPath = index$1.KritzelPath.create(this._store, {
|
|
389
250
|
points: [[x, y]],
|
|
390
251
|
translateX: -this._store.state.translateX,
|
|
391
252
|
translateY: -this._store.state.translateY,
|
|
@@ -401,7 +262,7 @@ class KritzelBrushTool extends index$1.KritzelBaseTool {
|
|
|
401
262
|
const x = Math.round(activePointers[0].clientX - this._store.offsetX);
|
|
402
263
|
const y = Math.round(activePointers[0].clientY - this._store.offsetY);
|
|
403
264
|
this._store.state.isDrawing = true;
|
|
404
|
-
this._store.state.currentPath = KritzelPath.create(this._store, {
|
|
265
|
+
this._store.state.currentPath = index$1.KritzelPath.create(this._store, {
|
|
405
266
|
points: [[x, y]],
|
|
406
267
|
translateX: -this._store.state.translateX,
|
|
407
268
|
translateY: -this._store.state.translateY,
|
|
@@ -421,7 +282,7 @@ class KritzelBrushTool extends index$1.KritzelBaseTool {
|
|
|
421
282
|
if (this._store.state.isDrawing) {
|
|
422
283
|
const x = event.clientX - this._store.offsetX;
|
|
423
284
|
const y = event.clientY - this._store.offsetY;
|
|
424
|
-
this._store.state.currentPath = KritzelPath.create(this._store, {
|
|
285
|
+
this._store.state.currentPath = index$1.KritzelPath.create(this._store, {
|
|
425
286
|
points: [...this._store.state.currentPath.points, [x, y]],
|
|
426
287
|
translateX: -this._store.state.translateX,
|
|
427
288
|
translateY: -this._store.state.translateY,
|
|
@@ -437,7 +298,7 @@ class KritzelBrushTool extends index$1.KritzelBaseTool {
|
|
|
437
298
|
if (activePointers.length === 1) {
|
|
438
299
|
const x = Math.round(activePointers[0].clientX - this._store.offsetX);
|
|
439
300
|
const y = Math.round(activePointers[0].clientY - this._store.offsetY);
|
|
440
|
-
this._store.state.currentPath = KritzelPath.create(this._store, {
|
|
301
|
+
this._store.state.currentPath = index$1.KritzelPath.create(this._store, {
|
|
441
302
|
points: [...this._store.state.currentPath.points, [x, y]],
|
|
442
303
|
translateX: -this._store.state.translateX,
|
|
443
304
|
translateY: -this._store.state.translateY,
|
|
@@ -483,7 +344,7 @@ class KritzelDevicesHelper {
|
|
|
483
344
|
}
|
|
484
345
|
}
|
|
485
346
|
|
|
486
|
-
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,
|
|
347
|
+
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}";
|
|
487
348
|
|
|
488
349
|
const KritzelControls = class {
|
|
489
350
|
constructor(hostRef) {
|
|
@@ -695,7 +556,7 @@ const KritzelCursorTrail = class {
|
|
|
695
556
|
};
|
|
696
557
|
KritzelCursorTrail.style = kritzelCursorTrailCss;
|
|
697
558
|
|
|
698
|
-
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,
|
|
559
|
+
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}";
|
|
699
560
|
|
|
700
561
|
const KritzelDropdown = class {
|
|
701
562
|
constructor(hostRef) {
|
|
@@ -808,24 +669,24 @@ class KritzelIconRegistry {
|
|
|
808
669
|
}
|
|
809
670
|
KritzelIconRegistry.registry = new Map();
|
|
810
671
|
KritzelIconRegistry.registerIcons({
|
|
811
|
-
'cursor': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
812
|
-
'pen': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
813
|
-
'highlighter': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
814
|
-
'eraser': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
815
|
-
'type': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
816
|
-
'image': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
817
|
-
'chevron-down': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
818
|
-
'chevron-up': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
819
|
-
'copy': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
820
|
-
'paste': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
821
|
-
'cut': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
822
|
-
'delete': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
823
|
-
'bring-to-front': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
824
|
-
'send-to-back': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
825
|
-
'select-all': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
826
|
-
'download': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
827
|
-
'undo': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
828
|
-
'redo': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="
|
|
672
|
+
'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>',
|
|
673
|
+
'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>',
|
|
674
|
+
'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>',
|
|
675
|
+
'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>',
|
|
676
|
+
'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>',
|
|
677
|
+
'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>',
|
|
678
|
+
'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>',
|
|
679
|
+
'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>',
|
|
680
|
+
'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>',
|
|
681
|
+
'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>',
|
|
682
|
+
'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>',
|
|
683
|
+
'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>',
|
|
684
|
+
'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>',
|
|
685
|
+
'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>',
|
|
686
|
+
'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>',
|
|
687
|
+
'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>',
|
|
688
|
+
'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>',
|
|
689
|
+
'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>'
|
|
829
690
|
});
|
|
830
691
|
|
|
831
692
|
class BatchCommand extends index$1.KritzelBaseCommand {
|
|
@@ -933,37 +794,6 @@ class KritzelEraserTool extends index$1.KritzelBaseTool {
|
|
|
933
794
|
}
|
|
934
795
|
}
|
|
935
796
|
|
|
936
|
-
class KritzelImage extends index$1.KritzelBaseObject {
|
|
937
|
-
constructor() {
|
|
938
|
-
super(...arguments);
|
|
939
|
-
this.__class__ = 'KritzelImage';
|
|
940
|
-
this.src = '';
|
|
941
|
-
this.debugInfoVisible = true;
|
|
942
|
-
}
|
|
943
|
-
static create(store) {
|
|
944
|
-
const object = new KritzelImage();
|
|
945
|
-
object._store = store;
|
|
946
|
-
object.id = object.generateId();
|
|
947
|
-
object.x = 0;
|
|
948
|
-
object.y = 0;
|
|
949
|
-
object.translateX = 0;
|
|
950
|
-
object.translateY = 0;
|
|
951
|
-
object.scale = object._store.state.scale;
|
|
952
|
-
object.zIndex = store.currentZIndex;
|
|
953
|
-
return object;
|
|
954
|
-
}
|
|
955
|
-
resize(x, y, width, height) {
|
|
956
|
-
if (width <= 1 || height <= 1) {
|
|
957
|
-
return;
|
|
958
|
-
}
|
|
959
|
-
const scaleFactor = height / this.height;
|
|
960
|
-
this.width = this.width * scaleFactor;
|
|
961
|
-
this.height = this.height * scaleFactor;
|
|
962
|
-
this.translateX = x;
|
|
963
|
-
this.translateY = y;
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
|
|
967
797
|
class RemoveSelectionGroupCommand extends index$1.KritzelBaseCommand {
|
|
968
798
|
constructor(store, initiator) {
|
|
969
799
|
super(store, initiator);
|
|
@@ -1841,13 +1671,13 @@ class KritzelReviver {
|
|
|
1841
1671
|
let revivedObj;
|
|
1842
1672
|
switch (obj.__class__) {
|
|
1843
1673
|
case 'KritzelPath':
|
|
1844
|
-
revivedObj = KritzelPath.create(this._store).revive(obj);
|
|
1674
|
+
revivedObj = index$1.KritzelPath.create(this._store).revive(obj);
|
|
1845
1675
|
break;
|
|
1846
1676
|
case 'KritzelText':
|
|
1847
1677
|
revivedObj = index$1.KritzelText.create(this._store, obj.fontSize, obj.fontFamily).revive(obj);
|
|
1848
1678
|
break;
|
|
1849
1679
|
case 'KritzelImage':
|
|
1850
|
-
revivedObj = KritzelImage.create(this._store).revive(obj);
|
|
1680
|
+
revivedObj = index$1.KritzelImage.create(this._store).revive(obj);
|
|
1851
1681
|
break;
|
|
1852
1682
|
case 'KritzelSelectionGroup':
|
|
1853
1683
|
revivedObj = KritzelSelectionGroup.create(this._store).revive(obj);
|
|
@@ -2125,7 +1955,7 @@ class KritzelImageTool extends index$1.KritzelBaseTool {
|
|
|
2125
1955
|
return { scaledWidth, scaledHeight };
|
|
2126
1956
|
}
|
|
2127
1957
|
createKritzelImage(img, width, height) {
|
|
2128
|
-
const image = KritzelImage.create(this._store);
|
|
1958
|
+
const image = index$1.KritzelImage.create(this._store);
|
|
2129
1959
|
image.src = img.src;
|
|
2130
1960
|
image.width = width;
|
|
2131
1961
|
image.height = height;
|
|
@@ -2286,6 +2116,7 @@ const kritzelEditorCss = "kritzel-editor{display:flex;margin:0;position:relative
|
|
|
2286
2116
|
const KritzelEditor = class {
|
|
2287
2117
|
constructor(hostRef) {
|
|
2288
2118
|
index.registerInstance(this, hostRef);
|
|
2119
|
+
this.isReady = index.createEvent(this, "isReady");
|
|
2289
2120
|
this.controls = DEFAULT_KRITZEL_CONTROLS;
|
|
2290
2121
|
this.customSvgIcons = {};
|
|
2291
2122
|
this.hideControls = false;
|
|
@@ -2302,6 +2133,9 @@ const KritzelEditor = class {
|
|
|
2302
2133
|
async removeObject(object) {
|
|
2303
2134
|
return this.engineRef.removeObject(object);
|
|
2304
2135
|
}
|
|
2136
|
+
async getSelectedObjects() {
|
|
2137
|
+
return this.engineRef.getSelectedObjects();
|
|
2138
|
+
}
|
|
2305
2139
|
async selectObjects(objects) {
|
|
2306
2140
|
return this.engineRef.selectObjects(objects);
|
|
2307
2141
|
}
|
|
@@ -2323,8 +2157,13 @@ const KritzelEditor = class {
|
|
|
2323
2157
|
(_a = this.controlsRef) === null || _a === void 0 ? void 0 : _a.closeTooltip();
|
|
2324
2158
|
}
|
|
2325
2159
|
}
|
|
2326
|
-
|
|
2160
|
+
async onEngineReady() {
|
|
2161
|
+
await customElements.whenDefined('kritzel-editor');
|
|
2162
|
+
await customElements.whenDefined('kritzel-controls');
|
|
2163
|
+
await customElements.whenDefined('kritzel-engine');
|
|
2327
2164
|
this.registerCustomSvgIcons();
|
|
2165
|
+
console.log('Editor in stencil is read');
|
|
2166
|
+
this.isReady.emit();
|
|
2328
2167
|
}
|
|
2329
2168
|
registerCustomSvgIcons() {
|
|
2330
2169
|
for (const [name, svg] of Object.entries(this.customSvgIcons)) {
|
|
@@ -2332,7 +2171,7 @@ const KritzelEditor = class {
|
|
|
2332
2171
|
}
|
|
2333
2172
|
}
|
|
2334
2173
|
render() {
|
|
2335
|
-
return (index.h(index.Host, { key: '
|
|
2174
|
+
return (index.h(index.Host, { key: '83aa8122498b051ab605dcbfeadb2a2595324ef2' }, index.h("kritzel-engine", { key: '4ba9ac23b99e0d42d65badc8ddc6be603857267c', ref: el => (this.engineRef = el), onIsEngineReady: () => this.onEngineReady() }), index.h("kritzel-controls", { key: '2eb28eed27ebec46dc37221b75f888f8bfe7ffbc', ref: el => (this.controlsRef = el), controls: this.controls, style: this.hideControls ? { display: 'none' } : { display: 'flex' } })));
|
|
2336
2175
|
}
|
|
2337
2176
|
get host() { return index.getElement(this); }
|
|
2338
2177
|
};
|
|
@@ -2759,6 +2598,7 @@ const DEFAULT_ENGINE_STATE = {
|
|
|
2759
2598
|
selectionGroup: null,
|
|
2760
2599
|
resizeHandleType: null,
|
|
2761
2600
|
hasViewportChanged: false,
|
|
2601
|
+
isReady: false,
|
|
2762
2602
|
isEnabled: true,
|
|
2763
2603
|
isScaling: false,
|
|
2764
2604
|
isPanning: false,
|
|
@@ -3171,6 +3011,12 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
|
3171
3011
|
}
|
|
3172
3012
|
}
|
|
3173
3013
|
|
|
3014
|
+
class KritzelClassHelper {
|
|
3015
|
+
static isInstanceOf(object, className) {
|
|
3016
|
+
return object.__class__ === className;
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
|
|
3174
3020
|
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}";
|
|
3175
3021
|
|
|
3176
3022
|
const KritzelEngine = class {
|
|
@@ -3182,7 +3028,7 @@ const KritzelEngine = class {
|
|
|
3182
3028
|
}
|
|
3183
3029
|
constructor(hostRef) {
|
|
3184
3030
|
index.registerInstance(this, hostRef);
|
|
3185
|
-
this.
|
|
3031
|
+
this.isEngineReady = index.createEvent(this, "isEngineReady");
|
|
3186
3032
|
this.activeToolChange = index.createEvent(this, "activeToolChange");
|
|
3187
3033
|
this.globalContextMenuItems = [
|
|
3188
3034
|
{
|
|
@@ -3234,7 +3080,10 @@ const KritzelEngine = class {
|
|
|
3234
3080
|
}
|
|
3235
3081
|
componentDidLoad() {
|
|
3236
3082
|
this.viewport = new KritzelViewport(this.store, this.host);
|
|
3237
|
-
this.
|
|
3083
|
+
if (this.store.state.isReady === false) {
|
|
3084
|
+
this.store.state.isReady = true;
|
|
3085
|
+
this.isEngineReady.emit();
|
|
3086
|
+
}
|
|
3238
3087
|
}
|
|
3239
3088
|
handleWheel(ev) {
|
|
3240
3089
|
var _a, _b;
|
|
@@ -3397,6 +3246,7 @@ const KritzelEngine = class {
|
|
|
3397
3246
|
this.store.deselectAllObjects();
|
|
3398
3247
|
object.id = object.generateId();
|
|
3399
3248
|
object._store = this.store;
|
|
3249
|
+
object.scale = object.scale ? object.scale : this.store.state.scale;
|
|
3400
3250
|
object.zIndex = this.store.currentZIndex;
|
|
3401
3251
|
const command = new index$1.AddObjectCommand(this.store, this, object);
|
|
3402
3252
|
this.store.history.executeCommand(command);
|
|
@@ -3414,12 +3264,16 @@ const KritzelEngine = class {
|
|
|
3414
3264
|
this.store.history.executeCommand(command);
|
|
3415
3265
|
return object;
|
|
3416
3266
|
}
|
|
3267
|
+
async getSelectedObjects() {
|
|
3268
|
+
return this.store.state.selectionGroup ? this.store.state.selectionGroup.objects : [];
|
|
3269
|
+
}
|
|
3417
3270
|
async selectObjects(objects) {
|
|
3418
3271
|
var _a;
|
|
3419
3272
|
(_a = this.store.state.activeTool) === null || _a === void 0 ? void 0 : _a.onDeactivate();
|
|
3420
3273
|
this.store.setState('activeTool', index$1.KritzelToolRegistry.getTool('selection'));
|
|
3421
3274
|
this.store.deselectAllObjects();
|
|
3422
3275
|
this.store.selectObjects(objects);
|
|
3276
|
+
console.log('Selected objects:', objects);
|
|
3423
3277
|
}
|
|
3424
3278
|
async selectAllObjectsInViewport() {
|
|
3425
3279
|
var _a;
|
|
@@ -3437,15 +3291,15 @@ const KritzelEngine = class {
|
|
|
3437
3291
|
const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
|
|
3438
3292
|
const baseHandleSize = parseFloat(baseHandleSizePx);
|
|
3439
3293
|
const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
|
|
3440
|
-
return (index.h(index.Host, { key: '
|
|
3441
|
-
_a.translateX), index.h("div", { key: '
|
|
3442
|
-
_b.translateY), index.h("div", { key: '
|
|
3443
|
-
_c.viewportWidth), index.h("div", { key: '
|
|
3444
|
-
_d.viewportHeight), index.h("div", { key: '
|
|
3445
|
-
_e.scale), index.h("div", { key: '
|
|
3446
|
-
_g.name), index.h("div", { key: '
|
|
3447
|
-
_m.cursorX), index.h("div", { key: '
|
|
3448
|
-
_o.cursorY)), index.h("div", { key: '
|
|
3294
|
+
return (index.h(index.Host, { key: 'b45e4ad6645643d642c94a91cafaa49a75bb3505' }, index.h("div", { key: 'c87b2fc89aae574b79b304299383e220a0c80ed2', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, index.h("div", { key: '09e6308374584f5e454abe11cd219370c9920f78' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
|
|
3295
|
+
_a.translateX), index.h("div", { key: 'df5b645b782fdce83c54361aca038a5a638183cd' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
|
|
3296
|
+
_b.translateY), index.h("div", { key: '12c251313bac25cf0d99090306e269e81949e168' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
|
|
3297
|
+
_c.viewportWidth), index.h("div", { key: '48bcc8b9318e9ff1ad97ac34c6a1b7bca6b23443' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
|
|
3298
|
+
_d.viewportHeight), index.h("div", { key: '81d47be11636989548b5b593368e74342abe655d' }, "ObjectsInViewport. ", this.store.objects.length), index.h("div", { key: '48313baf47c284b3780bf789fa15daee8b06027a' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
|
|
3299
|
+
_e.scale), index.h("div", { key: '8e7a32e747f85612cb9a405d596cc39c41048667' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
|
|
3300
|
+
_g.name), index.h("div", { key: '2c80e5568525c9852cc34f3ac0ffdbc20676feab' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), index.h("div", { key: 'db6d20659f7ab19baf63842f402018f3e5816e85' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), index.h("div", { key: '243e6aab8b40c08a4e4d278e1c915b7cd82ffafc' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), index.h("div", { key: '183bccbf711ae3e29474152e01a77fcfaf29130c' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), index.h("div", { key: 'c520ed2a0afb60e7fd73be7006e7fdef4d306df1' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), index.h("div", { key: '9e52bfec4a1ea0ad4ae09f3d006ae8689140da4a' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), index.h("div", { key: 'f917c984963ff98a99068c0286a74fd3910fa2f2' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), index.h("div", { key: '5811fa41a32f84aa38b76958e39b8529edc222ee' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), index.h("div", { key: '56e074738abaea466381c1a6aa219476dd4eaa89' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), index.h("div", { key: '9a9fb9893bec08bb88d9c95a80b9df646ad803ec' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), index.h("div", { key: 'bfee6adc9b6638a294924051a508c7c75e44aa51' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), index.h("div", { key: 'c70e2e780804ce63a3ee3839e5da8a6edf0c8f85' }, "CursorX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
|
|
3301
|
+
_m.cursorX), index.h("div", { key: '434f4eafc7182f48bf90390ae719ddc46d3bec48' }, "CursorY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
|
|
3302
|
+
_o.cursorY)), index.h("div", { key: '7997269880dab3dbc8b920f340a3ed01127bd5bf', class: "origin", style: {
|
|
3449
3303
|
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})`,
|
|
3450
3304
|
} }, (_t = this.store.objects) === null || _t === void 0 ? void 0 :
|
|
3451
3305
|
_t.map(object => {
|
|
@@ -3469,17 +3323,17 @@ const KritzelEngine = class {
|
|
|
3469
3323
|
borderStyle: 'solid',
|
|
3470
3324
|
padding: object.padding + 'px',
|
|
3471
3325
|
overflow: 'visible',
|
|
3472
|
-
} }, object
|
|
3326
|
+
} }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (index.h("svg", { ref: el => object.mount(el), xmlns: "http://www.w3.org/2000/svg", style: {
|
|
3473
3327
|
height: object === null || object === void 0 ? void 0 : object.height.toString(),
|
|
3474
3328
|
width: object === null || object === void 0 ? void 0 : object.width.toString(),
|
|
3475
3329
|
position: 'absolute',
|
|
3476
3330
|
overflow: 'visible',
|
|
3477
|
-
}, viewBox: object === null || object === void 0 ? void 0 : object.viewBox }, index.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
|
|
3331
|
+
}, viewBox: object === null || object === void 0 ? void 0 : object.viewBox }, index.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') && (index.h("img", { ref: el => object.mount(el), src: object.src, style: {
|
|
3478
3332
|
width: '100%',
|
|
3479
3333
|
height: '100%',
|
|
3480
3334
|
userSelect: 'none',
|
|
3481
3335
|
pointerEvents: 'none',
|
|
3482
|
-
}, draggable: false, onDragStart: e => e.preventDefault() })), object
|
|
3336
|
+
}, draggable: false, onDragStart: e => e.preventDefault() })), KritzelClassHelper.isInstanceOf(object, 'KritzelText') && (index.h("textarea", { ref: el => object.mount(el), value: object.value, onKeyDown: event => object.handleKeyDown(event), onInput: event => object.handleInput(event), rows: object.rows, style: {
|
|
3483
3337
|
width: '100%',
|
|
3484
3338
|
height: '100%',
|
|
3485
3339
|
color: object.fontColor,
|
|
@@ -3495,10 +3349,10 @@ const KritzelEngine = class {
|
|
|
3495
3349
|
pointerEvents: object.isReadonly ? 'none' : 'auto',
|
|
3496
3350
|
cursor: object.isReadonly ? 'default' : 'text',
|
|
3497
3351
|
caretColor: object.isReadonly ? 'transparent' : 'auto',
|
|
3498
|
-
} })), object
|
|
3352
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KritzelSelectionGroup') && (index.h("div", { ref: el => object.mount(el), style: {
|
|
3499
3353
|
width: '100%',
|
|
3500
3354
|
height: '100%',
|
|
3501
|
-
} })), object
|
|
3355
|
+
} })), KritzelClassHelper.isInstanceOf(object, 'KrtizelSelectionBox') && (index.h("div", { ref: el => object.mount(el), style: {
|
|
3502
3356
|
width: '100%',
|
|
3503
3357
|
height: '100%',
|
|
3504
3358
|
} }))), index.h("line", { x1: "0", y1: "0", x2: object.totalWidth, y2: "0", style: {
|
|
@@ -3542,7 +3396,7 @@ const KritzelEngine = class {
|
|
|
3542
3396
|
fill: 'transparent',
|
|
3543
3397
|
cursor: 'grab',
|
|
3544
3398
|
}, visibility: object.selected && !this.isSelecting ? 'visible' : 'hidden' }), index.h("g", { style: { display: this.store.state.debugInfo.showObjectInfo ? 'block' : 'none', pointerEvents: 'none' } }, index.h("foreignObject", { x: object.totalWidth.toString(), y: "0", width: "400px", height: "160px", style: { minHeight: '0', minWidth: '0', display: object.debugInfoVisible ? 'block' : 'none' } }, index.h("div", { style: { width: '100%', height: '100%' } }, index.h("div", { style: { whiteSpace: 'nowrap' } }, "zIndex: ", object.zIndex), index.h("div", { style: { whiteSpace: 'nowrap' } }, "translateX: ", object.translateX), index.h("div", { style: { whiteSpace: 'nowrap' } }, "translateY: ", object.translateY), index.h("div", { style: { whiteSpace: 'nowrap' } }, "width: ", object.width), index.h("div", { style: { whiteSpace: 'nowrap' } }, "height: ", object.height), index.h("div", { style: { whiteSpace: 'nowrap' } }, "scale: ", object.scale), index.h("div", { style: { whiteSpace: 'nowrap' } }, "rotation: ", object.rotation)))))));
|
|
3545
|
-
}), index.h("svg", { key: '
|
|
3399
|
+
}), index.h("svg", { key: '637b9098b88f3ecc36794d64bb205a3f26500598', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
3546
3400
|
height: (_u = this.store.state.currentPath) === null || _u === void 0 ? void 0 : _u.height.toString(),
|
|
3547
3401
|
width: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.width.toString(),
|
|
3548
3402
|
left: '0',
|
|
@@ -3552,12 +3406,12 @@ const KritzelEngine = class {
|
|
|
3552
3406
|
transform: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.transformationMatrix,
|
|
3553
3407
|
transformOrigin: 'top left',
|
|
3554
3408
|
overflow: 'visible',
|
|
3555
|
-
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, index.h("path", { key: '
|
|
3409
|
+
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, index.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 && (index.h("kritzel-context-menu", { key: '3c74a2d2cc100a2957f3065388f15238cbf0f92c', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, style: {
|
|
3556
3410
|
position: 'fixed',
|
|
3557
3411
|
left: `${this.store.state.contextMenuX}px`,
|
|
3558
3412
|
top: `${this.store.state.contextMenuY}px`,
|
|
3559
3413
|
zIndex: '10000',
|
|
3560
|
-
}, onActionSelected: event => this.handleContextMenuAction(event) })), ((_2 = this.store.state) === null || _2 === void 0 ? void 0 : _2.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && index.h("kritzel-cursor-trail", { key: '
|
|
3414
|
+
}, onActionSelected: event => this.handleContextMenuAction(event) })), ((_2 = this.store.state) === null || _2 === void 0 ? void 0 : _2.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && index.h("kritzel-cursor-trail", { key: '8ede38f5f2eff63fc7647836778e3b428106bca5', store: this.store })));
|
|
3561
3415
|
}
|
|
3562
3416
|
get host() { return index.getElement(this); }
|
|
3563
3417
|
};
|
|
@@ -3690,7 +3544,7 @@ const KritzelStrokeSize = class {
|
|
|
3690
3544
|
};
|
|
3691
3545
|
KritzelStrokeSize.style = kritzelStrokeSizeCss;
|
|
3692
3546
|
|
|
3693
|
-
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,
|
|
3547
|
+
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))}";
|
|
3694
3548
|
|
|
3695
3549
|
const MOBILE_BREAKPOINT = 768;
|
|
3696
3550
|
const KritzelTooltip = class {
|
|
@@ -3759,7 +3613,7 @@ const KritzelTooltip = class {
|
|
|
3759
3613
|
};
|
|
3760
3614
|
KritzelTooltip.style = kritzelTooltipCss;
|
|
3761
3615
|
|
|
3762
|
-
const kritzelUtilityPanelCss = ":host{display:flex;flex-direction:row;align-items:center;padding:4px;gap:8px;border-top-left-radius:
|
|
3616
|
+
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%)}";
|
|
3763
3617
|
|
|
3764
3618
|
const KritzelUtilityPanel = class {
|
|
3765
3619
|
constructor(hostRef) {
|