mirror of
https://github.com/viarotel-org/escrcpy.git
synced 2024-12-18 18:35:55 +01:00
41 lines
873 B
JavaScript
41 lines
873 B
JavaScript
|
export class FindInPageManager {
|
||
|
constructor(webContents) {
|
||
|
this.webContents = webContents
|
||
|
this.text = ''
|
||
|
}
|
||
|
|
||
|
update({ webContents } = {}) {
|
||
|
this.webContents = webContents
|
||
|
}
|
||
|
|
||
|
async start({ text, args = {} } = {}) {
|
||
|
this.text = text
|
||
|
|
||
|
this.webContents.on('found-in-page', (event, result) => {
|
||
|
console.log('found-in-page.result', result)
|
||
|
})
|
||
|
|
||
|
return this.webContents.findInPage(this.text, { findNext: false, ...args })
|
||
|
}
|
||
|
|
||
|
async next({ ...args } = {}) {
|
||
|
return this.webContents.findInPage(this.text, {
|
||
|
forward: true,
|
||
|
findNext: true,
|
||
|
...args,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
async prev({ ...args } = {}) {
|
||
|
return this.webContents.findInPage(this.text, {
|
||
|
forward: false,
|
||
|
findNext: true,
|
||
|
...args,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
async stop(action = 'clearSelection') {
|
||
|
return this.webContents.stopFindInPage(action)
|
||
|
}
|
||
|
}
|