@progress/kendo-editor-common 1.9.0-dev.202204181342 → 1.9.0-dev.202204181536
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/main.js +1 -1
- package/dist/es/plugins/table-resize/column-resize.js +1 -1
- package/dist/es/plugins/table-resize/index.js +1 -0
- package/dist/es/plugins/table-resize/row-resize.js +1 -1
- package/dist/es/plugins/table-resize/utils.js +8 -8
- package/dist/es2015/config/constants.js +3 -3
- package/dist/es2015/main.js +1 -1
- package/dist/es2015/plugins/table-resize/column-resize.js +1 -1
- package/dist/es2015/plugins/table-resize/index.js +1 -0
- package/dist/es2015/plugins/table-resize/row-resize.js +1 -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/main.d.ts +1 -1
- package/dist/npm/main.js +3 -0
- package/dist/npm/plugins/table-resize/column-resize.js +15 -15
- 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 +15 -15
- 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/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;
|
|
@@ -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
|
}
|
|
@@ -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';
|
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;
|
|
@@ -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';
|
|
@@ -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';
|
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);
|
|
@@ -11,7 +11,7 @@ function columnResizing() {
|
|
|
11
11
|
// tslint:disable-next-line:variable-name
|
|
12
12
|
var View = table_view_1.TableView, handleWidth = 5, cellMinWidth = 25;
|
|
13
13
|
var plugin = new prosemirror_state_1.Plugin({
|
|
14
|
-
key: utils_1.
|
|
14
|
+
key: utils_1.tableColumnResizeKey,
|
|
15
15
|
state: {
|
|
16
16
|
init: function (_, state) {
|
|
17
17
|
this.spec.props.nodeViews[prosemirror_tables_1.tableNodeTypes(state.schema).table.name] = function (node, view) { return new View(node, view); };
|
|
@@ -23,15 +23,15 @@ function columnResizing() {
|
|
|
23
23
|
},
|
|
24
24
|
props: {
|
|
25
25
|
attributes: function (state) {
|
|
26
|
-
if (utils_1.otherResizeHandle(utils_1.
|
|
26
|
+
if (utils_1.otherResizeHandle(utils_1.tableColumnResizeKey, state)) {
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
|
-
var pluginState = utils_1.
|
|
29
|
+
var pluginState = utils_1.tableColumnResizeKey.getState(state);
|
|
30
30
|
return pluginState.activeHandle > -1 ? { class: 'resize-cursor' } : null;
|
|
31
31
|
},
|
|
32
32
|
handleDOMEvents: {
|
|
33
33
|
mousemove: function (view, event) {
|
|
34
|
-
if (!utils_1.otherResizing(utils_1.
|
|
34
|
+
if (!utils_1.otherResizing(utils_1.tableColumnResizeKey, view.state)) {
|
|
35
35
|
handleMouseMove(view, event, handleWidth);
|
|
36
36
|
}
|
|
37
37
|
return false;
|
|
@@ -45,8 +45,8 @@ function columnResizing() {
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
decorations: function (state) {
|
|
48
|
-
if (!utils_1.otherResizing(utils_1.
|
|
49
|
-
var pluginState = utils_1.
|
|
48
|
+
if (!utils_1.otherResizing(utils_1.tableColumnResizeKey, state)) {
|
|
49
|
+
var pluginState = utils_1.tableColumnResizeKey.getState(state);
|
|
50
50
|
if (pluginState.activeHandle > -1) {
|
|
51
51
|
return handleDecorations(state, pluginState.activeHandle);
|
|
52
52
|
}
|
|
@@ -68,7 +68,7 @@ var ResizeState = /** @class */ (function () {
|
|
|
68
68
|
this.dragging = dragging;
|
|
69
69
|
}
|
|
70
70
|
ResizeState.prototype.apply = function (tr) {
|
|
71
|
-
var state = this, action = tr.getMeta(utils_1.
|
|
71
|
+
var state = this, action = tr.getMeta(utils_1.tableColumnResizeKey);
|
|
72
72
|
if (action && action.setHandle != null) {
|
|
73
73
|
return new ResizeState(action.setHandle, null);
|
|
74
74
|
}
|
|
@@ -87,7 +87,7 @@ var ResizeState = /** @class */ (function () {
|
|
|
87
87
|
return ResizeState;
|
|
88
88
|
}());
|
|
89
89
|
function handleMouseMove(view, event, handleWidth) {
|
|
90
|
-
var pluginState = utils_1.
|
|
90
|
+
var pluginState = utils_1.tableColumnResizeKey.getState(view.state);
|
|
91
91
|
if (!pluginState.dragging) {
|
|
92
92
|
var target = utils_1.domCellAround(event.target), cell = -1;
|
|
93
93
|
if (target) {
|
|
@@ -107,14 +107,14 @@ function handleMouseMove(view, event, handleWidth) {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
function handleMouseLeave(view) {
|
|
110
|
-
var pluginState = utils_1.
|
|
110
|
+
var pluginState = utils_1.tableColumnResizeKey.getState(view.state);
|
|
111
111
|
if (pluginState.activeHandle > -1 && !pluginState.dragging) {
|
|
112
112
|
updateHandle(view, -1);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
function handleMouseDown(view, event, cellMinWidth) {
|
|
116
116
|
var _a;
|
|
117
|
-
var pluginState = utils_1.
|
|
117
|
+
var pluginState = utils_1.tableColumnResizeKey.getState(view.state);
|
|
118
118
|
if (pluginState.activeHandle === -1 || pluginState.dragging) {
|
|
119
119
|
return false;
|
|
120
120
|
}
|
|
@@ -154,7 +154,7 @@ function handleMouseDown(view, event, cellMinWidth) {
|
|
|
154
154
|
tableAttrs = tslib_1.__assign({}, tableNode.attrs, (_a = {}, _a[constants_1.colgroupAttr] = '<colgroup>' + cols.reduce(function (acc, cur) { return acc + cur.outerHTML; }, '') + '</colgroup>', _a));
|
|
155
155
|
}
|
|
156
156
|
var width = parseFloat(col.style.width);
|
|
157
|
-
var tr = view.state.tr.setMeta(utils_1.
|
|
157
|
+
var tr = view.state.tr.setMeta(utils_1.tableColumnResizeKey, { setDragging: { startX: event.clientX, startWidth: width } });
|
|
158
158
|
if (!tableDom.style.width) {
|
|
159
159
|
var widths = Array.from(col.parentNode.children).map(function (c) { return c.style.width; });
|
|
160
160
|
if (widths.every(Boolean)) {
|
|
@@ -170,17 +170,17 @@ function handleMouseDown(view, event, cellMinWidth) {
|
|
|
170
170
|
function finish(ev) {
|
|
171
171
|
ev.view.removeEventListener('mouseup', finish);
|
|
172
172
|
ev.view.removeEventListener('mousemove', move);
|
|
173
|
-
var curPluginState = utils_1.
|
|
173
|
+
var curPluginState = utils_1.tableColumnResizeKey.getState(view.state);
|
|
174
174
|
if (curPluginState.dragging) {
|
|
175
175
|
updateColumnWidth(view, curPluginState.activeHandle, draggedWidth(curPluginState.dragging, ev, cellMinWidth));
|
|
176
|
-
view.dispatch(view.state.tr.setMeta(utils_1.
|
|
176
|
+
view.dispatch(view.state.tr.setMeta(utils_1.tableColumnResizeKey, { setDragging: null }));
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
function move(ev) {
|
|
180
180
|
if (!ev.which) {
|
|
181
181
|
return finish(ev);
|
|
182
182
|
}
|
|
183
|
-
var curPluginState = utils_1.
|
|
183
|
+
var curPluginState = utils_1.tableColumnResizeKey.getState(view.state);
|
|
184
184
|
var dragged = draggedWidth(curPluginState.dragging, ev, cellMinWidth);
|
|
185
185
|
displayColumnWidth(view, curPluginState.activeHandle, dragged, cellMinWidth);
|
|
186
186
|
}
|
|
@@ -210,7 +210,7 @@ function draggedWidth(dragging, event, cellMinWidth) {
|
|
|
210
210
|
return Math.max(cellMinWidth, dragging.startWidth + offset);
|
|
211
211
|
}
|
|
212
212
|
function updateHandle(view, value) {
|
|
213
|
-
view.dispatch(view.state.tr.setMeta(utils_1.
|
|
213
|
+
view.dispatch(view.state.tr.setMeta(utils_1.tableColumnResizeKey, { setHandle: value }));
|
|
214
214
|
}
|
|
215
215
|
function updateColumnWidth(view, cell, _width) {
|
|
216
216
|
var _a;
|
|
@@ -8,3 +8,7 @@ exports.tableResizing = function () { return [
|
|
|
8
8
|
column_resize_1.columnResizing(),
|
|
9
9
|
row_resize_1.rowResizing()
|
|
10
10
|
]; };
|
|
11
|
+
var utils_1 = require("./utils");
|
|
12
|
+
exports.tableResizeKey = utils_1.tableResizeKey;
|
|
13
|
+
exports.tableColumnResizeKey = utils_1.tableColumnResizeKey;
|
|
14
|
+
exports.tableRowResizeKey = utils_1.tableRowResizeKey;
|
|
@@ -15,7 +15,7 @@ var TableRowView = /** @class */ (function () {
|
|
|
15
15
|
function rowResizing() {
|
|
16
16
|
var handleWidth = 5;
|
|
17
17
|
var plugin = new prosemirror_state_1.Plugin({
|
|
18
|
-
key: utils_1.
|
|
18
|
+
key: utils_1.tableRowResizeKey,
|
|
19
19
|
state: {
|
|
20
20
|
init: function (_, state) {
|
|
21
21
|
this.spec.props.nodeViews[prosemirror_tables_1.tableNodeTypes(state.schema).row.name] = function (_node, _view) { return new TableRowView(); };
|
|
@@ -27,15 +27,15 @@ function rowResizing() {
|
|
|
27
27
|
},
|
|
28
28
|
props: {
|
|
29
29
|
attributes: function (state) {
|
|
30
|
-
if (utils_1.otherResizeHandle(utils_1.
|
|
30
|
+
if (utils_1.otherResizeHandle(utils_1.tableRowResizeKey, state)) {
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
|
-
var pluginState = utils_1.
|
|
33
|
+
var pluginState = utils_1.tableRowResizeKey.getState(state);
|
|
34
34
|
return pluginState.activeHandle > -1 ? { class: 'resize-cursor-vertical' } : null;
|
|
35
35
|
},
|
|
36
36
|
handleDOMEvents: {
|
|
37
37
|
mousemove: function (view, event) {
|
|
38
|
-
if (!utils_1.otherResizing(utils_1.
|
|
38
|
+
if (!utils_1.otherResizing(utils_1.tableRowResizeKey, view.state)) {
|
|
39
39
|
handleMouseMove(view, event, handleWidth);
|
|
40
40
|
}
|
|
41
41
|
return false;
|
|
@@ -49,10 +49,10 @@ function rowResizing() {
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
decorations: function (state) {
|
|
52
|
-
if (utils_1.otherResizing(utils_1.
|
|
52
|
+
if (utils_1.otherResizing(utils_1.tableRowResizeKey, state)) {
|
|
53
53
|
return prosemirror_view_1.DecorationSet.empty;
|
|
54
54
|
}
|
|
55
|
-
var pluginState = utils_1.
|
|
55
|
+
var pluginState = utils_1.tableRowResizeKey.getState(state);
|
|
56
56
|
if (pluginState.activeHandle > -1) {
|
|
57
57
|
return handleDecorations(state, pluginState.activeHandle);
|
|
58
58
|
}
|
|
@@ -72,7 +72,7 @@ var ResizeState = /** @class */ (function () {
|
|
|
72
72
|
this.dragging = dragging;
|
|
73
73
|
}
|
|
74
74
|
ResizeState.prototype.apply = function (tr) {
|
|
75
|
-
var state = this, action = tr.getMeta(utils_1.
|
|
75
|
+
var state = this, action = tr.getMeta(utils_1.tableRowResizeKey);
|
|
76
76
|
if (action && action.setHandle != null) {
|
|
77
77
|
return new ResizeState(action.setHandle, null);
|
|
78
78
|
}
|
|
@@ -91,7 +91,7 @@ var ResizeState = /** @class */ (function () {
|
|
|
91
91
|
return ResizeState;
|
|
92
92
|
}());
|
|
93
93
|
function handleMouseMove(view, event, handleWidth) {
|
|
94
|
-
var pluginState = utils_1.
|
|
94
|
+
var pluginState = utils_1.tableRowResizeKey.getState(view.state);
|
|
95
95
|
if (!pluginState.dragging) {
|
|
96
96
|
var target = utils_1.domCellAround(event.target), row = -1;
|
|
97
97
|
if (target) {
|
|
@@ -110,13 +110,13 @@ function handleMouseMove(view, event, handleWidth) {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
function handleMouseLeave(view) {
|
|
113
|
-
var pluginState = utils_1.
|
|
113
|
+
var pluginState = utils_1.tableRowResizeKey.getState(view.state);
|
|
114
114
|
if (pluginState.activeHandle > -1 && !pluginState.dragging) {
|
|
115
115
|
updateHandle(view, -1);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
function handleMouseDown(view, event) {
|
|
119
|
-
var pluginState = utils_1.
|
|
119
|
+
var pluginState = utils_1.tableRowResizeKey.getState(view.state);
|
|
120
120
|
if (pluginState.activeHandle === -1 || pluginState.dragging) {
|
|
121
121
|
return false;
|
|
122
122
|
}
|
|
@@ -131,7 +131,7 @@ function handleMouseDown(view, event) {
|
|
|
131
131
|
var tr = view.nodeDOM(pluginState.activeHandle);
|
|
132
132
|
rowHeight = tr.offsetHeight;
|
|
133
133
|
}
|
|
134
|
-
view.dispatch(view.state.tr.setMeta(utils_1.
|
|
134
|
+
view.dispatch(view.state.tr.setMeta(utils_1.tableRowResizeKey, {
|
|
135
135
|
setDragging: {
|
|
136
136
|
startY: event.clientY,
|
|
137
137
|
startHeight: { rowHeight: rowHeight, tableHeight: tableHeight }
|
|
@@ -140,9 +140,9 @@ function handleMouseDown(view, event) {
|
|
|
140
140
|
function finish(ev) {
|
|
141
141
|
ev.view.removeEventListener('mouseup', finish);
|
|
142
142
|
ev.view.removeEventListener('mousemove', move);
|
|
143
|
-
var curPluginState = utils_1.
|
|
143
|
+
var curPluginState = utils_1.tableRowResizeKey.getState(view.state);
|
|
144
144
|
if (curPluginState.dragging) {
|
|
145
|
-
var tr = view.state.tr.setMeta(utils_1.
|
|
145
|
+
var tr = view.state.tr.setMeta(utils_1.tableRowResizeKey, { setDragging: null });
|
|
146
146
|
updateRowHeight(view, tr, curPluginState.activeHandle);
|
|
147
147
|
view.dispatch(tr);
|
|
148
148
|
}
|
|
@@ -151,7 +151,7 @@ function handleMouseDown(view, event) {
|
|
|
151
151
|
if (!ev.which) {
|
|
152
152
|
return finish(ev);
|
|
153
153
|
}
|
|
154
|
-
var curPluginState = utils_1.
|
|
154
|
+
var curPluginState = utils_1.tableRowResizeKey.getState(view.state);
|
|
155
155
|
var dragged = draggedHeight(curPluginState.dragging, ev);
|
|
156
156
|
var offset = ev.clientY - curPluginState.dragging.startY;
|
|
157
157
|
displayRowHeight(view, curPluginState.activeHandle, dragged, offset, tableHeight);
|
|
@@ -182,7 +182,7 @@ function draggedHeight(dragging, event) {
|
|
|
182
182
|
return dragging.startHeight.rowHeight + offset;
|
|
183
183
|
}
|
|
184
184
|
function updateHandle(view, value) {
|
|
185
|
-
view.dispatch(view.state.tr.setMeta(utils_1.
|
|
185
|
+
view.dispatch(view.state.tr.setMeta(utils_1.tableRowResizeKey, { setHandle: value }));
|
|
186
186
|
}
|
|
187
187
|
function updateRowHeight(view, tr, rowPos) {
|
|
188
188
|
var doc = view.state.doc;
|
|
@@ -6,8 +6,8 @@ export declare const parseStyle: (styleText: string) => {
|
|
|
6
6
|
};
|
|
7
7
|
export declare function setNodeStyle(nodeAttrs: any, styleType: string, value: string): any;
|
|
8
8
|
export declare const tableResizeKey: PluginKey<any, any>;
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
9
|
+
export declare const tableColumnResizeKey: PluginKey<any, any>;
|
|
10
|
+
export declare const tableRowResizeKey: PluginKey<any, any>;
|
|
11
11
|
export declare function otherResizing(current: PluginKey, state: EditorState): boolean;
|
|
12
12
|
export declare function otherResizeHandle(current: PluginKey, state: EditorState): boolean;
|
|
13
13
|
export declare function getTable(dom: HTMLElement): HTMLTableElement;
|
|
@@ -28,27 +28,27 @@ function setNodeStyle(nodeAttrs, styleType, value) {
|
|
|
28
28
|
}
|
|
29
29
|
exports.setNodeStyle = setNodeStyle;
|
|
30
30
|
exports.tableResizeKey = new prosemirror_state_1.PluginKey('table-resize');
|
|
31
|
-
exports.
|
|
32
|
-
exports.
|
|
31
|
+
exports.tableColumnResizeKey = new prosemirror_state_1.PluginKey('table-column-resizing');
|
|
32
|
+
exports.tableRowResizeKey = new prosemirror_state_1.PluginKey('table-row-resizing');
|
|
33
33
|
function otherResizing(current, state) {
|
|
34
34
|
var activeResize = false;
|
|
35
35
|
activeResize = activeResize ||
|
|
36
36
|
(current !== exports.tableResizeKey && Boolean(exports.tableResizeKey.get(state)) && exports.tableResizeKey.getState(state).dragging);
|
|
37
37
|
activeResize = activeResize ||
|
|
38
|
-
(current !== exports.
|
|
38
|
+
(current !== exports.tableColumnResizeKey && Boolean(exports.tableColumnResizeKey.get(state)) && exports.tableColumnResizeKey.getState(state).dragging);
|
|
39
39
|
activeResize = activeResize ||
|
|
40
|
-
(current !== exports.
|
|
40
|
+
(current !== exports.tableRowResizeKey && Boolean(exports.tableRowResizeKey.get(state)) && exports.tableRowResizeKey.getState(state).dragging);
|
|
41
41
|
return activeResize;
|
|
42
42
|
}
|
|
43
43
|
exports.otherResizing = otherResizing;
|
|
44
44
|
function otherResizeHandle(current, state) {
|
|
45
45
|
var activeResize = false;
|
|
46
46
|
activeResize = activeResize ||
|
|
47
|
-
(current !== exports.
|
|
48
|
-
Boolean(exports.
|
|
49
|
-
exports.
|
|
47
|
+
(current !== exports.tableColumnResizeKey &&
|
|
48
|
+
Boolean(exports.tableColumnResizeKey.get(state)) &&
|
|
49
|
+
exports.tableColumnResizeKey.getState(state).activeHandle > -1);
|
|
50
50
|
activeResize = activeResize ||
|
|
51
|
-
(current !== exports.
|
|
51
|
+
(current !== exports.tableRowResizeKey && Boolean(exports.tableRowResizeKey.get(state)) && exports.tableRowResizeKey.getState(state).activeHandle > -1);
|
|
52
52
|
return activeResize;
|
|
53
53
|
}
|
|
54
54
|
exports.otherResizeHandle = otherResizeHandle;
|