@progress/kendo-editor-common 1.9.5-dev.202303280729 → 1.9.5-dev.202304171418

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.
@@ -1,3 +1,4 @@
1
+ import { fragmentToHtml, htmlToFragment } from "./source";
1
2
  var msoListRegExp = /style=['"]?[^'"]*?mso-list:\s*[a-zA-Z]+(\d+)\s[a-zA-Z]+(\d+)\s(\w+)/gi;
2
3
  var extractListLevels = function (html) {
3
4
  html = html.replace(msoListRegExp, function (match, list, level) {
@@ -113,7 +114,7 @@ var convertToLi = function (p) {
113
114
  }
114
115
  p.parentNode.removeChild(p);
115
116
  var li = document.createElement('li');
116
- li.innerHTML = content;
117
+ li.appendChild(htmlToFragment(content));
117
118
  return li;
118
119
  };
119
120
  var toList = function (blockNodes) {
@@ -176,10 +177,9 @@ var toList = function (blockNodes) {
176
177
  }
177
178
  };
178
179
  export var convertMsLists = function (html) {
179
- var container = document.createElement('div');
180
- container.innerHTML = extractListLevels(html);
180
+ var container = htmlToFragment(extractListLevels(html));
181
181
  var groups = new Set();
182
182
  mapListsCandidates(container.children, groups);
183
183
  groups.forEach(function (listsCandidates) { return toList(listsCandidates); });
184
- return container.innerHTML;
184
+ return fragmentToHtml(container);
185
185
  };
package/dist/es/paste.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { convertMsLists } from './listConvert';
2
+ import { fragmentToHtml, htmlToFragment } from './source';
2
3
  /**
3
4
  * Removes the invalid HTML. Use it as a first step for cleaning the HTML.
4
5
  */
@@ -106,10 +107,9 @@ export var pasteCleanup = function (html, settings) {
106
107
  result = removeTag(result, settings.stripTags);
107
108
  }
108
109
  if (settings.attributes) {
109
- var div = document.createElement('div');
110
- div.innerHTML = result;
111
- Array.from(div.querySelectorAll('*')).forEach(function (node) { return sanitizeNode(node, settings.attributes); });
112
- result = div.innerHTML;
110
+ var fragment = htmlToFragment(result);
111
+ Array.from(fragment.querySelectorAll('*')).forEach(function (node) { return sanitizeNode(node, settings.attributes); });
112
+ result = fragmentToHtml(fragment);
113
113
  }
114
114
  return result;
115
115
  };
package/dist/es/source.js CHANGED
@@ -95,6 +95,12 @@ export var htmlToFragment = function (html) {
95
95
  }
96
96
  return fragment;
97
97
  };
98
+ /**
99
+ * @hidden
100
+ */
101
+ export var fragmentToHtml = function (fragment) {
102
+ return Array.from(fragment.children).reduce(function (acc, cur) { return acc + (cur.outerHTML || cur.textContent || ''); }, '');
103
+ };
98
104
  /**
99
105
  * Creates a DocumentFragment from the given ProseMirrorNode.
100
106
  * @param doc ProseMirrorNode
@@ -1,3 +1,4 @@
1
+ import { fragmentToHtml, htmlToFragment } from "./source";
1
2
  const msoListRegExp = /style=['"]?[^'"]*?mso-list:\s*[a-zA-Z]+(\d+)\s[a-zA-Z]+(\d+)\s(\w+)/gi;
2
3
  const extractListLevels = (html) => {
3
4
  html = html.replace(msoListRegExp, (match, list, level) => {
@@ -113,7 +114,7 @@ const convertToLi = (p) => {
113
114
  }
114
115
  p.parentNode.removeChild(p);
115
116
  const li = document.createElement('li');
116
- li.innerHTML = content;
117
+ li.appendChild(htmlToFragment(content));
117
118
  return li;
118
119
  };
119
120
  const toList = (blockNodes) => {
@@ -176,10 +177,9 @@ const toList = (blockNodes) => {
176
177
  }
177
178
  };
178
179
  export const convertMsLists = (html) => {
179
- const container = document.createElement('div');
180
- container.innerHTML = extractListLevels(html);
180
+ const container = htmlToFragment(extractListLevels(html));
181
181
  const groups = new Set();
182
182
  mapListsCandidates(container.children, groups);
183
183
  groups.forEach(listsCandidates => toList(listsCandidates));
184
- return container.innerHTML;
184
+ return fragmentToHtml(container);
185
185
  };
@@ -1,4 +1,5 @@
1
1
  import { convertMsLists } from './listConvert';
2
+ import { fragmentToHtml, htmlToFragment } from './source';
2
3
  /**
3
4
  * Removes the invalid HTML. Use it as a first step for cleaning the HTML.
4
5
  */
@@ -105,10 +106,9 @@ export const pasteCleanup = (html, settings) => {
105
106
  result = removeTag(result, settings.stripTags);
106
107
  }
107
108
  if (settings.attributes) {
108
- const div = document.createElement('div');
109
- div.innerHTML = result;
110
- Array.from(div.querySelectorAll('*')).forEach(node => sanitizeNode(node, settings.attributes));
111
- result = div.innerHTML;
109
+ const fragment = htmlToFragment(result);
110
+ Array.from(fragment.querySelectorAll('*')).forEach(node => sanitizeNode(node, settings.attributes));
111
+ result = fragmentToHtml(fragment);
112
112
  }
113
113
  return result;
114
114
  };
