@tiptap/core 2.5.7 → 2.5.9
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 +23 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -14
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +23 -14
- package/dist/index.umd.js.map +1 -1
- package/dist/packages/core/src/Extension.d.ts +1 -1
- package/dist/packages/core/src/Mark.d.ts +1 -1
- package/dist/packages/core/src/Node.d.ts +1 -1
- package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +10 -4
- package/package.json +3 -3
- package/src/Extension.ts +1 -1
- package/src/Mark.ts +1 -1
- package/src/Node.ts +1 -1
- package/src/helpers/getMarksBetween.ts +1 -1
- package/src/helpers/getTextContentFromNodes.ts +1 -1
- package/src/helpers/isNodeEmpty.ts +33 -12
- package/src/utilities/findDuplicates.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -577,7 +577,7 @@ const getTextContentFromNodes = ($from, maxMatch = 500) => {
|
|
|
577
577
|
}))
|
|
578
578
|
|| node.textContent
|
|
579
579
|
|| '%leaf%';
|
|
580
|
-
textBefore += node.isAtom ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos));
|
|
580
|
+
textBefore += node.isAtom && !node.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos));
|
|
581
581
|
});
|
|
582
582
|
return textBefore;
|
|
583
583
|
};
|
|
@@ -964,7 +964,7 @@ function pasteRulesPlugin(props) {
|
|
|
964
964
|
|
|
965
965
|
function findDuplicates(items) {
|
|
966
966
|
const filtered = items.filter((el, index) => items.indexOf(el) !== index);
|
|
967
|
-
return
|
|
967
|
+
return Array.from(new Set(filtered));
|
|
968
968
|
}
|
|
969
969
|
|
|
970
970
|
class ExtensionManager {
|
|
@@ -2634,7 +2634,7 @@ function getMarksBetween(from, to, doc) {
|
|
|
2634
2634
|
.resolve(from)
|
|
2635
2635
|
.marks()
|
|
2636
2636
|
.forEach(mark => {
|
|
2637
|
-
const $pos = doc.resolve(from
|
|
2637
|
+
const $pos = doc.resolve(from);
|
|
2638
2638
|
const range = getMarkRange($pos, mark.type);
|
|
2639
2639
|
if (!range) {
|
|
2640
2640
|
return;
|
|
@@ -2827,31 +2827,40 @@ function isList(name, extensions) {
|
|
|
2827
2827
|
}
|
|
2828
2828
|
|
|
2829
2829
|
/**
|
|
2830
|
-
* Returns true if the given node is empty.
|
|
2831
|
-
* When `checkChildren` is true (default), it will also check if all children are empty.
|
|
2830
|
+
* Returns true if the given prosemirror node is empty.
|
|
2832
2831
|
*/
|
|
2833
|
-
function isNodeEmpty(node, { checkChildren
|
|
2832
|
+
function isNodeEmpty(node, { checkChildren = true, ignoreWhitespace = false, } = {}) {
|
|
2833
|
+
var _a;
|
|
2834
|
+
if (ignoreWhitespace) {
|
|
2835
|
+
if (node.type.name === 'hardBreak') {
|
|
2836
|
+
// Hard breaks are considered empty
|
|
2837
|
+
return true;
|
|
2838
|
+
}
|
|
2839
|
+
if (node.isText) {
|
|
2840
|
+
return /^\s*$/m.test((_a = node.text) !== null && _a !== void 0 ? _a : '');
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2834
2843
|
if (node.isText) {
|
|
2835
2844
|
return !node.text;
|
|
2836
2845
|
}
|
|
2846
|
+
if (node.isAtom || node.isLeaf) {
|
|
2847
|
+
return false;
|
|
2848
|
+
}
|
|
2837
2849
|
if (node.content.childCount === 0) {
|
|
2838
2850
|
return true;
|
|
2839
2851
|
}
|
|
2840
|
-
if (node.isLeaf) {
|
|
2841
|
-
return false;
|
|
2842
|
-
}
|
|
2843
2852
|
if (checkChildren) {
|
|
2844
|
-
let
|
|
2853
|
+
let isContentEmpty = true;
|
|
2845
2854
|
node.content.forEach(childNode => {
|
|
2846
|
-
if (
|
|
2855
|
+
if (isContentEmpty === false) {
|
|
2847
2856
|
// Exit early for perf
|
|
2848
2857
|
return;
|
|
2849
2858
|
}
|
|
2850
|
-
if (!isNodeEmpty(childNode)) {
|
|
2851
|
-
|
|
2859
|
+
if (!isNodeEmpty(childNode, { ignoreWhitespace, checkChildren })) {
|
|
2860
|
+
isContentEmpty = false;
|
|
2852
2861
|
}
|
|
2853
2862
|
});
|
|
2854
|
-
return
|
|
2863
|
+
return isContentEmpty;
|
|
2855
2864
|
}
|
|
2856
2865
|
return false;
|
|
2857
2866
|
}
|