diff --git a/src/core.js b/src/core.js index b79423e..b96ddbb 100644 --- a/src/core.js +++ b/src/core.js @@ -109,6 +109,7 @@ class MarkdownEditor { this._shortcuts = []; // v0.1.6: 快捷键注册表 this._contextMenuItems = []; // v0.1.6: 右键菜单项 this._customActions = {}; // 自定义工具栏动作 + this._outlineTimer = null; // 大纲防抖计时器 // 渲染函数:自定义覆盖内置解析器 this._renderFn = (typeof this.config.render === 'function') ? this.config.render : parseMarkdown; diff --git a/src/parser.js b/src/parser.js index 2daaea8..d0497bb 100644 --- a/src/parser.js +++ b/src/parser.js @@ -775,43 +775,31 @@ const extractInlineCodes = (text, codes) => { return result; }; +/** + * 单遍内联扫描正则(模块级常量,避免每次调用重新编译) + */ +const INLINE_RE = new RegExp([ + '(!\\[[^\\]]*\\]\\([^)]+\\))', + '|(? { - // 组合正则:按优先级从左到右 - const INLINE_RE = new RegExp([ - // 图片 ![...](...) - '(!\\[[^\\]]*\\]\\([^)]+\\))', - // 链接 [...](...) - 需要忽略图片前缀 - '|(?