diff --git a/assets/test/links-local.org b/assets/test/links-local.org index 9d60dd37..3c7ffa2e 100644 --- a/assets/test/links-local.org +++ b/assets/test/links-local.org @@ -9,6 +9,10 @@ - [[*Hogehoge][Local section link to nonexistent section]] - [[id:nonexistent-id][Local ID link to nonexistent ID]] - [[#hogehoge_id][Local custom ID link to nonexistent ID]] +- [[foo bar][Ambiguous link to dedicated target]] +- [[FOO BAR][Ambiguous link to dedicated target (case insensitive)]] +- [[named-block-here][Ambiguous link to named element]] +- [[NAMED-BLOCK-HERE][Ambiguous link to named element (case insensitive)]] * Foobar :PROPERTIES: @@ -17,9 +21,16 @@ Foobar! + <> + * Bizzbuzz :PROPERTIES: :CUSTOM_ID: bizzbuzz_id :END: Bizzbuzz! + + #+NAME: named-block-here + #+begin_src sh + echo hello, world + #+end_src diff --git a/lib/src/navigation.dart b/lib/src/navigation.dart index 284c98fb..b6bc63e5 100644 --- a/lib/src/navigation.dart +++ b/lib/src/navigation.dart @@ -115,12 +115,14 @@ class _DocumentPageWrapper extends StatelessWidget { errorHandler: (e) => WidgetsBinding.instance.addPostFrameCallback( (_) => showErrorSnackBar(context, OrgroError.from(e))), restorationId: 'org_page:${dataSource.id}', - child: DocumentPage( - layer: layer, - title: dataSource.name, - initialTarget: target, - initialMode: initialMode, - root: true, + child: OrgLocator( + child: DocumentPage( + layer: layer, + title: dataSource.name, + initialTarget: target, + initialMode: initialMode, + root: true, + ), ), ); }, @@ -187,13 +189,15 @@ Future narrow( searchQuery: _searchPattern(viewSettings.queryString), sparseQuery: _sparseQuery(viewSettings.filterData), restorationId: 'org_narrow_$layer:${dataSource.id}', - child: DocumentPage( - layer: layer, - title: AppLocalizations.of(context)! - .pageTitleNarrow(dataSource.name), - initialQuery: viewSettings.queryString, - initialFilter: viewSettings.filterData, - root: false, + child: OrgLocator( + child: DocumentPage( + layer: layer, + title: AppLocalizations.of(context)! + .pageTitleNarrow(dataSource.name), + initialQuery: viewSettings.queryString, + initialFilter: viewSettings.filterData, + root: false, + ), ), ); }), diff --git a/lib/src/pages/document/links.dart b/lib/src/pages/document/links.dart index 2ab24abb..bf704a3b 100644 --- a/lib/src/pages/document/links.dart +++ b/lib/src/pages/document/links.dart @@ -28,6 +28,9 @@ extension LinkHandler on DocumentPageState { return await _openExternalIdLink(link.location); } + final handled = await _openLocalFallbackTargets(doc, link.location); + if (handled) return true; + // Handle as a general URL try { final url = extractUrl(doc, link); @@ -142,6 +145,13 @@ extension LinkHandler on DocumentPageState { return false; } + Future _openLocalFallbackTargets(OrgTree doc, String target) async { + final locator = OrgLocator.of(context)!; + if (await locator.jumpToLinkTarget(target)) return true; + if (await locator.jumpToName(target)) return true; + return false; + } + Future _openFileInExternalApp(DataSource source) async { final tmp = await getTemporaryAttachmentsDirectory(); final tmpFile = diff --git a/pubspec.lock b/pubspec.lock index 8d426359..a05614bf 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -500,18 +500,18 @@ packages: dependency: "direct main" description: name: org_flutter - sha256: "45a069dc864ebd81da7f6218ee67608b6b1d5dc12dbc09451c33866a9816a370" + sha256: a567fddeffe7d457dce8c509b9cc1d8da422b4a325389aacdad266fa23be3d6d url: "https://pub.dev" source: hosted - version: "7.13.2" + version: "8.0.1" org_parser: dependency: transitive description: name: org_parser - sha256: cb5ddbdab0526e6f86f78666643fa2d7ad03952a65054ca631a99d04d95d7990 + sha256: "98ad7dfa9297791b5e4453bea844e1f63375c506ebe75ee887006075e87e1e3d" url: "https://pub.dev" source: hosted - version: "7.1.2" + version: "7.2.0" path: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 37ef0191..89d38528 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -43,7 +43,7 @@ dependencies: google_fonts: ^6.0.0 http: ^1.1.0 intl: ^0.19.0 - org_flutter: ^7.13.0 + org_flutter: ^8.0.1 # org_flutter: # path: ../org_flutter path_provider: ^2.0.9