@ckeditor/ckeditor5-ui 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 +3 -3
- package/{src → dist}/colorselector/documentcolorcollection.d.ts +4 -4
- package/{src → dist}/dialog/dialog.d.ts +1 -1
- package/dist/index-editor.css +2728 -587
- package/dist/index.css +2673 -850
- package/dist/index.css.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/{src → dist}/menubar/menubarmenuview.d.ts +4 -0
- package/{src → dist}/view.d.ts +1 -1
- package/package.json +25 -47
- package/lang/contexts.json +0 -51
- package/lang/translations/af.po +0 -208
- package/lang/translations/ar.po +0 -208
- package/lang/translations/ast.po +0 -208
- package/lang/translations/az.po +0 -208
- package/lang/translations/be.po +0 -208
- package/lang/translations/bg.po +0 -208
- package/lang/translations/bn.po +0 -208
- package/lang/translations/bs.po +0 -208
- package/lang/translations/ca.po +0 -208
- package/lang/translations/cs.po +0 -208
- package/lang/translations/da.po +0 -208
- package/lang/translations/de-ch.po +0 -208
- package/lang/translations/de.po +0 -208
- package/lang/translations/el.po +0 -208
- package/lang/translations/en-au.po +0 -208
- package/lang/translations/en-gb.po +0 -208
- package/lang/translations/en.po +0 -208
- package/lang/translations/eo.po +0 -208
- package/lang/translations/es-co.po +0 -208
- package/lang/translations/es.po +0 -208
- package/lang/translations/et.po +0 -208
- package/lang/translations/eu.po +0 -208
- package/lang/translations/fa.po +0 -208
- package/lang/translations/fi.po +0 -208
- package/lang/translations/fr.po +0 -208
- package/lang/translations/gl.po +0 -208
- package/lang/translations/gu.po +0 -208
- package/lang/translations/he.po +0 -208
- package/lang/translations/hi.po +0 -208
- package/lang/translations/hr.po +0 -208
- package/lang/translations/hu.po +0 -208
- package/lang/translations/hy.po +0 -208
- package/lang/translations/id.po +0 -208
- package/lang/translations/it.po +0 -208
- package/lang/translations/ja.po +0 -208
- package/lang/translations/jv.po +0 -208
- package/lang/translations/kk.po +0 -208
- package/lang/translations/km.po +0 -208
- package/lang/translations/kn.po +0 -208
- package/lang/translations/ko.po +0 -208
- package/lang/translations/ku.po +0 -208
- package/lang/translations/lt.po +0 -208
- package/lang/translations/lv.po +0 -208
- package/lang/translations/ms.po +0 -208
- package/lang/translations/nb.po +0 -208
- package/lang/translations/ne.po +0 -208
- package/lang/translations/nl.po +0 -208
- package/lang/translations/no.po +0 -208
- package/lang/translations/oc.po +0 -208
- package/lang/translations/pl.po +0 -208
- package/lang/translations/pt-br.po +0 -208
- package/lang/translations/pt.po +0 -208
- package/lang/translations/ro.po +0 -208
- package/lang/translations/ru.po +0 -208
- package/lang/translations/si.po +0 -208
- package/lang/translations/sk.po +0 -208
- package/lang/translations/sl.po +0 -208
- package/lang/translations/sq.po +0 -208
- package/lang/translations/sr-latn.po +0 -208
- package/lang/translations/sr.po +0 -208
- package/lang/translations/sv.po +0 -208
- package/lang/translations/th.po +0 -208
- package/lang/translations/ti.po +0 -208
- package/lang/translations/tk.po +0 -208
- package/lang/translations/tr.po +0 -208
- package/lang/translations/tt.po +0 -208
- package/lang/translations/ug.po +0 -208
- package/lang/translations/uk.po +0 -208
- package/lang/translations/ur.po +0 -208
- package/lang/translations/uz.po +0 -208
- package/lang/translations/vi.po +0 -208
- package/lang/translations/zh-cn.po +0 -208
- package/lang/translations/zh.po +0 -208
- package/src/arialiveannouncer.js +0 -189
- package/src/augmentation.js +0 -5
- package/src/autocomplete/autocompleteview.js +0 -157
- package/src/badge/badge.js +0 -226
- package/src/bindings/addkeyboardhandlingforgrid.js +0 -107
- package/src/bindings/clickoutsidehandler.js +0 -36
- package/src/bindings/csstransitiondisablermixin.js +0 -58
- package/src/bindings/draggableviewmixin.js +0 -144
- package/src/bindings/preventdefault.js +0 -35
- package/src/bindings/submithandler.js +0 -47
- package/src/button/button.js +0 -5
- package/src/button/buttonlabel.js +0 -5
- package/src/button/buttonlabelview.js +0 -42
- package/src/button/buttonview.js +0 -278
- package/src/button/filedialogbuttonview.js +0 -147
- package/src/button/listitembuttonview.js +0 -136
- package/src/button/switchbuttonview.js +0 -79
- package/src/collapsible/collapsibleview.js +0 -106
- package/src/colorgrid/colorgridview.js +0 -140
- package/src/colorgrid/colortileview.js +0 -42
- package/src/colorgrid/utils.js +0 -84
- package/src/colorpicker/colorpickerview.js +0 -356
- package/src/colorpicker/utils.js +0 -108
- package/src/colorselector/colorgridsfragmentview.js +0 -368
- package/src/colorselector/colorpickerfragmentview.js +0 -254
- package/src/colorselector/colorselectorview.js +0 -294
- package/src/colorselector/documentcolorcollection.js +0 -42
- package/src/componentfactory.js +0 -108
- package/src/dialog/dialog.js +0 -325
- package/src/dialog/dialogactionsview.js +0 -118
- package/src/dialog/dialogcontentview.js +0 -39
- package/src/dialog/dialogview.js +0 -507
- package/src/dropdown/button/dropdownbutton.js +0 -5
- package/src/dropdown/button/dropdownbuttonview.js +0 -70
- package/src/dropdown/button/splitbuttonview.js +0 -178
- package/src/dropdown/dropdownpanelfocusable.js +0 -5
- package/src/dropdown/dropdownpanelview.js +0 -106
- package/src/dropdown/dropdownview.js +0 -438
- package/src/dropdown/menu/dropdownmenubehaviors.js +0 -125
- package/src/dropdown/menu/dropdownmenubuttonview.js +0 -69
- package/src/dropdown/menu/dropdownmenulistitembuttonview.js +0 -30
- package/src/dropdown/menu/dropdownmenulistitemview.js +0 -38
- package/src/dropdown/menu/dropdownmenulistview.js +0 -29
- package/src/dropdown/menu/dropdownmenunestedmenupanelview.js +0 -63
- package/src/dropdown/menu/dropdownmenunestedmenuview.js +0 -214
- package/src/dropdown/menu/dropdownmenurootlistview.js +0 -168
- package/src/dropdown/menu/utils.js +0 -61
- package/src/dropdown/utils.js +0 -654
- package/src/editableui/editableuiview.js +0 -130
- package/src/editableui/inline/inlineeditableuiview.js +0 -75
- package/src/editorui/accessibilityhelp/accessibilityhelp.js +0 -142
- package/src/editorui/accessibilityhelp/accessibilityhelpcontentview.js +0 -112
- package/src/editorui/bodycollection.js +0 -128
- package/src/editorui/boxed/boxededitoruiview.js +0 -95
- package/src/editorui/editorui.js +0 -586
- package/src/editorui/editoruiview.js +0 -60
- package/src/editorui/evaluationbadge.js +0 -99
- package/src/editorui/poweredby.js +0 -120
- package/src/focuscycler.js +0 -383
- package/src/formheader/formheaderview.js +0 -77
- package/src/formrow/formrowview.js +0 -56
- package/src/highlightedtext/buttonlabelwithhighlightview.js +0 -31
- package/src/highlightedtext/highlightedtextview.js +0 -102
- package/src/highlightedtext/labelwithhighlightview.js +0 -37
- package/src/icon/iconview.js +0 -123
- package/src/iframe/iframeview.js +0 -63
- package/src/index.js +0 -132
- package/src/input/inputbase.js +0 -119
- package/src/input/inputview.js +0 -24
- package/src/inputnumber/inputnumberview.js +0 -40
- package/src/inputtext/inputtextview.js +0 -27
- package/src/label/labelview.js +0 -46
- package/src/labeledfield/labeledfieldview.js +0 -177
- package/src/labeledfield/utils.js +0 -176
- package/src/labeledinput/labeledinputview.js +0 -138
- package/src/legacyerrors.js +0 -20
- package/src/list/listitemgroupview.js +0 -82
- package/src/list/listitemview.js +0 -46
- package/src/list/listseparatorview.js +0 -28
- package/src/list/listview.js +0 -210
- package/src/menubar/menubarmenubuttonview.js +0 -68
- package/src/menubar/menubarmenulistitembuttonview.js +0 -30
- package/src/menubar/menubarmenulistitemfiledialogbuttonview.js +0 -32
- package/src/menubar/menubarmenulistitemview.js +0 -34
- package/src/menubar/menubarmenulistview.js +0 -72
- package/src/menubar/menubarmenupanelview.js +0 -64
- package/src/menubar/menubarmenuview.js +0 -198
- package/src/menubar/menubarview.js +0 -281
- package/src/menubar/utils.js +0 -1432
- package/src/model.js +0 -31
- package/src/notification/notification.js +0 -192
- package/src/panel/balloon/balloonpanelview.js +0 -1077
- package/src/panel/balloon/contextualballoon.js +0 -616
- package/src/panel/sticky/stickypanelview.js +0 -246
- package/src/search/filteredview.js +0 -5
- package/src/search/filtergroupanditemnames.js +0 -38
- package/src/search/searchinfoview.js +0 -59
- package/src/search/searchresultsview.js +0 -83
- package/src/search/text/searchtextqueryview.js +0 -87
- package/src/search/text/searchtextview.js +0 -242
- package/src/spinner/spinnerview.js +0 -38
- package/src/template.js +0 -1396
- package/src/textarea/textareaview.js +0 -189
- package/src/toolbar/balloon/balloontoolbar.js +0 -358
- package/src/toolbar/block/blockbuttonview.js +0 -41
- package/src/toolbar/block/blocktoolbar.js +0 -507
- package/src/toolbar/normalizetoolbarconfig.js +0 -52
- package/src/toolbar/toolbarlinebreakview.js +0 -28
- package/src/toolbar/toolbarseparatorview.js +0 -28
- package/src/toolbar/toolbarview.js +0 -873
- package/src/tooltipmanager.js +0 -454
- package/src/view.js +0 -471
- package/src/viewcollection.js +0 -210
- package/theme/components/arialiveannouncer/arialiveannouncer.css +0 -14
- package/theme/components/autocomplete/autocomplete.css +0 -22
- package/theme/components/button/button.css +0 -39
- package/theme/components/button/listitembutton.css +0 -48
- package/theme/components/button/switchbutton.css +0 -14
- package/theme/components/collapsible/collapsible.css +0 -10
- package/theme/components/colorgrid/colorgrid.css +0 -8
- package/theme/components/colorpicker/colorpicker.css +0 -34
- package/theme/components/colorselector/colorselector.css +0 -35
- package/theme/components/dialog/dialog.css +0 -42
- package/theme/components/dialog/dialogactions.css +0 -11
- package/theme/components/dropdown/dropdown.css +0 -95
- package/theme/components/dropdown/listdropdown.css +0 -10
- package/theme/components/dropdown/menu/dropdownmenu.css +0 -8
- package/theme/components/dropdown/menu/dropdownmenubutton.css +0 -9
- package/theme/components/dropdown/menu/dropdownmenulistitem.css +0 -10
- package/theme/components/dropdown/menu/dropdownmenulistitembutton.css +0 -10
- package/theme/components/dropdown/menu/dropdownmenupanel.css +0 -11
- package/theme/components/dropdown/splitbutton.css +0 -14
- package/theme/components/dropdown/toolbardropdown.css +0 -20
- package/theme/components/editorui/accessibilityhelp.css +0 -10
- package/theme/components/editorui/editorui.css +0 -10
- package/theme/components/form/form.css +0 -87
- package/theme/components/formheader/formheader.css +0 -18
- package/theme/components/formrow/formrow.css +0 -32
- package/theme/components/highlightedtext/highlightedtext.css +0 -12
- package/theme/components/icon/icon.css +0 -8
- package/theme/components/input/input.css +0 -10
- package/theme/components/label/label.css +0 -12
- package/theme/components/labeledfield/labeledfieldview.css +0 -16
- package/theme/components/labeledinput/labeledinput.css +0 -10
- package/theme/components/list/list.css +0 -26
- package/theme/components/menubar/menubar.css +0 -10
- package/theme/components/menubar/menubarmenu.css +0 -9
- package/theme/components/menubar/menubarmenubutton.css +0 -11
- package/theme/components/menubar/menubarmenulistitem.css +0 -10
- package/theme/components/menubar/menubarmenulistitembutton.css +0 -10
- package/theme/components/menubar/menubarmenupanel.css +0 -62
- package/theme/components/panel/balloonpanel.css +0 -56
- package/theme/components/panel/balloonrotator.css +0 -17
- package/theme/components/panel/fakepanel.css +0 -23
- package/theme/components/panel/stickypanel.css +0 -17
- package/theme/components/responsive-form/responsiveform.css +0 -42
- package/theme/components/search/search.css +0 -43
- package/theme/components/spinner/spinner.css +0 -23
- package/theme/components/textarea/textarea.css +0 -10
- package/theme/components/toolbar/blocktoolbar.css +0 -9
- package/theme/components/toolbar/toolbar.css +0 -58
- package/theme/components/tooltip/tooltip.css +0 -12
- package/theme/globals/_evaluationbadge.css +0 -54
- package/theme/globals/_hidden.css +0 -13
- package/theme/globals/_poweredby.css +0 -84
- package/theme/globals/_transition.css +0 -12
- package/theme/globals/_zindex.css +0 -10
- package/theme/globals/globals.css +0 -10
- package/theme/mixins/_dir.css +0 -10
- package/theme/mixins/_mediacolors.css +0 -20
- package/theme/mixins/_rwd.css +0 -10
- package/theme/mixins/_unselectable.css +0 -14
- /package/{src → dist}/arialiveannouncer.d.ts +0 -0
- /package/{src → dist}/augmentation.d.ts +0 -0
- /package/{src → dist}/autocomplete/autocompleteview.d.ts +0 -0
- /package/{src → dist}/badge/badge.d.ts +0 -0
- /package/{src → dist}/bindings/addkeyboardhandlingforgrid.d.ts +0 -0
- /package/{src → dist}/bindings/clickoutsidehandler.d.ts +0 -0
- /package/{src → dist}/bindings/csstransitiondisablermixin.d.ts +0 -0
- /package/{src → dist}/bindings/draggableviewmixin.d.ts +0 -0
- /package/{src → dist}/bindings/preventdefault.d.ts +0 -0
- /package/{src → dist}/bindings/submithandler.d.ts +0 -0
- /package/{src → dist}/button/button.d.ts +0 -0
- /package/{src → dist}/button/buttonlabel.d.ts +0 -0
- /package/{src → dist}/button/buttonlabelview.d.ts +0 -0
- /package/{src → dist}/button/buttonview.d.ts +0 -0
- /package/{src → dist}/button/filedialogbuttonview.d.ts +0 -0
- /package/{src → dist}/button/listitembuttonview.d.ts +0 -0
- /package/{src → dist}/button/switchbuttonview.d.ts +0 -0
- /package/{src → dist}/collapsible/collapsibleview.d.ts +0 -0
- /package/{src → dist}/colorgrid/colorgridview.d.ts +0 -0
- /package/{src → dist}/colorgrid/colortileview.d.ts +0 -0
- /package/{src → dist}/colorgrid/utils.d.ts +0 -0
- /package/{src → dist}/colorpicker/colorpickerview.d.ts +0 -0
- /package/{src → dist}/colorpicker/utils.d.ts +0 -0
- /package/{src → dist}/colorselector/colorgridsfragmentview.d.ts +0 -0
- /package/{src → dist}/colorselector/colorpickerfragmentview.d.ts +0 -0
- /package/{src → dist}/colorselector/colorselectorview.d.ts +0 -0
- /package/{src → dist}/componentfactory.d.ts +0 -0
- /package/{src → dist}/dialog/dialogactionsview.d.ts +0 -0
- /package/{src → dist}/dialog/dialogcontentview.d.ts +0 -0
- /package/{src → dist}/dialog/dialogview.d.ts +0 -0
- /package/{src → dist}/dropdown/button/dropdownbutton.d.ts +0 -0
- /package/{src → dist}/dropdown/button/dropdownbuttonview.d.ts +0 -0
- /package/{src → dist}/dropdown/button/splitbuttonview.d.ts +0 -0
- /package/{src → dist}/dropdown/dropdownpanelfocusable.d.ts +0 -0
- /package/{src → dist}/dropdown/dropdownpanelview.d.ts +0 -0
- /package/{src → dist}/dropdown/dropdownview.d.ts +0 -0
- /package/{src → dist}/dropdown/menu/dropdownmenubehaviors.d.ts +0 -0
- /package/{src → dist}/dropdown/menu/dropdownmenubuttonview.d.ts +0 -0
- /package/{src → dist}/dropdown/menu/dropdownmenulistitembuttonview.d.ts +0 -0
- /package/{src → dist}/dropdown/menu/dropdownmenulistitemview.d.ts +0 -0
- /package/{src → dist}/dropdown/menu/dropdownmenulistview.d.ts +0 -0
- /package/{src → dist}/dropdown/menu/dropdownmenunestedmenupanelview.d.ts +0 -0
- /package/{src → dist}/dropdown/menu/dropdownmenunestedmenuview.d.ts +0 -0
- /package/{src → dist}/dropdown/menu/dropdownmenurootlistview.d.ts +0 -0
- /package/{src → dist}/dropdown/menu/utils.d.ts +0 -0
- /package/{src → dist}/dropdown/utils.d.ts +0 -0
- /package/{src → dist}/editableui/editableuiview.d.ts +0 -0
- /package/{src → dist}/editableui/inline/inlineeditableuiview.d.ts +0 -0
- /package/{src → dist}/editorui/accessibilityhelp/accessibilityhelp.d.ts +0 -0
- /package/{src → dist}/editorui/accessibilityhelp/accessibilityhelpcontentview.d.ts +0 -0
- /package/{src → dist}/editorui/bodycollection.d.ts +0 -0
- /package/{src → dist}/editorui/boxed/boxededitoruiview.d.ts +0 -0
- /package/{src → dist}/editorui/editorui.d.ts +0 -0
- /package/{src → dist}/editorui/editoruiview.d.ts +0 -0
- /package/{src → dist}/editorui/evaluationbadge.d.ts +0 -0
- /package/{src → dist}/editorui/poweredby.d.ts +0 -0
- /package/{src → dist}/focuscycler.d.ts +0 -0
- /package/{src → dist}/formheader/formheaderview.d.ts +0 -0
- /package/{src → dist}/formrow/formrowview.d.ts +0 -0
- /package/{src → dist}/highlightedtext/buttonlabelwithhighlightview.d.ts +0 -0
- /package/{src → dist}/highlightedtext/highlightedtextview.d.ts +0 -0
- /package/{src → dist}/highlightedtext/labelwithhighlightview.d.ts +0 -0
- /package/{src → dist}/icon/iconview.d.ts +0 -0
- /package/{src → dist}/iframe/iframeview.d.ts +0 -0
- /package/{src → dist}/index.d.ts +0 -0
- /package/{src → dist}/input/inputbase.d.ts +0 -0
- /package/{src → dist}/input/inputview.d.ts +0 -0
- /package/{src → dist}/inputnumber/inputnumberview.d.ts +0 -0
- /package/{src → dist}/inputtext/inputtextview.d.ts +0 -0
- /package/{src → dist}/label/labelview.d.ts +0 -0
- /package/{src → dist}/labeledfield/labeledfieldview.d.ts +0 -0
- /package/{src → dist}/labeledfield/utils.d.ts +0 -0
- /package/{src → dist}/labeledinput/labeledinputview.d.ts +0 -0
- /package/{src → dist}/legacyerrors.d.ts +0 -0
- /package/{src → dist}/list/listitemgroupview.d.ts +0 -0
- /package/{src → dist}/list/listitemview.d.ts +0 -0
- /package/{src → dist}/list/listseparatorview.d.ts +0 -0
- /package/{src → dist}/list/listview.d.ts +0 -0
- /package/{src → dist}/menubar/menubarmenubuttonview.d.ts +0 -0
- /package/{src → dist}/menubar/menubarmenulistitembuttonview.d.ts +0 -0
- /package/{src → dist}/menubar/menubarmenulistitemfiledialogbuttonview.d.ts +0 -0
- /package/{src → dist}/menubar/menubarmenulistitemview.d.ts +0 -0
- /package/{src → dist}/menubar/menubarmenulistview.d.ts +0 -0
- /package/{src → dist}/menubar/menubarmenupanelview.d.ts +0 -0
- /package/{src → dist}/menubar/menubarview.d.ts +0 -0
- /package/{src → dist}/menubar/utils.d.ts +0 -0
- /package/{src → dist}/model.d.ts +0 -0
- /package/{src → dist}/notification/notification.d.ts +0 -0
- /package/{src → dist}/panel/balloon/balloonpanelview.d.ts +0 -0
- /package/{src → dist}/panel/balloon/contextualballoon.d.ts +0 -0
- /package/{src → dist}/panel/sticky/stickypanelview.d.ts +0 -0
- /package/{src → dist}/search/filteredview.d.ts +0 -0
- /package/{src → dist}/search/filtergroupanditemnames.d.ts +0 -0
- /package/{src → dist}/search/searchinfoview.d.ts +0 -0
- /package/{src → dist}/search/searchresultsview.d.ts +0 -0
- /package/{src → dist}/search/text/searchtextqueryview.d.ts +0 -0
- /package/{src → dist}/search/text/searchtextview.d.ts +0 -0
- /package/{src → dist}/spinner/spinnerview.d.ts +0 -0
- /package/{src → dist}/template.d.ts +0 -0
- /package/{src → dist}/textarea/textareaview.d.ts +0 -0
- /package/{src → dist}/toolbar/balloon/balloontoolbar.d.ts +0 -0
- /package/{src → dist}/toolbar/block/blockbuttonview.d.ts +0 -0
- /package/{src → dist}/toolbar/block/blocktoolbar.d.ts +0 -0
- /package/{src → dist}/toolbar/normalizetoolbarconfig.d.ts +0 -0
- /package/{src → dist}/toolbar/toolbarlinebreakview.d.ts +0 -0
- /package/{src → dist}/toolbar/toolbarseparatorview.d.ts +0 -0
- /package/{src → dist}/toolbar/toolbarview.d.ts +0 -0
- /package/{src → dist}/tooltipmanager.d.ts +0 -0
- /package/{src → dist}/viewcollection.d.ts +0 -0
|
@@ -1,189 +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 ui/textarea/textareaview
|
|
7
|
-
*/
|
|
8
|
-
import { Rect, toUnit, getBorderWidths, global, CKEditorError, isVisible, ResizeObserver } from '@ckeditor/ckeditor5-utils';
|
|
9
|
-
import { InputBase } from '../input/inputbase.js';
|
|
10
|
-
import '../../theme/components/input/input.css';
|
|
11
|
-
import '../../theme/components/textarea/textarea.css';
|
|
12
|
-
/**
|
|
13
|
-
* The textarea view class.
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* const textareaView = new TextareaView();
|
|
17
|
-
*
|
|
18
|
-
* textareaView.minRows = 2;
|
|
19
|
-
* textareaView.maxRows = 10;
|
|
20
|
-
*
|
|
21
|
-
* textareaView.render();
|
|
22
|
-
*
|
|
23
|
-
* document.body.append( textareaView.element );
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export class TextareaView extends InputBase {
|
|
27
|
-
/**
|
|
28
|
-
* An instance of the resize observer used to detect when the view is visible or not and update
|
|
29
|
-
* its height if any changes that affect it were made while it was invisible.
|
|
30
|
-
*
|
|
31
|
-
* **Note:** Created in {@link #render}.
|
|
32
|
-
*/
|
|
33
|
-
_resizeObserver;
|
|
34
|
-
/**
|
|
35
|
-
* A flag that indicates whether the {@link #_updateAutoGrowHeight} method should be called when the view becomes
|
|
36
|
-
* visible again. See {@link #_resizeObserver}.
|
|
37
|
-
*/
|
|
38
|
-
_isUpdateAutoGrowHeightPending = false;
|
|
39
|
-
/**
|
|
40
|
-
* @inheritDoc
|
|
41
|
-
*/
|
|
42
|
-
constructor(locale) {
|
|
43
|
-
super(locale);
|
|
44
|
-
const toPx = toUnit('px');
|
|
45
|
-
this.set('minRows', 2);
|
|
46
|
-
this.set('maxRows', 5);
|
|
47
|
-
this.set('_height', null);
|
|
48
|
-
this.set('resize', 'none');
|
|
49
|
-
this._resizeObserver = null;
|
|
50
|
-
this.on('change:minRows', this._validateMinMaxRows.bind(this));
|
|
51
|
-
this.on('change:maxRows', this._validateMinMaxRows.bind(this));
|
|
52
|
-
const bind = this.bindTemplate;
|
|
53
|
-
this.template.tag = 'textarea';
|
|
54
|
-
this.extendTemplate({
|
|
55
|
-
attributes: {
|
|
56
|
-
class: ['ck-textarea'],
|
|
57
|
-
style: {
|
|
58
|
-
height: bind.to('_height', height => height ? toPx(height) : null),
|
|
59
|
-
resize: bind.to('resize')
|
|
60
|
-
},
|
|
61
|
-
rows: bind.to('minRows')
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* @inheritDoc
|
|
67
|
-
*/
|
|
68
|
-
render() {
|
|
69
|
-
super.render();
|
|
70
|
-
let wasVisible = false;
|
|
71
|
-
this.on('input', () => {
|
|
72
|
-
this._updateAutoGrowHeight(true);
|
|
73
|
-
this.fire('update');
|
|
74
|
-
});
|
|
75
|
-
this.on('change:value', () => {
|
|
76
|
-
// The content needs to be updated by the browser after the value is changed. It takes a few ms.
|
|
77
|
-
global.window.requestAnimationFrame(() => {
|
|
78
|
-
if (!isVisible(this.element)) {
|
|
79
|
-
this._isUpdateAutoGrowHeightPending = true;
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
this._updateAutoGrowHeight();
|
|
83
|
-
this.fire('update');
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
// It may occur that the Textarea size needs to be updated (e.g. because it's content was changed)
|
|
87
|
-
// when it is not visible or detached from DOM.
|
|
88
|
-
// In such case, we need to detect the moment when it becomes visible again and update its height then.
|
|
89
|
-
// We're using ResizeObserver for that as it is the most reliable way to detect when the element becomes visible.
|
|
90
|
-
// IntersectionObserver didn't work well with the absolute positioned containers.
|
|
91
|
-
this._resizeObserver = new ResizeObserver(this.element, evt => {
|
|
92
|
-
const isVisible = !!evt.contentRect.width && !!evt.contentRect.height;
|
|
93
|
-
if (!wasVisible && isVisible && this._isUpdateAutoGrowHeightPending) {
|
|
94
|
-
// We're wrapping the auto-grow logic in RAF because otherwise there is an error thrown
|
|
95
|
-
// by the browser about recursive calls to the ResizeObserver. It used to happen in unit
|
|
96
|
-
// tests only, though. Since there is no risk of infinite loop here, it can stay here.
|
|
97
|
-
global.window.requestAnimationFrame(() => {
|
|
98
|
-
this._updateAutoGrowHeight();
|
|
99
|
-
this.fire('update');
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
wasVisible = isVisible;
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* @inheritDoc
|
|
107
|
-
*/
|
|
108
|
-
destroy() {
|
|
109
|
-
if (this._resizeObserver) {
|
|
110
|
-
this._resizeObserver.destroy();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* @inheritDoc
|
|
115
|
-
*/
|
|
116
|
-
reset() {
|
|
117
|
-
super.reset();
|
|
118
|
-
this._updateAutoGrowHeight();
|
|
119
|
-
this.fire('update');
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Updates the {@link #_height} of the view depending on {@link #minRows}, {@link #maxRows}, and the current content size.
|
|
123
|
-
*
|
|
124
|
-
* **Note**: This method overrides manual resize done by the user using a handle. It's a known bug.
|
|
125
|
-
*/
|
|
126
|
-
_updateAutoGrowHeight(shouldScroll) {
|
|
127
|
-
const viewElement = this.element;
|
|
128
|
-
if (!viewElement.offsetParent) {
|
|
129
|
-
this._isUpdateAutoGrowHeightPending = true;
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
this._isUpdateAutoGrowHeightPending = false;
|
|
133
|
-
const singleLineContentClone = getTextareaElementClone(viewElement, '1');
|
|
134
|
-
const fullTextValueClone = getTextareaElementClone(viewElement, viewElement.value);
|
|
135
|
-
const singleLineContentStyles = singleLineContentClone.ownerDocument.defaultView.getComputedStyle(singleLineContentClone);
|
|
136
|
-
const verticalPaddings = parseFloat(singleLineContentStyles.paddingTop) + parseFloat(singleLineContentStyles.paddingBottom);
|
|
137
|
-
const borders = getBorderWidths(singleLineContentClone);
|
|
138
|
-
const lineHeight = parseFloat(singleLineContentStyles.lineHeight);
|
|
139
|
-
const verticalBorder = borders.top + borders.bottom;
|
|
140
|
-
const singleLineAreaDefaultHeight = new Rect(singleLineContentClone).height;
|
|
141
|
-
const numberOfLines = Math.round((fullTextValueClone.scrollHeight - verticalPaddings) / lineHeight);
|
|
142
|
-
const maxHeight = this.maxRows * lineHeight + verticalPaddings + verticalBorder;
|
|
143
|
-
// There's a --ck-ui-component-min-height CSS custom property that enforces min height of the component.
|
|
144
|
-
// This min-height is relevant only when there's one line of text. Other than that, we can rely on line-height.
|
|
145
|
-
const minHeight = numberOfLines === 1 ? singleLineAreaDefaultHeight : this.minRows * lineHeight + verticalPaddings + verticalBorder;
|
|
146
|
-
// The size of textarea is controlled by height style instead of rows attribute because event though it is
|
|
147
|
-
// a more complex solution, it is immune to the layout textarea has been rendered in (gird, flex).
|
|
148
|
-
this._height = Math.min(Math.max(Math.max(numberOfLines, this.minRows) * lineHeight + verticalPaddings + verticalBorder, minHeight), maxHeight);
|
|
149
|
-
if (shouldScroll) {
|
|
150
|
-
viewElement.scrollTop = viewElement.scrollHeight;
|
|
151
|
-
}
|
|
152
|
-
singleLineContentClone.remove();
|
|
153
|
-
fullTextValueClone.remove();
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Validates the {@link #minRows} and {@link #maxRows} properties and warns in the console if the configuration is incorrect.
|
|
157
|
-
*/
|
|
158
|
-
_validateMinMaxRows() {
|
|
159
|
-
if (this.minRows > this.maxRows) {
|
|
160
|
-
/**
|
|
161
|
-
* The minimum number of rows is greater than the maximum number of rows.
|
|
162
|
-
*
|
|
163
|
-
* @error ui-textarea-view-min-rows-greater-than-max-rows
|
|
164
|
-
* @param {module:ui/textarea/textareaview~TextareaView} textareaView The misconfigured textarea view instance.
|
|
165
|
-
* @param {number} minRows The value of `minRows` property.
|
|
166
|
-
* @param {number} maxRows The value of `maxRows` property.
|
|
167
|
-
*/
|
|
168
|
-
throw new CKEditorError('ui-textarea-view-min-rows-greater-than-max-rows', {
|
|
169
|
-
textareaView: this,
|
|
170
|
-
minRows: this.minRows,
|
|
171
|
-
maxRows: this.maxRows
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
function getTextareaElementClone(element, value) {
|
|
177
|
-
const clone = element.cloneNode();
|
|
178
|
-
clone.style.position = 'absolute';
|
|
179
|
-
clone.style.top = '-99999px';
|
|
180
|
-
clone.style.left = '-99999px';
|
|
181
|
-
clone.style.height = 'auto';
|
|
182
|
-
clone.style.overflow = 'hidden';
|
|
183
|
-
clone.style.width = element.ownerDocument.defaultView.getComputedStyle(element).width;
|
|
184
|
-
clone.tabIndex = -1;
|
|
185
|
-
clone.rows = 1;
|
|
186
|
-
clone.value = value;
|
|
187
|
-
element.parentNode.insertBefore(clone, element);
|
|
188
|
-
return clone;
|
|
189
|
-
}
|
|
@@ -1,358 +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 ui/toolbar/balloon/balloontoolbar
|
|
7
|
-
*/
|
|
8
|
-
import { ContextualBalloon } from '../../panel/balloon/contextualballoon.js';
|
|
9
|
-
import { ToolbarView } from '../toolbarview.js';
|
|
10
|
-
import { BalloonPanelView } from '../../panel/balloon/balloonpanelview.js';
|
|
11
|
-
import { normalizeToolbarConfig } from '../normalizetoolbarconfig.js';
|
|
12
|
-
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
13
|
-
import { FocusTracker, Rect, ResizeObserver, env, global, toUnit } from '@ckeditor/ckeditor5-utils';
|
|
14
|
-
import { Observer } from '@ckeditor/ckeditor5-engine';
|
|
15
|
-
import { debounce } from 'es-toolkit/compat';
|
|
16
|
-
const toPx = /* #__PURE__ */ toUnit('px');
|
|
17
|
-
/**
|
|
18
|
-
* The contextual toolbar.
|
|
19
|
-
*
|
|
20
|
-
* It uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon plugin}.
|
|
21
|
-
*/
|
|
22
|
-
export class BalloonToolbar extends Plugin {
|
|
23
|
-
/**
|
|
24
|
-
* The toolbar view displayed in the balloon.
|
|
25
|
-
*/
|
|
26
|
-
toolbarView;
|
|
27
|
-
/**
|
|
28
|
-
* Tracks the focus of the {@link module:ui/editorui/editorui~EditorUI#getEditableElement editable element}
|
|
29
|
-
* and the {@link #toolbarView}. When both are blurred then the toolbar should hide.
|
|
30
|
-
*/
|
|
31
|
-
focusTracker;
|
|
32
|
-
/**
|
|
33
|
-
* A cached and normalized `config.balloonToolbar` object.
|
|
34
|
-
*/
|
|
35
|
-
_balloonConfig;
|
|
36
|
-
/**
|
|
37
|
-
* An instance of the resize observer that allows to respond to changes in editable's geometry
|
|
38
|
-
* so the toolbar can stay within its boundaries (and group toolbar items that do not fit).
|
|
39
|
-
*
|
|
40
|
-
* **Note**: Used only when `shouldNotGroupWhenFull` was **not** set in the
|
|
41
|
-
* {@link module:core/editor/editorconfig~EditorConfig#balloonToolbar configuration}.
|
|
42
|
-
*
|
|
43
|
-
* **Note:** Created in {@link #init}.
|
|
44
|
-
*/
|
|
45
|
-
_resizeObserver = null;
|
|
46
|
-
/**
|
|
47
|
-
* The contextual balloon plugin instance.
|
|
48
|
-
*/
|
|
49
|
-
_balloon;
|
|
50
|
-
/**
|
|
51
|
-
* Fires `_selectionChangeDebounced` event using `es-toolkit#debounce`.
|
|
52
|
-
*
|
|
53
|
-
* This event is an internal plugin event which is fired 200 ms after model selection last change.
|
|
54
|
-
* This is to makes easy test debounced action without need to use `setTimeout`.
|
|
55
|
-
*
|
|
56
|
-
* This function is stored as a plugin property to make possible to cancel
|
|
57
|
-
* trailing debounced invocation on destroy.
|
|
58
|
-
*/
|
|
59
|
-
_fireSelectionChangeDebounced;
|
|
60
|
-
/**
|
|
61
|
-
* @inheritDoc
|
|
62
|
-
*/
|
|
63
|
-
static get pluginName() {
|
|
64
|
-
return 'BalloonToolbar';
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* @inheritDoc
|
|
68
|
-
*/
|
|
69
|
-
static get isOfficialPlugin() {
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* @inheritDoc
|
|
74
|
-
*/
|
|
75
|
-
static get requires() {
|
|
76
|
-
return [ContextualBalloon];
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* @inheritDoc
|
|
80
|
-
*/
|
|
81
|
-
constructor(editor) {
|
|
82
|
-
super(editor);
|
|
83
|
-
this._balloonConfig = normalizeToolbarConfig(editor.config.get('balloonToolbar'));
|
|
84
|
-
this.toolbarView = this._createToolbarView();
|
|
85
|
-
this.focusTracker = new FocusTracker();
|
|
86
|
-
// Track focusable elements in the toolbar and the editable elements.
|
|
87
|
-
this._trackFocusableEditableElements();
|
|
88
|
-
this.focusTracker.add(this.toolbarView);
|
|
89
|
-
// Register the toolbar so it becomes available for Alt+F10 and Esc navigation.
|
|
90
|
-
editor.ui.addToolbar(this.toolbarView, {
|
|
91
|
-
beforeFocus: () => this.show(true),
|
|
92
|
-
afterBlur: () => this.hide(),
|
|
93
|
-
isContextual: true
|
|
94
|
-
});
|
|
95
|
-
this._balloon = editor.plugins.get(ContextualBalloon);
|
|
96
|
-
this._fireSelectionChangeDebounced = debounce(() => this.fire('_selectionChangeDebounced'), 200);
|
|
97
|
-
// The appearance of the BalloonToolbar method is event–driven.
|
|
98
|
-
// It is possible to stop the #show event and this prevent the toolbar from showing up.
|
|
99
|
-
this.decorate('show');
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* @inheritDoc
|
|
103
|
-
*/
|
|
104
|
-
init() {
|
|
105
|
-
const editor = this.editor;
|
|
106
|
-
const selection = editor.model.document.selection;
|
|
107
|
-
// Show/hide the toolbar on editable focus/blur.
|
|
108
|
-
this.listenTo(this.focusTracker, 'change:isFocused', (evt, name, isFocused) => {
|
|
109
|
-
if (!isFocused && this._isToolbarVisible) {
|
|
110
|
-
this.hide();
|
|
111
|
-
}
|
|
112
|
-
else if (isFocused) {
|
|
113
|
-
this.show();
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
// Hide the toolbar when the selection is changed by a direct change or has changed to collapsed.
|
|
117
|
-
this.listenTo(selection, 'change:range', (evt, data) => {
|
|
118
|
-
if (data.directChange || selection.isCollapsed) {
|
|
119
|
-
this.hide();
|
|
120
|
-
}
|
|
121
|
-
// Fire internal `_selectionChangeDebounced` event to use it for showing
|
|
122
|
-
// the toolbar after the selection stops changing.
|
|
123
|
-
this._fireSelectionChangeDebounced();
|
|
124
|
-
});
|
|
125
|
-
// Show the toolbar when the selection stops changing.
|
|
126
|
-
this.listenTo(this, '_selectionChangeDebounced', () => {
|
|
127
|
-
if (this.editor.editing.view.document.isFocused) {
|
|
128
|
-
this.show();
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
if (!this._balloonConfig.shouldNotGroupWhenFull) {
|
|
132
|
-
this.listenTo(editor, 'ready', () => {
|
|
133
|
-
const editableElement = editor.ui.view.editable.element;
|
|
134
|
-
// Set #toolbarView's max-width on the initialization and update it on the editable resize.
|
|
135
|
-
this._resizeObserver = new ResizeObserver(editableElement, entry => {
|
|
136
|
-
// The max-width equals 90% of the editable's width for the best user experience.
|
|
137
|
-
// The value keeps the balloon very close to the boundaries of the editable and limits the cases
|
|
138
|
-
// when the balloon juts out from the editable element it belongs to.
|
|
139
|
-
this.toolbarView.maxWidth = toPx(entry.contentRect.width * .9);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
// Listen to the toolbar view and whenever it changes its geometry due to some items being
|
|
144
|
-
// grouped or ungrouped, update the position of the balloon because a shorter/longer toolbar
|
|
145
|
-
// means the balloon could be pointing at the wrong place. Once updated, the balloon will point
|
|
146
|
-
// at the right selection in the content again.
|
|
147
|
-
// https://github.com/ckeditor/ckeditor5/issues/6444
|
|
148
|
-
this.listenTo(this.toolbarView, 'groupedItemsUpdate', () => {
|
|
149
|
-
this._updatePosition();
|
|
150
|
-
});
|
|
151
|
-
// Creates toolbar components based on given configuration.
|
|
152
|
-
// This needs to be done when all plugins are ready.
|
|
153
|
-
editor.ui.once('ready', () => {
|
|
154
|
-
this.toolbarView.fillFromConfig(this._balloonConfig, this.editor.ui.componentFactory);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Returns whether the toolbar is visible in the ContextualBalloon.
|
|
159
|
-
*/
|
|
160
|
-
get _isToolbarVisible() {
|
|
161
|
-
return this._balloon.visibleView === this.toolbarView;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Creates the toolbar view instance.
|
|
165
|
-
*/
|
|
166
|
-
_createToolbarView() {
|
|
167
|
-
const t = this.editor.locale.t;
|
|
168
|
-
const shouldGroupWhenFull = !this._balloonConfig.shouldNotGroupWhenFull;
|
|
169
|
-
const toolbarView = new ToolbarView(this.editor.locale, {
|
|
170
|
-
shouldGroupWhenFull,
|
|
171
|
-
isFloating: true
|
|
172
|
-
});
|
|
173
|
-
toolbarView.ariaLabel = t('Editor contextual toolbar');
|
|
174
|
-
toolbarView.render();
|
|
175
|
-
return toolbarView;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Shows the toolbar and attaches it to the selection.
|
|
179
|
-
*
|
|
180
|
-
* Fires {@link #event:show} event which can be stopped to prevent the toolbar from showing up.
|
|
181
|
-
*
|
|
182
|
-
* @param showForCollapsedSelection When set `true`, the toolbar will show despite collapsed selection in the
|
|
183
|
-
* editing view.
|
|
184
|
-
*/
|
|
185
|
-
show(showForCollapsedSelection = false) {
|
|
186
|
-
const editor = this.editor;
|
|
187
|
-
const selection = editor.model.document.selection;
|
|
188
|
-
const schema = editor.model.schema;
|
|
189
|
-
// Do not add the toolbar to the balloon stack twice.
|
|
190
|
-
if (this._balloon.hasView(this.toolbarView)) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
// Do not show the toolbar when the selection is collapsed.
|
|
194
|
-
if (selection.isCollapsed && !showForCollapsedSelection) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
// Do not show the toolbar when there is more than one range in the selection and they fully contain selectable elements.
|
|
198
|
-
// See https://github.com/ckeditor/ckeditor5/issues/6443.
|
|
199
|
-
if (selectionContainsOnlyMultipleSelectables(selection, schema)) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
// Do not show the toolbar when all components inside are disabled
|
|
203
|
-
// see https://github.com/ckeditor/ckeditor5-ui/issues/269.
|
|
204
|
-
if (Array.from(this.toolbarView.items).every((item) => item.isEnabled !== undefined && !item.isEnabled)) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
// Update the toolbar position when the editor ui should be refreshed.
|
|
208
|
-
this.listenTo(this.editor.ui, 'update', () => {
|
|
209
|
-
this._updatePosition();
|
|
210
|
-
});
|
|
211
|
-
// Add the toolbar to the common editor contextual balloon.
|
|
212
|
-
this._balloon.add({
|
|
213
|
-
view: this.toolbarView,
|
|
214
|
-
position: this._getBalloonPositionData(),
|
|
215
|
-
balloonClassName: 'ck-toolbar-container'
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Hides the toolbar.
|
|
220
|
-
*/
|
|
221
|
-
hide() {
|
|
222
|
-
if (this._balloon.hasView(this.toolbarView)) {
|
|
223
|
-
this.stopListening(this.editor.ui, 'update');
|
|
224
|
-
this._balloon.remove(this.toolbarView);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Add or remove editable elements to the focus tracker. It watches added and removed roots
|
|
229
|
-
* and adds or removes their editable elements to the focus tracker.
|
|
230
|
-
*/
|
|
231
|
-
_trackFocusableEditableElements() {
|
|
232
|
-
const { editor, focusTracker } = this;
|
|
233
|
-
const { editing } = editor;
|
|
234
|
-
editing.view.addObserver(class TrackEditableElements extends Observer {
|
|
235
|
-
/**
|
|
236
|
-
* @inheritDoc
|
|
237
|
-
*/
|
|
238
|
-
observe(domElement) {
|
|
239
|
-
focusTracker.add(domElement);
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* @inheritDoc
|
|
243
|
-
*/
|
|
244
|
-
stopObserving(domElement) {
|
|
245
|
-
focusTracker.remove(domElement);
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Returns positioning options for the {@link #_balloon}. They control the way balloon is attached
|
|
251
|
-
* to the selection.
|
|
252
|
-
*/
|
|
253
|
-
_getBalloonPositionData() {
|
|
254
|
-
const editor = this.editor;
|
|
255
|
-
const view = editor.editing.view;
|
|
256
|
-
const viewDocument = view.document;
|
|
257
|
-
const viewSelection = viewDocument.selection;
|
|
258
|
-
// Get direction of the selection.
|
|
259
|
-
const isBackward = viewDocument.selection.isBackward;
|
|
260
|
-
return {
|
|
261
|
-
// Because the target for BalloonPanelView is a Rect (not DOMRange), it's geometry will stay fixed
|
|
262
|
-
// as the window scrolls. To let the BalloonPanelView follow such Rect, is must be continuously
|
|
263
|
-
// computed and hence, the target is defined as a function instead of a static value.
|
|
264
|
-
// https://github.com/ckeditor/ckeditor5-ui/issues/195
|
|
265
|
-
target: () => {
|
|
266
|
-
const range = isBackward ? viewSelection.getFirstRange() : viewSelection.getLastRange();
|
|
267
|
-
const rangeRects = Rect.getDomRangeRects(view.domConverter.viewRangeToDom(range));
|
|
268
|
-
// Select the proper range rect depending on the direction of the selection.
|
|
269
|
-
if (isBackward) {
|
|
270
|
-
return rangeRects[0];
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
// Ditch the zero-width "orphan" rect in the next line for the forward selection if there's
|
|
274
|
-
// another one preceding it. It is not rendered as a selection by the web browser anyway.
|
|
275
|
-
// https://github.com/ckeditor/ckeditor5-ui/issues/308
|
|
276
|
-
if (rangeRects.length > 1 && rangeRects[rangeRects.length - 1].width === 0) {
|
|
277
|
-
rangeRects.pop();
|
|
278
|
-
}
|
|
279
|
-
return rangeRects[rangeRects.length - 1];
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
positions: this._getBalloonPositions(isBackward)
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Updates the position of the {@link #_balloon} to make up for changes:
|
|
287
|
-
*
|
|
288
|
-
* * in the geometry of the selection it is attached to (e.g. the selection moved in the viewport or expanded or shrunk),
|
|
289
|
-
* * or the geometry of the balloon toolbar itself (e.g. the toolbar has grouped or ungrouped some items and it is shorter or longer).
|
|
290
|
-
*/
|
|
291
|
-
_updatePosition() {
|
|
292
|
-
if (this._isToolbarVisible) {
|
|
293
|
-
this._balloon.updatePosition(this._getBalloonPositionData());
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* @inheritDoc
|
|
298
|
-
*/
|
|
299
|
-
destroy() {
|
|
300
|
-
super.destroy();
|
|
301
|
-
this.stopListening();
|
|
302
|
-
this._fireSelectionChangeDebounced.cancel();
|
|
303
|
-
this.toolbarView.destroy();
|
|
304
|
-
this.focusTracker.destroy();
|
|
305
|
-
if (this._resizeObserver) {
|
|
306
|
-
this._resizeObserver.destroy();
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Returns toolbar positions for the given direction of the selection.
|
|
311
|
-
*/
|
|
312
|
-
_getBalloonPositions(isBackward) {
|
|
313
|
-
const isSafariIniOS = env.isSafari && env.isiOS;
|
|
314
|
-
// https://github.com/ckeditor/ckeditor5/issues/7707
|
|
315
|
-
const positions = isSafariIniOS ? BalloonPanelView.generatePositions({
|
|
316
|
-
// 20px when zoomed out. Less then 20px when zoomed in; the "radius" of the native selection handle gets
|
|
317
|
-
// smaller as the user zooms in. No less than the default v-offset, though.
|
|
318
|
-
heightOffset: Math.max(BalloonPanelView.arrowHeightOffset, Math.round(20 / global.window.visualViewport.scale))
|
|
319
|
-
}) : BalloonPanelView.defaultPositions;
|
|
320
|
-
return isBackward ? [
|
|
321
|
-
positions.northWestArrowSouth,
|
|
322
|
-
positions.northWestArrowSouthWest,
|
|
323
|
-
positions.northWestArrowSouthEast,
|
|
324
|
-
positions.northWestArrowSouthMiddleEast,
|
|
325
|
-
positions.northWestArrowSouthMiddleWest,
|
|
326
|
-
positions.southWestArrowNorth,
|
|
327
|
-
positions.southWestArrowNorthWest,
|
|
328
|
-
positions.southWestArrowNorthEast,
|
|
329
|
-
positions.southWestArrowNorthMiddleWest,
|
|
330
|
-
positions.southWestArrowNorthMiddleEast
|
|
331
|
-
] : [
|
|
332
|
-
positions.southEastArrowNorth,
|
|
333
|
-
positions.southEastArrowNorthEast,
|
|
334
|
-
positions.southEastArrowNorthWest,
|
|
335
|
-
positions.southEastArrowNorthMiddleEast,
|
|
336
|
-
positions.southEastArrowNorthMiddleWest,
|
|
337
|
-
positions.northEastArrowSouth,
|
|
338
|
-
positions.northEastArrowSouthEast,
|
|
339
|
-
positions.northEastArrowSouthWest,
|
|
340
|
-
positions.northEastArrowSouthMiddleEast,
|
|
341
|
-
positions.northEastArrowSouthMiddleWest
|
|
342
|
-
];
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Returns "true" when the selection has multiple ranges and each range contains a selectable element
|
|
347
|
-
* and nothing else.
|
|
348
|
-
*/
|
|
349
|
-
function selectionContainsOnlyMultipleSelectables(selection, schema) {
|
|
350
|
-
// It doesn't contain multiple objects if there is only one range.
|
|
351
|
-
if (selection.rangeCount === 1) {
|
|
352
|
-
return false;
|
|
353
|
-
}
|
|
354
|
-
return [...selection.getRanges()].every(range => {
|
|
355
|
-
const element = range.getContainedElement();
|
|
356
|
-
return element && schema.isSelectable(element);
|
|
357
|
-
});
|
|
358
|
-
}
|
|
@@ -1,41 +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 ui/toolbar/block/blockbuttonview
|
|
7
|
-
*/
|
|
8
|
-
import { ButtonView } from '../../button/buttonview.js';
|
|
9
|
-
import { toUnit } from '@ckeditor/ckeditor5-utils';
|
|
10
|
-
import '../../../theme/components/toolbar/blocktoolbar.css';
|
|
11
|
-
const toPx = /* #__PURE__ */ toUnit('px');
|
|
12
|
-
/**
|
|
13
|
-
* The block button view class.
|
|
14
|
-
*
|
|
15
|
-
* This view represents a button attached next to block element where the selection is anchored.
|
|
16
|
-
*
|
|
17
|
-
* See {@link module:ui/toolbar/block/blocktoolbar~BlockToolbar}.
|
|
18
|
-
*/
|
|
19
|
-
export class BlockButtonView extends ButtonView {
|
|
20
|
-
/**
|
|
21
|
-
* @inheritDoc
|
|
22
|
-
*/
|
|
23
|
-
constructor(locale) {
|
|
24
|
-
super(locale);
|
|
25
|
-
const bind = this.bindTemplate;
|
|
26
|
-
// Hide button on init.
|
|
27
|
-
this.isVisible = false;
|
|
28
|
-
this.isToggleable = true;
|
|
29
|
-
this.set('top', 0);
|
|
30
|
-
this.set('left', 0);
|
|
31
|
-
this.extendTemplate({
|
|
32
|
-
attributes: {
|
|
33
|
-
class: 'ck-block-toolbar-button',
|
|
34
|
-
style: {
|
|
35
|
-
top: bind.to('top', val => toPx(val)),
|
|
36
|
-
left: bind.to('left', val => toPx(val))
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|