forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Monaco] Refactor the way XJSON grammar checker gets registered (elas…
…tic#75160) * Refactor the way XJSON grammar checker gets registered - avoid registering multiple model add listeners - remove regsiterGrammarChecker from public API! - fix getWorker handler to register XJSON only for XJSON models * remove unused import * updateAnnos -> updateAnnotations # Conflicts: # x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/field_components/xjson_editor.tsx
- Loading branch information
1 parent
c74c842
commit 59ac6aa
Showing
6 changed files
with
96 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...line_processors_editor/components/manage_processor_form/field_components/xjson_editor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { XJsonLang } from '@kbn/monaco'; | ||
import React, { FunctionComponent, useCallback } from 'react'; | ||
import { FieldHook, Monaco } from '../../../../../../shared_imports'; | ||
|
||
import { TextEditor } from './text_editor'; | ||
|
||
interface Props { | ||
field: FieldHook<string>; | ||
editorProps: { [key: string]: any }; | ||
} | ||
|
||
export const XJsonEditor: FunctionComponent<Props> = ({ field, editorProps }) => { | ||
const { value, setValue } = field; | ||
const { xJson, setXJson, convertToJson } = Monaco.useXJsonMode(value); | ||
|
||
const onChange = useCallback( | ||
(s) => { | ||
setXJson(s); | ||
setValue(convertToJson(s)); | ||
}, | ||
[setValue, setXJson, convertToJson] | ||
); | ||
return ( | ||
<TextEditor | ||
field={field} | ||
editorProps={{ | ||
value: xJson, | ||
languageId: XJsonLang.ID, | ||
options: { minimap: { enabled: false } }, | ||
onChange, | ||
...editorProps, | ||
}} | ||
/> | ||
); | ||
}; |