@ckeditor/ckeditor5-ui 39.0.2 → 40.1.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.
Files changed (136) hide show
  1. package/LICENSE.md +3 -3
  2. package/lang/contexts.json +5 -1
  3. package/lang/translations/ar.po +16 -0
  4. package/lang/translations/ast.po +16 -0
  5. package/lang/translations/az.po +16 -0
  6. package/lang/translations/bg.po +16 -0
  7. package/lang/translations/bn.po +16 -0
  8. package/lang/translations/ca.po +16 -0
  9. package/lang/translations/cs.po +16 -0
  10. package/lang/translations/da.po +16 -0
  11. package/lang/translations/de-ch.po +16 -0
  12. package/lang/translations/de.po +16 -0
  13. package/lang/translations/el.po +16 -0
  14. package/lang/translations/en-au.po +16 -0
  15. package/lang/translations/en-gb.po +16 -0
  16. package/lang/translations/en.po +16 -0
  17. package/lang/translations/eo.po +16 -0
  18. package/lang/translations/es.po +16 -0
  19. package/lang/translations/et.po +16 -0
  20. package/lang/translations/eu.po +16 -0
  21. package/lang/translations/fa.po +16 -0
  22. package/lang/translations/fi.po +16 -0
  23. package/lang/translations/fr.po +16 -0
  24. package/lang/translations/gl.po +16 -0
  25. package/lang/translations/he.po +16 -0
  26. package/lang/translations/hi.po +16 -0
  27. package/lang/translations/hr.po +16 -0
  28. package/lang/translations/hu.po +16 -0
  29. package/lang/translations/id.po +16 -0
  30. package/lang/translations/it.po +16 -0
  31. package/lang/translations/ja.po +16 -0
  32. package/lang/translations/km.po +16 -0
  33. package/lang/translations/kn.po +16 -0
  34. package/lang/translations/ko.po +16 -0
  35. package/lang/translations/ku.po +16 -0
  36. package/lang/translations/lt.po +16 -0
  37. package/lang/translations/lv.po +16 -0
  38. package/lang/translations/ms.po +16 -0
  39. package/lang/translations/nb.po +16 -0
  40. package/lang/translations/ne.po +16 -0
  41. package/lang/translations/nl.po +16 -0
  42. package/lang/translations/no.po +16 -0
  43. package/lang/translations/pl.po +16 -0
  44. package/lang/translations/pt-br.po +17 -1
  45. package/lang/translations/pt.po +16 -0
  46. package/lang/translations/ro.po +16 -0
  47. package/lang/translations/ru.po +16 -0
  48. package/lang/translations/sk.po +16 -0
  49. package/lang/translations/sl.po +16 -0
  50. package/lang/translations/sq.po +16 -0
  51. package/lang/translations/sr-latn.po +16 -0
  52. package/lang/translations/sr.po +16 -0
  53. package/lang/translations/sv.po +16 -0
  54. package/lang/translations/th.po +16 -0
  55. package/lang/translations/tk.po +16 -0
  56. package/lang/translations/tr.po +16 -0
  57. package/lang/translations/tt.po +16 -0
  58. package/lang/translations/ug.po +38 -22
  59. package/lang/translations/uk.po +16 -0
  60. package/lang/translations/ur.po +16 -0
  61. package/lang/translations/uz.po +16 -0
  62. package/lang/translations/vi.po +16 -0
  63. package/lang/translations/zh-cn.po +16 -0
  64. package/lang/translations/zh.po +16 -0
  65. package/package.json +3 -3
  66. package/src/arialiveannouncer.d.ts +94 -0
  67. package/src/arialiveannouncer.js +113 -0
  68. package/src/autocomplete/autocompleteview.d.ts +81 -0
  69. package/src/autocomplete/autocompleteview.js +153 -0
  70. package/src/button/button.d.ts +0 -6
  71. package/src/button/buttonlabel.d.ts +34 -0
  72. package/src/button/buttonlabel.js +5 -0
  73. package/src/button/buttonlabelview.d.ts +31 -0
  74. package/src/button/buttonlabelview.js +42 -0
  75. package/src/button/buttonview.d.ts +14 -10
  76. package/src/button/buttonview.js +11 -25
  77. package/src/dropdown/dropdownview.js +5 -4
  78. package/src/dropdown/utils.d.ts +15 -1
  79. package/src/dropdown/utils.js +47 -21
  80. package/src/editorui/editorui.d.ts +6 -0
  81. package/src/editorui/editorui.js +2 -0
  82. package/src/editorui/poweredby.js +14 -37
  83. package/src/focuscycler.d.ts +45 -2
  84. package/src/focuscycler.js +34 -9
  85. package/src/formheader/formheaderview.d.ts +6 -0
  86. package/src/formheader/formheaderview.js +6 -0
  87. package/src/highlightedtext/highlightedtextview.d.ts +38 -0
  88. package/src/highlightedtext/highlightedtextview.js +102 -0
  89. package/src/icon/iconview.d.ts +7 -0
  90. package/src/icon/iconview.js +2 -0
  91. package/src/index.d.ts +12 -2
  92. package/src/index.js +8 -0
  93. package/src/input/inputbase.d.ts +107 -0
  94. package/src/input/inputbase.js +110 -0
  95. package/src/input/inputview.d.ts +4 -89
  96. package/src/input/inputview.js +5 -87
  97. package/src/labeledfield/labeledfieldview.d.ts +7 -2
  98. package/src/labeledfield/labeledfieldview.js +2 -2
  99. package/src/labeledfield/utils.d.ts +34 -4
  100. package/src/labeledfield/utils.js +51 -6
  101. package/src/list/listitemgroupview.d.ts +59 -0
  102. package/src/list/listitemgroupview.js +63 -0
  103. package/src/list/listitemview.d.ts +2 -1
  104. package/src/list/listitemview.js +3 -1
  105. package/src/list/listview.d.ts +59 -2
  106. package/src/list/listview.js +105 -8
  107. package/src/panel/balloon/balloonpanelview.js +26 -4
  108. package/src/panel/sticky/stickypanelview.d.ts +1 -3
  109. package/src/panel/sticky/stickypanelview.js +53 -50
  110. package/src/search/filteredview.d.ts +31 -0
  111. package/src/search/filteredview.js +5 -0
  112. package/src/search/searchinfoview.d.ts +45 -0
  113. package/src/search/searchinfoview.js +59 -0
  114. package/src/search/searchresultsview.d.ts +54 -0
  115. package/src/search/searchresultsview.js +65 -0
  116. package/src/search/text/searchtextqueryview.d.ts +76 -0
  117. package/src/search/text/searchtextqueryview.js +75 -0
  118. package/src/search/text/searchtextview.d.ts +219 -0
  119. package/src/search/text/searchtextview.js +201 -0
  120. package/src/spinner/spinnerview.d.ts +25 -0
  121. package/src/spinner/spinnerview.js +38 -0
  122. package/src/textarea/textareaview.d.ts +88 -0
  123. package/src/textarea/textareaview.js +142 -0
  124. package/src/toolbar/block/blocktoolbar.js +30 -26
  125. package/src/toolbar/normalizetoolbarconfig.d.ts +1 -0
  126. package/src/toolbar/normalizetoolbarconfig.js +9 -8
  127. package/src/toolbar/toolbarview.d.ts +1 -0
  128. package/src/toolbar/toolbarview.js +4 -2
  129. package/theme/components/arialiveannouncer/arialiveannouncer.css +10 -0
  130. package/theme/components/autocomplete/autocomplete.css +22 -0
  131. package/theme/components/button/button.css +9 -1
  132. package/theme/components/formheader/formheader.css +4 -0
  133. package/theme/components/highlightedtext/highlightedtext.css +12 -0
  134. package/theme/components/search/search.css +43 -0
  135. package/theme/components/spinner/spinner.css +23 -0
  136. package/theme/components/textarea/textarea.css +10 -0
@@ -7,8 +7,11 @@
7
7
  */
8
8
  import View from '../../view';
9
9
  import Template from '../../template';
10
- import { getElementsIntersectionRect, getScrollableAncestors, global, toUnit, Rect } from '@ckeditor/ckeditor5-utils';
11
- // @if CK_DEBUG_STICKYPANEL // const RectDrawer = require( '@ckeditor/ckeditor5-utils/tests/_utils/rectdrawer' ).default
10
+ import { global, toUnit, Rect } from '@ckeditor/ckeditor5-utils';
11
+ // @if CK_DEBUG_STICKYPANEL // const {
12
+ // @if CK_DEBUG_STICKYPANEL // default: RectDrawer,
13
+ // @if CK_DEBUG_STICKYPANEL // diagonalStylesBlack
14
+ // @if CK_DEBUG_STICKYPANEL // } = require( '@ckeditor/ckeditor5-utils/tests/_utils/rectdrawer' );
12
15
  import '../../../theme/components/panel/stickypanel.css';
13
16
  const toPx = toUnit('px');
14
17
  /**
@@ -89,8 +92,8 @@ export default class StickyPanelView extends View {
89
92
  // Check if the panel should go into the sticky state immediately.
90
93
  this.checkIfShouldBeSticky();
91
94
  // Update sticky state of the panel as the window and ancestors are being scrolled.
92
- this.listenTo(global.document, 'scroll', (evt, data) => {
93
- this.checkIfShouldBeSticky(data.target);
95
+ this.listenTo(global.document, 'scroll', () => {
96
+ this.checkIfShouldBeSticky();
94
97
  }, { useCapture: true });
95
98
  // Synchronize with `model.isActive` because sticking an inactive panel is pointless.
96
99
  this.listenTo(this, 'change:isActive', () => {
@@ -100,23 +103,23 @@ export default class StickyPanelView extends View {
100
103
  /**
101
104
  * Analyzes the environment to decide whether the panel should be sticky or not.
102
105
  * Then handles the positioning of the panel.
103
- *
104
- * @param [scrollTarget] The element which is being scrolled.
105
106
  */
