@node-projects/web-component-designer 0.1.82 → 0.1.83
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/helper/CssUnitConverter.js +5 -2
- package/dist/elements/helper/ElementHelper.js +5 -1
- package/dist/elements/helper/TransformHelper.js +15 -11
- package/dist/elements/item/IBinding.d.ts +6 -0
- package/dist/elements/widgets/designerView/designerCanvas.d.ts +2 -1
- package/dist/elements/widgets/designerView/designerCanvas.js +16 -9
- package/dist/elements/widgets/designerView/extensions/ExtensionManager.js +1 -0
- package/dist/elements/widgets/designerView/tools/DrawElementTool.js +14 -13
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ export function convertCssUnitToPixel(cssValue, target, percentTarget) {
|
|
|
22
22
|
'vmax': value => value / 100 * (window.innerHeight > window.innerWidth ? window.innerHeight : window.innerWidth),
|
|
23
23
|
'lh': value => value * parseFloat(getComputedStyle(target).lineHeight),
|
|
24
24
|
'rlh': value => value * parseFloat(getComputedStyle(document.documentElement).lineHeight),
|
|
25
|
-
'%': value => value / 100 * (percentTarget == 'height' ? target
|
|
25
|
+
'%': value => value / 100 * (percentTarget == 'height' ? getOriginalSizeBeforeTransformation(target).height : getOriginalSizeBeforeTransformation(target).width),
|
|
26
26
|
/*TODO: container units
|
|
27
27
|
//find parent with computed style where container-type is inline-size or size (regarding to query type)
|
|
28
28
|
//use this size for calculation
|
|
@@ -82,7 +82,7 @@ export function convertCssUnit(cssValue, target, percentTarget, unit) {
|
|
|
82
82
|
'vmax': value => value * 100 / (window.innerHeight > window.innerWidth ? window.innerHeight : window.innerWidth),
|
|
83
83
|
'lh': value => value / parseFloat(getComputedStyle(target).lineHeight),
|
|
84
84
|
'rlh': value => value / parseFloat(getComputedStyle(document.documentElement).lineHeight),
|
|
85
|
-
'%': value => value * 100 / (percentTarget == 'height' ? target
|
|
85
|
+
'%': value => value * 100 / (percentTarget == 'height' ? getOriginalSizeBeforeTransformation(target).height : getOriginalSizeBeforeTransformation(target).width),
|
|
86
86
|
// Times
|
|
87
87
|
'ms': value => value,
|
|
88
88
|
's': value => value / 1000,
|
|
@@ -99,3 +99,6 @@ export function convertCssUnit(cssValue, target, percentTarget, unit) {
|
|
|
99
99
|
}
|
|
100
100
|
return cssValue;
|
|
101
101
|
}
|
|
102
|
+
function getOriginalSizeBeforeTransformation(element) {
|
|
103
|
+
return { width: element.offsetWidth, height: element.offsetHeight };
|
|
104
|
+
}
|
|
@@ -61,7 +61,11 @@ const windowOffsetsCacheKey = Symbol('windowOffsetsCacheKey');
|
|
|
61
61
|
export function getElementsWindowOffsetWithoutSelfAndParentTransformations(element, zoom, cache = {}) {
|
|
62
62
|
let offsetLeft = 0;
|
|
63
63
|
let offsetTop = 0;
|
|
64
|
-
let ch
|
|
64
|
+
let ch;
|
|
65
|
+
if (cache)
|
|
66
|
+
ch = cache[windowOffsetsCacheKey] ??= new Map();
|
|
67
|
+
else
|
|
68
|
+
ch = new Map();
|
|
65
69
|
let lst = [];
|
|
66
70
|
while (element) {
|
|
67
71
|
let cachedObj = ch.get(element);
|
|
@@ -113,24 +113,28 @@ export function getDesignerCanvasNormalizedTransformedOriginWithoutParentTransfo
|
|
|
113
113
|
const designerCanvasNormalizedTransformedOrigin = new DOMPoint(transformOriginAbsolutRelatedToWindowWithoutAnyTransformation.x - designerCanvas.containerBoundingRect.x, transformOriginAbsolutRelatedToWindowWithoutAnyTransformation.y - designerCanvas.containerBoundingRect.y);
|
|
114
114
|
return designerCanvasNormalizedTransformedOrigin;
|
|
115
115
|
}
|
|
116
|
-
const
|
|
116
|
+
//const elementMatrixCacheKey = Symbol('windowOffsetsCacheKey');
|
|
117
117
|
export function getResultingTransformationBetweenElementAndAllAncestors(element, ancestor, excludeAncestor, cache = {}) {
|
|
118
|
-
let ch
|
|
118
|
+
/*let ch: Map<any, [DOMMatrix]>;
|
|
119
|
+
if (cache)
|
|
120
|
+
ch = cache[elementMatrixCacheKey] ??= new Map<any, [DOMMatrix]>();
|
|
121
|
+
else
|
|
122
|
+
ch = new Map<any, [DOMMatrix]>();*/
|
|
119
123
|
let lst = [];
|
|
120
124
|
let actualElement = element;
|
|
121
125
|
let actualElementMatrix;
|
|
122
126
|
let newElementMatrix;
|
|
123
127
|
let originalElementAndAllParentsMultipliedMatrix;
|
|
124
128
|
while (actualElement != ancestor && actualElement != null) {
|
|
125
|
-
let cachedObj = ch.get(actualElement);
|
|
129
|
+
/*let cachedObj = ch.get(actualElement);
|
|
126
130
|
if (cachedObj) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
131
|
+
if (originalElementAndAllParentsMultipliedMatrix)
|
|
132
|
+
originalElementAndAllParentsMultipliedMatrix = cachedObj[0].multiply(originalElementAndAllParentsMultipliedMatrix);
|
|
133
|
+
else
|
|
134
|
+
originalElementAndAllParentsMultipliedMatrix = cachedObj[0];
|
|
135
|
+
lst.forEach(x => x[0] = x[0].multiply(originalElementAndAllParentsMultipliedMatrix));
|
|
136
|
+
break;
|
|
137
|
+
}*/
|
|
134
138
|
const newElement = getParentElementIncludingSlots(actualElement);
|
|
135
139
|
if (newElement) {
|
|
136
140
|
actualElementMatrix = getElementCombinedTransform(actualElement);
|
|
@@ -145,7 +149,7 @@ export function getResultingTransformationBetweenElementAndAllAncestors(element,
|
|
|
145
149
|
lst.forEach(x => x[0] = x[0].multiply(originalElementAndAllParentsMultipliedMatrix));
|
|
146
150
|
const cacheEntry = [originalElementAndAllParentsMultipliedMatrix];
|
|
147
151
|
lst.push(cacheEntry);
|
|
148
|
-
ch.set(actualElement, cacheEntry);
|
|
152
|
+
//ch.set(actualElement, cacheEntry);
|
|
149
153
|
}
|
|
150
154
|
actualElement = newElement;
|
|
151
155
|
}
|
|
@@ -9,9 +9,15 @@ export interface IBinding {
|
|
|
9
9
|
expression?: string;
|
|
10
10
|
expressionTwoWay?: string;
|
|
11
11
|
bindableObjectNames?: string[];
|
|
12
|
+
bindableObjects?: IBindableObject[];
|
|
12
13
|
converters?: any;
|
|
13
14
|
mode?: BindingMode;
|
|
14
15
|
invert?: boolean;
|
|
15
16
|
changedEvents?: string[];
|
|
16
17
|
nullSafe?: boolean;
|
|
17
18
|
}
|
|
19
|
+
export interface IBindableObject {
|
|
20
|
+
name?: string;
|
|
21
|
+
alias?: string;
|
|
22
|
+
modificator?: string;
|
|
23
|
+
}
|
|
@@ -23,6 +23,7 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
|
|
|
23
23
|
clickOverlay: HTMLDivElement;
|
|
24
24
|
private _activeTool;
|
|
25
25
|
private _gridSize;
|
|
26
|
+
private _moveGroup;
|
|
26
27
|
get gridSize(): number;
|
|
27
28
|
set gridSize(value: number);
|
|
28
29
|
pasteOffset: number;
|
|
@@ -128,7 +129,7 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
|
|
|
128
129
|
private _pointerEventHandler;
|
|
129
130
|
captureActiveTool(tool: ITool): void;
|
|
130
131
|
releaseActiveTool(): void;
|
|
131
|
-
|
|
132
|
+
fillCalculationrects(): void;
|
|
132
133
|
removeOverlay(element: SVGGraphicsElement): void;
|
|
133
134
|
zoomOntoRectangle(startPoint: IPoint, endPoint: IPoint): void;
|
|
134
135
|
zoomPoint(canvasPoint: IPoint, newZoom: number): void;
|
|
@@ -29,6 +29,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
29
29
|
_activeTool;
|
|
30
30
|
// IPlacementView
|
|
31
31
|
_gridSize = 10;
|
|
32
|
+
_moveGroup;
|
|
32
33
|
get gridSize() {
|
|
33
34
|
return this._gridSize;
|
|
34
35
|
}
|
|
@@ -638,7 +639,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
638
639
|
this._canvasContainer.style.bottom = this._outercanvas2.offsetHeight >= this._canvasContainer.offsetHeight ? '0' : '';
|
|
639
640
|
this._canvasContainer.style.right = this._outercanvas2.offsetWidth >= this._canvasContainer.offsetWidth ? '0' : '';
|
|
640
641
|
this._updateTransform();
|
|
641
|
-
this.
|
|
642
|
+
this.fillCalculationrects();
|
|
642
643
|
this.onZoomFactorChanged.emit(this._zoomFactor);
|
|
643
644
|
if (refreshExtensions) {
|
|
644
645
|
this.extensionManager.refreshAllAppliedExtentions();
|
|
@@ -668,7 +669,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
668
669
|
this.instanceServiceContainer.undoService.execute(setItemsAction);
|
|
669
670
|
}
|
|
670
671
|
_internalSetDesignItems(designItems) {
|
|
671
|
-
this.
|
|
672
|
+
this.fillCalculationrects();
|
|
672
673
|
this.overlayLayer.removeAllOverlays();
|
|
673
674
|
DomHelper.removeAllChildnodes(this.overlayLayer);
|
|
674
675
|
for (let i of [...this.rootDesignItem.children()])
|
|
@@ -711,7 +712,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
711
712
|
this.snapLines.clearSnaplines();
|
|
712
713
|
}
|
|
713
714
|
_onDragEnter(event) {
|
|
714
|
-
this.
|
|
715
|
+
this.fillCalculationrects();
|
|
715
716
|
event.preventDefault();
|
|
716
717
|
const hasTransferDataBindingObject = event.dataTransfer.types.indexOf(dragDropFormatNameBindingObject) >= 0;
|
|
717
718
|
if (hasTransferDataBindingObject) {
|
|
@@ -737,7 +738,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
737
738
|
}
|
|
738
739
|
}
|
|
739
740
|
_onDragLeave(event) {
|
|
740
|
-
this.
|
|
741
|
+
this.fillCalculationrects();
|
|
741
742
|
event.preventDefault();
|
|
742
743
|
this._canvas.classList.remove('dragFileActive');
|
|
743
744
|
const dragDropService = this.serviceContainer.dragDropService;
|
|
@@ -755,7 +756,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
755
756
|
let containerService = this.serviceContainer.getLastServiceWhere('containerService', x => x.serviceForContainer(this.rootDesignItem))
|
|
756
757
|
containerService.finishPlace(this, this.rootDesignItem, this._initialPoint, currentPoint, this.instanceServiceContainer.selectionService.selectedElements);
|
|
757
758
|
}*/
|
|
758
|
-
this.
|
|
759
|
+
this.fillCalculationrects();
|
|
759
760
|
if (event.dataTransfer.types.length > 0 && event.dataTransfer.types[0] == 'Files') {
|
|
760
761
|
const ddService = this.serviceContainer.externalDragDropService;
|
|
761
762
|
if (ddService) {
|
|
@@ -793,7 +794,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
793
794
|
this._lastDdElement = null;
|
|
794
795
|
event.preventDefault();
|
|
795
796
|
this._canvas.classList.remove('dragFileActive');
|
|
796
|
-
this.
|
|
797
|
+
this.fillCalculationrects();
|
|
797
798
|
if (event.dataTransfer.files?.length > 0) {
|
|
798
799
|
const ddService = this.serviceContainer.externalDragDropService;
|
|
799
800
|
if (ddService) {
|
|
@@ -813,7 +814,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
813
814
|
else {
|
|
814
815
|
const dragDropService = this.serviceContainer.dragDropService;
|
|
815
816
|
if (dragDropService) {
|
|
816
|
-
this.
|
|
817
|
+
this.fillCalculationrects();
|
|
817
818
|
dragDropService.drop(this, event);
|
|
818
819
|
}
|
|
819
820
|
}
|
|
@@ -863,6 +864,10 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
863
864
|
onKeyUp(event) {
|
|
864
865
|
if (event.composedPath().indexOf(this.eatEvents) >= 0)
|
|
865
866
|
return;
|
|
867
|
+
if (this._moveGroup) {
|
|
868
|
+
this._moveGroup.commit();
|
|
869
|
+
this._moveGroup = null;
|
|
870
|
+
}
|
|
866
871
|
event.preventDefault();
|
|
867
872
|
}
|
|
868
873
|
onKeyDown(event) {
|
|
@@ -902,6 +907,8 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
902
907
|
case 'ArrowLeft':
|
|
903
908
|
case 'ArrowRight':
|
|
904
909
|
{
|
|
910
|
+
if (!this._moveGroup)
|
|
911
|
+
this._moveGroup = this.rootDesignItem.openGroup("move items");
|
|
905
912
|
let offset = { x: 0, y: 0 };
|
|
906
913
|
if (event.key == 'ArrowDown')
|
|
907
914
|
offset.y = -moveOffset;
|
|
@@ -1018,7 +1025,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
1018
1025
|
_pointerEventHandler(event, forceElement = null) {
|
|
1019
1026
|
if (!this.serviceContainer)
|
|
1020
1027
|
return;
|
|
1021
|
-
this.
|
|
1028
|
+
this.fillCalculationrects();
|
|
1022
1029
|
if (this._pointerextensions) {
|
|
1023
1030
|
for (let pe of this._pointerextensions)
|
|
1024
1031
|
pe.refresh(event);
|
|
@@ -1069,7 +1076,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
1069
1076
|
releaseActiveTool() {
|
|
1070
1077
|
this._activeTool = null;
|
|
1071
1078
|
}
|
|
1072
|
-
|
|
1079
|
+
fillCalculationrects() {
|
|
1073
1080
|
this.containerBoundingRect = this._canvasContainer.getBoundingClientRect();
|
|
1074
1081
|
this.outerRect = this._outercanvas2.getBoundingClientRect();
|
|
1075
1082
|
}
|
|
@@ -358,6 +358,7 @@ export class ExtensionManager {
|
|
|
358
358
|
this.designerCanvas.overlayLayer.endBatch();
|
|
359
359
|
}
|
|
360
360
|
refreshAllAppliedExtentions() {
|
|
361
|
+
this.designerCanvas.fillCalculationrects();
|
|
361
362
|
this.refreshAllExtensions([...this.designItemsWithExtentions]);
|
|
362
363
|
}
|
|
363
364
|
//TODO: does not work with permanant, when not applied... maybe we need to do in another way
|
|
@@ -31,33 +31,34 @@ export class DrawElementTool {
|
|
|
31
31
|
}
|
|
32
32
|
keyboardEventHandler(designerCanvas, event, currentElement) { }
|
|
33
33
|
sizeOverlapThreshold = false;
|
|
34
|
-
async _onPointerDown(
|
|
34
|
+
async _onPointerDown(designerCanvas, event) {
|
|
35
|
+
const evPos = designerCanvas.getNormalizedEventCoordinates(event);
|
|
35
36
|
event.preventDefault();
|
|
36
|
-
this._startPosition = { x:
|
|
37
|
-
this._changeGroup =
|
|
38
|
-
this._createdItem = await
|
|
39
|
-
const targetRect = event.target.getBoundingClientRect();
|
|
37
|
+
this._startPosition = { x: evPos.x, y: evPos.y };
|
|
38
|
+
this._changeGroup = designerCanvas.rootDesignItem.openGroup("Insert Item");
|
|
39
|
+
this._createdItem = await designerCanvas.serviceContainer.forSomeServicesTillResult("instanceService", (service) => service.getElement(this._elementDefinition, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer));
|
|
40
40
|
this._createdItem.setStyle('position', 'absolute');
|
|
41
|
-
this._createdItem.setStyle('left',
|
|
42
|
-
this._createdItem.setStyle('top',
|
|
41
|
+
this._createdItem.setStyle('left', evPos.x + 'px');
|
|
42
|
+
this._createdItem.setStyle('top', evPos.y + 'px');
|
|
43
43
|
this._createdItem.setStyle('width', '0');
|
|
44
44
|
this._createdItem.setStyle('height', '0');
|
|
45
45
|
this._createdItem.element.style.overflow = 'hidden';
|
|
46
|
-
|
|
46
|
+
designerCanvas.rootDesignItem.insertChild(this._createdItem);
|
|
47
47
|
//draw via containerService??? how to draw into a grid, a stackpanel???
|
|
48
|
-
|
|
48
|
+
designerCanvas.instanceServiceContainer.selectionService.clearSelectedElements();
|
|
49
49
|
}
|
|
50
50
|
async _onPointerMove(designerCanvas, event) {
|
|
51
|
+
const evPos = designerCanvas.getNormalizedEventCoordinates(event);
|
|
51
52
|
if (this._createdItem) {
|
|
52
53
|
if (!this._rect) {
|
|
53
54
|
this._rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
54
55
|
designerCanvas.overlayLayer.addOverlay(this.constructor.name, this._rect, OverlayLayer.Foreground);
|
|
55
56
|
this._rect.setAttribute('class', 'svg-draw-new-element');
|
|
56
|
-
this._rect.setAttribute('x', (this._startPosition.x
|
|
57
|
-
this._rect.setAttribute('y', (this._startPosition.y
|
|
57
|
+
this._rect.setAttribute('x', (this._startPosition.x));
|
|
58
|
+
this._rect.setAttribute('y', (this._startPosition.y));
|
|
58
59
|
}
|
|
59
|
-
const w =
|
|
60
|
-
const h =
|
|
60
|
+
const w = evPos.x - this._startPosition.x;
|
|
61
|
+
const h = evPos.y - this._startPosition.y;
|
|
61
62
|
if (w >= 0) {
|
|
62
63
|
this._rect.setAttribute('width', w);
|
|
63
64
|
this._createdItem.setStyle('width', w + 'px');
|