Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unscrupulous <span> tags - can we prevent them? #14

Open
nathanhornby opened this issue Oct 9, 2014 · 2 comments
Open

Unscrupulous <span> tags - can we prevent them? #14

nathanhornby opened this issue Oct 9, 2014 · 2 comments

Comments

@nathanhornby
Copy link

These really wind me up - for pretty much no reason whatsoever I quite regularly find that Redactor has wrapped bits of text in span tags that contain inline styles for font size and line height. This can be triggered by all sorts of things, none of them warranted.

I have a feeling this will be a fault in Redactor itself (maybe even fixed as this extension seems to be, very unfortunately, unmaintained).

If anyone knows of a way we can stop these completely unwanted span tags from appearing I'd be hugely grateful. I can live with the odd <br/> and &nbsp;, but the spans can cause issues in the front-end (why would you ever want your WYSIWYG controlling line-height?? Madness).

@johnpuddephatt
Copy link

From imperavi.com/redactor/log/:

Version 9.0.0 May 30, 2013: Fixed garbage span tags in Chrome и Safari.

Like you say, it's unfortunate the extension isn't being maintained :(

@johnpuddephatt
Copy link

The issue is documented here, with a fix. I've tested the patch and it appears to work without issue.

I added the below method to redactor.min.js:

checkForSpan: function() {
            this.$editor.on("DOMNodeInserted", $.proxy(function(e) {
                if (e.target.tagName == "SPAN") {
                    var helper = $("<b>helper</b>");
                    $(e.target).before(helper);
                    helper.after($(e.target).contents());
                    helper.remove();
                    $(e.target).remove();
                }
            }, this));
        }

And added this.checkForSpan() within the formatNewLine method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants