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,401 @@
|
|
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/tablecellproperties/tablecellpropertiesui
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { Plugin } from 'ckeditor5/src/core';
|
11
|
+
import { ButtonView, clickOutsideHandler, ContextualBalloon, getLocalizedColorOptions, normalizeColorOptions } from 'ckeditor5/src/ui';
|
12
|
+
|
13
|
+
import TableCellPropertiesView from './ui/tablecellpropertiesview';
|
14
|
+
import {
|
15
|
+
colorFieldValidator,
|
16
|
+
getLocalizedColorErrorText,
|
17
|
+
getLocalizedLengthErrorText,
|
18
|
+
defaultColors,
|
19
|
+
lengthFieldValidator,
|
20
|
+
lineWidthFieldValidator
|
21
|
+
} from '../utils/ui/table-properties';
|
22
|
+
import { debounce } from 'lodash-es';
|
23
|
+
import { getTableWidgetAncestor } from '../utils/ui/widget';
|
24
|
+
import { getBalloonCellPositionData, repositionContextualBalloon } from '../utils/ui/contextualballoon';
|
25
|
+
|
26
|
+
import tableCellProperties from '../theme/icons/table-cell-properties.svg';
|
27
|
+
|
28
|
+
const ERROR_TEXT_TIMEOUT = 500;
|
29
|
+
|
30
|
+
// Map of view properties and related commands.
|
31
|
+
const propertyToCommandMap = {
|
32
|
+
borderStyle: 'tableCellBorderStyle',
|
33
|
+
borderColor: 'tableCellBorderColor',
|
34
|
+
borderWidth: 'tableCellBorderWidth',
|
35
|
+
width: 'tableCellWidth',
|
36
|
+
height: 'tableCellHeight',
|
37
|
+
padding: 'tableCellPadding',
|
38
|
+
backgroundColor: 'tableCellBackgroundColor',
|
39
|
+
horizontalAlignment: 'tableCellHorizontalAlignment',
|
40
|
+
verticalAlignment: 'tableCellVerticalAlignment'
|
41
|
+
};
|
42
|
+
|
43
|
+
/**
|
44
|
+
* The table cell properties UI plugin. It introduces the `'tableCellProperties'` button
|
45
|
+
* that opens a form allowing to specify the visual styling of a table cell.
|
46
|
+
*
|
47
|
+
* It uses the
|
48
|
+
* {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon plugin}.
|
49
|
+
*
|
50
|
+
* @extends module:core/plugin~Plugin
|
51
|
+
*/
|
52
|
+
export default class TableCellPropertiesUI extends Plugin {
|
53
|
+
/**
|
54
|
+
* @inheritDoc
|
55
|
+
*/
|
56
|
+
static get requires() {
|
57
|
+
return [ ContextualBalloon ];
|
58
|
+
}
|
59
|
+
|
60
|
+
/**
|
61
|
+
* @inheritDoc
|
62
|
+
*/
|
63
|
+
static get pluginName() {
|
64
|
+
return 'TableCellPropertiesUI';
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* @inheritDoc
|
69
|
+
*/
|
70
|
+
constructor( editor ) {
|
71
|
+
super( editor );
|
72
|
+
|
73
|
+
editor.config.define( 'table.tableCellProperties', {
|
74
|
+
borderColors: defaultColors,
|
75
|
+
backgroundColors: defaultColors
|
76
|
+
} );
|
77
|
+
}
|
78
|
+
|
79
|
+
/**
|
80
|
+
* @inheritDoc
|
81
|
+
*/
|
82
|
+
init() {
|
83
|
+
const editor = this.editor;
|
84
|
+
const t = editor.t;
|
85
|
+
|
86
|
+
/**
|
87
|
+
* The contextual balloon plugin instance.
|
88
|
+
*
|
89
|
+
* @private
|
90
|
+
* @member {module:ui/panel/balloon/contextualballoon~ContextualBalloon}
|
91
|
+
*/
|
92
|
+
this._balloon = editor.plugins.get( ContextualBalloon );
|
93
|
+
|
94
|
+
/**
|
95
|
+
* The cell properties form view displayed inside the balloon.
|
96
|
+
*
|
97
|
+
* @member {module:table/tablecellproperties/ui/tablecellpropertiesview~TableCellPropertiesView}
|
98
|
+
*/
|
99
|
+
this.view = this._createPropertiesView();
|
100
|
+
|
101
|
+
/**
|
102
|
+
* The batch used to undo all changes made by the form (which are live, as the user types)
|
103
|
+
* when "Cancel" was pressed. Each time the view is shown, a new batch is created.
|
104
|
+
*
|
105
|
+
* @protected
|
106
|
+
* @member {module:engine/model/batch~Batch}
|
107
|
+
*/
|
108
|
+
this._undoStepBatch = null;
|
109
|
+
|
110
|
+
editor.ui.componentFactory.add( 'tableCellProperties', locale => {
|
111
|
+
const view = new ButtonView( locale );
|
112
|
+
|
113
|
+
view.set( {
|
114
|
+
label: t( 'Cell properties' ),
|
115
|
+
icon: tableCellProperties,
|
116
|
+
tooltip: true
|
117
|
+
} );
|
118
|
+
|
119
|
+
this.listenTo( view, 'execute', () => this._showView() );
|
120
|
+
|
121
|
+
const commands = Object.values( propertyToCommandMap )
|
122
|
+
.map( commandName => editor.commands.get( commandName ) );
|
123
|
+
|
124
|
+
view.bind( 'isEnabled' ).toMany( commands, 'isEnabled', ( ...areEnabled ) => (
|
125
|
+
areEnabled.some( isCommandEnabled => isCommandEnabled )
|
126
|
+
) );
|
127
|
+
|
128
|
+
return view;
|
129
|
+
} );
|
130
|
+
}
|
131
|
+
|
132
|
+
/**
|
133
|
+
* @inheritDoc
|
134
|
+
*/
|
135
|
+
destroy() {
|
136
|
+
super.destroy();
|
137
|
+
|
138
|
+
// Destroy created UI components as they are not automatically destroyed.
|
139
|
+
// See https://github.com/ckeditor/ckeditor5/issues/1341.
|
140
|
+
this.view.destroy();
|
141
|
+
}
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Creates the {@link module:table/tablecellproperties/ui/tablecellpropertiesview~TableCellPropertiesView} instance.
|
145
|
+
*
|
146
|
+
* @private
|
147
|
+
* @returns {module:table/tablecellproperties/ui/tablecellpropertiesview~TableCellPropertiesView} The cell
|
148
|
+
* properties form view instance.
|
149
|
+
*/
|
150
|
+
_createPropertiesView() {
|
151
|
+
const editor = this.editor;
|
152
|
+
const viewDocument = editor.editing.view.document;
|
153
|
+
const config = editor.config.get( 'table.tableCellProperties' );
|
154
|
+
const borderColorsConfig = normalizeColorOptions( config.borderColors );
|
155
|
+
const localizedBorderColors = getLocalizedColorOptions( editor.locale, borderColorsConfig );
|
156
|
+
const backgroundColorsConfig = normalizeColorOptions( config.backgroundColors );
|
157
|
+
const localizedBackgroundColors = getLocalizedColorOptions( editor.locale, backgroundColorsConfig );
|
158
|
+
const view = new TableCellPropertiesView( editor.locale, {
|
159
|
+
borderColors: localizedBorderColors,
|
160
|
+
backgroundColors: localizedBackgroundColors
|
161
|
+
} );
|
162
|
+
const t = editor.t;
|
163
|
+
|
164
|
+
// Render the view so its #element is available for the clickOutsideHandler.
|
165
|
+
view.render();
|
166
|
+
|
167
|
+
this.listenTo( view, 'submit', () => {
|
168
|
+
this._hideView();
|
169
|
+
} );
|
170
|
+
|
171
|
+
this.listenTo( view, 'cancel', () => {
|
172
|
+
// https://github.com/ckeditor/ckeditor5/issues/6180
|
173
|
+
if ( this._undoStepBatch.operations.length ) {
|
174
|
+
editor.execute( 'undo', this._undoStepBatch );
|
175
|
+
}
|
176
|
+
|
177
|
+
this._hideView();
|
178
|
+
} );
|
179
|
+
|
180
|
+
// Close the balloon on Esc key press.
|
181
|
+
view.keystrokes.set( 'Esc', ( data, cancel ) => {
|
182
|
+
this._hideView();
|
183
|
+
cancel();
|
184
|
+
} );
|
185
|
+
|
186
|
+
// Reposition the balloon or hide the form if a table cell is no longer selected.
|
187
|
+
this.listenTo( editor.ui, 'update', () => {
|
188
|
+
if ( !getTableWidgetAncestor( viewDocument.selection ) ) {
|
189
|
+
this._hideView();
|
190
|
+
} else if ( this._isViewVisible ) {
|
191
|
+
repositionContextualBalloon( editor, 'cell' );
|
192
|
+
}
|
193
|
+
} );
|
194
|
+
|
195
|
+
// Close on click outside of balloon panel element.
|
196
|
+
clickOutsideHandler( {
|
197
|
+
emitter: view,
|
198
|
+
activator: () => this._isViewInBalloon,
|
199
|
+
contextElements: [ this._balloon.view.element ],
|
200
|
+
callback: () => this._hideView()
|
201
|
+
} );
|
202
|
+
|
203
|
+
const colorErrorText = getLocalizedColorErrorText( t );
|
204
|
+
const lengthErrorText = getLocalizedLengthErrorText( t );
|
205
|
+
|
206
|
+
// Create the "UI -> editor data" binding.
|
207
|
+
// These listeners update the editor data (via table commands) when any observable
|
208
|
+
// property of the view has changed. They also validate the value and display errors in the UI
|
209
|
+
// when necessary. This makes the view live, which means the changes are
|
210
|
+
// visible in the editing as soon as the user types or changes fields' values.
|
211
|
+
view.on( 'change:borderStyle', this._getPropertyChangeCallback( 'tableCellBorderStyle' ) );
|
212
|
+
|
213
|
+
view.on( 'change:borderColor', this._getValidatedPropertyChangeCallback( {
|
214
|
+
viewField: view.borderColorInput,
|
215
|
+
commandName: 'tableCellBorderColor',
|
216
|
+
errorText: colorErrorText,
|
217
|
+
validator: colorFieldValidator
|
218
|
+
} ) );
|
219
|
+
|
220
|
+
view.on( 'change:borderWidth', this._getValidatedPropertyChangeCallback( {
|
221
|
+
viewField: view.borderWidthInput,
|
222
|
+
commandName: 'tableCellBorderWidth',
|
223
|
+
errorText: lengthErrorText,
|
224
|
+
validator: lineWidthFieldValidator
|
225
|
+
} ) );
|
226
|
+
|
227
|
+
view.on( 'change:padding', this._getValidatedPropertyChangeCallback( {
|
228
|
+
viewField: view.paddingInput,
|
229
|
+
commandName: 'tableCellPadding',
|
230
|
+
errorText: lengthErrorText,
|
231
|
+
validator: lengthFieldValidator
|
232
|
+
} ) );
|
233
|
+
|
234
|
+
view.on( 'change:width', this._getValidatedPropertyChangeCallback( {
|
235
|
+
viewField: view.widthInput,
|
236
|
+
commandName: 'tableCellWidth',
|
237
|
+
errorText: lengthErrorText,
|
238
|
+
validator: lengthFieldValidator
|
239
|
+
} ) );
|
240
|
+
|
241
|
+
view.on( 'change:height', this._getValidatedPropertyChangeCallback( {
|
242
|
+
viewField: view.heightInput,
|
243
|
+
commandName: 'tableCellHeight',
|
244
|
+
errorText: lengthErrorText,
|
245
|
+
validator: lengthFieldValidator
|
246
|
+
} ) );
|
247
|
+
|
248
|
+
view.on( 'change:backgroundColor', this._getValidatedPropertyChangeCallback( {
|
249
|
+
viewField: view.backgroundInput,
|
250
|
+
commandName: 'tableCellBackgroundColor',
|
251
|
+
errorText: colorErrorText,
|
252
|
+
validator: colorFieldValidator
|
253
|
+
} ) );
|
254
|
+
|
255
|
+
view.on( 'change:horizontalAlignment', this._getPropertyChangeCallback( 'tableCellHorizontalAlignment' ) );
|
256
|
+
view.on( 'change:verticalAlignment', this._getPropertyChangeCallback( 'tableCellVerticalAlignment' ) );
|
257
|
+
|
258
|
+
return view;
|
259
|
+
}
|
260
|
+
|
261
|
+
/**
|
262
|
+
* In this method the "editor data -> UI" binding is happening.
|
263
|
+
*
|
264
|
+
* When executed, this method obtains selected cell property values from various table commands
|
265
|
+
* and passes them to the {@link #view}.
|
266
|
+
*
|
267
|
+
* This way, the UI stays up–to–date with the editor data.
|
268
|
+
*
|
269
|
+
* @private
|
270
|
+
*/
|
271
|
+
_fillViewFormFromCommandValues() {
|
272
|
+
const commands = this.editor.commands;
|
273
|
+
|
274
|
+
Object.entries( propertyToCommandMap )
|
275
|
+
.map( ( [ property, commandName ] ) => [ property, commands.get( commandName ).value || '' ] )
|
276
|
+
.forEach( ( [ property, value ] ) => this.view.set( property, value ) );
|
277
|
+
}
|
278
|
+
|
279
|
+
/**
|
280
|
+
* Shows the {@link #view} in the {@link #_balloon}.
|
281
|
+
*
|
282
|
+
* **Note**: Each time a view is shown, a new {@link #_undoStepBatch} is created. It contains
|
283
|
+
* all changes made to the document when the view is visible, allowing a single undo step
|
284
|
+
* for all of them.
|
285
|
+
*
|
286
|
+
* @protected
|
287
|
+
*/
|
288
|
+
_showView() {
|
289
|
+
const editor = this.editor;
|
290
|
+
|
291
|
+
// Update the view with the model values.
|
292
|
+
this._fillViewFormFromCommandValues();
|
293
|
+
|
294
|
+
this._balloon.add( {
|
295
|
+
view: this.view,
|
296
|
+
position: getBalloonCellPositionData( editor )
|
297
|
+
} );
|
298
|
+
|
299
|
+
// Create a new batch. Clicking "Cancel" will undo this batch.
|
300
|
+
this._undoStepBatch = editor.model.createBatch();
|
301
|
+
|
302
|
+
// Basic a11y.
|
303
|
+
this.view.focus();
|
304
|
+
}
|
305
|
+
|
306
|
+
/**
|
307
|
+
* Removes the {@link #view} from the {@link #_balloon}.
|
308
|
+
*
|
309
|
+
* @protected
|
310
|
+
*/
|
311
|
+
_hideView() {
|
312
|
+
if ( !this._isViewInBalloon ) {
|
313
|
+
return;
|
314
|
+
}
|
315
|
+
|
316
|
+
const editor = this.editor;
|
317
|
+
|
318
|
+
this.stopListening( editor.ui, 'update' );
|
319
|
+
|
320
|
+
// Blur any input element before removing it from DOM to prevent issues in some browsers.
|
321
|
+
// See https://github.com/ckeditor/ckeditor5/issues/1501.
|
322
|
+
this.view.saveButtonView.focus();
|
323
|
+
|
324
|
+
this._balloon.remove( this.view );
|
325
|
+
|
326
|
+
// Make sure the focus is not lost in the process by putting it directly
|
327
|
+
// into the editing view.
|
328
|
+
this.editor.editing.view.focus();
|
329
|
+
}
|
330
|
+
|
331
|
+
/**
|
332
|
+
* Returns `true` when the {@link #view} is visible in the {@link #_balloon}.
|
333
|
+
*
|
334
|
+
* @private
|
335
|
+
* @type {Boolean}
|
336
|
+
*/
|
337
|
+
get _isViewVisible() {
|
338
|
+
return this._balloon.visibleView === this.view;
|
339
|
+
}
|
340
|
+
|
341
|
+
/**
|
342
|
+
* Returns `true` when the {@link #view} is in the {@link #_balloon}.
|
343
|
+
*
|
344
|
+
* @private
|
345
|
+
* @type {Boolean}
|
346
|
+
*/
|
347
|
+
get _isViewInBalloon() {
|
348
|
+
return this._balloon.hasView( this.view );
|
349
|
+
}
|
350
|
+
|
351
|
+
/**
|
352
|
+
* Creates a callback that when executed upon the {@link #view view's} property change
|
353
|
+
* executes a related editor command with the new property value.
|
354
|
+
*
|
355
|
+
* @private
|
356
|
+
* @param {String} commandName
|
357
|
+
* @returns {Function}
|
358
|
+
*/
|
359
|
+
_getPropertyChangeCallback( commandName ) {
|
360
|
+
return ( evt, propertyName, newValue ) => {
|
361
|
+
this.editor.execute( commandName, {
|
362
|
+
value: newValue,
|
363
|
+
batch: this._undoStepBatch
|
364
|
+
} );
|
365
|
+
};
|
366
|
+
}
|
367
|
+
|
368
|
+
/**
|
369
|
+
* Creates a callback that when executed upon the {@link #view view's} property change:
|
370
|
+
* * Executes a related editor command with the new property value if the value is valid,
|
371
|
+
* * Or sets the error text next to the invalid field, if the value did not pass the validation.
|
372
|
+
*
|
373
|
+
* @private
|
374
|
+
* @param {Object} options
|
375
|
+
* @param {String} options.commandName
|
376
|
+
* @param {module:ui/view~View} options.viewField
|
377
|
+
* @param {Function} options.validator
|
378
|
+
* @param {String} options.errorText
|
379
|
+
* @returns {Function}
|
380
|
+
*/
|
381
|
+
_getValidatedPropertyChangeCallback( { commandName, viewField, validator, errorText } ) {
|
382
|
+
const setErrorTextDebounced = debounce( () => {
|
383
|
+
viewField.errorText = errorText;
|
384
|
+
}, ERROR_TEXT_TIMEOUT );
|
385
|
+
|
386
|
+
return ( evt, propertyName, newValue ) => {
|
387
|
+
setErrorTextDebounced.cancel();
|
388
|
+
|
389
|
+
if ( validator( newValue ) ) {
|
390
|
+
this.editor.execute( commandName, {
|
391
|
+
value: newValue,
|
392
|
+
batch: this._undoStepBatch
|
393
|
+
} );
|
394
|
+
|
395
|
+
viewField.errorText = null;
|
396
|
+
} else {
|
397
|
+
setErrorTextDebounced();
|
398
|
+
}
|
399
|
+
};
|
400
|
+
}
|
401
|
+
}
|