release: v0.1.6 — plugin v2, i18n instance isolation, shortcuts, toolbar, toast

feat(plugins): plugin system v2
- depends: declarative plugin dependencies with topological sort (Kahn algorithm)
- async plugins: install() returning Promise auto-await
- editor.unuse(name): uninstall individual plugins
- pluginUtils.validateConfig(schema, config): configuration validation
- plugin priority field controls install order within same dependency level

feat(i18n): instance-level locale isolation, pluralization, dynamic loading
- createInstanceI18n(): per-editor independent locale contexts
- editor.setLocale()/getLocale()/t() instance methods
- Plural rules: t('items', { count: 5 }) auto-selects one/other/few/many
- i18nUtils.loadRemote(url, locale): fetch translation packs from remote
- editor.on('localeChange') event

feat(core): toolbar & shortcut customization, context menu, toast
- editor.registerShortcut(combo, handler): custom keyboard shortcuts
- editor.configureToolbar(tools): dynamic toolbar rebuild
- editor.removeToolbarButton(action): remove single button
- editor.registerContextMenu(items): right-click context menu
- editor.toast(msg, {type, duration, animation}): toast notifications

style: toast notifications, context menu, dropdown CSS
- .me-toast with success/error/warning/info types, fade/slide animations
- .me-context-menu with items, separators, shortcut hints

test: 22 new tests covering plugin deps, unuse, shortcuts, toast, i18n plural (521 total)

chore: bump version 0.1.5 → 0.1.6 across all files, site, types
This commit is contained in:
2026-07-24 10:17:57 +08:00
parent d41da3c204
commit 45ed8d5351
20 changed files with 1038 additions and 405 deletions
+4 -4
View File
@@ -2,9 +2,9 @@
> 轻量、零依赖、精致美观的 Markdown Editor 库。单文件,开箱即用,中文优先。
[![npm version](https://img.shields.io/badge/version-0.1.5-blue.svg)](https://www.npmjs.com/package/@metona-team/metona-editor)
[![npm version](https://img.shields.io/badge/version-0.1.6-blue.svg)](https://www.npmjs.com/package/@metona-team/metona-editor)
[![license](https://img.shields.io/badge/license-MIT-green.svg)](./LICENSE)
[![tests](https://img.shields.io/badge/tests-499%20passed-brightgreen.svg)](./tests)
[![tests](https://img.shields.io/badge/tests-521%20passed-brightgreen.svg)](./tests)
[![coverage](https://img.shields.io/badge/coverage-97%25-brightgreen.svg)](./tests)
---
@@ -13,14 +13,14 @@
- **零依赖** — 单文件打包,无任何运行时依赖,UMD/ESM/CJS 三种格式
- **现代化** — 原生 ES2020+ 实现,CSS 变量主题系统,响应式布局,无障碍支持
- **易扩展** — 完整插件系统install/destroy 生命周期),自定义工具栏按钮,预设插件开箱即用
- **易扩展** — 完整插件系统 v2(依赖拓扑排序、异步插件、生命周期钩子、`unuse` 卸载),自定义工具栏按钮与快捷键,预设插件开箱即用
- **易维护** — 模块化源码,JSDoc 注释完整,TypeScript 类型声明,425 个单元测试覆盖
- **易使用** — 工厂函数 `create()` 一行接入,链式 API,中文优先文档与翻译
- **安全** — 内置 XSS 防护(`javascript:`/`vbscript:`/`file:` 协议过滤),HTML 转义,`safeUrl` 净化
- **内置解析器** — 自研 CommonMark 子集 + GFM 扩展(表格含列对齐、任务列表、上下标、数学公式、脚注、嵌套列表、emoji 短码等),可整体替换
- **三模式视图** — edit / split / preview 自由切换,分屏拖拽调整比例,滚动同步,模式切换保持滚动位置
- **主题系统** — light / dark / auto / warm 四套预设,CSS 变量定制,实例级主题隔离,外部主题跟随(syncWithElement / adoptFromParent),主题继承(extends),跟随系统主题,@media print 打印样式
- **国际化** — zh-CN / en-US 完整翻译,RTL 支持,`Intl` 数字/货币/日期格式化
- **国际化** — zh-CN / en-US 完整翻译,实例级语言隔离,复数规则,命名空间,动态远程加载翻译包,RTL 支持
- **历史栈** — 撤销/重做,防抖合并(可配置延迟),可配置上限
- **只读模式** — `readOnly` 配置 / `setReadOnly()` API,适用于预览/展示场景
- **预设插件** — autoSave(草稿)、exportTool(导出 .md/.html)、searchReplaceCtrl+F 查找替换)、imagePaste(粘贴图片转 base64