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