@aquera/nile-elements 0.0.87 → 0.0.89
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 +6 -0
- package/demo/index.html +1 -1
- package/dist/index.iife.js +5 -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.css.cjs.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.css.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.css.esm.js +5 -2
- 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.css.js +3 -0
- package/dist/src/nile-code-editor/nile-code-editor.css.js.map +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 +13 -31
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-code-editor/theme.d.ts +3 -1
- package/dist/src/nile-code-editor/theme.js +3 -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.css.ts +3 -0
- package/src/nile-code-editor/nile-code-editor.ts +24 -49
- package/src/nile-code-editor/theme.ts +4 -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,12 +71,14 @@ 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) {
|
81
|
+
if(!code) return '';
|
80
82
|
// Remove line breaks and unnecessary whitespace
|
81
83
|
return code.replace(/\s+/g, ' ').trim();
|
82
84
|
}
|
@@ -84,10 +86,6 @@ export class NileCodeEditor extends NileElement {
|
|
84
86
|
restrictSingleLineComp = new Compartment();
|
85
87
|
readOnlyComp = new Compartment();
|
86
88
|
|
87
|
-
|
88
|
-
@watch(['value'], { waitUntilFirstUpdate: true })
|
89
|
-
handleValueChange() { }
|
90
|
-
|
91
89
|
getLineNumbersExension() {
|
92
90
|
return this.multiline ? lineNumbers() : [];
|
93
91
|
}
|
@@ -114,24 +112,26 @@ export class NileCodeEditor extends NileElement {
|
|
114
112
|
? this.convertToSingleLine(this.value)
|
115
113
|
: this.value,
|
116
114
|
extensions: [
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
}),
|
115
|
+
basicSetup({
|
116
|
+
highlightActiveLine: false,
|
117
|
+
foldGutter: !!this.multiline,
|
118
|
+
}),
|
122
119
|
lineNumbersExtension,
|
123
120
|
readOnlyExtension,
|
124
121
|
restrictSingleLineExtension,
|
125
122
|
customAutoCompletions,
|
126
123
|
autocompletion(),
|
127
124
|
javascript(),
|
128
|
-
|
125
|
+
EditorView.theme(Theme),
|
129
126
|
EditorView.updateListener.of((v: ViewUpdate) => {
|
130
127
|
if (v.docChanged) {
|
131
|
-
this.
|
128
|
+
this.emit('nile-change', { value: this.view.state.doc.toString() })
|
132
129
|
}
|
133
130
|
}),
|
134
|
-
|
131
|
+
EditorView.domEventHandlers({
|
132
|
+
focus: () => this.dispatchEvent(new Event('nile-focus')),
|
133
|
+
blur: () => this.dispatchEvent(new Event('nile-blur')),
|
134
|
+
}),
|
135
135
|
],
|
136
136
|
});
|
137
137
|
|
@@ -139,26 +139,18 @@ export class NileCodeEditor extends NileElement {
|
|
139
139
|
state: startState,
|
140
140
|
parent: this.codeEditor,
|
141
141
|
});
|
142
|
-
this.addOpenListeners();
|
143
142
|
}
|
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
143
|
|
152
144
|
singleLineMultiLineToggle() {
|
153
145
|
this.view.dispatch({
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
146
|
+
changes: {
|
147
|
+
from: 0,
|
148
|
+
to: this.view.state.doc.length,
|
149
|
+
insert: !this.multiline
|
150
|
+
? this.convertToSingleLine(this.value)
|
151
|
+
: this.value,
|
152
|
+
},
|
153
|
+
});
|
162
154
|
}
|
163
155
|
|
164
156
|
updated(changedProperties: PropertyValues) {
|
@@ -179,23 +171,6 @@ export class NileCodeEditor extends NileElement {
|
|
179
171
|
}
|
180
172
|
}
|
181
173
|
|
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
174
|
expandCodeEditor() {
|
200
175
|
this.emit('nile-expand', { expand: true });
|
201
176
|
}
|