@ckeditor/ckeditor5-bookmark 44.3.0 → 45.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bookmark.js +2 -2
- package/build/translations/af.js +1 -1
- package/build/translations/ar.js +1 -1
- package/build/translations/ast.js +1 -1
- package/build/translations/az.js +1 -1
- package/build/translations/be.js +1 -0
- package/build/translations/bg.js +1 -1
- package/build/translations/bn.js +1 -1
- package/build/translations/bs.js +1 -1
- package/build/translations/ca.js +1 -1
- package/build/translations/cs.js +1 -1
- package/build/translations/da.js +1 -1
- package/build/translations/de-ch.js +1 -1
- package/build/translations/de.js +1 -1
- package/build/translations/el.js +1 -1
- package/build/translations/en-au.js +1 -1
- package/build/translations/en-gb.js +1 -1
- package/build/translations/eo.js +1 -1
- package/build/translations/es-co.js +1 -1
- package/build/translations/es.js +1 -1
- package/build/translations/et.js +1 -1
- package/build/translations/eu.js +1 -1
- package/build/translations/fa.js +1 -1
- package/build/translations/fi.js +1 -1
- package/build/translations/fr.js +1 -1
- package/build/translations/gl.js +1 -1
- package/build/translations/gu.js +1 -1
- package/build/translations/he.js +1 -1
- package/build/translations/hi.js +1 -1
- package/build/translations/hr.js +1 -1
- package/build/translations/hu.js +1 -1
- package/build/translations/hy.js +1 -1
- package/build/translations/id.js +1 -1
- package/build/translations/it.js +1 -1
- package/build/translations/ja.js +1 -1
- package/build/translations/jv.js +1 -1
- package/build/translations/kk.js +1 -1
- package/build/translations/km.js +1 -1
- package/build/translations/kn.js +1 -1
- package/build/translations/ko.js +1 -1
- package/build/translations/ku.js +1 -1
- package/build/translations/lt.js +1 -1
- package/build/translations/lv.js +1 -1
- package/build/translations/ms.js +1 -1
- package/build/translations/nb.js +1 -1
- package/build/translations/ne.js +1 -1
- package/build/translations/nl.js +1 -1
- package/build/translations/no.js +1 -1
- package/build/translations/oc.js +1 -1
- package/build/translations/pl.js +1 -1
- package/build/translations/pt-br.js +1 -1
- package/build/translations/pt.js +1 -1
- package/build/translations/ro.js +1 -1
- package/build/translations/ru.js +1 -1
- package/build/translations/si.js +1 -1
- package/build/translations/sk.js +1 -1
- package/build/translations/sl.js +1 -1
- package/build/translations/sq.js +1 -1
- package/build/translations/sr-latn.js +1 -1
- package/build/translations/sr.js +1 -1
- package/build/translations/sv.js +1 -1
- package/build/translations/th.js +1 -1
- package/build/translations/ti.js +1 -1
- package/build/translations/tk.js +1 -1
- package/build/translations/tr.js +1 -1
- package/build/translations/tt.js +1 -1
- package/build/translations/ug.js +1 -1
- package/build/translations/uk.js +1 -1
- package/build/translations/ur.js +1 -1
- package/build/translations/uz.js +1 -1
- package/build/translations/vi.js +1 -1
- package/build/translations/zh-cn.js +1 -1
- package/build/translations/zh.js +1 -1
- package/ckeditor5-metadata.json +1 -1
- package/dist/index-editor.css +56 -101
- package/dist/index.css +59 -119
- package/dist/index.css.map +1 -1
- package/dist/index.js +283 -389
- package/dist/index.js.map +1 -1
- package/dist/translations/af.js +1 -1
- package/dist/translations/af.umd.js +1 -1
- package/dist/translations/ar.js +1 -1
- package/dist/translations/ar.umd.js +1 -1
- package/dist/translations/ast.js +1 -1
- package/dist/translations/ast.umd.js +1 -1
- package/dist/translations/az.js +1 -1
- package/dist/translations/az.umd.js +1 -1
- package/dist/translations/be.d.ts +8 -0
- package/dist/translations/be.js +5 -0
- package/dist/translations/be.umd.js +11 -0
- package/dist/translations/bg.js +1 -1
- package/dist/translations/bg.umd.js +1 -1
- package/dist/translations/bn.js +1 -1
- package/dist/translations/bn.umd.js +1 -1
- package/dist/translations/bs.js +1 -1
- package/dist/translations/bs.umd.js +1 -1
- package/dist/translations/ca.js +1 -1
- package/dist/translations/ca.umd.js +1 -1
- package/dist/translations/cs.js +1 -1
- package/dist/translations/cs.umd.js +1 -1
- package/dist/translations/da.js +1 -1
- package/dist/translations/da.umd.js +1 -1
- package/dist/translations/de-ch.js +1 -1
- package/dist/translations/de-ch.umd.js +1 -1
- package/dist/translations/de.js +1 -1
- package/dist/translations/de.umd.js +1 -1
- package/dist/translations/el.js +1 -1
- package/dist/translations/el.umd.js +1 -1
- package/dist/translations/en-au.js +1 -1
- package/dist/translations/en-au.umd.js +1 -1
- package/dist/translations/en-gb.js +1 -1
- package/dist/translations/en-gb.umd.js +1 -1
- package/dist/translations/en.js +1 -1
- package/dist/translations/en.umd.js +1 -1
- package/dist/translations/eo.js +1 -1
- package/dist/translations/eo.umd.js +1 -1
- package/dist/translations/es-co.js +1 -1
- package/dist/translations/es-co.umd.js +1 -1
- package/dist/translations/es.js +1 -1
- package/dist/translations/es.umd.js +1 -1
- package/dist/translations/et.js +1 -1
- package/dist/translations/et.umd.js +1 -1
- package/dist/translations/eu.js +1 -1
- package/dist/translations/eu.umd.js +1 -1
- package/dist/translations/fa.js +1 -1
- package/dist/translations/fa.umd.js +1 -1
- package/dist/translations/fi.js +1 -1
- package/dist/translations/fi.umd.js +1 -1
- package/dist/translations/fr.js +1 -1
- package/dist/translations/fr.umd.js +1 -1
- package/dist/translations/gl.js +1 -1
- package/dist/translations/gl.umd.js +1 -1
- package/dist/translations/gu.js +1 -1
- package/dist/translations/gu.umd.js +1 -1
- package/dist/translations/he.js +1 -1
- package/dist/translations/he.umd.js +1 -1
- package/dist/translations/hi.js +1 -1
- package/dist/translations/hi.umd.js +1 -1
- package/dist/translations/hr.js +1 -1
- package/dist/translations/hr.umd.js +1 -1
- package/dist/translations/hu.js +1 -1
- package/dist/translations/hu.umd.js +1 -1
- package/dist/translations/hy.js +1 -1
- package/dist/translations/hy.umd.js +1 -1
- package/dist/translations/id.js +1 -1
- package/dist/translations/id.umd.js +1 -1
- package/dist/translations/it.js +1 -1
- package/dist/translations/it.umd.js +1 -1
- package/dist/translations/ja.js +1 -1
- package/dist/translations/ja.umd.js +1 -1
- package/dist/translations/jv.js +1 -1
- package/dist/translations/jv.umd.js +1 -1
- package/dist/translations/kk.js +1 -1
- package/dist/translations/kk.umd.js +1 -1
- package/dist/translations/km.js +1 -1
- package/dist/translations/km.umd.js +1 -1
- package/dist/translations/kn.js +1 -1
- package/dist/translations/kn.umd.js +1 -1
- package/dist/translations/ko.js +1 -1
- package/dist/translations/ko.umd.js +1 -1
- package/dist/translations/ku.js +1 -1
- package/dist/translations/ku.umd.js +1 -1
- package/dist/translations/lt.js +1 -1
- package/dist/translations/lt.umd.js +1 -1
- package/dist/translations/lv.js +1 -1
- package/dist/translations/lv.umd.js +1 -1
- package/dist/translations/ms.js +1 -1
- package/dist/translations/ms.umd.js +1 -1
- package/dist/translations/nb.js +1 -1
- package/dist/translations/nb.umd.js +1 -1
- package/dist/translations/ne.js +1 -1
- package/dist/translations/ne.umd.js +1 -1
- package/dist/translations/nl.js +1 -1
- package/dist/translations/nl.umd.js +1 -1
- package/dist/translations/no.js +1 -1
- package/dist/translations/no.umd.js +1 -1
- package/dist/translations/oc.js +1 -1
- package/dist/translations/oc.umd.js +1 -1
- package/dist/translations/pl.js +1 -1
- package/dist/translations/pl.umd.js +1 -1
- package/dist/translations/pt-br.js +1 -1
- package/dist/translations/pt-br.umd.js +1 -1
- package/dist/translations/pt.js +1 -1
- package/dist/translations/pt.umd.js +1 -1
- package/dist/translations/ro.js +1 -1
- package/dist/translations/ro.umd.js +1 -1
- package/dist/translations/ru.js +1 -1
- package/dist/translations/ru.umd.js +1 -1
- package/dist/translations/si.js +1 -1
- package/dist/translations/si.umd.js +1 -1
- package/dist/translations/sk.js +1 -1
- package/dist/translations/sk.umd.js +1 -1
- package/dist/translations/sl.js +1 -1
- package/dist/translations/sl.umd.js +1 -1
- package/dist/translations/sq.js +1 -1
- package/dist/translations/sq.umd.js +1 -1
- package/dist/translations/sr-latn.js +1 -1
- package/dist/translations/sr-latn.umd.js +1 -1
- package/dist/translations/sr.js +1 -1
- package/dist/translations/sr.umd.js +1 -1
- package/dist/translations/sv.js +1 -1
- package/dist/translations/sv.umd.js +1 -1
- package/dist/translations/th.js +1 -1
- package/dist/translations/th.umd.js +1 -1
- package/dist/translations/ti.js +1 -1
- package/dist/translations/ti.umd.js +1 -1
- package/dist/translations/tk.js +1 -1
- package/dist/translations/tk.umd.js +1 -1
- package/dist/translations/tr.js +1 -1
- package/dist/translations/tr.umd.js +1 -1
- package/dist/translations/tt.js +1 -1
- package/dist/translations/tt.umd.js +1 -1
- package/dist/translations/ug.js +1 -1
- package/dist/translations/ug.umd.js +1 -1
- package/dist/translations/uk.js +1 -1
- package/dist/translations/uk.umd.js +1 -1
- package/dist/translations/ur.js +1 -1
- package/dist/translations/ur.umd.js +1 -1
- package/dist/translations/uz.js +1 -1
- package/dist/translations/uz.umd.js +1 -1
- package/dist/translations/vi.js +1 -1
- package/dist/translations/vi.umd.js +1 -1
- package/dist/translations/zh-cn.js +1 -1
- package/dist/translations/zh-cn.umd.js +1 -1
- package/dist/translations/zh.js +1 -1
- package/dist/translations/zh.umd.js +1 -1
- package/lang/contexts.json +5 -3
- package/lang/translations/af.po +16 -8
- package/lang/translations/ar.po +16 -8
- package/lang/translations/ast.po +16 -8
- package/lang/translations/az.po +16 -8
- package/lang/translations/be.po +64 -0
- package/lang/translations/bg.po +16 -8
- package/lang/translations/bn.po +16 -8
- package/lang/translations/bs.po +16 -8
- package/lang/translations/ca.po +16 -8
- package/lang/translations/cs.po +16 -8
- package/lang/translations/da.po +16 -8
- package/lang/translations/de-ch.po +16 -8
- package/lang/translations/de.po +16 -8
- package/lang/translations/el.po +16 -8
- package/lang/translations/en-au.po +16 -8
- package/lang/translations/en-gb.po +16 -8
- package/lang/translations/en.po +16 -8
- package/lang/translations/eo.po +16 -8
- package/lang/translations/es-co.po +16 -8
- package/lang/translations/es.po +16 -8
- package/lang/translations/et.po +16 -8
- package/lang/translations/eu.po +16 -8
- package/lang/translations/fa.po +16 -8
- package/lang/translations/fi.po +16 -8
- package/lang/translations/fr.po +16 -8
- package/lang/translations/gl.po +16 -8
- package/lang/translations/gu.po +16 -8
- package/lang/translations/he.po +16 -8
- package/lang/translations/hi.po +16 -8
- package/lang/translations/hr.po +16 -8
- package/lang/translations/hu.po +16 -8
- package/lang/translations/hy.po +16 -8
- package/lang/translations/id.po +16 -8
- package/lang/translations/it.po +16 -8
- package/lang/translations/ja.po +16 -8
- package/lang/translations/jv.po +16 -8
- package/lang/translations/kk.po +16 -8
- package/lang/translations/km.po +16 -8
- package/lang/translations/kn.po +16 -8
- package/lang/translations/ko.po +16 -8
- package/lang/translations/ku.po +16 -8
- package/lang/translations/lt.po +16 -8
- package/lang/translations/lv.po +16 -8
- package/lang/translations/ms.po +16 -8
- package/lang/translations/nb.po +16 -8
- package/lang/translations/ne.po +16 -8
- package/lang/translations/nl.po +16 -8
- package/lang/translations/no.po +16 -8
- package/lang/translations/oc.po +16 -8
- package/lang/translations/pl.po +16 -8
- package/lang/translations/pt-br.po +16 -8
- package/lang/translations/pt.po +16 -8
- package/lang/translations/ro.po +16 -8
- package/lang/translations/ru.po +16 -8
- package/lang/translations/si.po +16 -8
- package/lang/translations/sk.po +16 -8
- package/lang/translations/sl.po +16 -8
- package/lang/translations/sq.po +16 -8
- package/lang/translations/sr-latn.po +16 -8
- package/lang/translations/sr.po +16 -8
- package/lang/translations/sv.po +16 -8
- package/lang/translations/th.po +16 -8
- package/lang/translations/ti.po +16 -8
- package/lang/translations/tk.po +16 -8
- package/lang/translations/tr.po +16 -8
- package/lang/translations/tt.po +16 -8
- package/lang/translations/ug.po +16 -8
- package/lang/translations/uk.po +16 -8
- package/lang/translations/ur.po +16 -8
- package/lang/translations/uz.po +16 -8
- package/lang/translations/vi.po +16 -8
- package/lang/translations/zh-cn.po +16 -8
- package/lang/translations/zh.po +16 -8
- package/package.json +8 -7
- package/src/bookmarkconfig.d.ts +24 -0
- package/src/bookmarkediting.d.ts +9 -1
- package/src/bookmarkediting.js +23 -9
- package/src/bookmarkui.d.ts +24 -57
- package/src/bookmarkui.js +208 -212
- package/src/ui/bookmarkformview.d.ts +24 -14
- package/src/ui/bookmarkformview.js +103 -62
- package/theme/bookmark.css +0 -46
- package/theme/bookmarkform.css +0 -38
- package/theme/bookmarktoolbar.css +4 -0
- package/src/ui/bookmarkactionsview.d.ts +0 -102
- package/src/ui/bookmarkactionsview.js +0 -154
- package/theme/bookmarkactions.css +0 -44
package/src/bookmarkui.js
CHANGED
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import { ButtonView, ContextualBalloon, CssTransitionDisablerMixin, MenuBarMenuListItemButtonView, clickOutsideHandler } from 'ckeditor5/src/ui.js';
|
|
10
|
-
import { ClickObserver } from 'ckeditor5/src/engine.js';
|
|
5
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
6
|
+
import { ButtonView, ContextualBalloon, CssTransitionDisablerMixin, MenuBarMenuListItemButtonView, clickOutsideHandler, LabelView, BalloonPanelView } from 'ckeditor5/src/ui.js';
|
|
7
|
+
import { IconBookmark, IconRemove, IconBookmarkMedium, IconBookmarkSmall, IconPencil } from 'ckeditor5/src/icons.js';
|
|
8
|
+
import { isWidget, WidgetToolbarRepository } from 'ckeditor5/src/widget.js';
|
|
11
9
|
import BookmarkFormView from './ui/bookmarkformview.js';
|
|
12
|
-
import BookmarkActionsView from './ui/bookmarkactionsview.js';
|
|
13
10
|
import BookmarkEditing from './bookmarkediting.js';
|
|
11
|
+
import '../theme/bookmarktoolbar.css';
|
|
14
12
|
const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
|
|
15
13
|
/**
|
|
16
14
|
* The UI plugin of the bookmark feature.
|
|
@@ -19,22 +17,19 @@ const VISUAL_SELECTION_MARKER_NAME = 'bookmark-ui';
|
|
|
19
17
|
* which inserts the `bookmark` element upon selection.
|
|
20
18
|
*/
|
|
21
19
|
export default class BookmarkUI extends Plugin {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*/
|
|
31
|
-
this.formView = null;
|
|
32
|
-
}
|
|
20
|
+
/**
|
|
21
|
+
* The form view displayed inside the balloon.
|
|
22
|
+
*/
|
|
23
|
+
formView = null;
|
|
24
|
+
/**
|
|
25
|
+
* The contextual balloon plugin instance.
|
|
26
|
+
*/
|
|
27
|
+
_balloon;
|
|
33
28
|
/**
|
|
34
29
|
* @inheritDoc
|
|
35
30
|
*/
|
|
36
31
|
static get requires() {
|
|
37
|
-
return [BookmarkEditing, ContextualBalloon];
|
|
32
|
+
return [BookmarkEditing, ContextualBalloon, WidgetToolbarRepository];
|
|
38
33
|
}
|
|
39
34
|
/**
|
|
40
35
|
* @inheritDoc
|
|
@@ -53,11 +48,13 @@ export default class BookmarkUI extends Plugin {
|
|
|
53
48
|
*/
|
|
54
49
|
init() {
|
|
55
50
|
const editor = this.editor;
|
|
56
|
-
editor.editing.view.addObserver(ClickObserver);
|
|
57
51
|
this._balloon = editor.plugins.get(ContextualBalloon);
|
|
52
|
+
// Register the link provider in link plugin to display the link form.
|
|
53
|
+
if (editor.plugins.has('LinkUI')) {
|
|
54
|
+
this._registerLinkProvider();
|
|
55
|
+
}
|
|
58
56
|
// Create toolbar buttons.
|
|
59
|
-
this.
|
|
60
|
-
this._enableBalloonActivators();
|
|
57
|
+
this._registerComponents();
|
|
61
58
|
// Renders a fake visual selection marker on an expanded selection.
|
|
62
59
|
editor.conversion.for('editingDowncast').markerToHighlight({
|
|
63
60
|
model: VISUAL_SELECTION_MARKER_NAME,
|
|
@@ -78,6 +75,36 @@ export default class BookmarkUI extends Plugin {
|
|
|
78
75
|
}
|
|
79
76
|
});
|
|
80
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* @inheritDoc
|
|
80
|
+
*/
|
|
81
|
+
afterInit() {
|
|
82
|
+
const editor = this.editor;
|
|
83
|
+
const t = editor.locale.t;
|
|
84
|
+
const widgetToolbarRepository = this.editor.plugins.get(WidgetToolbarRepository);
|
|
85
|
+
const defaultPositions = BalloonPanelView.defaultPositions;
|
|
86
|
+
widgetToolbarRepository.register('bookmark', {
|
|
87
|
+
ariaLabel: t('Bookmark toolbar'),
|
|
88
|
+
items: editor.config.get('bookmark.toolbar'),
|
|
89
|
+
getRelatedElement: getSelectedBookmarkWidget,
|
|
90
|
+
balloonClassName: 'ck-bookmark-balloon',
|
|
91
|
+
// Override positions to the same list as for balloon panel default
|
|
92
|
+
// so widget toolbar will try to use same position as form view.
|
|
93
|
+
positions: [
|
|
94
|
+
defaultPositions.southArrowNorth,
|
|
95
|
+
defaultPositions.southArrowNorthMiddleWest,
|
|
96
|
+
defaultPositions.southArrowNorthMiddleEast,
|
|
97
|
+
defaultPositions.southArrowNorthWest,
|
|
98
|
+
defaultPositions.southArrowNorthEast,
|
|
99
|
+
defaultPositions.northArrowSouth,
|
|
100
|
+
defaultPositions.northArrowSouthMiddleWest,
|
|
101
|
+
defaultPositions.northArrowSouthMiddleEast,
|
|
102
|
+
defaultPositions.northArrowSouthWest,
|
|
103
|
+
defaultPositions.northArrowSouthEast,
|
|
104
|
+
defaultPositions.viewportStickyNorth
|
|
105
|
+
]
|
|
106
|
+
});
|
|
107
|
+
}
|
|
81
108
|
/**
|
|
82
109
|
* @inheritDoc
|
|
83
110
|
*/
|
|
@@ -87,61 +114,36 @@ export default class BookmarkUI extends Plugin {
|
|
|
87
114
|
if (this.formView) {
|
|
88
115
|
this.formView.destroy();
|
|
89
116
|
}
|
|
90
|
-
if (this.actionsView) {
|
|
91
|
-
this.actionsView.destroy();
|
|
92
|
-
}
|
|
93
117
|
}
|
|
94
118
|
/**
|
|
95
119
|
* Creates views.
|
|
96
120
|
*/
|
|
97
121
|
_createViews() {
|
|
98
|
-
this.actionsView = this._createActionsView();
|
|
99
122
|
this.formView = this._createFormView();
|
|
100
123
|
// Attach lifecycle actions to the the balloon.
|
|
101
124
|
this._enableUserBalloonInteractions();
|
|
102
125
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Creates the {@link module:bookmark/ui/bookmarkactionsview~BookmarkActionsView} instance.
|
|
105
|
-
*/
|
|
106
|
-
_createActionsView() {
|
|
107
|
-
const editor = this.editor;
|
|
108
|
-
const actionsView = new BookmarkActionsView(editor.locale);
|
|
109
|
-
const updateBookmarkCommand = editor.commands.get('updateBookmark');
|
|
110
|
-
const deleteCommand = editor.commands.get('delete');
|
|
111
|
-
actionsView.bind('id').to(updateBookmarkCommand, 'value');
|
|
112
|
-
actionsView.editButtonView.bind('isEnabled').to(updateBookmarkCommand);
|
|
113
|
-
actionsView.removeButtonView.bind('isEnabled').to(deleteCommand);
|
|
114
|
-
// Display edit form view after clicking on the "Edit" button.
|
|
115
|
-
this.listenTo(actionsView, 'edit', () => {
|
|
116
|
-
this._addFormView();
|
|
117
|
-
});
|
|
118
|
-
// Execute remove command after clicking on the "Remove" button.
|
|
119
|
-
this.listenTo(actionsView, 'remove', () => {
|
|
120
|
-
this._hideUI();
|
|
121
|
-
editor.execute('delete');
|
|
122
|
-
});
|
|
123
|
-
// Close the panel on esc key press when the **actions have focus**.
|
|
124
|
-
actionsView.keystrokes.set('Esc', (data, cancel) => {
|
|
125
|
-
this._hideUI();
|
|
126
|
-
cancel();
|
|
127
|
-
});
|
|
128
|
-
return actionsView;
|
|
129
|
-
}
|
|
130
126
|
/**
|
|
131
127
|
* Creates the {@link module:bookmark/ui/bookmarkformview~BookmarkFormView} instance.
|
|
132
128
|
*/
|
|
133
129
|
_createFormView() {
|
|
134
130
|
const editor = this.editor;
|
|
135
131
|
const locale = editor.locale;
|
|
132
|
+
const t = locale.t;
|
|
136
133
|
const insertBookmarkCommand = editor.commands.get('insertBookmark');
|
|
137
134
|
const updateBookmarkCommand = editor.commands.get('updateBookmark');
|
|
138
135
|
const commands = [insertBookmarkCommand, updateBookmarkCommand];
|
|
139
136
|
const formView = new (CssTransitionDisablerMixin(BookmarkFormView))(locale, getFormValidators(editor));
|
|
140
137
|
formView.idInputView.fieldView.bind('value').to(updateBookmarkCommand, 'value');
|
|
138
|
+
formView.saveButtonView.bind('label').to(updateBookmarkCommand, 'value', value => value ? t('Save') : t('Insert'));
|
|
141
139
|
// Form elements should be read-only when corresponding commands are disabled.
|
|
142
140
|
formView.idInputView.bind('isEnabled').toMany(commands, 'isEnabled', (...areEnabled) => areEnabled.some(isEnabled => isEnabled));
|
|
143
141
|
// Disable the "save" button if the command is disabled.
|
|
144
|
-
formView.
|
|
142
|
+
formView.saveButtonView.bind('isEnabled').toMany(commands, 'isEnabled', (...areEnabled) => areEnabled.some(isEnabled => isEnabled));
|
|
143
|
+
// Close the panel on form after clicking back button.
|
|
144
|
+
this.listenTo(formView, 'cancel', () => {
|
|
145
|
+
this._hideFormView();
|
|
146
|
+
});
|
|
145
147
|
// Execute link command after clicking the "Save" button.
|
|
146
148
|
this.listenTo(formView, 'submit', () => {
|
|
147
149
|
if (formView.isValid()) {
|
|
@@ -152,41 +154,134 @@ export default class BookmarkUI extends Plugin {
|
|
|
152
154
|
else {
|
|
153
155
|
editor.execute('insertBookmark', { bookmarkId: value });
|
|
154
156
|
}
|
|
155
|
-
this.
|
|
157
|
+
this._hideFormView();
|
|
156
158
|
}
|
|
157
159
|
});
|
|
158
160
|
// Update balloon position when form error changes.
|
|
159
161
|
this.listenTo(formView.idInputView, 'change:errorText', () => {
|
|
160
162
|
editor.ui.update();
|
|
161
163
|
});
|
|
162
|
-
// Close the panel on esc key press when the **form has focus**.
|
|
163
|
-
formView.keystrokes.set('Esc', (data, cancel) => {
|
|
164
|
-
this._closeFormView();
|
|
165
|
-
cancel();
|
|
166
|
-
});
|
|
167
164
|
return formView;
|
|
168
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Creates link form menu list entry, so it'll be possible to access
|
|
168
|
+
* the list of the bookmarks from the link form.
|
|
169
|
+
*/
|
|
170
|
+
_registerLinkProvider() {
|
|
171
|
+
const t = this.editor.locale.t;
|
|
172
|
+
const linksUI = this.editor.plugins.get('LinkUI');
|
|
173
|
+
const bookmarkEditing = this.editor.plugins.get(BookmarkEditing);
|
|
174
|
+
const getListItems = () => Array
|
|
175
|
+
.from(bookmarkEditing.getAllBookmarkNames())
|
|
176
|
+
.sort((a, b) => a.localeCompare(b))
|
|
177
|
+
.map((bookmarkId) => ({
|
|
178
|
+
id: bookmarkId,
|
|
179
|
+
href: `#${bookmarkId}`,
|
|
180
|
+
label: bookmarkId,
|
|
181
|
+
icon: IconBookmarkMedium
|
|
182
|
+
}));
|
|
183
|
+
const getItem = (href) => {
|
|
184
|
+
const bookmark = [...bookmarkEditing.getAllBookmarkNames()].find(item => `#${item}` === href);
|
|
185
|
+
if (!bookmark) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
href,
|
|
190
|
+
label: bookmark,
|
|
191
|
+
icon: IconBookmarkSmall,
|
|
192
|
+
tooltip: t('Scroll to bookmark')
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
linksUI.registerLinksListProvider({
|
|
196
|
+
label: t('Bookmarks'),
|
|
197
|
+
emptyListPlaceholder: t('No bookmarks available.'),
|
|
198
|
+
navigate: ({ href }) => this._scrollToBookmark(href),
|
|
199
|
+
getListItems,
|
|
200
|
+
getItem
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Scrolls the editor to the bookmark with the given id.
|
|
205
|
+
*/
|
|
206
|
+
_scrollToBookmark(href) {
|
|
207
|
+
const bookmarkEditing = this.editor.plugins.get(BookmarkEditing);
|
|
208
|
+
const bookmarkElement = bookmarkEditing.getElementForBookmarkId(href.slice(1));
|
|
209
|
+
if (!bookmarkElement) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
this.editor.model.change(writer => {
|
|
213
|
+
writer.setSelection(bookmarkElement, 'on');
|
|
214
|
+
});
|
|
215
|
+
this.editor.editing.view.scrollToTheSelection({
|
|
216
|
+
alignToTop: true,
|
|
217
|
+
forceScroll: true
|
|
218
|
+
});
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
169
221
|
/**
|
|
170
222
|
* Creates a toolbar Bookmark button. Clicking this button will show
|
|
171
223
|
* a {@link #_balloon} attached to the selection.
|
|
172
224
|
*/
|
|
173
|
-
|
|
225
|
+
_registerComponents() {
|
|
174
226
|
const editor = this.editor;
|
|
175
227
|
editor.ui.componentFactory.add('bookmark', () => {
|
|
176
|
-
const buttonView = this.
|
|
228
|
+
const buttonView = this._createBookmarkButton(ButtonView);
|
|
177
229
|
buttonView.set({
|
|
178
230
|
tooltip: true
|
|
179
231
|
});
|
|
180
232
|
return buttonView;
|
|
181
233
|
});
|
|
182
234
|
editor.ui.componentFactory.add('menuBar:bookmark', () => {
|
|
183
|
-
return this.
|
|
235
|
+
return this._createBookmarkButton(MenuBarMenuListItemButtonView);
|
|
236
|
+
});
|
|
237
|
+
// Bookmark toolbar buttons.
|
|
238
|
+
editor.ui.componentFactory.add('bookmarkPreview', locale => {
|
|
239
|
+
const updateBookmarkCommand = editor.commands.get('updateBookmark');
|
|
240
|
+
const label = new LabelView(locale);
|
|
241
|
+
label.extendTemplate({
|
|
242
|
+
attributes: {
|
|
243
|
+
class: ['ck-bookmark-toolbar__preview']
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
label.bind('text').to(updateBookmarkCommand, 'value');
|
|
247
|
+
return label;
|
|
248
|
+
});
|
|
249
|
+
editor.ui.componentFactory.add('editBookmark', locale => {
|
|
250
|
+
const updateBookmarkCommand = editor.commands.get('updateBookmark');
|
|
251
|
+
const button = new ButtonView(locale);
|
|
252
|
+
const t = locale.t;
|
|
253
|
+
button.set({
|
|
254
|
+
label: t('Edit bookmark'),
|
|
255
|
+
icon: IconPencil,
|
|
256
|
+
tooltip: true
|
|
257
|
+
});
|
|
258
|
+
button.bind('isEnabled').to(updateBookmarkCommand);
|
|
259
|
+
this.listenTo(button, 'execute', () => {
|
|
260
|
+
this._showFormView();
|
|
261
|
+
});
|
|
262
|
+
return button;
|
|
263
|
+
});
|
|
264
|
+
editor.ui.componentFactory.add('removeBookmark', locale => {
|
|
265
|
+
const deleteCommand = editor.commands.get('delete');
|
|
266
|
+
const button = new ButtonView(locale);
|
|
267
|
+
const t = locale.t;
|
|
268
|
+
button.set({
|
|
269
|
+
label: t('Remove bookmark'),
|
|
270
|
+
icon: IconRemove,
|
|
271
|
+
tooltip: true
|
|
272
|
+
});
|
|
273
|
+
button.bind('isEnabled').to(deleteCommand);
|
|
274
|
+
this.listenTo(button, 'execute', () => {
|
|
275
|
+
editor.execute('delete');
|
|
276
|
+
editor.editing.view.focus();
|
|
277
|
+
});
|
|
278
|
+
return button;
|
|
184
279
|
});
|
|
185
280
|
}
|
|
186
281
|
/**
|
|
187
282
|
* Creates a button for `bookmark` command to use either in toolbar or in menu bar.
|
|
188
283
|
*/
|
|
189
|
-
|
|
284
|
+
_createBookmarkButton(ButtonClass) {
|
|
190
285
|
const editor = this.editor;
|
|
191
286
|
const locale = editor.locale;
|
|
192
287
|
const view = new ButtonClass(locale);
|
|
@@ -195,85 +290,32 @@ export default class BookmarkUI extends Plugin {
|
|
|
195
290
|
const t = locale.t;
|
|
196
291
|
view.set({
|
|
197
292
|
label: t('Bookmark'),
|
|
198
|
-
icon:
|
|
293
|
+
icon: IconBookmark
|
|
199
294
|
});
|
|
200
295
|
// Execute the command.
|
|
201
|
-
this.listenTo(view, 'execute', () => this.
|
|
296
|
+
this.listenTo(view, 'execute', () => this._showFormView());
|
|
202
297
|
view.bind('isEnabled').toMany([insertCommand, updateCommand], 'isEnabled', (...areEnabled) => areEnabled.some(isEnabled => isEnabled));
|
|
203
298
|
view.bind('isOn').to(updateCommand, 'value', value => !!value);
|
|
204
299
|
return view;
|
|
205
300
|
}
|
|
206
|
-
/**
|
|
207
|
-
* Attaches actions that control whether the balloon panel containing the
|
|
208
|
-
* {@link #formView} should be displayed.
|
|
209
|
-
*/
|
|
210
|
-
_enableBalloonActivators() {
|
|
211
|
-
const editor = this.editor;
|
|
212
|
-
const viewDocument = editor.editing.view.document;
|
|
213
|
-
// Handle click on view document and show panel when selection is placed inside the bookmark element.
|
|
214
|
-
// Keep panel open until selection will be inside the same bookmark element.
|
|
215
|
-
this.listenTo(viewDocument, 'click', () => {
|
|
216
|
-
const bookmark = this._getSelectedBookmarkElement();
|
|
217
|
-
if (bookmark) {
|
|
218
|
-
// Then show panel but keep focus inside editor editable.
|
|
219
|
-
this._showUI();
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
301
|
/**
|
|
224
302
|
* Attaches actions that control whether the balloon panel containing the
|
|
225
303
|
* {@link #formView} is visible or not.
|
|
226
304
|
*/
|
|
227
305
|
_enableUserBalloonInteractions() {
|
|
228
|
-
// Focus the form if the balloon is visible and the Tab key has been pressed.
|
|
229
|
-
this.editor.keystrokes.set('Tab', (data, cancel) => {
|
|
230
|
-
if (this._areActionsVisible && !this.actionsView.focusTracker.isFocused) {
|
|
231
|
-
this.actionsView.focus();
|
|
232
|
-
cancel();
|
|
233
|
-
}
|
|
234
|
-
}, {
|
|
235
|
-
// Use the high priority because the bookmark UI navigation is more important
|
|
236
|
-
// than other feature's actions, e.g. list indentation.
|
|
237
|
-
priority: 'high'
|
|
238
|
-
});
|
|
239
306
|
// Close the panel on the Esc key press when the editable has focus and the balloon is visible.
|
|
240
307
|
this.editor.keystrokes.set('Esc', (data, cancel) => {
|
|
241
|
-
if (this.
|
|
242
|
-
this.
|
|
308
|
+
if (this._isFormVisible) {
|
|
309
|
+
this._hideFormView();
|
|
243
310
|
cancel();
|
|
244
311
|
}
|
|
245
312
|
});
|
|
246
313
|
// Close on click outside of balloon panel element.
|
|
247
314
|
clickOutsideHandler({
|
|
248
315
|
emitter: this.formView,
|
|
249
|
-
activator: () => this.
|
|
316
|
+
activator: () => this._isFormInPanel,
|
|
250
317
|
contextElements: () => [this._balloon.view.element],
|
|
251
|
-
callback: () => this.
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Updates the button label. If bookmark is selected label is set to 'Update' otherwise
|
|
256
|
-
* it is 'Insert'.
|
|
257
|
-
*/
|
|
258
|
-
_updateFormButtonLabel(isBookmarkSelected) {
|
|
259
|
-
const t = this.editor.locale.t;
|
|
260
|
-
this.formView.buttonView.label = isBookmarkSelected ? t('Update') : t('Insert');
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Adds the {@link #actionsView} to the {@link #_balloon}.
|
|
264
|
-
*
|
|
265
|
-
* @internal
|
|
266
|
-
*/
|
|
267
|
-
_addActionsView() {
|
|
268
|
-
if (!this.actionsView) {
|
|
269
|
-
this._createViews();
|
|
270
|
-
}
|
|
271
|
-
if (this._areActionsInPanel) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
this._balloon.add({
|
|
275
|
-
view: this.actionsView,
|
|
276
|
-
position: this._getBalloonPositionData()
|
|
318
|
+
callback: () => this._hideFormView()
|
|
277
319
|
});
|
|
278
320
|
}
|
|
279
321
|
/**
|
|
@@ -286,14 +328,14 @@ export default class BookmarkUI extends Plugin {
|
|
|
286
328
|
if (this._isFormInPanel) {
|
|
287
329
|
return;
|
|
288
330
|
}
|
|
289
|
-
const
|
|
290
|
-
const updateBookmarkCommand = editor.commands.get('updateBookmark');
|
|
331
|
+
const updateBookmarkCommand = this.editor.commands.get('updateBookmark');
|
|
291
332
|
this.formView.disableCssTransitions();
|
|
292
333
|
this.formView.resetFormStatus();
|
|
293
334
|
this._balloon.add({
|
|
294
335
|
view: this.formView,
|
|
295
336
|
position: this._getBalloonPositionData()
|
|
296
337
|
});
|
|
338
|
+
this.formView.backButtonView.isVisible = updateBookmarkCommand.isEnabled;
|
|
297
339
|
this.formView.idInputView.fieldView.value = updateBookmarkCommand.value || '';
|
|
298
340
|
// Select input when form view is currently visible.
|
|
299
341
|
if (this._balloon.visibleView === this.formView) {
|
|
@@ -301,78 +343,42 @@ export default class BookmarkUI extends Plugin {
|
|
|
301
343
|
}
|
|
302
344
|
this.formView.enableCssTransitions();
|
|
303
345
|
}
|
|
304
|
-
/**
|
|
305
|
-
* Closes the form view. Decides whether the balloon should be hidden completely.
|
|
306
|
-
*/
|
|
307
|
-
_closeFormView() {
|
|
308
|
-
const updateBookmarkCommand = this.editor.commands.get('updateBookmark');
|
|
309
|
-
if (updateBookmarkCommand.value !== undefined) {
|
|
310
|
-
this._removeFormView();
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
this._hideUI();
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
346
|
/**
|
|
317
347
|
* Removes the {@link #formView} from the {@link #_balloon}.
|
|
318
348
|
*/
|
|
319
349
|
_removeFormView() {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
this._hideFakeVisualSelection();
|
|
331
|
-
}
|
|
350
|
+
// Blur the input element before removing it from DOM to prevent issues in some browsers.
|
|
351
|
+
// See https://github.com/ckeditor/ckeditor5/issues/1501.
|
|
352
|
+
this.formView.saveButtonView.focus();
|
|
353
|
+
// Reset the ID field to update the state of the submit button.
|
|
354
|
+
this.formView.idInputView.fieldView.reset();
|
|
355
|
+
this._balloon.remove(this.formView);
|
|
356
|
+
// Because the form has an input which has focus, the focus must be brought back
|
|
357
|
+
// to the editor. Otherwise, it would be lost.
|
|
358
|
+
this.editor.editing.view.focus();
|
|
359
|
+
this._hideFakeVisualSelection();
|
|
332
360
|
}
|
|
333
361
|
/**
|
|
334
|
-
* Shows the
|
|
362
|
+
* Shows the {@link #formView}.
|
|
335
363
|
*/
|
|
336
|
-
|
|
364
|
+
_showFormView() {
|
|
337
365
|
if (!this.formView) {
|
|
338
366
|
this._createViews();
|
|
339
367
|
}
|
|
340
|
-
// When there's no bookmark under the selection, go straight to the editing UI.
|
|
341
368
|
if (!this._getSelectedBookmarkElement()) {
|
|
342
|
-
// Show visual selection on a text without a bookmark when the contextual balloon is displayed.
|
|
343
369
|
this._showFakeVisualSelection();
|
|
344
|
-
this._addActionsView();
|
|
345
|
-
// Be sure panel with bookmark is visible.
|
|
346
|
-
if (forceVisible) {
|
|
347
|
-
this._balloon.showStack('main');
|
|
348
|
-
}
|
|
349
|
-
this._addFormView();
|
|
350
|
-
}
|
|
351
|
-
// If there's a bookmark under the selection...
|
|
352
|
-
else {
|
|
353
|
-
// Go to the editing UI if actions are already visible.
|
|
354
|
-
if (this._areActionsVisible) {
|
|
355
|
-
this._addFormView();
|
|
356
|
-
}
|
|
357
|
-
// Otherwise display just the actions UI.
|
|
358
|
-
else {
|
|
359
|
-
this._addActionsView();
|
|
360
|
-
}
|
|
361
|
-
// Be sure panel with bookmark is visible.
|
|
362
|
-
if (forceVisible) {
|
|
363
|
-
this._balloon.showStack('main');
|
|
364
|
-
}
|
|
365
370
|
}
|
|
371
|
+
this._addFormView();
|
|
372
|
+
// Be sure panel with bookmark is visible.
|
|
373
|
+
this._balloon.showStack('main');
|
|
366
374
|
// Begin responding to ui#update once the UI is added.
|
|
367
375
|
this._startUpdatingUI();
|
|
368
376
|
}
|
|
369
377
|
/**
|
|
370
378
|
* Removes the {@link #formView} from the {@link #_balloon}.
|
|
371
|
-
*
|
|
372
|
-
* See {@link #_addFormView}, {@link #_addActionsView}.
|
|
373
379
|
*/
|
|
374
|
-
|
|
375
|
-
if (!this.
|
|
380
|
+
_hideFormView() {
|
|
381
|
+
if (!this._isFormInPanel) {
|
|
376
382
|
return;
|
|
377
383
|
}
|
|
378
384
|
const editor = this.editor;
|
|
@@ -383,22 +389,19 @@ export default class BookmarkUI extends Plugin {
|
|
|
383
389
|
editor.editing.view.focus();
|
|
384
390
|
// Remove form first because it's on top of the stack.
|
|
385
391
|
this._removeFormView();
|
|
386
|
-
// Then remove the actions view because it's beneath the form.
|
|
387
|
-
this._balloon.remove(this.actionsView);
|
|
388
392
|
this._hideFakeVisualSelection();
|
|
389
393
|
}
|
|
390
394
|
/**
|
|
391
395
|
* Makes the UI react to the {@link module:ui/editorui/editorui~EditorUI#event:update} event to
|
|
392
396
|
* reposition itself when the editor UI should be refreshed.
|
|
393
397
|
*
|
|
394
|
-
* See: {@link #
|
|
398
|
+
* See: {@link #_hideFormView} to learn when the UI stops reacting to the `update` event.
|
|
395
399
|
*/
|
|
396
400
|
_startUpdatingUI() {
|
|
397
401
|
const editor = this.editor;
|
|
398
402
|
const viewDocument = editor.editing.view.document;
|
|
399
403
|
let prevSelectedBookmark = this._getSelectedBookmarkElement();
|
|
400
404
|
let prevSelectionParent = getSelectionParent();
|
|
401
|
-
this._updateFormButtonLabel(!!prevSelectedBookmark);
|
|
402
405
|
const update = () => {
|
|
403
406
|
const selectedBookmark = this._getSelectedBookmarkElement();
|
|
404
407
|
const selectionParent = getSelectionParent();
|
|
@@ -410,21 +413,20 @@ export default class BookmarkUI extends Plugin {
|
|
|
410
413
|
// else modified the document.
|
|
411
414
|
// * the selection has expanded (e.g. displaying bookmark actions then pressing SHIFT+Right arrow).
|
|
412
415
|
//
|
|
413
|
-
if (
|
|
414
|
-
|
|
415
|
-
this.
|
|
416
|
+
if (prevSelectedBookmark && !selectedBookmark ||
|
|
417
|
+
!prevSelectedBookmark && selectionParent !== prevSelectionParent) {
|
|
418
|
+
this._hideFormView();
|
|
416
419
|
}
|
|
417
420
|
// Update the position of the panel when:
|
|
418
421
|
// * bookmark panel is in the visible stack
|
|
419
422
|
// * the selection remains on the original bookmark element,
|
|
420
423
|
// * there was no bookmark element in the first place, i.e. creating a new bookmark
|
|
421
|
-
else if (this.
|
|
424
|
+
else if (this._isFormVisible) {
|
|
422
425
|
// If still in a bookmark element, simply update the position of the balloon.
|
|
423
426
|
// If there was no bookmark (e.g. inserting one), the balloon must be moved
|
|
424
427
|
// to the new position in the editing view (a new native DOM range).
|
|
425
428
|
this._balloon.updatePosition(this._getBalloonPositionData());
|
|
426
429
|
}
|
|
427
|
-
this._updateFormButtonLabel(!!prevSelectedBookmark);
|
|
428
430
|
prevSelectedBookmark = selectedBookmark;
|
|
429
431
|
prevSelectionParent = selectionParent;
|
|
430
432
|
};
|
|
@@ -443,31 +445,10 @@ export default class BookmarkUI extends Plugin {
|
|
|
443
445
|
return !!this.formView && this._balloon.hasView(this.formView);
|
|
444
446
|
}
|
|
445
447
|
/**
|
|
446
|
-
* Returns `true` when {@link #
|
|
447
|
-
*/
|
|
448
|
-
get _areActionsInPanel() {
|
|
449
|
-
return !!this.actionsView && this._balloon.hasView(this.actionsView);
|
|
450
|
-
}
|
|
451
|
-
/**
|
|
452
|
-
* Returns `true` when {@link #actionsView} is in the {@link #_balloon} and it is
|
|
453
|
-
* currently visible.
|
|
448
|
+
* Returns `true` when {@link #formView} is in the {@link #_balloon} and it is currently visible.
|
|
454
449
|
*/
|
|
455
|
-
get
|
|
456
|
-
return !!this.
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* Returns `true` when {@link #actionsView} or {@link #formView} is in the {@link #_balloon}.
|
|
460
|
-
*/
|
|
461
|
-
get _isUIInPanel() {
|
|
462
|
-
return this._isFormInPanel || this._areActionsInPanel;
|
|
463
|
-
}
|
|
464
|
-
/**
|
|
465
|
-
* Returns `true` when {@link #actionsView} or {@link #formView} is in the {@link #_balloon} and it is
|
|
466
|
-
* currently visible.
|
|
467
|
-
*/
|
|
468
|
-
get _isUIVisible() {
|
|
469
|
-
const visibleView = this._balloon.visibleView;
|
|
470
|
-
return !!this.formView && visibleView == this.formView || this._areActionsVisible;
|
|
450
|
+
get _isFormVisible() {
|
|
451
|
+
return !!this.formView && this._balloon.visibleView == this.formView;
|
|
471
452
|
}
|
|
472
453
|
/**
|
|
473
454
|
* Returns positioning options for the {@link #_balloon}. They control the way the balloon is attached
|
|
@@ -492,7 +473,12 @@ export default class BookmarkUI extends Plugin {
|
|
|
492
473
|
return domConverter.mapViewToDom(viewElement);
|
|
493
474
|
};
|
|
494
475
|
}
|
|
495
|
-
|
|
476
|
+
if (!target) {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
return {
|
|
480
|
+
target
|
|
481
|
+
};
|
|
496
482
|
}
|
|
497
483
|
/**
|
|
498
484
|
* Returns the bookmark {@link module:engine/view/attributeelement~AttributeElement} under
|
|
@@ -580,3 +566,13 @@ function getFormValidators(editor) {
|
|
|
580
566
|
}
|
|
581
567
|
];
|
|
582
568
|
}
|
|
569
|
+
/**
|
|
570
|
+
* Returns the currently selected bookmark view element.
|
|
571
|
+
*/
|
|
572
|
+
function getSelectedBookmarkWidget(selection) {
|
|
573
|
+
const element = selection.getSelectedElement();
|
|
574
|
+
if (!element || !isWidget(element) || !element.getCustomProperty('bookmark')) {
|
|
575
|
+
return null;
|
|
576
|
+
}
|
|
577
|
+
return element;
|
|
578
|
+
}
|