@ckeditor/ckeditor5-ui 0.0.0-internal-20241017.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/CHANGELOG.md +4 -0
- package/LICENSE.md +21 -0
- package/README.md +26 -0
- package/ckeditor5-metadata.json +25 -0
- package/dist/arialiveannouncer.d.ts +113 -0
- package/dist/augmentation.d.ts +92 -0
- package/dist/autocomplete/autocompleteview.d.ts +85 -0
- package/dist/badge/badge.d.ts +133 -0
- package/dist/bindings/addkeyboardhandlingforgrid.d.ts +31 -0
- package/dist/bindings/clickoutsidehandler.d.ts +34 -0
- package/dist/bindings/csstransitiondisablermixin.d.ts +44 -0
- package/dist/bindings/draggableviewmixin.d.ts +50 -0
- package/dist/bindings/injectcsstransitiondisabler.d.ts +63 -0
- package/dist/bindings/preventdefault.d.ts +37 -0
- package/dist/bindings/submithandler.d.ts +61 -0
- package/dist/button/button.d.ts +179 -0
- package/dist/button/buttonlabel.d.ts +38 -0
- package/dist/button/buttonlabelview.d.ts +35 -0
- package/dist/button/buttonview.d.ts +201 -0
- package/dist/button/filedialogbuttonview.d.ts +111 -0
- package/dist/button/listitembuttonview.d.ts +82 -0
- package/dist/button/switchbuttonview.d.ts +49 -0
- package/dist/collapsible/collapsibleview.d.ts +74 -0
- package/dist/colorgrid/colorgridview.d.ts +136 -0
- package/dist/colorgrid/colortileview.d.ts +32 -0
- package/dist/colorgrid/utils.d.ts +51 -0
- package/dist/colorpicker/colorpickerview.d.ts +177 -0
- package/dist/colorpicker/utils.d.ts +52 -0
- package/dist/colorselector/colorgridsfragmentview.d.ts +199 -0
- package/dist/colorselector/colorpickerfragmentview.d.ts +137 -0
- package/dist/colorselector/colorselectorview.d.ts +246 -0
- package/dist/colorselector/documentcolorcollection.d.ts +74 -0
- package/dist/componentfactory.d.ts +85 -0
- package/dist/dialog/dialog.d.ts +281 -0
- package/dist/dialog/dialogactionsview.d.ts +73 -0
- package/dist/dialog/dialogcontentview.d.ts +31 -0
- package/dist/dialog/dialogview.d.ts +260 -0
- package/dist/dropdown/button/dropdownbutton.d.ts +29 -0
- package/dist/dropdown/button/dropdownbuttonview.d.ts +52 -0
- package/dist/dropdown/button/splitbuttonview.d.ts +166 -0
- package/dist/dropdown/dropdownpanelfocusable.d.ts +25 -0
- package/dist/dropdown/dropdownpanelview.d.ts +66 -0
- package/dist/dropdown/dropdownview.d.ts +332 -0
- package/dist/dropdown/menu/dropdownmenubehaviors.d.ts +48 -0
- package/dist/dropdown/menu/dropdownmenubuttonview.d.ts +40 -0
- package/dist/dropdown/menu/dropdownmenulistitembuttonview.d.ts +21 -0
- package/dist/dropdown/menu/dropdownmenulistitemview.d.ts +26 -0
- package/dist/dropdown/menu/dropdownmenulistview.d.ts +28 -0
- package/dist/dropdown/menu/dropdownmenunestedmenupanelview.d.ts +38 -0
- package/dist/dropdown/menu/dropdownmenunestedmenuview.d.ts +135 -0
- package/dist/dropdown/menu/dropdownmenurootlistview.d.ts +144 -0
- package/dist/dropdown/menu/utils.d.ts +128 -0
- package/dist/dropdown/utils.d.ts +297 -0
- package/dist/editableui/editableuiview.d.ts +76 -0
- package/dist/editableui/inline/inlineeditableuiview.d.ts +48 -0
- package/dist/editorui/accessibilityhelp/accessibilityhelp.d.ts +59 -0
- package/dist/editorui/accessibilityhelp/accessibilityhelpcontentview.d.ts +39 -0
- package/dist/editorui/bodycollection.d.ts +59 -0
- package/dist/editorui/boxed/boxededitoruiview.d.ts +44 -0
- package/dist/editorui/editorui.d.ts +358 -0
- package/dist/editorui/editoruiview.d.ts +48 -0
- package/dist/editorui/evaluationbadge.d.ts +37 -0
- package/dist/editorui/poweredby.d.ts +38 -0
- package/dist/focuscycler.d.ts +295 -0
- package/dist/formheader/formheaderview.d.ts +62 -0
- package/dist/highlightedtext/buttonlabelwithhighlightview.d.ts +34 -0
- package/dist/highlightedtext/highlightedtextview.d.ts +42 -0
- package/dist/highlightedtext/labelwithhighlightview.d.ts +30 -0
- package/dist/icon/iconview.d.ts +92 -0
- package/dist/iframe/iframeview.d.ts +54 -0
- package/dist/index-content.css +4 -0
- package/dist/index-editor.css +754 -0
- package/dist/index.css +1063 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +17688 -0
- package/dist/index.js.map +1 -0
- package/dist/input/inputbase.d.ts +123 -0
- package/dist/input/inputview.d.ts +40 -0
- package/dist/inputnumber/inputnumberview.d.ts +53 -0
- package/dist/inputtext/inputtextview.d.ts +22 -0
- package/dist/label/labelview.d.ts +40 -0
- package/dist/labeledfield/labeledfieldview.d.ts +191 -0
- package/dist/labeledfield/utils.d.ts +127 -0
- package/dist/labeledinput/labeledinputview.d.ts +129 -0
- package/dist/list/listitemgroupview.d.ts +63 -0
- package/dist/list/listitemview.d.ts +40 -0
- package/dist/list/listseparatorview.d.ts +22 -0
- package/dist/list/listview.d.ts +128 -0
- package/dist/menubar/menubarmenubuttonview.d.ts +39 -0
- package/dist/menubar/menubarmenulistitembuttonview.d.ts +25 -0
- package/dist/menubar/menubarmenulistitemfiledialogbuttonview.d.ts +27 -0
- package/dist/menubar/menubarmenulistitemview.d.ts +29 -0
- package/dist/menubar/menubarmenulistview.d.ts +33 -0
- package/dist/menubar/menubarmenupanelview.d.ts +57 -0
- package/dist/menubar/menubarmenuview.d.ts +113 -0
- package/dist/menubar/menubarview.d.ts +177 -0
- package/dist/menubar/utils.d.ts +451 -0
- package/dist/model.d.ts +26 -0
- package/dist/notification/notification.d.ts +219 -0
- package/dist/panel/balloon/balloonpanelview.d.ts +701 -0
- package/dist/panel/balloon/contextualballoon.d.ts +313 -0
- package/dist/panel/sticky/stickypanelview.d.ts +160 -0
- package/dist/search/filteredview.d.ts +35 -0
- package/dist/search/filtergroupanditemnames.d.ts +19 -0
- package/dist/search/searchinfoview.d.ts +49 -0
- package/dist/search/searchresultsview.d.ts +58 -0
- package/dist/search/text/searchtextqueryview.d.ts +80 -0
- package/dist/search/text/searchtextview.d.ts +223 -0
- package/dist/spinner/spinnerview.d.ts +29 -0
- package/dist/template.d.ts +946 -0
- package/dist/textarea/textareaview.d.ts +108 -0
- package/dist/toolbar/balloon/balloontoolbar.d.ts +130 -0
- package/dist/toolbar/block/blockbuttonview.d.ts +39 -0
- package/dist/toolbar/block/blocktoolbar.d.ts +175 -0
- package/dist/toolbar/normalizetoolbarconfig.d.ts +44 -0
- package/dist/toolbar/toolbarlinebreakview.d.ts +22 -0
- package/dist/toolbar/toolbarseparatorview.d.ts +22 -0
- package/dist/toolbar/toolbarview.d.ts +271 -0
- package/dist/tooltipmanager.d.ts +192 -0
- package/dist/translations/af.d.ts +8 -0
- package/dist/translations/af.js +5 -0
- package/dist/translations/af.umd.js +11 -0
- package/dist/translations/ar.d.ts +8 -0
- package/dist/translations/ar.js +5 -0
- package/dist/translations/ar.umd.js +11 -0
- package/dist/translations/ast.d.ts +8 -0
- package/dist/translations/ast.js +5 -0
- package/dist/translations/ast.umd.js +11 -0
- package/dist/translations/az.d.ts +8 -0
- package/dist/translations/az.js +5 -0
- package/dist/translations/az.umd.js +11 -0
- package/dist/translations/bg.d.ts +8 -0
- package/dist/translations/bg.js +5 -0
- package/dist/translations/bg.umd.js +11 -0
- package/dist/translations/bn.d.ts +8 -0
- package/dist/translations/bn.js +5 -0
- package/dist/translations/bn.umd.js +11 -0
- package/dist/translations/bs.d.ts +8 -0
- package/dist/translations/bs.js +5 -0
- package/dist/translations/bs.umd.js +11 -0
- package/dist/translations/ca.d.ts +8 -0
- package/dist/translations/ca.js +5 -0
- package/dist/translations/ca.umd.js +11 -0
- package/dist/translations/cs.d.ts +8 -0
- package/dist/translations/cs.js +5 -0
- package/dist/translations/cs.umd.js +11 -0
- package/dist/translations/da.d.ts +8 -0
- package/dist/translations/da.js +5 -0
- package/dist/translations/da.umd.js +11 -0
- package/dist/translations/de-ch.d.ts +8 -0
- package/dist/translations/de-ch.js +5 -0
- package/dist/translations/de-ch.umd.js +11 -0
- package/dist/translations/de.d.ts +8 -0
- package/dist/translations/de.js +5 -0
- package/dist/translations/de.umd.js +11 -0
- package/dist/translations/el.d.ts +8 -0
- package/dist/translations/el.js +5 -0
- package/dist/translations/el.umd.js +11 -0
- package/dist/translations/en-au.d.ts +8 -0
- package/dist/translations/en-au.js +5 -0
- package/dist/translations/en-au.umd.js +11 -0
- package/dist/translations/en-gb.d.ts +8 -0
- package/dist/translations/en-gb.js +5 -0
- package/dist/translations/en-gb.umd.js +11 -0
- package/dist/translations/en.d.ts +8 -0
- package/dist/translations/en.js +5 -0
- package/dist/translations/en.umd.js +11 -0
- package/dist/translations/eo.d.ts +8 -0
- package/dist/translations/eo.js +5 -0
- package/dist/translations/eo.umd.js +11 -0
- package/dist/translations/es-co.d.ts +8 -0
- package/dist/translations/es-co.js +5 -0
- package/dist/translations/es-co.umd.js +11 -0
- package/dist/translations/es.d.ts +8 -0
- package/dist/translations/es.js +5 -0
- package/dist/translations/es.umd.js +11 -0
- package/dist/translations/et.d.ts +8 -0
- package/dist/translations/et.js +5 -0
- package/dist/translations/et.umd.js +11 -0
- package/dist/translations/eu.d.ts +8 -0
- package/dist/translations/eu.js +5 -0
- package/dist/translations/eu.umd.js +11 -0
- package/dist/translations/fa.d.ts +8 -0
- package/dist/translations/fa.js +5 -0
- package/dist/translations/fa.umd.js +11 -0
- package/dist/translations/fi.d.ts +8 -0
- package/dist/translations/fi.js +5 -0
- package/dist/translations/fi.umd.js +11 -0
- package/dist/translations/fr.d.ts +8 -0
- package/dist/translations/fr.js +5 -0
- package/dist/translations/fr.umd.js +11 -0
- package/dist/translations/gl.d.ts +8 -0
- package/dist/translations/gl.js +5 -0
- package/dist/translations/gl.umd.js +11 -0
- package/dist/translations/he.d.ts +8 -0
- package/dist/translations/he.js +5 -0
- package/dist/translations/he.umd.js +11 -0
- package/dist/translations/hi.d.ts +8 -0
- package/dist/translations/hi.js +5 -0
- package/dist/translations/hi.umd.js +11 -0
- package/dist/translations/hr.d.ts +8 -0
- package/dist/translations/hr.js +5 -0
- package/dist/translations/hr.umd.js +11 -0
- package/dist/translations/hu.d.ts +8 -0
- package/dist/translations/hu.js +5 -0
- package/dist/translations/hu.umd.js +11 -0
- package/dist/translations/id.d.ts +8 -0
- package/dist/translations/id.js +5 -0
- package/dist/translations/id.umd.js +11 -0
- package/dist/translations/it.d.ts +8 -0
- package/dist/translations/it.js +5 -0
- package/dist/translations/it.umd.js +11 -0
- package/dist/translations/ja.d.ts +8 -0
- package/dist/translations/ja.js +5 -0
- package/dist/translations/ja.umd.js +11 -0
- package/dist/translations/jv.d.ts +8 -0
- package/dist/translations/jv.js +5 -0
- package/dist/translations/jv.umd.js +11 -0
- package/dist/translations/km.d.ts +8 -0
- package/dist/translations/km.js +5 -0
- package/dist/translations/km.umd.js +11 -0
- package/dist/translations/kn.d.ts +8 -0
- package/dist/translations/kn.js +5 -0
- package/dist/translations/kn.umd.js +11 -0
- package/dist/translations/ko.d.ts +8 -0
- package/dist/translations/ko.js +5 -0
- package/dist/translations/ko.umd.js +11 -0
- package/dist/translations/ku.d.ts +8 -0
- package/dist/translations/ku.js +5 -0
- package/dist/translations/ku.umd.js +11 -0
- package/dist/translations/lt.d.ts +8 -0
- package/dist/translations/lt.js +5 -0
- package/dist/translations/lt.umd.js +11 -0
- package/dist/translations/lv.d.ts +8 -0
- package/dist/translations/lv.js +5 -0
- package/dist/translations/lv.umd.js +11 -0
- package/dist/translations/ms.d.ts +8 -0
- package/dist/translations/ms.js +5 -0
- package/dist/translations/ms.umd.js +11 -0
- package/dist/translations/nb.d.ts +8 -0
- package/dist/translations/nb.js +5 -0
- package/dist/translations/nb.umd.js +11 -0
- package/dist/translations/ne.d.ts +8 -0
- package/dist/translations/ne.js +5 -0
- package/dist/translations/ne.umd.js +11 -0
- package/dist/translations/nl.d.ts +8 -0
- package/dist/translations/nl.js +5 -0
- package/dist/translations/nl.umd.js +11 -0
- package/dist/translations/no.d.ts +8 -0
- package/dist/translations/no.js +5 -0
- package/dist/translations/no.umd.js +11 -0
- package/dist/translations/pl.d.ts +8 -0
- package/dist/translations/pl.js +5 -0
- package/dist/translations/pl.umd.js +11 -0
- package/dist/translations/pt-br.d.ts +8 -0
- package/dist/translations/pt-br.js +5 -0
- package/dist/translations/pt-br.umd.js +11 -0
- package/dist/translations/pt.d.ts +8 -0
- package/dist/translations/pt.js +5 -0
- package/dist/translations/pt.umd.js +11 -0
- package/dist/translations/ro.d.ts +8 -0
- package/dist/translations/ro.js +5 -0
- package/dist/translations/ro.umd.js +11 -0
- package/dist/translations/ru.d.ts +8 -0
- package/dist/translations/ru.js +5 -0
- package/dist/translations/ru.umd.js +11 -0
- package/dist/translations/sk.d.ts +8 -0
- package/dist/translations/sk.js +5 -0
- package/dist/translations/sk.umd.js +11 -0
- package/dist/translations/sl.d.ts +8 -0
- package/dist/translations/sl.js +5 -0
- package/dist/translations/sl.umd.js +11 -0
- package/dist/translations/sq.d.ts +8 -0
- package/dist/translations/sq.js +5 -0
- package/dist/translations/sq.umd.js +11 -0
- package/dist/translations/sr-latn.d.ts +8 -0
- package/dist/translations/sr-latn.js +5 -0
- package/dist/translations/sr-latn.umd.js +11 -0
- package/dist/translations/sr.d.ts +8 -0
- package/dist/translations/sr.js +5 -0
- package/dist/translations/sr.umd.js +11 -0
- package/dist/translations/sv.d.ts +8 -0
- package/dist/translations/sv.js +5 -0
- package/dist/translations/sv.umd.js +11 -0
- package/dist/translations/th.d.ts +8 -0
- package/dist/translations/th.js +5 -0
- package/dist/translations/th.umd.js +11 -0
- package/dist/translations/ti.d.ts +8 -0
- package/dist/translations/ti.js +5 -0
- package/dist/translations/ti.umd.js +11 -0
- package/dist/translations/tk.d.ts +8 -0
- package/dist/translations/tk.js +5 -0
- package/dist/translations/tk.umd.js +11 -0
- package/dist/translations/tr.d.ts +8 -0
- package/dist/translations/tr.js +5 -0
- package/dist/translations/tr.umd.js +11 -0
- package/dist/translations/tt.d.ts +8 -0
- package/dist/translations/tt.js +5 -0
- package/dist/translations/tt.umd.js +11 -0
- package/dist/translations/ug.d.ts +8 -0
- package/dist/translations/ug.js +5 -0
- package/dist/translations/ug.umd.js +11 -0
- package/dist/translations/uk.d.ts +8 -0
- package/dist/translations/uk.js +5 -0
- package/dist/translations/uk.umd.js +11 -0
- package/dist/translations/ur.d.ts +8 -0
- package/dist/translations/ur.js +5 -0
- package/dist/translations/ur.umd.js +11 -0
- package/dist/translations/uz.d.ts +8 -0
- package/dist/translations/uz.js +5 -0
- package/dist/translations/uz.umd.js +11 -0
- package/dist/translations/vi.d.ts +8 -0
- package/dist/translations/vi.js +5 -0
- package/dist/translations/vi.umd.js +11 -0
- package/dist/translations/zh-cn.d.ts +8 -0
- package/dist/translations/zh-cn.js +5 -0
- package/dist/translations/zh-cn.umd.js +11 -0
- package/dist/translations/zh.d.ts +8 -0
- package/dist/translations/zh.js +5 -0
- package/dist/translations/zh.umd.js +11 -0
- package/dist/view.d.ts +426 -0
- package/dist/viewcollection.d.ts +143 -0
- package/lang/contexts.json +51 -0
- package/lang/translations/af.po +214 -0
- package/lang/translations/ar.po +214 -0
- package/lang/translations/ast.po +214 -0
- package/lang/translations/az.po +214 -0
- package/lang/translations/bg.po +214 -0
- package/lang/translations/bn.po +214 -0
- package/lang/translations/bs.po +214 -0
- package/lang/translations/ca.po +214 -0
- package/lang/translations/cs.po +214 -0
- package/lang/translations/da.po +214 -0
- package/lang/translations/de-ch.po +214 -0
- package/lang/translations/de.po +214 -0
- package/lang/translations/el.po +214 -0
- package/lang/translations/en-au.po +214 -0
- package/lang/translations/en-gb.po +214 -0
- package/lang/translations/en.po +214 -0
- package/lang/translations/eo.po +214 -0
- package/lang/translations/es-co.po +214 -0
- package/lang/translations/es.po +214 -0
- package/lang/translations/et.po +214 -0
- package/lang/translations/eu.po +214 -0
- package/lang/translations/fa.po +214 -0
- package/lang/translations/fi.po +214 -0
- package/lang/translations/fr.po +214 -0
- package/lang/translations/gl.po +214 -0
- package/lang/translations/he.po +214 -0
- package/lang/translations/hi.po +214 -0
- package/lang/translations/hr.po +214 -0
- package/lang/translations/hu.po +214 -0
- package/lang/translations/id.po +214 -0
- package/lang/translations/it.po +214 -0
- package/lang/translations/ja.po +214 -0
- package/lang/translations/jv.po +214 -0
- package/lang/translations/km.po +214 -0
- package/lang/translations/kn.po +214 -0
- package/lang/translations/ko.po +214 -0
- package/lang/translations/ku.po +214 -0
- package/lang/translations/lt.po +214 -0
- package/lang/translations/lv.po +214 -0
- package/lang/translations/ms.po +214 -0
- package/lang/translations/nb.po +214 -0
- package/lang/translations/ne.po +214 -0
- package/lang/translations/nl.po +214 -0
- package/lang/translations/no.po +214 -0
- package/lang/translations/pl.po +214 -0
- package/lang/translations/pt-br.po +214 -0
- package/lang/translations/pt.po +214 -0
- package/lang/translations/ro.po +214 -0
- package/lang/translations/ru.po +214 -0
- package/lang/translations/sk.po +214 -0
- package/lang/translations/sl.po +214 -0
- package/lang/translations/sq.po +214 -0
- package/lang/translations/sr-latn.po +214 -0
- package/lang/translations/sr.po +214 -0
- package/lang/translations/sv.po +214 -0
- package/lang/translations/th.po +214 -0
- package/lang/translations/ti.po +214 -0
- package/lang/translations/tk.po +214 -0
- package/lang/translations/tr.po +214 -0
- package/lang/translations/tt.po +214 -0
- package/lang/translations/ug.po +214 -0
- package/lang/translations/uk.po +214 -0
- package/lang/translations/ur.po +214 -0
- package/lang/translations/uz.po +214 -0
- package/lang/translations/vi.po +214 -0
- package/lang/translations/zh-cn.po +214 -0
- package/lang/translations/zh.po +214 -0
- package/package.json +42 -0
- package/src/arialiveannouncer.d.ts +109 -0
- package/src/arialiveannouncer.js +165 -0
- package/src/augmentation.d.ts +88 -0
- package/src/augmentation.js +5 -0
- package/src/autocomplete/autocompleteview.d.ts +81 -0
- package/src/autocomplete/autocompleteview.js +154 -0
- package/src/badge/badge.d.ts +129 -0
- package/src/badge/badge.js +218 -0
- package/src/bindings/addkeyboardhandlingforgrid.d.ts +27 -0
- package/src/bindings/addkeyboardhandlingforgrid.js +107 -0
- package/src/bindings/clickoutsidehandler.d.ts +30 -0
- package/src/bindings/clickoutsidehandler.js +37 -0
- package/src/bindings/csstransitiondisablermixin.d.ts +40 -0
- package/src/bindings/csstransitiondisablermixin.js +55 -0
- package/src/bindings/draggableviewmixin.d.ts +46 -0
- package/src/bindings/draggableviewmixin.js +144 -0
- package/src/bindings/injectcsstransitiondisabler.d.ts +59 -0
- package/src/bindings/injectcsstransitiondisabler.js +71 -0
- package/src/bindings/preventdefault.d.ts +33 -0
- package/src/bindings/preventdefault.js +34 -0
- package/src/bindings/submithandler.d.ts +57 -0
- package/src/bindings/submithandler.js +47 -0
- package/src/button/button.d.ts +175 -0
- package/src/button/button.js +5 -0
- package/src/button/buttonlabel.d.ts +34 -0
- package/src/button/buttonlabel.js +5 -0
- package/src/button/buttonlabelview.d.ts +31 -0
- package/src/button/buttonlabelview.js +42 -0
- package/src/button/buttonview.d.ts +197 -0
- package/src/button/buttonview.js +248 -0
- package/src/button/filedialogbuttonview.d.ts +107 -0
- package/src/button/filedialogbuttonview.js +145 -0
- package/src/button/listitembuttonview.d.ts +78 -0
- package/src/button/listitembuttonview.js +129 -0
- package/src/button/switchbuttonview.d.ts +45 -0
- package/src/button/switchbuttonview.js +75 -0
- package/src/collapsible/collapsibleview.d.ts +70 -0
- package/src/collapsible/collapsibleview.js +95 -0
- package/src/colorgrid/colorgridview.d.ts +132 -0
- package/src/colorgrid/colorgridview.js +124 -0
- package/src/colorgrid/colortileview.d.ts +28 -0
- package/src/colorgrid/colortileview.js +42 -0
- package/src/colorgrid/utils.d.ts +47 -0
- package/src/colorgrid/utils.js +84 -0
- package/src/colorpicker/colorpickerview.d.ts +173 -0
- package/src/colorpicker/colorpickerview.js +326 -0
- package/src/colorpicker/utils.d.ts +48 -0
- package/src/colorpicker/utils.js +108 -0
- package/src/colorselector/colorgridsfragmentview.d.ts +195 -0
- package/src/colorselector/colorgridsfragmentview.js +291 -0
- package/src/colorselector/colorpickerfragmentview.d.ts +133 -0
- package/src/colorselector/colorpickerfragmentview.js +212 -0
- package/src/colorselector/colorselectorview.d.ts +242 -0
- package/src/colorselector/colorselectorview.js +257 -0
- package/src/colorselector/documentcolorcollection.d.ts +70 -0
- package/src/colorselector/documentcolorcollection.js +42 -0
- package/src/componentfactory.d.ts +81 -0
- package/src/componentfactory.js +104 -0
- package/src/dialog/dialog.d.ts +277 -0
- package/src/dialog/dialog.js +279 -0
- package/src/dialog/dialogactionsview.d.ts +69 -0
- package/src/dialog/dialogactionsview.js +98 -0
- package/src/dialog/dialogcontentview.d.ts +27 -0
- package/src/dialog/dialogcontentview.js +35 -0
- package/src/dialog/dialogview.d.ts +256 -0
- package/src/dialog/dialogview.js +453 -0
- package/src/dropdown/button/dropdownbutton.d.ts +25 -0
- package/src/dropdown/button/dropdownbutton.js +5 -0
- package/src/dropdown/button/dropdownbuttonview.d.ts +48 -0
- package/src/dropdown/button/dropdownbuttonview.js +66 -0
- package/src/dropdown/button/splitbuttonview.d.ts +162 -0
- package/src/dropdown/button/splitbuttonview.js +154 -0
- package/src/dropdown/dropdownpanelfocusable.d.ts +21 -0
- package/src/dropdown/dropdownpanelfocusable.js +5 -0
- package/src/dropdown/dropdownpanelview.d.ts +62 -0
- package/src/dropdown/dropdownpanelview.js +97 -0
- package/src/dropdown/dropdownview.d.ts +328 -0
- package/src/dropdown/dropdownview.js +380 -0
- package/src/dropdown/menu/dropdownmenubehaviors.d.ts +44 -0
- package/src/dropdown/menu/dropdownmenubehaviors.js +119 -0
- package/src/dropdown/menu/dropdownmenubuttonview.d.ts +36 -0
- package/src/dropdown/menu/dropdownmenubuttonview.js +65 -0
- package/src/dropdown/menu/dropdownmenulistitembuttonview.d.ts +17 -0
- package/src/dropdown/menu/dropdownmenulistitembuttonview.js +29 -0
- package/src/dropdown/menu/dropdownmenulistitemview.d.ts +22 -0
- package/src/dropdown/menu/dropdownmenulistitemview.js +34 -0
- package/src/dropdown/menu/dropdownmenulistview.d.ts +24 -0
- package/src/dropdown/menu/dropdownmenulistview.js +29 -0
- package/src/dropdown/menu/dropdownmenunestedmenupanelview.d.ts +34 -0
- package/src/dropdown/menu/dropdownmenunestedmenupanelview.js +63 -0
- package/src/dropdown/menu/dropdownmenunestedmenuview.d.ts +131 -0
- package/src/dropdown/menu/dropdownmenunestedmenuview.js +191 -0
- package/src/dropdown/menu/dropdownmenurootlistview.d.ts +140 -0
- package/src/dropdown/menu/dropdownmenurootlistview.js +160 -0
- package/src/dropdown/menu/utils.d.ts +124 -0
- package/src/dropdown/menu/utils.js +61 -0
- package/src/dropdown/utils.d.ts +293 -0
- package/src/dropdown/utils.js +562 -0
- package/src/editableui/editableuiview.d.ts +72 -0
- package/src/editableui/editableuiview.js +112 -0
- package/src/editableui/inline/inlineeditableuiview.d.ts +44 -0
- package/src/editableui/inline/inlineeditableuiview.js +71 -0
- package/src/editorui/accessibilityhelp/accessibilityhelp.d.ts +55 -0
- package/src/editorui/accessibilityhelp/accessibilityhelp.js +145 -0
- package/src/editorui/accessibilityhelp/accessibilityhelpcontentview.d.ts +35 -0
- package/src/editorui/accessibilityhelp/accessibilityhelpcontentview.js +112 -0
- package/src/editorui/bodycollection.d.ts +55 -0
- package/src/editorui/bodycollection.js +85 -0
- package/src/editorui/boxed/boxededitoruiview.d.ts +40 -0
- package/src/editorui/boxed/boxededitoruiview.js +81 -0
- package/src/editorui/editorui.d.ts +354 -0
- package/src/editorui/editorui.js +522 -0
- package/src/editorui/editoruiview.d.ts +44 -0
- package/src/editorui/editoruiview.js +38 -0
- package/src/editorui/evaluationbadge.d.ts +33 -0
- package/src/editorui/evaluationbadge.js +99 -0
- package/src/editorui/poweredby.d.ts +34 -0
- package/src/editorui/poweredby.js +127 -0
- package/src/focuscycler.d.ts +291 -0
- package/src/focuscycler.js +352 -0
- package/src/formheader/formheaderview.d.ts +58 -0
- package/src/formheader/formheaderview.js +69 -0
- package/src/highlightedtext/buttonlabelwithhighlightview.d.ts +30 -0
- package/src/highlightedtext/buttonlabelwithhighlightview.js +31 -0
- package/src/highlightedtext/highlightedtextview.d.ts +38 -0
- package/src/highlightedtext/highlightedtextview.js +102 -0
- package/src/highlightedtext/labelwithhighlightview.d.ts +26 -0
- package/src/highlightedtext/labelwithhighlightview.js +33 -0
- package/src/icon/iconview.d.ts +88 -0
- package/src/icon/iconview.js +115 -0
- package/src/iframe/iframeview.d.ts +50 -0
- package/src/iframe/iframeview.js +63 -0
- package/src/index.d.ts +93 -0
- package/src/index.js +90 -0
- package/src/input/inputbase.d.ts +119 -0
- package/src/input/inputbase.js +114 -0
- package/src/input/inputview.d.ts +36 -0
- package/src/input/inputview.js +24 -0
- package/src/inputnumber/inputnumberview.d.ts +49 -0
- package/src/inputnumber/inputnumberview.js +40 -0
- package/src/inputtext/inputtextview.d.ts +18 -0
- package/src/inputtext/inputtextview.js +27 -0
- package/src/label/labelview.d.ts +36 -0
- package/src/label/labelview.js +41 -0
- package/src/labeledfield/labeledfieldview.d.ts +187 -0
- package/src/labeledfield/labeledfieldview.js +157 -0
- package/src/labeledfield/utils.d.ts +123 -0
- package/src/labeledfield/utils.js +176 -0
- package/src/labeledinput/labeledinputview.d.ts +125 -0
- package/src/labeledinput/labeledinputview.js +125 -0
- package/src/list/listitemgroupview.d.ts +59 -0
- package/src/list/listitemgroupview.js +67 -0
- package/src/list/listitemview.d.ts +36 -0
- package/src/list/listitemview.js +42 -0
- package/src/list/listseparatorview.d.ts +18 -0
- package/src/list/listseparatorview.js +28 -0
- package/src/list/listview.d.ts +124 -0
- package/src/list/listview.js +188 -0
- package/src/menubar/menubarmenubuttonview.d.ts +35 -0
- package/src/menubar/menubarmenubuttonview.js +64 -0
- package/src/menubar/menubarmenulistitembuttonview.d.ts +21 -0
- package/src/menubar/menubarmenulistitembuttonview.js +30 -0
- package/src/menubar/menubarmenulistitemfiledialogbuttonview.d.ts +23 -0
- package/src/menubar/menubarmenulistitemfiledialogbuttonview.js +32 -0
- package/src/menubar/menubarmenulistitemview.d.ts +25 -0
- package/src/menubar/menubarmenulistitemview.js +34 -0
- package/src/menubar/menubarmenulistview.d.ts +29 -0
- package/src/menubar/menubarmenulistview.js +72 -0
- package/src/menubar/menubarmenupanelview.d.ts +53 -0
- package/src/menubar/menubarmenupanelview.js +60 -0
- package/src/menubar/menubarmenuview.d.ts +109 -0
- package/src/menubar/menubarmenuview.js +160 -0
- package/src/menubar/menubarview.d.ts +173 -0
- package/src/menubar/menubarview.js +261 -0
- package/src/menubar/utils.d.ts +447 -0
- package/src/menubar/utils.js +1388 -0
- package/src/model.d.ts +22 -0
- package/src/model.js +31 -0
- package/src/notification/notification.d.ts +215 -0
- package/src/notification/notification.js +193 -0
- package/src/panel/balloon/balloonpanelview.d.ts +697 -0
- package/src/panel/balloon/balloonpanelview.js +1055 -0
- package/src/panel/balloon/contextualballoon.d.ts +309 -0
- package/src/panel/balloon/contextualballoon.js +576 -0
- package/src/panel/sticky/stickypanelview.d.ts +156 -0
- package/src/panel/sticky/stickypanelview.js +234 -0
- package/src/search/filteredview.d.ts +31 -0
- package/src/search/filteredview.js +5 -0
- package/src/search/filtergroupanditemnames.d.ts +15 -0
- package/src/search/filtergroupanditemnames.js +38 -0
- package/src/search/searchinfoview.d.ts +45 -0
- package/src/search/searchinfoview.js +59 -0
- package/src/search/searchresultsview.d.ts +54 -0
- package/src/search/searchresultsview.js +65 -0
- package/src/search/text/searchtextqueryview.d.ts +76 -0
- package/src/search/text/searchtextqueryview.js +75 -0
- package/src/search/text/searchtextview.d.ts +219 -0
- package/src/search/text/searchtextview.js +202 -0
- package/src/spinner/spinnerview.d.ts +25 -0
- package/src/spinner/spinnerview.js +38 -0
- package/src/template.d.ts +942 -0
- package/src/template.js +1294 -0
- package/src/textarea/textareaview.d.ts +104 -0
- package/src/textarea/textareaview.js +182 -0
- package/src/toolbar/balloon/balloontoolbar.d.ts +126 -0
- package/src/toolbar/balloon/balloontoolbar.js +324 -0
- package/src/toolbar/block/blockbuttonview.d.ts +35 -0
- package/src/toolbar/block/blockbuttonview.js +41 -0
- package/src/toolbar/block/blocktoolbar.d.ts +171 -0
- package/src/toolbar/block/blocktoolbar.js +492 -0
- package/src/toolbar/normalizetoolbarconfig.d.ts +40 -0
- package/src/toolbar/normalizetoolbarconfig.js +52 -0
- package/src/toolbar/toolbarlinebreakview.d.ts +18 -0
- package/src/toolbar/toolbarlinebreakview.js +28 -0
- package/src/toolbar/toolbarseparatorview.d.ts +18 -0
- package/src/toolbar/toolbarseparatorview.js +28 -0
- package/src/toolbar/toolbarview.d.ts +267 -0
- package/src/toolbar/toolbarview.js +721 -0
- package/src/tooltipmanager.d.ts +188 -0
- package/src/tooltipmanager.js +413 -0
- package/src/view.d.ts +422 -0
- package/src/view.js +396 -0
- package/src/viewcollection.d.ts +139 -0
- package/src/viewcollection.js +206 -0
- package/theme/components/arialiveannouncer/arialiveannouncer.css +14 -0
- package/theme/components/autocomplete/autocomplete.css +22 -0
- package/theme/components/button/button.css +39 -0
- package/theme/components/button/listitembutton.css +48 -0
- package/theme/components/button/switchbutton.css +14 -0
- package/theme/components/collapsible/collapsible.css +10 -0
- package/theme/components/colorgrid/colorgrid.css +8 -0
- package/theme/components/colorpicker/colorpicker.css +34 -0
- package/theme/components/colorselector/colorselector.css +35 -0
- package/theme/components/dialog/dialog.css +39 -0
- package/theme/components/dialog/dialogactions.css +11 -0
- package/theme/components/dropdown/dropdown.css +95 -0
- package/theme/components/dropdown/listdropdown.css +10 -0
- package/theme/components/dropdown/menu/dropdownmenu.css +8 -0
- package/theme/components/dropdown/menu/dropdownmenubutton.css +9 -0
- package/theme/components/dropdown/menu/dropdownmenulistitem.css +10 -0
- package/theme/components/dropdown/menu/dropdownmenulistitembutton.css +10 -0
- package/theme/components/dropdown/menu/dropdownmenupanel.css +11 -0
- package/theme/components/dropdown/splitbutton.css +14 -0
- package/theme/components/dropdown/toolbardropdown.css +20 -0
- package/theme/components/editorui/accessibilityhelp.css +10 -0
- package/theme/components/editorui/editorui.css +10 -0
- package/theme/components/formheader/formheader.css +16 -0
- package/theme/components/highlightedtext/highlightedtext.css +12 -0
- package/theme/components/icon/icon.css +8 -0
- package/theme/components/input/input.css +10 -0
- package/theme/components/label/label.css +12 -0
- package/theme/components/labeledfield/labeledfieldview.css +16 -0
- package/theme/components/labeledinput/labeledinput.css +10 -0
- package/theme/components/list/list.css +26 -0
- package/theme/components/menubar/menubar.css +10 -0
- package/theme/components/menubar/menubarmenu.css +9 -0
- package/theme/components/menubar/menubarmenubutton.css +11 -0
- package/theme/components/menubar/menubarmenulistitem.css +10 -0
- package/theme/components/menubar/menubarmenulistitembutton.css +10 -0
- package/theme/components/menubar/menubarmenupanel.css +62 -0
- package/theme/components/panel/balloonpanel.css +56 -0
- package/theme/components/panel/balloonrotator.css +17 -0
- package/theme/components/panel/fakepanel.css +23 -0
- package/theme/components/panel/stickypanel.css +17 -0
- package/theme/components/responsive-form/responsiveform.css +42 -0
- package/theme/components/search/search.css +43 -0
- package/theme/components/spinner/spinner.css +23 -0
- package/theme/components/textarea/textarea.css +10 -0
- package/theme/components/toolbar/blocktoolbar.css +9 -0
- package/theme/components/toolbar/toolbar.css +58 -0
- package/theme/components/tooltip/tooltip.css +12 -0
- package/theme/globals/_evaluationbadge.css +50 -0
- package/theme/globals/_hidden.css +13 -0
- package/theme/globals/_poweredby.css +72 -0
- package/theme/globals/_transition.css +12 -0
- package/theme/globals/_zindex.css +10 -0
- package/theme/globals/globals.css +10 -0
- package/theme/icons/accessibility.svg +1 -0
- package/theme/icons/color-tile-check.svg +1 -0
- package/theme/icons/dropdown-arrow.svg +1 -0
- package/theme/icons/project-logo.svg +1 -0
- package/theme/mixins/_dir.css +10 -0
- package/theme/mixins/_mediacolors.css +20 -0
- package/theme/mixins/_rwd.css +10 -0
- package/theme/mixins/_unselectable.css +14 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ui/focuscycler
|
|
7
|
+
*/
|
|
8
|
+
import { isVisible, EmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
9
|
+
/**
|
|
10
|
+
* A utility class that helps cycling over {@link module:ui/focuscycler~FocusableView focusable views} in a
|
|
11
|
+
* {@link module:ui/viewcollection~ViewCollection} when the focus is tracked by the
|
|
12
|
+
* {@link module:utils/focustracker~FocusTracker} instance. It helps implementing keyboard
|
|
13
|
+
* navigation in HTML forms, toolbars, lists and the like.
|
|
14
|
+
*
|
|
15
|
+
* To work properly it requires:
|
|
16
|
+
* * a collection of focusable (HTML `tabindex` attribute) views that implement the `focus()` method,
|
|
17
|
+
* * an associated focus tracker to determine which view is focused.
|
|
18
|
+
*
|
|
19
|
+
* A simple cycler setup can look like this:
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* const focusables = new ViewCollection<FocusableView>();
|
|
23
|
+
* const focusTracker = new FocusTracker();
|
|
24
|
+
*
|
|
25
|
+
* // Add focusable views to the focus tracker.
|
|
26
|
+
* focusTracker.add( ... );
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* Then, the cycler can be used manually:
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* const cycler = new FocusCycler( { focusables, focusTracker } );
|
|
33
|
+
*
|
|
34
|
+
* // Will focus the first focusable view in #focusables.
|
|
35
|
+
* cycler.focusFirst();
|
|
36
|
+
*
|
|
37
|
+
* // Will log the next focusable item in #focusables.
|
|
38
|
+
* console.log( cycler.next );
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Alternatively, it can work side by side with the {@link module:utils/keystrokehandler~KeystrokeHandler}:
|
|
42
|
+
*
|
|
43
|
+
* ```ts
|
|
44
|
+
* const keystrokeHandler = new KeystrokeHandler();
|
|
45
|
+
*
|
|
46
|
+
* // Activate the keystroke handler.
|
|
47
|
+
* keystrokeHandler.listenTo( sourceOfEvents );
|
|
48
|
+
*
|
|
49
|
+
* const cycler = new FocusCycler( {
|
|
50
|
+
* focusables, focusTracker, keystrokeHandler,
|
|
51
|
+
* actions: {
|
|
52
|
+
* // When arrowup of arrowleft is detected by the #keystrokeHandler,
|
|
53
|
+
* // focusPrevious() will be called on the cycler.
|
|
54
|
+
* focusPrevious: [ 'arrowup', 'arrowleft' ],
|
|
55
|
+
* }
|
|
56
|
+
* } );
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* Check out the {@glink framework/deep-dive/ui/focus-tracking "Deep dive into focus tracking"} guide to learn more.
|
|
60
|
+
*/
|
|
61
|
+
export default class FocusCycler extends /* #__PURE__ */ EmitterMixin() {
|
|
62
|
+
/**
|
|
63
|
+
* Creates an instance of the focus cycler utility.
|
|
64
|
+
*
|
|
65
|
+
* @param options Configuration options.
|
|
66
|
+
*/
|
|
67
|
+
constructor(options) {
|
|
68
|
+
super();
|
|
69
|
+
this.focusables = options.focusables;
|
|
70
|
+
this.focusTracker = options.focusTracker;
|
|
71
|
+
this.keystrokeHandler = options.keystrokeHandler;
|
|
72
|
+
this.actions = options.actions;
|
|
73
|
+
if (options.actions && options.keystrokeHandler) {
|
|
74
|
+
for (const methodName in options.actions) {
|
|
75
|
+
let actions = options.actions[methodName];
|
|
76
|
+
if (typeof actions == 'string') {
|
|
77
|
+
actions = [actions];
|
|
78
|
+
}
|
|
79
|
+
for (const keystroke of actions) {
|
|
80
|
+
options.keystrokeHandler.set(keystroke, (data, cancel) => {
|
|
81
|
+
this[methodName]();
|
|
82
|
+
cancel();
|
|
83
|
+
}, options.keystrokeHandlerOptions);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
this.on('forwardCycle', () => this.focusFirst(), { priority: 'low' });
|
|
88
|
+
this.on('backwardCycle', () => this.focusLast(), { priority: 'low' });
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Returns the first focusable view in {@link #focusables}.
|
|
92
|
+
* Returns `null` if there is none.
|
|
93
|
+
*
|
|
94
|
+
* **Note**: Hidden views (e.g. with `display: none`) are ignored.
|
|
95
|
+
*/
|
|
96
|
+
get first() {
|
|
97
|
+
return (this.focusables.find(isDomFocusable) || null);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Returns the last focusable view in {@link #focusables}.
|
|
101
|
+
* Returns `null` if there is none.
|
|
102
|
+
*
|
|
103
|
+
* **Note**: Hidden views (e.g. with `display: none`) are ignored.
|
|
104
|
+
*/
|
|
105
|
+
get last() {
|
|
106
|
+
return (this.focusables.filter(isDomFocusable).slice(-1)[0] || null);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Returns the next focusable view in {@link #focusables} based on {@link #current}.
|
|
110
|
+
* Returns `null` if there is none.
|
|
111
|
+
*
|
|
112
|
+
* **Note**: Hidden views (e.g. with `display: none`) are ignored.
|
|
113
|
+
*/
|
|
114
|
+
get next() {
|
|
115
|
+
return this._getDomFocusableItem(1);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Returns the previous focusable view in {@link #focusables} based on {@link #current}.
|
|
119
|
+
* Returns `null` if there is none.
|
|
120
|
+
*
|
|
121
|
+
* **Note**: Hidden views (e.g. with `display: none`) are ignored.
|
|
122
|
+
*/
|
|
123
|
+
get previous() {
|
|
124
|
+
return this._getDomFocusableItem(-1);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* An index of the view in the {@link #focusables} which is focused according
|
|
128
|
+
* to {@link #focusTracker}. Returns `null` when there is no such view.
|
|
129
|
+
*/
|
|
130
|
+
get current() {
|
|
131
|
+
let index = null;
|
|
132
|
+
// There's no focused view in the focusables.
|
|
133
|
+
if (this.focusTracker.focusedElement === null) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
this.focusables.find((view, viewIndex) => {
|
|
137
|
+
const focused = view.element === this.focusTracker.focusedElement;
|
|
138
|
+
if (focused) {
|
|
139
|
+
index = viewIndex;
|
|
140
|
+
}
|
|
141
|
+
return focused;
|
|
142
|
+
});
|
|
143
|
+
return index;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Focuses the {@link #first} item in {@link #focusables}.
|
|
147
|
+
*
|
|
148
|
+
* **Note**: Hidden views (e.g. with `display: none`) are ignored.
|
|
149
|
+
*/
|
|
150
|
+
focusFirst() {
|
|
151
|
+
this._focus(this.first, 1);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Focuses the {@link #last} item in {@link #focusables}.
|
|
155
|
+
*
|
|
156
|
+
* **Note**: Hidden views (e.g. with `display: none`) are ignored.
|
|
157
|
+
*/
|
|
158
|
+
focusLast() {
|
|
159
|
+
this._focus(this.last, -1);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Focuses the {@link #next} item in {@link #focusables}.
|
|
163
|
+
*
|
|
164
|
+
* **Note**: Hidden views (e.g. with `display: none`) are ignored.
|
|
165
|
+
*/
|
|
166
|
+
focusNext() {
|
|
167
|
+
const next = this.next;
|
|
168
|
+
// If there's only one focusable item, we need to let the outside world know
|
|
169
|
+
// that the next cycle is about to happen. This may be useful
|
|
170
|
+
// e.g. if you want to move the focus to the parent focus cycler.
|
|
171
|
+
// Note that the focus is not actually moved in this case.
|
|
172
|
+
if (next && this.focusables.getIndex(next) === this.current) {
|
|
173
|
+
this.fire('forwardCycle');
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (next === this.first) {
|
|
177
|
+
this.fire('forwardCycle');
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
this._focus(next, 1);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Focuses the {@link #previous} item in {@link #focusables}.
|
|
185
|
+
*
|
|
186
|
+
* **Note**: Hidden views (e.g. with `display: none`) are ignored.
|
|
187
|
+
*/
|
|
188
|
+
focusPrevious() {
|
|
189
|
+
const previous = this.previous;
|
|
190
|
+
if (previous && this.focusables.getIndex(previous) === this.current) {
|
|
191
|
+
this.fire('backwardCycle');
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (previous === this.last) {
|
|
195
|
+
this.fire('backwardCycle');
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
this._focus(previous, -1);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Allows for creating continuous focus cycling across multiple focus cyclers and their collections of {@link #focusables}.
|
|
203
|
+
*
|
|
204
|
+
* It starts listening to the {@link module:ui/focuscycler~FocusCyclerForwardCycleEvent} and
|
|
205
|
+
* {@link module:ui/focuscycler~FocusCyclerBackwardCycleEvent} events of the chained focus cycler and engages,
|
|
206
|
+
* whenever the user reaches the last (forwards navigation) or first (backwards navigation) focusable view
|
|
207
|
+
* and would normally start over. Instead, the navigation continues on the higher level (flattens).
|
|
208
|
+
*
|
|
209
|
+
* For instance, for the following nested focus navigation structure, the focus would get stuck the moment
|
|
210
|
+
* the AB gets focused and its focus cycler starts managing it:
|
|
211
|
+
*
|
|
212
|
+
* ┌────────────┐ ┌──────────────────────────────────┐ ┌────────────┐
|
|
213
|
+
* │ AA │ │ AB │ │ AC │
|
|
214
|
+
* │ │ │ │ │ │
|
|
215
|
+
* │ │ │ ┌─────┐ ┌─────┐ ┌─────┐ │ │ │
|
|
216
|
+
* │ │ │ ┌──► ABA ├──► ABB ├──► ABC ├───┐ │ │ │
|
|
217
|
+
* │ ├───► │ └─────┘ └─────┘ └─────┘ │ │ │ │
|
|
218
|
+
* │ │ │ │ │ │ │ │
|
|
219
|
+
* │ │ │ │ │ │ │ │
|
|
220
|
+
* │ │ │ └──────────────────────────────┘ │ │ │
|
|
221
|
+
* │ │ │ │ │ │
|
|
222
|
+
* └────────────┘ └──────────────────────────────────┘ └────────────┘
|
|
223
|
+
*
|
|
224
|
+
* Chaining a focus tracker that manages AA, AB, and AC with the focus tracker that manages ABA, ABB, and ABC
|
|
225
|
+
* creates a seamless navigation experience instead:
|
|
226
|
+
*
|
|
227
|
+
* ┌────────────┐ ┌──────────────────────────────────┐ ┌────────────┐
|
|
228
|
+
* │ AA │ │ AB │ │ AC │
|
|
229
|
+
* │ │ │ │ │ │
|
|
230
|
+
* │ │ │ ┌─────┐ ┌─────┐ ┌─────┐ │ │ │
|
|
231
|
+
* │ │ │ ┌──► ABA ├──► ABB ├──► ABC ├──┐ │ │ │
|
|
232
|
+
* ┌──► ├───┼─┘ └─────┘ └─────┘ └─────┘ └──┼───► ├──┐
|
|
233
|
+
* │ │ │ │ │ │ │ │
|
|
234
|
+
* │ │ │ │ │ │ │ │
|
|
235
|
+
* │ │ │ │ │ │ │ │
|
|
236
|
+
* │ │ │ │ │ │ │ │
|
|
237
|
+
* │ └────────────┘ └──────────────────────────────────┘ └────────────┘ │
|
|
238
|
+
* │ │
|
|
239
|
+
* │ │
|
|
240
|
+
* └──────────────────────────────────────────────────────────────────────────┘
|
|
241
|
+
*
|
|
242
|
+
* See {@link #unchain} to reverse the chaining.
|
|
243
|
+
*/
|
|
244
|
+
chain(chainedFocusCycler) {
|
|
245
|
+
const getCurrentFocusedView = () => {
|
|
246
|
+
// This may happen when one focus cycler does not include focusables of the other (horizontal case).
|
|
247
|
+
if (this.current === null) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
return this.focusables.get(this.current);
|
|
251
|
+
};
|
|
252
|
+
this.listenTo(chainedFocusCycler, 'forwardCycle', evt => {
|
|
253
|
+
const oldCurrent = getCurrentFocusedView();
|
|
254
|
+
this.focusNext();
|
|
255
|
+
// Stop the event propagation only if an attempt at focusing the view actually moved the focus.
|
|
256
|
+
// If not, let the otherFocusCycler handle the event.
|
|
257
|
+
if (oldCurrent !== getCurrentFocusedView()) {
|
|
258
|
+
evt.stop();
|
|
259
|
+
}
|
|
260
|
+
// The priority is critical for cycling across multiple chain levels when there's a single view at some of them only.
|
|
261
|
+
}, { priority: 'low' });
|
|
262
|
+
this.listenTo(chainedFocusCycler, 'backwardCycle', evt => {
|
|
263
|
+
const oldCurrent = getCurrentFocusedView();
|
|
264
|
+
this.focusPrevious();
|
|
265
|
+
// Stop the event propagation only if an attempt at focusing the view actually moved the focus.
|
|
266
|
+
// If not, let the otherFocusCycler handle the event.
|
|
267
|
+
if (oldCurrent !== getCurrentFocusedView()) {
|
|
268
|
+
evt.stop();
|
|
269
|
+
}
|
|
270
|
+
// The priority is critical for cycling across multiple chain levels when there's a single view at some of them only.
|
|
271
|
+
}, { priority: 'low' });
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Reverses a chaining made by {@link #chain}.
|
|
275
|
+
*/
|
|
276
|
+
unchain(otherFocusCycler) {
|
|
277
|
+
this.stopListening(otherFocusCycler);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Focuses the given view if it exists.
|
|
281
|
+
*
|
|
282
|
+
* @param view The view to be focused
|
|
283
|
+
* @param direction The direction of the focus if the view has focusable children.
|
|
284
|
+
* @returns
|
|
285
|
+
*/
|
|
286
|
+
_focus(view, direction) {
|
|
287
|
+
// Don't fire focus events if the view is already focused.
|
|
288
|
+
// Such attempt may occur when cycling with only one focusable item:
|
|
289
|
+
// even though `focusNext()` method returns without changing focus,
|
|
290
|
+
// the `forwardCycle` event is fired, triggering the `focusFirst()` method.
|
|
291
|
+
if (view && this.focusTracker.focusedElement !== view.element) {
|
|
292
|
+
view.focus(direction);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Returns the next or previous focusable view in {@link #focusables} with respect
|
|
297
|
+
* to {@link #current}.
|
|
298
|
+
*
|
|
299
|
+
* @param step Either `1` for checking forward from {@link #current} or `-1` for checking backwards.
|
|
300
|
+
*/
|
|
301
|
+
_getDomFocusableItem(step) {
|
|
302
|
+
// Cache for speed.
|
|
303
|
+
const collectionLength = this.focusables.length;
|
|
304
|
+
if (!collectionLength) {
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
const current = this.current;
|
|
308
|
+
// Start from the beginning if no view is focused.
|
|
309
|
+
// https://github.com/ckeditor/ckeditor5-ui/issues/206
|
|
310
|
+
if (current === null) {
|
|
311
|
+
return this[step === 1 ? 'first' : 'last'];
|
|
312
|
+
}
|
|
313
|
+
// Note: If current is the only focusable view, it will also be returned for the given step.
|
|
314
|
+
let focusableItem = this.focusables.get(current);
|
|
315
|
+
// Cycle in both directions.
|
|
316
|
+
let index = (current + collectionLength + step) % collectionLength;
|
|
317
|
+
do {
|
|
318
|
+
const focusableItemCandidate = this.focusables.get(index);
|
|
319
|
+
if (isDomFocusable(focusableItemCandidate)) {
|
|
320
|
+
focusableItem = focusableItemCandidate;
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
// Cycle in both directions.
|
|
324
|
+
index = (index + collectionLength + step) % collectionLength;
|
|
325
|
+
} while (index !== current);
|
|
326
|
+
return focusableItem;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Checks whether a view can be focused (has `focus()` method and is visible).
|
|
331
|
+
*
|
|
332
|
+
* @param view A view to be checked.
|
|
333
|
+
*/
|
|
334
|
+
function isDomFocusable(view) {
|
|
335
|
+
return isFocusable(view) && isVisible(view.element);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Checks whether a view is {@link ~FocusableView}.
|
|
339
|
+
*
|
|
340
|
+
* @param view A view to be checked.
|
|
341
|
+
*/
|
|
342
|
+
export function isFocusable(view) {
|
|
343
|
+
return !!('focus' in view && typeof view.focus == 'function');
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Checks whether a view is an instance of {@link ~ViewWithFocusCycler}.
|
|
347
|
+
*
|
|
348
|
+
* @param view A view to be checked.
|
|
349
|
+
*/
|
|
350
|
+
export function isViewWithFocusCycler(view) {
|
|
351
|
+
return isFocusable(view) && 'focusCycler' in view && view.focusCycler instanceof FocusCycler;
|
|
352
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ui/formheader/formheaderview
|
|
7
|
+
*/
|
|
8
|
+
import View from '../view.js';
|
|
9
|
+
import type ViewCollection from '../viewcollection.js';
|
|
10
|
+
import IconView from '../icon/iconview.js';
|
|
11
|
+
import type { Locale } from '@ckeditor/ckeditor5-utils';
|
|
12
|
+
import '../../theme/components/formheader/formheader.css';
|
|
13
|
+
/**
|
|
14
|
+
* The class component representing a form header view. It should be used in more advanced forms to
|
|
15
|
+
* describe the main purpose of the form.
|
|
16
|
+
*
|
|
17
|
+
* By default the component contains a bolded label view that has to be set. The label is usually a short (at most 3-word) string.
|
|
18
|
+
* The component can also be extended by any other elements, like: icons, dropdowns, etc.
|
|
19
|
+
*
|
|
20
|
+
* It is used i.a.
|
|
21
|
+
* by {@link module:table/tablecellproperties/ui/tablecellpropertiesview~TableCellPropertiesView}.
|
|
22
|
+
*
|
|
23
|
+
* The latter is an example, where the component has been extended by {@link module:ui/dropdown/dropdownview~DropdownView} view.
|
|
24
|
+
*/
|
|
25
|
+
export default class FormHeaderView extends View {
|
|
26
|
+
/**
|
|
27
|
+
* A collection of header items.
|
|
28
|
+
*/
|
|
29
|
+
readonly children: ViewCollection;
|
|
30
|
+
/**
|
|
31
|
+
* The label of the header.
|
|
32
|
+
*
|
|
33
|
+
* @observable
|
|
34
|
+
*/
|
|
35
|
+
label: string;
|
|
36
|
+
/**
|
|
37
|
+
* An additional CSS class added to the {@link #element}.
|
|
38
|
+
*
|
|
39
|
+
* @observable
|
|
40
|
+
*/
|
|
41
|
+
class: string | null;
|
|
42
|
+
/**
|
|
43
|
+
* The icon view instance. Defined only if icon was passed in the constructor's options.
|
|
44
|
+
*/
|
|
45
|
+
readonly iconView?: IconView;
|
|
46
|
+
/**
|
|
47
|
+
* Creates an instance of the form header class.
|
|
48
|
+
*
|
|
49
|
+
* @param locale The locale instance.
|
|
50
|
+
* @param options.label A label.
|
|
51
|
+
* @param options.class An additional class.
|
|
52
|
+
*/
|
|
53
|
+
constructor(locale: Locale | undefined, options?: {
|
|
54
|
+
label?: string | null;
|
|
55
|
+
class?: string | null;
|
|
56
|
+
icon?: string | null;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ui/formheader/formheaderview
|
|
7
|
+
*/
|
|
8
|
+
import View from '../view.js';
|
|
9
|
+
import IconView from '../icon/iconview.js';
|
|
10
|
+
import '../../theme/components/formheader/formheader.css';
|
|
11
|
+
/**
|
|
12
|
+
* The class component representing a form header view. It should be used in more advanced forms to
|
|
13
|
+
* describe the main purpose of the form.
|
|
14
|
+
*
|
|
15
|
+
* By default the component contains a bolded label view that has to be set. The label is usually a short (at most 3-word) string.
|
|
16
|
+
* The component can also be extended by any other elements, like: icons, dropdowns, etc.
|
|
17
|
+
*
|
|
18
|
+
* It is used i.a.
|
|
19
|
+
* by {@link module:table/tablecellproperties/ui/tablecellpropertiesview~TableCellPropertiesView}.
|
|
20
|
+
*
|
|
21
|
+
* The latter is an example, where the component has been extended by {@link module:ui/dropdown/dropdownview~DropdownView} view.
|
|
22
|
+
*/
|
|
23
|
+
export default class FormHeaderView extends View {
|
|
24
|
+
/**
|
|
25
|
+
* Creates an instance of the form header class.
|
|
26
|
+
*
|
|
27
|
+
* @param locale The locale instance.
|
|
28
|
+
* @param options.label A label.
|
|
29
|
+
* @param options.class An additional class.
|
|
30
|
+
*/
|
|
31
|
+
constructor(locale, options = {}) {
|
|
32
|
+
super(locale);
|
|
33
|
+
const bind = this.bindTemplate;
|
|
34
|
+
this.set('label', options.label || '');
|
|
35
|
+
this.set('class', options.class || null);
|
|
36
|
+
this.children = this.createCollection();
|
|
37
|
+
this.setTemplate({
|
|
38
|
+
tag: 'div',
|
|
39
|
+
attributes: {
|
|
40
|
+
class: [
|
|
41
|
+
'ck',
|
|
42
|
+
'ck-form__header',
|
|
43
|
+
bind.to('class')
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
children: this.children
|
|
47
|
+
});
|
|
48
|
+
if (options.icon) {
|
|
49
|
+
this.iconView = new IconView();
|
|
50
|
+
this.iconView.content = options.icon;
|
|
51
|
+
this.children.add(this.iconView);
|
|
52
|
+
}
|
|
53
|
+
const label = new View(locale);
|
|
54
|
+
label.setTemplate({
|
|
55
|
+
tag: 'h2',
|
|
56
|
+
attributes: {
|
|
57
|
+
class: [
|
|
58
|
+
'ck',
|
|
59
|
+
'ck-form__header__label'
|
|
60
|
+
],
|
|
61
|
+
role: 'presentation'
|
|
62
|
+
},
|
|
63
|
+
children: [
|
|
64
|
+
{ text: bind.to('label') }
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
this.children.add(label);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ui/highlightedtext/buttonlabelwithhighlightview
|
|
7
|
+
*/
|
|
8
|
+
import type ButtonLabel from '../button/buttonlabel.js';
|
|
9
|
+
import HighlightedTextView from './highlightedtextview.js';
|
|
10
|
+
/**
|
|
11
|
+
* A button label view that can highlight a text fragment.
|
|
12
|
+
*/
|
|
13
|
+
export default class ButtonLabelWithHighlightView extends HighlightedTextView implements ButtonLabel {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
style: string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
text: string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
id: string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
constructor();
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
import HighlightedTextView from './highlightedtextview.js';
|
|
6
|
+
/**
|
|
7
|
+
* A button label view that can highlight a text fragment.
|
|
8
|
+
*/
|
|
9
|
+
export default class ButtonLabelWithHighlightView extends HighlightedTextView {
|
|
10
|
+
/**
|
|
11
|
+
* @inheritDoc
|
|
12
|
+
*/
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.set({
|
|
16
|
+
style: undefined,
|
|
17
|
+
text: undefined,
|
|
18
|
+
id: undefined
|
|
19
|
+
});
|
|
20
|
+
const bind = this.bindTemplate;
|
|
21
|
+
this.extendTemplate({
|
|
22
|
+
attributes: {
|
|
23
|
+
class: [
|
|
24
|
+
'ck-button__label'
|
|
25
|
+
],
|
|
26
|
+
style: bind.to('style'),
|
|
27
|
+
id: bind.to('id')
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ui/highlightedtext/highlightedtextview
|
|
7
|
+
*/
|
|
8
|
+
import View from '../view.js';
|
|
9
|
+
import '../../theme/components/highlightedtext/highlightedtext.css';
|
|
10
|
+
/**
|
|
11
|
+
* A class representing a view that displays a text which subset can be highlighted using the
|
|
12
|
+
* {@link #highlightText} method.
|
|
13
|
+
*/
|
|
14
|
+
export default class HighlightedTextView extends View {
|
|
15
|
+
/**
|
|
16
|
+
* The text that can be highlighted using the {@link #highlightText} method.
|
|
17
|
+
*
|
|
18
|
+
* **Note:** When this property changes, the previous highlighting is removed.
|
|
19
|
+
*
|
|
20
|
+
* @observable
|
|
21
|
+
*/
|
|
22
|
+
text: string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Highlights view's {@link #text} according to the specified `RegExp`. If the passed RegExp is `null`, the
|
|
29
|
+
* highlighting is removed
|
|
30
|
+
*
|
|
31
|
+
* @param regExp
|
|
32
|
+
*/
|
|
33
|
+
highlightText(regExp: RegExp | null): void;
|
|
34
|
+
/**
|
|
35
|
+
* Updates element's `innerHTML` with the passed content.
|
|
36
|
+
*/
|
|
37
|
+
private _updateInnerHTML;
|
|
38
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module ui/highlightedtext/highlightedtextview
|
|
7
|
+
*/
|
|
8
|
+
import View from '../view.js';
|
|
9
|
+
import { escape } from 'lodash-es';
|
|
10
|
+
import '../../theme/components/highlightedtext/highlightedtext.css';
|
|
11
|
+
/**
|
|
12
|
+
* A class representing a view that displays a text which subset can be highlighted using the
|
|
13
|
+
* {@link #highlightText} method.
|
|
14
|
+
*/
|
|
15
|
+
export default class HighlightedTextView extends View {
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
this.set('text', undefined);
|
|
22
|
+
this.setTemplate({
|
|
23
|
+
tag: 'span',
|
|
24
|
+
attributes: {
|
|
25
|
+
class: ['ck', 'ck-highlighted-text']
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
this.on('render', () => {
|
|
29
|
+
// Classic setTemplate binding for #text will not work because highlightText() replaces the
|
|
30
|
+
// pre-rendered DOM text node new a new one (and <mark> elements).
|
|
31
|
+
this.on('change:text', () => {
|
|
32
|
+
this._updateInnerHTML(this.text);
|
|
33
|
+
});
|
|
34
|
+
this._updateInnerHTML(this.text);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Highlights view's {@link #text} according to the specified `RegExp`. If the passed RegExp is `null`, the
|
|
39
|
+
* highlighting is removed
|
|
40
|
+
*
|
|
41
|
+
* @param regExp
|
|
42
|
+
*/
|
|
43
|
+
highlightText(regExp) {
|
|
44
|
+
this._updateInnerHTML(markText(this.text || '', regExp));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Updates element's `innerHTML` with the passed content.
|
|
48
|
+
*/
|
|
49
|
+
_updateInnerHTML(newInnerHTML) {
|
|
50
|
+
this.element.innerHTML = newInnerHTML || '';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Replaces `regExp` occurrences with `<mark>` tags in a text.
|
|
55
|
+
*
|
|
56
|
+
* @param text A text to get marked.
|
|
57
|
+
* @param regExp An optional `RegExp`. If not passed, this is a pass-through function.
|
|
58
|
+
* @returns A text with `RegExp` occurrences marked by `<mark>`.
|
|
59
|
+
*/
|
|
60
|
+
function markText(text, regExp) {
|
|
61
|
+
if (!regExp) {
|
|
62
|
+
return escape(text);
|
|
63
|
+
}
|
|
64
|
+
const textParts = [];
|
|
65
|
+
let lastMatchEnd = 0;
|
|
66
|
+
let matchInfo = regExp.exec(text);
|
|
67
|
+
// Iterate over all matches and create an array of text parts. The idea is to mark which parts are query matches
|
|
68
|
+
// so that later on they can be highlighted.
|
|
69
|
+
while (matchInfo !== null) {
|
|
70
|
+
const curMatchStart = matchInfo.index;
|
|
71
|
+
// Detect if there was something between last match and this one.
|
|
72
|
+
if (curMatchStart !== lastMatchEnd) {
|
|
73
|
+
textParts.push({
|
|
74
|
+
text: text.substring(lastMatchEnd, curMatchStart),
|
|
75
|
+
isMatch: false
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
textParts.push({
|
|
79
|
+
text: matchInfo[0],
|
|
80
|
+
isMatch: true
|
|
81
|
+
});
|
|
82
|
+
lastMatchEnd = regExp.lastIndex;
|
|
83
|
+
matchInfo = regExp.exec(text);
|
|
84
|
+
}
|
|
85
|
+
// Your match might not be the last part of a string. Be sure to add any plain text following the last match.
|
|
86
|
+
if (lastMatchEnd !== text.length) {
|
|
87
|
+
textParts.push({
|
|
88
|
+
text: text.substring(lastMatchEnd),
|
|
89
|
+
isMatch: false
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const outputHtml = textParts
|
|
93
|
+
// The entire text should be escaped.
|
|
94
|
+
.map(part => {
|
|
95
|
+
part.text = escape(part.text);
|
|
96
|
+
return part;
|
|
97
|
+
})
|
|
98
|
+
// Only matched text should be wrapped with HTML mark element.
|
|
99
|
+
.map(part => part.isMatch ? `<mark>${part.text}</mark>` : part.text)
|
|
100
|
+
.join('');
|
|
101
|
+
return outputHtml;
|
|
102
|
+
}
|