@node-projects/web-component-designer 0.0.170 → 0.0.171
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.d.ts +2 -2
- package/dist/elements/helper/CssUnitConverter.js +3 -3
- package/dist/elements/helper/GridHelper.d.ts +2 -0
- package/dist/elements/helper/GridHelper.js +16 -1
- package/dist/elements/item/DesignItem.d.ts +1 -0
- package/dist/elements/item/DesignItem.js +10 -7
- package/dist/elements/services/propertiesService/PropertyGroupsService.d.ts +2 -2
- package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService.d.ts +2 -2
- package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService.js +24 -7
- package/dist/elements/services/propertiesService/services/CssProperties.json +541 -0
- package/dist/elements/services/propertiesService/services/CssPropertiesService.d.ts +4 -4
- package/dist/elements/services/propertiesService/services/CssPropertiesService.js +42 -167
- package/dist/elements/services/propertiesService/services/NativeElementsPropertiesService.js +6 -0
- package/dist/elements/services/stylesheetService/CssToolsStylesheetService.d.ts +17 -0
- package/dist/elements/services/stylesheetService/CssToolsStylesheetService.js +45 -0
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService copy.d.ts +48 -0
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService copy.js +185 -0
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService.d.ts +3 -3
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService.js +32 -17
- package/dist/elements/services/stylesheetService/IStylesheetService.d.ts +4 -4
- package/dist/elements/widgets/designerView/extensions/GridExtension.d.ts +35 -4
- package/dist/elements/widgets/designerView/extensions/GridExtension.js +277 -90
- package/dist/elements/widgets/designerView/extensions/GridExtensionProvider.js +3 -1
- package/dist/elements/widgets/designerView/extensions/TransformOriginExtension.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TypedEvent } from "@node-projects/base-custom-webcomponent";
|
|
2
2
|
import { IDesignItem } from "../../item/IDesignItem.js";
|
|
3
|
-
import { IProperty } from "../propertiesService/IProperty.js";
|
|
4
3
|
export interface IStyleRule {
|
|
5
4
|
selector: string;
|
|
6
5
|
declarations: IStyleDeclaration[];
|
|
@@ -17,12 +16,13 @@ export interface IStylesheet {
|
|
|
17
16
|
name: string;
|
|
18
17
|
}
|
|
19
18
|
export interface IStylesheetService {
|
|
20
|
-
setStylesheets(stylesheets: IStylesheet[]):
|
|
19
|
+
setStylesheets(stylesheets: IStylesheet[]): void;
|
|
21
20
|
getStylesheets(): IStylesheet[];
|
|
22
21
|
getAppliedRules(designItem: IDesignItem): IStyleRule[];
|
|
23
|
-
getDeclarations(designItem: IDesignItem,
|
|
24
|
-
updateDeclarationWithProperty(designItem: IDesignItem, property: IProperty, value: string, important: boolean): boolean;
|
|
22
|
+
getDeclarations(designItem: IDesignItem, styleName: string): IStyleDeclaration[];
|
|
25
23
|
updateDeclarationWithDeclaration(declaration: IStyleDeclaration, value: string, important: boolean): boolean;
|
|
24
|
+
insertDeclarationIntoRule(rule: IStyleRule, declaration: IStyleDeclaration, important: boolean): boolean;
|
|
25
|
+
removeDeclarationFromRule(rule: IStyleRule, declaration: IStyleDeclaration): boolean;
|
|
26
26
|
stylesheetChanged: TypedEvent<{
|
|
27
27
|
stylesheet: IStylesheet;
|
|
28
28
|
}>;
|
|
@@ -5,16 +5,47 @@ import { IExtensionManager } from './IExtensionManger.js';
|
|
|
5
5
|
export declare class GridExtension extends AbstractExtension {
|
|
6
6
|
private _initialPoint;
|
|
7
7
|
private _initialSizes;
|
|
8
|
-
private
|
|
8
|
+
private _cells;
|
|
9
9
|
private _gaps;
|
|
10
|
+
private _headers;
|
|
11
|
+
private _headerTexts;
|
|
12
|
+
private _plusCircles;
|
|
10
13
|
private _resizeCircles;
|
|
11
14
|
private minPixelSize;
|
|
15
|
+
private gridInformation;
|
|
16
|
+
private defaultHeaderSize;
|
|
17
|
+
private defaultPlusSize;
|
|
18
|
+
private defaultDistanceToBox;
|
|
19
|
+
private defaultDistanceBetweenHeaders;
|
|
20
|
+
private defaultSizeOfNewRowOrColumn;
|
|
12
21
|
constructor(extensionManager: IExtensionManager, designerView: IDesignerCanvas, extendedItem: IDesignItem);
|
|
13
22
|
extend(): void;
|
|
14
23
|
refresh(): void;
|
|
15
24
|
dispose(): void;
|
|
16
|
-
|
|
25
|
+
_initSVGArrays(): void;
|
|
26
|
+
_drawResizeCircle(gap: any, oldCircle?: SVGCircleElement): SVGCircleElement;
|
|
27
|
+
_drawHeader(cell: any, oldHeader: any, index: any, alignment: "vertical" | "horizontal"): SVGRectElement;
|
|
28
|
+
_drawHeaderText(cell: any, oldHeaderText: any, alignment: "vertical" | "horizontal"): SVGTextElement;
|
|
29
|
+
_drawPlusCircle(x: any, y: any, oldPlusElement: {
|
|
30
|
+
circle: SVGCircleElement;
|
|
31
|
+
verticalLine: SVGLineElement;
|
|
32
|
+
horizontalLine: SVGLineElement;
|
|
33
|
+
}, index: any, alignment: "vertical" | "horizontal", final?: boolean): {
|
|
34
|
+
circle: any;
|
|
35
|
+
verticalLine: any;
|
|
36
|
+
horizontalLine: any;
|
|
37
|
+
};
|
|
38
|
+
_getHeaderText(size: number, unit: string, percentTarget: "width" | "height"): string;
|
|
39
|
+
_getInitialSizes(): {
|
|
40
|
+
x: any[];
|
|
41
|
+
xUnit: any[];
|
|
42
|
+
y: any[];
|
|
43
|
+
yUnit: any[];
|
|
44
|
+
};
|
|
17
45
|
_pointerActionTypeResize(event: PointerEvent, circle: SVGCircleElement, gapColumn: any, gapRow: any): void;
|
|
18
|
-
_calculateNewSize(iSizes:
|
|
19
|
-
|
|
46
|
+
_calculateNewSize(iSizes: number[], iUnits: string[], diff: any, gapIndex: any, percentTarget: 'width' | 'height', pointerUp?: boolean): string;
|
|
47
|
+
_editGrid(pos: number, alignment: "vertical" | "horizontal", task: "add" | "del"): void;
|
|
48
|
+
_calculateNewElementSize(elementTarget: "width" | "height"): string;
|
|
49
|
+
_toggleDisplayPlusCircles(index: any, alignment: "vertical" | "horizontal", double?: boolean): void;
|
|
50
|
+
_convertCssUnit(cssValue: string | number, target: HTMLElement, percentTarget: 'width' | 'height', unit: string): string | number;
|
|
20
51
|
}
|
|
@@ -6,43 +6,90 @@ import { OverlayLayer } from "./OverlayLayer.js";
|
|
|
6
6
|
export class GridExtension extends AbstractExtension {
|
|
7
7
|
_initialPoint;
|
|
8
8
|
_initialSizes;
|
|
9
|
-
|
|
9
|
+
_cells;
|
|
10
10
|
_gaps;
|
|
11
|
+
_headers;
|
|
12
|
+
_headerTexts;
|
|
13
|
+
_plusCircles;
|
|
11
14
|
_resizeCircles;
|
|
12
15
|
minPixelSize = 10;
|
|
16
|
+
gridInformation;
|
|
17
|
+
defaultHeaderSize = 20;
|
|
18
|
+
defaultPlusSize = this.defaultHeaderSize * 2 / 3;
|
|
19
|
+
defaultDistanceToBox = 5;
|
|
20
|
+
defaultDistanceBetweenHeaders = 10;
|
|
21
|
+
defaultSizeOfNewRowOrColumn = "50px";
|
|
13
22
|
constructor(extensionManager, designerView, extendedItem) {
|
|
14
23
|
super(extensionManager, designerView, extendedItem);
|
|
15
24
|
}
|
|
16
25
|
extend() {
|
|
17
|
-
|
|
18
|
-
this._rects = new Array(gridInformation.cells.length);
|
|
19
|
-
gridInformation.cells.forEach((cellRow, i) => {
|
|
20
|
-
this._rects[i] = new Array(cellRow.length);
|
|
21
|
-
});
|
|
22
|
-
this._gaps = new Array(gridInformation.gaps.length);
|
|
23
|
-
this._resizeCircles = new Array(gridInformation.gaps.length);
|
|
26
|
+
this._initSVGArrays();
|
|
24
27
|
this.refresh();
|
|
25
28
|
}
|
|
26
29
|
refresh() {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this.
|
|
35
|
-
|
|
36
|
-
const text = this._drawText(cell.name, cell.x, cell.y, 'svg-grid-area', null, OverlayLayer.Background);
|
|
37
|
-
text.setAttribute("dominant-baseline", "hanging");
|
|
38
|
-
}
|
|
30
|
+
this.gridInformation = CalculateGridInformation(this.extendedItem);
|
|
31
|
+
let cells = this.gridInformation.cells;
|
|
32
|
+
if (cells[0][0] && !isNaN(cells[0][0].height) && !isNaN(cells[0][0].width)) {
|
|
33
|
+
if (this.gridInformation.cells.length != this._cells.length || this.gridInformation.cells[0].length != this._cells[0].length)
|
|
34
|
+
this._initSVGArrays();
|
|
35
|
+
//draw gaps
|
|
36
|
+
this.gridInformation.gaps.forEach((gap, i) => {
|
|
37
|
+
this._gaps[i] = this._drawRect(gap.x, gap.y, gap.width, gap.height, 'svg-grid-gap', this._gaps[i], OverlayLayer.Foregorund);
|
|
38
|
+
this._resizeCircles[i] = this._drawResizeCircle(gap, this._resizeCircles[i]);
|
|
39
39
|
});
|
|
40
|
-
|
|
40
|
+
//draw cells
|
|
41
|
+
cells.forEach((row, i) => {
|
|
42
|
+
row.forEach((cell, j) => {
|
|
43
|
+
this._cells[i][j] = this._drawRect(cell.x, cell.y, cell.width, cell.height, 'svg-grid', this._cells[i][j], OverlayLayer.Background);
|
|
44
|
+
if (cell.name) {
|
|
45
|
+
const text = this._drawText(cell.name, cell.x, cell.y, 'svg-grid-area', null, OverlayLayer.Background);
|
|
46
|
+
text.setAttribute("dominant-baseline", "hanging");
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
//draw headers
|
|
51
|
+
cells.forEach((row, i) => {
|
|
52
|
+
this._headers[0][i] = this._drawHeader(row[0], this._headers[0][i], i, "vertical");
|
|
53
|
+
this._headerTexts[0][i] = this._drawHeaderText(row[0], this._headerTexts[0][i], "vertical");
|
|
54
|
+
});
|
|
55
|
+
cells[0].forEach((column, i) => {
|
|
56
|
+
this._headers[1][i] = this._drawHeader(column, this._headers[1][i], i, "horizontal");
|
|
57
|
+
this._headerTexts[1][i] = this._drawHeaderText(column, this._headerTexts[1][i], "horizontal");
|
|
58
|
+
});
|
|
59
|
+
//draw circles for adding rows/columns
|
|
60
|
+
for (let i = 0; i < this._plusCircles[0].length; i++)
|
|
61
|
+
if (i < this._plusCircles[0].length - 1)
|
|
62
|
+
this._plusCircles[0][i] = this._drawPlusCircle(cells[i][0].x, cells[i][0].y, this._plusCircles[0][i], i, "vertical");
|
|
63
|
+
else
|
|
64
|
+
this._plusCircles[0][i] = this._drawPlusCircle(cells[i - 1][0].x, cells[i - 1][0].y + cells[i - 1][0].height, this._plusCircles[0][i], i, "vertical", true);
|
|
65
|
+
for (let i = 0; i < this._plusCircles[1].length; i++)
|
|
66
|
+
if (i < this._plusCircles[1].length - 1)
|
|
67
|
+
this._plusCircles[1][i] = this._drawPlusCircle(cells[0][i].x, cells[0][i].y, this._plusCircles[1][i], i, "horizontal");
|
|
68
|
+
else
|
|
69
|
+
this._plusCircles[1][i] = this._drawPlusCircle(cells[0][i - 1].x + cells[0][i - 1].width, cells[0][i - 1].y, this._plusCircles[1][i], i, "horizontal", true);
|
|
70
|
+
}
|
|
41
71
|
}
|
|
42
72
|
dispose() {
|
|
43
73
|
this._removeAllOverlays();
|
|
44
74
|
}
|
|
45
|
-
|
|
75
|
+
_initSVGArrays() {
|
|
76
|
+
this._removeAllOverlays();
|
|
77
|
+
this.gridInformation = CalculateGridInformation(this.extendedItem);
|
|
78
|
+
this._cells = new Array(this.gridInformation.cells.length);
|
|
79
|
+
this.gridInformation.cells.forEach((row, i) => this._cells[i] = new Array(row.length));
|
|
80
|
+
this._gaps = new Array(this.gridInformation.gaps.length);
|
|
81
|
+
this._headers = new Array(2);
|
|
82
|
+
this._headers[0] = new Array(this.gridInformation.cells.length + 1); //array for the headers of columns
|
|
83
|
+
this._headers[1] = new Array(this.gridInformation.cells[0].length + 1); //array for the headers of rows
|
|
84
|
+
this._headerTexts = new Array(2);
|
|
85
|
+
this._headerTexts[0] = new Array(this.gridInformation.cells.length + 1);
|
|
86
|
+
this._headerTexts[1] = new Array(this.gridInformation.cells[0].length + 1);
|
|
87
|
+
this._plusCircles = new Array(2);
|
|
88
|
+
this._plusCircles[0] = new Array(this.gridInformation.cells.length + 1);
|
|
89
|
+
this._plusCircles[1] = new Array(this.gridInformation.cells[0].length + 1);
|
|
90
|
+
this._resizeCircles = new Array(this.gridInformation.gaps.length);
|
|
91
|
+
}
|
|
92
|
+
_drawResizeCircle(gap, oldCircle) {
|
|
46
93
|
let resizeCircle = this._drawCircle((gap.x + (gap.width / 2)), (gap.y + (gap.height / 2)), 1.5, 'svg-grid-resizer', oldCircle, OverlayLayer.Foregorund);
|
|
47
94
|
resizeCircle.style.pointerEvents = "all";
|
|
48
95
|
resizeCircle.style.cursor = gap.width < gap.height ? "ew-resize" : "ns-resize";
|
|
@@ -53,107 +100,247 @@ export class GridExtension extends AbstractExtension {
|
|
|
53
100
|
}
|
|
54
101
|
return resizeCircle;
|
|
55
102
|
}
|
|
103
|
+
_drawHeader(cell, oldHeader, index, alignment) {
|
|
104
|
+
let xOffset;
|
|
105
|
+
let yOffset;
|
|
106
|
+
let width;
|
|
107
|
+
let height;
|
|
108
|
+
if (alignment == "vertical") {
|
|
109
|
+
xOffset = -(this.defaultHeaderSize + this.defaultDistanceToBox);
|
|
110
|
+
yOffset = this.defaultDistanceBetweenHeaders / 2;
|
|
111
|
+
width = this.defaultHeaderSize;
|
|
112
|
+
height = cell.height - this.defaultDistanceBetweenHeaders;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
xOffset = this.defaultDistanceBetweenHeaders / 2;
|
|
116
|
+
yOffset = -(this.defaultHeaderSize + this.defaultDistanceToBox);
|
|
117
|
+
width = cell.width - this.defaultDistanceBetweenHeaders;
|
|
118
|
+
height = this.defaultHeaderSize;
|
|
119
|
+
}
|
|
120
|
+
let tmpHeader = this._drawRect(cell.x + xOffset, cell.y + yOffset, width, height, "svg-grid-header", oldHeader, OverlayLayer.Foregorund);
|
|
121
|
+
tmpHeader.style.pointerEvents = "all";
|
|
122
|
+
if (!oldHeader) {
|
|
123
|
+
tmpHeader.addEventListener(EventNames.PointerMove, event => {
|
|
124
|
+
this._toggleDisplayPlusCircles(index, alignment, true);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return tmpHeader;
|
|
128
|
+
}
|
|
129
|
+
_drawHeaderText(cell, oldHeaderText, alignment) {
|
|
130
|
+
let text;
|
|
131
|
+
let xOffset;
|
|
132
|
+
let yOffset;
|
|
133
|
+
if (alignment == "vertical") {
|
|
134
|
+
text = this._getHeaderText(cell.height, cell.initHeightUnit, "height");
|
|
135
|
+
xOffset = -12.5;
|
|
136
|
+
yOffset = cell.height / 2;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
text = this._getHeaderText(cell.width, cell.initWidthUnit, "width");
|
|
140
|
+
xOffset = cell.width / 2;
|
|
141
|
+
yOffset = -12.5;
|
|
142
|
+
}
|
|
143
|
+
let rText = this._drawText(text, cell.x + xOffset, cell.y + yOffset, null, oldHeaderText, OverlayLayer.Background);
|
|
144
|
+
if (alignment == "vertical")
|
|
145
|
+
rText.setAttribute("transform", "rotate(-90, " + (cell.x + xOffset) + ", " + (cell.y + yOffset) + ")");
|
|
146
|
+
return rText;
|
|
147
|
+
}
|
|
148
|
+
_drawPlusCircle(x, y, oldPlusElement, index, alignment, final = false) {
|
|
149
|
+
let plusElement = { circle: null, verticalLine: null, horizontalLine: null };
|
|
150
|
+
let posX;
|
|
151
|
+
let posY;
|
|
152
|
+
let gapOffset = index == 0 || final ? 0 : -(convertCssUnitToPixel(this.extendedItem.getStyle(alignment == "vertical" ? "row-gap" : "column-gap"), this.extendedItem.element, alignment == "vertical" ? "height" : "width") / 2);
|
|
153
|
+
if (alignment == "vertical") {
|
|
154
|
+
posX = x - this.defaultDistanceToBox - this.defaultHeaderSize / 2;
|
|
155
|
+
posY = y + gapOffset;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
posX = x + gapOffset;
|
|
159
|
+
posY = y - this.defaultDistanceToBox - this.defaultHeaderSize / 2;
|
|
160
|
+
}
|
|
161
|
+
plusElement.circle = this._drawCircle(posX, posY, this.defaultHeaderSize / 2, 'svg-grid-resizer', oldPlusElement ? oldPlusElement.circle : null, OverlayLayer.Foregorund);
|
|
162
|
+
plusElement.circle.style.pointerEvents = "all";
|
|
163
|
+
plusElement.circle.style.cursor = "pointer";
|
|
164
|
+
plusElement.circle.style.display = "none";
|
|
165
|
+
if (!oldPlusElement) {
|
|
166
|
+
plusElement.circle.addEventListener(EventNames.PointerMove, event => this._toggleDisplayPlusCircles(index, alignment));
|
|
167
|
+
plusElement.circle.addEventListener(EventNames.PointerDown, event => {
|
|
168
|
+
this._editGrid(index, alignment, "add");
|
|
169
|
+
event.stopPropagation();
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
plusElement.verticalLine = this._drawLine(posX, posY - this.defaultPlusSize / 2, posX, posY + this.defaultPlusSize / 2, "svg-grid-plus-sign", oldPlusElement ? oldPlusElement.verticalLine : null, OverlayLayer.Foregorund);
|
|
173
|
+
plusElement.verticalLine.style.display = "none";
|
|
174
|
+
plusElement.horizontalLine = this._drawLine(posX - this.defaultPlusSize / 2, posY, posX + this.defaultPlusSize / 2, posY, "svg-grid-plus-sign", oldPlusElement ? oldPlusElement.horizontalLine : null, OverlayLayer.Foregorund);
|
|
175
|
+
plusElement.horizontalLine.style.display = "none";
|
|
176
|
+
return plusElement;
|
|
177
|
+
}
|
|
178
|
+
_getHeaderText(size, unit, percentTarget) {
|
|
179
|
+
return Math.round(parseFloat(this._convertCssUnit(size, this.extendedItem.element, percentTarget, unit)) * 10) / 10 + unit;
|
|
180
|
+
}
|
|
181
|
+
_getInitialSizes() {
|
|
182
|
+
let rX = []; //in pixels
|
|
183
|
+
let rXUnit = []; //original unit
|
|
184
|
+
let rY = []; //in pixels
|
|
185
|
+
let rYUnit = []; //original unit
|
|
186
|
+
this.gridInformation.cells[0].forEach(row => {
|
|
187
|
+
rX.push(row.width);
|
|
188
|
+
rXUnit.push(row.initWidthUnit);
|
|
189
|
+
});
|
|
190
|
+
this.gridInformation.cells.forEach(column => {
|
|
191
|
+
rY.push(column[0].height);
|
|
192
|
+
rYUnit.push(column[0].initHeightUnit);
|
|
193
|
+
});
|
|
194
|
+
return { x: rX, xUnit: rXUnit, y: rY, yUnit: rYUnit };
|
|
195
|
+
}
|
|
56
196
|
_pointerActionTypeResize(event, circle, gapColumn, gapRow) {
|
|
57
197
|
event.stopPropagation();
|
|
58
198
|
switch (event.type) {
|
|
59
199
|
case EventNames.PointerDown:
|
|
60
200
|
circle.setPointerCapture(event.pointerId);
|
|
61
201
|
this._initialPoint = { x: event.clientX, y: event.clientY };
|
|
62
|
-
this._initialSizes =
|
|
202
|
+
this._initialSizes = this._getInitialSizes();
|
|
63
203
|
break;
|
|
64
204
|
case EventNames.PointerMove:
|
|
65
205
|
if (this._initialPoint) {
|
|
66
206
|
let elementStyle = this.extendedItem.element.style;
|
|
67
207
|
this.extendedItem.element.getBoundingClientRect;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
case "ns-resize":
|
|
73
|
-
elementStyle.gridTemplateRows = this._calculateNewSize(this._initialSizes.y, (event.clientY - this._initialPoint.y) / this.designerCanvas.zoomFactor, gapRow, "heigth");
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
208
|
+
if (circle.style.cursor == "ew-resize")
|
|
209
|
+
elementStyle.gridTemplateColumns = this._calculateNewSize(this._initialSizes.x, this._initialSizes.xUnit, (event.clientX - this._initialPoint.x) / this.designerCanvas.zoomFactor, gapColumn, "width");
|
|
210
|
+
else if (circle.style.cursor == "ns-resize")
|
|
211
|
+
elementStyle.gridTemplateRows = this._calculateNewSize(this._initialSizes.y, this._initialSizes.yUnit, (event.clientY - this._initialPoint.y) / this.designerCanvas.zoomFactor, gapRow, "height");
|
|
76
212
|
this.refresh();
|
|
77
213
|
}
|
|
78
214
|
break;
|
|
79
215
|
case EventNames.PointerUp:
|
|
80
216
|
circle.releasePointerCapture(event.pointerId);
|
|
217
|
+
if (circle.style.cursor == "ew-resize")
|
|
218
|
+
this.extendedItem.setStyle("grid-template-columns", this._calculateNewSize(this._initialSizes.x, this._initialSizes.xUnit, (event.clientX - this._initialPoint.x) / this.designerCanvas.zoomFactor, gapColumn, "width", true));
|
|
219
|
+
else if (circle.style.cursor == "ns-resize")
|
|
220
|
+
this.extendedItem.setStyle("grid-template-rows", this._calculateNewSize(this._initialSizes.y, this._initialSizes.yUnit, (event.clientY - this._initialPoint.y) / this.designerCanvas.zoomFactor, gapRow, "height", true));
|
|
81
221
|
this._initialPoint = null;
|
|
82
222
|
this._initialSizes = null;
|
|
83
|
-
|
|
84
|
-
this.extendedItem.setStyle("grid-template-columns", this.extendedItem.element.style.gridTemplateColumns);
|
|
85
|
-
if (this.extendedItem.getStyle("grid-template-rows") != this.extendedItem.element.style.gridTemplateRows)
|
|
86
|
-
this.extendedItem.setStyle("grid-template-rows", this.extendedItem.element.style.gridTemplateRows);
|
|
223
|
+
this.refresh();
|
|
87
224
|
break;
|
|
88
225
|
}
|
|
89
226
|
}
|
|
90
|
-
_calculateNewSize(iSizes, diff, gapIndex, percentTarget) {
|
|
227
|
+
_calculateNewSize(iSizes, iUnits, diff, gapIndex, percentTarget, pointerUp = false) {
|
|
91
228
|
let newSizes = [];
|
|
92
229
|
let edited = [];
|
|
93
230
|
for (let i = 0; i < iSizes.length; i++) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
231
|
+
newSizes.push(i + 1 == gapIndex ? iSizes[i] + diff : i == gapIndex ? iSizes[i] - diff : iSizes[i]);
|
|
232
|
+
edited.push(i + 1 == gapIndex || i == gapIndex);
|
|
233
|
+
}
|
|
234
|
+
for (let i = 0; i < newSizes.length; i++) {
|
|
235
|
+
let index = edited[i + 1] ? i + 1 : edited[i - 1] ? i - 1 : null;
|
|
236
|
+
if (newSizes[i] < 0 && pointerUp) {
|
|
237
|
+
if (confirm("Do you want to delete this " + (percentTarget == "width" ? "column" : "row") + "?")) {
|
|
238
|
+
this._editGrid(i, percentTarget == "width" ? "horizontal" : "vertical", "del");
|
|
239
|
+
newSizes[index] = iSizes[i] + iSizes[index];
|
|
240
|
+
newSizes.splice(i, 1);
|
|
241
|
+
break;
|
|
103
242
|
}
|
|
104
243
|
}
|
|
105
|
-
|
|
106
|
-
newSizes
|
|
107
|
-
|
|
244
|
+
if (newSizes[i] < this.minPixelSize) {
|
|
245
|
+
newSizes[index] = newSizes[i] + newSizes[index] - this.minPixelSize;
|
|
246
|
+
newSizes[i] = this.minPixelSize;
|
|
247
|
+
break;
|
|
108
248
|
}
|
|
109
249
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
250
|
+
let retVal = "";
|
|
251
|
+
newSizes.forEach((newSize, i) => retVal += this._convertCssUnit(newSize + "px", this.extendedItem.element, percentTarget, iUnits[i]) + ' ');
|
|
252
|
+
return retVal;
|
|
253
|
+
}
|
|
254
|
+
_editGrid(pos, alignment, task) {
|
|
255
|
+
let cellTarget;
|
|
256
|
+
let elementTarget;
|
|
257
|
+
if (alignment == "vertical") {
|
|
258
|
+
cellTarget = "grid-template-rows";
|
|
259
|
+
elementTarget = "height";
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
cellTarget = "grid-template-columns";
|
|
263
|
+
elementTarget = "width";
|
|
264
|
+
}
|
|
265
|
+
let sizes = this.extendedItem.getStyle(cellTarget).split(' ');
|
|
266
|
+
if (task == "add")
|
|
267
|
+
sizes.splice(pos, 0, this.defaultSizeOfNewRowOrColumn);
|
|
268
|
+
else
|
|
269
|
+
sizes.splice(pos, 1);
|
|
270
|
+
this.extendedItem.setStyle(cellTarget, sizes.join(' '));
|
|
271
|
+
if (task == "add") {
|
|
272
|
+
this.extendedItem.setStyle(elementTarget, convertCssUnit(this._calculateNewElementSize(elementTarget), this.designerCanvas.canvas, elementTarget, getCssUnit(this.extendedItem.getStyle(elementTarget))));
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
this.extendedItem.setStyle(elementTarget, convertCssUnit(convertCssUnitToPixel(this.extendedItem.getStyle(elementTarget), this.designerCanvas.canvas, elementTarget) - convertCssUnitToPixel(this.extendedItem.getStyle(alignment == "vertical" ? "row-gap" : "column-gap"), this.extendedItem.element, elementTarget), this.designerCanvas.canvas, elementTarget, getCssUnit(this.extendedItem.getStyle(elementTarget))));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
_calculateNewElementSize(elementTarget) {
|
|
279
|
+
let gc = CalculateGridInformation(this.extendedItem);
|
|
280
|
+
let tmpSize = 0;
|
|
281
|
+
if (elementTarget == "width") {
|
|
282
|
+
gc.cells[0].forEach(cell => { tmpSize += cell.width; });
|
|
283
|
+
tmpSize += convertCssUnitToPixel(this.extendedItem.getStyle("column-gap"), this.extendedItem.element, elementTarget) * (gc.cells[0].length - 1);
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
gc.cells.forEach(row => { tmpSize += row[0].height; });
|
|
287
|
+
tmpSize += convertCssUnitToPixel(this.extendedItem.getStyle("row-gap"), this.extendedItem.element, elementTarget) * (gc.cells.length - 1);
|
|
288
|
+
}
|
|
289
|
+
return tmpSize + "px";
|
|
290
|
+
}
|
|
291
|
+
_toggleDisplayPlusCircles(index, alignment, double = false) {
|
|
292
|
+
this._plusCircles.forEach(alignment => {
|
|
293
|
+
alignment.forEach(element => {
|
|
294
|
+
element.circle.style.display = "none";
|
|
295
|
+
element.verticalLine.style.display = "none";
|
|
296
|
+
element.horizontalLine.style.display = "none";
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
if (index != -1) {
|
|
300
|
+
this._plusCircles[alignment == "vertical" ? 0 : 1][index].circle.style.display = "inline";
|
|
301
|
+
this._plusCircles[alignment == "vertical" ? 0 : 1][index].verticalLine.style.display = "inline";
|
|
302
|
+
this._plusCircles[alignment == "vertical" ? 0 : 1][index].horizontalLine.style.display = "inline";
|
|
303
|
+
if (double) {
|
|
304
|
+
this._plusCircles[alignment == "vertical" ? 0 : 1][index + 1].circle.style.display = "inline";
|
|
305
|
+
this._plusCircles[alignment == "vertical" ? 0 : 1][index + 1].verticalLine.style.display = "inline";
|
|
306
|
+
this._plusCircles[alignment == "vertical" ? 0 : 1][index + 1].horizontalLine.style.display = "inline";
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
_convertCssUnit(cssValue, target, percentTarget, unit) {
|
|
311
|
+
if (unit == "fr") {
|
|
312
|
+
let containerSize = convertCssUnitToPixel(target.style.width, target, percentTarget);
|
|
313
|
+
let amountGaps = percentTarget == "width" ? this.gridInformation.cells.length - 1 : this.gridInformation.cells[0].length - 1;
|
|
314
|
+
let gapSize = convertCssUnitToPixel(percentTarget == "width" ? target.style.columnGap : target.style.rowGap, target, percentTarget);
|
|
315
|
+
let containerSizeWithoutGaps = containerSize - gapSize * amountGaps;
|
|
316
|
+
let amountFrSizes = 0;
|
|
317
|
+
let leftOver = containerSizeWithoutGaps;
|
|
318
|
+
if (percentTarget == "width") {
|
|
319
|
+
this.gridInformation.cells[0].forEach((column, i) => {
|
|
320
|
+
if (column.initWidthUnit == "fr")
|
|
321
|
+
amountFrSizes++;
|
|
322
|
+
else
|
|
323
|
+
leftOver -= column.width;
|
|
132
324
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
this.gridInformation.cells.forEach((row, i) => {
|
|
328
|
+
if (row[0].initHeightUnit == "fr")
|
|
329
|
+
amountFrSizes++;
|
|
330
|
+
else
|
|
331
|
+
leftOver -= row[0].height;
|
|
137
332
|
});
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
333
|
+
}
|
|
334
|
+
let frRatio = leftOver / amountFrSizes;
|
|
335
|
+
if (typeof cssValue == "number") {
|
|
336
|
+
//expected Value in Pixel
|
|
337
|
+
return (cssValue / frRatio) + "fr";
|
|
141
338
|
}
|
|
142
339
|
else {
|
|
143
|
-
|
|
144
|
-
let index = edited[i + 1] ? i + 1 : edited[i - 1] ? i - 1 : null;
|
|
145
|
-
if (this._getCssUnit(newSizes[index]) != "fr")
|
|
146
|
-
newSizes[index] = convertCssUnit(convertCssUnitToPixel(newSizes[i], this.extendedItem.element, percentTarget) + convertCssUnitToPixel(newSizes[index], this.extendedItem.element, percentTarget) - this.minPixelSize, this.extendedItem.element, percentTarget, this._getCssUnit(newSizes[index]));
|
|
147
|
-
newSizes[i] = convertCssUnit(this.minPixelSize, this.extendedItem.element, percentTarget, this._getCssUnit(newSizes[i]));
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
340
|
+
return (convertCssUnitToPixel(cssValue, target, percentTarget) / frRatio) + "fr";
|
|
150
341
|
}
|
|
151
342
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return retVal;
|
|
155
|
-
}
|
|
156
|
-
_getCssUnit(cssValue) {
|
|
157
|
-
return cssValue.substring(cssValue.length - 2, cssValue.length) == "fr" ? "fr" : getCssUnit(cssValue);
|
|
343
|
+
else
|
|
344
|
+
return convertCssUnit(cssValue, target, percentTarget, unit);
|
|
158
345
|
}
|
|
159
346
|
}
|
|
@@ -15,6 +15,8 @@ export class GridExtensionProvider {
|
|
|
15
15
|
.svg-grid { stroke: orange; stroke-dasharray: 5; fill: #ff944722; }
|
|
16
16
|
.svg-grid-area { font-size: 8px; }
|
|
17
17
|
.svg-grid-gap { stroke: orange; stroke-dasharray: 5; fill: #0000ff22; }
|
|
18
|
-
.svg-grid-resizer { fill: white; stroke: #3899ec }
|
|
18
|
+
.svg-grid-resizer { fill: white; stroke: #3899ec; }
|
|
19
|
+
.svg-grid-header { fill: #ff944722; stroke: orange; }
|
|
20
|
+
.svg-grid-plus-sign { stroke: black; }
|
|
19
21
|
`;
|
|
20
22
|
}
|
|
@@ -67,7 +67,7 @@ export class TransformOriginExtension extends AbstractExtension {
|
|
|
67
67
|
let newXs = convertCssUnit(newX, this.extendedItem.element, 'width', getCssUnit(oldSplit[0]));
|
|
68
68
|
let newYs = convertCssUnit(newX, this.extendedItem.element, 'width', getCssUnit(oldSplit[0]));
|
|
69
69
|
if (oldSplit.length > 1) {
|
|
70
|
-
newYs = convertCssUnit(newY, this.extendedItem.element, '
|
|
70
|
+
newYs = convertCssUnit(newY, this.extendedItem.element, 'height', getCssUnit(oldSplit[1]));
|
|
71
71
|
}
|
|
72
72
|
this.extendedItem.setStyle('transform-origin', newXs + ' ' + newYs);
|
|
73
73
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -102,6 +102,7 @@ export type { ISelectionService } from "./elements/services/selectionService/ISe
|
|
|
102
102
|
export * from "./elements/services/selectionService/SelectionService.js";
|
|
103
103
|
export type { IStyleRule, IStyleDeclaration, IStylesheet, IStylesheetService } from "./elements/services/stylesheetService/IStylesheetService.js";
|
|
104
104
|
export * from "./elements/services/stylesheetService/CssTreeStylesheetService.js";
|
|
105
|
+
export * from "./elements/services/stylesheetService/CssToolsStylesheetService.js";
|
|
105
106
|
export * from "./elements/services/stylesheetService/SpecificityCalculator.js";
|
|
106
107
|
export * from "./elements/services/undoService/ChangeGroup.js";
|
|
107
108
|
export type { ITransactionItem } from "./elements/services/undoService/ITransactionItem.js";
|
package/dist/index.js
CHANGED
|
@@ -69,6 +69,7 @@ export * from "./elements/services/propertiesService/ValueType.js";
|
|
|
69
69
|
export * from "./elements/services/propertiesService/PropertyTabsService.js";
|
|
70
70
|
export * from "./elements/services/selectionService/SelectionService.js";
|
|
71
71
|
export * from "./elements/services/stylesheetService/CssTreeStylesheetService.js";
|
|
72
|
+
export * from "./elements/services/stylesheetService/CssToolsStylesheetService.js";
|
|
72
73
|
export * from "./elements/services/stylesheetService/SpecificityCalculator.js";
|
|
73
74
|
export * from "./elements/services/undoService/ChangeGroup.js";
|
|
74
75
|
export * from "./elements/services/undoService/UndoService.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "A UI designer for Polymer apps",
|
|
3
3
|
"name": "@node-projects/web-component-designer",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.171",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"construct-style-sheets-polyfill": "^3.1.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
+
"@adobe/css-tools": "^4.0.2",
|
|
21
22
|
"@node-projects/lean-he-esm": "^3.3.0",
|
|
22
23
|
"@node-projects/node-html-parser-esm": "^2.5.1",
|
|
23
24
|
"@papyrs/stylo": "^0.0.42",
|