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

@ -15,10 +15,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
}
init_js.push_str(include_str!("./scripts/drag.js"));
#[cfg(any(debug_assertions, feature = "devtools"))]
{
init_js.push_str(include_str!("./scripts/hotkey.js"));
init_js.push_str(include_str!("./scripts/toggle-devtools.js"));
}
init_js.push_str(include_str!("./scripts/toggle-devtools.js"));
Builder::new("window")
.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', () => {
window.__TAURI_INVOKE__('plugin:window|internal_toggle_devtools');
});
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// 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