@node-projects/web-component-designer 0.1.169 → 0.1.170

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.
@@ -17,6 +17,6 @@ export declare function getElementSize(element: HTMLElement): {
17
17
  width: number;
18
18
  height: number;
19
19
  };
20
- export declare function getDesignerCanvasNormalizedTransformedCornerDOMPoints(element: HTMLElement, untransformedCornerPointsOffset: IPoint | null, designerCanvas: IDesignerCanvas, cache?: Record<string | symbol, any>): [DOMPoint, DOMPoint, DOMPoint, DOMPoint];
20
+ export declare function getDesignerCanvasNormalizedTransformedCornerDOMPoints(element: HTMLElement, untransformedCornerPointsOffset: IPoint | [IPoint, IPoint, IPoint, IPoint] | null, designerCanvas: IDesignerCanvas, cache?: Record<string | symbol, any>): [DOMPoint, DOMPoint, DOMPoint, DOMPoint];
21
21
  export declare function extractTranslationFromDOMMatrix(matrix: DOMMatrix): DOMPoint;
22
22
  export declare function extractRotationAngleFromDOMMatrix(matrix: DOMMatrix): number;
@@ -193,12 +193,26 @@ export function getElementSize(element) {
193
193
  }
194
194
  return { width, height };
195
195
  }
