Summernote event for switch from code view to edit

2019-07-19 17:37发布

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?

0条回答
登录 后发表回答