diff --git a/src/legacy/core_plugins/vis_type_vega/public/components/vega_actions_menu.tsx b/src/legacy/core_plugins/vis_type_vega/public/components/vega_actions_menu.tsx
index 00893d427682b..71a88b47a8be3 100644
--- a/src/legacy/core_plugins/vis_type_vega/public/components/vega_actions_menu.tsx
+++ b/src/legacy/core_plugins/vis_type_vega/public/components/vega_actions_menu.tsx
@@ -30,7 +30,7 @@ interface VegaActionsMenuProps {
function VegaActionsMenu({ formatHJson, formatJson }: VegaActionsMenuProps) {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
- const onButtonClick = useCallback(() => setIsPopoverOpen(!isPopoverOpen), [isPopoverOpen]);
+ const onButtonClick = useCallback(() => setIsPopoverOpen(isOpen => !isOpen), []);
const onHJsonCLick = useCallback(() => {
formatHJson();
setIsPopoverOpen(false);
diff --git a/src/legacy/core_plugins/vis_type_vega/public/components/vega_help_menu.tsx b/src/legacy/core_plugins/vis_type_vega/public/components/vega_help_menu.tsx
index c43ce60506f94..e4443c0058e9b 100644
--- a/src/legacy/core_plugins/vis_type_vega/public/components/vega_help_menu.tsx
+++ b/src/legacy/core_plugins/vis_type_vega/public/components/vega_help_menu.tsx
@@ -47,7 +47,7 @@ function VegaHelpMenu() {
>
,
,
,
];
diff --git a/src/legacy/core_plugins/vis_type_vega/public/components/vega_vis_editor.tsx b/src/legacy/core_plugins/vis_type_vega/public/components/vega_vis_editor.tsx
index 0ff024b1f8b40..6d14acf6ec7aa 100644
--- a/src/legacy/core_plugins/vis_type_vega/public/components/vega_vis_editor.tsx
+++ b/src/legacy/core_plugins/vis_type_vega/public/components/vega_vis_editor.tsx
@@ -39,10 +39,15 @@ const aceOptions = {
wrap: true,
};
-function format(value: string, stringify: typeof compactStringify) {
+const hjsonStringifyOptions = {
+ bracesSameLine: true,
+ keepWsc: true,
+};
+
+function format(value: string, stringify: typeof compactStringify, options?: any) {
try {
const spec = hjson.parse(value, { legacyRoot: false, keepWsc: true });
- return stringify(spec);
+ return stringify(spec, options);
} catch (err) {
// This is a common case - user tries to format an invalid HJSON text
toastNotifications.addError(err, {
@@ -69,7 +74,7 @@ function VegaVisEditor({ stateParams, setValue }: VisOptionsProps) {
);
const formatHJson = useCallback(
- () => setValue('spec', format(stateParams.spec, hjson.stringify)),
+ () => setValue('spec', format(stateParams.spec, hjson.stringify, hjsonStringifyOptions)),
[setValue, stateParams.spec]
);
diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json
index 59ac561065fa0..0159e1886f6f5 100644
--- a/x-pack/plugins/translations/translations/ja-JP.json
+++ b/x-pack/plugins/translations/translations/ja-JP.json
@@ -3161,11 +3161,8 @@
"visTypeVega.editor.formatError": "仕様のフォーマット中にエラーが発生",
"visTypeVega.editor.reformatAsHJSONButtonLabel": "HJSON に変換",
"visTypeVega.editor.reformatAsJSONButtonLabel": "JSON に変換しコメントを削除",
- "visTypeVega.editor.vegaDocumentationLinkText": "Vega ドキュメント",
"visTypeVega.editor.vegaEditorOptionsButtonAriaLabel": "Vega エディターオプション",
"visTypeVega.editor.vegaHelpButtonAriaLabel": "Vega ヘルプ",
- "visTypeVega.editor.vegaHelpLinkText": "Kibana Vega ヘルプ",
- "visTypeVega.editor.vegaLiteDocumentationLinkText": "Vega-Lite ドキュメンテーション",
"visTypeVega.emsFileParser.emsFileNameDoesNotExistErrorMessage": "{emsfile} {emsfileName} が存在しません",
"visTypeVega.emsFileParser.missingNameOfFileErrorMessage": "{dataUrlParamValue} の {dataUrlParam} には {nameParam} パラメーター (ファイル名) が必要です",
"visTypeVega.esQueryParser.autointervalValueTypeErrorMessage": "{autointerval} は文字 {trueValue} または数字である必要があります",
@@ -10514,4 +10511,4 @@
"xpack.fileUpload.fileParser.errorReadingFile": "ファイルの読み込み中にエラーが発生しました",
"xpack.fileUpload.fileParser.noFileProvided": "エラー、ファイルが提供されていません"
}
-}
\ No newline at end of file
+}
diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json
index cf40c5cb6e973..1d98f9f4bf227 100644
--- a/x-pack/plugins/translations/translations/zh-CN.json
+++ b/x-pack/plugins/translations/translations/zh-CN.json
@@ -3162,11 +3162,8 @@
"visTypeVega.editor.formatError": "格式化规范时出错",
"visTypeVega.editor.reformatAsHJSONButtonLabel": "重新格式化为 HJSON",
"visTypeVega.editor.reformatAsJSONButtonLabel": "重新格式化为 JSON,删除注释",
- "visTypeVega.editor.vegaDocumentationLinkText": "Vega 文档",
"visTypeVega.editor.vegaEditorOptionsButtonAriaLabel": "Vega 编辑器选项",
"visTypeVega.editor.vegaHelpButtonAriaLabel": "Vega 帮助",
- "visTypeVega.editor.vegaHelpLinkText": "Kibana Vega 帮助",
- "visTypeVega.editor.vegaLiteDocumentationLinkText": "Vega-Lite 文档",
"visTypeVega.emsFileParser.emsFileNameDoesNotExistErrorMessage": "{emsfile} {emsfileName} 不存在",
"visTypeVega.emsFileParser.missingNameOfFileErrorMessage": "具有 {dataUrlParamValue} 的 {dataUrlParam} 需要 {nameParam} 参数(文件名)",
"visTypeVega.esQueryParser.autointervalValueTypeErrorMessage": "{autointerval} 必须为 {trueValue} 或数字",
@@ -10670,4 +10667,4 @@
"xpack.fileUpload.fileParser.errorReadingFile": "读取文件时出错",
"xpack.fileUpload.fileParser.noFileProvided": "错误,未提供任何文件"
}
-}
\ No newline at end of file
+}