@node-projects/web-component-designer 0.0.87 → 0.0.88
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/elements/controls/PlainScrollbar.js +122 -116
- package/dist/elements/widgets/designerView/IDesignerCanvas.d.ts +5 -0
- package/dist/elements/widgets/designerView/designerCanvas.d.ts +10 -1
- package/dist/elements/widgets/designerView/designerCanvas.js +63 -14
- package/dist/elements/widgets/designerView/designerCanvas.ts.BASE.d.ts +92 -0
- package/dist/elements/widgets/designerView/designerCanvas.ts.BASE.js +734 -0
- package/dist/elements/widgets/designerView/designerCanvas.ts.LOCAL.d.ts +95 -0
- package/dist/elements/widgets/designerView/designerCanvas.ts.LOCAL.js +768 -0
- package/dist/elements/widgets/designerView/designerCanvas.ts.REMOTE.d.ts +94 -0
- package/dist/elements/widgets/designerView/designerCanvas.ts.REMOTE.js +745 -0
- package/dist/elements/widgets/designerView/designerView.js +19 -15
- package/dist/elements/widgets/designerView/tools/MagicWandSelectorTool.js +9 -9
- package/dist/elements/widgets/designerView/tools/RectangleSelectorTool.js +9 -9
- package/dist/elements/widgets/designerView/tools/ZoomTool.d.ts +7 -1
- package/dist/elements/widgets/designerView/tools/ZoomTool.js +34 -0
- package/package.json +1 -1
|
@@ -142,7 +142,7 @@ class Widget {
|
|
|
142
142
|
if (clippedNewValue == this.value) {
|
|
143
143
|
return false;
|
|
144
144
|
}
|
|
145
|
-
this.value = clippedNewValue;
|
|
145
|
+
this.value = isNaN(clippedNewValue) ? 0 : clippedNewValue;
|
|
146
146
|
this.updateThumbPosition();
|
|
147
147
|
return true;
|
|
148
148
|
}
|
|
@@ -281,10 +281,16 @@ export class PlainScrollbar extends HTMLElement {
|
|
|
281
281
|
widget;
|
|
282
282
|
constructor() {
|
|
283
283
|
super();
|
|
284
|
-
const value = parseFloat(this.getAttribute("value"));
|
|
285
284
|
this.widget = new Widget(this);
|
|
285
|
+
const value = parseFloat(this.getAttribute("value"));
|
|
286
286
|
if (!isNaN(value))
|
|
287
287
|
this.widget.value = value;
|
|
288
|
+
if (this.hasOwnProperty('value')) {
|
|
289
|
+
let value = this.value;
|
|
290
|
+
delete this.value;
|
|
291
|
+
if (!isNaN(value))
|
|
292
|
+
this.widget.value = value;
|
|
293
|
+
}
|
|
288
294
|
}
|
|
289
295
|
/* @Override */ connectedCallback() {
|
|
290
296
|
this.widget.connectedCallback();
|
|
@@ -343,121 +349,121 @@ export class PlainScrollbar extends HTMLElement {
|
|
|
343
349
|
const EPS = 1E-9;
|
|
344
350
|
const buttonSize = "var(--plain-scrollbar-button-size, 13px)";
|
|
345
351
|
const buttonPath = '<path d="M -60 30 h 120 L 0 -30 z" stroke-width="0"/>';
|
|
346
|
-
const scrollbarStyle = `
|
|
347
|
-
:host {
|
|
348
|
-
display: block;
|
|
349
|
-
contain: content;
|
|
350
|
-
background-color: #f8f8f8;
|
|
351
|
-
border-style: solid;
|
|
352
|
-
border-width: 1px;
|
|
353
|
-
border-color: #dddddd;
|
|
354
|
-
}
|
|
355
|
-
#root {
|
|
356
|
-
touch-action: none;
|
|
357
|
-
user-select: none;
|
|
358
|
-
box-sizing: border-box;
|
|
359
|
-
position: relative;
|
|
360
|
-
width: 100%;
|
|
361
|
-
height: 100%;
|
|
362
|
-
}
|
|
363
|
-
#trough {
|
|
364
|
-
position: absolute;
|
|
365
|
-
}
|
|
366
|
-
#root.vertical #trough {
|
|
367
|
-
width: 100%;
|
|
368
|
-
top: ${buttonSize};
|
|
369
|
-
bottom: ${buttonSize};
|
|
370
|
-
}
|
|
371
|
-
#root.horizontal #trough {
|
|
372
|
-
height: 100%;
|
|
373
|
-
left: ${buttonSize};
|
|
374
|
-
right: ${buttonSize};
|
|
375
|
-
}
|
|
376
|
-
#thumb {
|
|
377
|
-
box-sizing: border-box;
|
|
378
|
-
position: absolute;
|
|
379
|
-
width: 100%;
|
|
380
|
-
height: 100%;
|
|
381
|
-
background-color: var(--plain-scrollbar-thumb-background-color, #f0f0f0);
|
|
382
|
-
border-style: solid;
|
|
383
|
-
border-width: var(--plain-scrollbar-thumb-border-width, 1px);
|
|
384
|
-
border-color: var(--plain-scrollbar-thumb-border-color, #b8b8b8);
|
|
385
|
-
border-radius: var(--plain-scrollbar-thumb-border-radius, 4px);
|
|
386
|
-
transition: background-color 50ms linear;
|
|
387
|
-
}
|
|
388
|
-
#thumb:hover {
|
|
389
|
-
background-color: var(--plain-scrollbar-thumb-background-color-hover, #e0e0e0);
|
|
390
|
-
}
|
|
391
|
-
#thumb.active {
|
|
392
|
-
background-color: var(--plain-scrollbar-thumb-background-color-active, #c0c0c0);
|
|
393
|
-
}
|
|
394
|
-
#button1,
|
|
395
|
-
#button2 {
|
|
396
|
-
box-sizing: border-box;
|
|
397
|
-
position: absolute;
|
|
398
|
-
display: block;
|
|
399
|
-
fill: var(--plain-scrollbar-button-color, #606060);
|
|
400
|
-
}
|
|
401
|
-
#root.vertical #button1 {
|
|
402
|
-
top: 0;
|
|
403
|
-
width: 100%;
|
|
404
|
-
height: ${buttonSize};
|
|
405
|
-
}
|
|
406
|
-
#root.vertical #button2 {
|
|
407
|
-
bottom: 0;
|
|
408
|
-
width: 100%;
|
|
409
|
-
height: ${buttonSize};
|
|
410
|
-
}
|
|
411
|
-
#root.horizontal #button1 {
|
|
412
|
-
left: 0;
|
|
413
|
-
height: 100%;
|
|
414
|
-
width: ${buttonSize};
|
|
415
|
-
}
|
|
416
|
-
#root.horizontal #button2 {
|
|
417
|
-
right: 0;
|
|
418
|
-
height: 100%;
|
|
419
|
-
width: ${buttonSize};
|
|
420
|
-
}
|
|
421
|
-
#upArrow,
|
|
422
|
-
#downArrow,
|
|
423
|
-
#leftArrow,
|
|
424
|
-
#rightArrow {
|
|
425
|
-
display: none;
|
|
426
|
-
width: 100%;
|
|
427
|
-
height: 100%;
|
|
428
|
-
}
|
|
429
|
-
#root.vertical #upArrow,
|
|
430
|
-
#root.vertical #downArrow {
|
|
431
|
-
display: block;
|
|
432
|
-
}
|
|
433
|
-
#root.horizontal #leftArrow,
|
|
434
|
-
#root.horizontal #rightArrow {
|
|
435
|
-
display: block;
|
|
436
|
-
}
|
|
437
|
-
#button1:hover,
|
|
438
|
-
#button2:hover {
|
|
439
|
-
background-color: var(--plain-scrollbar-button-color-hover, #e0e0e0);
|
|
440
|
-
}
|
|
441
|
-
#button1.active,
|
|
442
|
-
#button2.active {
|
|
443
|
-
background-color: var(--plain-scrollbar-button-color-active, #c0c0c0);
|
|
444
|
-
}
|
|
352
|
+
const scrollbarStyle = `
|
|
353
|
+
:host {
|
|
354
|
+
display: block;
|
|
355
|
+
contain: content;
|
|
356
|
+
background-color: #f8f8f8;
|
|
357
|
+
border-style: solid;
|
|
358
|
+
border-width: 1px;
|
|
359
|
+
border-color: #dddddd;
|
|
360
|
+
}
|
|
361
|
+
#root {
|
|
362
|
+
touch-action: none;
|
|
363
|
+
user-select: none;
|
|
364
|
+
box-sizing: border-box;
|
|
365
|
+
position: relative;
|
|
366
|
+
width: 100%;
|
|
367
|
+
height: 100%;
|
|
368
|
+
}
|
|
369
|
+
#trough {
|
|
370
|
+
position: absolute;
|
|
371
|
+
}
|
|
372
|
+
#root.vertical #trough {
|
|
373
|
+
width: 100%;
|
|
374
|
+
top: ${buttonSize};
|
|
375
|
+
bottom: ${buttonSize};
|
|
376
|
+
}
|
|
377
|
+
#root.horizontal #trough {
|
|
378
|
+
height: 100%;
|
|
379
|
+
left: ${buttonSize};
|
|
380
|
+
right: ${buttonSize};
|
|
381
|
+
}
|
|
382
|
+
#thumb {
|
|
383
|
+
box-sizing: border-box;
|
|
384
|
+
position: absolute;
|
|
385
|
+
width: 100%;
|
|
386
|
+
height: 100%;
|
|
387
|
+
background-color: var(--plain-scrollbar-thumb-background-color, #f0f0f0);
|
|
388
|
+
border-style: solid;
|
|
389
|
+
border-width: var(--plain-scrollbar-thumb-border-width, 1px);
|
|
390
|
+
border-color: var(--plain-scrollbar-thumb-border-color, #b8b8b8);
|
|
391
|
+
border-radius: var(--plain-scrollbar-thumb-border-radius, 4px);
|
|
392
|
+
transition: background-color 50ms linear;
|
|
393
|
+
}
|
|
394
|
+
#thumb:hover {
|
|
395
|
+
background-color: var(--plain-scrollbar-thumb-background-color-hover, #e0e0e0);
|
|
396
|
+
}
|
|
397
|
+
#thumb.active {
|
|
398
|
+
background-color: var(--plain-scrollbar-thumb-background-color-active, #c0c0c0);
|
|
399
|
+
}
|
|
400
|
+
#button1,
|
|
401
|
+
#button2 {
|
|
402
|
+
box-sizing: border-box;
|
|
403
|
+
position: absolute;
|
|
404
|
+
display: block;
|
|
405
|
+
fill: var(--plain-scrollbar-button-color, #606060);
|
|
406
|
+
}
|
|
407
|
+
#root.vertical #button1 {
|
|
408
|
+
top: 0;
|
|
409
|
+
width: 100%;
|
|
410
|
+
height: ${buttonSize};
|
|
411
|
+
}
|
|
412
|
+
#root.vertical #button2 {
|
|
413
|
+
bottom: 0;
|
|
414
|
+
width: 100%;
|
|
415
|
+
height: ${buttonSize};
|
|
416
|
+
}
|
|
417
|
+
#root.horizontal #button1 {
|
|
418
|
+
left: 0;
|
|
419
|
+
height: 100%;
|
|
420
|
+
width: ${buttonSize};
|
|
421
|
+
}
|
|
422
|
+
#root.horizontal #button2 {
|
|
423
|
+
right: 0;
|
|
424
|
+
height: 100%;
|
|
425
|
+
width: ${buttonSize};
|
|
426
|
+
}
|
|
427
|
+
#upArrow,
|
|
428
|
+
#downArrow,
|
|
429
|
+
#leftArrow,
|
|
430
|
+
#rightArrow {
|
|
431
|
+
display: none;
|
|
432
|
+
width: 100%;
|
|
433
|
+
height: 100%;
|
|
434
|
+
}
|
|
435
|
+
#root.vertical #upArrow,
|
|
436
|
+
#root.vertical #downArrow {
|
|
437
|
+
display: block;
|
|
438
|
+
}
|
|
439
|
+
#root.horizontal #leftArrow,
|
|
440
|
+
#root.horizontal #rightArrow {
|
|
441
|
+
display: block;
|
|
442
|
+
}
|
|
443
|
+
#button1:hover,
|
|
444
|
+
#button2:hover {
|
|
445
|
+
background-color: var(--plain-scrollbar-button-color-hover, #e0e0e0);
|
|
446
|
+
}
|
|
447
|
+
#button1.active,
|
|
448
|
+
#button2.active {
|
|
449
|
+
background-color: var(--plain-scrollbar-button-color-active, #c0c0c0);
|
|
450
|
+
}
|
|
445
451
|
`;
|
|
446
|
-
const scrollbarHtmlTemplate = `
|
|
447
|
-
<style>${scrollbarStyle}</style>
|
|
448
|
-
<div id="root" part="root">
|
|
449
|
-
<div id="button1" part="button button1">
|
|
450
|
-
<svg id="upArrow" part="arrow upArrow" viewBox="-100 -100 200 200">${buttonPath}</svg>
|
|
451
|
-
<svg id="leftArrow" part="arrow leftArrow" viewBox="-100 -100 200 200"><g transform="rotate(-90)">${buttonPath}</g></svg>
|
|
452
|
-
</div>
|
|
453
|
-
<div id="trough" part="trough">
|
|
454
|
-
<div id="thumb" part="thumb"></div>
|
|
455
|
-
</div>
|
|
456
|
-
<div id="button2" part="button button2">
|
|
457
|
-
<svg id="downArrow" part="arrow downArrow" viewBox="-100 -100 200 200"><g transform="rotate(180)">${buttonPath}</g></svg>
|
|
458
|
-
<svg id="rightArrow" part="arrow rightArrow" viewBox="-100 -100 200 200"><g transform="rotate(90)">${buttonPath}</g></svg>
|
|
459
|
-
</div>
|
|
460
|
-
</div>
|
|
452
|
+
const scrollbarHtmlTemplate = `
|
|
453
|
+
<style>${scrollbarStyle}</style>
|
|
454
|
+
<div id="root" part="root">
|
|
455
|
+
<div id="button1" part="button button1">
|
|
456
|
+
<svg id="upArrow" part="arrow upArrow" viewBox="-100 -100 200 200">${buttonPath}</svg>
|
|
457
|
+
<svg id="leftArrow" part="arrow leftArrow" viewBox="-100 -100 200 200"><g transform="rotate(-90)">${buttonPath}</g></svg>
|
|
458
|
+
</div>
|
|
459
|
+
<div id="trough" part="trough">
|
|
460
|
+
<div id="thumb" part="thumb"></div>
|
|
461
|
+
</div>
|
|
462
|
+
<div id="button2" part="button button2">
|
|
463
|
+
<svg id="downArrow" part="arrow downArrow" viewBox="-100 -100 200 200"><g transform="rotate(180)">${buttonPath}</g></svg>
|
|
464
|
+
<svg id="rightArrow" part="arrow rightArrow" viewBox="-100 -100 200 200"><g transform="rotate(90)">${buttonPath}</g></svg>
|
|
465
|
+
</div>
|
|
466
|
+
</div>
|
|
461
467
|
`;
|
|
462
468
|
//------------------------------------------------------------------------------
|
|
463
469
|
function formatOrientation(b) {
|
|
@@ -9,10 +9,12 @@ import { IPoint } from "../../../interfaces/IPoint";
|
|
|
9
9
|
import { OverlayLayerView } from "./overlayLayerView";
|
|
10
10
|
import { IRect } from "../../../interfaces/IRect.js";
|
|
11
11
|
import { TypedEvent } from "@node-projects/base-custom-webcomponent";
|
|
12
|
+
import { ISize } from "../../../interfaces/ISize.js";
|
|
12
13
|
export interface IDesignerCanvas extends IPlacementView, IUiCommandHandler {
|
|
13
14
|
readonly serviceContainer: ServiceContainer;
|
|
14
15
|
readonly instanceServiceContainer: InstanceServiceContainer;
|
|
15
16
|
readonly containerBoundingRect: DOMRect;
|
|
17
|
+
readonly outerRect: DOMRect;
|
|
16
18
|
readonly rootDesignItem: IDesignItem;
|
|
17
19
|
readonly overlayLayer: OverlayLayerView;
|
|
18
20
|
readonly extensionManager: IExtensionManager;
|
|
@@ -28,9 +30,12 @@ export interface IDesignerCanvas extends IPlacementView, IUiCommandHandler {
|
|
|
28
30
|
eatEvents: Element;
|
|
29
31
|
initialize(serviceContainer: ServiceContainer): any;
|
|
30
32
|
getNormalizedEventCoordinates(event: MouseEvent): IPoint;
|
|
33
|
+
getViewportCoordinates(event: MouseEvent): IPoint;
|
|
31
34
|
getNormalizedElementCoordinates(element: Element): IRect;
|
|
35
|
+
getDesignSurfaceDimensions(): ISize;
|
|
32
36
|
getNormalizedOffsetInElement(event: MouseEvent, element: Element): IPoint;
|
|
33
37
|
getElementAtPoint(point: IPoint, ignoreElementCallback?: (element: HTMLElement) => boolean): any;
|
|
34
38
|
elementFromPoint(x: number, y: number): Element;
|
|
35
39
|
getItemsBelowMouse(event: MouseEvent): Element[];
|
|
40
|
+
zoomTowardsPointer(point: IPoint, scalechange: number): void;
|
|
36
41
|
}
|
|
@@ -13,6 +13,7 @@ import { IPoint } from "../../../interfaces/IPoint";
|
|
|
13
13
|
import { OverlayLayer } from "./extensions/OverlayLayer";
|
|
14
14
|
import { OverlayLayerView } from './overlayLayerView';
|
|
15
15
|
import { IRect } from "../../../interfaces/IRect.js";
|
|
16
|
+
import { ISize } from "../../../interfaces/ISize.js";
|
|
16
17
|
export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend implements IDesignerCanvas, IPlacementView, IUiCommandHandler {
|
|
17
18
|
serviceContainer: ServiceContainer;
|
|
18
19
|
instanceServiceContainer: InstanceServiceContainer;
|
|
@@ -30,12 +31,16 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
|
|
|
30
31
|
private _zoomFactor;
|
|
31
32
|
private _scaleFactor;
|
|
32
33
|
private _canvasOffset;
|
|
34
|
+
private _lastPointerDownHandler;
|
|
33
35
|
get zoomFactor(): number;
|
|
34
36
|
set zoomFactor(value: number);
|
|
35
37
|
get scaleFactor(): number;
|
|
36
38
|
get canvasOffset(): IPoint;
|
|
37
39
|
set canvasOffset(value: IPoint);
|
|
40
|
+
get canvasOffsetUnzoomed(): IPoint;
|
|
41
|
+
set canvasOffsetUnzoomed(value: IPoint);
|
|
38
42
|
onContentChanged: TypedEvent<void>;
|
|
43
|
+
onZoomFactorChanged: TypedEvent<number>;
|
|
39
44
|
private _canvas;
|
|
40
45
|
private _canvasContainer;
|
|
41
46
|
private _outercanvas2;
|
|
@@ -55,6 +60,7 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
|
|
|
55
60
|
set designerWidth(value: string);
|
|
56
61
|
get designerHeight(): string;
|
|
57
62
|
set designerHeight(value: string);
|
|
63
|
+
getDesignSurfaceDimensions(): ISize;
|
|
58
64
|
get designerOffsetWidth(): number;
|
|
59
65
|
get designerOffsetHeight(): number;
|
|
60
66
|
set additionalStyle(value: CSSStyleSheet);
|
|
@@ -67,7 +73,7 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
|
|
|
67
73
|
initialize(serviceContainer: ServiceContainer): void;
|
|
68
74
|
elementFromPoint(x: number, y: number): Element;
|
|
69
75
|
connectedCallback(): void;
|
|
70
|
-
|
|
76
|
+
private _zoomFactorChanged;
|
|
71
77
|
_updateTransform(): void;
|
|
72
78
|
setDesignItems(designItems: IDesignItem[]): void;
|
|
73
79
|
addDesignItems(designItems: IDesignItem[]): void;
|
|
@@ -81,6 +87,7 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
|
|
|
81
87
|
private onKeyUp;
|
|
82
88
|
private onKeyDown;
|
|
83
89
|
getNormalizedEventCoordinates(event: MouseEvent): IPoint;
|
|
90
|
+
getViewportCoordinates(event: MouseEvent): IPoint;
|
|
84
91
|
getNormalizedElementCoordinates(element: Element): IRect;
|
|
85
92
|
getNormalizedOffsetInElement(event: MouseEvent, element: Element): IPoint;
|
|
86
93
|
getElementAtPoint(point: IPoint, ignoreElementCallback?: (element: HTMLElement) => boolean): HTMLElement;
|
|
@@ -90,4 +97,6 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
|
|
|
90
97
|
addOverlay(element: SVGGraphicsElement, overlayLayer?: OverlayLayer): void;
|
|
91
98
|
removeOverlay(element: SVGGraphicsElement): void;
|
|
92
99
|
getItemsBelowMouse(event: MouseEvent): Element[];
|
|
100
|
+
zoomOntoRectangle(startpoint: IPoint, endPoint: IPoint, scalechange: number): void;
|
|
101
|
+
zoomTowardsPointer(point: IPoint, newZoom: number): void;
|
|
93
102
|
}
|
|
@@ -39,12 +39,13 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
39
39
|
_zoomFactor = 1; //if scale or zoom css property is used this needs to be the value
|
|
40
40
|
_scaleFactor = 1; //if scale css property is used this need to be the scale value
|
|
41
41
|
_canvasOffset = { x: 0, y: 0 };
|
|
42
|
+
_lastPointerDownHandler;
|
|
42
43
|
get zoomFactor() {
|
|
43
44
|
return this._zoomFactor;
|
|
44
45
|
}
|
|
45
46
|
set zoomFactor(value) {
|
|
46
47
|
this._zoomFactor = value;
|
|
47
|
-
this.
|
|
48
|
+
this._zoomFactorChanged();
|
|
48
49
|
}
|
|
49
50
|
get scaleFactor() {
|
|
50
51
|
return this._scaleFactor;
|
|
@@ -54,9 +55,16 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
54
55
|
}
|
|
55
56
|
set canvasOffset(value) {
|
|
56
57
|
this._canvasOffset = value;
|
|
57
|
-
this.
|
|
58
|
+
this._zoomFactorChanged();
|
|
59
|
+
}
|
|
60
|
+
get canvasOffsetUnzoomed() {
|
|
61
|
+
return { x: this._canvasOffset.x * this.zoomFactor, y: this._canvasOffset.y * this.zoomFactor };
|
|
62
|
+
}
|
|
63
|
+
set canvasOffsetUnzoomed(value) {
|
|
64
|
+
this.canvasOffset = { x: value.x / this.zoomFactor, y: value.y / this.zoomFactor };
|
|
58
65
|
}
|
|
59
66
|
onContentChanged = new TypedEvent();
|
|
67
|
+
onZoomFactorChanged = new TypedEvent();
|
|
60
68
|
// Private Variables
|
|
61
69
|
_canvas;
|
|
62
70
|
_canvasContainer;
|
|
@@ -135,10 +143,9 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
135
143
|
static template = html `
|
|
136
144
|
<div style="display: flex;flex-direction: column;width: 100%;height: 100%;">
|
|
137
145
|
<div style="width: 100%;height: 100%;">
|
|
138
|
-
<div id="node-projects-designer-canvas-outercanvas2"
|
|
139
|
-
style="width:100%;height:100%;position:relative;">
|
|
146
|
+
<div id="node-projects-designer-canvas-outercanvas2" style="width:100%;height:100%;position:relative;">
|
|
140
147
|
<div id="node-projects-designer-canvas-canvasContainer"
|
|
141
|
-
style="width: 100%;height: 100%;
|
|
148
|
+
style="width: 100%;height: 100%;position: absolute;top: 0;left: 0;user-select: none;">
|
|
142
149
|
<div id="node-projects-designer-canvas-canvas" part="canvas"></div>
|
|
143
150
|
</div>
|
|
144
151
|
</div>
|
|
@@ -168,14 +175,23 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
168
175
|
}
|
|
169
176
|
set designerWidth(value) {
|
|
170
177
|
this._canvasContainer.style.width = value;
|
|
171
|
-
this.
|
|
178
|
+
this._zoomFactorChanged();
|
|
172
179
|
}
|
|
173
180
|
get designerHeight() {
|
|
174
181
|
return this._canvasContainer.style.height;
|
|
175
182
|
}
|
|
176
183
|
set designerHeight(value) {
|
|
177
184
|
this._canvasContainer.style.height = value;
|
|
178
|
-
this.
|
|
185
|
+
this._zoomFactorChanged();
|
|
186
|
+
}
|
|
187
|
+
getDesignSurfaceDimensions() {
|
|
188
|
+
let ret = { width: null, height: null };
|
|
189
|
+
const cs = getComputedStyle(this._canvasContainer);
|
|
190
|
+
if (this._canvasContainer.style.width)
|
|
191
|
+
ret.width = parseFloat(cs.width);
|
|
192
|
+
if (this._canvasContainer.style.height)
|
|
193
|
+
ret.height = parseFloat(cs.height);
|
|
194
|
+
return ret;
|
|
179
195
|
}
|
|
180
196
|
get designerOffsetWidth() {
|
|
181
197
|
return this._canvasContainer.offsetWidth;
|
|
@@ -371,7 +387,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
371
387
|
this.clickOverlay.addEventListener(EventNames.DblClick, this._onDblClickBound, true);
|
|
372
388
|
}
|
|
373
389
|
}
|
|
374
|
-
|
|
390
|
+
_zoomFactorChanged() {
|
|
375
391
|
//a@ts-ignore
|
|
376
392
|
//this._canvasContainer.style.zoom = <any>this._zoomFactor;
|
|
377
393
|
//this._canvasContainer.style.transform = 'scale(' + this._zoomFactor+') translate(' + this._translate.x + ', '+this._translate.y+')';
|
|
@@ -379,10 +395,11 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
379
395
|
this._canvasContainer.style.bottom = this._outercanvas2.offsetHeight >= this._canvasContainer.offsetHeight ? '0' : '';
|
|
380
396
|
this._canvasContainer.style.right = this._outercanvas2.offsetWidth >= this._canvasContainer.offsetWidth ? '0' : '';
|
|
381
397
|
this._updateTransform();
|
|
398
|
+
this.onZoomFactorChanged.emit(this._zoomFactor);
|
|
382
399
|
}
|
|
383
400
|
_updateTransform() {
|
|
384
401
|
this._scaleFactor = this._zoomFactor;
|
|
385
|
-
this._canvasContainer.style.transform = 'scale(' + this._zoomFactor + ') translate(' + this._canvasOffset.x + 'px, ' + this._canvasOffset.y + 'px)';
|
|
402
|
+
this._canvasContainer.style.transform = 'scale(' + this._zoomFactor + ') translate(' + (isNaN(this._canvasOffset.x) ? '0' : this._canvasOffset.x) + 'px, ' + (isNaN(this._canvasOffset.y) ? '0' : this._canvasOffset.y) + 'px)';
|
|
386
403
|
this._canvasContainer.style.transformOrigin = '0 0';
|
|
387
404
|
this.snapLines.clearSnaplines();
|
|
388
405
|
}
|
|
@@ -591,12 +608,18 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
591
608
|
}
|
|
592
609
|
getNormalizedEventCoordinates(event) {
|
|
593
610
|
const offsetOfOuterX = (event.clientX - this.outerRect.x) / this.zoomFactor;
|
|
594
|
-
const offsetOfCanvasX = this.containerBoundingRect.x - this.outerRect.x
|
|
611
|
+
const offsetOfCanvasX = this.containerBoundingRect.x - this.outerRect.x;
|
|
595
612
|
const offsetOfOuterY = (event.clientY - this.outerRect.y) / this.zoomFactor;
|
|
596
|
-
const offsetOfCanvasY = this.containerBoundingRect.y - this.outerRect.y
|
|
613
|
+
const offsetOfCanvasY = this.containerBoundingRect.y - this.outerRect.y;
|
|
614
|
+
return {
|
|
615
|
+
x: offsetOfOuterX - offsetOfCanvasX / this.zoomFactor,
|
|
616
|
+
y: offsetOfOuterY - offsetOfCanvasY / this.zoomFactor
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
getViewportCoordinates(event) {
|
|
597
620
|
return {
|
|
598
|
-
x:
|
|
599
|
-
y:
|
|
621
|
+
x: (event.clientX - this.outerRect.x),
|
|
622
|
+
y: (event.clientY - this.outerRect.y)
|
|
600
623
|
};
|
|
601
624
|
}
|
|
602
625
|
getNormalizedElementCoordinates(element) {
|
|
@@ -675,9 +698,20 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
675
698
|
if (!DesignerCanvas.hasOrIsParent(currentElement, this._canvas))
|
|
676
699
|
return;
|
|
677
700
|
}*/
|
|
701
|
+
if (this._lastPointerDownHandler) {
|
|
702
|
+
try {
|
|
703
|
+
this._lastPointerDownHandler(event);
|
|
704
|
+
}
|
|
705
|
+
catch { }
|
|
706
|
+
if (event.type == EventNames.PointerUp)
|
|
707
|
+
this._lastPointerDownHandler = null;
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
678
710
|
if (currentElement instanceof SVGGraphicsElement && currentElement?.ownerSVGElement?.parentNode?.host == this.overlayLayer) {
|
|
679
711
|
this.clickOverlay.style.cursor = getComputedStyle(currentElement).cursor;
|
|
680
|
-
|
|
712
|
+
if (event.type == EventNames.PointerDown) {
|
|
713
|
+
this._lastPointerDownHandler = (evt) => currentElement.dispatchEvent(new evt.constructor(evt.type, evt));
|
|
714
|
+
}
|
|
681
715
|
currentElement.dispatchEvent(new event.constructor(event.type, event));
|
|
682
716
|
return;
|
|
683
717
|
}
|
|
@@ -701,6 +735,10 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
701
735
|
let tool = this.serviceContainer.globalContext.tool ?? this.serviceContainer.designerTools.get(NamedTools.Pointer);
|
|
702
736
|
this._canvas.style.cursor = tool.cursor;
|
|
703
737
|
tool.pointerEventHandler(this, event, currentElement);
|
|
738
|
+
if (event.type == EventNames.PointerDown) {
|
|
739
|
+
this._lastPointerDownHandler = (evt) => tool.pointerEventHandler(this, evt, currentElement);
|
|
740
|
+
}
|
|
741
|
+
tool.pointerEventHandler(this, event, currentElement);
|
|
704
742
|
}
|
|
705
743
|
_fillCalculationrects() {
|
|
706
744
|
this.containerBoundingRect = this._canvasContainer.getBoundingClientRect();
|
|
@@ -746,5 +784,16 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
746
784
|
}
|
|
747
785
|
return lstEl;
|
|
748
786
|
}
|
|
787
|
+
zoomOntoRectangle(startpoint, endPoint, scalechange) {
|
|
788
|
+
}
|
|
789
|
+
zoomTowardsPointer(point, newZoom) {
|
|
790
|
+
const scaleChange = newZoom / this.zoomFactor;
|
|
791
|
+
const newCanvasOffset = {
|
|
792
|
+
x: -(point.x * (scaleChange - 1) + scaleChange * -this.canvasOffsetUnzoomed.x),
|
|
793
|
+
y: -(point.y * (scaleChange - 1) + scaleChange * -this.canvasOffsetUnzoomed.y)
|
|
794
|
+
};
|
|
795
|
+
this.zoomFactor = newZoom;
|
|
796
|
+
this.canvasOffsetUnzoomed = newCanvasOffset;
|
|
797
|
+
}
|
|
749
798
|
}
|
|
750
799
|
customElements.define('node-projects-designer-canvas', DesignerCanvas);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ServiceContainer } from '../../services/ServiceContainer';
|
|
2
|
+
import { InstanceServiceContainer } from '../../services/InstanceServiceContainer';
|
|
3
|
+
import { IDesignItem } from '../../item/IDesignItem';
|
|
4
|
+
import { BaseCustomWebComponentLazyAppend, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
5
|
+
import { IDesignerCanvas } from './IDesignerCanvas';
|
|
6
|
+
import { Snaplines } from './Snaplines';
|
|
7
|
+
import { ContextMenuHelper } from '../../helper/contextMenu/ContextMenuHelper';
|
|
8
|
+
import { IPlacementView } from './IPlacementView';
|
|
9
|
+
import { IUiCommandHandler } from '../../../commandHandling/IUiCommandHandler';
|
|
10
|
+
import { IUiCommand } from '../../../commandHandling/IUiCommand';
|
|
11
|
+
import { IExtensionManager } from "./extensions/IExtensionManger";
|
|
12
|
+
import { IPoint } from "../../../interfaces/IPoint";
|
|
13
|
+
import { OverlayLayer } from "./extensions/OverlayLayer";
|
|
14
|
+
import { OverlayLayerView } from './overlayLayerView';
|
|
15
|
+
import { IRect } from "../../../interfaces/IRect.js";
|
|
16
|
+
export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend implements IDesignerCanvas, IPlacementView, IUiCommandHandler {
|
|
17
|
+
serviceContainer: ServiceContainer;
|
|
18
|
+
instanceServiceContainer: InstanceServiceContainer;
|
|
19
|
+
containerBoundingRect: DOMRect;
|
|
20
|
+
outerRect: DOMRect;
|
|
21
|
+
gridSize: number;
|
|
22
|
+
alignOnGrid: boolean;
|
|
23
|
+
alignOnSnap: boolean;
|
|
24
|
+
snapLines: Snaplines;
|
|
25
|
+
overlayLayer: OverlayLayerView;
|
|
26
|
+
rootDesignItem: IDesignItem;
|
|
27
|
+
eatEvents: Element;
|
|
28
|
+
transformHelperElement: HTMLDivElement;
|
|
29
|
+
private _zoomFactor;
|
|
30
|
+
private _scaleFactor;
|
|
31
|
+
private _canvasOffset;
|
|
32
|
+
get zoomFactor(): number;
|
|
33
|
+
set zoomFactor(value: number);
|
|
34
|
+
get scaleFactor(): number;
|
|
35
|
+
get canvasOffset(): IPoint;
|
|
36
|
+
set canvasOffset(value: IPoint);
|
|
37
|
+
onContentChanged: TypedEvent<void>;
|
|
38
|
+
private _canvas;
|
|
39
|
+
private _canvasContainer;
|
|
40
|
+
private _outercanvas2;
|
|
41
|
+
private _lastHoverDesignItem;
|
|
42
|
+
private _onContextMenuBound;
|
|
43
|
+
private _pointerEventHandlerBound;
|
|
44
|
+
private _firstConnect;
|
|
45
|
+
private _onKeyDownBound;
|
|
46
|
+
private _onKeyUpBound;
|
|
47
|
+
static readonly style: CSSStyleSheet;
|
|
48
|
+
static readonly template: HTMLTemplateElement;
|
|
49
|
+
extensionManager: IExtensionManager;
|
|
50
|
+
private _pointerextensions;
|
|
51
|
+
private _onDblClickBound;
|
|
52
|
+
constructor();
|
|
53
|
+
get designerWidth(): string;
|
|
54
|
+
set designerWidth(value: string);
|
|
55
|
+
get designerHeight(): string;
|
|
56
|
+
set designerHeight(value: string);
|
|
57
|
+
get designerOffsetWidth(): number;
|
|
58
|
+
get designerOffsetHeight(): number;
|
|
59
|
+
set additionalStyle(value: CSSStyleSheet);
|
|
60
|
+
executeCommand(command: IUiCommand): Promise<void>;
|
|
61
|
+
canExecuteCommand(command: IUiCommand): boolean;
|
|
62
|
+
handleSelectAll(): void;
|
|
63
|
+
handleCopyCommand(): Promise<void>;
|
|
64
|
+
handlePasteCommand(): Promise<void>;
|
|
65
|
+
handleDeleteCommand(): void;
|
|
66
|
+
initialize(serviceContainer: ServiceContainer): void;
|
|
67
|
+
elementFromPoint(x: number, y: number): Element;
|
|
68
|
+
connectedCallback(): void;
|
|
69
|
+
zoomFactorChanged(): void;
|
|
70
|
+
_updateTransform(): void;
|
|
71
|
+
setDesignItems(designItems: IDesignItem[]): void;
|
|
72
|
+
addDesignItems(designItems: IDesignItem[]): void;
|
|
73
|
+
private _onDragEnter;
|
|
74
|
+
private _onDragLeave;
|
|
75
|
+
private _onDragOver;
|
|
76
|
+
private _onDrop;
|
|
77
|
+
private _onContextMenu;
|
|
78
|
+
showDesignItemContextMenu(designItem: IDesignItem, event: MouseEvent): ContextMenuHelper;
|
|
79
|
+
private _onDblClick;
|
|
80
|
+
private onKeyUp;
|
|
81
|
+
private onKeyDown;
|
|
82
|
+
getNormalizedEventCoordinates(event: MouseEvent): IPoint;
|
|
83
|
+
getNormalizedElementCoordinates(element: Element): IRect;
|
|
84
|
+
getNormalizedOffsetInElement(event: MouseEvent, element: Element): IPoint;
|
|
85
|
+
getElementAtPoint(point: IPoint, ignoreElementCallback?: (element: HTMLElement) => boolean): HTMLElement;
|
|
86
|
+
_rect: SVGRectElement;
|
|
87
|
+
private _pointerEventHandler;
|
|
88
|
+
private _fillCalculationrects;
|
|
89
|
+
addOverlay(element: SVGGraphicsElement, overlayLayer?: OverlayLayer): void;
|
|
90
|
+
removeOverlay(element: SVGGraphicsElement): void;
|
|
91
|
+
getItemsBelowMouse(event: MouseEvent): Element[];
|
|
92
|
+
}
|