feat: v0.2.1 — reference links, context menu, RTL, ja/ko, regex search, hooks, copy API
## Added - Reference link/image resolution: [text][ref] + ![alt][ref] with [ref]: url definitions - Right-click context menu: undo/redo/cut/copy/paste/selectAll + custom items - RTL CSS layout support for Arabic, Hebrew, Persian etc. - Japanese (ja) and Korean (ko) locales with 60+ keys each - Divider position localStorage persistence - Regex search toggle in search/replace panel - Export HTML with embedded CSS styles - beforeChange / afterChange lifecycle hooks (instance + global) - copyAsMarkdown() / copyAsHTML() clipboard APIs - CHANGELOG.md, CONTRIBUTING.md, CI workflow (.github/workflows/ci.yml) - 2 new test suites: index.test.ts, styles.test.ts (684 total tests, +74) ## Changed - autoSave plugin: closure-based state per instance instead of this context - Plugin install() now receives options as second argument - RTL locale detection: now uses language prefix (ar-SA → RTL) - Rollup dev mode: only builds UMD format - prepublishOnly now includes typecheck + test - Version bumped to 0.2.1 ## Fixed - [text][ref] now correctly renders as link (was raw text) - ![alt][ref] no longer produces empty src - autoSave plugin state isolation across multiple editor instances - Footnote definitions no longer consumed by refDef handler
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
> TypeScript 重构 · 零运行时依赖 · 轻量级桌面端 Markdown Editor 库
|
||||
|
||||
[](https://git.metona.cn/MetonaTeam/-/packages/npm/@metona-team%2Fmetona-editor)
|
||||
[](https://git.metona.cn/MetonaTeam/-/packages/npm/@metona-team%2Fmetona-editor)
|
||||
[](./LICENSE)
|
||||
[](./tests)
|
||||
[](./tests)
|
||||
[](./tests)
|
||||
[](./tsconfig.json)
|
||||
|
||||
@@ -16,10 +16,14 @@
|
||||
- **插件系统 v2** — 拓扑排序依赖管理,6 个预设插件开箱即用,安装 / 卸载生命周期
|
||||
- **三模式视图** — edit / split / preview,拖拽分隔条调整比例,双向滚动同步
|
||||
- **主题系统** — light / dark / warm / auto,CSS 变量可定制,实例级隔离,主题继承,外部跟随
|
||||
- **国际化** — zh-CN / en-US 完整翻译,实例级语言隔离,远程加载翻译包
|
||||
- **编辑体验** — 行号装订线、智能 Enter、括号自动闭合、拖放文件、大纲面板、Zen 专注模式
|
||||
- **国际化** — zh-CN / en-US / ja / ko 完整翻译,实例级语言隔离,远程加载翻译包
|
||||
- **编辑体验** — 行号装订线、智能 Enter、括号自动闭合、拖放文件、大纲面板、Zen 专注模式、右键上下文菜单
|
||||
- **安全** — HTML 转义,XSS 协议过滤(javascript / vbscript / file / data),sanitize 钩子
|
||||
- **桌面端优先** — 纯电脑端设计,无移动端冗余代码
|
||||
- **引用链接** — 支持 `[text][ref]` / `![alt][ref]` 引用式链接和图片,含 title 属性
|
||||
- **RTL 支持** — 完整的从右到左布局适配(阿拉伯语、希伯来语等)
|
||||
- **正则搜索** — 查找替换面板支持正则表达式模式
|
||||
- **分隔条记忆** — 分屏比例自动保存到 localStorage
|
||||
|
||||
---
|
||||
|
||||
@@ -287,6 +291,13 @@ editor.toast(message: string, opts?: {
|
||||
}): this
|
||||
```
|
||||
|
||||
### Copy API
|
||||
|
||||
```typescript
|
||||
editor.copyAsMarkdown(): this // 复制 Markdown 源码到剪贴板
|
||||
editor.copyAsHTML(): this // 复制渲染后的 HTML 到剪贴板
|
||||
```
|
||||
|
||||
### 销毁
|
||||
|
||||
```typescript
|
||||
@@ -352,6 +363,9 @@ import { parseMarkdown, parseTokens, renderTokens, safeUrl, slugify, registerBlo
|
||||
| `linkClick` | 预览区链接点击 | `({ href, text })` |
|
||||
| `fileOpened` | fileSystem 打开文件 | `({ name, handle })` |
|
||||
| `fileSaved` | fileSystem 保存文件 | `({ handle })` |
|
||||
| `beforeChange` | 内容变更前 | `(oldValue, newValue, editor)` |
|
||||
| `afterChange` | 内容变更后 | `(newValue, editor)` |
|
||||
| `copy` | 复制到剪贴板 | `({ type })` |
|
||||
|
||||
### 全局钩子
|
||||
|
||||
@@ -363,6 +377,8 @@ import { parseMarkdown, parseTokens, renderTokens, safeUrl, slugify, registerBlo
|
||||
| `afterRender` | 每次渲染后(全局) |
|
||||
| `beforeDestroy` | destroy 前 |
|
||||
| `afterDestroy` | destroy 后 |
|
||||
| `beforeChange` | 内容变更前(全局) |
|
||||
| `afterChange` | 内容变更后(全局) |
|
||||
|
||||
---
|
||||
|
||||
@@ -393,6 +409,8 @@ import { parseMarkdown, parseTokens, renderTokens, safeUrl, slugify, registerBlo
|
||||
| 表格 | `\| a \| b \|` | `<table>` + 列对齐 |
|
||||
| 链接 | `[text](url 'title')` | `<a>` |
|
||||
| 图片 | `` | `<img>` |
|
||||
| 引用链接 | `[text][ref]` + `[ref]: url` | `<a>` |
|
||||
| 引用图片 | `![alt][ref]` + `[ref]: url` | `<img>` |
|
||||
| 自动链接 | `<https://...>` | `<a>` |
|
||||
| 数学公式 | `$E=mc^2$` `$$\int$$` | `<span>` / `<div>` |
|
||||
| 脚注 | `text[^1]` | `<sup>` + 底部定义 |
|
||||
|
||||
Reference in New Issue
Block a user