qms-angular 1.0.87 → 1.0.88

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 (190) hide show
  1. package/README.md +5 -1
  2. package/bundles/qms-angular.umd.js +121 -29
  3. package/bundles/qms-angular.umd.js.map +1 -1
  4. package/esm2015/lib/components/badges/qms-badges.component.js +1 -1
  5. package/esm2015/lib/components/banner/qms-banner/qms-banner.component.js +1 -1
  6. package/esm2015/lib/components/banner/qms-banner-confirm/qms-banner-confirm.component.js +1 -1
  7. package/esm2015/lib/components/banner/qms-banner-loading/qms-banner-loading.component.js +1 -1
  8. package/esm2015/lib/components/button/button-toggle.js +1 -1
  9. package/esm2015/lib/components/button/button.js +3 -3
  10. package/esm2015/lib/components/comment/comment.js +1 -1
  11. package/esm2015/lib/components/dialog/dialog.js +2 -2
  12. package/esm2015/lib/components/list/list.js +2 -2
  13. package/esm2015/lib/components/qms-paginator/qms-paginator.component.js +16 -7
  14. package/esm2015/lib/components/related/list-other-related/list-related.component.js +1 -1
  15. package/esm2015/lib/components/related/risk/list/list.component.js +1 -1
  16. package/esm2015/lib/components/related/risk/result/result.component.js +1 -1
  17. package/esm2015/lib/components/rich-text/rich-text.js +1 -1
  18. package/esm2015/lib/components/table/table-action.js +2 -2
  19. package/esm2015/lib/components/tooltip/tooltip.js +1 -1
  20. package/esm2015/lib/components/tree/tree.component.js +1 -1
  21. package/esm2015/lib/components/treeNew/tree.component.js +18 -2
  22. package/esm2015/lib/directives/text-truncate/text-truncate.directive.js +54 -0
  23. package/esm2015/lib/qms-angular.module.js +4 -1
  24. package/esm2015/lib/qms-ckeditor-components/common/functions/common.function.js +3 -1
  25. package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.component.js +1 -1
  26. package/esm2015/public-api.js +2 -1
  27. package/fesm2015/qms-angular.js +112 -30
  28. package/fesm2015/qms-angular.js.map +1 -1
  29. package/lib/components/qms-paginator/qms-paginator.component.d.ts +1 -0
  30. package/lib/components/treeNew/tree.component.d.ts +1 -0
  31. package/lib/directives/text-truncate/text-truncate.directive.d.ts +14 -0
  32. package/lib.theme.scss +178 -3
  33. package/package.json +1 -1
  34. package/public-api.d.ts +1 -0
  35. package/qms-angular.metadata.json +1 -1
  36. package/src/assets/fonts/Material/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2 +0 -0
  37. package/src/assets/fonts/Material/gok-H7zzDkdnRel8-DQ6KAXJ69wP1tGnf4ZGhUce.woff2 +0 -0
  38. package/src/assets/fonts/OpenSans/mem8YaGs126MiZpBA-UFUZ0bbck.woff2 +0 -0
  39. package/src/assets/fonts/OpenSans/mem8YaGs126MiZpBA-UFVZ0b.woff2 +0 -0
  40. package/src/assets/fonts/OpenSans/mem8YaGs126MiZpBA-UFVp0bbck.woff2 +0 -0
  41. package/src/assets/fonts/OpenSans/mem8YaGs126MiZpBA-UFW50bbck.woff2 +0 -0
  42. package/src/assets/fonts/OpenSans/mem8YaGs126MiZpBA-UFWJ0bbck.woff2 +0 -0
  43. package/src/assets/fonts/OpenSans/mem8YaGs126MiZpBA-UFWZ0bbck.woff2 +0 -0
  44. package/src/assets/fonts/OpenSans/mem8YaGs126MiZpBA-UFWp0bbck.woff2 +0 -0
  45. package/src/assets/fonts/Raleway/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCFPrEHJA.woff2 +0 -0
  46. package/src/assets/fonts/Raleway/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCGPrEHJA.woff2 +0 -0
  47. package/src/assets/fonts/Raleway/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCHPrEHJA.woff2 +0 -0
  48. package/src/assets/fonts/Raleway/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCIPrE.woff2 +0 -0
  49. package/src/assets/fonts/Raleway/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCMPrEHJA.woff2 +0 -0
  50. package/src/assets/qms-ckeditor-plugin/build/ckeditor.js +1 -1
  51. package/src/assets/qms-ckeditor-plugin/build/ckeditor.js.map +1 -1
  52. package/src/assets/qms-ckeditor-plugin/build/translations/ar.js +1 -1
  53. package/src/assets/qms-ckeditor-plugin/build/translations/az.js +1 -1
  54. package/src/assets/qms-ckeditor-plugin/build/translations/bg.js +1 -1
  55. package/src/assets/qms-ckeditor-plugin/build/translations/cs.js +1 -1
  56. package/src/assets/qms-ckeditor-plugin/build/translations/da.js +1 -1
  57. package/src/assets/qms-ckeditor-plugin/build/translations/de-ch.js +1 -1
  58. package/src/assets/qms-ckeditor-plugin/build/translations/de.js +1 -1
  59. package/src/assets/qms-ckeditor-plugin/build/translations/en-au.js +1 -1
  60. package/src/assets/qms-ckeditor-plugin/build/translations/en-gb.js +1 -1
  61. package/src/assets/qms-ckeditor-plugin/build/translations/es.js +1 -1
  62. package/src/assets/qms-ckeditor-plugin/build/translations/et.js +1 -1
  63. package/src/assets/qms-ckeditor-plugin/build/translations/fa.js +1 -1
  64. package/src/assets/qms-ckeditor-plugin/build/translations/fi.js +1 -1
  65. package/src/assets/qms-ckeditor-plugin/build/translations/fr.js +1 -1
  66. package/src/assets/qms-ckeditor-plugin/build/translations/gl.js +1 -1
  67. package/src/assets/qms-ckeditor-plugin/build/translations/hi.js +1 -1
  68. package/src/assets/qms-ckeditor-plugin/build/translations/hr.js +1 -1
  69. package/src/assets/qms-ckeditor-plugin/build/translations/hu.js +1 -1
  70. package/src/assets/qms-ckeditor-plugin/build/translations/id.js +1 -1
  71. package/src/assets/qms-ckeditor-plugin/build/translations/it.js +1 -1
  72. package/src/assets/qms-ckeditor-plugin/build/translations/ja.js +1 -1
  73. package/src/assets/qms-ckeditor-plugin/build/translations/ko.js +1 -1
  74. package/src/assets/qms-ckeditor-plugin/build/translations/ku.js +1 -1
  75. package/src/assets/qms-ckeditor-plugin/build/translations/lt.js +1 -1
  76. package/src/assets/qms-ckeditor-plugin/build/translations/lv.js +1 -1
  77. package/src/assets/qms-ckeditor-plugin/build/translations/nb.js +1 -1
  78. package/src/assets/qms-ckeditor-plugin/build/translations/ne.js +1 -1
  79. package/src/assets/qms-ckeditor-plugin/build/translations/nl.js +1 -1
  80. package/src/assets/qms-ckeditor-plugin/build/translations/no.js +1 -1
  81. package/src/assets/qms-ckeditor-plugin/build/translations/pl.js +1 -1
  82. package/src/assets/qms-ckeditor-plugin/build/translations/pt-br.js +1 -1
  83. package/src/assets/qms-ckeditor-plugin/build/translations/ro.js +1 -1
  84. package/src/assets/qms-ckeditor-plugin/build/translations/ru.js +1 -1
  85. package/src/assets/qms-ckeditor-plugin/build/translations/sk.js +1 -1
  86. package/src/assets/qms-ckeditor-plugin/build/translations/sq.js +1 -1
  87. package/src/assets/qms-ckeditor-plugin/build/translations/sr-latn.js +1 -1
  88. package/src/assets/qms-ckeditor-plugin/build/translations/sr.js +1 -1
  89. package/src/assets/qms-ckeditor-plugin/build/translations/sv.js +1 -1
  90. package/src/assets/qms-ckeditor-plugin/build/translations/th.js +1 -1
  91. package/src/assets/qms-ckeditor-plugin/build/translations/tk.js +1 -1
  92. package/src/assets/qms-ckeditor-plugin/build/translations/tr.js +1 -1
  93. package/src/assets/qms-ckeditor-plugin/build/translations/ug.js +1 -1
  94. package/src/assets/qms-ckeditor-plugin/build/translations/uk.js +1 -1
  95. package/src/assets/qms-ckeditor-plugin/build/translations/vi.js +1 -1
  96. package/src/assets/qms-ckeditor-plugin/build/translations/zh-cn.js +1 -1
  97. package/src/assets/qms-ckeditor-plugin/build/translations/zh.js +1 -1
  98. package/src/assets/qms-ckeditor-plugin/package-lock.json +0 -1
  99. package/src/assets/qms-ckeditor-plugin/package.json +0 -1
  100. package/src/assets/qms-ckeditor-plugin/src/ckeditor.js +5 -5
  101. package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/insertcolumncommand.js +83 -0
  102. package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/insertrowcommand.js +82 -0
  103. package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/inserttablecommand.js +76 -0
  104. package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/mergecellcommand.js +272 -0
  105. package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/mergecellscommand.js +122 -0
  106. package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/removecolumncommand.js +122 -0
  107. package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/removerowcommand.js +97 -0
  108. package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/selectcolumncommand.js +63 -0
  109. package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/selectrowcommand.js +56 -0
  110. package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/setheadercolumncommand.js +95 -0
  111. package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/setheaderrowcommand.js +105 -0
  112. package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/splitcellcommand.js +68 -0
  113. package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/downcast.js +529 -0
  114. package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/table-cell-paragraph-post-fixer.js +136 -0
  115. package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/table-cell-refresh-post-fixer.js +75 -0
  116. package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/table-heading-rows-refresh-post-fixer.js +55 -0
  117. package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/table-layout-post-fixer.js +399 -0
  118. package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/tableproperties.js +126 -0
  119. package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/upcasttable.js +211 -0
  120. package/src/assets/qms-ckeditor-plugin/src/plugins/table/index.js +42 -0
  121. package/src/assets/qms-ckeditor-plugin/src/plugins/table/table.js +103 -0
  122. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellbackgroundcolorcommand.js +35 -0
  123. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellbordercolorcommand.js +47 -0
  124. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellborderstylecommand.js +47 -0
  125. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellborderwidthcommand.js +62 -0
  126. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellheightcommand.js +51 -0
  127. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js +35 -0
  128. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellpaddingcommand.js +62 -0
  129. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellpropertycommand.js +110 -0
  130. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellverticalalignmentcommand.js +43 -0
  131. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellwidthcommand.js +51 -0
  132. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/tablecellpropertiesediting.js +204 -0
  133. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/tablecellpropertiesui.js +401 -0
  134. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/ui/tablecellpropertiesview.js +829 -0
  135. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties.js +80 -0
  136. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableclipboard.js +586 -0
  137. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableediting.js +160 -0
  138. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablekeyboard.js +343 -0
  139. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablemouse/mouseeventsobserver.js +72 -0
  140. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablemouse.js +218 -0
  141. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tablealignmentcommand.js +35 -0
  142. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tablebackgroundcolorcommand.js +35 -0
  143. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tablebordercolorcommand.js +47 -0
  144. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tableborderstylecommand.js +47 -0
  145. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tableborderwidthcommand.js +62 -0
  146. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tableheightcommand.js +51 -0
  147. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tablepropertycommand.js +98 -0
  148. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tablewidthcommand.js +51 -0
  149. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/tablepropertiesediting.js +182 -0
  150. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/tablepropertiesui.js +397 -0
  151. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/ui/tablepropertiesview.js +714 -0
  152. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties.js +81 -0
  153. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableselection.js +357 -0
  154. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tabletoolbar.js +111 -0
  155. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableui.js +359 -0
  156. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableutils.js +909 -0
  157. package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablewalker.js +538 -0
  158. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/colorinput.css +39 -0
  159. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/form.css +11 -0
  160. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/formrow.css +23 -0
  161. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/icons/table-cell-properties.svg +1 -0
  162. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/icons/table-column.svg +1 -0
  163. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/icons/table-merge-cell.svg +1 -0
  164. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/icons/table-properties.svg +1 -0
  165. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/icons/table-row.svg +1 -0
  166. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/icons/table.svg +1 -0
  167. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/inserttable.css +10 -0
  168. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/snippet.css +3876 -0
  169. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/table.css +67 -0
  170. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/tablecaption.css +53 -0
  171. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/tablecellproperties.css +28 -0
  172. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/tableediting.css +10 -0
  173. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/tableform.css +59 -0
  174. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/tableproperties.css +18 -0
  175. package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/tableselection.css +10 -0
  176. package/src/assets/qms-ckeditor-plugin/src/plugins/table/ui/colorinputview.js +343 -0
  177. package/src/assets/qms-ckeditor-plugin/src/plugins/table/ui/formrowview.js +103 -0
  178. package/src/assets/qms-ckeditor-plugin/src/plugins/table/ui/inserttableview.js +222 -0
  179. package/src/assets/qms-ckeditor-plugin/src/plugins/table/utils/common.js +57 -0
  180. package/src/assets/qms-ckeditor-plugin/src/plugins/table/utils/selection.js +276 -0
  181. package/src/assets/qms-ckeditor-plugin/src/plugins/table/utils/structure.js +543 -0
  182. package/src/assets/qms-ckeditor-plugin/src/plugins/table/utils/table-properties.js +66 -0
  183. package/src/assets/qms-ckeditor-plugin/src/plugins/table/utils/ui/contextualballoon.js +130 -0
  184. package/src/assets/qms-ckeditor-plugin/src/plugins/table/utils/ui/table-properties.js +397 -0
  185. package/src/assets/qms-ckeditor-plugin/src/plugins/table/utils/ui/widget.js +62 -0
  186. package/src/lib/components/qms-paginator/qms-paginator.component.scss +4 -1
  187. package/src/themes/core/_mat-icon.scss +60 -60
  188. package/src/themes/core/_table.scss +55 -2
  189. package/src/themes/core/_typography.scss +108 -108
  190. package/src/assets/fonts/OpenSans/OpenSans.woff2 +0 -0
@@ -0,0 +1,359 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module table/tableui
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import { addListToDropdown, createDropdown, Model, SplitButtonView } from 'ckeditor5/src/ui';
12
+ import { Collection } from 'ckeditor5/src/utils';
13
+
14
+ import InsertTableView from './ui/inserttableview';
15
+
16
+ import tableIcon from './theme/icons/table.svg';
17
+ import tableColumnIcon from './theme/icons/table-column.svg';
18
+ import tableRowIcon from './theme/icons/table-row.svg';
19
+ import tableMergeCellIcon from './theme/icons/table-merge-cell.svg';
20
+
21
+ /**
22
+ * The table UI plugin. It introduces:
23
+ *
24
+ * * The `'insertTable'` dropdown,
25
+ * * The `'tableColumn'` dropdown,
26
+ * * The `'tableRow'` dropdown,
27
+ * * The `'mergeTableCells'` split button.
28
+ *
29
+ * The `'tableColumn'`, `'tableRow'` and `'mergeTableCells'` dropdowns work best with {@link module:table/tabletoolbar~TableToolbar}.
30
+ *
31
+ * @extends module:core/plugin~Plugin
32
+ */
33
+ export default class TableUI extends Plugin {
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ static get pluginName() {
38
+ return 'TableUI';
39
+ }
40
+
41
+ /**
42
+ * @inheritDoc
43
+ */
44
+ init() {
45
+ const editor = this.editor;
46
+ const t = this.editor.t;
47
+ const contentLanguageDirection = editor.locale.contentLanguageDirection;
48
+ const isContentLtr = contentLanguageDirection === 'ltr';
49
+
50
+ editor.ui.componentFactory.add( 'insertTable', locale => {
51
+ const command = editor.commands.get( 'insertTable' );
52
+ const dropdownView = createDropdown( locale );
53
+
54
+ dropdownView.bind( 'isEnabled' ).to( command );
55
+
56
+ // Decorate dropdown's button.
57
+ dropdownView.buttonView.set( {
58
+ icon: tableIcon,
59
+ label: t( 'Insert table' ),
60
+ tooltip: true
61
+ } );
62
+
63
+ let insertTableView;
64
+
65
+ dropdownView.on( 'change:isOpen', () => {
66
+ if ( insertTableView ) {
67
+ return;
68
+ }
69
+
70
+ // Prepare custom view for dropdown's panel.
71
+ insertTableView = new InsertTableView( locale );
72
+ dropdownView.panelView.children.add( insertTableView );
73
+
74
+ insertTableView.delegate( 'execute' ).to( dropdownView );
75
+
76
+ dropdownView.buttonView.on( 'open', () => {
77
+ // Reset the chooser before showing it to the user.
78
+ insertTableView.rows = 0;
79
+ insertTableView.columns = 0;
80
+ } );
81
+
82
+ dropdownView.on( 'execute', () => {
83
+ editor.execute( 'insertTable', { rows: insertTableView.rows, columns: insertTableView.columns } );
84
+ editor.editing.view.focus();
85
+ } );
86
+ } );
87
+
88
+ return dropdownView;
89
+ } );
90
+
91
+ editor.ui.componentFactory.add( 'tableColumn', locale => {
92
+ const options = [
93
+ {
94
+ type: 'switchbutton',
95
+ model: {
96
+ commandName: 'setTableColumnHeader',
97
+ label: t( 'Header column' ),
98
+ bindIsOn: true
99
+ }
100
+ },
101
+ { type: 'separator' },
102
+ {
103
+ type: 'button',
104
+ model: {
105
+ commandName: isContentLtr ? 'insertTableColumnLeft' : 'insertTableColumnRight',
106
+ label: t( 'Insert column left' )
107
+ }
108
+ },
109
+ {
110
+ type: 'button',
111
+ model: {
112
+ commandName: isContentLtr ? 'insertTableColumnRight' : 'insertTableColumnLeft',
113
+ label: t( 'Insert column right' )
114
+ }
115
+ },
116
+ {
117
+ type: 'button',
118
+ model: {
119
+ commandName: 'removeTableColumn',
120
+ label: t( 'Delete column' )
121
+ }
122
+ },
123
+ {
124
+ type: 'button',
125
+ model: {
126
+ commandName: 'selectTableColumn',
127
+ label: t( 'Select column' )
128
+ }
129
+ }
130
+ ];
131
+
132
+ return this._prepareDropdown( t( 'Column' ), tableColumnIcon, options, locale );
133
+ } );
134
+
135
+ editor.ui.componentFactory.add( 'tableRow', locale => {
136
+ const options = [
137
+ {
138
+ type: 'switchbutton',
139
+ model: {
140
+ commandName: 'setTableRowHeader',
141
+ label: t( 'Header row' ),
142
+ bindIsOn: true
143
+ }
144
+ },
145
+ { type: 'separator' },
146
+ {
147
+ type: 'button',
148
+ model: {
149
+ commandName: 'insertTableRowAbove',
150
+ label: t( 'Insert row above' )
151
+ }
152
+ },
153
+ {
154
+ type: 'button',
155
+ model: {
156
+ commandName: 'insertTableRowBelow',
157
+ label: t( 'Insert row below' )
158
+ }
159
+ },
160
+ {
161
+ type: 'button',
162
+ model: {
163
+ commandName: 'removeTableRow',
164
+ label: t( 'Delete row' )
165
+ }
166
+ },
167
+ {
168
+ type: 'button',
169
+ model: {
170
+ commandName: 'selectTableRow',
171
+ label: t( 'Select row' )
172
+ }
173
+ }
174
+ ];
175
+
176
+ return this._prepareDropdown( t( 'Row' ), tableRowIcon, options, locale );
177
+ } );
178
+
179
+ editor.ui.componentFactory.add( 'mergeTableCells', locale => {
180
+ const options = [
181
+ {
182
+ type: 'button',
183
+ model: {
184
+ commandName: 'mergeTableCellUp',
185
+ label: t( 'Merge cell up' )
186
+ }
187
+ },
188
+ {
189
+ type: 'button',
190
+ model: {
191
+ commandName: isContentLtr ? 'mergeTableCellRight' : 'mergeTableCellLeft',
192
+ label: t( 'Merge cell right' )
193
+ }
194
+ },
195
+ {
196
+ type: 'button',
197
+ model: {
198
+ commandName: 'mergeTableCellDown',
199
+ label: t( 'Merge cell down' )
200
+ }
201
+ },
202
+ {
203
+ type: 'button',
204
+ model: {
205
+ commandName: isContentLtr ? 'mergeTableCellLeft' : 'mergeTableCellRight',
206
+ label: t( 'Merge cell left' )
207
+ }
208
+ },
209
+ { type: 'separator' },
210
+ {
211
+ type: 'button',
212
+ model: {
213
+ commandName: 'splitTableCellVertically',
214
+ label: t( 'Split cell vertically' )
215
+ }
216
+ },
217
+ {
218
+ type: 'button',
219
+ model: {
220
+ commandName: 'splitTableCellHorizontally',
221
+ label: t( 'Split cell horizontally' )
222
+ }
223
+ }
224
+ ];
225
+
226
+ return this._prepareMergeSplitButtonDropdown( t( 'Merge cells' ), tableMergeCellIcon, options, locale );
227
+ } );
228
+ }
229
+
230
+ /**
231
+ * Creates a dropdown view from a set of options.
232
+ *
233
+ * @private
234
+ * @param {String} label The dropdown button label.
235
+ * @param {String} icon An icon for the dropdown button.
236
+ * @param {Array.<module:ui/dropdown/utils~ListDropdownItemDefinition>} options The list of options for the dropdown.
237
+ * @param {module:utils/locale~Locale} locale
238
+ * @returns {module:ui/dropdown/dropdownview~DropdownView}
239
+ */
240
+ _prepareDropdown( label, icon, options, locale ) {
241
+ const editor = this.editor;
242
+ const dropdownView = createDropdown( locale );
243
+ const commands = this._fillDropdownWithListOptions( dropdownView, options );
244
+
245
+ // Decorate dropdown's button.
246
+ dropdownView.buttonView.set( {
247
+ label,
248
+ icon,
249
+ tooltip: true
250
+ } );
251
+
252
+ // Make dropdown button disabled when all options are disabled.
253
+ dropdownView.bind( 'isEnabled' ).toMany( commands, 'isEnabled', ( ...areEnabled ) => {
254
+ return areEnabled.some( isEnabled => isEnabled );
255
+ } );
256
+
257
+ this.listenTo( dropdownView, 'execute', evt => {
258
+ editor.execute( evt.source.commandName );
259
+ editor.editing.view.focus();
260
+ } );
261
+
262
+ return dropdownView;
263
+ }
264
+
265
+ /**
266
+ * Creates a dropdown view with a {@link module:ui/dropdown/button/splitbuttonview~SplitButtonView} for
267
+ * merge (and split)–related commands.
268
+ *
269
+ * @private
270
+ * @param {String} label The dropdown button label.
271
+ * @param {String} icon An icon for the dropdown button.
272
+ * @param {Array.<module:ui/dropdown/utils~ListDropdownItemDefinition>} options The list of options for the dropdown.
273
+ * @param {module:utils/locale~Locale} locale
274
+ * @returns {module:ui/dropdown/dropdownview~DropdownView}
275
+ */
276
+ _prepareMergeSplitButtonDropdown( label, icon, options, locale ) {
277
+ const editor = this.editor;
278
+ const dropdownView = createDropdown( locale, SplitButtonView );
279
+ const mergeCommandName = 'mergeTableCells';
280
+
281
+ this._fillDropdownWithListOptions( dropdownView, options );
282
+
283
+ dropdownView.buttonView.set( {
284
+ label,
285
+ icon,
286
+ tooltip: true,
287
+ isEnabled: true
288
+ } );
289
+
290
+ // Merge selected table cells when the main part of the split button is clicked.
291
+ this.listenTo( dropdownView.buttonView, 'execute', () => {
292
+ editor.execute( mergeCommandName );
293
+ editor.editing.view.focus();
294
+ } );
295
+
296
+ // Execute commands for events coming from the list in the dropdown panel.
297
+ this.listenTo( dropdownView, 'execute', evt => {
298
+ editor.execute( evt.source.commandName );
299
+ editor.editing.view.focus();
300
+ } );
301
+
302
+ return dropdownView;
303
+ }
304
+
305
+ /**
306
+ * Injects a {@link module:ui/list/listview~ListView} into the passed dropdown with buttons
307
+ * which execute editor commands as configured in passed options.
308
+ *
309
+ * @private
310
+ * @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView
311
+ * @param {Array.<module:ui/dropdown/utils~ListDropdownItemDefinition>} options The list of options for the dropdown.
312
+ * @returns {Array.<module:core/command~Command>} Commands the list options are interacting with.
313
+ */
314
+ _fillDropdownWithListOptions( dropdownView, options ) {
315
+ const editor = this.editor;
316
+ const commands = [];
317
+ const itemDefinitions = new Collection();
318
+
319
+ for ( const option of options ) {
320
+ addListOption( option, editor, commands, itemDefinitions );
321
+ }
322
+
323
+ addListToDropdown( dropdownView, itemDefinitions, editor.ui.componentFactory );
324
+
325
+ return commands;
326
+ }
327
+ }
328
+
329
+ // Adds an option to a list view.
330
+ //
331
+ // @param {module:table/tableui~DropdownOption} option A configuration option.
332
+ // @param {module:core/editor/editor~Editor} editor
333
+ // @param {Array.<module:core/command~Command>} commands The list of commands to update.
334
+ // @param {Iterable.<module:ui/dropdown/utils~ListDropdownItemDefinition>} itemDefinitions
335
+ // A collection of dropdown items to update with the given option.
336
+ function addListOption( option, editor, commands, itemDefinitions ) {
337
+ const model = option.model = new Model( option.model );
338
+ const { commandName, bindIsOn } = option.model;
339
+
340
+ if ( option.type === 'button' || option.type === 'switchbutton' ) {
341
+ const command = editor.commands.get( commandName );
342
+
343
+ commands.push( command );
344
+
345
+ model.set( { commandName } );
346
+
347
+ model.bind( 'isEnabled' ).to( command );
348
+
349
+ if ( bindIsOn ) {
350
+ model.bind( 'isOn' ).to( command, 'value' );
351
+ }
352
+ }
353
+
354
+ model.set( {
355
+ withText: true
356
+ } );
357
+
358
+ itemDefinitions.add( option );
359
+ }