@api-client/ui 0.5.19 → 0.5.20
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/build/src/elements/code-editor/internals/CodeEditor.d.ts +4 -8
- package/build/src/elements/code-editor/internals/CodeEditor.d.ts.map +1 -1
- package/build/src/elements/code-editor/internals/CodeEditor.js +13 -33
- package/build/src/elements/code-editor/internals/CodeEditor.js.map +1 -1
- package/demo/elements/code-editor/CodeEditorDemo.ts +7 -21
- package/package.json +1 -2
- package/src/elements/code-editor/README.md +9 -6
- package/src/elements/code-editor/internals/CodeEditor.ts +9 -21
- package/test/elements/code-editor/code-editor.accessibility.test.ts +2 -29
- package/test/elements/code-editor/code-editor.test.ts +10 -13
|
@@ -13,9 +13,9 @@ import '../../../md/button/ui-button.js';
|
|
|
13
13
|
* - Keyboard navigation
|
|
14
14
|
* - Accessibility support
|
|
15
15
|
*
|
|
16
|
-
* @fires
|
|
17
|
-
* @fires
|
|
18
|
-
* @fires
|
|
16
|
+
* @fires functioninsert - When a function is inserted
|
|
17
|
+
* @fires suggestioninsert - When a suggestion is inserted
|
|
18
|
+
* @fires docsrequest - When documentation is requested for a function
|
|
19
19
|
* @fires input - When the editor content changes
|
|
20
20
|
* @fires change - When the editor loses focus and content has changed
|
|
21
21
|
*/
|
|
@@ -74,10 +74,6 @@ export default class CodeEditor extends LitElement {
|
|
|
74
74
|
* Available suggestions for autocomplete
|
|
75
75
|
*/
|
|
76
76
|
accessor suggestions: Suggestion[];
|
|
77
|
-
/**
|
|
78
|
-
* Whether to use dark theme
|
|
79
|
-
*/
|
|
80
|
-
accessor darkTheme: boolean;
|
|
81
77
|
/**
|
|
82
78
|
* Programming language for syntax highlighting
|
|
83
79
|
* @attribute
|
|
@@ -85,7 +81,7 @@ export default class CodeEditor extends LitElement {
|
|
|
85
81
|
accessor language: string;
|
|
86
82
|
/**
|
|
87
83
|
* Whether to show documentation links/buttons in function tooltips and autocomplete
|
|
88
|
-
* @attribute
|
|
84
|
+
* @attribute
|
|
89
85
|
*/
|
|
90
86
|
accessor showDocumentation: boolean;
|
|
91
87
|
private accessor editorContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/CodeEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,cAAc,EAAE,cAAc,EAAW,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/CodeEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,cAAc,EAAE,cAAc,EAAW,MAAM,KAAK,CAAA;AAyB/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAGrE,OAAO,KAAK,EAAuB,UAAU,EAAqD,MAAM,YAAY,CAAA;AACpH,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AAExE,OAAO,iCAAiC,CAAA;AAExC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,UAAU;;IAChD;;;OAGG;IACH,OAAgB,iBAAiB,EAAE,cAAc,CAGhD;IAED;;;OAGG;IAEH,QAAQ,CAAC,KAAK,SAAK;IAEnB;;;OAGG;IAEH,QAAQ,CAAC,cAAc,SAAK;IAE5B;;;OAGG;IAEH,QAAQ,CAAC,QAAQ,UAAQ;IAEzB;;;OAGG;IAEH,QAAQ,CAAC,OAAO,UAAQ;IAExB;;;OAGG;IAEH,QAAQ,CAAC,IAAI,SAAK;IAElB;;;OAGG;IAEH,QAAQ,CAAC,QAAQ,UAAQ;IAEzB;;;OAGG;IAEH,QAAQ,CAAC,WAAW,SAAK;IAOzB;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IACI,KAAK,CAAC,QAAQ,EAAE,MAAM,EAOzB;IAED;;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AQhC;;OAEG;IACH,OAAO,CAAC,6BAA6B;IAQrC;;OAEG;IACM,KAAK,IAAI,IAAI;IAItB;;OAEG;IACH,YAAY,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAMnD;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAUrB,MAAM,IAAI,cAAc;CAgBlC"}
|
|
@@ -7,7 +7,6 @@ import { Compartment, EditorState } from '@codemirror/state';
|
|
|
7
7
|
import { autocompletion, } from '@codemirror/autocomplete';
|
|
8
8
|
import { javascript } from '@codemirror/lang-javascript';
|
|
9
9
|
import { syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language';
|
|
10
|
-
import { oneDark } from '@codemirror/theme-one-dark';
|
|
11
10
|
import { keymap } from '@codemirror/view';
|
|
12
11
|
import { defaultKeymap } from '@codemirror/commands';
|
|
13
12
|
import { EditorView, Decoration, ViewPlugin, hoverTooltip, } from '@codemirror/view';
|
|
@@ -46,9 +45,6 @@ let CodeEditor = (() => {
|
|
|
46
45
|
let _suggestions_decorators;
|
|
47
46
|
let _suggestions_initializers = [];
|
|
48
47
|
let _suggestions_extraInitializers = [];
|
|
49
|
-
let _darkTheme_decorators;
|
|
50
|
-
let _darkTheme_initializers = [];
|
|
51
|
-
let _darkTheme_extraInitializers = [];
|
|
52
48
|
let _language_decorators;
|
|
53
49
|
let _language_initializers = [];
|
|
54
50
|
let _language_extraInitializers = [];
|
|
@@ -68,7 +64,7 @@ let CodeEditor = (() => {
|
|
|
68
64
|
static {
|
|
69
65
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
70
66
|
_label_decorators = [property({ type: String })];
|
|
71
|
-
_supportingText_decorators = [property({ type: String
|
|
67
|
+
_supportingText_decorators = [property({ type: String })];
|
|
72
68
|
_disabled_decorators = [property({ type: Boolean, reflect: true })];
|
|
73
69
|
_invalid_decorators = [property({ type: Boolean, reflect: true })];
|
|
74
70
|
_name_decorators = [property({ type: String })];
|
|
@@ -77,9 +73,8 @@ let CodeEditor = (() => {
|
|
|
77
73
|
_set_value_decorators = [property({ type: String })];
|
|
78
74
|
_functionSchemas_decorators = [property({ type: Array, attribute: false })];
|
|
79
75
|
_suggestions_decorators = [property({ type: Array, attribute: false })];
|
|
80
|
-
_darkTheme_decorators = [property({ type: Boolean, attribute: 'dark-theme' })];
|
|
81
76
|
_language_decorators = [property({ type: String })];
|
|
82
|
-
_showDocumentation_decorators = [property({ type: Boolean
|
|
77
|
+
_showDocumentation_decorators = [property({ type: Boolean })];
|
|
83
78
|
_editorContainer_decorators = [query('.editor-container')];
|
|
84
79
|
_hasContent_decorators = [state()];
|
|
85
80
|
_isEditorFocus_decorators = [state()];
|
|
@@ -93,7 +88,6 @@ let CodeEditor = (() => {
|
|
|
93
88
|
__esDecorate(this, null, _set_value_decorators, { kind: "setter", name: "value", static: false, private: false, access: { has: obj => "value" in obj, set: (obj, value) => { obj.value = value; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
94
89
|
__esDecorate(this, null, _functionSchemas_decorators, { kind: "accessor", name: "functionSchemas", static: false, private: false, access: { has: obj => "functionSchemas" in obj, get: obj => obj.functionSchemas, set: (obj, value) => { obj.functionSchemas = value; } }, metadata: _metadata }, _functionSchemas_initializers, _functionSchemas_extraInitializers);
|
|
95
90
|
__esDecorate(this, null, _suggestions_decorators, { kind: "accessor", name: "suggestions", static: false, private: false, access: { has: obj => "suggestions" in obj, get: obj => obj.suggestions, set: (obj, value) => { obj.suggestions = value; } }, metadata: _metadata }, _suggestions_initializers, _suggestions_extraInitializers);
|
|
96
|
-
__esDecorate(this, null, _darkTheme_decorators, { kind: "accessor", name: "darkTheme", static: false, private: false, access: { has: obj => "darkTheme" in obj, get: obj => obj.darkTheme, set: (obj, value) => { obj.darkTheme = value; } }, metadata: _metadata }, _darkTheme_initializers, _darkTheme_extraInitializers);
|
|
97
91
|
__esDecorate(this, null, _language_decorators, { kind: "accessor", name: "language", static: false, private: false, access: { has: obj => "language" in obj, get: obj => obj.language, set: (obj, value) => { obj.language = value; } }, metadata: _metadata }, _language_initializers, _language_extraInitializers);
|
|
98
92
|
__esDecorate(this, null, _showDocumentation_decorators, { kind: "accessor", name: "showDocumentation", static: false, private: false, access: { has: obj => "showDocumentation" in obj, get: obj => obj.showDocumentation, set: (obj, value) => { obj.showDocumentation = value; } }, metadata: _metadata }, _showDocumentation_initializers, _showDocumentation_extraInitializers);
|
|
99
93
|
__esDecorate(this, null, _editorContainer_decorators, { kind: "accessor", name: "editorContainer", static: false, private: false, access: { has: obj => "editorContainer" in obj, get: obj => obj.editorContainer, set: (obj, value) => { obj.editorContainer = value; } }, metadata: _metadata }, _editorContainer_initializers, _editorContainer_extraInitializers);
|
|
@@ -222,7 +216,8 @@ let CodeEditor = (() => {
|
|
|
222
216
|
set functionSchemas(value) { this.#functionSchemas_accessor_storage = value; }
|
|
223
217
|
#suggestions_accessor_storage = (__runInitializers(this, _functionSchemas_extraInitializers), __runInitializers(this, _suggestions_initializers, []
|
|
224
218
|
/**
|
|
225
|
-
*
|
|
219
|
+
* Programming language for syntax highlighting
|
|
220
|
+
* @attribute
|
|
226
221
|
*/
|
|
227
222
|
));
|
|
228
223
|
/**
|
|
@@ -230,21 +225,10 @@ let CodeEditor = (() => {
|
|
|
230
225
|
*/
|
|
231
226
|
get suggestions() { return this.#suggestions_accessor_storage; }
|
|
232
227
|
set suggestions(value) { this.#suggestions_accessor_storage = value; }
|
|
233
|
-
#
|
|
234
|
-
/**
|
|
235
|
-
* Programming language for syntax highlighting
|
|
236
|
-
* @attribute
|
|
237
|
-
*/
|
|
238
|
-
));
|
|
239
|
-
/**
|
|
240
|
-
* Whether to use dark theme
|
|
241
|
-
*/
|
|
242
|
-
get darkTheme() { return this.#darkTheme_accessor_storage; }
|
|
243
|
-
set darkTheme(value) { this.#darkTheme_accessor_storage = value; }
|
|
244
|
-
#language_accessor_storage = (__runInitializers(this, _darkTheme_extraInitializers), __runInitializers(this, _language_initializers, 'javascript'
|
|
228
|
+
#language_accessor_storage = (__runInitializers(this, _suggestions_extraInitializers), __runInitializers(this, _language_initializers, 'javascript'
|
|
245
229
|
/**
|
|
246
230
|
* Whether to show documentation links/buttons in function tooltips and autocomplete
|
|
247
|
-
* @attribute
|
|
231
|
+
* @attribute
|
|
248
232
|
*/
|
|
249
233
|
));
|
|
250
234
|
/**
|
|
@@ -256,7 +240,7 @@ let CodeEditor = (() => {
|
|
|
256
240
|
#showDocumentation_accessor_storage = (__runInitializers(this, _language_extraInitializers), __runInitializers(this, _showDocumentation_initializers, false));
|
|
257
241
|
/**
|
|
258
242
|
* Whether to show documentation links/buttons in function tooltips and autocomplete
|
|
259
|
-
* @attribute
|
|
243
|
+
* @attribute
|
|
260
244
|
*/
|
|
261
245
|
get showDocumentation() { return this.#showDocumentation_accessor_storage; }
|
|
262
246
|
set showDocumentation(value) { this.#showDocumentation_accessor_storage = value; }
|
|
@@ -354,10 +338,6 @@ let CodeEditor = (() => {
|
|
|
354
338
|
if (this.language === 'javascript') {
|
|
355
339
|
extensions.push(javascript());
|
|
356
340
|
}
|
|
357
|
-
// Add theme
|
|
358
|
-
if (this.darkTheme) {
|
|
359
|
-
extensions.push(oneDark);
|
|
360
|
-
}
|
|
361
341
|
// Add placeholder
|
|
362
342
|
if (this.placeholder) {
|
|
363
343
|
extensions.push(EditorView.contentAttributes.of({
|
|
@@ -620,7 +600,7 @@ let CodeEditor = (() => {
|
|
|
620
600
|
* Dispatch function insert event
|
|
621
601
|
*/
|
|
622
602
|
dispatchFunctionInsert(functionSchema, position) {
|
|
623
|
-
const event = new CustomEvent('
|
|
603
|
+
const event = new CustomEvent('functioninsert', {
|
|
624
604
|
detail: { functionSchema, position },
|
|
625
605
|
bubbles: true,
|
|
626
606
|
});
|
|
@@ -630,7 +610,7 @@ let CodeEditor = (() => {
|
|
|
630
610
|
* Dispatch suggestion insert event
|
|
631
611
|
*/
|
|
632
612
|
dispatchSuggestionInsert(suggestion, position) {
|
|
633
|
-
const event = new CustomEvent('
|
|
613
|
+
const event = new CustomEvent('suggestioninsert', {
|
|
634
614
|
detail: { suggestion, position },
|
|
635
615
|
bubbles: true,
|
|
636
616
|
});
|
|
@@ -640,7 +620,7 @@ let CodeEditor = (() => {
|
|
|
640
620
|
* Dispatch function documentation event
|
|
641
621
|
*/
|
|
642
622
|
dispatchFunctionDocumentation(functionSchema) {
|
|
643
|
-
const event = new CustomEvent('
|
|
623
|
+
const event = new CustomEvent('docsrequest', {
|
|
644
624
|
detail: { functionSchema },
|
|
645
625
|
bubbles: true,
|
|
646
626
|
});
|
|
@@ -700,9 +680,9 @@ let CodeEditor = (() => {
|
|
|
700
680
|
* - Keyboard navigation
|
|
701
681
|
* - Accessibility support
|
|
702
682
|
*
|
|
703
|
-
* @fires
|
|
704
|
-
* @fires
|
|
705
|
-
* @fires
|
|
683
|
+
* @fires functioninsert - When a function is inserted
|
|
684
|
+
* @fires suggestioninsert - When a suggestion is inserted
|
|
685
|
+
* @fires docsrequest - When documentation is requested for a function
|
|
706
686
|
* @fires input - When the editor content changes
|
|
707
687
|
* @fires change - When the editor loses focus and content has changed
|
|
708
688
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeEditor.js","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/CodeEditor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAkC,OAAO,EAAE,MAAM,KAAK,CAAA;AAC/E,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAa,MAAM,mBAAmB,CAAA;AACvE,OAAO,EACL,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IAAI,CAAC,aAAa,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;;YAEtF,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAA,sBAAsB,IAAI,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO;;;;;UAKnE,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAA,gCAAgC,IAAI,CAAC,cAAc,QAAQ,CAAC,CAAC,CAAC,OAAO;;KAElG,CAAA;QACH,CAAC;;;AA3mBH;;;;;;;;;;;;;;;GAeG;AACH","sourcesContent":["import { html, LitElement, PropertyValues, TemplateResult, nothing } from 'lit'\nimport { property, query, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { linter } from '@codemirror/lint'\nimport { Compartment, EditorState, Extension } from '@codemirror/state'\nimport {\n autocompletion,\n CompletionContext,\n type CompletionResult,\n type CompletionSource,\n type Completion,\n} from '@codemirror/autocomplete'\nimport { javascript } from '@codemirror/lang-javascript'\nimport { syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language'\nimport { oneDark } from '@codemirror/theme-one-dark'\nimport { keymap } from '@codemirror/view'\nimport { defaultKeymap } from '@codemirror/commands'\nimport {\n EditorView,\n Decoration,\n DecorationSet,\n ViewPlugin,\n ViewUpdate,\n hoverTooltip,\n type Tooltip,\n} from '@codemirror/view'\nimport type { FunctionSchema } from '@pawel-up/jexl/schemas/types.js'\nimport { getTypeStringFromSchema } from '@pawel-up/jexl/schemas/utils.js'\nimport { functionLinter } from './Linter.js'\nimport type { FunctionInsertEvent, Suggestion, SuggestionInsertEvent, FunctionDocumentationEvent } from './types.js'\nimport { SuggestionMatchDecorator } from './SuggestionMatchDecorator.js'\n\nimport '../../../md/button/ui-button.js'\n\n/**\n * A CodeMirror 6 based editor component that supports function autocomplete and suggestion placeholders.\n *\n * Features:\n * - Dynamic function schema loading\n * - Autocomplete for functions and suggestions\n * - Suggestion placeholders with double curly braces ({{suggestion}})\n * - Keyboard navigation\n * - Accessibility support\n *\n * @fires function-insert - When a function is inserted\n * @fires suggestion-insert - When a suggestion is inserted\n * @fires function-documentation - When documentation is requested for a function\n * @fires input - When the editor content changes\n * @fires change - When the editor loses focus and content has changed\n */\nexport default class CodeEditor extends LitElement {\n /**\n * Shadow root configuration for the component.\n * Uses 'open' mode for accessibility and delegates focus to enable proper focus management.\n */\n static override shadowRootOptions: ShadowRootInit = {\n mode: 'open',\n delegatesFocus: true,\n }\n\n /**\n * The label text displayed as placeholder/floating label\n * @attribute\n */\n @property({ type: String })\n accessor label = ''\n\n /**\n * Supporting text displayed below the editor\n * @attribute\n */\n @property({ type: String, attribute: 'supporting-text' })\n accessor supportingText = ''\n\n /**\n * Whether the component is disabled\n * @attribute\n */\n @property({ type: Boolean, reflect: true })\n accessor disabled = false\n\n /**\n * Whether the component is in an invalid state\n * @attribute\n */\n @property({ type: Boolean, reflect: true })\n accessor invalid = false\n\n /**\n * The name attribute for form integration\n * @attribute\n */\n @property({ type: String })\n accessor name = ''\n\n /**\n * Whether the input is required\n * @attribute\n */\n @property({ type: Boolean })\n accessor required = false\n\n /**\n * Placeholder text shown when editor is empty\n * @attribute\n */\n @property({ type: String })\n accessor placeholder = ''\n\n /**\n * This property is used internally to set value without triggering updates.\n */\n #value = ''\n\n /**\n * The editor content value\n */\n get value(): string {\n return this.#value\n }\n\n @property({ type: String })\n set value(newValue: string) {\n const oldValue = this.#value\n if (newValue !== oldValue) {\n this.#value = newValue\n this._previousValue = newValue\n this.requestUpdate('value', oldValue)\n }\n }\n\n /**\n * Available function schemas for autocomplete\n */\n @property({ type: Array, attribute: false })\n accessor functionSchemas: FunctionSchema[] = []\n\n /**\n * Available suggestions for autocomplete\n */\n @property({ type: Array, attribute: false })\n accessor suggestions: Suggestion[] = []\n\n /**\n * Whether to use dark theme\n */\n @property({ type: Boolean, attribute: 'dark-theme' })\n accessor darkTheme = false\n\n /**\n * Programming language for syntax highlighting\n * @attribute\n */\n @property({ type: String })\n accessor language = 'javascript'\n\n /**\n * Whether to show documentation links/buttons in function tooltips and autocomplete\n * @attribute show-documentation\n */\n @property({ type: Boolean, attribute: 'show-documentation' })\n accessor showDocumentation = false\n\n @query('.editor-container')\n private accessor editorContainer!: HTMLDivElement\n\n @state()\n private accessor hasContent = false\n\n @state()\n private accessor isEditorFocus = false\n\n private editorView?: EditorView\n /**\n * A control value to track previous value of the editor.\n * This is used to detect when change event should be dispatched.\n */\n private _previousValue = ''\n /**\n * Matcher for suggestion placeholders in the editor.\n */\n placeholderMatcher?: SuggestionMatchDecorator\n\n /**\n * Get all suggestions (placeholders) currently in the editor\n */\n get activeSuggestions(): Suggestion[] {\n const suggestions: Suggestion[] = []\n const placeholderPattern = /\\{\\{([^}]+)\\}\\}/g\n let match: RegExpExecArray | null\n while ((match = placeholderPattern.exec(this.value)) !== null) {\n const placeholderText = match[1]\n // Find suggestion by id\n const suggestion = this.suggestions.find((s) => s.id === placeholderText)\n if (suggestion) {\n suggestions.push(suggestion)\n }\n }\n return suggestions\n }\n\n private readonlyState = new Compartment()\n\n override disconnectedCallback(): void {\n super.disconnectedCallback()\n this.editorView?.destroy()\n }\n\n override firstUpdated(): void {\n this.initializeCodeMirror()\n this.updateEditorContent()\n }\n\n override willUpdate(changedProperties: PropertyValues): void {\n super.willUpdate(changedProperties)\n\n if (changedProperties.has('suggestions')) {\n if (this.placeholderMatcher) {\n this.placeholderMatcher.suggestions = this.suggestions || []\n }\n }\n\n if (changedProperties.has('value') && this.editorView) {\n this.updateEditorContent()\n }\n\n if (changedProperties.has('disabled')) {\n this.editorView?.dispatch({\n effects: this.readonlyState.reconfigure(EditorState.readOnly.of(this.disabled)),\n })\n }\n }\n\n /**\n * Initialize CodeMirror editor with extensions\n */\n private initializeCodeMirror(): void {\n const extensions: Extension[] = [\n keymap.of(defaultKeymap),\n syntaxHighlighting(defaultHighlightStyle),\n autocompletion({\n override: [this.createCompletionSource()],\n activateOnTyping: true,\n maxRenderedOptions: 10,\n }),\n EditorView.updateListener.of((update: ViewUpdate) => {\n if (update.docChanged) {\n this.handleEditorChange()\n }\n if (update.focusChanged) {\n this.handleFocusChange(update.view.hasFocus)\n } else if (update.view.hasFocus !== this.isEditorFocus) {\n // If focus state changed without focusChanged event, update manually\n this.handleFocusChange(update.view.hasFocus)\n }\n }),\n this.createPlaceholderPlugin(),\n hoverTooltip(this.createHoverTooltipSource),\n linter((view) => functionLinter(view, this.functionSchemas, (e) => this.dispatchEvent(e))),\n this.readonlyState.of(EditorState.readOnly.of(this.disabled)),\n ]\n\n // Add language support\n if (this.language === 'javascript') {\n extensions.push(javascript())\n }\n\n // Add theme\n if (this.darkTheme) {\n extensions.push(oneDark)\n }\n\n // Add placeholder\n if (this.placeholder) {\n extensions.push(\n EditorView.contentAttributes.of({\n 'aria-placeholder': this.placeholder,\n })\n )\n }\n\n const state = EditorState.create({\n doc: this.value,\n extensions,\n })\n\n this.editorView = new EditorView({\n state,\n parent: this.editorContainer,\n })\n }\n\n /**\n * Creates the ViewPlugin for rendering suggestion placeholders.\n * This is created as a method to get access to the component's `suggestions`.\n */\n private createPlaceholderPlugin(): Extension {\n const placeholderMatcher = new SuggestionMatchDecorator(/\\{\\{([^}]+)\\}\\}/g, this.suggestions)\n this.placeholderMatcher = placeholderMatcher\n // This class needs to be defined here to have access to the `placeholderMatcher`\n class AtomicDecorationRange {\n placeholders: DecorationSet\n constructor(view: EditorView) {\n this.placeholders = placeholderMatcher.createDeco(view)\n }\n update(update: ViewUpdate) {\n this.placeholders = placeholderMatcher.updateDeco(update, this.placeholders)\n }\n }\n\n return ViewPlugin.fromClass(AtomicDecorationRange, {\n decorations: (instance) => instance.placeholders,\n provide: (plugin) => EditorView.atomicRanges.of((view) => view.plugin(plugin)?.placeholders || Decoration.none),\n })\n }\n\n /**\n * Create completion source for functions and suggestions\n */\n private createCompletionSource(): CompletionSource {\n return (context: CompletionContext): CompletionResult | null => {\n const { pos } = context\n const line = context.state.doc.lineAt(pos)\n const textBefore = line.text.slice(0, pos - line.from)\n\n // Check if we're typing a function name\n const functionMatch = textBefore.match(/(\\w+)$/)\n if (functionMatch) {\n const prefix = functionMatch[1]\n const functions = this.functionSchemas\n .filter((fn) => fn.name.toLowerCase().startsWith(prefix.toLowerCase()))\n .map((fn) => this.createFunctionCompletion(fn))\n\n if (functions.length > 0) {\n return {\n from: pos - prefix.length,\n options: functions,\n }\n }\n }\n\n // Check if we're typing a suggestion trigger (e.g., {{)\n const suggestionMatch = textBefore.match(/\\{\\{([^}]*)$/)\n if (suggestionMatch) {\n const prefix = suggestionMatch[1]\n const suggestions = this.suggestions\n .filter((suggestion) => suggestion.label.toLowerCase().startsWith(prefix.toLowerCase()))\n .map((suggestion) => this.createSuggestionCompletion(suggestion))\n\n if (suggestions.length > 0) {\n return {\n from: pos - prefix.length,\n options: suggestions,\n }\n }\n }\n\n return null\n }\n }\n\n private createFunctionCompletion(schema: FunctionSchema): Completion {\n const result: Completion = {\n label: schema.name,\n detail: schema.description || '',\n type: 'function',\n info: () => this.createFunctionInfoElement(schema),\n apply: (view: EditorView, completion: unknown, from: number, to: number) => {\n const functionCall = this.formatFunctionCall(schema)\n view.dispatch({\n changes: { from, to, insert: functionCall },\n selection: { anchor: from + functionCall.length },\n })\n this.dispatchFunctionInsert(schema, from)\n },\n }\n\n return result\n }\n\n private createSuggestionCompletion(suggestion: Suggestion): Completion {\n const result: Completion = {\n label: suggestion.label,\n detail: suggestion.description || '',\n info: suggestion.suffix || '',\n type: 'variable',\n apply: (view: EditorView, completion: unknown, from: number, to: number) => {\n const placeholderText = `{{${suggestion.id}}}`\n view.dispatch({\n changes: { from: from - 2, to, insert: placeholderText }, // -2 to include the {{\n selection: { anchor: from - 2 + placeholderText.length },\n })\n this.dispatchSuggestionInsert(suggestion, from - 2)\n },\n }\n\n return result\n }\n\n /**\n * Creates the source for the hover tooltips.\n * This is an arrow function to automatically bind `this`.\n */\n private createHoverTooltipSource = (view: EditorView, pos: number): Tooltip | null => {\n const word = view.state.wordAt(pos)\n if (!word) {\n return null\n }\n\n const functionName = view.state.doc.sliceString(word.from, word.to)\n const fnSchema = this.functionSchemas.find((schema) => schema.name === functionName)\n\n if (!fnSchema) {\n return null\n }\n\n return {\n pos: word.from,\n end: word.to,\n above: true,\n create: () => ({ dom: this.createFunctionInfoElement(fnSchema) }),\n }\n }\n\n /**\n * Creates a styled HTML element to display function documentation.\n * This is used for both hover tooltips and autocomplete info panels.\n */\n protected createFunctionInfoElement(fn: FunctionSchema): HTMLElement {\n const container = document.createElement('div')\n container.className = 'function-info' // for styling\n\n if (fn.description) {\n const description = document.createElement('p')\n description.className = 'description'\n description.textContent = fn.description\n container.appendChild(description)\n }\n\n if (fn.parameters && fn.parameters.length > 0) {\n const paramsContainer = document.createElement('div')\n paramsContainer.className = 'parameters'\n\n const paramsHeader = document.createElement('h4')\n paramsHeader.textContent = 'Parameters'\n paramsContainer.appendChild(paramsHeader)\n\n const paramsList = document.createElement('ul')\n fn.parameters.forEach((param) => {\n const listItem = document.createElement('li')\n\n const name = document.createElement('span')\n name.className = 'param-name'\n name.textContent = param.name\n\n const type = document.createElement('span')\n type.className = 'param-type'\n type.textContent = `: ${getTypeStringFromSchema(param.schema)}`\n\n listItem.appendChild(name)\n listItem.appendChild(type)\n\n if (param.schema.description) {\n const paramDesc = document.createElement('p')\n paramDesc.className = 'param-description'\n paramDesc.textContent = param.schema.description\n listItem.appendChild(paramDesc)\n }\n paramsList.appendChild(listItem)\n })\n paramsContainer.appendChild(paramsList)\n container.appendChild(paramsContainer)\n }\n\n if (fn.returns) {\n const returnsContainer = document.createElement('div')\n returnsContainer.className = 'returns'\n\n const returnsHeader = document.createElement('h4')\n returnsHeader.textContent = 'Returns'\n returnsContainer.appendChild(returnsHeader)\n\n const returnsDesc = document.createElement('p')\n const returnType = getTypeStringFromSchema(fn.returns)\n returnsDesc.textContent = fn.returns.description ? `${returnType}: ${fn.returns.description}` : returnType\n returnsContainer.appendChild(returnsDesc)\n container.appendChild(returnsContainer)\n }\n\n // Add documentation button if showDocumentation is enabled\n if (this.showDocumentation) {\n const docContainer = document.createElement('div')\n docContainer.className = 'documentation'\n\n const docButton = document.createElement('ui-button')\n docButton.type = 'button'\n docButton.className = 'documentation-button'\n docButton.textContent = 'Show documentation'\n docButton.setAttribute('aria-label', `Show documentation for ${fn.name} function`)\n\n docButton.addEventListener('click', (event) => {\n event.preventDefault()\n event.stopPropagation()\n this.dispatchFunctionDocumentation(fn)\n })\n\n docContainer.appendChild(docButton)\n container.appendChild(docContainer)\n }\n\n return container\n }\n\n /**\n * Format function call with parameters\n */\n private formatFunctionCall(fn: FunctionSchema): string {\n if (!fn.parameters || fn.parameters.length === 0) {\n return `${fn.name}()`\n }\n\n const params = fn.parameters\n .map((param) => {\n if (param.required) {\n return param.name\n }\n return `${param.name}?`\n })\n .join(', ')\n\n return `${fn.name}(${params})`\n }\n\n /**\n * Update editor content when value changes\n */\n private updateEditorContent(): void {\n if (!this.editorView) return\n\n const currentValue = this.editorView.state.doc.toString()\n if (currentValue !== this.value) {\n this.editorView.dispatch({\n changes: {\n from: 0,\n to: this.editorView.state.doc.length,\n insert: this.value,\n },\n })\n }\n }\n\n /**\n * Handle editor content change\n */\n private handleEditorChange(): void {\n if (!this.editorView) return\n\n const newValue = this.editorView.state.doc.toString()\n this.#value = newValue\n this.hasContent = newValue.length > 0\n\n this.dispatchEvent(new Event('input', { bubbles: true }))\n }\n\n /**\n * Handle focus change\n */\n private handleFocusChange(hasFocus: boolean): void {\n this.isEditorFocus = hasFocus\n\n if (!hasFocus && this.#value !== this._previousValue) {\n this._previousValue = this.#value\n this.dispatchEvent(new Event('change'))\n }\n }\n\n /**\n * Dispatch function insert event\n */\n private dispatchFunctionInsert(functionSchema: FunctionSchema, position: number): void {\n const event = new CustomEvent<FunctionInsertEvent>('function-insert', {\n detail: { functionSchema, position },\n bubbles: true,\n })\n this.dispatchEvent(event)\n }\n\n /**\n * Dispatch suggestion insert event\n */\n private dispatchSuggestionInsert(suggestion: Suggestion, position: number): void {\n const event = new CustomEvent<SuggestionInsertEvent>('suggestion-insert', {\n detail: { suggestion, position },\n bubbles: true,\n })\n this.dispatchEvent(event)\n }\n\n /**\n * Dispatch function documentation event\n */\n private dispatchFunctionDocumentation(functionSchema: FunctionSchema): void {\n const event = new CustomEvent<FunctionDocumentationEvent>('function-documentation', {\n detail: { functionSchema },\n bubbles: true,\n })\n this.dispatchEvent(event)\n }\n\n /**\n * Focus the editor\n */\n override focus(): void {\n this.editorView?.focus()\n }\n\n /**\n * Get the editor's current selection\n */\n getSelection(): { from: number; to: number } | null {\n if (!this.editorView) return null\n const { from, to } = this.editorView.state.selection.main\n return { from, to }\n }\n\n /**\n * Insert text at the current cursor position\n */\n insertText(text: string): void {\n if (!this.editorView) return\n\n const { from, to } = this.editorView.state.selection.main\n this.editorView.dispatch({\n changes: { from, to, insert: text },\n selection: { anchor: from + text.length },\n })\n }\n\n override render(): TemplateResult {\n const hasLabel = !!this.label\n const hasSupportingText = !!this.supportingText\n\n return html`\n <div class=\"surface ${classMap({ 'has-focus': this.isEditorFocus, 'invalid': this.invalid })}\">\n <div class=\"content\">\n ${hasLabel ? html`<div class=\"label\">${this.label}</div>` : nothing}\n\n <div class=\"editor-container\" part=\"editor\"></div>\n </div>\n\n ${hasSupportingText ? html`<div class=\"supporting-text\">${this.supportingText}</div>` : nothing}\n </div>\n `\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CodeEditor.js","sourceRoot":"","sources":["../../../../../src/elements/code-editor/internals/CodeEditor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAkC,OAAO,EAAE,MAAM,KAAK,CAAA;AAC/E,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAa,MA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AE,OAAO,IAAI,CAAA;YACjC,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAA;YACzD,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAA;QACrB,CAAC;QAED;;WAEG;QACH,UAAU,CAAC,IAAY;YACrB,IAAI,CAAC,IAAI,CAAC,UAAU;gBAAE,OAAM;YAE5B,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAA;YACzD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;gBACvB,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;gBACnC,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE;aAC1C,CAAC,CAAA;QACJ,CAAC;QAEQ,MAAM;YACb,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAA;YAC7B,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAA;YAE/C,OAAO,IAAI,CAAA;4BACa,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;;YAEtF,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAA,sBAAsB,IAAI,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO;;;;;UAKnE,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAA,gCAAgC,IAAI,CAAC,cAAc,QAAQ,CAAC,CAAC,CAAC,OAAO;;KAElG,CAAA;QACH,CAAC;;;AAhmBH;;;;;;;;;;;;;;;GAeG;AACH","sourcesContent":["import { html, LitElement, PropertyValues, TemplateResult, nothing } from 'lit'\nimport { property, query, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { linter } from '@codemirror/lint'\nimport { Compartment, EditorState, Extension } from '@codemirror/state'\nimport {\n autocompletion,\n CompletionContext,\n type CompletionResult,\n type CompletionSource,\n type Completion,\n} from '@codemirror/autocomplete'\nimport { javascript } from '@codemirror/lang-javascript'\nimport { syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language'\nimport { keymap } from '@codemirror/view'\nimport { defaultKeymap } from '@codemirror/commands'\nimport {\n EditorView,\n Decoration,\n DecorationSet,\n ViewPlugin,\n ViewUpdate,\n hoverTooltip,\n type Tooltip,\n} from '@codemirror/view'\nimport type { FunctionSchema } from '@pawel-up/jexl/schemas/types.js'\nimport { getTypeStringFromSchema } from '@pawel-up/jexl/schemas/utils.js'\nimport { functionLinter } from './Linter.js'\nimport type { FunctionInsertEvent, Suggestion, SuggestionInsertEvent, FunctionDocumentationEvent } from './types.js'\nimport { SuggestionMatchDecorator } from './SuggestionMatchDecorator.js'\n\nimport '../../../md/button/ui-button.js'\n\n/**\n * A CodeMirror 6 based editor component that supports function autocomplete and suggestion placeholders.\n *\n * Features:\n * - Dynamic function schema loading\n * - Autocomplete for functions and suggestions\n * - Suggestion placeholders with double curly braces ({{suggestion}})\n * - Keyboard navigation\n * - Accessibility support\n *\n * @fires functioninsert - When a function is inserted\n * @fires suggestioninsert - When a suggestion is inserted\n * @fires docsrequest - When documentation is requested for a function\n * @fires input - When the editor content changes\n * @fires change - When the editor loses focus and content has changed\n */\nexport default class CodeEditor extends LitElement {\n /**\n * Shadow root configuration for the component.\n * Uses 'open' mode for accessibility and delegates focus to enable proper focus management.\n */\n static override shadowRootOptions: ShadowRootInit = {\n mode: 'open',\n delegatesFocus: true,\n }\n\n /**\n * The label text displayed as placeholder/floating label\n * @attribute\n */\n @property({ type: String })\n accessor label = ''\n\n /**\n * Supporting text displayed below the editor\n * @attribute\n */\n @property({ type: String })\n accessor supportingText = ''\n\n /**\n * Whether the component is disabled\n * @attribute\n */\n @property({ type: Boolean, reflect: true })\n accessor disabled = false\n\n /**\n * Whether the component is in an invalid state\n * @attribute\n */\n @property({ type: Boolean, reflect: true })\n accessor invalid = false\n\n /**\n * The name attribute for form integration\n * @attribute\n */\n @property({ type: String })\n accessor name = ''\n\n /**\n * Whether the input is required\n * @attribute\n */\n @property({ type: Boolean })\n accessor required = false\n\n /**\n * Placeholder text shown when editor is empty\n * @attribute\n */\n @property({ type: String })\n accessor placeholder = ''\n\n /**\n * This property is used internally to set value without triggering updates.\n */\n #value = ''\n\n /**\n * The editor content value\n */\n get value(): string {\n return this.#value\n }\n\n @property({ type: String })\n set value(newValue: string) {\n const oldValue = this.#value\n if (newValue !== oldValue) {\n this.#value = newValue\n this._previousValue = newValue\n this.requestUpdate('value', oldValue)\n }\n }\n\n /**\n * Available function schemas for autocomplete\n */\n @property({ type: Array, attribute: false })\n accessor functionSchemas: FunctionSchema[] = []\n\n /**\n * Available suggestions for autocomplete\n */\n @property({ type: Array, attribute: false })\n accessor suggestions: Suggestion[] = []\n\n /**\n * Programming language for syntax highlighting\n * @attribute\n */\n @property({ type: String })\n accessor language = 'javascript'\n\n /**\n * Whether to show documentation links/buttons in function tooltips and autocomplete\n * @attribute\n */\n @property({ type: Boolean })\n accessor showDocumentation = false\n\n @query('.editor-container')\n private accessor editorContainer!: HTMLDivElement\n\n @state()\n private accessor hasContent = false\n\n @state()\n private accessor isEditorFocus = false\n\n private editorView?: EditorView\n /**\n * A control value to track previous value of the editor.\n * This is used to detect when change event should be dispatched.\n */\n private _previousValue = ''\n /**\n * Matcher for suggestion placeholders in the editor.\n */\n placeholderMatcher?: SuggestionMatchDecorator\n\n /**\n * Get all suggestions (placeholders) currently in the editor\n */\n get activeSuggestions(): Suggestion[] {\n const suggestions: Suggestion[] = []\n const placeholderPattern = /\\{\\{([^}]+)\\}\\}/g\n let match: RegExpExecArray | null\n while ((match = placeholderPattern.exec(this.value)) !== null) {\n const placeholderText = match[1]\n // Find suggestion by id\n const suggestion = this.suggestions.find((s) => s.id === placeholderText)\n if (suggestion) {\n suggestions.push(suggestion)\n }\n }\n return suggestions\n }\n\n private readonlyState = new Compartment()\n\n override disconnectedCallback(): void {\n super.disconnectedCallback()\n this.editorView?.destroy()\n }\n\n override firstUpdated(): void {\n this.initializeCodeMirror()\n this.updateEditorContent()\n }\n\n override willUpdate(changedProperties: PropertyValues): void {\n super.willUpdate(changedProperties)\n\n if (changedProperties.has('suggestions')) {\n if (this.placeholderMatcher) {\n this.placeholderMatcher.suggestions = this.suggestions || []\n }\n }\n\n if (changedProperties.has('value') && this.editorView) {\n this.updateEditorContent()\n }\n\n if (changedProperties.has('disabled')) {\n this.editorView?.dispatch({\n effects: this.readonlyState.reconfigure(EditorState.readOnly.of(this.disabled)),\n })\n }\n }\n\n /**\n * Initialize CodeMirror editor with extensions\n */\n private initializeCodeMirror(): void {\n const extensions: Extension[] = [\n keymap.of(defaultKeymap),\n syntaxHighlighting(defaultHighlightStyle),\n autocompletion({\n override: [this.createCompletionSource()],\n activateOnTyping: true,\n maxRenderedOptions: 10,\n }),\n EditorView.updateListener.of((update: ViewUpdate) => {\n if (update.docChanged) {\n this.handleEditorChange()\n }\n if (update.focusChanged) {\n this.handleFocusChange(update.view.hasFocus)\n } else if (update.view.hasFocus !== this.isEditorFocus) {\n // If focus state changed without focusChanged event, update manually\n this.handleFocusChange(update.view.hasFocus)\n }\n }),\n this.createPlaceholderPlugin(),\n hoverTooltip(this.createHoverTooltipSource),\n linter((view) => functionLinter(view, this.functionSchemas, (e) => this.dispatchEvent(e))),\n this.readonlyState.of(EditorState.readOnly.of(this.disabled)),\n ]\n\n // Add language support\n if (this.language === 'javascript') {\n extensions.push(javascript())\n }\n\n // Add placeholder\n if (this.placeholder) {\n extensions.push(\n EditorView.contentAttributes.of({\n 'aria-placeholder': this.placeholder,\n })\n )\n }\n\n const state = EditorState.create({\n doc: this.value,\n extensions,\n })\n\n this.editorView = new EditorView({\n state,\n parent: this.editorContainer,\n })\n }\n\n /**\n * Creates the ViewPlugin for rendering suggestion placeholders.\n * This is created as a method to get access to the component's `suggestions`.\n */\n private createPlaceholderPlugin(): Extension {\n const placeholderMatcher = new SuggestionMatchDecorator(/\\{\\{([^}]+)\\}\\}/g, this.suggestions)\n this.placeholderMatcher = placeholderMatcher\n // This class needs to be defined here to have access to the `placeholderMatcher`\n class AtomicDecorationRange {\n placeholders: DecorationSet\n constructor(view: EditorView) {\n this.placeholders = placeholderMatcher.createDeco(view)\n }\n update(update: ViewUpdate) {\n this.placeholders = placeholderMatcher.updateDeco(update, this.placeholders)\n }\n }\n\n return ViewPlugin.fromClass(AtomicDecorationRange, {\n decorations: (instance) => instance.placeholders,\n provide: (plugin) => EditorView.atomicRanges.of((view) => view.plugin(plugin)?.placeholders || Decoration.none),\n })\n }\n\n /**\n * Create completion source for functions and suggestions\n */\n private createCompletionSource(): CompletionSource {\n return (context: CompletionContext): CompletionResult | null => {\n const { pos } = context\n const line = context.state.doc.lineAt(pos)\n const textBefore = line.text.slice(0, pos - line.from)\n\n // Check if we're typing a function name\n const functionMatch = textBefore.match(/(\\w+)$/)\n if (functionMatch) {\n const prefix = functionMatch[1]\n const functions = this.functionSchemas\n .filter((fn) => fn.name.toLowerCase().startsWith(prefix.toLowerCase()))\n .map((fn) => this.createFunctionCompletion(fn))\n\n if (functions.length > 0) {\n return {\n from: pos - prefix.length,\n options: functions,\n }\n }\n }\n\n // Check if we're typing a suggestion trigger (e.g., {{)\n const suggestionMatch = textBefore.match(/\\{\\{([^}]*)$/)\n if (suggestionMatch) {\n const prefix = suggestionMatch[1]\n const suggestions = this.suggestions\n .filter((suggestion) => suggestion.label.toLowerCase().startsWith(prefix.toLowerCase()))\n .map((suggestion) => this.createSuggestionCompletion(suggestion))\n\n if (suggestions.length > 0) {\n return {\n from: pos - prefix.length,\n options: suggestions,\n }\n }\n }\n\n return null\n }\n }\n\n private createFunctionCompletion(schema: FunctionSchema): Completion {\n const result: Completion = {\n label: schema.name,\n detail: schema.description || '',\n type: 'function',\n info: () => this.createFunctionInfoElement(schema),\n apply: (view: EditorView, completion: unknown, from: number, to: number) => {\n const functionCall = this.formatFunctionCall(schema)\n view.dispatch({\n changes: { from, to, insert: functionCall },\n selection: { anchor: from + functionCall.length },\n })\n this.dispatchFunctionInsert(schema, from)\n },\n }\n\n return result\n }\n\n private createSuggestionCompletion(suggestion: Suggestion): Completion {\n const result: Completion = {\n label: suggestion.label,\n detail: suggestion.description || '',\n info: suggestion.suffix || '',\n type: 'variable',\n apply: (view: EditorView, completion: unknown, from: number, to: number) => {\n const placeholderText = `{{${suggestion.id}}}`\n view.dispatch({\n changes: { from: from - 2, to, insert: placeholderText }, // -2 to include the {{\n selection: { anchor: from - 2 + placeholderText.length },\n })\n this.dispatchSuggestionInsert(suggestion, from - 2)\n },\n }\n\n return result\n }\n\n /**\n * Creates the source for the hover tooltips.\n * This is an arrow function to automatically bind `this`.\n */\n private createHoverTooltipSource = (view: EditorView, pos: number): Tooltip | null => {\n const word = view.state.wordAt(pos)\n if (!word) {\n return null\n }\n\n const functionName = view.state.doc.sliceString(word.from, word.to)\n const fnSchema = this.functionSchemas.find((schema) => schema.name === functionName)\n\n if (!fnSchema) {\n return null\n }\n\n return {\n pos: word.from,\n end: word.to,\n above: true,\n create: () => ({ dom: this.createFunctionInfoElement(fnSchema) }),\n }\n }\n\n /**\n * Creates a styled HTML element to display function documentation.\n * This is used for both hover tooltips and autocomplete info panels.\n */\n protected createFunctionInfoElement(fn: FunctionSchema): HTMLElement {\n const container = document.createElement('div')\n container.className = 'function-info' // for styling\n\n if (fn.description) {\n const description = document.createElement('p')\n description.className = 'description'\n description.textContent = fn.description\n container.appendChild(description)\n }\n\n if (fn.parameters && fn.parameters.length > 0) {\n const paramsContainer = document.createElement('div')\n paramsContainer.className = 'parameters'\n\n const paramsHeader = document.createElement('h4')\n paramsHeader.textContent = 'Parameters'\n paramsContainer.appendChild(paramsHeader)\n\n const paramsList = document.createElement('ul')\n fn.parameters.forEach((param) => {\n const listItem = document.createElement('li')\n\n const name = document.createElement('span')\n name.className = 'param-name'\n name.textContent = param.name\n\n const type = document.createElement('span')\n type.className = 'param-type'\n type.textContent = `: ${getTypeStringFromSchema(param.schema)}`\n\n listItem.appendChild(name)\n listItem.appendChild(type)\n\n if (param.schema.description) {\n const paramDesc = document.createElement('p')\n paramDesc.className = 'param-description'\n paramDesc.textContent = param.schema.description\n listItem.appendChild(paramDesc)\n }\n paramsList.appendChild(listItem)\n })\n paramsContainer.appendChild(paramsList)\n container.appendChild(paramsContainer)\n }\n\n if (fn.returns) {\n const returnsContainer = document.createElement('div')\n returnsContainer.className = 'returns'\n\n const returnsHeader = document.createElement('h4')\n returnsHeader.textContent = 'Returns'\n returnsContainer.appendChild(returnsHeader)\n\n const returnsDesc = document.createElement('p')\n const returnType = getTypeStringFromSchema(fn.returns)\n returnsDesc.textContent = fn.returns.description ? `${returnType}: ${fn.returns.description}` : returnType\n returnsContainer.appendChild(returnsDesc)\n container.appendChild(returnsContainer)\n }\n\n // Add documentation button if showDocumentation is enabled\n if (this.showDocumentation) {\n const docContainer = document.createElement('div')\n docContainer.className = 'documentation'\n\n const docButton = document.createElement('ui-button')\n docButton.type = 'button'\n docButton.className = 'documentation-button'\n docButton.textContent = 'Show documentation'\n docButton.setAttribute('aria-label', `Show documentation for ${fn.name} function`)\n\n docButton.addEventListener('click', (event) => {\n event.preventDefault()\n event.stopPropagation()\n this.dispatchFunctionDocumentation(fn)\n })\n\n docContainer.appendChild(docButton)\n container.appendChild(docContainer)\n }\n\n return container\n }\n\n /**\n * Format function call with parameters\n */\n private formatFunctionCall(fn: FunctionSchema): string {\n if (!fn.parameters || fn.parameters.length === 0) {\n return `${fn.name}()`\n }\n\n const params = fn.parameters\n .map((param) => {\n if (param.required) {\n return param.name\n }\n return `${param.name}?`\n })\n .join(', ')\n\n return `${fn.name}(${params})`\n }\n\n /**\n * Update editor content when value changes\n */\n private updateEditorContent(): void {\n if (!this.editorView) return\n\n const currentValue = this.editorView.state.doc.toString()\n if (currentValue !== this.value) {\n this.editorView.dispatch({\n changes: {\n from: 0,\n to: this.editorView.state.doc.length,\n insert: this.value,\n },\n })\n }\n }\n\n /**\n * Handle editor content change\n */\n private handleEditorChange(): void {\n if (!this.editorView) return\n\n const newValue = this.editorView.state.doc.toString()\n this.#value = newValue\n this.hasContent = newValue.length > 0\n\n this.dispatchEvent(new Event('input', { bubbles: true }))\n }\n\n /**\n * Handle focus change\n */\n private handleFocusChange(hasFocus: boolean): void {\n this.isEditorFocus = hasFocus\n\n if (!hasFocus && this.#value !== this._previousValue) {\n this._previousValue = this.#value\n this.dispatchEvent(new Event('change'))\n }\n }\n\n /**\n * Dispatch function insert event\n */\n private dispatchFunctionInsert(functionSchema: FunctionSchema, position: number): void {\n const event = new CustomEvent<FunctionInsertEvent>('functioninsert', {\n detail: { functionSchema, position },\n bubbles: true,\n })\n this.dispatchEvent(event)\n }\n\n /**\n * Dispatch suggestion insert event\n */\n private dispatchSuggestionInsert(suggestion: Suggestion, position: number): void {\n const event = new CustomEvent<SuggestionInsertEvent>('suggestioninsert', {\n detail: { suggestion, position },\n bubbles: true,\n })\n this.dispatchEvent(event)\n }\n\n /**\n * Dispatch function documentation event\n */\n private dispatchFunctionDocumentation(functionSchema: FunctionSchema): void {\n const event = new CustomEvent<FunctionDocumentationEvent>('docsrequest', {\n detail: { functionSchema },\n bubbles: true,\n })\n this.dispatchEvent(event)\n }\n\n /**\n * Focus the editor\n */\n override focus(): void {\n this.editorView?.focus()\n }\n\n /**\n * Get the editor's current selection\n */\n getSelection(): { from: number; to: number } | null {\n if (!this.editorView) return null\n const { from, to } = this.editorView.state.selection.main\n return { from, to }\n }\n\n /**\n * Insert text at the current cursor position\n */\n insertText(text: string): void {\n if (!this.editorView) return\n\n const { from, to } = this.editorView.state.selection.main\n this.editorView.dispatch({\n changes: { from, to, insert: text },\n selection: { anchor: from + text.length },\n })\n }\n\n override render(): TemplateResult {\n const hasLabel = !!this.label\n const hasSupportingText = !!this.supportingText\n\n return html`\n <div class=\"surface ${classMap({ 'has-focus': this.isEditorFocus, 'invalid': this.invalid })}\">\n <div class=\"content\">\n ${hasLabel ? html`<div class=\"label\">${this.label}</div>` : nothing}\n\n <div class=\"editor-container\" part=\"editor\"></div>\n </div>\n\n ${hasSupportingText ? html`<div class=\"supporting-text\">${this.supportingText}</div>` : nothing}\n </div>\n `\n }\n}\n"]}
|
|
@@ -123,42 +123,28 @@ class CodeEditorDemo extends DemoPage {
|
|
|
123
123
|
|
|
124
124
|
<code-editor
|
|
125
125
|
label="Code Editor"
|
|
126
|
-
|
|
126
|
+
supportingtext="Type function names or {{fnName}} to see autocomplete"
|
|
127
127
|
.value=${this.editorValue}
|
|
128
128
|
.functionSchemas=${this.functions}
|
|
129
129
|
.suggestions=${this.suggestions}
|
|
130
|
-
@
|
|
131
|
-
@
|
|
130
|
+
@functioninsert=${this.handleFunctionInsert}
|
|
131
|
+
@suggestioninsert=${this.handleSuggestionInsert}
|
|
132
132
|
@input=${this.handleInput}
|
|
133
133
|
@change=${this.handleChange}
|
|
134
|
-
|
|
135
|
-
@
|
|
134
|
+
showdocumentation
|
|
135
|
+
@docsrequest="${this.handleFunctionDocumentation}"
|
|
136
136
|
></code-editor>
|
|
137
137
|
|
|
138
138
|
${this.output ? html`<p><strong>Output:</strong> ${this.output}</p>` : ''}
|
|
139
139
|
</section>
|
|
140
140
|
|
|
141
|
-
<section class="demo-section">
|
|
142
|
-
<h2 class="display-large">Dark Theme</h2>
|
|
143
|
-
<p>The same editor with dark theme enabled.</p>
|
|
144
|
-
|
|
145
|
-
<code-editor
|
|
146
|
-
label="Dark Theme Editor"
|
|
147
|
-
supporting-text="Dark theme variant"
|
|
148
|
-
.value=${'// Dark theme example\nconst theme = "dark"'}
|
|
149
|
-
.functionSchemas=${this.functions}
|
|
150
|
-
.suggestions=${this.suggestions}
|
|
151
|
-
dark-theme
|
|
152
|
-
></code-editor>
|
|
153
|
-
</section>
|
|
154
|
-
|
|
155
141
|
<section class="demo-section">
|
|
156
142
|
<h2 class="display-large">Disabled State</h2>
|
|
157
143
|
<p>A disabled editor for read-only content.</p>
|
|
158
144
|
|
|
159
145
|
<code-editor
|
|
160
146
|
label="Disabled Editor"
|
|
161
|
-
|
|
147
|
+
supportingtext="This editor is disabled"
|
|
162
148
|
.value=${'// This editor is disabled\nconst readOnly = true'}
|
|
163
149
|
.functionSchemas=${this.functions}
|
|
164
150
|
.suggestions=${this.suggestions}
|
|
@@ -172,7 +158,7 @@ class CodeEditorDemo extends DemoPage {
|
|
|
172
158
|
|
|
173
159
|
<code-editor
|
|
174
160
|
label="Error Editor"
|
|
175
|
-
|
|
161
|
+
supportingtext="This editor has an error"
|
|
176
162
|
.value=${'// This editor has an error\nconst invalid = true'}
|
|
177
163
|
.functionSchemas=${this.functions}
|
|
178
164
|
.suggestions=${this.suggestions}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@api-client/ui",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.20",
|
|
4
4
|
"description": "Internal UI component library for the API Client ecosystem.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "build/src/index.js",
|
|
@@ -186,7 +186,6 @@
|
|
|
186
186
|
"@codemirror/language": "^6.11.2",
|
|
187
187
|
"@codemirror/lint": "^6.8.5",
|
|
188
188
|
"@codemirror/state": "^6.5.2",
|
|
189
|
-
"@codemirror/theme-one-dark": "^6.1.3",
|
|
190
189
|
"@codemirror/view": "^6.38.0",
|
|
191
190
|
"@github/relative-time-element": "^4.4.6",
|
|
192
191
|
"@material/web": "^2.3.0",
|
|
@@ -29,8 +29,8 @@ import '@api-client/ui/elements/code-editor/code-editor.js'
|
|
|
29
29
|
.value=${this.code}
|
|
30
30
|
.functionSchemas=${this.functions}
|
|
31
31
|
.suggestions=${this.suggestions}
|
|
32
|
-
@
|
|
33
|
-
@
|
|
32
|
+
@functioninsert=${this.handleFunctionInsert}
|
|
33
|
+
@suggestioninsert=${this.handleSuggestionInsert}
|
|
34
34
|
@input=${this.handleInput}
|
|
35
35
|
></code-editor>
|
|
36
36
|
```
|
|
@@ -84,8 +84,8 @@ const suggestions: Suggestion[] = [
|
|
|
84
84
|
|
|
85
85
|
The component dispatches several events:
|
|
86
86
|
|
|
87
|
-
- `
|
|
88
|
-
- `
|
|
87
|
+
- `functioninsert`: When a function is inserted via autocomplete
|
|
88
|
+
- `suggestioninsert`: When a suggestion is inserted as a pill
|
|
89
89
|
- `input`: When the editor content changes (standard input event)
|
|
90
90
|
- `change`: When the editor loses focus and content has changed
|
|
91
91
|
|
|
@@ -129,6 +129,7 @@ code-editor {
|
|
|
129
129
|
## Accessibility
|
|
130
130
|
|
|
131
131
|
The component includes:
|
|
132
|
+
|
|
132
133
|
- Proper ARIA attributes for screen readers
|
|
133
134
|
- Keyboard navigation support
|
|
134
135
|
- Focus management
|
|
@@ -154,7 +155,7 @@ The component includes:
|
|
|
154
155
|
label="Code with Functions"
|
|
155
156
|
.value=${this.code}
|
|
156
157
|
.functionSchemas=${this.functions}
|
|
157
|
-
@
|
|
158
|
+
@functioninsert=${this.onFunctionInsert}
|
|
158
159
|
>
|
|
159
160
|
</code-editor>
|
|
160
161
|
```
|
|
@@ -166,7 +167,7 @@ The component includes:
|
|
|
166
167
|
label="Code with Mentions"
|
|
167
168
|
.value=${this.code}
|
|
168
169
|
.suggestions=${this.users}
|
|
169
|
-
@
|
|
170
|
+
@suggestioninsert=${this.onSuggestionInsert}
|
|
170
171
|
>
|
|
171
172
|
</code-editor>
|
|
172
173
|
```
|
|
@@ -189,6 +190,7 @@ A comprehensive demo is available at `/demo/elements/code-editor/` when running
|
|
|
189
190
|
## Browser Support
|
|
190
191
|
|
|
191
192
|
The component works in all modern browsers that support:
|
|
193
|
+
|
|
192
194
|
- ES2020+ features
|
|
193
195
|
- Web Components
|
|
194
196
|
- CSS Custom Properties
|
|
@@ -197,6 +199,7 @@ The component works in all modern browsers that support:
|
|
|
197
199
|
## Contributing
|
|
198
200
|
|
|
199
201
|
When contributing to this component, please follow the established patterns:
|
|
202
|
+
|
|
200
203
|
- Use TypeScript for type safety
|
|
201
204
|
- Follow the existing code style
|
|
202
205
|
- Include tests for new features
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
} from '@codemirror/autocomplete'
|
|
13
13
|
import { javascript } from '@codemirror/lang-javascript'
|
|
14
14
|
import { syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language'
|
|
15
|
-
import { oneDark } from '@codemirror/theme-one-dark'
|
|
16
15
|
import { keymap } from '@codemirror/view'
|
|
17
16
|
import { defaultKeymap } from '@codemirror/commands'
|
|
18
17
|
import {
|
|
@@ -42,9 +41,9 @@ import '../../../md/button/ui-button.js'
|
|
|
42
41
|
* - Keyboard navigation
|
|
43
42
|
* - Accessibility support
|
|
44
43
|
*
|
|
45
|
-
* @fires
|
|
46
|
-
* @fires
|
|
47
|
-
* @fires
|
|
44
|
+
* @fires functioninsert - When a function is inserted
|
|
45
|
+
* @fires suggestioninsert - When a suggestion is inserted
|
|
46
|
+
* @fires docsrequest - When documentation is requested for a function
|
|
48
47
|
* @fires input - When the editor content changes
|
|
49
48
|
* @fires change - When the editor loses focus and content has changed
|
|
50
49
|
*/
|
|
@@ -69,7 +68,7 @@ export default class CodeEditor extends LitElement {
|
|
|
69
68
|
* Supporting text displayed below the editor
|
|
70
69
|
* @attribute
|
|
71
70
|
*/
|
|
72
|
-
@property({ type: String
|
|
71
|
+
@property({ type: String })
|
|
73
72
|
accessor supportingText = ''
|
|
74
73
|
|
|
75
74
|
/**
|
|
@@ -141,12 +140,6 @@ export default class CodeEditor extends LitElement {
|
|
|
141
140
|
@property({ type: Array, attribute: false })
|
|
142
141
|
accessor suggestions: Suggestion[] = []
|
|
143
142
|
|
|
144
|
-
/**
|
|
145
|
-
* Whether to use dark theme
|
|
146
|
-
*/
|
|
147
|
-
@property({ type: Boolean, attribute: 'dark-theme' })
|
|
148
|
-
accessor darkTheme = false
|
|
149
|
-
|
|
150
143
|
/**
|
|
151
144
|
* Programming language for syntax highlighting
|
|
152
145
|
* @attribute
|
|
@@ -156,9 +149,9 @@ export default class CodeEditor extends LitElement {
|
|
|
156
149
|
|
|
157
150
|
/**
|
|
158
151
|
* Whether to show documentation links/buttons in function tooltips and autocomplete
|
|
159
|
-
* @attribute
|
|
152
|
+
* @attribute
|
|
160
153
|
*/
|
|
161
|
-
@property({ type: Boolean
|
|
154
|
+
@property({ type: Boolean })
|
|
162
155
|
accessor showDocumentation = false
|
|
163
156
|
|
|
164
157
|
@query('.editor-container')
|
|
@@ -265,11 +258,6 @@ export default class CodeEditor extends LitElement {
|
|
|
265
258
|
extensions.push(javascript())
|
|
266
259
|
}
|
|
267
260
|
|
|
268
|
-
// Add theme
|
|
269
|
-
if (this.darkTheme) {
|
|
270
|
-
extensions.push(oneDark)
|
|
271
|
-
}
|
|
272
|
-
|
|
273
261
|
// Add placeholder
|
|
274
262
|
if (this.placeholder) {
|
|
275
263
|
extensions.push(
|
|
@@ -578,7 +566,7 @@ export default class CodeEditor extends LitElement {
|
|
|
578
566
|
* Dispatch function insert event
|
|
579
567
|
*/
|
|
580
568
|
private dispatchFunctionInsert(functionSchema: FunctionSchema, position: number): void {
|
|
581
|
-
const event = new CustomEvent<FunctionInsertEvent>('
|
|
569
|
+
const event = new CustomEvent<FunctionInsertEvent>('functioninsert', {
|
|
582
570
|
detail: { functionSchema, position },
|
|
583
571
|
bubbles: true,
|
|
584
572
|
})
|
|
@@ -589,7 +577,7 @@ export default class CodeEditor extends LitElement {
|
|
|
589
577
|
* Dispatch suggestion insert event
|
|
590
578
|
*/
|
|
591
579
|
private dispatchSuggestionInsert(suggestion: Suggestion, position: number): void {
|
|
592
|
-
const event = new CustomEvent<SuggestionInsertEvent>('
|
|
580
|
+
const event = new CustomEvent<SuggestionInsertEvent>('suggestioninsert', {
|
|
593
581
|
detail: { suggestion, position },
|
|
594
582
|
bubbles: true,
|
|
595
583
|
})
|
|
@@ -600,7 +588,7 @@ export default class CodeEditor extends LitElement {
|
|
|
600
588
|
* Dispatch function documentation event
|
|
601
589
|
*/
|
|
602
590
|
private dispatchFunctionDocumentation(functionSchema: FunctionSchema): void {
|
|
603
|
-
const event = new CustomEvent<FunctionDocumentationEvent>('
|
|
591
|
+
const event = new CustomEvent<FunctionDocumentationEvent>('docsrequest', {
|
|
604
592
|
detail: { functionSchema },
|
|
605
593
|
bubbles: true,
|
|
606
594
|
})
|
|
@@ -42,7 +42,7 @@ describe('CodeEditor - Accessibility', () => {
|
|
|
42
42
|
return fixture(html`
|
|
43
43
|
<code-editor
|
|
44
44
|
label="Accessible Code Editor"
|
|
45
|
-
|
|
45
|
+
supportingtext="Enter your code with accessibility support"
|
|
46
46
|
placeholder="Type your code here..."
|
|
47
47
|
.functionSchemas="${sampleFunctionSchemas}"
|
|
48
48
|
.suggestions="${sampleSuggestions}"
|
|
@@ -54,7 +54,7 @@ describe('CodeEditor - Accessibility', () => {
|
|
|
54
54
|
return fixture(html`
|
|
55
55
|
<code-editor
|
|
56
56
|
label="Code Editor with Documentation"
|
|
57
|
-
|
|
57
|
+
showdocumentation
|
|
58
58
|
.functionSchemas="${sampleFunctionSchemas}"
|
|
59
59
|
></code-editor>
|
|
60
60
|
`)
|
|
@@ -245,33 +245,6 @@ describe('CodeEditor - Accessibility', () => {
|
|
|
245
245
|
})
|
|
246
246
|
})
|
|
247
247
|
|
|
248
|
-
describe('High Contrast and Theme Support', () => {
|
|
249
|
-
it('should support dark theme for accessibility', async () => {
|
|
250
|
-
const el = await accessibleFixture()
|
|
251
|
-
el.darkTheme = true
|
|
252
|
-
await nextFrame()
|
|
253
|
-
|
|
254
|
-
// Wait for CodeMirror to apply theme
|
|
255
|
-
await aTimeout(100)
|
|
256
|
-
|
|
257
|
-
assert.isTrue(el.darkTheme)
|
|
258
|
-
})
|
|
259
|
-
|
|
260
|
-
it('should maintain readability in different themes', async () => {
|
|
261
|
-
const el = await accessibleFixture()
|
|
262
|
-
await nextFrame()
|
|
263
|
-
|
|
264
|
-
// Test both light and dark themes
|
|
265
|
-
el.darkTheme = false
|
|
266
|
-
await nextFrame()
|
|
267
|
-
assert.isFalse(el.darkTheme)
|
|
268
|
-
|
|
269
|
-
el.darkTheme = true
|
|
270
|
-
await nextFrame()
|
|
271
|
-
assert.isTrue(el.darkTheme)
|
|
272
|
-
})
|
|
273
|
-
})
|
|
274
|
-
|
|
275
248
|
describe('Touch and Mobile Accessibility', () => {
|
|
276
249
|
it.skip('should be usable on touch devices', async () => {
|
|
277
250
|
const el = await accessibleFixture()
|
|
@@ -77,7 +77,7 @@ describe('CodeEditor', () => {
|
|
|
77
77
|
return fixture(html`
|
|
78
78
|
<code-editor
|
|
79
79
|
label="Test Editor"
|
|
80
|
-
|
|
80
|
+
supportingtext="Enter your code here"
|
|
81
81
|
placeholder="Type here..."
|
|
82
82
|
.functionSchemas="${sampleFunctionSchemas}"
|
|
83
83
|
.suggestions="${sampleSuggestions}"
|
|
@@ -88,7 +88,7 @@ describe('CodeEditor', () => {
|
|
|
88
88
|
async function documentationFixture(): Promise<CodeEditorElement> {
|
|
89
89
|
return fixture(html`
|
|
90
90
|
<code-editor
|
|
91
|
-
|
|
91
|
+
showdocumentation
|
|
92
92
|
.functionSchemas="${sampleFunctionSchemas}"
|
|
93
93
|
.suggestions="${sampleSuggestions}"
|
|
94
94
|
></code-editor>
|
|
@@ -106,7 +106,6 @@ describe('CodeEditor', () => {
|
|
|
106
106
|
assert.isFalse(el.required)
|
|
107
107
|
assert.equal(el.placeholder, '')
|
|
108
108
|
assert.equal(el.value, '')
|
|
109
|
-
assert.isFalse(el.darkTheme)
|
|
110
109
|
assert.equal(el.language, 'javascript')
|
|
111
110
|
assert.isFalse(el.showDocumentation)
|
|
112
111
|
assert.deepEqual(el.functionSchemas, [])
|
|
@@ -123,7 +122,6 @@ describe('CodeEditor', () => {
|
|
|
123
122
|
el.required = true
|
|
124
123
|
el.placeholder = 'Test Placeholder'
|
|
125
124
|
el.value = 'test code'
|
|
126
|
-
el.darkTheme = true
|
|
127
125
|
el.language = 'python'
|
|
128
126
|
el.showDocumentation = true
|
|
129
127
|
el.functionSchemas = sampleFunctionSchemas
|
|
@@ -138,7 +136,6 @@ describe('CodeEditor', () => {
|
|
|
138
136
|
assert.isTrue(el.required)
|
|
139
137
|
assert.equal(el.placeholder, 'Test Placeholder')
|
|
140
138
|
assert.equal(el.value, 'test code')
|
|
141
|
-
assert.isTrue(el.darkTheme)
|
|
142
139
|
assert.equal(el.language, 'python')
|
|
143
140
|
assert.isTrue(el.showDocumentation)
|
|
144
141
|
assert.deepEqual(el.functionSchemas, sampleFunctionSchemas)
|
|
@@ -342,7 +339,7 @@ describe('CodeEditor', () => {
|
|
|
342
339
|
})
|
|
343
340
|
|
|
344
341
|
describe('Function Events', () => {
|
|
345
|
-
it('should dispatch
|
|
342
|
+
it('should dispatch functioninsert event through user interaction', async () => {
|
|
346
343
|
const el = await configuredFixture()
|
|
347
344
|
await nextFrame()
|
|
348
345
|
|
|
@@ -351,33 +348,33 @@ describe('CodeEditor', () => {
|
|
|
351
348
|
|
|
352
349
|
// Create a spy to capture the event
|
|
353
350
|
const eventSpy = sinon.spy()
|
|
354
|
-
el.addEventListener('
|
|
351
|
+
el.addEventListener('functioninsert', eventSpy)
|
|
355
352
|
|
|
356
353
|
// Note: In a real test, this would be triggered by CodeMirror autocompletion
|
|
357
354
|
// For now, we test that the event listener is properly set up
|
|
358
355
|
assert.isFalse(eventSpy.called)
|
|
359
356
|
})
|
|
360
357
|
|
|
361
|
-
it('should dispatch
|
|
358
|
+
it('should dispatch suggestioninsert event through user interaction', async () => {
|
|
362
359
|
const el = await configuredFixture()
|
|
363
360
|
await nextFrame()
|
|
364
361
|
|
|
365
362
|
// Create a spy to capture the event
|
|
366
363
|
const eventSpy = sinon.spy()
|
|
367
|
-
el.addEventListener('
|
|
364
|
+
el.addEventListener('suggestioninsert', eventSpy)
|
|
368
365
|
|
|
369
366
|
// Note: In a real test, this would be triggered by CodeMirror autocompletion
|
|
370
367
|
// For now, we test that the event listener is properly set up
|
|
371
368
|
assert.isFalse(eventSpy.called)
|
|
372
369
|
})
|
|
373
370
|
|
|
374
|
-
it('should have
|
|
371
|
+
it('should have docsrequest event listener when showDocumentation is true', async () => {
|
|
375
372
|
const el = await documentationFixture()
|
|
376
373
|
await nextFrame()
|
|
377
374
|
|
|
378
375
|
// Create a spy to capture the event
|
|
379
376
|
const eventSpy = sinon.spy()
|
|
380
|
-
el.addEventListener('
|
|
377
|
+
el.addEventListener('docsrequest', eventSpy)
|
|
381
378
|
|
|
382
379
|
// Test that the element is configured to dispatch this event
|
|
383
380
|
assert.isTrue(el.showDocumentation)
|
|
@@ -487,13 +484,13 @@ describe('CodeEditor', () => {
|
|
|
487
484
|
assert.isAtLeast(el.functionSchemas.length, 1)
|
|
488
485
|
})
|
|
489
486
|
|
|
490
|
-
it('should dispatch
|
|
487
|
+
it('should dispatch docsrequest event when documentation is enabled', async () => {
|
|
491
488
|
const el = await documentationFixture()
|
|
492
489
|
await nextFrame()
|
|
493
490
|
await aTimeout(100) // Wait for CodeMirror initialization
|
|
494
491
|
|
|
495
492
|
const eventSpy = sinon.spy()
|
|
496
|
-
el.addEventListener('
|
|
493
|
+
el.addEventListener('docsrequest', eventSpy)
|
|
497
494
|
|
|
498
495
|
// Access the private method through bracket notation to avoid TypeScript errors
|
|
499
496
|
const functionSchema = sampleFunctionSchemas[0]
|