|
wysiwyg editor |
|
|
|
Froala Editor # $ |
|
Redactor # $ |
|
ContentTools #front |
|
TinyMCE |
|
CKEditor.com |
|
Trumbowyg #20kB |
|
Summernote - Super Simple WYSIWYG editor #Bootstrap |
|
简单的编辑功能 simditor |
|
- |
|
Trix is an open-source project from Basecamp |
|
internal document model |
|
ProseMirror # open-source, internal document model? |
|
Draft.js |
|
They all use contenteditable for I/O only (no execCommand), and they all maintain their own internal document model. |
|
- |
|
medium editor # float box |
|
Medium Draft - A rich text editor built on draft-js with focus on keyboard shortcuts. |
|
mobiledoc-kit # used by ghost |
|
|
|
https://news.ycombinator.com/item?id=10410879 |
|
https://m.reddit.com/r/drupal/comments/1x3vgj/best_wysiwyg_editor_and_image_handler_combo/ |
|
https://www.reddit.com/r/node/comments/525o6q/wysiwyg_editor_for_node_with_express |
|
https://news.ycombinator.com/item?id=11487667 |
|
https://www.zhihu.com/question/38699645 |
|
有多大比例的前端工程师,能在合理的时间内独立开发出一个足以供商业网站使用的文本编辑器? |
|
https://www.zhihu.com/question/26739121/answer/291059836 |
|
|
|
富文本编辑器选型 |
|
https://github.com/hax/hax.github.com/issues/41 |
|
|
|
--- |
|
|
|
可以自定 text-change 與 selection-change 兩個事件(event)的 listener,自定處理函數。 |
|
支援多人同時編輯,可以標示出每個人編輯的游標與內容。 |
|
支援 responsive layout。 |
|
|
|
判断当前光标下是否为粗体 |
|
document.queryCommandState('bold') |
|
切换当前光标下粗体状态 |
|
document.execCommand('bold') |
|
那这样的话,写一个富文本编辑器不是很简单吗?只要用 execCommand 做命令映射就好了,所有的 DOM 变更操作都由浏览器实现好了。 |
|
|
|
也有一些编辑器不是完全利用 execCommand 来实现编辑操作的,比如 Medium 的编辑器实现了一个自定义的 Model ,操作是对这个 Model 的修改,然后再把 Model 映射成 DOM 。 |
|
|
|
|
|
另外还了解过 quill.js ,开发很活跃,代码很清晰。也是自己搞的一套文档模型,很有学习价值。不过这家伙原来用 coffeescript ,一次推翻重来改用 ES6 重写,现在已经不敢在产品里用它了。。 |
|
|
|
另外推荐 tower.im 出的 simditor ,这个是没有自己的文档模型的,但是已经很成熟了,也在不少产品中有使用( teambition 也是用的它,哈哈)。我们产品上个月刚换它,效果还不错的,也很方便自己扩展。 |
|
https://www.v2ex.com/t/257613 |
|
|
|
|
|
Rich Text Editing: |
|
vue-quill-editor - Quill editor component for Vue2. |
|
vue-mobiledoc-editor - A mobiledoc editor component toolkit for Vuejs. |
|
vue2-medium-editor - A MediumEditor component for Vue 2. |
|
vue-froala - VueJS wrapper for Froala Editor. |
|
|
|
!!! |
|
HTML編輯器自己做!布丁版TinyMCE編緝器 / An Online HTML Editor: Customized TinyMCE Editor |
|
讓人需要的時候就直接打開網頁、使用TinyMCE編輯網頁吧。 |
|
http://blog.pulipuli.info/2017/08/htmltinymce-online-html-editor.html |
|
|
|
--- |
|
quilljs: |
|
|
|
get/set html |
|
quill.root.innerHTML |
|
https://github.com/quilljs/quill/issues/903 |
|
|
|
You can convert Quill Delta to HTML on the server with node.js and jsdom without using a real browser. |
|
https://github.com/quilljs/quill/issues/1240 |
|
https://github.com/quilljs/quill/issues/993#issuecomment-249387907 |
|
|
|
Deltas are a simple, yet expressive format that can be used to describe Quill’s contents and changes. |
|
https://github.com/quilljs/quill/issues/993#issuecomment-260889322 |
|
delta is non-trivial to render as it is an action log |
|
the execution trouble with deltas come from delete & retain |
|
ops: with only insert, delta becomes a state more than a script. |
|
https://github.com/quilljs/quill/issues/774 |
|
|
|
save: |
|
JSON.stringify( quill.getContents() ) |
|
http://quilljs.com/playground/#autosave |
|
|
|
load: |
|
quill.setContents( JSON.parse(data) ) |
|
https://stackoverflow.com/questions/39733120/how-to-read-in-existing-data-into-quill-js |
|
|
|
image handle: |
|
https://github.com/quilljs/quill/issues/1400#issuecomment-296936021 |
|
https://github.com/quilljs/quill/issues/863#issuecomment-240579430 |
|
|
|
--- |
|
summernote: |
|
|
|
改<input type="file">之預設值: |
|
$(document).ready(function() { |
|
$('#summernote').summernote({ |
|
callbacks: { |
|
onImageUpload: function(image) { |
|
var image = $('<img>').attr('src', 'badge.png'); |
|
$('#summernote').summernote("insertNode", image[0]); |
|
} |
|
} |
|
}); |
|
}); |
|
|
|
upload image handle example: |
|
https://stackoverflow.com/questions/34234004/summernote-onimageupload-not-being-executed |
|
https://stackoverflow.com/questions/46264048/summernote-0-8-8-onimageupload-example |
|
|
|
in electron: |
|
複製檔案 |
|
讀<input>檔案位置 |
|
create input tag, type file, then click() |
|
add url |
|
- |
|
Q: url與圖檔實際位址不同 |
|
|
|
inset image > select from files (code): |
|
https://github.com/summernote/summernote/blob/4b6e91b011bbaef7a6d1a4c6d8eea95b7d8285b0/src/js/base/module/ImageDialog.js#L27 |
|
https://github.com/summernote/summernote/issues/1240 |
|
|
|
don't add http:// on link: |
|
$(".summernote").summernote({ |
|
onCreateLink : function(originalLink) { |
|
return originalLink; // return original link |
|
} |
|
}); |
|
https://github.com/summernote/summernote/issues/1037 |
|
|
|
uncheck `open link in new window` |
|
$('.summernote').summernote({ |
|
linkTargetBlank: true |
|
}); |
|
https://github.com/summernote/summernote/pull/2195 |
|
|
|
custom popover: |
|
https://summernote.org/deep-dive/#custom-button |
|
https://summernote.org/deep-dive/#custom-toolbar-popover |
|
You can create whatever you want in summernote plugin system |
|
https://github.com/summernote/summernote/issues/1924 |
|
https://github.com/summernote/summernote/issues/871 |
|
|
|
plugins: |
|
https://github.com/summernote/awesome-summernote |
|
https://github.com/summernote/summernote/issues/1240 |
|
https://github.com/summernote/summernote/blob/develop/plugin/hello/summernote-ext-hello.js |
|
ex: https://github.com/DiemenDesign/summernote-image-attributes |
get user input wysiwyg editor read request
http://stackoverflow.com/questions/17849003/bootstrap-wysiwyg-how-to-get-the-formatted-text-on-the-server-side
http://stackoverflow.com/questions/5430543/trying-to-get-the-text-written-inside-a-tinymce-textarea