@node-projects/web-component-designer 0.0.203 → 0.0.205
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 +4 -1
- package/dist/elements/documentContainer.js +1 -1
- package/dist/elements/item/DesignItem.js +11 -7
- package/dist/elements/services/DefaultServiceBootstrap.js +1 -1
- package/dist/elements/services/placementService/GridPlacementService.js +4 -0
- package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService.js +3 -1
- package/dist/elements/services/selectionService/SelectionService.d.ts +2 -1
- package/dist/elements/services/selectionService/SelectionService.js +10 -3
- package/dist/elements/services/stylesheetService/AbstractStylesheetService.d.ts +5 -1
- package/dist/elements/services/stylesheetService/CssToolsStylesheetService.d.ts +2 -3
- package/dist/elements/services/stylesheetService/CssToolsStylesheetService.js +30 -3
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService.d.ts +1 -0
- package/dist/elements/services/stylesheetService/CssTreeStylesheetService.js +17 -5
- package/dist/elements/services/stylesheetService/IStylesheetService.d.ts +5 -1
- package/dist/elements/services/undoService/transactionItems/CssStyleChangeAction copy.d.ts +14 -0
- package/dist/elements/services/undoService/transactionItems/CssStyleChangeAction copy.js +44 -0
- package/dist/elements/services/undoService/transactionItems/StylesheetChangedAction.d.ts +14 -0
- package/dist/elements/services/undoService/transactionItems/StylesheetChangedAction.js +24 -0
- package/dist/elements/services/undoService/transactionItems/StylesheetStyleChangeAction.d.ts +17 -0
- package/dist/elements/services/undoService/transactionItems/StylesheetStyleChangeAction.js +28 -0
- package/dist/elements/widgets/codeView/code-view-ace.js +1 -1
- package/dist/elements/widgets/codeView/code-view-monaco.js +1 -1
- package/dist/elements/widgets/designerView/designerCanvas.js +16 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +3 -3
|
@@ -21,7 +21,10 @@ export declare class DocumentContainer extends BaseCustomWebComponentLazyAppend
|
|
|
21
21
|
set additionalStylesheets(stylesheets: IStylesheet[]);
|
|
22
22
|
get additionalStylesheets(): IStylesheet[];
|
|
23
23
|
additionalStylesheetChanged: TypedEvent<{
|
|
24
|
-
|
|
24
|
+
name: string;
|
|
25
|
+
newStyle: string;
|
|
26
|
+
oldStyle: string;
|
|
27
|
+
changeSource: 'extern' | 'styleupdate';
|
|
25
28
|
}>;
|
|
26
29
|
onContentChanged: TypedEvent<void>;
|
|
27
30
|
private _serviceContainer;
|
|
@@ -25,7 +25,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
25
25
|
if (stylesheetService) {
|
|
26
26
|
const instance = stylesheetService(this.designerView.designerCanvas);
|
|
27
27
|
this.instanceServiceContainer.register("stylesheetService", instance);
|
|
28
|
-
instance.stylesheetChanged.on(
|
|
28
|
+
instance.stylesheetChanged.on(e => this.additionalStylesheetChanged.emit({ name: e.name, newStyle: e.newStyle, oldStyle: e.oldStyle, changeSource: e.changeSource }));
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
31
|
console.warn("no Stylesheet-Service registered, but additionalStylesheets are used.");
|
|
@@ -8,6 +8,7 @@ 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 { StylesheetStyleChangeAction } from '../services/undoService/transactionItems/StylesheetStyleChangeAction.js';
|
|
11
12
|
const hideAtDesignTimeAttributeName = 'node-projects-hide-at-design-time';
|
|
12
13
|
const hideAtRunTimeAttributeName = 'node-projects-hide-at-run-time';
|
|
13
14
|
const lockAtDesignTimeAttributeName = 'node-projects-lock-at-design-time';
|
|
@@ -328,8 +329,8 @@ export class DesignItem {
|
|
|
328
329
|
updateStyleInSheetOrLocal(name, value, important) {
|
|
329
330
|
let nm = PropertiesHelper.camelToDashCase(name);
|
|
330
331
|
// Pre-sorted by specificity
|
|
331
|
-
let
|
|
332
|
-
if (this.hasStyle(name) || this.instanceServiceContainer.designContext.extensionOptions[enableStylesheetService] === false || !
|
|
332
|
+
let declarations = this.instanceServiceContainer.stylesheetService?.getDeclarations(this, nm);
|
|
333
|
+
if (this.hasStyle(name) || this.instanceServiceContainer.designContext.extensionOptions[enableStylesheetService] === false || !declarations?.length) {
|
|
333
334
|
// Set style locally
|
|
334
335
|
if (this.getStyle(nm) != value) {
|
|
335
336
|
this.setStyle(nm, value);
|
|
@@ -339,8 +340,8 @@ export class DesignItem {
|
|
|
339
340
|
}
|
|
340
341
|
}
|
|
341
342
|
else {
|
|
342
|
-
|
|
343
|
-
this.instanceServiceContainer.
|
|
343
|
+
const action = new StylesheetStyleChangeAction(this.instanceServiceContainer.stylesheetService, declarations[0], value, declarations[0].value);
|
|
344
|
+
this.instanceServiceContainer.undoService.execute(action);
|
|
344
345
|
}
|
|
345
346
|
}
|
|
346
347
|
getStyleFromSheetOrLocal(name, fallback = null) {
|
|
@@ -373,10 +374,13 @@ export class DesignItem {
|
|
|
373
374
|
return [];
|
|
374
375
|
const localStyles = [...this._styles.entries()].map(x => ({ name: x[0], value: x[1], important: false, parent: null }));
|
|
375
376
|
if (this.instanceServiceContainer.stylesheetService) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
377
|
+
try {
|
|
378
|
+
const rules = this.instanceServiceContainer.stylesheetService?.getAppliedRules(this);
|
|
379
|
+
if (rules) {
|
|
380
|
+
return [{ selector: null, declarations: localStyles, specificity: -1 }, ...rules];
|
|
381
|
+
}
|
|
379
382
|
}
|
|
383
|
+
catch (err) { }
|
|
380
384
|
}
|
|
381
385
|
return [{ selector: null, declarations: localStyles, specificity: -1 }];
|
|
382
386
|
}
|
|
@@ -102,7 +102,7 @@ export function createDefaultServiceContainer() {
|
|
|
102
102
|
serviceContainer.register("modelCommandService", new DefaultModelCommandService());
|
|
103
103
|
serviceContainer.register("demoProviderService", new DemoProviderService());
|
|
104
104
|
serviceContainer.register("undoService", (designerCanvas) => new UndoService(designerCanvas));
|
|
105
|
-
serviceContainer.register("selectionService", (designerCanvas) => new SelectionService(designerCanvas));
|
|
105
|
+
serviceContainer.register("selectionService", (designerCanvas) => new SelectionService(designerCanvas, false));
|
|
106
106
|
serviceContainer.register("contentService", (designerCanvas) => new ContentService(designerCanvas.rootDesignItem));
|
|
107
107
|
//serviceContainer.register("stylesheetService", new DemoProviderService());
|
|
108
108
|
serviceContainer.designerExtensions.set(ExtensionType.Permanent, [
|
|
@@ -84,12 +84,16 @@ export class GridPlacementService {
|
|
|
84
84
|
column = 0;
|
|
85
85
|
for (let cell of cellRow) {
|
|
86
86
|
if (pointInRect(pos, cell)) {
|
|
87
|
+
//Grid Area is shorthand for grid row/column, to make undo work correctly we need to set befor and after clear
|
|
87
88
|
if (cell.name) {
|
|
89
|
+
items[0].setStyle('grid-area', cell.name);
|
|
88
90
|
items[0].removeStyle('grid-column');
|
|
89
91
|
items[0].removeStyle('grid-row');
|
|
90
92
|
items[0].setStyle('grid-area', cell.name);
|
|
91
93
|
}
|
|
92
94
|
else {
|
|
95
|
+
items[0].setStyle('grid-column', column + 1);
|
|
96
|
+
items[0].setStyle('grid-row', row + 1);
|
|
93
97
|
items[0].removeStyle('grid-area');
|
|
94
98
|
items[0].setStyle('grid-column', column + 1);
|
|
95
99
|
items[0].setStyle('grid-row', row + 1);
|
|
@@ -3,6 +3,7 @@ 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';
|
|
6
7
|
//TODO: remove this code when import asserts are supported
|
|
7
8
|
let cssProperties;
|
|
8
9
|
//@ts-ignore
|
|
@@ -53,7 +54,8 @@ export class CssCurrentPropertiesService extends CommonPropertiesService {
|
|
|
53
54
|
setValue(designItems, property, value) {
|
|
54
55
|
// No selector means local style, styleDeclaration is null means new property
|
|
55
56
|
if (property.styleRule?.selector !== null && property.styleDeclaration) {
|
|
56
|
-
designItems[0].instanceServiceContainer.stylesheetService
|
|
57
|
+
const action = new StylesheetStyleChangeAction(designItems[0].instanceServiceContainer.stylesheetService, property.styleDeclaration, value, property.styleDeclaration.value);
|
|
58
|
+
designItems[0].instanceServiceContainer.undoService.execute(action);
|
|
57
59
|
this._notifyChangedProperty(designItems[0], property, value);
|
|
58
60
|
return;
|
|
59
61
|
}
|
|
@@ -7,7 +7,8 @@ export declare class SelectionService implements ISelectionService {
|
|
|
7
7
|
primarySelection: IDesignItem;
|
|
8
8
|
selectedElements: IDesignItem[];
|
|
9
9
|
_designerCanvas: IDesignerCanvas;
|
|
10
|
-
|
|
10
|
+
_undoSelectionChanges: boolean;
|
|
11
|
+
constructor(designerCanvas: IDesignerCanvas, undoSelectionChanges: boolean);
|
|
11
12
|
setSelectedElements(designItems: IDesignItem[]): void;
|
|
12
13
|
_withoutUndoSetSelectedElements(designItems: IDesignItem[]): void;
|
|
13
14
|
clearSelectedElements(): void;
|
|
@@ -4,13 +4,20 @@ export class SelectionService {
|
|
|
4
4
|
primarySelection;
|
|
5
5
|
selectedElements = [];
|
|
6
6
|
_designerCanvas;
|
|
7
|
-
|
|
7
|
+
_undoSelectionChanges;
|
|
8
|
+
constructor(designerCanvas, undoSelectionChanges) {
|
|
8
9
|
this._designerCanvas = designerCanvas;
|
|
10
|
+
this._undoSelectionChanges = undoSelectionChanges;
|
|
9
11
|
}
|
|
10
12
|
setSelectedElements(designItems) {
|
|
11
13
|
if (this.selectedElements != designItems) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
if (this._undoSelectionChanges) {
|
|
15
|
+
const action = new SelectionChangedAction(this.selectedElements, designItems, this);
|
|
16
|
+
this._designerCanvas.instanceServiceContainer.undoService.execute(action);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
this._withoutUndoSetSelectedElements(designItems);
|
|
20
|
+
}
|
|
14
21
|
}
|
|
15
22
|
}
|
|
16
23
|
_withoutUndoSetSelectedElements(designItems) {
|
|
@@ -9,8 +9,12 @@ export declare abstract class AbstractStylesheetService implements IStylesheetSe
|
|
|
9
9
|
abstract updateDeclarationValue(declaration: IStyleDeclaration, value: string, important: boolean): boolean;
|
|
10
10
|
abstract insertDeclarationIntoRule(rule: IStyleRule, property: string, value: string, important: boolean): boolean;
|
|
11
11
|
abstract removeDeclarationFromRule(rule: IStyleRule, property: string): boolean;
|
|
12
|
+
abstract updateCompleteStylesheet(name: string, newStyle: string): any;
|
|
12
13
|
stylesheetChanged: TypedEvent<{
|
|
13
|
-
|
|
14
|
+
name: string;
|
|
15
|
+
newStyle: string;
|
|
16
|
+
oldStyle: string;
|
|
17
|
+
changeSource: 'extern' | 'styleupdate';
|
|
14
18
|
}>;
|
|
15
19
|
stylesheetsChanged: TypedEvent<void>;
|
|
16
20
|
protected elementMatchesASelector(designItem: IDesignItem, selectors: string[]): boolean;
|
|
@@ -1,9 +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
|
-
type CssRuleAST
|
|
5
|
-
type CssDeclarationAST = any;
|
|
6
|
-
type CssStylesheetAST = any;
|
|
4
|
+
import type { CssDeclarationAST, CssRuleAST, CssStylesheetAST } from "@adobe/css-tools";
|
|
7
5
|
interface IRuleWithAST extends IStyleRule {
|
|
8
6
|
ast: CssRuleAST;
|
|
9
7
|
declarations: IDeclarationWithAST[];
|
|
@@ -35,5 +33,6 @@ export declare class CssToolsStylesheetService extends AbstractStylesheetService
|
|
|
35
33
|
insertDeclarationIntoRule(rule: IRuleWithAST, property: string, value: string, important: boolean): boolean;
|
|
36
34
|
removeDeclarationFromRule(rule: IRuleWithAST, property: string): boolean;
|
|
37
35
|
private updateStylesheet;
|
|
36
|
+
updateCompleteStylesheet(name: string, newStyle: string): void;
|
|
38
37
|
}
|
|
39
38
|
export {};
|
|
@@ -3,8 +3,26 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
|
3
3
|
_stylesheets = new Map();
|
|
4
4
|
_tools;
|
|
5
5
|
async setStylesheets(stylesheets) {
|
|
6
|
-
if (
|
|
6
|
+
if (!this._tools)
|
|
7
7
|
this._tools = await import('@adobe/css-tools');
|
|
8
|
+
if (this._stylesheets != null && stylesheets != null && this._stylesheets.size == stylesheets.length && stylesheets.every(x => this._stylesheets.has(x.name))) {
|
|
9
|
+
for (let stylesheet of stylesheets) {
|
|
10
|
+
const old = this._stylesheets.get(stylesheet.name);
|
|
11
|
+
if (old.stylesheet.content != stylesheet.content) {
|
|
12
|
+
try {
|
|
13
|
+
this._stylesheets.set(stylesheet.name, {
|
|
14
|
+
stylesheet: stylesheet,
|
|
15
|
+
ast: this._tools.parse(stylesheet.content)
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
console.warn("error parsing stylesheet", stylesheet, err);
|
|
20
|
+
}
|
|
21
|
+
this.stylesheetChanged.emit({ name: stylesheet.name, newStyle: stylesheet.content, oldStyle: old.stylesheet.content, changeSource: 'extern' });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else if (stylesheets != null) {
|
|
8
26
|
this._stylesheets = new Map();
|
|
9
27
|
for (let stylesheet of stylesheets) {
|
|
10
28
|
try {
|
|
@@ -39,7 +57,7 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
|
39
57
|
let rs = Array.from(this.getRulesFromAst(item[1].ast?.stylesheet?.rules, item[1].stylesheet, designItem))
|
|
40
58
|
.map(x => ({
|
|
41
59
|
selector: x.selectors.join(', '),
|
|
42
|
-
declarations: x.declarations.map(y => ({
|
|
60
|
+
declarations: x.declarations.filter(y => y.type == 'declaration').map(y => ({
|
|
43
61
|
name: y.property,
|
|
44
62
|
value: y.value.endsWith('!important') ? y.value.substring(0, y.value.length - 10).trimEnd() : y.value,
|
|
45
63
|
important: y.value.endsWith('!important'),
|
|
@@ -98,7 +116,16 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
|
98
116
|
return true;
|
|
99
117
|
}
|
|
100
118
|
updateStylesheet(ss) {
|
|
119
|
+
const old = ss.stylesheet.content;
|
|
101
120
|
ss.stylesheet.content = this._tools.stringify(ss.ast, { indent: ' ', compress: false, emptyDeclarations: true });
|
|
102
|
-
this.stylesheetChanged.emit({ stylesheet: ss.stylesheet });
|
|
121
|
+
this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
|
|
122
|
+
}
|
|
123
|
+
updateCompleteStylesheet(name, newStyle) {
|
|
124
|
+
const ss = this._stylesheets.get(name);
|
|
125
|
+
if (ss.stylesheet.content != newStyle) {
|
|
126
|
+
const old = ss.stylesheet.content;
|
|
127
|
+
ss.stylesheet.content = newStyle;
|
|
128
|
+
this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
|
|
129
|
+
}
|
|
103
130
|
}
|
|
104
131
|
}
|
|
@@ -43,6 +43,7 @@ export declare class CssTreeStylesheetService extends AbstractStylesheetService
|
|
|
43
43
|
updateDeclarationValue(declaration: IDeclarationWithAST, value: string, important: boolean): boolean;
|
|
44
44
|
insertDeclarationIntoRule(rule: IRuleWithAST, property: string, value: string, important: boolean): boolean;
|
|
45
45
|
removeDeclarationFromRule(rule: IRuleWithAST, property: string): boolean;
|
|
46
|
+
updateCompleteStylesheet(name: string, newStyle: string): void;
|
|
46
47
|
private rulesFromAST;
|
|
47
48
|
private astHasChildren;
|
|
48
49
|
private buildSelectorString;
|
|
@@ -93,19 +93,21 @@ export class CssTreeStylesheetService extends AbstractStylesheetService {
|
|
|
93
93
|
updateDeclarationValue(declaration, value, important) {
|
|
94
94
|
let sourceNode = this._stylesheets.get(declaration.parent.stylesheetName);
|
|
95
95
|
declaration.ast.value = window.csstree.toPlainObject(window.csstree.parse(declaration.name + ": " + value + (important ? " !important" : ""), { context: 'declaration', parseValue: false })).value;
|
|
96
|
+
const old = sourceNode.stylesheet.content;
|
|
96
97
|
sourceNode.stylesheet.content = window.csstree.generate(window.csstree.fromPlainObject(sourceNode.ast));
|
|
97
98
|
// After generating the stylesheet, parse again (so line numbers are correct)
|
|
98
99
|
sourceNode.ast = window.csstree.toPlainObject((window.csstree.parse(sourceNode.stylesheet.content, { positions: true, parseValue: false })));
|
|
99
|
-
this.stylesheetChanged.emit({ stylesheet: sourceNode.stylesheet });
|
|
100
|
+
this.stylesheetChanged.emit({ name: sourceNode.stylesheet.name, newStyle: sourceNode.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
|
|
100
101
|
return true;
|
|
101
102
|
}
|
|
102
103
|
insertDeclarationIntoRule(rule, property, value, important) {
|
|
103
104
|
let sourceNode = this._stylesheets.get(rule.stylesheetName);
|
|
104
105
|
rule.ast.block.children.push(window.csstree.toPlainObject(window.csstree.parse(property + ": " + value + (important ? " !important" : ""), { context: 'declaration', parseValue: false })));
|
|
106
|
+
const old = sourceNode.stylesheet.content;
|
|
105
107
|
sourceNode.stylesheet.content = window.csstree.generate(window.csstree.fromPlainObject(sourceNode.ast));
|
|
106
108
|
// After generating the stylesheet, parse again (so line numbers are correct)
|
|
107
109
|
sourceNode.ast = window.csstree.toPlainObject((window.csstree.parse(sourceNode.stylesheet.content, { positions: true, parseValue: false })));
|
|
108
|
-
this.stylesheetChanged.emit({ stylesheet: sourceNode.stylesheet });
|
|
110
|
+
this.stylesheetChanged.emit({ name: sourceNode.stylesheet.name, newStyle: sourceNode.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
|
|
109
111
|
return true;
|
|
110
112
|
}
|
|
111
113
|
removeDeclarationFromRule(rule, property) {
|
|
@@ -113,12 +115,22 @@ export class CssTreeStylesheetService extends AbstractStylesheetService {
|
|
|
113
115
|
if (index == -1)
|
|
114
116
|
return false;
|
|
115
117
|
rule.ast.block.children.splice(index, 1);
|
|
116
|
-
|
|
118
|
+
const ss = this._stylesheets.get(rule.stylesheetName);
|
|
119
|
+
const old = ss.stylesheet.content;
|
|
120
|
+
ss.stylesheet.content = window.csstree.generate(window.csstree.fromPlainObject(this._stylesheets.get(rule.stylesheetName).ast));
|
|
117
121
|
// After generating the stylesheet, parse again (so line numbers are correct)
|
|
118
|
-
|
|
119
|
-
this.stylesheetChanged.emit({
|
|
122
|
+
ss.ast = window.csstree.toPlainObject((window.csstree.parse(this._stylesheets.get(rule.stylesheetName).stylesheet.content, { positions: true, parseValue: false })));
|
|
123
|
+
this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
|
|
120
124
|
return true;
|
|
121
125
|
}
|
|
126
|
+
updateCompleteStylesheet(name, newStyle) {
|
|
127
|
+
const ss = this._stylesheets.get(name);
|
|
128
|
+
if (ss.stylesheet.content != newStyle) {
|
|
129
|
+
const old = ss.stylesheet.content;
|
|
130
|
+
ss.stylesheet.content = newStyle;
|
|
131
|
+
this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
122
134
|
/* Section covers the internal traversal creation of rules and declarations */
|
|
123
135
|
*rulesFromAST(ast, stylesheet, source, designItem, previousCheck = '') {
|
|
124
136
|
let parent = ast["children"] != null ? ast : ast.block;
|
|
@@ -24,8 +24,12 @@ export interface IStylesheetService {
|
|
|
24
24
|
updateDeclarationValue(declaration: IStyleDeclaration, value: string, important: boolean): boolean;
|
|
25
25
|
insertDeclarationIntoRule(rule: IStyleRule, property: string, value: string, important: boolean): boolean;
|
|
26
26
|
removeDeclarationFromRule(rule: IStyleRule, property: string): boolean;
|
|
27
|
+
updateCompleteStylesheet(name: string, newStyle: string): void;
|
|
27
28
|
stylesheetChanged: TypedEvent<{
|
|
28
|
-
|
|
29
|
+
name: string;
|
|
30
|
+
newStyle: string;
|
|
31
|
+
oldStyle: string;
|
|
32
|
+
changeSource: 'extern' | 'styleupdate';
|
|
29
33
|
}>;
|
|
30
34
|
stylesheetsChanged: TypedEvent<void>;
|
|
31
35
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ITransactionItem } from '../ITransactionItem.js';
|
|
2
|
+
import { IDesignItem } from '../../../item/IDesignItem.js';
|
|
3
|
+
export declare class CssStyleChangeAction implements ITransactionItem {
|
|
4
|
+
constructor(designItem: IDesignItem, name: string, newValue: any, oldValue: any);
|
|
5
|
+
title?: string;
|
|
6
|
+
get affectedItems(): IDesignItem[];
|
|
7
|
+
undo(): void;
|
|
8
|
+
do(): void;
|
|
9
|
+
designItem: IDesignItem;
|
|
10
|
+
name: string;
|
|
11
|
+
newValue: any;
|
|
12
|
+
oldValue: any;
|
|
13
|
+
mergeWith(other: ITransactionItem): boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export class CssStyleChangeAction {
|
|
2
|
+
constructor(designItem, name, newValue, oldValue) {
|
|
3
|
+
this.title = "Change Css Style " + name + " of <" + designItem.name + ">";
|
|
4
|
+
this.designItem = designItem;
|
|
5
|
+
this.name = name;
|
|
6
|
+
this.newValue = newValue;
|
|
7
|
+
this.oldValue = oldValue;
|
|
8
|
+
}
|
|
9
|
+
title;
|
|
10
|
+
get affectedItems() {
|
|
11
|
+
return [this.designItem];
|
|
12
|
+
}
|
|
13
|
+
undo() {
|
|
14
|
+
if (this.oldValue === '' || this.oldValue == null) {
|
|
15
|
+
this.designItem._withoutUndoRemoveStyle(this.name);
|
|
16
|
+
this.designItem.element.style[this.name] = '';
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
this.designItem._withoutUndoSetStyle(this.name, this.oldValue);
|
|
20
|
+
this.designItem.element.style[this.name] = this.oldValue;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
do() {
|
|
24
|
+
if (this.newValue === '' || this.newValue == null) {
|
|
25
|
+
this.designItem._withoutUndoRemoveStyle(this.name);
|
|
26
|
+
this.designItem.element.style[this.name] = '';
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
this.designItem._withoutUndoSetStyle(this.name, this.newValue);
|
|
30
|
+
this.designItem.element.style[this.name] = this.newValue;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
designItem;
|
|
34
|
+
name;
|
|
35
|
+
newValue;
|
|
36
|
+
oldValue;
|
|
37
|
+
mergeWith(other) {
|
|
38
|
+
if (other instanceof CssStyleChangeAction && this.designItem === other.designItem && this.name === other.name) {
|
|
39
|
+
this.newValue = other.newValue;
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IStylesheetService } from '../../stylesheetService/IStylesheetService.js';
|
|
2
|
+
import { ITransactionItem } from '../ITransactionItem.js';
|
|
3
|
+
export declare class StylesheetChangedAction implements ITransactionItem {
|
|
4
|
+
private stylesheetService;
|
|
5
|
+
constructor(stylesheetService: IStylesheetService, name: string, newValue: string, oldValue: string);
|
|
6
|
+
title?: string;
|
|
7
|
+
get affectedItems(): any[];
|
|
8
|
+
undo(): void;
|
|
9
|
+
do(): void;
|
|
10
|
+
name: string;
|
|
11
|
+
newValue: string;
|
|
12
|
+
oldValue: string;
|
|
13
|
+
mergeWith(other: ITransactionItem): boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class StylesheetChangedAction {
|
|
2
|
+
stylesheetService;
|
|
3
|
+
constructor(stylesheetService, name, newValue, oldValue) {
|
|
4
|
+
this.title = "Changed Css Stylesheet: " + name;
|
|
5
|
+
this.stylesheetService = stylesheetService;
|
|
6
|
+
this.name = name;
|
|
7
|
+
this.newValue = newValue;
|
|
8
|
+
this.oldValue = oldValue;
|
|
9
|
+
}
|
|
10
|
+
title;
|
|
11
|
+
get affectedItems() {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
undo() {
|
|
15
|
+
this.stylesheetService.updateCompleteStylesheet(this.name, this.oldValue);
|
|
16
|
+
}
|
|
17
|
+
do() {
|
|
18
|
+
this.stylesheetService.updateCompleteStylesheet(this.name, this.newValue);
|
|
19
|
+
}
|
|
20
|
+
name;
|
|
21
|
+
newValue;
|
|
22
|
+
oldValue;
|
|
23
|
+
mergeWith(other) { return false; }
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ITransactionItem } from '../ITransactionItem.js';
|
|
2
|
+
import { IDesignItem } from '../../../item/IDesignItem.js';
|
|
3
|
+
import { IStyleDeclaration, IStylesheetService } from '../../stylesheetService/IStylesheetService.js';
|
|
4
|
+
export declare class StylesheetStyleChangeAction implements ITransactionItem {
|
|
5
|
+
private stylesheetService;
|
|
6
|
+
private declaration;
|
|
7
|
+
constructor(stylesheetService: IStylesheetService, declaration: IStyleDeclaration, newValue: any, oldValue: any);
|
|
8
|
+
title?: string;
|
|
9
|
+
get affectedItems(): any[];
|
|
10
|
+
undo(): void;
|
|
11
|
+
do(): void;
|
|
12
|
+
designItem: IDesignItem;
|
|
13
|
+
name: string;
|
|
14
|
+
newValue: any;
|
|
15
|
+
oldValue: any;
|
|
16
|
+
mergeWith(other: ITransactionItem): boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class StylesheetStyleChangeAction {
|
|
2
|
+
stylesheetService;
|
|
3
|
+
declaration;
|
|
4
|
+
constructor(stylesheetService, declaration, newValue, oldValue) {
|
|
5
|
+
this.title = "Change Css Style " + declaration.name + " to " + newValue;
|
|
6
|
+
this.stylesheetService = stylesheetService;
|
|
7
|
+
this.declaration = declaration;
|
|
8
|
+
this.newValue = newValue;
|
|
9
|
+
this.oldValue = oldValue;
|
|
10
|
+
}
|
|
11
|
+
title;
|
|
12
|
+
get affectedItems() {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
undo() {
|
|
16
|
+
this.stylesheetService.updateDeclarationValue(this.declaration, this.oldValue, false);
|
|
17
|
+
}
|
|
18
|
+
do() {
|
|
19
|
+
this.stylesheetService.updateDeclarationValue(this.declaration, this.newValue, false);
|
|
20
|
+
}
|
|
21
|
+
designItem;
|
|
22
|
+
name;
|
|
23
|
+
newValue;
|
|
24
|
+
oldValue;
|
|
25
|
+
mergeWith(other) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -3,7 +3,7 @@ import { CommandType } from '../../../commandHandling/CommandType.js';
|
|
|
3
3
|
export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
4
4
|
static _initalized;
|
|
5
5
|
dispose() {
|
|
6
|
-
this._monacoEditor
|
|
6
|
+
this._monacoEditor?.dispose();
|
|
7
7
|
}
|
|
8
8
|
canvasElement;
|
|
9
9
|
elementsToPackages;
|
|
@@ -18,6 +18,7 @@ import { OverlayLayer } from './extensions/OverlayLayer.js';
|
|
|
18
18
|
import { OverlayLayerView } from './overlayLayerView.js';
|
|
19
19
|
import { ContextMenu } from '../../helper/contextMenu/ContextMenu.js';
|
|
20
20
|
import { NodeType } from '../../item/NodeType.js';
|
|
21
|
+
import { StylesheetChangedAction } from '../../services/undoService/transactionItems/StylesheetChangedAction.js';
|
|
21
22
|
export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
22
23
|
// Public Properties
|
|
23
24
|
serviceContainer;
|
|
@@ -433,8 +434,16 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
433
434
|
this.instanceServiceContainer.servicesChanged.on(e => {
|
|
434
435
|
if (e.serviceName == 'stylesheetService') {
|
|
435
436
|
this.applyAllStyles();
|
|
436
|
-
this.instanceServiceContainer.stylesheetService.stylesheetChanged.on(() =>
|
|
437
|
-
|
|
437
|
+
this.instanceServiceContainer.stylesheetService.stylesheetChanged.on((ss) => {
|
|
438
|
+
if (ss.changeSource == 'extern') {
|
|
439
|
+
const ssca = new StylesheetChangedAction(this.instanceServiceContainer.stylesheetService, ss.name, ss.newStyle, ss.oldStyle);
|
|
440
|
+
this.instanceServiceContainer.undoService.execute(ssca);
|
|
441
|
+
}
|
|
442
|
+
this.applyAllStyles();
|
|
443
|
+
});
|
|
444
|
+
this.instanceServiceContainer.stylesheetService.stylesheetsChanged.on(() => {
|
|
445
|
+
this.applyAllStyles();
|
|
446
|
+
});
|
|
438
447
|
}
|
|
439
448
|
});
|
|
440
449
|
this.extensionManager = new ExtensionManager(this);
|
|
@@ -689,8 +698,11 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
689
698
|
di.setStyle('position', 'absolute');
|
|
690
699
|
const containerService = this.serviceContainer.getLastServiceWhere('containerService', x => x.serviceForContainer(newContainer, getComputedStyle(newContainer.element)));
|
|
691
700
|
containerService.enterContainer(newContainer, [di]);
|
|
692
|
-
|
|
693
|
-
|
|
701
|
+
const containerPos = this.getNormalizedElementCoordinates(newContainer.element);
|
|
702
|
+
const evCoord = this.getNormalizedEventCoordinates(event);
|
|
703
|
+
const pos = { x: evCoord.x - containerPos.x, y: evCoord.y - containerPos.y };
|
|
704
|
+
containerService.place(event, this, newContainer, { x: 0, y: 0 }, { x: 0, y: 0 }, pos, [di]);
|
|
705
|
+
containerService.finishPlace(event, this, newContainer, { x: 0, y: 0 }, { x: 0, y: 0 }, pos, [di]);
|
|
694
706
|
this.instanceServiceContainer.undoService.execute(new InsertAction(newContainer, newContainer.childCount, di));
|
|
695
707
|
requestAnimationFrame(() => {
|
|
696
708
|
this.instanceServiceContainer.selectionService.setSelectedElements([di]);
|
package/dist/index.d.ts
CHANGED
|
@@ -116,6 +116,8 @@ export * from "./elements/services/undoService/transactionItems/CssStyleChangeAc
|
|
|
116
116
|
export * from "./elements/services/undoService/transactionItems/DeleteAction.js";
|
|
117
117
|
export * from "./elements/services/undoService/transactionItems/InsertAction.js";
|
|
118
118
|
export * from "./elements/services/undoService/transactionItems/InsertChildAction.js";
|
|
119
|
+
export * from "./elements/services/undoService/transactionItems/StylesheetChangedAction.js";
|
|
120
|
+
export * from "./elements/services/undoService/transactionItems/StylesheetStyleChangeAction.js";
|
|
119
121
|
export * from "./elements/services/BaseServiceContainer.js";
|
|
120
122
|
export * from "./elements/services/InstanceServiceContainer.js";
|
|
121
123
|
export type { IService } from "./elements/services/IService.js";
|
package/dist/index.js
CHANGED
|
@@ -80,6 +80,8 @@ export * from "./elements/services/undoService/transactionItems/CssStyleChangeAc
|
|
|
80
80
|
export * from "./elements/services/undoService/transactionItems/DeleteAction.js";
|
|
81
81
|
export * from "./elements/services/undoService/transactionItems/InsertAction.js";
|
|
82
82
|
export * from "./elements/services/undoService/transactionItems/InsertChildAction.js";
|
|
83
|
+
export * from "./elements/services/undoService/transactionItems/StylesheetChangedAction.js";
|
|
84
|
+
export * from "./elements/services/undoService/transactionItems/StylesheetStyleChangeAction.js";
|
|
83
85
|
export * from "./elements/services/BaseServiceContainer.js";
|
|
84
86
|
export * from "./elements/services/InstanceServiceContainer.js";
|
|
85
87
|
export * from "./elements/services/ServiceContainer.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "A UI designer for Polymer apps",
|
|
3
3
|
"name": "@node-projects/web-component-designer",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.205",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "",
|
|
@@ -25,7 +25,7 @@
|
|
|
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.
|
|
28
|
+
"@types/node": "^18.14.2",
|
|
29
29
|
"ace-builds": "^1.15.2",
|
|
30
30
|
"codemirror": "^6.0.1",
|
|
31
31
|
"css-tree": "^2.3.1",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"jquery": "^3.6.3",
|
|
36
36
|
"jquery.fancytree": "^2.38.3",
|
|
37
37
|
"mdn-data": "^2.0.31",
|
|
38
|
-
"monaco-editor": "^0.
|
|
38
|
+
"monaco-editor": "^0.36.1",
|
|
39
39
|
"ts-jest": "^29.0.5",
|
|
40
40
|
"typescript": "^4.9.5",
|
|
41
41
|
"typescript-lit-html-plugin": "^0.9.0"
|