From 1f770941e4889c7beb4432b5da977738bc08e60d Mon Sep 17 00:00:00 2001 From: Eason Wang Date: Mon, 17 Aug 2020 16:33:32 +0800 Subject: [PATCH] fix 13031 --- src/component/toolbox/feature/DataView.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/component/toolbox/feature/DataView.ts b/src/component/toolbox/feature/DataView.ts index e1bc67470..7d572333c 100644 --- a/src/component/toolbox/feature/DataView.ts +++ b/src/component/toolbox/feature/DataView.ts @@ -326,7 +326,9 @@ class DataView extends ToolboxFeature { const textarea = document.createElement('textarea'); viewMain.style.cssText = 'display:block;width:100%;overflow:auto;'; + // function const optionToContent = model.get('optionToContent'); + // undefined const contentToOption = model.get('contentToOption'); const result = getContentFromModel(ecModel); if (typeof optionToContent === 'function') { @@ -371,6 +373,13 @@ class DataView extends ToolboxFeature { addEventListener(closeButton, 'click', close); addEventListener(refreshButton, 'click', function () { + if ((typeof contentToOption === 'undefined' && typeof optionToContent !== 'undefined') || + (typeof contentToOption !== 'undefined' && typeof optionToContent === 'undefined')) { + console.warn('It seems you have just provided one of `contentToOption` and `optionToContent` functions but missed the other one. Data change is ignored.') + close(); + return; + } + let newOption; try { if (typeof contentToOption === 'function') { -- GitLab