@progress/kendo-editor-common 1.11.9-dev.202412020819 → 1.11.9-develop.1
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/dist/cdn/main.js +1 -1
- package/dist/es/DOMSerializer.js +71 -75
- package/dist/es/align.js +19 -16
- package/dist/es/blockNode.js +76 -78
- package/dist/es/blockquote.js +12 -9
- package/dist/es/cleanFormatting.js +16 -16
- package/dist/es/config/align-rules.js +8 -6
- package/dist/es/config/commands.js +9 -13
- package/dist/es/config/constants.js +9 -7
- package/dist/es/config/indent-rules.js +8 -6
- package/dist/es/config/keymap.js +20 -18
- package/dist/es/config/list-settings.js +7 -6
- package/dist/es/config/schema.js +184 -126
- package/dist/es/find-replace.js +34 -32
- package/dist/es/image.js +10 -7
- package/dist/es/indent.js +47 -44
- package/dist/es/inline-style.js +72 -70
- package/dist/es/link.js +51 -52
- package/dist/es/listConvert.js +37 -34
- package/dist/es/lists.js +83 -82
- package/dist/es/main.js +32 -33
- package/dist/es/mark.js +87 -92
- package/dist/es/paste.js +48 -46
- package/dist/es/plugins/caret-color.js +14 -11
- package/dist/es/plugins/csp-fix.js +23 -23
- package/dist/es/plugins/highlight.js +12 -10
- package/dist/es/plugins/image-resize.js +81 -81
- package/dist/es/plugins/list-markers-styles.js +43 -39
- package/dist/es/plugins/placeholder.js +12 -9
- package/dist/es/plugins/resize-utils.js +11 -9
- package/dist/es/plugins/spaces-fix.js +13 -10
- package/dist/es/plugins/table-resize/column-resize.js +104 -102
- package/dist/es/plugins/table-resize/index.js +10 -7
- package/dist/es/plugins/table-resize/row-resize.js +88 -89
- package/dist/es/plugins/table-resize/table-resize.js +129 -122
- package/dist/es/plugins/table-resize/table-view.js +46 -48
- package/dist/es/plugins/table-resize/utils.js +39 -41
- package/dist/es/source.js +78 -74
- package/dist/es/table.js +64 -66
- package/dist/es/text.js +4 -2
- package/dist/es/utils.js +107 -116
- package/dist/es2015/DOMSerializer.js +20 -17
- package/dist/es2015/align.js +6 -3
- package/dist/es2015/blockNode.js +15 -12
- package/dist/es2015/blockquote.js +5 -2
- package/dist/es2015/cleanFormatting.js +6 -3
- package/dist/es2015/config/align-rules.js +7 -5
- package/dist/es2015/config/commands.js +9 -13
- package/dist/es2015/config/constants.js +9 -7
- package/dist/es2015/config/indent-rules.js +6 -3
- package/dist/es2015/config/keymap.js +10 -7
- package/dist/es2015/config/list-settings.js +5 -3
- package/dist/es2015/config/schema.js +8 -6
- package/dist/es2015/find-replace.js +9 -6
- package/dist/es2015/image.js +5 -2
- package/dist/es2015/indent.js +14 -11
- package/dist/es2015/inline-style.js +9 -6
- package/dist/es2015/link.js +7 -4
- package/dist/es2015/listConvert.js +5 -2
- package/dist/es2015/lists.js +14 -11
- package/dist/es2015/main.js +32 -33
- package/dist/es2015/mark.js +15 -12
- package/dist/es2015/node_modules/tslib/tslib.es6.js +35 -0
- package/dist/es2015/paste.js +14 -11
- package/dist/es2015/plugins/caret-color.js +8 -5
- package/dist/es2015/plugins/csp-fix.js +5 -2
- package/dist/es2015/plugins/highlight.js +6 -3
- package/dist/es2015/plugins/image-resize.js +10 -7
- package/dist/es2015/plugins/list-markers-styles.js +6 -3
- package/dist/es2015/plugins/placeholder.js +5 -2
- package/dist/es2015/plugins/resize-utils.js +11 -9
- package/dist/es2015/plugins/spaces-fix.js +4 -1
- package/dist/es2015/plugins/table-resize/column-resize.js +24 -21
- package/dist/es2015/plugins/table-resize/index.js +9 -6
- package/dist/es2015/plugins/table-resize/row-resize.js +23 -20
- package/dist/es2015/plugins/table-resize/table-resize.js +20 -17
- package/dist/es2015/plugins/table-resize/table-view.js +9 -6
- package/dist/es2015/plugins/table-resize/utils.js +13 -10
- package/dist/es2015/source.js +24 -13
- package/dist/es2015/table.js +18 -15
- package/dist/es2015/text.js +3 -1
- package/dist/es2015/utils.js +22 -25
- package/dist/npm/DOMSerializer.js +73 -78
- package/dist/npm/align.d.ts +7 -4
- package/dist/npm/align.js +22 -21
- package/dist/npm/blockNode.d.ts +14 -15
- package/dist/npm/blockNode.js +91 -95
- package/dist/npm/blockquote.d.ts +5 -2
- package/dist/npm/blockquote.js +16 -15
- package/dist/npm/cleanFormatting.d.ts +6 -3
- package/dist/npm/cleanFormatting.js +17 -19
- package/dist/npm/config/align-rules.d.ts +8 -6
- package/dist/npm/config/align-rules.js +14 -9
- package/dist/npm/config/commands.d.ts +11 -19
- package/dist/npm/config/commands.js +17 -16
- package/dist/npm/config/constants.js +17 -10
- package/dist/npm/config/indent-rules.d.ts +6 -4
- package/dist/npm/config/indent-rules.js +11 -9
- package/dist/npm/config/keymap.d.ts +5 -2
- package/dist/npm/config/keymap.js +30 -30
- package/dist/npm/config/list-settings.js +13 -11
- package/dist/npm/config/schema.d.ts +4 -3
- package/dist/npm/config/schema.js +191 -134
- package/dist/npm/find-replace.d.ts +10 -7
- package/dist/npm/find-replace.js +47 -47
- package/dist/npm/image.d.ts +6 -3
- package/dist/npm/image.js +11 -10
- package/dist/npm/indent.d.ts +12 -9
- package/dist/npm/indent.js +68 -67
- package/dist/npm/inline-style.d.ts +7 -4
- package/dist/npm/inline-style.js +83 -83
- package/dist/npm/link.d.ts +4 -2
- package/dist/npm/link.js +58 -61
- package/dist/npm/listConvert.d.ts +3 -1
- package/dist/npm/listConvert.js +40 -39
- package/dist/npm/lists.d.ts +9 -9
- package/dist/npm/lists.js +94 -95
- package/dist/npm/main.d.ts +34 -33
- package/dist/npm/main.js +388 -198
- package/dist/npm/mark.d.ts +13 -18
- package/dist/npm/mark.js +104 -111
- package/dist/npm/paste.d.ts +12 -9
- package/dist/npm/paste.js +61 -61
- package/dist/npm/plugins/caret-color.d.ts +6 -3
- package/dist/npm/plugins/caret-color.js +21 -19
- package/dist/npm/plugins/csp-fix.d.ts +4 -1
- package/dist/npm/plugins/csp-fix.js +28 -30
- package/dist/npm/plugins/highlight.d.ts +7 -4
- package/dist/npm/plugins/highlight.js +17 -16
- package/dist/npm/plugins/image-resize.d.ts +7 -5
- package/dist/npm/plugins/image-resize.js +96 -97
- package/dist/npm/plugins/list-markers-styles.d.ts +5 -2
- package/dist/npm/plugins/list-markers-styles.js +49 -47
- package/dist/npm/plugins/placeholder.d.ts +4 -1
- package/dist/npm/plugins/placeholder.js +18 -17
- package/dist/npm/plugins/resize-utils.js +14 -12
- package/dist/npm/plugins/spaces-fix.d.ts +4 -1
- package/dist/npm/plugins/spaces-fix.js +19 -18
- package/dist/npm/plugins/table-resize/column-resize.js +117 -117
- package/dist/npm/plugins/table-resize/index.d.ts +5 -2
- package/dist/npm/plugins/table-resize/index.js +16 -15
- package/dist/npm/plugins/table-resize/row-resize.js +98 -101
- package/dist/npm/plugins/table-resize/table-resize.js +144 -139
- package/dist/npm/plugins/table-resize/table-view.js +59 -61
- package/dist/npm/plugins/table-resize/utils.d.ts +7 -17
- package/dist/npm/plugins/table-resize/utils.js +51 -52
- package/dist/npm/source.d.ts +18 -11
- package/dist/npm/source.js +94 -91
- package/dist/npm/table.d.ts +10 -9
- package/dist/npm/table.js +93 -82
- package/dist/npm/text.d.ts +6 -3
- package/dist/npm/text.js +5 -5
- package/dist/npm/types/active-marks.d.ts +4 -1
- package/dist/npm/types/command.d.ts +5 -2
- package/dist/npm/types/dispatchFn.d.ts +4 -1
- package/dist/npm/types/paste-cleanup-settings.d.ts +3 -1
- package/dist/npm/utils.d.ts +13 -32
- package/dist/npm/utils.js +133 -145
- package/package.json +34 -52
- package/dist/cdn/js/kendo-editor-common.js +0 -1
- package/dist/es/types/active-marks.js +0 -1
- package/dist/es/types/command.js +0 -1
- package/dist/es/types/dispatchFn.js +0 -1
- package/dist/es/types/paste-cleanup-settings.js +0 -1
- package/dist/es/types/predicate.js +0 -1
- package/dist/es2015/types/active-marks.js +0 -1
- package/dist/es2015/types/command.js +0 -1
- package/dist/es2015/types/dispatchFn.js +0 -1
- package/dist/es2015/types/paste-cleanup-settings.js +0 -1
- package/dist/es2015/types/predicate.js +0 -1
- package/dist/npm/DOMSerializer.d.ts +0 -35
- package/dist/npm/config/constants.d.ts +0 -7
- package/dist/npm/config/list-settings.d.ts +0 -30
- package/dist/npm/plugins/resize-utils.d.ts +0 -35
- package/dist/npm/plugins/table-resize/column-resize.d.ts +0 -2
- package/dist/npm/plugins/table-resize/row-resize.d.ts +0 -2
- package/dist/npm/plugins/table-resize/table-resize.d.ts +0 -18
- package/dist/npm/plugins/table-resize/table-view.d.ts +0 -28
- package/dist/npm/types/active-marks.js +0 -2
- package/dist/npm/types/command.js +0 -2
- package/dist/npm/types/dispatchFn.js +0 -2
- package/dist/npm/types/paste-cleanup-settings.js +0 -2
- package/dist/npm/types/predicate.d.ts +0 -1
- package/dist/npm/types/predicate.js +0 -2
- package/dist/systemjs/kendo-editor-common.js +0 -1
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { Plugin } from 'prosemirror-state';
|
|
3
2
|
import { TableMap } from 'prosemirror-tables';
|
|
4
|
-
import {
|
|
5
|
-
import { colgroupAttr } from '../../config/constants';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
import { DecorationSet, Decoration } from 'prosemirror-view';
|
|
4
|
+
import { colgroupAttr } from '../../config/constants.js';
|
|
5
|
+
import { TableWrapperView, TableView } from './table-view.js';
|
|
6
|
+
import { setNodeStyle, parseStyle } from '../../utils.js';
|
|
7
|
+
import { tableColumnResizeKey, otherResizeHandle, otherResizing, domCellAround, cellIndexes, edgeCell } from './utils.js';
|
|
8
|
+
|
|
9
|
+
function columnResizing() {
|
|
10
|
+
const handleWidth = 5, cellMinWidth = 25;
|
|
11
|
+
const plugin = new Plugin({
|
|
12
|
+
key: tableColumnResizeKey,
|
|
13
13
|
state: {
|
|
14
|
-
init
|
|
14
|
+
init() {
|
|
15
15
|
return new ResizeState(-1, null);
|
|
16
16
|
},
|
|
17
|
-
apply
|
|
17
|
+
apply(tr, prev) {
|
|
18
18
|
return prev.apply(tr);
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
props: {
|
|
22
|
-
attributes
|
|
23
|
-
if (otherResizeHandle(
|
|
22
|
+
attributes(state) {
|
|
23
|
+
if (otherResizeHandle(tableColumnResizeKey, state)) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
const pluginState = tableColumnResizeKey.getState(state);
|
|
27
27
|
return pluginState.activeHandle > -1 ? { class: 'resize-cursor' } : null;
|
|
28
28
|
},
|
|
29
29
|
handleDOMEvents: {
|
|
30
|
-
mousemove
|
|
31
|
-
if (!otherResizing(
|
|
30
|
+
mousemove(view, event) {
|
|
31
|
+
if (!otherResizing(tableColumnResizeKey, view.state)) {
|
|
32
32
|
handleMouseMove(view, event, handleWidth);
|
|
33
33
|
}
|
|
34
34
|
return false;
|
|
35
35
|
},
|
|
36
|
-
mouseleave
|
|
36
|
+
mouseleave(view) {
|
|
37
37
|
handleMouseLeave(view);
|
|
38
38
|
return false;
|
|
39
39
|
},
|
|
40
|
-
mousedown
|
|
40
|
+
mousedown(view, event) {
|
|
41
41
|
return handleMouseDown(view, event, cellMinWidth);
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
decorations
|
|
45
|
-
if (!otherResizing(
|
|
46
|
-
|
|
44
|
+
decorations(state) {
|
|
45
|
+
if (!otherResizing(tableColumnResizeKey, state)) {
|
|
46
|
+
const pluginState = tableColumnResizeKey.getState(state);
|
|
47
47
|
if (pluginState.activeHandle > -1) {
|
|
48
48
|
return handleDecorations(state, pluginState.activeHandle);
|
|
49
49
|
}
|
|
@@ -51,8 +51,8 @@ export function columnResizing() {
|
|
|
51
51
|
return DecorationSet.empty;
|
|
52
52
|
},
|
|
53
53
|
nodeViews: {
|
|
54
|
-
table_wrapper:
|
|
55
|
-
table:
|
|
54
|
+
table_wrapper: (node, view) => new TableWrapperView(node, view),
|
|
55
|
+
table: (node, view) => new TableView(node, view)
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
});
|
|
@@ -61,14 +61,14 @@ export function columnResizing() {
|
|
|
61
61
|
function pointsAtCell($pos) {
|
|
62
62
|
return Boolean($pos.parent.type.spec.tableRole === 'row' && $pos.nodeAfter);
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
class ResizeState {
|
|
65
|
+
constructor(activeHandle, dragging) {
|
|
66
66
|
this.activeHandle = activeHandle;
|
|
67
67
|
this.dragging = dragging;
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
apply(tr) {
|
|
70
|
+
let state;
|
|
71
|
+
const action = tr.getMeta(tableColumnResizeKey);
|
|
72
72
|
if (action && action.setHandle != null) {
|
|
73
73
|
return new ResizeState(action.setHandle, null);
|
|
74
74
|
}
|
|
@@ -76,24 +76,23 @@ var ResizeState = /** @class */ (function () {
|
|
|
76
76
|
return new ResizeState(this.activeHandle, action.setDragging);
|
|
77
77
|
}
|
|
78
78
|
if (this.activeHandle > -1 && tr.docChanged) {
|
|
79
|
-
|
|
79
|
+
let handle = tr.mapping.map(this.activeHandle, -1);
|
|
80
80
|
if (!pointsAtCell(tr.doc.resolve(handle))) {
|
|
81
81
|
handle = -1;
|
|
82
82
|
}
|
|
83
83
|
state = new ResizeState(handle, this.dragging);
|
|
84
84
|
}
|
|
85
85
|
return state || this;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
}());
|
|
86
|
+
}
|
|
87
|
+
}
|
|
89
88
|
function handleMouseMove(view, event, handleWidth) {
|
|
90
|
-
|
|
89
|
+
const pluginState = tableColumnResizeKey.getState(view.state);
|
|
91
90
|
if (!pluginState.dragging) {
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
const target = domCellAround(event.target);
|
|
92
|
+
let cell = -1;
|
|
94
93
|
if (target) {
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
const indexes = cellIndexes(target);
|
|
95
|
+
const { left, right } = target.getBoundingClientRect();
|
|
97
96
|
if (Math.abs(event.clientX - left) <= handleWidth && indexes.cellIndex > 0) {
|
|
98
97
|
indexes.cellIndex -= target.colSpan;
|
|
99
98
|
cell = edgeCell(view, event, indexes);
|
|
@@ -108,82 +107,84 @@ function handleMouseMove(view, event, handleWidth) {
|
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
109
|
function handleMouseLeave(view) {
|
|
111
|
-
|
|
110
|
+
const pluginState = tableColumnResizeKey.getState(view.state);
|
|
112
111
|
if (pluginState.activeHandle > -1 && !pluginState.dragging) {
|
|
113
112
|
updateHandle(view, -1);
|
|
114
113
|
}
|
|
115
114
|
}
|
|
116
115
|
function handleMouseDown(view, event, cellMinWidth) {
|
|
117
|
-
|
|
118
|
-
var pluginState = key.getState(view.state);
|
|
116
|
+
const pluginState = tableColumnResizeKey.getState(view.state);
|
|
119
117
|
if (pluginState.activeHandle === -1 || pluginState.dragging) {
|
|
120
118
|
return false;
|
|
121
119
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
for (
|
|
120
|
+
const $cell = view.state.doc.resolve(pluginState.activeHandle);
|
|
121
|
+
const row = $cell.parent;
|
|
122
|
+
const cellIndex = $cell.index();
|
|
123
|
+
let colSpan = 0;
|
|
124
|
+
for (let i = 0; i <= cellIndex; i++) {
|
|
127
125
|
colSpan += row.child(i).attrs.colspan;
|
|
128
126
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
127
|
+
const tableNode = $cell.node($cell.depth - 1);
|
|
128
|
+
const dom = view.domAtPos(pluginState.activeHandle);
|
|
129
|
+
const domCell = dom.node.childNodes[dom.offset];
|
|
130
|
+
const tableDom = domCell.closest('table');
|
|
131
|
+
let col, tableAttrs;
|
|
134
132
|
if (tableNode.attrs[colgroupAttr]) {
|
|
135
|
-
|
|
133
|
+
const colgroup = tableDom.firstChild;
|
|
136
134
|
col = colgroup.children[colSpan - 1];
|
|
137
135
|
if (!col.style.width) {
|
|
138
136
|
col.style.width = col.offsetWidth + 'px';
|
|
139
137
|
}
|
|
140
138
|
}
|
|
141
139
|
else {
|
|
142
|
-
|
|
143
|
-
for (
|
|
140
|
+
let total = 0;
|
|
141
|
+
for (let i = 0; i < row.childCount; i++) {
|
|
144
142
|
total += row.child(i).attrs.colspan;
|
|
145
143
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
for (
|
|
144
|
+
const colgroup = document.createElement('colgroup');
|
|
145
|
+
const cols = new Array(total);
|
|
146
|
+
for (let i = 0; i < total; i++) {
|
|
149
147
|
cols[i] = document.createElement('col');
|
|
150
148
|
colgroup.appendChild(cols[i]);
|
|
151
149
|
}
|
|
152
150
|
tableDom.insertBefore(colgroup, tableDom.firstChild);
|
|
153
151
|
col = cols[cellIndex];
|
|
154
152
|
col.style.width = col.offsetWidth + 'px';
|
|
155
|
-
tableAttrs =
|
|
153
|
+
tableAttrs = {
|
|
154
|
+
...tableNode.attrs,
|
|
155
|
+
[colgroupAttr]: '<colgroup>' + cols.reduce((acc, cur) => acc + cur.outerHTML, '') + '</colgroup>'
|
|
156
|
+
};
|
|
156
157
|
}
|
|
157
|
-
|
|
158
|
-
|
|
158
|
+
const width = parseFloat(col.style.width);
|
|
159
|
+
const tr = view.state.tr.setMeta(tableColumnResizeKey, { setDragging: { startX: event.clientX, startWidth: width } });
|
|
159
160
|
if (!tableDom.style.width) {
|
|
160
|
-
|
|
161
|
+
const widths = Array.from(col.parentNode.children).map((c) => c.style.width);
|
|
161
162
|
if (widths.every(Boolean)) {
|
|
162
|
-
|
|
163
|
+
const sum = widths.reduce((acc, cur) => acc + parseFloat(cur), 0);
|
|
163
164
|
tableAttrs = setNodeStyle(tableAttrs || tableNode.attrs, 'width', sum + 'px');
|
|
164
165
|
}
|
|
165
166
|
}
|
|
166
167
|
if (tableAttrs) {
|
|
167
|
-
|
|
168
|
+
const tablePos = $cell.posAtIndex(0, $cell.depth - 1) - 1;
|
|
168
169
|
tr.setNodeMarkup(tablePos, null, tableAttrs);
|
|
169
170
|
}
|
|
170
171
|
view.dispatch(tr);
|
|
171
172
|
function finish(ev) {
|
|
172
173
|
ev.view.removeEventListener('mouseup', finish);
|
|
173
174
|
ev.view.removeEventListener('mousemove', move);
|
|
174
|
-
|
|
175
|
+
const curPluginState = tableColumnResizeKey.getState(view.state);
|
|
175
176
|
if (curPluginState.dragging) {
|
|
176
|
-
|
|
177
|
+
const transaction = view.state.tr;
|
|
177
178
|
updateColumnWidth(view, transaction, curPluginState.activeHandle);
|
|
178
|
-
view.dispatch(transaction.setMeta(
|
|
179
|
+
view.dispatch(transaction.setMeta(tableColumnResizeKey, { setDragging: null }));
|
|
179
180
|
}
|
|
180
181
|
}
|
|
181
182
|
function move(ev) {
|
|
182
183
|
if (!ev.which) {
|
|
183
184
|
return finish(ev);
|
|
184
185
|
}
|
|
185
|
-
|
|
186
|
-
|
|
186
|
+
const curPluginState = tableColumnResizeKey.getState(view.state);
|
|
187
|
+
const dragged = draggedWidth(curPluginState.dragging, ev, cellMinWidth);
|
|
187
188
|
displayColumnWidth(view, curPluginState.activeHandle, dragged);
|
|
188
189
|
}
|
|
189
190
|
event.view.addEventListener('mouseup', finish);
|
|
@@ -192,77 +193,78 @@ function handleMouseDown(view, event, cellMinWidth) {
|
|
|
192
193
|
return true;
|
|
193
194
|
}
|
|
194
195
|
function draggedWidth(dragging, event, cellMinWidth) {
|
|
195
|
-
|
|
196
|
+
const offset = event.clientX - dragging.startX;
|
|
196
197
|
return Math.max(cellMinWidth, dragging.startWidth + offset);
|
|
197
198
|
}
|
|
198
199
|
function updateHandle(view, value) {
|
|
199
|
-
|
|
200
|
+
const tr = view.state.tr;
|
|
200
201
|
tr.setMeta('addToHistory', false);
|
|
201
|
-
tr.setMeta(
|
|
202
|
+
tr.setMeta(tableColumnResizeKey, { setHandle: value });
|
|
202
203
|
view.dispatch(tr);
|
|
203
204
|
}
|
|
204
205
|
function updateColumnWidth(view, tr, cell) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
var attrs = tableNode.attrs;
|
|
206
|
+
const $cell = view.state.doc.resolve(cell);
|
|
207
|
+
const tableNode = $cell.node(-1), start = $cell.start(-1);
|
|
208
|
+
const tablePos = $cell.posAtIndex(0, $cell.depth - 1) - 1;
|
|
209
|
+
const tableDom = view.nodeDOM(start).closest('table');
|
|
210
|
+
let attrs = tableNode.attrs;
|
|
211
211
|
if (tableNode && attrs[colgroupAttr]) {
|
|
212
|
-
|
|
213
|
-
attrs =
|
|
212
|
+
const colgroup = tableDom.firstChild;
|
|
213
|
+
attrs = { ...attrs, [colgroupAttr]: colgroup.outerHTML };
|
|
214
214
|
}
|
|
215
|
-
|
|
215
|
+
const tableDomWidth = tableDom.style.width;
|
|
216
216
|
if (tableDom && tableDomWidth && parseStyle(attrs.style).width !== tableDomWidth) {
|
|
217
217
|
attrs = setNodeStyle(attrs, 'width', tableDomWidth);
|
|
218
218
|
}
|
|
219
219
|
tr.setNodeMarkup(tablePos, null, attrs);
|
|
220
220
|
}
|
|
221
221
|
function displayColumnWidth(view, cell, width) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
222
|
+
const $cell = view.state.doc.resolve(cell);
|
|
223
|
+
const table = $cell.node(-1), start = $cell.start(-1);
|
|
224
|
+
const col = TableMap.get(table).colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;
|
|
225
|
+
let dom = view.domAtPos($cell.start(-1)).node;
|
|
226
226
|
if (dom.nodeName !== 'TABLE') {
|
|
227
227
|
dom = dom.closest('table');
|
|
228
228
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
229
|
+
const tableDom = dom;
|
|
230
|
+
const colgroup = tableDom.firstChild;
|
|
231
|
+
const cols = Array.from(colgroup.children);
|
|
232
232
|
cols[col].style.width = width + 'px';
|
|
233
233
|
if (tableDom.style.width) {
|
|
234
|
-
|
|
234
|
+
const widths = cols.map(c => c.style.width);
|
|
235
235
|
if (widths.every(Boolean)) {
|
|
236
|
-
|
|
236
|
+
const sum = widths.reduce((acc, cur) => acc + parseFloat(cur), 0);
|
|
237
237
|
tableDom.style.width = sum + 'px';
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
function handleDecorations(state, cell) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
for (
|
|
242
|
+
const decorations = [];
|
|
243
|
+
const $cell = state.doc.resolve(cell);
|
|
244
|
+
const table = $cell.node(-1), map = TableMap.get(table), start = $cell.start(-1);
|
|
245
|
+
const cellsPositions = [];
|
|
246
|
+
const cellPos = cell - start;
|
|
247
|
+
let column = -1;
|
|
248
|
+
for (let i = 0; i < map.height; i++) {
|
|
249
249
|
cellsPositions.push(map.map.slice(i * map.width, (i * map.width) + map.width));
|
|
250
250
|
if (column === -1) {
|
|
251
251
|
column = cellsPositions[i].lastIndexOf(cellPos);
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
|
-
|
|
255
|
-
cellsPositions.forEach(
|
|
256
|
-
|
|
254
|
+
const cells = [];
|
|
255
|
+
cellsPositions.forEach((row) => {
|
|
256
|
+
const c = row[column];
|
|
257
257
|
if (row[column] !== row[column + 1]) {
|
|
258
258
|
cells.push(c);
|
|
259
259
|
}
|
|
260
260
|
});
|
|
261
|
-
cells.forEach((
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
cells.forEach((cPos => {
|
|
262
|
+
const pos = start + cPos + table.nodeAt(cPos).nodeSize - 1;
|
|
263
|
+
const dom = document.createElement('div');
|
|
264
264
|
dom.className = 'column-resize-handle';
|
|
265
265
|
decorations.push(Decoration.widget(pos, dom));
|
|
266
266
|
}));
|
|
267
267
|
return DecorationSet.create(state.doc, decorations);
|
|
268
268
|
}
|
|
269
|
+
|
|
270
|
+
export { columnResizing };
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { columnResizing } from './column-resize';
|
|
2
|
-
import { tableResizing as
|
|
3
|
-
import { rowResizing } from './row-resize';
|
|
4
|
-
export
|
|
5
|
-
|
|
1
|
+
import { columnResizing } from './column-resize.js';
|
|
2
|
+
import { tableResizing as tableResizing$1 } from './table-resize.js';
|
|
3
|
+
import { rowResizing } from './row-resize.js';
|
|
4
|
+
export { tableColumnResizeKey, tableResizeKey, tableRowResizeKey } from './utils.js';
|
|
5
|
+
|
|
6
|
+
const tableResizing = () => [
|
|
7
|
+
tableResizing$1(),
|
|
6
8
|
columnResizing(),
|
|
7
9
|
rowResizing()
|
|
8
|
-
];
|
|
9
|
-
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export { tableResizing };
|