Skip to content

Commit

Permalink
Minor cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Oct 21, 2020
1 parent f5457bd commit 64c87e5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/ckeditor5-html-embed/src/htmlembedediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ export default class HtmlEmbedEditing extends Plugin {
},
model: 'rawHtml',
view: ( modelElement, { writer } ) => {
const widgetLabel = t( 'HTML snippet' );

let domContentWrapper, state, props;

const viewContainer = writer.createContainerElement( 'div', {
Expand All @@ -146,6 +144,7 @@ export default class HtmlEmbedEditing extends Plugin {
renderContent( { domElement, editor, state, props } );
} );

// API exposed on each raw HTML embed widget so other features can control a particular widget.
const rawHtmlApi = {
makeEditable() {
state = Object.assign( {}, state, {
Expand All @@ -162,6 +161,8 @@ export default class HtmlEmbedEditing extends Plugin {
domContentWrapper.querySelector( 'textarea' ).focus();
},
save( newValue ) {
// If the value didn't change, we just cancel. If it changed,
// it's enough to update the model – the entire widget will be reconverted.
if ( newValue !== state.getRawHtmlValue() ) {
editor.execute( 'updateHtmlEmbed', newValue );
} else {
Expand All @@ -183,7 +184,6 @@ export default class HtmlEmbedEditing extends Plugin {

state = {
showPreviews: htmlEmbedConfig.showPreviews,

isEditable: false,
getRawHtmlValue: () => modelElement.getAttribute( 'value' ) || ''
};
Expand All @@ -209,7 +209,7 @@ export default class HtmlEmbedEditing extends Plugin {
writer.setCustomProperty( 'rawHtml', true, viewContainer );

return toWidget( viewContainer, writer, {
widgetLabel,
widgetLabel: t( 'HTML snippet' ),
hasSelectionHandle: true
} );
}
Expand Down

0 comments on commit 64c87e5

Please sign in to comment.