[ES UI] Reintroduce import of brace/mode/json (#78571) (#79087)

* added brace/mode/json import everywhere json mode is being used

* added brace mocks to tests

* slight refactor of imports

* remove import from es ui shared

* Reverse adding brace/mode/json import everywhere

- different approach of just adding brace/json/mode to
  es_ui_shared as before with a BIG comment

* updated @kbn/ace readme

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Jean-Louis Leysens 2020-10-01 14:47:46 +02:00 committed by GitHub
parent 827b4a53ab
commit 50e3b52e08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 2 deletions

View file

@ -1,5 +1,20 @@
# @kbn/ace
Contains all Kibana-specific brace related code. Excluding the code that still inside of Console because that code is only used inside of console at the moment.
This package contains the XJSON mode for brace. This is an extension of the `brace/mode/json` mode.
This package enables plugins to use this functionality and import it as needed -- behind an async import so that brace does not bloat the JS code needed for first page load of Kibana.
This package also contains an import of the entire brace editor which is used for creating the custom XJSON worker.
## Note to plugins
_This code should not be eagerly loaded_.
Make sure imports of this package are behind a lazy-load `import()` statement.
Your plugin should already be loading application code this way in the `mount` function.
## Deprecated
This package is considered deprecated and will be removed in future.
New and existing editor functionality should use Monaco.
_Do not add new functionality to this package_. Build new functionality for Monaco and use it instead.

View file

@ -17,6 +17,21 @@
* under the License.
*/
/*
@TODO
The brace/mode/json import below is loaded eagerly - before this plugin is explicitly loaded by users. This makes
the brace JSON mode, used for JSON syntax highlighting and grammar checking, available across all of Kibana plugins.
This is not ideal because we are loading JS that is not necessary for Kibana to start, but the alternative
is breaking JSON mode for an unknown number of ace editors across Kibana - not all components reference the underlying
EuiCodeEditor (for instance, explicitly).
Importing here is a way of preventing a more sophisticated solution to this problem since we want to, eventually,
migrate all code editors over to Monaco. Once that is done, we should remove this import.
*/
import 'brace/mode/json';
export * from './field';
export * from './form_row';
export * from './fields';