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.
- package/README.md +5 -1
- package/bundles/qms-angular.umd.js +121 -29
- package/bundles/qms-angular.umd.js.map +1 -1
- package/esm2015/lib/components/badges/qms-badges.component.js +1 -1
- package/esm2015/lib/components/banner/qms-banner/qms-banner.component.js +1 -1
- package/esm2015/lib/components/banner/qms-banner-confirm/qms-banner-confirm.component.js +1 -1
- package/esm2015/lib/components/banner/qms-banner-loading/qms-banner-loading.component.js +1 -1
- package/esm2015/lib/components/button/button-toggle.js +1 -1
- package/esm2015/lib/components/button/button.js +3 -3
- package/esm2015/lib/components/comment/comment.js +1 -1
- package/esm2015/lib/components/dialog/dialog.js +2 -2
- package/esm2015/lib/components/list/list.js +2 -2
- package/esm2015/lib/components/qms-paginator/qms-paginator.component.js +16 -7
- package/esm2015/lib/components/related/list-other-related/list-related.component.js +1 -1
- package/esm2015/lib/components/related/risk/list/list.component.js +1 -1
- package/esm2015/lib/components/related/risk/result/result.component.js +1 -1
- package/esm2015/lib/components/rich-text/rich-text.js +1 -1
- package/esm2015/lib/components/table/table-action.js +2 -2
- package/esm2015/lib/components/tooltip/tooltip.js +1 -1
- package/esm2015/lib/components/tree/tree.component.js +1 -1
- package/esm2015/lib/components/treeNew/tree.component.js +18 -2
- package/esm2015/lib/directives/text-truncate/text-truncate.directive.js +54 -0
- package/esm2015/lib/qms-angular.module.js +4 -1
- package/esm2015/lib/qms-ckeditor-components/common/functions/common.function.js +3 -1
- package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.component.js +1 -1
- package/esm2015/public-api.js +2 -1
- package/fesm2015/qms-angular.js +112 -30
- package/fesm2015/qms-angular.js.map +1 -1
- package/lib/components/qms-paginator/qms-paginator.component.d.ts +1 -0
- package/lib/components/treeNew/tree.component.d.ts +1 -0
- package/lib/directives/text-truncate/text-truncate.directive.d.ts +14 -0
- package/lib.theme.scss +178 -3
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
- package/qms-angular.metadata.json +1 -1
- package/src/assets/fonts/Material/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2 +0 -0
- package/src/assets/fonts/Material/gok-H7zzDkdnRel8-DQ6KAXJ69wP1tGnf4ZGhUce.woff2 +0 -0
- package/src/assets/fonts/OpenSans/mem8YaGs126MiZpBA-UFUZ0bbck.woff2 +0 -0
- package/src/assets/fonts/OpenSans/mem8YaGs126MiZpBA-UFVZ0b.woff2 +0 -0
- package/src/assets/fonts/OpenSans/mem8YaGs126MiZpBA-UFVp0bbck.woff2 +0 -0
- package/src/assets/fonts/OpenSans/mem8YaGs126MiZpBA-UFW50bbck.woff2 +0 -0
- package/src/assets/fonts/OpenSans/mem8YaGs126MiZpBA-UFWJ0bbck.woff2 +0 -0
- package/src/assets/fonts/OpenSans/mem8YaGs126MiZpBA-UFWZ0bbck.woff2 +0 -0
- package/src/assets/fonts/OpenSans/mem8YaGs126MiZpBA-UFWp0bbck.woff2 +0 -0
- package/src/assets/fonts/Raleway/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCFPrEHJA.woff2 +0 -0
- package/src/assets/fonts/Raleway/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCGPrEHJA.woff2 +0 -0
- package/src/assets/fonts/Raleway/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCHPrEHJA.woff2 +0 -0
- package/src/assets/fonts/Raleway/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCIPrE.woff2 +0 -0
- package/src/assets/fonts/Raleway/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCMPrEHJA.woff2 +0 -0
- package/src/assets/qms-ckeditor-plugin/build/ckeditor.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/ckeditor.js.map +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ar.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/az.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/bg.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/cs.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/da.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/de-ch.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/de.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/en-au.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/en-gb.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/es.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/et.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/fa.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/fi.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/fr.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/gl.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/hi.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/hr.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/hu.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/id.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/it.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ja.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ko.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ku.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/lt.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/lv.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/nb.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ne.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/nl.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/no.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/pl.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/pt-br.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ro.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ru.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/sk.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/sq.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/sr-latn.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/sr.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/sv.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/th.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/tk.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/tr.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ug.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/uk.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/vi.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/zh-cn.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/zh.js +1 -1
- package/src/assets/qms-ckeditor-plugin/package-lock.json +0 -1
- package/src/assets/qms-ckeditor-plugin/package.json +0 -1
- package/src/assets/qms-ckeditor-plugin/src/ckeditor.js +5 -5
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/insertcolumncommand.js +83 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/insertrowcommand.js +82 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/inserttablecommand.js +76 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/mergecellcommand.js +272 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/mergecellscommand.js +122 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/removecolumncommand.js +122 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/removerowcommand.js +97 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/selectcolumncommand.js +63 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/selectrowcommand.js +56 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/setheadercolumncommand.js +95 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/setheaderrowcommand.js +105 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/splitcellcommand.js +68 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/downcast.js +529 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/table-cell-paragraph-post-fixer.js +136 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/table-cell-refresh-post-fixer.js +75 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/table-heading-rows-refresh-post-fixer.js +55 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/table-layout-post-fixer.js +399 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/tableproperties.js +126 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/upcasttable.js +211 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/index.js +42 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/table.js +103 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellbackgroundcolorcommand.js +35 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellbordercolorcommand.js +47 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellborderstylecommand.js +47 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellborderwidthcommand.js +62 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellheightcommand.js +51 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js +35 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellpaddingcommand.js +62 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellpropertycommand.js +110 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellverticalalignmentcommand.js +43 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/commands/tablecellwidthcommand.js +51 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/tablecellpropertiesediting.js +204 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/tablecellpropertiesui.js +401 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties/ui/tablecellpropertiesview.js +829 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablecellproperties.js +80 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableclipboard.js +586 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableediting.js +160 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablekeyboard.js +343 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablemouse/mouseeventsobserver.js +72 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablemouse.js +218 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tablealignmentcommand.js +35 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tablebackgroundcolorcommand.js +35 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tablebordercolorcommand.js +47 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tableborderstylecommand.js +47 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tableborderwidthcommand.js +62 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tableheightcommand.js +51 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tablepropertycommand.js +98 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/commands/tablewidthcommand.js +51 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/tablepropertiesediting.js +182 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/tablepropertiesui.js +397 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties/ui/tablepropertiesview.js +714 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableproperties.js +81 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableselection.js +357 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tabletoolbar.js +111 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableui.js +359 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tableutils.js +909 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/tablewalker.js +538 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/colorinput.css +39 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/form.css +11 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/formrow.css +23 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/icons/table-cell-properties.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/icons/table-column.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/icons/table-merge-cell.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/icons/table-properties.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/icons/table-row.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/icons/table.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/inserttable.css +10 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/snippet.css +3876 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/table.css +67 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/tablecaption.css +53 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/tablecellproperties.css +28 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/tableediting.css +10 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/tableform.css +59 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/tableproperties.css +18 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/tableselection.css +10 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/ui/colorinputview.js +343 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/ui/formrowview.js +103 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/ui/inserttableview.js +222 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/utils/common.js +57 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/utils/selection.js +276 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/utils/structure.js +543 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/utils/table-properties.js +66 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/utils/ui/contextualballoon.js +130 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/utils/ui/table-properties.js +397 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/utils/ui/widget.js +62 -0
- package/src/lib/components/qms-paginator/qms-paginator.component.scss +4 -1
- package/src/themes/core/_mat-icon.scss +60 -60
- package/src/themes/core/_table.scss +55 -2
- package/src/themes/core/_typography.scss +108 -108
- package/src/assets/fonts/OpenSans/OpenSans.woff2 +0 -0
@@ -0,0 +1,97 @@
|
|
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/commands/removerowcommand
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { Command } from 'ckeditor5/src/core';
|
11
|
+
|
12
|
+
import { getRowIndexes, getSelectionAffectedTableCells } from '../utils/selection';
|
13
|
+
|
14
|
+
/**
|
15
|
+
* The remove row command.
|
16
|
+
*
|
17
|
+
* The command is registered by {@link module:table/tableediting~TableEditing} as the `'removeTableRow'` editor command.
|
18
|
+
*
|
19
|
+
* To remove the row containing the selected cell, execute the command:
|
20
|
+
*
|
21
|
+
* editor.execute( 'removeTableRow' );
|
22
|
+
*
|
23
|
+
* @extends module:core/command~Command
|
24
|
+
*/
|
25
|
+
export default class RemoveRowCommand extends Command {
|
26
|
+
/**
|
27
|
+
* @inheritDoc
|
28
|
+
*/
|
29
|
+
refresh() {
|
30
|
+
const selectedCells = getSelectionAffectedTableCells( this.editor.model.document.selection );
|
31
|
+
const firstCell = selectedCells[ 0 ];
|
32
|
+
|
33
|
+
if ( firstCell ) {
|
34
|
+
const table = firstCell.findAncestor( 'table' );
|
35
|
+
const tableRowCount = this.editor.plugins.get( 'TableUtils' ).getRows( table );
|
36
|
+
const lastRowIndex = tableRowCount - 1;
|
37
|
+
|
38
|
+
const selectedRowIndexes = getRowIndexes( selectedCells );
|
39
|
+
|
40
|
+
const areAllRowsSelected = selectedRowIndexes.first === 0 && selectedRowIndexes.last === lastRowIndex;
|
41
|
+
|
42
|
+
// Disallow selecting whole table -> delete whole table should be used instead.
|
43
|
+
this.isEnabled = !areAllRowsSelected;
|
44
|
+
} else {
|
45
|
+
this.isEnabled = false;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
/**
|
50
|
+
* @inheritDoc
|
51
|
+
*/
|
52
|
+
execute() {
|
53
|
+
const model = this.editor.model;
|
54
|
+
const referenceCells = getSelectionAffectedTableCells( model.document.selection );
|
55
|
+
const removedRowIndexes = getRowIndexes( referenceCells );
|
56
|
+
|
57
|
+
const firstCell = referenceCells[ 0 ];
|
58
|
+
const table = firstCell.findAncestor( 'table' );
|
59
|
+
|
60
|
+
const columnIndexToFocus = this.editor.plugins.get( 'TableUtils' ).getCellLocation( firstCell ).column;
|
61
|
+
|
62
|
+
model.change( writer => {
|
63
|
+
const rowsToRemove = removedRowIndexes.last - removedRowIndexes.first + 1;
|
64
|
+
|
65
|
+
this.editor.plugins.get( 'TableUtils' ).removeRows( table, {
|
66
|
+
at: removedRowIndexes.first,
|
67
|
+
rows: rowsToRemove
|
68
|
+
} );
|
69
|
+
|
70
|
+
const cellToFocus = getCellToFocus( table, removedRowIndexes.first, columnIndexToFocus );
|
71
|
+
|
72
|
+
writer.setSelection( writer.createPositionAt( cellToFocus, 0 ) );
|
73
|
+
} );
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
// Returns a cell that should be focused before removing the row, belonging to the same column as the currently focused cell.
|
78
|
+
// * If the row was not the last one, the cell to focus will be in the row that followed it (before removal).
|
79
|
+
// * If the row was the last one, the cell to focus will be in the row that preceded it (before removal).
|
80
|
+
function getCellToFocus( table, removedRowIndex, columnToFocus ) {
|
81
|
+
const row = table.getChild( removedRowIndex ) || table.getChild( table.childCount - 1 );
|
82
|
+
|
83
|
+
// Default to first table cell.
|
84
|
+
let cellToFocus = row.getChild( 0 );
|
85
|
+
let column = 0;
|
86
|
+
|
87
|
+
for ( const tableCell of row.getChildren() ) {
|
88
|
+
if ( column > columnToFocus ) {
|
89
|
+
return cellToFocus;
|
90
|
+
}
|
91
|
+
|
92
|
+
cellToFocus = tableCell;
|
93
|
+
column += parseInt( tableCell.getAttribute( 'colspan' ) || 1 );
|
94
|
+
}
|
95
|
+
|
96
|
+
return cellToFocus;
|
97
|
+
}
|
@@ -0,0 +1,63 @@
|
|
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/commands/selectcolumncommand
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { Command } from 'ckeditor5/src/core';
|
11
|
+
|
12
|
+
import TableWalker from '../tablewalker';
|
13
|
+
import { getSelectionAffectedTableCells } from '../utils/selection';
|
14
|
+
|
15
|
+
/**
|
16
|
+
* The select column command.
|
17
|
+
*
|
18
|
+
* The command is registered by {@link module:table/tableediting~TableEditing} as the `'selectTableColumn'` editor command.
|
19
|
+
*
|
20
|
+
* To select the columns containing the selected cells, execute the command:
|
21
|
+
*
|
22
|
+
* editor.execute( 'selectTableColumn' );
|
23
|
+
*
|
24
|
+
* @extends module:core/command~Command
|
25
|
+
*/
|
26
|
+
export default class SelectColumnCommand extends Command {
|
27
|
+
/**
|
28
|
+
* @inheritDoc
|
29
|
+
*/
|
30
|
+
refresh() {
|
31
|
+
const selectedCells = getSelectionAffectedTableCells( this.editor.model.document.selection );
|
32
|
+
|
33
|
+
this.isEnabled = selectedCells.length > 0;
|
34
|
+
}
|
35
|
+
|
36
|
+
/**
|
37
|
+
* @inheritDoc
|
38
|
+
*/
|
39
|
+
execute() {
|
40
|
+
const model = this.editor.model;
|
41
|
+
const referenceCells = getSelectionAffectedTableCells( model.document.selection );
|
42
|
+
const firstCell = referenceCells[ 0 ];
|
43
|
+
const lastCell = referenceCells.pop();
|
44
|
+
const table = firstCell.findAncestor( 'table' );
|
45
|
+
|
46
|
+
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
47
|
+
const startLocation = tableUtils.getCellLocation( firstCell );
|
48
|
+
const endLocation = tableUtils.getCellLocation( lastCell );
|
49
|
+
|
50
|
+
const startColumn = Math.min( startLocation.column, endLocation.column );
|
51
|
+
const endColumn = Math.max( startLocation.column, endLocation.column );
|
52
|
+
|
53
|
+
const rangesToSelect = [];
|
54
|
+
|
55
|
+
for ( const cellInfo of new TableWalker( table, { startColumn, endColumn } ) ) {
|
56
|
+
rangesToSelect.push( model.createRangeOn( cellInfo.cell ) );
|
57
|
+
}
|
58
|
+
|
59
|
+
model.change( writer => {
|
60
|
+
writer.setSelection( rangesToSelect );
|
61
|
+
} );
|
62
|
+
}
|
63
|
+
}
|
@@ -0,0 +1,56 @@
|
|
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/commands/selectrowcommand
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { Command } from 'ckeditor5/src/core';
|
11
|
+
|
12
|
+
import { getRowIndexes, getSelectionAffectedTableCells } from '../utils/selection';
|
13
|
+
|
14
|
+
/**
|
15
|
+
* The select row command.
|
16
|
+
*
|
17
|
+
* The command is registered by {@link module:table/tableediting~TableEditing} as the `'selectTableRow'` editor command.
|
18
|
+
*
|
19
|
+
* To select the rows containing the selected cells, execute the command:
|
20
|
+
*
|
21
|
+
* editor.execute( 'selectTableRow' );
|
22
|
+
*
|
23
|
+
* @extends module:core/command~Command
|
24
|
+
*/
|
25
|
+
export default class SelectRowCommand extends Command {
|
26
|
+
/**
|
27
|
+
* @inheritDoc
|
28
|
+
*/
|
29
|
+
refresh() {
|
30
|
+
const selectedCells = getSelectionAffectedTableCells( this.editor.model.document.selection );
|
31
|
+
|
32
|
+
this.isEnabled = selectedCells.length > 0;
|
33
|
+
}
|
34
|
+
|
35
|
+
/**
|
36
|
+
* @inheritDoc
|
37
|
+
*/
|
38
|
+
execute() {
|
39
|
+
const model = this.editor.model;
|
40
|
+
const referenceCells = getSelectionAffectedTableCells( model.document.selection );
|
41
|
+
const rowIndexes = getRowIndexes( referenceCells );
|
42
|
+
|
43
|
+
const table = referenceCells[ 0 ].findAncestor( 'table' );
|
44
|
+
const rangesToSelect = [];
|
45
|
+
|
46
|
+
for ( let rowIndex = rowIndexes.first; rowIndex <= rowIndexes.last; rowIndex++ ) {
|
47
|
+
for ( const cell of table.getChild( rowIndex ).getChildren() ) {
|
48
|
+
rangesToSelect.push( model.createRangeOn( cell ) );
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
model.change( writer => {
|
53
|
+
writer.setSelection( rangesToSelect );
|
54
|
+
} );
|
55
|
+
}
|
56
|
+
}
|
@@ -0,0 +1,95 @@
|
|
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/commands/setheadercolumncommand
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { Command } from 'ckeditor5/src/core';
|
11
|
+
|
12
|
+
import {
|
13
|
+
isHeadingColumnCell,
|
14
|
+
updateNumericAttribute
|
15
|
+
} from '../utils/common';
|
16
|
+
import { getColumnIndexes, getSelectionAffectedTableCells } from '../utils/selection';
|
17
|
+
import { getHorizontallyOverlappingCells, splitVertically } from '../utils/structure';
|
18
|
+
|
19
|
+
/**
|
20
|
+
* The header column command.
|
21
|
+
*
|
22
|
+
* The command is registered by {@link module:table/tableediting~TableEditing} as the `'setTableColumnHeader'` editor command.
|
23
|
+
*
|
24
|
+
* You can make the column containing the selected cell a [header](https://www.w3.org/TR/html50/tabular-data.html#the-th-element)
|
25
|
+
* by executing:
|
26
|
+
*
|
27
|
+
* editor.execute( 'setTableColumnHeader' );
|
28
|
+
*
|
29
|
+
* **Note:** All preceding columns will also become headers. If the current column is already a header, executing this command
|
30
|
+
* will make it a regular column back again (including the following columns).
|
31
|
+
*
|
32
|
+
* @extends module:core/command~Command
|
33
|
+
*/
|
34
|
+
export default class SetHeaderColumnCommand extends Command {
|
35
|
+
/**
|
36
|
+
* @inheritDoc
|
37
|
+
*/
|
38
|
+
refresh() {
|
39
|
+
const model = this.editor.model;
|
40
|
+
const selectedCells = getSelectionAffectedTableCells( model.document.selection );
|
41
|
+
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
42
|
+
const isInTable = selectedCells.length > 0;
|
43
|
+
|
44
|
+
this.isEnabled = isInTable;
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Flag indicating whether the command is active. The command is active when the
|
48
|
+
* {@link module:engine/model/selection~Selection} is in a header column.
|
49
|
+
*
|
50
|
+
* @observable
|
51
|
+
* @readonly
|
52
|
+
* @member {Boolean} #value
|
53
|
+
*/
|
54
|
+
this.value = isInTable && selectedCells.every( cell => isHeadingColumnCell( tableUtils, cell ) );
|
55
|
+
}
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Executes the command.
|
59
|
+
*
|
60
|
+
* When the selection is in a non-header column, the command will set the `headingColumns` table attribute to cover that column.
|
61
|
+
*
|
62
|
+
* When the selection is already in a header column, it will set `headingColumns` so the heading section will end before that column.
|
63
|
+
*
|
64
|
+
* @fires execute
|
65
|
+
* @param {Object} [options]
|
66
|
+
* @param {Boolean} [options.forceValue] If set, the command will set (`true`) or unset (`false`) the header columns according to
|
67
|
+
* the `forceValue` parameter instead of the current model state.
|
68
|
+
*/
|
69
|
+
execute( options = {} ) {
|
70
|
+
if ( options.forceValue === this.value ) {
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
|
74
|
+
const model = this.editor.model;
|
75
|
+
const selectedCells = getSelectionAffectedTableCells( model.document.selection );
|
76
|
+
const table = selectedCells[ 0 ].findAncestor( 'table' );
|
77
|
+
|
78
|
+
const { first, last } = getColumnIndexes( selectedCells );
|
79
|
+
const headingColumnsToSet = this.value ? first : last + 1;
|
80
|
+
|
81
|
+
model.change( writer => {
|
82
|
+
if ( headingColumnsToSet ) {
|
83
|
+
// Changing heading columns requires to check if any of a heading cell is overlapping horizontally the table head.
|
84
|
+
// Any table cell that has a colspan attribute > 1 will not exceed the table head so we need to fix it in columns before.
|
85
|
+
const overlappingCells = getHorizontallyOverlappingCells( table, headingColumnsToSet );
|
86
|
+
|
87
|
+
for ( const { cell, column } of overlappingCells ) {
|
88
|
+
splitVertically( cell, column, headingColumnsToSet, writer );
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
updateNumericAttribute( 'headingColumns', headingColumnsToSet, table, writer, 0 );
|
93
|
+
} );
|
94
|
+
}
|
95
|
+
}
|
@@ -0,0 +1,105 @@
|
|
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/commands/setheaderrowcommand
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { Command } from 'ckeditor5/src/core';
|
11
|
+
|
12
|
+
import { updateNumericAttribute } from '../utils/common';
|
13
|
+
import { getRowIndexes, getSelectionAffectedTableCells } from '../utils/selection';
|
14
|
+
import { getVerticallyOverlappingCells, splitHorizontally } from '../utils/structure';
|
15
|
+
|
16
|
+
/**
|
17
|
+
* The header row command.
|
18
|
+
*
|
19
|
+
* The command is registered by {@link module:table/tableediting~TableEditing} as the `'setTableColumnHeader'` editor command.
|
20
|
+
*
|
21
|
+
* You can make the row containing the selected cell a [header](https://www.w3.org/TR/html50/tabular-data.html#the-th-element) by executing:
|
22
|
+
*
|
23
|
+
* editor.execute( 'setTableRowHeader' );
|
24
|
+
*
|
25
|
+
* **Note:** All preceding rows will also become headers. If the current row is already a header, executing this command
|
26
|
+
* will make it a regular row back again (including the following rows).
|
27
|
+
*
|
28
|
+
* @extends module:core/command~Command
|
29
|
+
*/
|
30
|
+
export default class SetHeaderRowCommand extends Command {
|
31
|
+
/**
|
32
|
+
* @inheritDoc
|
33
|
+
*/
|
34
|
+
refresh() {
|
35
|
+
const model = this.editor.model;
|
36
|
+
const selectedCells = getSelectionAffectedTableCells( model.document.selection );
|
37
|
+
const isInTable = selectedCells.length > 0;
|
38
|
+
|
39
|
+
this.isEnabled = isInTable;
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Flag indicating whether the command is active. The command is active when the
|
43
|
+
* {@link module:engine/model/selection~Selection} is in a header row.
|
44
|
+
*
|
45
|
+
* @observable
|
46
|
+
* @readonly
|
47
|
+
* @member {Boolean} #value
|
48
|
+
*/
|
49
|
+
this.value = isInTable && selectedCells.every( cell => this._isInHeading( cell, cell.parent.parent ) );
|
50
|
+
}
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Executes the command.
|
54
|
+
*
|
55
|
+
* When the selection is in a non-header row, the command will set the `headingRows` table attribute to cover that row.
|
56
|
+
*
|
57
|
+
* When the selection is already in a header row, it will set `headingRows` so the heading section will end before that row.
|
58
|
+
*
|
59
|
+
* @fires execute
|
60
|
+
* @param {Object} options
|
61
|
+
* @param {Boolean} [options.forceValue] If set, the command will set (`true`) or unset (`false`) the header rows according to
|
62
|
+
* the `forceValue` parameter instead of the current model state.
|
63
|
+
*/
|
64
|
+
execute( options = {} ) {
|
65
|
+
if ( options.forceValue === this.value ) {
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
const model = this.editor.model;
|
69
|
+
const selectedCells = getSelectionAffectedTableCells( model.document.selection );
|
70
|
+
const table = selectedCells[ 0 ].findAncestor( 'table' );
|
71
|
+
|
72
|
+
const { first, last } = getRowIndexes( selectedCells );
|
73
|
+
const headingRowsToSet = this.value ? first : last + 1;
|
74
|
+
const currentHeadingRows = table.getAttribute( 'headingRows' ) || 0;
|
75
|
+
|
76
|
+
model.change( writer => {
|
77
|
+
if ( headingRowsToSet ) {
|
78
|
+
// Changing heading rows requires to check if any of a heading cell is overlapping vertically the table head.
|
79
|
+
// Any table cell that has a rowspan attribute > 1 will not exceed the table head so we need to fix it in rows below.
|
80
|
+
const startRow = headingRowsToSet > currentHeadingRows ? currentHeadingRows : 0;
|
81
|
+
const overlappingCells = getVerticallyOverlappingCells( table, headingRowsToSet, startRow );
|
82
|
+
|
83
|
+
for ( const { cell } of overlappingCells ) {
|
84
|
+
splitHorizontally( cell, headingRowsToSet, writer );
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
updateNumericAttribute( 'headingRows', headingRowsToSet, table, writer, 0 );
|
89
|
+
} );
|
90
|
+
}
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Checks if a table cell is in the heading section.
|
94
|
+
*
|
95
|
+
* @param {module:engine/model/element~Element} tableCell
|
96
|
+
* @param {module:engine/model/element~Element} table
|
97
|
+
* @returns {Boolean}
|
98
|
+
* @private
|
99
|
+
*/
|
100
|
+
_isInHeading( tableCell, table ) {
|
101
|
+
const headingRows = parseInt( table.getAttribute( 'headingRows' ) || 0 );
|
102
|
+
|
103
|
+
return !!headingRows && tableCell.parent.index < headingRows;
|
104
|
+
}
|
105
|
+
}
|
@@ -0,0 +1,68 @@
|
|
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/commands/splitcellcommand
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { Command } from 'ckeditor5/src/core';
|
11
|
+
import { getSelectionAffectedTableCells } from '../utils/selection';
|
12
|
+
|
13
|
+
/**
|
14
|
+
* The split cell command.
|
15
|
+
*
|
16
|
+
* The command is registered by {@link module:table/tableediting~TableEditing} as the `'splitTableCellVertically'`
|
17
|
+
* and `'splitTableCellHorizontally'` editor commands.
|
18
|
+
*
|
19
|
+
* You can split any cell vertically or horizontally by executing this command. For example, to split the selected table cell vertically:
|
20
|
+
*
|
21
|
+
* editor.execute( 'splitTableCellVertically' );
|
22
|
+
*
|
23
|
+
* @extends module:core/command~Command
|
24
|
+
*/
|
25
|
+
export default class SplitCellCommand extends Command {
|
26
|
+
/**
|
27
|
+
* Creates a new `SplitCellCommand` instance.
|
28
|
+
*
|
29
|
+
* @param {module:core/editor/editor~Editor} editor The editor on which this command will be used.
|
30
|
+
* @param {Object} options
|
31
|
+
* @param {String} options.direction Indicates whether the command should split cells `'horizontally'` or `'vertically'`.
|
32
|
+
*/
|
33
|
+
constructor( editor, options = {} ) {
|
34
|
+
super( editor );
|
35
|
+
|
36
|
+
/**
|
37
|
+
* The direction that indicates which cell will be split.
|
38
|
+
*
|
39
|
+
* @readonly
|
40
|
+
* @member {String} #direction
|
41
|
+
*/
|
42
|
+
this.direction = options.direction || 'horizontally';
|
43
|
+
}
|
44
|
+
|
45
|
+
/**
|
46
|
+
* @inheritDoc
|
47
|
+
*/
|
48
|
+
refresh() {
|
49
|
+
const selectedCells = getSelectionAffectedTableCells( this.editor.model.document.selection );
|
50
|
+
|
51
|
+
this.isEnabled = selectedCells.length === 1;
|
52
|
+
}
|
53
|
+
|
54
|
+
/**
|
55
|
+
* @inheritDoc
|
56
|
+
*/
|
57
|
+
execute() {
|
58
|
+
const tableCell = getSelectionAffectedTableCells( this.editor.model.document.selection )[ 0 ];
|
59
|
+
const isHorizontal = this.direction === 'horizontally';
|
60
|
+
const tableUtils = this.editor.plugins.get( 'TableUtils' );
|
61
|
+
|
62
|
+
if ( isHorizontal ) {
|
63
|
+
tableUtils.splitCellHorizontally( tableCell, 2 );
|
64
|
+
} else {
|
65
|
+
tableUtils.splitCellVertically( tableCell, 2 );
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|