From 22d691ba04af77e69770740098aadf0642535377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?sunsonliu=28=E5=88=98=E9=98=B3=29?= Date: Fri, 27 Sep 2024 11:02:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20#925=20=E9=BB=98=E8=AE=A4=E5=85=B3?= =?UTF-8?q?=E6=8E=89codemirror=E5=AF=B9github=E7=89=B9=E6=AE=8A=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E6=A0=BC=E5=BC=8F=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Editor.js | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/Editor.js b/src/Editor.js index 2babecb15..6300c57d9 100644 --- a/src/Editor.js +++ b/src/Editor.js @@ -76,7 +76,11 @@ export default class Editor { tabSize: 4, // 一个tab转换成的空格数量 // styleActiveLine: false, // 当前行背景高亮 // matchBrackets: true, // 括号匹配 - mode: 'gfm', // 从markdown模式改成gfm模式,以使用默认高亮规则 + // mode: 'gfm', // 从markdown模式改成gfm模式,以使用默认高亮规则 + mode: { + name: 'gfm', + gitHubSpice: false, + }, lineWrapping: true, // 自动换行 indentWithTabs: true, // 缩进用tab表示 autofocus: true, @@ -433,28 +437,29 @@ export default class Editor { throw new Error('The specific element is not a textarea.'); } const editor = codemirror.fromTextArea(textArea, this.options.codemirror); - editor.addOverlay({ - name: 'invisibles', - token: function nextToken(stream) { - let tokenClass; - let spaces = 0; - let peek = stream.peek() === ' '; - if (peek) { - while (peek && spaces < Number.MAX_VALUE) { - spaces += 1; - stream.next(); - peek = stream.peek() === ' '; - } - tokenClass = `whitespace whitespace-${spaces}`; - } else { - while (!stream.eol()) { - stream.next(); - } - tokenClass = ''; - } - return tokenClass; - }, - }); + // 以下逻辑是针对\t等空白字符的处理,似乎已经不需要了,先注释掉,等有反馈了再考虑加回来 + // editor.addOverlay({ + // name: 'invisibles', + // token: function nextToken(stream) { + // let tokenClass; + // let spaces = 0; + // let peek = stream.peek() === ' '; + // if (peek) { + // while (peek && spaces < Number.MAX_VALUE) { + // spaces += 1; + // stream.next(); + // peek = stream.peek() === ' '; + // } + // tokenClass = `whitespace whitespace-${spaces}`; + // } else { + // while (!stream.eol()) { + // stream.next(); + // } + // tokenClass = ''; + // } + // return tokenClass; + // }, + // }); this.previewer = previewer; this.disableScrollListener = false;