@ckeditor/ckeditor5-bookmark 44.3.0 → 45.0.0-alpha.0
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 +282 -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 +207 -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,35 @@ 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
|
+
// Override positions to the same list as for balloon panel default
|
|
91
|
+
// so widget toolbar will try to use same position as form view.
|
|
92
|
+
positions: [
|
|
93
|
+
defaultPositions.southArrowNorth,
|
|
94
|
+
defaultPositions.southArrowNorthMiddleWest,
|
|
95
|
+
defaultPositions.southArrowNorthMiddleEast,
|
|
96
|
+
defaultPositions.southArrowNorthWest,
|
|
97
|
+
defaultPositions.southArrowNorthEast,
|
|
98
|
+
defaultPositions.northArrowSouth,
|
|
99
|
+
defaultPositions.northArrowSouthMiddleWest,
|
|
100
|
+
defaultPositions.northArrowSouthMiddleEast,
|
|
101
|
+
defaultPositions.northArrowSouthWest,
|
|
102
|
+
defaultPositions.northArrowSouthEast,
|
|
103
|
+
defaultPositions.viewportStickyNorth
|
|
104
|
+
]
|
|
105
|
+
});
|
|
106
|
+
}
|
|
81
107
|
/**
|
|
82
108
|
* @inheritDoc
|
|
83
109
|
*/
|
|
@@ -87,61 +113,36 @@ export default class BookmarkUI extends Plugin {
|
|
|
87
113
|
if (this.formView) {
|
|
88
114
|
this.formView.destroy();
|
|
89
115
|
}
|
|
90
|
-
if (this.actionsView) {
|
|
91
|
-
this.actionsView.destroy();
|
|
92
|
-
}
|
|
93
116
|
}
|
|
94
117
|
/**
|
|
95
118
|
* Creates views.
|
|
96
119
|
*/
|
|
97
120
|
_createViews() {
|
|
98
|
-
this.actionsView = this._createActionsView();
|
|
99
121
|
this.formView = this._createFormView();
|
|
100
122
|
// Attach lifecycle actions to the the balloon.
|
|
101
123
|
this._enableUserBalloonInteractions();
|
|
102
124
|
}
|
|
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
125
|
/**
|
|
131
126
|
* Creates the {@link module:bookmark/ui/bookmarkformview~BookmarkFormView} instance.
|
|
132
127
|
*/
|
|
133
128
|
_createFormView() {
|
|
134
129
|
const editor = this.editor;
|
|
135
130
|
const locale = editor.locale;
|
|
131
|
+
const t = locale.t;
|
|
136
132
|
const insertBookmarkCommand = editor.commands.get('insertBookmark');
|
|
137
133
|
const updateBookmarkCommand = editor.commands.get('updateBookmark');
|
|
138
134
|
const commands = [insertBookmarkCommand, updateBookmarkCommand];
|
|
139
135
|
const formView = new (CssTransitionDisablerMixin(BookmarkFormView))(locale, getFormValidators(editor));
|
|
140
136
|
formView.idInputView.fieldView.bind('value').to(updateBookmarkCommand, 'value');
|
|
137
|
+
formView.saveButtonView.bind('label').to(updateBookmarkCommand, 'value', value => value ? t('Save') : t('Insert'));
|
|
141
138
|
// Form elements should be read-only when corresponding commands are disabled.
|
|
142
139
|
formView.idInputView.bind('isEnabled').toMany(commands, 'isEnabled', (...areEnabled) => areEnabled.some(isEnabled => isEnabled));
|
|
143
140
|
// Disable the "save" button if the command is disabled.
|
|
144
|
-
formView.
|
|
141
|
+
formView.saveButtonView.bind('isEnabled').toMany(commands, 'isEnabled', (...areEnabled) => areEnabled.some(isEnabled => isEnabled));
|
|
142
|
+
// Close the panel on form after clicking back button.
|
|
143
|
+
this.listenTo(formView, 'cancel', () => {
|
|
144
|
+
this._hideFormView();
|
|
145
|
+
});
|
|
145
146
|
// Execute link command after clicking the "Save" button.
|
|
146
147
|
this.listenTo(formView, 'submit', () => {
|
|
147
148
|
if (formView.isValid()) {
|
|
@@ -152,41 +153,134 @@ export default class BookmarkUI extends Plugin {
|
|
|
152
153
|
else {
|
|
153
154
|
editor.execute('insertBookmark', { bookmarkId: value });
|
|
154
155
|
}
|
|
155
|
-
this.
|
|
156
|
+
this._hideFormView();
|
|
156
157
|
}
|
|
157
158
|
});
|
|
158
159
|
// Update balloon position when form error changes.
|
|
159
160
|
this.listenTo(formView.idInputView, 'change:errorText', () => {
|
|
160
161
|
editor.ui.update();
|
|
161
162
|
});
|
|
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
163
|
return formView;
|
|
168
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Creates link form menu list entry, so it'll be possible to access
|
|
167
|
+
* the list of the bookmarks from the link form.
|
|
168
|
+
*/
|
|
169
|
+
_registerLinkProvider() {
|
|
170
|
+
const t = this.editor.locale.t;
|
|
171
|
+
const linksUI = this.editor.plugins.get('LinkUI');
|
|
172
|
+
const bookmarkEditing = this.editor.plugins.get(BookmarkEditing);
|
|
173
|
+
const getListItems = () => Array
|
|
174
|
+
.from(bookmarkEditing.getAllBookmarkNames())
|
|
175
|
+
.sort((a, b) => a.localeCompare(b))
|
|
176
|
+
.map((bookmarkId) => ({
|
|
177
|
+
id: bookmarkId,
|
|
178
|
+
href: `#${bookmarkId}`,
|
|
179
|
+
label: bookmarkId,
|
|
180
|
+
icon: IconBookmarkMedium
|
|
181
|
+
}));
|
|
182
|
+
const getItem = (href) => {
|
|
183
|
+
const bookmark = [...bookmarkEditing.getAllBookmarkNames()].find(item => `#${item}` === href);
|
|
184
|
+
if (!bookmark) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
href,
|
|
189
|
+
label: bookmark,
|
|
190
|
+
icon: IconBookmarkSmall,
|
|
191
|
+
tooltip: t('Scroll to bookmark')
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
linksUI.registerLinksListProvider({
|
|
195
|
+
label: t('Bookmarks'),
|
|
196
|
+
emptyListPlaceholder: t('No bookmarks available.'),
|
|
197
|
+
navigate: ({ href }) => this._scrollToBookmark(href),
|
|
198
|
+
getListItems,
|
|
199
|
+
getItem
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Scrolls the editor to the bookmark with the given id.
|
|
204
|
+
*/
|
|
205
|
+
_scrollToBookmark(href) {
|
|
206
|
+
const bookmarkEditing = this.editor.plugins.get(BookmarkEditing);
|
|
207
|
+
const bookmarkElement = bookmarkEditing.getElementForBookmarkId(href.slice(1));
|
|
208
|
+
if (!bookmarkElement) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
this.editor.model.change(writer => {
|
|
212
|
+
writer.setSelection(bookmarkElement, 'on');
|
|
213
|
+
});
|
|
214
|
+
this.editor.editing.view.scrollToTheSelection({
|
|
215
|
+
alignToTop: true,
|
|
216
|
+
forceScroll: true
|
|
217
|
+
});
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
169
220
|
/**
|
|
170
221
|
* Creates a toolbar Bookmark button. Clicking this button will show
|
|
171
222
|
* a {@link #_balloon} attached to the selection.
|
|
172
223
|
*/
|
|
173
|
-
|
|
224
|
+
_registerComponents() {
|
|
174
225
|
const editor = this.editor;
|
|
175
226
|
editor.ui.componentFactory.add('bookmark', () => {
|
|
176
|
-
const buttonView = this.
|
|
227
|
+
const buttonView = this._createBookmarkButton(ButtonView);
|
|
177
228
|
buttonView.set({
|
|
178
229
|
tooltip: true
|
|
179
230
|
});
|
|
180
231
|
return buttonView;
|
|
181
232
|
});
|
|
182
233
|
editor.ui.componentFactory.add('menuBar:bookmark', () => {
|
|
183
|
-
return this.
|
|
234
|
+
return this._createBookmarkButton(MenuBarMenuListItemButtonView);
|
|
235
|
+
});
|
|
236
|
+
// Bookmark toolbar buttons.
|
|
237
|
+
editor.ui.componentFactory.add('bookmarkPreview', locale => {
|
|
238
|
+
const updateBookmarkCommand = editor.commands.get('updateBookmark');
|
|
239
|
+
const label = new LabelView(locale);
|
|
240
|
+
label.extendTemplate({
|
|
241
|
+
attributes: {
|
|
242
|
+
class: ['ck-bookmark-toolbar__preview']
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
label.bind('text').to(updateBookmarkCommand, 'value');
|
|
246
|
+
return label;
|
|
247
|
+
});
|
|
248
|
+
editor.ui.componentFactory.add('editBookmark', locale => {
|
|
249
|
+
const updateBookmarkCommand = editor.commands.get('updateBookmark');
|
|
250
|
+
const button = new ButtonView(locale);
|
|
251
|
+
const t = locale.t;
|
|
252
|
+
button.set({
|
|
253
|
+
label: t('Edit bookmark'),
|
|
254
|
+
icon: IconPencil,
|
|
255
|
+
tooltip: true
|
|
256
|
+
});
|
|
257
|
+
button.bind('isEnabled').to(updateBookmarkCommand);
|
|
258
|
+
this.listenTo(button, 'execute', () => {
|
|
259
|
+
this._showFormView();
|
|
260
|
+
});
|
|
261
|
+
return button;
|
|
262
|
+
});
|
|
263
|
+
editor.ui.componentFactory.add('removeBookmark', locale => {
|
|
264
|
+
const deleteCommand = editor.commands.get('delete');
|
|
265
|
+
const button = new ButtonView(locale);
|
|
266
|
+
const t = locale.t;
|
|
267
|
+
button.set({
|
|
268
|
+
label: t('Remove bookmark'),
|
|
269
|
+
icon: IconRemove,
|
|
270
|
+
tooltip: true
|
|
271
|
+
});
|
|
272
|
+
button.bind('isEnabled').to(deleteCommand);
|
|
273
|
+
this.listenTo(button, 'execute', () => {
|
|
274
|
+
editor.execute('delete');
|
|
275
|
+
editor.editing.view.focus();
|
|
276
|
+
});
|
|
277
|
+
return button;
|
|
184
278
|
});
|
|
185
279
|
}
|
|
186
280
|
/**
|
|
187
281
|
* Creates a button for `bookmark` command to use either in toolbar or in menu bar.
|
|
188
282
|
*/
|
|
189
|
-
|
|
283
|
+
_createBookmarkButton(ButtonClass) {
|
|
190
284
|
const editor = this.editor;
|
|
191
285
|
const locale = editor.locale;
|
|
192
286
|
const view = new ButtonClass(locale);
|
|
@@ -195,85 +289,32 @@ export default class BookmarkUI extends Plugin {
|
|
|
195
289
|
const t = locale.t;
|
|
196
290
|
view.set({
|
|
197
291
|
label: t('Bookmark'),
|
|
198
|
-
icon:
|
|
292
|
+
icon: IconBookmark
|
|
199
293
|
});
|
|
200
294
|
// Execute the command.
|
|
201
|
-
this.listenTo(view, 'execute', () => this.
|
|
295
|
+
this.listenTo(view, 'execute', () => this._showFormView());
|
|
202
296
|
view.bind('isEnabled').toMany([insertCommand, updateCommand], 'isEnabled', (...areEnabled) => areEnabled.some(isEnabled => isEnabled));
|
|
203
297
|
view.bind('isOn').to(updateCommand, 'value', value => !!value);
|
|
204
298
|
return view;
|
|
205
299
|
}
|
|
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
300
|
/**
|
|
224
301
|
* Attaches actions that control whether the balloon panel containing the
|
|
225
302
|
* {@link #formView} is visible or not.
|
|
226
303
|
*/
|
|
227
304
|
_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
305
|
// Close the panel on the Esc key press when the editable has focus and the balloon is visible.
|
|
240
306
|
this.editor.keystrokes.set('Esc', (data, cancel) => {
|
|
241
|
-
if (this.
|
|
242
|
-
this.
|
|
307
|
+
if (this._isFormVisible) {
|
|
308
|
+
this._hideFormView();
|
|
243
309
|
cancel();
|
|
244
310
|
}
|
|
245
311
|
});
|
|
246
312
|
// Close on click outside of balloon panel element.
|
|
247
313
|
clickOutsideHandler({
|
|
248
314
|
emitter: this.formView,
|
|
249
|
-
activator: () => this.
|
|
315
|
+
activator: () => this._isFormInPanel,
|
|
250
316
|
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()
|
|
317
|
+
callback: () => this._hideFormView()
|
|
277
318
|
});
|
|
278
319
|
}
|
|
279
320
|
/**
|
|
@@ -286,14 +327,14 @@ export default class BookmarkUI extends Plugin {
|
|
|
286
327
|
if (this._isFormInPanel) {
|
|
287
328
|
return;
|
|
288
329
|
}
|
|
289
|
-
const
|
|
290
|
-
const updateBookmarkCommand = editor.commands.get('updateBookmark');
|
|
330
|
+
const updateBookmarkCommand = this.editor.commands.get('updateBookmark');
|
|
291
331
|
this.formView.disableCssTransitions();
|
|
292
332
|
this.formView.resetFormStatus();
|
|
293
333
|
this._balloon.add({
|
|
294
334
|
view: this.formView,
|
|
295
335
|
position: this._getBalloonPositionData()
|
|
296
336
|
});
|
|
337
|
+
this.formView.backButtonView.isVisible = updateBookmarkCommand.isEnabled;
|
|
297
338
|
this.formView.idInputView.fieldView.value = updateBookmarkCommand.value || '';
|
|
298
339
|
// Select input when form view is currently visible.
|
|
299
340
|
if (this._balloon.visibleView === this.formView) {
|
|
@@ -301,78 +342,42 @@ export default class BookmarkUI extends Plugin {
|
|
|
301
342
|
}
|
|
302
343
|
this.formView.enableCssTransitions();
|
|
303
344
|
}
|
|
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
345
|
/**
|
|
317
346
|
* Removes the {@link #formView} from the {@link #_balloon}.
|
|
318
347
|
*/
|
|
319
348
|
_removeFormView() {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
this._hideFakeVisualSelection();
|
|
331
|
-
}
|
|
349
|
+
// Blur the input element before removing it from DOM to prevent issues in some browsers.
|
|
350
|
+
// See https://github.com/ckeditor/ckeditor5/issues/1501.
|
|
351
|
+
this.formView.saveButtonView.focus();
|
|
352
|
+
// Reset the ID field to update the state of the submit button.
|
|
353
|
+
this.formView.idInputView.fieldView.reset();
|
|
354
|
+
this._balloon.remove(this.formView);
|
|
355
|
+
// Because the form has an input which has focus, the focus must be brought back
|
|
356
|
+
// to the editor. Otherwise, it would be lost.
|
|
357
|
+
this.editor.editing.view.focus();
|
|
358
|
+
this._hideFakeVisualSelection();
|
|
332
359
|
}
|
|
333
360
|
/**
|
|
334
|
-
* Shows the
|
|
361
|
+
* Shows the {@link #formView}.
|
|
335
362
|
*/
|
|
336
|
-
|
|
363
|
+
_showFormView() {
|
|
337
364
|
if (!this.formView) {
|
|
338
365
|
this._createViews();
|
|
339
366
|
}
|
|
340
|
-
// When there's no bookmark under the selection, go straight to the editing UI.
|
|
341
367
|
if (!this._getSelectedBookmarkElement()) {
|
|
342
|
-
// Show visual selection on a text without a bookmark when the contextual balloon is displayed.
|
|
343
368
|
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
369
|
}
|
|
370
|
+
this._addFormView();
|
|
371
|
+
// Be sure panel with bookmark is visible.
|
|
372
|
+
this._balloon.showStack('main');
|
|
366
373
|
// Begin responding to ui#update once the UI is added.
|
|
367
374
|
this._startUpdatingUI();
|
|
368
375
|
}
|
|
369
376
|
/**
|
|
370
377
|
* Removes the {@link #formView} from the {@link #_balloon}.
|
|
371
|
-
*
|
|
372
|
-
* See {@link #_addFormView}, {@link #_addActionsView}.
|
|
373
378
|
*/
|
|
374
|
-
|
|
375
|
-
if (!this.
|
|
379
|
+
_hideFormView() {
|
|
380
|
+
if (!this._isFormInPanel) {
|
|
376
381
|
return;
|
|
377
382
|
}
|
|
378
383
|
const editor = this.editor;
|
|
@@ -383,22 +388,19 @@ export default class BookmarkUI extends Plugin {
|
|
|
383
388
|
editor.editing.view.focus();
|
|
384
389
|
// Remove form first because it's on top of the stack.
|
|
385
390
|
this._removeFormView();
|
|
386
|
-
// Then remove the actions view because it's beneath the form.
|
|
387
|
-
this._balloon.remove(this.actionsView);
|
|
388
391
|
this._hideFakeVisualSelection();
|
|
389
392
|
}
|
|
390
393
|
/**
|
|
391
394
|
* Makes the UI react to the {@link module:ui/editorui/editorui~EditorUI#event:update} event to
|
|
392
395
|
* reposition itself when the editor UI should be refreshed.
|
|
393
396
|
*
|
|
394
|
-
* See: {@link #
|
|
397
|
+
* See: {@link #_hideFormView} to learn when the UI stops reacting to the `update` event.
|
|
395
398
|
*/
|
|
396
399
|
_startUpdatingUI() {
|
|
397
400
|
const editor = this.editor;
|
|
398
401
|
const viewDocument = editor.editing.view.document;
|
|
399
402
|
let prevSelectedBookmark = this._getSelectedBookmarkElement();
|
|
400
403
|
let prevSelectionParent = getSelectionParent();
|
|
401
|
-
this._updateFormButtonLabel(!!prevSelectedBookmark);
|
|
402
404
|
const update = () => {
|
|
403
405
|
const selectedBookmark = this._getSelectedBookmarkElement();
|
|
404
406
|
const selectionParent = getSelectionParent();
|
|
@@ -410,21 +412,20 @@ export default class BookmarkUI extends Plugin {
|
|
|
410
412
|
// else modified the document.
|
|
411
413
|
// * the selection has expanded (e.g. displaying bookmark actions then pressing SHIFT+Right arrow).
|
|
412
414
|
//
|
|
413
|
-
if (
|
|
414
|
-
|
|
415
|
-
this.
|
|
415
|
+
if (prevSelectedBookmark && !selectedBookmark ||
|
|
416
|
+
!prevSelectedBookmark && selectionParent !== prevSelectionParent) {
|
|
417
|
+
this._hideFormView();
|
|
416
418
|
}
|
|
417
419
|
// Update the position of the panel when:
|
|
418
420
|
// * bookmark panel is in the visible stack
|
|
419
421
|
// * the selection remains on the original bookmark element,
|
|
420
422
|
// * there was no bookmark element in the first place, i.e. creating a new bookmark
|
|
421
|
-
else if (this.
|
|
423
|
+
else if (this._isFormVisible) {
|
|
422
424
|
// If still in a bookmark element, simply update the position of the balloon.
|
|
423
425
|
// If there was no bookmark (e.g. inserting one), the balloon must be moved
|
|
424
426
|
// to the new position in the editing view (a new native DOM range).
|
|
425
427
|
this._balloon.updatePosition(this._getBalloonPositionData());
|
|
426
428
|
}
|
|
427
|
-
this._updateFormButtonLabel(!!prevSelectedBookmark);
|
|
428
429
|
prevSelectedBookmark = selectedBookmark;
|
|
429
430
|
prevSelectionParent = selectionParent;
|
|
430
431
|
};
|
|
@@ -443,31 +444,10 @@ export default class BookmarkUI extends Plugin {
|
|
|
443
444
|
return !!this.formView && this._balloon.hasView(this.formView);
|
|
444
445
|
}
|
|
445
446
|
/**
|
|
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.
|
|
447
|
+
* Returns `true` when {@link #formView} is in the {@link #_balloon} and it is currently visible.
|
|
454
448
|
*/
|
|
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;
|
|
449
|
+
get _isFormVisible() {
|
|
450
|
+
return !!this.formView && this._balloon.visibleView == this.formView;
|
|
471
451
|
}
|
|
472
452
|
/**
|
|
473
453
|
* Returns positioning options for the {@link #_balloon}. They control the way the balloon is attached
|
|
@@ -492,7 +472,12 @@ export default class BookmarkUI extends Plugin {
|
|
|
492
472
|
return domConverter.mapViewToDom(viewElement);
|
|
493
473
|
};
|
|
494
474
|
}
|
|
495
|
-
|
|
475
|
+
if (!target) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
return {
|
|
479
|
+
target
|
|
480
|
+
};
|
|
496
481
|
}
|
|
497
482
|
/**
|
|
498
483
|
* Returns the bookmark {@link module:engine/view/attributeelement~AttributeElement} under
|
|
@@ -580,3 +565,13 @@ function getFormValidators(editor) {
|
|
|
580
565
|
}
|
|
581
566
|
];
|
|
582
567
|
}
|
|
568
|
+
/**
|
|
569
|
+
* Returns the currently selected bookmark view element.
|
|
570
|
+
*/
|
|
571
|
+
function getSelectedBookmarkWidget(selection) {
|
|
572
|
+
const element = selection.getSelectedElement();
|
|
573
|
+
if (!element || !isWidget(element) || !element.getCustomProperty('bookmark')) {
|
|
574
|
+
return null;
|
|
575
|
+
}
|
|
576
|
+
return element;
|
|
577
|
+
}
|