diff --git a/src/components/Editor/Preview/Popup.js b/src/components/Editor/Preview/Popup.js index 8c4057a7d8..b2e7629a29 100644 --- a/src/components/Editor/Preview/Popup.js +++ b/src/components/Editor/Preview/Popup.js @@ -179,6 +179,8 @@ export class Popup extends Component { getPreviewType(value: any) { if ( typeof value == "boolean" || + (typeof value == "string" && value.length < 10) || + (typeof value == "number" && value.toString().length < 10) || value.type == "null" || value.type == "undefined" || value.class === "Function" diff --git a/src/utils/editor/expression.js b/src/utils/editor/expression.js index f885ed7bfb..b36cd2c2c3 100644 --- a/src/utils/editor/expression.js +++ b/src/utils/editor/expression.js @@ -38,14 +38,22 @@ export function updatePreview( const invalidToken = tokenText === "" || tokenText.match(/[(){}\|&%,.;=<>\+-/\*\s]/); + const invalidTarget = (target.parentElement && !target.parentElement.closest(".CodeMirror-line")) || cursorPos.top == 0; + const isUpdating = preview && preview.updating; + const inScope = linesInScope && linesInScope.includes(location.line); - if (invalidTarget || !inScope || isUpdating || invalidToken) { + const invaildType = + target.className === "cm-string" || + target.className === "cm-number" || + target.className === "cm-atom"; + + if (invalidTarget || !inScope || isUpdating || invalidToken || invaildType) { return; }