1 |
|
2 |
|
3 |
|
4 |
|
5 | import { BalloonPanelView } from 'ckeditor5/src/ui.js';
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | export function repositionContextualBalloon(editor) {
|
14 | const balloon = editor.plugins.get('ContextualBalloon');
|
15 | const imageUtils = editor.plugins.get('ImageUtils');
|
16 | if (imageUtils.getClosestSelectedImageWidget(editor.editing.view.document.selection)) {
|
17 | const position = getBalloonPositionData(editor);
|
18 | balloon.updatePosition(position);
|
19 | }
|
20 | }
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | export function getBalloonPositionData(editor) {
|
29 | const editingView = editor.editing.view;
|
30 | const defaultPositions = BalloonPanelView.defaultPositions;
|
31 | const imageUtils = editor.plugins.get('ImageUtils');
|
32 | return {
|
33 | target: editingView.domConverter.mapViewToDom(imageUtils.getClosestSelectedImageWidget(editingView.document.selection)),
|
34 | positions: [
|
35 | defaultPositions.northArrowSouth,
|
36 | defaultPositions.northArrowSouthWest,
|
37 | defaultPositions.northArrowSouthEast,
|
38 | defaultPositions.southArrowNorth,
|
39 | defaultPositions.southArrowNorthWest,
|
40 | defaultPositions.southArrowNorthEast,
|
41 | defaultPositions.viewportStickyNorth
|
42 | ]
|
43 | };
|
44 | }
|