diff --git a/lib/src/pages/document.dart b/lib/src/pages/document.dart index 622baf0..c76fc99 100644 --- a/lib/src/pages/document.dart +++ b/lib/src/pages/document.dart @@ -247,10 +247,7 @@ class _DocumentPageState extends State with ViewSettingsState { constraints: const BoxConstraints(maxWidth: 800), child: OrgRootWidget( style: textStyle, - onLinkTap: (url) { - debugPrint('Launching URL: $url'); - return launch(url, forceSafariVC: false); - }, + onLinkTap: _openLink, onSectionLongPress: (section) => narrow(context, widget.dataSource, section), onLocalSectionLinkTap: (section) => @@ -292,6 +289,16 @@ class _DocumentPageState extends State with ViewSettingsState { ); } + Future _openLink(String url) { + if (looksLikeRelativePath(url) && url.endsWith('.org')) { + final resolved = widget.dataSource.resolveRelative(url); + return loadDocument(context, resolved); + } else { + debugPrint('Launching URL: $url'); + return launch(url, forceSafariVC: false); + } + } + bool? _hasRelativeLinks; bool get _askForDirectoryPermissions =>