Skip to content

Commit

Permalink
fix: #925 默认关掉codemirror对github特殊链接格式的支持
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsonliu committed Sep 27, 2024
1 parent 729abfe commit 22d691b
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions src/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 22d691b

Please sign in to comment.