@node-projects/web-component-designer 0.0.72 → 0.0.76
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/README.md +2 -2
- package/dist/elements/item/DesignItem.d.ts +5 -1
- package/dist/elements/item/DesignItem.js +56 -29
- package/dist/elements/item/IDesignItem.d.ts +4 -0
- package/dist/elements/services/BaseServiceContainer.d.ts +1 -0
- package/dist/elements/services/BaseServiceContainer.js +7 -0
- package/dist/elements/services/demoProviderService/DemoProviderService.js +1 -1
- package/dist/elements/services/elementsService/IElementDefinition.d.ts +2 -0
- package/dist/elements/services/elementsService/IElementsJson.d.ts +1 -0
- package/dist/elements/services/htmlParserService/NodeHtmlParserService.js +1 -1
- package/dist/elements/services/instanceService/DefaultInstanceService.js +1 -1
- package/dist/elements/services/manifestLoaders/WebcomponentManifestParserService.d.ts +26 -0
- package/dist/elements/services/manifestLoaders/WebcomponentManifestParserService.js +69 -0
- package/dist/elements/services/manifestParsers/WebcomponentManifestParserService.d.ts +23 -0
- package/dist/elements/services/manifestParsers/WebcomponentManifestParserService.js +80 -0
- package/dist/elements/services/modelCommandService/DefaultModelCommandService.js +12 -8
- package/dist/elements/services/placementService/SnaplinesProviderService.d.ts +2 -0
- package/dist/elements/services/placementService/SnaplinesProviderService.js +10 -0
- package/dist/elements/services/propertiesService/DefaultEditorTypesService.js +0 -1
- package/dist/elements/services/propertiesService/IPropertiesService.d.ts +0 -1
- package/dist/elements/services/propertiesService/IProperty.d.ts +5 -1
- package/dist/elements/services/propertiesService/PropertyType.d.ts +6 -0
- package/dist/elements/services/propertiesService/PropertyType.js +7 -0
- package/dist/elements/services/propertiesService/services/AbstractBasePropertiesService.js +7 -6
- package/dist/elements/services/propertiesService/services/AttributesPropertiesService.js +3 -2
- package/dist/elements/services/propertiesService/services/CommonPropertiesService.js +11 -4
- package/dist/elements/services/propertiesService/services/CssPropertiesService.js +81 -41
- package/dist/elements/services/propertiesService/services/IJsonPropertyDefinition.d.ts +4 -0
- package/dist/elements/services/propertiesService/services/ListPropertiesService.js +5 -1
- package/dist/elements/services/propertiesService/services/Lit2PropertiesService.js +7 -6
- package/dist/elements/services/propertiesService/services/NativeElementsPropertiesService.js +25 -12
- package/dist/elements/services/propertiesService/services/UnkownElementPropertiesService.d.ts +1 -2
- package/dist/elements/services/propertiesService/services/UnkownElementPropertiesService.js +1 -1
- package/dist/elements/services/undoService/transactionItems/DeleteAction.d.ts +1 -3
- package/dist/elements/services/undoService/transactionItems/DeleteAction.js +2 -5
- package/dist/elements/services/undoService/transactionItems/InsertAction.js +1 -1
- package/dist/elements/services/undoService/transactionItems/InsertChildAction.d.ts +16 -0
- package/dist/elements/services/undoService/transactionItems/InsertChildAction.js +31 -0
- package/dist/elements/services/webcomponentManifestParserService/WebcomponentManifestParserService.1.d.ts +0 -0
- package/dist/elements/services/webcomponentManifestParserService/WebcomponentManifestParserService.1.js +1 -0
- package/dist/elements/services/webcomponentManifestParserService/webcomponentManifestParserService.d.ts +26 -0
- package/dist/elements/services/webcomponentManifestParserService/webcomponentManifestParserService.js +69 -0
- package/dist/elements/widgets/bindableObjectsBrowser/bindable-objects-browser.js +2 -3
- package/dist/elements/widgets/codeView/code-view-code-mirror.js +6 -7
- package/dist/elements/widgets/codeView/code-view-monaco.js +6 -4
- package/dist/elements/widgets/designerView/designerCanvas.js +8 -2
- package/dist/elements/widgets/designerView/tools/PointerTool.js +1 -1
- package/dist/elements/widgets/paletteView/paletteTreeView.js +15 -11
- package/dist/elements/widgets/paletteView/paletteView.js +10 -5
- package/dist/elements/widgets/treeView/treeViewExtended.js +2 -8
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -1
- package/dist/interfaces/ICommandHandler.d.ts +5 -0
- package/dist/interfaces/ICommandHandler.js +1 -0
- package/package.json +2 -1
- package/dist/elements/services/undoService/transactionItems/MoveElementInDomAction.d.ts +0 -16
- package/dist/elements/services/undoService/transactionItems/MoveElementInDomAction.js +0 -31
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# web-component-designer
|
|
2
2
|
|
|
3
|
-
## Caution - this is a preview Version, a RC is planed for
|
|
3
|
+
## Caution - this is a preview Version, a RC is planed for January 2022
|
|
4
4
|
|
|
5
5
|
A HTML WebComponent for Designing Webcomponents and HTML Pages.
|
|
6
6
|
|
|
@@ -81,4 +81,4 @@ Your addition to your index.html should look like this:
|
|
|
81
81
|
The Library uses Images from the Chrome Dev Tools, see
|
|
82
82
|
https://github.com/ChromeDevTools/devtools-frontend/tree/main/front_end/Images/src
|
|
83
83
|
and
|
|
84
|
-
https://github.com/ChromeDevTools/devtools-frontend/blob/main/LICENSE
|
|
84
|
+
https://github.com/ChromeDevTools/devtools-frontend/blob/main/LICENSE
|
|
@@ -24,12 +24,14 @@ export declare class DesignItem implements IDesignItem {
|
|
|
24
24
|
get id(): string;
|
|
25
25
|
set id(value: string);
|
|
26
26
|
get isRootItem(): boolean;
|
|
27
|
-
|
|
27
|
+
_childArray: IDesignItem[];
|
|
28
28
|
get hasChildren(): boolean;
|
|
29
29
|
children(): IterableIterator<IDesignItem>;
|
|
30
30
|
get childCount(): number;
|
|
31
31
|
get firstChild(): IDesignItem;
|
|
32
32
|
get parent(): IDesignItem;
|
|
33
|
+
indexOf(designItem: IDesignItem): number;
|
|
34
|
+
insertAdjacentElement(designItem: IDesignItem, where: InsertPosition): void;
|
|
33
35
|
insertChild(designItem: IDesignItem, index?: number): void;
|
|
34
36
|
removeChild(designItem: IDesignItem): void;
|
|
35
37
|
remove(): void;
|
|
@@ -57,4 +59,6 @@ export declare class DesignItem implements IDesignItem {
|
|
|
57
59
|
removeStyle(name: string): void;
|
|
58
60
|
setAttribute(name: string, value?: string | null): void;
|
|
59
61
|
removeAttribute(name: string): void;
|
|
62
|
+
_insertChildInternal(designItem: IDesignItem, index?: number): void;
|
|
63
|
+
_removeChildInternal(designItem: IDesignItem): void;
|
|
60
64
|
}
|
|
@@ -2,9 +2,10 @@ import { CssStyleChangeAction } from '../services/undoService/transactionItems/C
|
|
|
2
2
|
import { NodeType } from './NodeType';
|
|
3
3
|
import { AttributeChangeAction } from '../services/undoService/transactionItems/AttributeChangeAction';
|
|
4
4
|
import { ExtensionType } from '../widgets/designerView/extensions/ExtensionType';
|
|
5
|
-
import { DomHelper } from '@node-projects/base-custom-webcomponent/dist/DomHelper';
|
|
6
5
|
import { CssAttributeParser } from '../helper/CssAttributeParser.js';
|
|
7
6
|
import { PropertiesHelper } from '../services/propertiesService/services/PropertiesHelper.js';
|
|
7
|
+
import { InsertChildAction } from '../services/undoService/transactionItems/InsertChildAction';
|
|
8
|
+
import { DeleteAction } from '../..';
|
|
8
9
|
const hideAtDesignTimeAttributeName = 'node-projects-hide-at-design-time';
|
|
9
10
|
const hideAtRunTimeAttributeName = 'node-projects-hide-at-run-time';
|
|
10
11
|
const lockAtDesignTimeAttributeName = 'node-projects-lock-at-design-time';
|
|
@@ -69,44 +70,41 @@ export class DesignItem {
|
|
|
69
70
|
get parent() {
|
|
70
71
|
return this.getOrCreateDesignItem(this.element.parentNode);
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (
|
|
77
|
-
|
|
73
|
+
indexOf(designItem) {
|
|
74
|
+
return this._childArray.indexOf(designItem);
|
|
75
|
+
}
|
|
76
|
+
insertAdjacentElement(designItem, where) {
|
|
77
|
+
if (where == 'afterbegin') {
|
|
78
|
+
this._insertChildInternal(designItem, 0);
|
|
78
79
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this._childArray.push(designItem);
|
|
82
|
-
this.element.appendChild(designItem.node);
|
|
80
|
+
else if (where == 'beforeend') {
|
|
81
|
+
this._insertChildInternal(designItem);
|
|
83
82
|
}
|
|
84
|
-
else {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
else if (where == 'beforebegin') {
|
|
84
|
+
this.parent._insertChildInternal(designItem, this.parent.indexOf(this));
|
|
85
|
+
}
|
|
86
|
+
else if (where == 'afterend') {
|
|
87
|
+
this.parent._insertChildInternal(designItem, this.parent.indexOf(this) + 1);
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
}
|
|
90
|
+
insertChild(designItem, index) {
|
|
91
|
+
const action = new InsertChildAction(designItem, this, index);
|
|
92
|
+
this.instanceServiceContainer.undoService.execute(action);
|
|
91
93
|
}
|
|
92
94
|
removeChild(designItem) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
designItem.instanceServiceContainer.designerCanvas.extensionManager.removeExtension(designItem.parent, ExtensionType.PrimarySelectionContainer);
|
|
96
|
-
const index = this._childArray.indexOf(designItem);
|
|
97
|
-
if (index > -1) {
|
|
98
|
-
this._childArray.splice(index, 1);
|
|
99
|
-
designItem.element.remove();
|
|
100
|
-
}
|
|
95
|
+
const action = new DeleteAction([designItem]);
|
|
96
|
+
this.instanceServiceContainer.undoService.execute(action);
|
|
101
97
|
}
|
|
102
98
|
remove() {
|
|
103
|
-
this.parent.
|
|
99
|
+
this.parent._removeChildInternal(this);
|
|
104
100
|
}
|
|
105
101
|
clearChildren() {
|
|
106
|
-
this._childArray
|
|
107
|
-
|
|
102
|
+
for (let i = this._childArray.length - 1; i >= 0; i--) {
|
|
103
|
+
let di = this._childArray[i];
|
|
104
|
+
di.remove();
|
|
105
|
+
}
|
|
108
106
|
}
|
|
109
|
-
//abstract text content to own property. so only
|
|
107
|
+
//abstract text content to own property. so only change via designer api will use it.
|
|
110
108
|
get hasContent() {
|
|
111
109
|
return this.nodeType == NodeType.TextNode || (this._childArray.length === 0 && this.content !== null);
|
|
112
110
|
}
|
|
@@ -259,4 +257,33 @@ export class DesignItem {
|
|
|
259
257
|
const action = new AttributeChangeAction(this, name, null, this.attributes.get(name));
|
|
260
258
|
this.instanceServiceContainer.undoService.execute(action);
|
|
261
259
|
}
|
|
260
|
+
// Internal implementations wich don't use undo/redo
|
|
261
|
+
_insertChildInternal(designItem, index) {
|
|
262
|
+
if (designItem.parent && this.instanceServiceContainer.selectionService.primarySelection == designItem)
|
|
263
|
+
designItem.instanceServiceContainer.designerCanvas.extensionManager.removeExtension(designItem.parent, ExtensionType.PrimarySelectionContainer);
|
|
264
|
+
if (designItem.parent) {
|
|
265
|
+
designItem.parent._removeChildInternal(designItem);
|
|
266
|
+
}
|
|
267
|
+
if (index == null || this._childArray.length == 0 || index >= this._childArray.length) {
|
|
268
|
+
this._childArray.push(designItem);
|
|
269
|
+
this.element.appendChild(designItem.node);
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
let el = this._childArray[index];
|
|
273
|
+
this.node.insertBefore(designItem.node, el.element);
|
|
274
|
+
this._childArray.splice(index, 0, designItem);
|
|
275
|
+
}
|
|
276
|
+
if (this.instanceServiceContainer.selectionService.primarySelection == designItem)
|
|
277
|
+
designItem.instanceServiceContainer.designerCanvas.extensionManager.applyExtension(designItem.parent, ExtensionType.PrimarySelectionContainer);
|
|
278
|
+
}
|
|
279
|
+
_removeChildInternal(designItem) {
|
|
280
|
+
if (designItem.parent && this.instanceServiceContainer.selectionService.primarySelection == designItem)
|
|
281
|
+
designItem.instanceServiceContainer.designerCanvas.extensionManager.removeExtension(designItem.parent, ExtensionType.PrimarySelectionContainer);
|
|
282
|
+
designItem.instanceServiceContainer.designerCanvas.extensionManager.removeExtensions([designItem]);
|
|
283
|
+
const index = this._childArray.indexOf(designItem);
|
|
284
|
+
if (index > -1) {
|
|
285
|
+
this._childArray.splice(index, 1);
|
|
286
|
+
designItem.element.remove();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
262
289
|
}
|
|
@@ -21,6 +21,10 @@ export interface IDesignItem {
|
|
|
21
21
|
readonly childCount: number;
|
|
22
22
|
readonly firstChild: IDesignItem;
|
|
23
23
|
readonly parent: IDesignItem;
|
|
24
|
+
_insertChildInternal(designItem: IDesignItem, index?: number): any;
|
|
25
|
+
_removeChildInternal(designItem: IDesignItem): any;
|
|
26
|
+
indexOf(designItem: IDesignItem): number;
|
|
27
|
+
insertAdjacentElement(designItem: IDesignItem, where: InsertPosition): any;
|
|
24
28
|
insertChild(designItem: IDesignItem, index?: number): any;
|
|
25
29
|
removeChild(designItem: IDesignItem): any;
|
|
26
30
|
remove(): any;
|
|
@@ -4,6 +4,7 @@ export declare class BaseServiceContainer<NameMap> {
|
|
|
4
4
|
getLastService<K extends keyof NameMap>(service: K): NameMap[K];
|
|
5
5
|
getServices<K extends keyof NameMap>(service: K): NameMap[K][];
|
|
6
6
|
register<K extends keyof NameMap>(name: K, service: NameMap[K]): void;
|
|
7
|
+
registerMultiple<K extends keyof NameMap>(names: K[], service: NameMap[K]): void;
|
|
7
8
|
forSomeServicesTillResult<K extends keyof NameMap, Y>(service: K, callback: (service: NameMap[K]) => Y): Y;
|
|
8
9
|
getLastServiceWhere<K extends keyof NameMap, Y>(service: K, callback: (service: NameMap[K]) => Y): NameMap[K];
|
|
9
10
|
}
|
|
@@ -14,6 +14,13 @@ export class BaseServiceContainer {
|
|
|
14
14
|
this._services.set(name, []);
|
|
15
15
|
this._services.get(name).push(service);
|
|
16
16
|
}
|
|
17
|
+
registerMultiple(names, service) {
|
|
18
|
+
for (const name of names) {
|
|
19
|
+
if (!this._services.has(name))
|
|
20
|
+
this._services.set(name, []);
|
|
21
|
+
this._services.get(name).push(service);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
17
24
|
forSomeServicesTillResult(service, callback) {
|
|
18
25
|
let services = this.getServices(service);
|
|
19
26
|
if (services == null) {
|
|
@@ -21,7 +21,7 @@ export class DemoProviderService {
|
|
|
21
21
|
}
|
|
22
22
|
doc.write("document.body.style.display='';");
|
|
23
23
|
doc.write('</script>');
|
|
24
|
-
doc.write('<body style="display:none">' + code + '</body>');
|
|
24
|
+
doc.write('<body style="display:none; width: 100%; height: 100%; margin: 0; padding: 0; position: absolute;">' + code + '</body>');
|
|
25
25
|
doc.close();
|
|
26
26
|
});
|
|
27
27
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IBinding } from "../../item/IBinding";
|
|
1
2
|
export interface IElementDefinition {
|
|
2
3
|
tag: string;
|
|
3
4
|
name?: string;
|
|
@@ -28,4 +29,5 @@ export interface IElementDefinition {
|
|
|
28
29
|
* If none, the DrawElementTool is used
|
|
29
30
|
*/
|
|
30
31
|
tool?: string;
|
|
32
|
+
defaultBinding?: IBinding;
|
|
31
33
|
}
|
|
@@ -70,7 +70,7 @@ export class NodeHtmlParserService {
|
|
|
70
70
|
element.draggable = false; //even if it should be true, for better designer exp.
|
|
71
71
|
for (let c of item.childNodes) {
|
|
72
72
|
let di = this._createDesignItemsRecursive(c, serviceContainer, instanceServiceContainer, element instanceof SVGElement ? 'http://www.w3.org/2000/svg' : null);
|
|
73
|
-
designItem.
|
|
73
|
+
designItem._insertChildInternal(di);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
else if (item.nodeType == 3) {
|
|
@@ -53,7 +53,7 @@ export class DefaultInstanceService {
|
|
|
53
53
|
if (definition.defaultProperties) {
|
|
54
54
|
let propertiesService = null;
|
|
55
55
|
if (definition.type) {
|
|
56
|
-
propertiesService = serviceContainer.getLastServiceWhere('propertyService', (x) => x.
|
|
56
|
+
propertiesService = serviceContainer.getLastServiceWhere('propertyService', (x) => x.isHandledElement(designItem));
|
|
57
57
|
}
|
|
58
58
|
let properties = propertiesService.getProperties(designItem);
|
|
59
59
|
for (let a in definition.defaultProperties) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IDesignItem } from "../../..";
|
|
2
|
+
import { BindingTarget } from "../../item/BindingTarget";
|
|
3
|
+
import { IElementDefinition } from "../elementsService/IElementDefinition";
|
|
4
|
+
import { IElementsService } from "../elementsService/IElementsService";
|
|
5
|
+
import { IPropertiesService } from "../propertiesService/IPropertiesService";
|
|
6
|
+
import { IProperty } from "../propertiesService/IProperty";
|
|
7
|
+
import { ValueType } from "../propertiesService/ValueType";
|
|
8
|
+
export declare class WebcomponentManifestParserService implements IElementsService, IPropertiesService {
|
|
9
|
+
private _name;
|
|
10
|
+
get name(): string;
|
|
11
|
+
private _packageData;
|
|
12
|
+
private _elementList;
|
|
13
|
+
private _resolveStored;
|
|
14
|
+
private _rejectStored;
|
|
15
|
+
constructor(name: string, file: string);
|
|
16
|
+
getElements(): Promise<IElementDefinition[]>;
|
|
17
|
+
isHandledElement(designItem: IDesignItem): boolean;
|
|
18
|
+
getProperties(designItem: IDesignItem): IProperty[];
|
|
19
|
+
getProperty(designItem: IDesignItem, name: string): IProperty;
|
|
20
|
+
getPropertyTarget(designItem: IDesignItem, property: IProperty): BindingTarget;
|
|
21
|
+
setValue(designItems: IDesignItem[], property: IProperty, value: any): void;
|
|
22
|
+
clearValue(designItems: IDesignItem[], property: IProperty): void;
|
|
23
|
+
isSet(designItems: IDesignItem[], property: IProperty): ValueType;
|
|
24
|
+
getValue(designItems: IDesignItem[], property: IProperty): void;
|
|
25
|
+
getUnsetValue(designItems: IDesignItem[], property: IProperty): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export class WebcomponentManifestParserService {
|
|
2
|
+
_name;
|
|
3
|
+
get name() { return this._name; }
|
|
4
|
+
_packageData;
|
|
5
|
+
_elementList;
|
|
6
|
+
_resolveStored;
|
|
7
|
+
_rejectStored;
|
|
8
|
+
constructor(name, file) {
|
|
9
|
+
this._name = name;
|
|
10
|
+
import(file, { assert: { type: 'json' } }).then(module => {
|
|
11
|
+
this._packageData = module.default;
|
|
12
|
+
this._elementList = [];
|
|
13
|
+
for (let m of this._packageData.modules) {
|
|
14
|
+
for (let e of m.exports) {
|
|
15
|
+
if (e.kind == 'custom-element-definition') {
|
|
16
|
+
this._elementList.push({ tag: e.name });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (this._resolveStored) {
|
|
20
|
+
this._resolveStored.forEach(x => x(this._elementList));
|
|
21
|
+
this._resolveStored = null;
|
|
22
|
+
this._rejectStored = null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}).catch(err => {
|
|
26
|
+
if (this._rejectStored) {
|
|
27
|
+
this._rejectStored.forEach(x => x(err));
|
|
28
|
+
this._resolveStored = null;
|
|
29
|
+
this._rejectStored = null;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async getElements() {
|
|
34
|
+
if (this._packageData)
|
|
35
|
+
return Promise.resolve(this._elementList);
|
|
36
|
+
if (!this._resolveStored) {
|
|
37
|
+
this._resolveStored = [];
|
|
38
|
+
this._rejectStored = [];
|
|
39
|
+
}
|
|
40
|
+
return new Promise((resolve, reject) => { this._resolveStored.push(resolve); this._rejectStored.push(reject); });
|
|
41
|
+
}
|
|
42
|
+
isHandledElement(designItem) {
|
|
43
|
+
throw new Error("Method not implemented.");
|
|
44
|
+
}
|
|
45
|
+
getProperties(designItem) {
|
|
46
|
+
throw new Error("Method not implemented.");
|
|
47
|
+
}
|
|
48
|
+
getProperty(designItem, name) {
|
|
49
|
+
throw new Error("Method not implemented.");
|
|
50
|
+
}
|
|
51
|
+
getPropertyTarget(designItem, property) {
|
|
52
|
+
throw new Error("Method not implemented.");
|
|
53
|
+
}
|
|
54
|
+
setValue(designItems, property, value) {
|
|
55
|
+
throw new Error("Method not implemented.");
|
|
56
|
+
}
|
|
57
|
+
clearValue(designItems, property) {
|
|
58
|
+
throw new Error("Method not implemented.");
|
|
59
|
+
}
|
|
60
|
+
isSet(designItems, property) {
|
|
61
|
+
throw new Error("Method not implemented.");
|
|
62
|
+
}
|
|
63
|
+
getValue(designItems, property) {
|
|
64
|
+
throw new Error("Method not implemented.");
|
|
65
|
+
}
|
|
66
|
+
getUnsetValue(designItems, property) {
|
|
67
|
+
throw new Error("Method not implemented.");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BindingTarget } from "../../item/BindingTarget";
|
|
2
|
+
import { IElementDefinition } from "../elementsService/IElementDefinition";
|
|
3
|
+
import { IElementsService } from "../elementsService/IElementsService";
|
|
4
|
+
import { IPropertiesService } from "../propertiesService/IPropertiesService";
|
|
5
|
+
import { IProperty } from "../propertiesService/IProperty";
|
|
6
|
+
import { IDesignItem } from "../../item/IDesignItem";
|
|
7
|
+
import { UnkownElementPropertiesService } from "../propertiesService/services/UnkownElementPropertiesService";
|
|
8
|
+
export declare class WebcomponentManifestParserService extends UnkownElementPropertiesService implements IElementsService, IPropertiesService {
|
|
9
|
+
private _name;
|
|
10
|
+
get name(): string;
|
|
11
|
+
private _packageData;
|
|
12
|
+
private _elementList;
|
|
13
|
+
private _propertiesList;
|
|
14
|
+
private _resolveStored;
|
|
15
|
+
private _rejectStored;
|
|
16
|
+
constructor(name: string, file: string);
|
|
17
|
+
private manifestClassPropertyTypeToEditorPropertyType;
|
|
18
|
+
getElements(): Promise<IElementDefinition[]>;
|
|
19
|
+
isHandledElement(designItem: IDesignItem): boolean;
|
|
20
|
+
getProperties(designItem: IDesignItem): IProperty[];
|
|
21
|
+
getProperty(designItem: IDesignItem, name: string): IProperty;
|
|
22
|
+
getPropertyTarget(designItem: IDesignItem, property: IProperty): BindingTarget;
|
|
23
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { BindingTarget } from "../../item/BindingTarget";
|
|
2
|
+
import { PropertyType } from "../propertiesService/PropertyType";
|
|
3
|
+
import { UnkownElementPropertiesService } from "../propertiesService/services/UnkownElementPropertiesService";
|
|
4
|
+
export class WebcomponentManifestParserService extends UnkownElementPropertiesService {
|
|
5
|
+
_name;
|
|
6
|
+
get name() { return this._name; }
|
|
7
|
+
_packageData;
|
|
8
|
+
_elementList;
|
|
9
|
+
_propertiesList;
|
|
10
|
+
_resolveStored;
|
|
11
|
+
_rejectStored;
|
|
12
|
+
constructor(name, file) {
|
|
13
|
+
super();
|
|
14
|
+
this._name = name;
|
|
15
|
+
let path = file.split('/').slice(0, -1).join('/');
|
|
16
|
+
import(file, { assert: { type: 'json' } }).then(module => {
|
|
17
|
+
this._packageData = module.default;
|
|
18
|
+
this._elementList = [];
|
|
19
|
+
this._propertiesList = {};
|
|
20
|
+
for (let m of this._packageData.modules) {
|
|
21
|
+
for (let e of m.exports) {
|
|
22
|
+
if (e.kind == 'custom-element-definition') {
|
|
23
|
+
this._elementList.push({ tag: e.name, import: path + '/' + e.declaration.module });
|
|
24
|
+
let properties = [];
|
|
25
|
+
let declaration = m.declarations.find(x => x.name == e.declaration.name);
|
|
26
|
+
for (let d of declaration.members) {
|
|
27
|
+
if (d.kind == 'field') {
|
|
28
|
+
let pType = PropertyType.property;
|
|
29
|
+
pType = declaration.attributes.find(x => x.fieldName == d.name) != null ? PropertyType.propertyAndAttribute : PropertyType.property;
|
|
30
|
+
properties.push({ name: d.name, service: this, propertyType: pType, type: this.manifestClassPropertyTypeToEditorPropertyType(d.type?.text) });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
this._propertiesList[e.name] = properties;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (this._resolveStored) {
|
|
37
|
+
this._resolveStored.forEach(x => x(this._elementList));
|
|
38
|
+
this._resolveStored = null;
|
|
39
|
+
this._rejectStored = null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}).catch(err => {
|
|
43
|
+
if (this._rejectStored) {
|
|
44
|
+
this._rejectStored.forEach(x => x(err));
|
|
45
|
+
this._resolveStored = null;
|
|
46
|
+
this._rejectStored = null;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
manifestClassPropertyTypeToEditorPropertyType(type) {
|
|
51
|
+
if (type) {
|
|
52
|
+
if (type.toLowerCase() === 'boolean')
|
|
53
|
+
return 'boolean';
|
|
54
|
+
if (type.toLowerCase() === 'number')
|
|
55
|
+
return 'number';
|
|
56
|
+
}
|
|
57
|
+
return type;
|
|
58
|
+
}
|
|
59
|
+
async getElements() {
|
|
60
|
+
if (this._packageData)
|
|
61
|
+
return Promise.resolve(this._elementList);
|
|
62
|
+
if (!this._resolveStored) {
|
|
63
|
+
this._resolveStored = [];
|
|
64
|
+
this._rejectStored = [];
|
|
65
|
+
}
|
|
66
|
+
return new Promise((resolve, reject) => { this._resolveStored.push(resolve); this._rejectStored.push(reject); });
|
|
67
|
+
}
|
|
68
|
+
isHandledElement(designItem) {
|
|
69
|
+
return this._elementList.find(x => x.tag == designItem.name) != null;
|
|
70
|
+
}
|
|
71
|
+
getProperties(designItem) {
|
|
72
|
+
return this._propertiesList[designItem.name];
|
|
73
|
+
}
|
|
74
|
+
getProperty(designItem, name) {
|
|
75
|
+
return this._propertiesList[designItem.name].find(x => x.name == name);
|
|
76
|
+
}
|
|
77
|
+
getPropertyTarget(designItem, property) {
|
|
78
|
+
return this._propertiesList[designItem.name].find(x => x.name == property.name).propertyType == PropertyType.attribute ? BindingTarget.attribute : BindingTarget.property;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { CommandType } from "../../../commandHandling/CommandType.js";
|
|
2
|
-
import { DesignItem } from "../../item/DesignItem.js";
|
|
3
|
-
import { MoveElementInDomAction } from "../undoService/transactionItems/MoveElementInDomAction.js";
|
|
4
2
|
export class DefaultModelCommandService {
|
|
5
3
|
canExecuteCommand(designerCanvas, command) {
|
|
6
4
|
if (command.type == CommandType.moveBackward ||
|
|
@@ -21,14 +19,20 @@ export class DefaultModelCommandService {
|
|
|
21
19
|
}
|
|
22
20
|
async executeCommand(designerCanvas, command) {
|
|
23
21
|
let sel = designerCanvas.instanceServiceContainer.selectionService.primarySelection;
|
|
24
|
-
if (command.type == CommandType.moveBackward)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
if (command.type == CommandType.moveBackward) {
|
|
23
|
+
let idx = sel.parent.indexOf(sel) - 1;
|
|
24
|
+
if (idx >= 0)
|
|
25
|
+
sel.parent.insertChild(sel, idx);
|
|
26
|
+
}
|
|
27
|
+
else if (command.type == CommandType.moveForward) {
|
|
28
|
+
let idx = sel.parent.indexOf(sel) + 1;
|
|
29
|
+
if (idx < sel.parent.childCount)
|
|
30
|
+
sel.parent.insertChild(sel, idx);
|
|
31
|
+
}
|
|
28
32
|
else if (command.type == CommandType.moveToBack)
|
|
29
|
-
|
|
33
|
+
sel.parent.insertChild(sel, 0);
|
|
30
34
|
else if (command.type == CommandType.moveToFront)
|
|
31
|
-
|
|
35
|
+
sel.parent.insertChild(sel);
|
|
32
36
|
else if (command.type == CommandType.arrangeLeft) {
|
|
33
37
|
const grp = designerCanvas.instanceServiceContainer.selectionService.primarySelection.openGroup('arrangeLeft');
|
|
34
38
|
const left = designerCanvas.instanceServiceContainer.selectionService.primarySelection.styles.get('left');
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { IRect } from '../../../interfaces/IRect.js';
|
|
2
2
|
import type { IDesignItem } from '../../item/IDesignItem.js';
|
|
3
3
|
import { ISnaplinesProviderService } from './ISnaplinesProviderService.js';
|
|
4
|
+
export declare const provideSnaplinesWithDistance = "provideSnaplinesWithDistance";
|
|
5
|
+
export declare const provideSnaplinesWithDistanceDistance = "provideSnaplinesWithDistanceDistance";
|
|
4
6
|
export declare class SnaplinesProviderService implements ISnaplinesProviderService {
|
|
5
7
|
provideSnaplines(containerItem: IDesignItem, ignoredItems: IDesignItem[]): {
|
|
6
8
|
outerRect: DOMRect;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { DomHelper } from '@node-projects/base-custom-webcomponent';
|
|
2
|
+
export const provideSnaplinesWithDistance = 'provideSnaplinesWithDistance';
|
|
3
|
+
export const provideSnaplinesWithDistanceDistance = 'provideSnaplinesWithDistanceDistance';
|
|
2
4
|
export class SnaplinesProviderService {
|
|
3
5
|
provideSnaplines(containerItem, ignoredItems) {
|
|
4
6
|
{
|
|
5
7
|
const canvas = containerItem.instanceServiceContainer.designerCanvas;
|
|
6
8
|
const ignMap = new Map(ignoredItems.map(i => [i.element, i]));
|
|
7
9
|
const outerRect = containerItem.element.getBoundingClientRect();
|
|
10
|
+
const provideWithDist = canvas.instanceServiceContainer.designContext.extensionOptions[provideSnaplinesWithDistance] !== false;
|
|
11
|
+
const provideWithDistDist = canvas.instanceServiceContainer.designContext.extensionOptions[provideSnaplinesWithDistanceDistance] ?? 5;
|
|
8
12
|
const positionsH = [];
|
|
9
13
|
const positionsMiddleH = [];
|
|
10
14
|
const positionsV = [];
|
|
@@ -20,16 +24,22 @@ export class SnaplinesProviderService {
|
|
|
20
24
|
const pMidV = (p.y - outerRect.y + p.height / 2) / canvas.scaleFactor;
|
|
21
25
|
const pBottom = (p.y - outerRect.y + p.height) / canvas.scaleFactor;
|
|
22
26
|
const transformedP = { x: pLeft + outerRect.x, y: pTop + outerRect.y, width: p.width / canvas.scaleFactor, height: p.height / canvas.scaleFactor };
|
|
27
|
+
if (provideWithDist)
|
|
28
|
+
positionsH.push([pLeft - provideWithDistDist, transformedP]);
|
|
23
29
|
positionsH.push([pLeft, transformedP]);
|
|
24
30
|
positionsMiddleH.push([pMidH, transformedP]);
|
|
25
31
|
positionsH.push([pRight, transformedP]);
|
|
32
|
+
if (provideWithDist)
|
|
33
|
+
positionsH.push([pRight + provideWithDistDist, transformedP]);
|
|
26
34
|
positionsV.push([pTop, transformedP]);
|
|
27
35
|
positionsMiddleV.push([pMidV, transformedP]);
|
|
28
36
|
positionsV.push([pBottom, transformedP]);
|
|
29
37
|
}
|
|
30
38
|
}
|
|
39
|
+
positionsH.push([0, { x: 0, y: 0, width: 0, height: 0 }]);
|
|
31
40
|
positionsH.sort((a, b) => a[0] - b[0]);
|
|
32
41
|
positionsMiddleH.sort((a, b) => a[0] - b[0]);
|
|
42
|
+
positionsV.push([0, { x: 0, y: 0, width: 0, height: 0 }]);
|
|
33
43
|
positionsV.sort((a, b) => a[0] - b[0]);
|
|
34
44
|
positionsMiddleV.sort((a, b) => a[0] - b[0]);
|
|
35
45
|
return { outerRect, positionsH, positionsMiddleH, positionsV, positionsMiddleV };
|
|
@@ -4,7 +4,6 @@ import { IDesignItem } from '../../item/IDesignItem';
|
|
|
4
4
|
import { ValueType } from './ValueType';
|
|
5
5
|
import { BindingTarget } from '../../item/BindingTarget';
|
|
6
6
|
export interface IPropertiesService extends IService {
|
|
7
|
-
readonly name: string;
|
|
8
7
|
isHandledElement(designItem: IDesignItem): boolean;
|
|
9
8
|
getProperties(designItem: IDesignItem): IProperty[];
|
|
10
9
|
getProperty(designItem: IDesignItem, name: string): IProperty;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { IPropertiesService } from './IPropertiesService';
|
|
2
2
|
import { IPropertyEditor } from './IPropertyEditor';
|
|
3
|
+
import { PropertyType } from './PropertyType';
|
|
3
4
|
export interface IProperty {
|
|
4
5
|
name: string;
|
|
6
|
+
propertyName?: string;
|
|
7
|
+
attributeName?: string;
|
|
5
8
|
description?: string;
|
|
6
|
-
type?: string;
|
|
9
|
+
type?: 'json' | 'color' | 'date' | 'number' | 'list' | 'enum' | 'boolean' | 'img-lis' | 'thickness' | 'css-length' | 'string' | string;
|
|
7
10
|
default?: any;
|
|
8
11
|
min?: number;
|
|
9
12
|
max?: number;
|
|
@@ -14,4 +17,5 @@ export interface IProperty {
|
|
|
14
17
|
value?: any;
|
|
15
18
|
service: IPropertiesService;
|
|
16
19
|
defaultValue?: any;
|
|
20
|
+
propertyType: PropertyType;
|
|
17
21
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var PropertyType;
|
|
2
|
+
(function (PropertyType) {
|
|
3
|
+
PropertyType["property"] = "property";
|
|
4
|
+
PropertyType["attribute"] = "attribute";
|
|
5
|
+
PropertyType["propertyAndAttribute"] = "propertyAndAttribute";
|
|
6
|
+
PropertyType["cssValue"] = "cssvalue";
|
|
7
|
+
})(PropertyType || (PropertyType = {}));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PropertiesHelper } from './PropertiesHelper';
|
|
2
2
|
import { UnkownElementPropertiesService } from "./UnkownElementPropertiesService";
|
|
3
|
+
import { PropertyType } from '../PropertyType';
|
|
3
4
|
export class AbstractBasePropertiesService extends UnkownElementPropertiesService {
|
|
4
5
|
getProperties(designItem) {
|
|
5
6
|
if (!this.isHandledElement(designItem))
|
|
@@ -14,27 +15,27 @@ export class AbstractBasePropertiesService extends UnkownElementPropertiesServic
|
|
|
14
15
|
if (polymerProperty.type)
|
|
15
16
|
type = polymerProperty.type;
|
|
16
17
|
if (type === String) {
|
|
17
|
-
let property = { name: name, type: "string", service: this };
|
|
18
|
+
let property = { name: name, type: "string", service: this, propertyType: PropertyType.propertyAndAttribute };
|
|
18
19
|
properties.push(property);
|
|
19
20
|
}
|
|
20
21
|
else if (type === Object) {
|
|
21
|
-
let property = { name: name, type: "object", service: this };
|
|
22
|
+
let property = { name: name, type: "object", service: this, propertyType: PropertyType.propertyAndAttribute };
|
|
22
23
|
properties.push(property);
|
|
23
24
|
}
|
|
24
25
|
else if (type === Number) {
|
|
25
|
-
let property = { name: name, type: "number", service: this };
|
|
26
|
+
let property = { name: name, type: "number", service: this, propertyType: PropertyType.propertyAndAttribute };
|
|
26
27
|
properties.push(property);
|
|
27
28
|
}
|
|
28
29
|
else if (type === Date) {
|
|
29
|
-
let property = { name: name, type: "date", service: this };
|
|
30
|
+
let property = { name: name, type: "date", service: this, propertyType: PropertyType.propertyAndAttribute };
|
|
30
31
|
properties.push(property);
|
|
31
32
|
}
|
|
32
33
|
else if (type === Boolean) {
|
|
33
|
-
let property = { name: name, type: "boolean", service: this };
|
|
34
|
+
let property = { name: name, type: "boolean", service: this, propertyType: PropertyType.propertyAndAttribute };
|
|
34
35
|
properties.push(property);
|
|
35
36
|
}
|
|
36
37
|
else if (PropertiesHelper.isTypescriptEnum(type)) {
|
|
37
|
-
let property = { name: name, type: "enum", enumValues: PropertiesHelper.getTypescriptEnumEntries(type), service: this };
|
|
38
|
+
let property = { name: name, type: "enum", enumValues: PropertiesHelper.getTypescriptEnumEntries(type), service: this, propertyType: PropertyType.propertyAndAttribute };
|
|
38
39
|
properties.push(property);
|
|
39
40
|
}
|
|
40
41
|
}
|