@tiptap/core 3.17.0 → 3.18.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/core",
3
3
  "description": "headless rich text editor",
4
- "version": "3.17.0",
4
+ "version": "3.18.0",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -52,10 +52,10 @@
52
52
  "jsx-dev-runtime"
53
53
  ],
54
54
  "devDependencies": {
55
- "@tiptap/pm": "^3.17.0"
55
+ "@tiptap/pm": "^3.18.0"
56
56
  },
57
57
  "peerDependencies": {
58
- "@tiptap/pm": "^3.17.0"
58
+ "@tiptap/pm": "^3.18.0"
59
59
  },
60
60
  "repository": {
61
61
  "type": "git",
package/src/NodePos.ts CHANGED
@@ -134,6 +134,7 @@ export class NodePos {
134
134
  this.node.content.forEach((node, offset) => {
135
135
  const isBlock = node.isBlock && !node.isTextblock
136
136
  const isNonTextAtom = node.isAtom && !node.isText
137
+ const isInline = node.isInline
137
138
 
138
139
  const targetPos = this.pos + offset + (isNonTextAtom ? 0 : 1)
139
140
 
@@ -144,17 +145,21 @@ export class NodePos {
144
145
 
145
146
  const $pos = this.resolvedPos.doc.resolve(targetPos)
146
147
 
147
- if (!isBlock && $pos.depth <= this.depth) {
148
+ // Only apply depth check for non-block, non-inline nodes (i.e., textblocks)
149
+ // Inline nodes should always be included as children since we're iterating
150
+ // over direct children via this.node.content
151
+ if (!isBlock && !isInline && $pos.depth <= this.depth) {
148
152
  return
149
153
  }
150
154
 
151
- const childNodePos = new NodePos($pos, this.editor, isBlock, isBlock ? node : null)
155
+ // Pass the node for both block and inline nodes to ensure correct node reference
156
+ const childNodePos = new NodePos($pos, this.editor, isBlock, isBlock || isInline ? node : null)
152
157
 
153
158
  if (isBlock) {
154
159
  childNodePos.actualDepth = this.depth + 1
155
160
  }
156
161
 
157
- children.push(new NodePos($pos, this.editor, isBlock, isBlock ? node : null))
162
+ children.push(childNodePos)
158
163
  })
159
164
 
160
165
  return children
@@ -69,8 +69,14 @@ export const focus: RawCommands['focus'] =
69
69
  })
70
70
  }
71
71
 
72
- if ((view.hasFocus() && position === null) || position === false) {
73
- return true
72
+ try {
73
+ if ((view.hasFocus() && position === null) || position === false) {
74
+ return true
75
+ }
76
+ } catch {
77
+ // if view.hasFocus fails (view not mounted yet)
78
+ // we will return false because there's nothing to focus
79
+ return false
74
80
  }
75
81
 
76
82
  // we don’t try to resolve a NodeSelection or CellSelection
@@ -461,8 +461,8 @@ export class ResizableNodeView {
461
461
  return this.container
462
462
  }
463
463
 
464
- get contentDOM() {
465
- return this.contentElement
464
+ get contentDOM(): HTMLElement | null {
465
+ return this.contentElement ?? null
466
466
  }
467
467
 
468
468
  private handleEditorUpdate() {