Reputation: 4249
In a widget's init function I can access the widget's inner HTML using
this.element.getHtml();
This HTML might contain widget data attributes like data-cke-enter-mode="1" data-cke-widget-editable="text"
.
I want to get the HTML without these data attributes, exactly the same as the source area/dialog would show it. What's the best way to do this?
Upvotes: 1
Views: 1336
Reputation: 22023
Just pass it trough the data processor:
editor.dataProcessor.toDataFormat( widget.wrapper.getOuterHtml() );
And in case of an inline widget:
editor.dataProcessor.toDataFormat( widget.wrapper.getOuterHtml(), { context: 'p' } );
Passing the context will prevent auto-paragraphing (inline widget will not be wrapped with a <p>
).
Upvotes: 2