@node-projects/web-component-designer 0.0.141 → 0.0.142

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.
@@ -1,10 +1,10 @@
1
1
  import { BaseServiceContainer } from './BaseServiceContainer';
2
- import { CodeViewMonaco } from "../widgets/codeView/code-view-monaco";
3
2
  import { DemoView } from '../widgets/demoView/demoView';
4
3
  import { GlobalContext } from './GlobalContext';
4
+ import { CodeViewSimple } from "../widgets/codeView/code-view-simple";
5
5
  export class ServiceContainer extends BaseServiceContainer {
6
6
  config = {
7
- codeViewWidget: CodeViewMonaco,
7
+ codeViewWidget: CodeViewSimple,
8
8
  demoViewWidget: DemoView
9
9
  };
10
10
  designerExtensions = new Map();
@@ -0,0 +1,25 @@
1
+ import { BaseCustomWebComponentLazyAppend, TypedEvent } from '@node-projects/base-custom-webcomponent';
2
+ import { ICodeView } from "./ICodeView";
3
+ import { IActivateable } from '../../../interfaces/IActivateable';
4
+ import { IStringPosition } from '../../services/htmlWriterService/IStringPosition';
5
+ import { IUiCommandHandler } from '../../../commandHandling/IUiCommandHandler';
6
+ import { IUiCommand } from '../../../commandHandling/IUiCommand';
7
+ export declare class CodeViewMonaco extends BaseCustomWebComponentLazyAppend implements ICodeView, IActivateable, IUiCommandHandler {
8
+ dispose(): void;
9
+ canvasElement: HTMLElement;
10
+ elementsToPackages: Map<string, string>;
11
+ code: string;
12
+ onTextChanged: TypedEvent<string>;
13
+ private _monacoEditor;
14
+ private _editor;
15
+ static readonly style: CSSStyleSheet;
16
+ static readonly template: HTMLTemplateElement;
17
+ executeCommand(command: IUiCommand): void;
18
+ canExecuteCommand(command: IUiCommand): boolean;
19
+ ready(): Promise<void>;
20
+ focusEditor(): void;
21
+ activated(): void;
22
+ update(code: any): void;
23
+ getText(): string;
24
+ setSelection(position: IStringPosition): void;
25
+ }
@@ -0,0 +1,119 @@
1
+ import { BaseCustomWebComponentLazyAppend, css, html, TypedEvent } from '@node-projects/base-custom-webcomponent';
2
+ import { CommandType } from '../../../commandHandling/CommandType';
3
+ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
4
+ dispose() {
5
+ this._monacoEditor.dispose();
6
+ }
7
+ canvasElement;
8
+ elementsToPackages;
9
+ code;
10
+ onTextChanged = new TypedEvent();
11
+ _monacoEditor;
12
+ _editor;
13
+ static style = css `
14
+ :host {
15
+ display: block;
16
+ height: 100%;
17
+ width: 100%;
18
+ }
19
+ `;
20
+ static template = html `
21
+ <div id="container" style="width: 100%; height: 100%; position: absolute;"></div>
22
+ `;
23
+ executeCommand(command) {
24
+ switch (command.type) {
25
+ case CommandType.undo:
26
+ this._monacoEditor.trigger('source', 'undo', null);
27
+ break;
28
+ case CommandType.redo:
29
+ this._monacoEditor.trigger('source', 'redo', null);
30
+ break;
31
+ case CommandType.copy:
32
+ this._monacoEditor.trigger('source', 'editor.action.clipboardCopyAction', null);
33
+ break;
34
+ case CommandType.paste:
35
+ this._monacoEditor.trigger('source', 'editor.action.clipboardPasteAction', null);
36
+ break;
37
+ case CommandType.cut:
38
+ break;
39
+ case CommandType.delete:
40
+ break;
41
+ }
42
+ }
43
+ canExecuteCommand(command) {
44
+ switch (command.type) {
45
+ case CommandType.undo:
46
+ case CommandType.redo:
47
+ case CommandType.copy:
48
+ case CommandType.paste:
49
+ case CommandType.cut:
50
+ case CommandType.delete:
51
+ return true;
52
+ }
53
+ return false;
54
+ }
55
+ async ready() {
56
+ let style;
57
+ //@ts-ignore
58
+ if (window.importShim)
59
+ //@ts-ignore
60
+ style = await importShim("monaco-editor/min/vs/editor/editor.main.css", { assert: { type: 'css' } });
61
+ else
62
+ //@ts-ignore
63
+ style = await import("monaco-editor/min/vs/editor/editor.main.css", { assert: { type: 'css' } });
64
+ this.shadowRoot.adoptedStyleSheets = [style.default, this.constructor.style];
65
+ this._editor = this._getDomElement('container');
66
+ //@ts-ignore
67
+ require.config({ paths: { 'vs': 'node_modules/monaco-editor/min/vs' } });
68
+ //@ts-ignore
69
+ require(['vs/editor/editor.main'], () => {
70
+ //@ts-ignore
71
+ this._monacoEditor = monaco.editor.create(this._editor, {
72
+ automaticLayout: true,
73
+ value: this.code,
74
+ language: 'html',
75
+ minimap: {
76
+ size: 'fill'
77
+ },
78
+ fixedOverflowWidgets: true
79
+ });
80
+ this._monacoEditor.layout();
81
+ let changeContentListener = this._monacoEditor.getModel().onDidChangeContent(e => {
82
+ this.onTextChanged.emit(this._monacoEditor.getValue());
83
+ });
84
+ this._monacoEditor.onDidChangeModel(e => {
85
+ changeContentListener.dispose();
86
+ changeContentListener = this._monacoEditor.getModel().onDidChangeContent(e => {
87
+ this.onTextChanged.emit(this._monacoEditor.getValue());
88
+ });
89
+ });
90
+ });
91
+ }
92
+ focusEditor() {
93
+ requestAnimationFrame(() => {
94
+ this.focus();
95
+ this._monacoEditor.focus();
96
+ });
97
+ }
98
+ activated() {
99
+ if (this._monacoEditor)
100
+ this._monacoEditor.layout();
101
+ }
102
+ update(code) {
103
+ this.code = code;
104
+ if (this._monacoEditor) {
105
+ this._monacoEditor.setValue(code);
106
+ }
107
+ }
108
+ getText() {
109
+ return this._monacoEditor.getValue();
110
+ }
111
+ setSelection(position) {
112
+ let model = this._monacoEditor.getModel();
113
+ let point1 = model.getPositionAt(position.start);
114
+ let point2 = model.getPositionAt(position.start + position.length);
115
+ this._monacoEditor.setSelection({ startLineNumber: point1.lineNumber, startColumn: point1.column, endLineNumber: point2.lineNumber, endColumn: point2.column });
116
+ setTimeout(() => this._monacoEditor.revealLine(point1.lineNumber), 20);
117
+ }
118
+ }
119
+ customElements.define('node-projects-code-view-monaco', CodeViewMonaco);
@@ -0,0 +1,23 @@
1
+ import { BaseCustomWebComponentConstructorAppend, TypedEvent } from '@node-projects/base-custom-webcomponent';
2
+ import { ICodeView } from "./ICodeView";
3
+ import { IActivateable } from '../../../interfaces/IActivateable';
4
+ import { IStringPosition } from '../../services/htmlWriterService/IStringPosition';
5
+ import { IUiCommandHandler } from '../../../commandHandling/IUiCommandHandler';
6
+ import { IUiCommand } from '../../../commandHandling/IUiCommand';
7
+ export declare class CodeViewSimple extends BaseCustomWebComponentConstructorAppend implements ICodeView, IActivateable, IUiCommandHandler {
8
+ dispose(): void;
9
+ canvasElement: HTMLElement;
10
+ elementsToPackages: Map<string, string>;
11
+ onTextChanged: TypedEvent<string>;
12
+ private _text;
13
+ static readonly style: CSSStyleSheet;
14
+ static readonly template: HTMLTemplateElement;
15
+ executeCommand(command: IUiCommand): void;
16
+ canExecuteCommand(command: IUiCommand): boolean;
17
+ ready(): Promise<void>;
18
+ focusEditor(): void;
19
+ activated(): void;
20
+ update(code: any): void;
21
+ getText(): string;
22
+ setSelection(position: IStringPosition): void;
23
+ }
@@ -0,0 +1,55 @@
1
+ import { BaseCustomWebComponentConstructorAppend, css, html, TypedEvent } from '@node-projects/base-custom-webcomponent';
2
+ export class CodeViewSimple extends BaseCustomWebComponentConstructorAppend {
3
+ dispose() {
4
+ }
5
+ canvasElement;
6
+ elementsToPackages;
7
+ onTextChanged = new TypedEvent();
8
+ _text;
9
+ static style = css `
10
+ :host {
11
+ display: block;
12
+ height: 100%;
13
+ width: 100%;
14
+ }
15
+
16
+ textarea {
17
+ height: 100%;
18
+ width: 100%;
19
+ resize: none;
20
+ white-space: nowrap;
21
+ box-sizing: border-box;
22
+ }
23
+ `;
24
+ static template = html `
25
+ <div id="container" style="width: 100%; height: 100%; position: absolute;">
26
+ <textarea id="text"></textarea>
27
+ </div>
28
+ `;
29
+ executeCommand(command) {
30
+ }
31
+ canExecuteCommand(command) {
32
+ return false;
33
+ }
34
+ async ready() {
35
+ this._text = this._getDomElement('text');
36
+ }
37
+ focusEditor() {
38
+ requestAnimationFrame(() => {
39
+ this.focus();
40
+ this._text.focus();
41
+ });
42
+ }
43
+ activated() {
44
+ }
45
+ update(code) {
46
+ this._text.value = code;
47
+ }
48
+ getText() {
49
+ return this._text.value;
50
+ }
51
+ setSelection(position) {
52
+ this._text.setSelectionRange(position.start, position.start + position.length);
53
+ }
54
+ }
55
+ customElements.define('node-projects-code-view-simple', CodeViewSimple);
package/dist/index.d.ts CHANGED
@@ -215,6 +215,7 @@ export type { ICodeView } from "./elements/widgets/codeView/ICodeView.js";
215
215
  export * from "./elements/widgets/codeView/code-view-monaco.js";
216
216
  export * from "./elements/widgets/codeView/code-view-ace.js";
217
217
  export * from "./elements/widgets/codeView/code-view-code-mirror.js";
218
+ export * from "./elements/widgets/codeView/code-view-simple.js";
218
219
  export * from "./elements/documentContainer.js";
219
220
  export * from "./enums/EventNames.js";
220
221
  export * from "./enums/PointerActionType.js";
package/dist/index.js CHANGED
@@ -167,6 +167,7 @@ export * from "./elements/widgets/treeView/treeViewExtended.js";
167
167
  export * from "./elements/widgets/codeView/code-view-monaco.js";
168
168
  export * from "./elements/widgets/codeView/code-view-ace.js";
169
169
  export * from "./elements/widgets/codeView/code-view-code-mirror.js";
170
+ export * from "./elements/widgets/codeView/code-view-simple.js";
170
171
  export * from "./elements/documentContainer.js";
171
172
  export * from "./enums/EventNames.js";
172
173
  export * from "./enums/PointerActionType.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "A UI designer for Polymer apps",
3
3
  "name": "@node-projects/web-component-designer",
4
- "version": "0.0.141",
4
+ "version": "0.0.142",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",