@tiptap/core 2.2.0-rc.8 → 2.2.0
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/index.cjs +16 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +16 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/helpers/getMarksBetween.ts +1 -1
- package/src/utilities/elementFromString.ts +19 -1
package/dist/index.umd.js
CHANGED
|
@@ -1581,10 +1581,24 @@
|
|
|
1581
1581
|
return commands.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, value, options);
|
|
1582
1582
|
};
|
|
1583
1583
|
|
|
1584
|
+
const removeWhitespaces = (node) => {
|
|
1585
|
+
const children = node.childNodes;
|
|
1586
|
+
for (let i = children.length - 1; i >= 0; i -= 1) {
|
|
1587
|
+
const child = children[i];
|
|
1588
|
+
if (child.nodeType === 3 && child.nodeValue && /^(\n\s\s|\n)$/.test(child.nodeValue)) {
|
|
1589
|
+
node.removeChild(child);
|
|
1590
|
+
}
|
|
1591
|
+
else if (child.nodeType === 1) {
|
|
1592
|
+
removeWhitespaces(child);
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
return node;
|
|
1596
|
+
};
|
|
1584
1597
|
function elementFromString(value) {
|
|
1585
1598
|
// add a wrapper to preserve leading and trailing whitespace
|
|
1586
1599
|
const wrappedValue = `<body>${value}</body>`;
|
|
1587
|
-
|
|
1600
|
+
const html = new window.DOMParser().parseFromString(wrappedValue, 'text/html').body;
|
|
1601
|
+
return removeWhitespaces(html);
|
|
1588
1602
|
}
|
|
1589
1603
|
|
|
1590
1604
|
function createNodeFromContent(content, schema, options) {
|
|
@@ -2312,7 +2326,7 @@
|
|
|
2312
2326
|
}
|
|
2313
2327
|
else {
|
|
2314
2328
|
doc.nodesBetween(from, to, (node, pos) => {
|
|
2315
|
-
if (!node || node.nodeSize === undefined) {
|
|
2329
|
+
if (!node || (node === null || node === void 0 ? void 0 : node.nodeSize) === undefined) {
|
|
2316
2330
|
return;
|
|
2317
2331
|
}
|
|
2318
2332
|
marks.push(...node.marks.map(mark => ({
|