@tiptap/core 2.5.9 → 3.0.0-next.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.
@@ -1,14 +1,8 @@
1
1
  import { Node as ProseMirrorNode } from '@tiptap/pm/model';
2
2
  /**
3
- * Returns true if the given prosemirror node is empty.
3
+ * Returns true if the given node is empty.
4
+ * When `checkChildren` is true (default), it will also check if all children are empty.
4
5
  */
5
- export declare function isNodeEmpty(node: ProseMirrorNode, { checkChildren, ignoreWhitespace, }?: {
6
- /**
7
- * When true (default), it will also check if all children are empty.
8
- */
9
- checkChildren?: boolean;
10
- /**
11
- * When true, it will ignore whitespace when checking for emptiness.
12
- */
13
- ignoreWhitespace?: boolean;
6
+ export declare function isNodeEmpty(node: ProseMirrorNode, { checkChildren }?: {
7
+ checkChildren: boolean;
14
8
  }): boolean;
@@ -1 +1 @@
1
- export declare const style = ".ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable=\"false\"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable=\"false\"] [contenteditable=\"true\"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}";
1
+ export declare const style = ".ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable=\"false\"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable=\"false\"] [contenteditable=\"true\"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/core",
3
3
  "description": "headless rich text editor",
4
- "version": "2.5.9",
4
+ "version": "3.0.0-next.0",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -32,10 +32,10 @@
32
32
  "dist"
33
33
  ],
34
34
  "devDependencies": {
35
- "@tiptap/pm": "^2.5.9"
35
+ "@tiptap/pm": "^3.0.0-next.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "@tiptap/pm": "^2.5.9"
38
+ "@tiptap/pm": "^3.0.0-next.0"
39
39
  },
40
40
  "repository": {
41
41
  "type": "git",
@@ -12,7 +12,7 @@ export function getMarksBetween(from: number, to: number, doc: ProseMirrorNode):
12
12
  .resolve(from)
13
13
  .marks()
14
14
  .forEach(mark => {
15
- const $pos = doc.resolve(from)
15
+ const $pos = doc.resolve(from - 1)
16
16
  const range = getMarkRange($pos, mark.type)
17
17
 
18
18
  if (!range) {
@@ -1,61 +1,40 @@
1
1
  import { Node as ProseMirrorNode } from '@tiptap/pm/model'
2
2
 
3
3
  /**
4
- * Returns true if the given prosemirror node is empty.
4
+ * Returns true if the given node is empty.
5
+ * When `checkChildren` is true (default), it will also check if all children are empty.
5
6
  */
6
7
  export function isNodeEmpty(
7
8
  node: ProseMirrorNode,
8
- {
9
- checkChildren = true,
10
- ignoreWhitespace = false,
11
- }: {
12
- /**
13
- * When true (default), it will also check if all children are empty.
14
- */
15
- checkChildren?: boolean;
16
- /**
17
- * When true, it will ignore whitespace when checking for emptiness.
18
- */
19
- ignoreWhitespace?: boolean;
20
- } = {},
9
+ { checkChildren }: { checkChildren: boolean } = { checkChildren: true },
21
10
  ): boolean {
22
- if (ignoreWhitespace) {
23
- if (node.type.name === 'hardBreak') {
24
- // Hard breaks are considered empty
25
- return true
26
- }
27
- if (node.isText) {
28
- return /^\s*$/m.test(node.text ?? '')
29
- }
30
- }
31
-
32
11
  if (node.isText) {
33
12
  return !node.text
34
13
  }
35
14
 
36
- if (node.isAtom || node.isLeaf) {
37
- return false
38
- }
39
-
40
15
  if (node.content.childCount === 0) {
41
16
  return true
42
17
  }
43
18
 
19
+ if (node.isLeaf) {
20
+ return false
21
+ }
22
+
44
23
  if (checkChildren) {
45
- let isContentEmpty = true
24
+ let hasSameContent = true
46
25
 
47
26
  node.content.forEach(childNode => {
48
- if (isContentEmpty === false) {
27
+ if (hasSameContent === false) {
49
28
  // Exit early for perf
50
29
  return
51
30
  }
52
31
 
53
- if (!isNodeEmpty(childNode, { ignoreWhitespace, checkChildren })) {
54
- isContentEmpty = false
32
+ if (!isNodeEmpty(childNode)) {
33
+ hasSameContent = false
55
34
  }
56
35
  })
57
36
 
58
- return isContentEmpty
37
+ return hasSameContent
59
38
  }
60
39
 
61
40
  return false
package/src/style.ts CHANGED
@@ -68,8 +68,4 @@ img.ProseMirror-separator {
68
68
 
69
69
  .ProseMirror-focused .ProseMirror-gapcursor {
70
70
  display: block;
71
- }
72
-
73
- .tippy-box[data-animation=fade][data-state=hidden] {
74
- opacity: 0
75
71
  }`