@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
package/src/editorui/editorui.js
DELETED
|
@@ -1,586 +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/editorui/editorui
|
|
7
|
-
*/
|
|
8
|
-
import { ComponentFactory } from '../componentfactory.js';
|
|
9
|
-
import { TooltipManager } from '../tooltipmanager.js';
|
|
10
|
-
import { PoweredBy } from './poweredby.js';
|
|
11
|
-
import { EvaluationBadge } from './evaluationbadge.js';
|
|
12
|
-
import { AriaLiveAnnouncer } from '../arialiveannouncer.js';
|
|
13
|
-
import { ObservableMixin, DomEmitterMixin, global, isVisible, FocusTracker, getVisualViewportOffset } from '@ckeditor/ckeditor5-utils';
|
|
14
|
-
import { normalizeMenuBarConfig } from '../menubar/utils.js';
|
|
15
|
-
/**
|
|
16
|
-
* A class providing the minimal interface that is required to successfully bootstrap any editor UI.
|
|
17
|
-
*/
|
|
18
|
-
export class EditorUI extends /* #__PURE__ */ ObservableMixin() {
|
|
19
|
-
/**
|
|
20
|
-
* The editor that the UI belongs to.
|
|
21
|
-
*/
|
|
22
|
-
editor;
|
|
23
|
-
/**
|
|
24
|
-
* An instance of the {@link module:ui/componentfactory~ComponentFactory}, a registry used by plugins
|
|
25
|
-
* to register factories of specific UI components.
|
|
26
|
-
*/
|
|
27
|
-
componentFactory;
|
|
28
|
-
/**
|
|
29
|
-
* Stores the information about the editor UI focus and propagates it so various plugins and components
|
|
30
|
-
* are unified as a focus group.
|
|
31
|
-
*/
|
|
32
|
-
focusTracker;
|
|
33
|
-
/**
|
|
34
|
-
* Manages the tooltips displayed on mouseover and focus across the UI.
|
|
35
|
-
*/
|
|
36
|
-
tooltipManager;
|
|
37
|
-
/**
|
|
38
|
-
* A helper that enables the "powered by" feature in the editor and renders a link to the project's webpage.
|
|
39
|
-
*/
|
|
40
|
-
poweredBy;
|
|
41
|
-
/**
|
|
42
|
-
* A helper that enables the "evaluation badge" feature in the editor.
|
|
43
|
-
*/
|
|
44
|
-
evaluationBadge;
|
|
45
|
-
/**
|
|
46
|
-
* A helper that manages the content of an `aria-live` regions used by editor features to announce status changes
|
|
47
|
-
* to screen readers.
|
|
48
|
-
*/
|
|
49
|
-
ariaLiveAnnouncer;
|
|
50
|
-
/**
|
|
51
|
-
* Indicates the UI is ready. Set `true` after {@link #event:ready} event is fired.
|
|
52
|
-
*
|
|
53
|
-
* @readonly
|
|
54
|
-
* @default false
|
|
55
|
-
*/
|
|
56
|
-
isReady = false;
|
|
57
|
-
/**
|
|
58
|
-
* Stores all editable elements used by the editor instance.
|
|
59
|
-
*/
|
|
60
|
-
_editableElementsMap = new Map();
|
|
61
|
-
/**
|
|
62
|
-
* All available & focusable toolbars.
|
|
63
|
-
*/
|
|
64
|
-
_focusableToolbarDefinitions = [];
|
|
65
|
-
/**
|
|
66
|
-
* All additional menu bar items, groups or menus that have their default location defined.
|
|
67
|
-
*/
|
|
68
|
-
_extraMenuBarElements = [];
|
|
69
|
-
/**
|
|
70
|
-
* The last focused element to which focus should return on `Esc` press.
|
|
71
|
-
*/
|
|
72
|
-
_lastFocusedForeignElement = null;
|
|
73
|
-
/**
|
|
74
|
-
* The DOM emitter instance used for visual viewport watching.
|
|
75
|
-
*/
|
|
76
|
-
_domEmitter;
|
|
77
|
-
/**
|
|
78
|
-
* Creates an instance of the editor UI class.
|
|
79
|
-
*
|
|
80
|
-
* @param editor The editor instance.
|
|
81
|
-
*/
|
|
82
|
-
constructor(editor) {
|
|
83
|
-
super();
|
|
84
|
-
const editingView = editor.editing.view;
|
|
85
|
-
this.editor = editor;
|
|
86
|
-
this.componentFactory = new ComponentFactory(editor);
|
|
87
|
-
this.focusTracker = new FocusTracker();
|
|
88
|
-
this.tooltipManager = new TooltipManager(editor);
|
|
89
|
-
this.poweredBy = new PoweredBy(editor);
|
|
90
|
-
this.evaluationBadge = new EvaluationBadge(editor);
|
|
91
|
-
this.ariaLiveAnnouncer = new AriaLiveAnnouncer(editor);
|
|
92
|
-
this._initViewportOffset(this._readViewportOffsetFromConfig());
|
|
93
|
-
this.once('ready', () => {
|
|
94
|
-
this._bindBodyCollectionWithFocusTracker();
|
|
95
|
-
this.isReady = true;
|
|
96
|
-
});
|
|
97
|
-
// Informs UI components that should be refreshed after layout change.
|
|
98
|
-
this.listenTo(editingView.document, 'layoutChanged', this.update.bind(this));
|
|
99
|
-
this.listenTo(editingView, 'scrollToTheSelection', this._handleScrollToTheSelection.bind(this));
|
|
100
|
-
this._initFocusTracking();
|
|
101
|
-
this._initVisualViewportSupport();
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* The main (outermost) DOM element of the editor UI.
|
|
105
|
-
*
|
|
106
|
-
* For example, in {@link module:editor-classic/classiceditor~ClassicEditor} it is a `<div>` which
|
|
107
|
-
* wraps the editable element and the toolbar. In {@link module:editor-inline/inlineeditor~InlineEditor}
|
|
108
|
-
* it is the editable element itself (as there is no other wrapper). However, in
|
|
109
|
-
* {@link module:editor-decoupled/decouplededitor~DecoupledEditor} it is set to `null` because this editor does not
|
|
110
|
-
* come with a single "main" HTML element (its editable element and toolbar are separate).
|
|
111
|
-
*
|
|
112
|
-
* This property can be understood as a shorthand for retrieving the element that a specific editor integration
|
|
113
|
-
* considers to be its main DOM element.
|
|
114
|
-
*/
|
|
115
|
-
get element() {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Fires the {@link module:ui/editorui/editorui~EditorUI#event:update `update`} event.
|
|
120
|
-
*
|
|
121
|
-
* This method should be called when the editor UI (e.g. positions of its balloons) needs to be updated due to
|
|
122
|
-
* some environmental change which CKEditor 5 is not aware of (e.g. resize of a container in which it is used).
|
|
123
|
-
*/
|
|
124
|
-
update() {
|
|
125
|
-
this.fire('update');
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Destroys the UI.
|
|
129
|
-
*/
|
|
130
|
-
destroy() {
|
|
131
|
-
this.stopListening();
|
|
132
|
-
this.focusTracker.destroy();
|
|
133
|
-
this.tooltipManager.destroy(this.editor);
|
|
134
|
-
this.poweredBy.destroy();
|
|
135
|
-
this.evaluationBadge.destroy();
|
|
136
|
-
// Clean–up the references to the CKEditor instance stored in the native editable DOM elements.
|
|
137
|
-
for (const domElement of this._editableElementsMap.values()) {
|
|
138
|
-
domElement.ckeditorInstance = null;
|
|
139
|
-
this.editor.keystrokes.stopListening(domElement);
|
|
140
|
-
}
|
|
141
|
-
this._editableElementsMap = new Map();
|
|
142
|
-
this._focusableToolbarDefinitions = [];
|
|
143
|
-
if (this._domEmitter) {
|
|
144
|
-
this._domEmitter.stopListening();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Stores the native DOM editable element used by the editor under a unique name.
|
|
149
|
-
*
|
|
150
|
-
* Also, registers the element in the editor to maintain the accessibility of the UI. When the user is editing text in a focusable
|
|
151
|
-
* editable area, they can use the <kbd>Alt</kbd> + <kbd>F10</kbd> keystroke to navigate over editor toolbars. See {@link #addToolbar}.
|
|
152
|
-
*
|
|
153
|
-
* @param rootName The unique name of the editable element.
|
|
154
|
-
* @param domElement The native DOM editable element.
|
|
155
|
-
*/
|
|
156
|
-
setEditableElement(rootName, domElement) {
|
|
157
|
-
this._editableElementsMap.set(rootName, domElement);
|
|
158
|
-
// Put a reference to the CKEditor instance in the editable native DOM element.
|
|
159
|
-
// It helps 3rd–party software (browser extensions, other libraries) access and recognize
|
|
160
|
-
// CKEditor 5 instances (editing roots) and use their API (there is no global editor
|
|
161
|
-
// instance registry).
|
|
162
|
-
if (!domElement.ckeditorInstance) {
|
|
163
|
-
domElement.ckeditorInstance = this.editor;
|
|
164
|
-
}
|
|
165
|
-
// Register the element, so it becomes available for Alt+F10 and Esc navigation.
|
|
166
|
-
this.focusTracker.add(domElement);
|
|
167
|
-
const setUpKeystrokeHandler = () => {
|
|
168
|
-
// The editing view of the editor is already listening to keystrokes from DOM roots (see: KeyObserver).
|
|
169
|
-
// Do not duplicate listeners.
|
|
170
|
-
if (this.editor.editing.view.getDomRoot(rootName)) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
this.editor.keystrokes.listenTo(domElement);
|
|
174
|
-
};
|
|
175
|
-
// For editable elements set by features after EditorUI is ready (e.g. source editing).
|
|
176
|
-
if (this.isReady) {
|
|
177
|
-
setUpKeystrokeHandler();
|
|
178
|
-
}
|
|
179
|
-
// For editable elements set while the editor is being created (e.g. DOM roots).
|
|
180
|
-
else {
|
|
181
|
-
this.once('ready', setUpKeystrokeHandler);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Removes the editable from the editor UI. Removes all handlers added by {@link #setEditableElement}.
|
|
186
|
-
*
|
|
187
|
-
* @param rootName The name of the editable element to remove.
|
|
188
|
-
*/
|
|
189
|
-
removeEditableElement(rootName) {
|
|
190
|
-
const domElement = this._editableElementsMap.get(rootName);
|
|
191
|
-
if (!domElement) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
this._editableElementsMap.delete(rootName);
|
|
195
|
-
this.editor.keystrokes.stopListening(domElement);
|
|
196
|
-
this.focusTracker.remove(domElement);
|
|
197
|
-
domElement.ckeditorInstance = null;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Returns the editable editor element with the given name or null if editable does not exist.
|
|
201
|
-
*
|
|
202
|
-
* @param rootName The editable name.
|
|
203
|
-
*/
|
|
204
|
-
getEditableElement(rootName = 'main') {
|
|
205
|
-
return this._editableElementsMap.get(rootName);
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Returns array of names of all editor editable elements.
|
|
209
|
-
*/
|
|
210
|
-
getEditableElementsNames() {
|
|
211
|
-
return this._editableElementsMap.keys();
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Adds a toolbar to the editor UI. Used primarily to maintain the accessibility of the UI.
|
|
215
|
-
*
|
|
216
|
-
* Focusable toolbars can be accessed (focused) by users by pressing the <kbd>Alt</kbd> + <kbd>F10</kbd> keystroke.
|
|
217
|
-
* Successive keystroke presses navigate over available toolbars.
|
|
218
|
-
*
|
|
219
|
-
* @param toolbarView A instance of the toolbar to be registered.
|
|
220
|
-
*/
|
|
221
|
-
addToolbar(toolbarView, options = {}) {
|
|
222
|
-
if (toolbarView.isRendered) {
|
|
223
|
-
this.focusTracker.add(toolbarView);
|
|
224
|
-
this.editor.keystrokes.listenTo(toolbarView.element);
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
toolbarView.once('render', () => {
|
|
228
|
-
this.focusTracker.add(toolbarView);
|
|
229
|
-
this.editor.keystrokes.listenTo(toolbarView.element);
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
this._focusableToolbarDefinitions.push({ toolbarView, options });
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Registers an extra menu bar element, which could be a single item, a group of items, or a menu containing groups.
|
|
236
|
-
*
|
|
237
|
-
* ```ts
|
|
238
|
-
* // Register a new menu bar item.
|
|
239
|
-
* editor.ui.extendMenuBar( {
|
|
240
|
-
* item: 'menuBar:customFunctionButton',
|
|
241
|
-
* position: 'after:menuBar:bold'
|
|
242
|
-
* } );
|
|
243
|
-
*
|
|
244
|
-
* // Register a new menu bar group.
|
|
245
|
-
* editor.ui.extendMenuBar( {
|
|
246
|
-
* group: {
|
|
247
|
-
* groupId: 'customGroup',
|
|
248
|
-
* items: [
|
|
249
|
-
* 'menuBar:customFunctionButton'
|
|
250
|
-
* ]
|
|
251
|
-
* },
|
|
252
|
-
* position: 'start:help'
|
|
253
|
-
* } );
|
|
254
|
-
*
|
|
255
|
-
* // Register a new menu bar menu.
|
|
256
|
-
* editor.ui.extendMenuBar( {
|
|
257
|
-
* menu: {
|
|
258
|
-
* menuId: 'customMenu',
|
|
259
|
-
* label: 'customMenu',
|
|
260
|
-
* groups: [
|
|
261
|
-
* {
|
|
262
|
-
* groupId: 'customGroup',
|
|
263
|
-
* items: [
|
|
264
|
-
* 'menuBar:customFunctionButton'
|
|
265
|
-
* ]
|
|
266
|
-
* }
|
|
267
|
-
* ]
|
|
268
|
-
* },
|
|
269
|
-
* position: 'after:help'
|
|
270
|
-
* } );
|
|
271
|
-
* ```
|
|
272
|
-
*/
|
|
273
|
-
extendMenuBar(config) {
|
|
274
|
-
this._extraMenuBarElements.push(config);
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Initializes menu bar.
|
|
278
|
-
*/
|
|
279
|
-
initMenuBar(menuBarView) {
|
|
280
|
-
const menuBarViewElement = menuBarView.element;
|
|
281
|
-
this.focusTracker.add(menuBarViewElement);
|
|
282
|
-
this.editor.keystrokes.listenTo(menuBarViewElement);
|
|
283
|
-
const normalizedMenuBarConfig = normalizeMenuBarConfig(this.editor.config.get('menuBar') || {});
|
|
284
|
-
menuBarView.fillFromConfig(normalizedMenuBarConfig, this.componentFactory, this._extraMenuBarElements);
|
|
285
|
-
this.editor.keystrokes.set('Esc', (data, cancel) => {
|
|
286
|
-
if (!menuBarViewElement.contains(this.editor.ui.focusTracker.focusedElement)) {
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
// Bring focus back to where it came from before focusing the toolbar:
|
|
290
|
-
// If it came from outside the engine view (e.g. source editing), move it there.
|
|
291
|
-
if (this._lastFocusedForeignElement) {
|
|
292
|
-
this._lastFocusedForeignElement.focus();
|
|
293
|
-
this._lastFocusedForeignElement = null;
|
|
294
|
-
}
|
|
295
|
-
// Else just focus the view editing.
|
|
296
|
-
else {
|
|
297
|
-
this.editor.editing.view.focus();
|
|
298
|
-
}
|
|
299
|
-
cancel();
|
|
300
|
-
});
|
|
301
|
-
this.editor.keystrokes.set('Alt+F9', (data, cancel) => {
|
|
302
|
-
// If menu bar is already focused do nothing.
|
|
303
|
-
if (menuBarViewElement.contains(this.editor.ui.focusTracker.focusedElement)) {
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
this._saveLastFocusedForeignElement();
|
|
307
|
-
menuBarView.isFocusBorderEnabled = true;
|
|
308
|
-
menuBarView.focus();
|
|
309
|
-
cancel();
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Returns viewport offsets object:
|
|
314
|
-
*
|
|
315
|
-
* ```js
|
|
316
|
-
* {
|
|
317
|
-
* top: Number,
|
|
318
|
-
* right: Number,
|
|
319
|
-
* bottom: Number,
|
|
320
|
-
* left: Number
|
|
321
|
-
* }
|
|
322
|
-
* ```
|
|
323
|
-
*
|
|
324
|
-
* Only top property is currently supported.
|
|
325
|
-
*/
|
|
326
|
-
_readViewportOffsetFromConfig() {
|
|
327
|
-
const editor = this.editor;
|
|
328
|
-
const viewportOffsetConfig = editor.config.get('ui.viewportOffset');
|
|
329
|
-
if (viewportOffsetConfig) {
|
|
330
|
-
return viewportOffsetConfig;
|
|
331
|
-
}
|
|
332
|
-
// Not present in EditorConfig type, because it's legacy. Hence the `as` expression.
|
|
333
|
-
const legacyOffsetConfig = editor.config.get('toolbar.viewportTopOffset');
|
|
334
|
-
// Fall back to deprecated toolbar config.
|
|
335
|
-
if (legacyOffsetConfig) {
|
|
336
|
-
/**
|
|
337
|
-
* The {@link module:core/editor/editorconfig~EditorConfig#toolbar `EditorConfig#toolbar.viewportTopOffset`}
|
|
338
|
-
* property has been deprecated and will be removed in the near future. Please use
|
|
339
|
-
* {@link module:core/editor/editorconfig~EditorConfig#ui `EditorConfig#ui.viewportOffset`} instead.
|
|
340
|
-
*
|
|
341
|
-
* @error editor-ui-deprecated-viewport-offset-config
|
|
342
|
-
*/
|
|
343
|
-
console.warn('editor-ui-deprecated-viewport-offset-config: ' +
|
|
344
|
-
'The `toolbar.vieportTopOffset` configuration option is deprecated. ' +
|
|
345
|
-
'It will be removed from future CKEditor versions. Use `ui.viewportOffset.top` instead.');
|
|
346
|
-
return { top: legacyOffsetConfig };
|
|
347
|
-
}
|
|
348
|
-
// More keys to come in the future.
|
|
349
|
-
return { top: 0 };
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Starts listening for <kbd>Alt</kbd> + <kbd>F10</kbd> and <kbd>Esc</kbd> keystrokes in the context of focusable
|
|
353
|
-
* {@link #setEditableElement editable elements} and {@link #addToolbar toolbars}
|
|
354
|
-
* to allow users navigate across the UI.
|
|
355
|
-
*/
|
|
356
|
-
_initFocusTracking() {
|
|
357
|
-
const editor = this.editor;
|
|
358
|
-
let candidateDefinitions;
|
|
359
|
-
// Focus the next focusable toolbar on <kbd>Alt</kbd> + <kbd>F10</kbd>.
|
|
360
|
-
editor.keystrokes.set('Alt+F10', (data, cancel) => {
|
|
361
|
-
this._saveLastFocusedForeignElement();
|
|
362
|
-
const currentFocusedToolbarDefinition = this._getCurrentFocusedToolbarDefinition();
|
|
363
|
-
// * When focusing a toolbar for the first time, set the array of definitions for successive presses of Alt+F10.
|
|
364
|
-
// This ensures, the navigation works always the same and no pair of toolbars takes over
|
|
365
|
-
// (e.g. image and table toolbars when a selected image is inside a cell).
|
|
366
|
-
// * It could be that the focus went to the toolbar by clicking a toolbar item (e.g. a dropdown). In this case,
|
|
367
|
-
// there were no candidates so they must be obtained (#12339).
|
|
368
|
-
if (!currentFocusedToolbarDefinition || !candidateDefinitions) {
|
|
369
|
-
candidateDefinitions = this._getFocusableCandidateToolbarDefinitions();
|
|
370
|
-
}
|
|
371
|
-
// In a single Alt+F10 press, check all candidates but if none were focused, don't go any further.
|
|
372
|
-
// This prevents an infinite loop.
|
|
373
|
-
for (let i = 0; i < candidateDefinitions.length; i++) {
|
|
374
|
-
const candidateDefinition = candidateDefinitions.shift();
|
|
375
|
-
// Put the first definition to the back of the array. This allows circular navigation over all toolbars
|
|
376
|
-
// on successive presses of Alt+F10.
|
|
377
|
-
candidateDefinitions.push(candidateDefinition);
|
|
378
|
-
// Don't focus the same toolbar again. If you did, this would move focus from the nth focused toolbar item back to the
|
|
379
|
-
// first item as per ToolbarView#focus() if the user navigated inside the toolbar.
|
|
380
|
-
if (candidateDefinition !== currentFocusedToolbarDefinition &&
|
|
381
|
-
this._focusFocusableCandidateToolbar(candidateDefinition)) {
|
|
382
|
-
// Clean up after a current visible toolbar when switching to the next one.
|
|
383
|
-
if (currentFocusedToolbarDefinition && currentFocusedToolbarDefinition.options.afterBlur) {
|
|
384
|
-
currentFocusedToolbarDefinition.options.afterBlur();
|
|
385
|
-
}
|
|
386
|
-
break;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
cancel();
|
|
390
|
-
});
|
|
391
|
-
// Blur the focused toolbar on <kbd>Esc</kbd> and bring the focus back to its origin.
|
|
392
|
-
editor.keystrokes.set('Esc', (data, cancel) => {
|
|
393
|
-
const focusedToolbarDef = this._getCurrentFocusedToolbarDefinition();
|
|
394
|
-
if (!focusedToolbarDef) {
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
// Bring focus back to where it came from before focusing the toolbar:
|
|
398
|
-
// 1. If it came from outside the engine view (e.g. source editing), move it there.
|
|
399
|
-
if (this._lastFocusedForeignElement) {
|
|
400
|
-
this._lastFocusedForeignElement.focus();
|
|
401
|
-
this._lastFocusedForeignElement = null;
|
|
402
|
-
}
|
|
403
|
-
// 2. There are two possibilities left:
|
|
404
|
-
// 2.1. It could be that the focus went from an editable element in the view (root or nested).
|
|
405
|
-
// 2.2. It could be the focus went straight to the toolbar before even focusing the editing area.
|
|
406
|
-
// In either case, just focus the view editing. The focus will land where it belongs.
|
|
407
|
-
else {
|
|
408
|
-
editor.editing.view.focus();
|
|
409
|
-
}
|
|
410
|
-
// Clean up after the toolbar if there is anything to do there.
|
|
411
|
-
if (focusedToolbarDef.options.afterBlur) {
|
|
412
|
-
focusedToolbarDef.options.afterBlur();
|
|
413
|
-
}
|
|
414
|
-
cancel();
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* Saves last focused element that doen not belong to editing view to restore focus on `Esc`.
|
|
419
|
-
*/
|
|
420
|
-
_saveLastFocusedForeignElement() {
|
|
421
|
-
const focusedElement = this.focusTracker.focusedElement;
|
|
422
|
-
// Focus moved out of a DOM element that
|
|
423
|
-
// * is not a toolbar,
|
|
424
|
-
// * does not belong to the editing view (e.g. source editing).
|
|
425
|
-
if (Array.from(this._editableElementsMap.values()).includes(focusedElement) &&
|
|
426
|
-
!Array.from(this.editor.editing.view.domRoots.values()).includes(focusedElement)) {
|
|
427
|
-
this._lastFocusedForeignElement = focusedElement;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Returns definitions of toolbars that could potentially be focused, sorted by their importance for the user.
|
|
432
|
-
*
|
|
433
|
-
* Focusable toolbars candidates are either:
|
|
434
|
-
* * already visible,
|
|
435
|
-
* * have `beforeFocus()` set in their {@link module:ui/editorui/editorui~FocusableToolbarDefinition definition} that suggests that
|
|
436
|
-
* they might show up when called. Keep in mind that determining whether a toolbar will show up (and become focusable) is impossible
|
|
437
|
-
* at this stage because it depends on its implementation, that in turn depends on the editing context (selection).
|
|
438
|
-
*
|
|
439
|
-
* **Note**: Contextual toolbars take precedence over regular toolbars.
|
|
440
|
-
*/
|
|
441
|
-
_getFocusableCandidateToolbarDefinitions() {
|
|
442
|
-
const definitions = [];
|
|
443
|
-
for (const toolbarDef of this._focusableToolbarDefinitions) {
|
|
444
|
-
const { toolbarView, options } = toolbarDef;
|
|
445
|
-
if (isVisible(toolbarView.element) || options.beforeFocus) {
|
|
446
|
-
definitions.push(toolbarDef);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
// Contextual and already visible toolbars have higher priority. If both are true, the toolbar will always focus first.
|
|
450
|
-
// For instance, a selected widget toolbar vs inline editor toolbar: both are visible but the widget toolbar is contextual.
|
|
451
|
-
definitions.sort((defA, defB) => getToolbarDefinitionWeight(defA) - getToolbarDefinitionWeight(defB));
|
|
452
|
-
return definitions;
|
|
453
|
-
}
|
|
454
|
-
/**
|
|
455
|
-
* Returns a definition of the toolbar that is currently visible and focused (one of its children has focus).
|
|
456
|
-
*
|
|
457
|
-
* `null` is returned when no toolbar is currently focused.
|
|
458
|
-
*/
|
|
459
|
-
_getCurrentFocusedToolbarDefinition() {
|
|
460
|
-
for (const definition of this._focusableToolbarDefinitions) {
|
|
461
|
-
if (definition.toolbarView.element && definition.toolbarView.element.contains(this.focusTracker.focusedElement)) {
|
|
462
|
-
return definition;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
return null;
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Focuses a focusable toolbar candidate using its definition.
|
|
469
|
-
*
|
|
470
|
-
* @param candidateToolbarDefinition A definition of the toolbar to focus.
|
|
471
|
-
* @returns `true` when the toolbar candidate was focused. `false` otherwise.
|
|
472
|
-
*/
|
|
473
|
-
_focusFocusableCandidateToolbar(candidateToolbarDefinition) {
|
|
474
|
-
const { toolbarView, options: { beforeFocus } } = candidateToolbarDefinition;
|
|
475
|
-
if (beforeFocus) {
|
|
476
|
-
beforeFocus();
|
|
477
|
-
}
|
|
478
|
-
// If it didn't show up after beforeFocus(), it's not focusable at all.
|
|
479
|
-
if (!isVisible(toolbarView.element)) {
|
|
480
|
-
return false;
|
|
481
|
-
}
|
|
482
|
-
toolbarView.focus();
|
|
483
|
-
return true;
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* Provides an integration between {@link #viewportOffset} and {@link module:utils/dom/scroll~scrollViewportToShowTarget}.
|
|
487
|
-
* It allows the UI-agnostic engine method to consider user-configured viewport offsets specific for the integration.
|
|
488
|
-
*
|
|
489
|
-
* @param evt The `scrollToTheSelection` event info.
|
|
490
|
-
* @param data The payload carried by the `scrollToTheSelection` event.
|
|
491
|
-
*/
|
|
492
|
-
_handleScrollToTheSelection(evt, data) {
|
|
493
|
-
const configuredViewportOffset = {
|
|
494
|
-
top: 0,
|
|
495
|
-
bottom: 0,
|
|
496
|
-
left: 0,
|
|
497
|
-
right: 0,
|
|
498
|
-
...this.viewportOffset
|
|
499
|
-
};
|
|
500
|
-
data.viewportOffset.top += configuredViewportOffset.top;
|
|
501
|
-
data.viewportOffset.bottom += configuredViewportOffset.bottom;
|
|
502
|
-
data.viewportOffset.left += configuredViewportOffset.left;
|
|
503
|
-
data.viewportOffset.right += configuredViewportOffset.right;
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* Ensures that the focus tracker is aware of all views' DOM elements in the body collection.
|
|
507
|
-
*/
|
|
508
|
-
_bindBodyCollectionWithFocusTracker() {
|
|
509
|
-
const body = this.view.body;
|
|
510
|
-
for (const view of body) {
|
|
511
|
-
this.focusTracker.add(view.element);
|
|
512
|
-
}
|
|
513
|
-
body.on('add', (evt, view) => {
|
|
514
|
-
this.focusTracker.add(view.element);
|
|
515
|
-
});
|
|
516
|
-
body.on('remove', (evt, view) => {
|
|
517
|
-
this.focusTracker.remove(view.element);
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* Set initial viewport offset and setup visualTop augmentation.
|
|
522
|
-
*/
|
|
523
|
-
_initViewportOffset(viewportOffsetConfig) {
|
|
524
|
-
// Augment the viewport offset set from outside the editor with the visualTop property.
|
|
525
|
-
this.on('set:viewportOffset', (evt, name, value) => {
|
|
526
|
-
const visualTop = this._getVisualViewportTopOffset(value);
|
|
527
|
-
// Update only if there is a change in a value, so we do not trigger
|
|
528
|
-
// listeners to the viewportOffset observable.
|
|
529
|
-
if (value.visualTop !== visualTop) {
|
|
530
|
-
evt.return = { ...value, visualTop };
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
// Set the initial value after augmenting the setter.
|
|
534
|
-
this.set('viewportOffset', viewportOffsetConfig);
|
|
535
|
-
}
|
|
536
|
-
/**
|
|
537
|
-
* Listen to visual viewport changes and update the viewportOffset with the visualTop property
|
|
538
|
-
* according to the visible part of it (visual viewport).
|
|
539
|
-
*/
|
|
540
|
-
_initVisualViewportSupport() {
|
|
541
|
-
if (!global.window.visualViewport) {
|
|
542
|
-
return;
|
|
543
|
-
}
|
|
544
|
-
const updateViewport = () => {
|
|
545
|
-
const visualTop = this._getVisualViewportTopOffset(this.viewportOffset);
|
|
546
|
-
// Update only if there is a change in a value, so we do not trigger
|
|
547
|
-
// listeners to the viewportOffset observable.
|
|
548
|
-
if (this.viewportOffset.visualTop !== visualTop) {
|
|
549
|
-
this.viewportOffset = { ...this.viewportOffset, visualTop };
|
|
550
|
-
}
|
|
551
|
-
};
|
|
552
|
-
// Listen to the changes in the visual viewport to adjust the visualTop of viewport offset.
|
|
553
|
-
this._domEmitter = new (DomEmitterMixin())();
|
|
554
|
-
this._domEmitter.listenTo(global.window.visualViewport, 'scroll', updateViewport);
|
|
555
|
-
this._domEmitter.listenTo(global.window.visualViewport, 'resize', updateViewport);
|
|
556
|
-
}
|
|
557
|
-
/**
|
|
558
|
-
* Calculate the viewport top offset according to the visible part of it (visual viewport).
|
|
559
|
-
*/
|
|
560
|
-
_getVisualViewportTopOffset(viewportOffset) {
|
|
561
|
-
const visualViewportOffsetTop = getVisualViewportOffset().top;
|
|
562
|
-
const viewportTopOffset = viewportOffset.top || 0;
|
|
563
|
-
return visualViewportOffsetTop > viewportTopOffset ? 0 : viewportTopOffset - visualViewportOffsetTop;
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* Returns a number (weight) for a toolbar definition. Visible toolbars have a higher priority and so do
|
|
568
|
-
* contextual toolbars (displayed in the context of a content, for instance, an image toolbar).
|
|
569
|
-
*
|
|
570
|
-
* A standard invisible toolbar is the heaviest. A visible contextual toolbar is the lightest.
|
|
571
|
-
*
|
|
572
|
-
* @param toolbarDef A toolbar definition to be weighted.
|
|
573
|
-
*/
|
|
574
|
-
function getToolbarDefinitionWeight(toolbarDef) {
|
|
575
|
-
const { toolbarView, options } = toolbarDef;
|
|
576
|
-
let weight = 10;
|
|
577
|
-
// Prioritize already visible toolbars. They should get focused first.
|
|
578
|
-
if (isVisible(toolbarView.element)) {
|
|
579
|
-
weight--;
|
|
580
|
-
}
|
|
581
|
-
// Prioritize contextual toolbars. They are displayed at the selection.
|
|
582
|
-
if (options.isContextual) {
|
|
583
|
-
weight -= 2;
|
|
584
|
-
}
|
|
585
|
-
return weight;
|
|
586
|
-
}
|
|
@@ -1,60 +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/editorui/editoruiview
|
|
7
|
-
*/
|
|
8
|
-
import { View } from '../view.js';
|
|
9
|
-
import { BodyCollection } from './bodycollection.js';
|
|
10
|
-
import '../../theme/components/editorui/editorui.css';
|
|
11
|
-
/**
|
|
12
|
-
* The editor UI view class. Base class for the editor main views.
|
|
13
|
-
*/
|
|
14
|
-
export class EditorUIView extends View {
|
|
15
|
-
/**
|
|
16
|
-
* Collection of the child views, detached from the DOM
|
|
17
|
-
* structure of the editor, like panels, icons etc.
|
|
18
|
-
*/
|
|
19
|
-
body;
|
|
20
|
-
/**
|
|
21
|
-
* Menu bar view instance. Initialized by default in:
|
|
22
|
-
*
|
|
23
|
-
* * balloon editor;
|
|
24
|
-
* * decoupled editor;
|
|
25
|
-
* * multiroot editor.
|
|
26
|
-
*/
|
|
27
|
-
menuBarView;
|
|
28
|
-
/**
|
|
29
|
-
* Toolbar view instance. Initialized by default in:
|
|
30
|
-
*
|
|
31
|
-
* * classic editor;
|
|
32
|
-
* * decoupled editor;
|
|
33
|
-
* * inline editor;
|
|
34
|
-
* * multiroot editor.
|
|
35
|
-
*/
|
|
36
|
-
toolbar;
|
|
37
|
-
/**
|
|
38
|
-
* Creates an instance of the editor UI view class.
|
|
39
|
-
*
|
|
40
|
-
* @param locale The locale instance.
|
|
41
|
-
*/
|
|
42
|
-
constructor(locale) {
|
|
43
|
-
super(locale);
|
|
44
|
-
this.body = new BodyCollection(locale);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* @inheritDoc
|
|
48
|
-
*/
|
|
49
|
-
render() {
|
|
50
|
-
super.render();
|
|
51
|
-
this.body.attachToDom();
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @inheritDoc
|
|
55
|
-
*/
|
|
56
|
-
destroy() {
|
|
57
|
-
this.body.detachFromDom();
|
|
58
|
-
return super.destroy();
|
|
59
|
-
}
|
|
60
|
-
}
|