Skip to content

Commit 160c3e7

Browse files
committed
fix(editor): empty link text error
close #270
1 parent 71559c8 commit 160c3e7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

packages/editor/src/extensions/Inline/from-inline-markdown.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,23 @@ function flatLink(mdastToken: mdast.Link, depth: number): InlineToken[] {
154154
const parentStartPos = mdastToken.position!.start.offset!
155155
const parentEndPos = mdastToken.position!.end.offset!
156156

157+
if (mdastToken.children.length === 0) {
158+
// process [](https://example.com)
159+
return [
160+
{
161+
marks: ['mdText'],
162+
attrs: { depth, first: true, last: true },
163+
start: mdastToken.position!.start.offset!,
164+
end: mdastToken.position!.start.offset! + 2,
165+
},
166+
{
167+
marks: ['mdMark'],
168+
attrs: { depth },
169+
start: mdastToken.position!.start.offset! + 2,
170+
end: parentEndPos,
171+
}
172+
]
173+
}
157174
const childrenStartPos = mdastToken.children[0].position!.start.offset!
158175
const childrenEndPos = mdastToken.children[mdastToken.children.length - 1].position!.end.offset!
159176

0 commit comments

Comments
 (0)