From 5532c62fa288659b5e5f98b79553795e7c71028a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E5=BF=86?= Date: Wed, 3 Jan 2024 21:48:52 +0800 Subject: [PATCH] fix(loadQuickDiff): altered-clicking on a link should open it in a new tab --- package.json | 3 +++ pnpm-lock.yaml | 9 +++++++++ src/module/loadQuickDiff.js | 35 +++++++++++++++++++---------------- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 7996e4a..df517fd 100644 --- a/package.json +++ b/package.json @@ -48,5 +48,8 @@ }, "bugs": { "url": "https://github.com/inpageedit/inpageedit-v2/issues" + }, + "dependencies": { + "filter-altered-clicks": "^2.0.1" } } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d80e39c..8755e55 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,11 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +dependencies: + filter-altered-clicks: + specifier: ^2.0.1 + version: 2.0.1 + devDependencies: '@dragon-fish/bump': specifier: ^0.0.15 @@ -739,6 +744,10 @@ packages: flat-cache: 3.1.1 dev: true + /filter-altered-clicks@2.0.1: + resolution: {integrity: sha512-/eguM/WumjpUls1kgLNk8T5JAdqTvI9hc8q7mOXsxIZAvxRLwttigaiJrfIuNXhREL8VrQZQKBiwFApJSbE7qA==} + dev: false + /find-up@5.0.0: resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} engines: {node: '>=10'} diff --git a/src/module/loadQuickDiff.js b/src/module/loadQuickDiff.js index 1f515d2..65c9579 100644 --- a/src/module/loadQuickDiff.js +++ b/src/module/loadQuickDiff.js @@ -1,3 +1,4 @@ +import filterAlteredClicks from 'filter-altered-clicks' import { _msg } from './_msg' import { _analytics } from './_analytics' import { quickDiff } from './quickDiff' @@ -86,11 +87,14 @@ function injectLinks(container) { $this.attr('ipe-diff-params', JSON.stringify(params)) // 点击事件 - $this.on('click', function (e) { - e.preventDefault() - _analytics('quick_diff_recentchanges') - return quickDiff(params) - }) + $this.on( + 'click', + filterAlteredClicks(function (e) { + e.preventDefault() + _analytics('quick_diff_recentchanges') + return quickDiff(params) + }) + ) }) } @@ -107,17 +111,16 @@ export function loadQuickDiff(container) { $('.historysubmit.mw-history-compareselectedversions-button').after( $('