@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/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.88",
7
7
  "main": "dist/src/index.js",
8
8
  "type": "module",
9
9
  "module": "dist/src/index.js",
@@ -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,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
- basicSetup({
118
- lineNumbers: false,
119
- highlightActiveLine: false,
120
- foldGutter: false,
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
- this.setTheme(),
124
+ EditorView.theme(Theme),
129
125
  EditorView.updateListener.of((v: ViewUpdate) => {
130
126
  if (v.docChanged) {
131
- this.emitValues(this.view.state.doc.toString());
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
- 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
- });
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
  }
@@ -1,9 +1,10 @@
1
1
  export const Theme = {
2
2
  '&': {
3
+ width:"100%",
3
4
  fontSize: '14px',
4
5
  fontFamily: 'Colfax-regular',
5
6
  fontWeight: '400',
6
7
  },
7
8
  '.cm-content': {},
8
- '.cm-scroller': {},
9
- };
9
+ ".cm-scroller": {overflow: "hidden"},
10
+ };