文章目录

  • 前言
  • 在线编辑器需要哪些功能?
  • 开源的web编辑器
    • Monaco Editor
    • ProseMirror
    • tiptap
    • Milkdown
    • 掘金markdown编辑器
    • 字节的Syllepsis
    • slate.js
    • draft-js
    • StackEdit
    • Quill
    • editor.md
    • mavonEditor
    • tui.editor
    • 腾讯的CherryMarkdown
    • 微信markdown编辑器
    • vditor
    • simplemde
    • 其它
    • 数学公式
  • HTML和Markdown格式的互转
  • 如何选择?
    • 附录:老外的讨论
  • 参考链接

前言

web在线编辑器多如牛毛,如google doc, 腾讯文档,石墨文档,语雀,飞书,我来、FlowUs。往小的方面说,它们是web editor, rich editor, markdown editor,往大的方向说,它们是办公协同软件。

10大知识库工具(含开源、免费等):1.PingCode;2.Confluence;3.MediaWiki;4.Gitbook;5.语雀;6.wiki.js;7.DokuWiki;8.Notion;9.docsify;10.坚果云。

我之前用过UEditor, CKEditor, wangEditor, Quill,TinyMCE,还有最近的vditor,但都不尽如人意。其中TinyMCE的一大优势就是对网上各种html格式的兼容,也就是不挑格式,这点导致我现在还一直用着它。

最后,我在Milkdown, tiptap和StackEdit之间纠结了很久,前两者都是插件体系的,第三个是CSDN编辑器的原型,但目前不活跃。这两者都是基于ProseMirror的,但milkdown的上手难度高,文档不全,例子偏少。后者插件更丰富,对vue3和react都有比较好的支持。

闲话一句,web编辑器研发是个大坑,成本极其高,以年计。

要让一款编辑器达到商 业级质量,从目前接触到主要的例子来看,独立开发时间太长:
Quill编辑器, 从 2012 年收到第一个 Issue 到 2016 年发布 1.0 版本,已经过去了四 年。
Prosemirror编辑器, 作者在 2015 年正式开源前筹款维护时已经开发了半年,而到发布 1.0 版本时,已经过去了接近三年。Slate 从开源到接近两年时,仍然有一堆边边角角用起来莫名其妙的 bug 。上面这几个单人主导的编辑器项目要达到稳定质量,时间是以年为单位来计算的。考虑到目前互联网“下周上线”的节奏,动辄几年的时间是不划算的。所以在人力,时间合理性各方面的约束下,使用开源框架是最好的选择。

在线编辑器需要哪些功能?

必选功能:

  • 文本段落和6级标题的支持,基本的文字处理,如字体颜色大小
  • 图片粘贴和上传
  • 表格
  • 基本排版,如缩进
    高阶功能:
  • markdown支持
  • 大纲显示
  • 数学公式
  • PlantUML和流程图
  • 其它如思维导图,图片裁剪我觉得已经不再属于web编辑器的范畴了,但目前主流的在线文档都必须支持了。

此外,性能要好,顺畅,大文件不卡。

开源的web编辑器

包括富文本编辑器和markdown编辑器。

Monaco Editor

微软出品,vscode背后的编辑器。支持多种编程语言,主要面向开发者。也可以作为markdown编辑器。

地址:https://microsoft.github.io/monaco-editor/

  • https://www.npmjs.com/package/monaco-editor-vue3

ProseMirror

一款可定制性及极强的「所见即所得」富文本编辑器框架,文档的可编辑性基于 contentEditable 属性,支持协同,作者是 @marijnh,他也是 CodeMirror 编辑器的开发者。但它本身并不像其他编辑器一样开箱即用,需要一系列的模块进行配合搭建,而且涉及到一些内部抽象概念,API 复杂且多,官方文档全英文,所以上手成本比较高。
地址:https://github.com/ProseMirror/prosemirror-view

tiptap

基于ProseMirror,对React和Vue支持比较好。Tiptap 是一款无头编辑器,它没有提供任何 UI 样式。目前2.0版本支持vue3。
注意:tiptap不支持Markdown作为输入和输出,只支持JSON和HTML。比较奇怪的一点。

  • https://github.com/ueberdosis/tiptap
  • 基于elementplus+tiptap的封装:https://github.com/Leecason/element-tiptap

Milkdown

