Files
thzxx d6a618af5d feat: v0.4.3 — 浮动工具栏定位引擎重做 + 程序化编辑统一刷新管线
- 浮动工具栏 mirror 镜像测量:隐藏镜像层复制 textarea 排版样式,选区锚点插零宽字符读像素坐标,CJK/软换行/跨行选区误差全部消除

- 实测尺寸替代魔法数字;滚动 rAF 节流重定位;滚出视口自动隐藏;a11y:role=toolbar + aria-label、visibility 移出 Tab 序列、键盘可达

- 修复死开关/监听器泄漏/销毁后 focus 崩溃/blur 焦点抖动误隐藏

- _afterProgrammaticEdit 统一 8 条程序化路径的渲染/行号/字数/大纲/事件刷新;右键菜单 label 转义、copyAsHTML Firefox 降级、paste 失败提示、Esc 退出全屏

- 测试 871 → 895,e2e 22 → 28 项断言(含真实浏览器浮动工具栏布局验证)
2026-08-20 20:43:01 +08:00

364 lines
25 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Changelog
All notable changes to MetonaEditor will be documented in this file.
## [0.4.3] - 2026-08-20
### Fixed
- **浮动工具栏定位系统性偏移(本轮主题)**: 旧版按"ASCII 0.6em / CJK 1em"逐字符估算宽度并按逻辑行推算纵坐标,中文混排、软换行(长行折行)、跨行选区、字体 fallback 均产生累积误差;现改为 mirror 镜像测量——隐藏镜像层复制 textarea 全部排版样式(font/行高/padding/white-space/overflow-wrap/tabSize/宽度),在选区锚点(文档序中点)插入零宽字符 marker 读取像素坐标,CJK、折行、tab 渲染宽度、字体差异的误差全部消除。锚点滚出可视区自动隐藏;textarea 滚动时 rAF 节流重定位;分隔条拖拽结束与窗口 resize 后隐藏待重新触发。
- **浮动工具栏魔法数字**: 工具栏宽度/高度改为渲染后实测 `getBoundingClientRect()`(居中、右边界 clamp、上下翻转判断全部基于实测值),删除 `-80` / `36` / `200` 等硬编码。
- **selectionDirection 反向修正逻辑错误**: 旧版在 backward 选区时将锚点列偏移乘 -1,但 `selectionStart` 恒为文档序小端,方向不影响中点;已删除。
- **`floatingToolbar: false` 后 toggle 变"死开关"**: 构造时条件跳过 `_initFloatingToolbar()` 导致事件监听器从未绑定,运行时 `toggleFloatingToolbar()` 打开后工具栏永不显示;现构造时无条件绑定事件(show 内部检查启用状态),死开关修复。
- **浮动工具栏隐藏态可聚焦**: 旧版仅 `opacity:0`,按钮仍在 Tab 序列中(可聚焦但不可见);现 `visibility:hidden` 纳入过渡,隐藏时移出 Tab 序列与可访问性树。
- **浮动工具栏按钮键盘不可操作**: 旧版命令绑定在 `mousedown`(键盘 Enter/Space 无效);现 mousedown 仅阻止夺焦,命令统一走 `click`,键盘可达。执行命令后工具栏隐藏。
- **浮动工具栏实例销毁后 focus 崩溃**: 按钮 click 的延迟 `focus()` 回调在 `destroy()` 之后触发时 `textarea` 已为 null,抛 `TypeError`;现增加存活检查。
- **浮动工具栏监听器泄漏**: `initFloatingToolbar` 绑定的 mouseup/keyup/blur/click/scroll/resize 监听器从不清理,destroy 后闭包引用实例;现统一注册到 `_cleanups`,镜像层 DOM 随 destroy 移除。
- **浮动工具栏被焦点抖动误隐藏**: blur 后 300ms 延迟隐藏的回调不校验焦点状态——自动化工具(如 Playwright fill 后还原焦点再 focus 回来)或宿主页面的快速焦点切换会让刚显示的工具栏被延迟回调误杀;现延迟到期时校验 `document.activeElement === textarea`,焦点已回归则不隐藏。
- **程序化编辑路径刷新与事件不一致(8 条路径)**: 智能 Enter / 括号自动闭合 / Tab 缩进 / `insert()` / `insertLink` / `insertImage` / `formatTable` / searchReplace 替换 此前各自为政——Smart Enter 后预览不刷新、括号闭合后字数不更新、Tab 后字数不加、点 h1 后大纲面板不出现新标题、程序化路径不发 `input` / `beforeChange` / `afterChange``onInput` / `onChange` 回调全漏);现统一收敛到 `_afterProgrammaticEdit()` 管线:渲染 + 行号 + 字数 + 大纲 + input/change 事件 + onInput/onChange 回调 + before/afterChange 钩子。undo/redo 与 replaceAll/replaceAllRegex 同步接入。
- **右键菜单自定义项 HTML 注入**: `registerContextMenu``label` / `shortcut` 未转义直接 `innerHTML``<img src=x onerror=...>` 可注入;现经 `escapeHTML` 转义。
- **`copyAsHTML` 在无 ClipboardItem 环境崩溃**: Firefox 等环境 `new ClipboardItem()` 构造即抛未捕获 `TypeError`;现能力检测 + try-catch,降级为纯文本剪贴板写入。
- **右键粘贴静默失败**: `execCommand('paste')` 被现代浏览器安全策略拒绝后无任何反馈;现失败时 toast 提示改用 Ctrl+V`pasteBlocked` 六语言文案)。
- **全屏无法用 Esc 退出**: 现全屏模式下按 Esc 退出(document 级监听,destroy 清理)。
### Added
- **浮动工具栏 a11y**: `role="toolbar"` + 实例语言 `aria-label``formatToolbar` 六语言文案),隐藏态自动移出可访问性树。
- 回归与补强测试 24 个(死开关修复、镜像层懒创建/复用/销毁清理、滚动重定位、a11y 属性、键盘 click 执行并隐藏、resize 隐藏、blur 焦点抖动防护、管线回归:Smart Enter 预览刷新与 input 事件、括号闭合预览与字数、Tab 字数、insert 行号、exec 后大纲刷新、undo/replaceAll 的 afterChange、exec 的 beforeChange 参数对与 onInput 回调、copyAsHTML 降级、paste toast、Esc 全屏、右键菜单转义),总数 871 → 895。
- e2e 冒烟测试 6 项新断言:浮动工具栏真实浏览器布局验证(中文选区显示、水平/垂直定位容差、bold 命令生效、执行后隐藏、长行折行选区保持可视区内),e2e 断言总数 22 → 28。
### Changed
- 行为变更:程序化编辑路径(命令 / 快捷键 / 插件 / API 直改)现补发 `input` 事件与 `beforeChange` / `afterChange` 钩子及 `onInput` / `onChange` 回调,与原生输入路径语义一致(`beforeChange` 的 oldValue 参数由调用方闭包保存,时机与原生路径相同)。
---
## [0.4.2] - 2026-08-19
### Fixed
- **插件面板文案未跟随实例 locale**: searchReplace / shortcutHelp / imagePaste 面板与提示此前使用全局 `t()`,实例 `locale` 与全局语言不一致时显示错误语言(v0.4.0 修复了核心 UI,插件面板遗漏);现统一经实例 `editor.t()` 取词。
- **undo/redo 后预览区跳顶**: `_applyHistory` 此前硬编码 `previewPane.scrollTop = 0`,分屏下长文档撤销时预览跳回顶部;现按滚动比例保存/恢复。
- **shortcutHelp 卸载面板残留**: `unuse('shortcutHelp')` / `destroy()` 此前保存的是 install 时刻的面板引用(null),已打开的快捷键面板不随之移除;现经 holder 取实时引用清理。
- **大纲点击在无 CSS.escape 环境崩溃**: `outline.ts` 直接调用全局 `CSS.escape()`jsdom 等未暴露 `window.CSS` 的环境下点击大纲链接抛 `ReferenceError`,光标定位静默失效;现能力检测 + 简易转义兜底。
- **大纲点击光标定位不准**: 此前用 `indexOf(标题文本)` 定位,重复标题永远跳第一个;`data-line` 属性误存标题 id 而非行号。现构建时计算各标题源码行号(跳过围栏代码块),点击按行号精确定位,`data-line` 记录 1 基行号。
- **setLocale 不刷新已渲染 UI**: 状态栏统计标签、大纲标题要等下一次输入才切换语言;现切换即时刷新。
- **浮动工具栏中文选区定位偏左**: 列宽估算固定按 ASCII 0.6em,中文全角字符约 1em;现逐字符按 CJK 判定累计宽度。
- **ko 语言包 imageTooLarge 混用中文全角括号**: 统一为半角括号。
### Added
- **运行时大纲 API**: `editor.setOutline(on)` / `editor.isOutline()`,运行时开关大纲面板(替代直接操作 `config.outline` + `_buildOutline()` 的私有用法)。
- **`getRenderCacheSize()`**: 暴露行内渲染缓存当前条目数(parser 导出),供观测 FIFO 淘汰。
- 回归与补强测试 30 个(7 个此前零断言事件:beforeRender / afterRender / zenChange / fullscreen / copy / fileOpened / fileSaved;全局钩子 beforeCreate / beforeDestroy / afterDestroy5 个零测试配置项:placeholder / height / spellcheck / tabSize(含 0 与 4/ historyDebounce;修复 3 处恒真/弱断言:同步滚动(含新增反向联动验证)、渲染缓存 FIFO 真实淘汰、搜索 findNext/prev 选中内容),总数 841 → 871。
- jest 覆盖率阈值:全局 lines 85% / branches 70%parser lines 95%(基线 94.95% / 75.72% / 98.93%)。
### Changed
- **CI lint 改为阻断**: 移除 verify job 中 lint 步骤的 `continue-on-error`lint 失败不再静默放行。
- **build.sh 依赖安装**: `npm install``npm ci`,保证构建可重现。
- **rollup.config.js 死代码清理**: 移除从未被引用的 `terserPlugin` / `isProd` 变量。
- 文档全面同步:README / docs.html / index.html 修正 "CI 4 job"(实际 5 个)、`document.body()` 错误写法、`afterChange` / `fileSaved` 事件参数(以源码为准)、docs.html 补齐约 15 处缺失 API`editor.t()``MeEditor.getStatus()` / `destroy()``configureToolbar` / `removeToolbarButton`、PluginManager & pluginUtils、`safeUrl` / `slugify` / `getSupportedLanguages``formatCurrency`、全局 beforeChange / afterChange 钩子、`data:image` 500KB 限制等);demo.html 私有 API hack 改用 `setOutline()` 公开 API。
---
## [0.4.1] - 2026-08-11
### Added
- **`zenMaxWidth` 配置项**: Zen 专注模式内容区宽度可配置(`number` 为 px / `string` 原样作为 CSS 值 / `false` 不限制),默认由硬编码 820px 提升至 960px,经 CSS 变量 `--md-zen-max-width` 实现实例级隔离。
- **运行时 API**: `editor.setZenMaxWidth(width)` / `editor.getZenMaxWidth()` 随时调整专注模式宽度。
### Fixed
- **`wordWrap: false` 配置不生效**: 构造函数此前将 `_wordWrap` 硬编码为 `true`,忽略配置项,导致初始仍自动换行;现读取配置并在构建时应用 `white-space: pre`
- **`outline: true` 启动时不显示大纲面板**: 构造函数此前只注册滚动跟踪、未构建面板,须等首次输入才出现;现构造后自动构建,且 `setMode()` 切换回预览类模式时同步重建。
- **edit 模式初始行号不渲染**: `_render()` 在 edit 模式直接返回导致 gutter 为空;现 edit 模式也维护行号装订线。
- **exportTool 卸载泄漏**: `unuse('exportTool')` / `destroy()` 此前不清理挂载在实例上的 `exportMarkdown` / `exportHTML` / `exportPDF` 方法;现卸载时一并删除。
- **searchReplace 替换后字数统计过期**: `replaceOne` / `replaceAll` 直接改值后未刷新状态栏统计;现调用 `_updateWordCount()`
### Added
- 回归测试 15 个(zenMaxWidth 默认/数字/字符串/false/运行时更新/启动应用、wordWrap: false 生效、outline 构造自动构建与模式切换重建、edit/preview 模式初始行号、exportTool 卸载清理),总数 826 → 841。
---
## [0.4.0] - 2026-08-11
### Added
- **Playwright 浏览器冒烟测试**: `e2e/` 目录(本地宿主页 + 真实 Chromium),22 项断言覆盖渲染 / 输入实时预览 / 工具栏命令 / 三模式切换 / 主题 / 搜索插件 / 状态栏 / 撤销 / 实例 API,并自动检测页面 console 错误。`npm run test:e2e` 一键运行,CI 新增 e2e job。
- **`sideEffects: false`**: 便于消费方打包器 tree-shaking。
### Fixed
- **实例 locale 未作用于全部 UI 文案**: 状态栏、工具栏 tooltip、右键菜单、大纲标题、插入链接/图片占位、模式切换播报此前混用全局 `t`;浏览器默认语言与实例 `locale` 不一致时显示错误语言。现 `_i18nCtx` 提前至 DOM 构建前创建,所有 UI 文案统一走实例 `t()`
### Changed
- **`MeEditor.destroy()` 全面复位**: 额外清理全局静态钩子(beforeCreate/afterCreate/beforeChange 等),并自动重建内部全局插件注入钩子,保证 `destroy()``MeEditor.use()` 依旧可用。
### Added
- 回归测试 5 个(实例 locale 决定状态栏/按钮/右键菜单文案、destroy 钩子清理与重建、destroy 后全局插件仍可用),总数 821 → 826。
---
## [0.3.1] - 2026-08-10
### Performance
- **高亮规则缓存**: `highlight()` 不再每次调用重建正则规则表,按语言缓存(`registerLanguage` 覆盖时自动失效)。
- **统计增量计算**: `getStats()` / `_updateWordCount()` / `_renderGutter()` 基于共同前缀/后缀的差异区间增量计算(含单词边界扩展保证一致),击键时不再对全文做 O(n) 正则。
- **大纲线性构建**: outline 树构建由递归 O(n²) 改为迭代栈 O(n),长文档无延迟。
### Changed
- **拖放图片大小限制**: 拖入 >500KB 的图片时 toast 警告且不插入,与 imagePaste 插件行为一致。
- **`scrollToLine` 真实行高**: 使用 `getComputedStyle().lineHeight` 替代硬编码 22px。
- **undo/redo 光标恢复**: 撤销/重做后光标位置 clamp 恢复(不越界)。
- **selectionChange / cursorMove 与浮动工具栏解耦**: 事件现无条件触发(`floatingToolbar: false` 时仍可用)。
- **`unregisterShortcut` 大小写归一**: 注册 `Ctrl+B` 可用 `ctrl+b` 注销。
- **toast 动画接入 ANIMATIONS**: `animation` 参数真正应用 enter/leave 变换与时长缓动(slide/fade/scale/bounce/flip/rotate/zoom)。
- **实例主题订阅随销毁断开**: `getThemeContext()` 新增 `dispose()``destroy()` 时自动断开外部跟随的 MutationObserver / 轮询订阅。
### Added
- 回归测试 20 个(高亮缓存失效 / 增量统计一致性与边界 / outline 树结构配对与长文档 / undo 光标 / selectionChange 解耦 / 快捷键归一 / toast 动画 / 拖放限大小 / 主题 dispose),总数 801 → 821。
---
## [0.3.0] - 2026-08-10
### Fixed
- **脚注 XSS 属性注入**: 脚注引用的 `fnId``[^id]` 中的 id)此前未转义直接拼入 `href` / `id` 属性,`[^a" onclick="x]` 可注入事件属性;现经属性级转义,行内引用与脚注区渲染均覆盖。
- **全局插件静默失效**: `MeEditor.use('searchReplace' | 'shortcutHelp' | 'imagePaste')` 此前在 `beforeCreate` 钩子安装,但此时 DOM 尚未构建、`editor.textarea` 不存在,三个依赖 textarea 的插件静默跳过;现改为 `afterCreate` 注入,DOM 就绪后再安装。
- **引用链接跨文档串数据**: 行内渲染缓存仅以文本为 key,不同文档中相同文本 + 不同 `[ref]: url` 定义会命中彼此缓存返回错误链接;现缓存 key 附加 refs 指纹(`parseMarkdown` 预计算,`renderTokens` 直接调用时兜底)。
- **underline 预览不可见**: `Ctrl+U` 生成的 `<u>` 此前被解析器转义为字面量 `&lt;u&gt;`;现解析器白名单透传裸 `<u>` / `</u>`(无属性,带属性的 `<u onclick=...>` 仍被转义,无注入面),代码块 / 行内代码内不受影响。
- **`getStatus().locale` 与实例不一致**: 此前返回全局 locale,实例 `setLocale` 后状态不跟随;现返回实例 locale,渲染 env 的 `locale` 字段同步改为实例级。
- **`replaceAll` 替换串 `$` 语义陷阱**: `replaceAll` 的替换文本现按字面处理(`$` 无特殊含义);`replaceAllRegex` 保留正则捕获组语义(`$1`)不变。
### Changed
- **`use()` 同名防重**: 同名插件重复安装时 warn 并跳过(`unuse` 后可重新安装),消除全局插件与 `config.plugins` 重复安装问题。
### Added
- 回归测试 19 个(脚注注入 / 全局插件 / 缓存指纹 / underline / getStatus locale / replaceAll `$` / use 防重),总数 782 → 801。
---
## [0.2.5] - 2026-08-09
### Fixed
- **npm 发布配置**: `module` / `exports.import` 不再指向 TS 源码,产物改用标准 `.mjs` / `.cjs` 扩展名(此前 `"type": "module"` 导致 Node 将 `.js` 产物按 ESM 解析,`require()` 拿不到任何导出)。
- **XSS 属性注入**: 链接/图片的 `href`/`src`/`alt`/`title` 及代码块 `language-*` 类与标题属性现经属性级转义(`escapeHTML` 在浏览器环境不转义双引号,此前的属性拼接存在注入面)。
- **本地存储串扰**: 分隔条比例键改为 `metona-editor-divider-${id}`,多实例互不覆盖。
### Added
- **maxLength 生效**: 之前仅有类型与默认值,现绑定 textarea `maxlength` 并对 `setValue` / `insert` / `replaceAll` / `replaceAllRegex` 截断。
- **zenMode 初始状态**: 配置 `zenMode: true` 启动即进入专注模式(此前仅 `toggleZen()` 可进入)。
- **搜索面板大小写 / 全字匹配**: `matchCase` / `wholeWord` 翻译键此前存在但未实现,现补齐 UI 开关与匹配逻辑(普通与正则模式均支持,中文全字边界感知)。
- **内置轻量语法高亮**: 新模块 `src/highlight.ts`,零依赖 tokenizer13 种语言,`MeEditor.highlight` 即插即用,输出 `me-hl-*` 类。
- **exportPDF**: exportTool 新增 `editor.exportPDF()`(隐藏 iframe + window.print)。
- **imagePaste 尺寸限制**: `editor.use('imagePaste', { maxSizeKB: 500 })`,超限 toast 警告。
- **性能基准**: `npm run bench`parseMarkdown 1MB ≈ 51mshighlight 200 函数 ≈ 1.2ms)。
### Changed
- **core.ts 拆分**: 命令、浮动工具栏、右键菜单、大纲 4 组方法拆至独立模块(`commands.ts` / `floating-toolbar.ts` / `context-menu.ts` / `outline.ts`),core 从 1162 行降至 865 行,API 完全兼容。
- **插件状态类型收紧**: 6 个预设插件的实例状态改用 Symbol 键存储(`EditorLike` 接口 + `pluginState` 助手),消灭 `(editor as any).__xxx` 魔法属性。
- **eslint type-aware**: 启用 `parserOptions.project``consistent-type-imports` / `no-unnecessary-type-assertion` 规则,0 errors。
- **CI 并行化**: 测试拆分为 parser / core / rest 三个并行 job,另设跨 Node 18/20/24 的 verify jobtypecheck + lint + build)。
- **docs.html / README 补齐**: 光标选区 API、浮动工具栏、replaceAll、新事件、内置高亮文档。
- 版本同步 0.2.4 → 0.2.5,测试 725 → 768。
---
## [0.2.4] - 2026-07-25
### Changed
- **Search panel redesigned**: Dark-themed glass-morphism design with SVG icons, smooth animation, improved spacing and focus states.
- **README & site install instructions**: Complete npm/CDN/ESM/CJS/Browser import examples added.
### Fixed
- **CI hang**: Removed `setInterval` polling in floating toolbar; now uses pure event-driven selection detection.
- **Floating toolbar positioning**: Corrected coordinate system (viewport→pane-local) for accurate placement near selected text.
- **Floating toolbar toggle button**: Now properly disables/enables via `toggleFloatingToolbar()` API.
---
## [0.2.3] - 2026-07-25
### Added
- **German (de) locale**: Complete translations for all 60+ UI keys.
- **Floating format toolbar**: Auto-shows bold/italic/code/link/strikethrough buttons above text selection.
- **Cursor/selection APIs**: `getSelectedText()`, `getCursorPosition()`, `setCursorPosition()`, `scrollToLine()`, `selectLine()`, `selectAll()`.
- **Content manipulation APIs**: `replaceAll()`, `replaceAllRegex()`, `lineCount()`, `getLine()`.
- **New events**: `selectionChange` and `cursorMove` emitted for cursor/selection tracking.
- **`floatingToolbar` config option**: Enable/disable floating toolbar (default `true`).
### Changed
- **`floatingToolbar` added to `DEFAULTS` and `EditorOptions` type**.
- **6 locales now**: zh-CN, en-US, ja, ko, fr, de.
### Fixed
- **`onLinkClick` type fix**: Removed `as any` cast; properly typed in `EditorOptions` and `DEFAULTS`.
- **Version consistency**: All files synced to 0.2.3.
---
## [0.2.2] - 2026-07-25
### Added
- **French (fr) locale**: Complete translations for all 60+ UI keys.
- **Outline scroll tracking**: Active heading auto-highlights in outline panel as you scroll.
- **Table auto-format**: `exec('formatTable')` aligns column widths in Markdown tables.
- **Code block title**: ` ```js title=hello.js ` renders a styled title bar above code blocks.
- **Escaped pipe in tables**: `\|` in table cells no longer splits columns.
- **Custom block token fallback render**: Unknown token types now render as `<div class="me-block-{type}">` instead of empty string.
- **Gutter incremental update**: Line number gutter uses DOM diff instead of full innerHTML replacement.
- **694 tests** (up from 684).
### Changed
- **All 6 plugins now use closure-based state** — searchReplace, imagePaste, shortcutHelp, fileSystem, autoSave refactored for thread safety.
- **shortcutHelp plugin is now i18n-aware** — shortcut descriptions follow the active locale.
- **Context menu labels (Cut/Copy/Paste/Select All) are now i18n-translated** across all 5 locales.
- **Warm theme now includes `progressBg` and `closeHoverBg`** for completeness.
- **Fenced code block regex improved** to capture optional info string attributes.
### Fixed
- Plugin `this` context pollution eliminated for all 6 preset plugins.
- Context menu labels no longer hardcoded to English.
- Warm theme missing CSS variable fields restored.
---
## [0.2.1] - 2026-07-25
### Added
- **Reference link/image resolution**: Full support for `[text][ref]` and `![alt][ref]` syntax with `[ref]: url` definitions.
- **Right-click context menu**: Built-in undo/redo/cut/copy/paste/selectAll with custom item support.
- **RTL (Right-to-Left) CSS support**: Full RTL layout for Arabic, Hebrew, Persian and other RTL languages.
- **Japanese (ja) and Korean (ko) locales**: Complete translations for all 60+ UI keys.
- **Divider position persistence**: Split-view divider ratio saved to localStorage and restored on reload.
- **Regex search support**: Toggle regex mode in search panel with `.*` button.
- **Export HTML with embedded CSS**: `exportHTML` now includes minimal CSS styles for standalone viewing.
- **`beforeChange` / `afterChange` lifecycle hooks**: Instance and global hooks that fire around content changes.
- **`copyAsMarkdown()` / `copyAsHTML()` APIs**: Copy editor content to clipboard as Markdown or rich HTML.
- **New test suites**: `tests/index.test.ts` (global API) and `tests/styles.test.ts` (CSS injection).
- **684 tests** (up from 610), 9 test suites (up from 7).
### Changed
- **autoSave plugin refactored**: Uses closure-based state per instance instead of `this` context, preventing state conflicts when the same plugin object is shared across multiple editors.
- **Plugin `install()` now receives `options` as second argument** for cleaner API.
- **RTL locale detection improved**: Now detects RTL by language prefix (e.g., `ar-SA` → RTL).
### Fixed
- Reference link syntax `[text][ref]` now correctly resolves to links instead of raw text.
- Reference image syntax `![alt][ref]` no longer produces empty `src=""`.
- autoSave plugin state isolation when used across multiple editor instances.
- Footnote definitions no longer incorrectly consumed by reference definition parser.
---
## [0.2.0] - 2026-07-23
### Added
- **TypeScript full rewrite**: All 12 source modules in TypeScript strict mode with complete type exports.
- **Parser 99% line coverage**: Self-built Markdown parser with 14 block-level handlers.
- **parseTokens / renderTokens API**: Separate tokenization and rendering for transform pipelines.
- **registerBlockHandler**: Extensible block syntax via handler registration.
- **610 tests**: Comprehensive test coverage across 7 suites.
- **Triple emphasis `***text***`**: Bold+italic combined formatting.
- **Link text inline formatting**: Bold, italic, and code within link text.
- **Backslash escape**: `\*`, `\_`, `\\` for literal punctuation.
- **Tab-indented code blocks**: Tab or 4-space indented code.
### Changed
- **Plugin system v2**: Topological sort dependency management, 6 preset plugins.
- **Theme system overhaul**: CSS variable-based, instance isolation, external theme following.
- **i18n overhaul**: Instance-level locale isolation, plural rules, remote loading.
---
## [0.1.15] - 2026-07-21
### Added
- Parser short and medium-term improvements.
- Triple emphasis syntax `***bold italic***`.
- Link text inline formatting support.
- Backslash escape sequences.
- `parseTokens` / `renderTokens` separation API.
---
## [0.1.14] - 2026-07-20
### Added
- Syntax highlighting feature (reverted in 0.1.15).
- Mermaid.js CDN support in demo page.
---
## [0.1.7] - 2026-07-19
### Added
- Line number gutter with active line highlighting.
- Smart Enter (list/quote continuation).
- Bracket auto-close with selection wrapping.
- Outline panel.
---
## [0.1.6] - 2026-07-18
### Added
- `topologicalSort` for plugin dependency resolution.
- `validateConfig` for plugin configuration validation.
- `editor.unuse()` to uninstall plugins.
- `editor.registerShortcut()` / `unregisterShortcut()`.
- `editor.toast()` notification API.
---
## [0.1.5] - 2026-07-17
### Added
- Instance-level theme context (`createInstanceTheme`).
- `followExternalTheme` / `adoptFromParent` for external theme following.
- `exportCSSVars` / `getCSSVariable` for theme inspection.
- `applyThemeToElement` for scoped theme application.
---
## [0.1.4] - 2026-07-16
### Added
- Setext headings (underlined H1/H2).
- Nested lists (3+ levels).
- Indented code blocks (4 spaces / tab).
- HTML comment passthrough.
- Entity reference protection.
- Hard line breaks (2 trailing spaces).
- Link titles with single quotes.
- LaTeX math formulas (`$inline$` / `$$block$$`).
- Footnotes `[^id]`.
- Definition lists (`Term\n: definition`).
- Backtick exact matching (`` ` ``).
- Enhanced emoji set (150+).
---
## [0.1.3] - 2026-07-15
### Fixed
- `exec` custom action support via `_customActions`.
- `refresh()` method for forced re-render.
- Focus/blur event parameter fixes.
---
## [0.1.2] - 2026-07-14
### Added
- Highlight marker `==text==`.
- Superscript `x^2^` and subscript `H~2~O`.
- Emoji shortcodes `:smile:` (100+ emojis).
- Table column alignment (`:---:`, `---:`).
- Read-only mode with `readOnly` config and `setReadOnly()`.
---
## [0.1.0] - 2026-07-10
### Added
- Initial release.
- Markdown editor with edit/split/preview modes.
- Self-built parser (CommonMark + GFM).
- Plugin system with autoSave, exportTool, searchReplace.
- Theme system (light/dark/auto).
- i18n (zh-CN/en-US).
- Toolbar, shortcuts, history stack.