From 2dd8471c15e48d2738653f5e484f238aec441ad0 Mon Sep 17 00:00:00 2001 From: jocs Date: Sun, 3 Nov 2019 17:41:34 +0800 Subject: [PATCH] Fix: unexpected load all languages --- src/muya/lib/contentState/codeBlockCtrl.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/muya/lib/contentState/codeBlockCtrl.js b/src/muya/lib/contentState/codeBlockCtrl.js index 237db711..77b3cf16 100644 --- a/src/muya/lib/contentState/codeBlockCtrl.js +++ b/src/muya/lib/contentState/codeBlockCtrl.js @@ -44,7 +44,10 @@ const codeBlockCtrl = ContentState => { * @param lang Language identifier */ ContentState.prototype.updateCodeLanguage = function (block, lang) { - loadLanguage(lang) + if (lang && typeof lang === 'string') { + loadLanguage(lang) + } + if (block.functionType === 'languageInput') { const preBlock = this.getParent(block) const nextSibling = this.getNextSibling(block) @@ -101,7 +104,9 @@ const codeBlockCtrl = ContentState => { functionType: 'languageInput' }) - loadLanguage(language) + if (language) { + loadLanguage(language) + } block.type = 'pre' block.functionType = 'fencecode'