@node-projects/web-component-designer 0.0.61 → 0.0.65

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.
Files changed (54) hide show
  1. package/.vscode/settings.json +1 -1
  2. package/ACKNOWLEDGMENTS +7 -0
  3. package/dist/elements/controls/DesignerTabControl.js +4 -2
  4. package/dist/elements/controls/PlainScrollbar.d.ts +15 -0
  5. package/dist/elements/controls/PlainScrollbar.js +482 -0
  6. package/dist/elements/controls/SimpleSplitView.d.ts +11 -0
  7. package/dist/elements/controls/SimpleSplitView.js +67 -0
  8. package/dist/elements/controls/SimpleSplitView2.d.ts +11 -0
  9. package/dist/elements/controls/SimpleSplitView2.js +63 -0
  10. package/dist/elements/controls/aa.d.ts +24 -0
  11. package/dist/elements/controls/aa.js +98 -0
  12. package/dist/elements/documentContainer.d.ts +6 -1
  13. package/dist/elements/documentContainer.js +51 -14
  14. package/dist/elements/helper/PathDataPolyfill.d.ts +5 -1
  15. package/dist/elements/helper/PathDataPolyfill.js +49 -1
  16. package/dist/elements/helper/contextMenu/ContextMenuHelper.js +1 -0
  17. package/dist/elements/services/DefaultServiceBootstrap.js +8 -0
  18. package/dist/elements/services/htmlParserService/NodeHtmlParserService.js +2 -0
  19. package/dist/elements/services/undoService/UndoService.js +3 -0
  20. package/dist/elements/widgets/codeView/code-view-monaco.js +2 -2
  21. package/dist/elements/widgets/designerView/IDesignerCanvas.d.ts +4 -0
  22. package/dist/elements/widgets/designerView/designerCanvas.d.ts +8 -1
  23. package/dist/elements/widgets/designerView/designerCanvas.js +48 -22
  24. package/dist/elements/widgets/designerView/designerView.d.ts +2 -1
  25. package/dist/elements/widgets/designerView/designerView.js +68 -18
  26. package/dist/elements/widgets/designerView/extensions/MouseOverExtension.js +1 -1
  27. package/dist/elements/widgets/designerView/extensions/PositionExtension.js +4 -4
  28. package/dist/elements/widgets/designerView/extensions/PrimarySelectionDefaultExtension.js +2 -2
  29. package/dist/elements/widgets/designerView/extensions/ResizeExtension.d.ts +2 -1
  30. package/dist/elements/widgets/designerView/extensions/ResizeExtension.js +19 -15
  31. package/dist/elements/widgets/designerView/extensions/RotateExtension.js +1 -1
  32. package/dist/elements/widgets/designerView/extensions/SelectionDefaultExtension.js +1 -1
  33. package/dist/elements/widgets/designerView/extensions/TransformOriginExtension.js +2 -2
  34. package/dist/elements/widgets/designerView/overlayLayerView.d.ts +1 -0
  35. package/dist/elements/widgets/designerView/overlayLayerView.js +6 -0
  36. package/dist/elements/widgets/designerView/tools/DrawEllipsisTool.d.ts +13 -0
  37. package/dist/elements/widgets/designerView/tools/DrawEllipsisTool.js +72 -0
  38. package/dist/elements/widgets/designerView/tools/DrawLineTool.d.ts +13 -0
  39. package/dist/elements/widgets/designerView/tools/DrawLineTool.js +75 -0
  40. package/dist/elements/widgets/designerView/tools/DrawPathTool.d.ts +0 -2
  41. package/dist/elements/widgets/designerView/tools/DrawPathTool.js +5 -18
  42. package/dist/elements/widgets/designerView/tools/DrawRectTool.d.ts +18 -0
  43. package/dist/elements/widgets/designerView/tools/DrawRectTool.js +86 -0
  44. package/dist/elements/widgets/designerView/tools/NamedTools.d.ts +3 -0
  45. package/dist/elements/widgets/designerView/tools/NamedTools.js +3 -0
  46. package/dist/elements/widgets/designerView/tools/PanTool.js +14 -0
  47. package/dist/elements/widgets/designerView/tools/PointerTool.js +7 -0
  48. package/dist/elements/widgets/designerView/tools/RectangleSelectorTool.js +2 -2
  49. package/dist/elements/widgets/propertyGrid/PropertyGrid.js +1 -0
  50. package/dist/elements/widgets/propertyGrid/PropertyGridWithHeader.js +1 -0
  51. package/dist/elements/widgets/treeView/treeView.js +1 -1
  52. package/dist/index.d.ts +4 -0
  53. package/dist/index.js +4 -0
  54. package/package.json +1 -1
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Split View is an image comparison component
3
+ *
4
+ * <split-view>
5
+ * <picture slot="top">[...]</picture>
6
+ * <picture slot="bottom">[...]</picture>
7
+ * </split-view>
8
+ *
9
+ * Options are;
10
+ *
11
+ * start (number) The point where the comparison line should start (0 = left, 1000 = right)
12
+ * mode (string) A CSS mix-blend-mode to use for comparison
13
+ */
14
+ import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
15
+ export declare class SimpleSplitView extends BaseCustomWebComponentConstructorAppend {
16
+ static readonly style: CSSStyleSheet;
17
+ static readonly template: HTMLTemplateElement;
18
+ static properties: {
19
+ start: NumberConstructor;
20
+ };
21
+ constructor();
22
+ start: number;
23
+ ready(): void;
24
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Split View is an image comparison component
3
+ *
4
+ * <split-view>
5
+ * <picture slot="top">[...]</picture>
6
+ * <picture slot="bottom">[...]</picture>
7
+ * </split-view>
8
+ *
9
+ * Options are;
10
+ *
11
+ * start (number) The point where the comparison line should start (0 = left, 1000 = right)
12
+ * mode (string) A CSS mix-blend-mode to use for comparison
13
+ */
14
+ import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
15
+ export class SimpleSplitView extends BaseCustomWebComponentConstructorAppend {
16
+ static style = css `
17
+ :host {
18
+ display: block;
19
+ }
20
+ :host([hidden]) { display: none }
21
+ .split {
22
+ position: relative;
23
+ height: 100%;
24
+ display: grid;
25
+ align-items: center;
26
+ --split: 100;
27
+ }
28
+ .top,
29
+ .bottom {
30
+ position: absolute;
31
+ top: 0;
32
+ left: 0;
33
+ right: 0;
34
+ bottom: 0;
35
+ }
36
+ .bottom {
37
+ background-color: red;
38
+ }
39
+ .top {
40
+ z-index: 2;
41
+ right: calc(8px + (((100% - 16px) / 100) * (100 - var(--split))));
42
+ overflow: hidden;
43
+ border-right: 1px solid white;
44
+ }
45
+ input {
46
+ position: absolute;
47
+ width: 100%;
48
+ height: 100%;
49
+ margin: 0;
50
+ padding: 0;
51
+ z-index: 3;
52
+ background-color: transparent;
53
+ -webkit-appearance: none;
54
+ }
55
+ input[type="range"]:focus {
56
+ outline: var(--outline, -webkit-focus-ring-color auto 1px);
57
+ }`;
58
+ static template = html `
59
+ <div class="split" id="split" role="img" aria-label="Comparison of two images">
60
+ <div class="bottom" id="bottom" aria-label="First image to compare">
61
+ <slot name="bottom"></slot>
62
+ </div>
63
+ <div class="top" id="top" aria-label="Second image to compare">
64
+ <slot name="top"></slot>
65
+ </div>
66
+ <label id="label" for="slider">Slide left and right to compare images</label>
67
+ <input type="range" role="slider" min="0" max="100" value="50" name="slider" id="slider" aria-labelledby="label" aria-valuemin="0" aria-valuemax="100">
68
+ </div>`;
69
+ static properties = {
70
+ start: Number
71
+ };
72
+ constructor() {
73
+ super();
74
+ }
75
+ start;
76
+ ready() {
77
+ this._parseAttributesToProperties();
78
+ const splitter = this._getDomElement("split");
79
+ const slider = this._getDomElement("slider");
80
+ const label = this._getDomElement("label");
81
+ const top = this._getDomElement("top");
82
+ const splitViewLabelText = this.getAttribute("split-view-label") || 'Comparison of two images';
83
+ const sliderLabelText = this.getAttribute("slider-label") || 'Press left and right to compare images';
84
+ const mode = this.getAttribute("mode") || "normal";
85
+ slider.addEventListener("input", (event) => {
86
+ const split = +event.target.value;
87
+ splitter.style.setProperty("--split", split);
88
+ slider.setAttribute('aria-valuenow', split);
89
+ });
90
+ splitter.style.setProperty("--split", this.start);
91
+ slider.setAttribute('aria-valuenow', this.start);
92
+ slider.value = this.start;
93
+ splitter.setAttribute('aria-label', splitViewLabelText);
94
+ label.innerText = sliderLabelText;
95
+ top.style.mixBlendMode = mode;
96
+ }
97
+ }
98
+ customElements.define('node-projects-simple-split-view', SimpleSplitView);
@@ -7,6 +7,7 @@ import { IDemoView } from './widgets/demoView/IDemoView';
7
7
  import { IUiCommandHandler } from "../commandHandling/IUiCommandHandler";
8
8
  import { IUiCommand } from "../commandHandling/IUiCommand";
9
9
  import { IDisposable } from "../interfaces/IDisposable";
10
+ import { ISelectionChangedEvent } from "./services/selectionService/ISelectionChangedEvent.js";
10
11
  export declare class DocumentContainer extends BaseCustomWebComponentLazyAppend implements IUiCommandHandler, IDisposable {
11
12
  designerView: DesignerView;
12
13
  codeView: ICodeView & HTMLElement;
@@ -20,9 +21,13 @@ export declare class DocumentContainer extends BaseCustomWebComponentLazyAppend
20
21
  private _designerDiv;
21
22
  private _codeDiv;
22
23
  private refreshInSplitViewDebounced;
24
+ private _disableChangeNotificationDesigner;
25
+ private _disableChangeNotificationEditor;
23
26
  static get style(): CSSStyleSheet;
24
27
  constructor(serviceContainer: ServiceContainer, content?: string);
25
- refreshInSplitView(): void;
28
+ refreshInSplitView(): Promise<void>;
29
+ designerSelectionChanged(e: ISelectionChangedEvent): void;
30
+ designerContentChanged(): void;
26
31
  dispose(): void;
27
32
  executeCommand(command: IUiCommand): void;
28
33
  canExecuteCommand(command: IUiCommand): boolean;
@@ -1,6 +1,7 @@
1
1
  import { BaseCustomWebComponentLazyAppend, css, debounce } from "@node-projects/base-custom-webcomponent";
2
2
  import { DesignerTabControl } from "./controls/DesignerTabControl";
3
3
  import { DesignerView } from "./widgets/designerView/designerView";
4
+ import { SimpleSplitView } from './controls/SimpleSplitView';
4
5
  export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
5
6
  designerView;
6
7
  codeView;
@@ -14,6 +15,8 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
14
15
  _designerDiv;
15
16
  _codeDiv;
16
17
  refreshInSplitViewDebounced;
18
+ _disableChangeNotificationDesigner;
19
+ _disableChangeNotificationEditor;
17
20
  static get style() {
18
21
  return css `
19
22
  div {
@@ -23,11 +26,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
23
26
  }
24
27
  node-projects-designer-view {
25
28
  height: 100%;
26
- /*overflow: auto;*/
27
- }
28
- .split-div {
29
- display: grid;
30
- grid-template-rows: 1fr 1fr;
29
+ overflow: hidden;
31
30
  }
32
31
  `;
33
32
  }
@@ -42,25 +41,32 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
42
41
  div.appendChild(this._tabControl);
43
42
  this.designerView = new DesignerView();
44
43
  this.designerView.setAttribute('exportparts', 'canvas');
44
+ this.designerView.slot = 'top';
45
45
  this._designerDiv = document.createElement("div");
46
+ this._tabControl.appendChild(this._designerDiv);
46
47
  this._designerDiv.title = 'Designer';
47
48
  this._designerDiv.appendChild(this.designerView);
48
- this._tabControl.appendChild(this._designerDiv);
49
49
  this.designerView.initialize(this._serviceContainer);
50
+ this.designerView.instanceServiceContainer.selectionService.onSelectionChanged.on(e => this.designerSelectionChanged(e));
51
+ this.designerView.designerCanvas.onContentChanged.on(() => this.designerContentChanged());
50
52
  this.codeView = new serviceContainer.config.codeViewWidget();
53
+ this.codeView.slot = 'bottom';
51
54
  this._codeDiv = document.createElement("div");
55
+ this._tabControl.appendChild(this._codeDiv);
52
56
  this._codeDiv.title = 'Code';
53
57
  this._codeDiv.appendChild(this.codeView);
54
58
  this.codeView.onTextChanged.on(text => {
55
- if (this._tabControl.selectedIndex === 2) {
56
- this._content = text;
57
- this.refreshInSplitViewDebounced();
59
+ if (!this._disableChangeNotificationDesigner) {
60
+ this._disableChangeNotificationEditor = true;
61
+ if (this._tabControl.selectedIndex === 2) {
62
+ this._content = text;
63
+ this.refreshInSplitViewDebounced();
64
+ }
58
65
  }
59
66
  });
60
- this._tabControl.appendChild(this._codeDiv);
61
- this._splitDiv = document.createElement("div");
67
+ this._splitDiv = new SimpleSplitView();
68
+ this._splitDiv.style.height = '100%';
62
69
  this._splitDiv.title = 'Split';
63
- this._splitDiv.className = 'split-div';
64
70
  this._tabControl.appendChild(this._splitDiv);
65
71
  this.demoView = new serviceContainer.config.demoViewWidget();
66
72
  this.demoView.title = 'Preview';
@@ -70,8 +76,39 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
70
76
  this._tabControl.selectedIndex = 0;
71
77
  });
72
78
  }
