@node-projects/web-component-designer 0.0.62 → 0.0.63
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/dist/elements/documentContainer.d.ts +4 -1
- package/dist/elements/documentContainer.js +39 -12
- package/dist/elements/services/undoService/UndoService.js +3 -0
- package/dist/elements/widgets/designerView/IDesignerCanvas.d.ts +2 -0
- package/dist/elements/widgets/designerView/designerCanvas.d.ts +2 -1
- package/dist/elements/widgets/designerView/designerCanvas.js +3 -1
- package/dist/elements/widgets/designerView/designerView.d.ts +2 -1
- package/dist/elements/widgets/designerView/designerView.js +6 -2
- package/dist/elements/widgets/designerView/overlayLayerView.d.ts +1 -0
- package/dist/elements/widgets/designerView/overlayLayerView.js +6 -0
- package/package.json +1 -1
|
@@ -21,10 +21,13 @@ export declare class DocumentContainer extends BaseCustomWebComponentLazyAppend
|
|
|
21
21
|
private _designerDiv;
|
|
22
22
|
private _codeDiv;
|
|
23
23
|
private refreshInSplitViewDebounced;
|
|
24
|
+
private _disableChangeNotificationDesigner;
|
|
25
|
+
private _disableChangeNotificationEditor;
|
|
24
26
|
static get style(): CSSStyleSheet;
|
|
25
27
|
constructor(serviceContainer: ServiceContainer, content?: string);
|
|
26
|
-
refreshInSplitView(): void
|
|
28
|
+
refreshInSplitView(): Promise<void>;
|
|
27
29
|
designerSelectionChanged(e: ISelectionChangedEvent): void;
|
|
30
|
+
designerContentChanged(): void;
|
|
28
31
|
dispose(): void;
|
|
29
32
|
executeCommand(command: IUiCommand): void;
|
|
30
33
|
canExecuteCommand(command: IUiCommand): boolean;
|
|
@@ -14,6 +14,8 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
14
14
|
_designerDiv;
|
|
15
15
|
_codeDiv;
|
|
16
16
|
refreshInSplitViewDebounced;
|
|
17
|
+
_disableChangeNotificationDesigner;
|
|
18
|
+
_disableChangeNotificationEditor;
|
|
17
19
|
static get style() {
|
|
18
20
|
return css `
|
|
19
21
|
div {
|
|
@@ -48,15 +50,19 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
48
50
|
this._designerDiv.appendChild(this.designerView);
|
|
49
51
|
this.designerView.initialize(this._serviceContainer);
|
|
50
52
|
this.designerView.instanceServiceContainer.selectionService.onSelectionChanged.on(e => this.designerSelectionChanged(e));
|
|
53
|
+
this.designerView.designerCanvas.onContentChanged.on(() => this.designerContentChanged());
|
|
51
54
|
this.codeView = new serviceContainer.config.codeViewWidget();
|
|
52
55
|
this._codeDiv = document.createElement("div");
|
|
53
56
|
this._tabControl.appendChild(this._codeDiv);
|
|
54
57
|
this._codeDiv.title = 'Code';
|
|
55
58
|
this._codeDiv.appendChild(this.codeView);
|
|
56
59
|
this.codeView.onTextChanged.on(text => {
|
|
57
|
-
if (this.
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
60
|
+
if (!this._disableChangeNotificationDesigner) {
|
|
61
|
+
this._disableChangeNotificationEditor = true;
|
|
62
|
+
if (this._tabControl.selectedIndex === 2) {
|
|
63
|
+
this._content = text;
|
|
64
|
+
this.refreshInSplitViewDebounced();
|
|
65
|
+
}
|
|
60
66
|
}
|
|
61
67
|
});
|
|
62
68
|
this._splitDiv = document.createElement("div");
|
|
@@ -71,17 +77,38 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
71
77
|
this._tabControl.selectedIndex = 0;
|
|
72
78
|
});
|
|
73
79
|
}
|
|
74
|
-
refreshInSplitView() {
|
|
75
|
-
this.designerView.parseHTML(this._content);
|
|
80
|
+
async refreshInSplitView() {
|
|
81
|
+
await this.designerView.parseHTML(this._content);
|
|
82
|
+
this._disableChangeNotificationEditor = false;
|
|
76
83
|
}
|
|
77
84
|
designerSelectionChanged(e) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
if (this._tabControl.selectedIndex === 2) {
|
|
86
|
+
let primarySelection = this.instanceServiceContainer.selectionService.primarySelection;
|
|
87
|
+
if (primarySelection) {
|
|
88
|
+
let designItemsAssignmentList = new Map();
|
|
89
|
+
this._content = this.designerView.getHTML(designItemsAssignmentList);
|
|
90
|
+
this._selectionPosition = designItemsAssignmentList.get(primarySelection);
|
|
91
|
+
this.codeView.setSelection(this._selectionPosition);
|
|
92
|
+
this._selectionPosition = null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
designerContentChanged() {
|
|
97
|
+
if (!this._disableChangeNotificationEditor) {
|
|
98
|
+
this._disableChangeNotificationDesigner = true;
|
|
99
|
+
if (this._tabControl.selectedIndex === 2) {
|
|
100
|
+
let primarySelection = this.instanceServiceContainer.selectionService.primarySelection;
|
|
101
|
+
let designItemsAssignmentList = new Map();
|
|
102
|
+
this._content = this.designerView.getHTML(designItemsAssignmentList);
|
|
103
|
+
this.codeView.update(this._content);
|
|
104
|
+
if (primarySelection) {
|
|
105
|
+
this._selectionPosition = designItemsAssignmentList.get(primarySelection);
|
|
106
|
+
if (this._selectionPosition)
|
|
107
|
+
this.codeView.setSelection(this._selectionPosition);
|
|
108
|
+
this._selectionPosition = null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
this._disableChangeNotificationDesigner = false;
|
|
85
112
|
}
|
|
86
113
|
}
|
|
87
114
|
dispose() {
|
|
@@ -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,6 +20,7 @@ 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;
|
|
23
25
|
eatEvents: Element;
|
|
24
26
|
initialize(serviceContainer: ServiceContainer): any;
|
|
@@ -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';
|
|
@@ -28,6 +28,7 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
|
|
|
28
28
|
private _zoomFactor;
|
|
29
29
|
get zoomFactor(): number;
|
|
30
30
|
set zoomFactor(value: number);
|
|
31
|
+
onContentChanged: TypedEvent<void>;
|
|
31
32
|
private _canvas;
|
|
32
33
|
private _canvasContainer;
|
|
33
34
|
private _outercanvas2;
|
|
@@ -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';
|
|
@@ -42,6 +42,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
42
42
|
this._zoomFactor = value;
|
|
43
43
|
this.zoomFactorChanged();
|
|
44
44
|
}
|
|
45
|
+
onContentChanged = new TypedEvent();
|
|
45
46
|
// Private Variables
|
|
46
47
|
_canvas;
|
|
47
48
|
_canvasContainer;
|
|
@@ -330,6 +331,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
330
331
|
}
|
|
331
332
|
setDesignItems(designItems) {
|
|
332
333
|
this.instanceServiceContainer.undoService.clear();
|
|
334
|
+
this.overlayLayer.removeAllOverlays();
|
|
333
335
|
DomHelper.removeAllChildnodes(this.overlayLayer);
|
|
334
336
|
this.rootDesignItem.clearChildren();
|
|
335
337
|
this.addDesignItems(designItems);
|
|
@@ -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;
|
|
@@ -16,6 +16,10 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
16
16
|
set instanceServiceContainer(value) {
|
|
17
17
|
this._designerCanvas.instanceServiceContainer = value;
|
|
18
18
|
}
|
|
19
|
+
_designerCanvas;
|
|
20
|
+
get designerCanvas() {
|
|
21
|
+
return this._designerCanvas;
|
|
22
|
+
}
|
|
19
23
|
_zoomInput;
|
|
20
24
|
_lowertoolbar;
|
|
21
25
|
static style = css `
|
|
@@ -99,7 +103,6 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
99
103
|
<div title="snap to elements" id="alignSnap" class="toolbar-control snap-guide"></div>
|
|
100
104
|
</div>
|
|
101
105
|
</div>`;
|
|
102
|
-
_designerCanvas;
|
|
103
106
|
constructor() {
|
|
104
107
|
super();
|
|
105
108
|
const outer = this._getDomElement('outer');
|
|
@@ -196,13 +199,14 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
196
199
|
}
|
|
197
200
|
}
|
|
198
201
|
getHTML(designItemsAssignmentList) {
|
|
199
|
-
this.instanceServiceContainer.selectionService.setSelectedElements(null);
|
|
202
|
+
//this.instanceServiceContainer.selectionService.setSelectedElements(null);
|
|
200
203
|
return DomConverter.ConvertToString([...this._designerCanvas.rootDesignItem.children()], designItemsAssignmentList);
|
|
201
204
|
}
|
|
202
205
|
async parseHTML(html) {
|
|
203
206
|
const parserService = this.serviceContainer.htmlParserService;
|
|
204
207
|
if (!html) {
|
|
205
208
|
this.instanceServiceContainer.undoService.clear();
|
|
209
|
+
this._designerCanvas.overlayLayer.removeAllOverlays();
|
|
206
210
|
DomHelper.removeAllChildnodes(this._designerCanvas.overlayLayer);
|
|
207
211
|
this._designerCanvas.rootDesignItem.clearChildren();
|
|
208
212
|
}
|
|
@@ -15,6 +15,7 @@ export declare class OverlayLayerView extends BaseCustomWebComponentConstructorA
|
|
|
15
15
|
addOverlay(element: SVGGraphicsElement, overlayLayer?: OverlayLayer): void;
|
|
16
16
|
removeOverlay(element: SVGGraphicsElement): void;
|
|
17
17
|
removeAllNodesWithClass(className: string): void;
|
|
18
|
+
removeAllOverlays(): void;
|
|
18
19
|
createPoint(): DOMPointInit;
|
|
19
20
|
elementFromPoint(x: number, y: number): Element;
|
|
20
21
|
drawLine(x1: number, y1: number, x2: number, y2: number, className?: string, line?: SVGLineElement, overlayLayer?: OverlayLayer): SVGLineElement;
|
|
@@ -80,6 +80,12 @@ export class OverlayLayerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
80
80
|
e.parentNode.removeChild(e);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
removeAllOverlays() {
|
|
84
|
+
const nodes = this._svg.querySelectorAll('svg > g > *');
|
|
85
|
+
for (const e of nodes) {
|
|
86
|
+
e.parentNode.removeChild(e);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
83
89
|
createPoint() {
|
|
84
90
|
//@ts-ignore
|
|
85
91
|
return this._svg.createSVGPoint();
|