@ckeditor/ckeditor5-ui 41.3.1 → 41.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index-content.css +4 -0
- package/dist/index-editor.css +497 -0
- package/dist/index.css +942 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +14343 -0
- package/dist/index.js.map +1 -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/types/arialiveannouncer.d.ts +113 -0
- package/dist/types/augmentation.d.ts +92 -0
- package/dist/types/autocomplete/autocompleteview.d.ts +85 -0
- package/dist/types/bindings/addkeyboardhandlingforgrid.d.ts +31 -0
- package/dist/types/bindings/clickoutsidehandler.d.ts +32 -0
- package/dist/types/bindings/csstransitiondisablermixin.d.ts +44 -0
- package/dist/types/bindings/draggableviewmixin.d.ts +50 -0
- package/dist/types/bindings/injectcsstransitiondisabler.d.ts +63 -0
- package/dist/types/bindings/preventdefault.d.ts +37 -0
- package/dist/types/bindings/submithandler.d.ts +61 -0
- package/dist/types/button/button.d.ts +185 -0
- package/dist/types/button/buttonlabel.d.ts +38 -0
- package/dist/types/button/buttonlabelview.d.ts +35 -0
- package/dist/types/button/buttonview.d.ts +189 -0
- package/dist/types/button/filedialogbuttonview.d.ts +84 -0
- package/dist/types/button/switchbuttonview.d.ts +49 -0
- package/dist/types/collapsible/collapsibleview.d.ts +74 -0
- package/dist/types/colorgrid/colorgridview.d.ts +136 -0
- package/dist/types/colorgrid/colortileview.d.ts +32 -0
- package/dist/types/colorgrid/utils.d.ts +51 -0
- package/dist/types/colorpicker/colorpickerview.d.ts +177 -0
- package/dist/types/colorpicker/utils.d.ts +52 -0
- package/dist/types/colorselector/colorgridsfragmentview.d.ts +199 -0
- package/dist/types/colorselector/colorpickerfragmentview.d.ts +137 -0
- package/dist/types/colorselector/colorselectorview.d.ts +246 -0
- package/dist/types/colorselector/documentcolorcollection.d.ts +74 -0
- package/dist/types/componentfactory.d.ts +85 -0
- package/dist/types/dialog/dialog.d.ts +277 -0
- package/dist/types/dialog/dialogactionsview.d.ts +73 -0
- package/dist/types/dialog/dialogcontentview.d.ts +31 -0
- package/dist/types/dialog/dialogview.d.ts +260 -0
- package/dist/types/dropdown/button/dropdownbutton.d.ts +29 -0
- package/dist/types/dropdown/button/dropdownbuttonview.d.ts +52 -0
- package/dist/types/dropdown/button/splitbuttonview.d.ts +166 -0
- package/dist/types/dropdown/dropdownpanelfocusable.d.ts +25 -0
- package/dist/types/dropdown/dropdownpanelview.d.ts +66 -0
- package/dist/types/dropdown/dropdownview.d.ts +319 -0
- package/dist/types/dropdown/utils.d.ts +239 -0
- package/dist/types/editableui/editableuiview.d.ts +76 -0
- package/dist/types/editableui/inline/inlineeditableuiview.d.ts +44 -0
- package/dist/types/editorui/accessibilityhelp/accessibilityhelp.d.ts +55 -0
- package/dist/types/editorui/accessibilityhelp/accessibilityhelpcontentview.d.ts +39 -0
- package/dist/types/editorui/bodycollection.d.ts +59 -0
- package/dist/types/editorui/boxed/boxededitoruiview.d.ts +44 -0
- package/dist/types/editorui/editorui.d.ts +292 -0
- package/dist/types/editorui/editoruiview.d.ts +43 -0
- package/dist/types/editorui/poweredby.d.ts +75 -0
- package/dist/types/focuscycler.d.ts +249 -0
- package/dist/types/formheader/formheaderview.d.ts +63 -0
- package/dist/types/highlightedtext/highlightedtextview.d.ts +42 -0
- package/dist/types/icon/iconview.d.ts +92 -0
- package/dist/types/iframe/iframeview.d.ts +54 -0
- package/dist/types/index.d.ts +87 -0
- package/dist/types/input/inputbase.d.ts +123 -0
- package/dist/types/input/inputview.d.ts +40 -0
- package/dist/types/inputnumber/inputnumberview.d.ts +53 -0
- package/dist/types/inputtext/inputtextview.d.ts +22 -0
- package/dist/types/label/labelview.d.ts +40 -0
- package/dist/types/labeledfield/labeledfieldview.d.ts +191 -0
- package/dist/types/labeledfield/utils.d.ts +127 -0
- package/dist/types/labeledinput/labeledinputview.d.ts +129 -0
- package/dist/types/list/listitemgroupview.d.ts +63 -0
- package/dist/types/list/listitemview.d.ts +40 -0
- package/dist/types/list/listseparatorview.d.ts +22 -0
- package/dist/types/list/listview.d.ts +128 -0
- package/dist/types/menubar/menubarmenubuttonview.d.ts +39 -0
- package/dist/types/menubar/menubarmenulistitembuttonview.d.ts +25 -0
- package/dist/types/menubar/menubarmenulistitemfiledialogbuttonview.d.ts +27 -0
- package/dist/types/menubar/menubarmenulistitemview.d.ts +29 -0
- package/dist/types/menubar/menubarmenulistview.d.ts +28 -0
- package/dist/types/menubar/menubarmenupanelview.d.ts +57 -0
- package/dist/types/menubar/menubarmenuview.d.ts +113 -0
- package/dist/types/menubar/menubarview.d.ts +168 -0
- package/dist/types/menubar/utils.d.ts +443 -0
- package/dist/types/model.d.ts +26 -0
- package/dist/types/notification/notification.d.ts +215 -0
- package/dist/types/panel/balloon/balloonpanelview.d.ts +689 -0
- package/dist/types/panel/balloon/contextualballoon.d.ts +303 -0
- package/dist/types/panel/sticky/stickypanelview.d.ts +160 -0
- package/dist/types/search/filteredview.d.ts +35 -0
- package/dist/types/search/searchinfoview.d.ts +49 -0
- package/dist/types/search/searchresultsview.d.ts +58 -0
- package/dist/types/search/text/searchtextqueryview.d.ts +80 -0
- package/dist/types/search/text/searchtextview.d.ts +223 -0
- package/dist/types/spinner/spinnerview.d.ts +29 -0
- package/dist/types/template.d.ts +946 -0
- package/dist/types/textarea/textareaview.d.ts +108 -0
- package/dist/types/toolbar/balloon/balloontoolbar.d.ts +121 -0
- package/dist/types/toolbar/block/blockbuttonview.d.ts +39 -0
- package/dist/types/toolbar/block/blocktoolbar.d.ts +157 -0
- package/dist/types/toolbar/normalizetoolbarconfig.d.ts +44 -0
- package/dist/types/toolbar/toolbarlinebreakview.d.ts +22 -0
- package/dist/types/toolbar/toolbarseparatorview.d.ts +22 -0
- package/dist/types/toolbar/toolbarview.d.ts +271 -0
- package/dist/types/tooltipmanager.d.ts +199 -0
- package/dist/types/view.d.ts +426 -0
- package/dist/types/viewcollection.d.ts +143 -0
- package/lang/contexts.json +2 -1
- package/lang/translations/af.po +4 -0
- package/lang/translations/ar.po +4 -0
- package/lang/translations/ast.po +4 -0
- package/lang/translations/az.po +4 -0
- package/lang/translations/bg.po +4 -0
- package/lang/translations/bn.po +4 -0
- package/lang/translations/bs.po +4 -0
- package/lang/translations/ca.po +4 -0
- package/lang/translations/cs.po +4 -0
- package/lang/translations/da.po +4 -0
- package/lang/translations/de-ch.po +4 -0
- package/lang/translations/de.po +4 -0
- package/lang/translations/el.po +4 -0
- package/lang/translations/en-au.po +4 -0
- package/lang/translations/en-gb.po +4 -0
- package/lang/translations/en.po +4 -0
- package/lang/translations/eo.po +4 -0
- package/lang/translations/es-co.po +4 -0
- package/lang/translations/es.po +4 -0
- package/lang/translations/et.po +4 -0
- package/lang/translations/eu.po +4 -0
- package/lang/translations/fa.po +4 -0
- package/lang/translations/fi.po +4 -0
- package/lang/translations/fr.po +4 -0
- package/lang/translations/gl.po +4 -0
- package/lang/translations/he.po +4 -0
- package/lang/translations/hi.po +4 -0
- package/lang/translations/hr.po +4 -0
- package/lang/translations/hu.po +4 -0
- package/lang/translations/id.po +4 -0
- package/lang/translations/it.po +4 -0
- package/lang/translations/ja.po +4 -0
- package/lang/translations/jv.po +4 -0
- package/lang/translations/km.po +4 -0
- package/lang/translations/kn.po +4 -0
- package/lang/translations/ko.po +4 -0
- package/lang/translations/ku.po +4 -0
- package/lang/translations/lt.po +4 -0
- package/lang/translations/lv.po +4 -0
- package/lang/translations/ms.po +4 -0
- package/lang/translations/nb.po +4 -0
- package/lang/translations/ne.po +4 -0
- package/lang/translations/nl.po +4 -0
- package/lang/translations/no.po +4 -0
- package/lang/translations/pl.po +4 -0
- package/lang/translations/pt-br.po +4 -0
- package/lang/translations/pt.po +4 -0
- package/lang/translations/ro.po +4 -0
- package/lang/translations/ru.po +4 -0
- package/lang/translations/sk.po +4 -0
- package/lang/translations/sl.po +4 -0
- package/lang/translations/sq.po +4 -0
- package/lang/translations/sr-latn.po +4 -0
- package/lang/translations/sr.po +4 -0
- package/lang/translations/sv.po +4 -0
- package/lang/translations/th.po +4 -0
- package/lang/translations/ti.po +214 -0
- package/lang/translations/tk.po +4 -0
- package/lang/translations/tr.po +4 -0
- package/lang/translations/tt.po +4 -0
- package/lang/translations/ug.po +4 -0
- package/lang/translations/uk.po +4 -0
- package/lang/translations/ur.po +4 -0
- package/lang/translations/uz.po +4 -0
- package/lang/translations/vi.po +4 -0
- package/lang/translations/zh-cn.po +4 -0
- package/lang/translations/zh.po +4 -0
- package/package.json +4 -3
- package/src/arialiveannouncer.d.ts +34 -23
- package/src/arialiveannouncer.js +80 -30
- package/src/colorgrid/colortileview.d.ts +1 -1
- package/src/colorgrid/colortileview.js +3 -1
- package/src/colorpicker/colorpickerview.d.ts +32 -1
- package/src/colorpicker/colorpickerview.js +62 -13
- package/src/colorselector/colorpickerfragmentview.d.ts +4 -0
- package/src/colorselector/colorpickerfragmentview.js +13 -5
- package/src/colorselector/colorselectorview.js +1 -0
- package/src/index.d.ts +4 -4
- package/src/index.js +3 -2
- package/src/menubar/utils.d.ts +8 -1
- package/src/menubar/utils.js +26 -2
- package/src/toolbar/toolbarview.js +2 -3
- package/theme/components/arialiveannouncer/arialiveannouncer.css +4 -0
- package/theme/components/tooltip/tooltip.css +4 -0
- package/theme/globals/globals.css +0 -1
- package/theme/mixins/_mediacolors.css +20 -0
- package/theme/globals/_reset.css +0 -13
|
@@ -0,0 +1,246 @@
|
|
|
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
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @module ui/colorselector/colorselectorview
|
|
11
|
+
*/
|
|
12
|
+
import FocusCycler, { type FocusableView } from '../focuscycler.js';
|
|
13
|
+
import View from '../view.js';
|
|
14
|
+
import ViewCollection from '../viewcollection.js';
|
|
15
|
+
import { FocusTracker, KeystrokeHandler, type Locale } from '@ckeditor/ckeditor5-utils';
|
|
16
|
+
import type { ColorPickerViewConfig } from '../colorpicker/utils.js';
|
|
17
|
+
import type { ColorDefinition } from '../colorgrid/colorgridview.js';
|
|
18
|
+
import type { Model } from '@ckeditor/ckeditor5-engine';
|
|
19
|
+
import ColorGridsFragmentView from './colorgridsfragmentview.js';
|
|
20
|
+
import ColorPickerFragmentView from './colorpickerfragmentview.js';
|
|
21
|
+
import '../../theme/components/colorselector/colorselector.css';
|
|
22
|
+
/**
|
|
23
|
+
* The configurable color selector view class. It allows users to select colors from a predefined set of colors as well as from
|
|
24
|
+
* a color picker.
|
|
25
|
+
*
|
|
26
|
+
* This meta-view is is made of two components (fragments):
|
|
27
|
+
*
|
|
28
|
+
* * {@link module:ui/colorselector/colorselectorview~ColorSelectorView#colorGridsFragmentView},
|
|
29
|
+
* * {@link module:ui/colorselector/colorselectorview~ColorSelectorView#colorPickerFragmentView}.
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* const colorDefinitions = [
|
|
33
|
+
* { color: '#000', label: 'Black', options: { hasBorder: false } },
|
|
34
|
+
* { color: 'rgb(255, 255, 255)', label: 'White', options: { hasBorder: true } },
|
|
35
|
+
* { color: 'red', label: 'Red', options: { hasBorder: false } }
|
|
36
|
+
* ];
|
|
37
|
+
*
|
|
38
|
+
* const selectorView = new ColorSelectorView( locale, {
|
|
39
|
+
* colors: colorDefinitions,
|
|
40
|
+
* columns: 5,
|
|
41
|
+
* removeButtonLabel: 'Remove color',
|
|
42
|
+
* documentColorsLabel: 'Document colors',
|
|
43
|
+
* documentColorsCount: 4,
|
|
44
|
+
* colorPickerViewConfig: {
|
|
45
|
+
* format: 'hsl'
|
|
46
|
+
* }
|
|
47
|
+
* } );
|
|
48
|
+
*
|
|
49
|
+
* selectorView.appendUI();
|
|
50
|
+
* selectorView.selectedColor = 'red';
|
|
51
|
+
* selectorView.updateSelectedColors();
|
|
52
|
+
*
|
|
53
|
+
* selectorView.on<ColorSelectorExecuteEvent>( 'execute', ( evt, data ) => {
|
|
54
|
+
* console.log( 'Color changed', data.value, data.source );
|
|
55
|
+
* } );
|
|
56
|
+
*
|
|
57
|
+
* selectorView.on<ColorSelectorColorPickerShowEvent>( 'colorPicker:show', ( evt ) => {
|
|
58
|
+
* console.log( 'Color picker showed up', evt );
|
|
59
|
+
* } );
|
|
60
|
+
*
|
|
61
|
+
* selectorView.on<ColorSelectorColorPickerCancelEvent>( 'colorPicker:cancel', ( evt ) => {
|
|
62
|
+
* console.log( 'Color picker cancel', evt );
|
|
63
|
+
* } );
|
|
64
|
+
*
|
|
65
|
+
* selectorView.render();
|
|
66
|
+
*
|
|
67
|
+
* document.body.appendChild( selectorView.element );
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export default class ColorSelectorView extends View {
|
|
71
|
+
/**
|
|
72
|
+
* Tracks information about the DOM focus in the list.
|
|
73
|
+
*/
|
|
74
|
+
readonly focusTracker: FocusTracker;
|
|
75
|
+
/**
|
|
76
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
77
|
+
*/
|
|
78
|
+
readonly keystrokes: KeystrokeHandler;
|
|
79
|
+
/**
|
|
80
|
+
* A collection of components.
|
|
81
|
+
*/
|
|
82
|
+
readonly items: ViewCollection;
|
|
83
|
+
/**
|
|
84
|
+
* A fragment that allows users to select colors from the a predefined set and from existing document colors.
|
|
85
|
+
*/
|
|
86
|
+
readonly colorGridsFragmentView: ColorGridsFragmentView;
|
|
87
|
+
/**
|
|
88
|
+
* A fragment that allows users to select a color from a color picker.
|
|
89
|
+
*/
|
|
90
|
+
readonly colorPickerFragmentView: ColorPickerFragmentView;
|
|
91
|
+
/**
|
|
92
|
+
* Keeps the value of the command associated with the component for the current selection.
|
|
93
|
+
*/
|
|
94
|
+
selectedColor?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Reflects the visibility state of the color grids fragment.
|
|
97
|
+
*
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
_isColorGridsFragmentVisible: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Reflects the visibility state of the color picker fragment.
|
|
103
|
+
*
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
_isColorPickerFragmentVisible: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Helps cycling over focusable {@link #items} in the list.
|
|
109
|
+
*
|
|
110
|
+
* @readonly
|
|
111
|
+
*/
|
|
112
|
+
protected _focusCycler: FocusCycler;
|
|
113
|
+
/**
|
|
114
|
+
* A collection of views that can be focused in the view.
|
|
115
|
+
*
|
|
116
|
+
* @readonly
|
|
117
|
+
*/
|
|
118
|
+
protected _focusables: ViewCollection<FocusableView>;
|
|
119
|
+
/**
|
|
120
|
+
* The configuration of color picker sub-component.
|
|
121
|
+
*/
|
|
122
|
+
private _colorPickerViewConfig;
|
|
123
|
+
/**
|
|
124
|
+
* Creates a view to be inserted as a child of {@link module:ui/dropdown/dropdownview~DropdownView}.
|
|
125
|
+
*
|
|
126
|
+
* @param locale The localization services instance.
|
|
127
|
+
* @param colors An array with definitions of colors to be displayed in the table.
|
|
128
|
+
* @param columns The number of columns in the color grid.
|
|
129
|
+
* @param removeButtonLabel The label of the button responsible for removing the color.
|
|
130
|
+
* @param colorPickerLabel The label of the button responsible for color picker appearing.
|
|
131
|
+
* @param documentColorsLabel The label for the section with the document colors.
|
|
132
|
+
* @param documentColorsCount The number of colors in the document colors section inside the color dropdown.
|
|
133
|
+
* @param colorPickerViewConfig The configuration of color picker feature. If set to `false`, the color picker will be hidden.
|
|
134
|
+
*/
|
|
135
|
+
constructor(locale: Locale, { colors, columns, removeButtonLabel, documentColorsLabel, documentColorsCount, colorPickerLabel, colorPickerViewConfig }: {
|
|
136
|
+
colors: Array<ColorDefinition>;
|
|
137
|
+
columns: number;
|
|
138
|
+
removeButtonLabel: string;
|
|
139
|
+
documentColorsLabel?: string;
|
|
140
|
+
documentColorsCount?: number;
|
|
141
|
+
colorPickerLabel: string;
|
|
142
|
+
colorPickerViewConfig: ColorPickerViewConfig | false;
|
|
143
|
+
});
|
|
144
|
+
/**
|
|
145
|
+
* @inheritDoc
|
|
146
|
+
*/
|
|
147
|
+
render(): void;
|
|
148
|
+
/**
|
|
149
|
+
* @inheritDoc
|
|
150
|
+
*/
|
|
151
|
+
destroy(): void;
|
|
152
|
+
/**
|
|
153
|
+
* Renders the internals of the component on demand:
|
|
154
|
+
* * {@link #colorPickerFragmentView},
|
|
155
|
+
* * {@link #colorGridsFragmentView}.
|
|
156
|
+
*
|
|
157
|
+
* It allows for deferring component initialization to improve the performance.
|
|
158
|
+
*
|
|
159
|
+
* See {@link #showColorPickerFragment}, {@link #showColorGridsFragment}.
|
|
160
|
+
*/
|
|
161
|
+
appendUI(): void;
|
|
162
|
+
/**
|
|
163
|
+
* Shows the {@link #colorPickerFragmentView} and hides the {@link #colorGridsFragmentView}.
|
|
164
|
+
*
|
|
165
|
+
* **Note**: It requires {@link #appendUI} to be called first.
|
|
166
|
+
*
|
|
167
|
+
* See {@link #showColorGridsFragment}, {@link ~ColorSelectorView#event:colorPicker:show}.
|
|
168
|
+
*/
|
|
169
|
+
showColorPickerFragment(): void;
|
|
170
|
+
/**
|
|
171
|
+
* Shows the {@link #colorGridsFragmentView} and hides the {@link #colorPickerFragmentView}.
|
|
172
|
+
*
|
|
173
|
+
* See {@link #showColorPickerFragment}.
|
|
174
|
+
*
|
|
175
|
+
* **Note**: It requires {@link #appendUI} to be called first.
|
|
176
|
+
*/
|
|
177
|
+
showColorGridsFragment(): void;
|
|
178
|
+
/**
|
|
179
|
+
* Focuses the first focusable element in {@link #items}.
|
|
180
|
+
*/
|
|
181
|
+
focus(): void;
|
|
182
|
+
/**
|
|
183
|
+
* Focuses the last focusable element in {@link #items}.
|
|
184
|
+
*/
|
|
185
|
+
focusLast(): void;
|
|
186
|
+
/**
|
|
187
|
+
* Scans through the editor model and searches for text node attributes with the given `attributeName`.
|
|
188
|
+
* Found entries are set as document colors in {@link #colorGridsFragmentView}.
|
|
189
|
+
*
|
|
190
|
+
* All the previously stored document colors will be lost in the process.
|
|
191
|
+
*
|
|
192
|
+
* @param model The model used as a source to obtain the document colors.
|
|
193
|
+
* @param attributeName Determines the name of the related model's attribute for a given dropdown.
|
|
194
|
+
*/
|
|
195
|
+
updateDocumentColors(model: Model, attributeName: string): void;
|
|
196
|
+
/**
|
|
197
|
+
* Refreshes the state of the selected color in one or both grids located in {@link #colorGridsFragmentView}.
|
|
198
|
+
*
|
|
199
|
+
* It guarantees that the selection will occur only in one of them.
|
|
200
|
+
*/
|
|
201
|
+
updateSelectedColors(): void;
|
|
202
|
+
/**
|
|
203
|
+
* Appends the view containing static and document color grid views.
|
|
204
|
+
*/
|
|
205
|
+
private _appendColorGridsFragment;
|
|
206
|
+
/**
|
|
207
|
+
* Appends the view with the color picker.
|
|
208
|
+
*/
|
|
209
|
+
private _appendColorPickerFragment;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Fired whenever the color was changed. There are multiple sources of this event and you can distinguish them
|
|
213
|
+
* using the `source` property passed along this event.
|
|
214
|
+
*
|
|
215
|
+
* @eventName ~ColorSelectorView#execute
|
|
216
|
+
*/
|
|
217
|
+
export type ColorSelectorExecuteEvent = {
|
|
218
|
+
name: 'execute';
|
|
219
|
+
args: [
|
|
220
|
+
{
|
|
221
|
+
value: string;
|
|
222
|
+
source: 'staticColorsGrid' | 'documentColorsGrid' | 'removeColorButton' | 'colorPicker' | 'colorPickerSaveButton';
|
|
223
|
+
}
|
|
224
|
+
];
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Fired when the user pressed the "Cancel" button in the
|
|
228
|
+
* {@link module:ui/colorselector/colorselectorview~ColorSelectorView#colorPickerFragmentView}.
|
|
229
|
+
*
|
|
230
|
+
* @eventName ~ColorSelectorView#colorPicker:cancel
|
|
231
|
+
*/
|
|
232
|
+
export type ColorSelectorColorPickerCancelEvent = {
|
|
233
|
+
name: 'colorPicker:cancel';
|
|
234
|
+
args: [];
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Fired whenever {@link module:ui/colorselector/colorselectorview~ColorSelectorView#colorPickerFragmentView} is shown.
|
|
238
|
+
*
|
|
239
|
+
* See {@link ~ColorSelectorView#showColorPickerFragment}.
|
|
240
|
+
*
|
|
241
|
+
* @eventName ~ColorSelectorView#colorPicker:show
|
|
242
|
+
*/
|
|
243
|
+
export type ColorSelectorColorPickerShowEvent = {
|
|
244
|
+
name: 'colorPicker:show';
|
|
245
|
+
args: [];
|
|
246
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @module ui/colorselector/documentcolorcollection
|
|
11
|
+
*/
|
|
12
|
+
import type { ColorDefinition } from '../colorgrid/colorgridview.js';
|
|
13
|
+
import { Collection, type CollectionAddEvent, type CollectionRemoveEvent, type CollectionChangeEvent } from '@ckeditor/ckeditor5-utils';
|
|
14
|
+
declare const DocumentColorCollection_base: import("@ckeditor/ckeditor5-utils").Mixed<{
|
|
15
|
+
new (options?: {
|
|
16
|
+
readonly idProperty?: string | undefined;
|
|
17
|
+
} | undefined): Collection<ColorDefinition>;
|
|
18
|
+
new (initialItems: Iterable<ColorDefinition>, options?: {
|
|
19
|
+
readonly idProperty?: string | undefined;
|
|
20
|
+
} | undefined): Collection<ColorDefinition>;
|
|
21
|
+
}, import("@ckeditor/ckeditor5-utils").Observable>;
|
|
22
|
+
/**
|
|
23
|
+
* A collection to store document colors. It enforces colors to be unique.
|
|
24
|
+
*/
|
|
25
|
+
export default class DocumentColorCollection extends DocumentColorCollection_base {
|
|
26
|
+
/**
|
|
27
|
+
* Indicates whether the document color collection is empty.
|
|
28
|
+
*
|
|
29
|
+
* @observable
|
|
30
|
+
*/
|
|
31
|
+
readonly isEmpty: boolean;
|
|
32
|
+
constructor(options?: any);
|
|
33
|
+
/**
|
|
34
|
+
* Adds a color to the document color collection.
|
|
35
|
+
*
|
|
36
|
+
* This method ensures that no color duplicates are inserted (compared using
|
|
37
|
+
* the color value of the {@link module:ui/colorgrid/colorgridview~ColorDefinition}).
|
|
38
|
+
*
|
|
39
|
+
* If the item does not have an ID, it will be automatically generated and set on the item.
|
|
40
|
+
*
|
|
41
|
+
* @param index The position of the item in the collection. The item is pushed to the collection when `index` is not specified.
|
|
42
|
+
* @fires add
|
|
43
|
+
* @fires change
|
|
44
|
+
*/
|
|
45
|
+
add(item: ColorDefinition, index?: number): this;
|
|
46
|
+
/**
|
|
47
|
+
* Checks if an object with given colors is present in the document color collection.
|
|
48
|
+
*/
|
|
49
|
+
hasColor(color: string): boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Fired when the collection was changed due to adding or removing items.
|
|
53
|
+
*
|
|
54
|
+
* @eventName ~DocumentColorCollection#change
|
|
55
|
+
* @param data Changed items.
|
|
56
|
+
*/
|
|
57
|
+
export type DocumentColorCollectionChangeEvent = CollectionChangeEvent;
|
|
58
|
+
/**
|
|
59
|
+
* Fired when an item is added to the collection.
|
|
60
|
+
*
|
|
61
|
+
* @eventName ~DocumentColorCollection#add
|
|
62
|
+
* @param item The added item.
|
|
63
|
+
* @param index An index where the addition occurred.
|
|
64
|
+
*/
|
|
65
|
+
export type DocumentColorCollectionAddEvent = CollectionAddEvent;
|
|
66
|
+
/**
|
|
67
|
+
* Fired when an item is removed from the collection.
|
|
68
|
+
*
|
|
69
|
+
* @eventName ~DocumentColorCollection#remove
|
|
70
|
+
* @param item The removed item.
|
|
71
|
+
* @param index Index from which item was removed.
|
|
72
|
+
*/
|
|
73
|
+
export type DocumentColorCollectionRemoveEvent = CollectionRemoveEvent;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @module ui/componentfactory
|
|
11
|
+
*/
|
|
12
|
+
import { type Locale } from '@ckeditor/ckeditor5-utils';
|
|
13
|
+
import type { Editor } from '@ckeditor/ckeditor5-core';
|
|
14
|
+
import type View from './view.js';
|
|
15
|
+
/**
|
|
16
|
+
* A helper class implementing the UI component ({@link module:ui/view~View view}) factory.
|
|
17
|
+
*
|
|
18
|
+
* It allows functions producing specific UI components to be registered under their unique names
|
|
19
|
+
* in the factory. A registered component can be then instantiated by providing its name.
|
|
20
|
+
* Note that the names are case insensitive.
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* // The editor provides localization tools for the factory.
|
|
24
|
+
* const factory = new ComponentFactory( editor );
|
|
25
|
+
*
|
|
26
|
+
* factory.add( 'foo', locale => new FooView( locale ) );
|
|
27
|
+
* factory.add( 'bar', locale => new BarView( locale ) );
|
|
28
|
+
*
|
|
29
|
+
* // An instance of FooView.
|
|
30
|
+
* const fooInstance = factory.create( 'foo' );
|
|
31
|
+
*
|
|
32
|
+
* // Names are case insensitive so this is also allowed:
|
|
33
|
+
* const barInstance = factory.create( 'Bar' );
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* The {@link module:core/editor/editor~Editor#locale editor locale} is passed to the factory
|
|
37
|
+
* function when {@link module:ui/componentfactory~ComponentFactory#create} is called.
|
|
38
|
+
*/
|
|
39
|
+
export default class ComponentFactory {
|
|
40
|
+
/**
|
|
41
|
+
* The editor instance that the factory belongs to.
|
|
42
|
+
*/
|
|
43
|
+
readonly editor: Editor;
|
|
44
|
+
/**
|
|
45
|
+
* Registered component factories.
|
|
46
|
+
*/
|
|
47
|
+
private readonly _components;
|
|
48
|
+
/**
|
|
49
|
+
* Creates an instance of the factory.
|
|
50
|
+
*
|
|
51
|
+
* @param editor The editor instance.
|
|
52
|
+
*/
|
|
53
|
+
constructor(editor: Editor);
|
|
54
|
+
/**
|
|
55
|
+
* Returns an iterator of registered component names. Names are returned in lower case.
|
|
56
|
+
*/
|
|
57
|
+
names(): IterableIterator<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Registers a component factory function that will be used by the
|
|
60
|
+
* {@link #create create} method and called with the
|
|
61
|
+
* {@link module:core/editor/editor~Editor#locale editor locale} as an argument,
|
|
62
|
+
* allowing localization of the {@link module:ui/view~View view}.
|
|
63
|
+
*
|
|
64
|
+
* @param name The name of the component.
|
|
65
|
+
* @param callback The callback that returns the component.
|
|
66
|
+
*/
|
|
67
|
+
add(name: string, callback: (locale: Locale) => View): void;
|
|
68
|
+
/**
|
|
69
|
+
* Creates an instance of a component registered in the factory under a specific name.
|
|
70
|
+
*
|
|
71
|
+
* When called, the {@link module:core/editor/editor~Editor#locale editor locale} is passed to
|
|
72
|
+
* the previously {@link #add added} factory function, allowing localization of the
|
|
73
|
+
* {@link module:ui/view~View view}.
|
|
74
|
+
*
|
|
75
|
+
* @param name The name of the component.
|
|
76
|
+
* @returns The instantiated component view.
|
|
77
|
+
*/
|
|
78
|
+
create(name: string): View;
|
|
79
|
+
/**
|
|
80
|
+
* Checks if a component of a given name is registered in the factory.
|
|
81
|
+
*
|
|
82
|
+
* @param name The name of the component.
|
|
83
|
+
*/
|
|
84
|
+
has(name: string): boolean;
|
|
85
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
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
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @module ui/dialog/dialog
|
|
11
|
+
*/
|
|
12
|
+
import type View from '../view.js';
|
|
13
|
+
import { type Editor, Plugin } from '@ckeditor/ckeditor5-core';
|
|
14
|
+
import DialogView, { DialogViewPosition } from './dialogview.js';
|
|
15
|
+
import type { DialogActionButtonDefinition } from './dialogactionsview.js';
|
|
16
|
+
/**
|
|
17
|
+
* The dialog controller class. It is used to show and hide the {@link module:ui/dialog/dialogview~DialogView}.
|
|
18
|
+
*/
|
|
19
|
+
export default class Dialog extends Plugin {
|
|
20
|
+
/**
|
|
21
|
+
* The name of the currently visible dialog view instance.
|
|
22
|
+
*
|
|
23
|
+
* @observable
|
|
24
|
+
*/
|
|
25
|
+
id: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* The currently visible dialog view instance.
|
|
28
|
+
*/
|
|
29
|
+
view?: DialogView;
|
|
30
|
+
/**
|
|
31
|
+
* The `Dialog` plugin instance which most recently showed the dialog.
|
|
32
|
+
*
|
|
33
|
+
* Only one dialog can be visible at once, even if there are many editor instances on the page.
|
|
34
|
+
* If an editor wants to show a dialog, it should first hide the dialog that is already opened.
|
|
35
|
+
* But only the `Dialog` instance that showed the dialog is able able to properly hide it.
|
|
36
|
+
* This is why we need to store it in a globally available space (static property).
|
|
37
|
+
* This way every `Dialog` plugin in every editor is able to correctly close any open dialog window.
|
|
38
|
+
*/
|
|
39
|
+
private static _visibleDialogPlugin;
|
|
40
|
+
/**
|
|
41
|
+
* A flag indicating whether the dialog is currently visible.
|
|
42
|
+
*
|
|
43
|
+
* @observable
|
|
44
|
+
*/
|
|
45
|
+
isOpen: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* A configurable callback called when the dialog is hidden.
|
|
48
|
+
*/
|
|
49
|
+
private _onHide;
|
|
50
|
+
/**
|
|
51
|
+
* @inheritDoc
|
|
52
|
+
*/
|
|
53
|
+
static get pluginName(): "Dialog";
|
|
54
|
+
/**
|
|
55
|
+
* @inheritDoc
|
|
56
|
+
*/
|
|
57
|
+
constructor(editor: Editor);
|
|
58
|
+
/**
|
|
59
|
+
* Initiates listeners for the `show` and `hide` events emitted by this plugin.
|
|
60
|
+
*
|
|
61
|
+
* We could not simply decorate the {@link #show} and {@link #hide} methods to fire events,
|
|
62
|
+
* because they would be fired in the wrong order – first would be `show` and then `hide`
|
|
63
|
+
* (because showing the dialog actually starts with hiding the previously visible one).
|
|
64
|
+
* Hence, we added private methods {@link #_show} and {@link #_hide} which are called on events
|
|
65
|
+
* in the desired sequence.
|
|
66
|
+
*/
|
|
67
|
+
private _initShowHideListeners;
|
|
68
|
+
/**
|
|
69
|
+
* Initiates keystroke handler for toggling the focus between the editor and the dialog view.
|
|
70
|
+
*/
|
|
71
|
+
private _initFocusToggler;
|
|
72
|
+
/**
|
|
73
|
+
* Provides an integration between the root attaching and detaching and positioning of the view.
|
|
74
|
+
*/
|
|
75
|
+
private _initMultiRootIntegration;
|
|
76
|
+
/**
|
|
77
|
+
* Displays a dialog window.
|
|
78
|
+
*
|
|
79
|
+
* This method requires a {@link ~DialogDefinition} that defines the dialog's content, title, icon, action buttons, etc.
|
|
80
|
+
*
|
|
81
|
+
* For example, the following definition will create a dialog with:
|
|
82
|
+
* * A header consisting of an icon, a title, and a "Close" button (it is added by default).
|
|
83
|
+
* * A content consisting of a view with a single paragraph.
|
|
84
|
+
* * A footer consisting of two buttons: "Yes" and "No".
|
|
85
|
+
*
|
|
86
|
+
* ```js
|
|
87
|
+
* // Create the view that will be used as the dialog's content.
|
|
88
|
+
* const textView = new View( locale );
|
|
89
|
+
*
|
|
90
|
+
* textView.setTemplate( {
|
|
91
|
+
* tag: 'div',
|
|
92
|
+
* attributes: {
|
|
93
|
+
* style: {
|
|
94
|
+
* padding: 'var(--ck-spacing-large)',
|
|
95
|
+
* whiteSpace: 'initial',
|
|
96
|
+
* width: '100%',
|
|
97
|
+
* maxWidth: '500px'
|
|
98
|
+
* },
|
|
99
|
+
* tabindex: -1
|
|
100
|
+
* },
|
|
101
|
+
* children: [
|
|
102
|
+
* 'Lorem ipsum dolor sit amet...'
|
|
103
|
+
* ]
|
|
104
|
+
* } );
|
|
105
|
+
*
|
|
106
|
+
* // Show the dialog.
|
|
107
|
+
* editor.plugins.get( 'Dialog' ).show( {
|
|
108
|
+
* id: 'myDialog',
|
|
109
|
+
* icon: 'myIcon', // This should be an SVG string.
|
|
110
|
+
* title: 'My dialog',
|
|
111
|
+
* content: textView,
|
|
112
|
+
* actionButtons: [
|
|
113
|
+
* {
|
|
114
|
+
* label: t( 'Yes' ),
|
|
115
|
+
* class: 'ck-button-action',
|
|
116
|
+
* withText: true,
|
|
117
|
+
* onExecute: () => dialog.hide()
|
|
118
|
+
* },
|
|
119
|
+
* {
|
|
120
|
+
* label: t( 'No' ),
|
|
121
|
+
* withText: true,
|
|
122
|
+
* onExecute: () => dialog.hide()
|
|
123
|
+
* }
|
|
124
|
+
* ]
|
|
125
|
+
* } );
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* By specifying the {@link ~DialogDefinition#onShow} and {@link ~DialogDefinition#onHide} callbacks
|
|
129
|
+
* it is also possible to add callbacks that will be called when the dialog is shown or hidden.
|
|
130
|
+
*
|
|
131
|
+
* For example, the callbacks in the following definition:
|
|
132
|
+
* * Disable the default behavior of the <kbd>Esc</kbd> key.
|
|
133
|
+
* * Fire a custom event when the dialog gets hidden.
|
|
134
|
+
*
|
|
135
|
+
* ```js
|
|
136
|
+
* editor.plugins.get( 'Dialog' ).show( {
|
|
137
|
+
* // ...
|
|
138
|
+
* onShow: dialog => {
|
|
139
|
+
* dialog.view.on( 'close', ( evt, data ) => {
|
|
140
|
+
* // Only prevent the event from the "Esc" key - do not affect the other ways of closing the dialog.
|
|
141
|
+
* if ( data.source === 'escKeyPress' ) {
|
|
142
|
+
* evt.stop();
|
|
143
|
+
* }
|
|
144
|
+
* } );
|
|
145
|
+
* },
|
|
146
|
+
* onHide: dialog => {
|
|
147
|
+
* dialog.fire( 'dialogDestroyed' );
|
|
148
|
+
* }
|
|
149
|
+
* } );
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* Internally, calling this method:
|
|
153
|
+
* 1. Hides the currently visible dialog (if any) calling the {@link #hide} method
|
|
154
|
+
* (fires the {@link ~DialogHideEvent hide event}).
|
|
155
|
+
* 2. Fires the {@link ~DialogShowEvent show event} which allows for adding callbacks that customize the
|
|
156
|
+
* behavior of the dialog.
|
|
157
|
+
* 3. Shows the dialog.
|
|
158
|
+
*/
|
|
159
|
+
show(dialogDefinition: DialogDefinition): void;
|
|
160
|
+
/**
|
|
161
|
+
* Handles creating the {@link module:ui/dialog/dialogview~DialogView} instance and making it visible.
|
|
162
|
+
*/
|
|
163
|
+
private _show;
|
|
164
|
+
/**
|
|
165
|
+
* Hides the dialog. This method is decorated to enable interacting on the {@link ~DialogHideEvent hide event}.
|
|
166
|
+
*
|
|
167
|
+
* See {@link #show}.
|
|
168
|
+
*/
|
|
169
|
+
hide(): void;
|
|
170
|
+
/**
|
|
171
|
+
* Destroys the {@link module:ui/dialog/dialogview~DialogView} and cleans up the stored dialog state.
|
|
172
|
+
*/
|
|
173
|
+
private _hide;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The definition that describes a dialog window and its content. Passed to the {@link module:ui/dialog/dialog~Dialog#show} method.
|
|
177
|
+
*/
|
|
178
|
+
export interface DialogDefinition {
|
|
179
|
+
/**
|
|
180
|
+
* A unique identifier of the dialog. It allows for distinguishing between different dialogs and their visibility.
|
|
181
|
+
* For instance, when open, the ID of the currently visible dialog is stored in {@link module:ui/dialog/dialog~Dialog#id}.
|
|
182
|
+
*
|
|
183
|
+
* The `id` is also passed along the {@link module:ui/dialog/dialog~DialogShowEvent} and {@link module:ui/dialog/dialog~DialogHideEvent}
|
|
184
|
+
* events.
|
|
185
|
+
*/
|
|
186
|
+
id: string;
|
|
187
|
+
/**
|
|
188
|
+
* The SVG string of an icon displayed in dialogs's header. Used only when {@link #title} is also set
|
|
189
|
+
* and the header is displayed.
|
|
190
|
+
*
|
|
191
|
+
* See more in {@link module:ui/icon/iconview~IconView#content}.
|
|
192
|
+
*/
|
|
193
|
+
icon?: string;
|
|
194
|
+
/**
|
|
195
|
+
* A title displayed in the dialogs's header. It also works as an accessible name of the dialog used by assistive technologies.
|
|
196
|
+
*
|
|
197
|
+
* When not set, the header is not displayed. Affects {@link #icon} and {@link #hasCloseButton}.
|
|
198
|
+
*/
|
|
199
|
+
title?: string;
|
|
200
|
+
/**
|
|
201
|
+
* A flag indicating whether the dialog should have a close button in the header.
|
|
202
|
+
* `true` by default. Works when {@link #title} is also set and the header is displayed.
|
|
203
|
+
*
|
|
204
|
+
* **Note**: If you hide the close button, make sure that the dialog can be closed in another way.
|
|
205
|
+
*/
|
|
206
|
+
hasCloseButton?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* The content of the dialog. It can be a single {@link module:ui/view~View} or an array of views.
|
|
209
|
+
*/
|
|
210
|
+
content?: View | Array<View>;
|
|
211
|
+
/**
|
|
212
|
+
* The action buttons displayed in the dialog's footer.
|
|
213
|
+
*/
|
|
214
|
+
actionButtons?: Array<DialogActionButtonDefinition>;
|
|
215
|
+
/**
|
|
216
|
+
* An additional CSS class set on the outermost (`.ck.ck-dialog`) container element allowing for visual customization.
|
|
217
|
+
*/
|
|
218
|
+
className?: string;
|
|
219
|
+
/**
|
|
220
|
+
* When set to `true`, the dialog will become a modal, that is, it will block the UI until it is closed.
|
|
221
|
+
*/
|
|
222
|
+
isModal?: boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Available dialog positions. By default `DialogViewPosition.EDITOR_CENTER` is used for {@link #isModal non-modals}
|
|
225
|
+
* and `DialogViewPosition.SCREEN_CENTER` for modals.
|
|
226
|
+
*
|
|
227
|
+
* {@link module:ui/dialog/dialogview#DialogViewPosition Learn more} about available positions.
|
|
228
|
+
*/
|
|
229
|
+
position?: typeof DialogViewPosition[keyof typeof DialogViewPosition];
|
|
230
|
+
/**
|
|
231
|
+
* A callback called when the dialog shows up with a `low` priority. It allows for setting up the dialog's {@link #content}.
|
|
232
|
+
*/
|
|
233
|
+
onShow?: (dialog: Dialog) => void;
|
|
234
|
+
/**
|
|
235
|
+
* A callback called when the dialog hides with a `low` priority.
|
|
236
|
+
* It allows for cleaning up (for example, resetting) the dialog's {@link #content}.
|
|
237
|
+
*/
|
|
238
|
+
onHide?: (dialog: Dialog) => void;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* An event fired after {@link module:ui/dialog/dialog~Dialog#show} is called. You can use it to customize the behavior
|
|
242
|
+
* of any dialog.
|
|
243
|
+
*
|
|
244
|
+
* ```js
|
|
245
|
+
* import { DialogViewPosition } from 'ckeditor5/src/ui.js';
|
|
246
|
+
*
|
|
247
|
+
* // ...
|
|
248
|
+
*
|
|
249
|
+
* // Changes the position of the "Find and Replace" dialog.
|
|
250
|
+
* editor.plugins.get( 'Dialog' ).on( 'show:findAndReplace', ( evt, data ) => {
|
|
251
|
+
* Object.assign( data, { position: DialogViewPosition.EDITOR_BOTTOM_CENTER } );
|
|
252
|
+
* }, { priority: 'high' } );
|
|
253
|
+
* ```
|
|
254
|
+
*
|
|
255
|
+
* @eventName ~Dialog#show
|
|
256
|
+
*/
|
|
257
|
+
export type DialogShowEvent = {
|
|
258
|
+
name: 'show' | `show:${string}`;
|
|
259
|
+
args: [dialogDefinition: DialogDefinition];
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* An event fired after {@link module:ui/dialog/dialog~Dialog#hide} is called. You can use it to customize the behavior
|
|
263
|
+
* of any dialog.
|
|
264
|
+
*
|
|
265
|
+
* ```js
|
|
266
|
+
* // Logs after the "Find and Replace" dialog gets hidden
|
|
267
|
+
* editor.plugins.get( 'Dialog' ).on( 'hide:findAndReplace', () => {
|
|
268
|
+
* console.log( 'The "Find and Replace" dialog was hidden.' );
|
|
269
|
+
* } );
|
|
270
|
+
* ```
|
|
271
|
+
*
|
|
272
|
+
* @eventName ~Dialog#hide
|
|
273
|
+
*/
|
|
274
|
+
export type DialogHideEvent = {
|
|
275
|
+
name: 'hide' | `hide:${string}`;
|
|
276
|
+
args: [];
|
|
277
|
+
};
|