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.
[SearchProfiler] Parse triple quotes JSON in SearchProfiler editor (e…
…lastic#41282) * Initial pass at introducing XJsonWorker for searchprofiler app: - Added some copy pasted logic from console (json rules) - Copied and modified brace's json worker/parser. Added the ability to take """ - Updated existing controller and logic to work with new files * Added comment * Fixed type worker.js type issue Added some more clarifying comments * semi-colon * Brought OO inheritance more in line with what ace expects (no `class`) Added tests * Clarify ts module declaration for raw loaded worker.js file * Minor refactor * Added comment * Added safe apply mechanism to notify ng about changes to editor content
- Loading branch information
1 parent
87226e8
commit 89aa6ac
Showing
11 changed files
with
1,571 additions
and
19 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
33 changes: 33 additions & 0 deletions
33
x-pack/legacy/plugins/searchprofiler/public/editor/index.ts
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,33 @@ | ||
/* | ||
* 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 ace from 'brace'; | ||
import { installXJsonMode } from './x_json_mode'; | ||
|
||
export function initializeEditor({ | ||
el, | ||
licenseEnabled, | ||
initialContent, | ||
}: { | ||
el: HTMLDivElement; | ||
licenseEnabled: boolean; | ||
initialContent: string; | ||
}) { | ||
const editor: ace.Editor = ace.acequire('ace/ace').edit(el); | ||
|
||
installXJsonMode(editor); | ||
editor.$blockScrolling = Infinity; | ||
|
||
if (!licenseEnabled) { | ||
editor.setReadOnly(true); | ||
editor.container.style.pointerEvents = 'none'; | ||
editor.container.style.opacity = '0.5'; | ||
editor.renderer.setStyle('disabled'); | ||
editor.blur(); | ||
} | ||
|
||
return editor; | ||
} |
12 changes: 12 additions & 0 deletions
12
x-pack/legacy/plugins/searchprofiler/public/editor/worker/index.ts
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,12 @@ | ||
/* | ||
* 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 src from '!!raw-loader!./worker.js'; | ||
|
||
export const workerModule = { | ||
id: 'ace/mode/json_worker', | ||
src, | ||
}; |
12 changes: 12 additions & 0 deletions
12
x-pack/legacy/plugins/searchprofiler/public/editor/worker/worker.d.ts
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,12 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
// Satisfy TS's requirements that the module be declared per './index.ts'. | ||
declare module '!!raw-loader!./worker.js' { | ||
const content: string; | ||
// eslint-disable-next-line import/no-default-export | ||
export default content; | ||
} |
Oops, something went wrong.