@node-projects/web-component-designer 0.0.188 → 0.0.190
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/item/DesignItem.js +1 -1
- package/dist/elements/widgets/codeView/code-view-monaco.d.ts +2 -0
- package/dist/elements/widgets/codeView/code-view-monaco.js +77 -52
- package/dist/elements/widgets/designerView/extensions/ExtensionManager.d.ts +1 -1
- package/dist/elements/widgets/designerView/extensions/ExtensionManager.js +9 -3
- package/dist/elements/widgets/designerView/extensions/IExtensionManger.d.ts +1 -1
- package/package.json +1 -1
|
@@ -407,7 +407,7 @@ export class DesignItem {
|
|
|
407
407
|
_removeChildInternal(designItem) {
|
|
408
408
|
if (designItem.parent && this.instanceServiceContainer.selectionService.primarySelection == designItem)
|
|
409
409
|
designItem.instanceServiceContainer.designerCanvas.extensionManager.removeExtension(designItem.parent, ExtensionType.PrimarySelectionContainer);
|
|
410
|
-
designItem.instanceServiceContainer.designerCanvas.extensionManager.removeExtensions([designItem]);
|
|
410
|
+
designItem.instanceServiceContainer.designerCanvas.extensionManager.removeExtensions([designItem], true);
|
|
411
411
|
const index = this._childArray.indexOf(designItem);
|
|
412
412
|
if (index > -1) {
|
|
413
413
|
this._childArray.splice(index, 1);
|
|
@@ -5,6 +5,7 @@ import { IStringPosition } from '../../services/htmlWriterService/IStringPositio
|
|
|
5
5
|
import { IUiCommandHandler } from '../../../commandHandling/IUiCommandHandler.js';
|
|
6
6
|
import { IUiCommand } from '../../../commandHandling/IUiCommand.js';
|
|
7
7
|
export declare class CodeViewMonaco extends BaseCustomWebComponentLazyAppend implements ICodeView, IActivateable, IUiCommandHandler {
|
|
8
|
+
private static _initalized;
|
|
8
9
|
dispose(): void;
|
|
9
10
|
canvasElement: HTMLElement;
|
|
10
11
|
elementsToPackages: Map<string, string>;
|
|
@@ -16,6 +17,7 @@ export declare class CodeViewMonaco extends BaseCustomWebComponentLazyAppend imp
|
|
|
16
17
|
static readonly template: HTMLTemplateElement;
|
|
17
18
|
executeCommand(command: IUiCommand): void;
|
|
18
19
|
canExecuteCommand(command: IUiCommand): boolean;
|
|
20
|
+
static initMonacoEditor(): Promise<void>;
|
|
19
21
|
ready(): Promise<void>;
|
|
20
22
|
focusEditor(): void;
|
|
21
23
|
activated(): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseCustomWebComponentLazyAppend, css, html, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
2
|
import { CommandType } from '../../../commandHandling/CommandType.js';
|
|
3
3
|
export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
4
|
+
static _initalized;
|
|
4
5
|
dispose() {
|
|
5
6
|
this._monacoEditor.dispose();
|
|
6
7
|
}
|
|
@@ -53,6 +54,35 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
|
53
54
|
}
|
|
54
55
|
return false;
|
|
55
56
|
}
|
|
57
|
+
static initMonacoEditor() {
|
|
58
|
+
return new Promise(async (resolve) => {
|
|
59
|
+
if (!CodeViewMonaco._initalized) {
|
|
60
|
+
CodeViewMonaco._initalized = true;
|
|
61
|
+
//@ts-ignore
|
|
62
|
+
require.config({ paths: { 'vs': 'node_modules/monaco-editor/min/vs' } });
|
|
63
|
+
//@ts-ignore
|
|
64
|
+
require(['vs/editor/editor.main'], () => {
|
|
65
|
+
//@ts-ignore
|
|
66
|
+
monaco.editor.defineTheme('webComponentDesignerTheme', {
|
|
67
|
+
base: 'vs',
|
|
68
|
+
inherit: true,
|
|
69
|
+
//@ts-ignore
|
|
70
|
+
rules: [{ background: 'EDF9FA' }],
|
|
71
|
+
colors: {
|
|
72
|
+
'editor.selectionBackground': '#add6ff',
|
|
73
|
+
'editor.inactiveSelectionBackground': '#add6ff'
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
//@ts-ignore
|
|
77
|
+
monaco.editor.setTheme('webComponentDesignerTheme');
|
|
78
|
+
resolve();
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
resolve();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
56
86
|
async ready() {
|
|
57
87
|
let style;
|
|
58
88
|
//@ts-ignore
|
|
@@ -64,80 +94,75 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
|
64
94
|
style = await import("monaco-editor/min/vs/editor/editor.main.css", { assert: { type: 'css' } });
|
|
65
95
|
this.shadowRoot.adoptedStyleSheets = [style.default, this.constructor.style];
|
|
66
96
|
this._editor = this._getDomElement('container');
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
require(['vs/editor/editor.main'], () => {
|
|
71
|
-
//@ts-ignore
|
|
72
|
-
this._monacoEditor = monaco.editor.create(this._editor, {
|
|
73
|
-
automaticLayout: true,
|
|
74
|
-
wordWrapColumn: 1000,
|
|
75
|
-
wordWrap: 'wordWrapColumn',
|
|
76
|
-
value: this.code,
|
|
77
|
-
language: 'html',
|
|
78
|
-
minimap: {
|
|
79
|
-
size: 'fill'
|
|
80
|
-
},
|
|
81
|
-
fixedOverflowWidgets: true,
|
|
82
|
-
scrollbar: {
|
|
83
|
-
useShadows: false,
|
|
84
|
-
verticalHasArrows: true,
|
|
85
|
-
horizontalHasArrows: true,
|
|
86
|
-
vertical: 'visible',
|
|
87
|
-
horizontal: 'visible'
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
//@ts-ignore
|
|
91
|
-
monaco.editor.defineTheme('myTheme', {
|
|
92
|
-
base: 'vs',
|
|
93
|
-
inherit: true,
|
|
97
|
+
await CodeViewMonaco.initMonacoEditor();
|
|
98
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
99
|
+
if (this._editor.offsetWidth > 0) {
|
|
94
100
|
//@ts-ignore
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
101
|
+
this._monacoEditor = monaco.editor.create(this._editor, {
|
|
102
|
+
automaticLayout: true,
|
|
103
|
+
wordWrapColumn: 1000,
|
|
104
|
+
wordWrap: 'wordWrapColumn',
|
|
105
|
+
value: this.code,
|
|
106
|
+
language: 'html',
|
|
107
|
+
minimap: {
|
|
108
|
+
size: 'fill'
|
|
109
|
+
},
|
|
110
|
+
fixedOverflowWidgets: true,
|
|
111
|
+
scrollbar: {
|
|
112
|
+
useShadows: false,
|
|
113
|
+
verticalHasArrows: true,
|
|
114
|
+
horizontalHasArrows: true,
|
|
115
|
+
vertical: 'visible',
|
|
116
|
+
horizontal: 'visible'
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
let changeContentListener = this._monacoEditor.getModel().onDidChangeContent(e => {
|
|
110
120
|
this.onTextChanged.emit(this._monacoEditor.getValue());
|
|
111
121
|
});
|
|
112
|
-
|
|
122
|
+
this._monacoEditor.onDidChangeModel(e => {
|
|
123
|
+
changeContentListener.dispose();
|
|
124
|
+
changeContentListener = this._monacoEditor.getModel().onDidChangeContent(e => {
|
|
125
|
+
this.onTextChanged.emit(this._monacoEditor.getValue());
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
this._monacoEditor.focus();
|
|
129
|
+
resizeObserver.disconnect();
|
|
130
|
+
}
|
|
131
|
+
;
|
|
113
132
|
});
|
|
133
|
+
resizeObserver.observe(this._editor);
|
|
114
134
|
}
|
|
115
135
|
focusEditor() {
|
|
116
136
|
requestAnimationFrame(() => {
|
|
117
137
|
this.focus();
|
|
118
|
-
this._monacoEditor
|
|
138
|
+
if (this._monacoEditor)
|
|
139
|
+
this._monacoEditor.focus();
|
|
119
140
|
});
|
|
120
141
|
}
|
|
121
142
|
activated() {
|
|
122
143
|
if (this._monacoEditor)
|
|
123
|
-
this._monacoEditor
|
|
144
|
+
if (this._monacoEditor)
|
|
145
|
+
this._monacoEditor.layout();
|
|
124
146
|
}
|
|
125
147
|
update(code) {
|
|
126
148
|
this.code = code;
|
|
127
149
|
if (this._monacoEditor) {
|
|
128
|
-
this._monacoEditor
|
|
150
|
+
if (this._monacoEditor)
|
|
151
|
+
this._monacoEditor.setValue(code);
|
|
129
152
|
}
|
|
130
153
|
}
|
|
131
154
|
getText() {
|
|
132
155
|
return this._monacoEditor.getValue();
|
|
133
156
|
}
|
|
134
157
|
setSelection(position) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
158
|
+
if (this._monacoEditor) {
|
|
159
|
+
let model = this._monacoEditor.getModel();
|
|
160
|
+
let point1 = model.getPositionAt(position.start);
|
|
161
|
+
let point2 = model.getPositionAt(position.start + position.length);
|
|
162
|
+
this._monacoEditor.setSelection({ startLineNumber: point1.lineNumber, startColumn: point1.column, endLineNumber: point2.lineNumber, endColumn: point2.column });
|
|
163
|
+
//@ts-ignore
|
|
164
|
+
setTimeout(() => this._monacoEditor.revealRangeInCenter(new monaco.Range(point1.lineNumber, point1.column, point2.lineNumber, point2.column), 1));
|
|
165
|
+
}
|
|
141
166
|
}
|
|
142
167
|
}
|
|
143
168
|
customElements.define('node-projects-code-view-monaco', CodeViewMonaco);
|
|
@@ -12,7 +12,7 @@ export declare class ExtensionManager implements IExtensionManager {
|
|
|
12
12
|
applyExtension(designItem: IDesignItem, extensionType: ExtensionType, recursive?: boolean): IDesignerExtension[];
|
|
13
13
|
applyExtensions(designItems: IDesignItem[], extensionType: ExtensionType, recursive?: boolean): void;
|
|
14
14
|
removeExtension(designItem: IDesignItem, extensionType?: ExtensionType): void;
|
|
15
|
-
removeExtensions(designItems: IDesignItem[], extensionType?: ExtensionType): void;
|
|
15
|
+
removeExtensions(designItems: IDesignItem[], includeChildren: boolean, extensionType?: ExtensionType): void;
|
|
16
16
|
refreshExtension(designItem: IDesignItem, extensionType?: ExtensionType): void;
|
|
17
17
|
refreshExtensions(designItems: IDesignItem[], extensionType?: ExtensionType, ignoredExtension?: any): void;
|
|
18
18
|
refreshAllExtensions(designItems: IDesignItem[], ignoredExtension?: any): void;
|
|
@@ -22,7 +22,7 @@ export class ExtensionManager {
|
|
|
22
22
|
this.applyExtensions(Array.from(this.designerCanvas.rootDesignItem.children()), ExtensionType.Permanent, true);
|
|
23
23
|
break;
|
|
24
24
|
case 'removed':
|
|
25
|
-
this.removeExtensions(contentChanged.designItems, ExtensionType.Permanent);
|
|
25
|
+
this.removeExtensions(contentChanged.designItems, true, ExtensionType.Permanent);
|
|
26
26
|
break;
|
|
27
27
|
}
|
|
28
28
|
});
|
|
@@ -33,7 +33,7 @@ export class ExtensionManager {
|
|
|
33
33
|
const primaryContainer = DesignItem.GetOrCreateDesignItem(selectionChangedEvent.oldSelectedElements[0].parent.element, this.designerCanvas.serviceContainer, this.designerCanvas.instanceServiceContainer);
|
|
34
34
|
this.removeExtension(primaryContainer, ExtensionType.PrimarySelectionContainer);
|
|
35
35
|
this.removeExtension(selectionChangedEvent.oldSelectedElements[0], ExtensionType.PrimarySelection);
|
|
36
|
-
this.removeExtensions(selectionChangedEvent.oldSelectedElements, ExtensionType.Selection);
|
|
36
|
+
this.removeExtensions(selectionChangedEvent.oldSelectedElements, false, ExtensionType.Selection);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
if (selectionChangedEvent.selectedElements && selectionChangedEvent.selectedElements.length) {
|
|
@@ -154,10 +154,13 @@ export class ExtensionManager {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
removeExtensions(designItems, extensionType) {
|
|
157
|
+
removeExtensions(designItems, includeChildren, extensionType) {
|
|
158
158
|
if (designItems) {
|
|
159
159
|
if (extensionType) {
|
|
160
160
|
for (let i of designItems) {
|
|
161
|
+
if (includeChildren && i.hasChildren) {
|
|
162
|
+
this.removeExtensions([...i.children()], true, extensionType);
|
|
163
|
+
}
|
|
161
164
|
i.shouldAppliedDesignerExtensions.delete(extensionType);
|
|
162
165
|
let exts = i.appliedDesignerExtensions.get(extensionType);
|
|
163
166
|
if (exts) {
|
|
@@ -177,6 +180,9 @@ export class ExtensionManager {
|
|
|
177
180
|
}
|
|
178
181
|
else {
|
|
179
182
|
for (let i of designItems) {
|
|
183
|
+
if (includeChildren && i.hasChildren) {
|
|
184
|
+
this.removeExtensions([...i.children()], true, extensionType);
|
|
185
|
+
}
|
|
180
186
|
i.shouldAppliedDesignerExtensions.clear();
|
|
181
187
|
for (let appE of i.appliedDesignerExtensions) {
|
|
182
188
|
for (let e of appE[1]) {
|
|
@@ -5,7 +5,7 @@ export interface IExtensionManager {
|
|
|
5
5
|
applyExtension(designItem: IDesignItem, extensionType: ExtensionType, recursive?: boolean): IDesignerExtension[];
|
|
6
6
|
applyExtensions(designItems: IDesignItem[], extensionType: ExtensionType, recursive?: boolean): any;
|
|
7
7
|
removeExtension(designItem: IDesignItem, extensionType?: ExtensionType): any;
|
|
8
|
-
removeExtensions(designItems: IDesignItem[], extensionType?: ExtensionType): any;
|
|
8
|
+
removeExtensions(designItems: IDesignItem[], includeChildren: boolean, extensionType?: ExtensionType): any;
|
|
9
9
|
refreshExtension(designItem: IDesignItem, extensionType?: ExtensionType): any;
|
|
10
10
|
refreshExtensions(designItems: IDesignItem[], extensionType?: ExtensionType): any;
|
|
11
11
|
refreshAllExtensions(designItems: IDesignItem[], ignoredExtension?: any): any;
|