@node-projects/web-component-designer 0.0.211 → 0.0.213
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 +1 -0
- package/dist/elements/documentContainer.js +6 -11
- package/dist/elements/item/DesignItem.d.ts +3 -3
- package/dist/elements/item/DesignItem.js +69 -49
- package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService.js +1 -3
- package/dist/elements/services/stylesheetService/AbstractStylesheetService.d.ts +6 -1
- package/dist/elements/services/stylesheetService/AbstractStylesheetService.js +21 -5
- package/dist/elements/services/stylesheetService/CssToolsStylesheetService.d.ts +3 -1
- package/dist/elements/services/stylesheetService/CssToolsStylesheetService.js +9 -4
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService.d.ts +5 -2
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService.js +14 -6
- package/dist/elements/services/stylesheetService/IStylesheetService.d.ts +4 -4
- package/dist/elements/services/undoService/transactionItems/InsertChildAction.js +7 -4
- package/dist/elements/services/undoService/transactionItems/StylesheetStyleChangeAction.js +2 -2
- package/dist/elements/widgets/designerView/IDesignerCanvas.d.ts +1 -0
- package/dist/elements/widgets/designerView/designerCanvas.d.ts +4 -0
- package/dist/elements/widgets/designerView/designerCanvas.js +34 -21
- package/dist/elements/widgets/propertyGrid/PropertyGridWithHeader.js +2 -2
- package/dist/elements/widgets/treeView/treeViewExtended.js +1 -1
- package/package.json +6 -6
|
@@ -15,6 +15,7 @@ export declare class DocumentContainer extends BaseCustomWebComponentLazyAppend
|
|
|
15
15
|
demoView: IDemoView & HTMLElement;
|
|
16
16
|
additionalData: any;
|
|
17
17
|
private _firstLoad;
|
|
18
|
+
private _stylesheetChangedEventRegistered;
|
|
18
19
|
private _additionalStyle;
|
|
19
20
|
set additionalStyleString(style: string);
|
|
20
21
|
get additionalStyleString(): string;
|
|
@@ -8,6 +8,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
8
8
|
demoView;
|
|
9
9
|
additionalData;
|
|
10
10
|
_firstLoad = true;
|
|
11
|
+
_stylesheetChangedEventRegistered;
|
|
11
12
|
_additionalStyle;
|
|
12
13
|
set additionalStyleString(style) {
|
|
13
14
|
this._additionalStyle = style;
|
|
@@ -21,19 +22,12 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
21
22
|
_additionalStylesheets;
|
|
22
23
|
set additionalStylesheets(stylesheets) {
|
|
23
24
|
this._additionalStylesheets = stylesheets;
|
|
24
|
-
if (!this.instanceServiceContainer.stylesheetService) {
|
|
25
|
-
const stylesheetService = this.designerView.serviceContainer.getLastService('stylesheetService');
|
|
26
|
-
if (stylesheetService) {
|
|
27
|
-
const instance = stylesheetService(this.designerView.designerCanvas);
|
|
28
|
-
this.instanceServiceContainer.register("stylesheetService", instance);
|
|
29
|
-
instance.stylesheetChanged.on(e => this.additionalStylesheetChanged.emit({ name: e.name, newStyle: e.newStyle, oldStyle: e.oldStyle, changeSource: e.changeSource }));
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
console.warn("no Stylesheet-Service registered, but additionalStylesheets are used.");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
25
|
if (this.designerView.instanceServiceContainer.stylesheetService)
|
|
36
26
|
this.designerView.instanceServiceContainer.stylesheetService.setStylesheets(stylesheets);
|
|
27
|
+
if (!this._stylesheetChangedEventRegistered) {
|
|
28
|
+
this._stylesheetChangedEventRegistered = true;
|
|
29
|
+
this.designerView.instanceServiceContainer.stylesheetService.stylesheetChanged.on(e => this.additionalStylesheetChanged.emit({ name: e.name, newStyle: e.newStyle, oldStyle: e.oldStyle, changeSource: e.changeSource }));
|
|
30
|
+
}
|
|
37
31
|
}
|
|
38
32
|
;
|
|
39
33
|
get additionalStylesheets() {
|
|
@@ -150,6 +144,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
150
144
|
}
|
|
151
145
|
dispose() {
|
|
152
146
|
this.codeView.dispose();
|
|
147
|
+
this.demoView.dispose();
|
|
153
148
|
}
|
|
154
149
|
executeCommand(command) {
|
|
155
150
|
if (this._tabControl.selectedIndex === 0 || this._tabControl.selectedIndex === 2)
|
|
@@ -27,6 +27,7 @@ export declare class DesignItem implements IDesignItem {
|
|
|
27
27
|
attributes(): Generator<[string, string], void, unknown>;
|
|
28
28
|
_withoutUndoSetAttribute(name: string, value: string): void;
|
|
29
29
|
_withoutUndoRemoveAttribute(name: string): void;
|
|
30
|
+
_reparseSpecialAttributes(name: string): void;
|
|
30
31
|
private _styles;
|
|
31
32
|
get hasStyles(): boolean;
|
|
32
33
|
hasStyle(name: string): boolean;
|
|
@@ -45,6 +46,7 @@ export declare class DesignItem implements IDesignItem {
|
|
|
45
46
|
children(): IterableIterator<IDesignItem>;
|
|
46
47
|
get childCount(): number;
|
|
47
48
|
get firstChild(): IDesignItem;
|
|
49
|
+
private _parent;
|
|
48
50
|
get parent(): IDesignItem;
|
|
49
51
|
indexOf(designItem: IDesignItem): number;
|
|
50
52
|
insertAdjacentElement(designItem: IDesignItem, where: InsertPosition): void;
|
|
@@ -58,13 +60,10 @@ export declare class DesignItem implements IDesignItem {
|
|
|
58
60
|
get innerHTML(): string;
|
|
59
61
|
set innerHTML(value: string);
|
|
60
62
|
get isEmptyTextNode(): boolean;
|
|
61
|
-
private _hideAtDesignTime;
|
|
62
63
|
get hideAtDesignTime(): boolean;
|
|
63
64
|
set hideAtDesignTime(value: boolean);
|
|
64
|
-
private _hideAtRunTime;
|
|
65
65
|
get hideAtRunTime(): boolean;
|
|
66
66
|
set hideAtRunTime(value: boolean);
|
|
67
|
-
private _lockAtDesignTime;
|
|
68
67
|
get lockAtDesignTime(): boolean;
|
|
69
68
|
set lockAtDesignTime(value: boolean);
|
|
70
69
|
static createDesignItemFromInstance(node: Node, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer): DesignItem;
|
|
@@ -85,4 +84,5 @@ export declare class DesignItem implements IDesignItem {
|
|
|
85
84
|
removeAttribute(name: string): void;
|
|
86
85
|
_insertChildInternal(designItem: IDesignItem, index?: number): void;
|
|
87
86
|
_removeChildInternal(designItem: IDesignItem): void;
|
|
87
|
+
_refreshIfStyleSheet(): void;
|
|
88
88
|
}
|
|
@@ -8,7 +8,8 @@ import { InsertChildAction } from '../services/undoService/transactionItems/Inse
|
|
|
8
8
|
import { DomConverter } from '../widgets/designerView/DomConverter.js';
|
|
9
9
|
import { DeleteAction } from '../services/undoService/transactionItems/DeleteAction.js';
|
|
10
10
|
import { enableStylesheetService } from '../widgets/designerView/extensions/buttons/StylesheetServiceDesignViewConfigButtons.js';
|
|
11
|
-
import {
|
|
11
|
+
import { AbstractStylesheetService } from '../services/stylesheetService/AbstractStylesheetService.js';
|
|
12
|
+
import { cssFromString } from '@node-projects/base-custom-webcomponent';
|
|
12
13
|
const hideAtDesignTimeAttributeName = 'node-projects-hide-at-design-time';
|
|
13
14
|
const hideAtRunTimeAttributeName = 'node-projects-hide-at-run-time';
|
|
14
15
|
const lockAtDesignTimeAttributeName = 'node-projects-lock-at-design-time';
|
|
@@ -70,9 +71,37 @@ export class DesignItem {
|
|
|
70
71
|
}
|
|
71
72
|
_withoutUndoSetAttribute(name, value) {
|
|
72
73
|
this._attributes.set(name, value);
|
|
74
|
+
this._reparseSpecialAttributes(name);
|
|
73
75
|
}
|
|
74
76
|
_withoutUndoRemoveAttribute(name) {
|
|
75
77
|
this._attributes.delete(name);
|
|
78
|
+
this._reparseSpecialAttributes(name);
|
|
79
|
+
}
|
|
80
|
+
_reparseSpecialAttributes(name) {
|
|
81
|
+
if (name == hideAtDesignTimeAttributeName) {
|
|
82
|
+
if (this.element instanceof HTMLElement || this.element instanceof SVGElement) {
|
|
83
|
+
if (!this._attributes.has(hideAtDesignTimeAttributeName))
|
|
84
|
+
this.element.style.display = this._styles.get('display') ?? "";
|
|
85
|
+
else
|
|
86
|
+
this.element.style.display = 'none';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (name == hideAtRunTimeAttributeName) {
|
|
90
|
+
if (this.element instanceof HTMLElement || this.element instanceof SVGElement) {
|
|
91
|
+
if (!this._attributes.has(hideAtRunTimeAttributeName))
|
|
92
|
+
this.element.style.opacity = this._styles.get('opacity') ?? "";
|
|
93
|
+
else
|
|
94
|
+
this.element.style.opacity = '0.3';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (name == lockAtDesignTimeAttributeName) {
|
|
98
|
+
if (this.element instanceof HTMLElement || this.element instanceof SVGElement) {
|
|
99
|
+
if (!this._attributes.has(lockAtDesignTimeAttributeName))
|
|
100
|
+
this.element.style.pointerEvents = 'auto';
|
|
101
|
+
else
|
|
102
|
+
this.element.style.pointerEvents = 'none';
|
|
103
|
+
}
|
|
104
|
+
}
|
|
76
105
|
}
|
|
77
106
|
_styles;
|
|
78
107
|
get hasStyles() {
|
|
@@ -131,8 +160,9 @@ export class DesignItem {
|
|
|
131
160
|
get firstChild() {
|
|
132
161
|
return this._childArray[0];
|
|
133
162
|
}
|
|
163
|
+
_parent;
|
|
134
164
|
get parent() {
|
|
135
|
-
return this.
|
|
165
|
+
return this._parent;
|
|
136
166
|
}
|
|
137
167
|
indexOf(designItem) {
|
|
138
168
|
return this._childArray.indexOf(designItem);
|
|
@@ -176,10 +206,13 @@ export class DesignItem {
|
|
|
176
206
|
return this.nodeType == NodeType.TextNode || (this._childArray.length === 0 && this.content !== null);
|
|
177
207
|
}
|
|
178
208
|
get content() {
|
|
179
|
-
|
|
209
|
+
if (!this.hasChildren)
|
|
210
|
+
return this.node.textContent;
|
|
211
|
+
else
|
|
212
|
+
return this._childArray.map(x => x.content).join();
|
|
180
213
|
}
|
|
181
214
|
set content(value) {
|
|
182
|
-
const grp = this.openGroup('set
|
|
215
|
+
const grp = this.openGroup('set content');
|
|
183
216
|
this.clearChildren();
|
|
184
217
|
let t = document.createTextNode(value);
|
|
185
218
|
let di = DesignItem.GetOrCreateDesignItem(t, this.serviceContainer, this.instanceServiceContainer);
|
|
@@ -212,56 +245,32 @@ export class DesignItem {
|
|
|
212
245
|
get isEmptyTextNode() {
|
|
213
246
|
return this.nodeType === NodeType.TextNode && this.content?.trim() == '';
|
|
214
247
|
}
|
|
215
|
-
_hideAtDesignTime;
|
|
216
248
|
get hideAtDesignTime() {
|
|
217
|
-
return this.
|
|
249
|
+
return this.hasAttribute(hideAtDesignTimeAttributeName);
|
|
218
250
|
}
|
|
219
251
|
set hideAtDesignTime(value) {
|
|
220
|
-
this._hideAtDesignTime = value;
|
|
221
252
|
if (value)
|
|
222
|
-
this.
|
|
253
|
+
this.setAttribute(hideAtDesignTimeAttributeName, "");
|
|
223
254
|
else
|
|
224
|
-
this.
|
|
225
|
-
if (this.element instanceof HTMLElement || this.element instanceof SVGElement) {
|
|
226
|
-
if (!value)
|
|
227
|
-
this.element.style.display = this._styles.get('display') ?? "";
|
|
228
|
-
else
|
|
229
|
-
this.element.style.display = 'none';
|
|
230
|
-
}
|
|
255
|
+
this.removeAttribute(hideAtDesignTimeAttributeName);
|
|
231
256
|
}
|
|
232
|
-
_hideAtRunTime;
|
|
233
257
|
get hideAtRunTime() {
|
|
234
|
-
return this.
|
|
258
|
+
return this.hasAttribute(hideAtRunTimeAttributeName);
|
|
235
259
|
}
|
|
236
260
|
set hideAtRunTime(value) {
|
|
237
|
-
this._hideAtRunTime = value;
|
|
238
261
|
if (value)
|
|
239
|
-
this.
|
|
262
|
+
this.setAttribute(hideAtRunTimeAttributeName, "");
|
|
240
263
|
else
|
|
241
|
-
this.
|
|
242
|
-
if (this.element instanceof HTMLElement || this.element instanceof SVGElement) {
|
|
243
|
-
if (!value)
|
|
244
|
-
this.element.style.opacity = this._styles.get('opacity') ?? "";
|
|
245
|
-
else
|
|
246
|
-
this.element.style.opacity = '0.3';
|
|
247
|
-
}
|
|
264
|
+
this.removeAttribute(hideAtRunTimeAttributeName);
|
|
248
265
|
}
|
|
249
|
-
_lockAtDesignTime;
|
|
250
266
|
get lockAtDesignTime() {
|
|
251
|
-
return this.
|
|
267
|
+
return this.hasAttribute(lockAtDesignTimeAttributeName);
|
|
252
268
|
}
|
|
253
269
|
set lockAtDesignTime(value) {
|
|
254
|
-
this._lockAtDesignTime = value;
|
|
255
270
|
if (value)
|
|
256
|
-
this.
|
|
271
|
+
this.setAttribute(lockAtDesignTimeAttributeName, "");
|
|
257
272
|
else
|
|
258
|
-
this.
|
|
259
|
-
if (this.element instanceof HTMLElement || this.element instanceof SVGElement) {
|
|
260
|
-
if (!value)
|
|
261
|
-
this.element.style.pointerEvents = 'auto';
|
|
262
|
-
else
|
|
263
|
-
this.element.style.pointerEvents = 'none';
|
|
264
|
-
}
|
|
273
|
+
this.removeAttribute(lockAtDesignTimeAttributeName);
|
|
265
274
|
}
|
|
266
275
|
static createDesignItemFromInstance(node, serviceContainer, instanceServiceContainer) {
|
|
267
276
|
let designItem = new DesignItem(node, node, serviceContainer, instanceServiceContainer);
|
|
@@ -269,12 +278,6 @@ export class DesignItem {
|
|
|
269
278
|
for (let a of designItem.element.attributes) {
|
|
270
279
|
if (a.name !== 'style') {
|
|
271
280
|
designItem._attributes.set(a.name, a.value);
|
|
272
|
-
if (a.name === hideAtDesignTimeAttributeName)
|
|
273
|
-
designItem._hideAtDesignTime = true;
|
|
274
|
-
if (a.name === hideAtRunTimeAttributeName)
|
|
275
|
-
designItem._hideAtRunTime = true;
|
|
276
|
-
if (a.name === lockAtDesignTimeAttributeName)
|
|
277
|
-
designItem._lockAtDesignTime = true;
|
|
278
281
|
}
|
|
279
282
|
}
|
|
280
283
|
if (node instanceof HTMLElement || node instanceof SVGElement) {
|
|
@@ -286,12 +289,11 @@ export class DesignItem {
|
|
|
286
289
|
designItem._styles.set(e.name, e.value);
|
|
287
290
|
}
|
|
288
291
|
}
|
|
289
|
-
if (!designItem.
|
|
292
|
+
if (!designItem.lockAtDesignTime) {
|
|
290
293
|
requestAnimationFrame(() => node.style.pointerEvents = 'auto');
|
|
291
294
|
}
|
|
292
295
|
else
|
|
293
296
|
node.style.pointerEvents = 'none';
|
|
294
|
-
//node.style.cursor = 'pointer';
|
|
295
297
|
}
|
|
296
298
|
node.draggable = false; //even if it should be true, for better designer exp.
|
|
297
299
|
}
|
|
@@ -301,9 +303,13 @@ export class DesignItem {
|
|
|
301
303
|
updateChildrenFromNodesChildren() {
|
|
302
304
|
this._childArray = [];
|
|
303
305
|
if (this.nodeType == NodeType.Element) {
|
|
304
|
-
for (const c of this.element.childNodes)
|
|
305
|
-
|
|
306
|
+
for (const c of this.element.childNodes) {
|
|
307
|
+
const di = DesignItem.createDesignItemFromInstance(c, this.serviceContainer, this.instanceServiceContainer);
|
|
308
|
+
this._childArray.push(di);
|
|
309
|
+
di._parent = this;
|
|
310
|
+
}
|
|
306
311
|
}
|
|
312
|
+
this._refreshIfStyleSheet();
|
|
307
313
|
}
|
|
308
314
|
constructor(node, parsedNode, serviceContainer, instanceServiceContainer) {
|
|
309
315
|
this.node = node;
|
|
@@ -359,8 +365,7 @@ export class DesignItem {
|
|
|
359
365
|
}
|
|
360
366
|
}
|
|
361
367
|
else {
|
|
362
|
-
|
|
363
|
-
this.instanceServiceContainer.undoService.execute(action);
|
|
368
|
+
this.instanceServiceContainer.stylesheetService.updateDeclarationValue(declarations[0], value, false);
|
|
364
369
|
}
|
|
365
370
|
}
|
|
366
371
|
getStyleFromSheetOrLocal(name, fallback = null) {
|
|
@@ -427,9 +432,11 @@ export class DesignItem {
|
|
|
427
432
|
this.node.insertBefore(designItem.node, el.element);
|
|
428
433
|
this._childArray.splice(index, 0, designItem);
|
|
429
434
|
}
|
|
435
|
+
designItem._parent = this;
|
|
430
436
|
//todo: is this still needed???
|
|
431
437
|
if (this.instanceServiceContainer.selectionService.primarySelection == designItem)
|
|
432
438
|
designItem.instanceServiceContainer.designerCanvas.extensionManager.applyExtension(designItem.parent, ExtensionType.PrimarySelectionContainer);
|
|
439
|
+
this._refreshIfStyleSheet();
|
|
433
440
|
}
|
|
434
441
|
_removeChildInternal(designItem) {
|
|
435
442
|
if (designItem.parent && this.instanceServiceContainer.selectionService.primarySelection == designItem)
|
|
@@ -439,6 +446,19 @@ export class DesignItem {
|
|
|
439
446
|
if (index > -1) {
|
|
440
447
|
this._childArray.splice(index, 1);
|
|
441
448
|
designItem.element.remove();
|
|
449
|
+
designItem._parent = null;
|
|
450
|
+
}
|
|
451
|
+
this._refreshIfStyleSheet();
|
|
452
|
+
}
|
|
453
|
+
_refreshIfStyleSheet() {
|
|
454
|
+
if (this.name == 'style' || this.parent?.name == 'style') {
|
|
455
|
+
//Update Stylesheetservice with sheet info
|
|
456
|
+
//Patch this sheetdata
|
|
457
|
+
const realContent = this._childArray.reduce((a, b) => a + b.content, '');
|
|
458
|
+
this.node.textContent = AbstractStylesheetService.buildPatchedStyleSheet([cssFromString(realContent)]);
|
|
459
|
+
this.instanceServiceContainer.designerCanvas.lazyTriggerReparseDocumentStylesheets();
|
|
460
|
+
}
|
|
461
|
+
else if (this.name == 'link') {
|
|
442
462
|
}
|
|
443
463
|
}
|
|
444
464
|
}
|
|
@@ -3,7 +3,6 @@ import { RefreshMode } from '../IPropertiesService.js';
|
|
|
3
3
|
import { CommonPropertiesService } from './CommonPropertiesService.js';
|
|
4
4
|
import { ValueType } from '../ValueType.js';
|
|
5
5
|
import { NodeType } from '../../../item/NodeType.js';
|
|
6
|
-
import { StylesheetStyleChangeAction } from '../../undoService/transactionItems/StylesheetStyleChangeAction.js';
|
|
7
6
|
//TODO: remove this code when import asserts are supported
|
|
8
7
|
let cssProperties;
|
|
9
8
|
//@ts-ignore
|
|
@@ -58,8 +57,7 @@ export class CssCurrentPropertiesService extends CommonPropertiesService {
|
|
|
58
57
|
// TODO: we do not respect if a same style is found in a media query or another @rule, maybe we need a refresh in the stylesheet parser
|
|
59
58
|
const decls = designItems[0].instanceServiceContainer.stylesheetService?.getDeclarations(designItems[0], property.styleDeclaration.name);
|
|
60
59
|
const currentDecl = decls.find(x => x.parent.selector == property.styleDeclaration.parent.selector && x.parent.stylesheetName == property.styleDeclaration.parent.stylesheetName);
|
|
61
|
-
|
|
62
|
-
designItems[0].instanceServiceContainer.undoService.execute(action);
|
|
60
|
+
designItems[0].instanceServiceContainer.stylesheetService.updateDeclarationValue(currentDecl, value, false);
|
|
63
61
|
this._notifyChangedProperty(designItems[0], property, value);
|
|
64
62
|
return;
|
|
65
63
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { TypedEvent } from "@node-projects/base-custom-webcomponent";
|
|
2
2
|
import { IDesignItem } from '../../item/IDesignItem.js';
|
|
3
3
|
import { IDocumentStylesheet, IStyleDeclaration, IStyleRule, IStylesheet, IStylesheetService } from './IStylesheetService.js';
|
|
4
|
+
import { InstanceServiceContainer } from "../InstanceServiceContainer.js";
|
|
5
|
+
import { IDesignerCanvas } from "../../widgets/designerView/IDesignerCanvas.js";
|
|
4
6
|
export declare abstract class AbstractStylesheetService implements IStylesheetService {
|
|
5
7
|
protected _stylesheets: Map<string, {
|
|
6
8
|
stylesheet: IStylesheet;
|
|
@@ -14,6 +16,8 @@ export declare abstract class AbstractStylesheetService implements IStylesheetSe
|
|
|
14
16
|
stylesheet: IStylesheet | IDocumentStylesheet;
|
|
15
17
|
ast: any;
|
|
16
18
|
}>;
|
|
19
|
+
protected _instanceServiceContainer: InstanceServiceContainer;
|
|
20
|
+
constructor(designerCanvas: IDesignerCanvas);
|
|
17
21
|
setStylesheets(stylesheets: IStylesheet[]): Promise<void>;
|
|
18
22
|
setDocumentStylesheets(stylesheets: IDocumentStylesheet[]): Promise<void>;
|
|
19
23
|
internalSetStylesheets(stylesheets: IStylesheet[], targetMap: Map<string, {
|
|
@@ -24,10 +28,11 @@ export declare abstract class AbstractStylesheetService implements IStylesheetSe
|
|
|
24
28
|
getStylesheets(): IStylesheet[];
|
|
25
29
|
abstract getAppliedRules(designItem: IDesignItem): IStyleRule[];
|
|
26
30
|
abstract getDeclarations(designItem: IDesignItem, styleName: string): IStyleDeclaration[];
|
|
27
|
-
|
|
31
|
+
updateDeclarationValue(declaration: IStyleDeclaration, value: string, important: boolean): void;
|
|
28
32
|
abstract insertDeclarationIntoRule(rule: IStyleRule, property: string, value: string, important: boolean): boolean;
|
|
29
33
|
abstract removeDeclarationFromRule(rule: IStyleRule, property: string): boolean;
|
|
30
34
|
abstract updateCompleteStylesheet(name: string, newStyle: string): any;
|
|
35
|
+
abstract updateDeclarationValueWithoutUndo(declaration: IStyleDeclaration, value: string, important: boolean): any;
|
|
31
36
|
stylesheetChanged: TypedEvent<{
|
|
32
37
|
name: string;
|
|
33
38
|
newStyle: string;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { TypedEvent } from "@node-projects/base-custom-webcomponent";
|
|
2
2
|
import { DesignerCanvas } from '../../widgets/designerView/designerCanvas.js';
|
|
3
|
+
import { StylesheetStyleChangeAction } from "../undoService/transactionItems/StylesheetStyleChangeAction.js";
|
|
3
4
|
export class AbstractStylesheetService {
|
|
4
5
|
_stylesheets = new Map();
|
|
5
6
|
_documentStylesheets = new Map();
|
|
6
7
|
_allStylesheets = new Map();
|
|
8
|
+
_instanceServiceContainer;
|
|
9
|
+
constructor(designerCanvas) {
|
|
10
|
+
this._instanceServiceContainer = designerCanvas.instanceServiceContainer;
|
|
11
|
+
}
|
|
7
12
|
async setStylesheets(stylesheets) {
|
|
8
13
|
await this.internalSetStylesheets(stylesheets, this._stylesheets);
|
|
9
14
|
}
|
|
@@ -24,7 +29,8 @@ export class AbstractStylesheetService {
|
|
|
24
29
|
catch (err) {
|
|
25
30
|
console.warn("error parsing stylesheet", stylesheet, err);
|
|
26
31
|
}
|
|
27
|
-
|
|
32
|
+
if (targetMap == this._stylesheets)
|
|
33
|
+
this.stylesheetChanged.emit({ name: stylesheet.name, newStyle: stylesheet.content, oldStyle: old.stylesheet.content, changeSource: 'extern' });
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
}
|
|
@@ -41,7 +47,8 @@ export class AbstractStylesheetService {
|
|
|
41
47
|
console.warn("error parsing stylesheet", stylesheet, err);
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
|
-
this.
|
|
50
|
+
if (targetMap == this._stylesheets)
|
|
51
|
+
this.stylesheetsChanged.emit();
|
|
45
52
|
}
|
|
46
53
|
else {
|
|
47
54
|
targetMap.clear();
|
|
@@ -54,18 +61,27 @@ export class AbstractStylesheetService {
|
|
|
54
61
|
this._allStylesheets.set(s[0], s[1]);
|
|
55
62
|
}
|
|
56
63
|
}
|
|
64
|
+
//todo: rename to externalStylesheets
|
|
57
65
|
getStylesheets() {
|
|
58
66
|
let stylesheets = [];
|
|
59
67
|
for (let item of this._stylesheets) {
|
|
60
68
|
stylesheets.push(item[1].stylesheet);
|
|
61
69
|
}
|
|
62
70
|
;
|
|
63
|
-
for (let item of this._documentStylesheets) {
|
|
71
|
+
/*for (let item of this._documentStylesheets) {
|
|
64
72
|
stylesheets.push(item[1].stylesheet);
|
|
65
|
-
}
|
|
66
|
-
;
|
|
73
|
+
};*/
|
|
67
74
|
return stylesheets;
|
|
68
75
|
}
|
|
76
|
+
updateDeclarationValue(declaration, value, important) {
|
|
77
|
+
if (!declaration.stylesheet.designItem) {
|
|
78
|
+
const action = new StylesheetStyleChangeAction(this, declaration, value, declaration.value);
|
|
79
|
+
this._instanceServiceContainer.undoService.execute(action);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.updateDeclarationValueWithoutUndo(declaration, value, important);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
69
85
|
stylesheetChanged = new TypedEvent();
|
|
70
86
|
stylesheetsChanged = new TypedEvent();
|
|
71
87
|
elementMatchesASelector(designItem, selectors) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IDesignItem } from "../../item/IDesignItem.js";
|
|
2
2
|
import { IStyleDeclaration, IStyleRule, IStylesheet } from "./IStylesheetService.js";
|
|
3
3
|
import { AbstractStylesheetService } from "./AbstractStylesheetService.js";
|
|
4
|
+
import { IDesignerCanvas } from "../../widgets/designerView/IDesignerCanvas.js";
|
|
4
5
|
type CssRuleAST = any;
|
|
5
6
|
type CssDeclarationAST = any;
|
|
6
7
|
type CssStylesheetAST = any;
|
|
@@ -14,6 +15,7 @@ interface IDeclarationWithAST extends IStyleDeclaration {
|
|
|
14
15
|
ast: CssDeclarationAST;
|
|
15
16
|
}
|
|
16
17
|
export declare class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
18
|
+
constructor(designerCanvas: IDesignerCanvas);
|
|
17
19
|
_tools: {
|
|
18
20
|
parse: (css: string, options?: {
|
|
19
21
|
source?: string;
|
|
@@ -29,7 +31,7 @@ export declare class CssToolsStylesheetService extends AbstractStylesheetService
|
|
|
29
31
|
getAppliedRules(designItem: IDesignItem): IRuleWithAST[];
|
|
30
32
|
private getRulesFromAst;
|
|
31
33
|
getDeclarations(designItem: IDesignItem, styleName: string): IStyleDeclaration[];
|
|
32
|
-
|
|
34
|
+
updateDeclarationValueWithoutUndo(declaration: IDeclarationWithAST, value: string, important: boolean): void;
|
|
33
35
|
insertDeclarationIntoRule(rule: IRuleWithAST, property: string, value: string, important: boolean): boolean;
|
|
34
36
|
removeDeclarationFromRule(rule: IRuleWithAST, property: string): boolean;
|
|
35
37
|
private updateStylesheet;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { AbstractStylesheetService } from "./AbstractStylesheetService.js";
|
|
2
2
|
export class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
3
|
+
constructor(designerCanvas) {
|
|
4
|
+
super(designerCanvas);
|
|
5
|
+
}
|
|
3
6
|
_tools;
|
|
4
7
|
async internalParse(style) {
|
|
5
8
|
if (!this._tools)
|
|
@@ -20,6 +23,7 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
|
20
23
|
important: y.value.endsWith('!important'),
|
|
21
24
|
parent: null,
|
|
22
25
|
ast: y,
|
|
26
|
+
stylesheet: item[1].stylesheet
|
|
23
27
|
})),
|
|
24
28
|
specificity: 0,
|
|
25
29
|
stylesheetName: item[0],
|
|
@@ -49,11 +53,10 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
|
49
53
|
getDeclarations(designItem, styleName) {
|
|
50
54
|
return this.getAppliedRules(designItem).flatMap(x => x.declarations).filter(x => x.name == styleName);
|
|
51
55
|
}
|
|
52
|
-
|
|
56
|
+
updateDeclarationValueWithoutUndo(declaration, value, important) {
|
|
53
57
|
declaration.ast.value = important ? value + ' !important' : value;
|
|
54
58
|
let ss = this._allStylesheets.get(declaration.parent.stylesheetName);
|
|
55
59
|
this.updateStylesheet(ss);
|
|
56
|
-
return true;
|
|
57
60
|
}
|
|
58
61
|
insertDeclarationIntoRule(rule, property, value, important) {
|
|
59
62
|
rule.ast.declarations.push({
|
|
@@ -78,7 +81,8 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
|
78
81
|
if (ss.stylesheet.designItem) {
|
|
79
82
|
ss.stylesheet.designItem.content = ss.stylesheet.content;
|
|
80
83
|
}
|
|
81
|
-
|
|
84
|
+
else
|
|
85
|
+
this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
|
|
82
86
|
}
|
|
83
87
|
updateCompleteStylesheet(name, newStyle) {
|
|
84
88
|
const ss = this._allStylesheets.get(name);
|
|
@@ -88,7 +92,8 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
|
88
92
|
if (ss.stylesheet.designItem) {
|
|
89
93
|
ss.stylesheet.designItem.content = ss.stylesheet.content;
|
|
90
94
|
}
|
|
91
|
-
|
|
95
|
+
else
|
|
96
|
+
this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
|
|
92
97
|
}
|
|
93
98
|
}
|
|
94
99
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IDesignItem } from "../../item/IDesignItem.js";
|
|
2
|
-
import { IStyleDeclaration, IStyleRule } from "./IStylesheetService.js";
|
|
2
|
+
import { IStyleDeclaration, IStyleRule, IStylesheet } from "./IStylesheetService.js";
|
|
3
3
|
import { AbstractStylesheetService } from "./AbstractStylesheetService.js";
|
|
4
|
+
import { IDesignerCanvas } from "../../widgets/designerView/IDesignerCanvas.js";
|
|
4
5
|
declare namespace csstree {
|
|
5
6
|
type CssNodePlain = any;
|
|
6
7
|
type CssNode = any;
|
|
@@ -28,17 +29,19 @@ declare global {
|
|
|
28
29
|
interface IRuleWithAST extends IStyleRule {
|
|
29
30
|
ast: csstree.RulePlain;
|
|
30
31
|
declarations: IDeclarationWithAST[];
|
|
32
|
+
stylesheet: IStylesheet;
|
|
31
33
|
}
|
|
32
34
|
interface IDeclarationWithAST extends IStyleDeclaration {
|
|
33
35
|
ast: csstree.DeclarationPlain;
|
|
34
36
|
}
|
|
35
37
|
export declare class CssTreeStylesheetService extends AbstractStylesheetService {
|
|
38
|
+
constructor(designerCanvas: IDesignerCanvas);
|
|
36
39
|
internalParse(style: string): Promise<any>;
|
|
37
40
|
private getAppliedRulesInternal;
|
|
38
41
|
getAppliedRules(designItem: IDesignItem): IRuleWithAST[];
|
|
39
42
|
private getDeclarationInternal;
|
|
40
43
|
getDeclarations(designItem: IDesignItem, stlyeName: string): IDeclarationWithAST[];
|
|
41
|
-
|
|
44
|
+
updateDeclarationValueWithoutUndo(declaration: IDeclarationWithAST, value: string, important: boolean): void;
|
|
42
45
|
insertDeclarationIntoRule(rule: IRuleWithAST, property: string, value: string, important: boolean): boolean;
|
|
43
46
|
removeDeclarationFromRule(rule: IRuleWithAST, property: string): boolean;
|
|
44
47
|
updateCompleteStylesheet(name: string, newStyle: string): void;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { calculate as calculateSpecifity } from "./SpecificityCalculator.js";
|
|
2
2
|
import { AbstractStylesheetService } from "./AbstractStylesheetService.js";
|
|
3
3
|
export class CssTreeStylesheetService extends AbstractStylesheetService {
|
|
4
|
+
constructor(designerCanvas) {
|
|
5
|
+
super(designerCanvas);
|
|
6
|
+
}
|
|
4
7
|
async internalParse(style) {
|
|
5
8
|
return window.csstree.toPlainObject((window.csstree.parse(style, { positions: true, parseValue: false })));
|
|
6
9
|
}
|
|
@@ -52,6 +55,7 @@ export class CssTreeStylesheetService extends AbstractStylesheetService {
|
|
|
52
55
|
name: styleName,
|
|
53
56
|
value: declaration.value.value,
|
|
54
57
|
important: declaration.important == true,
|
|
58
|
+
stylesheet: rule.stylesheet
|
|
55
59
|
});
|
|
56
60
|
}
|
|
57
61
|
;
|
|
@@ -64,7 +68,7 @@ export class CssTreeStylesheetService extends AbstractStylesheetService {
|
|
|
64
68
|
return this.sortDeclarations(declarations);
|
|
65
69
|
}
|
|
66
70
|
/* Section covers the update of rules and declarations */
|
|
67
|
-
|
|
71
|
+
updateDeclarationValueWithoutUndo(declaration, value, important) {
|
|
68
72
|
let sourceNode = this._allStylesheets.get(declaration.parent.stylesheetName);
|
|
69
73
|
declaration.ast.value = window.csstree.toPlainObject(window.csstree.parse(declaration.name + ": " + value + (important ? " !important" : ""), { context: 'declaration', parseValue: false })).value;
|
|
70
74
|
const old = sourceNode.stylesheet.content;
|
|
@@ -74,8 +78,8 @@ export class CssTreeStylesheetService extends AbstractStylesheetService {
|
|
|
74
78
|
if (sourceNode.stylesheet.designItem) {
|
|
75
79
|
sourceNode.stylesheet.designItem.content = sourceNode.stylesheet.content;
|
|
76
80
|
}
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
else
|
|
82
|
+
this.stylesheetChanged.emit({ name: sourceNode.stylesheet.name, newStyle: sourceNode.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
|
|
79
83
|
}
|
|
80
84
|
insertDeclarationIntoRule(rule, property, value, important) {
|
|
81
85
|
let sourceNode = this._allStylesheets.get(rule.stylesheetName);
|
|
@@ -87,7 +91,8 @@ export class CssTreeStylesheetService extends AbstractStylesheetService {
|
|
|
87
91
|
if (sourceNode.stylesheet.designItem) {
|
|
88
92
|
sourceNode.stylesheet.designItem.content = sourceNode.stylesheet.content;
|
|
89
93
|
}
|
|
90
|
-
|
|
94
|
+
else
|
|
95
|
+
this.stylesheetChanged.emit({ name: sourceNode.stylesheet.name, newStyle: sourceNode.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
|
|
91
96
|
return true;
|
|
92
97
|
}
|
|
93
98
|
removeDeclarationFromRule(rule, property) {
|
|
@@ -103,7 +108,8 @@ export class CssTreeStylesheetService extends AbstractStylesheetService {
|
|
|
103
108
|
if (ss.stylesheet.designItem) {
|
|
104
109
|
ss.stylesheet.designItem.content = ss.stylesheet.content;
|
|
105
110
|
}
|
|
106
|
-
|
|
111
|
+
else
|
|
112
|
+
this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
|
|
107
113
|
return true;
|
|
108
114
|
}
|
|
109
115
|
updateCompleteStylesheet(name, newStyle) {
|
|
@@ -114,7 +120,8 @@ export class CssTreeStylesheetService extends AbstractStylesheetService {
|
|
|
114
120
|
if (ss.stylesheet.designItem) {
|
|
115
121
|
ss.stylesheet.designItem.content = ss.stylesheet.content;
|
|
116
122
|
}
|
|
117
|
-
|
|
123
|
+
else
|
|
124
|
+
this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
|
|
118
125
|
}
|
|
119
126
|
}
|
|
120
127
|
/* Section covers the internal traversal creation of rules and declarations */
|
|
@@ -146,6 +153,7 @@ export class CssTreeStylesheetService extends AbstractStylesheetService {
|
|
|
146
153
|
specificity: this.getSpecificity(child.prelude),
|
|
147
154
|
stylesheetName: source,
|
|
148
155
|
declarations: null,
|
|
156
|
+
stylesheet: this._allStylesheets.get(source).stylesheet
|
|
149
157
|
});
|
|
150
158
|
}
|
|
151
159
|
}
|
|
@@ -11,14 +11,13 @@ export interface IStyleDeclaration {
|
|
|
11
11
|
value: string;
|
|
12
12
|
important: boolean;
|
|
13
13
|
parent: IStyleRule;
|
|
14
|
+
stylesheet?: IStylesheet;
|
|
14
15
|
}
|
|
15
16
|
export interface IStylesheet {
|
|
16
17
|
content: string;
|
|
17
18
|
name: string;
|
|
18
19
|
}
|
|
19
|
-
export interface IDocumentStylesheet {
|
|
20
|
-
content: string;
|
|
21
|
-
name: string;
|
|
20
|
+
export interface IDocumentStylesheet extends IStylesheet {
|
|
22
21
|
designItem: IDesignItem;
|
|
23
22
|
}
|
|
24
23
|
export interface IStylesheetService {
|
|
@@ -27,7 +26,8 @@ export interface IStylesheetService {
|
|
|
27
26
|
setDocumentStylesheets(stylesheets: IDocumentStylesheet[]): Promise<void>;
|
|
28
27
|
getAppliedRules(designItem: IDesignItem): IStyleRule[];
|
|
29
28
|
getDeclarations(designItem: IDesignItem, styleName: string): IStyleDeclaration[];
|
|
30
|
-
updateDeclarationValue(declaration: IStyleDeclaration, value: string, important: boolean):
|
|
29
|
+
updateDeclarationValue(declaration: IStyleDeclaration, value: string, important: boolean): any;
|
|
30
|
+
updateDeclarationValueWithoutUndo(declaration: IStyleDeclaration, value: string, important: boolean): any;
|
|
31
31
|
insertDeclarationIntoRule(rule: IStyleRule, property: string, value: string, important: boolean): boolean;
|
|
32
32
|
removeDeclarationFromRule(rule: IStyleRule, property: string): boolean;
|
|
33
33
|
updateCompleteStylesheet(name: string, newStyle: string): void;
|
|
@@ -12,18 +12,21 @@ export class InsertChildAction {
|
|
|
12
12
|
return [this.designItem, this.newParent];
|
|
13
13
|
}
|
|
14
14
|
undo() {
|
|
15
|
-
if (this.oldParent)
|
|
15
|
+
if (this.oldParent) {
|
|
16
16
|
this.oldParent._insertChildInternal(this.designItem, this.oldIndex);
|
|
17
|
-
|
|
17
|
+
this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'moved', designItems: [this.designItem] });
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
18
20
|
this.designItem.parent._removeChildInternal(this.designItem);
|
|
19
|
-
|
|
21
|
+
this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'removed', designItems: [this.designItem] });
|
|
22
|
+
}
|
|
20
23
|
}
|
|
21
24
|
do() {
|
|
22
25
|
this.oldParent = this.designItem.parent;
|
|
23
26
|
if (this.oldParent)
|
|
24
27
|
this.oldIndex = this.designItem.parent.indexOf(this.designItem);
|
|
25
28
|
this.newParent._insertChildInternal(this.designItem, this.newIndex);
|
|
26
|
-
this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'moved', designItems: [this.designItem] });
|
|
29
|
+
this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: this.oldParent ? 'moved' : 'added', designItems: [this.designItem] });
|
|
27
30
|
}
|
|
28
31
|
designItem;
|
|
29
32
|
newParent;
|
|
@@ -13,10 +13,10 @@ export class StylesheetStyleChangeAction {
|
|
|
13
13
|
return [];
|
|
14
14
|
}
|
|
15
15
|
undo() {
|
|
16
|
-
this.stylesheetService.
|
|
16
|
+
this.stylesheetService.updateDeclarationValueWithoutUndo(this.declaration, this.oldValue, false);
|
|
17
17
|
}
|
|
18
18
|
do() {
|
|
19
|
-
this.stylesheetService.
|
|
19
|
+
this.stylesheetService.updateDeclarationValueWithoutUndo(this.declaration, this.newValue, false);
|
|
20
20
|
}
|
|
21
21
|
designItem;
|
|
22
22
|
name;
|
|
@@ -55,4 +55,5 @@ export interface IDesignerCanvas extends IPlacementView, IUiCommandHandler {
|
|
|
55
55
|
zoomPoint(canvasPoint: IPoint, newZoom: number): void;
|
|
56
56
|
zoomOntoRectangle(startPoint: IPoint, endPoint: IPoint): void;
|
|
57
57
|
showDesignItemContextMenu(designItem: IDesignItem, event: MouseEvent): void;
|
|
58
|
+
lazyTriggerReparseDocumentStylesheets(): any;
|
|
58
59
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { ServiceContainer } from '../../services/ServiceContainer.js';
|
|
2
3
|
import { InstanceServiceContainer } from '../../services/InstanceServiceContainer.js';
|
|
3
4
|
import { IDesignItem } from '../../item/IDesignItem.js';
|
|
@@ -84,6 +85,9 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
|
|
|
84
85
|
private _updateTransform;
|
|
85
86
|
setDesignItems(designItems: IDesignItem[]): void;
|
|
86
87
|
_internalSetDesignItems(designItems: IDesignItem[]): void;
|
|
88
|
+
reparseTimeout: NodeJS.Timeout | null;
|
|
89
|
+
lazyTriggerReparseDocumentStylesheets(): void;
|
|
90
|
+
private reparseDocumentStylesheets;
|
|
87
91
|
addDesignItems(designItems: IDesignItem[]): void;
|
|
88
92
|
_dragOverExtensionItem: IDesignItem;
|
|
89
93
|
private _onDragEnter;
|
|
@@ -431,23 +431,24 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
431
431
|
}
|
|
432
432
|
this.rootDesignItem = DesignItem.GetOrCreateDesignItem(this._canvas, this.serviceContainer, this.instanceServiceContainer);
|
|
433
433
|
const contentService = this.serviceContainer.getLastService('contentService');
|
|
434
|
-
if (contentService)
|
|
434
|
+
if (contentService) {
|
|
435
435
|
this.instanceServiceContainer.register("contentService", contentService(this));
|
|
436
|
-
|
|
437
|
-
|
|
436
|
+
}
|
|
437
|
+
const stylesheetService = this.serviceContainer.getLastService('stylesheetService');
|
|
438
|
+
if (stylesheetService) {
|
|
439
|
+
const instance = stylesheetService(this);
|
|
440
|
+
this.instanceServiceContainer.register("stylesheetService", instance);
|
|
441
|
+
this.instanceServiceContainer.stylesheetService.stylesheetChanged.on((ss) => {
|
|
442
|
+
if (ss.changeSource == 'extern') {
|
|
443
|
+
const ssca = new StylesheetChangedAction(this.instanceServiceContainer.stylesheetService, ss.name, ss.newStyle, ss.oldStyle);
|
|
444
|
+
this.instanceServiceContainer.undoService.execute(ssca);
|
|
445
|
+
}
|
|
438
446
|
this.applyAllStyles();
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
this.applyAllStyles();
|
|
445
|
-
});
|
|
446
|
-
this.instanceServiceContainer.stylesheetService.stylesheetsChanged.on(() => {
|
|
447
|
-
this.applyAllStyles();
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
});
|
|
447
|
+
});
|
|
448
|
+
this.instanceServiceContainer.stylesheetService.stylesheetsChanged.on(() => {
|
|
449
|
+
this.applyAllStyles();
|
|
450
|
+
});
|
|
451
|
+
}
|
|
451
452
|
this.extensionManager = new ExtensionManager(this);
|
|
452
453
|
this.overlayLayer = new OverlayLayerView(serviceContainer);
|
|
453
454
|
this.overlayLayer.style.pointerEvents = 'none';
|
|
@@ -535,16 +536,28 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
535
536
|
for (let i of [...this.rootDesignItem.children()])
|
|
536
537
|
this.rootDesignItem._removeChildInternal(i);
|
|
537
538
|
this.addDesignItems(designItems);
|
|
539
|
+
this.lazyTriggerReparseDocumentStylesheets();
|
|
540
|
+
this.instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'parsed' });
|
|
541
|
+
this.instanceServiceContainer.selectionService._withoutUndoSetSelectedElements(null);
|
|
542
|
+
setTimeout(() => this.extensionManager.refreshAllAppliedExtentions(), 50);
|
|
543
|
+
}
|
|
544
|
+
reparseTimeout;
|
|
545
|
+
lazyTriggerReparseDocumentStylesheets() {
|
|
546
|
+
if (this.reparseTimeout) {
|
|
547
|
+
clearTimeout(this.reparseTimeout);
|
|
548
|
+
}
|
|
549
|
+
this.reparseTimeout = setTimeout(async () => {
|
|
550
|
+
await this.reparseDocumentStylesheets();
|
|
551
|
+
clearTimeout(this.reparseTimeout);
|
|
552
|
+
}, 20);
|
|
553
|
+
}
|
|
554
|
+
async reparseDocumentStylesheets() {
|
|
538
555
|
if (this.instanceServiceContainer.stylesheetService) {
|
|
539
556
|
const styleElements = this.rootDesignItem.element.querySelectorAll('style');
|
|
540
557
|
let i = 1;
|
|
541
|
-
const intStyleSheets = [...styleElements].map(x => ({ name: '<style> #' + (x.id ? x.id + '(' + i++ + ')' : i++), content: x.
|
|
542
|
-
|
|
543
|
-
this.instanceServiceContainer.stylesheetService.setDocumentStylesheets(intStyleSheets);
|
|
558
|
+
const intStyleSheets = [...styleElements].map(x => ({ name: '<style> #' + (x.id ? x.id + '(' + i++ + ')' : i++), content: DesignItem.GetDesignItem(x).content, designItem: DesignItem.GetDesignItem(x) }));
|
|
559
|
+
await this.instanceServiceContainer.stylesheetService.setDocumentStylesheets(intStyleSheets);
|
|
544
560
|
}
|
|
545
|
-
this.instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'parsed' });
|
|
546
|
-
this.instanceServiceContainer.selectionService._withoutUndoSetSelectedElements(null);
|
|
547
|
-
setTimeout(() => this.extensionManager.refreshAllAppliedExtentions(), 50);
|
|
548
561
|
}
|
|
549
562
|
addDesignItems(designItems) {
|
|
550
563
|
if (designItems) {
|
|
@@ -104,10 +104,10 @@ export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
|
|
|
104
104
|
this._type.innerText = this._instanceServiceContainer.selectionService.primarySelection?.node?.nodeName ?? '';
|
|
105
105
|
this._id.value = this._instanceServiceContainer.selectionService.primarySelection?.id ?? '';
|
|
106
106
|
if (this._instanceServiceContainer.selectionService.primarySelection?.element?.nodeType != NodeType.Element) {
|
|
107
|
-
this._content.value = this._instanceServiceContainer.selectionService.primarySelection?.
|
|
107
|
+
this._content.value = this._instanceServiceContainer.selectionService.primarySelection?.content ?? '';
|
|
108
108
|
}
|
|
109
109
|
else if (this._instanceServiceContainer.selectionService.primarySelection?.element?.children?.length <= 0)
|
|
110
|
-
this._content.value = this._instanceServiceContainer.selectionService.primarySelection?.
|
|
110
|
+
this._content.value = this._instanceServiceContainer.selectionService.primarySelection?.content ?? '';
|
|
111
111
|
else
|
|
112
112
|
this._content.value = '';
|
|
113
113
|
this._content.title = this._content.value;
|
|
@@ -338,7 +338,7 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
|
|
|
338
338
|
currentNode = this._tree.getRootNode();
|
|
339
339
|
}
|
|
340
340
|
const newNode = currentNode.addChildren({
|
|
341
|
-
title: item.nodeType === NodeType.Element ? item.name + " " + (item.id ? ('#' + item.id) : '') : '<small><small><small>#' + (item.nodeType === NodeType.TextNode ? 'text' : 'comment') + ' </small></small></small> ' + DomConverter.normalizeContentValue(item.content),
|
|
341
|
+
title: item.isRootItem ? '-root-' : item.nodeType === NodeType.Element ? item.name + " " + (item.id ? ('#' + item.id) : '') : '<small><small><small>#' + (item.nodeType === NodeType.TextNode ? 'text' : 'comment') + ' </small></small></small> ' + DomConverter.normalizeContentValue(item.content),
|
|
342
342
|
folder: item.children.length > 0 ? true : false,
|
|
343
343
|
//@ts-ignore
|
|
344
344
|
ref: item
|
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.213",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"construct-style-sheets-polyfill": "^3.1.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@adobe/css-tools": "^4.
|
|
20
|
+
"@adobe/css-tools": "^4.3.0-beta.1",
|
|
21
21
|
"@node-projects/lean-he-esm": "^3.3.0",
|
|
22
22
|
"@node-projects/node-html-parser-esm": "^2.5.1",
|
|
23
23
|
"@papyrs/stylo": "^0.0.42",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"@types/css-tree": "^2.3.1",
|
|
26
26
|
"@types/jquery": "^3.5.16",
|
|
27
27
|
"@types/jquery.fancytree": "0.0.7",
|
|
28
|
-
"@types/node": "^18.14.
|
|
29
|
-
"ace-builds": "^1.15.
|
|
28
|
+
"@types/node": "^18.14.6",
|
|
29
|
+
"ace-builds": "^1.15.3",
|
|
30
30
|
"codemirror": "^6.0.1",
|
|
31
31
|
"css-tree": "^2.3.1",
|
|
32
32
|
"esprima-next": "^5.8.4",
|
|
33
33
|
"html2canvas": "*",
|
|
34
|
-
"jest": "^29.
|
|
35
|
-
"jquery": "^3.6.
|
|
34
|
+
"jest": "^29.5.0",
|
|
35
|
+
"jquery": "^3.6.4",
|
|
36
36
|
"jquery.fancytree": "^2.38.3",
|
|
37
37
|
"mdn-data": "^2.0.31",
|
|
38
38
|
"monaco-editor": "^0.36.1",
|