- 4种存储引擎:Memory / IndexedDB / OPFS / Hybrid - 完整SQL支持:SELECT/INSERT/UPDATE/DELETE/JOIN/GROUP BY/HAVING/DISTINCT - Query Builder链式API + TypeScript泛型支持 - 聚合函数:COUNT/SUM/AVG/MIN/MAX - 事务、插件系统(14 hooks)、发布订阅、数据迁移、导入导出 - React/Vue框架集成 - 264个测试用例,93.46%覆盖率 - 零运行时依赖
3.6 KiB
3.6 KiB
Contributing to MetonaEditor
Thanks for your interest in contributing! This document outlines the development workflow and conventions.
Prerequisites
- Node.js >= 16.0.0
- npm >= 8.0.0
Setup
git clone https://git.metona.cn/MetonaTeam/MetonaEditor.git
cd MetonaEditor
npm install
Development
# Start dev server with hot reload (port 3001)
npm run dev
# Run tests in watch mode
npm run test:watch
# Type check
npm run typecheck
# Lint
npm run lint
npm run lint:fix
# Format
npm run format
Project Structure
src/
├── index.ts # Entry point, global API
├── core.ts # MarkdownEditor class
├── parser.ts # Markdown parser (tokenizer + renderer)
├── plugins.ts # Plugin system & 6 presets
├── themes.ts # Theme system
├── i18n.ts # Internationalization
├── styles.ts # CSS-in-JS injection
├── constants.ts # Types, defaults, configs
├── utils.ts # Utility functions
├── animations.ts # Animation metadata
├── icons.ts # Toolbar SVG icons
└── locales.ts # Translation data
tests/
├── parser.test.ts
├── core.test.ts
├── plugins.test.ts
├── themes.test.ts
├── i18n.test.ts
├── utils.test.ts
├── animations.test.ts
├── index.test.ts
└── styles.test.ts
site/
├── index.html # Landing page
├── demo.html # Full-featured demo
└── docs.html # API documentation
Code Conventions
TypeScript
- Strict mode is enabled — all code must pass
tsc --noEmit. - Export types explicitly. Avoid
anywhere possible. - Use
interfacefor object shapes,typefor unions/primitives.
Style
- Run
npm run formatbefore committing (uses Prettier). - Follow existing comment patterns: JSDoc
/** */for public APIs,//for inline notes. - Keep functions focused and under ~60 lines where practical.
Testing
- Every new feature must include tests.
- Test files mirror source structure:
src/foo.ts→tests/foo.test.ts. - Use descriptive test names:
('does X when Y'). - Run the full suite before submitting:
npm test.
Commits
- Use conventional commit messages:
feat: add reference link resolutionfix: autoSave plugin state conflictdocs: update API referencetest: add index.ts global API testschore: optimize rollup dev build
Building
# Production build (all formats)
npm run build
# Output in dist/
# ├── metona-editor.js UMD
# ├── metona-editor.min.js UMD minified
# ├── metona-editor.esm.js ES Module
# ├── metona-editor.cjs.js CommonJS
# └── metona-editor.d.ts TypeScript declarations
Plugin Development
Plugins follow a simple convention:
const myPlugin = {
name: 'myPlugin',
version: '1.0.0',
description: 'Description of my plugin',
depends: [], // optional: plugin names this depends on
priority: 50, // optional: for topological sort ordering
install(editor, options?) {
// Called when plugin is installed
// Use editor.on() to subscribe to events
// Return a Promise for async initialization
},
destroy(editor) {
// Called when plugin is uninstalled
// Clean up event listeners, timers, DOM nodes
},
};
Releasing
- Update version in
package.jsonandsrc/index.ts(VERSIONconstant). - Update
CHANGELOG.md. - Run full test suite:
npm test. - Build:
npm run build. - Publish:
npm publish.
Questions?
Open an issue at git.metona.cn/MetonaTeam/MetonaEditor/issues.