release: v0.1.11 — quality & stability improvements
fix(core): clear _outlineTimer in destroy() to prevent post-destroy callbacks fix(core): remove '<' from BRACKET_PAIRS to avoid HTML tag conflicts fix(core): setValue now updates outline panel and resets gutter scroll fix(core): getValue returns '' on destroyed instances (safe API access) opt(core): _renderGutter skips rebuild when line count unchanged chore: bump version 0.1.10 → 0.1.11 across all files
This commit is contained in:
+9
-3
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* MetonaEditor Core - 编辑器核心
|
||||
* @module core
|
||||
* @version 0.1.10
|
||||
* @version 0.1.11
|
||||
* @description MarkdownEditor 类实现:DOM 构建、事件、渲染、历史栈、选区操作、模式切换
|
||||
* v0.1.6: 插件依赖拓扑排序、实例 i18n、快捷键/工具栏定制、右键菜单、Toast
|
||||
* v0.1.7: 行号装订线、自动格式化、括号自动闭合、拖放、大纲面板
|
||||
@@ -27,7 +27,7 @@ const TOAST_ICONS = {
|
||||
|
||||
/** 括号/引号自动闭合映射 */
|
||||
const BRACKET_PAIRS = {
|
||||
'(': ')', '[': ']', '{': '}', '<': '>',
|
||||
'(': ')', '[': ']', '{': '}',
|
||||
'"': '"', "'": "'", '`': '`',
|
||||
'*': '*', '_': '_',
|
||||
};
|
||||
@@ -1164,14 +1164,19 @@ class MarkdownEditor {
|
||||
|
||||
// ============ 公共 API ============
|
||||
|
||||
getValue() { return this._value; }
|
||||
getValue() { return this._destroyed ? '' : this._value; }
|
||||
|
||||
setValue(md, opts = {}) {
|
||||
if (this._destroyed) return this;
|
||||
this._value = md || '';
|
||||
this.textarea.value = this._value;
|
||||
if (!opts.silent) this._pushHistory();
|
||||
this._render();
|
||||
this._renderGutter();
|
||||
this._updateWordCount();
|
||||
this._updateOutline();
|
||||
// 同步行号滚动
|
||||
if (this.gutter) this.gutter.scrollTop = 0;
|
||||
if (!opts.silent) {
|
||||
this._emit('change', this._value);
|
||||
if (typeof this.config.onChange === 'function') {
|
||||
@@ -1507,6 +1512,7 @@ class MarkdownEditor {
|
||||
|
||||
if (this._renderRaf) cancelAnimationFrame(this._renderRaf);
|
||||
if (this._historyTimer) clearTimeout(this._historyTimer);
|
||||
if (this._outlineTimer) clearTimeout(this._outlineTimer);
|
||||
|
||||
this._cleanups.forEach((fn) => { try { fn(); } catch (_) {} });
|
||||
this._cleanups = [];
|
||||
|
||||
Reference in New Issue
Block a user