kritzel-stencil 0.0.113 → 0.0.115
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/app-globals-V2Kpy_OQ.js +8 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js.map +1 -0
- package/dist/cjs/index-C2M4eyxF.js +652 -0
- package/dist/cjs/index-C2M4eyxF.js.map +1 -0
- package/dist/cjs/{index-D62tBCuq.js → index-CXT94beA.js} +111 -109
- package/dist/cjs/index-CXT94beA.js.map +1 -0
- package/dist/cjs/index.cjs.js +5 -0
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +120 -725
- package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +4 -3
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/cjs/stencil.cjs.js +5 -4
- package/dist/cjs/stencil.cjs.js.map +1 -1
- package/dist/collection/classes/handlers/key.handler.js +4 -4
- package/dist/collection/classes/handlers/key.handler.js.map +1 -1
- package/dist/collection/classes/store.class.js +12 -8
- package/dist/collection/classes/store.class.js.map +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +214 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +96 -20
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/index.js +10 -1
- package/dist/collection/index.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-color-palette.js +1 -1
- package/dist/components/kritzel-color.js +1 -1
- package/dist/components/kritzel-context-menu.js +1 -1
- package/dist/components/kritzel-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-cursor-trail.js +1 -1
- package/dist/components/kritzel-dropdown.js +1 -1
- package/dist/components/kritzel-editor.js +49 -21
- 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-font-size.js +1 -1
- package/dist/components/kritzel-font.js +1 -1
- package/dist/components/kritzel-icon.js +1 -1
- package/dist/components/kritzel-stroke-size.js +1 -1
- package/dist/components/kritzel-tooltip.js +1 -1
- package/dist/components/kritzel-utility-panel.js +1 -1
- package/dist/components/{p-CmckGlXt.js → p-B57pFHwJ.js} +3 -3
- package/dist/components/{p-CmckGlXt.js.map → p-B57pFHwJ.js.map} +1 -1
- package/dist/components/{p-Ddfewfv9.js → p-B94Na1ee.js} +4 -4
- package/dist/components/{p-Ddfewfv9.js.map → p-B94Na1ee.js.map} +1 -1
- package/dist/components/{p-Ck2d5Wd1.js → p-BH1Tkwyh.js} +5 -5
- package/dist/components/{p-Ck2d5Wd1.js.map → p-BH1Tkwyh.js.map} +1 -1
- package/dist/components/{p-DqZOaMbq.js → p-BIlVkMTU.js} +378 -378
- package/dist/components/p-BIlVkMTU.js.map +1 -0
- package/dist/components/{p-BXJ8s30N.js → p-BtjtAfGW.js} +10 -10
- package/dist/components/{p-BXJ8s30N.js.map → p-BtjtAfGW.js.map} +1 -1
- package/dist/components/{p-DInF8Iby.js → p-C9FTWNZY.js} +3 -3
- package/dist/components/{p-DInF8Iby.js.map → p-C9FTWNZY.js.map} +1 -1
- package/dist/components/{p-B7P9QBiE.js → p-C9ZagG9K.js} +4 -4
- package/dist/components/{p-B7P9QBiE.js.map → p-C9ZagG9K.js.map} +1 -1
- package/dist/components/{p-BmAloSfd.js → p-CRiUM-tD.js} +4 -4
- package/dist/components/{p-BmAloSfd.js.map → p-CRiUM-tD.js.map} +1 -1
- package/dist/components/{p-BvPTbq7F.js → p-CSSrNLad.js} +3 -3
- package/dist/components/{p-BvPTbq7F.js.map → p-CSSrNLad.js.map} +1 -1
- package/dist/components/{p-DFhbw-Fr.js → p-CaQ7Iei7.js} +3 -3
- package/dist/components/{p-DFhbw-Fr.js.map → p-CaQ7Iei7.js.map} +1 -1
- package/dist/components/{p-CPjl7Inl.js → p-D04aTZsR.js} +4 -4
- package/dist/components/{p-CPjl7Inl.js.map → p-D04aTZsR.js.map} +1 -1
- package/dist/components/{p-maiDeBe9.js → p-DLV-5gE_.js} +9 -9
- package/dist/components/{p-maiDeBe9.js.map → p-DLV-5gE_.js.map} +1 -1
- package/dist/components/{p-DC8SDK2U.js → p-DoQOtXjT.js} +111 -107
- package/dist/components/p-DoQOtXjT.js.map +1 -0
- package/dist/components/{p-DieKGjdj.js → p-aZgXbW1r.js} +47 -35
- package/dist/components/{p-DieKGjdj.js.map → p-aZgXbW1r.js.map} +1 -1
- package/dist/components/{p-DfMdBA8L.js → p-fmNiA3Yr.js} +4 -4
- package/dist/components/{p-DfMdBA8L.js.map → p-fmNiA3Yr.js.map} +1 -1
- package/dist/components/{p-c6tIpE_t.js → p-h3bqYufZ.js} +3 -3
- package/dist/components/{p-c6tIpE_t.js.map → p-h3bqYufZ.js.map} +1 -1
- package/dist/components/{p-CZkSABuJ.js → p-ksTCzgsY.js} +3 -3
- package/dist/components/{p-CZkSABuJ.js.map → p-ksTCzgsY.js.map} +1 -1
- package/dist/components/{p-CFwf2KYj.js → p-mz1ayKXG.js} +17 -17
- package/dist/components/{p-CFwf2KYj.js.map → p-mz1ayKXG.js.map} +1 -1
- package/dist/components/{p-DHT5gK0E.js → p-yBnfPxIa.js} +4 -4
- package/dist/components/{p-DHT5gK0E.js.map → p-yBnfPxIa.js.map} +1 -1
- package/dist/esm/app-globals-DQuL1Twl.js +6 -0
- package/dist/esm/app-globals-DQuL1Twl.js.map +1 -0
- package/dist/esm/{index-BOJOOWaP.js → index-CGHvfMWF.js} +112 -109
- package/dist/esm/index-CGHvfMWF.js.map +1 -0
- package/dist/esm/index-rckCSz7Y.js +641 -0
- package/dist/esm/index-rckCSz7Y.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-brush-style_18.entry.js +62 -667
- package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
- package/dist/esm/loader.js +4 -3
- package/dist/esm/loader.js.map +1 -1
- package/dist/esm/stencil.js +5 -4
- package/dist/esm/stencil.js.map +1 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/loader.esm.js.map +1 -1
- package/dist/stencil/p-9394d74e.entry.js +2 -0
- package/dist/stencil/p-9394d74e.entry.js.map +1 -0
- package/dist/stencil/p-CGHvfMWF.js +3 -0
- package/dist/stencil/p-CGHvfMWF.js.map +1 -0
- package/dist/stencil/p-DQuL1Twl.js +2 -0
- package/dist/stencil/p-DQuL1Twl.js.map +1 -0
- package/dist/stencil/p-rckCSz7Y.js +2 -0
- package/dist/stencil/p-rckCSz7Y.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/stencil/stencil.esm.js.map +1 -1
- package/dist/types/classes/store.class.d.ts +4 -4
- package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +10 -2
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +4 -2
- package/dist/types/components.d.ts +13 -4
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +12 -5
- package/package.json +1 -1
- package/dist/cjs/index-D62tBCuq.js.map +0 -1
- package/dist/components/p-DC8SDK2U.js.map +0 -1
- package/dist/components/p-DqZOaMbq.js.map +0 -1
- package/dist/esm/index-BOJOOWaP.js.map +0 -1
- package/dist/stencil/p-BOJOOWaP.js +0 -3
- package/dist/stencil/p-BOJOOWaP.js.map +0 -1
- package/dist/stencil/p-dc26eb80.entry.js +0 -2
- package/dist/stencil/p-dc26eb80.entry.js.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h, H as Host,
|
|
1
|
+
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-CGHvfMWF.js';
|
|
2
|
+
import { K as KritzelBaseObject, a as KritzelBaseTool, b as KritzelEventHelper, A as AddObjectCommand, c as KritzelTextTool, d as KritzelMouseButton, e as KritzelBaseCommand, f as KritzelText, O as ObjectHelper, g as KritzelToolRegistry, h as KritzelKeyboardHelper } from './index-rckCSz7Y.js';
|
|
2
3
|
|
|
3
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)}";
|
|
4
5
|
|
|
@@ -223,98 +224,6 @@ const KritzelControlTextConfig = class {
|
|
|
223
224
|
};
|
|
224
225
|
KritzelControlTextConfig.style = kritzelControlTextConfigCss;
|
|
225
226
|
|
|
226
|
-
var KritzelMouseButton;
|
|
227
|
-
(function (KritzelMouseButton) {
|
|
228
|
-
KritzelMouseButton[KritzelMouseButton["Left"] = 0] = "Left";
|
|
229
|
-
KritzelMouseButton[KritzelMouseButton["Middle"] = 1] = "Middle";
|
|
230
|
-
KritzelMouseButton[KritzelMouseButton["Right"] = 2] = "Right";
|
|
231
|
-
})(KritzelMouseButton || (KritzelMouseButton = {}));
|
|
232
|
-
|
|
233
|
-
class KritzelEventHelper {
|
|
234
|
-
static isRightClick(ev) {
|
|
235
|
-
return ev.button === KritzelMouseButton.Right;
|
|
236
|
-
}
|
|
237
|
-
static isLeftClick(ev) {
|
|
238
|
-
return ev.button === KritzelMouseButton.Left;
|
|
239
|
-
}
|
|
240
|
-
static isMainMouseWheel(event) {
|
|
241
|
-
return Math.abs(event.deltaY) > 0 && Math.abs(event.deltaX) === 0 && Number.isInteger(event.deltaY);
|
|
242
|
-
}
|
|
243
|
-
static isPointerEventOnContextMenu(event) {
|
|
244
|
-
const path = event.composedPath();
|
|
245
|
-
const contextMenu = path.find(element => element.classList && element.classList.contains('context-menu'));
|
|
246
|
-
return !!contextMenu;
|
|
247
|
-
}
|
|
248
|
-
static onLongTouchPress(event, onSuccess, onCancel) {
|
|
249
|
-
if (event.pointerType !== 'touch') {
|
|
250
|
-
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
251
|
-
return () => { };
|
|
252
|
-
}
|
|
253
|
-
const longPressTimeout = 400;
|
|
254
|
-
const moveThreshold = 10;
|
|
255
|
-
const startX = event.clientX;
|
|
256
|
-
const startY = event.clientY;
|
|
257
|
-
const target = event.target;
|
|
258
|
-
const timer = setTimeout(() => {
|
|
259
|
-
removeListeners();
|
|
260
|
-
onSuccess(event);
|
|
261
|
-
}, longPressTimeout);
|
|
262
|
-
const cancel = () => {
|
|
263
|
-
clearTimeout(timer);
|
|
264
|
-
removeListeners();
|
|
265
|
-
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
266
|
-
};
|
|
267
|
-
const onPointerMove = (e) => {
|
|
268
|
-
if (Math.abs(e.clientX - startX) > moveThreshold || Math.abs(e.clientY - startY) > moveThreshold) {
|
|
269
|
-
cancel();
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
const onPointerUp = () => {
|
|
273
|
-
cancel();
|
|
274
|
-
};
|
|
275
|
-
const onPointerCancel = () => {
|
|
276
|
-
cancel();
|
|
277
|
-
};
|
|
278
|
-
const removeListeners = () => {
|
|
279
|
-
target.removeEventListener('pointermove', onPointerMove);
|
|
280
|
-
target.removeEventListener('pointerup', onPointerUp);
|
|
281
|
-
target.removeEventListener('pointercancel', onPointerCancel);
|
|
282
|
-
};
|
|
283
|
-
target.addEventListener('pointermove', onPointerMove, { passive: true });
|
|
284
|
-
target.addEventListener('pointerup', onPointerUp, { once: true });
|
|
285
|
-
target.addEventListener('pointercancel', onPointerCancel, { once: true });
|
|
286
|
-
return cancel;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
class KritzelBaseCommand {
|
|
291
|
-
constructor(store, initiator) {
|
|
292
|
-
var _a, _b;
|
|
293
|
-
this._store = store;
|
|
294
|
-
this.initiator = (_b = (_a = initiator === null || initiator === void 0 ? void 0 : initiator.constructor) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'Unknown';
|
|
295
|
-
this.isUndoable = true;
|
|
296
|
-
}
|
|
297
|
-
execute() {
|
|
298
|
-
throw new Error('Method not implemented.');
|
|
299
|
-
}
|
|
300
|
-
undo() {
|
|
301
|
-
throw new Error('Method not implemented.');
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
class AddObjectCommand extends KritzelBaseCommand {
|
|
306
|
-
constructor(store, initiator, object) {
|
|
307
|
-
super(store, initiator);
|
|
308
|
-
this.object = object;
|
|
309
|
-
}
|
|
310
|
-
execute() {
|
|
311
|
-
this._store.state.objectsOctree.insert(this.object);
|
|
312
|
-
}
|
|
313
|
-
undo() {
|
|
314
|
-
this._store.state.objectsOctree.remove(object => object.id === this.object.id);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
227
|
var cjs = {};
|
|
319
228
|
|
|
320
229
|
var hasRequiredCjs;
|
|
@@ -336,225 +245,6 @@ class KritzelMathHelper {
|
|
|
336
245
|
}
|
|
337
246
|
}
|
|
338
247
|
|
|
339
|
-
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
340
|
-
var t = {};
|
|
341
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
342
|
-
t[p] = s[p];
|
|
343
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
344
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
345
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
346
|
-
t[p[i]] = s[p[i]];
|
|
347
|
-
}
|
|
348
|
-
return t;
|
|
349
|
-
};
|
|
350
|
-
class ObjectHelper {
|
|
351
|
-
static generateUUID() {
|
|
352
|
-
return Math.random().toString(36).substr(2, 9);
|
|
353
|
-
}
|
|
354
|
-
static clone(objOrObjs) {
|
|
355
|
-
const cloneObject = (obj) => {
|
|
356
|
-
const remainingProps = __rest(obj, ["_store", "_elementRef", "totalWidth", "totalHeight"]);
|
|
357
|
-
return structuredClone(remainingProps);
|
|
358
|
-
};
|
|
359
|
-
if (Array.isArray(objOrObjs)) {
|
|
360
|
-
return objOrObjs.map(cloneObject);
|
|
361
|
-
}
|
|
362
|
-
return cloneObject(objOrObjs);
|
|
363
|
-
}
|
|
364
|
-
static isEmpty(obj) {
|
|
365
|
-
if (obj === null || obj === undefined) {
|
|
366
|
-
return true;
|
|
367
|
-
}
|
|
368
|
-
return (Object === null || Object === void 0 ? void 0 : Object.keys(obj).length) === 0 && (obj === null || obj === void 0 ? void 0 : obj.constructor) === Object;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
class KritzelBaseObject {
|
|
373
|
-
get totalWidth() {
|
|
374
|
-
return this.width + this.padding * 2;
|
|
375
|
-
}
|
|
376
|
-
get totalHeight() {
|
|
377
|
-
return this.height + this.padding * 2;
|
|
378
|
-
}
|
|
379
|
-
set elementRef(element) {
|
|
380
|
-
this._elementRef = element;
|
|
381
|
-
}
|
|
382
|
-
get elementRef() {
|
|
383
|
-
return this._elementRef;
|
|
384
|
-
}
|
|
385
|
-
get boundingBox() {
|
|
386
|
-
return {
|
|
387
|
-
x: this.translateX,
|
|
388
|
-
y: this.translateY,
|
|
389
|
-
z: this.scale,
|
|
390
|
-
width: this.totalWidth / this.scale,
|
|
391
|
-
height: this.totalHeight / this.scale,
|
|
392
|
-
depth: 0,
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
get rotatedBoundingBox() {
|
|
396
|
-
return {
|
|
397
|
-
x: this.minXRotated,
|
|
398
|
-
y: this.minYRotated,
|
|
399
|
-
z: this.scale,
|
|
400
|
-
width: this.maxXRotated - this.minXRotated,
|
|
401
|
-
height: this.maxYRotated - this.minYRotated,
|
|
402
|
-
depth: 0,
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
get rotatedPolygon() {
|
|
406
|
-
const cx = (this.translateX + this.totalWidth / 2 / this.scale);
|
|
407
|
-
const cy = (this.translateY + this.totalHeight / 2 / this.scale);
|
|
408
|
-
const angle = this.rotation;
|
|
409
|
-
const adjustedWidth = this.totalWidth / this.scale;
|
|
410
|
-
const adjustedHeight = this.totalHeight / this.scale;
|
|
411
|
-
const corners = {
|
|
412
|
-
topLeft: { x: this.translateX, y: this.translateY },
|
|
413
|
-
topRight: { x: this.translateX + adjustedWidth, y: this.translateY },
|
|
414
|
-
bottomRight: { x: this.translateX + adjustedWidth, y: this.translateY + adjustedHeight },
|
|
415
|
-
bottomLeft: { x: this.translateX, y: this.translateY + adjustedHeight },
|
|
416
|
-
};
|
|
417
|
-
const rotatedCorners = Object.keys(corners).reduce((acc, key) => {
|
|
418
|
-
const corner = corners[key];
|
|
419
|
-
const rotatedX = Math.cos(angle) * (corner.x - cx) - Math.sin(angle) * (corner.y - cy) + cx;
|
|
420
|
-
const rotatedY = Math.sin(angle) * (corner.x - cx) + Math.cos(angle) * (corner.y - cy) + cy;
|
|
421
|
-
acc[key] = { x: rotatedX, y: rotatedY };
|
|
422
|
-
return acc;
|
|
423
|
-
}, {});
|
|
424
|
-
return rotatedCorners;
|
|
425
|
-
}
|
|
426
|
-
get minXRotated() {
|
|
427
|
-
const corners = [
|
|
428
|
-
this.rotatedPolygon.topLeft.x,
|
|
429
|
-
this.rotatedPolygon.topRight.x,
|
|
430
|
-
this.rotatedPolygon.bottomRight.x,
|
|
431
|
-
this.rotatedPolygon.bottomLeft.x,
|
|
432
|
-
];
|
|
433
|
-
return Math.min(...corners);
|
|
434
|
-
}
|
|
435
|
-
get minYRotated() {
|
|
436
|
-
const corners = [
|
|
437
|
-
this.rotatedPolygon.topLeft.y,
|
|
438
|
-
this.rotatedPolygon.topRight.y,
|
|
439
|
-
this.rotatedPolygon.bottomRight.y,
|
|
440
|
-
this.rotatedPolygon.bottomLeft.y,
|
|
441
|
-
];
|
|
442
|
-
return Math.min(...corners);
|
|
443
|
-
}
|
|
444
|
-
get maxXRotated() {
|
|
445
|
-
const corners = [
|
|
446
|
-
this.rotatedPolygon.topLeft.x,
|
|
447
|
-
this.rotatedPolygon.topRight.x,
|
|
448
|
-
this.rotatedPolygon.bottomRight.x,
|
|
449
|
-
this.rotatedPolygon.bottomLeft.x,
|
|
450
|
-
];
|
|
451
|
-
return Math.max(...corners);
|
|
452
|
-
}
|
|
453
|
-
get maxYRotated() {
|
|
454
|
-
const corners = [
|
|
455
|
-
this.rotatedPolygon.topLeft.y,
|
|
456
|
-
this.rotatedPolygon.topRight.y,
|
|
457
|
-
this.rotatedPolygon.bottomRight.y,
|
|
458
|
-
this.rotatedPolygon.bottomLeft.y,
|
|
459
|
-
];
|
|
460
|
-
return Math.max(...corners);
|
|
461
|
-
}
|
|
462
|
-
get transformationMatrix() {
|
|
463
|
-
const scale = 1 / this.scale;
|
|
464
|
-
const translateX = this.translateX;
|
|
465
|
-
const translateY = this.translateY;
|
|
466
|
-
return `matrix(${scale}, 0, 0, ${scale}, ${translateX}, ${translateY})`;
|
|
467
|
-
}
|
|
468
|
-
get rotationDegrees() {
|
|
469
|
-
return this.rotation * (180 / Math.PI);
|
|
470
|
-
}
|
|
471
|
-
get centerX() {
|
|
472
|
-
return this.translateX + this.totalWidth / 2;
|
|
473
|
-
}
|
|
474
|
-
get centerY() {
|
|
475
|
-
return this.translateY + this.totalHeight / 2;
|
|
476
|
-
}
|
|
477
|
-
constructor() {
|
|
478
|
-
this.__class__ = 'KritzelBaseObject';
|
|
479
|
-
this.visible = true;
|
|
480
|
-
this.borderWidth = 0;
|
|
481
|
-
this.opacity = 1;
|
|
482
|
-
this.padding = 0;
|
|
483
|
-
this.selected = false;
|
|
484
|
-
this.resizing = false;
|
|
485
|
-
this.rotation = 0;
|
|
486
|
-
this.markedForRemoval = false;
|
|
487
|
-
this.isMounted = false;
|
|
488
|
-
this.zIndex = 0;
|
|
489
|
-
this.debugInfoVisible = false;
|
|
490
|
-
this.id = this.generateId();
|
|
491
|
-
}
|
|
492
|
-
static create(store) {
|
|
493
|
-
const object = new KritzelBaseObject();
|
|
494
|
-
object._store = store;
|
|
495
|
-
object.zIndex = store.currentZIndex;
|
|
496
|
-
return object;
|
|
497
|
-
}
|
|
498
|
-
mount(element) {
|
|
499
|
-
if (this.isMounted) {
|
|
500
|
-
return;
|
|
501
|
-
}
|
|
502
|
-
this.elementRef = element;
|
|
503
|
-
this.isMounted = true;
|
|
504
|
-
}
|
|
505
|
-
generateId() {
|
|
506
|
-
return ObjectHelper.generateUUID();
|
|
507
|
-
}
|
|
508
|
-
isInViewport() {
|
|
509
|
-
const viewportBounds = {
|
|
510
|
-
x: -this._store.state.translateX / this._store.state.scale,
|
|
511
|
-
y: -this._store.state.translateY / this._store.state.scale,
|
|
512
|
-
width: this._store.state.viewportWidth / this._store.state.scale,
|
|
513
|
-
height: this._store.state.viewportHeight / this._store.state.scale};
|
|
514
|
-
return this.boundingBox.x < viewportBounds.x + viewportBounds.width &&
|
|
515
|
-
this.boundingBox.x + this.boundingBox.width > viewportBounds.x &&
|
|
516
|
-
this.boundingBox.y < viewportBounds.y + viewportBounds.height &&
|
|
517
|
-
this.boundingBox.y + this.boundingBox.height > viewportBounds.y;
|
|
518
|
-
}
|
|
519
|
-
centerInViewport() {
|
|
520
|
-
const scale = this._store.state.scale;
|
|
521
|
-
this.translateX = (this._store.state.viewportWidth / 2 - this.totalWidth / 2 - this._store.state.translateX) / scale;
|
|
522
|
-
this.translateY = (this._store.state.viewportHeight / 2 - this.totalHeight / 2 - this._store.state.translateY) / scale;
|
|
523
|
-
}
|
|
524
|
-
move(startX, startY, endX, endY) {
|
|
525
|
-
const deltaX = (startX - endX) / this._store.state.scale;
|
|
526
|
-
const deltaY = (startY - endY) / this._store.state.scale;
|
|
527
|
-
this.translateX += deltaX;
|
|
528
|
-
this.translateY += deltaY;
|
|
529
|
-
}
|
|
530
|
-
resize(x, y, width, height) {
|
|
531
|
-
if (width <= 1 || height <= 1) {
|
|
532
|
-
return;
|
|
533
|
-
}
|
|
534
|
-
this.width = width;
|
|
535
|
-
this.height = height;
|
|
536
|
-
this.translateX = x;
|
|
537
|
-
this.translateY = y;
|
|
538
|
-
}
|
|
539
|
-
rotate(value) {
|
|
540
|
-
this.rotation = value;
|
|
541
|
-
}
|
|
542
|
-
copy() {
|
|
543
|
-
const copiedObject = Object.create(Object.getPrototypeOf(this));
|
|
544
|
-
Object.assign(copiedObject, this);
|
|
545
|
-
copiedObject.id = this.generateId();
|
|
546
|
-
copiedObject.isMounted = false;
|
|
547
|
-
return copiedObject;
|
|
548
|
-
}
|
|
549
|
-
onSelectedClick() {
|
|
550
|
-
// This method can be overridden by subclasses to handle click events when the object is selected.
|
|
551
|
-
}
|
|
552
|
-
revive(object) {
|
|
553
|
-
Object.assign(this, object);
|
|
554
|
-
return this;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
248
|
class KritzelPath extends KritzelBaseObject {
|
|
559
249
|
constructor() {
|
|
560
250
|
super(...arguments);
|
|
@@ -673,36 +363,6 @@ class KritzelPath extends KritzelBaseObject {
|
|
|
673
363
|
}
|
|
674
364
|
}
|
|
675
365
|
|
|
676
|
-
class KritzelBaseTool {
|
|
677
|
-
constructor(store) {
|
|
678
|
-
this.__class__ = this.constructor.name;
|
|
679
|
-
this.name = 'base-tool';
|
|
680
|
-
this._store = store;
|
|
681
|
-
}
|
|
682
|
-
onActivate() {
|
|
683
|
-
// default implementation
|
|
684
|
-
}
|
|
685
|
-
onDeactivate() {
|
|
686
|
-
// default implementation
|
|
687
|
-
}
|
|
688
|
-
handlePointerDown(_event) {
|
|
689
|
-
// default implementation
|
|
690
|
-
}
|
|
691
|
-
handlePointerMove(_event) {
|
|
692
|
-
// default implementation
|
|
693
|
-
}
|
|
694
|
-
handlePointerUp(_event) {
|
|
695
|
-
// default implementation
|
|
696
|
-
}
|
|
697
|
-
handleWheel(_event) {
|
|
698
|
-
// default implementation
|
|
699
|
-
}
|
|
700
|
-
revive(object) {
|
|
701
|
-
Object.assign(this, object);
|
|
702
|
-
return this;
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
|
|
706
366
|
class KritzelBrushTool extends KritzelBaseTool {
|
|
707
367
|
constructor(store) {
|
|
708
368
|
super(store);
|
|
@@ -815,302 +475,6 @@ class KritzelBrushTool extends KritzelBaseTool {
|
|
|
815
475
|
}
|
|
816
476
|
}
|
|
817
477
|
|
|
818
|
-
class KritzelToolRegistry {
|
|
819
|
-
static registerTool(toolName, constructor, store) {
|
|
820
|
-
const toolInstance = new constructor(store);
|
|
821
|
-
toolInstance.name = toolName;
|
|
822
|
-
this.registry[toolName] = toolInstance;
|
|
823
|
-
return toolInstance;
|
|
824
|
-
}
|
|
825
|
-
static getTool(toolName) {
|
|
826
|
-
const toolInstance = this.registry[toolName];
|
|
827
|
-
if (!toolInstance) {
|
|
828
|
-
console.warn(`Unknown tool: ${toolName}`);
|
|
829
|
-
return null;
|
|
830
|
-
}
|
|
831
|
-
return toolInstance;
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
KritzelToolRegistry.registry = {};
|
|
835
|
-
|
|
836
|
-
class KritzelText extends KritzelBaseObject {
|
|
837
|
-
get isReadonly() {
|
|
838
|
-
return !(this._store.state.activeTool instanceof KritzelTextTool);
|
|
839
|
-
}
|
|
840
|
-
constructor(config) {
|
|
841
|
-
super();
|
|
842
|
-
this.__class__ = 'KritzelText';
|
|
843
|
-
this.value = '';
|
|
844
|
-
this.fontFamily = 'Arial';
|
|
845
|
-
this.fontSize = 8;
|
|
846
|
-
this.fontColor = '#000000';
|
|
847
|
-
this.initialWidth = 3;
|
|
848
|
-
this.isNew = true;
|
|
849
|
-
this.debugInfoVisible = true;
|
|
850
|
-
this.rows = 1;
|
|
851
|
-
if (config) {
|
|
852
|
-
this.value = config.value || ' ';
|
|
853
|
-
this.translateX = config.translateX || 0;
|
|
854
|
-
this.translateY = config.translateY || 0;
|
|
855
|
-
this.fontSize = config.fontSize || 8;
|
|
856
|
-
this.fontFamily = config.fontFamily || 'Arial';
|
|
857
|
-
this.fontColor = config.fontColor || '#000000';
|
|
858
|
-
this.height = config.height || this.fontSize * 1.2;
|
|
859
|
-
this.width = config.width || 0;
|
|
860
|
-
this.scale = config.scale || 1;
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
static create(store, fontSize, fontFamily) {
|
|
864
|
-
const object = new KritzelText();
|
|
865
|
-
object._store = store;
|
|
866
|
-
object.fontSize = fontSize;
|
|
867
|
-
object.fontFamily = fontFamily;
|
|
868
|
-
object.translateX = 0;
|
|
869
|
-
object.translateY = 0;
|
|
870
|
-
object.width = object.initialWidth / (object._store.state.scale < 0 ? object._store.state.scale : 1);
|
|
871
|
-
object.height = (object.fontSize * 1.2) / (object._store.state.scale < 0 ? object._store.state.scale : 1);
|
|
872
|
-
object.padding = 5;
|
|
873
|
-
object.backgroundColor = 'transparent';
|
|
874
|
-
object.scale = object._store.state.scale;
|
|
875
|
-
object.value = ' ';
|
|
876
|
-
object.zIndex = store.currentZIndex;
|
|
877
|
-
return object;
|
|
878
|
-
}
|
|
879
|
-
mount(element) {
|
|
880
|
-
if ((this.isMounted && this.elementRef === element) || this.isInViewport() === false) {
|
|
881
|
-
return;
|
|
882
|
-
}
|
|
883
|
-
this.elementRef = element;
|
|
884
|
-
this.isMounted = true;
|
|
885
|
-
}
|
|
886
|
-
resize(x, y, width, height) {
|
|
887
|
-
if (width <= 1 || height <= 1) {
|
|
888
|
-
return;
|
|
889
|
-
}
|
|
890
|
-
const scaleFactor = height / this.height;
|
|
891
|
-
this.fontSize = this.fontSize * scaleFactor;
|
|
892
|
-
this.width = this.width * scaleFactor;
|
|
893
|
-
this.height = height;
|
|
894
|
-
this.translateX = x;
|
|
895
|
-
this.translateY = y;
|
|
896
|
-
}
|
|
897
|
-
handleKeyDown(event) {
|
|
898
|
-
if (this.isReadonly) {
|
|
899
|
-
event.preventDefault();
|
|
900
|
-
event.stopPropagation();
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
handleInput(event) {
|
|
904
|
-
const target = event.target;
|
|
905
|
-
if (target.value === '') {
|
|
906
|
-
this.value = ' ';
|
|
907
|
-
target.value = ' ';
|
|
908
|
-
target.selectionStart = target.selectionEnd = target.value.length;
|
|
909
|
-
}
|
|
910
|
-
else {
|
|
911
|
-
this.value = target.value.trim();
|
|
912
|
-
}
|
|
913
|
-
this.adjustTextareaSize();
|
|
914
|
-
}
|
|
915
|
-
adjustTextareaSize() {
|
|
916
|
-
if (this.elementRef) {
|
|
917
|
-
const span = document.createElement('span');
|
|
918
|
-
span.style.position = 'absolute';
|
|
919
|
-
span.style.whiteSpace = 'pre-wrap';
|
|
920
|
-
span.style.visibility = 'hidden';
|
|
921
|
-
span.style.fontSize = window.getComputedStyle(this.elementRef).fontSize;
|
|
922
|
-
span.style.fontFamily = window.getComputedStyle(this.elementRef).fontFamily;
|
|
923
|
-
span.innerHTML = this.elementRef.value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g, '<br>') + '<br>';
|
|
924
|
-
document.body.appendChild(span);
|
|
925
|
-
const textWidth = span.offsetWidth;
|
|
926
|
-
const textHeight = span.offsetHeight;
|
|
927
|
-
document.body.removeChild(span);
|
|
928
|
-
this.width = textWidth;
|
|
929
|
-
this.height = textHeight;
|
|
930
|
-
this._store.rerender();
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
focus() {
|
|
934
|
-
if (this.elementRef) {
|
|
935
|
-
this.elementRef.focus();
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
selectAll() {
|
|
939
|
-
if (this.elementRef) {
|
|
940
|
-
this.elementRef.select();
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
insertFromClipboard() {
|
|
944
|
-
if (this.elementRef) {
|
|
945
|
-
this.elementRef.focus();
|
|
946
|
-
try {
|
|
947
|
-
navigator.clipboard.readText().then(text => {
|
|
948
|
-
const start = this.elementRef.selectionStart;
|
|
949
|
-
const end = this.elementRef.selectionEnd;
|
|
950
|
-
const value = this.elementRef.value;
|
|
951
|
-
this.elementRef.value = value.substring(0, start) + text + value.substring(end);
|
|
952
|
-
this.elementRef.selectionStart = this.elementRef.selectionEnd = start + text.length;
|
|
953
|
-
this.value = this.elementRef.value;
|
|
954
|
-
this.adjustTextareaSize();
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
catch (err) {
|
|
958
|
-
console.error('Failed to read clipboard contents:', err);
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
onSelectedClick() {
|
|
963
|
-
this._store.setState('activeTool', KritzelToolRegistry.getTool('text'));
|
|
964
|
-
this._store.state.selectionGroup = null;
|
|
965
|
-
this._store.state.selectionBox = null;
|
|
966
|
-
this._store.state.activeText = this;
|
|
967
|
-
setTimeout(() => {
|
|
968
|
-
this.focus();
|
|
969
|
-
}, 300);
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
class KritzelKeyboardHelper {
|
|
974
|
-
static forceHideKeyboard() {
|
|
975
|
-
if (document.activeElement instanceof HTMLElement) {
|
|
976
|
-
document.activeElement.blur();
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
static enableInteractiveWidget() {
|
|
980
|
-
const meta = document.querySelector('meta[name="viewport"][content*="interactive-widget=resizes-content"]');
|
|
981
|
-
if (meta) {
|
|
982
|
-
let currentContent = meta.getAttribute('content');
|
|
983
|
-
if (!currentContent.includes('interactive-widget=resizes-content')) {
|
|
984
|
-
currentContent += ', interactive-widget=resizes-content';
|
|
985
|
-
}
|
|
986
|
-
meta.setAttribute('content', currentContent);
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
static disableInteractiveWidget() {
|
|
990
|
-
const meta = document.querySelector('meta[name="viewport"][content*="interactive-widget=resizes-content"]');
|
|
991
|
-
if (meta) {
|
|
992
|
-
let currentContent = meta.getAttribute('content');
|
|
993
|
-
let newContent = currentContent.replace(/\s*interactive-widget=resizes-content\s*[,;]?/g, '');
|
|
994
|
-
newContent = newContent
|
|
995
|
-
.replace(/,(\s*,)+/g, ',')
|
|
996
|
-
.replace(/^,/, '')
|
|
997
|
-
.replace(/,$/, '')
|
|
998
|
-
.trim();
|
|
999
|
-
meta.setAttribute('content', newContent);
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
class KritzelTextTool extends KritzelBaseTool {
|
|
1005
|
-
constructor(store) {
|
|
1006
|
-
super(store);
|
|
1007
|
-
this.fontFamily = 'Arial';
|
|
1008
|
-
this.fontSize = 16;
|
|
1009
|
-
this.fontColor = '#000000';
|
|
1010
|
-
this.palette = [
|
|
1011
|
-
'#000000',
|
|
1012
|
-
'#FFFFFF',
|
|
1013
|
-
'#FF0000',
|
|
1014
|
-
'#00FF00',
|
|
1015
|
-
'#0000FF',
|
|
1016
|
-
'#FFFF00',
|
|
1017
|
-
'#FF00FF',
|
|
1018
|
-
'#00FFFF',
|
|
1019
|
-
'#808080',
|
|
1020
|
-
'#C0C0C0',
|
|
1021
|
-
'#800000',
|
|
1022
|
-
'#008000',
|
|
1023
|
-
'#000080',
|
|
1024
|
-
'#808000',
|
|
1025
|
-
'#800080',
|
|
1026
|
-
];
|
|
1027
|
-
}
|
|
1028
|
-
handlePointerDown(event) {
|
|
1029
|
-
if (event.cancelable) {
|
|
1030
|
-
event.preventDefault();
|
|
1031
|
-
}
|
|
1032
|
-
if (event.pointerType === 'mouse') {
|
|
1033
|
-
const path = event.composedPath().slice(1);
|
|
1034
|
-
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
1035
|
-
const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
|
|
1036
|
-
if (this._store.state.activeText === null && object && object instanceof KritzelText) {
|
|
1037
|
-
this._store.state.activeText = object;
|
|
1038
|
-
object.focus();
|
|
1039
|
-
return;
|
|
1040
|
-
}
|
|
1041
|
-
if (this._store.state.activeText !== null && object instanceof KritzelText) {
|
|
1042
|
-
object.focus();
|
|
1043
|
-
return;
|
|
1044
|
-
}
|
|
1045
|
-
if (this._store.state.activeText !== null) {
|
|
1046
|
-
this._store.resetActiveText();
|
|
1047
|
-
this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
1048
|
-
return;
|
|
1049
|
-
}
|
|
1050
|
-
if (KritzelEventHelper.isLeftClick(event) === false) {
|
|
1051
|
-
return;
|
|
1052
|
-
}
|
|
1053
|
-
const clientX = event.clientX - this._store.offsetX;
|
|
1054
|
-
const clientY = event.clientY - this._store.offsetY;
|
|
1055
|
-
const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
|
|
1056
|
-
text.fontColor = this.fontColor;
|
|
1057
|
-
text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
|
|
1058
|
-
text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
|
|
1059
|
-
text.zIndex = this._store.currentZIndex;
|
|
1060
|
-
this._store.state.activeText = text;
|
|
1061
|
-
this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
|
|
1062
|
-
}
|
|
1063
|
-
if (event.pointerType === 'touch') {
|
|
1064
|
-
const activePointers = Array.from(this._store.state.pointers.values());
|
|
1065
|
-
const path = event.composedPath().slice(1);
|
|
1066
|
-
const objectElement = path.find(element => element.classList && element.classList.contains('object'));
|
|
1067
|
-
const object = this._store.findObjectById(objectElement === null || objectElement === void 0 ? void 0 : objectElement.id);
|
|
1068
|
-
if (this._store.state.activeText === null && object && object instanceof KritzelText) {
|
|
1069
|
-
this._store.state.activeText = object;
|
|
1070
|
-
object.focus();
|
|
1071
|
-
return;
|
|
1072
|
-
}
|
|
1073
|
-
if (this._store.state.activeText !== null && object instanceof KritzelText) {
|
|
1074
|
-
object.focus();
|
|
1075
|
-
return;
|
|
1076
|
-
}
|
|
1077
|
-
if (this._store.state.activeText !== null) {
|
|
1078
|
-
this._store.resetActiveText();
|
|
1079
|
-
this._store.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
1080
|
-
return;
|
|
1081
|
-
}
|
|
1082
|
-
if (activePointers.length > 1) {
|
|
1083
|
-
return;
|
|
1084
|
-
}
|
|
1085
|
-
KritzelKeyboardHelper.disableInteractiveWidget();
|
|
1086
|
-
const clientX = Math.round(activePointers[0].clientX - this._store.offsetX);
|
|
1087
|
-
const clientY = Math.round(activePointers[0].clientY - this._store.offsetY);
|
|
1088
|
-
const text = KritzelText.create(this._store, this.fontSize, this.fontFamily);
|
|
1089
|
-
text.fontColor = this.fontColor;
|
|
1090
|
-
text.translateX = (clientX - this._store.state.translateX) / this._store.state.scale;
|
|
1091
|
-
text.translateY = (clientY - this._store.state.translateY) / this._store.state.scale;
|
|
1092
|
-
text.zIndex = this._store.currentZIndex;
|
|
1093
|
-
this._store.state.activeText = text;
|
|
1094
|
-
this._store.history.executeCommand(new AddObjectCommand(this._store, this, text));
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
handlePointerUp(event) {
|
|
1098
|
-
var _a, _b, _c, _d;
|
|
1099
|
-
if (event.cancelable) {
|
|
1100
|
-
event.preventDefault();
|
|
1101
|
-
}
|
|
1102
|
-
if (event.pointerType === 'mouse') {
|
|
1103
|
-
(_a = this._store.state.activeText) === null || _a === void 0 ? void 0 : _a.adjustTextareaSize();
|
|
1104
|
-
(_b = this._store.state.activeText) === null || _b === void 0 ? void 0 : _b.focus();
|
|
1105
|
-
}
|
|
1106
|
-
if (event.pointerType === 'touch') {
|
|
1107
|
-
(_c = this._store.state.activeText) === null || _c === void 0 ? void 0 : _c.adjustTextareaSize();
|
|
1108
|
-
(_d = this._store.state.activeText) === null || _d === void 0 ? void 0 : _d.focus();
|
|
1109
|
-
KritzelKeyboardHelper.enableInteractiveWidget();
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
478
|
class KritzelDevicesHelper {
|
|
1115
479
|
static isTouchDevice() {
|
|
1116
480
|
return window.matchMedia('(any-pointer: coarse)').matches;
|
|
@@ -2924,6 +2288,27 @@ const KritzelEditor = class {
|
|
|
2924
2288
|
this.customSvgIcons = {};
|
|
2925
2289
|
this.hideControls = false;
|
|
2926
2290
|
}
|
|
2291
|
+
async getObjectById(id) {
|
|
2292
|
+
return this.engineRef.getObjectById(id);
|
|
2293
|
+
}
|
|
2294
|
+
async addObject(object) {
|
|
2295
|
+
return this.engineRef.addObject(object);
|
|
2296
|
+
}
|
|
2297
|
+
async updateObject(object, updatedProperties) {
|
|
2298
|
+
return this.engineRef.updateObject(object, updatedProperties);
|
|
2299
|
+
}
|
|
2300
|
+
async removeObject(object) {
|
|
2301
|
+
return this.engineRef.removeObject(object);
|
|
2302
|
+
}
|
|
2303
|
+
async selectObjects(objects) {
|
|
2304
|
+
return this.engineRef.selectObjects(objects);
|
|
2305
|
+
}
|
|
2306
|
+
async selectAllObjectsInViewport() {
|
|
2307
|
+
return this.engineRef.selectAllObjectsInViewport();
|
|
2308
|
+
}
|
|
2309
|
+
async clearSelection() {
|
|
2310
|
+
this.engineRef.clearSelection();
|
|
2311
|
+
}
|
|
2927
2312
|
handleTouchStart(event) {
|
|
2928
2313
|
if (event.cancelable) {
|
|
2929
2314
|
event.preventDefault();
|
|
@@ -2945,7 +2330,7 @@ const KritzelEditor = class {
|
|
|
2945
2330
|
}
|
|
2946
2331
|
}
|
|
2947
2332
|
render() {
|
|
2948
|
-
return (h(Host, { key: '
|
|
2333
|
+
return (h(Host, { key: '5192399124222f7bd8a8d66054e6053befdebdfb' }, h("kritzel-engine", { key: '5fe3019675f579dfd14bb0072422de1e97f4fe18', ref: el => (this.engineRef = el) }), h("kritzel-controls", { key: '99f382d75380d770a634cbdbe873c29bf95a7b08', ref: el => (this.controlsRef = el), controls: this.controls, style: this.hideControls ? { display: 'none' } : { display: 'flex' } })));
|
|
2949
2334
|
}
|
|
2950
2335
|
get host() { return getElement(this); }
|
|
2951
2336
|
};
|
|
@@ -3536,9 +2921,10 @@ class KritzelStore {
|
|
|
3536
2921
|
this.state.copiedObjects = this.state.selectionGroup.copy();
|
|
3537
2922
|
this.setState('activeTool', KritzelToolRegistry.getTool('selection'));
|
|
3538
2923
|
}
|
|
3539
|
-
|
|
2924
|
+
bringForward(object) {
|
|
3540
2925
|
const max = this.allObjects.length + 1;
|
|
3541
|
-
const
|
|
2926
|
+
const objects = object ? [object] : this.state.selectionGroup.objects;
|
|
2927
|
+
const increaseZIndexCommands = objects.map(obj => {
|
|
3542
2928
|
if (obj.zIndex === max) {
|
|
3543
2929
|
return;
|
|
3544
2930
|
}
|
|
@@ -3546,9 +2932,10 @@ class KritzelStore {
|
|
|
3546
2932
|
});
|
|
3547
2933
|
this.history.executeCommand(new BatchCommand(this, this, increaseZIndexCommands));
|
|
3548
2934
|
}
|
|
3549
|
-
|
|
2935
|
+
sendBackward(object) {
|
|
3550
2936
|
const min = 0;
|
|
3551
|
-
const
|
|
2937
|
+
const objects = object ? [object] : this.state.selectionGroup.objects;
|
|
2938
|
+
const decreaseZIndexCommands = objects.map(obj => {
|
|
3552
2939
|
if (obj.zIndex === min) {
|
|
3553
2940
|
return;
|
|
3554
2941
|
}
|
|
@@ -3556,16 +2943,18 @@ class KritzelStore {
|
|
|
3556
2943
|
});
|
|
3557
2944
|
this.history.executeCommand(new BatchCommand(this, this, decreaseZIndexCommands));
|
|
3558
2945
|
}
|
|
3559
|
-
|
|
2946
|
+
bringToFront(object) {
|
|
3560
2947
|
const max = this.allObjects.length + 1;
|
|
3561
|
-
const
|
|
2948
|
+
const objects = object ? [object] : this.state.selectionGroup.objects;
|
|
2949
|
+
const increaseZIndexCommands = objects.map(obj => {
|
|
3562
2950
|
return new UpdateObjectCommand(this, this, obj, { zIndex: max });
|
|
3563
2951
|
});
|
|
3564
2952
|
this.history.executeCommand(new BatchCommand(this, this, increaseZIndexCommands));
|
|
3565
2953
|
}
|
|
3566
|
-
|
|
2954
|
+
sendToBack(object) {
|
|
3567
2955
|
const min = -1;
|
|
3568
|
-
const
|
|
2956
|
+
const objects = object ? [object] : this.state.selectionGroup.objects;
|
|
2957
|
+
const decreaseZIndexCommands = objects.map(obj => {
|
|
3569
2958
|
return new UpdateObjectCommand(this, this, obj, { zIndex: min });
|
|
3570
2959
|
});
|
|
3571
2960
|
this.history.executeCommand(new BatchCommand(this, this, decreaseZIndexCommands));
|
|
@@ -3710,16 +3099,16 @@ class KritzelKeyHandler extends KritzelBaseHandler {
|
|
|
3710
3099
|
this._store.paste();
|
|
3711
3100
|
}
|
|
3712
3101
|
if (event.key === '+' && event.ctrlKey && this._store.state.selectionGroup) {
|
|
3713
|
-
this._store.
|
|
3102
|
+
this._store.bringForward();
|
|
3714
3103
|
}
|
|
3715
3104
|
if (event.key === '-' && event.ctrlKey && this._store.state.selectionGroup) {
|
|
3716
|
-
this._store.
|
|
3105
|
+
this._store.sendBackward();
|
|
3717
3106
|
}
|
|
3718
3107
|
if (event.key === '*' && event.shiftKey && this._store.state.selectionGroup) {
|
|
3719
|
-
this._store.
|
|
3108
|
+
this._store.bringToFront();
|
|
3720
3109
|
}
|
|
3721
3110
|
if (event.key === '_' && event.shiftKey && this._store.state.selectionGroup) {
|
|
3722
|
-
this._store.
|
|
3111
|
+
this._store.sendToBack();
|
|
3723
3112
|
}
|
|
3724
3113
|
if (event.key === 'a' && event.ctrlKey && this._store.state.activeText) {
|
|
3725
3114
|
this._store.state.activeText.selectAll();
|
|
@@ -3974,11 +3363,17 @@ const KritzelEngine = class {
|
|
|
3974
3363
|
async paste(x, y) {
|
|
3975
3364
|
this.store.paste(x, y);
|
|
3976
3365
|
}
|
|
3977
|
-
async
|
|
3978
|
-
this.store.
|
|
3366
|
+
async bringForward(object) {
|
|
3367
|
+
this.store.bringForward(object);
|
|
3368
|
+
}
|
|
3369
|
+
async sendBackward(object) {
|
|
3370
|
+
this.store.sendBackward(object);
|
|
3371
|
+
}
|
|
3372
|
+
async moveToTop(object) {
|
|
3373
|
+
this.store.bringToFront(object);
|
|
3979
3374
|
}
|
|
3980
|
-
async moveToBottom() {
|
|
3981
|
-
this.store.
|
|
3375
|
+
async moveToBottom(object) {
|
|
3376
|
+
this.store.sendToBack(object);
|
|
3982
3377
|
}
|
|
3983
3378
|
async undo() {
|
|
3984
3379
|
this.store.history.undo();
|
|
@@ -4040,15 +3435,15 @@ const KritzelEngine = class {
|
|
|
4040
3435
|
const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
|
|
4041
3436
|
const baseHandleSize = parseFloat(baseHandleSizePx);
|
|
4042
3437
|
const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
|
|
4043
|
-
return (h(Host, { key: '
|
|
4044
|
-
_a.translateX), h("div", { key: '
|
|
4045
|
-
_b.translateY), h("div", { key: '
|
|
4046
|
-
_c.viewportWidth), h("div", { key: '
|
|
4047
|
-
_d.viewportHeight), h("div", { key: '
|
|
4048
|
-
_e.scale), h("div", { key: '
|
|
4049
|
-
_g.name), h("div", { key: '
|
|
4050
|
-
_m.cursorX), h("div", { key: '
|
|
4051
|
-
_o.cursorY)), h("div", { key: '
|
|
3438
|
+
return (h(Host, { key: '46b1c0d4000229b7881636625af38db319ff49ae' }, h("div", { key: '7b91f710711ff1fefd395c38f79004c84a3df74d', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, h("div", { key: '63568d0cceef92262bbf40f54f84d5003302f7c1' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
|
|
3439
|
+
_a.translateX), h("div", { key: 'cd7a9f6bf33d547b23814468c1d2ae726f5d5576' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
|
|
3440
|
+
_b.translateY), h("div", { key: '42788d635e64f1e1f1da2f6b0ec8cf0fec988769' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
|
|
3441
|
+
_c.viewportWidth), h("div", { key: 'bd674b2a6b13b22ad177d2bc0527a6b2d41d523f' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
|
|
3442
|
+
_d.viewportHeight), h("div", { key: 'faa9581a80b8020ebe4f48cfbea4b0a91a17b1d0' }, "ObjectsInViewport. ", this.store.objects.length), h("div", { key: '74e9671f7f546debca0884e74e7b5cdbba0810de' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
|
|
3443
|
+
_e.scale), h("div", { key: '7f14af283874e226cfdcdf5bf17c0c4f6935f154' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
|
|
3444
|
+
_g.name), h("div", { key: '5d9bb07762326387a04d99d9d1f0487c809a8d13' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), h("div", { key: '65b54f060f162e328d8756845a991b84cd377fa8' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), h("div", { key: '0593106ef382e3a4b4368f503d435550ee52b686' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), h("div", { key: '2d9102c016bbc89bd3f61b46c364663d822ae773' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), h("div", { key: '5393b7974bf7e8c391ec67945610b0051d155393' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), h("div", { key: '3591db55fdf4b92162f4d516d307b9f42a6f996a' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", { key: '2fef15767414c841b320705638328f45ab6e01b7' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", { key: '20cf1b12790c3f7112484de2343ed157536f072f' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", { key: 'b23da45c9f13deb827f837651ab4e09cdb435aa9' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", { key: '6c3d8cf2aeacf3c9e7930eca83676bfa59f3d2cb' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), h("div", { key: 'c87abe35d1aa55d11d321cec3d78f6722a04d114' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), h("div", { key: '3d371da3b1075c5b116ae0db50ae5b8d22e6c2eb' }, "CursorX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
|
|
3445
|
+
_m.cursorX), h("div", { key: '1a426883cfbfd742aa127d7fff92080586f4af62' }, "CursorY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
|
|
3446
|
+
_o.cursorY)), h("div", { key: '5de09bb5222a271a3163d7226e012cb86c722a7e', class: "origin", style: {
|
|
4052
3447
|
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})`,
|
|
4053
3448
|
} }, (_t = this.store.objects) === null || _t === void 0 ? void 0 :
|
|
4054
3449
|
_t.map(object => {
|
|
@@ -4145,7 +3540,7 @@ const KritzelEngine = class {
|
|
|
4145
3540
|
fill: 'transparent',
|
|
4146
3541
|
cursor: 'grab',
|
|
4147
3542
|
}, 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)))))));
|
|
4148
|
-
}), h("svg", { key: '
|
|
3543
|
+
}), h("svg", { key: '684971a4c93f5d8cdf52497d0f3f81dc21ece397', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
4149
3544
|
height: (_u = this.store.state.currentPath) === null || _u === void 0 ? void 0 : _u.height.toString(),
|
|
4150
3545
|
width: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.width.toString(),
|
|
4151
3546
|
left: '0',
|
|
@@ -4155,12 +3550,12 @@ const KritzelEngine = class {
|
|
|
4155
3550
|
transform: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.transformationMatrix,
|
|
4156
3551
|
transformOrigin: 'top left',
|
|
4157
3552
|
overflow: 'visible',
|
|
4158
|
-
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, h("path", { key: '
|
|
3553
|
+
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, h("path", { key: 'e29e0b110612e569a8fada121d749f66ab5e2aae', 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: '81b88db00390e6ba768b7432e941a87ba56e54e5', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, style: {
|
|
4159
3554
|
position: 'fixed',
|
|
4160
3555
|
left: `${this.store.state.contextMenuX}px`,
|
|
4161
3556
|
top: `${this.store.state.contextMenuY}px`,
|
|
4162
3557
|
zIndex: '10000',
|
|
4163
|
-
}, 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: '
|
|
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: '700ef43b524157ef757973fc039b2d74e7920578', store: this.store })));
|
|
4164
3559
|
}
|
|
4165
3560
|
get host() { return getElement(this); }
|
|
4166
3561
|
};
|