@ckeditor/ckeditor5-image 47.6.1-alpha.1 → 48.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/LICENSE.md +1 -1
- package/ckeditor5-metadata.json +25 -25
- package/{src → dist}/autoimage.d.ts +4 -4
- package/{src → dist}/image/converters.d.ts +1 -1
- package/{src → dist}/image/imageblockediting.d.ts +2 -2
- package/{src → dist}/image/imageediting.d.ts +1 -1
- package/{src → dist}/image/imageinlineediting.d.ts +2 -2
- package/{src → dist}/image/imageloadobserver.d.ts +1 -1
- package/{src → dist}/image/imageplaceholder.d.ts +1 -1
- package/{src → dist}/image/imagetypecommand.d.ts +2 -2
- package/{src → dist}/image/insertimagecommand.d.ts +2 -2
- package/{src → dist}/image/replaceimagesourcecommand.d.ts +2 -2
- package/{src → dist}/image/ui/utils.d.ts +2 -2
- package/{src → dist}/image/utils.d.ts +2 -2
- package/{src → dist}/image.d.ts +1 -1
- package/{src → dist}/imageblock.d.ts +2 -2
- package/{src → dist}/imagecaption/imagecaptionediting.d.ts +2 -2
- package/{src → dist}/imagecaption/imagecaptionui.d.ts +1 -1
- package/{src → dist}/imagecaption/imagecaptionutils.d.ts +2 -2
- package/{src → dist}/imagecaption/toggleimagecaptioncommand.d.ts +1 -1
- package/{src → dist}/imagecaption.d.ts +1 -1
- package/{src → dist}/imageconfig.d.ts +25 -16
- package/{src → dist}/imageinline.d.ts +2 -2
- package/{src → dist}/imageinsert/imageinsertui.d.ts +3 -3
- package/{src → dist}/imageinsert/imageinsertviaurlui.d.ts +2 -2
- package/{src → dist}/imageinsert/ui/imageinsertformview.d.ts +2 -2
- package/{src → dist}/imageinsert/ui/imageinserturlview.d.ts +2 -2
- package/{src → dist}/imageinsert.d.ts +1 -1
- package/{src → dist}/imageinsertviaurl.d.ts +1 -1
- package/{src → dist}/imageresize/imagecustomresizeui.d.ts +2 -2
- package/{src → dist}/imageresize/imageresizebuttons.d.ts +1 -1
- package/{src → dist}/imageresize/imageresizeediting.d.ts +1 -1
- package/{src → dist}/imageresize/imageresizehandles.d.ts +2 -2
- package/{src → dist}/imageresize/resizeimagecommand.d.ts +1 -1
- package/{src → dist}/imageresize/ui/imagecustomresizeformview.d.ts +2 -4
- package/{src → dist}/imageresize/utils/getselectedimageeditornodes.d.ts +2 -2
- package/{src → dist}/imageresize/utils/getselectedimagepossibleresizerange.d.ts +1 -1
- package/{src → dist}/imageresize/utils/getselectedimagewidthinunits.d.ts +1 -1
- package/{src → dist}/imageresize.d.ts +1 -1
- package/{src → dist}/imagesizeattributes.d.ts +1 -1
- package/{src → dist}/imagestyle/converters.d.ts +2 -2
- package/{src → dist}/imagestyle/imagestylecommand.d.ts +2 -2
- package/{src → dist}/imagestyle/imagestyleediting.d.ts +1 -1
- package/{src → dist}/imagestyle/imagestyleui.d.ts +1 -1
- package/{src → dist}/imagestyle/utils.d.ts +1 -1
- package/{src → dist}/imagestyle.d.ts +1 -1
- package/{src → dist}/imagetextalternative/imagetextalternativecommand.d.ts +1 -1
- package/{src → dist}/imagetextalternative/imagetextalternativeediting.d.ts +1 -1
- package/{src → dist}/imagetextalternative/imagetextalternativeui.d.ts +2 -2
- package/{src → dist}/imagetextalternative/ui/textalternativeformview.d.ts +2 -4
- package/{src → dist}/imagetextalternative.d.ts +1 -1
- package/{src → dist}/imagetoolbar.d.ts +2 -2
- package/{src → dist}/imageupload/imageuploadediting.d.ts +5 -5
- package/{src → dist}/imageupload/imageuploadprogress.d.ts +1 -1
- package/{src → dist}/imageupload/imageuploadui.d.ts +1 -1
- package/{src → dist}/imageupload/uploadimagecommand.d.ts +2 -2
- package/{src → dist}/imageupload/utils.d.ts +1 -1
- package/{src → dist}/imageupload.d.ts +1 -1
- package/{src → dist}/imageutils.d.ts +2 -2
- package/dist/index-content.css +97 -100
- package/dist/index-editor.css +313 -190
- package/dist/index.css +388 -458
- package/dist/index.css.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/{src → dist}/pictureediting.d.ts +1 -1
- package/package.json +29 -53
- package/build/image.js +0 -5
- package/build/translations/af.js +0 -1
- package/build/translations/ar.js +0 -1
- package/build/translations/ast.js +0 -1
- package/build/translations/az.js +0 -1
- package/build/translations/be.js +0 -1
- package/build/translations/bg.js +0 -1
- package/build/translations/bn.js +0 -1
- package/build/translations/bs.js +0 -1
- package/build/translations/ca.js +0 -1
- package/build/translations/cs.js +0 -1
- package/build/translations/da.js +0 -1
- package/build/translations/de-ch.js +0 -1
- package/build/translations/de.js +0 -1
- package/build/translations/el.js +0 -1
- package/build/translations/en-au.js +0 -1
- package/build/translations/en-gb.js +0 -1
- package/build/translations/eo.js +0 -1
- package/build/translations/es-co.js +0 -1
- package/build/translations/es.js +0 -1
- package/build/translations/et.js +0 -1
- package/build/translations/eu.js +0 -1
- package/build/translations/fa.js +0 -1
- package/build/translations/fi.js +0 -1
- package/build/translations/fr.js +0 -1
- package/build/translations/gl.js +0 -1
- package/build/translations/gu.js +0 -1
- package/build/translations/he.js +0 -1
- package/build/translations/hi.js +0 -1
- package/build/translations/hr.js +0 -1
- package/build/translations/hu.js +0 -1
- package/build/translations/hy.js +0 -1
- package/build/translations/id.js +0 -1
- package/build/translations/it.js +0 -1
- package/build/translations/ja.js +0 -1
- package/build/translations/jv.js +0 -1
- package/build/translations/kk.js +0 -1
- package/build/translations/km.js +0 -1
- package/build/translations/kn.js +0 -1
- package/build/translations/ko.js +0 -1
- package/build/translations/ku.js +0 -1
- package/build/translations/lt.js +0 -1
- package/build/translations/lv.js +0 -1
- package/build/translations/ms.js +0 -1
- package/build/translations/nb.js +0 -1
- package/build/translations/ne.js +0 -1
- package/build/translations/nl.js +0 -1
- package/build/translations/no.js +0 -1
- package/build/translations/oc.js +0 -1
- package/build/translations/pl.js +0 -1
- package/build/translations/pt-br.js +0 -1
- package/build/translations/pt.js +0 -1
- package/build/translations/ro.js +0 -1
- package/build/translations/ru.js +0 -1
- package/build/translations/si.js +0 -1
- package/build/translations/sk.js +0 -1
- package/build/translations/sl.js +0 -1
- package/build/translations/sq.js +0 -1
- package/build/translations/sr-latn.js +0 -1
- package/build/translations/sr.js +0 -1
- package/build/translations/sv.js +0 -1
- package/build/translations/th.js +0 -1
- package/build/translations/ti.js +0 -1
- package/build/translations/tk.js +0 -1
- package/build/translations/tr.js +0 -1
- package/build/translations/tt.js +0 -1
- package/build/translations/ug.js +0 -1
- package/build/translations/uk.js +0 -1
- package/build/translations/ur.js +0 -1
- package/build/translations/uz.js +0 -1
- package/build/translations/vi.js +0 -1
- package/build/translations/zh-cn.js +0 -1
- package/build/translations/zh.js +0 -1
- package/lang/contexts.json +0 -48
- package/lang/translations/af.po +0 -196
- package/lang/translations/ar.po +0 -196
- package/lang/translations/ast.po +0 -196
- package/lang/translations/az.po +0 -196
- package/lang/translations/be.po +0 -196
- package/lang/translations/bg.po +0 -196
- package/lang/translations/bn.po +0 -196
- package/lang/translations/bs.po +0 -196
- package/lang/translations/ca.po +0 -196
- package/lang/translations/cs.po +0 -196
- package/lang/translations/da.po +0 -196
- package/lang/translations/de-ch.po +0 -196
- package/lang/translations/de.po +0 -196
- package/lang/translations/el.po +0 -196
- package/lang/translations/en-au.po +0 -196
- package/lang/translations/en-gb.po +0 -196
- package/lang/translations/en.po +0 -196
- package/lang/translations/eo.po +0 -196
- package/lang/translations/es-co.po +0 -196
- package/lang/translations/es.po +0 -196
- package/lang/translations/et.po +0 -196
- package/lang/translations/eu.po +0 -196
- package/lang/translations/fa.po +0 -196
- package/lang/translations/fi.po +0 -196
- package/lang/translations/fr.po +0 -196
- package/lang/translations/gl.po +0 -196
- package/lang/translations/gu.po +0 -196
- package/lang/translations/he.po +0 -196
- package/lang/translations/hi.po +0 -196
- package/lang/translations/hr.po +0 -196
- package/lang/translations/hu.po +0 -196
- package/lang/translations/hy.po +0 -196
- package/lang/translations/id.po +0 -196
- package/lang/translations/it.po +0 -196
- package/lang/translations/ja.po +0 -196
- package/lang/translations/jv.po +0 -196
- package/lang/translations/kk.po +0 -196
- package/lang/translations/km.po +0 -196
- package/lang/translations/kn.po +0 -196
- package/lang/translations/ko.po +0 -196
- package/lang/translations/ku.po +0 -196
- package/lang/translations/lt.po +0 -196
- package/lang/translations/lv.po +0 -196
- package/lang/translations/ms.po +0 -196
- package/lang/translations/nb.po +0 -196
- package/lang/translations/ne.po +0 -196
- package/lang/translations/nl.po +0 -196
- package/lang/translations/no.po +0 -196
- package/lang/translations/oc.po +0 -196
- package/lang/translations/pl.po +0 -196
- package/lang/translations/pt-br.po +0 -196
- package/lang/translations/pt.po +0 -196
- package/lang/translations/ro.po +0 -196
- package/lang/translations/ru.po +0 -196
- package/lang/translations/si.po +0 -196
- package/lang/translations/sk.po +0 -196
- package/lang/translations/sl.po +0 -196
- package/lang/translations/sq.po +0 -196
- package/lang/translations/sr-latn.po +0 -196
- package/lang/translations/sr.po +0 -196
- package/lang/translations/sv.po +0 -196
- package/lang/translations/th.po +0 -196
- package/lang/translations/ti.po +0 -196
- package/lang/translations/tk.po +0 -196
- package/lang/translations/tr.po +0 -196
- package/lang/translations/tt.po +0 -196
- package/lang/translations/ug.po +0 -196
- package/lang/translations/uk.po +0 -196
- package/lang/translations/ur.po +0 -196
- package/lang/translations/uz.po +0 -196
- package/lang/translations/vi.po +0 -196
- package/lang/translations/zh-cn.po +0 -196
- package/lang/translations/zh.po +0 -196
- package/src/augmentation.js +0 -5
- package/src/autoimage.js +0 -148
- package/src/image/converters.js +0 -236
- package/src/image/imageblockediting.js +0 -159
- package/src/image/imageediting.js +0 -69
- package/src/image/imageinlineediting.js +0 -178
- package/src/image/imageloadobserver.js +0 -52
- package/src/image/imageplaceholder.js +0 -119
- package/src/image/imagetypecommand.js +0 -84
- package/src/image/insertimagecommand.js +0 -125
- package/src/image/replaceimagesourcecommand.js +0 -75
- package/src/image/ui/utils.js +0 -46
- package/src/image/utils.js +0 -125
- package/src/image.js +0 -44
- package/src/imageblock.js +0 -44
- package/src/imagecaption/imagecaptionediting.js +0 -238
- package/src/imagecaption/imagecaptionui.js +0 -68
- package/src/imagecaption/imagecaptionutils.js +0 -68
- package/src/imagecaption/toggleimagecaptioncommand.js +0 -138
- package/src/imagecaption.js +0 -36
- package/src/imageconfig.js +0 -5
- package/src/imageinline.js +0 -44
- package/src/imageinsert/imageinsertui.js +0 -216
- package/src/imageinsert/imageinsertviaurlui.js +0 -175
- package/src/imageinsert/ui/imageinsertformview.js +0 -117
- package/src/imageinsert/ui/imageinserturlview.js +0 -102
- package/src/imageinsert.js +0 -43
- package/src/imageinsertviaurl.js +0 -41
- package/src/imageresize/imagecustomresizeui.js +0 -177
- package/src/imageresize/imageresizebuttons.js +0 -303
- package/src/imageresize/imageresizeediting.js +0 -206
- package/src/imageresize/imageresizehandles.js +0 -118
- package/src/imageresize/resizeimagecommand.js +0 -63
- package/src/imageresize/ui/imagecustomresizeformview.js +0 -264
- package/src/imageresize/utils/getselectedimageeditornodes.js +0 -25
- package/src/imageresize/utils/getselectedimagepossibleresizerange.js +0 -33
- package/src/imageresize/utils/getselectedimagewidthinunits.js +0 -42
- package/src/imageresize/utils/tryparsedimensionwithunit.js +0 -58
- package/src/imageresize.js +0 -38
- package/src/imagesizeattributes.js +0 -163
- package/src/imagestyle/converters.js +0 -118
- package/src/imagestyle/imagestylecommand.js +0 -117
- package/src/imagestyle/imagestyleediting.js +0 -127
- package/src/imagestyle/imagestyleui.js +0 -198
- package/src/imagestyle/utils.js +0 -333
- package/src/imagestyle.js +0 -42
- package/src/imagetextalternative/imagetextalternativecommand.js +0 -44
- package/src/imagetextalternative/imagetextalternativeediting.js +0 -41
- package/src/imagetextalternative/imagetextalternativeui.js +0 -183
- package/src/imagetextalternative/ui/textalternativeformview.js +0 -193
- package/src/imagetextalternative.js +0 -39
- package/src/imagetoolbar.js +0 -63
- package/src/imageupload/imageuploadediting.js +0 -482
- package/src/imageupload/imageuploadprogress.js +0 -222
- package/src/imageupload/imageuploadui.js +0 -135
- package/src/imageupload/uploadimagecommand.js +0 -110
- package/src/imageupload/utils.js +0 -114
- package/src/imageupload.js +0 -42
- package/src/imageutils.js +0 -309
- package/src/index.js +0 -67
- package/src/pictureediting.js +0 -136
- package/theme/image.css +0 -143
- package/theme/imagecaption.css +0 -53
- package/theme/imagecustomresizeform.css +0 -4
- package/theme/imageinsert.css +0 -14
- package/theme/imageplaceholder.css +0 -10
- package/theme/imageresize.css +0 -53
- package/theme/imagestyle.css +0 -120
- package/theme/imageuploadicon.css +0 -23
- package/theme/imageuploadloader.css +0 -18
- package/theme/imageuploadprogress.css +0 -19
- package/theme/textalternativeform.css +0 -4
- /package/{src → dist}/augmentation.d.ts +0 -0
- /package/{src → dist}/imageresize/utils/tryparsedimensionwithunit.d.ts +0 -0
- /package/{src → dist}/index.d.ts +0 -0
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, 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 image/imagetextalternative/imagetextalternativeui
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { ButtonView, ContextualBalloon, clickOutsideHandler, CssTransitionDisablerMixin } from 'ckeditor5/src/ui.js';
|
|
10
|
-
import { IconTextAlternative } from 'ckeditor5/src/icons.js';
|
|
11
|
-
import { TextAlternativeFormView } from './ui/textalternativeformview.js';
|
|
12
|
-
import { repositionContextualBalloon, getBalloonPositionData } from '../image/ui/utils.js';
|
|
13
|
-
/**
|
|
14
|
-
* The image text alternative UI plugin.
|
|
15
|
-
*
|
|
16
|
-
* The plugin uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon}.
|
|
17
|
-
*/
|
|
18
|
-
export class ImageTextAlternativeUI extends Plugin {
|
|
19
|
-
/**
|
|
20
|
-
* The contextual balloon plugin instance.
|
|
21
|
-
*/
|
|
22
|
-
_balloon;
|
|
23
|
-
/**
|
|
24
|
-
* A form containing a textarea and buttons, used to change the `alt` text value.
|
|
25
|
-
*/
|
|
26
|
-
_form;
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
static get requires() {
|
|
31
|
-
return [ContextualBalloon];
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @inheritDoc
|
|
35
|
-
*/
|
|
36
|
-
static get pluginName() {
|
|
37
|
-
return 'ImageTextAlternativeUI';
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* @inheritDoc
|
|
41
|
-
*/
|
|
42
|
-
static get isOfficialPlugin() {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* @inheritDoc
|
|
47
|
-
*/
|
|
48
|
-
init() {
|
|
49
|
-
this._createButton();
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* @inheritDoc
|
|
53
|
-
*/
|
|
54
|
-
destroy() {
|
|
55
|
-
super.destroy();
|
|
56
|
-
// Destroy created UI components as they are not automatically destroyed (see ckeditor5#1341).
|
|
57
|
-
if (this._form) {
|
|
58
|
-
this._form.destroy();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Creates a button showing the balloon panel for changing the image text alternative and
|
|
63
|
-
* registers it in the editor {@link module:ui/componentfactory~ComponentFactory ComponentFactory}.
|
|
64
|
-
*/
|
|
65
|
-
_createButton() {
|
|
66
|
-
const editor = this.editor;
|
|
67
|
-
const t = editor.t;
|
|
68
|
-
editor.ui.componentFactory.add('imageTextAlternative', locale => {
|
|
69
|
-
const command = editor.commands.get('imageTextAlternative');
|
|
70
|
-
const view = new ButtonView(locale);
|
|
71
|
-
view.set({
|
|
72
|
-
label: t('Change image text alternative'),
|
|
73
|
-
icon: IconTextAlternative,
|
|
74
|
-
tooltip: true
|
|
75
|
-
});
|
|
76
|
-
view.bind('isEnabled').to(command, 'isEnabled');
|
|
77
|
-
view.bind('isOn').to(command, 'value', value => !!value);
|
|
78
|
-
this.listenTo(view, 'execute', () => {
|
|
79
|
-
this._showForm();
|
|
80
|
-
});
|
|
81
|
-
return view;
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Creates the {@link module:image/imagetextalternative/ui/textalternativeformview~TextAlternativeFormView}
|
|
86
|
-
* form.
|
|
87
|
-
*/
|
|
88
|
-
_createForm() {
|
|
89
|
-
const editor = this.editor;
|
|
90
|
-
const view = editor.editing.view;
|
|
91
|
-
const viewDocument = view.document;
|
|
92
|
-
const imageUtils = editor.plugins.get('ImageUtils');
|
|
93
|
-
this._balloon = this.editor.plugins.get('ContextualBalloon');
|
|
94
|
-
this._form = new (CssTransitionDisablerMixin(TextAlternativeFormView))(editor.locale);
|
|
95
|
-
// Render the form so its #element is available for clickOutsideHandler.
|
|
96
|
-
this._form.render();
|
|
97
|
-
this.listenTo(this._form, 'submit', () => {
|
|
98
|
-
editor.execute('imageTextAlternative', {
|
|
99
|
-
newValue: this._form.labeledInput.fieldView.element.value
|
|
100
|
-
});
|
|
101
|
-
this._hideForm(true);
|
|
102
|
-
});
|
|
103
|
-
this.listenTo(this._form, 'cancel', () => {
|
|
104
|
-
this._hideForm(true);
|
|
105
|
-
});
|
|
106
|
-
// Reposition the balloon or hide the form if an image widget is no longer selected.
|
|
107
|
-
this.listenTo(editor.ui, 'update', () => {
|
|
108
|
-
if (!imageUtils.getClosestSelectedImageWidget(viewDocument.selection)) {
|
|
109
|
-
this._hideForm(true);
|
|
110
|
-
}
|
|
111
|
-
else if (this._isVisible) {
|
|
112
|
-
repositionContextualBalloon(editor);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
// Close on click outside of balloon panel element.
|
|
116
|
-
clickOutsideHandler({
|
|
117
|
-
emitter: this._form,
|
|
118
|
-
activator: () => this._isVisible,
|
|
119
|
-
contextElements: () => [this._balloon.view.element],
|
|
120
|
-
callback: () => this._hideForm()
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Shows the {@link #_form} in the {@link #_balloon}.
|
|
125
|
-
*/
|
|
126
|
-
_showForm() {
|
|
127
|
-
if (this._isVisible) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
if (!this._form) {
|
|
131
|
-
this._createForm();
|
|
132
|
-
}
|
|
133
|
-
const editor = this.editor;
|
|
134
|
-
const command = editor.commands.get('imageTextAlternative');
|
|
135
|
-
const labeledInput = this._form.labeledInput;
|
|
136
|
-
this._form.disableCssTransitions();
|
|
137
|
-
if (!this._isInBalloon) {
|
|
138
|
-
this._balloon.add({
|
|
139
|
-
view: this._form,
|
|
140
|
-
position: getBalloonPositionData(editor)
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
// Make sure that each time the panel shows up, the field remains in sync with the value of
|
|
144
|
-
// the command. If the user typed in the input, then canceled the balloon (`labeledInput#value`
|
|
145
|
-
// stays unaltered) and re-opened it without changing the value of the command, they would see the
|
|
146
|
-
// old value instead of the actual value of the command.
|
|
147
|
-
// https://github.com/ckeditor/ckeditor5-image/issues/114
|
|
148
|
-
labeledInput.fieldView.value = labeledInput.fieldView.element.value = command.value || '';
|
|
149
|
-
this._form.labeledInput.fieldView.select();
|
|
150
|
-
this._form.enableCssTransitions();
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Removes the {@link #_form} from the {@link #_balloon}.
|
|
154
|
-
*
|
|
155
|
-
* @param focusEditable Controls whether the editing view is focused afterwards.
|
|
156
|
-
*/
|
|
157
|
-
_hideForm(focusEditable = false) {
|
|
158
|
-
if (!this._isInBalloon) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
// Blur the input element before removing it from DOM to prevent issues in some browsers.
|
|
162
|
-
// See https://github.com/ckeditor/ckeditor5/issues/1501.
|
|
163
|
-
if (this._form.focusTracker.isFocused) {
|
|
164
|
-
this._form.saveButtonView.focus();
|
|
165
|
-
}
|
|
166
|
-
this._balloon.remove(this._form);
|
|
167
|
-
if (focusEditable) {
|
|
168
|
-
this.editor.editing.view.focus();
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Returns `true` when the {@link #_form} is the visible view in the {@link #_balloon}.
|
|
173
|
-
*/
|
|
174
|
-
get _isVisible() {
|
|
175
|
-
return !!this._balloon && this._balloon.visibleView === this._form;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Returns `true` when the {@link #_form} is in the {@link #_balloon}.
|
|
179
|
-
*/
|
|
180
|
-
get _isInBalloon() {
|
|
181
|
-
return !!this._balloon && this._balloon.hasView(this._form);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, 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 image/imagetextalternative/ui/textalternativeformview
|
|
7
|
-
*/
|
|
8
|
-
import { ButtonView, FocusCycler, FormRowView, FormHeaderView, LabeledFieldView, View, ViewCollection, createLabeledInputText, submitHandler } from 'ckeditor5/src/ui.js';
|
|
9
|
-
import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';
|
|
10
|
-
import { IconPreviousArrow } from 'ckeditor5/src/icons.js';
|
|
11
|
-
import '../../../theme/textalternativeform.css';
|
|
12
|
-
// See: #8833.
|
|
13
|
-
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
|
14
|
-
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
|
15
|
-
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
|
16
|
-
import '@ckeditor/ckeditor5-ui/theme/components/form/form.css';
|
|
17
|
-
/**
|
|
18
|
-
* The TextAlternativeFormView class.
|
|
19
|
-
*
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
export class TextAlternativeFormView extends View {
|
|
23
|
-
/**
|
|
24
|
-
* Tracks information about the DOM focus in the form.
|
|
25
|
-
*/
|
|
26
|
-
focusTracker;
|
|
27
|
-
/**
|
|
28
|
-
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
29
|
-
*/
|
|
30
|
-
keystrokes;
|
|
31
|
-
/**
|
|
32
|
-
* An input with a label.
|
|
33
|
-
*/
|
|
34
|
-
labeledInput;
|
|
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 child views.
|
|
45
|
-
*/
|
|
46
|
-
children;
|
|
47
|
-
/**
|
|
48
|
-
* A collection of views which can be focused in the form.
|
|
49
|
-
*/
|
|
50
|
-
_focusables;
|
|
51
|
-
/**
|
|
52
|
-
* Helps cycling over {@link #_focusables} in the form.
|
|
53
|
-
*/
|
|
54
|
-
_focusCycler;
|
|
55
|
-
/**
|
|
56
|
-
* @inheritDoc
|
|
57
|
-
*/
|
|
58
|
-
constructor(locale) {
|
|
59
|
-
super(locale);
|
|
60
|
-
this.focusTracker = new FocusTracker();
|
|
61
|
-
this.keystrokes = new KeystrokeHandler();
|
|
62
|
-
// Create buttons.
|
|
63
|
-
this.backButtonView = this._createBackButton();
|
|
64
|
-
this.saveButtonView = this._createSaveButton();
|
|
65
|
-
// Create input fields.
|
|
66
|
-
this.labeledInput = this._createLabeledInputView();
|
|
67
|
-
this.children = this.createCollection([
|
|
68
|
-
this._createHeaderView()
|
|
69
|
-
]);
|
|
70
|
-
this.children.add(new FormRowView(locale, {
|
|
71
|
-
children: [
|
|
72
|
-
this.labeledInput,
|
|
73
|
-
this.saveButtonView
|
|
74
|
-
],
|
|
75
|
-
class: [
|
|
76
|
-
'ck-form__row_with-submit',
|
|
77
|
-
'ck-form__row_large-top-padding'
|
|
78
|
-
]
|
|
79
|
-
}));
|
|
80
|
-
this._focusables = new ViewCollection();
|
|
81
|
-
// Close the panel on esc key press when the **form has focus**.
|
|
82
|
-
this.keystrokes.set('Esc', (data, cancel) => {
|
|
83
|
-
this.fire('cancel');
|
|
84
|
-
cancel();
|
|
85
|
-
});
|
|
86
|
-
this._focusCycler = new FocusCycler({
|
|
87
|
-
focusables: this._focusables,
|
|
88
|
-
focusTracker: this.focusTracker,
|
|
89
|
-
keystrokeHandler: this.keystrokes,
|
|
90
|
-
actions: {
|
|
91
|
-
// Navigate form fields backwards using the Shift + Tab keystroke.
|
|
92
|
-
focusPrevious: 'shift + tab',
|
|
93
|
-
// Navigate form fields forwards using the Tab key.
|
|
94
|
-
focusNext: 'tab'
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
this.setTemplate({
|
|
98
|
-
tag: 'form',
|
|
99
|
-
attributes: {
|
|
100
|
-
class: [
|
|
101
|
-
'ck',
|
|
102
|
-
'ck-form',
|
|
103
|
-
'ck-text-alternative-form',
|
|
104
|
-
'ck-responsive-form'
|
|
105
|
-
],
|
|
106
|
-
// https://github.com/ckeditor/ckeditor5-image/issues/40
|
|
107
|
-
tabindex: '-1'
|
|
108
|
-
},
|
|
109
|
-
children: this.children
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* @inheritDoc
|
|
114
|
-
*/
|
|
115
|
-
render() {
|
|
116
|
-
super.render();
|
|
117
|
-
submitHandler({
|
|
118
|
-
view: this
|
|
119
|
-
});
|
|
120
|
-
const childViews = [
|
|
121
|
-
this.backButtonView,
|
|
122
|
-
this.labeledInput,
|
|
123
|
-
this.saveButtonView
|
|
124
|
-
];
|
|
125
|
-
childViews.forEach(v => {
|
|
126
|
-
// Register the view as focusable.
|
|
127
|
-
this._focusables.add(v);
|
|
128
|
-
// Register the view in the focus tracker.
|
|
129
|
-
this.focusTracker.add(v.element);
|
|
130
|
-
});
|
|
131
|
-
this.keystrokes.listenTo(this.element);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* @inheritDoc
|
|
135
|
-
*/
|
|
136
|
-
destroy() {
|
|
137
|
-
super.destroy();
|
|
138
|
-
this.focusTracker.destroy();
|
|
139
|
-
this.keystrokes.destroy();
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Creates a back button view that cancels the form.
|
|
143
|
-
*/
|
|
144
|
-
_createBackButton() {
|
|
145
|
-
const t = this.locale.t;
|
|
146
|
-
const backButton = new ButtonView(this.locale);
|
|
147
|
-
backButton.set({
|
|
148
|
-
class: 'ck-button-back',
|
|
149
|
-
label: t('Back'),
|
|
150
|
-
icon: IconPreviousArrow,
|
|
151
|
-
tooltip: true
|
|
152
|
-
});
|
|
153
|
-
backButton.delegate('execute').to(this, 'cancel');
|
|
154
|
-
return backButton;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Creates a save button view that text alternative the image.
|
|
158
|
-
*/
|
|
159
|
-
_createSaveButton() {
|
|
160
|
-
const t = this.locale.t;
|
|
161
|
-
const saveButton = new ButtonView(this.locale);
|
|
162
|
-
saveButton.set({
|
|
163
|
-
label: t('Save'),
|
|
164
|
-
withText: true,
|
|
165
|
-
type: 'submit',
|
|
166
|
-
class: 'ck-button-action ck-button-bold'
|
|
167
|
-
});
|
|
168
|
-
return saveButton;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Creates a header view for the form.
|
|
172
|
-
*/
|
|
173
|
-
_createHeaderView() {
|
|
174
|
-
const t = this.locale.t;
|
|
175
|
-
const header = new FormHeaderView(this.locale, {
|
|
176
|
-
label: t('Text Alternative')
|
|
177
|
-
});
|
|
178
|
-
header.children.add(this.backButtonView, 0);
|
|
179
|
-
return header;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Creates an input with a label.
|
|
183
|
-
*
|
|
184
|
-
* @returns Labeled field view instance.
|
|
185
|
-
*/
|
|
186
|
-
_createLabeledInputView() {
|
|
187
|
-
const t = this.locale.t;
|
|
188
|
-
const labeledInput = new LabeledFieldView(this.locale, createLabeledInputText);
|
|
189
|
-
labeledInput.label = t('Text alternative');
|
|
190
|
-
labeledInput.class = 'ck-labeled-field-view_full-width';
|
|
191
|
-
return labeledInput;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, 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 image/imagetextalternative
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { ImageTextAlternativeEditing } from './imagetextalternative/imagetextalternativeediting.js';
|
|
10
|
-
import { ImageTextAlternativeUI } from './imagetextalternative/imagetextalternativeui.js';
|
|
11
|
-
/**
|
|
12
|
-
* The image text alternative plugin.
|
|
13
|
-
*
|
|
14
|
-
* For a detailed overview, check the {@glink features/images/images-styles image styles} documentation.
|
|
15
|
-
*
|
|
16
|
-
* This is a "glue" plugin which loads the
|
|
17
|
-
* {@link module:image/imagetextalternative/imagetextalternativeediting~ImageTextAlternativeEditing}
|
|
18
|
-
* and {@link module:image/imagetextalternative/imagetextalternativeui~ImageTextAlternativeUI} plugins.
|
|
19
|
-
*/
|
|
20
|
-
export class ImageTextAlternative extends Plugin {
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
static get requires() {
|
|
25
|
-
return [ImageTextAlternativeEditing, ImageTextAlternativeUI];
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
static get pluginName() {
|
|
31
|
-
return 'ImageTextAlternative';
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @inheritDoc
|
|
35
|
-
*/
|
|
36
|
-
static get isOfficialPlugin() {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
}
|
package/src/imagetoolbar.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, 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 image/imagetoolbar
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { WidgetToolbarRepository } from 'ckeditor5/src/widget.js';
|
|
10
|
-
import { ImageUtils } from './imageutils.js';
|
|
11
|
-
import { isObject } from 'es-toolkit/compat';
|
|
12
|
-
/**
|
|
13
|
-
* The image toolbar plugin. It creates and manages the image toolbar (the toolbar displayed when an image is selected).
|
|
14
|
-
*
|
|
15
|
-
* For an overview, check the {@glink features/images/images-overview#image-contextual-toolbar image contextual toolbar} documentation.
|
|
16
|
-
*
|
|
17
|
-
* Instances of toolbar components (e.g. buttons) are created using the editor's
|
|
18
|
-
* {@link module:ui/componentfactory~ComponentFactory component factory}
|
|
19
|
-
* based on the {@link module:image/imageconfig~ImageConfig#toolbar `image.toolbar` configuration option}.
|
|
20
|
-
*
|
|
21
|
-
* The toolbar uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon}.
|
|
22
|
-
*/
|
|
23
|
-
export class ImageToolbar extends Plugin {
|
|
24
|
-
/**
|
|
25
|
-
* @inheritDoc
|
|
26
|
-
*/
|
|
27
|
-
static get requires() {
|
|
28
|
-
return [WidgetToolbarRepository, ImageUtils];
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @inheritDoc
|
|
32
|
-
*/
|
|
33
|
-
static get pluginName() {
|
|
34
|
-
return 'ImageToolbar';
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @inheritDoc
|
|
38
|
-
*/
|
|
39
|
-
static get isOfficialPlugin() {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* @inheritDoc
|
|
44
|
-
*/
|
|
45
|
-
afterInit() {
|
|
46
|
-
const editor = this.editor;
|
|
47
|
-
const t = editor.t;
|
|
48
|
-
const widgetToolbarRepository = editor.plugins.get(WidgetToolbarRepository);
|
|
49
|
-
const imageUtils = editor.plugins.get('ImageUtils');
|
|
50
|
-
widgetToolbarRepository.register('image', {
|
|
51
|
-
ariaLabel: t('Image toolbar'),
|
|
52
|
-
items: normalizeDeclarativeConfig(editor.config.get('image.toolbar') || []),
|
|
53
|
-
getRelatedElement: selection => imageUtils.getClosestSelectedImageWidget(selection)
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Convert the dropdown definitions to their keys registered in the ComponentFactory.
|
|
59
|
-
* The registration precess should be handled by the plugin which handles the UI of a particular feature.
|
|
60
|
-
*/
|
|
61
|
-
function normalizeDeclarativeConfig(config) {
|
|
62
|
-
return config.map(item => isObject(item) ? item.name : item);
|
|
63
|
-
}
|