@progress/kendo-editor-common 1.11.7-dev.202410140458 → 1.11.7-dev.202410250931
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/mark.js +7 -5
- package/dist/es/paste.js +5 -8
- package/dist/es/utils.js +12 -12
- package/dist/es2015/mark.js +7 -5
- package/dist/es2015/paste.js +5 -7
- package/dist/es2015/utils.js +12 -11
- package/dist/npm/mark.js +7 -5
- package/dist/npm/paste.js +5 -8
- package/dist/npm/utils.d.ts +1 -1
- package/dist/npm/utils.js +12 -12
- package/dist/systemjs/kendo-editor-common.js +1 -1
- package/package.json +6 -5
package/dist/es/mark.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RemoveMarkStep } from 'prosemirror-transform';
|
|
2
2
|
import { MarkType } from 'prosemirror-model';
|
|
3
|
+
import { parseStyle } from './utils';
|
|
3
4
|
export var markApplies = function (doc, ranges, type) {
|
|
4
5
|
var loop = function (i) {
|
|
5
6
|
var ref = ranges[i];
|
|
@@ -192,11 +193,12 @@ export var hasMark = function (state, options) {
|
|
|
192
193
|
};
|
|
193
194
|
export var styleValue = function (mark, style) {
|
|
194
195
|
var styleText = (mark && mark.attrs.style) || '';
|
|
195
|
-
var styles = styleText
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
var styles = parseStyle(styleText);
|
|
197
|
+
var styleNames = Object.keys(styles);
|
|
198
|
+
for (var i = 0; i < styleNames.length; i++) {
|
|
199
|
+
var name_1 = styleNames[i];
|
|
200
|
+
if (name_1.toLowerCase() === style.name && style.value.test(styles[name_1])) {
|
|
201
|
+
return styles[name_1];
|
|
200
202
|
}
|
|
201
203
|
}
|
|
202
204
|
return null;
|
package/dist/es/paste.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { convertMsLists } from './listConvert';
|
|
2
2
|
import { fragmentToHtml, htmlToFragment } from './source';
|
|
3
|
+
import { parseStyle } from './utils';
|
|
3
4
|
/**
|
|
4
5
|
* Removes the invalid HTML. Use it as a first step for cleaning the HTML.
|
|
5
6
|
*/
|
|
@@ -44,21 +45,17 @@ export var sanitizeClassAttr = function (attr) {
|
|
|
44
45
|
removeAttribute(attr);
|
|
45
46
|
}
|
|
46
47
|
};
|
|
47
|
-
var stylesSplit = /\s*;\s*/;
|
|
48
|
-
var styleValueSplit = /\s*:\s*/;
|
|
49
48
|
/**
|
|
50
49
|
* Removes invalid HTML styles.
|
|
51
50
|
*/
|
|
52
51
|
export var sanitizeStyleAttr = function (attr) {
|
|
53
|
-
var styles = attr.value
|
|
52
|
+
var styles = parseStyle(attr.value);
|
|
54
53
|
var element = attr.ownerElement;
|
|
55
54
|
var supportedStyles = element.style;
|
|
56
|
-
var result = ''
|
|
57
|
-
styles.forEach(function (
|
|
58
|
-
var _a;
|
|
59
|
-
_a = style.split(styleValueSplit), name = _a[0], value = _a[1];
|
|
55
|
+
var result = '';
|
|
56
|
+
Object.keys(styles).forEach(function (name) {
|
|
60
57
|
if (supportedStyles[name] !== undefined) {
|
|
61
|
-
result += "".concat(name, ": ").concat(
|
|
58
|
+
result += "".concat(name, ": ").concat(styles[name], "; ");
|
|
62
59
|
}
|
|
63
60
|
});
|
|
64
61
|
result = result.trim();
|
package/dist/es/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
import { Node, Fragment } from 'prosemirror-model';
|
|
3
3
|
import { TextSelection, AllSelection, NodeSelection } from 'prosemirror-state';
|
|
4
|
+
import { parseInlineStyles } from '@progress/kendo-common';
|
|
4
5
|
import { parseContent } from './source';
|
|
5
6
|
export var changeStylesString = function (styleText, newStyle) {
|
|
6
7
|
var styleToChange = newStyle.style;
|
|
@@ -9,17 +10,21 @@ export var changeStylesString = function (styleText, newStyle) {
|
|
|
9
10
|
if (!styleText) {
|
|
10
11
|
return { changed: false, style: null };
|
|
11
12
|
}
|
|
12
|
-
var styles = styleText
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
var styles = parseStyle(styleText);
|
|
14
|
+
var styleNames = Object.keys(styles);
|
|
15
|
+
var filtered = [];
|
|
16
|
+
for (var i = 0; i < styleNames.length; i++) {
|
|
17
|
+
var name_1 = styleNames[i];
|
|
18
|
+
if (name_1.toLowerCase() !== styleToChange || !regExp.test(styles[name_1])) {
|
|
19
|
+
filtered.push("".concat(name_1, ": ").concat(styles[name_1]));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
17
22
|
if (newValue) {
|
|
18
23
|
filtered.push("".concat(styleToChange, ": ").concat(newValue));
|
|
19
24
|
}
|
|
20
25
|
return {
|
|
21
26
|
style: filtered.join('; ') + (filtered.length ? ';' : ''),
|
|
22
|
-
changed: Boolean(newValue) || filtered.length !==
|
|
27
|
+
changed: Boolean(newValue) || filtered.length !== styleNames.length
|
|
23
28
|
};
|
|
24
29
|
};
|
|
25
30
|
var reAnyValue = /^.+$/;
|
|
@@ -257,12 +262,7 @@ export var expandToWordWrap = function (command, options) {
|
|
|
257
262
|
};
|
|
258
263
|
};
|
|
259
264
|
export var parseStyle = function (styleText) {
|
|
260
|
-
|
|
261
|
-
var _a;
|
|
262
|
-
var nameValue = s.split(/\s*:\s*/);
|
|
263
|
-
return _a = {}, _a[nameValue[0]] = nameValue[1], _a;
|
|
264
|
-
}).reduce(function (acc, val) { return (__assign(__assign({}, acc), val)); }, {});
|
|
265
|
-
return styles;
|
|
265
|
+
return parseInlineStyles(styleText);
|
|
266
266
|
};
|
|
267
267
|
export var applyStyle = function (styleText, styleType, styleValue) {
|
|
268
268
|
var styles = parseStyle(styleText);
|
package/dist/es2015/mark.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RemoveMarkStep } from 'prosemirror-transform';
|
|
2
2
|
import { MarkType } from 'prosemirror-model';
|
|
3
|
+
import { parseStyle } from './utils';
|
|
3
4
|
export const markApplies = (doc, ranges, type) => {
|
|
4
5
|
const loop = i => {
|
|
5
6
|
const ref = ranges[i];
|
|
@@ -184,11 +185,12 @@ export const hasMark = (state, options) => {
|
|
|
184
185
|
};
|
|
185
186
|
export const styleValue = (mark, style) => {
|
|
186
187
|
const styleText = (mark && mark.attrs.style) || '';
|
|
187
|
-
const styles = styleText
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
188
|
+
const styles = parseStyle(styleText);
|
|
189
|
+
const styleNames = Object.keys(styles);
|
|
190
|
+
for (let i = 0; i < styleNames.length; i++) {
|
|
191
|
+
const name = styleNames[i];
|
|
192
|
+
if (name.toLowerCase() === style.name && style.value.test(styles[name])) {
|
|
193
|
+
return styles[name];
|
|
192
194
|
}
|
|
193
195
|
}
|
|
194
196
|
return null;
|
package/dist/es2015/paste.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { convertMsLists } from './listConvert';
|
|
2
2
|
import { fragmentToHtml, htmlToFragment } from './source';
|
|
3
|
+
import { parseStyle } from './utils';
|
|
3
4
|
/**
|
|
4
5
|
* Removes the invalid HTML. Use it as a first step for cleaning the HTML.
|
|
5
6
|
*/
|
|
@@ -44,20 +45,17 @@ export const sanitizeClassAttr = (attr) => {
|
|
|
44
45
|
removeAttribute(attr);
|
|
45
46
|
}
|
|
46
47
|
};
|
|
47
|
-
const stylesSplit = /\s*;\s*/;
|
|
48
|
-
const styleValueSplit = /\s*:\s*/;
|
|
49
48
|
/**
|
|
50
49
|
* Removes invalid HTML styles.
|
|
51
50
|
*/
|
|
52
51
|
export const sanitizeStyleAttr = (attr) => {
|
|
53
|
-
const styles = attr.value
|
|
52
|
+
const styles = parseStyle(attr.value);
|
|
54
53
|
const element = attr.ownerElement;
|
|
55
54
|
const supportedStyles = element.style;
|
|
56
|
-
let result = ''
|
|
57
|
-
styles.forEach(
|
|
58
|
-
[name, value] = style.split(styleValueSplit);
|
|
55
|
+
let result = '';
|
|
56
|
+
Object.keys(styles).forEach(name => {
|
|
59
57
|
if (supportedStyles[name] !== undefined) {
|
|
60
|
-
result += `${name}: ${
|
|
58
|
+
result += `${name}: ${styles[name]}; `;
|
|
61
59
|
}
|
|
62
60
|
});
|
|
63
61
|
result = result.trim();
|
package/dist/es2015/utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Node, Fragment } from 'prosemirror-model';
|
|
2
2
|
import { TextSelection, AllSelection, NodeSelection } from 'prosemirror-state';
|
|
3
|
+
import { parseInlineStyles } from '@progress/kendo-common';
|
|
3
4
|
import { parseContent } from './source';
|
|
4
5
|
export const changeStylesString = (styleText, newStyle) => {
|
|
5
6
|
const styleToChange = newStyle.style;
|
|
@@ -8,17 +9,21 @@ export const changeStylesString = (styleText, newStyle) => {
|
|
|
8
9
|
if (!styleText) {
|
|
9
10
|
return { changed: false, style: null };
|
|
10
11
|
}
|
|
11
|
-
const styles = styleText
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const styles = parseStyle(styleText);
|
|
13
|
+
const styleNames = Object.keys(styles);
|
|
14
|
+
const filtered = [];
|
|
15
|
+
for (let i = 0; i < styleNames.length; i++) {
|
|
16
|
+
const name = styleNames[i];
|
|
17
|
+
if (name.toLowerCase() !== styleToChange || !regExp.test(styles[name])) {
|
|
18
|
+
filtered.push(`${name}: ${styles[name]}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
16
21
|
if (newValue) {
|
|
17
22
|
filtered.push(`${styleToChange}: ${newValue}`);
|
|
18
23
|
}
|
|
19
24
|
return {
|
|
20
25
|
style: filtered.join('; ') + (filtered.length ? ';' : ''),
|
|
21
|
-
changed: Boolean(newValue) || filtered.length !==
|
|
26
|
+
changed: Boolean(newValue) || filtered.length !== styleNames.length
|
|
22
27
|
};
|
|
23
28
|
};
|
|
24
29
|
const reAnyValue = /^.+$/;
|
|
@@ -251,11 +256,7 @@ export const expandToWordWrap = (command, options) => {
|
|
|
251
256
|
};
|
|
252
257
|
};
|
|
253
258
|
export const parseStyle = (styleText) => {
|
|
254
|
-
|
|
255
|
-
const nameValue = s.split(/\s*:\s*/);
|
|
256
|
-
return { [nameValue[0]]: nameValue[1] };
|
|
257
|
-
}).reduce((acc, val) => (Object.assign(Object.assign({}, acc), val)), {});
|
|
258
|
-
return styles;
|
|
259
|
+
return parseInlineStyles(styleText);
|
|
259
260
|
};
|
|
260
261
|
export const applyStyle = (styleText, styleType, styleValue) => {
|
|
261
262
|
const styles = parseStyle(styleText);
|
package/dist/npm/mark.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
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
4
|
var prosemirror_transform_1 = require("prosemirror-transform");
|
|
5
5
|
var prosemirror_model_1 = require("prosemirror-model");
|
|
6
|
+
var utils_1 = require("./utils");
|
|
6
7
|
var markApplies = function (doc, ranges, type) {
|
|
7
8
|
var loop = function (i) {
|
|
8
9
|
var ref = ranges[i];
|
|
@@ -202,11 +203,12 @@ var hasMark = function (state, options) {
|
|
|
202
203
|
exports.hasMark = hasMark;
|
|
203
204
|
var styleValue = function (mark, style) {
|
|
204
205
|
var styleText = (mark && mark.attrs.style) || '';
|
|
205
|
-
var styles =
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
206
|
+
var styles = (0, utils_1.parseStyle)(styleText);
|
|
207
|
+
var styleNames = Object.keys(styles);
|
|
208
|
+
for (var i = 0; i < styleNames.length; i++) {
|
|
209
|
+
var name_1 = styleNames[i];
|
|
210
|
+
if (name_1.toLowerCase() === style.name && style.value.test(styles[name_1])) {
|
|
211
|
+
return styles[name_1];
|
|
210
212
|
}
|
|
211
213
|
}
|
|
212
214
|
return null;
|
package/dist/npm/paste.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.replaceImageSourcesFromRtf = exports.pasteCleanup = exports.sanitizeStyleAttr = exports.sanitizeClassAttr = exports.removeAttribute = exports.removeTag = exports.removeComments = exports.sanitize = void 0;
|
|
4
4
|
var listConvert_1 = require("./listConvert");
|
|
5
5
|
var source_1 = require("./source");
|
|
6
|
+
var utils_1 = require("./utils");
|
|
6
7
|
/**
|
|
7
8
|
* Removes the invalid HTML. Use it as a first step for cleaning the HTML.
|
|
8
9
|
*/
|
|
@@ -52,21 +53,17 @@ var sanitizeClassAttr = function (attr) {
|
|
|
52
53
|
}
|
|
53
54
|
};
|
|
54
55
|
exports.sanitizeClassAttr = sanitizeClassAttr;
|
|
55
|
-
var stylesSplit = /\s*;\s*/;
|
|
56
|
-
var styleValueSplit = /\s*:\s*/;
|
|
57
56
|
/**
|
|
58
57
|
* Removes invalid HTML styles.
|
|
59
58
|
*/
|
|
60
59
|
var sanitizeStyleAttr = function (attr) {
|
|
61
|
-
var styles =
|
|
60
|
+
var styles = (0, utils_1.parseStyle)(attr.value);
|
|
62
61
|
var element = attr.ownerElement;
|
|
63
62
|
var supportedStyles = element.style;
|
|
64
|
-
var result = ''
|
|
65
|
-
styles.forEach(function (
|
|
66
|
-
var _a;
|
|
67
|
-
_a = style.split(styleValueSplit), name = _a[0], value = _a[1];
|
|
63
|
+
var result = '';
|
|
64
|
+
Object.keys(styles).forEach(function (name) {
|
|
68
65
|
if (supportedStyles[name] !== undefined) {
|
|
69
|
-
result += "".concat(name, ": ").concat(
|
|
66
|
+
result += "".concat(name, ": ").concat(styles[name], "; ");
|
|
70
67
|
}
|
|
71
68
|
});
|
|
72
69
|
result = result.trim();
|
package/dist/npm/utils.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export declare const expandSelection: (state: any, dispatch: any, options: any)
|
|
|
62
62
|
*/
|
|
63
63
|
export declare const expandToWordWrap: (command: any, options: any) => (state: any, dispatch: any) => any;
|
|
64
64
|
export declare const parseStyle: (styleText: string | null) => {
|
|
65
|
-
[
|
|
65
|
+
[key: string]: string;
|
|
66
66
|
};
|
|
67
67
|
export declare const applyStyle: (styleText: string | null, styleType: string, styleValue: string) => string;
|
|
68
68
|
export declare const setAttribute: (node: HTMLElement, attrName: string, value?: string) => void;
|
package/dist/npm/utils.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.setAttribute = exports.applyStyle = exports.parseStyle = exports.expandT
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var prosemirror_model_1 = require("prosemirror-model");
|
|
6
6
|
var prosemirror_state_1 = require("prosemirror-state");
|
|
7
|
+
var kendo_common_1 = require("@progress/kendo-common");
|
|
7
8
|
var source_1 = require("./source");
|
|
8
9
|
var changeStylesString = function (styleText, newStyle) {
|
|
9
10
|
var styleToChange = newStyle.style;
|
|
@@ -12,17 +13,21 @@ var changeStylesString = function (styleText, newStyle) {
|
|
|
12
13
|
if (!styleText) {
|
|
13
14
|
return { changed: false, style: null };
|
|
14
15
|
}
|
|
15
|
-
var styles =
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
var styles = (0, exports.parseStyle)(styleText);
|
|
17
|
+
var styleNames = Object.keys(styles);
|
|
18
|
+
var filtered = [];
|
|
19
|
+
for (var i = 0; i < styleNames.length; i++) {
|
|
20
|
+
var name_1 = styleNames[i];
|
|
21
|
+
if (name_1.toLowerCase() !== styleToChange || !regExp.test(styles[name_1])) {
|
|
22
|
+
filtered.push("".concat(name_1, ": ").concat(styles[name_1]));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
20
25
|
if (newValue) {
|
|
21
26
|
filtered.push("".concat(styleToChange, ": ").concat(newValue));
|
|
22
27
|
}
|
|
23
28
|
return {
|
|
24
29
|
style: filtered.join('; ') + (filtered.length ? ';' : ''),
|
|
25
|
-
changed: Boolean(newValue) || filtered.length !==
|
|
30
|
+
changed: Boolean(newValue) || filtered.length !== styleNames.length
|
|
26
31
|
};
|
|
27
32
|
};
|
|
28
33
|
exports.changeStylesString = changeStylesString;
|
|
@@ -274,12 +279,7 @@ var expandToWordWrap = function (command, options) {
|
|
|
274
279
|
};
|
|
275
280
|
exports.expandToWordWrap = expandToWordWrap;
|
|
276
281
|
var parseStyle = function (styleText) {
|
|
277
|
-
|
|
278
|
-
var _a;
|
|
279
|
-
var nameValue = s.split(/\s*:\s*/);
|
|
280
|
-
return _a = {}, _a[nameValue[0]] = nameValue[1], _a;
|
|
281
|
-
}).reduce(function (acc, val) { return (tslib_1.__assign(tslib_1.__assign({}, acc), val)); }, {});
|
|
282
|
-
return styles;
|
|
282
|
+
return (0, kendo_common_1.parseInlineStyles)(styleText);
|
|
283
283
|
};
|
|
284
284
|
exports.parseStyle = parseStyle;
|
|
285
285
|
var applyStyle = function (styleText, styleType, styleValue) {
|