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