feat: 点击链接在新窗口打开

This commit is contained in:
Frankie Huang 2025-05-03 00:37:08 +08:00
parent 093f918dad
commit 861ff4667c
3 changed files with 332 additions and 261 deletions

577
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -15,6 +15,7 @@
"@tauri-apps/plugin-fs": "^2.2.1", "@tauri-apps/plugin-fs": "^2.2.1",
"@tauri-apps/plugin-opener": "^2", "@tauri-apps/plugin-opener": "^2",
"@vavt/v3-extension": "^3.0.0", "@vavt/v3-extension": "^3.0.0",
"markdown-it-link-attributes": "^4.0.1",
"md-editor-v3": "^5.5.0", "md-editor-v3": "^5.5.0",
"plantuml-encoder": "^1.4.0", "plantuml-encoder": "^1.4.0",
"scriptjs": "^2.5.9", "scriptjs": "^2.5.9",

View File

@ -53,6 +53,7 @@ import scriptjs from 'scriptjs'
import { config, MdEditor, MdCatalog, NormalToolbar, XSSPlugin } from 'md-editor-v3'; import { config, MdEditor, MdCatalog, NormalToolbar, XSSPlugin } from 'md-editor-v3';
import { ThemeSwitch, PreviewThemeSwitch, ExportPDF } from '@vavt/v3-extension'; import { ThemeSwitch, PreviewThemeSwitch, ExportPDF } from '@vavt/v3-extension';
import { lineNumbers } from '@codemirror/view'; import { lineNumbers } from '@codemirror/view';
import LinkAttr from 'markdown-it-link-attributes';
import { ref, reactive, watch, nextTick, onMounted } from "vue"; import { ref, reactive, watch, nextTick, onMounted } from "vue";
import { Message } from 'view-ui-plus' import { Message } from 'view-ui-plus'
import { encode as plantumlEncoder } from 'plantuml-encoder'; import { encode as plantumlEncoder } from 'plantuml-encoder';
@ -179,6 +180,20 @@ config({
plugin: XSSPlugin, plugin: XSSPlugin,
options: {}, options: {},
}, },
{
type: 'linkAttr',
plugin: LinkAttr,
options: {
matcher(href) {
// 使 markdown-it-anchor
//
return !href.startsWith('#');
},
attrs: {
target: '_blank',
},
},
},
]; ];
}, },
}); });