@node-projects/web-component-designer 0.0.291 → 0.0.292

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.
@@ -5,6 +5,10 @@
5
5
  "@microsoft/fast-components": {
6
6
  "script": "let res = await import('@microsoft/fast-components');\nres.provideFASTDesignSystem().register(res.allComponents);"
7
7
  },
8
+ "@zooplus/zoo-web-components": {
9
+ "script": "let res = await import('@zooplus/zoo-web-components');\nres.registerComponents(res);",
10
+ "style": ":root {\n--primary-mid: #3C9700;\n--primary-light: #66B100;\n--primary-dark: #286400;\n--primary-ultralight: #EBF4E5;\n--secondary-mid: #FF6200;\n--secondary-light: #F80;\n--secondary-dark: #CC4E00;\n--info-ultralight: #ECF5FA;\n--info-mid: #459FD0;\n--warning-ultralight: #FDE8E9;\n--warning-mid: #ED1C24;\n}"
11
+ },
8
12
  "@material/web": {
9
13
  "import": "@material/web/all.js"
10
14
  }
@@ -8,6 +8,7 @@ export declare class NpmPackageLoader {
8
8
  static patchCustomElementsRegistryToHandleErrors(): void;
9
9
  loadNpmPackage(pkg: string, serviceContainer?: ServiceContainer, paletteTree?: PaletteTreeView, loadAllImports?: boolean, reportState?: (state: string) => void): Promise<{
10
10
  html: string;
11
+ style: string;
11
12
  }>;
12
13
  loadDependency(dependency: string, version?: string, reportState?: (state: string) => void): Promise<void>;
13
14
  addToImportmap(baseUrl: string, packageJsonObj: {
@@ -209,6 +209,9 @@ export class NpmPackageLoader {
209
209
  if (packageHacks[pkg]?.html) {
210
210
  retVal.html = (packageHacks[pkg]?.html).replaceAll("${baseUrl}", baseUrl);
211
211
  }
212
+ if (packageHacks[pkg]?.style) {
213
+ retVal.style = (packageHacks[pkg]?.style).replaceAll("${baseUrl}", baseUrl);
214
+ }
212
215
  return retVal;
213
216
  }
214
217
  async loadDependency(dependency, version, reportState) {
@@ -10,6 +10,7 @@ import { DeleteAction } from '../services/undoService/transactionItems/DeleteAct
10
10
  import { enableStylesheetService } from '../widgets/designerView/extensions/buttons/StylesheetServiceDesignViewConfigButtons.js';
11
11
  import { AbstractStylesheetService } from '../services/stylesheetService/AbstractStylesheetService.js';
12
12
  import { TypedEvent, cssFromString } from '@node-projects/base-custom-webcomponent';
13
+ import { TextContentChangeAction } from '../services/undoService/transactionItems/TextContentChangeAction.js';
13
14
  const hideAtDesignTimeAttributeName = 'node-projects-hide-at-design-time';
14
15
  const hideAtRunTimeAttributeName = 'node-projects-hide-at-run-time';
15
16
  const lockAtDesignTimeAttributeName = 'node-projects-lock-at-design-time';
@@ -205,7 +206,7 @@ export class DesignItem {
205
206
  }
206
207
  //abstract text content to own property. so only change via designer api will use it.
207
208
  get hasContent() {
208
- return this.nodeType == NodeType.TextNode || (this._childArray.length === 0 && this.content !== null);
209
+ return this.nodeType == NodeType.TextNode || (this.nodeType == NodeType.Comment && this.element.textContent != "") || (this._childArray.length === 0 && this.content !== null);
209
210
  }
210
211
  get content() {
211
212
  if (!this.hasChildren)
@@ -224,6 +225,10 @@ export class DesignItem {
224
225
  this.remove();
225
226
  parent.insertChild(di, idx);
226
227
  }
228
+ else if (this.nodeType == NodeType.Comment) {
229
+ const action = new TextContentChangeAction(this, value, this.content);
230
+ this.instanceServiceContainer.undoService.execute(action);
231
+ }
227
232
  else
228
233
  this.insertChild(di);
229
234
  grp.commit();
@@ -2,16 +2,48 @@ import { IDesignItem } from "../../item/IDesignItem.js";
2
2
  import { IEvent } from "./IEvent.js";
3
3
  import { IEventsService } from "./IEventsService.js";
4
4
  export declare class EventsService implements IEventsService {
5
- protected _windowEvents: string[];
6
- protected _allElements: string[];
7
- protected _focusableEvents: string[];
8
- protected _form: string[];
9
- protected _mouseEvents: string[];
10
- protected _pointerEvents: string[];
11
- protected _touchEvents: string[];
12
- protected _dragEvents: string[];
13
- protected _clipboard: string[];
14
- protected _details: string[];
5
+ constructor();
6
+ protected _allEvents: IEvent[];
7
+ protected _windowEvents: {
8
+ name: string;
9
+ propertyName: string;
10
+ eventObjectName: string;
11
+ }[];
12
+ protected _allElements: IEvent[];
13
+ protected _focusableEvents: {
14
+ name: string;
15
+ propertyName: string;
16
+ eventObjectName: string;
17
+ }[];
18
+ protected _form: {
19
+ name: string;
20
+ propertyName: string;
21
+ eventObjectName: string;
22
+ }[];
23
+ protected _simpleMouseEvents: IEvent[];
24
+ protected _mouseEvents: {
25
+ name: string;
26
+ propertyName: string;
27
+ eventObjectName: string;
28
+ }[];
29
+ protected _pointerEvents: IEvent[];
30
+ protected _touchEvents: IEvent[];
31
+ protected _dragEvents: {
32
+ name: string;
33
+ propertyName: string;
34
+ eventObjectName: string;
35
+ }[];
36
+ protected _clipboard: {
37
+ name: string;
38
+ propertyName: string;
39
+ eventObjectName: string;
40
+ }[];
41
+ protected _details: {
42
+ name: string;
43
+ propertyName: string;
44
+ eventObjectName: string;
45
+ }[];
15
46
  isHandledElement(designItem: IDesignItem): boolean;
16
47
  getPossibleEvents(designItem: IDesignItem): IEvent[];
48
+ getEvent(name: string): IEvent;
17
49
  }
@@ -1,91 +1,103 @@
1
1
  export class EventsService {
2
+ constructor() {
3
+ this._allEvents = [...this._windowEvents, ...this._form, ...this._simpleMouseEvents, ...this._mouseEvents, ...this._pointerEvents, ...this._touchEvents, ...this._allElements, ...this._focusableEvents, ...this._dragEvents, ...this._clipboard, ...this._dragEvents];
4
+ }
5
+ _allEvents;
2
6
  _windowEvents = [
3
- "afterprint",
4
- "beforeprint",
5
- "beforeunload",
6
- "error",
7
- "hashchange",
8
- "load",
9
- "message",
10
- "offline",
11
- "online",
12
- "pageshow",
13
- "popstate",
14
- "resize",
15
- "storage",
16
- "unload"
7
+ { name: "afterprint", propertyName: "onafterprint", eventObjectName: "Event" },
8
+ { name: "beforeprint", propertyName: "onbeforeprint", eventObjectName: "Event" },
9
+ { name: "beforeunload", propertyName: "onbeforeunload", eventObjectName: "Event" },
10
+ { name: "error", propertyName: "onerror", eventObjectName: "Event" },
11
+ { name: "load", propertyName: "onload", eventObjectName: "Event" },
12
+ { name: "hashchange", propertyName: "onhashchange", eventObjectName: "Event" },
13
+ { name: "message", propertyName: "onmessage", eventObjectName: "Event" },
14
+ { name: "offline", propertyName: "onoffline", eventObjectName: "Event" },
15
+ { name: "online", propertyName: "ononline", eventObjectName: "Event" },
16
+ { name: "pageshow", propertyName: "onpageshow", eventObjectName: "Event" },
17
+ { name: "popstate", propertyName: "onpopstate", eventObjectName: "Event" },
18
+ { name: "resize", propertyName: "onresize", eventObjectName: "Event" },
19
+ { name: "storage", propertyName: "onstorage", eventObjectName: "Event" },
20
+ { name: "unload", propertyName: "onunload", eventObjectName: "Event" }
17
21
  ];
18
22
  _allElements = [
19
- "contextmenu",
23
+ { name: "contextmenu", propertyName: "oncontextmenu", eventObjectName: "PointerEvent" }
20
24
  ];
21
25
  _focusableEvents = [
22
- "blur",
23
- "focus",
24
- "keydown",
25
- "keypress",
26
- "keyup"
26
+ { name: "blur", propertyName: "onblur", eventObjectName: "FocusEvent" },
27
+ { name: "focus", propertyName: "onfocus", eventObjectName: "FocusEvent" },
28
+ { name: "keydown", propertyName: "onkeydown", eventObjectName: "KeyboardEvent" },
29
+ { name: "keyup", propertyName: "onkeyup", eventObjectName: "KeyboardEvent" }
27
30
  ];
28
31
  _form = [
29
- "change",
30
- "input",
31
- "invalid",
32
- "reset",
33
- "search",
34
- "select",
35
- "submit"
32
+ { name: "beforeinput", propertyName: "onbeforeinput", eventObjectName: "InputEvent" },
33
+ { name: "input", propertyName: "oninput", eventObjectName: "InputEvent" },
34
+ { name: "change", propertyName: "onchange", eventObjectName: "Event" },
35
+ { name: "invalid", propertyName: "oninvalid", eventObjectName: "Event" },
36
+ { name: "reset", propertyName: "onreset", eventObjectName: "Event" },
37
+ { name: "select", propertyName: "onselect", eventObjectName: "Event" },
38
+ { name: "submit", propertyName: "onsubmit", eventObjectName: "SubmitEvent" }
39
+ ];
40
+ _simpleMouseEvents = [
41
+ { name: "click", propertyName: "onclick", eventObjectName: "PointerEvent" },
42
+ { name: "dblclick", propertyName: "ondblclick", eventObjectName: "MouseEvent" },
43
+ { name: "wheel", propertyName: "onwheel", eventObjectName: "WheelEvent" },
44
+ { name: "scroll", propertyName: "onscroll", eventObjectName: "Event" },
36
45
  ];
37
46
  _mouseEvents = [
38
- "click",
39
- "dblclick",
40
- "mousedown",
41
- "mouseup",
42
- "mousemove",
43
- "mouseover",
44
- "mouseout",
45
- "mousewheel",
46
- "wheel"
47
+ { name: "mousedown", propertyName: "onmousedown", eventObjectName: "MouseEvent" },
48
+ { name: "mouseup", propertyName: "onmouseup", eventObjectName: "MouseEvent" },
49
+ { name: "mousemove", propertyName: "onmousemove", eventObjectName: "MouseEvent" },
50
+ { name: "mouseover", propertyName: "onmouseover", eventObjectName: "MouseEvent" },
51
+ { name: "mouseout", propertyName: "onmouseout", eventObjectName: "MouseEvent" }
47
52
  ];
48
53
  _pointerEvents = [
49
- "pointerdown",
50
- "pointerup",
51
- "pointerenter",
52
- "pointerleave",
53
- "pointermove",
54
- "pointerover",
55
- "pointerout",
56
- "pointercancel"
54
+ { name: "pointerdown", propertyName: "onpointerdown", eventObjectName: "PointerEvent" },
55
+ { name: "pointerup", propertyName: "onpointerup", eventObjectName: "PointerEvent" },
56
+ { name: "pointerenter", propertyName: "onpointerenter", eventObjectName: "PointerEvent" },
57
+ { name: "pointerleave", propertyName: "onpointerleave", eventObjectName: "PointerEvent" },
58
+ { name: "pointermove", propertyName: "onpointermove", eventObjectName: "PointerEvent" },
59
+ { name: "pointerover", propertyName: "onpointerover", eventObjectName: "PointerEvent" },
60
+ { name: "pointerout", propertyName: "onpointerout", eventObjectName: "PointerEvent" },
61
+ { name: "pointercancel", propertyName: "onpointercancel", eventObjectName: "PointerEvent" }
57
62
  ];
58
63
  _touchEvents = [
59
- "touchstart",
60
- "touchend",
61
- "touchmove",
62
- "touchcancel"
64
+ { name: "touchstart", propertyName: "ontouchstart", eventObjectName: "TouchEvent" },
65
+ { name: "touchend", propertyName: "ontouchend", eventObjectName: "TouchEvent" },
66
+ { name: "touchmove", propertyName: "ontouchmove", eventObjectName: "TouchEvent" },
67
+ { name: "touchcancel", propertyName: "ontouchcancel", eventObjectName: "TouchEvent" }
63
68
  ];
64
69
  _dragEvents = [
65
- "drag",
66
- "dragend",
67
- "dragenter",
68
- "dragleave",
69
- "dragover",
70
- "dragstart",
71
- "drop",
72
- "scroll"
70
+ { name: "drag", propertyName: "ondrag", eventObjectName: "DragEvent" },
71
+ { name: "dragend", propertyName: "ondragend", eventObjectName: "DragEvent" },
72
+ { name: "dragenter", propertyName: "ondragenter", eventObjectName: "DragEvent" },
73
+ { name: "dragleave", propertyName: "ondragleave", eventObjectName: "DragEvent" },
74
+ { name: "dragover", propertyName: "ondragover", eventObjectName: "DragEvent" },
75
+ { name: "dragstart", propertyName: "ondragstart", eventObjectName: "DragEvent" },
76
+ { name: "drop", propertyName: "ondrop", eventObjectName: "DragEvent" }
73
77
  ];
74
78
  _clipboard = [
75
- "copy",
76
- "cut",
77
- "paste"
79
+ { name: "copy", propertyName: "oncopy", eventObjectName: "ClipboardEvent" },
80
+ { name: "cut", propertyName: "oncut", eventObjectName: "ClipboardEvent" },
81
+ { name: "paste", propertyName: "onpaste", eventObjectName: "ClipboardEvent" }
78
82
  ];
79
83
  _details = [
80
- "toggle"
84
+ { name: "toggle", propertyName: "ontoggle", eventObjectName: "Event" }
81
85
  ];
82
86
  isHandledElement(designItem) {
83
87
  return true;
84
88
  }
85
89
  getPossibleEvents(designItem) {
86
- //Todo: create corret events list for all std. elements
87
- let lst = [...this._mouseEvents, ...this._allElements, ...this._focusableEvents];
88
- let events = lst.map(x => ({ name: x, propertyName: 'on' + x }));
90
+ if (designItem.element instanceof HTMLInputElement ||
91
+ designItem.element instanceof HTMLTextAreaElement ||
92
+ designItem.element instanceof HTMLSelectElement) {
93
+ let events = [...this._form, ...this._simpleMouseEvents, ...this._pointerEvents, ...this._allElements, ...this._focusableEvents];
94
+ return events;
95
+ }
96
+ let events = [...this._simpleMouseEvents, ...this._pointerEvents, ...this._allElements, ...this._focusableEvents];
89
97
  return events;
90
98
  }
99
+ getEvent(name) {
100
+ let evt = this._allEvents.find(x => x.name == name);
101
+ return evt ?? { name, propertyName: 'on' + name, eventObjectName: 'Event' };
102
+ }
91
103
  }
@@ -1,4 +1,5 @@
1
1
  export interface IEvent {
2
2
  name: string;
3
3
  propertyName?: string;
4
+ eventObjectName?: string;
4
5
  }
@@ -3,4 +3,5 @@ import { IEvent } from "./IEvent.js";
3
3
  export interface IEventsService {
4
4
  isHandledElement(designItem: IDesignItem): boolean;
5
5
  getPossibleEvents(designItem: IDesignItem): IEvent[];
6
+ getEvent(name: string): IEvent;
6
7
  }
@@ -1,3 +1,4 @@
1
+ import { NodeType } from '../../item/NodeType.js';
1
2
  import { AttachedPropertiesService } from './services/AttachedPropertiesService.js';
2
3
  import { AttributesPropertiesService } from './services/AttributesPropertiesService.js';
3
4
  import { CommonPropertiesService } from './services/CommonPropertiesService.js';
@@ -35,6 +36,8 @@ export class PropertyTabsService {
35
36
  getPropertygroups(designItems) {
36
37
  if (designItems == null || designItems.length == 0)
37
38
  return [];
39
+ if (designItems[0].nodeType == NodeType.TextNode || designItems[0].nodeType == NodeType.Comment)
40
+ return [];
38
41
  this._pgList[0].propertiesService = designItems[0].serviceContainer.getLastServiceWhere('propertyService', x => x.isHandledElement(designItems[0]));
39
42
  this._svgPgList[0].propertiesService = designItems[0].serviceContainer.getLastServiceWhere('propertyService', x => x.isHandledElement(designItems[0]));
40
43
  let lst = this._pgList;
@@ -0,0 +1,15 @@
1
+ import { ITransactionItem } from '../ITransactionItem.js';
2
+ import { IDesignItem } from '../../../item/IDesignItem.js';
3
+ import { IBinding } from '../../../item/IBinding.js';
4
+ export declare class AttributeChangeAction implements ITransactionItem {
5
+ constructor(designItem: IDesignItem, name: string, newValue: string | IBinding | null, oldValue: string | IBinding | null);
6
+ title?: string;
7
+ get affectedItems(): IDesignItem[];
8
+ undo(): void;
9
+ do(): void;
10
+ designItem: IDesignItem;
11
+ name: string;
12
+ newValue: any;
13
+ oldValue: any;
14
+ mergeWith(other: ITransactionItem): boolean;
15
+ }
@@ -0,0 +1,70 @@
1
+ export class AttributeChangeAction {
2
+ constructor(designItem, name, newValue, oldValue) {
3
+ this.title = "Change Attribute " + name + " of &lt;" + designItem.name + "&gt;";
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 == null) {
15
+ this.designItem._withoutUndoRemoveAttribute(this.name);
16
+ try {
17
+ this.designItem.element.removeAttribute(this.name);
18
+ }
19
+ catch (e) {
20
+ console.warn(e);
21
+ }
22
+ }
23
+ else {
24
+ this.designItem._withoutUndoSetAttribute(this.name, this.oldValue);
25
+ if (this.name != "draggable") {
26
+ try {
27
+ if (typeof this.oldValue === 'string')
28
+ this.designItem.element.setAttribute(this.name, this.oldValue);
29
+ }
30
+ catch (e) {
31
+ console.warn(e);
32
+ }
33
+ }
34
+ }
35
+ }
36
+ do() {
37
+ if (this.newValue == null) {
38
+ this.designItem._withoutUndoRemoveAttribute(this.name);
39
+ try {
40
+ this.designItem.element.removeAttribute(this.name);
41
+ }
42
+ catch (e) {
43
+ console.warn(e);
44
+ }
45
+ }
46
+ else {
47
+ this.designItem._withoutUndoSetAttribute(this.name, this.newValue);
48
+ if (this.name != "draggable") {
49
+ try {
50
+ if (typeof this.newValue === 'string')
51
+ this.designItem.element.setAttribute(this.name, this.newValue);
52
+ }
53
+ catch (e) {
54
+ console.warn(e);
55
+ }
56
+ }
57
+ }
58
+ }
59
+ designItem;
60
+ name;
61
+ newValue;
62
+ oldValue;
63
+ mergeWith(other) {
64
+ if (other instanceof AttributeChangeAction && this.designItem === other.designItem && this.name === other.name) {
65
+ this.newValue = other.newValue;
66
+ return true;
67
+ }
68
+ return false;
69
+ }
70
+ }
@@ -0,0 +1,14 @@
1
+ import { ITransactionItem } from '../ITransactionItem.js';
2
+ import { IDesignItem } from '../../../item/IDesignItem.js';
3
+ import { IBinding } from '../../../item/IBinding.js';
4
+ export declare class TextContentChangeAction implements ITransactionItem {
5
+ constructor(designItem: IDesignItem, newValue: string | IBinding | null, oldValue: string | IBinding | null);
6
+ title?: string;
7
+ get affectedItems(): IDesignItem[];
8
+ undo(): void;
9
+ do(): void;
10
+ designItem: IDesignItem;
11
+ newValue: any;
12
+ oldValue: any;
13
+ mergeWith(other: ITransactionItem): boolean;
14
+ }
@@ -0,0 +1,24 @@
1
+ export class TextContentChangeAction {
2
+ constructor(designItem, newValue, oldValue) {
3
+ this.title = "Change TextContent from '" + oldValue + "' to '" + newValue + "'";
4
+ this.designItem = designItem;
5
+ this.newValue = newValue;
6
+ this.oldValue = oldValue;
7
+ }
8
+ title;
9
+ get affectedItems() {
10
+ return [this.designItem];
11
+ }
12
+ undo() {
13
+ this.designItem.element.textContent = this.oldValue;
14
+ }
15
+ do() {
16
+ this.designItem.element.textContent = this.newValue;
17
+ }
18
+ designItem;
19
+ newValue;
20
+ oldValue;
21
+ mergeWith(other) {
22
+ return false;
23
+ }
24
+ }
@@ -1,6 +1,8 @@
1
1
  import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
2
2
  import { DesignItem } from "../../item/DesignItem.js";
3
3
  function generateSelector(element) {
4
+ if (!element)
5
+ return '';
4
6
  let selector, tag = element.nodeName.toLowerCase();
5
7
  if (element.id) {
6
8
  selector = '#' + element.getAttribute('id');
@@ -193,7 +195,7 @@ export class DebugView extends BaseCustomWebComponentConstructorAppend {
193
195
  if (this._ready) {
194
196
  requestAnimationFrame(() => {
195
197
  let element = designItem?.element;
196
- if (element) {
198
+ if (element && element.nodeType != 8) {
197
199
  if (element.nodeType == 3)
198
200
  element = element.parentNode;
199
201
  this.computedStyle = getComputedStyle(element);
@@ -1,8 +1,9 @@
1
1
  import { SelectionDefaultExtension } from './SelectionDefaultExtension.js';
2
2
  import { css } from "@node-projects/base-custom-webcomponent";
3
+ import { NodeType } from '../../../item/NodeType.js';
3
4
  export class SelectionDefaultExtensionProvider {
4
5
  shouldExtend(extensionManager, designerView, designItem) {
5
- return true;
6
+ return designItem.nodeType != NodeType.Comment;
6
7
  }
7
8
  getExtension(extensionManager, designerView, designItem) {
8
9
  return new SelectionDefaultExtension(extensionManager, designerView, designItem);
package/dist/index.d.ts CHANGED
@@ -141,6 +141,7 @@ export * from "./elements/services/undoService/transactionItems/InsertAction.js"
141
141
  export * from "./elements/services/undoService/transactionItems/InsertChildAction.js";
142
142
  export * from "./elements/services/undoService/transactionItems/StylesheetChangedAction.js";
143
143
  export * from "./elements/services/undoService/transactionItems/SetDesignItemsAction.js";
144
+ export * from "./elements/services/undoService/transactionItems/TextContentChangeAction.js";
144
145
  export * from "./elements/services/BaseServiceContainer.js";
145
146
  export * from "./elements/services/InstanceServiceContainer.js";
146
147
  export type { IService } from "./elements/services/IService.js";
package/dist/index.js CHANGED
@@ -96,6 +96,7 @@ export * from "./elements/services/undoService/transactionItems/InsertAction.js"
96
96
  export * from "./elements/services/undoService/transactionItems/InsertChildAction.js";
97
97
  export * from "./elements/services/undoService/transactionItems/StylesheetChangedAction.js";
98
98
  export * from "./elements/services/undoService/transactionItems/SetDesignItemsAction.js";
99
+ export * from "./elements/services/undoService/transactionItems/TextContentChangeAction.js";
99
100
  export * from "./elements/services/BaseServiceContainer.js";
100
101
  export * from "./elements/services/InstanceServiceContainer.js";
101
102
  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.291",
4
+ "version": "0.0.292",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",