Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Temporary code. [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Piechaczek committed Feb 12, 2019
1 parent 7c84ba4 commit 6819f4b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/imagecaption/imagecaptionediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
getCaptionFromImage,
matchImageCaption
} from './utils';
import ClickObserver from '@ckeditor/ckeditor5-engine/src/view/observer/clickobserver';

/**
* The image caption engine plugin.
Expand All @@ -34,6 +35,8 @@ export default class ImageCaptionEditing extends Plugin {
const data = editor.data;
const editing = editor.editing;
const t = editor.t;

view.addObserver( ClickObserver );

/**
* The last selected caption editable.
Expand Down Expand Up @@ -79,6 +82,14 @@ export default class ImageCaptionEditing extends Plugin {

// Update caption visibility on view in post fixer.
view.document.registerPostFixer( writer => this._updateCaptionVisibility( writer ) );

view.document.on( 'click', ( evt, data ) => {
const viewElement = view.domConverter.mapDomToView( data.domTarget );

if ( viewElement.is( 'figcaption' ) ) {
viewElement.fire( 'click', data, editor.model );
}
} );
}

/**
Expand Down Expand Up @@ -226,6 +237,14 @@ function captionModelToView( elementCreator, hide = true ) {
}

insertViewCaptionAndBind( viewCaption, data.item, viewImage, conversionApi );

viewCaption.on( 'click', ( evt, data, model ) => {
if ( data.domEvent.detail > 2 ) {
model.change( writer => {
writer.setSelection( conversionApi.mapper.toModelElement( viewCaption ), 'in' );
} );
}
} );
}
};
}
Expand Down

0 comments on commit 6819f4b

Please sign in to comment.