CodeMirror readOnly允许从键盘快捷键和鼠标右键单击选项

时间:2015-07-25 21:55:11

标签: codemirror

我正在做一个应用程序,用于教授使用codemirror插件的学生班级。我有这个问题,我不希望学生能够在编辑器中更改我为他们显示的代码,所以我按照文档,我已将readOnly属性设置为true,这确实禁用了打字能力对他们来说但是一些聪明的学生发现他可以使用CTRL + V或鼠标右键单击并从中选择paste来将某些内容粘贴到编辑器中。你知道如何制止它吗?

这是一个实例:

    var appCM = CodeMirror.fromTextArea(document.getElementById('app-cm'), {
        mode: 'text/html',
        theme: "monokai",
        styleActiveLine: true,
        lineNumbers: true,
        matchBrackets: true,
        indentUnit: 4,
        indentWithTabs: true,
        autoCloseTags: true,
        autoCloseBrackets: true,
        matchTags: false,
        extraKeys: {
            "Ctrl-Space": "autocomplete",
            "Ctrl-Q": function(appCM) {
                appCM.foldCode(appCM.getCursor());
            }
        },
        foldGutter: true,
        gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
        readOnly: true
    });

我一直在读这篇文章,但我找不到任何有用的东西

1 个答案:

答案 0 :(得分:2)

这是几天前修复的5.5版中的错误(请参阅this bug report)。您可以获取当前开发,手动应用从该问题链接的补丁,或等待下一个版本。

相关问题