CI / test-parser (push) Successful in 9m27s
CI / test-core (push) Successful in 9m34s
CI / test-rest (push) Successful in 9m27s
CI / e2e (push) Failing after 5m15s
CI / verify (20.x) (push) Successful in 9m54s
CI / verify (18.x) (push) Successful in 9m56s
CI / verify (24.x) (push) Successful in 9m48s
0.3.0 修复版: - 脚注 id 属性注入 XSS 防护(行内引用 + 脚注区) - 全局插件注入移至 afterCreate(searchReplace 等依赖 textarea 的插件真正生效)+ use() 同名防重 - 行内渲染缓存附加 refs 指纹,防跨文档引用链接串数据 - 白名单裸标签 <u>/</u> 透传,underline(Ctrl+U)预览可见 - getStatus()/渲染 env 使用实例 locale;replaceAll 替换文本按字面处理 - replaceAllRegex 保留 $1 捕获组语义 0.3.1 性能版: - 高亮规则按语言缓存(registerLanguage 覆盖失效),bench +33% - 统计增量计算:字数/词数/行数差异区间,击键零全量扫描 - outline 树构建 O(n²) → 迭代栈 O(n) - 拖放图片 >500KB 拦截、scrollToLine 真实行高、undo/redo 光标恢复 - selectionChange/cursorMove 与浮动工具栏解耦、unregisterShortcut 大小写归一 - toast 接入 7 种 ANIMATIONS、实例主题订阅随 destroy 断开(dispose) 0.4.0 工程版: - Playwright 真实浏览器冒烟测试(e2e/,22 项断言)+ CI e2e job - sideEffects: false 便于 tree-shaking - MeEditor.destroy() 全面复位(全局钩子清理 + 内部注入钩子重建) - 实例 locale 统一作用于全部 UI 文案(状态栏/工具栏/右键菜单/大纲) 测试 782 → 826,全绿;typecheck/lint/build 通过
15 KiB
15 KiB
Changelog
All notable changes to MetonaEditor will be documented in this file.
[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>此前被解析器转义为字面量<u>;现解析器白名单透传裸<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,零依赖 tokenizer,13 种语言,MeEditor.highlight即插即用,输出me-hl-*类。 - exportPDF: exportTool 新增
editor.exportPDF()(隐藏 iframe + window.print)。 - imagePaste 尺寸限制:
editor.use('imagePaste', { maxSizeKB: 500 }),超限 toast 警告。 - 性能基准:
npm run bench(parseMarkdown 1MB ≈ 51ms,highlight 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 job(typecheck + 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
setIntervalpolling 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:
selectionChangeandcursorMoveemitted for cursor/selection tracking. floatingToolbarconfig option: Enable/disable floating toolbar (defaulttrue).
Changed
floatingToolbaradded toDEFAULTSandEditorOptionstype.- 6 locales now: zh-CN, en-US, ja, ko, fr, de.
Fixed
onLinkClicktype fix: Removedas anycast; properly typed inEditorOptionsandDEFAULTS.- 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.jsrenders 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
progressBgandcloseHoverBgfor completeness. - Fenced code block regex improved to capture optional info string attributes.
Fixed
- Plugin
thiscontext 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]: urldefinitions. - 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:
exportHTMLnow includes minimal CSS styles for standalone viewing. beforeChange/afterChangelifecycle 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) andtests/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
thiscontext, preventing state conflicts when the same plugin object is shared across multiple editors. - Plugin
install()now receivesoptionsas 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 emptysrc="". - 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/renderTokensseparation 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
topologicalSortfor plugin dependency resolution.validateConfigfor 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/adoptFromParentfor external theme following.exportCSSVars/getCSSVariablefor theme inspection.applyThemeToElementfor 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
execcustom 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 subscriptH~2~O. - Emoji shortcodes
:smile:(100+ emojis). - Table column alignment (
:---:,---:). - Read-only mode with
readOnlyconfig andsetReadOnly().
[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.