@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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent nile-elements following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "nile-elements",
6
- "version": "0.0.87",
6
+ "version": "0.0.89",
7
7
  "main": "dist/src/index.js",
8
8
  "type": "module",
9
9
  "module": "dist/src/index.js",
@@ -23,6 +23,9 @@ export const styles = css`
23
23
  border-radius: 5px;
24
24
  border: 1px solid rgb(204, 204, 204);
25
25
  }
26
+ .code-mirror__singleline .cm-scroller{
27
+ scrollbar-width:none;
28
+ }
26
29
 
27
30
  .error {
28
31
  border-color: #e5434d;
@@ -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: any = false;
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
- basicSetup({
118
- lineNumbers: false,
119
- highlightActiveLine: false,
120
- foldGutter: false,
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
- this.setTheme(),
125
+ EditorView.theme(Theme),
129
126
  EditorView.updateListener.of((v: ViewUpdate) => {
130
127
  if (v.docChanged) {
131
- this.emitValues(this.view.state.doc.toString());
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
- changes: {
155
- from: 0,
156
- to: this.view.state.doc.length,
157
- insert: !this.multiline
158
- ? this.convertToSingleLine(this.value)
159
- : this.value,
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
  }
@@ -5,5 +5,7 @@ export const Theme = {
5
5
  fontWeight: '400',
6
6
  },
7
7
  '.cm-content': {},
8
- '.cm-scroller': {},
9
- };
8
+ ".cm-scroller": {
9
+ scrollbarWidth:'thin',
10
+ },
11
+ };