@node-projects/web-component-designer 0.0.167 → 0.0.169
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/documentContainer.d.ts +7 -0
- package/dist/elements/documentContainer.js +23 -0
- package/dist/elements/helper/CssUnitConverter.js +11 -1
- package/dist/elements/helper/contextMenu/ContextMenu.js +21 -21
- package/dist/elements/item/DesignItem.d.ts +4 -1
- package/dist/elements/item/DesignItem.js +28 -1
- package/dist/elements/item/IDesignItem.d.ts +4 -1
- package/dist/elements/services/BaseServiceContainer.d.ts +4 -0
- package/dist/elements/services/BaseServiceContainer.js +4 -0
- package/dist/elements/services/DefaultServiceBootstrap.js +9 -2
- package/dist/elements/services/InstanceServiceContainer.d.ts +3 -0
- package/dist/elements/services/InstanceServiceContainer.js +3 -0
- package/dist/elements/services/ServiceContainer.d.ts +12 -3
- package/dist/elements/services/elementsService/IElementDefinition.d.ts +0 -3
- package/dist/elements/services/instanceService/DefaultInstanceService.js +0 -12
- package/dist/elements/services/propertiesService/IPropertiesService.d.ts +2 -1
- package/dist/elements/services/propertiesService/IProperty copy.d.ts +22 -0
- package/dist/elements/services/propertiesService/IProperty copy.js +1 -0
- package/dist/elements/services/propertiesService/IPropertyGroup.d.ts +6 -0
- package/dist/elements/services/propertiesService/IPropertyGroup.js +1 -0
- package/dist/elements/services/propertiesService/IPropertyTabsService.d.ts +8 -0
- package/dist/elements/services/propertiesService/IPropertyTabsService.js +1 -0
- package/dist/elements/services/propertiesService/PropertyGroupsService.d.ts +2 -2
- package/dist/elements/services/propertiesService/PropertyTabsService.d.ts +17 -0
- package/dist/elements/services/propertiesService/PropertyTabsService.js +29 -0
- package/dist/elements/services/propertiesService/services/AbstractPropertiesService.d.ts +2 -1
- package/dist/elements/services/propertiesService/services/AbstractPropertiesService.js +7 -7
- package/dist/elements/services/propertiesService/services/CommonPropertiesService.d.ts +2 -1
- package/dist/elements/services/propertiesService/services/CssPropertiesService.d.ts +2 -1
- package/dist/elements/services/propertiesService/services/CssPropertiesService.js +8 -2
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService.d.ts +47 -0
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService.js +183 -0
- package/dist/elements/services/stylesheetService/IStylesheetService.d.ts +29 -0
- package/dist/elements/services/stylesheetService/IStylesheetService.js +1 -0
- package/dist/elements/services/stylesheetService/SpecificityCalculator.d.ts +7 -0
- package/dist/elements/services/stylesheetService/SpecificityCalculator.js +178 -0
- package/dist/elements/services/stylesheetService/StylesheetService.d.ts +28 -0
- package/dist/elements/services/stylesheetService/StylesheetService.js +108 -0
- package/dist/elements/widgets/designerView/designerCanvas.d.ts +6 -0
- package/dist/elements/widgets/designerView/designerCanvas.js +73 -34
- package/dist/elements/widgets/propertyGrid/PropertyGridPropertyList.d.ts +2 -0
- package/dist/elements/widgets/propertyGrid/PropertyGridPropertyList.js +96 -66
- package/dist/index.d.ts +6 -2
- package/dist/index.js +3 -1
- package/package.json +6 -3
|
@@ -8,6 +8,7 @@ import { IUiCommandHandler } from '../commandHandling/IUiCommandHandler.js';
|
|
|
8
8
|
import { IUiCommand } from '../commandHandling/IUiCommand.js';
|
|
9
9
|
import { IDisposable } from '../interfaces/IDisposable.js';
|
|
10
10
|
import { ISelectionChangedEvent } from "./services/selectionService/ISelectionChangedEvent.js";
|
|
11
|
+
import { IStylesheet } from "./services/stylesheetService/IStylesheetService.js";
|
|
11
12
|
export declare class DocumentContainer extends BaseCustomWebComponentLazyAppend implements IUiCommandHandler, IDisposable {
|
|
12
13
|
designerView: DesignerView;
|
|
13
14
|
codeView: ICodeView & HTMLElement;
|
|
@@ -16,6 +17,12 @@ export declare class DocumentContainer extends BaseCustomWebComponentLazyAppend
|
|
|
16
17
|
private _additionalStyle;
|
|
17
18
|
set additionalStyleString(style: string);
|
|
18
19
|
get additionalStyleString(): string;
|
|
20
|
+
private _additionalStylesheets;
|
|
21
|
+
set additionalStylesheets(stylesheets: IStylesheet[]);
|
|
22
|
+
get additionalStylesheets(): IStylesheet[];
|
|
23
|
+
additionalStylesheetChanged: TypedEvent<{
|
|
24
|
+
stylesheet: IStylesheet;
|
|
25
|
+
}>;
|
|
19
26
|
onContentChanged: TypedEvent<void>;
|
|
20
27
|
private _serviceContainer;
|
|
21
28
|
private _content;
|
|
@@ -17,6 +17,29 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
17
17
|
return this._additionalStyle;
|
|
18
18
|
}
|
|
19
19
|
;
|
|
20
|
+
_additionalStylesheets;
|
|
21
|
+
set additionalStylesheets(stylesheets) {
|
|
22
|
+
this._additionalStylesheets = stylesheets;
|
|
23
|
+
if (!this.instanceServiceContainer.stylesheetService) {
|
|
24
|
+
const stylesheetService = this.designerView.serviceContainer.getLastService('stylesheetService');
|
|
25
|
+
if (stylesheetService) {
|
|
26
|
+
const instance = stylesheetService(this.designerView.designerCanvas);
|
|
27
|
+
this.instanceServiceContainer.register("stylesheetService", instance);
|
|
28
|
+
instance.stylesheetChanged.on(s => this.additionalStylesheetChanged.emit(s));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
console.warn("no Stylesheet-Service registered, but additionalStylesheets are used.");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (this.designerView.instanceServiceContainer.stylesheetService)
|
|
35
|
+
this.designerView.instanceServiceContainer.stylesheetService.setStylesheets(stylesheets);
|
|
36
|
+
}
|
|
37
|
+
;
|
|
38
|
+
get additionalStylesheets() {
|
|
39
|
+
return this._additionalStylesheets;
|
|
40
|
+
}
|
|
41
|
+
;
|
|
42
|
+
additionalStylesheetChanged = new TypedEvent;
|
|
20
43
|
onContentChanged = new TypedEvent();
|
|
21
44
|
_serviceContainer;
|
|
22
45
|
_content = '';
|
|
@@ -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'];
|
|
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'];
|
|
3
3
|
const pattern = new RegExp(`^([\-\+]?(?:\\d+(?:\\.\\d+)?))(${units.join('|')})$`, 'i');
|
|
4
4
|
export function convertCssUnitToPixel(cssValue, target, percentTarget) {
|
|
5
5
|
const supportedUnits = {
|
|
@@ -21,6 +21,16 @@ export function convertCssUnitToPixel(cssValue, target, percentTarget) {
|
|
|
21
21
|
'lh': value => value * parseFloat(getComputedStyle(target).lineHeight),
|
|
22
22
|
'rlh': value => value * parseFloat(getComputedStyle(document.documentElement).lineHeight),
|
|
23
23
|
'%': value => value / 100 * (percentTarget == 'heigth' ? target.getBoundingClientRect().height : target.getBoundingClientRect().width),
|
|
24
|
+
/* todo
|
|
25
|
+
//find parent with computed style where contaner-type is inline-size or size (regarding to query type)
|
|
26
|
+
//use this size for calculation
|
|
27
|
+
'cqw':
|
|
28
|
+
'cqh':
|
|
29
|
+
'cqi':
|
|
30
|
+
'cqb':
|
|
31
|
+
'cqmin':
|
|
32
|
+
'cqmax':
|
|
33
|
+
*/
|
|
24
34
|
// Times
|
|
25
35
|
'ms': value => value,
|
|
26
36
|
's': value => value * 1000,
|
|
@@ -13,7 +13,7 @@ export class ContextMenu {
|
|
|
13
13
|
color: black;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
.context_menu.
|
|
16
|
+
.context_menu.context_menu_display {
|
|
17
17
|
opacity: 1;
|
|
18
18
|
transform: scale(1);
|
|
19
19
|
}
|
|
@@ -46,18 +46,18 @@ export class ContextMenu {
|
|
|
46
46
|
background-color: #bbb;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
.context_menu li .
|
|
50
|
-
width:
|
|
49
|
+
.context_menu li .context_menu_icon_span {
|
|
50
|
+
width: 28px;
|
|
51
51
|
display: inline-block;
|
|
52
52
|
border-right: 1px solid #aaa;
|
|
53
|
-
padding: 0px 3px;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
.context_menu li .
|
|
57
|
-
padding-left:
|
|
55
|
+
.context_menu li .context_menu_text {
|
|
56
|
+
padding-left: 2px;
|
|
57
|
+
vertical-align: middle;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
.context_menu li .
|
|
60
|
+
.context_menu li .context_menu_sub_span {
|
|
61
61
|
width: 1em;
|
|
62
62
|
display: inline-block;
|
|
63
63
|
text-align: center;
|
|
@@ -81,23 +81,23 @@ export class ContextMenu {
|
|
|
81
81
|
visibility: visible;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
.context_menu li.
|
|
84
|
+
.context_menu li.context_menu_divider {
|
|
85
85
|
border-bottom: 1px solid #aaa;
|
|
86
86
|
margin: 5px;
|
|
87
87
|
padding: 0;
|
|
88
88
|
cursor: default;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
.context_menu li.
|
|
91
|
+
.context_menu li.context_menu_divider:hover {
|
|
92
92
|
background-color: inherit;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
.context_menu.
|
|
95
|
+
.context_menu.context_menu_border_right>ul ul {
|
|
96
96
|
left: unset;
|
|
97
97
|
right: 100%;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
.context_menu.
|
|
100
|
+
.context_menu.context_menu_border_bottom>ul ul {
|
|
101
101
|
top: unset;
|
|
102
102
|
bottom: 0;
|
|
103
103
|
}
|
|
@@ -132,7 +132,7 @@ export class ContextMenu {
|
|
|
132
132
|
if (this._menuElement == null) {
|
|
133
133
|
this._menuElement = document.createElement("div");
|
|
134
134
|
this._menuElement.className = "context_menu";
|
|
135
|
-
this._menuElement.id = "
|
|
135
|
+
this._menuElement.id = "context_menu_" + this.num;
|
|
136
136
|
if (shadowRoot === document)
|
|
137
137
|
document.body.appendChild(this._menuElement);
|
|
138
138
|
else
|
|
@@ -151,7 +151,7 @@ export class ContextMenu {
|
|
|
151
151
|
let li = document.createElement("li");
|
|
152
152
|
if (item.title !== '-') {
|
|
153
153
|
let icon_span = document.createElement("span");
|
|
154
|
-
icon_span.className = '
|
|
154
|
+
icon_span.className = 'context_menu_icon_span';
|
|
155
155
|
if ((item.icon ?? '') != '') {
|
|
156
156
|
icon_span.innerHTML = item.icon;
|
|
157
157
|
}
|
|
@@ -159,10 +159,10 @@ export class ContextMenu {
|
|
|
159
159
|
icon_span.innerHTML = this.options?.defaultIcon ?? '';
|
|
160
160
|
}
|
|
161
161
|
let text_span = document.createElement("span");
|
|
162
|
-
text_span.className = '
|
|
162
|
+
text_span.className = 'context_menu_text';
|
|
163
163
|
text_span.innerHTML = item.title;
|
|
164
164
|
let sub_span = document.createElement("span");
|
|
165
|
-
sub_span.className = '
|
|
165
|
+
sub_span.className = 'context_menu_sub_span';
|
|
166
166
|
if (item.children != null) {
|
|
167
167
|
sub_span.innerHTML = this.options?.subIcon ?? '›';
|
|
168
168
|
}
|
|
@@ -195,7 +195,7 @@ export class ContextMenu {
|
|
|
195
195
|
}
|
|
196
196
|
else {
|
|
197
197
|
if (!lastWasDivider) {
|
|
198
|
-
li.className = "
|
|
198
|
+
li.className = "context_menu_divider";
|
|
199
199
|
lastWasDivider = true;
|
|
200
200
|
ul_outer.appendChild(li);
|
|
201
201
|
}
|
|
@@ -227,18 +227,18 @@ export class ContextMenu {
|
|
|
227
227
|
}
|
|
228
228
|
let sizes = ContextUtil.getSizes(menu);
|
|
229
229
|
if ((windowWidth - clickCoordsX) < sizes.width) {
|
|
230
|
-
menu.classList.add("
|
|
230
|
+
menu.classList.add("context_menu_border_right");
|
|
231
231
|
}
|
|
232
232
|
else {
|
|
233
|
-
menu.classList.remove("
|
|
233
|
+
menu.classList.remove("context_menu_border_right");
|
|
234
234
|
}
|
|
235
235
|
if ((windowHeight - clickCoordsY) < sizes.height) {
|
|
236
|
-
menu.classList.add("
|
|
236
|
+
menu.classList.add("context_menu_border_bottom");
|
|
237
237
|
}
|
|
238
238
|
else {
|
|
239
|
-
menu.classList.remove("
|
|
239
|
+
menu.classList.remove("context_menu_border_bottom");
|
|
240
240
|
}
|
|
241
|
-
menu.classList.add("
|
|
241
|
+
menu.classList.add("context_menu_display");
|
|
242
242
|
event.preventDefault();
|
|
243
243
|
window.addEventListener("keyup", this._windowKeyUpBound);
|
|
244
244
|
window.addEventListener("mousedown", this._windowDownBound);
|
|
@@ -7,6 +7,7 @@ import { ExtensionType } from '../widgets/designerView/extensions/ExtensionType.
|
|
|
7
7
|
import { IDesignerExtension } from '../widgets/designerView/extensions/IDesignerExtension.js';
|
|
8
8
|
import { ISize } from '../../interfaces/ISize.js';
|
|
9
9
|
import { IDesignerExtensionProvider } from '../widgets/designerView/extensions/IDesignerExtensionProvider.js';
|
|
10
|
+
import { IStyleRule } from '../services/stylesheetService/IStylesheetService.js';
|
|
10
11
|
export declare class DesignItem implements IDesignItem {
|
|
11
12
|
lastContainerSize: ISize;
|
|
12
13
|
parsedNode: any;
|
|
@@ -72,8 +73,10 @@ export declare class DesignItem implements IDesignItem {
|
|
|
72
73
|
getOrCreateDesignItem(node: Node): IDesignItem;
|
|
73
74
|
static GetOrCreateDesignItem(node: Node, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer): IDesignItem;
|
|
74
75
|
static GetDesignItem(node: Node): IDesignItem;
|
|
75
|
-
setStyle(name: string, value?: string | null): void;
|
|
76
|
+
setStyle(name: string, value?: string | null, important?: boolean): void;
|
|
76
77
|
removeStyle(name: string): void;
|
|
78
|
+
updateStyleInSheetOrLocal(name: string, value?: string | null, important?: boolean): void;
|
|
79
|
+
getAllStyles(): IStyleRule[];
|
|
77
80
|
setAttribute(name: string, value?: string | null): void;
|
|
78
81
|
removeAttribute(name: string): void;
|
|
79
82
|
_insertChildInternal(designItem: IDesignItem, index?: number): void;
|
|
@@ -292,7 +292,7 @@ export class DesignItem {
|
|
|
292
292
|
let designItem = DesignItem._designItemMap.get(node);
|
|
293
293
|
return designItem;
|
|
294
294
|
}
|
|
295
|
-
setStyle(name, value) {
|
|
295
|
+
setStyle(name, value, important) {
|
|
296
296
|
let nm = PropertiesHelper.camelToDashCase(name);
|
|
297
297
|
const action = new CssStyleChangeAction(this, nm, value, this._styles.get(nm));
|
|
298
298
|
this.instanceServiceContainer.undoService.execute(action);
|
|
@@ -302,6 +302,33 @@ export class DesignItem {
|
|
|
302
302
|
const action = new CssStyleChangeAction(this, nm, '', this._styles.get(nm));
|
|
303
303
|
this.instanceServiceContainer.undoService.execute(action);
|
|
304
304
|
}
|
|
305
|
+
updateStyleInSheetOrLocal(name, value, important) {
|
|
306
|
+
let nm = PropertiesHelper.camelToDashCase(name);
|
|
307
|
+
const declaration = null;
|
|
308
|
+
//const declaration = this.serviceContainer.stylesheetService?.getDeclarations(d, property);
|
|
309
|
+
//const rules = this.serviceContainer.stylesheetService?.getAppliedRules(d, property);
|
|
310
|
+
if (!declaration) {
|
|
311
|
+
if (this.getStyle(nm) != value) {
|
|
312
|
+
this.setStyle(nm, value);
|
|
313
|
+
}
|
|
314
|
+
else if (value == null) {
|
|
315
|
+
this.removeStyle(nm);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
//todo -> modify stylesheet, or local css
|
|
319
|
+
//we need undo for modification of stylesheet, look how we do this
|
|
320
|
+
//maybe undo in stylsheet service?
|
|
321
|
+
}
|
|
322
|
+
getAllStyles() {
|
|
323
|
+
const localStyles = [...this._styles.entries()].map(x => ({ name: x[0], value: x[1], important: false }));
|
|
324
|
+
if (this.instanceServiceContainer.stylesheetService) {
|
|
325
|
+
const rules = this.instanceServiceContainer.stylesheetService?.getAppliedRules(this);
|
|
326
|
+
if (rules) {
|
|
327
|
+
return [{ selector: null, declarations: localStyles, specificity: -1 }, ...rules];
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return [{ selector: null, declarations: localStyles, specificity: -1 }];
|
|
331
|
+
}
|
|
305
332
|
setAttribute(name, value) {
|
|
306
333
|
const action = new AttributeChangeAction(this, name, value, this._attributes.get(name));
|
|
307
334
|
this.instanceServiceContainer.undoService.execute(action);
|
|
@@ -6,6 +6,7 @@ import { ExtensionType } from '../widgets/designerView/extensions/ExtensionType.
|
|
|
6
6
|
import { IDesignerExtension } from '../widgets/designerView/extensions/IDesignerExtension.js';
|
|
7
7
|
import { ISize } from "../../interfaces/ISize.js";
|
|
8
8
|
import { IDesignerExtensionProvider } from '../widgets/designerView/extensions/IDesignerExtensionProvider.js';
|
|
9
|
+
import { IStyleRule } from '../services/stylesheetService/IStylesheetService.js';
|
|
9
10
|
export interface IDesignItem {
|
|
10
11
|
lastContainerSize: ISize;
|
|
11
12
|
replaceNode(newNode: Node): any;
|
|
@@ -51,8 +52,10 @@ export interface IDesignItem {
|
|
|
51
52
|
styles(): Iterable<[name: string, value: string]>;
|
|
52
53
|
getStyle(name: string): any;
|
|
53
54
|
hasStyle(name: string): any;
|
|
54
|
-
setStyle(name: string, value?: string | null): any;
|
|
55
|
+
setStyle(name: string, value?: string | null, important?: boolean): any;
|
|
55
56
|
removeStyle(name: string): any;
|
|
57
|
+
updateStyleInSheetOrLocal(name: string, value?: string | null, important?: boolean): any;
|
|
58
|
+
getAllStyles(): IStyleRule[];
|
|
56
59
|
attributes(): Iterable<[name: string, value: string]>;
|
|
57
60
|
getAttribute(name: string): any;
|
|
58
61
|
hasAttribute(name: string): any;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
1
2
|
import { IService } from './IService.js';
|
|
2
3
|
export declare class BaseServiceContainer<NameMap> {
|
|
3
4
|
protected _services: Map<string, IService[]>;
|
|
5
|
+
servicesChanged: TypedEvent<{
|
|
6
|
+
serviceName: keyof NameMap;
|
|
7
|
+
}>;
|
|
4
8
|
getLastService<K extends keyof NameMap>(service: K): NameMap[K];
|
|
5
9
|
getServices<K extends keyof NameMap>(service: K): NameMap[K][];
|
|
6
10
|
register<K extends keyof NameMap>(name: K, service: NameMap[K]): void;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
1
2
|
export class BaseServiceContainer {
|
|
2
3
|
_services = new Map();
|
|
4
|
+
servicesChanged = new TypedEvent();
|
|
3
5
|
getLastService(service) {
|
|
4
6
|
let list = this._services.get(service);
|
|
5
7
|
if (list && list.length)
|
|
@@ -13,12 +15,14 @@ export class BaseServiceContainer {
|
|
|
13
15
|
if (!this._services.has(name))
|
|
14
16
|
this._services.set(name, []);
|
|
15
17
|
this._services.get(name).push(service);
|
|
18
|
+
this.servicesChanged.emit({ serviceName: name });
|
|
16
19
|
}
|
|
17
20
|
registerMultiple(names, service) {
|
|
18
21
|
for (const name of names) {
|
|
19
22
|
if (!this._services.has(name))
|
|
20
23
|
this._services.set(name, []);
|
|
21
24
|
this._services.get(name).push(service);
|
|
25
|
+
this.servicesChanged.emit({ serviceName: name });
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
forSomeServicesTillResult(service, callback) {
|
|
@@ -67,11 +67,14 @@ import { GrayOutDragOverContainerExtensionProvider } from '../widgets/designerVi
|
|
|
67
67
|
import { LineExtensionProvider } from '../widgets/designerView/extensions/svg/LineExtensionProvider.js';
|
|
68
68
|
import { RectExtentionProvider } from '../widgets/designerView/extensions/svg/RectExtensionProvider.js';
|
|
69
69
|
import { EllipsisExtensionProvider } from '../widgets/designerView/extensions/svg/EllipsisExtensionProvider.js';
|
|
70
|
-
import {
|
|
70
|
+
import { PropertyTabsService } from './propertiesService/PropertyTabsService.js';
|
|
71
71
|
import { PlacementExtensionProvider } from '../widgets/designerView/extensions/PlacementExtensionProvider.js';
|
|
72
72
|
import { FlexboxExtensionProvider } from '../widgets/designerView/extensions/FlexboxExtensionProvider.js';
|
|
73
73
|
import { FlexboxExtensionDesignViewConfigButtons } from '../widgets/designerView/extensions/FlexboxExtensionDesignViewConfigButtons.js';
|
|
74
74
|
import { InvisibleElementExtensionDesignViewConfigButtons } from '../widgets/designerView/extensions/InvisibleElementExtensionDesignViewConfigButtons.js';
|
|
75
|
+
import { UndoService } from './undoService/UndoService.js';
|
|
76
|
+
import { SelectionService } from './selectionService/SelectionService.js';
|
|
77
|
+
import { ContentService } from './contentService/ContentService.js';
|
|
75
78
|
export function createDefaultServiceContainer() {
|
|
76
79
|
let serviceContainer = new ServiceContainer();
|
|
77
80
|
serviceContainer.register("propertyService", new PolymerPropertiesService());
|
|
@@ -80,7 +83,7 @@ export function createDefaultServiceContainer() {
|
|
|
80
83
|
serviceContainer.register("propertyService", new SVGElementsPropertiesService());
|
|
81
84
|
serviceContainer.register("propertyService", new Lit2PropertiesService());
|
|
82
85
|
serviceContainer.register("propertyService", new BaseCustomWebComponentPropertiesService());
|
|
83
|
-
serviceContainer.register("propertyGroupsService", new
|
|
86
|
+
serviceContainer.register("propertyGroupsService", new PropertyTabsService());
|
|
84
87
|
serviceContainer.register("instanceService", new DefaultInstanceService());
|
|
85
88
|
serviceContainer.register("editorTypesService", new DefaultEditorTypesService());
|
|
86
89
|
serviceContainer.register("htmlWriterService", new HtmlWriterService());
|
|
@@ -94,6 +97,10 @@ export function createDefaultServiceContainer() {
|
|
|
94
97
|
serviceContainer.register("copyPasteService", new CopyPasteService());
|
|
95
98
|
serviceContainer.register("modelCommandService", new DefaultModelCommandService());
|
|
96
99
|
serviceContainer.register("demoProviderService", new DemoProviderService());
|
|
100
|
+
serviceContainer.register("undoService", (designerCanvas) => new UndoService(designerCanvas));
|
|
101
|
+
serviceContainer.register("selectionService", (designerCanvas) => new SelectionService(designerCanvas));
|
|
102
|
+
serviceContainer.register("contentService", (designerCanvas) => new ContentService(designerCanvas.rootDesignItem));
|
|
103
|
+
//serviceContainer.register("stylesheetService", new DemoProviderService());
|
|
97
104
|
serviceContainer.designerExtensions.set(ExtensionType.Permanent, [
|
|
98
105
|
// new ResizeExtensionProvider(false),
|
|
99
106
|
new InvisibleElementExtensionProvider(),
|
|
@@ -4,10 +4,12 @@ import { BaseServiceContainer } from './BaseServiceContainer.js';
|
|
|
4
4
|
import { IContentService } from './contentService/IContentService.js';
|
|
5
5
|
import { IDesignContext } from '../widgets/designerView/IDesignContext.js';
|
|
6
6
|
import { IDesignerCanvas } from '../widgets/designerView/IDesignerCanvas.js';
|
|
7
|
+
import { IStylesheetService } from './stylesheetService/IStylesheetService.js';
|
|
7
8
|
interface InstanceServiceNameMap {
|
|
8
9
|
"undoService": IUndoService;
|
|
9
10
|
"selectionService": ISelectionService;
|
|
10
11
|
"contentService": IContentService;
|
|
12
|
+
"stylesheetService": IStylesheetService;
|
|
11
13
|
}
|
|
12
14
|
export declare class InstanceServiceContainer extends BaseServiceContainer<InstanceServiceNameMap> {
|
|
13
15
|
designContext: IDesignContext;
|
|
@@ -17,5 +19,6 @@ export declare class InstanceServiceContainer extends BaseServiceContainer<Insta
|
|
|
17
19
|
get undoService(): IUndoService;
|
|
18
20
|
get selectionService(): ISelectionService;
|
|
19
21
|
get contentService(): IContentService;
|
|
22
|
+
get stylesheetService(): IStylesheetService;
|
|
20
23
|
}
|
|
21
24
|
export {};
|
|
@@ -32,7 +32,12 @@ import { IProperty } from "./propertiesService/IProperty.js";
|
|
|
32
32
|
import { IDesignItem } from "../item/IDesignItem.js";
|
|
33
33
|
import { IBinding } from '../item/IBinding.js';
|
|
34
34
|
import { BindingTarget } from '../item/BindingTarget.js';
|
|
35
|
-
import {
|
|
35
|
+
import { IPropertyTabsService } from './propertiesService/IPropertyTabsService.js';
|
|
36
|
+
import { IUndoService } from './undoService/IUndoService.js';
|
|
37
|
+
import { ISelectionService } from './selectionService/ISelectionService.js';
|
|
38
|
+
import { IContentService } from './contentService/IContentService.js';
|
|
39
|
+
import { IStylesheetService } from './stylesheetService/IStylesheetService.js';
|
|
40
|
+
import { IDesignerCanvas } from '../widgets/designerView/IDesignerCanvas.js';
|
|
36
41
|
interface ServiceNameMap {
|
|
37
42
|
"propertyService": IPropertiesService;
|
|
38
43
|
"containerService": IPlacementService;
|
|
@@ -52,7 +57,11 @@ interface ServiceNameMap {
|
|
|
52
57
|
"modelCommandService": IModelCommandService;
|
|
53
58
|
"demoProviderService": IDemoProviderService;
|
|
54
59
|
"elementInteractionService": IElementInteractionService;
|
|
55
|
-
"propertyGroupsService":
|
|
60
|
+
"propertyGroupsService": IPropertyTabsService;
|
|
61
|
+
"undoService": (designerCanvas: IDesignerCanvas) => IUndoService;
|
|
62
|
+
"selectionService": (designerCanvas: IDesignerCanvas) => ISelectionService;
|
|
63
|
+
"contentService": (designerCanvas: IDesignerCanvas) => IContentService;
|
|
64
|
+
"stylesheetService": (designerCanvas: IDesignerCanvas) => IStylesheetService;
|
|
56
65
|
}
|
|
57
66
|
export declare class ServiceContainer extends BaseServiceContainer<ServiceNameMap> {
|
|
58
67
|
readonly config: {
|
|
@@ -76,7 +85,7 @@ export declare class ServiceContainer extends BaseServiceContainer<ServiceNameMa
|
|
|
76
85
|
get bindableObjectDragDropService(): IBindableObjectDragDropService;
|
|
77
86
|
get elementInteractionServices(): IElementInteractionService[];
|
|
78
87
|
get propertiesServices(): IPropertiesService[];
|
|
79
|
-
get propertyGroupService():
|
|
88
|
+
get propertyGroupService(): IPropertyTabsService;
|
|
80
89
|
get containerServices(): IPlacementService[];
|
|
81
90
|
get snaplinesProviderService(): ISnaplinesProviderService;
|
|
82
91
|
get elementsServices(): IElementsService[];
|
|
@@ -66,18 +66,6 @@ export class DefaultInstanceService {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
let designItem = DesignItem.createDesignItemFromInstance(element, serviceContainer, instanceServiceContainer);
|
|
69
|
-
if (definition.defaultProperties) {
|
|
70
|
-
let propertiesService = null;
|
|
71
|
-
if (definition.type) {
|
|
72
|
-
propertiesService = serviceContainer.getLastServiceWhere('propertyService', (x) => x.isHandledElement(designItem));
|
|
73
|
-
}
|
|
74
|
-
let properties = propertiesService.getProperties(designItem);
|
|
75
|
-
for (let a in definition.defaultProperties) {
|
|
76
|
-
let value = definition.defaultProperties[a];
|
|
77
|
-
let p = properties.find(x => x.name == a);
|
|
78
|
-
propertiesService.setValue([designItem], p, value);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
69
|
return designItem;
|
|
82
70
|
}
|
|
83
71
|
}
|
|
@@ -4,6 +4,7 @@ import { IDesignItem } from '../../item/IDesignItem.js';
|
|
|
4
4
|
import { ValueType } from './ValueType.js';
|
|
5
5
|
import { BindingTarget } from '../../item/BindingTarget.js';
|
|
6
6
|
import { IBinding } from '../../item/IBinding.js';
|
|
7
|
+
import { IPropertyGroup } from './IPropertyGroup.js';
|
|
7
8
|
export declare enum RefreshMode {
|
|
8
9
|
none = 0,
|
|
9
10
|
full = 1,
|
|
@@ -12,7 +13,7 @@ export declare enum RefreshMode {
|
|
|
12
13
|
export interface IPropertiesService extends IService {
|
|
13
14
|
getRefreshMode(designItem: IDesignItem): RefreshMode;
|
|
14
15
|
isHandledElement(designItem: IDesignItem): boolean;
|
|
15
|
-
getProperties(designItem: IDesignItem): IProperty[];
|
|
16
|
+
getProperties(designItem: IDesignItem): IProperty[] | IPropertyGroup[];
|
|
16
17
|
getProperty(designItem: IDesignItem, name: string): IProperty;
|
|
17
18
|
getBinding(designItems: IDesignItem[], property: IProperty): IBinding;
|
|
18
19
|
getPropertyTarget(designItem: IDesignItem, property: IProperty): BindingTarget;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IPropertiesService } from './IPropertiesService.js';
|
|
2
|
+
import { IPropertyEditor } from './IPropertyEditor.js';
|
|
3
|
+
import { PropertyType } from './PropertyType.js';
|
|
4
|
+
export interface IProperty {
|
|
5
|
+
name: string;
|
|
6
|
+
renamable?: boolean;
|
|
7
|
+
propertyName?: string;
|
|
8
|
+
attributeName?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
type?: 'addNew' | 'json' | 'color' | 'date' | 'number' | 'list' | 'enum' | 'boolean' | 'img-lis' | 'thickness' | 'css-length' | 'string' | string;
|
|
11
|
+
default?: any;
|
|
12
|
+
min?: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
step?: number;
|
|
15
|
+
values?: string[];
|
|
16
|
+
enumValues?: [name: string, value: string | number][];
|
|
17
|
+
createEditor?: (property: IProperty) => IPropertyEditor;
|
|
18
|
+
value?: any;
|
|
19
|
+
service: IPropertiesService;
|
|
20
|
+
defaultValue?: any;
|
|
21
|
+
propertyType: PropertyType;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IDesignItem } from '../../item/IDesignItem.js';
|
|
2
|
+
import { IPropertiesService } from './IPropertiesService.js';
|
|
3
|
+
export interface IPropertyTabsService {
|
|
4
|
+
getPropertygroups(designItems: IDesignItem[]): {
|
|
5
|
+
name: string;
|
|
6
|
+
propertiesService: IPropertiesService;
|
|
7
|
+
}[];
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 { IPropertyTabsService } from './IPropertyTabsService.js';
|
|
4
|
+
export declare class PropertyGroupsService implements IPropertyTabsService {
|
|
5
5
|
protected _pgList: {
|
|
6
6
|
name: string;
|
|
7
7
|
propertiesService: IPropertiesService;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IDesignItem } from '../../item/IDesignItem.js';
|
|
2
|
+
import { IPropertiesService } from './IPropertiesService.js';
|
|
3
|
+
import { IPropertyTabsService } from './IPropertyTabsService.js';
|
|
4
|
+
export declare class PropertyTabsService implements IPropertyTabsService {
|
|
5
|
+
protected _pgList: {
|
|
6
|
+
name: string;
|
|
7
|
+
propertiesService: IPropertiesService;
|
|
8
|
+
}[];
|
|
9
|
+
protected _svgPgList: {
|
|
10
|
+
name: string;
|
|
11
|
+
propertiesService: IPropertiesService;
|
|
12
|
+
}[];
|
|
13
|
+
getPropertygroups(designItems: IDesignItem[]): {
|
|
14
|
+
name: string;
|
|
15
|
+
propertiesService: IPropertiesService;
|
|
16
|
+
}[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AttributesPropertiesService } from './services/AttributesPropertiesService.js';
|
|
2
|
+
import { CommonPropertiesService } from './services/CommonPropertiesService.js';
|
|
3
|
+
import { CssPropertiesService } from './services/CssPropertiesService.js';
|
|
4
|
+
export class PropertyTabsService {
|
|
5
|
+
_pgList = [
|
|
6
|
+
{ name: 'properties', propertiesService: null },
|
|
7
|
+
{ name: 'attributes', propertiesService: new AttributesPropertiesService() },
|
|
8
|
+
{ name: 'common', propertiesService: new CommonPropertiesService() },
|
|
9
|
+
{ name: 'styles', propertiesService: new CssPropertiesService("styles") },
|
|
10
|
+
{ name: 'layout', propertiesService: new CssPropertiesService("layout") },
|
|
11
|
+
{ name: 'flex', propertiesService: new CssPropertiesService("flex") },
|
|
12
|
+
{ name: 'grid', propertiesService: new CssPropertiesService("grid") },
|
|
13
|
+
];
|
|
14
|
+
_svgPgList = [
|
|
15
|
+
{ name: 'properties', propertiesService: null },
|
|
16
|
+
{ name: 'attributes', propertiesService: new AttributesPropertiesService() },
|
|
17
|
+
{ name: 'styles', propertiesService: new CssPropertiesService("styles") },
|
|
18
|
+
{ name: 'layout', propertiesService: new CssPropertiesService("layout") },
|
|
19
|
+
];
|
|
20
|
+
getPropertygroups(designItems) {
|
|
21
|
+
if (designItems == null || designItems.length == 0)
|
|
22
|
+
return [];
|
|
23
|
+
this._pgList[0].propertiesService = designItems[0].serviceContainer.getLastServiceWhere('propertyService', x => x.isHandledElement(designItems[0]));
|
|
24
|
+
this._svgPgList[0].propertiesService = designItems[0].serviceContainer.getLastServiceWhere('propertyService', x => x.isHandledElement(designItems[0]));
|
|
25
|
+
if (designItems[0].element instanceof SVGElement)
|
|
26
|
+
return this._svgPgList;
|
|
27
|
+
return this._pgList;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -4,12 +4,13 @@ import { IDesignItem } from '../../../item/IDesignItem.js';
|
|
|
4
4
|
import { ValueType } from '../ValueType.js';
|
|
5
5
|
import { BindingTarget } from '../../../item/BindingTarget.js';
|
|
6
6
|
import { IBinding } from '../../../item/IBinding.js';
|
|
7
|
+
import { IPropertyGroup } from '../IPropertyGroup.js';
|
|
7
8
|
export declare abstract class AbstractPropertiesService implements IPropertiesService {
|
|
8
9
|
abstract getRefreshMode(designItem: IDesignItem): RefreshMode;
|
|
9
10
|
abstract isHandledElement(designItem: IDesignItem): boolean;
|
|
10
11
|
protected _notifyChangedProperty(designItem: IDesignItem, property: IProperty, value: any): void;
|
|
11
12
|
getProperty(designItem: IDesignItem, name: string): IProperty;
|
|
12
|
-
abstract getProperties(designItem: IDesignItem): IProperty[];
|
|
13
|
+
abstract getProperties(designItem: IDesignItem): IProperty[] | IPropertyGroup[];
|
|
13
14
|
setValue(designItems: IDesignItem[], property: IProperty, value: any): void;
|
|
14
15
|
getPropertyTarget(designItem: IDesignItem, property: IProperty): BindingTarget;
|
|
15
16
|
clearValue(designItems: IDesignItem[], property: IProperty): void;
|
|
@@ -7,18 +7,18 @@ export class AbstractPropertiesService {
|
|
|
7
7
|
_notifyChangedProperty(designItem, property, value) {
|
|
8
8
|
}
|
|
9
9
|
getProperty(designItem, name) {
|
|
10
|
-
|
|
10
|
+
let properties = this.getProperties(designItem);
|
|
11
|
+
if ('properties' in properties[0]) {
|
|
12
|
+
return properties.flatMap(x => x.properties).find(x => x.name == name);
|
|
13
|
+
}
|
|
14
|
+
else
|
|
15
|
+
return properties.find(x => x.name == name);
|
|
11
16
|
}
|
|
12
17
|
setValue(designItems, property, value) {
|
|
13
18
|
const cg = designItems[0].openGroup("properties changed");
|
|
14
19
|
for (let d of designItems) {
|
|
15
20
|
if (property.propertyType == PropertyType.cssValue) {
|
|
16
|
-
|
|
17
|
-
d.setStyle(property.name, value);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
this.clearValue(designItems, property);
|
|
21
|
-
}
|
|
21
|
+
d.updateStyleInSheetOrLocal(property.name, value);
|
|
22
22
|
//unkown css property names do not trigger the mutation observer of property grid,
|
|
23
23
|
//fixed by assinging stle again to the attribute
|
|
24
24
|
d.element.setAttribute('style', d.element.getAttribute('style'));
|
|
@@ -2,11 +2,12 @@ import { IProperty } from '../IProperty.js';
|
|
|
2
2
|
import { IDesignItem } from '../../../item/IDesignItem.js';
|
|
3
3
|
import { AbstractPropertiesService } from './AbstractPropertiesService.js';
|
|
4
4
|
import { RefreshMode } from '../IPropertiesService.js';
|
|
5
|
+
import { IPropertyGroup } from '../IPropertyGroup.js';
|
|
5
6
|
export declare class CommonPropertiesService extends AbstractPropertiesService {
|
|
6
7
|
getRefreshMode(designItem: IDesignItem): RefreshMode;
|
|
7
8
|
private commonProperties;
|
|
8
9
|
name: string;
|
|
9
10
|
isHandledElement(designItem: IDesignItem): boolean;
|
|
10
11
|
getProperty(designItem: IDesignItem, name: string): IProperty;
|
|
11
|
-
getProperties(designItem: IDesignItem): IProperty[];
|
|
12
|
+
getProperties(designItem: IDesignItem): IProperty[] | IPropertyGroup[];
|
|
12
13
|
}
|