@progress/kendo-editor-common 1.9.0-dev.202204180753 → 1.9.0-dev.202204190918
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/js/kendo-editor-common.js +2 -2
- package/dist/cdn/main.js +1 -1
- package/dist/es/config/constants.js +3 -3
- package/dist/es/config/schema.js +10 -6
- package/dist/es/main.js +1 -1
- package/dist/es/plugins/table-resize/column-resize.js +9 -9
- package/dist/es/plugins/table-resize/index.js +1 -0
- package/dist/es/plugins/table-resize/row-resize.js +5 -2
- package/dist/es/plugins/table-resize/table-resize.js +9 -3
- package/dist/es/plugins/table-resize/utils.js +8 -8
- package/dist/es2015/config/constants.js +3 -3
- package/dist/es2015/config/schema.js +6 -6
- package/dist/es2015/main.js +1 -1
- package/dist/es2015/plugins/table-resize/column-resize.js +9 -9
- package/dist/es2015/plugins/table-resize/index.js +1 -0
- package/dist/es2015/plugins/table-resize/row-resize.js +5 -2
- package/dist/es2015/plugins/table-resize/table-resize.js +7 -1
- package/dist/es2015/plugins/table-resize/utils.js +8 -8
- package/dist/npm/config/constants.d.ts +3 -3
- package/dist/npm/config/constants.js +3 -3
- package/dist/npm/config/schema.js +10 -6
- package/dist/npm/main.d.ts +1 -1
- package/dist/npm/main.js +3 -0
- package/dist/npm/plugins/table-resize/column-resize.js +21 -21
- package/dist/npm/plugins/table-resize/index.d.ts +1 -0
- package/dist/npm/plugins/table-resize/index.js +4 -0
- package/dist/npm/plugins/table-resize/row-resize.js +18 -15
- package/dist/npm/plugins/table-resize/table-resize.js +9 -3
- package/dist/npm/plugins/table-resize/utils.d.ts +2 -2
- package/dist/npm/plugins/table-resize/utils.js +8 -8
- package/dist/systemjs/kendo-editor-common.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export var rowTypeAttr = 'k-parent-node';
|
|
2
2
|
export var colgroupAttr = 'k-colgroup-data';
|
|
3
|
-
export var resizableAttr = 'resizable-node';
|
|
3
|
+
export var resizableAttr = 'k-resizable-node';
|
|
4
4
|
export var resizableWrap = 'k-editor-resize-wrap-element';
|
|
5
5
|
export var resizeHandle = 'k-editor-resize-handle';
|
|
6
|
-
export var dataResizeDirTable = 'data-
|
|
7
|
-
export var dataResizeDirImage = 'data-
|
|
6
|
+
export var dataResizeDirTable = 'data-dir-table-resize';
|
|
7
|
+
export var dataResizeDirImage = 'data-dir-image-resize';
|
package/dist/es/config/schema.js
CHANGED
|
@@ -32,11 +32,15 @@ var hasAttrs = function (attrs, exclude) {
|
|
|
32
32
|
return false;
|
|
33
33
|
};
|
|
34
34
|
var pmAttributes = function (attrs, exclude) {
|
|
35
|
+
if (exclude === void 0) { exclude = []; }
|
|
35
36
|
var result = {};
|
|
36
|
-
|
|
37
|
-
if (attr && attrs[attr] !== null && attr
|
|
37
|
+
var _loop_1 = function (attr) {
|
|
38
|
+
if (attr && attrs[attr] !== null && !exclude.find(function (e) { return e === attr; })) {
|
|
38
39
|
result[attr] = attrs[attr];
|
|
39
40
|
}
|
|
41
|
+
};
|
|
42
|
+
for (var attr in attrs) {
|
|
43
|
+
_loop_1(attr);
|
|
40
44
|
}
|
|
41
45
|
return result;
|
|
42
46
|
};
|
|
@@ -121,7 +125,7 @@ tNodes.table_row.toDOM = function (node) { return ['tr', pmAttributes(node.attrs
|
|
|
121
125
|
tNodes.table_row.parseDOM = [{ tag: 'tr', getAttrs: domAttributes }];
|
|
122
126
|
tNodes.table.attrs = tslib_1.__assign({}, tNodes.table.attrs, defaultAttrs(['style', 'class', 'id', colgroupAttr, resizableAttr]));
|
|
123
127
|
tNodes.table.toDOM = function (node) {
|
|
124
|
-
var tableAttrs = hasAttrs(node.attrs) ? pmAttributes(node.attrs, colgroupAttr) : {};
|
|
128
|
+
var tableAttrs = hasAttrs(node.attrs) ? pmAttributes(node.attrs, [colgroupAttr, resizableAttr]) : {};
|
|
125
129
|
var colgroup = null;
|
|
126
130
|
if (node.attrs[colgroupAttr] && !shouldSkipColgroup(node)) {
|
|
127
131
|
var colgroupEl = parseStrColgroup(node.attrs[colgroupAttr]);
|
|
@@ -210,7 +214,7 @@ var nodes = tslib_1.__assign({
|
|
|
210
214
|
{ tag: 'h6', getAttrs: function (node) { return (tslib_1.__assign({}, domAttributes(node), { level: 6 })); } }
|
|
211
215
|
],
|
|
212
216
|
toDOM: function (node) { return hasAttrs(node.attrs, 'level') ?
|
|
213
|
-
['h' + node.attrs.level, pmAttributes(node.attrs, 'level'), hole] :
|
|
217
|
+
['h' + node.attrs.level, pmAttributes(node.attrs, ['level']), hole] :
|
|
214
218
|
['h' + node.attrs.level, hole]; }
|
|
215
219
|
},
|
|
216
220
|
// :: NodeSpec A code listing. Disallows marks or non-text inline
|
|
@@ -267,8 +271,8 @@ var nodes = tslib_1.__assign({
|
|
|
267
271
|
} }],
|
|
268
272
|
toDOM: function (node) {
|
|
269
273
|
return node.attrs.order === 1 ?
|
|
270
|
-
(hasAttrs(node.attrs, 'order') ? ['ol', pmAttributes(node.attrs, 'order'), hole] : olDOM) :
|
|
271
|
-
['ol', tslib_1.__assign({}, pmAttributes(node.attrs, 'order'), { start: node.attrs.order }), hole];
|
|
274
|
+
(hasAttrs(node.attrs, 'order') ? ['ol', pmAttributes(node.attrs, ['order']), hole] : olDOM) :
|
|
275
|
+
['ol', tslib_1.__assign({}, pmAttributes(node.attrs, ['order']), { start: node.attrs.order }), hole];
|
|
272
276
|
}
|
|
273
277
|
},
|
|
274
278
|
// :: NodeSpec
|
package/dist/es/main.js
CHANGED
|
@@ -24,7 +24,7 @@ export { spacesFix } from './plugins/spaces-fix';
|
|
|
24
24
|
export { textHighlight, textHighlightKey } from './plugins/highlight';
|
|
25
25
|
export { imageResizing, imageResizeKey } from './plugins/image-resize';
|
|
26
26
|
export { caretColor, caretColorKey } from './plugins/caret-color';
|
|
27
|
-
export { tableResizing } from './plugins/table-resize';
|
|
27
|
+
export { tableResizing, tableResizeKey, tableColumnResizeKey, tableRowResizeKey } from './plugins/table-resize';
|
|
28
28
|
// ProseMirror re-exports
|
|
29
29
|
export * from 'prosemirror-commands';
|
|
30
30
|
export * from 'prosemirror-dropcursor';
|
|
@@ -4,7 +4,7 @@ import { tableNodeTypes, TableMap } from 'prosemirror-tables';
|
|
|
4
4
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
5
5
|
import { colgroupAttr } from '../../config/constants';
|
|
6
6
|
import { TableView } from './table-view';
|
|
7
|
-
import { cellIndexes, domCellAround, otherResizeHandle, otherResizing, parentNode, parseStyle, setNodeStyle,
|
|
7
|
+
import { cellIndexes, domCellAround, otherResizeHandle, otherResizing, parentNode, parseStyle, setNodeStyle, tableColumnResizeKey as key } from './utils';
|
|
8
8
|
export function columnResizing() {
|
|
9
9
|
// tslint:disable-next-line:variable-name
|
|
10
10
|
var View = TableView, handleWidth = 5, cellMinWidth = 25;
|
|
@@ -169,8 +169,9 @@ function handleMouseDown(view, event, cellMinWidth) {
|
|
|
169
169
|
ev.view.removeEventListener('mousemove', move);
|
|
170
170
|
var curPluginState = key.getState(view.state);
|
|
171
171
|
if (curPluginState.dragging) {
|
|
172
|
-
|
|
173
|
-
view.
|
|
172
|
+
var transaction = view.state.tr;
|
|
173
|
+
updateColumnWidth(view, transaction, curPluginState.activeHandle, draggedWidth(curPluginState.dragging, ev, cellMinWidth));
|
|
174
|
+
view.dispatch(transaction.setMeta(key, { setDragging: null }));
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
177
|
function move(ev) {
|
|
@@ -207,13 +208,15 @@ function draggedWidth(dragging, event, cellMinWidth) {
|
|
|
207
208
|
return Math.max(cellMinWidth, dragging.startWidth + offset);
|
|
208
209
|
}
|
|
209
210
|
function updateHandle(view, value) {
|
|
210
|
-
view.
|
|
211
|
+
var tr = view.state.tr;
|
|
212
|
+
tr.setMeta('addToHistory', false);
|
|
213
|
+
tr.setMeta(key, { setHandle: value });
|
|
214
|
+
view.dispatch(tr);
|
|
211
215
|
}
|
|
212
|
-
function updateColumnWidth(view, cell, _width) {
|
|
216
|
+
function updateColumnWidth(view, tr, cell, _width) {
|
|
213
217
|
var _a;
|
|
214
218
|
var $cell = view.state.doc.resolve(cell);
|
|
215
219
|
var tableNode = $cell.node(-1), start = $cell.start(-1);
|
|
216
|
-
var tr = view.state.tr;
|
|
217
220
|
var tablePos = $cell.posAtIndex(0, $cell.depth - 1) - 1;
|
|
218
221
|
var tableDom = view.nodeDOM(start).closest('table');
|
|
219
222
|
var attrs = tableNode.attrs;
|
|
@@ -226,9 +229,6 @@ function updateColumnWidth(view, cell, _width) {
|
|
|
226
229
|
attrs = setNodeStyle(attrs, 'width', tableDomWidth);
|
|
227
230
|
tr.setNodeMarkup(tablePos, null, attrs);
|
|
228
231
|
}
|
|
229
|
-
if (tr.docChanged) {
|
|
230
|
-
view.dispatch(tr);
|
|
231
|
-
}
|
|
232
232
|
}
|
|
233
233
|
function displayColumnWidth(view, cell, width, _cellMinWidth) {
|
|
234
234
|
var $cell = view.state.doc.resolve(cell);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Plugin } from 'prosemirror-state';
|
|
2
2
|
import { TableMap, tableNodeTypes } from 'prosemirror-tables';
|
|
3
3
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
4
|
-
import { domCellAround, otherResizeHandle, otherResizing, parentNode, parseStyle, setNodeStyle,
|
|
4
|
+
import { domCellAround, otherResizeHandle, otherResizing, parentNode, parseStyle, setNodeStyle, tableRowResizeKey as key } from './utils';
|
|
5
5
|
var TableRowView = /** @class */ (function () {
|
|
6
6
|
function TableRowView() {
|
|
7
7
|
}
|
|
@@ -179,7 +179,10 @@ function draggedHeight(dragging, event) {
|
|
|
179
179
|
return dragging.startHeight.rowHeight + offset;
|
|
180
180
|
}
|
|
181
181
|
function updateHandle(view, value) {
|
|
182
|
-
view.
|
|
182
|
+
var tr = view.state.tr;
|
|
183
|
+
tr.setMeta('addToHistory', false);
|
|
184
|
+
tr.setMeta(key, { setHandle: value });
|
|
185
|
+
view.dispatch(tr);
|
|
183
186
|
}
|
|
184
187
|
function updateRowHeight(view, tr, rowPos) {
|
|
185
188
|
var doc = view.state.doc;
|
|
@@ -208,7 +208,7 @@ export var tableResizing = function (options) {
|
|
|
208
208
|
return null;
|
|
209
209
|
},
|
|
210
210
|
update: function (view, prevState) {
|
|
211
|
-
var _a, _b, _c, _d;
|
|
211
|
+
var _a, _b, _c, _d, _f;
|
|
212
212
|
var state = view.state;
|
|
213
213
|
var nodeType = state.schema.nodes[options.node];
|
|
214
214
|
var selected = this.selectedNode(state, nodeType);
|
|
@@ -219,19 +219,25 @@ export var tableResizing = function (options) {
|
|
|
219
219
|
}
|
|
220
220
|
if (selected || prevSelected) {
|
|
221
221
|
var tr = state.tr;
|
|
222
|
+
tr.setMeta('addToHistory', false);
|
|
222
223
|
if (selected && prevSelected && selected.pos !== prevSelected.pos) {
|
|
223
224
|
tr.setMeta(key, { nodePosition: selected.pos });
|
|
224
225
|
tr.setNodeMarkup(prevSelected.pos, nodeType, tslib_1.__assign({}, prevSelected.node.attrs, (_a = {}, _a[resizableAttr] = false, _a)));
|
|
225
226
|
tr.setNodeMarkup(selected.pos, nodeType, tslib_1.__assign({}, selected.node.attrs, (_b = {}, _b[resizableAttr] = true, _b)));
|
|
226
227
|
view.dispatch(tr);
|
|
227
228
|
}
|
|
228
|
-
else if (selected &&
|
|
229
|
+
else if (selected && prevSelected && selected.pos === prevSelected.pos &&
|
|
230
|
+
!selected.node.attrs[resizableAttr] && !state.selection.eq(prevState.selection)) {
|
|
229
231
|
tr.setMeta(key, { nodePosition: selected.pos });
|
|
230
232
|
view.dispatch(tr.setNodeMarkup(selected.pos, nodeType, tslib_1.__assign({}, selected.node.attrs, (_c = {}, _c[resizableAttr] = true, _c))));
|
|
231
233
|
}
|
|
234
|
+
else if (selected && !prevSelected) {
|
|
235
|
+
tr.setMeta(key, { nodePosition: selected.pos });
|
|
236
|
+
view.dispatch(tr.setNodeMarkup(selected.pos, nodeType, tslib_1.__assign({}, selected.node.attrs, (_d = {}, _d[resizableAttr] = true, _d))));
|
|
237
|
+
}
|
|
232
238
|
else if (!selected && prevSelected) {
|
|
233
239
|
tr.setMeta(key, { nodePosition: -1 });
|
|
234
|
-
view.dispatch(tr.setNodeMarkup(prevSelected.pos, nodeType, tslib_1.__assign({}, prevSelected.node.attrs, (
|
|
240
|
+
view.dispatch(tr.setNodeMarkup(prevSelected.pos, nodeType, tslib_1.__assign({}, prevSelected.node.attrs, (_f = {}, _f[resizableAttr] = false, _f))));
|
|
235
241
|
}
|
|
236
242
|
}
|
|
237
243
|
}
|
|
@@ -25,26 +25,26 @@ export function setNodeStyle(nodeAttrs, styleType, value) {
|
|
|
25
25
|
return attrs;
|
|
26
26
|
}
|
|
27
27
|
export var tableResizeKey = new PluginKey('table-resize');
|
|
28
|
-
export var
|
|
29
|
-
export var
|
|
28
|
+
export var tableColumnResizeKey = new PluginKey('table-column-resizing');
|
|
29
|
+
export var tableRowResizeKey = new PluginKey('table-row-resizing');
|
|
30
30
|
export function otherResizing(current, state) {
|
|
31
31
|
var activeResize = false;
|
|
32
32
|
activeResize = activeResize ||
|
|
33
33
|
(current !== tableResizeKey && Boolean(tableResizeKey.get(state)) && tableResizeKey.getState(state).dragging);
|
|
34
34
|
activeResize = activeResize ||
|
|
35
|
-
(current !==
|
|
35
|
+
(current !== tableColumnResizeKey && Boolean(tableColumnResizeKey.get(state)) && tableColumnResizeKey.getState(state).dragging);
|
|
36
36
|
activeResize = activeResize ||
|
|
37
|
-
(current !==
|
|
37
|
+
(current !== tableRowResizeKey && Boolean(tableRowResizeKey.get(state)) && tableRowResizeKey.getState(state).dragging);
|
|
38
38
|
return activeResize;
|
|
39
39
|
}
|
|
40
40
|
export function otherResizeHandle(current, state) {
|
|
41
41
|
var activeResize = false;
|
|
42
42
|
activeResize = activeResize ||
|
|
43
|
-
(current !==
|
|
44
|
-
Boolean(
|
|
45
|
-
|
|
43
|
+
(current !== tableColumnResizeKey &&
|
|
44
|
+
Boolean(tableColumnResizeKey.get(state)) &&
|
|
45
|
+
tableColumnResizeKey.getState(state).activeHandle > -1);
|
|
46
46
|
activeResize = activeResize ||
|
|
47
|
-
(current !==
|
|
47
|
+
(current !== tableRowResizeKey && Boolean(tableRowResizeKey.get(state)) && tableRowResizeKey.getState(state).activeHandle > -1);
|
|
48
48
|
return activeResize;
|
|
49
49
|
}
|
|
50
50
|
export function getTable(dom) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const rowTypeAttr = 'k-parent-node';
|
|
2
2
|
export const colgroupAttr = 'k-colgroup-data';
|
|
3
|
-
export const resizableAttr = 'resizable-node';
|
|
3
|
+
export const resizableAttr = 'k-resizable-node';
|
|
4
4
|
export const resizableWrap = 'k-editor-resize-wrap-element';
|
|
5
5
|
export const resizeHandle = 'k-editor-resize-handle';
|
|
6
|
-
export const dataResizeDirTable = 'data-
|
|
7
|
-
export const dataResizeDirImage = 'data-
|
|
6
|
+
export const dataResizeDirTable = 'data-dir-table-resize';
|
|
7
|
+
export const dataResizeDirImage = 'data-dir-image-resize';
|
|
@@ -30,10 +30,10 @@ const hasAttrs = (attrs, exclude) => {
|
|
|
30
30
|
}
|
|
31
31
|
return false;
|
|
32
32
|
};
|
|
33
|
-
const pmAttributes = (attrs, exclude) => {
|
|
33
|
+
const pmAttributes = (attrs, exclude = []) => {
|
|
34
34
|
const result = {};
|
|
35
35
|
for (let attr in attrs) {
|
|
36
|
-
if (attr && attrs[attr] !== null &&
|
|
36
|
+
if (attr && attrs[attr] !== null && !exclude.find(e => e === attr)) {
|
|
37
37
|
result[attr] = attrs[attr];
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -118,7 +118,7 @@ tNodes.table_row.toDOM = node => ['tr', pmAttributes(node.attrs), 0];
|
|
|
118
118
|
tNodes.table_row.parseDOM = [{ tag: 'tr', getAttrs: domAttributes }];
|
|
119
119
|
tNodes.table.attrs = Object.assign({}, tNodes.table.attrs, defaultAttrs(['style', 'class', 'id', colgroupAttr, resizableAttr]));
|
|
120
120
|
tNodes.table.toDOM = (node) => {
|
|
121
|
-
const tableAttrs = hasAttrs(node.attrs) ? pmAttributes(node.attrs, colgroupAttr) : {};
|
|
121
|
+
const tableAttrs = hasAttrs(node.attrs) ? pmAttributes(node.attrs, [colgroupAttr, resizableAttr]) : {};
|
|
122
122
|
let colgroup = null;
|
|
123
123
|
if (node.attrs[colgroupAttr] && !shouldSkipColgroup(node)) {
|
|
124
124
|
const colgroupEl = parseStrColgroup(node.attrs[colgroupAttr]);
|
|
@@ -207,7 +207,7 @@ const nodes = Object.assign({
|
|
|
207
207
|
{ tag: 'h6', getAttrs: node => (Object.assign({}, domAttributes(node), { level: 6 })) }
|
|
208
208
|
],
|
|
209
209
|
toDOM: node => hasAttrs(node.attrs, 'level') ?
|
|
210
|
-
['h' + node.attrs.level, pmAttributes(node.attrs, 'level'), hole] :
|
|
210
|
+
['h' + node.attrs.level, pmAttributes(node.attrs, ['level']), hole] :
|
|
211
211
|
['h' + node.attrs.level, hole]
|
|
212
212
|
},
|
|
213
213
|
// :: NodeSpec A code listing. Disallows marks or non-text inline
|
|
@@ -264,8 +264,8 @@ const nodes = Object.assign({
|
|
|
264
264
|
} }],
|
|
265
265
|
toDOM: node => {
|
|
266
266
|
return node.attrs.order === 1 ?
|
|
267
|
-
(hasAttrs(node.attrs, 'order') ? ['ol', pmAttributes(node.attrs, 'order'), hole] : olDOM) :
|
|
268
|
-
['ol', Object.assign({}, pmAttributes(node.attrs, 'order'), { start: node.attrs.order }), hole];
|
|
267
|
+
(hasAttrs(node.attrs, 'order') ? ['ol', pmAttributes(node.attrs, ['order']), hole] : olDOM) :
|
|
268
|
+
['ol', Object.assign({}, pmAttributes(node.attrs, ['order']), { start: node.attrs.order }), hole];
|
|
269
269
|
}
|
|
270
270
|
},
|
|
271
271
|
// :: NodeSpec
|
package/dist/es2015/main.js
CHANGED
|
@@ -24,7 +24,7 @@ export { spacesFix } from './plugins/spaces-fix';
|
|
|
24
24
|
export { textHighlight, textHighlightKey } from './plugins/highlight';
|
|
25
25
|
export { imageResizing, imageResizeKey } from './plugins/image-resize';
|
|
26
26
|
export { caretColor, caretColorKey } from './plugins/caret-color';
|
|
27
|
-
export { tableResizing } from './plugins/table-resize';
|
|
27
|
+
export { tableResizing, tableResizeKey, tableColumnResizeKey, tableRowResizeKey } from './plugins/table-resize';
|
|
28
28
|
// ProseMirror re-exports
|
|
29
29
|
export * from 'prosemirror-commands';
|
|
30
30
|
export * from 'prosemirror-dropcursor';
|
|
@@ -3,7 +3,7 @@ import { tableNodeTypes, TableMap } from 'prosemirror-tables';
|
|
|
3
3
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
4
4
|
import { colgroupAttr } from '../../config/constants';
|
|
5
5
|
import { TableView } from './table-view';
|
|
6
|
-
import { cellIndexes, domCellAround, otherResizeHandle, otherResizing, parentNode, parseStyle, setNodeStyle,
|
|
6
|
+
import { cellIndexes, domCellAround, otherResizeHandle, otherResizing, parentNode, parseStyle, setNodeStyle, tableColumnResizeKey as key } from './utils';
|
|
7
7
|
export function columnResizing() {
|
|
8
8
|
// tslint:disable-next-line:variable-name
|
|
9
9
|
const View = TableView, handleWidth = 5, cellMinWidth = 25;
|
|
@@ -166,8 +166,9 @@ function handleMouseDown(view, event, cellMinWidth) {
|
|
|
166
166
|
ev.view.removeEventListener('mousemove', move);
|
|
167
167
|
let curPluginState = key.getState(view.state);
|
|
168
168
|
if (curPluginState.dragging) {
|
|
169
|
-
|
|
170
|
-
view.
|
|
169
|
+
const transaction = view.state.tr;
|
|
170
|
+
updateColumnWidth(view, transaction, curPluginState.activeHandle, draggedWidth(curPluginState.dragging, ev, cellMinWidth));
|
|
171
|
+
view.dispatch(transaction.setMeta(key, { setDragging: null }));
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
174
|
function move(ev) {
|
|
@@ -204,12 +205,14 @@ function draggedWidth(dragging, event, cellMinWidth) {
|
|
|
204
205
|
return Math.max(cellMinWidth, dragging.startWidth + offset);
|
|
205
206
|
}
|
|
206
207
|
function updateHandle(view, value) {
|
|
207
|
-
view.
|
|
208
|
+
const tr = view.state.tr;
|
|
209
|
+
tr.setMeta('addToHistory', false);
|
|
210
|
+
tr.setMeta(key, { setHandle: value });
|
|
211
|
+
view.dispatch(tr);
|
|
208
212
|
}
|
|
209
|
-
function updateColumnWidth(view, cell, _width) {
|
|
213
|
+
function updateColumnWidth(view, tr, cell, _width) {
|
|
210
214
|
let $cell = view.state.doc.resolve(cell);
|
|
211
215
|
let tableNode = $cell.node(-1), start = $cell.start(-1);
|
|
212
|
-
let tr = view.state.tr;
|
|
213
216
|
const tablePos = $cell.posAtIndex(0, $cell.depth - 1) - 1;
|
|
214
217
|
const tableDom = view.nodeDOM(start).closest('table');
|
|
215
218
|
let attrs = tableNode.attrs;
|
|
@@ -222,9 +225,6 @@ function updateColumnWidth(view, cell, _width) {
|
|
|
222
225
|
attrs = setNodeStyle(attrs, 'width', tableDomWidth);
|
|
223
226
|
tr.setNodeMarkup(tablePos, null, attrs);
|
|
224
227
|
}
|
|
225
|
-
if (tr.docChanged) {
|
|
226
|
-
view.dispatch(tr);
|
|
227
|
-
}
|
|
228
228
|
}
|
|
229
229
|
function displayColumnWidth(view, cell, width, _cellMinWidth) {
|
|
230
230
|
let $cell = view.state.doc.resolve(cell);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Plugin } from 'prosemirror-state';
|
|
2
2
|
import { TableMap, tableNodeTypes } from 'prosemirror-tables';
|
|
3
3
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
4
|
-
import { domCellAround, otherResizeHandle, otherResizing, parentNode, parseStyle, setNodeStyle,
|
|
4
|
+
import { domCellAround, otherResizeHandle, otherResizing, parentNode, parseStyle, setNodeStyle, tableRowResizeKey as key } from './utils';
|
|
5
5
|
class TableRowView {
|
|
6
6
|
ignoreMutation(record) {
|
|
7
7
|
return record.type === 'attributes' && record.attributeName === 'style' && record.target.nodeName === 'TR';
|
|
@@ -175,7 +175,10 @@ function draggedHeight(dragging, event) {
|
|
|
175
175
|
return dragging.startHeight.rowHeight + offset;
|
|
176
176
|
}
|
|
177
177
|
function updateHandle(view, value) {
|
|
178
|
-
view.
|
|
178
|
+
const tr = view.state.tr;
|
|
179
|
+
tr.setMeta('addToHistory', false);
|
|
180
|
+
tr.setMeta(key, { setHandle: value });
|
|
181
|
+
view.dispatch(tr);
|
|
179
182
|
}
|
|
180
183
|
function updateRowHeight(view, tr, rowPos) {
|
|
181
184
|
const doc = view.state.doc;
|
|
@@ -214,13 +214,19 @@ export const tableResizing = (options = { node: 'table' }) => {
|
|
|
214
214
|
return;
|
|
215
215
|
}
|
|
216
216
|
if (selected || prevSelected) {
|
|
217
|
-
|
|
217
|
+
const tr = state.tr;
|
|
218
|
+
tr.setMeta('addToHistory', false);
|
|
218
219
|
if (selected && prevSelected && selected.pos !== prevSelected.pos) {
|
|
219
220
|
tr.setMeta(key, { nodePosition: selected.pos });
|
|
220
221
|
tr.setNodeMarkup(prevSelected.pos, nodeType, Object.assign({}, prevSelected.node.attrs, { [resizableAttr]: false }));
|
|
221
222
|
tr.setNodeMarkup(selected.pos, nodeType, Object.assign({}, selected.node.attrs, { [resizableAttr]: true }));
|
|
222
223
|
view.dispatch(tr);
|
|
223
224
|
}
|
|
225
|
+
else if (selected && prevSelected && selected.pos === prevSelected.pos &&
|
|
226
|
+
!selected.node.attrs[resizableAttr] && !state.selection.eq(prevState.selection)) {
|
|
227
|
+
tr.setMeta(key, { nodePosition: selected.pos });
|
|
228
|
+
view.dispatch(tr.setNodeMarkup(selected.pos, nodeType, Object.assign({}, selected.node.attrs, { [resizableAttr]: true })));
|
|
229
|
+
}
|
|
224
230
|
else if (selected && !prevSelected) {
|
|
225
231
|
tr.setMeta(key, { nodePosition: selected.pos });
|
|
226
232
|
view.dispatch(tr.setNodeMarkup(selected.pos, nodeType, Object.assign({}, selected.node.attrs, { [resizableAttr]: true })));
|
|
@@ -23,26 +23,26 @@ export function setNodeStyle(nodeAttrs, styleType, value) {
|
|
|
23
23
|
return attrs;
|
|
24
24
|
}
|
|
25
25
|
export const tableResizeKey = new PluginKey('table-resize');
|
|
26
|
-
export const
|
|
27
|
-
export const
|
|
26
|
+
export const tableColumnResizeKey = new PluginKey('table-column-resizing');
|
|
27
|
+
export const tableRowResizeKey = new PluginKey('table-row-resizing');
|
|
28
28
|
export function otherResizing(current, state) {
|
|
29
29
|
let activeResize = false;
|
|
30
30
|
activeResize = activeResize ||
|
|
31
31
|
(current !== tableResizeKey && Boolean(tableResizeKey.get(state)) && tableResizeKey.getState(state).dragging);
|
|
32
32
|
activeResize = activeResize ||
|
|
33
|
-
(current !==
|
|
33
|
+
(current !== tableColumnResizeKey && Boolean(tableColumnResizeKey.get(state)) && tableColumnResizeKey.getState(state).dragging);
|
|
34
34
|
activeResize = activeResize ||
|
|
35
|
-
(current !==
|
|
35
|
+
(current !== tableRowResizeKey && Boolean(tableRowResizeKey.get(state)) && tableRowResizeKey.getState(state).dragging);
|
|
36
36
|
return activeResize;
|
|
37
37
|
}
|
|
38
38
|
export function otherResizeHandle(current, state) {
|
|
39
39
|
let activeResize = false;
|
|
40
40
|
activeResize = activeResize ||
|
|
41
|
-
(current !==
|
|
42
|
-
Boolean(
|
|
43
|
-
|
|
41
|
+
(current !== tableColumnResizeKey &&
|
|
42
|
+
Boolean(tableColumnResizeKey.get(state)) &&
|
|
43
|
+
tableColumnResizeKey.getState(state).activeHandle > -1);
|
|
44
44
|
activeResize = activeResize ||
|
|
45
|
-
(current !==
|
|
45
|
+
(current !== tableRowResizeKey && Boolean(tableRowResizeKey.get(state)) && tableRowResizeKey.getState(state).activeHandle > -1);
|
|
46
46
|
return activeResize;
|
|
47
47
|
}
|
|
48
48
|
export function getTable(dom) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const rowTypeAttr = "k-parent-node";
|
|
2
2
|
export declare const colgroupAttr = "k-colgroup-data";
|
|
3
|
-
export declare const resizableAttr = "resizable-node";
|
|
3
|
+
export declare const resizableAttr = "k-resizable-node";
|
|
4
4
|
export declare const resizableWrap = "k-editor-resize-wrap-element";
|
|
5
5
|
export declare const resizeHandle = "k-editor-resize-handle";
|
|
6
|
-
export declare const dataResizeDirTable = "data-
|
|
7
|
-
export declare const dataResizeDirImage = "data-
|
|
6
|
+
export declare const dataResizeDirTable = "data-dir-table-resize";
|
|
7
|
+
export declare const dataResizeDirImage = "data-dir-image-resize";
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rowTypeAttr = 'k-parent-node';
|
|
4
4
|
exports.colgroupAttr = 'k-colgroup-data';
|
|
5
|
-
exports.resizableAttr = 'resizable-node';
|
|
5
|
+
exports.resizableAttr = 'k-resizable-node';
|
|
6
6
|
exports.resizableWrap = 'k-editor-resize-wrap-element';
|
|
7
7
|
exports.resizeHandle = 'k-editor-resize-handle';
|
|
8
|
-
exports.dataResizeDirTable = 'data-
|
|
9
|
-
exports.dataResizeDirImage = 'data-
|
|
8
|
+
exports.dataResizeDirTable = 'data-dir-table-resize';
|
|
9
|
+
exports.dataResizeDirImage = 'data-dir-image-resize';
|
|
@@ -34,11 +34,15 @@ var hasAttrs = function (attrs, exclude) {
|
|
|
34
34
|
return false;
|
|
35
35
|
};
|
|
36
36
|
var pmAttributes = function (attrs, exclude) {
|
|
37
|
+
if (exclude === void 0) { exclude = []; }
|
|
37
38
|
var result = {};
|
|
38
|
-
|
|
39
|
-
if (attr && attrs[attr] !== null && attr
|
|
39
|
+
var _loop_1 = function (attr) {
|
|
40
|
+
if (attr && attrs[attr] !== null && !exclude.find(function (e) { return e === attr; })) {
|
|
40
41
|
result[attr] = attrs[attr];
|
|
41
42
|
}
|
|
43
|
+
};
|
|
44
|
+
for (var attr in attrs) {
|
|
45
|
+
_loop_1(attr);
|
|
42
46
|
}
|
|
43
47
|
return result;
|
|
44
48
|
};
|
|
@@ -124,7 +128,7 @@ tNodes.table_row.toDOM = function (node) { return ['tr', pmAttributes(node.attrs
|
|
|
124
128
|
tNodes.table_row.parseDOM = [{ tag: 'tr', getAttrs: domAttributes }];
|
|
125
129
|
tNodes.table.attrs = tslib_1.__assign({}, tNodes.table.attrs, defaultAttrs(['style', 'class', 'id', constants_1.colgroupAttr, constants_1.resizableAttr]));
|
|
126
130
|
tNodes.table.toDOM = function (node) {
|
|
127
|
-
var tableAttrs = hasAttrs(node.attrs) ? pmAttributes(node.attrs, constants_1.colgroupAttr) : {};
|
|
131
|
+
var tableAttrs = hasAttrs(node.attrs) ? pmAttributes(node.attrs, [constants_1.colgroupAttr, constants_1.resizableAttr]) : {};
|
|
128
132
|
var colgroup = null;
|
|
129
133
|
if (node.attrs[constants_1.colgroupAttr] && !shouldSkipColgroup(node)) {
|
|
130
134
|
var colgroupEl = exports.parseStrColgroup(node.attrs[constants_1.colgroupAttr]);
|
|
@@ -213,7 +217,7 @@ var nodes = tslib_1.__assign({
|
|
|
213
217
|
{ tag: 'h6', getAttrs: function (node) { return (tslib_1.__assign({}, domAttributes(node), { level: 6 })); } }
|
|
214
218
|
],
|
|
215
219
|
toDOM: function (node) { return hasAttrs(node.attrs, 'level') ?
|
|
216
|
-
['h' + node.attrs.level, pmAttributes(node.attrs, 'level'), hole] :
|
|
220
|
+
['h' + node.attrs.level, pmAttributes(node.attrs, ['level']), hole] :
|
|
217
221
|
['h' + node.attrs.level, hole]; }
|
|
218
222
|
},
|
|
219
223
|
// :: NodeSpec A code listing. Disallows marks or non-text inline
|
|
@@ -270,8 +274,8 @@ var nodes = tslib_1.__assign({
|
|
|
270
274
|
} }],
|
|
271
275
|
toDOM: function (node) {
|
|
272
276
|
return node.attrs.order === 1 ?
|
|
273
|
-
(hasAttrs(node.attrs, 'order') ? ['ol', pmAttributes(node.attrs, 'order'), hole] : olDOM) :
|
|
274
|
-
['ol', tslib_1.__assign({}, pmAttributes(node.attrs, 'order'), { start: node.attrs.order }), hole];
|
|
277
|
+
(hasAttrs(node.attrs, 'order') ? ['ol', pmAttributes(node.attrs, ['order']), hole] : olDOM) :
|
|
278
|
+
['ol', tslib_1.__assign({}, pmAttributes(node.attrs, ['order']), { start: node.attrs.order }), hole];
|
|
275
279
|
}
|
|
276
280
|
},
|
|
277
281
|
// :: NodeSpec
|
package/dist/npm/main.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export { spacesFix } from './plugins/spaces-fix';
|
|
|
26
26
|
export { textHighlight, textHighlightKey, InlineDecoration } from './plugins/highlight';
|
|
27
27
|
export { imageResizing, imageResizeKey, ImageResizeOptions } from './plugins/image-resize';
|
|
28
28
|
export { caretColor, caretColorKey } from './plugins/caret-color';
|
|
29
|
-
export { tableResizing } from './plugins/table-resize';
|
|
29
|
+
export { tableResizing, tableResizeKey, tableColumnResizeKey, tableRowResizeKey } from './plugins/table-resize';
|
|
30
30
|
export * from 'prosemirror-commands';
|
|
31
31
|
export * from 'prosemirror-dropcursor';
|
|
32
32
|
export * from 'prosemirror-gapcursor';
|
package/dist/npm/main.js
CHANGED
|
@@ -122,6 +122,9 @@ exports.caretColor = caret_color_1.caretColor;
|
|
|
122
122
|
exports.caretColorKey = caret_color_1.caretColorKey;
|
|
123
123
|
var table_resize_1 = require("./plugins/table-resize");
|
|
124
124
|
exports.tableResizing = table_resize_1.tableResizing;
|
|
125
|
+
exports.tableResizeKey = table_resize_1.tableResizeKey;
|
|
126
|
+
exports.tableColumnResizeKey = table_resize_1.tableColumnResizeKey;
|
|
127
|
+
exports.tableRowResizeKey = table_resize_1.tableRowResizeKey;
|
|
125
128
|
// ProseMirror re-exports
|
|
126
129
|
tslib_1.__exportStar(require("prosemirror-commands"), exports);
|
|
127
130
|
tslib_1.__exportStar(require("prosemirror-dropcursor"), exports);
|