mirror of
https://github.com/busyogg/OneStepWikiLink.git
synced 2026-07-22 05:41:52 +00:00
移除默认快捷键
修改文件路径判定逻辑
This commit is contained in:
parent
908d32fb47
commit
0ec27ac172
2 changed files with 19 additions and 15 deletions
|
|
@ -13,7 +13,7 @@
|
|||
* 当前界面所有潜在的匹配文本(基于插件的匹配规则)
|
||||
* 转换按钮,点击该按钮可以将当前界面所有匹配的文本转换为维基链接。
|
||||
|
||||
或者你可以选择使用命令 `Convert All Matching Words to Wiki Links` 来执行转换。(默认快捷键 Mod + R,即 Ctrl + R / Cmd + R)
|
||||
或者你可以选择使用命令 `Convert All Matching Words to Wiki Links` 来执行转换。
|
||||
|
||||
## 自定义设置
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ After enabling this plugin, there will be two new elements on the outlink interf
|
|||
* All potential matches in the current document (based on the plugin's matching rules)
|
||||
* The Convert button, which will convert all matched text in the current document to Wiki links.
|
||||
|
||||
Or you can use the command `Convert All Matching Words to Wiki Links` to perform the conversion. (The default shortcut is Mod + R, which is Ctrl + R / Cmd + R)
|
||||
Or you can use the command `Convert All Matching Words to Wiki Links` to perform the conversion.
|
||||
|
||||
## Customization
|
||||
|
||||
|
|
|
|||
26
src/main.ts
26
src/main.ts
|
|
@ -119,19 +119,20 @@ export default class OneStepWikiLinkPlugin extends Plugin {
|
|||
this.openEditor = this.app.workspace.getActiveViewOfType(MarkdownView)?.editor;
|
||||
|
||||
if (file && this.openEditor) {
|
||||
this.currentFileName = (file as TFile).basename;
|
||||
|
||||
if (file instanceof TFile) {
|
||||
this.currentFileName = file.basename;
|
||||
let content = await this.app.vault.read(file);
|
||||
this.checkContent(content);
|
||||
}
|
||||
}
|
||||
|
||||
this.addCommand({
|
||||
id: "convert-all-matching-words-to-wiki-links",
|
||||
name: "Convert All Matching Words to Wiki Links",
|
||||
hotkeys: [{
|
||||
modifiers: ['Mod'],
|
||||
key: 'r'
|
||||
}],
|
||||
// hotkeys: [{
|
||||
// modifiers: ['Mod'],
|
||||
// key: 'r'
|
||||
// }],
|
||||
editorCallback: (editor) => {
|
||||
this.convert2WikiLink();
|
||||
}
|
||||
|
|
@ -141,19 +142,22 @@ export default class OneStepWikiLinkPlugin extends Plugin {
|
|||
//监听文本变化
|
||||
this.registerEvent(this.app.workspace.on("editor-change", async (file, data) => {
|
||||
// console.log(file, data);
|
||||
if (file) {
|
||||
this.currentFileName = (data.file as TFile).basename;
|
||||
// console.log(file.getValue());
|
||||
if (file && data.file instanceof TFile) {
|
||||
this.currentFileName = data.file.basename;
|
||||
this.checkContent(file.getValue());
|
||||
}
|
||||
}));
|
||||
|
||||
this.registerEvent(this.app.vault.on("rename", (file, oldPath) => {
|
||||
this.updateFileNameList((file as TFile).basename, true, oldPath.replace(".md", ""));
|
||||
if (file && file instanceof TFile) {
|
||||
this.updateFileNameList(file.basename, true, oldPath.replace(".md", ""));
|
||||
}
|
||||
}));
|
||||
|
||||
this.registerEvent(this.app.vault.on("delete", (file) => {
|
||||
this.updateFileNameList((file as TFile).basename, false);
|
||||
if (file && file instanceof TFile) {
|
||||
this.updateFileNameList(file.basename, false);
|
||||
}
|
||||
}));
|
||||
|
||||
this.registerDomEvent(document.body, "input", () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue