@node-projects/web-component-designer 0.0.169 → 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/PropertyTabsService.js +3 -2
- package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService copy.d.ts +18 -0
- package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService copy.js +221 -0
- package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService.d.ts +17 -0
- package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService.js +53 -0
- package/dist/elements/services/propertiesService/services/CssProperties.json +541 -0
- package/dist/elements/services/propertiesService/services/CssPropertiesService copy.d.ts +18 -0
- package/dist/elements/services/propertiesService/services/CssPropertiesService copy.js +221 -0
- package/dist/elements/services/propertiesService/services/CssPropertiesService.d.ts +5 -6
- package/dist/elements/services/propertiesService/services/CssPropertiesService.js +43 -192
- 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 +4 -3
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService.js +34 -17
- package/dist/elements/services/stylesheetService/IStylesheetService.d.ts +5 -4
- package/dist/elements/widgets/designerView/designerCanvas.js +2 -0
- 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 +2 -0
- package/dist/index.js +2 -0
- package/package.json +2 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function convertCssUnitToPixel(cssValue: string, target: HTMLElement, percentTarget: 'width' | '
|
|
1
|
+
export declare function convertCssUnitToPixel(cssValue: string, target: HTMLElement, percentTarget: 'width' | 'height'): number;
|
|
2
2
|
export declare function getCssUnit(cssValue: string): string;
|
|
3
|
-
export declare function convertCssUnit(cssValue: string | number, target: HTMLElement, percentTarget: 'width' | '
|
|
3
|
+
export declare function convertCssUnit(cssValue: string | number, target: HTMLElement, percentTarget: 'width' | 'height', unit: string): string | number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//unsupported: ex, ch, svw, svh, vw, lvh, dvw, dvh
|
|
2
|
-
const units = ['px', 'cm', 'mm', 'q', 'in', 'pc', 'pt', 'rem', 'em', 'vw', 'vh', 'vmin', 'vmax', 'lh', 'rlh', '%', 'ms', 's', 'deg', 'rad', 'grad', 'turn', 'cqw', 'cqh', 'cqi', 'cqb', 'cqmin', 'cqmax'];
|
|
2
|
+
const units = ['px', 'cm', 'mm', 'q', 'in', 'pc', 'pt', 'rem', 'em', 'vw', 'vh', 'vmin', 'vmax', 'lh', 'rlh', '%', 'ms', 's', 'deg', 'rad', 'grad', 'turn', 'cqw', 'cqh', 'cqi', 'cqb', 'cqmin', 'cqmax', 'fr'];
|
|
3
3
|
const pattern = new RegExp(`^([\-\+]?(?:\\d+(?:\\.\\d+)?))(${units.join('|')})$`, 'i');
|
|
4
4
|
export function convertCssUnitToPixel(cssValue, target, percentTarget) {
|
|
5
5
|
const supportedUnits = {
|
|
@@ -20,7 +20,7 @@ export function convertCssUnitToPixel(cssValue, target, percentTarget) {
|
|
|
20
20
|
'vmax': value => value / 100 * (window.innerHeight > window.innerWidth ? window.innerHeight : window.innerWidth),
|
|
21
21
|
'lh': value => value * parseFloat(getComputedStyle(target).lineHeight),
|
|
22
22
|
'rlh': value => value * parseFloat(getComputedStyle(document.documentElement).lineHeight),
|
|
23
|
-
'%': value => value / 100 * (percentTarget == '
|
|
23
|
+
'%': value => value / 100 * (percentTarget == 'height' ? target.getBoundingClientRect().height : target.getBoundingClientRect().width),
|
|
24
24
|
/* todo
|
|
25
25
|
//find parent with computed style where contaner-type is inline-size or size (regarding to query type)
|
|
26
26
|
//use this size for calculation
|
|
@@ -76,7 +76,7 @@ export function convertCssUnit(cssValue, target, percentTarget, unit) {
|
|
|
76
76
|
'vmax': value => value * 100 / (window.innerHeight > window.innerWidth ? window.innerHeight : window.innerWidth),
|
|
77
77
|
'lh': value => value / parseFloat(getComputedStyle(target).lineHeight),
|
|
78
78
|
'rlh': value => value / parseFloat(getComputedStyle(document.documentElement).lineHeight),
|
|
79
|
-
'%': value => value * 100 / (percentTarget == '
|
|
79
|
+
'%': value => value * 100 / (percentTarget == 'height' ? target.getBoundingClientRect().height : target.getBoundingClientRect().width),
|
|
80
80
|
// Times
|
|
81
81
|
'ms': value => value,
|
|
82
82
|
's': value => value / 1000,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getCssUnit } from "./CssUnitConverter.js";
|
|
1
2
|
export function CalculateGridInformation(designItem) {
|
|
2
3
|
//todo:
|
|
3
4
|
//same name should combine columns/rows
|
|
@@ -6,6 +7,20 @@ export function CalculateGridInformation(designItem) {
|
|
|
6
7
|
const computedStyle = getComputedStyle(designItem.element);
|
|
7
8
|
const rows = computedStyle.gridTemplateRows.split(' ');
|
|
8
9
|
const columns = computedStyle.gridTemplateColumns.split(' ');
|
|
10
|
+
const rowUnits = [];
|
|
11
|
+
let tmpStyle = designItem.getStyle("grid-template-rows");
|
|
12
|
+
if (tmpStyle)
|
|
13
|
+
tmpStyle.split(' ').forEach(rowWidth => { if (rowWidth != "")
|
|
14
|
+
rowUnits.push(getCssUnit(rowWidth)); });
|
|
15
|
+
else
|
|
16
|
+
rows.forEach(() => rowUnits.push("px"));
|
|
17
|
+
const columnUnits = [];
|
|
18
|
+
tmpStyle = designItem.getStyle("grid-template-columns");
|
|
19
|
+
if (tmpStyle)
|
|
20
|
+
tmpStyle.split(' ').forEach(columnHeight => { if (columnHeight != "")
|
|
21
|
+
columnUnits.push(getCssUnit(columnHeight)); });
|
|
22
|
+
else
|
|
23
|
+
columns.forEach(() => columnUnits.push("px"));
|
|
9
24
|
const paddingLeft = Number.parseFloat(computedStyle.paddingLeft);
|
|
10
25
|
const paddingTop = Number.parseFloat(computedStyle.paddingTop);
|
|
11
26
|
let y = 0;
|
|
@@ -100,7 +115,7 @@ export function CalculateGridInformation(designItem) {
|
|
|
100
115
|
name = nm;
|
|
101
116
|
}
|
|
102
117
|
}
|
|
103
|
-
const cell = { x: x + xOffset + paddingLeft, y: y + yOffset + paddingTop, width: currX, height: currY, name: name };
|
|
118
|
+
const cell = { x: x + xOffset + paddingLeft, y: y + yOffset + paddingTop, width: currX, initWidthUnit: columnUnits[yIdx], height: currY, initHeightUnit: rowUnits[xIdx], name: name };
|
|
104
119
|
cellList.push(cell);
|
|
105
120
|
x += currX;
|
|
106
121
|
cl++;
|
|
@@ -76,6 +76,7 @@ export declare class DesignItem implements IDesignItem {
|
|
|
76
76
|
setStyle(name: string, value?: string | null, important?: boolean): void;
|
|
77
77
|
removeStyle(name: string): void;
|
|
78
78
|
updateStyleInSheetOrLocal(name: string, value?: string | null, important?: boolean): void;
|
|
79
|
+
getStyleFromSheetOrLocal(name: string): void;
|
|
79
80
|
getAllStyles(): IStyleRule[];
|
|
80
81
|
setAttribute(name: string, value?: string | null): void;
|
|
81
82
|
removeAttribute(name: string): void;
|
|
@@ -304,10 +304,10 @@ export class DesignItem {
|
|
|
304
304
|
}
|
|
305
305
|
updateStyleInSheetOrLocal(name, value, important) {
|
|
306
306
|
let nm = PropertiesHelper.camelToDashCase(name);
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
307
|
+
// Pre-sorted by priority
|
|
308
|
+
let declerations = this.instanceServiceContainer.stylesheetService?.getDeclarations(this, nm);
|
|
309
|
+
if (this.hasStyle(name) || !declerations) {
|
|
310
|
+
// Set style locally
|
|
311
311
|
if (this.getStyle(nm) != value) {
|
|
312
312
|
this.setStyle(nm, value);
|
|
313
313
|
}
|
|
@@ -315,9 +315,12 @@ export class DesignItem {
|
|
|
315
315
|
this.removeStyle(nm);
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
318
|
+
else {
|
|
319
|
+
// Set style in sheet
|
|
320
|
+
this.instanceServiceContainer.stylesheetService.updateDeclarationWithDeclaration(declerations[0], value, important);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
getStyleFromSheetOrLocal(name) {
|
|
321
324
|
}
|
|
322
325
|
getAllStyles() {
|
|
323
326
|
const localStyles = [...this._styles.entries()].map(x => ({ name: x[0], value: x[1], important: false }));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IDesignItem } from '../../item/IDesignItem.js';
|
|
2
2
|
import { IPropertiesService } from './IPropertiesService.js';
|
|
3
|
-
import {
|
|
4
|
-
export declare class PropertyGroupsService implements
|
|
3
|
+
import { IPropertyGroupsService } from './IPropertyGroupsService.js';
|
|
4
|
+
export declare class PropertyGroupsService implements IPropertyGroupsService {
|
|
5
5
|
protected _pgList: {
|
|
6
6
|
name: string;
|
|
7
7
|
propertiesService: IPropertiesService;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { AttributesPropertiesService } from './services/AttributesPropertiesService.js';
|
|
2
2
|
import { CommonPropertiesService } from './services/CommonPropertiesService.js';
|
|
3
|
+
import { CssCurrentPropertiesService } from './services/CssCurrentPropertiesService.js';
|
|
3
4
|
import { CssPropertiesService } from './services/CssPropertiesService.js';
|
|
4
5
|
export class PropertyTabsService {
|
|
5
6
|
_pgList = [
|
|
6
7
|
{ name: 'properties', propertiesService: null },
|
|
7
8
|
{ name: 'attributes', propertiesService: new AttributesPropertiesService() },
|
|
8
9
|
{ name: 'common', propertiesService: new CommonPropertiesService() },
|
|
9
|
-
{ name: 'styles', propertiesService: new
|
|
10
|
+
{ name: 'styles', propertiesService: new CssCurrentPropertiesService() },
|
|
10
11
|
{ name: 'layout', propertiesService: new CssPropertiesService("layout") },
|
|
11
12
|
{ name: 'flex', propertiesService: new CssPropertiesService("flex") },
|
|
12
13
|
{ name: 'grid', propertiesService: new CssPropertiesService("grid") },
|
|
@@ -14,7 +15,7 @@ export class PropertyTabsService {
|
|
|
14
15
|
_svgPgList = [
|
|
15
16
|
{ name: 'properties', propertiesService: null },
|
|
16
17
|
{ name: 'attributes', propertiesService: new AttributesPropertiesService() },
|
|
17
|
-
{ name: 'styles', propertiesService: new
|
|
18
|
+
{ name: 'styles', propertiesService: new CssCurrentPropertiesService() },
|
|
18
19
|
{ name: 'layout', propertiesService: new CssPropertiesService("layout") },
|
|
19
20
|
];
|
|
20
21
|
getPropertygroups(designItems) {
|
package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService copy.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IProperty } from '../IProperty.js';
|
|
2
|
+
import { IDesignItem } from '../../../item/IDesignItem.js';
|
|
3
|
+
import { BindingTarget } from '../../../item/BindingTarget.js';
|
|
4
|
+
import { CommonPropertiesService } from './CommonPropertiesService.js';
|
|
5
|
+
import { RefreshMode } from '../IPropertiesService.js';
|
|
6
|
+
import { IPropertyGroup } from '../IPropertyGroup.js';
|
|
7
|
+
export declare class CssPropertiesService extends CommonPropertiesService {
|
|
8
|
+
getRefreshMode(designItem: IDesignItem): RefreshMode.none | RefreshMode.fullOnValueChange;
|
|
9
|
+
layout: IProperty[];
|
|
10
|
+
grid: IProperty[];
|
|
11
|
+
flex: IProperty[];
|
|
12
|
+
constructor(name: 'styles' | 'layout' | 'grid' | 'flex');
|
|
13
|
+
isHandledElement(designItem: IDesignItem): boolean;
|
|
14
|
+
getProperty(designItem: IDesignItem, name: string): IProperty;
|
|
15
|
+
getProperties(designItem: IDesignItem): IProperty[] | IPropertyGroup[];
|
|
16
|
+
getPropertyTarget(designItem: IDesignItem, property: IProperty): BindingTarget;
|
|
17
|
+
setValue(designItems: IDesignItem[], property: IProperty, value: any): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { BindingTarget } from '../../../item/BindingTarget.js';
|
|
2
|
+
import { PropertyType } from '../PropertyType.js';
|
|
3
|
+
import { CommonPropertiesService } from './CommonPropertiesService.js';
|
|
4
|
+
import { RefreshMode } from '../IPropertiesService.js';
|
|
5
|
+
export class CssPropertiesService extends CommonPropertiesService {
|
|
6
|
+
getRefreshMode(designItem) {
|
|
7
|
+
return this.name == 'styles' ? RefreshMode.fullOnValueChange : RefreshMode.none;
|
|
8
|
+
}
|
|
9
|
+
layout = [
|
|
10
|
+
{
|
|
11
|
+
name: "display",
|
|
12
|
+
type: "list",
|
|
13
|
+
values: ["block", "inline", "inline-block", "flex", "inline-flex", "contents", "grid", "inline-grid", "inherit", "initial", "none"],
|
|
14
|
+
service: this,
|
|
15
|
+
propertyType: PropertyType.cssValue
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "color",
|
|
19
|
+
type: "color",
|
|
20
|
+
service: this,
|
|
21
|
+
propertyType: PropertyType.cssValue
|
|
22
|
+
}, {
|
|
23
|
+
name: "background-color",
|
|
24
|
+
type: "color",
|
|
25
|
+
service: this,
|
|
26
|
+
propertyType: PropertyType.cssValue
|
|
27
|
+
}, {
|
|
28
|
+
name: "box-sizing",
|
|
29
|
+
type: "list",
|
|
30
|
+
values: ["border-box", "content-box"],
|
|
31
|
+
service: this,
|
|
32
|
+
propertyType: PropertyType.cssValue
|
|
33
|
+
}, {
|
|
34
|
+
name: "border",
|
|
35
|
+
type: "string",
|
|
36
|
+
default: "0px none rbg(0,0,0)",
|
|
37
|
+
service: this,
|
|
38
|
+
propertyType: PropertyType.cssValue
|
|
39
|
+
}, {
|
|
40
|
+
name: "box-shadow",
|
|
41
|
+
type: "string",
|
|
42
|
+
default: "none",
|
|
43
|
+
service: this,
|
|
44
|
+
propertyType: PropertyType.cssValue
|
|
45
|
+
}, {
|
|
46
|
+
name: "opacity",
|
|
47
|
+
type: "number",
|
|
48
|
+
min: 0,
|
|
49
|
+
max: 1,
|
|
50
|
+
step: 0.1,
|
|
51
|
+
service: this,
|
|
52
|
+
propertyType: PropertyType.cssValue
|
|
53
|
+
}, {
|
|
54
|
+
name: "metrics",
|
|
55
|
+
type: "metrics",
|
|
56
|
+
service: this,
|
|
57
|
+
propertyType: PropertyType.complex
|
|
58
|
+
}, {
|
|
59
|
+
name: "position",
|
|
60
|
+
type: "list",
|
|
61
|
+
values: ["static", "relative", "absolute"],
|
|
62
|
+
service: this,
|
|
63
|
+
propertyType: PropertyType.cssValue
|
|
64
|
+
}, {
|
|
65
|
+
name: "font-size",
|
|
66
|
+
type: "css-length",
|
|
67
|
+
service: this,
|
|
68
|
+
propertyType: PropertyType.cssValue
|
|
69
|
+
}, {
|
|
70
|
+
name: "font-weight",
|
|
71
|
+
type: "list",
|
|
72
|
+
values: ["normal", "bold", "100", "200", "300", "400", "500", "600", "700", "800", "900", "lighter", "bolder"],
|
|
73
|
+
service: this,
|
|
74
|
+
propertyType: PropertyType.cssValue
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
grid = [
|
|
78
|
+
{
|
|
79
|
+
name: "display",
|
|
80
|
+
type: "list",
|
|
81
|
+
values: ["block", "inline-block", "flex", "contents", "grid", "inherit", "initial", "none"],
|
|
82
|
+
service: this,
|
|
83
|
+
propertyType: PropertyType.cssValue
|
|
84
|
+
}, {
|
|
85
|
+
name: "position",
|
|
86
|
+
type: "list",
|
|
87
|
+
values: ["static", "relative", "absolute"],
|
|
88
|
+
service: this,
|
|
89
|
+
propertyType: PropertyType.cssValue
|
|
90
|
+
}, {
|
|
91
|
+
name: "grid-template-columns",
|
|
92
|
+
type: "string",
|
|
93
|
+
service: this,
|
|
94
|
+
propertyType: PropertyType.cssValue
|
|
95
|
+
}, {
|
|
96
|
+
name: "grid-template-rows",
|
|
97
|
+
type: "string",
|
|
98
|
+
service: this,
|
|
99
|
+
propertyType: PropertyType.cssValue
|
|
100
|
+
}, {
|
|
101
|
+
name: "column-gap",
|
|
102
|
+
type: "css-length",
|
|
103
|
+
service: this,
|
|
104
|
+
propertyType: PropertyType.cssValue
|
|
105
|
+
}, {
|
|
106
|
+
name: "row-gap",
|
|
107
|
+
type: "css-length",
|
|
108
|
+
service: this,
|
|
109
|
+
propertyType: PropertyType.cssValue
|
|
110
|
+
}, {
|
|
111
|
+
name: "align-content",
|
|
112
|
+
type: "img-list",
|
|
113
|
+
values: ["center", "space-between", "space-around", "space-evenly", "stretch"],
|
|
114
|
+
service: this,
|
|
115
|
+
propertyType: PropertyType.cssValue
|
|
116
|
+
}, {
|
|
117
|
+
name: "justify-content",
|
|
118
|
+
type: "img-list",
|
|
119
|
+
values: ["center", "start", "end", "space-between", "space-around", "space-evenly"],
|
|
120
|
+
service: this,
|
|
121
|
+
propertyType: PropertyType.cssValue
|
|
122
|
+
}, {
|
|
123
|
+
name: "align-items",
|
|
124
|
+
type: "img-list",
|
|
125
|
+
values: ["center", "start", "end", "stretch", "baseline"],
|
|
126
|
+
service: this,
|
|
127
|
+
propertyType: PropertyType.cssValue
|
|
128
|
+
}, {
|
|
129
|
+
name: "justify-items",
|
|
130
|
+
type: "img-list",
|
|
131
|
+
values: ["center", "start", "end", "stretch"],
|
|
132
|
+
service: this,
|
|
133
|
+
propertyType: PropertyType.cssValue
|
|
134
|
+
}
|
|
135
|
+
];
|
|
136
|
+
flex = [
|
|
137
|
+
{
|
|
138
|
+
name: "display",
|
|
139
|
+
type: "list",
|
|
140
|
+
values: ["block", "inline-block", "flex", "contents", "grid", "inherit", "initial", "none"],
|
|
141
|
+
service: this,
|
|
142
|
+
propertyType: PropertyType.cssValue
|
|
143
|
+
}, {
|
|
144
|
+
name: "position",
|
|
145
|
+
type: "list",
|
|
146
|
+
values: ["static", "relative", "absolute"],
|
|
147
|
+
service: this,
|
|
148
|
+
propertyType: PropertyType.cssValue
|
|
149
|
+
}, {
|
|
150
|
+
name: "flex-direction",
|
|
151
|
+
type: "img-list",
|
|
152
|
+
values: ["row", "column"],
|
|
153
|
+
service: this,
|
|
154
|
+
propertyType: PropertyType.cssValue
|
|
155
|
+
}, {
|
|
156
|
+
name: "flex-wrap",
|
|
157
|
+
type: "img-list",
|
|
158
|
+
values: ["nowrap", "wrap"],
|
|
159
|
+
service: this,
|
|
160
|
+
propertyType: PropertyType.cssValue
|
|
161
|
+
}, {
|
|
162
|
+
name: "align-content",
|
|
163
|
+
type: "img-list",
|
|
164
|
+
values: ["center", "flex-start", "flex-end", "space-between", "space-around", "stretch"],
|
|
165
|
+
service: this,
|
|
166
|
+
propertyType: PropertyType.cssValue
|
|
167
|
+
}, {
|
|
168
|
+
name: "justify-content",
|
|
169
|
+
type: "img-list",
|
|
170
|
+
values: ["center", "flex-start", "flex-end", "space-between", "space-around", "space-evenly"],
|
|
171
|
+
service: this,
|
|
172
|
+
propertyType: PropertyType.cssValue
|
|
173
|
+
}, {
|
|
174
|
+
name: "align-items",
|
|
175
|
+
type: "img-list",
|
|
176
|
+
values: ["center", "flex-start", "flex-end", "stretch", "baseline"],
|
|
177
|
+
service: this,
|
|
178
|
+
propertyType: PropertyType.cssValue
|
|
179
|
+
}
|
|
180
|
+
];
|
|
181
|
+
constructor(name) {
|
|
182
|
+
super();
|
|
183
|
+
this.name = name;
|
|
184
|
+
}
|
|
185
|
+
isHandledElement(designItem) {
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
getProperty(designItem, name) {
|
|
189
|
+
if (this.name == 'styles') {
|
|
190
|
+
return { name: name, type: 'string', service: this, propertyType: PropertyType.cssValue };
|
|
191
|
+
}
|
|
192
|
+
return this[this.name][name];
|
|
193
|
+
}
|
|
194
|
+
getProperties(designItem) {
|
|
195
|
+
if (this.name == 'styles') {
|
|
196
|
+
if (!designItem)
|
|
197
|
+
return [];
|
|
198
|
+
let styles = designItem.getAllStyles();
|
|
199
|
+
let arr = styles.map(x => ({ name: x.selector ?? '<local>', description: x.stylesheetName ?? '', properties: [
|
|
200
|
+
...x.declarations.map(y => ({ name: y.name, renamable: true, type: 'string', service: this, propertyType: PropertyType.cssValue })),
|
|
201
|
+
{ name: '', type: 'addNew', service: this, propertyType: PropertyType.complex }
|
|
202
|
+
]
|
|
203
|
+
}));
|
|
204
|
+
//let arr: IProperty[] = Array.from(designItem.styles(), ([key, value]) => ({ name: key, renamable: true, type: 'string', service: this, propertyType: PropertyType.cssValue }));
|
|
205
|
+
//arr.push({ name: '', type: 'addNew', service: this, propertyType: PropertyType.complex });
|
|
206
|
+
return arr;
|
|
207
|
+
}
|
|
208
|
+
return this[this.name];
|
|
209
|
+
}
|
|
210
|
+
getPropertyTarget(designItem, property) {
|
|
211
|
+
return BindingTarget.css;
|
|
212
|
+
}
|
|
213
|
+
setValue(designItems, property, value) {
|
|
214
|
+
if (this.name == 'styles') {
|
|
215
|
+
super.setValue(designItems, { ...property, propertyType: PropertyType.cssValue }, value);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
super.setValue(designItems, property, value);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IProperty } from '../IProperty.js';
|
|
2
|
+
import { IDesignItem } from '../../../item/IDesignItem.js';
|
|
3
|
+
import { RefreshMode } from '../IPropertiesService.js';
|
|
4
|
+
import { IPropertyGroup } from '../IPropertyGroup.js';
|
|
5
|
+
import { IStyleDeclaration, IStyleRule } from '../../stylesheetService/IStylesheetService.js';
|
|
6
|
+
import { CommonPropertiesService } from './CommonPropertiesService.js';
|
|
7
|
+
export declare class CssCurrentPropertiesService extends CommonPropertiesService {
|
|
8
|
+
getRefreshMode(designItem: IDesignItem): RefreshMode;
|
|
9
|
+
constructor();
|
|
10
|
+
isHandledElement(designItem: IDesignItem): boolean;
|
|
11
|
+
getProperty(designItem: IDesignItem, name: string): IProperty;
|
|
12
|
+
getProperties(designItem: IDesignItem): IProperty[] | IPropertyGroup[];
|
|
13
|
+
setValue(designItems: IDesignItem[], property: (IProperty & {
|
|
14
|
+
styleRule: IStyleRule;
|
|
15
|
+
styleDeclaration: IStyleDeclaration;
|
|
16
|
+
}), value: any): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { PropertyType } from '../PropertyType.js';
|
|
2
|
+
import { RefreshMode } from '../IPropertiesService.js';
|
|
3
|
+
import { CommonPropertiesService } from './CommonPropertiesService.js';
|
|
4
|
+
import cssProperties from './CssProperties.json' assert { type: 'json' };
|
|
5
|
+
export class CssCurrentPropertiesService extends CommonPropertiesService {
|
|
6
|
+
getRefreshMode(designItem) {
|
|
7
|
+
return RefreshMode.fullOnValueChange;
|
|
8
|
+
}
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.name = 'styles';
|
|
12
|
+
}
|
|
13
|
+
isHandledElement(designItem) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
getProperty(designItem, name) {
|
|
17
|
+
return { name: name, type: 'string', service: this, propertyType: PropertyType.cssValue };
|
|
18
|
+
}
|
|
19
|
+
getProperties(designItem) {
|
|
20
|
+
if (!designItem)
|
|
21
|
+
return [];
|
|
22
|
+
let styles = designItem.getAllStyles();
|
|
23
|
+
let arr = styles.map(x => ({
|
|
24
|
+
name: x.selector ?? '<local>', description: x.stylesheetName ?? '', properties: [
|
|
25
|
+
...x.declarations.map(y => ({
|
|
26
|
+
name: y.name,
|
|
27
|
+
renamable: true,
|
|
28
|
+
type: cssProperties[y.name]?.type ?? 'string',
|
|
29
|
+
values: cssProperties[y.name]?.values ? [...cssProperties[y.name]?.values, 'initial', 'inherit', 'unset'] : ['initial', 'inherit', 'unset'],
|
|
30
|
+
service: this,
|
|
31
|
+
propertyType: PropertyType.cssValue,
|
|
32
|
+
styleRule: x,
|
|
33
|
+
styleDeclaration: y
|
|
34
|
+
})),
|
|
35
|
+
{ name: '', type: 'addNew', service: this, propertyType: PropertyType.complex, styleRule: x }
|
|
36
|
+
]
|
|
37
|
+
}));
|
|
38
|
+
return arr;
|
|
39
|
+
}
|
|
40
|
+
setValue(designItems, property, value) {
|
|
41
|
+
// No selector means local style, styleDeclaration is null means new property
|
|
42
|
+
if (property.styleRule?.selector !== null && property.styleDeclaration) {
|
|
43
|
+
designItems[0].instanceServiceContainer.stylesheetService.updateDeclarationWithDeclaration(property.styleDeclaration, value, false);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (property.styleRule?.selector !== null && !property.styleDeclaration) {
|
|
47
|
+
designItems[0].instanceServiceContainer.stylesheetService.insertDeclarationIntoRule(property.styleRule, { name: property.name, value: value, important: false }, false);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// Local style
|
|
51
|
+
super.setValue(designItems, { ...property, propertyType: PropertyType.cssValue }, value);
|
|
52
|
+
}
|
|
53
|
+
}
|