@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,47 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { PluginKey, Plugin, NodeSelection } from 'prosemirror-state';
|
|
2
|
+
import { DecorationSet, Decoration } from 'prosemirror-view';
|
|
3
|
+
import { resizeHandle, dataResizeDirImage } from '../config/constants.js';
|
|
4
|
+
import { changeStylesString } from '../utils.js';
|
|
5
|
+
import { handles, directions } from './resize-utils.js';
|
|
6
|
+
|
|
7
|
+
const imageResizeKey = new PluginKey('image-resize');
|
|
8
|
+
const setSize = (domNode, sizeType, value) => {
|
|
9
9
|
domNode.style[sizeType] = value + 'px';
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const reSize = /[^\-]width:|[^\-]height:/;
|
|
12
|
+
const reAnyValue = /^.+$/;
|
|
13
|
+
class ResizeState {
|
|
14
|
+
constructor(activeHandle, dragging, rect, nodePosition) {
|
|
15
15
|
this.activeHandle = activeHandle;
|
|
16
16
|
this.dragging = dragging;
|
|
17
17
|
this.rect = rect;
|
|
18
18
|
this.nodePosition = nodePosition;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
apply(tr) {
|
|
21
|
+
const next = tr.getMeta(imageResizeKey);
|
|
22
22
|
if (next) {
|
|
23
23
|
return new ResizeState(next.activeHandle, next.setDragging, next.rect, next.nodePosition);
|
|
24
24
|
}
|
|
25
25
|
return this;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var rect = state.rect, dragging = state.dragging, nodePosition = state.nodePosition, activeHandle = state.activeHandle;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const handleMouseMove = (view, event, options) => {
|
|
29
|
+
const state = imageResizeKey.getState(view.state);
|
|
30
|
+
const { rect, dragging, nodePosition: nodePosition, activeHandle } = state;
|
|
32
31
|
if (!dragging || !rect) {
|
|
33
32
|
return;
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
const img = view.nodeDOM(nodePosition);
|
|
35
|
+
const dir = directions[activeHandle];
|
|
36
|
+
const diffX = (event.clientX - dragging.startX) * dir.x;
|
|
37
|
+
const diffY = (event.clientY - dragging.startY) * dir.y;
|
|
38
|
+
let width = dir.x ? diffX + img.width : rect.width;
|
|
39
|
+
let height = dir.y ? diffY + img.height : rect.height;
|
|
41
40
|
if (options.lockRatio && dir.x && dir.y) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const ratio = Math.min(width / img.width, height / img.height);
|
|
42
|
+
const lockWidth = img.width * ratio;
|
|
43
|
+
const lockHeight = img.height * ratio;
|
|
45
44
|
dragging.startX = event.clientX - (width - lockWidth) * dir.x;
|
|
46
45
|
dragging.startY = event.clientY - (height - lockHeight) * dir.y;
|
|
47
46
|
width = lockWidth;
|
|
@@ -57,32 +56,32 @@ var handleMouseMove = function (view, event, options) {
|
|
|
57
56
|
rect.left = img.offsetLeft;
|
|
58
57
|
rect.width = img.offsetWidth;
|
|
59
58
|
rect.height = img.offsetHeight;
|
|
60
|
-
|
|
59
|
+
const handlesWrapper = img.nextElementSibling;
|
|
61
60
|
handlesWrapper.style.width = rect.width + 'px';
|
|
62
61
|
handlesWrapper.style.height = rect.height + 'px';
|
|
63
62
|
handlesWrapper.style.top = rect.top + 'px';
|
|
64
63
|
handlesWrapper.style.left = rect.left + 'px';
|
|
65
64
|
};
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
const handleMouseUp = (view) => {
|
|
66
|
+
const { rect, dragging, nodePosition } = imageResizeKey.getState(view.state);
|
|
68
67
|
if (dragging && rect) {
|
|
69
|
-
|
|
68
|
+
const selection = view.state.selection;
|
|
70
69
|
if (selection instanceof NodeSelection) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
const currAttrs = selection.node.attrs;
|
|
71
|
+
const width = rect.width;
|
|
72
|
+
const height = rect.height;
|
|
73
|
+
let attrs;
|
|
75
74
|
if (reSize.test(currAttrs.style || '')) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
attrs =
|
|
75
|
+
const changedWidth = changeStylesString(currAttrs.style, { style: 'width', value: reAnyValue, newValue: width + 'px' });
|
|
76
|
+
const { style } = changeStylesString(changedWidth.style || '', { style: 'height', value: reAnyValue, newValue: height + 'px' });
|
|
77
|
+
attrs = { ...currAttrs, style };
|
|
79
78
|
}
|
|
80
79
|
else {
|
|
81
|
-
attrs =
|
|
80
|
+
attrs = { ...currAttrs, width, height };
|
|
82
81
|
}
|
|
83
|
-
|
|
82
|
+
const newImage = selection.node.type.createAndFill(attrs);
|
|
84
83
|
if (newImage) {
|
|
85
|
-
|
|
84
|
+
const tr = view.state.tr;
|
|
86
85
|
tr.replaceWith(nodePosition, nodePosition + 1, newImage);
|
|
87
86
|
tr.setSelection(NodeSelection.create(tr.doc, nodePosition));
|
|
88
87
|
tr.setMeta('commandName', 'image-resize');
|
|
@@ -90,26 +89,26 @@ var handleMouseUp = function (view) {
|
|
|
90
89
|
tr.setMeta(imageResizeKey, {
|
|
91
90
|
setDragging: null,
|
|
92
91
|
activeHandle: null,
|
|
93
|
-
rect
|
|
94
|
-
nodePosition
|
|
92
|
+
rect,
|
|
93
|
+
nodePosition
|
|
95
94
|
});
|
|
96
95
|
view.dispatch(tr);
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
const handleMouseDown = (view, event, options) => {
|
|
101
|
+
const target = event.target;
|
|
102
|
+
const activeHandle = target.getAttribute(dataResizeDirImage);
|
|
104
103
|
if (!activeHandle) {
|
|
105
104
|
return false;
|
|
106
105
|
}
|
|
107
|
-
|
|
106
|
+
const resizeState = imageResizeKey.getState(view.state);
|
|
108
107
|
event.preventDefault();
|
|
109
|
-
|
|
108
|
+
const transaction = view.state.tr;
|
|
110
109
|
transaction.setMeta(imageResizeKey, {
|
|
111
110
|
setDragging: { startX: event.clientX, startY: event.clientY },
|
|
112
|
-
activeHandle
|
|
111
|
+
activeHandle,
|
|
113
112
|
rect: resizeState.rect,
|
|
114
113
|
nodePosition: resizeState.nodePosition
|
|
115
114
|
});
|
|
@@ -127,12 +126,11 @@ var handleMouseDown = function (view, event, options) {
|
|
|
127
126
|
event.view.addEventListener('mousemove', move);
|
|
128
127
|
return true;
|
|
129
128
|
};
|
|
130
|
-
|
|
131
|
-
if (options === void 0) { options = { node: 'image', lockRatio: true }; }
|
|
129
|
+
const imageResizing = (options = { node: 'image', lockRatio: true }) => {
|
|
132
130
|
return new Plugin({
|
|
133
131
|
key: imageResizeKey,
|
|
134
|
-
view:
|
|
135
|
-
resize
|
|
132
|
+
view: (viewObj) => ({
|
|
133
|
+
resize() {
|
|
136
134
|
if (imageResizeKey.getState(viewObj.state).rect) {
|
|
137
135
|
viewObj.dispatch(viewObj.state.tr.setMeta('resize', true));
|
|
138
136
|
}
|
|
@@ -140,28 +138,28 @@ export var imageResizing = function (options) {
|
|
|
140
138
|
get window() {
|
|
141
139
|
return viewObj.dom.ownerDocument && viewObj.dom.ownerDocument.defaultView;
|
|
142
140
|
},
|
|
143
|
-
attachResize
|
|
144
|
-
|
|
141
|
+
attachResize() {
|
|
142
|
+
const win = this.window;
|
|
145
143
|
if (win) {
|
|
146
144
|
win.removeEventListener('resize', this.resize);
|
|
147
145
|
win.addEventListener('resize', this.resize);
|
|
148
146
|
}
|
|
149
147
|
},
|
|
150
|
-
removeResize
|
|
151
|
-
|
|
148
|
+
removeResize() {
|
|
149
|
+
const win = this.window;
|
|
152
150
|
if (win) {
|
|
153
151
|
win.removeEventListener('resize', this.resize);
|
|
154
152
|
}
|
|
155
153
|
},
|
|
156
|
-
update
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
154
|
+
update(view, prevState) {
|
|
155
|
+
const state = view.state;
|
|
156
|
+
const selection = state.selection;
|
|
157
|
+
const nodeType = state.schema.nodes[options.node];
|
|
158
|
+
const pluginState = imageResizeKey.getState(state);
|
|
159
|
+
const prevRect = pluginState.rect;
|
|
162
160
|
if (selection instanceof NodeSelection && nodeType === selection.node.type) {
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
const img = view.nodeDOM(selection.from);
|
|
162
|
+
const rect = {
|
|
165
163
|
top: img.offsetTop,
|
|
166
164
|
left: img.offsetLeft,
|
|
167
165
|
width: img.offsetWidth,
|
|
@@ -170,8 +168,8 @@ export var imageResizing = function (options) {
|
|
|
170
168
|
if (!prevState.selection.eq(selection) ||
|
|
171
169
|
(prevRect && (prevRect.width !== rect.width || prevRect.height !== rect.height ||
|
|
172
170
|
prevRect.top !== rect.top || prevRect.left !== rect.left))) {
|
|
173
|
-
|
|
174
|
-
tr.setMeta(imageResizeKey, { rect
|
|
171
|
+
const tr = state.tr;
|
|
172
|
+
tr.setMeta(imageResizeKey, { rect, nodePosition: selection.from });
|
|
175
173
|
view.dispatch(tr);
|
|
176
174
|
this.attachResize();
|
|
177
175
|
}
|
|
@@ -181,37 +179,37 @@ export var imageResizing = function (options) {
|
|
|
181
179
|
pluginState.nodePosition = -1;
|
|
182
180
|
}
|
|
183
181
|
},
|
|
184
|
-
destroy
|
|
182
|
+
destroy() {
|
|
185
183
|
this.removeResize();
|
|
186
184
|
}
|
|
187
|
-
})
|
|
185
|
+
}),
|
|
188
186
|
state: {
|
|
189
|
-
init
|
|
187
|
+
init() {
|
|
190
188
|
return new ResizeState('', null, null, -1);
|
|
191
189
|
},
|
|
192
|
-
apply
|
|
190
|
+
apply(tr, prev) {
|
|
193
191
|
return prev.apply(tr);
|
|
194
192
|
}
|
|
195
193
|
},
|
|
196
194
|
props: {
|
|
197
195
|
handleDOMEvents: {
|
|
198
|
-
mousedown
|
|
196
|
+
mousedown(view, event) {
|
|
199
197
|
return handleMouseDown(view, event, options);
|
|
200
198
|
}
|
|
201
199
|
},
|
|
202
|
-
decorations
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
200
|
+
decorations(state) {
|
|
201
|
+
const selection = state.selection;
|
|
202
|
+
const nodeType = state.schema.nodes[options.node];
|
|
203
|
+
const rect = imageResizeKey.getState(state).rect;
|
|
206
204
|
if (rect && selection instanceof NodeSelection && nodeType === selection.node.type) {
|
|
207
|
-
|
|
205
|
+
const wrapper = document.createElement('div');
|
|
208
206
|
wrapper.className = 'k-editor-resize-handles-wrapper';
|
|
209
207
|
wrapper.style.width = rect.width + 'px';
|
|
210
208
|
wrapper.style.height = rect.height + 'px';
|
|
211
209
|
wrapper.style.top = rect.top + 'px';
|
|
212
210
|
wrapper.style.left = rect.left + 'px';
|
|
213
|
-
for (
|
|
214
|
-
|
|
211
|
+
for (let i = 0; i < handles.length; i++) {
|
|
212
|
+
const dom = document.createElement('div');
|
|
215
213
|
dom.className = resizeHandle + ' ' + handles[i];
|
|
216
214
|
dom.setAttribute(dataResizeDirImage, handles[i]);
|
|
217
215
|
wrapper.appendChild(dom);
|
|
@@ -223,3 +221,5 @@ export var imageResizing = function (options) {
|
|
|
223
221
|
}
|
|
224
222
|
});
|
|
225
223
|
};
|
|
224
|
+
|
|
225
|
+
export { imageResizeKey, imageResizing };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
3
2
|
import { RemoveMarkStep } from 'prosemirror-transform';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import { applyStyle, parseStyle, parentNode } from '../utils.js';
|
|
4
|
+
|
|
5
|
+
const inSelection = (from, to, nodePos, node, doc) => {
|
|
6
|
+
const $from = doc.resolve(from);
|
|
7
|
+
const $to = doc.resolve(to);
|
|
8
|
+
const nodeName = node.type.name;
|
|
9
|
+
let wrapper, parentLi;
|
|
10
10
|
if (!$from.nodeBefore) {
|
|
11
11
|
wrapper = $from.node($from.depth);
|
|
12
12
|
parentLi = $from.node($from.depth - 1);
|
|
@@ -23,44 +23,47 @@ var inSelection = function (from, to, nodePos, node, doc) {
|
|
|
23
23
|
}
|
|
24
24
|
return from <= nodePos && nodePos + node.content.size <= to;
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
doc.nodesBetween(from, to,
|
|
26
|
+
const applyToListItems = (tr, state, options) => {
|
|
27
|
+
const { tr: transaction, doc, selection: { from, to } } = state;
|
|
28
|
+
const args = tr.getMeta('args');
|
|
29
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
30
30
|
if ((node.type.name === options.listItem) && inSelection(from, to, pos, node, doc)) {
|
|
31
|
-
transaction.setNodeMarkup(pos, null,
|
|
31
|
+
transaction.setNodeMarkup(pos, null, {
|
|
32
|
+
...node.attrs,
|
|
33
|
+
style: applyStyle(node.attrs.style, args.style, args.value)
|
|
34
|
+
});
|
|
32
35
|
}
|
|
33
36
|
});
|
|
34
37
|
return transaction.docChanged ? transaction : undefined;
|
|
35
38
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
doc.nodesBetween(from, to,
|
|
39
|
+
const cleanListItems = (tr, state, options) => {
|
|
40
|
+
const stylesToClean = Object.keys(options.resetValues);
|
|
41
|
+
const { tr: transaction, doc, selection: { from, to } } = state;
|
|
42
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
40
43
|
if (node.type.name === options.listItem && inSelection(from, to, pos, node, doc)) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
stylesToClean.forEach(
|
|
44
|
-
if (
|
|
45
|
-
|
|
44
|
+
let attrs = node.attrs;
|
|
45
|
+
const nodeStyles = parseStyle(node.attrs.style);
|
|
46
|
+
stylesToClean.forEach(style => {
|
|
47
|
+
if (nodeStyles[style]) {
|
|
48
|
+
attrs = { ...attrs, style: applyStyle(attrs.style, style, '') };
|
|
46
49
|
}
|
|
47
50
|
});
|
|
48
|
-
if (
|
|
49
|
-
transaction.setNodeMarkup(pos, null,
|
|
51
|
+
if (attrs !== node.attrs) {
|
|
52
|
+
transaction.setNodeMarkup(pos, null, attrs);
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
});
|
|
53
|
-
tr.steps.forEach(
|
|
56
|
+
tr.steps.forEach((step) => {
|
|
54
57
|
if (step instanceof RemoveMarkStep) {
|
|
55
|
-
|
|
58
|
+
const mark = step.mark;
|
|
56
59
|
if (mark.type.name === 'style' && mark.attrs.style) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
const [name] = mark.attrs.style.split(/\s*:\s*/);
|
|
61
|
+
const $pos = transaction.doc.resolve(step.from);
|
|
62
|
+
const li = parentNode($pos, n => n.type.name === options.listItem);
|
|
60
63
|
if (li) {
|
|
61
|
-
|
|
62
|
-
if (liStyles[
|
|
63
|
-
|
|
64
|
+
const liStyles = parseStyle(li.node.attrs.style);
|
|
65
|
+
if (liStyles[name] && options.resetValues[name]) {
|
|
66
|
+
const newMark = mark.type.create({ style: `${name}: ${options.resetValues[name]};` });
|
|
64
67
|
transaction.addMark(step.from, step.to, newMark);
|
|
65
68
|
}
|
|
66
69
|
}
|
|
@@ -69,10 +72,10 @@ var cleanListItems = function (tr, state, options) {
|
|
|
69
72
|
});
|
|
70
73
|
return transaction.docChanged ? transaction : undefined;
|
|
71
74
|
};
|
|
72
|
-
|
|
75
|
+
const DEFAULT_OPTIONS = {
|
|
73
76
|
listItem: 'list_item',
|
|
74
77
|
resetValues: {
|
|
75
|
-
'font-size': '',
|
|
78
|
+
'font-size': '', // 'initial' or '16px'
|
|
76
79
|
'font-family': '',
|
|
77
80
|
'color': ''
|
|
78
81
|
}
|
|
@@ -80,14 +83,13 @@ var DEFAULT_OPTIONS = {
|
|
|
80
83
|
/**
|
|
81
84
|
* Returns a plugin which applies font-size, font-family, color styles to list item marker.
|
|
82
85
|
*/
|
|
83
|
-
|
|
84
|
-
if (options === void 0) { options = DEFAULT_OPTIONS; }
|
|
86
|
+
function listMarkersStyles(options = DEFAULT_OPTIONS) {
|
|
85
87
|
return new Plugin({
|
|
86
88
|
key: new PluginKey('list-markers-styles'),
|
|
87
|
-
appendTransaction:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
appendTransaction: (transactions, _oldState, newState) => {
|
|
90
|
+
const tr = transactions.slice().pop();
|
|
91
|
+
const commandName = tr.getMeta('commandName');
|
|
92
|
+
let transaction;
|
|
91
93
|
if (commandName === 'FontSize' || commandName === 'FontName' || commandName === 'ForeColor') {
|
|
92
94
|
transaction = applyToListItems(tr, newState, options);
|
|
93
95
|
}
|
|
@@ -101,3 +103,5 @@ export function listMarkersStyles(options) {
|
|
|
101
103
|
}
|
|
102
104
|
});
|
|
103
105
|
}
|
|
106
|
+
|
|
107
|
+
export { listMarkersStyles };
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { DecorationSet, Decoration } from 'prosemirror-view';
|
|
3
|
+
|
|
4
|
+
function placeholder(message) {
|
|
5
|
+
const decAttrs = { class: 'k-placeholder', 'data-placeholder': message };
|
|
5
6
|
return new Plugin({
|
|
6
7
|
key: new PluginKey('placeholder'),
|
|
7
8
|
props: {
|
|
8
|
-
decorations:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
decorations: (state) => {
|
|
10
|
+
const { doc } = state;
|
|
11
|
+
const firstChild = doc.content.firstChild;
|
|
12
|
+
const empty = doc.childCount === 0 ||
|
|
12
13
|
(doc.childCount === 1 && firstChild.inlineContent && firstChild.childCount === 0);
|
|
13
14
|
if (!empty) {
|
|
14
15
|
return DecorationSet.empty;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
doc.descendants(
|
|
17
|
+
const decorations = [];
|
|
18
|
+
doc.descendants((node, pos) => {
|
|
18
19
|
decorations.push(Decoration.node(pos, pos + node.nodeSize, decAttrs));
|
|
19
20
|
});
|
|
20
21
|
return DecorationSet.create(doc, decorations);
|
|
@@ -22,3 +23,5 @@ export function placeholder(message) {
|
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
}
|
|
26
|
+
|
|
27
|
+
export { placeholder };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
'southeast': { x: 1, y: 1 },
|
|
3
|
-
'east': { x: 1, y: 0 },
|
|
4
|
-
'south': { x: 0, y: 1 },
|
|
5
|
-
'north': { x: 0, y: -1 },
|
|
6
|
-
'west': { x: -1, y: 0 },
|
|
7
|
-
'southwest': { x: -1, y: 1 },
|
|
8
|
-
'northwest': { x: -1, y: -1 },
|
|
1
|
+
const directions = {
|
|
2
|
+
'southeast': { x: 1, y: 1 }, // bottom right
|
|
3
|
+
'east': { x: 1, y: 0 }, // right
|
|
4
|
+
'south': { x: 0, y: 1 }, // bottom
|
|
5
|
+
'north': { x: 0, y: -1 }, // top
|
|
6
|
+
'west': { x: -1, y: 0 }, // left
|
|
7
|
+
'southwest': { x: -1, y: 1 }, // bottom left
|
|
8
|
+
'northwest': { x: -1, y: -1 }, // top left
|
|
9
9
|
'northeast': { x: 1, y: -1 } // top right
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
const handles = Object.keys(directions);
|
|
12
|
+
|
|
13
|
+
export { directions, handles };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
2
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
3
|
+
|
|
3
4
|
// The plugin resolves the following problems:
|
|
4
5
|
//
|
|
5
6
|
// 1. white-space: pre-wrap does not work with text-align: justify in firefox
|
|
@@ -10,17 +11,17 @@ import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
|
10
11
|
// Additional info here:
|
|
11
12
|
// https://github.com/ProseMirror/prosemirror/issues/651
|
|
12
13
|
// https://github.com/ProseMirror/prosemirror/issues/857
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const spaces = /\s+/g;
|
|
15
|
+
const align = /text-align/;
|
|
16
|
+
const aligned = (node) => align.test((node && node.attrs && node.attrs.style) || '');
|
|
17
|
+
const spacesFix = () => new Plugin({
|
|
17
18
|
key: new PluginKey('spaces-fix'),
|
|
18
19
|
props: {
|
|
19
|
-
decorations:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
doc.nodesBetween(0, doc.content.size,
|
|
20
|
+
decorations: (state) => {
|
|
21
|
+
const decorations = [];
|
|
22
|
+
const doc = state.doc;
|
|
23
|
+
let start, match, length, i;
|
|
24
|
+
doc.nodesBetween(0, doc.content.size, (node, position, parent) => {
|
|
24
25
|
if (node.type.isText && aligned(parent)) {
|
|
25
26
|
match = spaces.exec(node.text || '');
|
|
26
27
|
while (match !== null) {
|
|
@@ -40,4 +41,6 @@ export var spacesFix = function () { return new Plugin({
|
|
|
40
41
|
return DecorationSet.create(doc, decorations);
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
|
-
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export { spacesFix };
|