@progress/kendo-editor-common 1.12.3-develop.9 → 1.12.3

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.
@@ -4,7 +4,7 @@ import { Decoration, DecorationSet } from 'prosemirror-view';
4
4
  import { colgroupAttr } from '../../config/constants';
5
5
  import { TableView, TableWrapperView } from './table-view';
6
6
  import { parseStyle, setNodeStyle } from './../../utils';
7
- import { cellIndexes, domCellAround, otherResizeHandle, otherResizing, edgeCell, tableColumnResizeKey as key } from './utils';
7
+ import { cellIndexes, domCellAround, otherResizeHandle, otherResizing, edgeCell, tableColumnResizeKey as key, splitCols } from './utils';
8
8
  export function columnResizing() {
9
9
  const handleWidth = 5, cellMinWidth = 25;
10
10
  const plugin = new Plugin({
@@ -130,6 +130,12 @@ function handleMouseDown(view, event, cellMinWidth) {
130
130
  let col, tableAttrs;
131
131
  if (tableNode.attrs[colgroupAttr]) {
132
132
  const colgroup = tableDom.firstChild;
133
+ if (splitCols(colgroup)) {
134
+ tableAttrs = {
135
+ ...tableNode.attrs,
136
+ [colgroupAttr]: colgroup.outerHTML
137
+ };
138
+ }
133
139
  col = colgroup.children[colSpan - 1];
134
140
  if (!col.style.width) {
135
141
  col.style.width = col.offsetWidth + 'px';
@@ -1,6 +1,6 @@
1
1
  import { NodeSelection, Plugin } from 'prosemirror-state';
2
2
  import { colgroupAttr, dataResizeDirTable, resizableAttr } from '../../config/constants';
3
- import { getTable, tableResizeKey as key } from './utils';
3
+ import { getTable, tableResizeKey as key, splitCols } from './utils';
4
4
  import { parseStyle, setNodeStyle, parentNode } from './../../utils';
5
5
  import { directions } from './../resize-utils';
6
6
  const commonDir = {
@@ -70,14 +70,14 @@ const handleMouseMove = (view, event) => {
70
70
  const toPercents = (view, tr, tablePos) => {
71
71
  const tableNode = view.state.doc.nodeAt(tablePos);
72
72
  const tableDom = getTable(view.nodeDOM(tablePos));
73
- const { width, height, colsWidth, rowsHeight, offsetWidth, offsetHeight } = tableSize(tableDom);
74
73
  const colgroup = tableDom.firstChild;
74
+ let colsChanged = splitCols(colgroup);
75
+ const { width, height, colsWidth, rowsHeight, offsetWidth, offsetHeight } = tableSize(tableDom);
75
76
  const cols = Array.from((colgroup && colgroup.children) || []);
76
- let widthChanged = false;
77
77
  cols.forEach((col, i) => {
78
78
  if (col.style.width && !/%$/.test(col.style.width)) {
79
79
  col.style.width = ((colsWidth[i]) * 100 / width) + '%';
80
- widthChanged = true;
80
+ colsChanged = true;
81
81
  }
82
82
  });
83
83
  let heightChange = false;
@@ -92,13 +92,13 @@ const toPercents = (view, tr, tablePos) => {
92
92
  if (parseStyle(tableAttrs.style).width !== offsetWidth + 'px') {
93
93
  tableAttrs = setNodeStyle(tableAttrs, 'width', offsetWidth + 'px');
94
94
  }
95
- if (widthChanged) {
95
+ if (colsChanged) {
96
96
  tableAttrs[colgroupAttr] = colgroup.outerHTML;
97
97
  }
98
98
  if (heightChange) {
99
99
  tableAttrs = setNodeStyle(tableAttrs, 'height', offsetHeight + 'px');
100
100
  }
101
- if (widthChanged || heightChange) {
101
+ if (colsChanged || heightChange) {
102
102
  tr.setNodeMarkup(tablePos, null, tableAttrs);
103
103
  }
104
104
  };
@@ -88,3 +88,17 @@ export function edgeCell(view, event, indexes) {
88
88
  const cell = tablePos + map.map[(map.width * indexes.rowIndex) + indexes.cellIndex];
89
89
  return cell;
90
90
  }
91
+ export function splitCols(colgroup) {
92
+ const cols = Array.from((colgroup && colgroup.children || []));
93
+ let splitted = false;
94
+ cols.forEach((col) => {
95
+ while (col.span > 1) {
96
+ const newCol = col.cloneNode();
97
+ newCol.span = 1;
98
+ colgroup.insertBefore(newCol, col);
99
+ col.span -= 1;
100
+ splitted = true;
101
+ }
102
+ });
103
+ return splitted;
104
+ }
@@ -133,6 +133,12 @@ function handleMouseDown(view, event, cellMinWidth) {
133
133
  let col, tableAttrs;
134
134
  if (tableNode.attrs[constants_1.colgroupAttr]) {
135
135
  const colgroup = tableDom.firstChild;
136
+ if ((0, utils_2.splitCols)(colgroup)) {
137
+ tableAttrs = {
138
+ ...tableNode.attrs,
139
+ [constants_1.colgroupAttr]: colgroup.outerHTML
140
+ };
141
+ }
136
142
  col = colgroup.children[colSpan - 1];
137
143
  if (!col.style.width) {
138
144
  col.style.width = col.offsetWidth + 'px';
@@ -73,14 +73,14 @@ const handleMouseMove = (view, event) => {
73
73
  const toPercents = (view, tr, tablePos) => {
74
74
  const tableNode = view.state.doc.nodeAt(tablePos);
75
75
  const tableDom = (0, utils_1.getTable)(view.nodeDOM(tablePos));
76
- const { width, height, colsWidth, rowsHeight, offsetWidth, offsetHeight } = tableSize(tableDom);
77
76
  const colgroup = tableDom.firstChild;
77
+ let colsChanged = (0, utils_1.splitCols)(colgroup);
78
+ const { width, height, colsWidth, rowsHeight, offsetWidth, offsetHeight } = tableSize(tableDom);
78
79
  const cols = Array.from((colgroup && colgroup.children) || []);
79
- let widthChanged = false;
80
80
  cols.forEach((col, i) => {
81
81
  if (col.style.width && !/%$/.test(col.style.width)) {
82
82
  col.style.width = ((colsWidth[i]) * 100 / width) + '%';
83
- widthChanged = true;
83
+ colsChanged = true;
84
84
  }
85
85
  });
86
86
  let heightChange = false;
@@ -95,13 +95,13 @@ const toPercents = (view, tr, tablePos) => {
95
95
  if ((0, utils_2.parseStyle)(tableAttrs.style).width !== offsetWidth + 'px') {
96
96
  tableAttrs = (0, utils_2.setNodeStyle)(tableAttrs, 'width', offsetWidth + 'px');
97
97
  }
98
- if (widthChanged) {
98
+ if (colsChanged) {
99
99
  tableAttrs[constants_1.colgroupAttr] = colgroup.outerHTML;
100
100
  }
101
101
  if (heightChange) {
102
102
  tableAttrs = (0, utils_2.setNodeStyle)(tableAttrs, 'height', offsetHeight + 'px');
103
103
  }
104
- if (widthChanged || heightChange) {
104
+ if (colsChanged || heightChange) {
105
105
  tr.setNodeMarkup(tablePos, null, tableAttrs);
106
106
  }
107
107
  };
@@ -15,3 +15,4 @@ export declare function edgeCell(view: EditorView, event: MouseEvent, indexes: {
15
15
  cellIndex: number;
16
16
  rowIndex: number;
17
17
  }): number;
18
+ export declare function splitCols(colgroup?: HTMLTableColElement): boolean;
@@ -7,6 +7,7 @@ exports.getTable = getTable;
7
7
  exports.domCellAround = domCellAround;
8
8
  exports.cellIndexes = cellIndexes;
9
9
  exports.edgeCell = edgeCell;
10
+ exports.splitCols = splitCols;
10
11
  const prosemirror_state_1 = require("prosemirror-state");
11
12
  const prosemirror_tables_1 = require("prosemirror-tables");
12
13
  const utils_1 = require("../../utils");
@@ -97,3 +98,17 @@ function edgeCell(view, event, indexes) {
97
98
  const cell = tablePos + map.map[(map.width * indexes.rowIndex) + indexes.cellIndex];
98
99
  return cell;
99
100
  }
101
+ function splitCols(colgroup) {
102
+ const cols = Array.from((colgroup && colgroup.children || []));
103
+ let splitted = false;
104
+ cols.forEach((col) => {
105
+ while (col.span > 1) {
106
+ const newCol = col.cloneNode();
107
+ newCol.span = 1;
108
+ colgroup.insertBefore(newCol, col);
109
+ col.span -= 1;
110
+ splitted = true;
111
+ }
112
+ });
113
+ return splitted;
114
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@progress/kendo-editor-common",
3
3
  "description": "Kendo UI TypeScript package exporting functions for Editor component",
4
- "version": "1.12.3-develop.9",
4
+ "version": "1.12.3",
5
5
  "keywords": [
6
6
  "Kendo UI"
7
7
  ],