@node-projects/web-component-designer 0.0.59 → 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/.github/FUNDING.yml +3 -0
- package/dist/commandHandling/CommandType.d.ts +3 -0
- package/dist/commandHandling/CommandType.js +3 -0
- package/dist/elements/documentContainer.d.ts +10 -0
- package/dist/elements/documentContainer.js +88 -11
- package/dist/elements/services/DefaultServiceBootstrap.js +5 -0
- package/dist/elements/services/GlobalContext.d.ts +4 -0
- package/dist/elements/services/GlobalContext.js +12 -0
- package/dist/elements/services/ServiceContainer.d.ts +5 -0
- package/dist/elements/services/ServiceContainer.js +4 -0
- package/dist/elements/services/demoProviderService/DemoProviderService.d.ts +6 -0
- package/dist/elements/services/demoProviderService/DemoProviderService.js +28 -0
- package/dist/elements/services/demoProviderService/IDemoProviderService.d.ts +5 -0
- package/dist/elements/services/demoProviderService/IDemoProviderService.js +1 -0
- package/dist/elements/services/undoService/UndoService.js +3 -0
- package/dist/elements/widgets/codeView/ICodeView.d.ts +2 -0
- package/dist/elements/widgets/codeView/code-view-ace.d.ts +2 -1
- package/dist/elements/widgets/codeView/code-view-ace.js +3 -1
- package/dist/elements/widgets/codeView/code-view-code-mirror.d.ts +2 -1
- package/dist/elements/widgets/codeView/code-view-code-mirror.js +3 -1
- package/dist/elements/widgets/codeView/code-view-monaco.d.ts +2 -1
- package/dist/elements/widgets/codeView/code-view-monaco.js +11 -1
- package/dist/elements/widgets/demoView/demoView.d.ts +1 -1
- package/dist/elements/widgets/demoView/demoView.js +3 -22
- package/dist/elements/widgets/designerView/ButtonSeperatorProvider copy.d.ts +7 -0
- package/dist/elements/widgets/designerView/ButtonSeperatorProvider copy.js +11 -0
- package/dist/elements/widgets/designerView/ButtonSeperatorProvider.d.ts +8 -0
- package/dist/elements/widgets/designerView/ButtonSeperatorProvider.js +11 -0
- package/dist/elements/widgets/designerView/DesignContext.d.ts +3 -0
- package/dist/elements/widgets/designerView/DesignContext.js +1 -0
- package/dist/elements/widgets/designerView/DesignerViewUseOverlayScollbars.d.ts +7 -0
- package/dist/elements/widgets/designerView/DesignerViewUseOverlayScollbars.js +13 -0
- package/dist/elements/widgets/designerView/IDesignContext.d.ts +3 -0
- package/dist/elements/widgets/designerView/IDesignViewConfigButtonsProvider.d.ts +5 -0
- package/dist/elements/widgets/designerView/IDesignViewConfigButtonsProvider.js +1 -0
- package/dist/elements/widgets/designerView/IDesignerCanvas.d.ts +2 -0
- package/dist/elements/widgets/designerView/designerCanvas.d.ts +2 -2
- package/dist/elements/widgets/designerView/designerCanvas.js +28 -13
- package/dist/elements/widgets/designerView/designerView.d.ts +3 -1
- package/dist/elements/widgets/designerView/designerView.js +20 -2
- package/dist/elements/widgets/designerView/extensions/GridExtensionConfigButtons.d.ts +5 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionConfigButtons.js +12 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionDesignViewConfigButtons.d.ts +6 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionDesignViewConfigButtons.js +21 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionProvider copy.d.ts +10 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionProvider copy.js +18 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionProvider.d.ts +1 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionProvider.js +2 -1
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderConfigButtons.d.ts +5 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderConfigButtons.js +12 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderOptions.d.ts +10 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderOptions.js +18 -0
- package/dist/elements/widgets/designerView/extensions/IDesignViewConfigButtonsProvider.d.ts +0 -0
- package/dist/elements/widgets/designerView/extensions/IDesignViewConfigButtonsProvider.js +1 -0
- package/dist/elements/widgets/designerView/extensions/IExtensionConfiguration.d.ts +3 -0
- package/dist/elements/widgets/designerView/extensions/IExtensionConfiguration.js +1 -0
- 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/DrawPathTool.d.ts +9 -0
- package/dist/elements/widgets/designerView/tools/DrawPathTool.js +95 -29
- package/dist/elements/widgets/designerView/tools/PointerTool.js +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/package.json +4 -4
|
@@ -21,5 +21,8 @@ export declare enum CommandType {
|
|
|
21
21
|
'distributeHorizontal' = "distributeHorizontaly",
|
|
22
22
|
'distributeVertical' = "distributeVertical",
|
|
23
23
|
'setTool' = "setTool",
|
|
24
|
+
'setStrokeColor' = "setStrokeColor",
|
|
25
|
+
'setFillBrush' = "setFillBrush",
|
|
26
|
+
'setStrokeThickness' = "setStrokeThickness",
|
|
24
27
|
'screenshot' = "screenshot"
|
|
25
28
|
}
|
|
@@ -22,5 +22,8 @@ export var CommandType;
|
|
|
22
22
|
CommandType["distributeHorizontal"] = "distributeHorizontaly";
|
|
23
23
|
CommandType["distributeVertical"] = "distributeVertical";
|
|
24
24
|
CommandType["setTool"] = "setTool";
|
|
25
|
+
CommandType["setStrokeColor"] = "setStrokeColor";
|
|
26
|
+
CommandType["setFillBrush"] = "setFillBrush";
|
|
27
|
+
CommandType["setStrokeThickness"] = "setStrokeThickness";
|
|
25
28
|
CommandType["screenshot"] = "screenshot";
|
|
26
29
|
})(CommandType || (CommandType = {}));
|
|
@@ -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;
|
|
@@ -16,8 +17,17 @@ export declare class DocumentContainer extends BaseCustomWebComponentLazyAppend
|
|
|
16
17
|
private _content;
|
|
17
18
|
private _tabControl;
|
|
18
19
|
private _selectionPosition;
|
|
20
|
+
private _splitDiv;
|
|
21
|
+
private _designerDiv;
|
|
22
|
+
private _codeDiv;
|
|
23
|
+
private refreshInSplitViewDebounced;
|
|
24
|
+
private _disableChangeNotificationDesigner;
|
|
25
|
+
private _disableChangeNotificationEditor;
|
|
19
26
|
static get style(): CSSStyleSheet;
|
|
20
27
|
constructor(serviceContainer: ServiceContainer, content?: string);
|
|
28
|
+
refreshInSplitView(): Promise<void>;
|
|
29
|
+
designerSelectionChanged(e: ISelectionChangedEvent): void;
|
|
30
|
+
designerContentChanged(): void;
|
|
21
31
|
dispose(): void;
|
|
22
32
|
executeCommand(command: IUiCommand): void;
|
|
23
33
|
canExecuteCommand(command: IUiCommand): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseCustomWebComponentLazyAppend, css } from "@node-projects/base-custom-webcomponent";
|
|
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
4
|
export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
@@ -10,6 +10,12 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
10
10
|
_content = '';
|
|
11
11
|
_tabControl;
|
|
12
12
|
_selectionPosition;
|
|
13
|
+
_splitDiv;
|
|
14
|
+
_designerDiv;
|
|
15
|
+
_codeDiv;
|
|
16
|
+
refreshInSplitViewDebounced;
|
|
17
|
+
_disableChangeNotificationDesigner;
|
|
18
|
+
_disableChangeNotificationEditor;
|
|
13
19
|
static get style() {
|
|
14
20
|
return css `
|
|
15
21
|
div {
|
|
@@ -20,10 +26,16 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
20
26
|
node-projects-designer-view {
|
|
21
27
|
height: 100%;
|
|
22
28
|
/*overflow: auto;*/
|
|
23
|
-
}
|
|
29
|
+
}
|
|
30
|
+
.split-div {
|
|
31
|
+
display: grid;
|
|
32
|
+
grid-template-rows: 1fr 1fr;
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
24
35
|
}
|
|
25
36
|
constructor(serviceContainer, content) {
|
|
26
37
|
super();
|
|
38
|
+
this.refreshInSplitViewDebounced = debounce(this.refreshInSplitView, 200);
|
|
27
39
|
this._serviceContainer = serviceContainer;
|
|
28
40
|
if (content != null)
|
|
29
41
|
this._content = content;
|
|
@@ -32,12 +44,31 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
32
44
|
div.appendChild(this._tabControl);
|
|
33
45
|
this.designerView = new DesignerView();
|
|
34
46
|
this.designerView.setAttribute('exportparts', 'canvas');
|
|
35
|
-
this.
|
|
36
|
-
this._tabControl.appendChild(this.
|
|
47
|
+
this._designerDiv = document.createElement("div");
|
|
48
|
+
this._tabControl.appendChild(this._designerDiv);
|
|
49
|
+
this._designerDiv.title = 'Designer';
|
|
50
|
+
this._designerDiv.appendChild(this.designerView);
|
|
37
51
|
this.designerView.initialize(this._serviceContainer);
|
|
52
|
+
this.designerView.instanceServiceContainer.selectionService.onSelectionChanged.on(e => this.designerSelectionChanged(e));
|
|
53
|
+
this.designerView.designerCanvas.onContentChanged.on(() => this.designerContentChanged());
|
|
38
54
|
this.codeView = new serviceContainer.config.codeViewWidget();
|
|
39
|
-
this.
|
|
40
|
-
this._tabControl.appendChild(this.
|
|
55
|
+
this._codeDiv = document.createElement("div");
|
|
56
|
+
this._tabControl.appendChild(this._codeDiv);
|
|
57
|
+
this._codeDiv.title = 'Code';
|
|
58
|
+
this._codeDiv.appendChild(this.codeView);
|
|
59
|
+
this.codeView.onTextChanged.on(text => {
|
|
60
|
+
if (!this._disableChangeNotificationDesigner) {
|
|
61
|
+
this._disableChangeNotificationEditor = true;
|
|
62
|
+
if (this._tabControl.selectedIndex === 2) {
|
|
63
|
+
this._content = text;
|
|
64
|
+
this.refreshInSplitViewDebounced();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
this._splitDiv = document.createElement("div");
|
|
69
|
+
this._splitDiv.title = 'Split';
|
|
70
|
+
this._splitDiv.className = 'split-div';
|
|
71
|
+
this._tabControl.appendChild(this._splitDiv);
|
|
41
72
|
this.demoView = new serviceContainer.config.demoViewWidget();
|
|
42
73
|
this.demoView.title = 'Preview';
|
|
43
74
|
this._tabControl.appendChild(this.demoView);
|
|
@@ -46,6 +77,40 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
46
77
|
this._tabControl.selectedIndex = 0;
|
|
47
78
|
});
|
|
48
79
|
}
|
|
80
|
+
async refreshInSplitView() {
|
|
81
|
+
await this.designerView.parseHTML(this._content);
|
|
82
|
+
this._disableChangeNotificationEditor = false;
|
|
83
|
+
}
|
|
84
|
+
designerSelectionChanged(e) {
|
|
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;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
49
114
|
dispose() {
|
|
50
115
|
this.codeView.dispose();
|
|
51
116
|
}
|
|
@@ -69,7 +134,9 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
69
134
|
this.designerView.parseHTML(this._content);
|
|
70
135
|
else if (this._tabControl.selectedIndex === 1)
|
|
71
136
|
this.codeView.update(this._content);
|
|
72
|
-
else if (this._tabControl.selectedIndex === 2)
|
|
137
|
+
else if (this._tabControl.selectedIndex === 2) {
|
|
138
|
+
}
|
|
139
|
+
else if (this._tabControl.selectedIndex === 3)
|
|
73
140
|
this.demoView.display(this._serviceContainer, this.designerView.instanceServiceContainer, this._content);
|
|
74
141
|
}
|
|
75
142
|
}
|
|
@@ -91,11 +158,16 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
91
158
|
this._content = this.designerView.getHTML(designItemsAssignmentList);
|
|
92
159
|
this._selectionPosition = designItemsAssignmentList.get(primarySelection);
|
|
93
160
|
}
|
|
94
|
-
else if (i.oldIndex === 1)
|
|
161
|
+
else if (i.oldIndex === 1) {
|
|
95
162
|
this._content = this.codeView.getText();
|
|
96
|
-
|
|
163
|
+
}
|
|
164
|
+
else if (i.oldIndex === 2) {
|
|
165
|
+
this._designerDiv.appendChild(this.designerView);
|
|
166
|
+
this._codeDiv.appendChild(this.codeView);
|
|
167
|
+
}
|
|
168
|
+
if (i.newIndex === 0 || i.newIndex === 2)
|
|
97
169
|
this.designerView.parseHTML(this._content);
|
|
98
|
-
|
|
170
|
+
if (i.newIndex === 1 || i.newIndex === 2) {
|
|
99
171
|
this.codeView.update(this._content);
|
|
100
172
|
if (this._selectionPosition) {
|
|
101
173
|
this.codeView.setSelection(this._selectionPosition);
|
|
@@ -105,8 +177,13 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
105
177
|
this.codeView.focusEditor();
|
|
106
178
|
}
|
|
107
179
|
}
|
|
108
|
-
|
|
180
|
+
if (i.newIndex === 2) {
|
|
181
|
+
this._splitDiv.appendChild(this.designerView);
|
|
182
|
+
this._splitDiv.appendChild(this.codeView);
|
|
183
|
+
}
|
|
184
|
+
if (i.newIndex === 3) {
|
|
109
185
|
this.demoView.display(this._serviceContainer, this.designerView.instanceServiceContainer, this._content);
|
|
186
|
+
}
|
|
110
187
|
});
|
|
111
188
|
if (this._content)
|
|
112
189
|
this.content = this._content;
|
|
@@ -45,6 +45,9 @@ import { DragDropService } from './dragDropService/DragDropService';
|
|
|
45
45
|
import { EditTextExtensionProvider } from '../widgets/designerView/extensions/EditText/EditTextExtensionProvider.js';
|
|
46
46
|
import { CopyPasteService } from './copyPasteService/CopyPasteService';
|
|
47
47
|
import { DefaultModelCommandService } from './modelCommandService/DefaultModelCommandService';
|
|
48
|
+
import { ButtonSeperatorProvider } from '../widgets/designerView/ButtonSeperatorProvider';
|
|
49
|
+
import { GridExtensionDesignViewConfigButtons } from '../widgets/designerView/extensions/GridExtensionDesignViewConfigButtons';
|
|
50
|
+
import { DemoProviderService } from './demoProviderService/DemoProviderService';
|
|
48
51
|
export function createDefaultServiceContainer() {
|
|
49
52
|
let serviceContainer = new ServiceContainer();
|
|
50
53
|
serviceContainer.register("propertyService", new PolymerPropertiesService());
|
|
@@ -65,6 +68,7 @@ export function createDefaultServiceContainer() {
|
|
|
65
68
|
serviceContainer.register("dragDropService", new DragDropService());
|
|
66
69
|
serviceContainer.register("copyPasteService", new CopyPasteService());
|
|
67
70
|
serviceContainer.register("modelCommandService", new DefaultModelCommandService());
|
|
71
|
+
serviceContainer.register("demoProviderService", new DemoProviderService());
|
|
68
72
|
serviceContainer.designerExtensions.set(ExtensionType.Permanent, [
|
|
69
73
|
new ResizeExtensionProvider(false),
|
|
70
74
|
new InvisibleDivExtensionProvider()
|
|
@@ -106,6 +110,7 @@ export function createDefaultServiceContainer() {
|
|
|
106
110
|
serviceContainer.designerTools.set(NamedTools.MagicWandSelector, new MagicWandSelectorTool());
|
|
107
111
|
serviceContainer.designerTools.set(NamedTools.PickColor, new PickColorTool());
|
|
108
112
|
serviceContainer.designerTools.set(NamedTools.Text, new TextTool());
|
|
113
|
+
serviceContainer.designViewConfigButtons.push(new ButtonSeperatorProvider(20), new GridExtensionDesignViewConfigButtons());
|
|
109
114
|
serviceContainer.designerContextMenuExtensions = [
|
|
110
115
|
new CopyPasteContextMenu(),
|
|
111
116
|
new ZMoveContextMenu(),
|
|
@@ -5,6 +5,7 @@ export declare class GlobalContext {
|
|
|
5
5
|
private _serviceContainer;
|
|
6
6
|
private _tool;
|
|
7
7
|
private _strokeColor;
|
|
8
|
+
private _strokeThickness;
|
|
8
9
|
private _fillBrush;
|
|
9
10
|
constructor(serviceContainer: ServiceContainer);
|
|
10
11
|
set tool(tool: ITool);
|
|
@@ -14,6 +15,9 @@ export declare class GlobalContext {
|
|
|
14
15
|
set strokeColor(strokeColor: string);
|
|
15
16
|
get strokeColor(): string;
|
|
16
17
|
readonly onStrokeColorChanged: TypedEvent<PropertyChangedArgs<string>>;
|
|
18
|
+
set strokeThickness(strokeThickness: string);
|
|
19
|
+
get strokeThickness(): string;
|
|
20
|
+
readonly onStrokeThicknessChanged: TypedEvent<PropertyChangedArgs<string>>;
|
|
17
21
|
set fillBrush(fillBrush: string);
|
|
18
22
|
get fillBrush(): string;
|
|
19
23
|
readonly onFillBrushChanged: TypedEvent<PropertyChangedArgs<string>>;
|
|
@@ -5,6 +5,7 @@ export class GlobalContext {
|
|
|
5
5
|
_serviceContainer;
|
|
6
6
|
_tool;
|
|
7
7
|
_strokeColor = 'black';
|
|
8
|
+
_strokeThickness = '3';
|
|
8
9
|
_fillBrush = 'transparent';
|
|
9
10
|
constructor(serviceContainer) {
|
|
10
11
|
this._serviceContainer = serviceContainer;
|
|
@@ -36,6 +37,17 @@ export class GlobalContext {
|
|
|
36
37
|
return this._strokeColor;
|
|
37
38
|
}
|
|
38
39
|
onStrokeColorChanged = new TypedEvent();
|
|
40
|
+
set strokeThickness(strokeThickness) {
|
|
41
|
+
if (this._strokeThickness !== strokeThickness) {
|
|
42
|
+
const oldStrokeThickness = this._strokeThickness;
|
|
43
|
+
this._strokeThickness = strokeThickness;
|
|
44
|
+
this.onStrokeThicknessChanged.emit(new PropertyChangedArgs(strokeThickness, oldStrokeThickness));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
get strokeThickness() {
|
|
48
|
+
return this._strokeThickness;
|
|
49
|
+
}
|
|
50
|
+
onStrokeThicknessChanged = new TypedEvent();
|
|
39
51
|
set fillBrush(fillBrush) {
|
|
40
52
|
this._fillBrush = fillBrush;
|
|
41
53
|
if (this._fillBrush !== fillBrush) {
|
|
@@ -23,6 +23,8 @@ import { IDragDropService } from './dragDropService/IDragDropService';
|
|
|
23
23
|
import { ICopyPasteService } from "./copyPasteService/ICopyPasteService.js";
|
|
24
24
|
import { IDesignerPointerExtensionProvider } from "../widgets/designerView/extensions/pointerExtensions/IDesignerPointerExtensionProvider.js";
|
|
25
25
|
import { IModelCommandService } from "./modelCommandService/IModelCommandService.js";
|
|
26
|
+
import { IDesignViewConfigButtonsProvider } from "../widgets/designerView/IDesignViewConfigButtonsProvider.js";
|
|
27
|
+
import { IDemoProviderService } from "./demoProviderService/IDemoProviderService.js";
|
|
26
28
|
interface ServiceNameMap {
|
|
27
29
|
"propertyService": IPropertiesService;
|
|
28
30
|
"containerService": IPlacementService;
|
|
@@ -39,6 +41,7 @@ interface ServiceNameMap {
|
|
|
39
41
|
"dragDropService": IDragDropService;
|
|
40
42
|
"copyPasteService": ICopyPasteService;
|
|
41
43
|
"modelCommandService": IModelCommandService;
|
|
44
|
+
"demoProviderService": IDemoProviderService;
|
|
42
45
|
}
|
|
43
46
|
export declare class ServiceContainer extends BaseServiceContainer<ServiceNameMap> {
|
|
44
47
|
readonly config: {
|
|
@@ -46,6 +49,7 @@ export declare class ServiceContainer extends BaseServiceContainer<ServiceNameMa
|
|
|
46
49
|
demoViewWidget: new (...args: any[]) => IDemoView & HTMLElement;
|
|
47
50
|
};
|
|
48
51
|
readonly designerExtensions: Map<(ExtensionType | string), IDesignerExtensionProvider[]>;
|
|
52
|
+
readonly designViewConfigButtons: IDesignViewConfigButtonsProvider[];
|
|
49
53
|
readonly designerPointerExtensions: IDesignerPointerExtensionProvider[];
|
|
50
54
|
designerContextMenuExtensions: IContextMenuExtension[];
|
|
51
55
|
readonly globalContext: GlobalContext;
|
|
@@ -65,5 +69,6 @@ export declare class ServiceContainer extends BaseServiceContainer<ServiceNameMa
|
|
|
65
69
|
get dragDropService(): IDragDropService;
|
|
66
70
|
get copyPasteService(): ICopyPasteService;
|
|
67
71
|
get modelCommandService(): IModelCommandService;
|
|
72
|
+
get demoProviderService(): IDemoProviderService;
|
|
68
73
|
}
|
|
69
74
|
export {};
|
|
@@ -8,6 +8,7 @@ export class ServiceContainer extends BaseServiceContainer {
|
|
|
8
8
|
demoViewWidget: DemoView
|
|
9
9
|
};
|
|
10
10
|
designerExtensions = new Map();
|
|
11
|
+
designViewConfigButtons = [];
|
|
11
12
|
designerPointerExtensions = [];
|
|
12
13
|
designerContextMenuExtensions;
|
|
13
14
|
globalContext = new GlobalContext(this);
|
|
@@ -57,4 +58,7 @@ export class ServiceContainer extends BaseServiceContainer {
|
|
|
57
58
|
get modelCommandService() {
|
|
58
59
|
return this.getLastService('modelCommandService');
|
|
59
60
|
}
|
|
61
|
+
get demoProviderService() {
|
|
62
|
+
return this.getLastService('demoProviderService');
|
|
63
|
+
}
|
|
60
64
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { InstanceServiceContainer } from "../InstanceServiceContainer.js";
|
|
2
|
+
import { ServiceContainer } from "../ServiceContainer.js";
|
|
3
|
+
import { IDemoProviderService } from "./IDemoProviderService.js";
|
|
4
|
+
export declare class DemoProviderService implements IDemoProviderService {
|
|
5
|
+
provideDemo(container: HTMLElement, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, code: string): Promise<void>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DomHelper } from '@node-projects/base-custom-webcomponent/dist/DomHelper';
|
|
2
|
+
export class DemoProviderService {
|
|
3
|
+
provideDemo(container, serviceContainer, instanceServiceContainer, code) {
|
|
4
|
+
return new Promise(resolve => {
|
|
5
|
+
const iframe = document.createElement('iframe');
|
|
6
|
+
iframe.style.width = '100%';
|
|
7
|
+
iframe.style.height = '100%';
|
|
8
|
+
iframe.style.border = 'none';
|
|
9
|
+
iframe.style.display = 'none';
|
|
10
|
+
DomHelper.removeAllChildnodes(container);
|
|
11
|
+
container.appendChild(iframe);
|
|
12
|
+
iframe.onload = () => {
|
|
13
|
+
iframe.style.display = 'block';
|
|
14
|
+
resolve();
|
|
15
|
+
};
|
|
16
|
+
const doc = iframe.contentWindow.document;
|
|
17
|
+
doc.open();
|
|
18
|
+
doc.write('<script type="module">');
|
|
19
|
+
for (let i of instanceServiceContainer.designContext.imports) {
|
|
20
|
+
doc.write("import '" + i + "';");
|
|
21
|
+
}
|
|
22
|
+
doc.write("document.body.style.display='';");
|
|
23
|
+
doc.write('</script>');
|
|
24
|
+
doc.write('<body style="display:none">' + code + '</body>');
|
|
25
|
+
doc.close();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InstanceServiceContainer } from "../InstanceServiceContainer.js";
|
|
2
|
+
import { ServiceContainer } from "../ServiceContainer.js";
|
|
3
|
+
export interface IDemoProviderService {
|
|
4
|
+
provideDemo(container: HTMLElement, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, code: string): any;
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { IUiCommandHandler } from "../../../commandHandling/IUiCommandHandler";
|
|
2
2
|
import { IDisposable } from "../../../interfaces/IDisposable";
|
|
3
3
|
import { IStringPosition } from "../../services/htmlWriterService/IStringPosition";
|
|
4
|
+
import { TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
4
5
|
export interface ICodeView extends IUiCommandHandler, IDisposable {
|
|
5
6
|
update(code: string): any;
|
|
6
7
|
getText(): any;
|
|
7
8
|
setSelection(position: IStringPosition): any;
|
|
8
9
|
focusEditor(): any;
|
|
10
|
+
onTextChanged: TypedEvent<string>;
|
|
9
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseCustomWebComponentLazyAppend } from '@node-projects/base-custom-webcomponent';
|
|
1
|
+
import { BaseCustomWebComponentLazyAppend, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
2
|
import { ICodeView } from "./ICodeView";
|
|
3
3
|
import { IStringPosition } from '../../services/htmlWriterService/IStringPosition';
|
|
4
4
|
import { IUiCommand } from '../../../commandHandling/IUiCommand';
|
|
@@ -7,6 +7,7 @@ export declare class CodeViewAce extends BaseCustomWebComponentLazyAppend implem
|
|
|
7
7
|
canvasElement: HTMLElement;
|
|
8
8
|
elementsToPackages: Map<string, string>;
|
|
9
9
|
code: string;
|
|
10
|
+
onTextChanged: TypedEvent<string>;
|
|
10
11
|
private _aceEditor;
|
|
11
12
|
private _editor;
|
|
12
13
|
static readonly style: CSSStyleSheet;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseCustomWebComponentLazyAppend, css } from '@node-projects/base-custom-webcomponent';
|
|
1
|
+
import { BaseCustomWebComponentLazyAppend, css, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
2
|
import { CommandType } from '../../../commandHandling/CommandType';
|
|
3
3
|
class CodeViewAceCompleter {
|
|
4
4
|
getCompletions(editor, session, pos, prefix, callback) {
|
|
@@ -18,6 +18,7 @@ export class CodeViewAce extends BaseCustomWebComponentLazyAppend {
|
|
|
18
18
|
canvasElement;
|
|
19
19
|
elementsToPackages;
|
|
20
20
|
code;
|
|
21
|
+
onTextChanged = new TypedEvent();
|
|
21
22
|
_aceEditor;
|
|
22
23
|
_editor;
|
|
23
24
|
static style = css `
|
|
@@ -111,6 +112,7 @@ export class CodeViewAce extends BaseCustomWebComponentLazyAppend {
|
|
|
111
112
|
});
|
|
112
113
|
let config = { attributes: true, childList: true, characterData: true };
|
|
113
114
|
observer.observe(this.shadowRoot.querySelector('.ace_content'), config);
|
|
115
|
+
this._aceEditor.on('change', () => this.onTextChanged.emit(this._aceEditor.getValue()));
|
|
114
116
|
}
|
|
115
117
|
update(code) {
|
|
116
118
|
this._aceEditor.setValue(code);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseCustomWebComponentLazyAppend } from '@node-projects/base-custom-webcomponent';
|
|
1
|
+
import { BaseCustomWebComponentLazyAppend, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
2
|
import { ICodeView } from "./ICodeView";
|
|
3
3
|
import { IStringPosition } from '../../services/htmlWriterService/IStringPosition';
|
|
4
4
|
import { IUiCommand } from '../../../commandHandling/IUiCommand';
|
|
@@ -7,6 +7,7 @@ export declare class CodeViewCodeMirror extends BaseCustomWebComponentLazyAppend
|
|
|
7
7
|
canvasElement: HTMLElement;
|
|
8
8
|
elementsToPackages: Map<string, string>;
|
|
9
9
|
code: string;
|
|
10
|
+
onTextChanged: TypedEvent<string>;
|
|
10
11
|
private _codeMirrorEditor;
|
|
11
12
|
private _editor;
|
|
12
13
|
static readonly style: CSSStyleSheet;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { BaseCustomWebComponentLazyAppend, css, html } from '@node-projects/base-custom-webcomponent';
|
|
1
|
+
import { BaseCustomWebComponentLazyAppend, css, html, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
2
|
import { CommandType } from '../../../commandHandling/CommandType';
|
|
3
3
|
export class CodeViewCodeMirror extends BaseCustomWebComponentLazyAppend {
|
|
4
4
|
canvasElement;
|
|
5
5
|
elementsToPackages;
|
|
6
6
|
code;
|
|
7
|
+
onTextChanged = new TypedEvent();
|
|
7
8
|
_codeMirrorEditor;
|
|
8
9
|
_editor;
|
|
9
10
|
static style = css `
|
|
@@ -82,6 +83,7 @@ export class CodeViewCodeMirror extends BaseCustomWebComponentLazyAppend {
|
|
|
82
83
|
//@ts-ignore
|
|
83
84
|
this._codeMirrorEditor = CodeMirror(this._editor, config);
|
|
84
85
|
this._codeMirrorEditor.setSize('100%', '100%');
|
|
86
|
+
this._codeMirrorEditor.on('change', () => this.onTextChanged.emit(this._codeMirrorEditor.getValue()));
|
|
85
87
|
}
|
|
86
88
|
update(code) {
|
|
87
89
|
this._codeMirrorEditor.setValue(code);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseCustomWebComponentLazyAppend } from '@node-projects/base-custom-webcomponent';
|
|
1
|
+
import { BaseCustomWebComponentLazyAppend, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
2
|
import { ICodeView } from "./ICodeView";
|
|
3
3
|
import { IActivateable } from '../../../interfaces/IActivateable';
|
|
4
4
|
import { IStringPosition } from '../../services/htmlWriterService/IStringPosition';
|
|
@@ -9,6 +9,7 @@ export declare class CodeViewMonaco extends BaseCustomWebComponentLazyAppend imp
|
|
|
9
9
|
canvasElement: HTMLElement;
|
|
10
10
|
elementsToPackages: Map<string, string>;
|
|
11
11
|
code: string;
|
|
12
|
+
onTextChanged: TypedEvent<string>;
|
|
12
13
|
private _monacoEditor;
|
|
13
14
|
private _editor;
|
|
14
15
|
static readonly style: CSSStyleSheet;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseCustomWebComponentLazyAppend, css, html } from '@node-projects/base-custom-webcomponent';
|
|
1
|
+
import { BaseCustomWebComponentLazyAppend, css, html, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
2
|
import { CommandType } from '../../../commandHandling/CommandType';
|
|
3
3
|
export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
4
4
|
dispose() {
|
|
@@ -7,6 +7,7 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
|
7
7
|
canvasElement;
|
|
8
8
|
elementsToPackages;
|
|
9
9
|
code;
|
|
10
|
+
onTextChanged = new TypedEvent();
|
|
10
11
|
_monacoEditor;
|
|
11
12
|
_editor;
|
|
12
13
|
static style = css `
|
|
@@ -69,6 +70,15 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
|
69
70
|
}
|
|
70
71
|
});
|
|
71
72
|
this._monacoEditor.layout();
|
|
73
|
+
let changeContentListener = this._monacoEditor.getModel().onDidChangeContent(e => {
|
|
74
|
+
this.onTextChanged.emit(this._monacoEditor.getValue());
|
|
75
|
+
});
|
|
76
|
+
this._monacoEditor.onDidChangeModel(e => {
|
|
77
|
+
changeContentListener.dispose();
|
|
78
|
+
changeContentListener = this._monacoEditor.getModel().onDidChangeContent(e => {
|
|
79
|
+
this.onTextChanged.emit(this._monacoEditor.getValue());
|
|
80
|
+
});
|
|
81
|
+
});
|
|
72
82
|
});
|
|
73
83
|
}
|
|
74
84
|
focusEditor() {
|
|
@@ -7,5 +7,5 @@ export declare class DemoView extends BaseCustomWebComponentLazyAppend implement
|
|
|
7
7
|
private _loading;
|
|
8
8
|
static readonly style: CSSStyleSheet;
|
|
9
9
|
constructor();
|
|
10
|
-
display(serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, code: string): void
|
|
10
|
+
display(serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, code: string): Promise<void>;
|
|
11
11
|
}
|
|
@@ -18,11 +18,6 @@ export class DemoView extends BaseCustomWebComponentLazyAppend {
|
|
|
18
18
|
position: absolute;
|
|
19
19
|
top: 60px;
|
|
20
20
|
left: 20px;
|
|
21
|
-
}
|
|
22
|
-
iframe {
|
|
23
|
-
width: 100%;
|
|
24
|
-
height: 100%;
|
|
25
|
-
border: none;
|
|
26
21
|
}`;
|
|
27
22
|
constructor() {
|
|
28
23
|
super();
|
|
@@ -34,24 +29,10 @@ export class DemoView extends BaseCustomWebComponentLazyAppend {
|
|
|
34
29
|
this._loading.textContent = '🛀 Hold on, loading...';
|
|
35
30
|
this.shadowRoot.appendChild(this._loading);
|
|
36
31
|
}
|
|
37
|
-
display(serviceContainer, instanceServiceContainer, code) {
|
|
38
|
-
let iframe = document.createElement('iframe');
|
|
39
|
-
this._placeholder.innerHTML = '';
|
|
40
|
-
this._placeholder.appendChild(iframe);
|
|
32
|
+
async display(serviceContainer, instanceServiceContainer, code) {
|
|
41
33
|
this._loading.hidden = false;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
let doc = iframe.contentWindow.document;
|
|
46
|
-
doc.open();
|
|
47
|
-
doc.write('<script type="module">');
|
|
48
|
-
for (let i of instanceServiceContainer.designContext.imports) {
|
|
49
|
-
doc.write("import '" + i + "';");
|
|
50
|
-
}
|
|
51
|
-
doc.write("document.body.style.display='';");
|
|
52
|
-
doc.write('</script>');
|
|
53
|
-
doc.write('<body style="display:none">' + code + '</body>');
|
|
54
|
-
doc.close();
|
|
34
|
+
await serviceContainer.demoProviderService.provideDemo(this._placeholder, serviceContainer, instanceServiceContainer, code);
|
|
35
|
+
this._loading.hidden = true;
|
|
55
36
|
}
|
|
56
37
|
}
|
|
57
38
|
customElements.define('node-projects-demo-view', DemoView);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IDesignerCanvas } from "./IDesignerCanvas.js";
|
|
2
|
+
import { IDesignViewConfigButtonsProvider } from "./IDesignViewConfigButtonsProvider.js";
|
|
3
|
+
export declare class ButtonSeperatorProvider implements IDesignViewConfigButtonsProvider {
|
|
4
|
+
_space: number;
|
|
5
|
+
constructor(space: number);
|
|
6
|
+
provideButtons(designerCanvas: IDesignerCanvas): HTMLElement[];
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DesignerView } from "./designerView.js";
|
|
2
|
+
import { IDesignerCanvas } from "./IDesignerCanvas.js";
|
|
3
|
+
import { IDesignViewConfigButtonsProvider } from "./IDesignViewConfigButtonsProvider.js";
|
|
4
|
+
export declare class ButtonSeperatorProvider implements IDesignViewConfigButtonsProvider {
|
|
5
|
+
_space: number;
|
|
6
|
+
constructor(space: number);
|
|
7
|
+
provideButtons(designerView: DesignerView, designerCanvas: IDesignerCanvas): HTMLElement[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class ButtonSeperatorProvider {
|
|
2
|
+
_space;
|
|
3
|
+
constructor(space) {
|
|
4
|
+
this._space = space;
|
|
5
|
+
}
|
|
6
|
+
provideButtons(designerView, designerCanvas) {
|
|
7
|
+
const div = document.createElement('div');
|
|
8
|
+
div.style.marginLeft = this._space + 'px';
|
|
9
|
+
return [div];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IDesignerCanvas } from "./IDesignerCanvas.js";
|
|
2
|
+
import { IDesignViewConfigButtonsProvider } from "./IDesignViewConfigButtonsProvider.js";
|
|
3
|
+
import { DesignerView } from './designerView';
|
|
4
|
+
export declare class DesignerViewUseOverlayScollbars implements IDesignViewConfigButtonsProvider {
|
|
5
|
+
constructor();
|
|
6
|
+
provideButtons(designerView: DesignerView, designerCanvas: IDesignerCanvas): HTMLElement[];
|
|
7
|
+
}
|