steveathon / bootstrap-wysiwyg

Tiny bootstrap-compatible WYSIWYG rich text editor
MIT License
661 stars 1.71k forks source link

How to use cleanHtml in the OOP version? #105

Open andrews05 opened 7 years ago

andrews05 commented 7 years ago

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'.

codewithtyler commented 7 years ago

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'
});
andrews05 commented 7 years ago

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.

steveathon commented 7 years ago

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

andrews05 commented 7 years ago

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.

huww98 commented 7 years ago

I'm facing the same problem.

andrews05 commented 7 years ago

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.

steveathon commented 7 years ago

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