remove hotkey script

pull/361/head
Lucas Nogueira 2 years ago
parent 952b24ecaf
commit 4d8366f323
No known key found for this signature in database
GPG Key ID: FFEA6C72E73482F1

@ -2,43 +2,39 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// open <a href="..."> links with the API ;(function () {
function __openLinks() { // open <a href="..."> links with the API
document.querySelector('body').addEventListener( function openLinks() {
'click', document.querySelector('body').addEventListener(
function (e) { 'click',
var target = e.target function (e) {
while (target != null) { var target = e.target
if (target.matches('a')) { while (target != null) {
if ( if (target.matches('a')) {
target.href && if (
(['http://', 'https://', 'mailto:', 'tel:'].some(v => target.href.startsWith(v))) && target.href &&
target.target === '_blank' (['http://', 'https://', 'mailto:', 'tel:'].some(v => target.href.startsWith(v))) &&
) { target.target === '_blank'
window.__TAURI_INVOKE__('plugin:shell|open', { ) {
path: target.href window.__TAURI_INVOKE__('plugin:shell|open', {
}) path: target.href
e.preventDefault() })
e.preventDefault()
}
break
} }
break target = target.parentElement
} }
target = target.parentElement
} }
} )
) }
}
if ( if (
document.readyState === 'complete' || document.readyState === 'complete' ||
document.readyState === 'interactive' document.readyState === 'interactive'
) { ) {
__openLinks() openLinks()
} else { } else {
window.addEventListener( window.addEventListener('DOMContentLoaded', openLinks, true)
'DOMContentLoaded', }
function () { })()
__openLinks()
},
true
)
}

@ -15,10 +15,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
} }
init_js.push_str(include_str!("./scripts/drag.js")); init_js.push_str(include_str!("./scripts/drag.js"));
#[cfg(any(debug_assertions, feature = "devtools"))] #[cfg(any(debug_assertions, feature = "devtools"))]
{ init_js.push_str(include_str!("./scripts/toggle-devtools.js"));
init_js.push_str(include_str!("./scripts/hotkey.js"));
init_js.push_str(include_str!("./scripts/toggle-devtools.js"));
}
Builder::new("window") Builder::new("window")
.js_init_script(init_js) .js_init_script(init_js)

File diff suppressed because one or more lines are too long

@ -1,3 +1,26 @@
window.hotkeys(navigator.appVersion.includes('Mac') ? 'command+option+i' : 'ctrl+shift+i', () => { // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
window.__TAURI_INVOKE__('plugin:window|internal_toggle_devtools'); // SPDX-License-Identifier: Apache-2.0
}); // SPDX-License-Identifier: MIT
;(function () {
function toggleDevtoolsHotkey() {
const isHotkey = navigator.appVersion.includes('Mac')
? event => event.metaKey && event.altKey && event.key === 'I'
: event => event.ctrlKey && event.shiftKey && event.key === 'I'
document.addEventListener('keydown', event => {
if (isHotkey(event)) {
window.__TAURI_INVOKE__('plugin:window|internal_toggle_devtools');
}
})
}
if (
document.readyState === 'complete' ||
document.readyState === 'interactive'
) {
toggleDevtoolsHotkey()
} else {
window.addEventListener('DOMContentLoaded', toggleDevtoolsHotkey, true)
}
})()

Loading…
Cancel
Save