@node-projects/web-component-designer 0.0.62 → 0.0.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +1 -1
- package/ACKNOWLEDGMENTS +7 -0
- package/dist/elements/controls/DesignerTabControl.js +4 -2
- package/dist/elements/controls/PlainScrollbar.d.ts +15 -0
- package/dist/elements/controls/PlainScrollbar.js +482 -0
- package/dist/elements/controls/SimpleSplitView.d.ts +11 -0
- package/dist/elements/controls/SimpleSplitView.js +67 -0
- package/dist/elements/documentContainer.d.ts +4 -1
- package/dist/elements/documentContainer.js +45 -19
- package/dist/elements/helper/PathDataPolyfill.d.ts +5 -1
- package/dist/elements/helper/PathDataPolyfill.js +49 -1
- package/dist/elements/helper/contextMenu/ContextMenuHelper.js +1 -0
- package/dist/elements/services/DefaultServiceBootstrap.js +10 -0
- package/dist/elements/services/htmlParserService/NodeHtmlParserService.js +2 -0
- package/dist/elements/services/placementService/DefaultPlacementService.js +1 -1
- package/dist/elements/services/placementService/ISnaplinesProviderService.d.ts +5 -4
- package/dist/elements/services/placementService/SnaplinesProviderService.d.ts +5 -4
- package/dist/elements/services/placementService/SnaplinesProviderService.js +15 -13
- package/dist/elements/services/undoService/UndoService.js +3 -0
- package/dist/elements/widgets/designerView/IDesignerCanvas.d.ts +4 -0
- package/dist/elements/widgets/designerView/IPlacementView.d.ts +2 -0
- package/dist/elements/widgets/designerView/Snaplines.d.ts +2 -1
- package/dist/elements/widgets/designerView/designerCanvas.d.ts +8 -1
- package/dist/elements/widgets/designerView/designerCanvas.js +49 -26
- package/dist/elements/widgets/designerView/designerView.d.ts +5 -1
- package/dist/elements/widgets/designerView/designerView.js +81 -18
- package/dist/elements/widgets/designerView/extensions/AltToEnterContainerExtension.js +3 -3
- package/dist/elements/widgets/designerView/extensions/MouseOverExtension.js +1 -1
- package/dist/elements/widgets/designerView/extensions/PositionExtension.js +4 -4
- package/dist/elements/widgets/designerView/extensions/PrimarySelectionDefaultExtension.js +2 -2
- package/dist/elements/widgets/designerView/extensions/ResizeExtension.d.ts +2 -1
- package/dist/elements/widgets/designerView/extensions/ResizeExtension.js +19 -15
- package/dist/elements/widgets/designerView/extensions/RotateExtension.js +1 -1
- package/dist/elements/widgets/designerView/extensions/SelectionDefaultExtension.js +2 -2
- package/dist/elements/widgets/designerView/extensions/TransformOriginExtension.js +2 -2
- package/dist/elements/widgets/designerView/overlayLayerView.d.ts +1 -0
- package/dist/elements/widgets/designerView/overlayLayerView.js +6 -0
- package/dist/elements/widgets/designerView/tools/DrawEllipsisTool.d.ts +15 -0
- package/dist/elements/widgets/designerView/tools/DrawEllipsisTool.js +90 -0
- package/dist/elements/widgets/designerView/tools/DrawLineTool.d.ts +13 -0
- package/dist/elements/widgets/designerView/tools/DrawLineTool.js +75 -0
- package/dist/elements/widgets/designerView/tools/DrawPathTool.d.ts +0 -2
- package/dist/elements/widgets/designerView/tools/DrawPathTool.js +5 -18
- package/dist/elements/widgets/designerView/tools/DrawRectTool.d.ts +18 -0
- package/dist/elements/widgets/designerView/tools/DrawRectTool.js +105 -0
- package/dist/elements/widgets/designerView/tools/NamedTools.d.ts +3 -0
- package/dist/elements/widgets/designerView/tools/NamedTools.js +3 -0
- package/dist/elements/widgets/designerView/tools/PanTool.js +14 -0
- package/dist/elements/widgets/designerView/tools/PointerTool.js +7 -0
- package/dist/elements/widgets/designerView/tools/RectangleSelectorTool.js +2 -2
- package/dist/elements/widgets/paletteView/paletteTreeView.js +0 -5
- package/dist/elements/widgets/propertyGrid/PropertyGrid.js +1 -0
- package/dist/elements/widgets/propertyGrid/PropertyGridWithHeader.js +1 -0
- package/dist/elements/widgets/treeView/treeView.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/package.json +1 -1
- package/dist/elements/widgets/designerView/ButtonSeperatorProvider copy.d.ts +0 -7
- package/dist/elements/widgets/designerView/ButtonSeperatorProvider copy.js +0 -11
- package/dist/elements/widgets/designerView/extensions/GridExtensionConfigButtons.d.ts +0 -5
- package/dist/elements/widgets/designerView/extensions/GridExtensionConfigButtons.js +0 -12
- package/dist/elements/widgets/designerView/extensions/GridExtensionProvider copy.d.ts +0 -10
- package/dist/elements/widgets/designerView/extensions/GridExtensionProvider copy.js +0 -18
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderConfigButtons.d.ts +0 -5
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderConfigButtons.js +0 -12
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderOptions.d.ts +0 -10
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderOptions.js +0 -18
- package/dist/elements/widgets/designerView/extensions/IDesignViewConfigButtonsProvider.d.ts +0 -0
- package/dist/elements/widgets/designerView/extensions/IDesignViewConfigButtonsProvider.js +0 -1
- package/dist/elements/widgets/designerView/extensions/IExtensionConfiguration.d.ts +0 -3
- package/dist/elements/widgets/designerView/extensions/IExtensionConfiguration.js +0 -1
|
@@ -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
|
-
|
|
27
|
-
}
|
|
28
|
-
.split-div {
|
|
29
|
-
display: grid;
|
|
30
|
-
grid-template-rows: 1fr 1fr;
|
|
29
|
+
overflow: hidden;
|
|
31
30
|
}
|
|
32
31
|
`;
|
|
33
32
|
}
|
|
@@ -42,26 +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
46
|
this._tabControl.appendChild(this._designerDiv);
|
|
47
47
|
this._designerDiv.title = 'Designer';
|
|
48
48
|
this._designerDiv.appendChild(this.designerView);
|
|
49
49
|
this.designerView.initialize(this._serviceContainer);
|
|
50
50
|
this.designerView.instanceServiceContainer.selectionService.onSelectionChanged.on(e => this.designerSelectionChanged(e));
|
|
51
|
+
this.designerView.designerCanvas.onContentChanged.on(() => this.designerContentChanged());
|
|
51
52
|
this.codeView = new serviceContainer.config.codeViewWidget();
|
|
53
|
+
this.codeView.slot = 'bottom';
|
|
52
54
|
this._codeDiv = document.createElement("div");
|
|
53
55
|
this._tabControl.appendChild(this._codeDiv);
|
|
54
56
|
this._codeDiv.title = 'Code';
|
|
55
57
|
this._codeDiv.appendChild(this.codeView);
|
|
56
58
|
this.codeView.onTextChanged.on(text => {
|
|
57
|
-
if (this.
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
59
|
+
if (!this._disableChangeNotificationDesigner) {
|
|
60
|
+
this._disableChangeNotificationEditor = true;
|
|
61
|
+
if (this._tabControl.selectedIndex === 2) {
|
|
62
|
+
this._content = text;
|
|
63
|
+
this.refreshInSplitViewDebounced();
|
|
64
|
+
}
|
|
60
65
|
}
|
|
61
66
|
});
|
|
62
|
-
this._splitDiv =
|
|
67
|
+
this._splitDiv = new SimpleSplitView();
|
|
68
|
+
this._splitDiv.style.height = '100%';
|
|
63
69
|
this._splitDiv.title = 'Split';
|
|
64
|
-
this._splitDiv.className = 'split-div';
|
|
65
70
|
this._tabControl.appendChild(this._splitDiv);
|
|
66
71
|
this.demoView = new serviceContainer.config.demoViewWidget();
|
|
67
72
|
this.demoView.title = 'Preview';
|
|
@@ -71,17 +76,38 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
71
76
|
this._tabControl.selectedIndex = 0;
|
|
72
77
|
});
|
|
73
78
|
}
|
|
74
|
-
refreshInSplitView() {
|
|
75
|
-
this.designerView.parseHTML(this._content);
|
|
79
|
+
async refreshInSplitView() {
|
|
80
|
+
await this.designerView.parseHTML(this._content);
|
|
81
|
+
this._disableChangeNotificationEditor = false;
|
|
76
82
|
}
|
|
77
83
|
designerSelectionChanged(e) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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;
|
|
85
111
|
}
|
|
86
112
|
}
|
|
87
113
|
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
|
|
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
|
|
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
|
{
|
|
@@ -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,18 @@ 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(
|
|
121
|
+
//new CursorLinePointerExtensionProvider()
|
|
122
|
+
);
|
|
113
123
|
serviceContainer.designViewConfigButtons.push(new ButtonSeperatorProvider(20), new GridExtensionDesignViewConfigButtons());
|
|
114
124
|
serviceContainer.designerContextMenuExtensions = [
|
|
115
125
|
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;
|
|
@@ -31,7 +31,7 @@ export class DefaultPlacementService {
|
|
|
31
31
|
}
|
|
32
32
|
else if (placementView.alignOnSnap) {
|
|
33
33
|
let rect = item.element.getBoundingClientRect();
|
|
34
|
-
let newPos = placementView.snapLines.snapToPosition({ x: newPoint.x - offsetInControl.x, y: newPoint.y - offsetInControl.y }, { width: rect.width, height: rect.height }, { x: trackX > 0 ? 1 : -1, y: trackY > 0 ? 1 : -1 });
|
|
34
|
+
let newPos = placementView.snapLines.snapToPosition({ x: (newPoint.x - offsetInControl.x), y: (newPoint.y - offsetInControl.y) }, { width: rect.width / placementView.scaleFactor, height: rect.height / placementView.scaleFactor }, { x: trackX > 0 ? 1 : -1, y: trackY > 0 ? 1 : -1 });
|
|
35
35
|
if (newPos.x !== null) {
|
|
36
36
|
trackX = newPos.x - Math.round(startPoint.x) + Math.round(offsetInControl.x);
|
|
37
37
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IService } from "../IService";
|
|
2
2
|
import { IDesignItem } from "../../item/IDesignItem";
|
|
3
|
+
import { IRect } from "../../../interfaces/IRect.js";
|
|
3
4
|
export interface ISnaplinesProviderService extends IService {
|
|
4
5
|
provideSnaplines(containerItem: IDesignItem, ignoredItems: IDesignItem[]): {
|
|
5
6
|
outerRect: DOMRect;
|
|
6
|
-
positionsH: [number,
|
|
7
|
-
positionsMiddleH: [number,
|
|
8
|
-
positionsV: [number,
|
|
9
|
-
positionsMiddleV: [number,
|
|
7
|
+
positionsH: [number, IRect][];
|
|
8
|
+
positionsMiddleH: [number, IRect][];
|
|
9
|
+
positionsV: [number, IRect][];
|
|
10
|
+
positionsMiddleV: [number, IRect][];
|
|
10
11
|
};
|
|
11
12
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { IRect } from '../../../interfaces/IRect.js';
|
|
1
2
|
import type { IDesignItem } from '../../item/IDesignItem.js';
|
|
2
3
|
import { ISnaplinesProviderService } from './ISnaplinesProviderService.js';
|
|
3
4
|
export declare class SnaplinesProviderService implements ISnaplinesProviderService {
|
|
4
5
|
provideSnaplines(containerItem: IDesignItem, ignoredItems: IDesignItem[]): {
|
|
5
6
|
outerRect: DOMRect;
|
|
6
|
-
positionsH: [number,
|
|
7
|
-
positionsMiddleH: [number,
|
|
8
|
-
positionsV: [number,
|
|
9
|
-
positionsMiddleV: [number,
|
|
7
|
+
positionsH: [number, IRect][];
|
|
8
|
+
positionsMiddleH: [number, IRect][];
|
|
9
|
+
positionsV: [number, IRect][];
|
|
10
|
+
positionsMiddleV: [number, IRect][];
|
|
10
11
|
};
|
|
11
12
|
}
|
|
@@ -2,6 +2,7 @@ import { DomHelper } from '@node-projects/base-custom-webcomponent';
|
|
|
2
2
|
export class SnaplinesProviderService {
|
|
3
3
|
provideSnaplines(containerItem, ignoredItems) {
|
|
4
4
|
{
|
|
5
|
+
const canvas = containerItem.instanceServiceContainer.designerCanvas;
|
|
5
6
|
const ignMap = new Map(ignoredItems.map(i => [i.element, i]));
|
|
6
7
|
const outerRect = containerItem.element.getBoundingClientRect();
|
|
7
8
|
const positionsH = [];
|
|
@@ -11,19 +12,20 @@ export class SnaplinesProviderService {
|
|
|
11
12
|
let ignoreElements = ignoredItems.map(x => x.element);
|
|
12
13
|
for (let n of DomHelper.getAllChildNodes(containerItem.element, false, ignoreElements)) {
|
|
13
14
|
if (!ignMap.has(n)) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
const p = n.getBoundingClientRect();
|
|
16
|
+
const pLeft = (p.x - outerRect.x) / canvas.scaleFactor;
|
|
17
|
+
const pMidH = (p.x - outerRect.x + p.width / 2) / canvas.scaleFactor;
|
|
18
|
+
const pRight = (p.x - outerRect.x + p.width) / canvas.scaleFactor;
|
|
19
|
+
const pTop = (p.y - outerRect.y) / canvas.scaleFactor;
|
|
20
|
+
const pMidV = (p.y - outerRect.y + p.height / 2) / canvas.scaleFactor;
|
|
21
|
+
const pBottom = (p.y - outerRect.y + p.height) / canvas.scaleFactor;
|
|
22
|
+
const transformedP = { x: pLeft + outerRect.x, y: pTop + outerRect.y, width: p.width / canvas.scaleFactor, height: p.height / canvas.scaleFactor };
|
|
23
|
+
positionsH.push([pLeft, transformedP]);
|
|
24
|
+
positionsMiddleH.push([pMidH, transformedP]);
|
|
25
|
+
positionsH.push([pRight, transformedP]);
|
|
26
|
+
positionsV.push([pTop, transformedP]);
|
|
27
|
+
positionsMiddleV.push([pMidV, transformedP]);
|
|
28
|
+
positionsV.push([pBottom, transformedP]);
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
positionsH.sort((a, b) => a[0] - b[0]);
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -2,6 +2,7 @@ import type { IDesignItem } from "../../item/IDesignItem";
|
|
|
2
2
|
import type { IPoint } from "../../../interfaces/IPoint";
|
|
3
3
|
import type { ISize } from '../../../interfaces/ISize';
|
|
4
4
|
import { OverlayLayerView } from "./overlayLayerView";
|
|
5
|
+
import { IRect } from "../../../interfaces/IRect.js";
|
|
5
6
|
export declare class Snaplines {
|
|
6
7
|
snapOffset: number;
|
|
7
8
|
private _overlayLayerView;
|
|
@@ -16,5 +17,5 @@ export declare class Snaplines {
|
|
|
16
17
|
clearSnaplines(): void;
|
|
17
18
|
calculateSnaplines(ignoredItems: IDesignItem[]): void;
|
|
18
19
|
snapToPosition(position: IPoint, size: ISize, moveDirection: IPoint): IPoint;
|
|
19
|
-
drawSnaplines(position: IPoint, size: ISize, rectsH:
|
|
20
|
+
drawSnaplines(position: IPoint, size: ISize, rectsH: IRect[], rectsV: IRect[]): void;
|
|
20
21
|
}
|
|
@@ -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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
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
|
-
|
|
407
|
-
|
|
408
|
-
this.instanceServiceContainer.selectionService.
|
|
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,17 +520,17 @@ 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) {
|
|
506
532
|
const targetRect = element.getBoundingClientRect();
|
|
507
|
-
return { x: targetRect.x - this.containerBoundingRect.x, y: targetRect.y - this.containerBoundingRect.y, width: targetRect.width, height: targetRect.height };
|
|
533
|
+
return { x: (targetRect.x - this.containerBoundingRect.x) / this.scaleFactor, y: (targetRect.y - this.containerBoundingRect.y) / this.scaleFactor, width: targetRect.width / this.scaleFactor, height: targetRect.height / this.scaleFactor };
|
|
508
534
|
}
|
|
509
535
|
getNormalizedOffsetInElement(event, element) {
|
|
510
536
|
const normEvt = this.getNormalizedEventCoordinates(event);
|
|
@@ -556,16 +582,13 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
556
582
|
_rect;
|
|
557
583
|
_pointerEventHandler(event) {
|
|
558
584
|
this._fillCalculationrects();
|
|
559
|
-
/*let clickOnScrollbar = event.clientX - this.containerBoundingRect.x > this.containerBoundingRect.width || event.clientY - this.containerBoundingRect.y > this.containerBoundingRect.height
|
|
560
|
-
if (clickOnScrollbar) https://kingsora.github.io/OverlayScrollbars/
|
|
561
|
-
return;*/
|
|
562
585
|
if (this._pointerextensions) {
|
|
563
586
|
for (let pe of this._pointerextensions)
|
|
564
587
|
pe.refresh(event);
|
|
565
588
|
}
|
|
566
589
|
if (event.composedPath().indexOf(this.eatEvents) >= 0)
|
|
567
590
|
return;
|
|
568
|
-
if (event.
|
|
591
|
+
if (event.buttons == 2)
|
|
569
592
|
return;
|
|
570
593
|
let currentElement = this.serviceContainer.elementAtPointService.getElementAtPoint(this, { x: event.x, y: event.y });
|
|
571
594
|
if (currentElement === this._outercanvas2 || currentElement === this.overlayLayer || !currentElement) {
|
|
@@ -7,16 +7,20 @@ import { DesignerCanvas } from "./designerCanvas.js";
|
|
|
7
7
|
import { IDesignItem } from '../../item/IDesignItem.js';
|
|
8
8
|
import { IStringPosition } from '../../services/htmlWriterService/IStringPosition.js';
|
|
9
9
|
export declare class DesignerView extends BaseCustomWebComponentConstructorAppend implements IUiCommandHandler {
|
|
10
|
+
private _sVert;
|
|
11
|
+
private _sHor;
|
|
10
12
|
get serviceContainer(): ServiceContainer;
|
|
11
13
|
set serviceContainer(value: ServiceContainer);
|
|
12
14
|
get instanceServiceContainer(): InstanceServiceContainer;
|
|
13
15
|
set instanceServiceContainer(value: InstanceServiceContainer);
|
|
16
|
+
private _designerCanvas;
|
|
17
|
+
get designerCanvas(): DesignerCanvas;
|
|
14
18
|
private _zoomInput;
|
|
15
19
|
private _lowertoolbar;
|
|
16
20
|
static readonly style: CSSStyleSheet;
|
|
17
21
|
static readonly template: HTMLTemplateElement;
|
|
18
|
-
private _designerCanvas;
|
|
19
22
|
constructor();
|
|
23
|
+
private _onScrollbar;
|
|
20
24
|
private _onWheel;
|
|
21
25
|
get designerWidth(): string;
|
|
22
26
|
set designerWidth(value: string);
|