11import { TFile } from 'obsidian' ;
22import OzanImagePlugin from 'src/main' ;
33import * as ExcalidrawHandler from 'src/util/excalidrawHandler' ;
4+ import * as ObsidianHelper from 'src/util/obsidianHelper' ;
45
56export const transclusionTypes = [ 'file-transclusion' , 'header-transclusion' , 'blockid-transclusion' ] ;
67
@@ -292,14 +293,17 @@ export const detectLink = (params: { lineText: string; sourceFile: TFile; plugin
292293 }
293294
294295 // --> F: Local File Wiki
296+ /* @deprecated Local File Wiki is not supported anymore
297+ https://discord.com/channels/686053708261228577/1103015564055691324/1103025035498758154
298+ ***************************************************************************************************
295299 const localFileWikiRegex = /!\[\[(file\:\/\/\/|app\:\/\/local\/).*(.pdf|.jpe?g|.png|.gif|.svg|.bmp)(.*)?\]\]/;
296- const localFileNameRegex = / ( f i l e \: \/ \/ \/ | a p p \: \/ \/ l o c a l \/ ) .* ( .p d f | .j p e ? g | .p n g | .g i f | .s v g | .b m p ) / ;
297300 const localFileMatchWiki = lineText.match(localFileWikiRegex);
298301
299302 if (localFileMatchWiki) {
300303 const localFileNameWikiMatch = localFileMatchWiki[0].match(localFileNameRegex);
301304 if (localFileNameWikiMatch) {
302- const fileLink = localFileNameWikiMatch [ 0 ] . replace ( 'file:///' , 'app://local/' ) ;
305+ let resourcePathPrefix = ObsidianHelper.getObsidianResourcePathPrefix();
306+ const fileLink = localFileNameWikiMatch[0].replace('file:///', resourcePathPrefix);
303307 const localPDFPageNumberRegex = /#page=[0-9]+\]\]/;
304308 const localPDFPageNumberMatch = localFileMatchWiki[0].match(localPDFPageNumberRegex);
305309 const wikiAltRegex = /\|.*(?=]])/;
@@ -314,15 +318,19 @@ export const detectLink = (params: { lineText: string; sourceFile: TFile; plugin
314318 };
315319 }
316320 }
321+ ***************************************************************************************************
322+ */
317323
318324 // --> G: Local File Markdown
319325 const localFileMdRegex = / ! \[ ( ^ $ | .* ) \] \( ( f i l e \: \/ \/ \/ | a p p \: \/ \/ l o c a l \/ ) .* ( .p d f | .j p e ? g | .p n g | .g i f | .s v g | .b m p ) ( .* ) ? \) / ;
326+ const localFileNameRegex = / ( f i l e \: \/ \/ \/ | a p p \: \/ \/ l o c a l \/ ) .* ( .p d f | .j p e ? g | .p n g | .g i f | .s v g | .b m p ) / ;
320327 const localFileMatchMd = lineText . match ( localFileMdRegex ) ;
321328
322329 if ( localFileMatchMd ) {
323330 const localFileNameMdMatch = localFileMatchMd [ 0 ] . match ( localFileNameRegex ) ;
324331 if ( localFileNameMdMatch ) {
325- const fileLink = localFileNameMdMatch [ 0 ] . replace ( 'file:///' , 'app://local/' ) ;
332+ let resourcePathPrefix = ObsidianHelper . getObsidianResourcePathPrefix ( ) ;
333+ const fileLink = localFileNameMdMatch [ 0 ] . replace ( 'file:///' , resourcePathPrefix ) ;
326334 const localPDFPageNumberRegex = / # p a g e = [ 0 - 9 ] + \) / ;
327335 const localPDFPageNumberMatch = localFileMatchMd [ 0 ] . match ( localPDFPageNumberRegex ) ;
328336 const mdAltRegex = / \[ ( ^ $ | .* ) (? = \] ) / ;
0 commit comments