PANmedia / raptor-editor

Raptor, an HTML5 WYSIWYG content editor!
www.raptor-editor.com
GNU General Public License v3.0
533 stars 136 forks source link

Raptor destroy is broken #173

Open Petah opened 9 years ago

Petah commented 9 years ago

Cannot seem to destroy an instance of Raptor after initialisation. Should be as simple as:

$('.editable').raptor('destroy');

But it doesn't work.

AriPaaWun commented 9 years ago

Can confirm. Calling it first time does something since calling it a second time gives this error:

Uncaught Error: cannot call methods on raptor prior to initialization; attempted to call method 'destroy'(…)

But nothing seems to actually happen after the first call. I can still edit elements after calling it.

deeknow commented 9 years ago

Hey @Petah not sure if it was you who raised this or were just logging here on behalf of someone else but was just looking at this issue. I see there was a commit way back in 2013 (sha: d9405e4) in which the destroy() method was commented out in raptor-widget.js. It's mostly a call to destruct() which does seem to work as advertised in the raptor-editor docs, i.e..

Hides the toolbar, disables editing, and fires the destroy event, and unbinds any events see: https://www.raptor-editor.com/documentation/api/symbols/RaptorWidget#.destruct

Is $('.editable').raptor('destruct'); the functionality you were looking for @AriPaaWun ?

If so maybe we should reintroduce that destroy() alias as it is a commonly used name for such things in other projects for garbage-collection-like operations.

Petah commented 9 years ago

I would have raised it on behalf.

Also I can't remember why the destroy method was removed, most likely it didn't work correctly, couldn't be re initialised after, or caused memory leaks (which would be especially bad when using Raptor in an Angular app etc).

deeknow commented 9 years ago

Yeah there's no easy way of going back after this call as it stands at the moment, be interesting to know what the original intent was. I think this should be marked closed as not a bug without any other info.

Petah commented 9 years ago

Its a legit bug as destroy should literally remove all functionality that Raptor placed on the elements, which it currently does not.

I tested the destruct function and its not quite there, it removes some functionality but still leaves some in a broken state: http://jsfiddle.net/6dvbbgcu/

deeknow commented 9 years ago

Brilliant, thanks for the jsfiddle.