@progress/kendo-editor-common 1.12.2-develop.5 → 1.12.2-develop.7
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 +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/DOMSerializer.js +6 -7
- package/dist/es/align.js +3 -6
- package/dist/es/blockNode.js +11 -14
- package/dist/es/blockquote.js +2 -5
- package/dist/es/cleanFormatting.js +3 -6
- package/dist/es/config/align-rules.js +5 -7
- package/dist/es/config/commands.js +13 -9
- package/dist/es/config/constants.js +7 -9
- package/dist/es/config/indent-rules.js +3 -6
- package/dist/es/config/keymap.js +7 -10
- package/dist/es/config/list-settings.js +3 -5
- package/dist/es/config/schema.js +4 -6
- package/dist/es/find-replace.js +8 -10
- package/dist/es/flatten-spans.js +2 -5
- package/dist/es/image.js +2 -5
- package/dist/es/indent.js +11 -14
- package/dist/es/inline-style.js +10 -12
- package/dist/es/link.js +5 -8
- package/dist/es/listConvert.js +8 -9
- package/dist/es/lists.js +12 -15
- package/dist/es/main.js +34 -33
- package/dist/es/mark.js +16 -17
- package/dist/es/paste.js +10 -13
- package/dist/es/plugins/caret-color.js +5 -8
- package/dist/es/plugins/csp-fix.js +2 -5
- package/dist/es/plugins/highlight.js +3 -6
- package/dist/es/plugins/image-resize.js +8 -11
- package/dist/es/plugins/list-markers-styles.js +2 -5
- package/dist/es/plugins/placeholder.js +2 -5
- package/dist/es/plugins/resize-utils.js +2 -4
- package/dist/es/plugins/spaces-fix.js +1 -4
- package/dist/es/plugins/table-resize/column-resize.js +21 -24
- package/dist/es/plugins/table-resize/index.js +6 -9
- package/dist/es/plugins/table-resize/row-resize.js +23 -24
- package/dist/es/plugins/table-resize/table-resize.js +17 -20
- package/dist/es/plugins/table-resize/table-view.js +6 -9
- package/dist/es/plugins/table-resize/utils.js +10 -13
- package/dist/es/source.js +15 -18
- package/dist/es/table.js +15 -18
- package/dist/es/text.js +1 -3
- package/dist/es/types/active-marks.js +1 -0
- package/dist/es/types/command.js +1 -0
- package/dist/es/types/dispatchFn.js +1 -0
- package/dist/es/types/paste-cleanup-settings.js +1 -0
- package/dist/es/types/predicate.js +1 -0
- package/dist/es/utils.js +18 -21
- package/dist/npm/DOMSerializer.d.ts +35 -0
- package/dist/npm/DOMSerializer.js +10 -9
- package/dist/npm/align.d.ts +4 -7
- package/dist/npm/align.js +9 -10
- package/dist/npm/blockNode.d.ts +15 -12
- package/dist/npm/blockNode.js +28 -29
- package/dist/npm/blockquote.d.ts +2 -5
- package/dist/npm/blockquote.js +6 -7
- package/dist/npm/cleanFormatting.d.ts +3 -6
- package/dist/npm/cleanFormatting.js +7 -8
- package/dist/npm/config/align-rules.d.ts +6 -8
- package/dist/npm/config/align-rules.js +8 -13
- package/dist/npm/config/commands.d.ts +19 -11
- package/dist/npm/config/commands.js +16 -17
- package/dist/npm/config/constants.d.ts +7 -0
- package/dist/npm/config/constants.js +10 -17
- package/dist/npm/config/indent-rules.d.ts +4 -6
- package/dist/npm/config/indent-rules.js +8 -11
- package/dist/npm/config/keymap.d.ts +2 -5
- package/dist/npm/config/keymap.js +21 -22
- package/dist/npm/config/list-settings.d.ts +30 -0
- package/dist/npm/config/list-settings.js +10 -13
- package/dist/npm/config/schema.d.ts +2 -3
- package/dist/npm/config/schema.js +19 -20
- package/dist/npm/find-replace.d.ts +7 -10
- package/dist/npm/find-replace.js +20 -20
- package/dist/npm/flatten-spans.d.ts +1 -3
- package/dist/npm/flatten-spans.js +6 -7
- package/dist/npm/image.d.ts +3 -6
- package/dist/npm/image.js +5 -6
- package/dist/npm/indent.d.ts +9 -12
- package/dist/npm/indent.js +37 -38
- package/dist/npm/inline-style.d.ts +4 -7
- package/dist/npm/inline-style.js +28 -28
- package/dist/npm/link.d.ts +2 -4
- package/dist/npm/link.js +21 -22
- package/dist/npm/listConvert.d.ts +1 -3
- package/dist/npm/listConvert.js +13 -12
- package/dist/npm/lists.d.ts +8 -8
- package/dist/npm/lists.js +26 -27
- package/dist/npm/main.d.ts +34 -35
- package/dist/npm/main.js +214 -391
- package/dist/npm/mark.d.ts +17 -12
- package/dist/npm/mark.js +30 -29
- package/dist/npm/paste.d.ts +8 -11
- package/dist/npm/paste.js +19 -20
- package/dist/npm/plugins/caret-color.d.ts +2 -5
- package/dist/npm/plugins/caret-color.js +15 -17
- package/dist/npm/plugins/csp-fix.d.ts +1 -4
- package/dist/npm/plugins/csp-fix.js +8 -9
- package/dist/npm/plugins/highlight.d.ts +4 -7
- package/dist/npm/plugins/highlight.js +11 -13
- package/dist/npm/plugins/image-resize.d.ts +5 -7
- package/dist/npm/plugins/image-resize.js +35 -37
- package/dist/npm/plugins/list-markers-styles.d.ts +2 -5
- package/dist/npm/plugins/list-markers-styles.js +14 -16
- package/dist/npm/plugins/placeholder.d.ts +1 -4
- package/dist/npm/plugins/placeholder.js +10 -12
- package/dist/npm/plugins/resize-utils.d.ts +35 -0
- package/dist/npm/plugins/resize-utils.js +5 -7
- package/dist/npm/plugins/spaces-fix.d.ts +1 -4
- package/dist/npm/plugins/spaces-fix.js +9 -10
- package/dist/npm/plugins/table-resize/column-resize.d.ts +2 -0
- package/dist/npm/plugins/table-resize/column-resize.js +44 -46
- package/dist/npm/plugins/table-resize/index.d.ts +2 -5
- package/dist/npm/plugins/table-resize/index.js +13 -14
- package/dist/npm/plugins/table-resize/row-resize.d.ts +2 -0
- package/dist/npm/plugins/table-resize/row-resize.js +40 -40
- package/dist/npm/plugins/table-resize/table-resize.d.ts +18 -0
- package/dist/npm/plugins/table-resize/table-resize.js +51 -52
- package/dist/npm/plugins/table-resize/table-view.d.ts +28 -0
- package/dist/npm/plugins/table-resize/table-view.js +23 -24
- package/dist/npm/plugins/table-resize/utils.d.ts +17 -7
- package/dist/npm/plugins/table-resize/utils.js +24 -28
- package/dist/npm/source.d.ts +13 -16
- package/dist/npm/source.js +35 -36
- package/dist/npm/table.d.ts +9 -10
- package/dist/npm/table.js +33 -49
- package/dist/npm/text.d.ts +3 -6
- package/dist/npm/text.js +3 -3
- package/dist/npm/types/active-marks.d.ts +1 -4
- package/dist/npm/types/active-marks.js +2 -0
- package/dist/npm/types/command.d.ts +2 -5
- package/dist/npm/types/command.js +2 -0
- package/dist/npm/types/dispatchFn.d.ts +1 -4
- package/dist/npm/types/dispatchFn.js +2 -0
- package/dist/npm/types/paste-cleanup-settings.d.ts +1 -3
- package/dist/npm/types/paste-cleanup-settings.js +2 -0
- package/dist/npm/types/predicate.d.ts +1 -0
- package/dist/npm/types/predicate.js +2 -0
- package/dist/npm/utils.d.ts +33 -14
- package/dist/npm/utils.js +38 -39
- package/package.json +4 -51
- package/dist/es2015/DOMSerializer.js +0 -184
- package/dist/es2015/align.js +0 -43
- package/dist/es2015/blockNode.js +0 -180
- package/dist/es2015/blockquote.js +0 -26
- package/dist/es2015/cleanFormatting.js +0 -20
- package/dist/es2015/config/align-rules.js +0 -30
- package/dist/es2015/config/commands.js +0 -50
- package/dist/es2015/config/constants.js +0 -9
- package/dist/es2015/config/indent-rules.js +0 -42
- package/dist/es2015/config/keymap.js +0 -51
- package/dist/es2015/config/list-settings.js +0 -21
- package/dist/es2015/config/schema.js +0 -314
- package/dist/es2015/find-replace.js +0 -122
- package/dist/es2015/flatten-spans.js +0 -112
- package/dist/es2015/image.js +0 -10
- package/dist/es2015/indent.js +0 -105
- package/dist/es2015/inline-style.js +0 -177
- package/dist/es2015/link.js +0 -105
- package/dist/es2015/listConvert.js +0 -184
- package/dist/es2015/lists.js +0 -266
- package/dist/es2015/main.js +0 -44
- package/dist/es2015/mark.js +0 -239
- package/dist/es2015/node_modules/tslib/tslib.es6.js +0 -35
- package/dist/es2015/paste.js +0 -162
- package/dist/es2015/plugins/caret-color.js +0 -34
- package/dist/es2015/plugins/csp-fix.js +0 -51
- package/dist/es2015/plugins/highlight.js +0 -23
- package/dist/es2015/plugins/image-resize.js +0 -225
- package/dist/es2015/plugins/list-markers-styles.js +0 -104
- package/dist/es2015/plugins/placeholder.js +0 -27
- package/dist/es2015/plugins/resize-utils.js +0 -13
- package/dist/es2015/plugins/spaces-fix.js +0 -46
- package/dist/es2015/plugins/table-resize/column-resize.js +0 -267
- package/dist/es2015/plugins/table-resize/index.js +0 -12
- package/dist/es2015/plugins/table-resize/row-resize.js +0 -234
- package/dist/es2015/plugins/table-resize/table-resize.js +0 -278
- package/dist/es2015/plugins/table-resize/table-view.js +0 -128
- package/dist/es2015/plugins/table-resize/utils.js +0 -93
- package/dist/es2015/source.js +0 -251
- package/dist/es2015/table.js +0 -132
- package/dist/es2015/text.js +0 -5
- package/dist/es2015/utils.js +0 -289
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { Plugin } from 'prosemirror-state';
|
|
2
2
|
import { TableMap } from 'prosemirror-tables';
|
|
3
|
-
import {
|
|
4
|
-
import { colgroupAttr } from '../../config/constants
|
|
5
|
-
import { TableView, TableWrapperView } from './table-view
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
function columnResizing() {
|
|
3
|
+
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
4
|
+
import { colgroupAttr } from '../../config/constants';
|
|
5
|
+
import { TableView, TableWrapperView } from './table-view';
|
|
6
|
+
import { parseStyle, setNodeStyle } from './../../utils';
|
|
7
|
+
import { cellIndexes, domCellAround, otherResizeHandle, otherResizing, edgeCell, tableColumnResizeKey as key } from './utils';
|
|
8
|
+
export function columnResizing() {
|
|
10
9
|
const handleWidth = 5, cellMinWidth = 25;
|
|
11
10
|
const plugin = new Plugin({
|
|
12
|
-
key
|
|
11
|
+
key,
|
|
13
12
|
state: {
|
|
14
13
|
init() {
|
|
15
14
|
return new ResizeState(-1, null);
|
|
@@ -20,15 +19,15 @@ function columnResizing() {
|
|
|
20
19
|
},
|
|
21
20
|
props: {
|
|
22
21
|
attributes(state) {
|
|
23
|
-
if (otherResizeHandle(
|
|
22
|
+
if (otherResizeHandle(key, state)) {
|
|
24
23
|
return null;
|
|
25
24
|
}
|
|
26
|
-
const pluginState =
|
|
25
|
+
const pluginState = key.getState(state);
|
|
27
26
|
return pluginState.activeHandle > -1 ? { class: 'resize-cursor' } : null;
|
|
28
27
|
},
|
|
29
28
|
handleDOMEvents: {
|
|
30
29
|
mousemove(view, event) {
|
|
31
|
-
if (!otherResizing(
|
|
30
|
+
if (!otherResizing(key, view.state)) {
|
|
32
31
|
handleMouseMove(view, event, handleWidth);
|
|
33
32
|
}
|
|
34
33
|
return false;
|
|
@@ -42,8 +41,8 @@ function columnResizing() {
|
|
|
42
41
|
}
|
|
43
42
|
},
|
|
44
43
|
decorations(state) {
|
|
45
|
-
if (!otherResizing(
|
|
46
|
-
const pluginState =
|
|
44
|
+
if (!otherResizing(key, state)) {
|
|
45
|
+
const pluginState = key.getState(state);
|
|
47
46
|
if (pluginState.activeHandle > -1) {
|
|
48
47
|
return handleDecorations(state, pluginState.activeHandle);
|
|
49
48
|
}
|
|
@@ -68,7 +67,7 @@ class ResizeState {
|
|
|
68
67
|
}
|
|
69
68
|
apply(tr) {
|
|
70
69
|
let state;
|
|
71
|
-
const action = tr.getMeta(
|
|
70
|
+
const action = tr.getMeta(key);
|
|
72
71
|
if (action && action.setHandle != null) {
|
|
73
72
|
return new ResizeState(action.setHandle, null);
|
|
74
73
|
}
|
|
@@ -86,7 +85,7 @@ class ResizeState {
|
|
|
86
85
|
}
|
|
87
86
|
}
|
|
88
87
|
function handleMouseMove(view, event, handleWidth) {
|
|
89
|
-
const pluginState =
|
|
88
|
+
const pluginState = key.getState(view.state);
|
|
90
89
|
if (!pluginState.dragging) {
|
|
91
90
|
const target = domCellAround(event.target);
|
|
92
91
|
let cell = -1;
|
|
@@ -107,13 +106,13 @@ function handleMouseMove(view, event, handleWidth) {
|
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
function handleMouseLeave(view) {
|
|
110
|
-
const pluginState =
|
|
109
|
+
const pluginState = key.getState(view.state);
|
|
111
110
|
if (pluginState.activeHandle > -1 && !pluginState.dragging) {
|
|
112
111
|
updateHandle(view, -1);
|
|
113
112
|
}
|
|
114
113
|
}
|
|
115
114
|
function handleMouseDown(view, event, cellMinWidth) {
|
|
116
|
-
const pluginState =
|
|
115
|
+
const pluginState = key.getState(view.state);
|
|
117
116
|
if (pluginState.activeHandle === -1 || pluginState.dragging) {
|
|
118
117
|
return false;
|
|
119
118
|
}
|
|
@@ -156,7 +155,7 @@ function handleMouseDown(view, event, cellMinWidth) {
|
|
|
156
155
|
};
|
|
157
156
|
}
|
|
158
157
|
const width = parseFloat(col.style.width);
|
|
159
|
-
const tr = view.state.tr.setMeta(
|
|
158
|
+
const tr = view.state.tr.setMeta(key, { setDragging: { startX: event.clientX, startWidth: width } });
|
|
160
159
|
if (!tableDom.style.width) {
|
|
161
160
|
const widths = Array.from(col.parentNode.children).map((c) => c.style.width);
|
|
162
161
|
if (widths.every(Boolean)) {
|
|
@@ -172,18 +171,18 @@ function handleMouseDown(view, event, cellMinWidth) {
|
|
|
172
171
|
function finish(ev) {
|
|
173
172
|
ev.view.removeEventListener('mouseup', finish);
|
|
174
173
|
ev.view.removeEventListener('mousemove', move);
|
|
175
|
-
const curPluginState =
|
|
174
|
+
const curPluginState = key.getState(view.state);
|
|
176
175
|
if (curPluginState.dragging) {
|
|
177
176
|
const transaction = view.state.tr;
|
|
178
177
|
updateColumnWidth(view, transaction, curPluginState.activeHandle);
|
|
179
|
-
view.dispatch(transaction.setMeta(
|
|
178
|
+
view.dispatch(transaction.setMeta(key, { setDragging: null }));
|
|
180
179
|
}
|
|
181
180
|
}
|
|
182
181
|
function move(ev) {
|
|
183
182
|
if (!ev.which) {
|
|
184
183
|
return finish(ev);
|
|
185
184
|
}
|
|
186
|
-
const curPluginState =
|
|
185
|
+
const curPluginState = key.getState(view.state);
|
|
187
186
|
const dragged = draggedWidth(curPluginState.dragging, ev, cellMinWidth);
|
|
188
187
|
displayColumnWidth(view, curPluginState.activeHandle, dragged);
|
|
189
188
|
}
|
|
@@ -199,7 +198,7 @@ function draggedWidth(dragging, event, cellMinWidth) {
|
|
|
199
198
|
function updateHandle(view, value) {
|
|
200
199
|
const tr = view.state.tr;
|
|
201
200
|
tr.setMeta('addToHistory', false);
|
|
202
|
-
tr.setMeta(
|
|
201
|
+
tr.setMeta(key, { setHandle: value });
|
|
203
202
|
view.dispatch(tr);
|
|
204
203
|
}
|
|
205
204
|
function updateColumnWidth(view, tr, cell) {
|
|
@@ -266,5 +265,3 @@ function handleDecorations(state, cell) {
|
|
|
266
265
|
}));
|
|
267
266
|
return DecorationSet.create(state.doc, decorations);
|
|
268
267
|
}
|
|
269
|
-
|
|
270
|
-
export { columnResizing };
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { columnResizing } from './column-resize
|
|
2
|
-
import { tableResizing as
|
|
3
|
-
import { rowResizing } from './row-resize
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
const tableResizing = () => [
|
|
7
|
-
tableResizing$1(),
|
|
1
|
+
import { columnResizing } from './column-resize';
|
|
2
|
+
import { tableResizing as tableResize } from './table-resize';
|
|
3
|
+
import { rowResizing } from './row-resize';
|
|
4
|
+
export const tableResizing = () => [
|
|
5
|
+
tableResize(),
|
|
8
6
|
columnResizing(),
|
|
9
7
|
rowResizing()
|
|
10
8
|
];
|
|
11
|
-
|
|
12
|
-
export { tableResizing };
|
|
9
|
+
export { tableResizeKey, tableColumnResizeKey, tableRowResizeKey } from './utils';
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { Plugin } from 'prosemirror-state';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { parseStyle, setNodeStyle } from '
|
|
6
|
-
|
|
2
|
+
import { TableMap, tableNodeTypes } from 'prosemirror-tables';
|
|
3
|
+
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
4
|
+
import { cellIndexes, domCellAround, otherResizeHandle, otherResizing, tableRowResizeKey as key, edgeCell } from './utils';
|
|
5
|
+
import { parseStyle, setNodeStyle } from './../../utils';
|
|
7
6
|
class TableRowView {
|
|
8
7
|
ignoreMutation(record) {
|
|
9
8
|
return record.type === 'attributes' && record.attributeName === 'style' && record.target.nodeName === 'TR';
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
|
-
function rowResizing() {
|
|
11
|
+
export function rowResizing() {
|
|
13
12
|
const handleWidth = 5;
|
|
14
13
|
const plugin = new Plugin({
|
|
15
|
-
key
|
|
14
|
+
key,
|
|
16
15
|
state: {
|
|
17
16
|
init(_, state) {
|
|
18
17
|
this.spec.props.nodeViews[tableNodeTypes(state.schema).row.name] = () => new TableRowView();
|
|
@@ -24,15 +23,15 @@ function rowResizing() {
|
|
|
24
23
|
},
|
|
25
24
|
props: {
|
|
26
25
|
attributes(state) {
|
|
27
|
-
if (otherResizeHandle(
|
|
26
|
+
if (otherResizeHandle(key, state)) {
|
|
28
27
|
return null;
|
|
29
28
|
}
|
|
30
|
-
const pluginState =
|
|
29
|
+
const pluginState = key.getState(state);
|
|
31
30
|
return pluginState.activeHandle > -1 ? { class: 'resize-cursor-vertical' } : null;
|
|
32
31
|
},
|
|
33
32
|
handleDOMEvents: {
|
|
34
33
|
mousemove(view, event) {
|
|
35
|
-
if (!otherResizing(
|
|
34
|
+
if (!otherResizing(key, view.state)) {
|
|
36
35
|
handleMouseMove(view, event, handleWidth);
|
|
37
36
|
}
|
|
38
37
|
return false;
|
|
@@ -46,10 +45,10 @@ function rowResizing() {
|
|
|
46
45
|
}
|
|
47
46
|
},
|
|
48
47
|
decorations(state) {
|
|
49
|
-
if (otherResizing(
|
|
48
|
+
if (otherResizing(key, state)) {
|
|
50
49
|
return DecorationSet.empty;
|
|
51
50
|
}
|
|
52
|
-
const pluginState =
|
|
51
|
+
const pluginState = key.getState(state);
|
|
53
52
|
if (pluginState.activeHandle > -1) {
|
|
54
53
|
return handleDecorations(state, pluginState.activeHandle);
|
|
55
54
|
}
|
|
@@ -68,7 +67,8 @@ class ResizeState {
|
|
|
68
67
|
this.dragging = dragging;
|
|
69
68
|
}
|
|
70
69
|
apply(tr) {
|
|
71
|
-
let state
|
|
70
|
+
let state;
|
|
71
|
+
const action = tr.getMeta(key);
|
|
72
72
|
if (action && action.setHandle != null) {
|
|
73
73
|
return new ResizeState(action.setHandle, null);
|
|
74
74
|
}
|
|
@@ -86,9 +86,10 @@ class ResizeState {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
function handleMouseMove(view, event, handleWidth) {
|
|
89
|
-
const pluginState =
|
|
89
|
+
const pluginState = key.getState(view.state);
|
|
90
90
|
if (!pluginState.dragging) {
|
|
91
|
-
|
|
91
|
+
const target = domCellAround(event.target);
|
|
92
|
+
let cell = -1;
|
|
92
93
|
if (target) {
|
|
93
94
|
const indexes = cellIndexes(target);
|
|
94
95
|
const { top, bottom } = target.getBoundingClientRect();
|
|
@@ -106,13 +107,13 @@ function handleMouseMove(view, event, handleWidth) {
|
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
function handleMouseLeave(view) {
|
|
109
|
-
const pluginState =
|
|
110
|
+
const pluginState = key.getState(view.state);
|
|
110
111
|
if (pluginState.activeHandle > -1 && !pluginState.dragging) {
|
|
111
112
|
updateHandle(view, -1);
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
function handleMouseDown(view, event) {
|
|
115
|
-
const pluginState =
|
|
116
|
+
const pluginState = key.getState(view.state);
|
|
116
117
|
if (pluginState.activeHandle === -1 || pluginState.dragging) {
|
|
117
118
|
return false;
|
|
118
119
|
}
|
|
@@ -127,7 +128,7 @@ function handleMouseDown(view, event) {
|
|
|
127
128
|
const tr = view.nodeDOM(pluginState.activeHandle);
|
|
128
129
|
rowHeight = tr.offsetHeight;
|
|
129
130
|
}
|
|
130
|
-
view.dispatch(view.state.tr.setMeta(
|
|
131
|
+
view.dispatch(view.state.tr.setMeta(key, {
|
|
131
132
|
setDragging: {
|
|
132
133
|
startY: event.clientY,
|
|
133
134
|
startHeight: { rowHeight, tableHeight }
|
|
@@ -136,9 +137,9 @@ function handleMouseDown(view, event) {
|
|
|
136
137
|
function finish(ev) {
|
|
137
138
|
ev.view.removeEventListener('mouseup', finish);
|
|
138
139
|
ev.view.removeEventListener('mousemove', move);
|
|
139
|
-
const curPluginState =
|
|
140
|
+
const curPluginState = key.getState(view.state);
|
|
140
141
|
if (curPluginState.dragging) {
|
|
141
|
-
const tr = view.state.tr.setMeta(
|
|
142
|
+
const tr = view.state.tr.setMeta(key, { setDragging: null });
|
|
142
143
|
updateRowHeight(view, tr, curPluginState.activeHandle);
|
|
143
144
|
view.dispatch(tr);
|
|
144
145
|
}
|
|
@@ -147,7 +148,7 @@ function handleMouseDown(view, event) {
|
|
|
147
148
|
if (!ev.which) {
|
|
148
149
|
return finish(ev);
|
|
149
150
|
}
|
|
150
|
-
const curPluginState =
|
|
151
|
+
const curPluginState = key.getState(view.state);
|
|
151
152
|
const dragged = draggedHeight(curPluginState.dragging, ev);
|
|
152
153
|
const offset = ev.clientY - curPluginState.dragging.startY;
|
|
153
154
|
displayRowHeight(view, curPluginState.activeHandle, dragged, offset, tableHeight);
|
|
@@ -164,7 +165,7 @@ function draggedHeight(dragging, event) {
|
|
|
164
165
|
function updateHandle(view, value) {
|
|
165
166
|
const tr = view.state.tr;
|
|
166
167
|
tr.setMeta('addToHistory', false);
|
|
167
|
-
tr.setMeta(
|
|
168
|
+
tr.setMeta(key, { setHandle: value });
|
|
168
169
|
view.dispatch(tr);
|
|
169
170
|
}
|
|
170
171
|
function updateRowHeight(view, tr, cellPos) {
|
|
@@ -230,5 +231,3 @@ function handleDecorations(state, cell) {
|
|
|
230
231
|
});
|
|
231
232
|
return DecorationSet.create(state.doc, decorations);
|
|
232
233
|
}
|
|
233
|
-
|
|
234
|
-
export { rowResizing };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { directions } from '
|
|
6
|
-
|
|
1
|
+
import { NodeSelection, Plugin } from 'prosemirror-state';
|
|
2
|
+
import { colgroupAttr, dataResizeDirTable, resizableAttr } from '../../config/constants';
|
|
3
|
+
import { getTable, tableResizeKey as key } from './utils';
|
|
4
|
+
import { parseStyle, setNodeStyle, parentNode } from './../../utils';
|
|
5
|
+
import { directions } from './../resize-utils';
|
|
7
6
|
const commonDir = {
|
|
8
7
|
'southeast': true,
|
|
9
8
|
'southwest': true,
|
|
@@ -27,7 +26,7 @@ class ResizeState {
|
|
|
27
26
|
this.nodePosition = nodePosition;
|
|
28
27
|
}
|
|
29
28
|
apply(tr) {
|
|
30
|
-
const next = tr.getMeta(
|
|
29
|
+
const next = tr.getMeta(key);
|
|
31
30
|
if (next) {
|
|
32
31
|
const nextState = new ResizeState(next.activeHandle, next.setDragging, next.nodePosition);
|
|
33
32
|
return nextState;
|
|
@@ -37,7 +36,7 @@ class ResizeState {
|
|
|
37
36
|
}
|
|
38
37
|
const handleMouseMove = (view, event) => {
|
|
39
38
|
var _a;
|
|
40
|
-
const state =
|
|
39
|
+
const state = key.getState(view.state);
|
|
41
40
|
const { dragging, nodePosition, activeHandle } = state;
|
|
42
41
|
if (nodePosition < 0 || !dragging) {
|
|
43
42
|
return;
|
|
@@ -141,7 +140,7 @@ const tableSize = (table) => {
|
|
|
141
140
|
return { width, height, colsWidth, rowsHeight, offsetWidth, offsetHeight };
|
|
142
141
|
};
|
|
143
142
|
const handleMouseUp = (view) => {
|
|
144
|
-
const { dragging, nodePosition, activeHandle } =
|
|
143
|
+
const { dragging, nodePosition, activeHandle } = key.getState(view.state);
|
|
145
144
|
if (dragging) {
|
|
146
145
|
const node = view.state.doc.nodeAt(nodePosition);
|
|
147
146
|
const dom = getTable(view.nodeDOM(nodePosition));
|
|
@@ -162,7 +161,7 @@ const handleMouseUp = (view) => {
|
|
|
162
161
|
tr.setNodeMarkup(nodePosition, null, attrs);
|
|
163
162
|
tr.setMeta('commandName', 'node-resize');
|
|
164
163
|
tr.setMeta('args', attrs);
|
|
165
|
-
tr.setMeta(
|
|
164
|
+
tr.setMeta(key, {
|
|
166
165
|
setDragging: null,
|
|
167
166
|
activeHandle: null,
|
|
168
167
|
nodePosition
|
|
@@ -186,10 +185,10 @@ const handleMouseDown = (view, event) => {
|
|
|
186
185
|
if (!activeHandle) {
|
|
187
186
|
return false;
|
|
188
187
|
}
|
|
189
|
-
const resizeState =
|
|
188
|
+
const resizeState = key.getState(view.state);
|
|
190
189
|
event.preventDefault();
|
|
191
190
|
const transaction = view.state.tr;
|
|
192
|
-
transaction.setMeta(
|
|
191
|
+
transaction.setMeta(key, {
|
|
193
192
|
setDragging: { startX: event.clientX, startY: event.clientY },
|
|
194
193
|
activeHandle,
|
|
195
194
|
nodePosition: resizeState.nodePosition
|
|
@@ -210,9 +209,9 @@ const handleMouseDown = (view, event) => {
|
|
|
210
209
|
curWindow.addEventListener('mousemove', move);
|
|
211
210
|
return true;
|
|
212
211
|
};
|
|
213
|
-
const tableResizing = (options = { node: 'table' }) => {
|
|
212
|
+
export const tableResizing = (options = { node: 'table' }) => {
|
|
214
213
|
return new Plugin({
|
|
215
|
-
key:
|
|
214
|
+
key: key,
|
|
216
215
|
view: () => ({
|
|
217
216
|
selectedNode(state, nodeType) {
|
|
218
217
|
const selection = state.selection;
|
|
@@ -241,7 +240,7 @@ const tableResizing = (options = { node: 'table' }) => {
|
|
|
241
240
|
const tr = state.tr;
|
|
242
241
|
tr.setMeta('addToHistory', false);
|
|
243
242
|
if (selected && prevSelected && selected.pos !== prevSelected.pos) {
|
|
244
|
-
tr.setMeta(
|
|
243
|
+
tr.setMeta(key, { nodePosition: selected.pos });
|
|
245
244
|
const prevNode = tr.doc.nodeAt(prevSelected.pos);
|
|
246
245
|
if (prevNode && prevNode.type.name === nodeType.name) {
|
|
247
246
|
tr.setNodeMarkup(prevSelected.pos, nodeType, { ...prevSelected.node.attrs, [resizableAttr]: false });
|
|
@@ -251,15 +250,15 @@ const tableResizing = (options = { node: 'table' }) => {
|
|
|
251
250
|
}
|
|
252
251
|
else if (selected && prevSelected && selected.pos === prevSelected.pos &&
|
|
253
252
|
!selected.node.attrs[resizableAttr] && !state.selection.eq(prevState.selection)) {
|
|
254
|
-
tr.setMeta(
|
|
253
|
+
tr.setMeta(key, { nodePosition: selected.pos });
|
|
255
254
|
view.dispatch(tr.setNodeMarkup(selected.pos, nodeType, { ...selected.node.attrs, [resizableAttr]: true }));
|
|
256
255
|
}
|
|
257
256
|
else if (selected && !prevSelected) {
|
|
258
|
-
tr.setMeta(
|
|
257
|
+
tr.setMeta(key, { nodePosition: selected.pos });
|
|
259
258
|
view.dispatch(tr.setNodeMarkup(selected.pos, nodeType, { ...selected.node.attrs, [resizableAttr]: true }));
|
|
260
259
|
}
|
|
261
260
|
else if (!selected && prevSelected) {
|
|
262
|
-
tr.setMeta(
|
|
261
|
+
tr.setMeta(key, { nodePosition: -1 });
|
|
263
262
|
view.dispatch(tr.setNodeMarkup(prevSelected.pos, nodeType, { ...prevSelected.node.attrs, [resizableAttr]: false }));
|
|
264
263
|
}
|
|
265
264
|
}
|
|
@@ -282,5 +281,3 @@ const tableResizing = (options = { node: 'table' }) => {
|
|
|
282
281
|
}
|
|
283
282
|
});
|
|
284
283
|
};
|
|
285
|
-
|
|
286
|
-
export { tableResizing };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { parseStrColgroup } from '../../config/schema
|
|
3
|
-
import { handles } from '
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
class TableView {
|
|
1
|
+
import { colgroupAttr, dataResizeDirTable, resizableAttr, resizableWrap, resizeHandle } from '../../config/constants';
|
|
2
|
+
import { parseStrColgroup } from '../../config/schema';
|
|
3
|
+
import { handles } from './../resize-utils';
|
|
4
|
+
import { parseStyle, setAttribute } from './../../utils';
|
|
5
|
+
export class TableView {
|
|
7
6
|
constructor(node, view) {
|
|
8
7
|
this.node = node;
|
|
9
8
|
this.view = view;
|
|
@@ -84,7 +83,7 @@ class TableView {
|
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
|
-
class TableWrapperView {
|
|
86
|
+
export class TableWrapperView {
|
|
88
87
|
constructor(node, view) {
|
|
89
88
|
this.node = node;
|
|
90
89
|
this.view = view;
|
|
@@ -124,5 +123,3 @@ class TableWrapperView {
|
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
|
-
|
|
128
|
-
export { TableView, TableWrapperView };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { PluginKey } from 'prosemirror-state';
|
|
2
2
|
import { TableMap } from 'prosemirror-tables';
|
|
3
|
-
import { parentNode } from '../../utils
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
function otherResizing(current, state) {
|
|
3
|
+
import { parentNode } from '../../utils';
|
|
4
|
+
export const tableResizeKey = new PluginKey('table-resize');
|
|
5
|
+
export const tableColumnResizeKey = new PluginKey('table-column-resizing');
|
|
6
|
+
export const tableRowResizeKey = new PluginKey('table-row-resizing');
|
|
7
|
+
export function otherResizing(current, state) {
|
|
9
8
|
let activeResize = false;
|
|
10
9
|
activeResize = activeResize ||
|
|
11
10
|
(current !== tableResizeKey && Boolean(tableResizeKey.get(state)) && tableResizeKey.getState(state).dragging);
|
|
@@ -15,7 +14,7 @@ function otherResizing(current, state) {
|
|
|
15
14
|
(current !== tableRowResizeKey && Boolean(tableRowResizeKey.get(state)) && tableRowResizeKey.getState(state).dragging);
|
|
16
15
|
return activeResize;
|
|
17
16
|
}
|
|
18
|
-
function otherResizeHandle(current, state) {
|
|
17
|
+
export function otherResizeHandle(current, state) {
|
|
19
18
|
let activeResize = false;
|
|
20
19
|
activeResize = activeResize ||
|
|
21
20
|
(current !== tableColumnResizeKey &&
|
|
@@ -25,13 +24,13 @@ function otherResizeHandle(current, state) {
|
|
|
25
24
|
(current !== tableRowResizeKey && Boolean(tableRowResizeKey.get(state)) && tableRowResizeKey.getState(state).activeHandle > -1);
|
|
26
25
|
return activeResize;
|
|
27
26
|
}
|
|
28
|
-
function getTable(dom) {
|
|
27
|
+
export function getTable(dom) {
|
|
29
28
|
if (dom && dom.firstChild && dom.firstChild.nodeName === 'TABLE') {
|
|
30
29
|
return dom.firstChild;
|
|
31
30
|
}
|
|
32
31
|
return dom;
|
|
33
32
|
}
|
|
34
|
-
function domCellAround(target) {
|
|
33
|
+
export function domCellAround(target) {
|
|
35
34
|
while (target && target.nodeName !== 'TD' && target.nodeName !== 'TH') {
|
|
36
35
|
target = target.classList.contains('ProseMirror') ? null : target.parentNode;
|
|
37
36
|
}
|
|
@@ -57,7 +56,7 @@ function tableSpansMap(table) {
|
|
|
57
56
|
});
|
|
58
57
|
return map;
|
|
59
58
|
}
|
|
60
|
-
function cellIndexes(dataCell) {
|
|
59
|
+
export function cellIndexes(dataCell) {
|
|
61
60
|
const map = tableSpansMap(dataCell.closest('table'));
|
|
62
61
|
let result = null;
|
|
63
62
|
for (let r = 0; r < map.length; r++) {
|
|
@@ -73,7 +72,7 @@ function cellIndexes(dataCell) {
|
|
|
73
72
|
}
|
|
74
73
|
return result || { rowIndex: -1, cellIndex: -1 };
|
|
75
74
|
}
|
|
76
|
-
function edgeCell(view, event, indexes) {
|
|
75
|
+
export function edgeCell(view, event, indexes) {
|
|
77
76
|
const found = view.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
78
77
|
if (!found) {
|
|
79
78
|
return -1;
|
|
@@ -89,5 +88,3 @@ function edgeCell(view, event, indexes) {
|
|
|
89
88
|
const cell = tablePos + map.map[(map.width * indexes.rowIndex) + indexes.cellIndex];
|
|
90
89
|
return cell;
|
|
91
90
|
}
|
|
92
|
-
|
|
93
|
-
export { cellIndexes, domCellAround, edgeCell, getTable, otherResizeHandle, otherResizing, tableColumnResizeKey, tableResizeKey, tableRowResizeKey };
|
package/dist/es/source.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { DOMParser, Fragment } from 'prosemirror-model';
|
|
1
|
+
import { DOMParser as ProseMirrorDOMParser, Fragment } from 'prosemirror-model';
|
|
2
2
|
import { AllSelection } from 'prosemirror-state';
|
|
3
|
-
import { rowTypeAttr, colgroupAttr } from './config/constants
|
|
4
|
-
import { DOMSerializer } from './DOMSerializer
|
|
5
|
-
import { setStyleAttr } from './utils
|
|
6
|
-
|
|
3
|
+
import { rowTypeAttr, colgroupAttr } from './config/constants';
|
|
4
|
+
import { DOMSerializer } from './DOMSerializer';
|
|
5
|
+
import { setStyleAttr } from './utils';
|
|
7
6
|
const blockWrappers = [
|
|
8
7
|
'div', 'ol', 'ul', 'li', 'table', 'tbody', 'thead', 'tfoot', 'caption', 'td', 'th', 'p',
|
|
9
8
|
'tr', 'col', 'colgroup', 'article', 'main', 'nav', 'header', 'footer', 'aside', 'section'
|
|
@@ -125,7 +124,7 @@ const validateTablesToPmSchema = (fragment) => {
|
|
|
125
124
|
*
|
|
126
125
|
* @returns The trimmed HTML content
|
|
127
126
|
*/
|
|
128
|
-
const trimWhitespace = (html, trimAroundTags = blockWrappers) => {
|
|
127
|
+
export const trimWhitespace = (html, trimAroundTags = blockWrappers) => {
|
|
129
128
|
const tags = trimAroundTags.join('|');
|
|
130
129
|
return html.replace(new RegExp('\\s*(<(?:' + tags + ')(?:\\s[^>]*?)?>)', 'g'), '$1')
|
|
131
130
|
.replace(new RegExp('(<\\/(?:' + tags + ')(?:\\s[^>]*?)?>)\\s*', 'g'), '$1');
|
|
@@ -153,7 +152,7 @@ const restoreStyleAttr = (container) => {
|
|
|
153
152
|
* @param html
|
|
154
153
|
* @returns DocumentFragment
|
|
155
154
|
*/
|
|
156
|
-
const htmlToFragment = (html) => {
|
|
155
|
+
export const htmlToFragment = (html) => {
|
|
157
156
|
const template = document.createElement('template');
|
|
158
157
|
template.innerHTML = replaceStyleAttr(html);
|
|
159
158
|
restoreStyleAttr(template.content);
|
|
@@ -162,7 +161,7 @@ const htmlToFragment = (html) => {
|
|
|
162
161
|
/**
|
|
163
162
|
* @hidden
|
|
164
163
|
*/
|
|
165
|
-
const fragmentToHtml = (fragment) => {
|
|
164
|
+
export const fragmentToHtml = (fragment) => {
|
|
166
165
|
return Array.from(fragment.childNodes).reduce((acc, cur) => acc + (cur.outerHTML || cur.textContent || ''), '');
|
|
167
166
|
};
|
|
168
167
|
/**
|
|
@@ -171,7 +170,7 @@ const fragmentToHtml = (fragment) => {
|
|
|
171
170
|
* @param doc ProseMirrorNode
|
|
172
171
|
* @returns DocumentFragment
|
|
173
172
|
*/
|
|
174
|
-
const pmDocToFragment = (doc) => {
|
|
173
|
+
export const pmDocToFragment = (doc) => {
|
|
175
174
|
const fragment = DOMSerializer.fromSchema(doc.type.schema).serializeFragment(doc.content);
|
|
176
175
|
restoreTables(fragment);
|
|
177
176
|
return fragment;
|
|
@@ -184,8 +183,8 @@ const pmDocToFragment = (doc) => {
|
|
|
184
183
|
* @param parseOptions
|
|
185
184
|
* @returns ProseMirrorNode
|
|
186
185
|
*/
|
|
187
|
-
const domToPmDoc = (dom, schema, parseOptions) => {
|
|
188
|
-
return
|
|
186
|
+
export const domToPmDoc = (dom, schema, parseOptions) => {
|
|
187
|
+
return ProseMirrorDOMParser.fromSchema(schema).parse(dom, parseOptions);
|
|
189
188
|
};
|
|
190
189
|
/**
|
|
191
190
|
* Creates a ProseMirrorNode from the given HTML content.
|
|
@@ -195,7 +194,7 @@ const domToPmDoc = (dom, schema, parseOptions) => {
|
|
|
195
194
|
* @param parseOptions - ProseMirror parse options recognized by the `parse` and `parseSlice` methods.
|
|
196
195
|
* @returns - New ProseMirrorNode instance.
|
|
197
196
|
*/
|
|
198
|
-
const parseContent = (content, schema, parseOptions) => {
|
|
197
|
+
export const parseContent = (content, schema, parseOptions) => {
|
|
199
198
|
const dom = htmlToFragment(content);
|
|
200
199
|
validateTablesToPmSchema(dom);
|
|
201
200
|
return domToPmDoc(dom, schema, parseOptions);
|
|
@@ -206,7 +205,7 @@ const parseContent = (content, schema, parseOptions) => {
|
|
|
206
205
|
* @param state - The Editor State
|
|
207
206
|
* @returns - The serialized content
|
|
208
207
|
*/
|
|
209
|
-
const getHtml = (state) => {
|
|
208
|
+
export const getHtml = (state) => {
|
|
210
209
|
const fragment = pmDocToFragment(state.doc);
|
|
211
210
|
return fragmentToHtml(fragment);
|
|
212
211
|
};
|
|
@@ -218,14 +217,14 @@ const getHtml = (state) => {
|
|
|
218
217
|
* @param parseOptions - ProseMirror parse options recognized by the `parse` and `parseSlice` methods.
|
|
219
218
|
* @returns - Command function that takes an editor `state` and `dispatch` function.
|
|
220
219
|
*/
|
|
221
|
-
const setHtml = (content, command = 'setHTML', parseOptions = { preserveWhitespace: 'full' }) => (state, dispatch) => dispatch(state.tr
|
|
220
|
+
export const setHtml = (content, command = 'setHTML', parseOptions = { preserveWhitespace: 'full' }) => (state, dispatch) => dispatch(state.tr
|
|
222
221
|
.setSelection(new AllSelection(state.doc))
|
|
223
222
|
.replaceSelectionWith(parseContent(content, state.schema, parseOptions))
|
|
224
223
|
.setMeta('commandName', command));
|
|
225
224
|
/**
|
|
226
225
|
* @hidden
|
|
227
226
|
*/
|
|
228
|
-
const hasSameMarkup = (dom1, dom2, schema, parseOptions) => {
|
|
227
|
+
export const hasSameMarkup = (dom1, dom2, schema, parseOptions) => {
|
|
229
228
|
const fragment1 = Fragment.from(parseContent(dom1, schema, parseOptions));
|
|
230
229
|
const fragment2 = Fragment.from(parseContent(dom2, schema, parseOptions));
|
|
231
230
|
return fragment1.eq(fragment2);
|
|
@@ -233,7 +232,7 @@ const hasSameMarkup = (dom1, dom2, schema, parseOptions) => {
|
|
|
233
232
|
/**
|
|
234
233
|
* Removes comments in HTML.
|
|
235
234
|
*/
|
|
236
|
-
const removeComments = (html) => {
|
|
235
|
+
export const removeComments = (html) => {
|
|
237
236
|
const fragment = htmlToFragment(html);
|
|
238
237
|
removeCommentsFromDom(fragment);
|
|
239
238
|
return fragmentToHtml(fragment);
|
|
@@ -247,5 +246,3 @@ const removeCommentsFromDom = (dom) => {
|
|
|
247
246
|
commentNode = iterator.nextNode();
|
|
248
247
|
}
|
|
249
248
|
};
|
|
250
|
-
|
|
251
|
-
export { domToPmDoc, fragmentToHtml, getHtml, hasSameMarkup, htmlToFragment, parseContent, pmDocToFragment, removeComments, setHtml, trimWhitespace };
|