@aquera/nile-elements 0.0.87 → 0.0.88
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 +3 -0
- package/demo/index.html +1 -1
- package/dist/index.iife.js +2 -2
- package/dist/nile-code-editor/index.cjs.js +1 -1
- package/dist/nile-code-editor/index.esm.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js +2 -2
- package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.esm.js +3 -3
- package/dist/nile-code-editor/theme.cjs.js +1 -1
- package/dist/nile-code-editor/theme.cjs.js.map +1 -1
- package/dist/nile-code-editor/theme.esm.js +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.d.ts +1 -6
- package/dist/src/nile-code-editor/nile-code-editor.js +11 -31
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-code-editor/theme.d.ts +4 -1
- package/dist/src/nile-code-editor/theme.js +2 -1
- package/dist/src/nile-code-editor/theme.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-code-editor/nile-code-editor.ts +23 -49
- package/src/nile-code-editor/theme.ts +3 -2
package/package.json
CHANGED
@@ -50,11 +50,11 @@ export class NileCodeEditor extends NileElement {
|
|
50
50
|
@property({ type: String }) customAutoCompletions: any = {};
|
51
51
|
@property({ type: Boolean }) updateValue: any = false;
|
52
52
|
@property({ attribute: 'error-message' }) errorMessage = '';
|
53
|
-
@property({ attribute: 'error' }) error = false;
|
54
|
-
@property({ attribute: 'noborder' }) noborder = false;
|
53
|
+
@property({ attribute: 'error', type: Boolean }) error = false;
|
54
|
+
@property({ attribute: 'noborder', type:Boolean }) noborder = false;
|
55
55
|
|
56
56
|
@property({ type: Boolean }) expandable: any = false;
|
57
|
-
@property({ type: Boolean }) readonly:
|
57
|
+
@property({ type: Boolean, reflect:true }) readonly: boolean = false;
|
58
58
|
|
59
59
|
/**
|
60
60
|
* The styles for CodeEditor
|
@@ -71,10 +71,11 @@ export class NileCodeEditor extends NileElement {
|
|
71
71
|
|
72
72
|
disconnectedCallback(): void {
|
73
73
|
super.disconnectedCallback();
|
74
|
+
this.view.destroy()
|
74
75
|
this.emit('nile-destroy');
|
75
76
|
}
|
76
77
|
|
77
|
-
view: EditorView;
|
78
|
+
public view: EditorView;
|
78
79
|
|
79
80
|
convertToSingleLine(code: any) {
|
80
81
|
// Remove line breaks and unnecessary whitespace
|
@@ -84,10 +85,6 @@ export class NileCodeEditor extends NileElement {
|
|
84
85
|
restrictSingleLineComp = new Compartment();
|
85
86
|
readOnlyComp = new Compartment();
|
86
87
|
|
87
|
-
|
88
|
-
@watch(['value'], { waitUntilFirstUpdate: true })
|
89
|
-
handleValueChange() { }
|
90
|
-
|
91
88
|
getLineNumbersExension() {
|
92
89
|
return this.multiline ? lineNumbers() : [];
|
93
90
|
}
|
@@ -114,24 +111,26 @@ export class NileCodeEditor extends NileElement {
|
|
114
111
|
? this.convertToSingleLine(this.value)
|
115
112
|
: this.value,
|
116
113
|
extensions: [
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
}),
|
114
|
+
basicSetup({
|
115
|
+
highlightActiveLine: false,
|
116
|
+
foldGutter: !!this.multiline,
|
117
|
+
}),
|
122
118
|
lineNumbersExtension,
|
123
119
|
readOnlyExtension,
|
124
120
|
restrictSingleLineExtension,
|
125
121
|
customAutoCompletions,
|
126
122
|
autocompletion(),
|
127
123
|
javascript(),
|
128
|
-
|
124
|
+
EditorView.theme(Theme),
|
129
125
|
EditorView.updateListener.of((v: ViewUpdate) => {
|
130
126
|
if (v.docChanged) {
|
131
|
-
this.
|
127
|
+
this.emit('nile-change', { value: this.view.state.doc.toString() })
|
132
128
|
}
|
133
129
|
}),
|
134
|
-
|
130
|
+
EditorView.domEventHandlers({
|
131
|
+
focus: () => this.dispatchEvent(new Event('nile-focus')),
|
132
|
+
blur: () => this.dispatchEvent(new Event('nile-blur')),
|
133
|
+
}),
|
135
134
|
],
|
136
135
|
});
|
137
136
|
|
@@ -139,26 +138,18 @@ export class NileCodeEditor extends NileElement {
|
|
139
138
|
state: startState,
|
140
139
|
parent: this.codeEditor,
|
141
140
|
});
|
142
|
-
this.addOpenListeners();
|
143
141
|
}
|
144
|
-
|
145
|
-
|
146
|
-
addOpenListeners() {
|
147
|
-
this.view.contentDOM.addEventListener('blur', () => this.toggleFocusAndBlur('blur'));
|
148
|
-
this.view.contentDOM.addEventListener('focus', () => this.toggleFocusAndBlur('focus'));
|
149
|
-
}
|
150
|
-
|
151
142
|
|
152
143
|
singleLineMultiLineToggle() {
|
153
144
|
this.view.dispatch({
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
145
|
+
changes: {
|
146
|
+
from: 0,
|
147
|
+
to: this.view.state.doc.length,
|
148
|
+
insert: !this.multiline
|
149
|
+
? this.convertToSingleLine(this.value)
|
150
|
+
: this.value,
|
151
|
+
},
|
152
|
+
});
|
162
153
|
}
|
163
154
|
|
164
155
|
updated(changedProperties: PropertyValues) {
|
@@ -179,23 +170,6 @@ export class NileCodeEditor extends NileElement {
|
|
179
170
|
}
|
180
171
|
}
|
181
172
|
|
182
|
-
toggleFocusAndBlur(action: 'blur' | 'focus') {
|
183
|
-
if(action === 'blur'){
|
184
|
-
this.emit('nile-blur', { onBlur : true });
|
185
|
-
}
|
186
|
-
if (action === 'focus') {
|
187
|
-
this.emit('nile-focus', { onFocus : true });
|
188
|
-
}
|
189
|
-
}
|
190
|
-
|
191
|
-
setTheme() {
|
192
|
-
return EditorView.theme(Theme);
|
193
|
-
}
|
194
|
-
|
195
|
-
emitValues(value: string) {
|
196
|
-
this.emit('nile-change', { value: value });
|
197
|
-
}
|
198
|
-
|
199
173
|
expandCodeEditor() {
|
200
174
|
this.emit('nile-expand', { expand: true });
|
201
175
|
}
|