106
- checkIfShouldBeSticky(scrollTarget) {
107
+ checkIfShouldBeSticky() {
107
108
  // @if CK_DEBUG_STICKYPANEL // RectDrawer.clear();
108
109
  if (!this.limiterElement || !this.isActive) {
109
110
  this._unstick();
110
111
  return;
111
112
  }
112
- const scrollableAncestors = getScrollableAncestors(this.limiterElement);
113
- if (scrollTarget && !scrollableAncestors.includes(scrollTarget)) {
114
- return;
115
- }
116
- const visibleAncestorsRect = getElementsIntersectionRect(scrollableAncestors, this.viewportTopOffset);
117
113
  const limiterRect = new Rect(this.limiterElement);
118
- // @if CK_DEBUG_STICKYPANEL // if ( visibleAncestorsRect ) {
119
- // @if CK_DEBUG_STICKYPANEL // RectDrawer.draw( visibleAncestorsRect,
114
+ let visibleLimiterRect = limiterRect.getVisible();
115
+ if (visibleLimiterRect) {
116
+ const windowRect = new Rect(global.window);
117
+ windowRect.top += this.viewportTopOffset;
118
+ windowRect.height -= this.viewportTopOffset;
119
+ visibleLimiterRect = visibleLimiterRect.getIntersection(windowRect);
120
+ }
121
+ // @if CK_DEBUG_STICKYPANEL // if ( visibleLimiterRect ) {
122
+ // @if CK_DEBUG_STICKYPANEL // RectDrawer.draw( visibleLimiterRect,
120
123
  // @if CK_DEBUG_STICKYPANEL // { outlineWidth: '3px', opacity: '.8', outlineColor: 'red', outlineOffset: '-3px' },
121
124
  // @if CK_DEBUG_STICKYPANEL // 'Visible anc'
122
125
  // @if CK_DEBUG_STICKYPANEL // );
@@ -129,48 +132,40 @@ export default class StickyPanelView extends View {
129
132
  // Stick the panel only if
130
133
  // * the limiter's ancestors are intersecting with each other so that some of their rects are visible,
131
134
  // * and the limiter's top edge is above the visible ancestors' top edge.
132
- if (visibleAncestorsRect && limiterRect.top < visibleAncestorsRect.top) {
133
- const visibleLimiterRect = limiterRect.getIntersection(visibleAncestorsRect);
134
- // Sticky the panel only if the limiter's visible rect is at least partially visible in the
135
- // visible ancestors' rects intersection.
136
- if (visibleLimiterRect) {
137
- // @if CK_DEBUG_STICKYPANEL // RectDrawer.draw( visibleLimiterRect,
138
- // @if CK_DEBUG_STICKYPANEL // { outlineWidth: '3px', opacity: '.8', outlineColor: 'fuchsia', outlineOffset: '-3px',
139
- // @if CK_DEBUG_STICKYPANEL // backgroundColor: 'rgba(255, 0, 255, .3)' },
140
- // @if CK_DEBUG_STICKYPANEL // 'Visible limiter'
135
+ if (visibleLimiterRect && limiterRect.top < visibleLimiterRect.top) {
136
+ // @if CK_DEBUG_STICKYPANEL // RectDrawer.draw( visibleLimiterRect,
137
+ // @if CK_DEBUG_STICKYPANEL // { outlineWidth: '3px', opacity: '.8', outlineColor: 'fuchsia', outlineOffset: '-3px',
138
+ // @if CK_DEBUG_STICKYPANEL // backgroundColor: 'rgba(255, 0, 255, .3)' },
139
+ // @if CK_DEBUG_STICKYPANEL // 'Visible limiter'
140
+ // @if CK_DEBUG_STICKYPANEL // );
141
+ const visibleLimiterTop = visibleLimiterRect.top;
142
+ // Check if there's a change the panel can be sticky to the bottom of the limiter.
143
+ if (visibleLimiterTop + this._contentPanelRect.height + this.limiterBottomOffset > visibleLimiterRect.bottom) {
144
+ const stickyBottomOffset = Math.max(limiterRect.bottom - visibleLimiterRect.bottom, 0) + this.limiterBottomOffset;
145
+ // @if CK_DEBUG_STICKYPANEL // const stickyBottomOffsetRect = new Rect( {
146
+ // @if CK_DEBUG_STICKYPANEL // top: limiterRect.bottom - stickyBottomOffset, left: 0, right: 2000,
147
+ // @if CK_DEBUG_STICKYPANEL // bottom: limiterRect.bottom - stickyBottomOffset, width: 2000, height: 1
148
+ // @if CK_DEBUG_STICKYPANEL // } );
149
+ // @if CK_DEBUG_STICKYPANEL // RectDrawer.draw( stickyBottomOffsetRect,
150
+ // @if CK_DEBUG_STICKYPANEL // { outlineWidth: '1px', opacity: '.8', outlineColor: 'black' },
151
+ // @if CK_DEBUG_STICKYPANEL // 'Sticky bottom offset'
141
152
  // @if CK_DEBUG_STICKYPANEL // );
142
- const visibleAncestorsTop = visibleAncestorsRect.top;
143
- // Check if there's a change the panel can be sticky to the bottom of the limiter.
144
- if (visibleAncestorsTop + this._contentPanelRect.height + this.limiterBottomOffset > visibleLimiterRect.bottom) {
145
- const stickyBottomOffset = Math.max(limiterRect.bottom - visibleAncestorsRect.bottom, 0) + this.limiterBottomOffset;
146
- // @if CK_DEBUG_STICKYPANEL // const stickyBottomOffsetRect = new Rect( {
147
- // @if CK_DEBUG_STICKYPANEL // top: limiterRect.bottom - stickyBottomOffset, left: 0, right: 2000,
148
- // @if CK_DEBUG_STICKYPANEL // bottom: limiterRect.bottom - stickyBottomOffset, width: 2000, height: 1
149
- // @if CK_DEBUG_STICKYPANEL // } );
150
- // @if CK_DEBUG_STICKYPANEL // RectDrawer.draw( stickyBottomOffsetRect,
151
- // @if CK_DEBUG_STICKYPANEL // { outlineWidth: '1px', opacity: '.8', outlineColor: 'black' },
152
- // @if CK_DEBUG_STICKYPANEL // 'Sticky bottom offset'
153
- // @if CK_DEBUG_STICKYPANEL // );
154
- // Check if sticking the panel to the bottom of the limiter does not cause it to suddenly
155
- // move upwards if there's not enough space for it.
156
- if (limiterRect.bottom - stickyBottomOffset > limiterRect.top + this._contentPanelRect.height) {
157
- this._stickToBottomOfLimiter(stickyBottomOffset);
158
- }
159
- else {
160
- this._unstick();
161
- }
153
+ // Check if sticking the panel to the bottom of the limiter does not cause it to suddenly
154
+ // move upwards if there's not enough space for it.
155
+ if (limiterRect.bottom - stickyBottomOffset > limiterRect.top + this._contentPanelRect.height) {
156
+ this._stickToBottomOfLimiter(stickyBottomOffset);
162
157
  }
163
158
  else {
164
- if (this._contentPanelRect.height + this.limiterBottomOffset < limiterRect.height) {
165
- this._stickToTopOfAncestors(visibleAncestorsTop);
166
- }
167
- else {
168
- this._unstick();
169
- }
159
+ this._unstick();
170
160
  }
171
161
  }
172
162
  else {
173
- this._unstick();
163
+ if (this._contentPanelRect.height + this.limiterBottomOffset < limiterRect.height) {
164
+ this._stickToTopOfAncestors(visibleLimiterTop);
165
+ }
166
+ else {
167
+ this._unstick();
168
+ }
174
169
  }
175
170
  }
176
171
  else {
@@ -181,6 +176,14 @@ export default class StickyPanelView extends View {
181
176
  // @if CK_DEBUG_STICKYPANEL // console.log( '_isStickyToTheBottomOfLimiter', this._isStickyToTheBottomOfLimiter );
182
177
  // @if CK_DEBUG_STICKYPANEL // console.log( '_stickyTopOffset', this._stickyTopOffset );
183
178
  // @if CK_DEBUG_STICKYPANEL // console.log( '_stickyBottomOffset', this._stickyBottomOffset );
179
+ // @if CK_DEBUG_STICKYPANEL // if ( visibleLimiterRect ) {
180
+ // @if CK_DEBUG_STICKYPANEL // RectDrawer.draw( visibleLimiterRect,
181
+ // @if CK_DEBUG_STICKYPANEL // { ...diagonalStylesBlack,
182
+ // @if CK_DEBUG_STICKYPANEL // outlineWidth: '3px', opacity: '.8', outlineColor: 'orange', outlineOffset: '-3px',
183
+ // @if CK_DEBUG_STICKYPANEL // backgroundColor: 'rgba(0, 0, 255, .2)' },
184
+ // @if CK_DEBUG_STICKYPANEL // 'visibleLimiterRect'
185
+ // @if CK_DEBUG_STICKYPANEL // );
186
+ // @if CK_DEBUG_STICKYPANEL // }
184
187
  }
185
188
  /**
186
189
  * Sticks the panel at the given CSS `top` offset.
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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 type { FocusableView } from '../focuscycler';
6
+ /**
7
+ * @module ui/search/filteredview
8
+ */
9
+ /**
10
+ * A view that can be filtered by a {@link module:ui/search/text/searchtextview~SearchTextView}.
11
+ */
12
+ export default interface FilteredView extends FocusableView {
13
+ /**
14
+ * Filters the view by the given regular expression.
15
+ */
16
+ filter(regExp: RegExp | null): {
17
+ resultsCount: number;
18
+ totalItemsCount: number;
19
+ };
20
+ }
21
+ /**
22
+ * Fired when the user selects an autocomplete option. The event data should contain the selected value.
23
+ *
24
+ * @eventName ~FilteredView#execute
25
+ */
26
+ export interface FilteredViewExecuteEvent {
27
+ name: 'execute';
28
+ args: [{
29
+ value: string;
30
+ }];
31
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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
+ export {};
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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/search/searchinfoview
7
+ */
8
+ import type { FocusableView } from '../focuscycler';
9
+ import View from '../view';
10
+ /**
11
+ * A view displaying an information text related to different states of {@link module:ui/search/text/searchtextview~SearchTextView}.
12
+ *
13
+ * @internal
14
+ */
15
+ export default class SearchInfoView extends View implements FocusableView {
16
+ /**
17
+ * Controls whether the view is visible.
18
+ *
19
+ * @observable
20
+ * @default false
21
+ */
22
+ isVisible: boolean;
23
+ /**
24
+ * Controls the primary line of text in the info.
25
+ *
26
+ * @observable
27
+ * @default ''
28
+ */
29
+ primaryText: string;
30
+ /**
31
+ * Controls the secondary line of text in the info.
32
+ *
33
+ * @observable
34
+ * @default ''
35
+ */
36
+ secondaryText: string;
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ constructor();
41
+ /**
42
+ * Focuses the view
43
+ */
44
+ focus(): void;
45
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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 View from '../view';
6
+ /**
7
+ * A view displaying an information text related to different states of {@link module:ui/search/text/searchtextview~SearchTextView}.
8
+ *
9
+ * @internal
10
+ */
11
+ export default class SearchInfoView extends View {
12
+ /**
13
+ * @inheritDoc
14
+ */
15
+ constructor() {
16
+ super();
17
+ const bind = this.bindTemplate;
18
+ this.set({
19
+ isVisible: false,
20
+ primaryText: '',
21
+ secondaryText: ''
22
+ });
23
+ this.setTemplate({
24
+ tag: 'div',
25
+ attributes: {
26
+ class: [
27
+ 'ck',
28
+ 'ck-search__info',
29
+ bind.if('isVisible', 'ck-hidden', value => !value)
30
+ ],
31
+ tabindex: -1
32
+ },
33
+ children: [
34
+ {
35
+ tag: 'span',
36
+ children: [
37
+ {
38
+ text: [bind.to('primaryText')]
39
+ }
40
+ ]
41
+ },
42
+ {
43
+ tag: 'span',
44
+ children: [
45
+ {
46
+ text: [bind.to('secondaryText')]
47
+ }
48
+ ]
49
+ }
50
+ ]
51
+ });
52
+ }
53
+ /**
54
+ * Focuses the view
55
+ */
56
+ focus() {
57
+ this.element.focus();
58
+ }
59
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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/search/searchresultsview
7
+ */
8
+ import View from '../view';
9
+ import type ViewCollection from '../viewcollection';
10
+ import { FocusTracker, type Locale } from '@ckeditor/ckeditor5-utils';
11
+ import { default as FocusCycler, type FocusableView } from '../focuscycler';
12
+ /**
13
+ * A sub-component of {@link module:ui/search/text/searchtextview~SearchTextView}. It hosts the filtered and the information views.
14
+ */
15
+ export default class SearchResultsView extends View implements FocusableView {
16
+ /**
17
+ * Tracks information about the DOM focus in the view.
18
+ *
19
+ * @readonly
20
+ */
21
+ focusTracker: FocusTracker;
22
+ /**
23
+ * The collection of the child views inside of the list item {@link #element}.
24
+ *
25
+ * @readonly
26
+ */
27
+ children: ViewCollection;
28
+ /**
29
+ * Provides the focus management (keyboard navigation) in the view.
30
+ *
31
+ * @readonly
32
+ */
33
+ protected _focusCycler: FocusCycler;
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ constructor(locale: Locale);
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ render(): void;
42
+ /**
43
+ * Focuses the view.
44
+ */
45
+ focus(): void;
46
+ /**
47
+ * Focuses the first child view.
48
+ */
49
+ focusFirst(): void;
50
+ /**
51
+ * Focuses the last child view.
52
+ */
53
+ focusLast(): void;
54
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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/search/searchresultsview
7
+ */
8
+ import View from '../view';
9
+ import { FocusTracker } from '@ckeditor/ckeditor5-utils';
10
+ import { default as FocusCycler } from '../focuscycler';
11
+ /**
12
+ * A sub-component of {@link module:ui/search/text/searchtextview~SearchTextView}. It hosts the filtered and the information views.
13
+ */
14
+ export default class SearchResultsView extends View {
15
+ /**
16
+ * @inheritDoc
17
+ */
18
+ constructor(locale) {
19
+ super(locale);
20
+ this.children = this.createCollection();
21
+ this.focusTracker = new FocusTracker();
22
+ this.setTemplate({
23
+ tag: 'div',
24
+ attributes: {
25
+ class: [
26
+ 'ck',
27
+ 'ck-search__results'
28
+ ],
29
+ tabindex: -1
30
+ },
31
+ children: this.children
32
+ });
33
+ this._focusCycler = new FocusCycler({
34
+ focusables: this.children,
35
+ focusTracker: this.focusTracker
36
+ });
37
+ }
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ render() {
42
+ super.render();
43
+ for (const child of this.children) {
44
+ this.focusTracker.add(child.element);
45
+ }
46
+ }
47
+ /**
48
+ * Focuses the view.
49
+ */
50
+ focus() {
51
+ this._focusCycler.focusFirst();
52
+ }
53
+ /**
54
+ * Focuses the first child view.
55
+ */
56
+ focusFirst() {
57
+ this._focusCycler.focusFirst();
58
+ }
59
+ /**
60
+ * Focuses the last child view.
61
+ */
62
+ focusLast() {
63
+ this._focusCycler.focusLast();
64
+ }
65
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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/search/text/searchtextqueryview
7
+ */
8
+ import ButtonView from '../../button/buttonview';
9
+ import IconView from '../../icon/iconview';
10
+ import LabeledFieldView, { type LabeledFieldViewCreator } from '../../labeledfield/labeledfieldview';
11
+ import type InputBase from '../../input/inputbase';
12
+ import type { Locale } from '@ckeditor/ckeditor5-utils';
13
+ /**
14
+ * A search input field for the {@link module:ui/search/text/searchtextview~SearchTextView} component.
15
+ *
16
+ * @internal
17
+ * @extends module:ui/labeledfield/labeledfieldview~LabeledFieldView
18
+ */
19
+ export default class SearchTextQueryView<TQueryFieldView extends InputBase<HTMLInputElement | HTMLTextAreaElement>> extends LabeledFieldView<TQueryFieldView> {
20
+ /**
21
+ * The loupe icon displayed next to the {@link #fieldView}.
22
+ */
23
+ iconView?: IconView;
24
+ /**
25
+ * The button that clears and focuses the {@link #fieldView}.
26
+ */
27
+ resetButtonView?: ButtonView;
28
+ /**
29
+ * A reference to the view configuration.
30
+ */
31
+ private readonly _viewConfig;
32
+ /**
33
+ * @inheritDoc
34
+ */
35
+ constructor(locale: Locale, config: SearchTextQueryViewConfig<TQueryFieldView>);
36
+ /**
37
+ * Resets the search field to its default state.
38
+ */
39
+ reset(): void;
40
+ }
41
+ /**
42
+ * An event fired when the field is reset using the
43
+ * {@link module:ui/search/text/searchtextqueryview~SearchTextQueryView#resetButtonView}.
44
+ *
45
+ * @eventName ~SearchTextQueryView#reset
46
+ */
47
+ export type SearchTextQueryViewResetEvent = {
48
+ name: 'reset';
49
+ args: [];
50
+ };
51
+ /**
52
+ * The configuration of the {@link module:ui/search/text/searchtextqueryview~SearchTextQueryView} view.
53
+ */
54
+ export interface SearchTextQueryViewConfig<TConfigSearchField extends InputBase<HTMLInputElement | HTMLTextAreaElement>> {
55
+ /**
56
+ * The human-readable label of the search field.
57
+ */
58
+ label: string;
59
+ /**
60
+ * Determines whether the button that resets the search should be visible.
61
+ *
62
+ * @default true
63
+ */
64
+ showResetButton?: boolean;
65
+ /**
66
+ * Determines whether the loupe icon should be visible.
67
+ *
68
+ * @default true
69
+ */
70
+ showIcon?: boolean;
71
+ /**
72
+ * The function that creates the search field input view. By default, a plain
73
+ * {@link module:ui/inputtext/inputtextview~InputTextView} is used for this purpose.
74
+ */
75
+ creator?: LabeledFieldViewCreator<TConfigSearchField>;
76
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, 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/search/text/searchtextqueryview
7
+ */
8
+ import ButtonView from '../../button/buttonview';
9
+ import IconView from '../../icon/iconview';
10
+ import LabeledFieldView from '../../labeledfield/labeledfieldview';
11
+ import { createLabeledInputText } from '../../labeledfield/utils';
12
+ import { icons } from '@ckeditor/ckeditor5-core';
13
+ /**
14
+ * A search input field for the {@link module:ui/search/text/searchtextview~SearchTextView} component.
15
+ *
16
+ * @internal
17
+ * @extends module:ui/labeledfield/labeledfieldview~LabeledFieldView
18
+ */
19
+ export default class SearchTextQueryView extends LabeledFieldView {
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ constructor(locale, config) {
24
+ const t = locale.t;
25
+ const viewConfig = Object.assign({}, {
26
+ showResetButton: true,
27
+ showIcon: true,
28
+ creator: createLabeledInputText
29
+ }, config);
30
+ super(locale, viewConfig.creator);
31
+ this.label = config.label;
32
+ this._viewConfig = viewConfig;
33
+ if (this._viewConfig.showIcon) {
34
+ this.iconView = new IconView();
35
+ this.iconView.content = icons.loupe;
36
+ this.fieldWrapperChildren.add(this.iconView, 0);
37
+ this.extendTemplate({
38
+ attributes: {
39
+ class: 'ck-search__query_with-icon'
40
+ }
41
+ });
42
+ }
43
+ if (this._viewConfig.showResetButton) {
44
+ this.resetButtonView = new ButtonView(locale);
45
+ this.resetButtonView.set({
46
+ label: t('Clear'),
47
+ icon: icons.cancel,
48
+ class: 'ck-search__reset',
49
+ isVisible: false,
50
+ tooltip: true
51
+ });
52
+ this.resetButtonView.on('execute', () => {
53
+ this.reset();
54
+ this.focus();
55
+ this.fire('reset');
56
+ });
57
+ this.resetButtonView.bind('isVisible').to(this.fieldView, 'isEmpty', isEmpty => !isEmpty);
58
+ this.fieldWrapperChildren.add(this.resetButtonView);
59
+ this.extendTemplate({
60
+ attributes: {
61
+ class: 'ck-search__query_with-reset'
62
+ }
63
+ });
64
+ }
65
+ }
66
+ /**
67
+ * Resets the search field to its default state.
68
+ */
69
+ reset() {
70
+ this.fieldView.reset();
71
+ if (this._viewConfig.showResetButton) {
72
+ this.resetButtonView.isVisible = false;
73
+ }
74
+ }
75
+ }