Light Mode | Dark Mode |
---|---|
This is a practice project for exploring Svelte
and Tiptap
to create a WYSIWYG
rich text editor.
Yeah, this project is in prototype phase.🤣
This project's final goal is to be able to be a HTML5 Copy/Paste Friendly
& Email Friendly
& Markdown Friendly
feature rich WYSIWYG rich text editor.
Before first public release, I will mainly use Chinese, but, a Q & Issue in English is OK.
Resources will release a docs with English too, after the first public release.
I wrote a post on this demo page to show how I built it. Hopefully, it can help you, and I'm very grateful for your feedback.
- basic Marks, Styles(fontFamily, fontSize, ColorPicker, Indent/Outdent, Text Alignment)
- BulletList/TaskList, Blockquote, Emojis, InlineCode/Code Block, Image, Link, Table...
- nice toolbars with manually adjusted svg icons (thanks iconify)
- table of contents with quick navigation jump
- builtin light i18n system
- (dev mode) assets auto save and assets sidebar, deploy to github.io by CI/CD in production
❗️❗️❗ This project is still in the prototype phase, and there are still many features to be implemented, update very
fast. If you have any
suggestions or ideas, please feel free to open an issue (Currently PR not welcome)🙏
❗️❗️❗ And be careful while saving content, there is no swap file yet.
Goto collection issue for details: #29
- current practice status:
✅ supported; ❌ not support; ⏳ working on; 🚧 planning; - other editors status (mainly paste to):
🆗 partially support; 📋 paste support;
features | 本编辑器 | markdown | 微信公众号 | 知乎 | 掘金富文本 |
---|---|---|---|---|---|
Undo/Redo | ✅ | ✅ | ✅ | ✅ | ✅ |
clear marks | ✅ | ❌ | ✅ | ✅ | ❌ |
bold | ✅ | ✅ | ✅ | ✅ | ✅ |
italic | ✅ | ✅ | ✅ | ✅ | ✅ |
inline code | ✅ | ✅ | ✅ | ✅ | ✅ |
strike | ✅ | ✅ | ✅ | ✅ | ❌ |
superscript | ✅ | ✅ | ❌ | ✅ | ❌ |
subscript | ✅ | ✅ | ❌ | ✅ | ❌ |
underline | ✅ | ✅ | ✅ | ✅ | ✅ |
fontFamily | ✅ | ❌ | ✅ | ❌ | ❌ |
fontSize | ✅ | ❌ | ✅ | ❌ | ❌ |
HeadingLevel | ✅ | ✅ | ✅ | ❌ | ✅ |
link | ✅ | ✅ | ❌ | ✅ | ✅ |
blockquote | ✅ | ✅ | ✅ | ✅ | ✅ |
fontColor | ✅ | ❌ | ✅ | ❌ | ❌ |
bgColor | ✅ | ❌ | ✅ | ❌ | ❌ |
Clear font/bg color only | ✅ | ❌ | ✅ | ❌ | ❌ |
Hr | ✅ | ✅ | ✅ | ✅ | ❌ |
BulletList | ✅ | ✅ | ✅ | ✅ | ✅ |
TaskList | ✅ | ✅ | ❌ | ❌ | ❌ |
Alignment | ✅ | ||||
Indent/Outdent | ✅ | ||||
LineHeight | ✅ | ||||
Paragraph Margin | ✅ | ||||
Emoji | ✅ | ||||
Table | ✅ | ||||
Table Head/Cell Toggle | ✅ | ||||
Table Cell Merge/Split | ✅ | ||||
Table Row Add/Delete | ✅ | ||||
Table Col Add/Delete | ✅ | ||||
Code Block | ✅ | ||||
Image | ✅ | ||||
Table Layout | 🚧 | ||||
Float layout | 🚧 |
To compact with other rich text editors, I'm try my best to use inline style. But using classes to style the editor is can not be avoided. So here is the classes table I'm using in this editor
- ✅ used classes
- ❌ not support
internal classes | extension | current | we-chat |
---|---|---|---|
list-paddingleft-1 | taskList, bulletList | ✅ | ✅ |
This project is a monorepo based on pnpm workspaces.
packages/*
: customized extensions.example
: this demo page.example/dev-server.mjs
: provide/content
api, and serve vite (as middleware mode).src/App.svelte
: Page layout (editor, toolbars), Editor state contextsrc/icons/toolbars
: all toolbar SVG icons here are modified to look the same size and support svelte.src/icons/*
: other SVG icons.src/components/ui
: shadcn-svelte components, you can see the details insrc/components.josn
src/components/Toolbar.svelte
: toolbar entry component.src/components/toolbars/*.svelte
: all toolbar and editor features implemented here.src/states/*.svelte.ts
: global shared states. (editor state, theme, color picker histories ...)src/assets/noto-emojis-v16.json
: Google NotoEmoji metadata json file.public/NotoColorEmoji.ttf
: Google NotoEmoji font file.
This project based on Node 21.7.3
, I personally recommend using fnm to manager your
node version.
> git clone https://github.com/tiptiz/editor.git --depth=1
> cd editor
> fnm install/use # optional
> pnpm install
> cd exmaple
> node dev-server.mjs # also pnpm server, or you can't use local save