@ckeditor/ckeditor5-bookmark 0.0.0-nightly-next-20250302.0 → 0.0.0-nightly-20250303.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/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 +101 -56
- package/dist/index.css +119 -59
- package/dist/index.css.map +1 -1
- package/dist/index.js +389 -282
- package/dist/index.js.map +1 -1
- package/lang/contexts.json +3 -5
- package/package.json +7 -8
- package/src/bookmarkconfig.d.ts +0 -24
- package/src/bookmarkediting.d.ts +1 -9
- package/src/bookmarkediting.js +9 -23
- package/src/bookmarkui.d.ts +57 -24
- package/src/bookmarkui.js +212 -207
- package/src/ui/bookmarkactionsview.d.ts +102 -0
- package/src/ui/bookmarkactionsview.js +154 -0
- package/src/ui/bookmarkformview.d.ts +14 -24
- package/src/ui/bookmarkformview.js +62 -103
- package/theme/bookmark.css +46 -0
- package/theme/bookmarkactions.css +44 -0
- package/theme/bookmarkform.css +38 -0
- package/theme/bookmarktoolbar.css +0 -4
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module bookmark/ui/bookmarkactionsview
|
|
7
|
+
*/
|
|
8
|
+
import { LabelView, ButtonView, View } from 'ckeditor5/src/ui.js';
|
|
9
|
+
import { FocusTracker, KeystrokeHandler, type LocaleTranslate, type Locale } from 'ckeditor5/src/utils.js';
|
|
10
|
+
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
|
11
|
+
import '../../theme/bookmarkactions.css';
|
|
12
|
+
/**
|
|
13
|
+
* The bookmark actions view class. This view displays the bookmark preview, allows
|
|
14
|
+
* removing or editing the bookmark.
|
|
15
|
+
*/
|
|
16
|
+
export default class BookmarkActionsView extends View {
|
|
17
|
+
/**
|
|
18
|
+
* Tracks information about DOM focus in the actions.
|
|
19
|
+
*/
|
|
20
|
+
readonly focusTracker: FocusTracker;
|
|
21
|
+
/**
|
|
22
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
23
|
+
*/
|
|
24
|
+
readonly keystrokes: KeystrokeHandler;
|
|
25
|
+
/**
|
|
26
|
+
* The bookmark preview view.
|
|
27
|
+
*/
|
|
28
|
+
bookmarkPreviewView: LabelView;
|
|
29
|
+
/**
|
|
30
|
+
* The remove button view.
|
|
31
|
+
*/
|
|
32
|
+
removeButtonView: ButtonView;
|
|
33
|
+
/**
|
|
34
|
+
* The edit bookmark button view.
|
|
35
|
+
*/
|
|
36
|
+
editButtonView: ButtonView;
|
|
37
|
+
/**
|
|
38
|
+
* The id preview view.
|
|
39
|
+
*
|
|
40
|
+
* @observable
|
|
41
|
+
*/
|
|
42
|
+
id: string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* A collection of views that can be focused in the view.
|
|
45
|
+
*/
|
|
46
|
+
private readonly _focusables;
|
|
47
|
+
/**
|
|
48
|
+
* Helps cycling over {@link #_focusables} in the view.
|
|
49
|
+
*/
|
|
50
|
+
private readonly _focusCycler;
|
|
51
|
+
t: LocaleTranslate;
|
|
52
|
+
/**
|
|
53
|
+
* @inheritDoc
|
|
54
|
+
*/
|
|
55
|
+
constructor(locale: Locale);
|
|
56
|
+
/**
|
|
57
|
+
* @inheritDoc
|
|
58
|
+
*/
|
|
59
|
+
render(): void;
|
|
60
|
+
/**
|
|
61
|
+
* @inheritDoc
|
|
62
|
+
*/
|
|
63
|
+
destroy(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Focuses the fist {@link #_focusables} in the actions.
|
|
66
|
+
*/
|
|
67
|
+
focus(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Creates a button view.
|
|
70
|
+
*
|
|
71
|
+
* @param label The button label.
|
|
72
|
+
* @param icon The button icon.
|
|
73
|
+
* @param eventName An event name that the `ButtonView#execute` event will be delegated to.
|
|
74
|
+
* @param additionalLabel An additional label outside the button.
|
|
75
|
+
* @returns The button view instance.
|
|
76
|
+
*/
|
|
77
|
+
private _createButton;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a bookmark name preview label.
|
|
80
|
+
*
|
|
81
|
+
* @returns The label view instance.
|
|
82
|
+
*/
|
|
83
|
+
private _createBookmarkPreviewView;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Fired when the {@link ~BookmarkActionsView#editButtonView} is clicked.
|
|
87
|
+
*
|
|
88
|
+
* @eventName ~BookmarkActionsView#edit
|
|
89
|
+
*/
|
|
90
|
+
export type EditEvent = {
|
|
91
|
+
name: 'edit';
|
|
92
|
+
args: [];
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Fired when the {@link ~BookmarkActionsView#removeButtonView} is clicked.
|
|
96
|
+
*
|
|
97
|
+
* @eventName ~BookmarkActionsView#remove
|
|
98
|
+
*/
|
|
99
|
+
export type RemoveEvent = {
|
|
100
|
+
name: 'remove';
|
|
101
|
+
args: [];
|
|
102
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module bookmark/ui/bookmarkactionsview
|
|
7
|
+
*/
|
|
8
|
+
import { LabelView, ButtonView, View, ViewCollection, FocusCycler } from 'ckeditor5/src/ui.js';
|
|
9
|
+
import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';
|
|
10
|
+
import { icons } from 'ckeditor5/src/core.js';
|
|
11
|
+
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
|
12
|
+
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
|
13
|
+
import '../../theme/bookmarkactions.css';
|
|
14
|
+
/**
|
|
15
|
+
* The bookmark actions view class. This view displays the bookmark preview, allows
|
|
16
|
+
* removing or editing the bookmark.
|
|
17
|
+
*/
|
|
18
|
+
export default class BookmarkActionsView extends View {
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
constructor(locale) {
|
|
23
|
+
super(locale);
|
|
24
|
+
/**
|
|
25
|
+
* Tracks information about DOM focus in the actions.
|
|
26
|
+
*/
|
|
27
|
+
this.focusTracker = new FocusTracker();
|
|
28
|
+
/**
|
|
29
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
30
|
+
*/
|
|
31
|
+
this.keystrokes = new KeystrokeHandler();
|
|
32
|
+
/**
|
|
33
|
+
* A collection of views that can be focused in the view.
|
|
34
|
+
*/
|
|
35
|
+
this._focusables = new ViewCollection();
|
|
36
|
+
const t = locale.t;
|
|
37
|
+
this.bookmarkPreviewView = this._createBookmarkPreviewView();
|
|
38
|
+
this.removeButtonView = this._createButton(t('Remove bookmark'), icons.remove, 'remove', this.bookmarkPreviewView);
|
|
39
|
+
this.editButtonView = this._createButton(t('Edit bookmark'), icons.pencil, 'edit', this.bookmarkPreviewView);
|
|
40
|
+
this.set('id', undefined);
|
|
41
|
+
this._focusCycler = new FocusCycler({
|
|
42
|
+
focusables: this._focusables,
|
|
43
|
+
focusTracker: this.focusTracker,
|
|
44
|
+
keystrokeHandler: this.keystrokes,
|
|
45
|
+
actions: {
|
|
46
|
+
// Navigate fields backwards using the Shift + Tab keystroke.
|
|
47
|
+
focusPrevious: 'shift + tab',
|
|
48
|
+
// Navigate fields forwards using the Tab key.
|
|
49
|
+
focusNext: 'tab'
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
this.setTemplate({
|
|
53
|
+
tag: 'div',
|
|
54
|
+
attributes: {
|
|
55
|
+
class: [
|
|
56
|
+
'ck',
|
|
57
|
+
'ck-bookmark-actions',
|
|
58
|
+
'ck-responsive-form'
|
|
59
|
+
],
|
|
60
|
+
// https://github.com/ckeditor/ckeditor5-link/issues/90
|
|
61
|
+
tabindex: '-1'
|
|
62
|
+
},
|
|
63
|
+
children: [
|
|
64
|
+
this.bookmarkPreviewView,
|
|
65
|
+
this.editButtonView,
|
|
66
|
+
this.removeButtonView
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @inheritDoc
|
|
72
|
+
*/
|
|
73
|
+
render() {
|
|
74
|
+
super.render();
|
|
75
|
+
const childViews = [
|
|
76
|
+
this.editButtonView,
|
|
77
|
+
this.removeButtonView
|
|
78
|
+
];
|
|
79
|
+
childViews.forEach(v => {
|
|
80
|
+
// Register the view as focusable.
|
|
81
|
+
this._focusables.add(v);
|
|
82
|
+
// Register the view in the focus tracker.
|
|
83
|
+
this.focusTracker.add(v.element);
|
|
84
|
+
});
|
|
85
|
+
// Start listening for the keystrokes coming from #element.
|
|
86
|
+
this.keystrokes.listenTo(this.element);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* @inheritDoc
|
|
90
|
+
*/
|
|
91
|
+
destroy() {
|
|
92
|
+
super.destroy();
|
|
93
|
+
this.focusTracker.destroy();
|
|
94
|
+
this.keystrokes.destroy();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Focuses the fist {@link #_focusables} in the actions.
|
|
98
|
+
*/
|
|
99
|
+
focus() {
|
|
100
|
+
this._focusCycler.focusFirst();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Creates a button view.
|
|
104
|
+
*
|
|
105
|
+
* @param label The button label.
|
|
106
|
+
* @param icon The button icon.
|
|
107
|
+
* @param eventName An event name that the `ButtonView#execute` event will be delegated to.
|
|
108
|
+
* @param additionalLabel An additional label outside the button.
|
|
109
|
+
* @returns The button view instance.
|
|
110
|
+
*/
|
|
111
|
+
_createButton(label, icon, eventName, additionalLabel) {
|
|
112
|
+
const button = new ButtonView(this.locale);
|
|
113
|
+
button.set({
|
|
114
|
+
label,
|
|
115
|
+
icon,
|
|
116
|
+
tooltip: true
|
|
117
|
+
});
|
|
118
|
+
button.delegate('execute').to(this, eventName);
|
|
119
|
+
// Since button label `id` is bound to the `ariaLabelledBy` property
|
|
120
|
+
// we need to modify this binding to include only the first ID token
|
|
121
|
+
// as this button will be labeled by multiple labels.
|
|
122
|
+
button.labelView.unbind('id');
|
|
123
|
+
button.labelView.bind('id').to(button, 'ariaLabelledBy', ariaLabelledBy => {
|
|
124
|
+
return getFirstToken(ariaLabelledBy);
|
|
125
|
+
});
|
|
126
|
+
button.ariaLabelledBy = `${button.ariaLabelledBy} ${additionalLabel.id}`;
|
|
127
|
+
return button;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Creates a bookmark name preview label.
|
|
131
|
+
*
|
|
132
|
+
* @returns The label view instance.
|
|
133
|
+
*/
|
|
134
|
+
_createBookmarkPreviewView() {
|
|
135
|
+
const label = new LabelView(this.locale);
|
|
136
|
+
label.extendTemplate({
|
|
137
|
+
attributes: {
|
|
138
|
+
class: [
|
|
139
|
+
'ck',
|
|
140
|
+
'ck-bookmark-actions__preview'
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
// Bind label text with the bookmark ID.
|
|
145
|
+
label.bind('text').to(this, 'id');
|
|
146
|
+
return label;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Returns the first token from space separated token list.
|
|
151
|
+
*/
|
|
152
|
+
function getFirstToken(tokenList) {
|
|
153
|
+
return tokenList.split(' ')[0];
|
|
154
|
+
}
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
import { ButtonView, LabeledFieldView, View, ViewCollection, type InputTextView } from 'ckeditor5/src/ui.js';
|
|
9
9
|
import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils.js';
|
|
10
10
|
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
|
11
|
-
import '@ckeditor/ckeditor5-ui/theme/components/form/form.css';
|
|
12
11
|
import '../../theme/bookmarkform.css';
|
|
13
12
|
/**
|
|
14
13
|
* The bookmark form view controller class.
|
|
@@ -29,13 +28,9 @@ export default class BookmarkFormView extends View {
|
|
|
29
28
|
*/
|
|
30
29
|
idInputView: LabeledFieldView<InputTextView>;
|
|
31
30
|
/**
|
|
32
|
-
* The
|
|
31
|
+
* The Submit button view.
|
|
33
32
|
*/
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* A button used to submit the form.
|
|
37
|
-
*/
|
|
38
|
-
saveButtonView: ButtonView;
|
|
33
|
+
buttonView: ButtonView;
|
|
39
34
|
/**
|
|
40
35
|
* A collection of form child views in the form.
|
|
41
36
|
*/
|
|
@@ -85,23 +80,27 @@ export default class BookmarkFormView extends View {
|
|
|
85
80
|
*/
|
|
86
81
|
resetFormStatus(): void;
|
|
87
82
|
/**
|
|
88
|
-
* Creates
|
|
83
|
+
* Creates header and form view.
|
|
89
84
|
*/
|
|
90
|
-
private
|
|
85
|
+
private _createViewChildren;
|
|
91
86
|
/**
|
|
92
|
-
* Creates
|
|
87
|
+
* Creates form content view with input and button.
|
|
93
88
|
*/
|
|
94
|
-
private
|
|
95
|
-
/**
|
|
96
|
-
* Creates a header view for the form.
|
|
97
|
-
*/
|
|
98
|
-
private _createHeaderView;
|
|
89
|
+
private _createFormContentView;
|
|
99
90
|
/**
|
|
100
91
|
* Creates a labeled input view.
|
|
101
92
|
*
|
|
102
93
|
* @returns Labeled field view instance.
|
|
103
94
|
*/
|
|
104
95
|
private _createIdInput;
|
|
96
|
+
/**
|
|
97
|
+
* Creates a button view.
|
|
98
|
+
*
|
|
99
|
+
* @param label The button label.
|
|
100
|
+
* @param className The additional button CSS class name.
|
|
101
|
+
* @returns The button view instance.
|
|
102
|
+
*/
|
|
103
|
+
private _createButton;
|
|
105
104
|
/**
|
|
106
105
|
* The native DOM `value` of the {@link #idInputView} element.
|
|
107
106
|
*
|
|
@@ -117,12 +116,3 @@ export default class BookmarkFormView extends View {
|
|
|
117
116
|
* If string is returned, it is assumed that the form value is incorrect and the returned string is displayed in the error label
|
|
118
117
|
*/
|
|
119
118
|
export type BookmarkFormValidatorCallback = (form: BookmarkFormView) => string | undefined;
|
|
120
|
-
/**
|
|
121
|
-
* Fired when the form view is canceled.
|
|
122
|
-
*
|
|
123
|
-
* @eventName ~BookmarkFormView#cancel
|
|
124
|
-
*/
|
|
125
|
-
export type BookmarkFormViewCancelEvent = {
|
|
126
|
-
name: 'cancel';
|
|
127
|
-
args: [];
|
|
128
|
-
};
|
|
@@ -5,14 +5,11 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module bookmark/ui/bookmarkformview
|
|
7
7
|
*/
|
|
8
|
-
import { ButtonView, FocusCycler,
|
|
8
|
+
import { ButtonView, FocusCycler, LabeledFieldView, View, ViewCollection, createLabeledInputText, submitHandler, FormHeaderView } from 'ckeditor5/src/ui.js';
|
|
9
9
|
import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';
|
|
10
|
-
import { IconPreviousArrow } from '@ckeditor/ckeditor5-icons';
|
|
11
10
|
// See: #8833.
|
|
12
11
|
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
|
13
12
|
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
|
14
|
-
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
|
15
|
-
import '@ckeditor/ckeditor5-ui/theme/components/form/form.css';
|
|
16
13
|
import '../../theme/bookmarkform.css';
|
|
17
14
|
/**
|
|
18
15
|
* The bookmark form view controller class.
|
|
@@ -20,42 +17,6 @@ import '../../theme/bookmarkform.css';
|
|
|
20
17
|
* See {@link module:bookmark/ui/bookmarkformview~BookmarkFormView}.
|
|
21
18
|
*/
|
|
22
19
|
export default class BookmarkFormView extends View {
|
|
23
|
-
/**
|
|
24
|
-
* Tracks information about DOM focus in the form.
|
|
25
|
-
*/
|
|
26
|
-
focusTracker = new FocusTracker();
|
|
27
|
-
/**
|
|
28
|
-
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
29
|
-
*/
|
|
30
|
-
keystrokes = new KeystrokeHandler();
|
|
31
|
-
/**
|
|
32
|
-
* The ID input view.
|
|
33
|
-
*/
|
|
34
|
-
idInputView;
|
|
35
|
-
/**
|
|
36
|
-
* The Back button view displayed in the header.
|
|
37
|
-
*/
|
|
38
|
-
backButtonView;
|
|
39
|
-
/**
|
|
40
|
-
* A button used to submit the form.
|
|
41
|
-
*/
|
|
42
|
-
saveButtonView;
|
|
43
|
-
/**
|
|
44
|
-
* A collection of form child views in the form.
|
|
45
|
-
*/
|
|
46
|
-
children;
|
|
47
|
-
/**
|
|
48
|
-
* An array of form validators used by {@link #isValid}.
|
|
49
|
-
*/
|
|
50
|
-
_validators;
|
|
51
|
-
/**
|
|
52
|
-
* A collection of views that can be focused in the form.
|
|
53
|
-
*/
|
|
54
|
-
_focusables = new ViewCollection();
|
|
55
|
-
/**
|
|
56
|
-
* Helps cycling over {@link #_focusables} in the form.
|
|
57
|
-
*/
|
|
58
|
-
_focusCycler;
|
|
59
20
|
/**
|
|
60
21
|
* Creates an instance of the {@link module:bookmark/ui/bookmarkformview~BookmarkFormView} class.
|
|
61
22
|
*
|
|
@@ -66,28 +27,24 @@ export default class BookmarkFormView extends View {
|
|
|
66
27
|
*/
|
|
67
28
|
constructor(locale, validators) {
|
|
68
29
|
super(locale);
|
|
30
|
+
/**
|
|
31
|
+
* Tracks information about DOM focus in the form.
|
|
32
|
+
*/
|
|
33
|
+
this.focusTracker = new FocusTracker();
|
|
34
|
+
/**
|
|
35
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
36
|
+
*/
|
|
37
|
+
this.keystrokes = new KeystrokeHandler();
|
|
38
|
+
/**
|
|
39
|
+
* A collection of views that can be focused in the form.
|
|
40
|
+
*/
|
|
41
|
+
this._focusables = new ViewCollection();
|
|
42
|
+
const t = locale.t;
|
|
69
43
|
this._validators = validators;
|
|
70
|
-
// Create buttons.
|
|
71
|
-
this.backButtonView = this._createBackButton();
|
|
72
|
-
this.saveButtonView = this._createSaveButton();
|
|
73
|
-
// Create input fields.
|
|
74
44
|
this.idInputView = this._createIdInput();
|
|
75
|
-
this.
|
|
76
|
-
this.
|
|
77
|
-
|
|
78
|
-
this.idInputView,
|
|
79
|
-
this.saveButtonView
|
|
80
|
-
],
|
|
81
|
-
class: [
|
|
82
|
-
'ck-form__row_with-submit',
|
|
83
|
-
'ck-form__row_large-top-padding'
|
|
84
|
-
]
|
|
85
|
-
}));
|
|
86
|
-
// Close the panel on esc key press when the **form has focus**.
|
|
87
|
-
this.keystrokes.set('Esc', (data, cancel) => {
|
|
88
|
-
this.fire('cancel');
|
|
89
|
-
cancel();
|
|
90
|
-
});
|
|
45
|
+
this.buttonView = this._createButton(t('Insert'), 'ck-button-action ck-button-bold');
|
|
46
|
+
this.buttonView.type = 'submit';
|
|
47
|
+
this.children = this._createViewChildren();
|
|
91
48
|
this._focusCycler = new FocusCycler({
|
|
92
49
|
focusables: this._focusables,
|
|
93
50
|
focusTracker: this.focusTracker,
|
|
@@ -99,15 +56,11 @@ export default class BookmarkFormView extends View {
|
|
|
99
56
|
focusNext: 'tab'
|
|
100
57
|
}
|
|
101
58
|
});
|
|
59
|
+
const classList = ['ck', 'ck-bookmark-view'];
|
|
102
60
|
this.setTemplate({
|
|
103
61
|
tag: 'form',
|
|
104
62
|
attributes: {
|
|
105
|
-
class:
|
|
106
|
-
'ck',
|
|
107
|
-
'ck-form',
|
|
108
|
-
'ck-bookmark-form',
|
|
109
|
-
'ck-responsive-form'
|
|
110
|
-
],
|
|
63
|
+
class: classList,
|
|
111
64
|
// https://github.com/ckeditor/ckeditor5-link/issues/90
|
|
112
65
|
tabindex: '-1'
|
|
113
66
|
},
|
|
@@ -123,9 +76,8 @@ export default class BookmarkFormView extends View {
|
|
|
123
76
|
view: this
|
|
124
77
|
});
|
|
125
78
|
const childViews = [
|
|
126
|
-
this.backButtonView,
|
|
127
79
|
this.idInputView,
|
|
128
|
-
this.
|
|
80
|
+
this.buttonView
|
|
129
81
|
];
|
|
130
82
|
childViews.forEach(v => {
|
|
131
83
|
// Register the view as focusable.
|
|
@@ -148,7 +100,7 @@ export default class BookmarkFormView extends View {
|
|
|
148
100
|
* Focuses the fist {@link #_focusables} in the form.
|
|
149
101
|
*/
|
|
150
102
|
focus() {
|
|
151
|
-
this.
|
|
103
|
+
this._focusCycler.focusFirst();
|
|
152
104
|
}
|
|
153
105
|
/**
|
|
154
106
|
* Validates the form and returns `false` when some fields are invalid.
|
|
@@ -176,44 +128,32 @@ export default class BookmarkFormView extends View {
|
|
|
176
128
|
this.idInputView.errorText = null;
|
|
177
129
|
}
|
|
178
130
|
/**
|
|
179
|
-
* Creates
|
|
131
|
+
* Creates header and form view.
|
|
180
132
|
*/
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
icon: IconPreviousArrow,
|
|
188
|
-
tooltip: true
|
|
189
|
-
});
|
|
190
|
-
backButton.delegate('execute').to(this, 'cancel');
|
|
191
|
-
return backButton;
|
|
133
|
+
_createViewChildren() {
|
|
134
|
+
const children = this.createCollection();
|
|
135
|
+
const t = this.t;
|
|
136
|
+
children.add(new FormHeaderView(this.locale, { label: t('Bookmark') }));
|
|
137
|
+
children.add(this._createFormContentView());
|
|
138
|
+
return children;
|
|
192
139
|
}
|
|
193
140
|
/**
|
|
194
|
-
* Creates
|
|
141
|
+
* Creates form content view with input and button.
|
|
195
142
|
*/
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
* Creates a header view for the form.
|
|
209
|
-
*/
|
|
210
|
-
_createHeaderView() {
|
|
211
|
-
const t = this.locale.t;
|
|
212
|
-
const header = new FormHeaderView(this.locale, {
|
|
213
|
-
label: t('Bookmark')
|
|
143
|
+
_createFormContentView() {
|
|
144
|
+
const view = new View(this.locale);
|
|
145
|
+
const children = this.createCollection();
|
|
146
|
+
const classList = ['ck', 'ck-bookmark-form', 'ck-responsive-form'];
|
|
147
|
+
children.add(this.idInputView);
|
|
148
|
+
children.add(this.buttonView);
|
|
149
|
+
view.setTemplate({
|
|
150
|
+
tag: 'div',
|
|
151
|
+
attributes: {
|
|
152
|
+
class: classList
|
|
153
|
+
},
|
|
154
|
+
children
|
|
214
155
|
});
|
|
215
|
-
|
|
216
|
-
return header;
|
|
156
|
+
return view;
|
|
217
157
|
}
|
|
218
158
|
/**
|
|
219
159
|
* Creates a labeled input view.
|
|
@@ -225,9 +165,28 @@ export default class BookmarkFormView extends View {
|
|
|
225
165
|
const labeledInput = new LabeledFieldView(this.locale, createLabeledInputText);
|
|
226
166
|
labeledInput.label = t('Bookmark name');
|
|
227
167
|
labeledInput.infoText = t('Enter the bookmark name without spaces.');
|
|
228
|
-
labeledInput.class = 'ck-labeled-field-view_full-width';
|
|
229
168
|
return labeledInput;
|
|
230
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Creates a button view.
|
|
172
|
+
*
|
|
173
|
+
* @param label The button label.
|
|
174
|
+
* @param className The additional button CSS class name.
|
|
175
|
+
* @returns The button view instance.
|
|
176
|
+
*/
|
|
177
|
+
_createButton(label, className) {
|
|
178
|
+
const button = new ButtonView(this.locale);
|
|
179
|
+
button.set({
|
|
180
|
+
label,
|
|
181
|
+
withText: true
|
|
182
|
+
});
|
|
183
|
+
button.extendTemplate({
|
|
184
|
+
attributes: {
|
|
185
|
+
class: className
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
return button;
|
|
189
|
+
}
|
|
231
190
|
/**
|
|
232
191
|
* The native DOM `value` of the {@link #idInputView} element.
|
|
233
192
|
*
|
package/theme/bookmark.css
CHANGED
|
@@ -2,3 +2,49 @@
|
|
|
2
2
|
* 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
|
+
:root {
|
|
7
|
+
--ck-bookmark-icon-hover-fill-color: var(--ck-color-widget-hover-border);
|
|
8
|
+
--ck-bookmark-icon-selected-fill-color: var(--ck-color-focus-border);
|
|
9
|
+
--ck-bookmark-icon-animation-duration: var(--ck-widget-handler-animation-duration);
|
|
10
|
+
--ck-bookmark-icon-animation-curve: var(--ck-widget-handler-animation-curve);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.ck-bookmark {
|
|
14
|
+
&.ck-widget {
|
|
15
|
+
outline: none;
|
|
16
|
+
|
|
17
|
+
& .ck-bookmark__icon .ck-icon__fill {
|
|
18
|
+
transition: fill var(--ck-bookmark-icon-animation-duration) var(--ck-bookmark-icon-animation-curve);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
& .ck-bookmark__icon .ck-icon__fill {
|
|
23
|
+
fill: var(--ck-bookmark-icon-hover-fill-color);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&.ck-widget_selected {
|
|
28
|
+
.ck-bookmark__icon .ck-icon__fill {
|
|
29
|
+
fill: var(--ck-bookmark-icon-selected-fill-color);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&.ck-widget_selected,
|
|
34
|
+
&.ck-widget_selected:hover {
|
|
35
|
+
outline: none;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
& .ck-bookmark__icon {
|
|
39
|
+
position: relative;
|
|
40
|
+
/* To make it align with text baseline. */
|
|
41
|
+
top: -0.1em;
|
|
42
|
+
|
|
43
|
+
& .ck-icon {
|
|
44
|
+
height: 1.2em;
|
|
45
|
+
width: auto;
|
|
46
|
+
vertical-align: middle;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@import "@ckeditor/ckeditor5-ui/theme/mixins/_rwd.css";
|
|
7
|
+
@import "@ckeditor/ckeditor5-ui/theme/mixins/_unselectable.css";
|
|
8
|
+
|
|
9
|
+
.ck.ck-bookmark-actions {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
|
|
13
|
+
& .ck-bookmark-actions__preview {
|
|
14
|
+
max-width: var(--ck-input-width);
|
|
15
|
+
min-width: 3em;
|
|
16
|
+
font-weight: normal;
|
|
17
|
+
text-overflow: ellipsis;
|
|
18
|
+
text-align: center;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
|
|
21
|
+
@mixin ck-unselectable;
|
|
22
|
+
cursor: default;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@mixin ck-media-phone {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-wrap: wrap;
|
|
28
|
+
|
|
29
|
+
& .ck-bookmark-actions__preview {
|
|
30
|
+
flex-basis: 100%;
|
|
31
|
+
margin: var(--ck-spacing-standard) var(--ck-spacing-standard) 0;
|
|
32
|
+
min-width: auto;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&.ck-responsive-form {
|
|
37
|
+
& .ck-button {
|
|
38
|
+
@mixin ck-media-phone {
|
|
39
|
+
flex-basis: 50%;
|
|
40
|
+
margin-top: var(--ck-spacing-standard);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|