@node-projects/web-component-designer 0.0.97 → 0.0.100

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.
@@ -10,7 +10,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
10
10
  _additionalStyle;
11
11
  set additionalStyleString(style) {
12
12
  this._additionalStyle = style;
13
- this.designerView.additionalStyle = cssFromString(style);
13
+ this.designerView.additionalStyles = [cssFromString(style)];
14
14
  }
15
15
  ;
16
16
  get additionalStyleString() {
@@ -135,7 +135,11 @@ export class CssCombiner {
135
135
  styles.delete('margin-right');
136
136
  styles.delete('margin-bottom');
137
137
  styles.delete('margin-left');
138
- styles.set('margin', e.style.marginTop + ' ' + e.style.marginRight + ' ' + e.style.marginBottom + ' ' + e.style.marginLeft);
138
+ if (e.style.marginTop == e.style.marginRight && e.style.marginTop == e.style.marginBottom && e.style.marginTop == e.style.marginLeft) {
139
+ styles.set('margin', e.style.marginTop);
140
+ }
141
+ else
142
+ styles.set('margin', e.style.marginTop + ' ' + e.style.marginRight + ' ' + e.style.marginBottom + ' ' + e.style.marginLeft);
139
143
  }
140
144
  }
141
145
  static combinePadding(styles) {
@@ -155,7 +159,11 @@ export class CssCombiner {
155
159
  styles.delete('padding-right');
156
160
  styles.delete('padding-bottom');
157
161
  styles.delete('padding-left');
158
- styles.set('padding', e.style.paddingTop + ' ' + e.style.paddingRight + ' ' + e.style.paddingBottom + ' ' + e.style.paddingLeft);
162
+ if (e.style.paddingTop == e.style.paddingRight && e.style.paddingTop == e.style.paddingBottom && e.style.paddingTop == e.style.paddingLeft) {
163
+ styles.set('padding', e.style.paddingTop);
164
+ }
165
+ else
166
+ styles.set('padding', e.style.paddingTop + ' ' + e.style.paddingRight + ' ' + e.style.paddingBottom + ' ' + e.style.paddingLeft);
159
167
  }
160
168
  }
