@node-projects/web-component-designer 0.0.203 → 0.0.204
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/item/DesignItem.js +6 -3
- package/dist/elements/services/DefaultServiceBootstrap.js +1 -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/CssToolsStylesheetService.d.ts +1 -3
- package/dist/elements/services/stylesheetService/CssToolsStylesheetService.js +1 -1
- package/dist/elements/widgets/designerView/designerCanvas.js +5 -2
- package/package.json +1 -1
|
@@ -373,10 +373,13 @@ export class DesignItem {
|
|
|
373
373
|
return [];
|
|
374
374
|
const localStyles = [...this._styles.entries()].map(x => ({ name: x[0], value: x[1], important: false, parent: null }));
|
|
375
375
|
if (this.instanceServiceContainer.stylesheetService) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
376
|
+
try {
|
|
377
|
+
const rules = this.instanceServiceContainer.stylesheetService?.getAppliedRules(this);
|
|
378
|
+
if (rules) {
|
|
379
|
+
return [{ selector: null, declarations: localStyles, specificity: -1 }, ...rules];
|
|
380
|
+
}
|
|
379
381
|
}
|
|
382
|
+
catch (err) { }
|
|
380
383
|
}
|
|
381
384
|
return [{ selector: null, declarations: localStyles, specificity: -1 }];
|
|
382
385
|
}
|
|
@@ -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, [
|
|
@@ -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) {
|
|
@@ -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[];
|
|
@@ -39,7 +39,7 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
|
|
|
39
39
|
let rs = Array.from(this.getRulesFromAst(item[1].ast?.stylesheet?.rules, item[1].stylesheet, designItem))
|
|
40
40
|
.map(x => ({
|
|
41
41
|
selector: x.selectors.join(', '),
|
|
42
|
-
declarations: x.declarations.map(y => ({
|
|
42
|
+
declarations: x.declarations.filter(y => y.type == 'declaration').map(y => ({
|
|
43
43
|
name: y.property,
|
|
44
44
|
value: y.value.endsWith('!important') ? y.value.substring(0, y.value.length - 10).trimEnd() : y.value,
|
|
45
45
|
important: y.value.endsWith('!important'),
|
|
@@ -689,8 +689,11 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
689
689
|
di.setStyle('position', 'absolute');
|
|
690
690
|
const containerService = this.serviceContainer.getLastServiceWhere('containerService', x => x.serviceForContainer(newContainer, getComputedStyle(newContainer.element)));
|
|
691
691
|
containerService.enterContainer(newContainer, [di]);
|
|
692
|
-
|
|
693
|
-
|
|
692
|
+
const containerPos = this.getNormalizedElementCoordinates(newContainer.element);
|
|
693
|
+
const evCoord = this.getNormalizedEventCoordinates(event);
|
|
694
|
+
const pos = { x: evCoord.x - containerPos.x, y: evCoord.y - containerPos.y };
|
|
695
|
+
containerService.place(event, this, newContainer, { x: 0, y: 0 }, { x: 0, y: 0 }, pos, [di]);
|
|
696
|
+
containerService.finishPlace(event, this, newContainer, { x: 0, y: 0 }, { x: 0, y: 0 }, pos, [di]);
|
|
694
697
|
this.instanceServiceContainer.undoService.execute(new InsertAction(newContainer, newContainer.childCount, di));
|
|
695
698
|
requestAnimationFrame(() => {
|
|
696
699
|
this.instanceServiceContainer.selectionService.setSelectedElements([di]);
|