File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -150,9 +150,9 @@ class WikilinkDragHandleWidget extends WidgetType {
150150 }
151151}
152152
153- // Matches wikilinks [[...]] (not embeds ![[...]]) and markdown links [text](path)
154- const INTERNAL_LINK_RE =
155- / (?< ! ! ) \[ \[ ( [ ^ \] ] + ) \] \] | (?< ! ! ) \[ ( [ ^ \] ] + ) \] \( ( [ ^ ) ] + \. m d ) \) / g;
153+ // Matches wikilinks [[...]] and markdown links [text](path.md).
154+ // Embed exclusion (![[...]] and ) is handled in the loop.
155+ const INTERNAL_LINK_RE = / \[ \[ ( [ ^ \] ] + ) \] \] | \[ ( [ ^ \] ] + ) \] \( ( [ ^ ) ] + \. m d ) \) / g;
156156
157157const buildWidgetDecorations = (
158158 view : EditorView ,
@@ -166,6 +166,10 @@ const buildWidgetDecorations = (
166166 INTERNAL_LINK_RE . lastIndex = 0 ;
167167
168168 while ( ( match = INTERNAL_LINK_RE . exec ( text ) ) !== null ) {
169+ let isEmbed = false ;
170+ if ( match . index > 0 ) isEmbed = text [ match . index - 1 ] === "!" ;
171+ isEmbed = view . state . doc . sliceString ( from - 1 , from ) === "!" ;
172+ if ( isEmbed ) continue ;
169173 const matchEnd = from + match . index + match [ 0 ] . length ;
170174 const linkPath = extractLinkPath ( match [ 0 ] ) ;
171175 const widget = new WikilinkDragHandleWidget ( linkPath , plugin ) ;
You can’t perform that action at this time.
0 commit comments