@node-projects/web-component-designer-codeview-monaco 0.1.18 → 0.1.20
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/README.md
CHANGED
|
@@ -12,20 +12,20 @@ This uses the Monaco Editor for the Webcomponent Designer Codeview
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
serviceContainer.config.codeViewWidget =
|
|
15
|
+
import { CodeViewMonaco } from '@node-projects/web-component-designer-codeview-monaco';
|
|
16
|
+
serviceContainer.config.codeViewWidget = CodeViewMonaco;
|
|
17
17
|
|
|
18
18
|
You need to load the monaco manualy and call
|
|
19
19
|
|
|
20
|
-
await
|
|
20
|
+
await CodeViewMonaco.setMonacoLibrary(...);
|
|
21
21
|
|
|
22
22
|
or via
|
|
23
23
|
|
|
24
|
-
await
|
|
24
|
+
await CodeViewMonaco.loadMonacoEditorViaRequire();
|
|
25
25
|
|
|
26
26
|
or
|
|
27
27
|
|
|
28
|
-
await
|
|
28
|
+
await CodeViewMonaco.loadMonacoEditorViaImport();
|
|
29
29
|
|
|
30
30
|
or
|
|
31
31
|
|
|
@@ -2,6 +2,7 @@ import { BaseCustomWebComponentLazyAppend, TypedEvent } from '@node-projects/bas
|
|
|
2
2
|
import { IActivateable, ICodeView, InstanceServiceContainer, IStringPosition, IUiCommand, IUiCommandHandler } from '@node-projects/web-component-designer';
|
|
3
3
|
import type * as monacoType from 'monaco-editor';
|
|
4
4
|
export declare class CodeViewMonaco extends BaseCustomWebComponentLazyAppend implements ICodeView, IActivateable, IUiCommandHandler {
|
|
5
|
+
#private;
|
|
5
6
|
private static _initalized;
|
|
6
7
|
static monacoLib: {
|
|
7
8
|
editor: typeof monacoType.editor;
|
|
@@ -13,13 +14,18 @@ export declare class CodeViewMonaco extends BaseCustomWebComponentLazyAppend imp
|
|
|
13
14
|
code: string;
|
|
14
15
|
onTextChanged: TypedEvent<string>;
|
|
15
16
|
language: string;
|
|
17
|
+
singleRow: boolean;
|
|
16
18
|
private _theme;
|
|
17
19
|
get theme(): string;
|
|
18
20
|
set theme(value: string);
|
|
21
|
+
get readOnly(): boolean;
|
|
22
|
+
set readOnly(v: boolean);
|
|
19
23
|
static readonly properties: {
|
|
20
24
|
code: StringConstructor;
|
|
21
25
|
language: StringConstructor;
|
|
22
26
|
theme: StringConstructor;
|
|
27
|
+
singleRow: BooleanConstructor;
|
|
28
|
+
readOnly: BooleanConstructor;
|
|
23
29
|
};
|
|
24
30
|
private _monacoEditor;
|
|
25
31
|
private _editor;
|
|
@@ -2,7 +2,6 @@ import { BaseCustomWebComponentLazyAppend, css, cssFromString, html, TypedEvent
|
|
|
2
2
|
import { CommandType } from '@node-projects/web-component-designer';
|
|
3
3
|
export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
4
4
|
static _initalized;
|
|
5
|
-
//@ts-ignore
|
|
6
5
|
static monacoLib;
|
|
7
6
|
dispose() {
|
|
8
7
|
this._monacoEditor?.dispose();
|
|
@@ -12,6 +11,7 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
|
12
11
|
code;
|
|
13
12
|
onTextChanged = new TypedEvent();
|
|
14
13
|
language = 'html';
|
|
14
|
+
singleRow = false;
|
|
15
15
|
_theme = 'webComponentDesignerTheme';
|
|
16
16
|
get theme() {
|
|
17
17
|
return this._theme;
|
|
@@ -22,10 +22,21 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
|
22
22
|
CodeViewMonaco.monacoLib ??= window.monaco;
|
|
23
23
|
CodeViewMonaco.monacoLib.editor.setTheme(value);
|
|
24
24
|
}
|
|
25
|
+
#readOnly = false;
|
|
26
|
+
get readOnly() {
|
|
27
|
+
return this.#readOnly;
|
|
28
|
+
}
|
|
29
|
+
set readOnly(v) {
|
|
30
|
+
this.#readOnly = v;
|
|
31
|
+
if (this._monacoEditor)
|
|
32
|
+
this._monacoEditor.updateOptions({ readOnly: v });
|
|
33
|
+
}
|
|
25
34
|
static properties = {
|
|
26
35
|
code: String,
|
|
27
36
|
language: String,
|
|
28
|
-
theme: String
|
|
37
|
+
theme: String,
|
|
38
|
+
singleRow: Boolean,
|
|
39
|
+
readOnly: Boolean
|
|
29
40
|
};
|
|
30
41
|
_monacoEditor;
|
|
31
42
|
_editor;
|
|
@@ -121,28 +132,36 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
|
121
132
|
this._editor = this._getDomElement('container');
|
|
122
133
|
//@ts-ignore
|
|
123
134
|
CodeViewMonaco.monacoLib ??= window.monaco;
|
|
135
|
+
CodeViewMonaco.initMonacoEditor(CodeViewMonaco.monacoLib);
|
|
124
136
|
const resizeObserver = new ResizeObserver(() => {
|
|
125
137
|
if (this._editor.offsetWidth > 0) {
|
|
126
|
-
|
|
138
|
+
let options = {
|
|
127
139
|
automaticLayout: true,
|
|
128
|
-
wordWrapColumn: 1000,
|
|
129
|
-
//wordWrap: 'wordWrapColumn',
|
|
130
|
-
fontLigatures: '',
|
|
131
|
-
value: this.code,
|
|
132
140
|
language: this.language,
|
|
141
|
+
value: this.code,
|
|
142
|
+
fixedOverflowWidgets: true,
|
|
133
143
|
minimap: {
|
|
134
144
|
size: 'fill'
|
|
135
145
|
},
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
readOnly: this.#readOnly
|
|
147
|
+
};
|
|
148
|
+
if (this.singleRow) {
|
|
149
|
+
options.minimap.enabled = false;
|
|
150
|
+
options.lineNumbers = 'off';
|
|
151
|
+
options.glyphMargin = false;
|
|
152
|
+
options.folding = false;
|
|
153
|
+
options.lineDecorationsWidth = 0;
|
|
154
|
+
options.lineNumbersMinChars = 0;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
options.scrollbar = {};
|
|
158
|
+
options.scrollbar.useShadows = false;
|
|
159
|
+
options.scrollbar.verticalHasArrows = true;
|
|
160
|
+
options.scrollbar.horizontalHasArrows = true;
|
|
161
|
+
options.scrollbar.vertical = 'visible';
|
|
162
|
+
options.scrollbar.horizontal = 'visible';
|
|
163
|
+
}
|
|
164
|
+
this._monacoEditor = CodeViewMonaco.monacoLib.editor.create(this._editor, options);
|
|
146
165
|
let selectionTimeout;
|
|
147
166
|
let disableCursorChange;
|
|
148
167
|
let changeContentListener = this._monacoEditor.getModel().onDidChangeContent(e => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "web-component-designer addon: Code Editor using Monaco",
|
|
3
3
|
"name": "@node-projects/web-component-designer-codeview-monaco",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.20",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/widgets/codeView/code-view-monaco.js",
|
|
7
7
|
"author": "jochen.kuehner@gmx.de",
|