nhnent / tui.editor
- воскресенье, 14 января 2018 г. в 03:16:06
🍞 📝 Markdown WYSIWYG Editor. Chart & UML in markdown syntax.
GFM Markdown Wysiwyg Editor - Productive and Extensible
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
10+ | Yes | Yes | Yes | Yes |
Today CommonMark is the de-facto Markdown standard. GFM (GitHub Flavored Markdown) is another popular specification based on CommonMark - maintained by GitHub, which is known as the biggest Markdown user. TOAST UI Editor respects both CommonMark and GFM specifications. Write documents with ease using productive tools provided by TOAST UI Editor. You can open this document wherever the specifications are supported.
CommonMark and GFM are great, but we often face requirements beyond the specifications. The TOAST UI Editor comes with powerful Extensions in compliance with the Markdown syntax, while also providing APIs so you can develop your own extensions.
Here are some of the extensions you can start with:
To learn more about Extensions check the Using Extension
TOAST UI Editor provides Markdown mode and Wysiwyg mode.
Some may like the productivity of Markdown, while others may be looking for a way to make it easier to edit. The TOAST UI Editor can be the coordinator of both. It offers Markdown mode and Wysiwyg mode, which can be switched at any time during writing content. Both work together conveniently in one document.
npm install --save tui-editor
bower install --save tui-editor
Below codes are for npm. If you are using bower please see Getting started with bower.
Place a <div></div>
where you want TOAST UI Editor rendered.
<body>
...
<div id="editSection"></div>
...
</body>
Initialize Editor class with given element to make an Editor.
var Editor = require('tui-editor');
...
var editor = new Editor({
el: document.querySelector('#editSection'),
initialEditType: 'markdown',
previewStyle: 'vertical',
height: '300px'
});
or you can use jquery plugin.
$('#editSection').tuiEditor({
initialEditType: 'markdown',
previewStyle: 'vertical',
height: '300px'
});
300px
| auto
markdown
| wysiwyg
tab
| vertical
Find out more options here
TOAST UI Editor provides a Viewer in case you want to show Markdown content without loading the editor. The Viewer has much lighter than the editor.
var Viewer = require('tui-editor/dist/tui-editor-Viewer');
...
var editor = new Viewer({
el: document.querySelector('#viewerSection'),
height: '500px',
initialValue: '# content to be rendered'
});
...
Be careful not to load both the editor and the viewer. Since the editor already includes the viewer function, you can initialize editor by calling Editor.factory() with viewer
option true
value to make the editor a viewer. You can also call getHTML() to get rendered HTML string.
var Editor = require('tui-editor');
...
var editor = Editor.factory({
el: document.querySelector('#viewerSection'),
viewer: true,
height: '500px',
initialValue: '# content to be rendered'
});
...
TOAST UI Editor respects CommonMark and GFM. So any Markdown renderer including markdownit can handle the content it made. You can use any of those renderer without Viewer if you want.