@progress/kendo-editor-common 1.12.9-develop.3 → 1.12.9-develop.5
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/main.js +1 -1
- package/dist/es/paste.js +51 -5
- package/dist/npm/main.d.ts +1 -1
- package/dist/npm/main.js +5 -2
- package/dist/npm/paste.d.ts +39 -0
- package/dist/npm/paste.js +54 -6
- package/package.json +2 -2
package/dist/es/main.js
CHANGED
|
@@ -17,7 +17,7 @@ export { indentRules, outdentRules } from './config/indent-rules';
|
|
|
17
17
|
export { nodes, marks } from './config/schema';
|
|
18
18
|
export { buildKeymap, buildListKeymap } from './config/keymap';
|
|
19
19
|
export { bold, italic, underline, strikethrough, subscript, superscript, link } from './config/commands';
|
|
20
|
-
export { sanitize, removeTag, pasteCleanup, sanitizeClassAttr, sanitizeStyleAttr, removeAttribute, replaceImageSourcesFromRtf } from './paste';
|
|
20
|
+
export { sanitize, removeTag, pasteCleanup, sanitizeClassAttr, sanitizeStyleAttr, removeAttribute, replaceImageSourcesFromRtf, extractCSSRules, applyCSSRules } from './paste';
|
|
21
21
|
export { convertMsLists } from './listConvert';
|
|
22
22
|
export { find, findAt, findAll, replace, replaceAll } from './find-replace';
|
|
23
23
|
export { placeholder } from './plugins/placeholder';
|
package/dist/es/paste.js
CHANGED
|
@@ -36,6 +36,55 @@ const applyCssRulesInline = (fragment, cssRules) => {
|
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Extracts CSS rules from the given HTML string.
|
|
41
|
+
*
|
|
42
|
+
* @param html The HTML string from which to extract CSS rules.
|
|
43
|
+
* @returns The extracted CSS rules, or undefined if none are found.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { extractCSSRules, applyCSSRules, sanitize, convertMsLists } from '@progress/kendo-editor-common';
|
|
48
|
+
*
|
|
49
|
+
* transformPastedHTML: (html: string) => {
|
|
50
|
+
* const cssRules = extractCSSRules(html);
|
|
51
|
+
* html = convertMsLists(sanitize(html));
|
|
52
|
+
* html = applyCSSRules(html, cssRules);
|
|
53
|
+
* return html;
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export const extractCSSRules = (html) => {
|
|
58
|
+
const css = extractStyles(html);
|
|
59
|
+
return parseStyleSheet(css);
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Applies the given CSS rules to the HTML string.
|
|
63
|
+
*
|
|
64
|
+
* @param html The HTML string to which the CSS rules will be applied.
|
|
65
|
+
* @param cssRules The CSS rules to apply.
|
|
66
|
+
* @returns The HTML string with the CSS rules applied.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import { extractCSSRules, applyCSSRules, sanitize, convertMsLists } from '@progress/kendo-editor-common';
|
|
71
|
+
*
|
|
72
|
+
* transformPastedHTML: (html: string) => {
|
|
73
|
+
* const cssRules = extractCSSRules(html);
|
|
74
|
+
* html = convertMsLists(sanitize(html));
|
|
75
|
+
* html = applyCSSRules(html, cssRules);
|
|
76
|
+
* return html;
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export const applyCSSRules = (html, cssRules) => {
|
|
81
|
+
if (cssRules) {
|
|
82
|
+
const fragment = htmlToFragment(html);
|
|
83
|
+
applyCssRulesInline(fragment, cssRules);
|
|
84
|
+
html = fragmentToHtml(fragment);
|
|
85
|
+
}
|
|
86
|
+
return html;
|
|
87
|
+
};
|
|
39
88
|
/**
|
|
40
89
|
* Removes the invalid HTML. Use it as a first step for cleaning the HTML.
|
|
41
90
|
*/
|
|
@@ -45,11 +94,8 @@ export const sanitize = (html) => {
|
|
|
45
94
|
const trimmed = bodyWithTableFragment[1]
|
|
46
95
|
.replace(/<!--StartFragment-->/gi, '')
|
|
47
96
|
.replace(/<!--EndFragment-->/gi, '');
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const cssRules = parseStyleSheet(css);
|
|
51
|
-
applyCssRulesInline(tableFragment, cssRules);
|
|
52
|
-
html = fragmentToHtml(tableFragment);
|
|
97
|
+
const cssRules = extractCSSRules(html);
|
|
98
|
+
html = applyCSSRules(trimmed, cssRules);
|
|
53
99
|
}
|
|
54
100
|
else {
|
|
55
101
|
html = html.replace(/^[\s\S]+?<!--StartFragment-->\s*([\s\S]*?)\s*<!--EndFragment-->[\s\S]+$/, '$1');
|
package/dist/npm/main.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export { type PasteCleanupSettings } from './types/paste-cleanup-settings';
|
|
|
19
19
|
export { nodes, marks } from './config/schema';
|
|
20
20
|
export { buildKeymap, buildListKeymap } from './config/keymap';
|
|
21
21
|
export { bold, italic, underline, strikethrough, subscript, superscript, link, type InlineFormatOptions } from './config/commands';
|
|
22
|
-
export { sanitize, removeTag, pasteCleanup, sanitizeClassAttr, sanitizeStyleAttr, removeAttribute, replaceImageSourcesFromRtf } from './paste';
|
|
22
|
+
export { sanitize, removeTag, pasteCleanup, sanitizeClassAttr, sanitizeStyleAttr, removeAttribute, replaceImageSourcesFromRtf, extractCSSRules, applyCSSRules } from './paste';
|
|
23
23
|
export { convertMsLists } from './listConvert';
|
|
24
24
|
export { find, findAt, findAll, replace, replaceAll, type SearchOptions } from './find-replace';
|
|
25
25
|
export { placeholder } from './plugins/placeholder';
|
package/dist/npm/main.js
CHANGED
|
@@ -15,8 +15,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.getNodeFromSelection = exports.getSelectionText = exports.liftBlockquote = exports.blockquote = exports.listStyle = exports.toggleList = exports.toggleUnorderedList = exports.toggleOrderedList = exports.indentBlocks = exports.canBeIndented = exports.isIndented = exports.canOutdentAsListItem = exports.outdent = exports.canIndentAsListItem = exports.indent = exports.selectionMarks = exports.cleanMarks = exports.removeAllMarks = exports.getActiveMarks = exports.getMark = exports.hasMark = exports.cleanTextBlockFormatting = exports.blockNodes = exports.changeTextBlock = exports.parentBlockFormat = exports.getBlockFormats = exports.formatBlockElements = exports.activeNode = exports.hasNode = exports.cleanFormatting = exports.isAligned = exports.alignBlocks = exports.insertImage = exports.insertText = exports.removeLink = exports.applyLink = exports.toggleInlineFormat = exports.getInlineStyles = exports.applyInlineStyle = exports.flattenNestedSpans = exports.removeComments = exports.hasSameMarkup = exports.fragmentToHtml = exports.pmDocToFragment = exports.domToPmDoc = exports.htmlToFragment = exports.trimWhitespace = exports.parseContent = exports.setHtml = exports.getHtml = void 0;
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
18
|
+
exports.tableResizing = exports.caretColorKey = exports.caretColor = exports.imageResizeKey = exports.imageResizing = exports.textHighlightKey = exports.textHighlight = exports.cspFix = exports.spacesFix = exports.placeholder = exports.replaceAll = exports.replace = exports.findAll = exports.findAt = exports.find = exports.convertMsLists = exports.applyCSSRules = exports.extractCSSRules = exports.replaceImageSourcesFromRtf = exports.removeAttribute = exports.sanitizeStyleAttr = exports.sanitizeClassAttr = exports.pasteCleanup = exports.removeTag = exports.sanitize = exports.link = exports.superscript = exports.subscript = exports.strikethrough = exports.underline = exports.italic = exports.bold = exports.buildListKeymap = exports.buildKeymap = exports.marks = exports.nodes = exports.outdentRules = exports.indentRules = exports.alignRemoveRules = exports.alignJustifyRules = exports.alignRightRules = exports.alignCenterRules = exports.alignLeftRules = exports.indentHtml = exports.insertNode = exports.parentNode = exports.canInsert = exports.expandToWordWrap = exports.expandSelection = exports.selectedLineTextOnly = void 0;
|
|
19
|
+
exports.pmAddRowAfter = exports.pmAddColumnAfter = exports.pmAddColumnBefore = exports.deleteColumn = exports.addColumnAfter = exports.addColumnBefore = exports.addRowBefore = exports.addRowAfter = exports.createTable = exports.nextCell = exports.moveCellForward = exports.removeColSpan = exports.findCell = exports.cellAround = exports.updateColumnsOnResize = exports.columnResizingPluginKey = exports.columnResizing = exports.columnIsHeader = exports.colCount = exports.addColumn = exports.addColSpan = exports.addRow = exports.rowIsHeader = exports.deleteRow = exports.mergeCells = exports.splitCellWithType = exports.splitCell = exports.toggleHeaderRow = exports.toggleHeaderColumn = exports.toggleHeaderCell = exports.toggleHeader = exports.goToNextCell = exports.setCellAttr = exports.selectionCell = exports.selectedRect = exports.CellSelection = exports.inSameTable = exports.deleteTable = exports.isInTable = exports.fixTablesKey = exports.fixTables = exports.tableNodes = exports.tableNodeTypes = exports.tableEditingKey = exports.tableEditing = exports.TableMap = exports.listMarkersStyles = exports.tableRowResizeKey = exports.tableColumnResizeKey = exports.tableResizeKey = void 0;
|
|
20
|
+
exports.pmDeleteColumn = exports.pmAddRowBefore = void 0;
|
|
20
21
|
var source_1 = require("./source");
|
|
21
22
|
Object.defineProperty(exports, "getHtml", { enumerable: true, get: function () { return source_1.getHtml; } });
|
|
22
23
|
Object.defineProperty(exports, "setHtml", { enumerable: true, get: function () { return source_1.setHtml; } });
|
|
@@ -119,6 +120,8 @@ Object.defineProperty(exports, "sanitizeClassAttr", { enumerable: true, get: fun
|
|
|
119
120
|
Object.defineProperty(exports, "sanitizeStyleAttr", { enumerable: true, get: function () { return paste_1.sanitizeStyleAttr; } });
|
|
120
121
|
Object.defineProperty(exports, "removeAttribute", { enumerable: true, get: function () { return paste_1.removeAttribute; } });
|
|
121
122
|
Object.defineProperty(exports, "replaceImageSourcesFromRtf", { enumerable: true, get: function () { return paste_1.replaceImageSourcesFromRtf; } });
|
|
123
|
+
Object.defineProperty(exports, "extractCSSRules", { enumerable: true, get: function () { return paste_1.extractCSSRules; } });
|
|
124
|
+
Object.defineProperty(exports, "applyCSSRules", { enumerable: true, get: function () { return paste_1.applyCSSRules; } });
|
|
122
125
|
var listConvert_1 = require("./listConvert");
|
|
123
126
|
Object.defineProperty(exports, "convertMsLists", { enumerable: true, get: function () { return listConvert_1.convertMsLists; } });
|
|
124
127
|
var find_replace_1 = require("./find-replace");
|
package/dist/npm/paste.d.ts
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
1
1
|
import { PasteCleanupSettings } from './types/paste-cleanup-settings';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts CSS rules from the given HTML string.
|
|
4
|
+
*
|
|
5
|
+
* @param html The HTML string from which to extract CSS rules.
|
|
6
|
+
* @returns The extracted CSS rules, or undefined if none are found.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { extractCSSRules, applyCSSRules, sanitize, convertMsLists } from '@progress/kendo-editor-common';
|
|
11
|
+
*
|
|
12
|
+
* transformPastedHTML: (html: string) => {
|
|
13
|
+
* const cssRules = extractCSSRules(html);
|
|
14
|
+
* html = convertMsLists(sanitize(html));
|
|
15
|
+
* html = applyCSSRules(html, cssRules);
|
|
16
|
+
* return html;
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const extractCSSRules: (html: string) => CSSRuleList | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Applies the given CSS rules to the HTML string.
|
|
23
|
+
*
|
|
24
|
+
* @param html The HTML string to which the CSS rules will be applied.
|
|
25
|
+
* @param cssRules The CSS rules to apply.
|
|
26
|
+
* @returns The HTML string with the CSS rules applied.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { extractCSSRules, applyCSSRules, sanitize, convertMsLists } from '@progress/kendo-editor-common';
|
|
31
|
+
*
|
|
32
|
+
* transformPastedHTML: (html: string) => {
|
|
33
|
+
* const cssRules = extractCSSRules(html);
|
|
34
|
+
* html = convertMsLists(sanitize(html));
|
|
35
|
+
* html = applyCSSRules(html, cssRules);
|
|
36
|
+
* return html;
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare const applyCSSRules: (html: string, cssRules?: CSSRuleList) => string;
|
|
2
41
|
/**
|
|
3
42
|
* Removes the invalid HTML. Use it as a first step for cleaning the HTML.
|
|
4
43
|
*/
|
package/dist/npm/paste.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.replaceImageSourcesFromRtf = exports.pasteCleanup = exports.sanitizeStyleAttr = exports.sanitizeClassAttr = exports.removeAttribute = exports.removeTag = exports.sanitize = void 0;
|
|
3
|
+
exports.replaceImageSourcesFromRtf = exports.pasteCleanup = exports.sanitizeStyleAttr = exports.sanitizeClassAttr = exports.removeAttribute = exports.removeTag = exports.sanitize = exports.applyCSSRules = exports.extractCSSRules = void 0;
|
|
4
4
|
const listConvert_1 = require("./listConvert");
|
|
5
5
|
const source_1 = require("./source");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
@@ -39,6 +39,57 @@ const applyCssRulesInline = (fragment, cssRules) => {
|
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Extracts CSS rules from the given HTML string.
|
|
44
|
+
*
|
|
45
|
+
* @param html The HTML string from which to extract CSS rules.
|
|
46
|
+
* @returns The extracted CSS rules, or undefined if none are found.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { extractCSSRules, applyCSSRules, sanitize, convertMsLists } from '@progress/kendo-editor-common';
|
|
51
|
+
*
|
|
52
|
+
* transformPastedHTML: (html: string) => {
|
|
53
|
+
* const cssRules = extractCSSRules(html);
|
|
54
|
+
* html = convertMsLists(sanitize(html));
|
|
55
|
+
* html = applyCSSRules(html, cssRules);
|
|
56
|
+
* return html;
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
const extractCSSRules = (html) => {
|
|
61
|
+
const css = extractStyles(html);
|
|
62
|
+
return parseStyleSheet(css);
|
|
63
|
+
};
|
|
64
|
+
exports.extractCSSRules = extractCSSRules;
|
|
65
|
+
/**
|
|
66
|
+
* Applies the given CSS rules to the HTML string.
|
|
67
|
+
*
|
|
68
|
+
* @param html The HTML string to which the CSS rules will be applied.
|
|
69
|
+
* @param cssRules The CSS rules to apply.
|
|
70
|
+
* @returns The HTML string with the CSS rules applied.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { extractCSSRules, applyCSSRules, sanitize, convertMsLists } from '@progress/kendo-editor-common';
|
|
75
|
+
*
|
|
76
|
+
* transformPastedHTML: (html: string) => {
|
|
77
|
+
* const cssRules = extractCSSRules(html);
|
|
78
|
+
* html = convertMsLists(sanitize(html));
|
|
79
|
+
* html = applyCSSRules(html, cssRules);
|
|
80
|
+
* return html;
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
const applyCSSRules = (html, cssRules) => {
|
|
85
|
+
if (cssRules) {
|
|
86
|
+
const fragment = (0, source_1.htmlToFragment)(html);
|
|
87
|
+
applyCssRulesInline(fragment, cssRules);
|
|
88
|
+
html = (0, source_1.fragmentToHtml)(fragment);
|
|
89
|
+
}
|
|
90
|
+
return html;
|
|
91
|
+
};
|
|
92
|
+
exports.applyCSSRules = applyCSSRules;
|
|
42
93
|
/**
|
|
43
94
|
* Removes the invalid HTML. Use it as a first step for cleaning the HTML.
|
|
44
95
|
*/
|
|
@@ -48,11 +99,8 @@ const sanitize = (html) => {
|
|
|
48
99
|
const trimmed = bodyWithTableFragment[1]
|
|
49
100
|
.replace(/<!--StartFragment-->/gi, '')
|
|
50
101
|
.replace(/<!--EndFragment-->/gi, '');
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
const cssRules = parseStyleSheet(css);
|
|
54
|
-
applyCssRulesInline(tableFragment, cssRules);
|
|
55
|
-
html = (0, source_1.fragmentToHtml)(tableFragment);
|
|
102
|
+
const cssRules = (0, exports.extractCSSRules)(html);
|
|
103
|
+
html = (0, exports.applyCSSRules)(trimmed, cssRules);
|
|
56
104
|
}
|
|
57
105
|
else {
|
|
58
106
|
html = html.replace(/^[\s\S]+?<!--StartFragment-->\s*([\s\S]*?)\s*<!--EndFragment-->[\s\S]+$/, '$1');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-editor-common",
|
|
3
3
|
"description": "Kendo UI TypeScript package exporting functions for Editor component",
|
|
4
|
-
"version": "1.12.9-develop.
|
|
4
|
+
"version": "1.12.9-develop.5",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Kendo UI"
|
|
7
7
|
],
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"prosemirror-state": "1.4.4",
|
|
45
45
|
"prosemirror-tables": "1.8.5",
|
|
46
46
|
"prosemirror-transform": "1.12.1",
|
|
47
|
-
"prosemirror-view": "1.42.
|
|
47
|
+
"prosemirror-view": "1.42.3",
|
|
48
48
|
"tslib": "^2.8.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|