qms-angular 1.0.86 → 1.0.89
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 +6943 -219
- 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 +6 -3
- package/esm2015/lib/components/dialog/dialog.js +2 -2
- package/esm2015/lib/components/list/list.js +2 -2
- package/esm2015/lib/components/qms-navigation-drawer/qms-navigation-drawer.component.js +3 -3
- package/esm2015/lib/components/qms-paginator/qms-paginator.component.js +16 -7
- package/esm2015/lib/components/related/content/related-content.component.js +2 -2
- 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/table/table.module.js +4 -4
- 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/file-upload/file-upload-multiple-selector.directive.js +3 -1
- package/esm2015/lib/directives/file-upload/file-upload-selector.directive.js +3 -1
- package/esm2015/lib/directives/file-upload/file-upload.directive.js +1 -1
- package/esm2015/lib/directives/text-truncate/text-truncate.directive.js +58 -0
- package/esm2015/lib/model/en.js +63 -2
- package/esm2015/lib/model/no.js +63 -2
- package/esm2015/lib/qms-angular.module.js +4 -1
- package/esm2015/lib/qms-ckeditor-components/common/flowchart/config/halo.function.js +87 -0
- package/esm2015/lib/qms-ckeditor-components/common/flowchart/config/inspector.function.js +3767 -0
- package/esm2015/lib/qms-ckeditor-components/common/flowchart/config/selection.function.js +56 -0
- package/esm2015/lib/qms-ckeditor-components/common/flowchart/config/stencil.function.js +1003 -0
- package/esm2015/lib/qms-ckeditor-components/common/flowchart/config/toolbar.function.js +302 -0
- package/esm2015/lib/qms-ckeditor-components/common/flowchart/models/app-shapes.js +320 -0
- package/esm2015/lib/qms-ckeditor-components/common/flowchart/service/keyboard-service.js +69 -0
- package/esm2015/lib/qms-ckeditor-components/common/flowchart/service/kitchensink-service.js +412 -0
- package/esm2015/lib/qms-ckeditor-components/common/flowchart/themes/theme-picker.js +80 -0
- package/esm2015/lib/qms-ckeditor-components/common/functions/common.function.js +34 -1
- package/esm2015/lib/qms-ckeditor-components/common/models/qms-ckeditor-save-as-template.model.js +1 -1
- package/esm2015/lib/qms-ckeditor-components/common/module/confirm/qms-ckeditor-confirm.component.js +3 -3
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-about/qms-ckeditor-about.component.js +1 -1
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-bpmn/qms-ckeditor-bpmn.component.js +2 -2
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-bpmn/save-template/save-template.component.js +2 -2
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-flowchart/qms-ckeditor-flowchart.component.js +317 -0
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.js +3 -3
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-link/attachments/link-attachment.component.js +3 -3
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-link/qms-ckeditor-link.component.js +3 -3
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-load-template/qms-ckeditor-load-template.component.js +3 -3
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-relation/qmsckeditor-related.component.js +3 -3
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-template/qms-ckeditor-template.component.js +3 -3
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-tooltip/qms-ckeditor-tooltip.component.js +3 -3
- package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.component.js +35 -3
- package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.module.js +4 -2
- package/esm2015/public-api.js +8 -1
- package/esm2015/qms-angular.js +2 -1
- package/fesm2015/qms-angular.js +6882 -213
- package/fesm2015/qms-angular.js.map +1 -1
- package/lib/components/comment/comment.d.ts +1 -0
- 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 +15 -0
- package/lib/model/en.d.ts +61 -0
- package/lib/model/no.d.ts +61 -0
- package/lib/qms-ckeditor-components/common/flowchart/config/halo.function.d.ts +37 -0
- package/lib/qms-ckeditor-components/common/flowchart/config/inspector.function.d.ts +7 -0
- package/lib/qms-ckeditor-components/common/flowchart/config/selection.function.d.ts +39 -0
- package/lib/qms-ckeditor-components/common/flowchart/config/stencil.function.d.ts +11 -0
- package/lib/qms-ckeditor-components/common/flowchart/config/toolbar.function.d.ts +224 -0
- package/lib/qms-ckeditor-components/common/flowchart/models/app-shapes.d.ts +58 -0
- package/lib/qms-ckeditor-components/common/flowchart/service/keyboard-service.d.ts +16 -0
- package/lib/qms-ckeditor-components/common/flowchart/service/kitchensink-service.d.ts +56 -0
- package/lib/qms-ckeditor-components/common/flowchart/themes/theme-picker.d.ts +35 -0
- package/lib/qms-ckeditor-components/common/functions/common.function.d.ts +12 -0
- package/lib/qms-ckeditor-components/common/models/qms-ckeditor-save-as-template.model.d.ts +2 -0
- package/lib/qms-ckeditor-components/components/qms-ckeditor-flowchart/qms-ckeditor-flowchart.component.d.ts +41 -0
- package/lib/qms-ckeditor-components/qms-ckeditor.component.d.ts +4 -0
- package/lib.theme.scss +179 -0
- package/package.json +1 -1
- package/public-api.d.ts +7 -0
- package/qms-angular.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/jointjs/images/delete-icon-modern.png +0 -0
- package/src/assets/jointjs/images/reset-icon-modern.png +0 -0
- package/src/assets/jointjs/images/save-icon-modern.png +0 -0
- package/src/assets/jointjs/images/to-front-icon-modern.png +0 -0
- package/src/assets/jointjs/images/toback-icon-modern.png +0 -0
- package/src/assets/jointjs/images/toolbar-icons-material.png +0 -0
- package/src/assets/jointjs/images/toolbar-icons-modern.png +0 -0
- package/src/assets/jointjs/scss/rappid.scss +326 -0
- package/src/assets/jointjs/scss/theme-picker.scss +22 -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/ca.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/el.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/eo.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/eu.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/he.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/km.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/kn.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/pt.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/sl.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 +12632 -345
- package/src/assets/qms-ckeditor-plugin/package.json +0 -2
- package/src/assets/qms-ckeditor-plugin/src/ckeditor.js +8 -8
- package/src/assets/qms-ckeditor-plugin/src/plugins/common/qmsCKEditorService.js +9 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/flowchart/flowchartdialogcommand.js +47 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/flowchart/qmsCKEditorFlowchartPlugin.js +30 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/heading.js +119 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/headingbuttonsui.js +103 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/headingcommand.js +96 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/headingediting.js +163 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/headingui.js +115 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/index.js +22 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/theme/heading.css +35 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/theme/icons/heading1.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/theme/icons/heading2.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/theme/icons/heading3.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/theme/icons/heading4.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/theme/icons/heading5.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/theme/icons/heading6.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/title.js +598 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/utils.js +42 -0
- 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/assets/qms-ckeditor-plugin/src/themes/icons/flowchart.svg +507 -0
- package/src/lib/components/comment/comment.scss +1 -0
- package/src/lib/components/qms-navigation-drawer/qms-navigation-drawer.component.scss +1 -0
- package/src/lib/components/qms-paginator/qms-paginator.component.scss +4 -1
- package/src/lib/qms-ckeditor-components/common/flowchart/assets/image-icon1.svg +1 -0
- package/src/lib/qms-ckeditor-components/common/flowchart/assets/image-icon2.svg +6 -0
- package/src/lib/qms-ckeditor-components/common/flowchart/assets/image-icon3.svg +11 -0
- package/src/lib/qms-ckeditor-components/common/flowchart/assets/image-icon4.svg +8 -0
- package/src/lib/qms-ckeditor-components/common/flowchart/assets/member-female.png +0 -0
- package/src/lib/qms-ckeditor-components/common/flowchart/assets/member-male.png +0 -0
- package/src/lib/qms-ckeditor-components/common/flowchart/assets/no-color-icon.svg +72 -0
- package/src/lib/qms-ckeditor-components/common/flowchart/assets/toolbar-icons-material.png +0 -0
- package/src/lib/qms-ckeditor-components/common/flowchart/assets/toolbar-icons-modern.png +0 -0
- package/src/lib/qms-ckeditor-components/common/flowchart/assets/transparent-icon.svg +50 -0
- package/src/lib/qms-ckeditor-components/components/qms-ckeditor-flowchart/qms-ckeditor-flowchart.component.scss +68 -0
- package/src/lib/qms-ckeditor-components/styles/_modules.scss +9 -0
- package/src/themes/core/_mat-icon.scss +60 -60
- package/src/themes/core/_table.scss +72 -4
- package/src/themes/core/_typography.scss +108 -108
@@ -0,0 +1,909 @@
|
|
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/tableutils
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { Plugin } from 'ckeditor5/src/core';
|
11
|
+
|
12
|
+
import TableWalker from './tablewalker';
|
13
|
+
import { createEmptyTableCell, updateNumericAttribute } from './utils/common';
|
14
|
+
import { removeEmptyColumns, removeEmptyRows } from './utils/structure';
|
15
|
+
|
16
|
+
/**
|
17
|
+
* The table utilities plugin.
|
18
|
+
*
|
19
|
+
* @extends module:core/plugin~Plugin
|
20
|
+
*/
|
21
|
+
export default class TableUtils extends Plugin {
|
22
|
+
/**
|
23
|
+
* @inheritDoc
|
24
|
+
*/
|
25
|
+
static get pluginName() {
|
26
|
+
return 'TableUtils';
|
27
|
+
}
|
28
|
+
|
29
|
+
/**
|
30
|
+
* @inheritDoc
|
31
|
+
*/
|
32
|
+
init() {
|
33
|
+
this.decorate( 'insertColumns' );
|
34
|
+
this.decorate( 'insertRows' );
|
35
|
+
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Returns the table cell location as an object with table row and table column indexes.
|
39
|
+
*
|
40
|
+
* For instance, in the table below:
|
41
|
+
*
|
42
|
+
* 0 1 2 3
|
43
|
+
* +---+---+---+---+
|
44
|
+
* 0 | a | b | c |
|
45
|
+
* + + +---+
|
46
|
+
* 1 | | | d |
|
47
|
+
* +---+---+ +---+
|
48
|
+
* 2 | e | | f |
|
49
|
+
* +---+---+---+---+
|
50
|
+
*
|
51
|
+
* the method will return:
|
52
|
+
*
|
53
|
+
* const cellA = table.getNodeByPath( [ 0, 0 ] );
|
54
|
+
* editor.plugins.get( 'TableUtils' ).getCellLocation( cellA );
|
55
|
+
* // will return { row: 0, column: 0 }
|
56
|
+
*
|
57
|
+
* const cellD = table.getNodeByPath( [ 1, 0 ] );
|
58
|
+
* editor.plugins.get( 'TableUtils' ).getCellLocation( cellD );
|
59
|
+
* // will return { row: 1, column: 3 }
|
60
|
+
*
|
61
|
+
* @param {module:engine/model/element~Element} tableCell
|
62
|
+
* @returns {Object} Returns a `{row, column}` object.
|
63
|
+
*/
|
64
|
+
getCellLocation( tableCell ) {
|
65
|
+
const tableRow = tableCell.parent;
|
66
|
+
const table = tableRow.parent;
|
67
|
+
|
68
|
+
const rowIndex = table.getChildIndex( tableRow );
|
69
|
+
|
70
|
+
const tableWalker = new TableWalker( table, { row: rowIndex } );
|
71
|
+
|
72
|
+
for ( const { cell, row, column } of tableWalker ) {
|
73
|
+
if ( cell === tableCell ) {
|
74
|
+
return { row, column };
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Creates an empty table with a proper structure. The table needs to be inserted into the model,
|
81
|
+
* for example, by using the {@link module:engine/model/model~Model#insertContent} function.
|
82
|
+
*
|
83
|
+
* model.change( ( writer ) => {
|
84
|
+
* // Create a table of 2 rows and 7 columns:
|
85
|
+
* const table = tableUtils.createTable( writer, { rows: 2, columns: 7 } );
|
86
|
+
*
|
87
|
+
* // Insert a table to the model at the best position taking the current selection:
|
88
|
+
* model.insertContent( table );
|
89
|
+
* }
|
90
|
+
*
|
91
|
+
* @param {module:engine/model/writer~Writer} writer The model writer.
|
92
|
+
* @param {Object} options
|
93
|
+
* @param {Number} [options.rows=2] The number of rows to create.
|
94
|
+
* @param {Number} [options.columns=2] The number of columns to create.
|
95
|
+
* @param {Number} [options.headingRows=0] The number of heading rows.
|
96
|
+
* @param {Number} [options.headingColumns=0] The number of heading columns.
|
97
|
+
* @returns {module:engine/model/element~Element} The created table element.
|
98
|
+
*/
|
99
|
+
createTable( writer, options ) {
|
100
|
+
const table = writer.createElement( 'table' );
|
101
|
+
|
102
|
+
const rows = parseInt( options.rows ) || 2;
|
103
|
+
const columns = parseInt( options.columns ) || 2;
|
104
|
+
|
105
|
+
createEmptyRows( writer, table, 0, rows, columns );
|
106
|
+
|
107
|
+
if ( options.headingRows ) {
|
108
|
+
updateNumericAttribute( 'headingRows', options.headingRows, table, writer, 0 );
|
109
|
+
}
|
110
|
+
|
111
|
+
if ( options.headingColumns ) {
|
112
|
+
updateNumericAttribute( 'headingColumns', options.headingColumns, table, writer, 0 );
|
113
|
+
}
|
114
|
+
|
115
|
+
return table;
|
116
|
+
}
|
117
|
+
|
118
|
+
/**
|
119
|
+
* Inserts rows into a table.
|
120
|
+
*
|
121
|
+
* editor.plugins.get( 'TableUtils' ).insertRows( table, { at: 1, rows: 2 } );
|
122
|
+
*
|
123
|
+
* Assuming the table on the left, the above code will transform it to the table on the right:
|
124
|
+
*
|
125
|
+
* row index
|
126
|
+
* 0 +---+---+---+ `at` = 1, +---+---+---+ 0
|
127
|
+
* | a | b | c | `rows` = 2, | a | b | c |
|
128
|
+
* 1 + +---+---+ <-- insert here + +---+---+ 1
|
129
|
+
* | | d | e | | | | |
|
130
|
+
* 2 + +---+---+ will give: + +---+---+ 2
|
131
|
+
* | | f | g | | | | |
|
132
|
+
* 3 +---+---+---+ + +---+---+ 3
|
133
|
+
* | | d | e |
|
134
|
+
* + +---+---+ 4
|
135
|
+
* + + f | g |
|
136
|
+
* +---+---+---+ 5
|
137
|
+
*
|
138
|
+
* @param {module:engine/model/element~Element} table The table model element where the rows will be inserted.
|
139
|
+
* @param {Object} options
|
140
|
+
* @param {Number} [options.at=0] The row index at which the rows will be inserted.
|
141
|
+
* @param {Number} [options.rows=1] The number of rows to insert.
|
142
|
+
* @param {Boolean|undefined} [options.copyStructureFromAbove] The flag for copying row structure. Note that
|
143
|
+
* the row structure will not be copied if this option is not provided.
|
144
|
+
*/
|
145
|
+
insertRows( table, options = {} ) {
|
146
|
+
const model = this.editor.model;
|
147
|
+
|
148
|
+
const insertAt = options.at || 0;
|
149
|
+
const rowsToInsert = options.rows || 1;
|
150
|
+
const isCopyStructure = options.copyStructureFromAbove !== undefined;
|
151
|
+
const copyStructureFrom = options.copyStructureFromAbove ? insertAt - 1 : insertAt;
|
152
|
+
|
153
|
+
const rows = this.getRows( table );
|
154
|
+
const columns = this.getColumns( table );
|
155
|
+
|
156
|
+
model.change( writer => {
|
157
|
+
const headingRows = table.getAttribute( 'headingRows' ) || 0;
|
158
|
+
|
159
|
+
// Inserting rows inside heading section requires to update `headingRows` attribute as the heading section will grow.
|
160
|
+
if ( headingRows > insertAt ) {
|
161
|
+
updateNumericAttribute( 'headingRows', headingRows + rowsToInsert, table, writer, 0 );
|
162
|
+
}
|
163
|
+
|
164
|
+
// Inserting at the end or at the beginning of a table doesn't require to calculate anything special.
|
165
|
+
if ( !isCopyStructure && ( insertAt === 0 || insertAt === rows ) ) {
|
166
|
+
createEmptyRows( writer, table, insertAt, rowsToInsert, columns );
|
167
|
+
|
168
|
+
return;
|
169
|
+
}
|
170
|
+
|
171
|
+
// Iterate over all the rows above the inserted rows in order to check for the row-spanned cells.
|
172
|
+
const walkerEndRow = isCopyStructure ? Math.max( insertAt, copyStructureFrom ) : insertAt;
|
173
|
+
const tableIterator = new TableWalker( table, { endRow: walkerEndRow } );
|
174
|
+
|
175
|
+
// Store spans of the reference row to reproduce it's structure. This array is column number indexed.
|
176
|
+
const rowColSpansMap = new Array( columns ).fill( 1 );
|
177
|
+
|
178
|
+
for ( const { row, column, cellHeight, cellWidth, cell } of tableIterator ) {
|
179
|
+
const lastCellRow = row + cellHeight - 1;
|
180
|
+
|
181
|
+
const isOverlappingInsertedRow = row < insertAt && insertAt <= lastCellRow;
|
182
|
+
const isReferenceRow = row <= copyStructureFrom && copyStructureFrom <= lastCellRow;
|
183
|
+
|
184
|
+
// If the cell is row-spanned and overlaps the inserted row, then reserve space for it in the row map.
|
185
|
+
if ( isOverlappingInsertedRow ) {
|
186
|
+
// This cell overlaps the inserted rows so we need to expand it further.
|
187
|
+
writer.setAttribute( 'rowspan', cellHeight + rowsToInsert, cell );
|
188
|
+
|
189
|
+
// Mark this cell with negative number to indicate how many cells should be skipped when adding the new cells.
|
190
|
+
rowColSpansMap[ column ] = -cellWidth;
|
191
|
+
}
|
192
|
+
// Store the colspan from reference row.
|
193
|
+
else if ( isCopyStructure && isReferenceRow ) {
|
194
|
+
rowColSpansMap[ column ] = cellWidth;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
|
198
|
+
for ( let rowIndex = 0; rowIndex < rowsToInsert; rowIndex++ ) {
|
199
|
+
const tableRow = writer.createElement( 'tableRow' );
|
200
|
+
|
201
|
+
writer.insert( tableRow, table, insertAt );
|
202
|
+
|
203
|
+
for ( let cellIndex = 0; cellIndex < rowColSpansMap.length; cellIndex++ ) {
|
204
|
+
const colspan = rowColSpansMap[ cellIndex ];
|
205
|
+
const insertPosition = writer.createPositionAt( tableRow, 'end' );
|
206
|
+
|
207
|
+
// Insert the empty cell only if this slot is not row-spanned from any other cell.
|
208
|
+
if ( colspan > 0 ) {
|
209
|
+
createEmptyTableCell( writer, insertPosition, colspan > 1 ? { colspan } : null );
|
210
|
+
}
|
211
|
+
|
212
|
+
// Skip the col-spanned slots, there won't be any cells.
|
213
|
+
cellIndex += Math.abs( colspan ) - 1;
|
214
|
+
}
|
215
|
+
}
|
216
|
+
} );
|
217
|
+
}
|
218
|
+
|
219
|
+
/**
|
220
|
+
* Inserts columns into a table.
|
221
|
+
*
|
222
|
+
* editor.plugins.get( 'TableUtils' ).insertColumns( table, { at: 1, columns: 2 } );
|
223
|
+
*
|
224
|
+
* Assuming the table on the left, the above code will transform it to the table on the right:
|
225
|
+
*
|
226
|
+
* 0 1 2 3 0 1 2 3 4 5
|
227
|
+
* +---+---+---+ +---+---+---+---+---+
|
228
|
+
* | a | b | | a | b |
|
229
|
+
* + +---+ + +---+
|
230
|
+
* | | c | | | c |
|
231
|
+
* +---+---+---+ will give: +---+---+---+---+---+
|
232
|
+
* | d | e | f | | d | | | e | f |
|
233
|
+
* +---+ +---+ +---+---+---+ +---+
|
234
|
+
* | g | | h | | g | | | | h |
|
235
|
+
* +---+---+---+ +---+---+---+---+---+
|
236
|
+
* | i | | i |
|
237
|
+
* +---+---+---+ +---+---+---+---+---+
|
238
|
+
* ^---- insert here, `at` = 1, `columns` = 2
|
239
|
+
*
|
240
|
+
* @param {module:engine/model/element~Element} table The table model element where the columns will be inserted.
|
241
|
+
* @param {Object} options
|
242
|
+
* @param {Number} [options.at=0] The column index at which the columns will be inserted.
|
243
|
+
* @param {Number} [options.columns=1] The number of columns to insert.
|
244
|
+
*/
|
245
|
+
insertColumns( table, options = {} ) {
|
246
|
+
const model = this.editor.model;
|
247
|
+
|
248
|
+
const insertAt = options.at || 0;
|
249
|
+
const columnsToInsert = options.columns || 1;
|
250
|
+
|
251
|
+
model.change( writer => {
|
252
|
+
const headingColumns = table.getAttribute( 'headingColumns' );
|
253
|
+
|
254
|
+
// Inserting columns inside heading section requires to update `headingColumns` attribute as the heading section will grow.
|
255
|
+
if ( insertAt < headingColumns ) {
|
256
|
+
writer.setAttribute( 'headingColumns', headingColumns + columnsToInsert, table );
|
257
|
+
}
|
258
|
+
|
259
|
+
const tableColumns = this.getColumns( table );
|
260
|
+
|
261
|
+
// Inserting at the end and at the beginning of a table doesn't require to calculate anything special.
|
262
|
+
if ( insertAt === 0 || tableColumns === insertAt ) {
|
263
|
+
for ( const tableRow of table.getChildren() ) {
|
264
|
+
createCells( columnsToInsert, writer, writer.createPositionAt( tableRow, insertAt ? 'end' : 0 ) );
|
265
|
+
}
|
266
|
+
|
267
|
+
return;
|
268
|
+
}
|
269
|
+
|
270
|
+
const tableWalker = new TableWalker( table, { column: insertAt, includeAllSlots: true } );
|
271
|
+
|
272
|
+
for ( const tableSlot of tableWalker ) {
|
273
|
+
const { row, cell, cellAnchorColumn, cellAnchorRow, cellWidth, cellHeight } = tableSlot;
|
274
|
+
|
275
|
+
// When iterating over column the table walker outputs either:
|
276
|
+
// - cells at given column index (cell "e" from method docs),
|
277
|
+
// - spanned columns (spanned cell from row between cells "g" and "h" - spanned by "e", only if `includeAllSlots: true`),
|
278
|
+
// - or a cell from the same row which spans over this column (cell "a").
|
279
|
+
|
280
|
+
if ( cellAnchorColumn < insertAt ) {
|
281
|
+
// If cell is anchored in previous column, it is a cell that spans over an inserted column (cell "a" & "i").
|
282
|
+
// For such cells expand them by a number of columns inserted.
|
283
|
+
writer.setAttribute( 'colspan', cellWidth + columnsToInsert, cell );
|
284
|
+
|
285
|
+
// This cell will overlap cells in rows below so skip them (because of `includeAllSlots` option) - (cell "a")
|
286
|
+
const lastCellRow = cellAnchorRow + cellHeight - 1;
|
287
|
+
|
288
|
+
for ( let i = row; i <= lastCellRow; i++ ) {
|
289
|
+
tableWalker.skipRow( i );
|
290
|
+
}
|
291
|
+
} else {
|
292
|
+
// It's either cell at this column index or spanned cell by a row-spanned cell from row above.
|
293
|
+
// In table above it's cell "e" and a spanned position from row below (empty cell between cells "g" and "h")
|
294
|
+
createCells( columnsToInsert, writer, tableSlot.getPositionBefore() );
|
295
|
+
}
|
296
|
+
}
|
297
|
+
} );
|
298
|
+
}
|
299
|
+
|
300
|
+
/**
|
301
|
+
* Removes rows from the given `table`.
|
302
|
+
*
|
303
|
+
* This method re-calculates the table geometry including `rowspan` attribute of table cells overlapping removed rows
|
304
|
+
* and table headings values.
|
305
|
+
*
|
306
|
+
* editor.plugins.get( 'TableUtils' ).removeRows( table, { at: 1, rows: 2 } );
|
307
|
+
*
|
308
|
+
* Executing the above code in the context of the table on the left will transform its structure as presented on the right:
|
309
|
+
*
|
310
|
+
* row index
|
311
|
+
* ┌───┬───┬───┐ `at` = 1 ┌───┬───┬───┐
|
312
|
+
* 0 │ a │ b │ c │ `rows` = 2 │ a │ b │ c │ 0
|
313
|
+
* │ ├───┼───┤ │ ├───┼───┤
|
314
|
+
* 1 │ │ d │ e │ <-- remove from here │ │ d │ g │ 1
|
315
|
+
* │ │ ├───┤ will give: ├───┼───┼───┤
|
316
|
+
* 2 │ │ │ f │ │ h │ i │ j │ 2
|
317
|
+
* │ │ ├───┤ └───┴───┴───┘
|
318
|
+
* 3 │ │ │ g │
|
319
|
+
* ├───┼───┼───┤
|
320
|
+
* 4 │ h │ i │ j │
|
321
|
+
* └───┴───┴───┘
|
322
|
+
*
|
323
|
+
* @param {module:engine/model/element~Element} table
|
324
|
+
* @param {Object} options
|
325
|
+
* @param {Number} options.at The row index at which the removing rows will start.
|
326
|
+
* @param {Number} [options.rows=1] The number of rows to remove.
|
327
|
+
*/
|
328
|
+
removeRows( table, options ) {
|
329
|
+
const model = this.editor.model;
|
330
|
+
|
331
|
+
const rowsToRemove = options.rows || 1;
|
332
|
+
const first = options.at;
|
333
|
+
const last = first + rowsToRemove - 1;
|
334
|
+
|
335
|
+
model.change( writer => {
|
336
|
+
// Removing rows from the table require that most calculations to be done prior to changing table structure.
|
337
|
+
// Preparations must be done in the same enqueueChange callback to use the current table structure.
|
338
|
+
|
339
|
+
// 1. Preparation - get row-spanned cells that have to be modified after removing rows.
|
340
|
+
const { cellsToMove, cellsToTrim } = getCellsToMoveAndTrimOnRemoveRow( table, first, last );
|
341
|
+
|
342
|
+
// 2. Execution
|
343
|
+
|
344
|
+
// 2a. Move cells from removed rows that extends over a removed section - must be done before removing rows.
|
345
|
+
// This will fill any gaps in a rows below that previously were empty because of row-spanned cells.
|
346
|
+
if ( cellsToMove.size ) {
|
347
|
+
const rowAfterRemovedSection = last + 1;
|
348
|
+
moveCellsToRow( table, rowAfterRemovedSection, cellsToMove, writer );
|
349
|
+
}
|
350
|
+
|
351
|
+
// 2b. Remove all required rows.
|
352
|
+
for ( let i = last; i >= first; i-- ) {
|
353
|
+
writer.remove( table.getChild( i ) );
|
354
|
+
}
|
355
|
+
|
356
|
+
// 2c. Update cells from rows above that overlap removed section. Similar to step 2 but does not involve moving cells.
|
357
|
+
for ( const { rowspan, cell } of cellsToTrim ) {
|
358
|
+
updateNumericAttribute( 'rowspan', rowspan, cell, writer );
|
359
|
+
}
|
360
|
+
|
361
|
+
// 2d. Adjust heading rows if removed rows were in a heading section.
|
362
|
+
updateHeadingRows( table, first, last, writer );
|
363
|
+
|
364
|
+
// 2e. Remove empty columns (without anchored cells) if there are any.
|
365
|
+
if ( !removeEmptyColumns( table, this ) ) {
|
366
|
+
// If there wasn't any empty columns then we still need to check if this wasn't called
|
367
|
+
// because of cleaning empty rows and we only removed one of them.
|
368
|
+
removeEmptyRows( table, this );
|
369
|
+
}
|
370
|
+
} );
|
371
|
+
}
|
372
|
+
|
373
|
+
/**
|
374
|
+
* Removes columns from the given `table`.
|
375
|
+
*
|
376
|
+
* This method re-calculates the table geometry including the `colspan` attribute of table cells overlapping removed columns
|
377
|
+
* and table headings values.
|
378
|
+
*
|
379
|
+
* editor.plugins.get( 'TableUtils' ).removeColumns( table, { at: 1, columns: 2 } );
|
380
|
+
*
|
381
|
+
* Executing the above code in the context of the table on the left will transform its structure as presented on the right:
|
382
|
+
*
|
383
|
+
* 0 1 2 3 4 0 1 2
|
384
|
+
* ┌───────────────┬───┐ ┌───────┬───┐
|
385
|
+
* │ a │ b │ │ a │ b │
|
386
|
+
* │ ├───┤ │ ├───┤
|
387
|
+
* │ │ c │ │ │ c │
|
388
|
+
* ├───┬───┬───┬───┼───┤ will give: ├───┬───┼───┤
|
389
|
+
* │ d │ e │ f │ g │ h │ │ d │ g │ h │
|
390
|
+
* ├───┼───┼───┤ ├───┤ ├───┤ ├───┤
|
391
|
+
* │ i │ j │ k │ │ l │ │ i │ │ l │
|
392
|
+
* ├───┴───┴───┴───┴───┤ ├───┴───┴───┤
|
393
|
+
* │ m │ │ m │
|
394
|
+
* └───────────────────┘ └───────────┘
|
395
|
+
* ^---- remove from here, `at` = 1, `columns` = 2
|
396
|
+
*
|
397
|
+
* @param {module:engine/model/element~Element} table
|
398
|
+
* @param {Object} options
|
399
|
+
* @param {Number} options.at The row index at which the removing columns will start.
|
400
|
+
* @param {Number} [options.columns=1] The number of columns to remove.
|
401
|
+
*/
|
402
|
+
removeColumns( table, options ) {
|
403
|
+
const model = this.editor.model;
|
404
|
+
const first = options.at;
|
405
|
+
const columnsToRemove = options.columns || 1;
|
406
|
+
const last = options.at + columnsToRemove - 1;
|
407
|
+
|
408
|
+
model.change( writer => {
|
409
|
+
adjustHeadingColumns( table, { first, last }, writer );
|
410
|
+
|
411
|
+
for ( let removedColumnIndex = last; removedColumnIndex >= first; removedColumnIndex-- ) {
|
412
|
+
for ( const { cell, column, cellWidth } of [ ...new TableWalker( table ) ] ) {
|
413
|
+
// If colspaned cell overlaps removed column decrease its span.
|
414
|
+
if ( column <= removedColumnIndex && cellWidth > 1 && column + cellWidth > removedColumnIndex ) {
|
415
|
+
updateNumericAttribute( 'colspan', cellWidth - 1, cell, writer );
|
416
|
+
} else if ( column === removedColumnIndex ) {
|
417
|
+
// The cell in removed column has colspan of 1.
|
418
|
+
writer.remove( cell );
|
419
|
+
}
|
420
|
+
}
|
421
|
+
}
|
422
|
+
|
423
|
+
// Remove empty rows that could appear after removing columns.
|
424
|
+
if ( !removeEmptyRows( table, this ) ) {
|
425
|
+
// If there wasn't any empty rows then we still need to check if this wasn't called
|
426
|
+
// because of cleaning empty columns and we only removed one of them.
|
427
|
+
removeEmptyColumns( table, this );
|
428
|
+
}
|
429
|
+
} );
|
430
|
+
}
|
431
|
+
|
432
|
+
/**
|
433
|
+
* Divides a table cell vertically into several ones.
|
434
|
+
*
|
435
|
+
* The cell will be visually split into more cells by updating colspans of other cells in a column
|
436
|
+
* and inserting cells (columns) after that cell.
|
437
|
+
*
|
438
|
+
* In the table below, if cell "a" is split into 3 cells:
|
439
|
+
*
|
440
|
+
* +---+---+---+
|
441
|
+
* | a | b | c |
|
442
|
+
* +---+---+---+
|
443
|
+
* | d | e | f |
|
444
|
+
* +---+---+---+
|
445
|
+
*
|
446
|
+
* it will result in the table below:
|
447
|
+
*
|
448
|
+
* +---+---+---+---+---+
|
449
|
+
* | a | | | b | c |
|
450
|
+
* +---+---+---+---+---+
|
451
|
+
* | d | e | f |
|
452
|
+
* +---+---+---+---+---+
|
453
|
+
*
|
454
|
+
* So cell "d" will get its `colspan` updated to `3` and 2 cells will be added (2 columns will be created).
|
455
|
+
*
|
456
|
+
* Splitting a cell that already has a `colspan` attribute set will distribute the cell `colspan` evenly and the remainder
|
457
|
+
* will be left to the original cell:
|
458
|
+
*
|
459
|
+
* +---+---+---+
|
460
|
+
* | a |
|
461
|
+
* +---+---+---+
|
462
|
+
* | b | c | d |
|
463
|
+
* +---+---+---+
|
464
|
+
*
|
465
|
+
* Splitting cell "a" with `colspan=3` into 2 cells will create 1 cell with a `colspan=a` and cell "a" that will have `colspan=2`:
|
466
|
+
*
|
467
|
+
* +---+---+---+
|
468
|
+
* | a | |
|
469
|
+
* +---+---+---+
|
470
|
+
* | b | c | d |
|
471
|
+
* +---+---+---+
|
472
|
+
*
|
473
|
+
* @param {module:engine/model/element~Element} tableCell
|
474
|
+
* @param {Number} numberOfCells
|
475
|
+
*/
|
476
|
+
splitCellVertically( tableCell, numberOfCells = 2 ) {
|
477
|
+
const model = this.editor.model;
|
478
|
+
const tableRow = tableCell.parent;
|
479
|
+
const table = tableRow.parent;
|
480
|
+
|
481
|
+
const rowspan = parseInt( tableCell.getAttribute( 'rowspan' ) || 1 );
|
482
|
+
const colspan = parseInt( tableCell.getAttribute( 'colspan' ) || 1 );
|
483
|
+
|
484
|
+
model.change( writer => {
|
485
|
+
// First check - the cell spans over multiple rows so before doing anything else just split this cell.
|
486
|
+
if ( colspan > 1 ) {
|
487
|
+
// Get spans of new (inserted) cells and span to update of split cell.
|
488
|
+
const { newCellsSpan, updatedSpan } = breakSpanEvenly( colspan, numberOfCells );
|
489
|
+
|
490
|
+
updateNumericAttribute( 'colspan', updatedSpan, tableCell, writer );
|
491
|
+
|
492
|
+
// Each inserted cell will have the same attributes:
|
493
|
+
const newCellsAttributes = {};
|
494
|
+
|
495
|
+
// Do not store default value in the model.
|
496
|
+
if ( newCellsSpan > 1 ) {
|
497
|
+
newCellsAttributes.colspan = newCellsSpan;
|
498
|
+
}
|
499
|
+
|
500
|
+
// Copy rowspan of split cell.
|
501
|
+
if ( rowspan > 1 ) {
|
502
|
+
newCellsAttributes.rowspan = rowspan;
|
503
|
+
}
|
504
|
+
|
505
|
+
const cellsToInsert = colspan > numberOfCells ? numberOfCells - 1 : colspan - 1;
|
506
|
+
createCells( cellsToInsert, writer, writer.createPositionAfter( tableCell ), newCellsAttributes );
|
507
|
+
}
|
508
|
+
|
509
|
+
// Second check - the cell has colspan of 1 or we need to create more cells then the currently one spans over.
|
510
|
+
if ( colspan < numberOfCells ) {
|
511
|
+
const cellsToInsert = numberOfCells - colspan;
|
512
|
+
|
513
|
+
// First step: expand cells on the same column as split cell.
|
514
|
+
const tableMap = [ ...new TableWalker( table ) ];
|
515
|
+
|
516
|
+
// Get the column index of split cell.
|
517
|
+
const { column: splitCellColumn } = tableMap.find( ( { cell } ) => cell === tableCell );
|
518
|
+
|
519
|
+
// Find cells which needs to be expanded vertically - those on the same column or those that spans over split cell's column.
|
520
|
+
const cellsToUpdate = tableMap.filter( ( { cell, cellWidth, column } ) => {
|
521
|
+
const isOnSameColumn = cell !== tableCell && column === splitCellColumn;
|
522
|
+
const spansOverColumn = ( column < splitCellColumn && column + cellWidth > splitCellColumn );
|
523
|
+
|
524
|
+
return isOnSameColumn || spansOverColumn;
|
525
|
+
} );
|
526
|
+
|
527
|
+
// Expand cells vertically.
|
528
|
+
for ( const { cell, cellWidth } of cellsToUpdate ) {
|
529
|
+
writer.setAttribute( 'colspan', cellWidth + cellsToInsert, cell );
|
530
|
+
}
|
531
|
+
|
532
|
+
// Second step: create columns after split cell.
|
533
|
+
|
534
|
+
// Each inserted cell will have the same attributes:
|
535
|
+
const newCellsAttributes = {};
|
536
|
+
|
537
|
+
// Do not store default value in the model.
|
538
|
+
|
539
|
+
// Copy rowspan of split cell.
|
540
|
+
if ( rowspan > 1 ) {
|
541
|
+
newCellsAttributes.rowspan = rowspan;
|
542
|
+
}
|
543
|
+
|
544
|
+
createCells( cellsToInsert, writer, writer.createPositionAfter( tableCell ), newCellsAttributes );
|
545
|
+
|
546
|
+
const headingColumns = table.getAttribute( 'headingColumns' ) || 0;
|
547
|
+
|
548
|
+
// Update heading section if split cell is in heading section.
|
549
|
+
if ( headingColumns > splitCellColumn ) {
|
550
|
+
updateNumericAttribute( 'headingColumns', headingColumns + cellsToInsert, table, writer );
|
551
|
+
}
|
552
|
+
}
|
553
|
+
} );
|
554
|
+
}
|
555
|
+
|
556
|
+
/**
|
557
|
+
* Divides a table cell horizontally into several ones.
|
558
|
+
*
|
559
|
+
* The cell will be visually split into more cells by updating rowspans of other cells in the row and inserting rows with a single cell
|
560
|
+
* below.
|
561
|
+
*
|
562
|
+
* If in the table below cell "b" is split into 3 cells:
|
563
|
+
*
|
564
|
+
* +---+---+---+
|
565
|
+
* | a | b | c |
|
566
|
+
* +---+---+---+
|
567
|
+
* | d | e | f |
|
568
|
+
* +---+---+---+
|
569
|
+
*
|
570
|
+
* It will result in the table below:
|
571
|
+
*
|
572
|
+
* +---+---+---+
|
573
|
+
* | a | b | c |
|
574
|
+
* + +---+ +
|
575
|
+
* | | | |
|
576
|
+
* + +---+ +
|
577
|
+
* | | | |
|
578
|
+
* +---+---+---+
|
579
|
+
* | d | e | f |
|
580
|
+
* +---+---+---+
|
581
|
+
*
|
582
|
+
* So cells "a" and "b" will get their `rowspan` updated to `3` and 2 rows with a single cell will be added.
|
583
|
+
*
|
584
|
+
* Splitting a cell that already has a `rowspan` attribute set will distribute the cell `rowspan` evenly and the remainder
|
585
|
+
* will be left to the original cell:
|
586
|
+
*
|
587
|
+
* +---+---+---+
|
588
|
+
* | a | b | c |
|
589
|
+
* + +---+---+
|
590
|
+
* | | d | e |
|
591
|
+
* + +---+---+
|
592
|
+
* | | f | g |
|
593
|
+
* + +---+---+
|
594
|
+
* | | h | i |
|
595
|
+
* +---+---+---+
|
596
|
+
*
|
597
|
+
* Splitting cell "a" with `rowspan=4` into 3 cells will create 2 cells with a `rowspan=1` and cell "a" will have `rowspan=2`:
|
598
|
+
*
|
599
|
+
* +---+---+---+
|
600
|
+
* | a | b | c |
|
601
|
+
* + +---+---+
|
602
|
+
* | | d | e |
|
603
|
+
* +---+---+---+
|
604
|
+
* | | f | g |
|
605
|
+
* +---+---+---+
|
606
|
+
* | | h | i |
|
607
|
+
* +---+---+---+
|
608
|
+
*
|
609
|
+
* @param {module:engine/model/element~Element} tableCell
|
610
|
+
* @param {Number} numberOfCells
|
611
|
+
*/
|
612
|
+
splitCellHorizontally( tableCell, numberOfCells = 2 ) {
|
613
|
+
const model = this.editor.model;
|
614
|
+
|
615
|
+
const tableRow = tableCell.parent;
|
616
|
+
const table = tableRow.parent;
|
617
|
+
const splitCellRow = table.getChildIndex( tableRow );
|
618
|
+
|
619
|
+
const rowspan = parseInt( tableCell.getAttribute( 'rowspan' ) || 1 );
|
620
|
+
const colspan = parseInt( tableCell.getAttribute( 'colspan' ) || 1 );
|
621
|
+
|
622
|
+
model.change( writer => {
|
623
|
+
// First check - the cell spans over multiple rows so before doing anything else just split this cell.
|
624
|
+
if ( rowspan > 1 ) {
|
625
|
+
// Cache table map before updating table.
|
626
|
+
const tableMap = [ ...new TableWalker( table, {
|
627
|
+
startRow: splitCellRow,
|
628
|
+
endRow: splitCellRow + rowspan - 1,
|
629
|
+
includeAllSlots: true
|
630
|
+
} ) ];
|
631
|
+
|
632
|
+
// Get spans of new (inserted) cells and span to update of split cell.
|
633
|
+
const { newCellsSpan, updatedSpan } = breakSpanEvenly( rowspan, numberOfCells );
|
634
|
+
|
635
|
+
updateNumericAttribute( 'rowspan', updatedSpan, tableCell, writer );
|
636
|
+
|
637
|
+
const { column: cellColumn } = tableMap.find( ( { cell } ) => cell === tableCell );
|
638
|
+
|
639
|
+
// Each inserted cell will have the same attributes:
|
640
|
+
const newCellsAttributes = {};
|
641
|
+
|
642
|
+
// Do not store default value in the model.
|
643
|
+
if ( newCellsSpan > 1 ) {
|
644
|
+
newCellsAttributes.rowspan = newCellsSpan;
|
645
|
+
}
|
646
|
+
|
647
|
+
// Copy colspan of split cell.
|
648
|
+
if ( colspan > 1 ) {
|
649
|
+
newCellsAttributes.colspan = colspan;
|
650
|
+
}
|
651
|
+
|
652
|
+
for ( const tableSlot of tableMap ) {
|
653
|
+
const { column, row } = tableSlot;
|
654
|
+
|
655
|
+
// As both newly created cells and the split cell might have rowspan,
|
656
|
+
// the insertion of new cells must go to appropriate rows:
|
657
|
+
//
|
658
|
+
// 1. It's a row after split cell + it's height.
|
659
|
+
const isAfterSplitCell = row >= splitCellRow + updatedSpan;
|
660
|
+
// 2. Is on the same column.
|
661
|
+
const isOnSameColumn = column === cellColumn;
|
662
|
+
// 3. And it's row index is after previous cell height.
|
663
|
+
const isInEvenlySplitRow = ( row + splitCellRow + updatedSpan ) % newCellsSpan === 0;
|
664
|
+
|
665
|
+
if ( isAfterSplitCell && isOnSameColumn && isInEvenlySplitRow ) {
|
666
|
+
createCells( 1, writer, tableSlot.getPositionBefore(), newCellsAttributes );
|
667
|
+
}
|
668
|
+
}
|
669
|
+
}
|
670
|
+
|
671
|
+
// Second check - the cell has rowspan of 1 or we need to create more cells than the current cell spans over.
|
672
|
+
if ( rowspan < numberOfCells ) {
|
673
|
+
// We already split the cell in check one so here we split to the remaining number of cells only.
|
674
|
+
const cellsToInsert = numberOfCells - rowspan;
|
675
|
+
|
676
|
+
// This check is needed since we need to check if there are any cells from previous rows than spans over this cell's row.
|
677
|
+
const tableMap = [ ...new TableWalker( table, { startRow: 0, endRow: splitCellRow } ) ];
|
678
|
+
|
679
|
+
// First step: expand cells.
|
680
|
+
for ( const { cell, cellHeight, row } of tableMap ) {
|
681
|
+
// Expand rowspan of cells that are either:
|
682
|
+
// - on the same row as current cell,
|
683
|
+
// - or are below split cell row and overlaps that row.
|
684
|
+
if ( cell !== tableCell && row + cellHeight > splitCellRow ) {
|
685
|
+
const rowspanToSet = cellHeight + cellsToInsert;
|
686
|
+
|
687
|
+
writer.setAttribute( 'rowspan', rowspanToSet, cell );
|
688
|
+
}
|
689
|
+
}
|
690
|
+
|
691
|
+
// Second step: create rows with single cell below split cell.
|
692
|
+
const newCellsAttributes = {};
|
693
|
+
|
694
|
+
// Copy colspan of split cell.
|
695
|
+
if ( colspan > 1 ) {
|
696
|
+
newCellsAttributes.colspan = colspan;
|
697
|
+
}
|
698
|
+
|
699
|
+
createEmptyRows( writer, table, splitCellRow + 1, cellsToInsert, 1, newCellsAttributes );
|
700
|
+
|
701
|
+
// Update heading section if split cell is in heading section.
|
702
|
+
const headingRows = table.getAttribute( 'headingRows' ) || 0;
|
703
|
+
|
704
|
+
if ( headingRows > splitCellRow ) {
|
705
|
+
updateNumericAttribute( 'headingRows', headingRows + cellsToInsert, table, writer );
|
706
|
+
}
|
707
|
+
}
|
708
|
+
} );
|
709
|
+
}
|
710
|
+
|
711
|
+
/**
|
712
|
+
* Returns the number of columns for a given table.
|
713
|
+
*
|
714
|
+
* editor.plugins.get( 'TableUtils' ).getColumns( table );
|
715
|
+
*
|
716
|
+
* @param {module:engine/model/element~Element} table The table to analyze.
|
717
|
+
* @returns {Number}
|
718
|
+
*/
|
719
|
+
getColumns( table ) {
|
720
|
+
// Analyze first row only as all the rows should have the same width.
|
721
|
+
const row = table.getChild( 0 );
|
722
|
+
|
723
|
+
return [ ...row.getChildren() ].reduce( ( columns, row ) => {
|
724
|
+
const columnWidth = parseInt( row.getAttribute( 'colspan' ) || 1 );
|
725
|
+
|
726
|
+
return columns + columnWidth;
|
727
|
+
}, 0 );
|
728
|
+
}
|
729
|
+
|
730
|
+
/**
|
731
|
+
* Returns the number of rows for a given table.
|
732
|
+
*
|
733
|
+
* editor.plugins.get( 'TableUtils' ).getRows( table );
|
734
|
+
*
|
735
|
+
* @param {module:engine/model/element~Element} table The table to analyze.
|
736
|
+
* @returns {Number}
|
737
|
+
*/
|
738
|
+
getRows( table ) {
|
739
|
+
// Simple row counting, not including rowspan due to #6427.
|
740
|
+
return table.childCount;
|
741
|
+
}
|
742
|
+
}
|
743
|
+
|
744
|
+
// Creates empty rows at the given index in an existing table.
|
745
|
+
//
|
746
|
+
// @param {module:engine/model/writer~Writer} writer
|
747
|
+
// @param {module:engine/model/element~Element} table
|
748
|
+
// @param {Number} insertAt The row index of row insertion.
|
749
|
+
// @param {Number} rows The number of rows to create.
|
750
|
+
// @param {Number} tableCellToInsert The number of cells to insert in each row.
|
751
|
+
function createEmptyRows( writer, table, insertAt, rows, tableCellToInsert, attributes = {} ) {
|
752
|
+
for ( let i = 0; i < rows; i++ ) {
|
753
|
+
const tableRow = writer.createElement( 'tableRow' );
|
754
|
+
|
755
|
+
writer.insert( tableRow, table, insertAt );
|
756
|
+
|
757
|
+
createCells( tableCellToInsert, writer, writer.createPositionAt( tableRow, 'end' ), attributes );
|
758
|
+
}
|
759
|
+
}
|
760
|
+
|
761
|
+
// Creates cells at a given position.
|
762
|
+
//
|
763
|
+
// @param {Number} columns The number of columns to create
|
764
|
+
// @param {module:engine/model/writer~Writer} writer
|
765
|
+
// @param {module:engine/model/position~Position} insertPosition
|
766
|
+
function createCells( cells, writer, insertPosition, attributes = {} ) {
|
767
|
+
for ( let i = 0; i < cells; i++ ) {
|
768
|
+
createEmptyTableCell( writer, insertPosition, attributes );
|
769
|
+
}
|
770
|
+
}
|
771
|
+
|
772
|
+
// Evenly distributes the span of a cell to a number of provided cells.
|
773
|
+
// The resulting spans will always be integer values.
|
774
|
+
//
|
775
|
+
// For instance breaking a span of 7 into 3 cells will return:
|
776
|
+
//
|
777
|
+
// { newCellsSpan: 2, updatedSpan: 3 }
|
778
|
+
//
|
779
|
+
// as two cells will have a span of 2 and the remainder will go the first cell so its span will change to 3.
|
780
|
+
//
|
781
|
+
// @param {Number} span The span value do break.
|
782
|
+
// @param {Number} numberOfCells The number of resulting spans.
|
783
|
+
// @returns {{newCellsSpan: Number, updatedSpan: Number}}
|
784
|
+
function breakSpanEvenly( span, numberOfCells ) {
|
785
|
+
if ( span < numberOfCells ) {
|
786
|
+
return { newCellsSpan: 1, updatedSpan: 1 };
|
787
|
+
}
|
788
|
+
|
789
|
+
const newCellsSpan = Math.floor( span / numberOfCells );
|
790
|
+
const updatedSpan = ( span - newCellsSpan * numberOfCells ) + newCellsSpan;
|
791
|
+
|
792
|
+
return { newCellsSpan, updatedSpan };
|
793
|
+
}
|
794
|
+
|
795
|
+
// Updates heading columns attribute if removing a row from head section.
|
796
|
+
function adjustHeadingColumns( table, removedColumnIndexes, writer ) {
|
797
|
+
const headingColumns = table.getAttribute( 'headingColumns' ) || 0;
|
798
|
+
|
799
|
+
if ( headingColumns && removedColumnIndexes.first < headingColumns ) {
|
800
|
+
const headingsRemoved = Math.min( headingColumns - 1 /* Other numbers are 0-based */, removedColumnIndexes.last ) -
|
801
|
+
removedColumnIndexes.first + 1;
|
802
|
+
|
803
|
+
writer.setAttribute( 'headingColumns', headingColumns - headingsRemoved, table );
|
804
|
+
}
|
805
|
+
}
|
806
|
+
|
807
|
+
// Calculates a new heading rows value for removing rows from heading section.
|
808
|
+
function updateHeadingRows( table, first, last, writer ) {
|
809
|
+
const headingRows = table.getAttribute( 'headingRows' ) || 0;
|
810
|
+
|
811
|
+
if ( first < headingRows ) {
|
812
|
+
const newRows = last < headingRows ? headingRows - ( last - first + 1 ) : first;
|
813
|
+
|
814
|
+
updateNumericAttribute( 'headingRows', newRows, table, writer, 0 );
|
815
|
+
}
|
816
|
+
}
|
817
|
+
|
818
|
+
// Finds cells that will be:
|
819
|
+
// - trimmed - Cells that are "above" removed rows sections and overlap the removed section - their rowspan must be trimmed.
|
820
|
+
// - moved - Cells from removed rows section might stick out of. These cells are moved to the next row after a removed section.
|
821
|
+
//
|
822
|
+
// Sample table with overlapping & sticking out cells:
|
823
|
+
//
|
824
|
+
// +----+----+----+----+----+
|
825
|
+
// | 00 | 01 | 02 | 03 | 04 |
|
826
|
+
// +----+ + + + +
|
827
|
+
// | 10 | | | | |
|
828
|
+
// +----+----+ + + +
|
829
|
+
// | 20 | 21 | | | | <-- removed row
|
830
|
+
// + + +----+ + +
|
831
|
+
// | | | 32 | | | <-- removed row
|
832
|
+
// +----+ + +----+ +
|
833
|
+
// | 40 | | | 43 | |
|
834
|
+
// +----+----+----+----+----+
|
835
|
+
//
|
836
|
+
// In a table above:
|
837
|
+
// - cells to trim: '02', '03' & '04'.
|
838
|
+
// - cells to move: '21' & '32'.
|
839
|
+
function getCellsToMoveAndTrimOnRemoveRow( table, first, last ) {
|
840
|
+
const cellsToMove = new Map();
|
841
|
+
const cellsToTrim = [];
|
842
|
+
|
843
|
+
for ( const { row, column, cellHeight, cell } of new TableWalker( table, { endRow: last } ) ) {
|
844
|
+
const lastRowOfCell = row + cellHeight - 1;
|
845
|
+
|
846
|
+
const isCellStickingOutFromRemovedRows = row >= first && row <= last && lastRowOfCell > last;
|
847
|
+
|
848
|
+
if ( isCellStickingOutFromRemovedRows ) {
|
849
|
+
const rowspanInRemovedSection = last - row + 1;
|
850
|
+
const rowSpanToSet = cellHeight - rowspanInRemovedSection;
|
851
|
+
|
852
|
+
cellsToMove.set( column, {
|
853
|
+
cell,
|
854
|
+
rowspan: rowSpanToSet
|
855
|
+
} );
|
856
|
+
}
|
857
|
+
|
858
|
+
const isCellOverlappingRemovedRows = row < first && lastRowOfCell >= first;
|
859
|
+
|
860
|
+
if ( isCellOverlappingRemovedRows ) {
|
861
|
+
let rowspanAdjustment;
|
862
|
+
|
863
|
+
// Cell fully covers removed section - trim it by removed rows count.
|
864
|
+
if ( lastRowOfCell >= last ) {
|
865
|
+
rowspanAdjustment = last - first + 1;
|
866
|
+
}
|
867
|
+
// Cell partially overlaps removed section - calculate cell's span that is in removed section.
|
868
|
+
else {
|
869
|
+
rowspanAdjustment = lastRowOfCell - first + 1;
|
870
|
+
}
|
871
|
+
|
872
|
+
cellsToTrim.push( {
|
873
|
+
cell,
|
874
|
+
rowspan: cellHeight - rowspanAdjustment
|
875
|
+
} );
|
876
|
+
}
|
877
|
+
}
|
878
|
+
return { cellsToMove, cellsToTrim };
|
879
|
+
}
|
880
|
+
|
881
|
+
function moveCellsToRow( table, targetRowIndex, cellsToMove, writer ) {
|
882
|
+
const tableWalker = new TableWalker( table, {
|
883
|
+
includeAllSlots: true,
|
884
|
+
row: targetRowIndex
|
885
|
+
} );
|
886
|
+
|
887
|
+
const tableRowMap = [ ...tableWalker ];
|
888
|
+
const row = table.getChild( targetRowIndex );
|
889
|
+
|
890
|
+
let previousCell;
|
891
|
+
|
892
|
+
for ( const { column, cell, isAnchor } of tableRowMap ) {
|
893
|
+
if ( cellsToMove.has( column ) ) {
|
894
|
+
const { cell: cellToMove, rowspan } = cellsToMove.get( column );
|
895
|
+
|
896
|
+
const targetPosition = previousCell ?
|
897
|
+
writer.createPositionAfter( previousCell ) :
|
898
|
+
writer.createPositionAt( row, 0 );
|
899
|
+
|
900
|
+
writer.move( writer.createRangeOn( cellToMove ), targetPosition );
|
901
|
+
updateNumericAttribute( 'rowspan', rowspan, cellToMove, writer );
|
902
|
+
|
903
|
+
previousCell = cellToMove;
|
904
|
+
} else if ( isAnchor ) {
|
905
|
+
// If cell is spanned then `cell` holds reference to overlapping cell. See ckeditor/ckeditor5#6502.
|
906
|
+
previousCell = cell;
|
907
|
+
}
|
908
|
+
}
|
909
|
+
}
|