@@ -94,6 +94,12 @@ export const htmlToFragment = (html) => {
94
94
  }
95
95
  return fragment;
96
96
  };
97
+ /**
98
+ * @hidden
99
+ */
100
+ export const fragmentToHtml = (fragment) => {
101
+ return Array.from(fragment.children).reduce((acc, cur) => acc + (cur.outerHTML || cur.textContent || ''), '');
102
+ };
97
103
  /**
98
104
  * Creates a DocumentFragment from the given ProseMirrorNode.
99
105
  * @param doc ProseMirrorNode
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.convertMsLists = void 0;
4
+ var source_1 = require("./source");
4
5
  var msoListRegExp = /style=['"]?[^'"]*?mso-list:\s*[a-zA-Z]+(\d+)\s[a-zA-Z]+(\d+)\s(\w+)/gi;
5
6
  var extractListLevels = function (html) {
6
7
  html = html.replace(msoListRegExp, function (match, list, level) {
@@ -116,7 +117,7 @@ var convertToLi = function (p) {
116
117
  }
117
118
  p.parentNode.removeChild(p);
118
119
  var li = document.createElement('li');
119
- li.innerHTML = content;
120
+ li.appendChild(source_1.htmlToFragment(content));
120
121
  return li;
121
122
  };
122
123
  var toList = function (blockNodes) {
@@ -179,11 +180,10 @@ var toList = function (blockNodes) {
179
180
  }
180
181
  };
181
182
  var convertMsLists = function (html) {
182
- var container = document.createElement('div');
183
- container.innerHTML = extractListLevels(html);
183
+ var container = source_1.htmlToFragment(extractListLevels(html));
184
184
  var groups = new Set();
185
185
  mapListsCandidates(container.children, groups);
186
186
  groups.forEach(function (listsCandidates) { return toList(listsCandidates); });
187
- return container.innerHTML;
187
+ return source_1.fragmentToHtml(container);
188
188
  };
189
189
  exports.convertMsLists = convertMsLists;
package/dist/npm/paste.js CHANGED
@@ -2,6 +2,7 @@
2
2
  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
+ var source_1 = require("./source");
5
6
  /**
6
7
  * Removes the invalid HTML. Use it as a first step for cleaning the HTML.
7
8
  */
@@ -115,10 +116,9 @@ var pasteCleanup = function (html, settings) {
115
116
  result = exports.removeTag(result, settings.stripTags);
116
117
  }
117
118
  if (settings.attributes) {
118
- var div = document.createElement('div');
119
- div.innerHTML = result;
120
- Array.from(div.querySelectorAll('*')).forEach(function (node) { return sanitizeNode(node, settings.attributes); });
121
- result = div.innerHTML;
119
+ var fragment = source_1.htmlToFragment(result);
120
+ Array.from(fragment.querySelectorAll('*')).forEach(function (node) { return sanitizeNode(node, settings.attributes); });
121
+ result = source_1.fragmentToHtml(fragment);
122
122
  }
123
123
  return result;
124
124
  };
@@ -21,6 +21,10 @@ export declare const trimWhitespace: (html: string, trimAroundTags?: string[]) =
21
21
  * @returns DocumentFragment
22
22
  */
23
23
  export declare const htmlToFragment: (html: string) => DocumentFragment;
24
+ /**
25
+ * @hidden
26
+ */
27
+ export declare const fragmentToHtml: (fragment: DocumentFragment) => string;
24
28
  /**
25
29
  * Creates a DocumentFragment from the given ProseMirrorNode.
26
30
  * @param doc ProseMirrorNode
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setHtml = exports.getHtml = exports.parseContent = exports.domToPmDoc = exports.pmDocToFragment = exports.htmlToFragment = exports.trimWhitespace = void 0;
3
+ exports.setHtml = exports.getHtml = exports.parseContent = exports.domToPmDoc = exports.pmDocToFragment = exports.fragmentToHtml = exports.htmlToFragment = exports.trimWhitespace = void 0;
4
4
  var prosemirror_model_1 = require("prosemirror-model");
5
5
  var prosemirror_state_1 = require("prosemirror-state");
6
6
  var constants_1 = require("./config/constants");
@@ -100,6 +100,13 @@ var htmlToFragment = function (html) {
100
100
  return fragment;
101
101
  };
102
102
  exports.htmlToFragment = htmlToFragment;
103
+ /**
104
+ * @hidden
105
+ */
106
+ var fragmentToHtml = function (fragment) {
107
+ return Array.from(fragment.children).reduce(function (acc, cur) { return acc + (cur.outerHTML || cur.textContent || ''); }, '');
108
+ };
109
+ exports.fragmentToHtml = fragmentToHtml;
103
110
  /**
104
111
  * Creates a DocumentFragment from the given ProseMirrorNode.
105
112
  * @param doc ProseMirrorNode