https://github.com/Saul-Mirone/milkdown
插件化的体系结构,扩展性好。20k。网上相关资料不多,API复杂,文档不全面,上手难度大。
基于prosemirror 和 remark构建
基于mermaid的图表支持,通过插件。
支持协同编辑。
采用prismjs支持各种代码语法高亮和基本编辑:https://prismjs.com/

掘金markdown编辑器

ByteMD编辑器是字节跳动的掘金团队(字节2020年收购了掘金)所使用的编辑器。此编辑器也是在2020开源,基于Svelte 这个前端框架,经过二年打磨,功能已经比较齐全。ByteMD支持多种web框架使用,并且也支持多个插件。

主要特点:

  • 轻量级和框架无关:ByteMD 是用Svelte构建的。它编译为 vanilla JS DOM 操作,无需导入任何 UI 框架运行时包,这使其轻量级,并易于适应其他库/框架。
  • 易于扩展:ByteMD 有一个插件系统来扩展基本的 Markdown 语法,这使得添加附加功能变得很容易,例如代码语法高亮、数学方程和美人鱼流程图。如果这些插件不能满足您的需求,您也可以编写自己的插件。
  • 默认情况下是安全的:ByteMD已经正确处理了跨站点脚本(XSS) 攻击。无需引入额外的 DOM 清理步骤。
  • SSR 兼容:ByteMD 可以在服务器端渲染(SSR)环境中使用,无需额外配置。SSR 在某些情况下被广泛使用,因为它具有更好的 SEO 和在慢速网络连接中快速获取内容的时间。

地址:

  • https://bytemd.js.org/
  • https://github.com/bytedance/bytemd

字节的Syllepsis

字节基于Prosemirror二次封装开箱即用的的富文本编辑器兼容主流现代浏览器。
Syllepsis 是一款开箱即用的的富文本编辑器,兼容主流现代浏览器。我们在 Prosemirror 的基础上做了二次封装,提供更简洁的 API,大量基础插件扩展,和自定义插件支持,让定制编辑器更简单。

功能特色:

  • 开箱即用:支持快速接入React,引入 Syllepsis 和其它普通组件一样简单。
  • 大量基础插件:提供大量常规插件,按需选择,即插即用,无需额外的开发成本。
  • 可拓展性:更简单的插件封装和 API,使开发者轻松定制业务插件。
  • 其它特色功能:我们在框架中积累了大量的工程实践和优化技巧,可移步官网进一步了解

地址:https://github.com/bytedance/syllepsis
https://bytedance.github.io/syllepsis/#/zh-cn/plugins/README

slate.js

强大,基于React框架,语雀一度基于它开发的。
https://github.com/ianstormtaylor/slate

draft-js

已经停止更新了。A React framework for building text editors.
https://github.com/facebookarchive/draft-js

StackEdit

目前已经不再更新,CSDN的博客编辑器基于它开发。该编辑器基于PageDown。PageDown是一个用来解析和编辑 Markdown 内容的 JavaScript 库,可将 Markdown 转成 HTML 文本,并提供一个编辑器可实时预览生成的 HTML。

Full-featured, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites.

地址:https://github.com/benweet/stackedit
国人汉化版:stackedit
vue封装版:https://github.com/loliconer/vue-stackedit
stackedit.js:https://github.com/benweet/stackedit.js

Quill

老牌富文本编辑器。

editor.md

12.8k star,国人开发。也是非常棒,基本开箱即用。
地址:https://editor.md.ipandao.com/

mavonEditor

5.9k,轻量级。

https://github.com/hinesboy/mavonEditor

tui.editor

15.6k, 全功能编辑器,支持所见即所得和markdown编辑。

The Editor allows you to edit your Markdown documents using text or WYSIWYG and comes with Syntax Highlighting, Scroll-Sync, Live Preview, and Chart features.

https://ui.toast.com/tui-editor
https://github.com/nhn/tui.editor

腾讯的CherryMarkdown

Cherry Markdown Editor 是一款 Javascript Markdown 编辑器,具有开箱即用、轻量简洁、易于扩展等特点. 它可以运行在浏览器或服务端(NodeJs).

项目名称:
Cherry Markdown Editor
项目地址:
https://github.com/Tencent/cherry-markdown

Cherry Markdown Editor

微信markdown编辑器

3.7k,还在发展中
doocs.github.io/md

vditor

b3log出品,剑走偏锋,架构独特。5.8k star, 插入代码有bug,放弃了。

https://github.com/Vanessa219/vditor

simplemde

https://github.com/sparksuite/simplemde-markdown-editor