196
+ const nullOffsetArray = [{ x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }];
196
197
  export function getDesignerCanvasNormalizedTransformedCornerDOMPoints(element, untransformedCornerPointsOffset, designerCanvas, cache) {
197
198
  const topleft = 0;
198
199
  const topright = 1;
199
200
  const bottomleft = 2;
200
201
  const bottomright = 3;
201
- const intUntransformedCornerPointsOffset = untransformedCornerPointsOffset ? { x: untransformedCornerPointsOffset.x / designerCanvas.scaleFactor, y: untransformedCornerPointsOffset.y / designerCanvas.scaleFactor } : { x: 0, y: 0 };
202
+ let intUntransformedCornerPointsOffset = nullOffsetArray;
203
+ if (untransformedCornerPointsOffset != null) {
204
+ if (Array.isArray(untransformedCornerPointsOffset)) {
205
+ const v0 = { x: untransformedCornerPointsOffset[0].x / designerCanvas.scaleFactor, y: untransformedCornerPointsOffset[0].y / designerCanvas.scaleFactor };
206
+ const v1 = { x: untransformedCornerPointsOffset[1].x / designerCanvas.scaleFactor, y: untransformedCornerPointsOffset[1].y / designerCanvas.scaleFactor };
207
+ const v2 = { x: untransformedCornerPointsOffset[2].x / designerCanvas.scaleFactor, y: untransformedCornerPointsOffset[2].y / designerCanvas.scaleFactor };
208
+ const v3 = { x: untransformedCornerPointsOffset[3].x / designerCanvas.scaleFactor, y: untransformedCornerPointsOffset[3].y / designerCanvas.scaleFactor };
209
+ intUntransformedCornerPointsOffset = [v0, v1, v2, v3];
210
+ }
211
+ else {
212
+ const v = { x: untransformedCornerPointsOffset.x / designerCanvas.scaleFactor, y: untransformedCornerPointsOffset.y / designerCanvas.scaleFactor };
213
+ intUntransformedCornerPointsOffset = [v, v, v, v];
214
+ }
215
+ }
202
216
  const p0Offsets = getElementsWindowOffsetWithoutSelfAndParentTransformations(element, designerCanvas.zoomFactor, cache);
203
217
  const p0OffsetsRelatedToCanvas = DOMPoint.fromPoint({
204
218
  x: p0Offsets.offsetLeft - designerCanvas.containerBoundingRect.left,
@@ -207,20 +221,20 @@ export function getDesignerCanvasNormalizedTransformedCornerDOMPoints(element, u
207
221
  let { width, height } = getElementSize(element);
208
222
  const elementWithoutTransformCornerDOMPoints = [];
209
223
  elementWithoutTransformCornerDOMPoints[topleft] = DOMPoint.fromPoint({
210
- x: p0OffsetsRelatedToCanvas.x - intUntransformedCornerPointsOffset.x,
211
- y: p0OffsetsRelatedToCanvas.y - intUntransformedCornerPointsOffset.y
224
+ x: p0OffsetsRelatedToCanvas.x - intUntransformedCornerPointsOffset[0].x,
225
+ y: p0OffsetsRelatedToCanvas.y - intUntransformedCornerPointsOffset[0].y
212
226
  });
213
227
  elementWithoutTransformCornerDOMPoints[topright] = DOMPoint.fromPoint({
214
- x: p0OffsetsRelatedToCanvas.x + width + intUntransformedCornerPointsOffset.x,
215
- y: p0OffsetsRelatedToCanvas.y - intUntransformedCornerPointsOffset.y
228
+ x: p0OffsetsRelatedToCanvas.x + width + intUntransformedCornerPointsOffset[1].x,
229
+ y: p0OffsetsRelatedToCanvas.y - intUntransformedCornerPointsOffset[1].y
216
230
  });
217
231
  elementWithoutTransformCornerDOMPoints[bottomleft] = DOMPoint.fromPoint({
218
- x: p0OffsetsRelatedToCanvas.x - intUntransformedCornerPointsOffset.x,
219
- y: p0OffsetsRelatedToCanvas.y + height + intUntransformedCornerPointsOffset.y
232
+ x: p0OffsetsRelatedToCanvas.x - intUntransformedCornerPointsOffset[2].x,
233
+ y: p0OffsetsRelatedToCanvas.y + height + intUntransformedCornerPointsOffset[2].y
220
234
  });
221
235
  elementWithoutTransformCornerDOMPoints[bottomright] = DOMPoint.fromPoint({
222
- x: p0OffsetsRelatedToCanvas.x + width + intUntransformedCornerPointsOffset.x,
223
- y: p0OffsetsRelatedToCanvas.y + height + intUntransformedCornerPointsOffset.y
236
+ x: p0OffsetsRelatedToCanvas.x + width + intUntransformedCornerPointsOffset[3].x,
237
+ y: p0OffsetsRelatedToCanvas.y + height + intUntransformedCornerPointsOffset[3].y
224
238
  });
225
239
  const toSplit = getComputedStyle(element).transformOrigin.split(' ');
226
240
  const tfX = parseFloat(toSplit[0]);
@@ -24,7 +24,7 @@ export declare class DesignItem implements IDesignItem {
24
24
  nodeReplaced: TypedEvent<void>;
25
25
  get window(): Window & typeof globalThis;
26
26
  get document(): Document;
27
- get usableContainer(): ShadowRoot | Document | Element;
27
+ get usableContainer(): Element | ShadowRoot | Document;
28
28
  clone(): Promise<IDesignItem>;
29
29
  allMatching(selectors: string): Generator<IDesignItem, void, undefined>;
30
30
  replaceNode(newNode: Node): void;
@@ -44,5 +44,6 @@ export declare abstract class AbstractStylesheetService implements IStylesheetSe
44
44
  changeSource: 'extern' | 'styleupdate' | 'undo';
45
45
  }>;
46
46
  stylesheetsChanged: TypedEvent<void>;
47
+ static patchStylesheetSelectorForDesigner(text: string): string;
47
48
  protected elementMatchesASelector(designItem: IDesignItem, selectors: string[]): boolean;
48
49
  }
@@ -1,5 +1,5 @@
1
1
  import { TypedEvent } from "@node-projects/base-custom-webcomponent";
2
- import { DesignerCanvas } from '../../widgets/designerView/designerCanvas.js';
2
+ import { forceActiveAttributeName, forceFocusAttributeName, forceFocusVisibleAttributeName, forceFocusWithinAttributeName, forceHoverAttributeName, forceVisitedAttributeName } from "../../item/DesignItem.js";
3
3
  export class AbstractStylesheetService {
4
4
  _stylesheets = new Map();
5
5
  _documentStylesheets = new Map();
@@ -100,14 +100,22 @@ export class AbstractStylesheetService {
100
100
  }
101
101
  stylesheetChanged = new TypedEvent();
102
102
  stylesheetsChanged = new TypedEvent();
103
+ static patchStylesheetSelectorForDesigner(text) {
104
+ return text.replaceAll(':hover', '[' + forceHoverAttributeName + ']')
105
+ .replaceAll(':active', '[' + forceActiveAttributeName + ']')
106
+ .replaceAll(':visited', '[' + forceVisitedAttributeName + ']')
107
+ .replaceAll(':focus', '[' + forceFocusAttributeName + ']')
108
+ .replaceAll(':focus-within', '[' + forceFocusWithinAttributeName + ']')
109
+ .replaceAll(':focus-visible', '[' + forceFocusVisibleAttributeName + ']');
110
+ }
103
111
  elementMatchesASelector(designItem, selectors) {
104
112
  if (designItem == null)
105
113
  return true;
106
114
  for (let selector of selectors) {
107
- if (selector == ':host') {
115
+ /*if (selector == ':host') {
108
116
  selector = DesignerCanvas.cssprefixConstant;
109
- }
110
- if (designItem.element.matches(selector))
117
+ }*/
118
+ if (designItem.element.matches(AbstractStylesheetService.patchStylesheetSelectorForDesigner(selector)))
111
119
  return true;
112
120
  }
113
121
  return false;
@@ -58,7 +58,6 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
58
58
  private _outercanvas2;
59
59
  private _lastHoverDesignItem;
60
60
  private _firstConnect;
61
- static cssprefixConstant: string;
62
61
  static readonly style: CSSStyleSheet;
63
62
  static readonly template: HTMLTemplateElement;
64
63
  extensionManager: IExtensionManager;
@@ -131,7 +130,6 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
131
130
  private transformPoint;
132
131
  elementsFromPoint(x: number, y: number): Element[];
133
132
  getElementAtPoint(point: IPoint, ignoreElementCallback?: (element: HTMLElement) => boolean): HTMLElement;
134
- _patchStylesheetForDesigner(text: string): string;
135
133
  private _hoverElement;
136
134
  showHoverExtension(element: Element, event: Event): void;
137
135
  private _onWheel;
@@ -1,6 +1,6 @@
1
1
  import { EventNames } from '../../../enums/EventNames.js';
2
2
  import { InstanceServiceContainer } from '../../services/InstanceServiceContainer.js';
3
- import { DesignItem, forceActiveAttributeName, forceFocusAttributeName, forceFocusVisibleAttributeName, forceFocusWithinAttributeName, forceHoverAttributeName, forceVisitedAttributeName } from '../../item/DesignItem.js';
3
+ import { DesignItem, forceHoverAttributeName } from '../../item/DesignItem.js';
4
4
  import { BaseCustomWebComponentLazyAppend, css, html, TypedEvent } from '@node-projects/base-custom-webcomponent';
5
5
  import { dragDropFormatNameBindingObject } from '../../../Constants.js';
6
6
  import { InsertAction } from '../../services/undoService/transactionItems/InsertAction.js';
@@ -22,6 +22,7 @@ import { SetDesignItemsAction } from '../../services/undoService/transactionItem
22
22
  import { filterChildPlaceItems } from '../../helper/LayoutHelper.js';
23
23
  import { TouchGestureHelper } from '../../helper/TouchGestureHelper.js';
24
24
  import { stylesheetFromString } from '../../helper/StylesheetHelper.js';
25
+ import { AbstractStylesheetService } from '../../services/stylesheetService/AbstractStylesheetService.js';
25
26
  export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
26
27
  // Public Properties
27
28
  serviceContainer;
@@ -111,7 +112,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
111
112
  _outercanvas2;
112
113
  _lastHoverDesignItem;
113
114
  _firstConnect;
114
- static cssprefixConstant = '#node-projects-designer-canvas-canvas ';
115
+ //public static cssprefixConstant = '#node-projects-designer-canvas-canvas ';
115
116
  static style = css `
116
117
  :host {
117
118
  display: block;
@@ -375,7 +376,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
375
376
  if (this.instanceServiceContainer.stylesheetService) {
376
377
  styles.push(...this.instanceServiceContainer.stylesheetService
377
378
  .getStylesheets()
378
- .map(x => stylesheetFromString(this._window, this._patchStylesheetForDesigner(x.content))));
379
+ .map(x => stylesheetFromString(this._window, AbstractStylesheetService.patchStylesheetSelectorForDesigner(x.content))));
379
380
  }
380
381
  if (this._useIframe) {
381
382
  this._iframe.contentWindow.document.adoptedStyleSheets = styles;
@@ -1116,14 +1117,6 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
1116
1117
  }
1117
1118
  return currentElement;
1118
1119
  }
1119
- _patchStylesheetForDesigner(text) {
1120
- return text.replaceAll(':hover', '[' + forceHoverAttributeName + ']')
1121
- .replaceAll(':active', '[' + forceActiveAttributeName + ']')
1122
- .replaceAll(':visited', '[' + forceVisitedAttributeName + ']')
1123
- .replaceAll(':focus', '[' + forceFocusAttributeName + ']')
1124
- .replaceAll(':focus-within', '[' + forceFocusWithinAttributeName + ']')
1125
- .replaceAll(':focus-visible', '[' + forceFocusVisibleAttributeName + ']');
1126
- }
1127
1120
  _hoverElement;
1128
1121
  showHoverExtension(element, event) {
1129
1122
  const currentDesignItem = DesignItem.GetOrCreateDesignItem(element, element, this.serviceContainer, this.instanceServiceContainer);
@@ -17,6 +17,7 @@ export declare abstract class AbstractExtensionBase {
17
17
  protected _drawLine(x1: number, y1: number, x2: number, y2: number, className?: string, line?: SVGLineElement, overlayLayer?: OverlayLayer): SVGLineElement;
18
18
  protected _drawCircle(x: number, y: number, radius: number, className?: string, circle?: SVGCircleElement, overlayLayer?: OverlayLayer): SVGCircleElement;
19
19
  protected _drawRect(x: number, y: number, w: number, h: number, className?: string, rect?: SVGRectElement, overlayLayer?: OverlayLayer): SVGRectElement;
20
+ protected _drawComplexRect(points: [IPoint, IPoint, IPoint, IPoint], className?: string, rect?: SVGPathElement, overlayLayer?: OverlayLayer): SVGPathElement;
20
21
  protected _drawPath(data: string, className?: string, path?: SVGPathElement, overlayLayer?: OverlayLayer): SVGPathElement;
21
22
  protected _drawText(text: string, x: number, y: number, className?: string, textEl?: SVGTextElement, overlayLayer?: OverlayLayer): SVGTextElement;
22
23
  protected _drawHTML(html: string | HTMLElement, x: number, y: number, w: number, h: number, className?: string, htmlObj?: SVGForeignObjectElement, overlayLayer?: OverlayLayer): SVGForeignObjectElement;
@@ -66,6 +66,14 @@ export class AbstractExtensionBase {
66
66
  }
67
67
  return newRect;
68
68
  }
69
+ _drawComplexRect(points, className, rect, overlayLayer) {
70
+ const d = "M" + points.map(x => x.x + ',' + x.y).join(' ') + 'Z';
71
+ const newRect = this.overlayLayerView.drawPath(this.constructor.name, d, className, rect, overlayLayer);
72
+ if (!rect) {
73
+ this.overlays.push(newRect);
74
+ }
75
+ return newRect;
76
+ }
69
77
  _drawPath(data, className, path, overlayLayer) {
70
78
  const newPath = this.overlayLayerView.drawPath(this.constructor.name, data, className, path, overlayLayer);
71
79
  if (!path) {
@@ -4,7 +4,8 @@ import { AbstractExtension } from './AbstractExtension.js';
4
4
  import { IExtensionManager } from './IExtensionManger.js';
5
5
  export declare class MarginExtension extends AbstractExtension {
6
6
  constructor(extensionManager: IExtensionManager, designerView: IDesignerCanvas, extendedItem: IDesignItem);
7
- extend(): void;
8
- refresh(): void;
7
+ private _path;
8
+ extend(cache: Record<string | symbol, any>, event?: Event): void;
9
+ refresh(cache: Record<string | symbol, any>, event?: Event): void;
9
10
  dispose(): void;
10
11
  }
@@ -1,14 +1,15 @@
1
+ import { getDesignerCanvasNormalizedTransformedCornerDOMPoints } from '../../../helper/TransformHelper.js';
1
2
  import { AbstractExtension } from './AbstractExtension.js';
2
3
  import { OverlayLayer } from './OverlayLayer.js';
3
4
  export class MarginExtension extends AbstractExtension {
4
5
  constructor(extensionManager, designerView, extendedItem) {
5
6
  super(extensionManager, designerView, extendedItem);
6
7
  }
7
- extend() {
8
- this.refresh();
8
+ _path;
9
+ extend(cache, event) {
10
+ this.refresh(cache, event);
9
11
  }
10
- refresh() {
11
- const itemRect = this.designerCanvas.getNormalizedElementCoordinates(this.extendedItem.element);
12
+ refresh(cache, event) {
12
13
  const computedStyle = getComputedStyle(this.extendedItem.element);
13
14
  if (computedStyle.margin !== '0px') {
14
15
  const left = Number.parseFloat(computedStyle.marginLeft.replace('px', ''));
@@ -16,12 +17,14 @@ export class MarginExtension extends AbstractExtension {
16
17
  const right = Number.parseFloat(computedStyle.marginRight.replace('px', ''));
17
18
  const bottom = Number.parseFloat(computedStyle.marginBottom.replace('px', ''));
18
19
  if (!isNaN(left) && !isNaN(top) && !isNaN(right) && !isNaN(bottom)) {
19
- if (this._valuesHaveChanges(left, top, right, bottom, itemRect.x, itemRect.y, itemRect.width, itemRect.height)) {
20
- this._removeAllOverlays();
21
- this._drawRect(itemRect.x - left, itemRect.y - top, left + itemRect.width + right, top, 'svg-margin', null, OverlayLayer.Background);
22
- this._drawRect(itemRect.x - left, itemRect.y, left, itemRect.height, 'svg-margin', null, OverlayLayer.Background);
23
- this._drawRect(itemRect.x + itemRect.width, itemRect.y, right, itemRect.height, 'svg-margin', null, OverlayLayer.Background);
24
- this._drawRect(itemRect.x - left, itemRect.y + itemRect.height, left + itemRect.width + right, bottom, 'svg-margin', null, OverlayLayer.Background);
20
+ const p = getDesignerCanvasNormalizedTransformedCornerDOMPoints(this.extendedItem.element, null, this.designerCanvas, cache);
21
+ if (!isNaN(p[0].x)) {
22
+ if (this._valuesHaveChanges(left, top, right, bottom, p[0].x, p[0].y, p[1].x, p[1].y, p[2].x, p[2].y, p[3].x, p[3].y)) {
23
+ const p2 = getDesignerCanvasNormalizedTransformedCornerDOMPoints(this.extendedItem.element, [{ x: left, y: top }, { x: right, y: top }, { x: left, y: bottom }, { x: right, y: bottom }], this.designerCanvas, cache);
24
+ let d = "M" + [p[0], p[1], p[3], p[2]].map(x => x.x + ',' + x.y).join(' ') + 'Z ';
25
+ d += "M" + [p2[0], p2[1], p2[3], p2[2]].map(x => x.x + ',' + x.y).join(' ') + 'Z ';
26
+ this._path = this._drawPath(d, 'svg-margin', this._path, OverlayLayer.Background);
27
+ }
25
28
  }
26
29
  }
27
30
  }
@@ -11,6 +11,6 @@ export class MarginExtensionProvider {
11
11
  return new MarginExtension(extensionManager, designerView, designItem);
12
12
  }
13
13
  style = css `
14
- .svg-margin { fill: #ff944766; }
14
+ .svg-margin { fill: #ff944766; fill-rule: evenodd; }
15
15
  `;
16
16
  }
@@ -17,16 +17,18 @@ export class MultipleSelectionRectExtension extends AbstractExtension {
17
17
  }
18
18
  refresh() {
19
19
  let selection = this._designerView.instanceServiceContainer.selectionService.selectedElements;
20
- selection = filterChildPlaceItems(selection);
21
- let rect = calculateOuterRect(selection, this._designerView);
22
- this._line1 = this._drawLine(rect.x, rect.y, rect.x + rect.width, rect.y, 'svg-multiple-rect-selection', this._line1, OverlayLayer.Background);
23
- this._line2 = this._drawLine(rect.x + rect.width, rect.y, rect.x + rect.width, rect.y + rect.height, 'svg-multiple-rect-selection', this._line2, OverlayLayer.Background);
24
- this._line3 = this._drawLine(rect.x + rect.width, rect.y + rect.height, rect.x, rect.y + rect.height, 'svg-multiple-rect-selection', this._line3, OverlayLayer.Background);
25
- this._line4 = this._drawLine(rect.x, rect.y + rect.height, rect.x, rect.y, 'svg-multiple-rect-selection', this._line4, OverlayLayer.Background);
26
- this._line1.style.strokeWidth = (2 / this.designerCanvas.zoomFactor).toString();
27
- this._line2.style.strokeWidth = (2 / this.designerCanvas.zoomFactor).toString();
28
- this._line3.style.strokeWidth = (2 / this.designerCanvas.zoomFactor).toString();
29
- this._line4.style.strokeWidth = (2 / this.designerCanvas.zoomFactor).toString();
20
+ if (selection.length > 1) {
21
+ selection = filterChildPlaceItems(selection);
22
+ let rect = calculateOuterRect(selection, this._designerView);
23
+ this._line1 = this._drawLine(rect.x, rect.y, rect.x + rect.width, rect.y, 'svg-multiple-rect-selection', this._line1, OverlayLayer.Background);
24
+ this._line2 = this._drawLine(rect.x + rect.width, rect.y, rect.x + rect.width, rect.y + rect.height, 'svg-multiple-rect-selection', this._line2, OverlayLayer.Background);
25
+ this._line3 = this._drawLine(rect.x + rect.width, rect.y + rect.height, rect.x, rect.y + rect.height, 'svg-multiple-rect-selection', this._line3, OverlayLayer.Background);
26
+ this._line4 = this._drawLine(rect.x, rect.y + rect.height, rect.x, rect.y, 'svg-multiple-rect-selection', this._line4, OverlayLayer.Background);
27
+ this._line1.style.strokeWidth = (2 / this.designerCanvas.zoomFactor).toString();
28
+ this._line2.style.strokeWidth = (2 / this.designerCanvas.zoomFactor).toString();
29
+ this._line3.style.strokeWidth = (2 / this.designerCanvas.zoomFactor).toString();
30
+ this._line4.style.strokeWidth = (2 / this.designerCanvas.zoomFactor).toString();
31
+ }
30
32
  }
31
33
  dispose() {
32
34
  this._removeAllOverlays();
@@ -4,7 +4,8 @@ import { AbstractExtension } from './AbstractExtension.js';
4
4
  import { IExtensionManager } from './IExtensionManger.js';
5
5
  export declare class PaddingExtension extends AbstractExtension {
6
6
  constructor(extensionManager: IExtensionManager, designerView: IDesignerCanvas, extendedItem: IDesignItem);
7
- extend(): void;
8
- refresh(): void;
7
+ private _path;
8
+ extend(cache: Record<string | symbol, any>, event?: Event): void;
9
+ refresh(cache: Record<string | symbol, any>, event?: Event): void;
9
10
  dispose(): void;
10
11
  }
@@ -1,31 +1,34 @@
1
+ import { getDesignerCanvasNormalizedTransformedCornerDOMPoints } from '../../../helper/TransformHelper.js';
1
2
  import { AbstractExtension } from './AbstractExtension.js';
2
3
  import { OverlayLayer } from './OverlayLayer.js';
3
4
  export class PaddingExtension extends AbstractExtension {
4
5
  constructor(extensionManager, designerView, extendedItem) {
5
6
  super(extensionManager, designerView, extendedItem);
6
7
  }
7
- extend() {
8
- this.refresh();
8
+ _path;
9
+ extend(cache, event) {
10
+ this.refresh(cache, event);
9
11
  }
10
- refresh() {
11
- const itemRect = this.designerCanvas.getNormalizedElementCoordinates(this.extendedItem.element);
12
+ refresh(cache, event) {
12
13
  const computedStyle = getComputedStyle(this.extendedItem.element);
13
14
  if (computedStyle.padding !== '0px') {
14
- const left = Number.parseFloat(computedStyle.paddingLeft.replace('px', ''));
15
- const top = Number.parseFloat(computedStyle.paddingTop.replace('px', ''));
16
- const right = Number.parseFloat(computedStyle.paddingRight.replace('px', ''));
17
- const bottom = Number.parseFloat(computedStyle.paddingBottom.replace('px', ''));
18
- const bleft = Number.parseFloat(computedStyle.borderLeftWidth.replace('px', ''));
19
- const btop = Number.parseFloat(computedStyle.borderTopWidth.replace('px', ''));
20
- const bright = Number.parseFloat(computedStyle.borderRightWidth.replace('px', ''));
21
- const bbottom = Number.parseFloat(computedStyle.borderBottomWidth.replace('px', ''));
15
+ let left = Number.parseFloat(computedStyle.paddingLeft.replace('px', ''));
16
+ let top = Number.parseFloat(computedStyle.paddingTop.replace('px', ''));
17
+ let right = Number.parseFloat(computedStyle.paddingRight.replace('px', ''));
18
+ let bottom = Number.parseFloat(computedStyle.paddingBottom.replace('px', ''));
19
+ left += Number.parseFloat(computedStyle.borderLeftWidth.replace('px', ''));
20
+ top += Number.parseFloat(computedStyle.borderTopWidth.replace('px', ''));
21
+ right += Number.parseFloat(computedStyle.borderRightWidth.replace('px', ''));
22
+ bottom += Number.parseFloat(computedStyle.borderBottomWidth.replace('px', ''));
22
23
  if (!isNaN(left) && !isNaN(top) && !isNaN(right) && !isNaN(bottom)) {
23
- if (this._valuesHaveChanges(left, top, right, bottom, bleft, btop, bright, bbottom, itemRect.x, itemRect.y, itemRect.width, itemRect.height)) {
24
- this._removeAllOverlays();
25
- this._drawRect(itemRect.x + bleft + left, itemRect.y + btop, itemRect.width - left - right - bleft - bright, top, 'svg-padding', null, OverlayLayer.Background);
26
- this._drawRect(itemRect.x + bleft, itemRect.y + btop, left, itemRect.height - btop - bbottom, 'svg-padding', null, OverlayLayer.Background);
27
- this._drawRect(itemRect.x + bleft + left, itemRect.y + itemRect.height - bottom - bbottom, itemRect.width - left - right - bleft - bright, bottom, 'svg-padding', null, OverlayLayer.Background);
28
- this._drawRect(itemRect.x + itemRect.width - right - bright, itemRect.y + btop, right, itemRect.height - btop - bbottom, 'svg-padding', null, OverlayLayer.Background);
24
+ const p = getDesignerCanvasNormalizedTransformedCornerDOMPoints(this.extendedItem.element, null, this.designerCanvas, cache);
25
+ if (!isNaN(p[0].x)) {
26
+ if (this._valuesHaveChanges(left, top, right, bottom, p[0].x, p[0].y, p[1].x, p[1].y, p[2].x, p[2].y, p[3].x, p[3].y)) {
27
+ const p2 = getDesignerCanvasNormalizedTransformedCornerDOMPoints(this.extendedItem.element, [{ x: -left, y: -top }, { x: -right, y: -top }, { x: -left, y: -bottom }, { x: -right, y: -bottom }], this.designerCanvas, cache);
28
+ let d = "M" + [p[0], p[1], p[3], p[2]].map(x => x.x + ',' + x.y).join(' ') + 'Z ';
29
+ d += "M" + [p2[0], p2[1], p2[3], p2[2]].map(x => x.x + ',' + x.y).join(' ') + 'Z ';
30
+ this._path = this._drawPath(d, 'svg-padding', this._path, OverlayLayer.Background);
31
+ }
29
32
  }
30
33
  }
31
34
  }
@@ -11,6 +11,6 @@ export class PaddingExtensionProvider {
11
11
  return new PaddingExtension(extensionManager, designerView, designItem);
12
12
  }
13
13
  static style = css `
14
- .svg-padding { fill: #32cd3266; }
14
+ .svg-padding { fill: #32cd3266; fill-rule: evenodd; }
15
15
  `;
16
16
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "A WYSIWYG designer webcomponent for html components",
3
3
  "name": "@node-projects/web-component-designer",
4
- "version": "0.1.169",
4
+ "version": "0.1.170",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",
@@ -9,6 +9,8 @@
9
9
  "scripts": {
10
10
  "tsc": "tsc",
11
11
  "build": "tsc",
12
+ "link": "npm link",
13
+ "watch": "pm2 start tsc --watch",
12
14
  "prepublishOnly": "npm run build"
13
15
  },
14
16
  "dependencies": {