diff --git a/app/bibleview-js/src/components/TextEditor.vue b/app/bibleview-js/src/components/TextEditor.vue index 268f74840b..fd69ee9f6e 100644 --- a/app/bibleview-js/src/components/TextEditor.vue +++ b/app/bibleview-js/src/components/TextEditor.vue @@ -126,7 +126,10 @@ const bibleLink = { while (parsed === "" && text !== null) { text = await inputText.value!.inputText(text, error); if (text !== null) { - parsed = parse(text) + parsed = await android.parseRef(text) + if(parsed === "") { + parsed = parse(text) + } if (parsed === "") { error = strings.invalidReference; } else { diff --git a/app/bibleview-js/src/composables/android.ts b/app/bibleview-js/src/composables/android.ts index 011c26d464..5333fd20a9 100644 --- a/app/bibleview-js/src/composables/android.ts +++ b/app/bibleview-js/src/composables/android.ts @@ -41,6 +41,7 @@ export type BibleJavascriptInterface = { requestMoreToBeginning: AsyncFunc, requestMoreToEnd: AsyncFunc, refChooserDialog: AsyncFunc, + parseRef: (callId: number, s: String) => void, saveBookmarkNote: (bookmarkId: IdType, note: Nullable) => void, saveGenericBookmarkNote: (bookmarkId: IdType, note: Nullable) => void, removeBookmark: (bookmarkId: IdType) => void, @@ -402,6 +403,11 @@ export function useAndroid({bookmarks}: { bookmarks: Ref }, conf window.android.openDownloads(); } + async function parseRef(s: string): Promise { + const result = await deferredCall((callId) => window.android.parseRef(callId, s)) + return result ?? "" + } + function updateOrderNumber( labelId: IdType, bookmarks: StudyPadBibleBookmarkItem[], @@ -536,6 +542,7 @@ export function useAndroid({bookmarks}: { bookmarks: Ref }, conf speakGeneric, helpDialog, onKeyDown, + parseRef, } if (config.developmentMode) return { diff --git a/app/src/main/java/net/bible/android/view/activity/page/BibleJavascriptInterface.kt b/app/src/main/java/net/bible/android/view/activity/page/BibleJavascriptInterface.kt index a460888a68..bbdca89cdb 100644 --- a/app/src/main/java/net/bible/android/view/activity/page/BibleJavascriptInterface.kt +++ b/app/src/main/java/net/bible/android/view/activity/page/BibleJavascriptInterface.kt @@ -134,6 +134,12 @@ class BibleJavascriptInterface( bibleView.requestMoreToEnd(callId) } + @JavascriptInterface + fun parseRef(callId: Long, s: String) { + Log.i(TAG, "Request more text at end") + bibleView.parseRef(callId, s) + } + @JavascriptInterface fun refChooserDialog(callId: Long) { scope.launch { diff --git a/app/src/main/java/net/bible/android/view/activity/page/BibleView.kt b/app/src/main/java/net/bible/android/view/activity/page/BibleView.kt index 5550db150b..a88ee9fbce 100644 --- a/app/src/main/java/net/bible/android/view/activity/page/BibleView.kt +++ b/app/src/main/java/net/bible/android/view/activity/page/BibleView.kt @@ -102,6 +102,7 @@ import net.bible.android.database.IdType import net.bible.android.database.bookmarks.BookmarkEntities import net.bible.android.database.bookmarks.KJVA import net.bible.android.database.json +import net.bible.android.misc.wrapString import net.bible.android.view.activity.base.DocumentView import net.bible.android.view.activity.base.IntentHelper import net.bible.android.view.activity.base.SharedActivityState @@ -1925,6 +1926,11 @@ class BibleView(val mainBibleActivity: MainBibleActivity, super.onFocusChanged(focused, direction, previouslyFocusedRect) } + fun parseRef(callId: Long, s: String) { + val ref = wrapString(linkControl.resolveRef(s, (firstDocument as? BibleDocument)?.swordBook)?.osisRef) + executeJavascriptOnUiThread("bibleView.response($callId, $ref);") + } + var onDestroy: (() -> Unit)? = null private val TAG get() = "BibleView[${windowRef.get()?.displayId}]"