@aquera/nile-elements 0.1.16 → 0.1.17

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.1.16",
6
+ "version": "0.1.17",
7
7
  "main": "dist/src/index.js",
8
8
  "type": "module",
9
9
  "module": "dist/src/index.js",
@@ -21,7 +21,7 @@ import {
21
21
  EditorState,
22
22
  Extension
23
23
  } from '@codemirror/state';
24
-
24
+ import { StyleSpec } from 'style-mod';
25
25
  import {
26
26
  syntaxHighlighting,
27
27
  defaultHighlightStyle,
@@ -39,7 +39,7 @@ import { autocompletion,CompletionContext,CompletionResult } from '@codemirror/a
39
39
  import NileElement from '../internal/nile-element';
40
40
  import { basicSetup } from './extensionSetup';
41
41
  import { classMap } from 'lit/directives/class-map.js';
42
- import { Theme, CustomTheme } from './theme';
42
+ import { Theme as DefaultTheme, CustomTheme } from './theme';
43
43
 
44
44
  // Choose the appropriate mode for your use case
45
45
 
@@ -80,7 +80,7 @@ export class NileCodeEditor extends NileElement {
80
80
 
81
81
  @property({ type: Boolean, reflect: true , attribute: false }) disableSyntaxHighlighting: boolean = false;
82
82
 
83
- @property({ type: Boolean, reflect: true , attribute: false }) useCustomTextFormatting: boolean = false;
83
+ @property({ type: Object, attribute: false }) customThemeCSS: object | null = null;
84
84
 
85
85
  @property({ type: Boolean, reflect: true , attribute: true }) lineNumbersMultiline: boolean = true;
86
86
 
@@ -105,6 +105,7 @@ export class NileCodeEditor extends NileElement {
105
105
  private customCompletionComp = new Compartment();
106
106
  private placeholderComp = new Compartment();
107
107
  private defaultSyntaxHighlightingComp = new Compartment();
108
+ private themeComp = new Compartment();
108
109
 
109
110
  /**
110
111
  * The styles for CodeEditor
@@ -186,6 +187,13 @@ export class NileCodeEditor extends NileElement {
186
187
  ]
187
188
  })
188
189
  }
190
+ if(changedProperties.has('customThemeCSS')){
191
+ this.view.dispatch({
192
+ effects: [
193
+ this.themeComp.reconfigure(this.getCustomThemeExtension())
194
+ ]
195
+ })
196
+ }
189
197
  }
190
198
 
191
199
  public render(): TemplateResult {
@@ -239,6 +247,7 @@ export class NileCodeEditor extends NileElement {
239
247
  const readOnlyExtension = this.readOnlyComp.of(this.getReadOnlyExtension());
240
248
  const restrictSingleLineExtension = this.restrictSingleLineComp.of(this.getSingleLineExtension())
241
249
  const placeholderExtension = this.placeholderComp.of(this.getPlaceholderExtension())
250
+ const customThemeExtension=this.themeComp.of(this.getCustomThemeExtension());
242
251
  const defaultSyntaxHighlightingExtension = this.defaultSyntaxHighlightingComp.of(this.getDefaultSyntaxHighlightingExtension());
243
252
  const language = this.getLanguageExtension()
244
253
  const customAutoCompletions = this.customCompletionComp.of(javascriptLanguage.data.of({
@@ -260,7 +269,7 @@ export class NileCodeEditor extends NileElement {
260
269
  defaultSyntaxHighlightingExtension,
261
270
  autocompletion(),
262
271
  language,
263
- EditorView.theme(this.useCustomTextFormatting?CustomTheme:Theme),
272
+ customThemeExtension,
264
273
  EditorView.updateListener.of((v: ViewUpdate) => {
265
274
  if (v.docChanged) {
266
275
  this.debounce ? this.emitAfterTimeout({ value: this.view.state.doc.toString() }) : this.emit('nile-change', { value: this.view.state.doc.toString() })
@@ -447,6 +456,13 @@ export class NileCodeEditor extends NileElement {
447
456
  return !this.disableSyntaxHighlighting ? syntaxHighlighting(defaultHighlightStyle, { fallback: true }):[]
448
457
  }
449
458
 
459
+ getCustomThemeExtension(): Extension {
460
+ if (this.customThemeCSS) {
461
+ return EditorView.theme(this.customThemeCSS as { [selector: string]: StyleSpec });
462
+ }
463
+ return EditorView.theme(DefaultTheme);
464
+ }
465
+
450
466
  restrictSingleLine() {
451
467
  return EditorState.transactionFilter.of(tr =>
452
468
  tr.newDoc.lines > 1 ? [] : tr
@@ -159,12 +159,12 @@ export const styles = css`
159
159
  height: 24px;
160
160
  display: flex;
161
161
  border-radius: 4px;
162
- border: 1px solid #e5e9eb;
162
+ border: 1px solid var(--nile-colors-neutral-400);
163
163
  background: var(--nile-colors-white-base);
164
164
  }
165
165
 
166
166
  .alert__tag-content {
167
- border-left: 1px solid #e5e9eb;
167
+ border-left: 1px solid var(--nile-colors-neutral-400);
168
168
  display: flex;
169
169
  align-items: center;
170
170
  justify-content: center;
@@ -784,7 +784,7 @@
784
784
  },
785
785
  {
786
786
  "name": "nile-code-editor",
787
- "description": "Nile icon component.\n\nEvents:\n\n * `nile-focus` {`Event`} - \n\n * `nile-blur` {`Event`} - \n\nAttributes:\n\n * `value` {`string`} - \n\n * `expandIcon` {`string`} - \n\n * `placeholder` {`string`} - \n\n * `customAutoCompletions` - \n\n * `customCompletionsPaths` {`string[]`} - \n\n * `language` {`\"html\" | \"javascript\" | \"sql\" | \"json\"`} - \n\n * `error-message` {`string`} - \n\n * `error` {`boolean`} - \n\n * `noborder` {`boolean`} - \n\n * `multiline` {`boolean`} - \n\n * `allowVariableInCustomSuggestion` {`boolean`} - \n\n * `lineNumbers` {`boolean`} - \n\n * `lineNumbersMultiline` {`boolean`} - \n\n * `hasScroller` {`boolean`} - \n\n * `expandable` {`boolean`} - \n\n * `readonly` {`boolean`} - \n\n * `debounce` {`boolean`} - \n\n * `debounceTimeout` {`number`} - \n\nProperties:\n\n * `codeEditor` {`HTMLInputElement`} - \n\n * `value` {`string`} - \n\n * `expandIcon` {`string`} - \n\n * `placeholder` {`string`} - \n\n * `customAutoCompletions` - \n\n * `customCompletionsPaths` {`string[]`} - \n\n * `language` {`\"html\" | \"javascript\" | \"sql\" | \"json\"`} - \n\n * `errorMessage` {`string`} - \n\n * `error` {`boolean`} - \n\n * `noborder` {`boolean`} - \n\n * `multiline` {`boolean`} - \n\n * `allowVariableInCustomSuggestion` {`boolean`} - \n\n * `lineNumbers` {`boolean`} - \n\n * `disableSyntaxHighlighting` {`boolean`} - \n\n * `useCustomTextFormatting` {`boolean`} - \n\n * `lineNumbersMultiline` {`boolean`} - \n\n * `hasScroller` {`boolean`} - \n\n * `expandable` {`boolean`} - \n\n * `readonly` {`boolean`} - \n\n * `debounce` {`boolean`} - \n\n * `debounceTimeout` {`number`} - \n\n * `view` - \n\n * `viewState` - \n\n * `timeOut` - \n\n * `lineNumbersComp` - \n\n * `restrictSingleLineComp` - \n\n * `readOnlyComp` - \n\n * `customCompletionComp` - \n\n * `placeholderComp` - \n\n * `defaultSyntaxHighlightingComp` - \n\n * `customAutocomplete` - Custom autocomplete handler for code editor suggestions\n\n * `insertBetweenCode` - \n\n * `BUBBLES` {`boolean`} - \n\n * `COMPOSED` {`boolean`} - \n\n * `CANCELABLE` {`boolean`} - ",
787
+ "description": "Nile icon component.\n\nEvents:\n\n * `nile-focus` {`Event`} - \n\n * `nile-blur` {`Event`} - \n\nAttributes:\n\n * `value` {`string`} - \n\n * `expandIcon` {`string`} - \n\n * `placeholder` {`string`} - \n\n * `customAutoCompletions` - \n\n * `customCompletionsPaths` {`string[]`} - \n\n * `language` {`\"html\" | \"javascript\" | \"sql\" | \"json\"`} - \n\n * `error-message` {`string`} - \n\n * `error` {`boolean`} - \n\n * `noborder` {`boolean`} - \n\n * `multiline` {`boolean`} - \n\n * `allowVariableInCustomSuggestion` {`boolean`} - \n\n * `lineNumbers` {`boolean`} - \n\n * `lineNumbersMultiline` {`boolean`} - \n\n * `hasScroller` {`boolean`} - \n\n * `expandable` {`boolean`} - \n\n * `readonly` {`boolean`} - \n\n * `debounce` {`boolean`} - \n\n * `debounceTimeout` {`number`} - \n\nProperties:\n\n * `codeEditor` {`HTMLInputElement`} - \n\n * `value` {`string`} - \n\n * `expandIcon` {`string`} - \n\n * `placeholder` {`string`} - \n\n * `customAutoCompletions` - \n\n * `customCompletionsPaths` {`string[]`} - \n\n * `language` {`\"html\" | \"javascript\" | \"sql\" | \"json\"`} - \n\n * `errorMessage` {`string`} - \n\n * `error` {`boolean`} - \n\n * `noborder` {`boolean`} - \n\n * `multiline` {`boolean`} - \n\n * `allowVariableInCustomSuggestion` {`boolean`} - \n\n * `lineNumbers` {`boolean`} - \n\n * `disableSyntaxHighlighting` {`boolean`} - \n\n * `customThemeCSS` {`object | null`} - \n\n * `lineNumbersMultiline` {`boolean`} - \n\n * `hasScroller` {`boolean`} - \n\n * `expandable` {`boolean`} - \n\n * `readonly` {`boolean`} - \n\n * `debounce` {`boolean`} - \n\n * `debounceTimeout` {`number`} - \n\n * `view` - \n\n * `viewState` - \n\n * `timeOut` - \n\n * `lineNumbersComp` - \n\n * `restrictSingleLineComp` - \n\n * `readOnlyComp` - \n\n * `customCompletionComp` - \n\n * `placeholderComp` - \n\n * `defaultSyntaxHighlightingComp` - \n\n * `themeComp` - \n\n * `customAutocomplete` - Custom autocomplete handler for code editor suggestions\n\n * `insertBetweenCode` - \n\n * `BUBBLES` {`boolean`} - \n\n * `COMPOSED` {`boolean`} - \n\n * `CANCELABLE` {`boolean`} - ",
788
788
  "attributes": [
789
789
  {
790
790
  "name": "value",