如何用TinyMCE实现markdown编辑器?
How to implement markdown editor with TinyMCE?
我想为用户添加一个降价编辑器,以便 post 他们的答案进入我的页面。我找到了 TinyMCE,但它有一个问题:我不知道如何使用 TinyMCE 实现 markdown 编辑器。
有没有人有这方面的经验?请告诉我如何使用它设置降价编辑器。
看起来 Text Pattern Plugin 可以做到这一点:
This plugin matches special patterns in the text and applies formats or executed commands on these patterns.
…
tinymce.init({
selector: "textarea", // change this value according to your HTML
plugin: 'textpattern',
textpattern_patterns: [
{start: '*', end: '*', format: 'italic'},
{start: '**', end: '**', format: 'bold'},
{start: '#', format: 'h1'},
{start: '##', format: 'h2'},
{start: '###', format: 'h3'},
{start: '####', format: 'h4'},
{start: '#####', format: 'h5'},
{start: '######', format: 'h6'},
{start: '1. ', cmd: 'InsertOrderedList'},
{start: '* ', cmd: 'InsertUnorderedList'},
{start: '- ', cmd: 'InsertUnorderedList'}
]
});
似乎 TinyMCE 现在为其编辑器提供了 Markdown 插件
https://www.tiny.cloud/labs/markdown/
Tiny Markdown is a markdown syntax plugin for TinyMCE, providing
flexible rich text and markdown content creation options for authors,
and also provides robust, reliable markdown output for developer
projects.
当我在代码中写“plugin”时它没有加载插件,它应该是“plugins”。
tinymce.init({
selector: ".make_post",
plugins: 'textpattern',
textpattern_patterns: [
{start: '*', end: '*', format: 'italic'},
{start: '**', end: '**', format: 'bold'},
{start: '#', format: 'h1'},
{start: '##', format: 'h2'},
{start: '###', format: 'h3'},
{start: '####', format: 'h4'},
{start: '#####', format: 'h5'},
{start: '######', format: 'h6'},
{start: '1. ', cmd: 'InsertOrderedList'},
{start: '* ', cmd: 'InsertUnorderedList'},
{start: '- ', cmd: 'InsertUnorderedList'}
]
});
我想为用户添加一个降价编辑器,以便 post 他们的答案进入我的页面。我找到了 TinyMCE,但它有一个问题:我不知道如何使用 TinyMCE 实现 markdown 编辑器。
有没有人有这方面的经验?请告诉我如何使用它设置降价编辑器。
看起来 Text Pattern Plugin 可以做到这一点:
This plugin matches special patterns in the text and applies formats or executed commands on these patterns.
…
tinymce.init({ selector: "textarea", // change this value according to your HTML plugin: 'textpattern', textpattern_patterns: [ {start: '*', end: '*', format: 'italic'}, {start: '**', end: '**', format: 'bold'}, {start: '#', format: 'h1'}, {start: '##', format: 'h2'}, {start: '###', format: 'h3'}, {start: '####', format: 'h4'}, {start: '#####', format: 'h5'}, {start: '######', format: 'h6'}, {start: '1. ', cmd: 'InsertOrderedList'}, {start: '* ', cmd: 'InsertUnorderedList'}, {start: '- ', cmd: 'InsertUnorderedList'} ] });
似乎 TinyMCE 现在为其编辑器提供了 Markdown 插件
https://www.tiny.cloud/labs/markdown/
Tiny Markdown is a markdown syntax plugin for TinyMCE, providing flexible rich text and markdown content creation options for authors, and also provides robust, reliable markdown output for developer projects.
当我在代码中写“plugin”时它没有加载插件,它应该是“plugins”。
tinymce.init({
selector: ".make_post",
plugins: 'textpattern',
textpattern_patterns: [
{start: '*', end: '*', format: 'italic'},
{start: '**', end: '**', format: 'bold'},
{start: '#', format: 'h1'},
{start: '##', format: 'h2'},
{start: '###', format: 'h3'},
{start: '####', format: 'h4'},
{start: '#####', format: 'h5'},
{start: '######', format: 'h6'},
{start: '1. ', cmd: 'InsertOrderedList'},
{start: '* ', cmd: 'InsertUnorderedList'},
{start: '- ', cmd: 'InsertUnorderedList'}
]
});