其它

其它: ckeditor, wangEditor, UEditor。

数学公式

这个还不错:
https://demo.wiris.com/mathtype/en/developers.php#mathml-latex

码云的Web IDE不错,一看,来自Monaco Editor。网上一搜,的确有不少基于Monaco的web IDE。

HTML和Markdown格式的互转

  • 将Markdown转换为html的开源库有很多,比如markdown-it、marked、showdown
  • html转md: turndown 和 html2md(helloworld网站的作品)

如何选择?

  1. 不想做二次开发,傻瓜型,开箱即用:TinyMCE
  2. 做适度定制: Milkdown 和 Tiptap,StackEdit也可以考虑

附录:老外的讨论

The full list of findings can be found here: https://docs.google.com/spreadsheets/d/18v2G44v0ix41xbAseOIcMcFOMNluc67IJz9f2U5IpRo/edit#gid=0.

6 were declined declined for recommendation due to lack of activity or being deprecated, though other factors could also cause it to be declined:

CodeMirror5 - deprecated by CodeMirror6
Easy MarkDown Editor - based on CodeMirror5, a big rewrite is pending
stackedit.js - lack of activity
StrapDown.js - lack of activity
TeXMe - lack of activity
zero-md - lack of activity
5 were declined due to lack of compatibility, though other factors could also cause it to be declined:

mark - does not appear to be extensible
react-markdown - no Vue support
react-md-editor - no Vue support
React Monaco Editor - no Vue support
Silver Bullet - this seems to be a “whole package” deal, not something easily dropped into Directus
1 was declined because it requires a license: Typora.

5 were declined because they were single purpose, that is they only supported Markdown. This is important because in order to keep code weight down the editor should be multi-purpose:

ByteMD
kg-markdown-html-renderrer
md-editor-v3
Showdown.js
Toast UI
This left 5 for consideration that support Vue, are active projects, and are multipurpose:

CodeMirror6 - code or Markdown
Milkdown - Markdown or WYSIWYG
Monaco - code or Markdown
ProseMirror - Markdown or WYSIWYG
Tiptap - Markdown or WYSIWYG
Recommendation
Further evaluation is needed to identify a sure path forward. I believe there are two general paths to take, Option 1 and Option 2 as clarified below. This deeper evaluation should consider specific features for each of the Markdown, Code, and WYSIWYG fields such as extensibility, autosave, collaborative editing, accessibility, internationalization, syntax highlighting, code completion, undo history, preview vs source toggling, and the overall experience and needs for those respective field types.

Option 1: Use one editor for Markdown and Code Fields and another for WYSIWYG Field
In this scenario, it probably makes most sense to proceed with using CodeMirror for Markdown and Code fields, but upgrade from CodeMirror5 to CodeMirror6 to address defects. Continue using TinyMCE for WYSIWYG.

The alternative would be to use Monaco instead of CodeMirror for the Markdown and Code fields since it seems (on the surface) to offer comparable functionality, but there are reasons to decide against Monaco. One, Directus already has experience with CodeMirror. Two, of the Markdown editors I found there was only 1 based on Monaco but at least 2 based on CodeMirror. Third, of the CMS’s I evaluated none of them used Monaco for the Markdown inputs but 3 of them used CodeMirror.

Option 2: Use one editor for Markdown and WYSIWYG Fields and another for Code Field
In this scenario, it probably makes sense to use CodeMirror for the Code field. Upgrading from CodeMirror5 to 6 is ideal, but optional in the near term.

TinyMCE would be removed from the project and a ProseMirror editor would be used instead. There are 3 options:

Milkdown
ProseMirror
Tiptap
Further evaluation would need to be done to identify which is the best fit. They all have examples of a WYSIWYG view so they should be compatible for the WYSIWYG field. But, I did not find examples of how to use these editors in a side-by-side view or toggle view which allows the author to write in raw Markdown. However, that should be supported. They are all based on ProseMirror and its documentation shows that a raw view would be supported as shown here: https://prosemirror.net/examples/markdown/.

参考链接

  • awesome-web-editor
  • awesome-wysiwyg
  • 我来
  • Notion
  • 飞书
  • 语雀
  • 思源笔记
  • 觅思文档
  • TodoLangEditor
  • https://docs.github.com/zh/codespaces/the-githubdev-web-based-editor
  • marktext
  • 参考文章

