@tiptap/core 2.5.8 → 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 +22 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -13
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +22 -13
- 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/isNodeEmpty.ts +33 -12
- package/src/utilities/findDuplicates.ts +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -962,7 +962,7 @@
|
|
|
962
962
|
|
|
963
963
|
function findDuplicates(items) {
|
|
964
964
|
const filtered = items.filter((el, index) => items.indexOf(el) !== index);
|
|
965
|
-
return
|
|
965
|
+
return Array.from(new Set(filtered));
|
|
966
966
|
}
|
|
967
967
|
|
|
968
968
|
class ExtensionManager {
|
|
@@ -2632,7 +2632,7 @@
|
|
|
2632
2632
|
.resolve(from)
|
|
2633
2633
|
.marks()
|
|
2634
2634
|
.forEach(mark => {
|
|
2635
|
-
const $pos = doc.resolve(from
|
|
2635
|
+
const $pos = doc.resolve(from);
|
|
2636
2636
|
const range = getMarkRange($pos, mark.type);
|
|
2637
2637
|
if (!range) {
|
|
2638
2638
|
return;
|
|
@@ -2825,31 +2825,40 @@
|
|
|
2825
2825
|
}
|
|
2826
2826
|
|
|
2827
2827
|
/**
|
|
2828
|
-
* Returns true if the given node is empty.
|
|
2829
|
-
* When `checkChildren` is true (default), it will also check if all children are empty.
|
|
2828
|
+
* Returns true if the given prosemirror node is empty.
|
|
2830
2829
|
*/
|
|
2831
|
-
function isNodeEmpty(node, { checkChildren
|
|
2830
|
+
function isNodeEmpty(node, { checkChildren = true, ignoreWhitespace = false, } = {}) {
|
|
2831
|
+
var _a;
|
|
2832
|
+
if (ignoreWhitespace) {
|
|
2833
|
+
if (node.type.name === 'hardBreak') {
|
|
2834
|
+
// Hard breaks are considered empty
|
|
2835
|
+
return true;
|
|
2836
|
+
}
|
|
2837
|
+
if (node.isText) {
|
|
2838
|
+
return /^\s*$/m.test((_a = node.text) !== null && _a !== void 0 ? _a : '');
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2832
2841
|
if (node.isText) {
|
|
2833
2842
|
return !node.text;
|
|
2834
2843
|
}
|
|
2844
|
+
if (node.isAtom || node.isLeaf) {
|
|
2845
|
+
return false;
|
|
2846
|
+
}
|
|
2835
2847
|
if (node.content.childCount === 0) {
|
|
2836
2848
|
return true;
|
|
2837
2849
|
}
|
|
2838
|
-
if (node.isLeaf) {
|
|
2839
|
-
return false;
|
|
2840
|
-
}
|
|
2841
2850
|
if (checkChildren) {
|
|
2842
|
-
let
|
|
2851
|
+
let isContentEmpty = true;
|
|
2843
2852
|
node.content.forEach(childNode => {
|
|
2844
|
-
if (
|
|
2853
|
+
if (isContentEmpty === false) {
|
|
2845
2854
|
// Exit early for perf
|
|
2846
2855
|
return;
|
|
2847
2856
|
}
|
|
2848
|
-
if (!isNodeEmpty(childNode)) {
|
|
2849
|
-
|
|
2857
|
+
if (!isNodeEmpty(childNode, { ignoreWhitespace, checkChildren })) {
|
|
2858
|
+
isContentEmpty = false;
|
|
2850
2859
|
}
|
|
2851
2860
|
});
|
|
2852
|
-
return
|
|
2861
|
+
return isContentEmpty;
|
|
2853
2862
|
}
|
|
2854
2863
|
return false;
|
|
2855
2864
|
}
|