161
169
  static combineInset(styles) {
@@ -1,7 +1,8 @@
1
1
  export function CalculateGridInformation(designItem) {
2
2
  //todo:
3
3
  //same name should combine columns/rows
4
- let itemRect = designItem.element.getBoundingClientRect();
4
+ let itemRect = designItem.instanceServiceContainer.designerCanvas.getNormalizedElementCoordinates(designItem.element);
5
+ //let itemRect = designItem.element.getBoundingClientRect();
5
6
  const computedStyle = getComputedStyle(designItem.element);
6
7
  const rows = computedStyle.gridTemplateRows.split(' ');
7
8
  const columns = computedStyle.gridTemplateColumns.split(' ');
@@ -11,8 +12,8 @@ export function CalculateGridInformation(designItem) {
11
12
  let xGap = 0;
12
13
  let yGap = 0;
13
14
  let rw = 0;
14
- let xOffset = itemRect.x - designItem.instanceServiceContainer.designerCanvas.containerBoundingRect.x;
15
- let yOffset = itemRect.y - designItem.instanceServiceContainer.designerCanvas.containerBoundingRect.y;
15
+ let xOffset = itemRect.x; // - designItem.instanceServiceContainer.designerCanvas.containerBoundingRect.x;
16
+ let yOffset = itemRect.y; // - designItem.instanceServiceContainer.designerCanvas.containerBoundingRect.y;
16
17
  let gridA = null;
17
18
  if (computedStyle.gridTemplateAreas && computedStyle.gridTemplateAreas !== 'none')
18
19
  gridA = computedStyle.gridTemplateAreas.split('\"');
@@ -64,7 +64,7 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
64
64
  getDesignSurfaceDimensions(): ISize;
65
65
  get designerOffsetWidth(): number;
66
66
  get designerOffsetHeight(): number;
67
- set additionalStyle(value: CSSStyleSheet);
67
+ set additionalStyles(value: CSSStyleSheet[]);
68
68
  executeCommand(command: IUiCommand): Promise<void>;
69
69
  canExecuteCommand(command: IUiCommand): boolean;
70
70
  handleSelectAll(): void;
@@ -3,7 +3,7 @@ import { InstanceServiceContainer } from '../../services/InstanceServiceContaine
3
3
  import { UndoService } from '../../services/undoService/UndoService';
4
4
  import { SelectionService } from '../../services/selectionService/SelectionService';
5
5
  import { DesignItem } from '../../item/DesignItem';
6
- import { BaseCustomWebComponentLazyAppend, css, html, TypedEvent } from '@node-projects/base-custom-webcomponent';
6
+ import { BaseCustomWebComponentLazyAppend, css, html, TypedEvent, cssFromString } from '@node-projects/base-custom-webcomponent';
7
7
  import { dragDropFormatNameElementDefinition, dragDropFormatNameBindingObject } from '../../../Constants';
8
8
  import { ContentService } from '../../services/contentService/ContentService';
9
9
  import { InsertAction } from '../../services/undoService/transactionItems/InsertAction';
@@ -199,21 +199,24 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
199
199
  get designerOffsetHeight() {
200
200
  return this._canvasContainer.offsetHeight;
201
201
  }
202
- set additionalStyle(value) {
202
+ set additionalStyles(value) {
203
203
  if (value) {
204
- for (let r of value.rules) {
205
- if (r instanceof CSSStyleRule) {
206
- let parts = r.selectorText.split(',');
207
- let t = '';
208
- for (let p of parts) {
209
- if (r.selectorText)
210
- t += ',';
211
- t += '#canvas ' + p;
204
+ let style = '';
205
+ for (let s of value) {
206
+ for (let r of s.cssRules) {
207
+ if (r instanceof CSSStyleRule) {
208
+ let parts = r.selectorText.split(',');
209
+ let t = '';
210
+ for (let p of parts) {
211
+ if (t)
212
+ t += ',';
213
+ t += '#node-projects-designer-canvas-canvas ' + p;
214
+ }
215
+ style += t + '{' + r.style.cssText + '}';
212
216
  }
213
- r.selectorText = t;
214
217
  }
215
218
  }
216
- this.shadowRoot.adoptedStyleSheets = [this.constructor.style, value];
219
+ this.shadowRoot.adoptedStyleSheets = [this.constructor.style, cssFromString(style)];
217
220
  }
218
221
  else
219
222
  this.shadowRoot.adoptedStyleSheets = [this.constructor.style];
@@ -21,7 +21,6 @@ export declare class DesignerView extends BaseCustomWebComponentConstructorAppen
21
21
  static readonly style: CSSStyleSheet;
22
22
  static readonly template: HTMLTemplateElement;
23
23
  constructor();
24
- ready(): Promise<void>;
25
24
  zoomReset(): void;
26
25
  zoomToFit(): void;
27
26
  private _onScrollbar;
@@ -30,7 +29,7 @@ export declare class DesignerView extends BaseCustomWebComponentConstructorAppen
30
29
  set designerWidth(value: string);
31
30
  get designerHeight(): string;
32
31
  set designerHeight(value: string);
33
- set additionalStyle(value: CSSStyleSheet);
32
+ set additionalStyles(value: CSSStyleSheet[]);
34
33
  setDesignItems(designItems: IDesignItem[]): void;
35
34
  executeCommand(command: IUiCommand): Promise<void>;
36
35
  canExecuteCommand(command: IUiCommand): boolean;
@@ -3,6 +3,7 @@ import { DesignerCanvas } from "./designerCanvas.js";
3
3
  import { DomConverter } from './DomConverter.js';
4
4
  import { DefaultHtmlParserService } from '../../services/htmlParserService/DefaultHtmlParserService.js';
5
5
  import { EventNames } from '../../../enums/EventNames.js';
6
+ import { DesignerToolbar } from './tools/toolBar/DesignerToolbar.js';
6
7
  const autoZomOffset = 10;
7
8
  export class DesignerView extends BaseCustomWebComponentConstructorAppend {
8
9
  _sVert;
@@ -83,7 +84,7 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
83
84
  height: calc(100% - 32px);
84
85
  }
85
86
 
86
- #tool-bar{
87
+ #tool-bar {
87
88
  width: 24px;
88
89
  height: calc(100% - 32px);
89
90
  position: absolute;
@@ -131,7 +132,6 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
131
132
  <node-projects-plain-scrollbar id="s-hor" value="0.5" class="bottom-scroll"></node-projects-plain-scrollbar>
132
133
  <node-projects-plain-scrollbar id="s-vert" value="0.5" orientation="vertical" class="right-scroll">
133
134
  </node-projects-plain-scrollbar>
134
- <node-projects-designer-toolbar id="tool-bar" class="tool-bar"></node-projects-designer-toolbar>
135
135
  <div class="bottom-right"></div>
136
136
  <div id="lowertoolbar">
137
137
  <input id="zoomInput" type="text" value="100%">
@@ -150,11 +150,16 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
150
150
  constructor() {
151
151
  super();
152
152
  this._restoreCachedInititalValues();
153
+ this._sVert = this._getDomElement('s-vert');
154
+ this._sHor = this._getDomElement('s-hor');
153
155
  const outer = this._getDomElement('outer');
154
156
  this._designerCanvas = new DesignerCanvas();
155
157
  this._designerCanvas.id = "canvas";
156
158
  this._designerCanvas.appendChild(document.createElement("slot"));
157
159
  outer.insertAdjacentElement('afterbegin', this._designerCanvas);
160
+ this._toolbar = new DesignerToolbar();
161
+ this._toolbar.id = 'tool-bar';
162
+ this._sVert.insertAdjacentElement('afterend', this._toolbar);
158
163
  this._designerCanvas.onZoomFactorChanged.on(() => {
159
164
  this._zoomInput.value = Math.round(this._designerCanvas.zoomFactor * 100) + '%';
160
165
  const pos = this.designerCanvas.canvasOffset;
@@ -205,15 +210,9 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
205
210
  alignGrid.onclick = () => { this._designerCanvas.alignOnGrid = !this._designerCanvas.alignOnGrid; alignGrid.style.backgroundColor = this._designerCanvas.alignOnGrid ? 'deepskyblue' : ''; };
206
211
  alignGrid.style.backgroundColor = this._designerCanvas.alignOnGrid ? 'deepskyblue' : '';
207
212
  this._lowertoolbar = this._getDomElement('lowertoolbar');
208
- this._sVert = this._getDomElement('s-vert');
209
- this._sHor = this._getDomElement('s-hor');
210
213
  this._sVert.addEventListener('scrollbar-input', (e) => this._onScrollbar(e));
211
214
  this._sHor.addEventListener('scrollbar-input', (e) => this._onScrollbar(e));
212
215
  }
213
- async ready() {
214
- this._toolbar = await this._getDomElement('tool-bar');
215
- this._toolbar.initialize(this.serviceContainer, this);
216
- }
217
216
  zoomReset() {
218
217
  this._designerCanvas.canvasOffset = { x: 0, y: 0 };
219
218
  this._designerCanvas.zoomFactor = 1;
@@ -244,7 +243,9 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
244
243
  scaleX = cvRect.width / dimensions.width;
245
244
  if (dimensions.height)
246
245
  scaleY = cvRect.height / dimensions.height;
247
- this._designerCanvas.zoomFactor = scaleX < scaleY ? scaleX : scaleY;
246
+ let fak = scaleX < scaleY ? scaleX : scaleY;
247
+ if (!isNaN(fak))
248
+ this._designerCanvas.zoomFactor = fak;
248
249
  this._zoomInput.value = Math.round(this._designerCanvas.zoomFactor * 100) + '%';
249
250
  }
250
251
  _onScrollbar(e) {
@@ -296,8 +297,8 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
296
297
  set designerHeight(value) {
297
298
  this._designerCanvas.designerHeight = value;
298
299
  }
299
- set additionalStyle(value) {
300
- this._designerCanvas.additionalStyle = value;
300
+ set additionalStyles(value) {
301
+ this._designerCanvas.additionalStyles = value;
301
302
  }
302
303
  setDesignItems(designItems) {
303
304
  this._designerCanvas.setDesignItems(designItems);
@@ -319,6 +320,7 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
319
320
  this._lowertoolbar.appendChild(btn);
320
321
  }
321
322
  }
323
+ this._toolbar.initialize(this.serviceContainer, this);
322
324
  }
323
325
  getHTML(designItemsAssignmentList) {
324
326
  //this.instanceServiceContainer.selectionService.setSelectedElements(null);
@@ -4,19 +4,17 @@ export class CanvasExtension extends AbstractExtension {
4
4
  super(extensionManager, designerView, extendedItem);
5
5
  }
6
6
  extend() {
7
- let itemRect = this.extendedItem.element.getBoundingClientRect();
7
+ let itemRect = this.designerCanvas.getNormalizedElementCoordinates(this.extendedItem.element);
8
8
  const computedStyle = getComputedStyle(this.extendedItem.element);
9
9
  if (computedStyle.margin !== '0px') {
10
- const xOffset = itemRect.x - this.designerCanvas.containerBoundingRect.x;
11
- const yOffset = itemRect.y - this.designerCanvas.containerBoundingRect.y;
12
10
  const left = Number.parseFloat(computedStyle.marginLeft.replace('px', ''));
13
11
  const top = Number.parseFloat(computedStyle.marginTop.replace('px', ''));
14
12
  const right = Number.parseFloat(computedStyle.marginRight.replace('px', ''));
15
13
  const bottom = Number.parseFloat(computedStyle.marginBottom.replace('px', ''));
16
- this._drawRect(xOffset - left, yOffset - top, left + itemRect.width + right, top, 'svg-margin');
17
- this._drawRect(xOffset - left, yOffset, left, itemRect.height, 'svg-margin');
18
- this._drawRect(xOffset + itemRect.width, yOffset, right, itemRect.height, 'svg-margin');
19
- this._drawRect(xOffset - left, yOffset + itemRect.height, left + itemRect.width + right, bottom, 'svg-margin');
14
+ this._drawRect(itemRect.x - left, itemRect.y - top, left + itemRect.width + right, top, 'svg-margin');
15
+ this._drawRect(itemRect.x - left, itemRect.y, left, itemRect.height, 'svg-margin');
16
+ this._drawRect(itemRect.x + itemRect.width, itemRect.y, right, itemRect.height, 'svg-margin');
17
+ this._drawRect(itemRect.x - left, itemRect.y + itemRect.height, left + itemRect.width + right, bottom, 'svg-margin');
20
18
  }
21
19
  }
22
20
  refresh() {
@@ -1,4 +1,5 @@
1
1
  import { AbstractExtension } from "./AbstractExtension";
2
+ import { OverlayLayer } from "./OverlayLayer.js";
2
3
  export class GrayOutExtension extends AbstractExtension {
3
4
  _path;
4
5
  constructor(extensionManager, designerView, extendedItem) {
@@ -11,7 +12,7 @@ export class GrayOutExtension extends AbstractExtension {
11
12
  if (!this._path) {
12
13
  this._path = document.createElementNS("http://www.w3.org/2000/svg", "path");
13
14
  this._path.setAttribute('class', 'svg-gray-out');
14
- this.overlayLayerView.appendChild(this._path);
15
+ this.overlayLayerView.addOverlay(this._path, OverlayLayer.Background);
15
16
  this.overlays.push(this._path);
16
17
  }
17
18
  let itemRect = this.extendedItem.element.getBoundingClientRect();
package/dist/index.d.ts CHANGED
@@ -101,6 +101,16 @@ export type { IPlacementView } from "./elements/widgets/designerView/IPlacementV
101
101
  export * from "./elements/widgets/designerView/designerView.js";
102
102
  export * from "./elements/widgets/designerView/overlayLayerView.js";
103
103
  export * from "./elements/widgets/designerView/defaultConfiguredDesignerView.js";
104
+ export * from "./elements/widgets/designerView/tools/toolBar/buttons/DrawToolButtonProvider.js";
105
+ export * from "./elements/widgets/designerView/tools/toolBar/buttons/PointerToolButtonProvider.js";
106
+ export * from "./elements/widgets/designerView/tools/toolBar/buttons/SelectorToolButtonProvider.js";
107
+ export * from "./elements/widgets/designerView/tools/toolBar/buttons/SeperatorToolProvider.js";
108
+ export * from "./elements/widgets/designerView/tools/toolBar/buttons/TextToolButtonProvider.js";
109
+ export * from "./elements/widgets/designerView/tools/toolBar/buttons/ZoomToolButtonProvider.js";
110
+ export * from "./elements/widgets/designerView/tools/toolBar/popups/DrawToolPopup.js";
111
+ export * from "./elements/widgets/designerView/tools/toolBar/DesignerToolbar.js";
112
+ export * from "./elements/widgets/designerView/tools/toolBar/DesignerToolbarButton.js";
113
+ export type { IDesignViewToolbarButtonProvider } from "./elements/widgets/designerView/tools/toolBar/IDesignViewToolbarButtonProvider.js";
104
114
  export type { ITool } from "./elements/widgets/designerView/tools/ITool.js";
105
115
  export * from "./elements/widgets/designerView/tools/toolBar/DesignerToolbar.js";
106
116
  export * from "./elements/widgets/designerView/tools/NamedTools.js";
package/dist/index.js CHANGED
@@ -66,6 +66,15 @@ export * from "./elements/widgets/propertyGrid/PropertyGridWithHeader.js";
66
66
  export * from "./elements/widgets/designerView/designerView.js";
67
67
  export * from "./elements/widgets/designerView/overlayLayerView.js";
68
68
  export * from "./elements/widgets/designerView/defaultConfiguredDesignerView.js";
69
+ export * from "./elements/widgets/designerView/tools/toolBar/buttons/DrawToolButtonProvider.js";
70
+ export * from "./elements/widgets/designerView/tools/toolBar/buttons/PointerToolButtonProvider.js";
71
+ export * from "./elements/widgets/designerView/tools/toolBar/buttons/SelectorToolButtonProvider.js";
72
+ export * from "./elements/widgets/designerView/tools/toolBar/buttons/SeperatorToolProvider.js";
73
+ export * from "./elements/widgets/designerView/tools/toolBar/buttons/TextToolButtonProvider.js";
74
+ export * from "./elements/widgets/designerView/tools/toolBar/buttons/ZoomToolButtonProvider.js";
75
+ export * from "./elements/widgets/designerView/tools/toolBar/popups/DrawToolPopup.js";
76
+ export * from "./elements/widgets/designerView/tools/toolBar/DesignerToolbar.js";
77
+ export * from "./elements/widgets/designerView/tools/toolBar/DesignerToolbarButton.js";
69
78
  export * from "./elements/widgets/designerView/tools/toolBar/DesignerToolbar.js";
70
79
  export * from "./elements/widgets/designerView/tools/NamedTools.js";
71
80
  export * from "./elements/widgets/designerView/tools/DrawElementTool.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.97",
4
+ "version": "0.0.100",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",
@@ -19,20 +19,20 @@
19
19
  "devDependencies": {
20
20
  "@node-projects/lean-he-esm": "^3.3.0",
21
21
  "@node-projects/node-html-parser-esm": "^2.4.1",
22
- "@papyrs/stylo": "^0.0.15",
22
+ "@papyrs/stylo": "^0.0.26",
23
23
  "@types/codemirror": "^5.60.5",
24
24
  "@types/jquery": "^3.5.14",
25
25
  "@types/jquery.fancytree": "0.0.7",
26
- "ace-builds": "^1.4.14",
27
- "codemirror": "^5.65.3",
28
- "esprima-next": "^5.8.1",
26
+ "ace-builds": "^1.5.1",
27
+ "codemirror": "^5.65.4",
28
+ "esprima-next": "^5.8.2",
29
29
  "html2canvas": "*",
30
- "jest": "^27.5.1",
30
+ "jest": "^28.1.0",
31
31
  "jquery": "^3.6.0",
32
32
  "jquery.fancytree": "^2.38.1",
33
33
  "monaco-editor": "^0.33.0",
34
- "ts-jest": "^27.1.4",
35
- "typescript": "^4.6.3",
34
+ "ts-jest": "^28.0.3",
35
+ "typescript": "^4.7.2",
36
36
  "typescript-lit-html-plugin": "^0.9.0"
37
37
  },
38
38
  "repository": {