## 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
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.