mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 14:42:32 -05:00
declare search for native app
This commit is contained in:
1 parent
2b9e5a86b6
commit
359f695eb5
9 files changed
+133
-102
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import { target, targetable } from '@github/catalyst/lib/targetable'
|
||||
|
||||
export default targetable(class extends HTMLElement {
|
||||
static [target.static] = ['form']
|
||||
|
||||
connectedCallback () {
|
||||
const bridge = window.webkit?.messageHandlers?.native
|
||||
|
||||
if (!bridge || !this.form) return
|
||||
|
||||
const url = new URL(this.form.action)
|
||||
|
||||
new FormData(this.form).forEach((value, key) => {
|
||||
if (key !== 'q' && value) url.searchParams.set(key, value)
|
||||
})
|
||||
|
||||
this.declared = true
|
||||
|
||||
bridge.postMessage({ type: 'search', op: 'add', url: url.pathname + url.search })
|
||||
}
|
||||
|
||||
disconnectedCallback () {
|
||||
if (this.declared) {
|
||||
window.webkit?.messageHandlers?.native?.postMessage({ type: 'search', op: 'remove' })
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user