bootstrap-wysiwyg icon indicating copy to clipboard operation
bootstrap-wysiwyg copied to clipboard

How to use cleanHtml in the OOP version?

Open andrews05 opened this issue 8 years ago • 7 comments

I've been using an older version of the plugin and am just looking at updating to the current OOP version but can't figure out how to run the cleanHtml function. Calling $('#editor').cleanHtml() doesn't work anymore.

I also can't set the defaults the same way I could before, e.g. $.fn.wysiwyg.defaults.activeToolbarClass = 'active'.

andrews05 avatar Nov 26 '16 20:11 andrews05

I'll check into the cleanHtml question.

As for the problem with the activeToolbarClass you should be able to do the following:

$('#editor').wysiwyg({
  activeToolbarClass: 'active'
});

codewithtyler avatar Nov 26 '16 21:11 codewithtyler

Yup, I know I can pass in the options to the function but setting the defaults can be helpful so I don't have to keep passing in the same options everywhere I want to use it.

andrews05 avatar Nov 26 '16 23:11 andrews05

Hrm, @andrews05 is it every time? This could be a bug with the way it cleans.

steveathon avatar Dec 16 '16 13:12 steveathon

Hi @steveathon, I'm not quite sure what you're asking. The problem is the cleanHtml function doesn't appear to exist anymore, or at least it isn't callable in the way that it was before.

andrews05 avatar Dec 18 '16 05:12 andrews05

I'm facing the same problem.

huww98 avatar Jan 15 '17 13:01 huww98

In the previous version, cleanHtml was added as a jQuery function ($.fn.cleanHtml = ...). In version 2, it appears to be a function of the Wysiwyg object which isn't accessible from outside the plugin. I'd suggest either turning it back into a jQuery function, or allow it to be called in the form of $('#myeditor').wysiwyg('cleanHtml').

I'll also note that the $.fn.wysiwyg function currently doesn't return anything, meaning it can't be chained like most jQuery functions.

andrews05 avatar Jan 29 '17 07:01 andrews05

Thanks everyone,

As @andrews05 points out this is a problem with the way this has been implemented. We should make this directly callable. Likewise, I've opened another request for the jQuery chaining. #112

steveathon avatar Jan 29 '17 07:01 steveathon