@progress/kendo-editor-common 1.11.9-dev.202411251354 → 1.11.9-develop.1
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 +388 -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 +13 -32
- 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
package/dist/npm/paste.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var listConvert = require('./listConvert.js');
|
|
4
|
+
var source = require('./source.js');
|
|
5
|
+
var utils = require('./utils.js');
|
|
6
|
+
|
|
7
7
|
/**
|
|
8
8
|
* Removes the invalid HTML. Use it as a first step for cleaning the HTML.
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
const sanitize = (html) => {
|
|
11
11
|
html = html.replace(/^[\s\S]+?<!--StartFragment-->\s*([\s\S]*?)\s*<!--EndFragment-->[\s\S]+$/, '$1');
|
|
12
12
|
html = html.replace(/<\/?[ovw]:[^>]*?>/gi, ''); // MS elements, e.g. <o:p>, <w:sdtPr>, <v:
|
|
13
13
|
html = html.replace(/<\\?\??xml[^>]*>/gi, ''); // XML namespaces
|
|
@@ -20,50 +20,45 @@ var sanitize = function (html) {
|
|
|
20
20
|
html = html.replace(/<!\[endif\]>/ig, '');
|
|
21
21
|
return html;
|
|
22
22
|
};
|
|
23
|
-
exports.sanitize = sanitize;
|
|
24
23
|
/**
|
|
25
24
|
* Removes comments in HTML.
|
|
26
25
|
*/
|
|
27
|
-
|
|
26
|
+
const removeComments = (html) => {
|
|
28
27
|
return html.replace(/<!--[\s\S]+?-->/g, '');
|
|
29
28
|
};
|
|
30
|
-
exports.removeComments = removeComments;
|
|
31
29
|
/**
|
|
32
30
|
* Removes the specified tag(s).
|
|
33
31
|
*/
|
|
34
|
-
|
|
32
|
+
const removeTag = (html, tagPattern) => {
|
|
35
33
|
return html.replace(new RegExp('<\\/?(' + tagPattern + ')(?:\\s[^>]*?)?>', 'gi'), '');
|
|
36
34
|
};
|
|
37
|
-
exports.removeTag = removeTag;
|
|
38
35
|
/**
|
|
39
36
|
* Removes the passed attribute.
|
|
40
37
|
*/
|
|
41
|
-
|
|
38
|
+
const removeAttribute = (attr) => {
|
|
42
39
|
if (attr.ownerElement) {
|
|
43
40
|
attr.ownerElement.removeAttribute(attr.name);
|
|
44
41
|
}
|
|
45
42
|
};
|
|
46
|
-
exports.removeAttribute = removeAttribute;
|
|
47
43
|
/**
|
|
48
44
|
* Remove the attribute if its value matches /^Mso/ regex.
|
|
49
45
|
*/
|
|
50
|
-
|
|
46
|
+
const sanitizeClassAttr = (attr) => {
|
|
51
47
|
if (/^Mso/.test(attr.value)) {
|
|
52
|
-
|
|
48
|
+
removeAttribute(attr);
|
|
53
49
|
}
|
|
54
50
|
};
|
|
55
|
-
exports.sanitizeClassAttr = sanitizeClassAttr;
|
|
56
51
|
/**
|
|
57
52
|
* Removes invalid HTML styles.
|
|
58
53
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Object.keys(styles).forEach(
|
|
54
|
+
const sanitizeStyleAttr = (attr) => {
|
|
55
|
+
const styles = utils.parseStyle(attr.value);
|
|
56
|
+
const element = attr.ownerElement;
|
|
57
|
+
const supportedStyles = element.style;
|
|
58
|
+
let result = '';
|
|
59
|
+
Object.keys(styles).forEach(name => {
|
|
65
60
|
if (supportedStyles[name] !== undefined) {
|
|
66
|
-
result +=
|
|
61
|
+
result += `${name}: ${styles[name]}; `;
|
|
67
62
|
}
|
|
68
63
|
});
|
|
69
64
|
result = result.trim();
|
|
@@ -71,12 +66,11 @@ var sanitizeStyleAttr = function (attr) {
|
|
|
71
66
|
attr.value = result;
|
|
72
67
|
}
|
|
73
68
|
else {
|
|
74
|
-
|
|
69
|
+
removeAttribute(attr);
|
|
75
70
|
}
|
|
76
71
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var parentNode = node.parentNode;
|
|
72
|
+
const removeNode = (node) => {
|
|
73
|
+
const parentNode = node.parentNode;
|
|
80
74
|
if (parentNode) {
|
|
81
75
|
while (node.firstChild) {
|
|
82
76
|
parentNode.insertBefore(node.firstChild, node);
|
|
@@ -84,10 +78,10 @@ var removeNode = function (node) {
|
|
|
84
78
|
parentNode.removeChild(node);
|
|
85
79
|
}
|
|
86
80
|
};
|
|
87
|
-
|
|
81
|
+
const sanitizeNode = (node, attributes) => {
|
|
88
82
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
89
|
-
for (
|
|
90
|
-
|
|
83
|
+
for (let i = node.attributes.length - 1; i >= 0; i--) {
|
|
84
|
+
const attr = node.attributes[i];
|
|
91
85
|
if (attributes[attr.name]) {
|
|
92
86
|
attributes[attr.name](attr);
|
|
93
87
|
}
|
|
@@ -104,37 +98,36 @@ var sanitizeNode = function (node, attributes) {
|
|
|
104
98
|
* Cleans the HTML based on passed settings.
|
|
105
99
|
* Before using it, clean the HTML with the `sanitize` function.
|
|
106
100
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
const pasteCleanup = (html, settings) => {
|
|
102
|
+
let result = html;
|
|
109
103
|
if (settings.convertMsLists) {
|
|
110
|
-
result =
|
|
104
|
+
result = listConvert.convertMsLists(result);
|
|
111
105
|
}
|
|
112
106
|
if (settings.stripTags) {
|
|
113
|
-
result =
|
|
107
|
+
result = removeTag(result, settings.stripTags);
|
|
114
108
|
}
|
|
115
109
|
if (settings.attributes) {
|
|
116
|
-
|
|
117
|
-
Array.from(fragment.querySelectorAll('*')).forEach(
|
|
118
|
-
result =
|
|
110
|
+
const fragment = source.htmlToFragment(result);
|
|
111
|
+
Array.from(fragment.querySelectorAll('*')).forEach(node => sanitizeNode(node, settings.attributes));
|
|
112
|
+
result = source.fragmentToHtml(fragment);
|
|
119
113
|
}
|
|
120
114
|
return result;
|
|
121
115
|
};
|
|
122
|
-
exports.pasteCleanup = pasteCleanup;
|
|
123
116
|
function convertHexToBase64(hex) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
for (
|
|
117
|
+
const length = hex.length;
|
|
118
|
+
const data = new Array(length / 2);
|
|
119
|
+
for (let i = 0; i < length; i += 2) {
|
|
127
120
|
data[i] = String.fromCharCode(parseInt(hex.substring(i, i + 2), 16));
|
|
128
121
|
}
|
|
129
122
|
return btoa(data.join(''));
|
|
130
123
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
124
|
+
const reHtmlImg = /<img\s[^>]*?src=(?:'|")file:\/[^'"]+(?:'|")[^>]*>/gi;
|
|
125
|
+
const reRtfImgHeader = /{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/;
|
|
126
|
+
const reRtfImg = new RegExp('(?:(' + reRtfImgHeader.source + '))([\\da-fA-F\\s]+)\\}', 'g');
|
|
127
|
+
const reNonHex = /[^\da-fA-F]/g;
|
|
128
|
+
const reLocalFile = /file:\/[^'"]+\.(jpg|png|gif)/i;
|
|
129
|
+
const reExtension = /\\(png|jpeg)blip\\/;
|
|
130
|
+
const textRtfType = 'text/rtf';
|
|
138
131
|
/**
|
|
139
132
|
* If the input HTML contains images with 'src' pointing to local file system (it happens when pasting images and text from MS Word),
|
|
140
133
|
* the function will extract the image sources form the RTF and replace the image 'src' with extracted base64 format data in `html` string.
|
|
@@ -143,31 +136,38 @@ var textRtfType = 'text/rtf';
|
|
|
143
136
|
* @param clipboardData - The paste event clipboardData object (event.clipboardData).
|
|
144
137
|
* @returns - The html with the replaced images sources.
|
|
145
138
|
*/
|
|
146
|
-
|
|
147
|
-
|
|
139
|
+
const replaceImageSourcesFromRtf = (html, clipboardData) => {
|
|
140
|
+
const htmlImages = html.match(reHtmlImg);
|
|
148
141
|
if (!htmlImages || clipboardData.types.indexOf(textRtfType) === -1) {
|
|
149
142
|
return html;
|
|
150
143
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
144
|
+
const rtf = clipboardData.getData(textRtfType);
|
|
145
|
+
const base64Sources = [];
|
|
146
|
+
const rtfImages = rtf.match(reRtfImg);
|
|
154
147
|
if (!rtf || !rtfImages) {
|
|
155
148
|
return html;
|
|
156
149
|
}
|
|
157
|
-
for (
|
|
158
|
-
|
|
159
|
-
var extension = reExtension.exec(image);
|
|
150
|
+
for (const image of rtfImages) {
|
|
151
|
+
const extension = reExtension.exec(image);
|
|
160
152
|
if (extension) {
|
|
161
|
-
|
|
162
|
-
base64Sources.push(
|
|
153
|
+
const hex = image.replace(reRtfImgHeader, '').replace(reNonHex, '');
|
|
154
|
+
base64Sources.push(`data:image/${extension[1]};base64,${convertHexToBase64(hex)}`);
|
|
163
155
|
}
|
|
164
156
|
}
|
|
165
157
|
if (htmlImages.length !== base64Sources.length) {
|
|
166
158
|
return html;
|
|
167
159
|
}
|
|
168
|
-
return html.replace(reHtmlImg,
|
|
169
|
-
|
|
160
|
+
return html.replace(reHtmlImg, img => {
|
|
161
|
+
const src = base64Sources.shift() || '';
|
|
170
162
|
return img.replace(reLocalFile, src);
|
|
171
163
|
});
|
|
172
164
|
};
|
|
165
|
+
|
|
166
|
+
exports.pasteCleanup = pasteCleanup;
|
|
167
|
+
exports.removeAttribute = removeAttribute;
|
|
168
|
+
exports.removeComments = removeComments;
|
|
169
|
+
exports.removeTag = removeTag;
|
|
173
170
|
exports.replaceImageSourcesFromRtf = replaceImageSourcesFromRtf;
|
|
171
|
+
exports.sanitize = sanitize;
|
|
172
|
+
exports.sanitizeClassAttr = sanitizeClassAttr;
|
|
173
|
+
exports.sanitizeStyleAttr = sanitizeStyleAttr;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { PluginKey, Plugin } from 'prosemirror-state';
|
|
2
|
+
|
|
3
|
+
declare const caretColorKey: PluginKey<any>;
|
|
4
|
+
declare function caretColor(): Plugin;
|
|
5
|
+
|
|
6
|
+
export { caretColor, caretColorKey };
|
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var prosemirrorState = require('prosemirror-state');
|
|
4
|
+
var prosemirrorView = require('prosemirror-view');
|
|
5
|
+
var mark = require('../mark.js');
|
|
6
|
+
|
|
7
|
+
const caretColorKey = new prosemirrorState.PluginKey('caret-color');
|
|
8
8
|
function caretColor() {
|
|
9
|
-
return new
|
|
10
|
-
key:
|
|
9
|
+
return new prosemirrorState.Plugin({
|
|
10
|
+
key: caretColorKey,
|
|
11
11
|
props: {
|
|
12
|
-
decorations:
|
|
13
|
-
|
|
12
|
+
decorations: (state) => {
|
|
13
|
+
const { doc, selection, storedMarks } = state;
|
|
14
14
|
if (!selection.empty || !storedMarks) {
|
|
15
|
-
return
|
|
15
|
+
return prosemirrorView.DecorationSet.empty;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
const color = mark.styleValue((storedMarks || []).find((m) => m.type.name === 'style'), { name: 'color', value: /^.+$/ });
|
|
18
18
|
if (!color) {
|
|
19
|
-
return
|
|
19
|
+
return prosemirrorView.DecorationSet.empty;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
doc.descendants(
|
|
21
|
+
const parentNode = selection.$anchor.parent;
|
|
22
|
+
const decorations = [];
|
|
23
|
+
doc.descendants((node, pos) => {
|
|
24
24
|
if (node.eq(parentNode)) {
|
|
25
|
-
decorations.push(
|
|
25
|
+
decorations.push(prosemirrorView.Decoration.node(pos, pos + node.nodeSize, {
|
|
26
26
|
style: 'caret-color: ' + color
|
|
27
27
|
}));
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
return
|
|
30
|
+
return prosemirrorView.DecorationSet.create(doc, decorations);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
+
|
|
35
36
|
exports.caretColor = caretColor;
|
|
37
|
+
exports.caretColorKey = caretColorKey;
|
|
@@ -1,55 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
for (
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var prosemirrorState = require('prosemirror-state');
|
|
4
|
+
var utils = require('../utils.js');
|
|
5
|
+
|
|
6
|
+
const setAttributes = (dom, attrs) => {
|
|
7
|
+
for (const attrName in attrs) {
|
|
8
8
|
if (attrName) {
|
|
9
|
-
|
|
9
|
+
utils.setAttribute(dom, attrName, attrs[attrName]);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (isLeaf === void 0) { isLeaf = false; }
|
|
13
|
+
class CustomNodeView {
|
|
14
|
+
constructor(node, view, nodeName, isLeaf = false) {
|
|
16
15
|
this.node = node;
|
|
17
16
|
this.view = view;
|
|
18
17
|
this.dom = document.createElement(nodeName);
|
|
19
18
|
setAttributes(this.dom, node.attrs);
|
|
20
19
|
this.contentDOM = !isLeaf ? this.dom : undefined;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
function StyleView(mark, view) {
|
|
21
|
+
}
|
|
22
|
+
class StyleView {
|
|
23
|
+
constructor(mark, view) {
|
|
26
24
|
this.mark = mark;
|
|
27
25
|
this.view = view;
|
|
28
26
|
this.dom = document.createElement('span');
|
|
29
27
|
setAttributes(this.dom, mark.attrs);
|
|
30
28
|
this.contentDOM = this.dom;
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
key: new prosemirror_state_1.PluginKey('csp-fix'),
|
|
30
|
+
}
|
|
31
|
+
const cspFix = () => {
|
|
32
|
+
return new prosemirrorState.Plugin({
|
|
33
|
+
key: new prosemirrorState.PluginKey('csp-fix'),
|
|
37
34
|
props: {
|
|
38
35
|
nodeViews: {
|
|
39
|
-
paragraph:
|
|
40
|
-
div:
|
|
41
|
-
table_wrapper:
|
|
42
|
-
table_caption_external:
|
|
43
|
-
table:
|
|
44
|
-
table_row:
|
|
45
|
-
table_cell:
|
|
46
|
-
table_header:
|
|
47
|
-
image:
|
|
36
|
+
paragraph: (node, view) => new CustomNodeView(node, view, 'p'),
|
|
37
|
+
div: (node, view) => new CustomNodeView(node, view, 'div'),
|
|
38
|
+
table_wrapper: (node, view) => new CustomNodeView(node, view, 'div'),
|
|
39
|
+
table_caption_external: (node, view) => new CustomNodeView(node, view, 'div'),
|
|
40
|
+
table: (node, view) => new CustomNodeView(node, view, 'table'),
|
|
41
|
+
table_row: (node, view) => new CustomNodeView(node, view, 'tr'),
|
|
42
|
+
table_cell: (node, view) => new CustomNodeView(node, view, 'td'),
|
|
43
|
+
table_header: (node, view) => new CustomNodeView(node, view, 'th'),
|
|
44
|
+
image: (node, view) => new CustomNodeView(node, view, 'img', true)
|
|
48
45
|
},
|
|
49
46
|
markViews: {
|
|
50
|
-
style:
|
|
47
|
+
style: (mark, view) => new StyleView(mark, view)
|
|
51
48
|
}
|
|
52
49
|
}
|
|
53
50
|
});
|
|
54
51
|
};
|
|
52
|
+
|
|
55
53
|
exports.cspFix = cspFix;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluginKey, Plugin } from 'prosemirror-state';
|
|
2
2
|
import { DecorationAttrs } from 'prosemirror-view';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
interface InlineDecoration {
|
|
4
5
|
from: number;
|
|
5
6
|
to: number;
|
|
6
7
|
attrs: DecorationAttrs;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
declare const textHighlightKey: PluginKey<any>;
|
|
10
|
+
declare function textHighlight(key?: PluginKey): Plugin;
|
|
11
|
+
|
|
12
|
+
export { type InlineDecoration, textHighlight, textHighlightKey };
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var prosemirrorState = require('prosemirror-state');
|
|
4
|
+
var prosemirrorView = require('prosemirror-view');
|
|
5
|
+
|
|
6
6
|
// https://discuss.prosemirror.net/t/passing-data-between-plugins/1843
|
|
7
|
-
|
|
8
|
-
function textHighlight(key) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
key: key,
|
|
7
|
+
const textHighlightKey = new prosemirrorState.PluginKey('highlight');
|
|
8
|
+
function textHighlight(key = textHighlightKey) {
|
|
9
|
+
return new prosemirrorState.Plugin({
|
|
10
|
+
key,
|
|
12
11
|
state: {
|
|
13
|
-
init
|
|
14
|
-
apply
|
|
12
|
+
init() { return null; },
|
|
13
|
+
apply(tr) { return tr.getMeta(this.spec.key); }
|
|
15
14
|
},
|
|
16
15
|
props: {
|
|
17
|
-
decorations
|
|
18
|
-
|
|
19
|
-
.map(
|
|
20
|
-
return
|
|
16
|
+
decorations(state) {
|
|
17
|
+
const decorations = (this.spec.key.getState(state) || [])
|
|
18
|
+
.map((d) => prosemirrorView.Decoration.inline(d.from, d.to, d.attrs));
|
|
19
|
+
return prosemirrorView.DecorationSet.create(state.doc, decorations);
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
22
|
});
|
|
24
23
|
}
|
|
24
|
+
|
|
25
25
|
exports.textHighlight = textHighlight;
|
|
26
|
+
exports.textHighlightKey = textHighlightKey;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { PluginKey, Plugin, Transaction } from 'prosemirror-state';
|
|
2
|
+
|
|
3
|
+
declare const imageResizeKey: PluginKey<any>;
|
|
3
4
|
interface Rect {
|
|
4
5
|
top: number;
|
|
5
6
|
left: number;
|
|
@@ -20,9 +21,10 @@ declare class ResizeState {
|
|
|
20
21
|
} | null, rect: Rect | null, nodePosition: number);
|
|
21
22
|
apply(tr: Transaction): ResizeState;
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
+
interface ImageResizeOptions {
|
|
24
25
|
node: string;
|
|
25
26
|
lockRatio: boolean;
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
declare const imageResizing: (options?: ImageResizeOptions) => Plugin<ResizeState>;
|
|
29
|
+
|
|
30
|
+
export { type ImageResizeOptions, imageResizeKey, imageResizing };
|