@ckeditor/ckeditor5-image 41.3.1 → 41.4.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/image.js +2 -2
- 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/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/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/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/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/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 -0
- 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-content.css +105 -0
- package/dist/index-editor.css +129 -0
- package/dist/index.css +562 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +5637 -0
- package/dist/index.js.map +1 -0
- package/dist/translations/ar.d.ts +8 -0
- package/dist/translations/ar.js +5 -0
- package/dist/translations/ar.umd.js +11 -0
- package/dist/translations/ast.d.ts +8 -0
- package/dist/translations/ast.js +5 -0
- package/dist/translations/ast.umd.js +11 -0
- package/dist/translations/az.d.ts +8 -0
- package/dist/translations/az.js +5 -0
- package/dist/translations/az.umd.js +11 -0
- package/dist/translations/bg.d.ts +8 -0
- package/dist/translations/bg.js +5 -0
- package/dist/translations/bg.umd.js +11 -0
- package/dist/translations/bn.d.ts +8 -0
- package/dist/translations/bn.js +5 -0
- package/dist/translations/bn.umd.js +11 -0
- package/dist/translations/bs.d.ts +8 -0
- package/dist/translations/bs.js +5 -0
- package/dist/translations/bs.umd.js +11 -0
- package/dist/translations/ca.d.ts +8 -0
- package/dist/translations/ca.js +5 -0
- package/dist/translations/ca.umd.js +11 -0
- package/dist/translations/cs.d.ts +8 -0
- package/dist/translations/cs.js +5 -0
- package/dist/translations/cs.umd.js +11 -0
- package/dist/translations/da.d.ts +8 -0
- package/dist/translations/da.js +5 -0
- package/dist/translations/da.umd.js +11 -0
- package/dist/translations/de-ch.d.ts +8 -0
- package/dist/translations/de-ch.js +5 -0
- package/dist/translations/de-ch.umd.js +11 -0
- package/dist/translations/de.d.ts +8 -0
- package/dist/translations/de.js +5 -0
- package/dist/translations/de.umd.js +11 -0
- package/dist/translations/el.d.ts +8 -0
- package/dist/translations/el.js +5 -0
- package/dist/translations/el.umd.js +11 -0
- package/dist/translations/en-au.d.ts +8 -0
- package/dist/translations/en-au.js +5 -0
- package/dist/translations/en-au.umd.js +11 -0
- package/dist/translations/en-gb.d.ts +8 -0
- package/dist/translations/en-gb.js +5 -0
- package/dist/translations/en-gb.umd.js +11 -0
- package/dist/translations/en.d.ts +8 -0
- package/dist/translations/en.js +5 -0
- package/dist/translations/en.umd.js +11 -0
- package/dist/translations/eo.d.ts +8 -0
- package/dist/translations/eo.js +5 -0
- package/dist/translations/eo.umd.js +11 -0
- package/dist/translations/es-co.d.ts +8 -0
- package/dist/translations/es-co.js +5 -0
- package/dist/translations/es-co.umd.js +11 -0
- package/dist/translations/es.d.ts +8 -0
- package/dist/translations/es.js +5 -0
- package/dist/translations/es.umd.js +11 -0
- package/dist/translations/et.d.ts +8 -0
- package/dist/translations/et.js +5 -0
- package/dist/translations/et.umd.js +11 -0
- package/dist/translations/eu.d.ts +8 -0
- package/dist/translations/eu.js +5 -0
- package/dist/translations/eu.umd.js +11 -0
- package/dist/translations/fa.d.ts +8 -0
- package/dist/translations/fa.js +5 -0
- package/dist/translations/fa.umd.js +11 -0
- package/dist/translations/fi.d.ts +8 -0
- package/dist/translations/fi.js +5 -0
- package/dist/translations/fi.umd.js +11 -0
- package/dist/translations/fr.d.ts +8 -0
- package/dist/translations/fr.js +5 -0
- package/dist/translations/fr.umd.js +11 -0
- package/dist/translations/gl.d.ts +8 -0
- package/dist/translations/gl.js +5 -0
- package/dist/translations/gl.umd.js +11 -0
- package/dist/translations/he.d.ts +8 -0
- package/dist/translations/he.js +5 -0
- package/dist/translations/he.umd.js +11 -0
- package/dist/translations/hi.d.ts +8 -0
- package/dist/translations/hi.js +5 -0
- package/dist/translations/hi.umd.js +11 -0
- package/dist/translations/hr.d.ts +8 -0
- package/dist/translations/hr.js +5 -0
- package/dist/translations/hr.umd.js +11 -0
- package/dist/translations/hu.d.ts +8 -0
- package/dist/translations/hu.js +5 -0
- package/dist/translations/hu.umd.js +11 -0
- package/dist/translations/id.d.ts +8 -0
- package/dist/translations/id.js +5 -0
- package/dist/translations/id.umd.js +11 -0
- package/dist/translations/it.d.ts +8 -0
- package/dist/translations/it.js +5 -0
- package/dist/translations/it.umd.js +11 -0
- package/dist/translations/ja.d.ts +8 -0
- package/dist/translations/ja.js +5 -0
- package/dist/translations/ja.umd.js +11 -0
- package/dist/translations/jv.d.ts +8 -0
- package/dist/translations/jv.js +5 -0
- package/dist/translations/jv.umd.js +11 -0
- package/dist/translations/km.d.ts +8 -0
- package/dist/translations/km.js +5 -0
- package/dist/translations/km.umd.js +11 -0
- package/dist/translations/kn.d.ts +8 -0
- package/dist/translations/kn.js +5 -0
- package/dist/translations/kn.umd.js +11 -0
- package/dist/translations/ko.d.ts +8 -0
- package/dist/translations/ko.js +5 -0
- package/dist/translations/ko.umd.js +11 -0
- package/dist/translations/ku.d.ts +8 -0
- package/dist/translations/ku.js +5 -0
- package/dist/translations/ku.umd.js +11 -0
- package/dist/translations/lt.d.ts +8 -0
- package/dist/translations/lt.js +5 -0
- package/dist/translations/lt.umd.js +11 -0
- package/dist/translations/lv.d.ts +8 -0
- package/dist/translations/lv.js +5 -0
- package/dist/translations/lv.umd.js +11 -0
- package/dist/translations/ms.d.ts +8 -0
- package/dist/translations/ms.js +5 -0
- package/dist/translations/ms.umd.js +11 -0
- package/dist/translations/nb.d.ts +8 -0
- package/dist/translations/nb.js +5 -0
- package/dist/translations/nb.umd.js +11 -0
- package/dist/translations/ne.d.ts +8 -0
- package/dist/translations/ne.js +5 -0
- package/dist/translations/ne.umd.js +11 -0
- package/dist/translations/nl.d.ts +8 -0
- package/dist/translations/nl.js +5 -0
- package/dist/translations/nl.umd.js +11 -0
- package/dist/translations/no.d.ts +8 -0
- package/dist/translations/no.js +5 -0
- package/dist/translations/no.umd.js +11 -0
- package/dist/translations/pl.d.ts +8 -0
- package/dist/translations/pl.js +5 -0
- package/dist/translations/pl.umd.js +11 -0
- package/dist/translations/pt-br.d.ts +8 -0
- package/dist/translations/pt-br.js +5 -0
- package/dist/translations/pt-br.umd.js +11 -0
- package/dist/translations/pt.d.ts +8 -0
- package/dist/translations/pt.js +5 -0
- package/dist/translations/pt.umd.js +11 -0
- package/dist/translations/ro.d.ts +8 -0
- package/dist/translations/ro.js +5 -0
- package/dist/translations/ro.umd.js +11 -0
- package/dist/translations/ru.d.ts +8 -0
- package/dist/translations/ru.js +5 -0
- package/dist/translations/ru.umd.js +11 -0
- package/dist/translations/si.d.ts +8 -0
- package/dist/translations/si.js +5 -0
- package/dist/translations/si.umd.js +11 -0
- package/dist/translations/sk.d.ts +8 -0
- package/dist/translations/sk.js +5 -0
- package/dist/translations/sk.umd.js +11 -0
- package/dist/translations/sq.d.ts +8 -0
- package/dist/translations/sq.js +5 -0
- package/dist/translations/sq.umd.js +11 -0
- package/dist/translations/sr-latn.d.ts +8 -0
- package/dist/translations/sr-latn.js +5 -0
- package/dist/translations/sr-latn.umd.js +11 -0
- package/dist/translations/sr.d.ts +8 -0
- package/dist/translations/sr.js +5 -0
- package/dist/translations/sr.umd.js +11 -0
- package/dist/translations/sv.d.ts +8 -0
- package/dist/translations/sv.js +5 -0
- package/dist/translations/sv.umd.js +11 -0
- package/dist/translations/th.d.ts +8 -0
- package/dist/translations/th.js +5 -0
- package/dist/translations/th.umd.js +11 -0
- package/dist/translations/ti.d.ts +8 -0
- package/dist/translations/ti.js +5 -0
- package/dist/translations/ti.umd.js +11 -0
- package/dist/translations/tk.d.ts +8 -0
- package/dist/translations/tk.js +5 -0
- package/dist/translations/tk.umd.js +11 -0
- package/dist/translations/tr.d.ts +8 -0
- package/dist/translations/tr.js +5 -0
- package/dist/translations/tr.umd.js +11 -0
- package/dist/translations/tt.d.ts +8 -0
- package/dist/translations/tt.js +5 -0
- package/dist/translations/tt.umd.js +11 -0
- package/dist/translations/ug.d.ts +8 -0
- package/dist/translations/ug.js +5 -0
- package/dist/translations/ug.umd.js +11 -0
- package/dist/translations/uk.d.ts +8 -0
- package/dist/translations/uk.js +5 -0
- package/dist/translations/uk.umd.js +11 -0
- package/dist/translations/ur.d.ts +8 -0
- package/dist/translations/ur.js +5 -0
- package/dist/translations/ur.umd.js +11 -0
- package/dist/translations/uz.d.ts +8 -0
- package/dist/translations/uz.js +5 -0
- package/dist/translations/uz.umd.js +11 -0
- package/dist/translations/vi.d.ts +8 -0
- package/dist/translations/vi.js +5 -0
- package/dist/translations/vi.umd.js +11 -0
- package/dist/translations/zh-cn.d.ts +8 -0
- package/dist/translations/zh-cn.js +5 -0
- package/dist/translations/zh-cn.umd.js +11 -0
- package/dist/translations/zh.d.ts +8 -0
- package/dist/translations/zh.js +5 -0
- package/dist/translations/zh.umd.js +11 -0
- package/dist/types/augmentation.d.ts +61 -0
- package/dist/types/autoimage.d.ts +56 -0
- package/dist/types/image/converters.d.ts +70 -0
- package/dist/types/image/imageblockediting.d.ts +63 -0
- package/dist/types/image/imageediting.d.ts +34 -0
- package/dist/types/image/imageinlineediting.d.ts +64 -0
- package/dist/types/image/imageloadobserver.d.ts +52 -0
- package/dist/types/image/imageplaceholder.d.ts +43 -0
- package/dist/types/image/imagetypecommand.d.ts +48 -0
- package/dist/types/image/insertimagecommand.d.ts +70 -0
- package/dist/types/image/replaceimagesourcecommand.d.ts +55 -0
- package/dist/types/image/ui/utils.d.ts +29 -0
- package/dist/types/image/utils.d.ts +68 -0
- package/dist/types/image.d.ts +38 -0
- package/dist/types/imageblock.d.ts +38 -0
- package/dist/types/imagecaption/imagecaptionediting.d.ts +93 -0
- package/dist/types/imagecaption/imagecaptionui.d.ts +30 -0
- package/dist/types/imagecaption/imagecaptionutils.d.ts +42 -0
- package/dist/types/imagecaption/toggleimagecaptioncommand.d.ts +70 -0
- package/dist/types/imagecaption.d.ts +30 -0
- package/dist/types/imageconfig.d.ts +716 -0
- package/dist/types/imageinline.d.ts +38 -0
- package/dist/types/imageinsert/imageinsertui.d.ts +78 -0
- package/dist/types/imageinsert/imageinsertviaurlui.d.ts +48 -0
- package/dist/types/imageinsert/ui/imageinsertformview.d.ts +60 -0
- package/dist/types/imageinsert/ui/imageinserturlview.d.ts +111 -0
- package/dist/types/imageinsert.d.ts +37 -0
- package/dist/types/imageinsertviaurl.d.ts +35 -0
- package/dist/types/imageresize/imagecustomresizeui.d.ts +65 -0
- package/dist/types/imageresize/imageresizebuttons.d.ts +68 -0
- package/dist/types/imageresize/imageresizeediting.d.ts +45 -0
- package/dist/types/imageresize/imageresizehandles.d.ts +35 -0
- package/dist/types/imageresize/resizeimagecommand.d.ts +46 -0
- package/dist/types/imageresize/ui/imagecustomresizeformview.d.ts +133 -0
- package/dist/types/imageresize/utils/getselectedimageeditornodes.d.ts +28 -0
- package/dist/types/imageresize/utils/getselectedimagepossibleresizerange.d.ts +28 -0
- package/dist/types/imageresize/utils/getselectedimagewidthinunits.d.ts +22 -0
- package/dist/types/imageresize/utils/tryparsedimensionwithunit.d.ts +41 -0
- package/dist/types/imageresize.d.ts +32 -0
- package/dist/types/imagesizeattributes.d.ts +38 -0
- package/dist/types/imagestyle/converters.d.ts +28 -0
- package/dist/types/imagestyle/imagestylecommand.d.ts +72 -0
- package/dist/types/imagestyle/imagestyleediting.d.ts +54 -0
- package/dist/types/imagestyle/imagestyleui.d.ts +60 -0
- package/dist/types/imagestyle/utils.d.ts +105 -0
- package/dist/types/imagestyle.d.ts +36 -0
- package/dist/types/imagetextalternative/imagetextalternativecommand.d.ts +38 -0
- package/dist/types/imagetextalternative/imagetextalternativeediting.d.ts +32 -0
- package/dist/types/imagetextalternative/imagetextalternativeui.d.ts +72 -0
- package/dist/types/imagetextalternative/ui/textalternativeformview.d.ts +94 -0
- package/dist/types/imagetextalternative.d.ts +33 -0
- package/dist/types/imagetoolbar.d.ts +39 -0
- package/dist/types/imageupload/imageuploadediting.d.ts +115 -0
- package/dist/types/imageupload/imageuploadprogress.d.ts +46 -0
- package/dist/types/imageupload/imageuploadui.d.ts +34 -0
- package/dist/types/imageupload/uploadimagecommand.d.ts +64 -0
- package/dist/types/imageupload/utils.d.ts +37 -0
- package/dist/types/imageupload.d.ts +36 -0
- package/dist/types/imageutils.d.ts +129 -0
- package/dist/types/index.d.ts +53 -0
- package/dist/types/pictureediting.d.ts +92 -0
- package/lang/contexts.json +9 -1
- package/lang/translations/ar.po +32 -0
- package/lang/translations/ast.po +32 -0
- package/lang/translations/az.po +32 -0
- package/lang/translations/bg.po +32 -0
- package/lang/translations/bn.po +32 -0
- package/lang/translations/bs.po +32 -0
- package/lang/translations/ca.po +32 -0
- package/lang/translations/cs.po +32 -0
- package/lang/translations/da.po +32 -0
- package/lang/translations/de-ch.po +32 -0
- package/lang/translations/de.po +32 -0
- package/lang/translations/el.po +32 -0
- package/lang/translations/en-au.po +32 -0
- package/lang/translations/en-gb.po +32 -0
- package/lang/translations/en.po +32 -0
- package/lang/translations/eo.po +32 -0
- package/lang/translations/es-co.po +32 -0
- package/lang/translations/es.po +32 -0
- package/lang/translations/et.po +32 -0
- package/lang/translations/eu.po +32 -0
- package/lang/translations/fa.po +32 -0
- package/lang/translations/fi.po +32 -0
- package/lang/translations/fr.po +32 -0
- package/lang/translations/gl.po +32 -0
- package/lang/translations/he.po +32 -0
- package/lang/translations/hi.po +32 -0
- package/lang/translations/hr.po +32 -0
- package/lang/translations/hu.po +32 -0
- package/lang/translations/id.po +32 -0
- package/lang/translations/it.po +32 -0
- package/lang/translations/ja.po +32 -0
- package/lang/translations/jv.po +32 -0
- package/lang/translations/km.po +32 -0
- package/lang/translations/kn.po +32 -0
- package/lang/translations/ko.po +32 -0
- package/lang/translations/ku.po +32 -0
- package/lang/translations/lt.po +32 -0
- package/lang/translations/lv.po +32 -0
- package/lang/translations/ms.po +32 -0
- package/lang/translations/nb.po +32 -0
- package/lang/translations/ne.po +32 -0
- package/lang/translations/nl.po +32 -0
- package/lang/translations/no.po +32 -0
- package/lang/translations/pl.po +32 -0
- package/lang/translations/pt-br.po +32 -0
- package/lang/translations/pt.po +32 -0
- package/lang/translations/ro.po +32 -0
- package/lang/translations/ru.po +32 -0
- package/lang/translations/si.po +32 -0
- package/lang/translations/sk.po +32 -0
- package/lang/translations/sq.po +32 -0
- package/lang/translations/sr-latn.po +32 -0
- package/lang/translations/sr.po +32 -0
- package/lang/translations/sv.po +32 -0
- package/lang/translations/th.po +32 -0
- package/lang/translations/ti.po +178 -0
- package/lang/translations/tk.po +32 -0
- package/lang/translations/tr.po +32 -0
- package/lang/translations/tt.po +32 -0
- package/lang/translations/ug.po +32 -0
- package/lang/translations/uk.po +32 -0
- package/lang/translations/ur.po +32 -0
- package/lang/translations/uz.po +32 -0
- package/lang/translations/vi.po +32 -0
- package/lang/translations/zh-cn.po +32 -0
- package/lang/translations/zh.po +32 -0
- package/package.json +4 -3
- package/src/augmentation.d.ts +2 -1
- package/src/imageresize/imagecustomresizeui.d.ts +61 -0
- package/src/imageresize/imagecustomresizeui.js +168 -0
- package/src/imageresize/imageresizebuttons.d.ts +0 -3
- package/src/imageresize/imageresizebuttons.js +95 -23
- package/src/imageresize/imageresizeediting.js +9 -2
- package/src/imageresize/imageresizehandles.js +1 -2
- package/src/imageresize/ui/imagecustomresizeformview.d.ts +129 -0
- package/src/imageresize/ui/imagecustomresizeformview.js +186 -0
- package/src/imageresize/utils/getselectedimageeditornodes.d.ts +24 -0
- package/src/imageresize/utils/getselectedimageeditornodes.js +24 -0
- package/src/imageresize/utils/getselectedimagepossibleresizerange.d.ts +24 -0
- package/src/imageresize/utils/getselectedimagepossibleresizerange.js +32 -0
- package/src/imageresize/utils/getselectedimagewidthinunits.d.ts +18 -0
- package/src/imageresize/utils/getselectedimagewidthinunits.js +41 -0
- package/src/imageresize/utils/tryparsedimensionwithunit.d.ts +37 -0
- package/src/imageresize/utils/tryparsedimensionwithunit.js +56 -0
- package/src/imageresize.d.ts +2 -1
- package/src/imageresize.js +2 -1
- package/src/imageupload/imageuploadediting.js +9 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/theme/imagecaption.css +15 -1
- package/theme/imagecustomresizeform.css +33 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module image/imageresize/utils/getselectedimagewidthinunits
|
|
7
|
+
*/
|
|
8
|
+
import { Rect } from 'ckeditor5/src/utils.js';
|
|
9
|
+
import { calculateResizeHostAncestorWidth } from 'ckeditor5/src/widget.js';
|
|
10
|
+
import { tryCastDimensionsToUnit, tryParseDimensionWithUnit } from './tryparsedimensionwithunit.js';
|
|
11
|
+
import { getSelectedImageEditorNodes } from './getselectedimageeditornodes.js';
|
|
12
|
+
/**
|
|
13
|
+
* Returns image width in specified units. It is width of image after resize.
|
|
14
|
+
*
|
|
15
|
+
* * If image is not selected or command is disabled then `null` will be returned.
|
|
16
|
+
* * If image is not fully loaded (and it is impossible to determine its natural size) then `null` will be returned.
|
|
17
|
+
* * If `targetUnit` percentage is passed then it will return width percentage of image related to its accessors.
|
|
18
|
+
*
|
|
19
|
+
* @param editor Editor instance.
|
|
20
|
+
* @param targetUnit Unit in which dimension will be returned.
|
|
21
|
+
* @returns Parsed image width after resize (with unit).
|
|
22
|
+
*/
|
|
23
|
+
export function getSelectedImageWidthInUnits(editor, targetUnit) {
|
|
24
|
+
const imageNodes = getSelectedImageEditorNodes(editor);
|
|
25
|
+
if (!imageNodes) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const parsedResizedWidth = tryParseDimensionWithUnit(imageNodes.model.getAttribute('resizedWidth') || null);
|
|
29
|
+
if (!parsedResizedWidth) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
if (parsedResizedWidth.unit === targetUnit) {
|
|
33
|
+
return parsedResizedWidth;
|
|
34
|
+
}
|
|
35
|
+
const imageParentWidthPx = calculateResizeHostAncestorWidth(imageNodes.dom);
|
|
36
|
+
const imageHolderDimension = {
|
|
37
|
+
unit: 'px',
|
|
38
|
+
value: new Rect(imageNodes.dom).width
|
|
39
|
+
};
|
|
40
|
+
return tryCastDimensionsToUnit(imageParentWidthPx, imageHolderDimension, targetUnit);
|
|
41
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module image/imageresize/utils/tryparsedimensionwithunit
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Parses provided string with dimension value and returns extracted numeric value and unit.
|
|
10
|
+
*
|
|
11
|
+
* * If non-string dimension is passed then `null` value is returned.
|
|
12
|
+
* * If unit is missing then `null` is returned.
|
|
13
|
+
* * If numeric value part of string is not a number then `null` is returned.
|
|
14
|
+
*
|
|
15
|
+
* Example:
|
|
16
|
+
* `"222px"` => `{ value: 222, unit: "px" }`
|
|
17
|
+
* `"99%"` => `{ value: 99, unit: "%" }`
|
|
18
|
+
|
|
19
|
+
* @param dimension Unsafe string with dimension.
|
|
20
|
+
* @returns Parsed dimension with extracted numeric value and units.
|
|
21
|
+
*/
|
|
22
|
+
export declare function tryParseDimensionWithUnit(dimension: string | null | undefined): DimensionWithUnit | null;
|
|
23
|
+
/**
|
|
24
|
+
* Converts dimension between `px` -> `%` and `%` -> `px`.
|
|
25
|
+
*
|
|
26
|
+
* @param parentDimensionPx Dimension of parent element that contains measured element.
|
|
27
|
+
* @param dimension Measured element dimension.
|
|
28
|
+
* @returns Casted dimension.
|
|
29
|
+
*/
|
|
30
|
+
export declare function tryCastDimensionsToUnit(parentDimensionPx: number, dimension: DimensionWithUnit, targetUnit: string): DimensionWithUnit;
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
export type DimensionWithUnit = {
|
|
35
|
+
value: number;
|
|
36
|
+
unit: string;
|
|
37
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module image/imageresize/utils/tryparsedimensionwithunit
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Parses provided string with dimension value and returns extracted numeric value and unit.
|
|
10
|
+
*
|
|
11
|
+
* * If non-string dimension is passed then `null` value is returned.
|
|
12
|
+
* * If unit is missing then `null` is returned.
|
|
13
|
+
* * If numeric value part of string is not a number then `null` is returned.
|
|
14
|
+
*
|
|
15
|
+
* Example:
|
|
16
|
+
* `"222px"` => `{ value: 222, unit: "px" }`
|
|
17
|
+
* `"99%"` => `{ value: 99, unit: "%" }`
|
|
18
|
+
|
|
19
|
+
* @param dimension Unsafe string with dimension.
|
|
20
|
+
* @returns Parsed dimension with extracted numeric value and units.
|
|
21
|
+
*/
|
|
22
|
+
export function tryParseDimensionWithUnit(dimension) {
|
|
23
|
+
if (!dimension) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const [, rawValue, unit] = dimension.trim().match(/([.,\d]+)(%|px)$/) || [];
|
|
27
|
+
const parsedValue = Number.parseFloat(rawValue);
|
|
28
|
+
if (Number.isNaN(parsedValue)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
value: parsedValue,
|
|
33
|
+
unit
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Converts dimension between `px` -> `%` and `%` -> `px`.
|
|
38
|
+
*
|
|
39
|
+
* @param parentDimensionPx Dimension of parent element that contains measured element.
|
|
40
|
+
* @param dimension Measured element dimension.
|
|
41
|
+
* @returns Casted dimension.
|
|
42
|
+
*/
|
|
43
|
+
export function tryCastDimensionsToUnit(parentDimensionPx, dimension, targetUnit) {
|
|
44
|
+
// "%" -> "px" conversion
|
|
45
|
+
if (targetUnit === 'px') {
|
|
46
|
+
return {
|
|
47
|
+
value: dimension.value,
|
|
48
|
+
unit: 'px'
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// "px" -> "%" conversion
|
|
52
|
+
return {
|
|
53
|
+
value: dimension.value / parentDimensionPx * 100,
|
|
54
|
+
unit: '%'
|
|
55
|
+
};
|
|
56
|
+
}
|
package/src/imageresize.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { Plugin } from 'ckeditor5/src/core.js';
|
|
|
9
9
|
import ImageResizeButtons from './imageresize/imageresizebuttons.js';
|
|
10
10
|
import ImageResizeEditing from './imageresize/imageresizeediting.js';
|
|
11
11
|
import ImageResizeHandles from './imageresize/imageresizehandles.js';
|
|
12
|
+
import ImageCustomResizeUI from './imageresize/imagecustomresizeui.js';
|
|
12
13
|
import '../theme/imageresize.css';
|
|
13
14
|
/**
|
|
14
15
|
* The image resize plugin.
|
|
@@ -19,7 +20,7 @@ export default class ImageResize extends Plugin {
|
|
|
19
20
|
/**
|
|
20
21
|
* @inheritDoc
|
|
21
22
|
*/
|
|
22
|
-
static get requires(): readonly [typeof ImageResizeEditing, typeof ImageResizeHandles, typeof ImageResizeButtons];
|
|
23
|
+
static get requires(): readonly [typeof ImageResizeEditing, typeof ImageResizeHandles, typeof ImageCustomResizeUI, typeof ImageResizeButtons];
|
|
23
24
|
/**
|
|
24
25
|
* @inheritDoc
|
|
25
26
|
*/
|
package/src/imageresize.js
CHANGED
|
@@ -9,6 +9,7 @@ import { Plugin } from 'ckeditor5/src/core.js';
|
|
|
9
9
|
import ImageResizeButtons from './imageresize/imageresizebuttons.js';
|
|
10
10
|
import ImageResizeEditing from './imageresize/imageresizeediting.js';
|
|
11
11
|
import ImageResizeHandles from './imageresize/imageresizehandles.js';
|
|
12
|
+
import ImageCustomResizeUI from './imageresize/imagecustomresizeui.js';
|
|
12
13
|
import '../theme/imageresize.css';
|
|
13
14
|
/**
|
|
14
15
|
* The image resize plugin.
|
|
@@ -20,7 +21,7 @@ export default class ImageResize extends Plugin {
|
|
|
20
21
|
* @inheritDoc
|
|
21
22
|
*/
|
|
22
23
|
static get requires() {
|
|
23
|
-
return [ImageResizeEditing, ImageResizeHandles, ImageResizeButtons];
|
|
24
|
+
return [ImageResizeEditing, ImageResizeHandles, ImageCustomResizeUI, ImageResizeButtons];
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* @inheritDoc
|
|
@@ -248,6 +248,9 @@ export default class ImageUploadEditing extends Plugin {
|
|
|
248
248
|
domFigure.style.display = originalDisplay;
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
|
+
if (editor.ui) {
|
|
252
|
+
editor.ui.ariaLiveAnnouncer.announce(t('Uploading image'));
|
|
253
|
+
}
|
|
251
254
|
model.enqueueChange({ isUndoable: false }, writer => {
|
|
252
255
|
writer.setAttribute('uploadStatus', 'uploading', imageElement);
|
|
253
256
|
});
|
|
@@ -257,11 +260,17 @@ export default class ImageUploadEditing extends Plugin {
|
|
|
257
260
|
model.enqueueChange({ isUndoable: false }, writer => {
|
|
258
261
|
const imageElement = imageUploadElements.get(loader.id);
|
|
259
262
|
writer.setAttribute('uploadStatus', 'complete', imageElement);
|
|
263
|
+
if (editor.ui) {
|
|
264
|
+
editor.ui.ariaLiveAnnouncer.announce(t('Image upload complete'));
|
|
265
|
+
}
|
|
260
266
|
this.fire('uploadComplete', { data, imageElement });
|
|
261
267
|
});
|
|
262
268
|
clean();
|
|
263
269
|
})
|
|
264
270
|
.catch(error => {
|
|
271
|
+
if (editor.ui) {
|
|
272
|
+
editor.ui.ariaLiveAnnouncer.announce(t('Error during image upload'));
|
|
273
|
+
}
|
|
265
274
|
// If status is not 'error' nor 'aborted' - throw error because it means that something else went wrong,
|
|
266
275
|
// it might be generic error and it would be real pain to find what is going on.
|
|
267
276
|
if (loader.status !== 'error' && loader.status !== 'aborted') {
|
package/src/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export { default as ImageResize } from './imageresize.js';
|
|
|
17
17
|
export { default as ImageResizeButtons } from './imageresize/imageresizebuttons.js';
|
|
18
18
|
export { default as ImageResizeEditing } from './imageresize/imageresizeediting.js';
|
|
19
19
|
export { default as ImageResizeHandles } from './imageresize/imageresizehandles.js';
|
|
20
|
+
export { default as ImageCustomResizeUI } from './imageresize/imagecustomresizeui.js';
|
|
20
21
|
export { default as ImageSizeAttributes } from './imagesizeattributes.js';
|
|
21
22
|
export { default as ImageStyle } from './imagestyle.js';
|
|
22
23
|
export { default as ImageStyleEditing } from './imagestyle/imagestyleediting.js';
|
package/src/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export { default as ImageResize } from './imageresize.js';
|
|
|
17
17
|
export { default as ImageResizeButtons } from './imageresize/imageresizebuttons.js';
|
|
18
18
|
export { default as ImageResizeEditing } from './imageresize/imageresizeediting.js';
|
|
19
19
|
export { default as ImageResizeHandles } from './imageresize/imageresizehandles.js';
|
|
20
|
+
export { default as ImageCustomResizeUI } from './imageresize/imagecustomresizeui.js';
|
|
20
21
|
export { default as ImageSizeAttributes } from './imagesizeattributes.js';
|
|
21
22
|
export { default as ImageStyle } from './imagestyle.js';
|
|
22
23
|
export { default as ImageStyleEditing } from './imagestyle/imagestyleediting.js';
|
package/theme/imagecaption.css
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
@import "@ckeditor/ckeditor5-ui/theme/mixins/_mediacolors.css";
|
|
7
|
+
|
|
6
8
|
:root {
|
|
7
9
|
--ck-color-image-caption-background: hsl(0, 0%, 97%);
|
|
8
10
|
--ck-color-image-caption-text: hsl(0, 0%, 20%);
|
|
@@ -19,11 +21,23 @@
|
|
|
19
21
|
padding: .6em;
|
|
20
22
|
font-size: .75em;
|
|
21
23
|
outline-offset: -1px;
|
|
24
|
+
|
|
25
|
+
/* Improve placeholder rendering in high-constrast mode (https://github.com/ckeditor/ckeditor5/issues/14907). */
|
|
26
|
+
@media (forced-colors: active) {
|
|
27
|
+
background-color: unset;
|
|
28
|
+
color: unset;
|
|
29
|
+
}
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
/* Editing styles */
|
|
25
33
|
.ck.ck-editor__editable .image > figcaption.image__caption_highlighted {
|
|
26
|
-
|
|
34
|
+
@mixin ck-media-default-colors {
|
|
35
|
+
animation: ck-image-caption-highlight .6s ease-out;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@media (prefers-reduced-motion: reduce) {
|
|
39
|
+
animation: none;
|
|
40
|
+
}
|
|
27
41
|
}
|
|
28
42
|
|
|
29
43
|
@keyframes ck-image-caption-highlight {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@import "@ckeditor/ckeditor5-ui/theme/mixins/_rwd.css";
|
|
7
|
+
|
|
8
|
+
.ck.ck-image-custom-resize-form {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: row;
|
|
11
|
+
flex-wrap: nowrap;
|
|
12
|
+
align-items: flex-start;
|
|
13
|
+
|
|
14
|
+
& .ck-labeled-field-view {
|
|
15
|
+
display: inline-block;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
& .ck-label {
|
|
19
|
+
display: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@mixin ck-media-phone {
|
|
23
|
+
flex-wrap: wrap;
|
|
24
|
+
|
|
25
|
+
& .ck-labeled-field-view {
|
|
26
|
+
flex-basis: 100%;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
& .ck-button {
|
|
30
|
+
flex-basis: 50%;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|