【问题标题】:How do I remove Image and Table option from TinyMCE textarea?如何从 TinyMCE 文本区域中删除图像和表格选项?
【发布时间】:2021-05-30 05:27:39
【问题描述】:

每次我在文本区域内单击以键入时,都会显示这两个选项。我不需要它们。我尝试在 TinyMCE 网站上查找,但找不到任何东西。希望有人能帮我找到解决办法。

这是我的 tinyMCE.js 代码

var useDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches;

[tinymce.init({
    selector: "textarea",
    plugins:
        "print preview paste importcss searchreplace autolink autosave save directionality code visualblocks visualchars fullscreen codesample charmap hr nonbreaking toc insertdatetime advlist lists wordcount imagetools textpattern noneditable help charmap quickbars emoticons",
    toolbar: "undo redo | charmap emoticons | bold italic",
    toolbar_sticky: true,
    autosave_ask_before_unload: true,
    autosave_interval: "30s",
    autosave_prefix: "{path}{query}-{id}-",
    autosave_restore_when_empty: false,
    autosave_retention: "2m",
    image_advtab: true,
    branding: false,
    link_list: \[
        { title: "My page 1", value: "https://www.tiny.cloud" },
        { title: "My page 2", value: "http://www.moxiecode.com" },
    \],
    image_list: \[
        { title: "My page 1", value: "https://www.tiny.cloud" },
        { title: "My page 2", value: "http://www.moxiecode.com" },
    \],
    image_class_list: \[
        { title: "None", value: "" },
        { title: "Some class", value: "class-name" },
    \],
    importcss_append: true,

    template_cdate_format: "\[Date Created (CDATE): %m/%d/%Y : %H:%M:%S\]",
    template_mdate_format: "\[Date Modified (MDATE): %m/%d/%Y : %H:%M:%S\]",
    height: 300,
    image_caption: true,
    quickbars_selection_toolbar: "bold italic | h2 h3 blockquote",
    noneditable_noneditable_class: "mceNonEditable",
    toolbar_mode: "sliding",
    skin: useDarkMode ? "oxide-dark" : "oxide",
    content_css: useDarkMode ? "dark" : "default",
    content_style:
        "body { background-color: rgba(0,0,0,0.3); color: #ebfdffff; font-family:Helvetica,Arial,sans-serif; font-size:14px }",
    oninit: "postInitWork",
});

【问题讨论】:

    标签: plugins tinymce rich-text-editor


    【解决方案1】:

    您只需从plugins 中删除quickbars。

    这是用于演示的代码笔: https://codepen.io/michael-vascue/pen/MWpOmVB?editors=1011

    tinymce.init({
        selector: "textarea#basic-example",
        height: 500,
        menubar: false,
         plugins:
            "print preview paste importcss searchreplace autolink autosave save directionality code visualblocks visualchars fullscreen codesample charmap hr nonbreaking toc insertdatetime advlist lists wordcount imagetools textpattern noneditable help charmap  emoticons",
        toolbar: "undo redo | charmap emoticons | bold italic",
        toolbar_sticky: true,
        autosave_ask_before_unload: true,
        autosave_interval: "30s",
        autosave_prefix: "{path}{query}-{id}-",
        autosave_restore_when_empty: false,
        autosave_retention: "2m",
        image_advtab: true,
        branding: false,
        link_list: [
            { title: "My page 1", value: "https://www.tiny.cloud" },
            { title: "My page 2", value: "http://www.moxiecode.com" },
        ],
        image_list: [
            { title: "My page 1", value: "https://www.tiny.cloud" },
            { title: "My page 2", value: "http://www.moxiecode.com" },
        ],
        image_class_list: [
            { title: "None", value: "" },
            { title: "Some class", value: "class-name" },
        ],
        importcss_append: true,
        template_cdate_format: "\[Date Created (CDATE): %m/%d/%Y : %H:%M:%S\]",
        template_mdate_format: "\[Date Modified (MDATE): %m/%d/%Y : %H:%M:%S\]",
        height: 300,
        image_caption: true,
        quickbars_selection_toolbar: "bold italic | h2 h3 blockquote",
        noneditable_noneditable_class: "mceNonEditable",
        toolbar_mode: "sliding",
        skin: "oxide-dark",
        content_css: "dark",
        content_style:
            "body { background-color: rgba(0,0,0,0.3); color: #ebfdffff; font-family:Helvetica,Arial,sans-serif; font-size:14px }",
        oninit: "postInitWork"
    });
    
    
    

    【讨论】:

    • 值得注意的是,这将禁用所有快速栏。看起来 OP 仍然想要选择工具栏,所以最好禁用插入工具栏:tiny.cloud/docs/plugins/opensource/quickbars/…
    • 禁用快速栏插入工具栏也可以,但我不需要选择工具栏,所以对我来说没关系。对于仍然希望快速选择工具栏将文本加粗、斜体的人来说,他们应该使用这种方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-29
    • 2015-04-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多