如何限制tinyMCE中的缩进

问题描述 投票:0回答:1

我试图限制TinyMCE中可能的缩进数量,但是我找不到选择的方式,您有想法吗?谢谢

tinymce indentation
1个回答
0
投票

TinyMCE在处理内容时会触发各种事件。如果要阻止某人缩进内容,则必须捕获当某人单击缩进按钮并确定要执行的操作时触发的事件。

以下是可用于侦听事件的代码类型的一些示例:

setup: function (editor) {
    editor.on('init', function (e) {
       editor.setContent('<p>This is the content in TinyMCE!</p>');
    });
    editor.on('init keydown change click blur', function (e) {
        document.getElementById('data').innerText = editor.getContent();
    });     
    editor.on('ExecCommand', function (e) {
        console.log('ExecCommand:', e.command);
        if (e.command === "indent") {
            console.log('Someone clicked the indent key');  
        }
        if (e.command === "outdent") {
            console.log('Someone clicked the outdent key');  
        }
    });
    editor.on('NodeChange', function(e) {
        console.log('NodeChange event fired', e);
        console.log(editor.selection.getNode());

    });
    editor.on('change', function (e) {
        console.log('change event fired');
        console.log(e);
    });
}

这里是一个TinyMCE提琴,它显示了一些正在运行的代码:http://fiddle.tinymce.com/6fhaab/1

[一旦您知道有人单击缩进/缩进这些事件,您就可以访问TinyMCE即将修改的内容,并且您可以执行需要修改或取消该事件的操作。

© www.soinside.com 2019 - 2024. All rights reserved.