Dimension tags to insert into the DOM content element

My goal is to remove all tags when pasted into the DOM content element. I use the WordPress Front-end Editor , which is a recognized plugin that can end up in the core of WordPress.

When pasting content into the header editing area, the plugin currently separates the tags onblur. This leads to the fact that the formatting becomes visible until the focus is lost (then the tags will be deleted). How to do this, see https://github.com/avryl/wp-front-end-editor/blob/master/js/wp-front-end-editor.js#L118

I need the tags to be removed when pasting so that the copied styles and formatting don't show up. I thought about using an event pasteto tag tags on insertion, but I'm not sure how to implement it.

I tried replacing 'blur'with 'paste', but that didn't work.

Hope someone can help?

+3
source share
1 answer

Insert this after line 117:

.on('paste', function (e) {
    e.preventDefault();
    var contentOnBlur = (e.originalEvent || e).clipboardData.getData('text/plain') || prompt('Paste something..');
    contentOnBlur = contentOnBlur.replace(/(<([^>]+)>)/ig,'');
    document.execCommand('insertText', false, contentOnBlur);
})

Insert the same block after 171 lines (do not forget that the previous paste could move it lower).

+2
source

All Articles