TinyMCE:ASP.NETMVC

TinyMCE : ASP.NET MVC

这是我的 TinyMCE 代码

   @model TinyEditorWithMVCApp.Models.Post


@{
    ViewBag.Title = "AddPost";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Add new Post</h2>

<h2>Add new Post</h2>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>TintMCE App</title>
    <script src="~/Scripts/tinymce/tinymce.min.js"></script>
    <script type="text/javascript">
        tinyMCE.init({
            mode: "textareas",
            theme: "modern",
            plugins: "advlist,code,bbcode,hr,link,paste,save",
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "center",
            theme_advanced_statusbar_location: "bottom",
            forced_root_block: false,
        });
    </script>
</head>
<body>
    <div>
        @using (Html.BeginForm("AddPost", "Home", FormMethod.Post))
        {
            <div>
                @Html.TextBoxFor(model => model.AuthorName)
            </div>

            <div>
                @Html.TextAreaFor(model => model.Body)
            </div>

            <div>
                <input type="submit" value="Save Post" />
            </div>
        }
    </div>
</body>
</html>

结果应该是这样的:enter image description here

这是我在调试项目后得到的enter image description here

我的代码有什么问题?

我从浏览器检查了控制台,我收到了这个错误 enter image description here

您没有分享您正在使用的 TinyMCE 版本,但假设您正在使用 TinyMCE v5.x您配置中的几个选项无效。

最重要的是,TinyMCE 5 中没有 modern 主题,所以此行无效:

theme: "modern",

TinyMCE 将自动使用其默认主题,因此您根本不需要该行 - 您可以将其删除。虽然您的错误消息难以阅读,但我相信您发布的错误是 TinyMCE 无法加载不存在的 modern 主题。

所有以 theme_advanced_ 开头的设置对 TinyMCE 5 也无效 - 这些设置最后在 TinyMCE 3.x.

中有效