diff --git a/core/tauri/scripts/core.js b/core/tauri/scripts/core.js index 0f539d868..9af28ee1b 100644 --- a/core/tauri/scripts/core.js +++ b/core/tauri/scripts/core.js @@ -85,73 +85,4 @@ } }) } - - // open links with the Tauri 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__('tauri', { - __tauriModule: 'Shell', - message: { - cmd: 'open', - path: target.href - } - }) - e.preventDefault() - } - break - } - target = target.parentElement - } - } - ) - } - - if ( - document.readyState === 'complete' || - document.readyState === 'interactive' - ) { - __openLinks() - } else { - window.addEventListener( - 'DOMContentLoaded', - function () { - __openLinks() - }, - true - ) - } - - // drag region - document.addEventListener('mousedown', (e) => { - if (e.target.hasAttribute('data-tauri-drag-region') && e.buttons === 1) { - // prevents text cursor - e.preventDefault() - // fix #2549: double click on drag region edge causes content to maximize without window sizing change - // https://github.com/tauri-apps/tauri/issues/2549#issuecomment-1250036908 - e.stopImmediatePropagation() - - // start dragging if the element has a `tauri-drag-region` data attribute and maximize on double-clicking it - window.__TAURI_INVOKE__('tauri', { - __tauriModule: 'Window', - message: { - cmd: 'manage', - data: { - cmd: { - type: e.detail === 2 ? '__toggleMaximize' : 'startDragging' - } - } - } - }) - } - }) })() diff --git a/core/tauri/scripts/init.js b/core/tauri/scripts/init.js index 6277eebcf..0a242919b 100644 --- a/core/tauri/scripts/init.js +++ b/core/tauri/scripts/init.js @@ -5,10 +5,6 @@ ; (function () { __RAW_freeze_prototype__ - ; (function () { - __RAW_hotkeys__ - })() - __RAW_pattern_script__ __RAW_ipc_script__ @@ -20,11 +16,7 @@ __RAW_core_script__ - __RAW_window_dialogs_script__ - - __RAW_window_print_script__ - - __RAW_event_initialization_script__ + __RAW_event_initialization_script__ if (window.ipc) { window.__TAURI_INVOKE__('__initialized', { url: window.location.href }) diff --git a/core/tauri/scripts/window_dialogs.js b/core/tauri/scripts/window_dialogs.js deleted file mode 100644 index 8d5df5592..000000000 --- a/core/tauri/scripts/window_dialogs.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -window.alert = function (message) { - window.__TAURI_INVOKE__('tauri', { - __tauriModule: 'Dialog', - message: { - cmd: 'messageDialog', - message: message.toString() - } - }) -} - -window.confirm = function (message) { - return window.__TAURI_INVOKE__('tauri', { - __tauriModule: 'Dialog', - message: { - cmd: 'confirmDialog', - message: message.toString() - } - }) -} diff --git a/core/tauri/scripts/window_print.js b/core/tauri/scripts/window_print.js deleted file mode 100644 index 6658963fc..000000000 --- a/core/tauri/scripts/window_print.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -window.print = function () { - return window.__TAURI_INVOKE__('tauri', { - __tauriModule: 'Window', - message: { - cmd: 'manage', - data: { - cmd: { - type: 'print' - } - } - } - }) -} diff --git a/core/tauri/src/manager.rs b/core/tauri/src/manager.rs index a6f633424..7d73244ac 100644 --- a/core/tauri/src/manager.rs +++ b/core/tauri/src/manager.rs @@ -1025,17 +1025,11 @@ impl WindowManager { #[raw] core_script: &'a str, #[raw] - window_dialogs_script: &'a str, - #[raw] - window_print_script: &'a str, - #[raw] event_initialization_script: &'a str, #[raw] plugin_initialization_script: &'a str, #[raw] freeze_prototype: &'a str, - #[raw] - hotkeys: &'a str, } let bundle_script = if with_global_tauri { @@ -1050,34 +1044,6 @@ impl WindowManager { "" }; - #[cfg(any(debug_assertions, feature = "devtools"))] - let hotkeys = &format!( - " - {}; - window.hotkeys('{}', () => {{ - window.__TAURI_INVOKE__('tauri', {{ - __tauriModule: 'Window', - message: {{ - cmd: 'manage', - data: {{ - cmd: {{ - type: '__toggleDevtools' - }} - }} - }} - }}); - }}); - ", - include_str!("../scripts/hotkey.js"), - if cfg!(target_os = "macos") { - "command+option+i" - } else { - "ctrl+shift+i" - } - ); - #[cfg(not(any(debug_assertions, feature = "devtools")))] - let hotkeys = ""; - InitJavascript { pattern_script, ipc_script, @@ -1093,23 +1059,9 @@ impl WindowManager { ) ), core_script: include_str!("../scripts/core.js"), - - // window.print works on Linux/Windows; need to use the API on macOS - #[cfg(any(target_os = "macos", target_os = "ios"))] - window_print_script: include_str!("../scripts/window_print.js"), - #[cfg(not(any(target_os = "macos", target_os = "ios")))] - window_print_script: "", - - // dialogs are implemented natively on Android - #[cfg(not(target_os = "android"))] - window_dialogs_script: include_str!("../scripts/window_dialogs.js"), - #[cfg(target_os = "android")] - window_dialogs_script: "", - event_initialization_script: &self.event_initialization_script(), plugin_initialization_script, freeze_prototype, - hotkeys, } .render_default(&Default::default()) .map(|s| s.into_string())