Summernote event for switch from code view to editor

◇◆丶佛笑我妖孽 提交于 2020-02-04 04:57:27

问题


I use google caja html sanitizer to prevent script executions on client side. So I need to put event on switch from code view to editor, and in that event I would clean html. Since there is no any event for that switch I wrote something like this:

$('#newFeaturesView .note-editor .btn-codeview').click(function () {
        if (!$(element).hasClass('active'))
        {
            var html = $('#summernote').summernote('code');
            var sanitizedHtml = html_sanitize(html, urlTransformer, classIdTransformer);
            $('#summernote').summernote('code', sanitizedHtml);
        }
});

But if html is dirty and contains for example script with alert, alert is executed just before html is cleaned and pasted into html editor. How to force my function for clean to trigger first?

来源:https://stackoverflow.com/questions/39115431/summernote-event-for-switch-from-code-view-to-editor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!