web在线编辑器与在线文档盘点相关推荐

  1. web项目使用OpenOffice实现前端在线预览office文档(超详细)

    超详细的OpenOffice实现前端在线预览office文档记录 最近搞一个数字化共享平台,是一个java web项目,使用框架ssm,其中项目有一个需要在线预览PDF.excle.ppt.word文 ...

  2. web项目 在线预览doc文档

    在线预览word文档 前端代码 后台controller代码(使用Aspose.Words) 前端代码 在前端发送ajax请求,并展示后端生成的html临时文件 showFile:function(m ...

  3. 在线预览word文档

    在线预览word文档 在线预览word文档 Java 使用wps将word文件转换pdf文件 转成PDF 在线预览word(转成pdf)前端展示 欢迎来提更好的意见 在线预览word文档 昨天下午组长 ...

  4. weboffice功能的实现:在线编辑,保护文档部分编辑,显示,下载

    点聚Weboffice IE 上的用法: Weboffice7文件夹是weboffice的文件: .cab是一个压缩形式的文件,里面包含了安装信息,IE会自动安装. Main.js是weboffice ...

  5. 安卓WebView在线预览office文档功能实现

    *## 在线预览office文档 我就直奔主题吧!估计是目前最简单的了吧! 我也搜了很多资料不外乎2种 使用谷歌文档服务(google国内使用不了,各种试就是显示不出来,) mWebView.load ...

  6. Springboot 超简单实现在线预览,Word文档 doc、xlsx、pdf、txt等

    前言 PDF.TXT 只要资源可访问,根本就不需要进行任何处理,直接访问查看就完事了. 也是因为这个PDF可以直接查看(现在浏览器基本支持了),那么我们实现Word文档在线预览,其实也是 把WORD文 ...

  7. pdf加密怎么加?在线免费对PDF文档加密

    pdf加密怎么加?相信许多小伙伴使用的一些pdf文件内容中都会有重要内容,总是会担心文件安全.那么今天小编就来给大家分享怎么给pdf加密~在线免费对PDF文档进行加密,不用安装任何软件程序并且每天都可 ...

  8. 加载js文件,在线预览pdf文档

    加载js文件,在线预览pdf文档 效果演示 环境要求 JS文件下载 Jsp页面导入js文件 jquery.media.js源码 效果演示 首先,先展示效果图 环境要求 Tomcat8.5 [注意]:T ...

  9. 在线PDF转Word文档-PDFtoWord

    在线PDF转Word文档-PDFtoWord [ 2010/01/24 01:02 | by ] 大 | 中 | 小 之前一篇文章介绍了PDF转DOC格式工具后,我在为大家介绍一款在线PDF转DOC格 ...

最新文章

  1. sku属性组合小例子
  2. 2.内核异常处理流程
  3. Storm on yarn 安装
  4. 软件工程作业 - word count
  5. 浅入深出Vue:环境搭建
  6. 面向服务的架构SOA
  7. 各国“未雨绸缪”致网络安全陷入困境 安全防御诱发“防御性入侵”
  8. 中鸣机器人编程教程 c 语言,中鸣教育机器人简介.doc
  9. Android包管理机制(一) PackageInstaller的初始化
  10. Python单例模式的多种实现方式
  11. 你的代码暴漏了你的年龄(毕业设计)--技术文档+程序源代码
  12. 台式计算机的安装顺序,台式电脑安装步骤教程
  13. NSString转GBK编码格式
  14. 3.5主存储器与CPU的连接
  15. 08.attempt 方法
  16. SCAU 18935 贪吃的小Q
  17. 【转载】Linux常用命令大全之文件处理命令(一)
  18. 红米6 红米6A完美刷入开发版获取ROOT超级权限的经验
  19. 初闻不知曲中意,再听已是曲终人!哪首歌让你,而立之年泪流满面
  20. golan学习(1)语言特性以及基本语法

热门文章

  1. 【产品推荐】河道水质监测站——水质监测平台
  2. Jvm笔记---李兴华老师讲jvm
  3. 卡巴斯基杀360安全卫士!!!
  4. 【Brian2学习教程之三】Introduction to Brian part 3: Simulations
  5. echarts使用3d地图,解决塌陷
  6. 2022-2028全球及中国特殊气体行业研究及十四五规划分析报告
  7. SAP MDG —— 一个典型的MDG项目组织架构和顾问技能要求(仅供参考~)
  8. S7-200 PID指令功能
  9. 手机常亮展示软件_手机常亮展示
  10. wireshark下载