73
- refreshInSplitView() {
74
- this.designerView.parseHTML(this._content);
79
+ async refreshInSplitView() {
80
+ await this.designerView.parseHTML(this._content);
81
+ this._disableChangeNotificationEditor = false;
82
+ }
83
+ designerSelectionChanged(e) {
84
+ if (this._tabControl.selectedIndex === 2) {
85
+ let primarySelection = this.instanceServiceContainer.selectionService.primarySelection;
86
+ if (primarySelection) {
87
+ let designItemsAssignmentList = new Map();
88
+ this._content = this.designerView.getHTML(designItemsAssignmentList);
89
+ this._selectionPosition = designItemsAssignmentList.get(primarySelection);
90
+ this.codeView.setSelection(this._selectionPosition);
91
+ this._selectionPosition = null;
92
+ }
93
+ }
94
+ }
95
+ designerContentChanged() {
96
+ if (!this._disableChangeNotificationEditor) {
97
+ this._disableChangeNotificationDesigner = true;
98
+ if (this._tabControl.selectedIndex === 2) {
99
+ let primarySelection = this.instanceServiceContainer.selectionService.primarySelection;
100
+ let designItemsAssignmentList = new Map();
101
+ this._content = this.designerView.getHTML(designItemsAssignmentList);
102
+ this.codeView.update(this._content);
103
+ if (primarySelection) {
104
+ this._selectionPosition = designItemsAssignmentList.get(primarySelection);
105
+ if (this._selectionPosition)
106
+ this.codeView.setSelection(this._selectionPosition);
107
+ this._selectionPosition = null;
108
+ }
109
+ }
110
+ this._disableChangeNotificationDesigner = false;
111
+ }
75
112
  }
76
113
  dispose() {
77
114
  this.codeView.dispose();
@@ -1,3 +1,4 @@
1
+ import { IPoint } from "../../interfaces/IPoint.js";
1
2
  export {};
2
3
  declare type PathDataM = {
3
4
  type: 'M' | 'm';
@@ -42,7 +43,10 @@ declare type PathDataA = {
42
43
  declare type PathData = {
43
44
  type: string;
44
45
  } & (PathDataM | PathDataL | PathDataH | PathDataV | PathDataZ | PathDataC | PathDataS | PathDataQ | PathDataT | PathDataA)[];
45
- export declare function movePathData(path: SVGPathElement, xFactor: number, yFactor: number): string;
46
+ export declare function straightenLine(p1: IPoint, p2: IPoint): IPoint;
47
+ export declare function calculateNormLegth(p1: IPoint, p2: IPoint): number;
48
+ export declare function calculateAlpha(p1: IPoint, p2: IPoint): number;
49
+ export declare function moveSVGPath(path: SVGPathElement, xFactor: number, yFactor: number): string;
46
50
  declare global {
47
51
  interface SVGGraphicsElement {
48
52
  getPathData(options?: {
@@ -856,7 +856,55 @@ if (!SVGPathElement.prototype.getPathData || !SVGPathElement.prototype.setPathDa
856
856
  };
857
857
  })();
858
858
  }
859
- export function movePathData(path, xFactor, yFactor) {
859
+ export function straightenLine(p1, p2) {
860
+ let newP = p2;
861
+ let alpha = calculateAlpha(p1, p2);
862
+ let normLength;
863
+ if ((alpha >= 337.5 && alpha < 360 || alpha >= 0 && alpha < 22.5)) { // 0
864
+ newP = { x: p2.x, y: p1.y };
865
+ }
866
+ else if ((alpha >= 22.5 && alpha < 67.5)) { // 45
867
+ normLength = calculateNormLegth(p1, p2);
868
+ newP = { x: p1.x + normLength, y: p1.y - normLength };
869
+ }
870
+ else if ((alpha >= 67.5 && alpha < 112.5)) { // 90
871
+ newP = { x: p1.x, y: p2.y };
872
+ }
873
+ else if ((alpha >= 112.5 && alpha < 157.5)) { // 135
874
+ normLength = calculateNormLegth(p1, p2);
875
+ newP = { x: p1.x - normLength, y: p1.y - normLength };
876
+ }
877
+ else if ((alpha >= 157.5 && alpha < 202.5)) { // 180
878
+ newP = { x: p2.x, y: p1.y };
879
+ }
880
+ else if ((alpha >= 202.5 && alpha < 247.5)) { // 225
881
+ normLength = calculateNormLegth(p1, p2);
882
+ newP = { x: p1.x - normLength, y: p1.y + normLength };
883
+ }
884
+ else if ((alpha >= 247.5 && alpha < 292.5)) { // 270
885
+ newP = { x: p1.x, y: p2.y };
886
+ }
887
+ else if ((alpha >= 292.5 && alpha < 337.5)) { // 315
888
+ normLength = calculateNormLegth(p1, p2);
889
+ newP = { x: p1.x + normLength, y: p1.y + normLength };
890
+ }
891
+ return newP;
892
+ }
893
+ export function calculateNormLegth(p1, p2) {
894
+ let normLenght;
895
+ let currentLength = Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
896
+ let alpha = calculateAlpha(p1, p2);
897
+ let beta = alpha - ((Math.floor(alpha / 90) * 90) + 45);
898
+ normLenght = currentLength * Math.cos(beta * (Math.PI / 180)) / Math.sqrt(2);
899
+ return normLenght;
900
+ }
901
+ export function calculateAlpha(p1, p2) {
902
+ let alpha = -1 * Math.atan2(p2.y - p1.y, p2.x - p1.x) * 180 / Math.PI;
903
+ if (alpha < 0)
904
+ alpha += 360;
905
+ return alpha;
906
+ }
907
+ export function moveSVGPath(path, xFactor, yFactor) {
860
908
  let newPathData = "";
861
909
  let pd = path.getPathData({ normalize: true });
862
910
  {
@@ -11,6 +11,7 @@ export class ContextMenuHelper {
11
11
  box-shadow: 1px 1px 2px #cfcfcf;
12
12
  cursor: default;
13
13
  user-select: none;
14
+ -webkit-user-select: none;
14
15
  border-radius: 12px;
15
16
  }
16
17
 
@@ -48,6 +48,10 @@ import { DefaultModelCommandService } from './modelCommandService/DefaultModelCo
48
48
  import { ButtonSeperatorProvider } from '../widgets/designerView/ButtonSeperatorProvider';
49
49
  import { GridExtensionDesignViewConfigButtons } from '../widgets/designerView/extensions/GridExtensionDesignViewConfigButtons';
50
50
  import { DemoProviderService } from './demoProviderService/DemoProviderService';
51
+ import { CursorLinePointerExtensionProvider } from '../widgets/designerView/extensions/pointerExtensions/CursorLinePointerExtensionProvider.js';
52
+ import { DrawRectTool } from '../widgets/designerView/tools/DrawRectTool.js';
53
+ import { DrawEllipsisTool } from '../widgets/designerView/tools/DrawEllipsisTool.js';
54
+ import { DrawLineTool } from '../widgets/designerView/tools/DrawLineTool.js';
51
55
  export function createDefaultServiceContainer() {
52
56
  let serviceContainer = new ServiceContainer();
53
57
  serviceContainer.register("propertyService", new PolymerPropertiesService());
@@ -104,12 +108,16 @@ export function createDefaultServiceContainer() {
104
108
  serviceContainer.designerTools.set(NamedTools.Pointer, new PointerTool());
105
109
  serviceContainer.designerTools.set(NamedTools.DrawSelection, new RectangleSelectorTool());
106
110
  serviceContainer.designerTools.set(NamedTools.DrawPath, new DrawPathTool());
111
+ serviceContainer.designerTools.set(NamedTools.DrawRect, new DrawRectTool());
112
+ serviceContainer.designerTools.set(NamedTools.DrawEllipsis, new DrawEllipsisTool());
113
+ serviceContainer.designerTools.set(NamedTools.DrawLine, new DrawLineTool());
107
114
  serviceContainer.designerTools.set(NamedTools.Zoom, new ZoomTool());
108
115
  serviceContainer.designerTools.set(NamedTools.Pan, new PanTool());
109
116
  serviceContainer.designerTools.set(NamedTools.RectangleSelector, new RectangleSelectorTool());
110
117
  serviceContainer.designerTools.set(NamedTools.MagicWandSelector, new MagicWandSelectorTool());
111
118
  serviceContainer.designerTools.set(NamedTools.PickColor, new PickColorTool());
112
119
  serviceContainer.designerTools.set(NamedTools.Text, new TextTool());
120
+ serviceContainer.designerPointerExtensions.push(new CursorLinePointerExtensionProvider());
113
121
  serviceContainer.designViewConfigButtons.push(new ButtonSeperatorProvider(20), new GridExtensionDesignViewConfigButtons());
114
122
  serviceContainer.designerContextMenuExtensions = [
115
123
  new CopyPasteContextMenu(),
@@ -62,6 +62,8 @@ export class NodeHtmlParserService {
62
62
  designItem.setStyle(s.name, s.value);
63
63
  }
64
64
  }
65
+ if (element instanceof HTMLElement || element instanceof SVGElement)
66
+ element.style.pointerEvents = 'auto';
65
67
  designItem.hideAtDesignTime = hideAtDesignTime;
66
68
  designItem.hideAtRunTime = hideAtRunTime;
67
69
  designItem.lockAtDesignTime = lockAtDesignTime;
@@ -42,6 +42,7 @@ export class UndoService {
42
42
  this._transactionStack[this._transactionStack.length - 1].execute(item);
43
43
  }
44
44
  this._designerCanvas.extensionManager.refreshAllExtensions(item.affectedItems);
45
+ this._designerCanvas.onContentChanged.emit();
45
46
  }
46
47
  clear() {
47
48
  this._undoStack = [];
@@ -63,6 +64,7 @@ export class UndoService {
63
64
  throw err;
64
65
  }
65
66
  this._designerCanvas.extensionManager.refreshAllExtensions(item.affectedItems);
67
+ this._designerCanvas.onContentChanged.emit();
66
68
  }
67
69
  redo() {
68
70
  if (!this.canRedo())
@@ -79,6 +81,7 @@ export class UndoService {
79
81
  throw err;
80
82
  }
81
83
  this._designerCanvas.extensionManager.refreshAllExtensions(item.affectedItems);
84
+ this._designerCanvas.onContentChanged.emit();
82
85
  }
83
86
  canUndo() {
84
87
  return this._undoStack.length > 0;
@@ -71,12 +71,12 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
71
71
  });
72
72
  this._monacoEditor.layout();
73
73
  let changeContentListener = this._monacoEditor.getModel().onDidChangeContent(e => {
74
- () => this.onTextChanged.emit(this._monacoEditor.getValue());
74
+ this.onTextChanged.emit(this._monacoEditor.getValue());
75
75
  });
76
76
  this._monacoEditor.onDidChangeModel(e => {
77
77
  changeContentListener.dispose();
78
78
  changeContentListener = this._monacoEditor.getModel().onDidChangeContent(e => {
79
- () => this.onTextChanged.emit(this._monacoEditor.getValue());
79
+ this.onTextChanged.emit(this._monacoEditor.getValue());
80
80
  });
81
81
  });
82
82
  });
@@ -8,6 +8,7 @@ import { IUiCommandHandler } from "../../../commandHandling/IUiCommandHandler";
8
8
  import { IPoint } from "../../../interfaces/IPoint";
9
9
  import { OverlayLayerView } from "./overlayLayerView";
10
10
  import { IRect } from "../../../interfaces/IRect.js";
11
+ import { TypedEvent } from "@node-projects/base-custom-webcomponent";
11
12
  export interface IDesignerCanvas extends IPlacementView, IUiCommandHandler {
12
13
  readonly serviceContainer: ServiceContainer;
13
14
  readonly instanceServiceContainer: InstanceServiceContainer;
@@ -19,7 +20,10 @@ export interface IDesignerCanvas extends IPlacementView, IUiCommandHandler {
19
20
  readonly shadowRoot: ShadowRoot;
20
21
  readonly alignOnGrid: boolean;
21
22
  readonly alignOnSnap: boolean;
23
+ readonly onContentChanged: TypedEvent<void>;
22
24
  zoomFactor: number;
25
+ readonly scaleFactor: number;
26
+ canvasOffset: IPoint;
23
27
  eatEvents: Element;
24
28
  initialize(serviceContainer: ServiceContainer): any;
25
29
  getNormalizedEventCoordinates(event: MouseEvent): IPoint;
@@ -1,7 +1,7 @@
1
1
  import { ServiceContainer } from '../../services/ServiceContainer';
2
2
  import { InstanceServiceContainer } from '../../services/InstanceServiceContainer';
3
3
  import { IDesignItem } from '../../item/IDesignItem';
4
- import { BaseCustomWebComponentLazyAppend } from '@node-projects/base-custom-webcomponent';
4
+ import { BaseCustomWebComponentLazyAppend, TypedEvent } from '@node-projects/base-custom-webcomponent';
5
5
  import { IDesignerCanvas } from './IDesignerCanvas';
6
6
  import { Snaplines } from './Snaplines';
7
7
  import { ContextMenuHelper } from '../../helper/contextMenu/ContextMenuHelper';
@@ -26,8 +26,14 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
26
26
  rootDesignItem: IDesignItem;
27
27
  eatEvents: Element;
28
28
  private _zoomFactor;
29
+ private _scaleFactor;
30
+ private _canvasOffset;
29
31
  get zoomFactor(): number;
30
32
  set zoomFactor(value: number);
33
+ get scaleFactor(): number;
34
+ get canvasOffset(): IPoint;
35
+ set canvasOffset(value: IPoint);
36
+ onContentChanged: TypedEvent<void>;
31
37
  private _canvas;
32
38
  private _canvasContainer;
33
39
  private _outercanvas2;
@@ -58,6 +64,7 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
58
64
  elementFromPoint(x: number, y: number): Element;
59
65
  connectedCallback(): void;
60
66
  zoomFactorChanged(): void;
67
+ _updateTransform(): void;
61
68
  setDesignItems(designItems: IDesignItem[]): void;
62
69
  addDesignItems(designItems: IDesignItem[]): void;
63
70
  private _onDragEnter;
@@ -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 } from '@node-projects/base-custom-webcomponent';
6
+ import { BaseCustomWebComponentLazyAppend, css, html, TypedEvent } from '@node-projects/base-custom-webcomponent';
7
7
  import { dragDropFormatName } from '../../../Constants';
8
8
  import { ContentService } from '../../services/contentService/ContentService';
9
9
  import { InsertAction } from '../../services/undoService/transactionItems/InsertAction';
@@ -34,7 +34,9 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
34
34
  overlayLayer;
35
35
  rootDesignItem;
36
36
  eatEvents;
37
- _zoomFactor = 1;
37
+ _zoomFactor = 1; //if scale or zoom css property is used this needs to be the value
38
+ _scaleFactor = 1; //if scale css property is used this need to be the scale value
39
+ _canvasOffset = { x: 0, y: 0 };
38
40
  get zoomFactor() {
39
41
  return this._zoomFactor;
40
42
  }
@@ -42,6 +44,17 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
42
44
  this._zoomFactor = value;
43
45
  this.zoomFactorChanged();
44
46
  }
47
+ get scaleFactor() {
48
+ return this._scaleFactor;
49
+ }
50
+ get canvasOffset() {
51
+ return this._canvasOffset;
52
+ }
53
+ set canvasOffset(value) {
54
+ this._canvasOffset = value;
55
+ this.zoomFactorChanged();
56
+ }
57
+ onContentChanged = new TypedEvent();
45
58
  // Private Variables
46
59
  _canvas;
47
60
  _canvasContainer;
@@ -90,23 +103,27 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
90
103
  pointer-events: none;
91
104
  overflow: visible;
92
105
  user-select: none;
106
+ -webkit-user-select: none;
93
107
  z-index: 999999999999;
94
108
  }
95
109
 
96
110
  #node-projects-designer-canvas-canvas * {
97
111
  cursor: pointer;
98
112
  user-select: none;
113
+ -webkit-user-select: none;
99
114
  }`;
100
115
  static template = html `
101
- <div style="display: flex;flex-direction: column;width: 100%;height: 100%;">
102
- <div style="width: 100%;height: 100%;">
103
- <div id="node-projects-designer-canvas-outercanvas2" style="width: 100%;height: 100%;position: relative;overflow: auto;">
104
- <div id="node-projects-designer-canvas-canvasContainer" style="width: 100%;height: 100%;margin: auto;position: absolute;top: 0;/* bottom: 0; does not work with fixed sized when size is bigger then view */left: 0;user-select: none;">
105
- <div id="node-projects-designer-canvas-canvas" part="canvas" tabindex="0"></div>
106
- </div>
107
- </div>
116
+ <div style="display: flex;flex-direction: column;width: 100%;height: 100%;">
117
+ <div style="width: 100%;height: 100%;">
118
+ <div id="node-projects-designer-canvas-outercanvas2"
119
+ style="width:100%;height:100%;position:relative;">
120
+ <div id="node-projects-designer-canvas-canvasContainer"
121
+ style="width: 100%;height: 100%;margin: auto;position: absolute;top: 0;/* bottom: 0; does not work with fixed sized when size is bigger then view */left: 0;user-select: none;">
122
+ <div id="node-projects-designer-canvas-canvas" part="canvas" tabindex="0"></div>
108
123
  </div>
109
- </div>`;
124
+ </div>
125
+ </div>
126
+ </div>`;
110
127
  extensionManager;
111
128
  _pointerextensions;
112
129
  _onDblClickBound;
@@ -320,16 +337,23 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
320
337
  }
321
338
  }
322
339
  zoomFactorChanged() {
323
- //@ts-ignore
324
- this._canvasContainer.style.zoom = this._zoomFactor;
325
- //this._canvasContainer.style.transform = 'scale(' + this._zoomFactor+')';
340
+ //a@ts-ignore
341
+ //this._canvasContainer.style.zoom = <any>this._zoomFactor;
342
+ //this._canvasContainer.style.transform = 'scale(' + this._zoomFactor+') translate(' + this._translate.x + ', '+this._translate.y+')';
326
343
  //this._canvasContainer.style.transformOrigin = '0 0';
327
344
  this._canvasContainer.style.bottom = this._outercanvas2.offsetHeight >= this._canvasContainer.offsetHeight ? '0' : '';
328
345
  this._canvasContainer.style.right = this._outercanvas2.offsetWidth >= this._canvasContainer.offsetWidth ? '0' : '';
346
+ this._updateTransform();
347
+ }
348
+ _updateTransform() {
349
+ this._scaleFactor = this._zoomFactor;
350
+ this._canvasContainer.style.transform = 'scale(' + this._zoomFactor + ') translate(' + this._canvasOffset.x + 'px, ' + this._canvasOffset.y + 'px)';
351
+ this._canvasContainer.style.transformOrigin = '0 0';
329
352
  this.snapLines.clearSnaplines();
330
353
  }
331
354
  setDesignItems(designItems) {
332
355
  this.instanceServiceContainer.undoService.clear();
356
+ this.overlayLayer.removeAllOverlays();
333
357
  DomHelper.removeAllChildnodes(this.overlayLayer);
334
358
  this.rootDesignItem.clearChildren();
335
359
  this.addDesignItems(designItems);
@@ -403,11 +427,13 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
403
427
  }
404
428
  _onContextMenu(event) {
405
429
  event.preventDefault();
406
- const designItem = DesignItem.GetOrCreateDesignItem(event.target, this.serviceContainer, this.instanceServiceContainer);
407
- if (!this.instanceServiceContainer.selectionService.isSelected(designItem)) {
408
- this.instanceServiceContainer.selectionService.setSelectedElements([designItem]);
430
+ if (!event.shiftKey) {
431
+ const designItem = DesignItem.GetOrCreateDesignItem(event.target, this.serviceContainer, this.instanceServiceContainer);
432
+ if (!this.instanceServiceContainer.selectionService.isSelected(designItem)) {
433
+ this.instanceServiceContainer.selectionService.setSelectedElements([designItem]);
434
+ }
435
+ this.showDesignItemContextMenu(designItem, event);
409
436
  }
410
- this.showDesignItemContextMenu(designItem, event);
411
437
  }
412
438
  showDesignItemContextMenu(designItem, event) {
413
439
  const mnuItems = [];
@@ -494,12 +520,12 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
494
520
  }
495
521
  getNormalizedEventCoordinates(event) {
496
522
  const offsetOfOuterX = (event.clientX - this.outerRect.x) / this.zoomFactor;
497
- const offsetOfCanvasX = this.containerBoundingRect.x - this.outerRect.x / this.zoomFactor;
523
+ const offsetOfCanvasX = this.containerBoundingRect.x - this.outerRect.x / this.zoomFactor * this._scaleFactor;
498
524
  const offsetOfOuterY = (event.clientY - this.outerRect.y) / this.zoomFactor;
499
- const offsetOfCanvasY = this.containerBoundingRect.y - this.outerRect.y / this.zoomFactor;
525
+ const offsetOfCanvasY = this.containerBoundingRect.y - this.outerRect.y / this.zoomFactor * this._scaleFactor;
500
526
  return {
501
- x: offsetOfOuterX - offsetOfCanvasX,
502
- y: offsetOfOuterY - offsetOfCanvasY
527
+ x: offsetOfOuterX - offsetOfCanvasX + offsetOfCanvasX - offsetOfCanvasX / this.zoomFactor,
528
+ y: offsetOfOuterY - offsetOfCanvasY + offsetOfCanvasY - offsetOfCanvasY / this.zoomFactor
503
529
  };
504
530
  }
505
531
  getNormalizedElementCoordinates(element) {
@@ -565,7 +591,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
565
591
  }
566
592
  if (event.composedPath().indexOf(this.eatEvents) >= 0)
567
593
  return;
568
- if (event.button == 2)
594
+ if (event.buttons == 2)
569
595
  return;
570
596
  let currentElement = this.serviceContainer.elementAtPointService.getElementAtPoint(this, { x: event.x, y: event.y });
571
597
  if (currentElement === this._outercanvas2 || currentElement === this.overlayLayer || !currentElement) {
@@ -11,11 +11,12 @@ export declare class DesignerView extends BaseCustomWebComponentConstructorAppen
11
11
  set serviceContainer(value: ServiceContainer);
12
12
  get instanceServiceContainer(): InstanceServiceContainer;
13
13
  set instanceServiceContainer(value: InstanceServiceContainer);
14
+ private _designerCanvas;
15
+ get designerCanvas(): DesignerCanvas;
14
16
  private _zoomInput;
15
17
  private _lowertoolbar;
16
18
  static readonly style: CSSStyleSheet;
17
19
  static readonly template: HTMLTemplateElement;
18
- private _designerCanvas;
19
20
  constructor();
20
21
  private _onWheel;
21
22
  get designerWidth(): string;