@progress/kendo-editor-common 1.12.2-develop.5 → 1.12.2-develop.6
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 +3 -50
- 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
package/dist/npm/mark.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { MarkType, Mark } from 'prosemirror-model';
|
|
2
2
|
import { EditorState, Transaction } from 'prosemirror-state';
|
|
3
|
-
import { InlineFormatOptions } from './config/commands
|
|
4
|
-
import { Command } from './types/command
|
|
5
|
-
import { ActiveMarks } from './types/active-marks
|
|
6
|
-
|
|
7
|
-
declare const
|
|
3
|
+
import { InlineFormatOptions } from './config/commands';
|
|
4
|
+
import { Command } from './types/command';
|
|
5
|
+
import { ActiveMarks } from './types/active-marks';
|
|
6
|
+
export declare const markApplies: (doc: any, ranges: any, type: any) => boolean;
|
|
7
|
+
export declare const toggleMark: (markType: MarkType, attrs: any, tr: Transaction) => (state: any, dispatch: any) => boolean;
|
|
8
|
+
export declare const removeMark: (tr: any, from: any, to: any, mark: any) => any;
|
|
9
|
+
export declare const removeMarks: (marks: any, state: any, dispatch: any, tr: any) => boolean;
|
|
10
|
+
export declare const removeAllMarks: ({ except }?: {
|
|
8
11
|
except?: MarkType | MarkType[];
|
|
9
12
|
}) => Command;
|
|
10
13
|
/**
|
|
@@ -14,26 +17,28 @@ declare const removeAllMarks: ({ except }?: {
|
|
|
14
17
|
* @example
|
|
15
18
|
* See `removeAllMarks` or `cleanFormatting` function.
|
|
16
19
|
*/
|
|
17
|
-
declare const cleanMarks: (tr: Transaction, { except }: {
|
|
20
|
+
export declare const cleanMarks: (tr: Transaction, { except }: {
|
|
18
21
|
except?: MarkType[];
|
|
19
22
|
}) => void;
|
|
20
23
|
/**
|
|
21
24
|
* Checks if a mark exists in the selection.
|
|
22
25
|
* Used for checking the state of bold, italic, ... and unlink tools.
|
|
23
26
|
*/
|
|
24
|
-
declare const hasMark: (state: EditorState, options: InlineFormatOptions) => boolean;
|
|
27
|
+
export declare const hasMark: (state: EditorState, options: InlineFormatOptions) => boolean;
|
|
28
|
+
export declare const styleValue: (mark: Mark | undefined, style: {
|
|
29
|
+
name: string;
|
|
30
|
+
value: RegExp;
|
|
31
|
+
}) => string | null;
|
|
25
32
|
/**
|
|
26
33
|
* Returns the marks of a specific type for every inline node in the selection.
|
|
27
34
|
*/
|
|
28
|
-
declare const selectionMarks: (state: EditorState, markType: MarkType) => Array<Mark | undefined>;
|
|
35
|
+
export declare const selectionMarks: (state: EditorState, markType: MarkType) => Array<Mark | undefined>;
|
|
29
36
|
/**
|
|
30
37
|
* Returns the specified mark which wraps the selection.
|
|
31
38
|
* Used by link tools.
|
|
32
39
|
*/
|
|
33
|
-
declare const getMark: (state: EditorState, markType: MarkType) => Mark | undefined;
|
|
40
|
+
export declare const getMark: (state: EditorState, markType: MarkType) => Mark | undefined;
|
|
34
41
|
/**
|
|
35
42
|
* **Deprecated.** Use `selectionMarks` function instead.
|
|
36
43
|
*/
|
|
37
|
-
declare const getActiveMarks: (state: EditorState, markType: MarkType) => ActiveMarks;
|
|
38
|
-
|
|
39
|
-
export { cleanMarks, getActiveMarks, getMark, hasMark, removeAllMarks, selectionMarks };
|
|
44
|
+
export declare const getActiveMarks: (state: EditorState, markType: MarkType) => ActiveMarks;
|
package/dist/npm/mark.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getActiveMarks = exports.getMark = exports.selectionMarks = exports.styleValue = exports.hasMark = exports.cleanMarks = exports.removeAllMarks = exports.removeMarks = exports.removeMark = exports.toggleMark = exports.markApplies = void 0;
|
|
4
|
+
const prosemirror_transform_1 = require("prosemirror-transform");
|
|
5
|
+
const prosemirror_model_1 = require("prosemirror-model");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
7
|
const markApplies = (doc, ranges, type) => {
|
|
8
8
|
const loop = i => {
|
|
9
9
|
const ref = ranges[i];
|
|
@@ -28,9 +28,10 @@ const markApplies = (doc, ranges, type) => {
|
|
|
28
28
|
}
|
|
29
29
|
return false;
|
|
30
30
|
};
|
|
31
|
+
exports.markApplies = markApplies;
|
|
31
32
|
const toggleMark = (markType, attrs, tr) => (state, dispatch) => {
|
|
32
33
|
const { empty, $cursor, ranges } = state.selection;
|
|
33
|
-
if ((empty && !$cursor) || !markApplies(state.doc, ranges, markType)) {
|
|
34
|
+
if ((empty && !$cursor) || !(0, exports.markApplies)(state.doc, ranges, markType)) {
|
|
34
35
|
return false;
|
|
35
36
|
}
|
|
36
37
|
if (dispatch) {
|
|
@@ -62,18 +63,20 @@ const toggleMark = (markType, attrs, tr) => (state, dispatch) => {
|
|
|
62
63
|
}
|
|
63
64
|
return true;
|
|
64
65
|
};
|
|
66
|
+
exports.toggleMark = toggleMark;
|
|
65
67
|
const removeMark = (tr, from, to, mark) => {
|
|
66
68
|
if (mark === void 0) {
|
|
67
69
|
mark = null;
|
|
68
70
|
}
|
|
69
|
-
|
|
71
|
+
const matched = [];
|
|
72
|
+
let step = 0;
|
|
70
73
|
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
71
74
|
if (!node.isInline) {
|
|
72
75
|
return;
|
|
73
76
|
}
|
|
74
77
|
step++;
|
|
75
78
|
let toRemove = null;
|
|
76
|
-
if (mark instanceof
|
|
79
|
+
if (mark instanceof prosemirror_model_1.MarkType) {
|
|
77
80
|
const found = mark.isInSet(node.marks);
|
|
78
81
|
if (found) {
|
|
79
82
|
toRemove = [found];
|
|
@@ -90,7 +93,8 @@ const removeMark = (tr, from, to, mark) => {
|
|
|
90
93
|
if (toRemove && toRemove.length) {
|
|
91
94
|
const end = Math.min(pos + node.nodeSize, to);
|
|
92
95
|
for (let i = 0; i < toRemove.length; i++) {
|
|
93
|
-
|
|
96
|
+
const style = toRemove[i];
|
|
97
|
+
let found$1 = (void 0);
|
|
94
98
|
for (let j = 0; j < matched.length; j++) {
|
|
95
99
|
const m = matched[j];
|
|
96
100
|
if (m.step === step - 1 && style.eq(m.style)) {
|
|
@@ -107,9 +111,10 @@ const removeMark = (tr, from, to, mark) => {
|
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
113
|
});
|
|
110
|
-
matched.forEach((m) => { return tr.step(new
|
|
114
|
+
matched.forEach((m) => { return tr.step(new prosemirror_transform_1.RemoveMarkStep(m.from, m.to, m.style)); });
|
|
111
115
|
return tr;
|
|
112
116
|
};
|
|
117
|
+
exports.removeMark = removeMark;
|
|
113
118
|
const removeMarks = (marks, state, dispatch, tr) => {
|
|
114
119
|
const { $cursor, ranges } = state.selection;
|
|
115
120
|
tr = tr || state.tr;
|
|
@@ -124,21 +129,23 @@ const removeMarks = (marks, state, dispatch, tr) => {
|
|
|
124
129
|
for (let i = 0; i < ranges.length; i++) {
|
|
125
130
|
const { $from, $to } = ranges[i];
|
|
126
131
|
marks.forEach(m => {
|
|
127
|
-
removeMark(tr, $from.pos, $to.pos, m);
|
|
132
|
+
(0, exports.removeMark)(tr, $from.pos, $to.pos, m);
|
|
128
133
|
});
|
|
129
134
|
}
|
|
130
135
|
dispatch(tr.scrollIntoView());
|
|
131
136
|
}
|
|
132
137
|
return true;
|
|
133
138
|
};
|
|
139
|
+
exports.removeMarks = removeMarks;
|
|
134
140
|
const toArray = (x) => x instanceof Array ? x : [x];
|
|
135
141
|
const removeAllMarks = ({ except = [] } = {}) => (state, dispatch) => {
|
|
136
142
|
const tr = state.tr;
|
|
137
|
-
cleanMarks(tr, { except: toArray(except) });
|
|
143
|
+
(0, exports.cleanMarks)(tr, { except: toArray(except) });
|
|
138
144
|
if (tr.docChanged) {
|
|
139
145
|
dispatch(tr);
|
|
140
146
|
}
|
|
141
147
|
};
|
|
148
|
+
exports.removeAllMarks = removeAllMarks;
|
|
142
149
|
/**
|
|
143
150
|
* Removes the marks from the selection base on the passed parameter.
|
|
144
151
|
* Requires to dispatch the transaction.
|
|
@@ -160,6 +167,7 @@ const cleanMarks = (tr, { except }) => {
|
|
|
160
167
|
});
|
|
161
168
|
}
|
|
162
169
|
};
|
|
170
|
+
exports.cleanMarks = cleanMarks;
|
|
163
171
|
/**
|
|
164
172
|
* Checks if a mark exists in the selection.
|
|
165
173
|
* Used for checking the state of bold, italic, ... and unlink tools.
|
|
@@ -181,14 +189,15 @@ const hasMark = (state, options) => {
|
|
|
181
189
|
result = (type && doc.rangeHasMark(from, to, type)) || altMarks.some(m => doc.rangeHasMark(from, to, marks[m]));
|
|
182
190
|
}
|
|
183
191
|
if (!result && altStyle && marks.style) {
|
|
184
|
-
return selectionMarks(state, marks.style)
|
|
185
|
-
.some(mark => styleValue(mark, altStyle) !== null);
|
|
192
|
+
return (0, exports.selectionMarks)(state, marks.style)
|
|
193
|
+
.some(mark => (0, exports.styleValue)(mark, altStyle) !== null);
|
|
186
194
|
}
|
|
187
195
|
return Boolean(result);
|
|
188
196
|
};
|
|
197
|
+
exports.hasMark = hasMark;
|
|
189
198
|
const styleValue = (mark, style) => {
|
|
190
199
|
const styleText = (mark && mark.attrs.style) || '';
|
|
191
|
-
const styles =
|
|
200
|
+
const styles = (0, utils_1.parseStyle)(styleText);
|
|
192
201
|
const styleNames = Object.keys(styles);
|
|
193
202
|
for (let i = 0; i < styleNames.length; i++) {
|
|
194
203
|
const name = styleNames[i];
|
|
@@ -198,6 +207,7 @@ const styleValue = (mark, style) => {
|
|
|
198
207
|
}
|
|
199
208
|
return null;
|
|
200
209
|
};
|
|
210
|
+
exports.styleValue = styleValue;
|
|
201
211
|
/**
|
|
202
212
|
* Returns the marks of a specific type for every inline node in the selection.
|
|
203
213
|
*/
|
|
@@ -216,20 +226,22 @@ const selectionMarks = (state, markType) => {
|
|
|
216
226
|
}
|
|
217
227
|
return marks;
|
|
218
228
|
};
|
|
229
|
+
exports.selectionMarks = selectionMarks;
|
|
219
230
|
/**
|
|
220
231
|
* Returns the specified mark which wraps the selection.
|
|
221
232
|
* Used by link tools.
|
|
222
233
|
*/
|
|
223
234
|
const getMark = (state, markType) => {
|
|
224
|
-
const marks = selectionMarks(state, markType);
|
|
235
|
+
const marks = (0, exports.selectionMarks)(state, markType);
|
|
225
236
|
const filtered = marks.filter(m => Boolean(m));
|
|
226
237
|
return marks.length === filtered.length ? marks[0] : undefined;
|
|
227
238
|
};
|
|
239
|
+
exports.getMark = getMark;
|
|
228
240
|
/**
|
|
229
241
|
* **Deprecated.** Use `selectionMarks` function instead.
|
|
230
242
|
*/
|
|
231
243
|
const getActiveMarks = (state, markType) => {
|
|
232
|
-
const marks = selectionMarks(state, markType);
|
|
244
|
+
const marks = (0, exports.selectionMarks)(state, markType);
|
|
233
245
|
const filtered = marks.filter(m => Boolean(m));
|
|
234
246
|
const hasNodesWithoutMarks = marks.length !== filtered.length;
|
|
235
247
|
return {
|
|
@@ -237,15 +249,4 @@ const getActiveMarks = (state, markType) => {
|
|
|
237
249
|
marks: filtered
|
|
238
250
|
};
|
|
239
251
|
};
|
|
240
|
-
|
|
241
|
-
exports.cleanMarks = cleanMarks;
|
|
242
252
|
exports.getActiveMarks = getActiveMarks;
|
|
243
|
-
exports.getMark = getMark;
|
|
244
|
-
exports.hasMark = hasMark;
|
|
245
|
-
exports.markApplies = markApplies;
|
|
246
|
-
exports.removeAllMarks = removeAllMarks;
|
|
247
|
-
exports.removeMark = removeMark;
|
|
248
|
-
exports.removeMarks = removeMarks;
|
|
249
|
-
exports.selectionMarks = selectionMarks;
|
|
250
|
-
exports.styleValue = styleValue;
|
|
251
|
-
exports.toggleMark = toggleMark;
|
package/dist/npm/paste.d.ts
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import { PasteCleanupSettings } from './types/paste-cleanup-settings
|
|
2
|
-
|
|
1
|
+
import { PasteCleanupSettings } from './types/paste-cleanup-settings';
|
|
3
2
|
/**
|
|
4
3
|
* Removes the invalid HTML. Use it as a first step for cleaning the HTML.
|
|
5
4
|
*/
|
|
6
|
-
declare const sanitize: (html: string) => string;
|
|
5
|
+
export declare const sanitize: (html: string) => string;
|
|
7
6
|
/**
|
|
8
7
|
* Removes the specified tag(s).
|
|
9
8
|
*/
|
|
10
|
-
declare const removeTag: (html: string, tagPattern: string) => string;
|
|
9
|
+
export declare const removeTag: (html: string, tagPattern: string) => string;
|
|
11
10
|
/**
|
|
12
11
|
* Removes the passed attribute.
|
|
13
12
|
*/
|
|
14
|
-
declare const removeAttribute: (attr: Attr) => void;
|
|
13
|
+
export declare const removeAttribute: (attr: Attr) => void;
|
|
15
14
|
/**
|
|
16
15
|
* Remove the attribute if its value matches /^Mso/ regex.
|
|
17
16
|
*/
|
|
18
|
-
declare const sanitizeClassAttr: (attr: Attr) => void;
|
|
17
|
+
export declare const sanitizeClassAttr: (attr: Attr) => void;
|
|
19
18
|
/**
|
|
20
19
|
* Removes invalid HTML styles.
|
|
21
20
|
*/
|
|
22
|
-
declare const sanitizeStyleAttr: (attr: Attr) => void;
|
|
21
|
+
export declare const sanitizeStyleAttr: (attr: Attr) => void;
|
|
23
22
|
/**
|
|
24
23
|
* Cleans the HTML based on passed settings.
|
|
25
24
|
* Before using it, clean the HTML with the `sanitize` function.
|
|
26
25
|
*/
|
|
27
|
-
declare const pasteCleanup: (html: string, settings: PasteCleanupSettings) => string;
|
|
26
|
+
export declare const pasteCleanup: (html: string, settings: PasteCleanupSettings) => string;
|
|
28
27
|
/**
|
|
29
28
|
* If the input HTML contains images with 'src' pointing to local file system (it happens when pasting images and text from MS Word),
|
|
30
29
|
* the function will extract the image sources form the RTF and replace the image 'src' with extracted base64 format data in `html` string.
|
|
@@ -33,6 +32,4 @@ declare const pasteCleanup: (html: string, settings: PasteCleanupSettings) => st
|
|
|
33
32
|
* @param clipboardData - The paste event clipboardData object (event.clipboardData).
|
|
34
33
|
* @returns - The html with the replaced images sources.
|
|
35
34
|
*/
|
|
36
|
-
declare const replaceImageSourcesFromRtf: (html: string, clipboardData: DataTransfer) => string;
|
|
37
|
-
|
|
38
|
-
export { pasteCleanup, removeAttribute, removeTag, replaceImageSourcesFromRtf, sanitize, sanitizeClassAttr, sanitizeStyleAttr };
|
|
35
|
+
export declare const replaceImageSourcesFromRtf: (html: string, clipboardData: DataTransfer) => string;
|
package/dist/npm/paste.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replaceImageSourcesFromRtf = exports.pasteCleanup = exports.sanitizeStyleAttr = exports.sanitizeClassAttr = exports.removeAttribute = exports.removeTag = exports.sanitize = void 0;
|
|
4
|
+
const listConvert_1 = require("./listConvert");
|
|
5
|
+
const source_1 = require("./source");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
7
|
/**
|
|
8
8
|
* Removes the invalid HTML. Use it as a first step for cleaning the HTML.
|
|
9
9
|
*/
|
|
@@ -24,12 +24,14 @@ const sanitize = (html) => {
|
|
|
24
24
|
html = html.replace(/<!\[endif\]>/ig, '');
|
|
25
25
|
return html;
|
|
26
26
|
};
|
|
27
|
+
exports.sanitize = sanitize;
|
|
27
28
|
/**
|
|
28
29
|
* Removes the specified tag(s).
|
|
29
30
|
*/
|
|
30
31
|
const removeTag = (html, tagPattern) => {
|
|
31
32
|
return html.replace(new RegExp('<\\/?(' + tagPattern + ')(?:\\s[^>]*?)?>', 'gi'), '');
|
|
32
33
|
};
|
|
34
|
+
exports.removeTag = removeTag;
|
|
33
35
|
/**
|
|
34
36
|
* Removes the passed attribute.
|
|
35
37
|
*/
|
|
@@ -38,19 +40,21 @@ const removeAttribute = (attr) => {
|
|
|
38
40
|
attr.ownerElement.removeAttribute(attr.name);
|
|
39
41
|
}
|
|
40
42
|
};
|
|
43
|
+
exports.removeAttribute = removeAttribute;
|
|
41
44
|
/**
|
|
42
45
|
* Remove the attribute if its value matches /^Mso/ regex.
|
|
43
46
|
*/
|
|
44
47
|
const sanitizeClassAttr = (attr) => {
|
|
45
48
|
if (/^Mso/.test(attr.value)) {
|
|
46
|
-
removeAttribute(attr);
|
|
49
|
+
(0, exports.removeAttribute)(attr);
|
|
47
50
|
}
|
|
48
51
|
};
|
|
52
|
+
exports.sanitizeClassAttr = sanitizeClassAttr;
|
|
49
53
|
/**
|
|
50
54
|
* Removes invalid HTML styles.
|
|
51
55
|
*/
|
|
52
56
|
const sanitizeStyleAttr = (attr) => {
|
|
53
|
-
const styles =
|
|
57
|
+
const styles = (0, utils_1.parseStyle)(attr.value);
|
|
54
58
|
const element = attr.ownerElement;
|
|
55
59
|
const supportedStyles = element.style;
|
|
56
60
|
let result = '';
|
|
@@ -64,9 +68,10 @@ const sanitizeStyleAttr = (attr) => {
|
|
|
64
68
|
attr.value = result;
|
|
65
69
|
}
|
|
66
70
|
else {
|
|
67
|
-
removeAttribute(attr);
|
|
71
|
+
(0, exports.removeAttribute)(attr);
|
|
68
72
|
}
|
|
69
73
|
};
|
|
74
|
+
exports.sanitizeStyleAttr = sanitizeStyleAttr;
|
|
70
75
|
const removeNode = (node) => {
|
|
71
76
|
const parentNode = node.parentNode;
|
|
72
77
|
if (parentNode) {
|
|
@@ -99,18 +104,19 @@ const sanitizeNode = (node, attributes) => {
|
|
|
99
104
|
const pasteCleanup = (html, settings) => {
|
|
100
105
|
let result = html;
|
|
101
106
|
if (settings.convertMsLists) {
|
|
102
|
-
result =
|
|
107
|
+
result = (0, listConvert_1.convertMsLists)(result);
|
|
103
108
|
}
|
|
104
109
|
if (settings.stripTags) {
|
|
105
|
-
result = removeTag(result, settings.stripTags);
|
|
110
|
+
result = (0, exports.removeTag)(result, settings.stripTags);
|
|
106
111
|
}
|
|
107
112
|
if (settings.attributes) {
|
|
108
|
-
const fragment =
|
|
113
|
+
const fragment = (0, source_1.htmlToFragment)(result);
|
|
109
114
|
Array.from(fragment.querySelectorAll('*')).forEach(node => sanitizeNode(node, settings.attributes));
|
|
110
|
-
result =
|
|
115
|
+
result = (0, source_1.fragmentToHtml)(fragment);
|
|
111
116
|
}
|
|
112
117
|
return result;
|
|
113
118
|
};
|
|
119
|
+
exports.pasteCleanup = pasteCleanup;
|
|
114
120
|
function convertHexToBase64(hex) {
|
|
115
121
|
const length = hex.length;
|
|
116
122
|
const data = new Array(length / 2);
|
|
@@ -160,11 +166,4 @@ const replaceImageSourcesFromRtf = (html, clipboardData) => {
|
|
|
160
166
|
return img.replace(reLocalFile, src);
|
|
161
167
|
});
|
|
162
168
|
};
|
|
163
|
-
|
|
164
|
-
exports.pasteCleanup = pasteCleanup;
|
|
165
|
-
exports.removeAttribute = removeAttribute;
|
|
166
|
-
exports.removeTag = removeTag;
|
|
167
169
|
exports.replaceImageSourcesFromRtf = replaceImageSourcesFromRtf;
|
|
168
|
-
exports.sanitize = sanitize;
|
|
169
|
-
exports.sanitizeClassAttr = sanitizeClassAttr;
|
|
170
|
-
exports.sanitizeStyleAttr = sanitizeStyleAttr;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
|
-
|
|
3
|
-
declare
|
|
4
|
-
declare function caretColor(): Plugin;
|
|
5
|
-
|
|
6
|
-
export { caretColor, caretColorKey };
|
|
2
|
+
export declare const caretColorKey: PluginKey<any>;
|
|
3
|
+
export declare function caretColor(): Plugin;
|
|
@@ -1,37 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.caretColorKey = void 0;
|
|
4
|
+
exports.caretColor = caretColor;
|
|
5
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
6
|
+
const prosemirror_view_1 = require("prosemirror-view");
|
|
7
|
+
const mark_1 = require("./../mark");
|
|
8
|
+
exports.caretColorKey = new prosemirror_state_1.PluginKey('caret-color');
|
|
8
9
|
function caretColor() {
|
|
9
|
-
return new
|
|
10
|
-
key: caretColorKey,
|
|
10
|
+
return new prosemirror_state_1.Plugin({
|
|
11
|
+
key: exports.caretColorKey,
|
|
11
12
|
props: {
|
|
12
13
|
decorations: (state) => {
|
|
13
14
|
const { doc, selection, storedMarks } = state;
|
|
14
15
|
if (!selection.empty || !storedMarks) {
|
|
15
|
-
return
|
|
16
|
+
return prosemirror_view_1.DecorationSet.empty;
|
|
16
17
|
}
|
|
17
|
-
const color =
|
|
18
|
+
const color = (0, mark_1.styleValue)((storedMarks || []).find((m) => m.type.name === 'style'), { name: 'color', value: /^.+$/ });
|
|
18
19
|
if (!color) {
|
|
19
|
-
return
|
|
20
|
+
return prosemirror_view_1.DecorationSet.empty;
|
|
20
21
|
}
|
|
21
22
|
const parentNode = selection.$anchor.parent;
|
|
22
23
|
const decorations = [];
|
|
23
24
|
doc.descendants((node, pos) => {
|
|
24
25
|
if (node.eq(parentNode)) {
|
|
25
|
-
decorations.push(
|
|
26
|
+
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
|
|
26
27
|
style: 'caret-color: ' + color
|
|
27
28
|
}));
|
|
28
29
|
}
|
|
29
30
|
});
|
|
30
|
-
return
|
|
31
|
+
return prosemirror_view_1.DecorationSet.create(doc, decorations);
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
exports.caretColor = caretColor;
|
|
37
|
-
exports.caretColorKey = caretColorKey;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cspFix = void 0;
|
|
4
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
6
|
const setAttributes = (dom, attrs) => {
|
|
7
7
|
for (const attrName in attrs) {
|
|
8
8
|
if (attrName) {
|
|
9
|
-
|
|
9
|
+
(0, utils_1.setAttribute)(dom, attrName, attrs[attrName]);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
};
|
|
@@ -29,8 +29,8 @@ class StyleView {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
const cspFix = () => {
|
|
32
|
-
return new
|
|
33
|
-
key: new
|
|
32
|
+
return new prosemirror_state_1.Plugin({
|
|
33
|
+
key: new prosemirror_state_1.PluginKey('csp-fix'),
|
|
34
34
|
props: {
|
|
35
35
|
nodeViews: {
|
|
36
36
|
paragraph: (node, view) => new CustomNodeView(node, view, 'p'),
|
|
@@ -49,5 +49,4 @@ const cspFix = () => {
|
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
|
-
|
|
53
52
|
exports.cspFix = cspFix;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
2
|
import { DecorationAttrs } from 'prosemirror-view';
|
|
3
|
-
|
|
4
|
-
interface InlineDecoration {
|
|
3
|
+
export interface InlineDecoration {
|
|
5
4
|
from: number;
|
|
6
5
|
to: number;
|
|
7
6
|
attrs: DecorationAttrs;
|
|
8
7
|
}
|
|
9
|
-
declare const textHighlightKey: PluginKey<any>;
|
|
10
|
-
declare function textHighlight(key?: PluginKey): Plugin;
|
|
11
|
-
|
|
12
|
-
export { type InlineDecoration, textHighlight, textHighlightKey };
|
|
8
|
+
export declare const textHighlightKey: PluginKey<any>;
|
|
9
|
+
export declare function textHighlight(key?: PluginKey): Plugin;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textHighlightKey = void 0;
|
|
4
|
+
exports.textHighlight = textHighlight;
|
|
5
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
6
|
+
const prosemirror_view_1 = require("prosemirror-view");
|
|
6
7
|
// https://discuss.prosemirror.net/t/passing-data-between-plugins/1843
|
|
7
|
-
|
|
8
|
-
function textHighlight(key = textHighlightKey) {
|
|
9
|
-
return new
|
|
8
|
+
exports.textHighlightKey = new prosemirror_state_1.PluginKey('highlight');
|
|
9
|
+
function textHighlight(key = exports.textHighlightKey) {
|
|
10
|
+
return new prosemirror_state_1.Plugin({
|
|
10
11
|
key,
|
|
11
12
|
state: {
|
|
12
13
|
init() { return null; },
|
|
@@ -15,12 +16,9 @@ function textHighlight(key = textHighlightKey) {
|
|
|
15
16
|
props: {
|
|
16
17
|
decorations(state) {
|
|
17
18
|
const decorations = (this.spec.key.getState(state) || [])
|
|
18
|
-
.map((d) =>
|
|
19
|
-
return
|
|
19
|
+
.map((d) => prosemirror_view_1.Decoration.inline(d.from, d.to, d.attrs));
|
|
20
|
+
return prosemirror_view_1.DecorationSet.create(state.doc, decorations);
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
exports.textHighlight = textHighlight;
|
|
26
|
-
exports.textHighlightKey = textHighlightKey;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Plugin,
|
|
2
|
-
|
|
3
|
-
declare const imageResizeKey: PluginKey<any>;
|
|
1
|
+
import { Plugin, PluginKey, Transaction } from 'prosemirror-state';
|
|
2
|
+
export declare const imageResizeKey: PluginKey<any>;
|
|
4
3
|
interface Rect {
|
|
5
4
|
top: number;
|
|
6
5
|
left: number;
|
|
@@ -21,10 +20,9 @@ declare class ResizeState {
|
|
|
21
20
|
} | null, rect: Rect | null, nodePosition: number);
|
|
22
21
|
apply(tr: Transaction): ResizeState;
|
|
23
22
|
}
|
|
24
|
-
interface ImageResizeOptions {
|
|
23
|
+
export interface ImageResizeOptions {
|
|
25
24
|
node: string;
|
|
26
25
|
lockRatio: boolean;
|
|
27
26
|
}
|
|
28
|
-
declare const imageResizing: (options?: ImageResizeOptions) => Plugin<ResizeState>;
|
|
29
|
-
|
|
30
|
-
export { type ImageResizeOptions, imageResizeKey, imageResizing };
|
|
27
|
+
export declare const imageResizing: (options?: ImageResizeOptions) => Plugin<ResizeState>;
|
|
28
|
+
export {};
|