Integrating tinyMCE in ASP.NET Core
Table of Contents
一、实现的功能说明
tinymce 目前有 3.x 4.x 5.x三大类版本,本文针对 4.x版本
Asp .Net Core +tinymce + 插入本地图片并上传到后台+插入代码片段+代码高亮
二、运行环境说明
Asp .Net Core 2.1 + tinymce 4.8.3
三、配置步骤说明
我们需要使用tinymce.init()来进行初始化;
tinymce.init()内的初始化对象包含众多参数,但都是可省略的,唯一必须的参数就是selector
(允许通过css选择器指定tinymce要绑定的内容容器,div和textarea都是可以的)
id
class
textarea
textarea
textarea通过表单提交
开始逐步实现我们需要的功能:将下面网页中的id="AspNetCoretextarea"的文本框变为富文本编辑器。
step 1:Include this line of code in the <head>
of your HTML page
step 2:初始化tinyMCE
然后就长成了这个样子
step 3:开始添加图片插件
How to make tinymce paste in plain text by default
配置的上传图片的路由
4.add Blod
添加功能步骤说明
How to take heading (h1, h2, h3) directly on toolbar in tinymce 4
step 1:First, you have to create the plugin:
Nop.Web\Themes\RootTheme\Views\Shared\EditorTemplates\RichEditor.cshtml
1. selector :指定网页中的某个id,tinymce 将初始化这个id
2.plugins: 如果要添加某项功能,则指定对应的插件,tinymce会在初始化时加载这些插件。
3. toolbar: 添加对应的功能,则在工具条显示对应功能,用|分组
step 2:And then add "| formatselect" in your toolbar:
old
new
result
old
new
tinymce 4.x官方操作文档
https://www.tiny.cloud/docs-4x/demo/basic-example/
TinyMCE中文文档中文手册
http://tinymce.ax-z.cn/