sciencefair icon indicating copy to clipboard operation
sciencefair copied to clipboard

[Reader] Search in article

Open phcerdan opened this issue 7 years ago • 3 comments

Hey, I guess the amazing Lens reader rely on the browser search functionalities? How do we search from the electron app?

phcerdan avatar May 05 '17 00:05 phcerdan

hmm good point - there is no browser find equivalent interface built into electron - we'll have to add it directly to our lens reader window, perhaps using one of these:

  • https://www.npmjs.com/package/electron-in-page-search
  • https://www.npmjs.com/package/electron-search-text

blahah avatar May 05 '17 00:05 blahah

@CAYdenberg if we use electron-in-page-search, this would be achieved from inside the reader view as opposed to Lens. This has the benefit of also supporting other readers that we might want in the future (scholarlyHTML, ePub, etc.), and that it can be maintained outside Lens, and that we can apply it to other parts of the app if that becomes appropriate.

See the docs linked above, but it should work something like this on the reader webview:

const frame = html`<webview id="reader" class="${style.frame}"></webview>`

// frame customisation stuff

const readersearch = searchInPage(frame)

// register a keyboard shortcut for cmd[OR]ctrl+f
function onCmdOrCtrlF () {
  readersearch.openSearchWindow()
}

We have not yet set up the app-wide shortcut registering mechanism - but if you're interested in implementing this I can make that a priority.

blahah avatar Jul 06 '17 08:07 blahah

@CAYdenberg haha I wrote this before I saw your PR #130 - looks like you took matters into your own hands which is awesome :D

blahah avatar Jul 06 '17 08:07 blahah