Skip to content

Commit 8a62c93

Browse files
committed
更新插件类名,增加特殊情况处理
1 parent 1f40d1d commit 8a62c93

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
# Eazy Link for Obsidian
1+
# Easy Link for Obsidian
22

33
[中文版](./README_zh.md)
44

5-
Eazy Link is a plugin for Obsidian designed to boost your note-taking efficiency by automatically converting URLs into titled Markdown links, formatting image links, or applying links to your selected text.
6-
7-
![Eazy Link Demo](https://raw.githubusercontent.com/mnao/eazy-link-obsidian/master/demo.gif)
5+
Easy Link is a plugin for Obsidian designed to boost your note-taking efficiency by automatically converting URLs into titled Markdown links, formatting image links, or applying links to your selected text.
86

97
## Core Features
108

README_zh.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
# Eazy Link for Obsidian (中文版)
1+
# Easy Link for Obsidian (中文版)
22

33
[English Version](./README.md)
44

5-
Eazy Link 是一款为 Obsidian 设计的插件,它能自动将 URL 转换为带标题的 Markdown 链接、格式化图片链接,或将链接应用到您选中的文本上,从而提升您的笔记效率。
6-
7-
![Eazy Link Demo](https://raw.githubusercontent.com/mnao/eazy-link-obsidian/master/demo.gif)
5+
Easy Link 是一款为 Obsidian 设计的插件,它能自动将 URL 转换为带标题的 Markdown 链接、格式化图片链接,或将链接应用到您选中的文本上,从而提升您的笔记效率。
86

97
## 核心功能
108

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"description": "Automatically formats pasted URLs into titled links, image links, or applies them to selected text.",
77
"author": "poenl",
88
"authorUrl": "https://github.com/poenl",
9-
"fundingUrl": "https://github.com/poenl/eazy-link-obsidian",
9+
"fundingUrl": "https://github.com/poenl/easy-link-obsidian",
1010
"isDesktopOnly": false
1111
}

src/main.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { App, Plugin, PluginSettingTab, requestUrl, Setting } from "obsidian";
33
const DEFAULT_SETTINGS = {
44
autoFormat: true,
55
};
6+
const IGNORE_REG = [/<$/, /^\[.*\]:\s*/];
67

7-
export default class MyPlugin extends Plugin {
8+
export default class EasyLinkPlugin extends Plugin {
89
settings: typeof DEFAULT_SETTINGS;
910

1011
async onload() {
@@ -27,8 +28,18 @@ export default class MyPlugin extends Plugin {
2728
editor.replaceSelection(`[${select}](${url.href})`);
2829
return;
2930
}
30-
// 自动获取网页标题
31+
3132
const from = editor.getCursor("from");
33+
// 处理需要跳过的情况
34+
const lineText = editor.getLine(from.line);
35+
for (let index = 0; index < this.ignore.length; index++) {
36+
const reg = this.ignore[index];
37+
if (lineText.match(reg)) {
38+
editor.replaceSelection(clipboardText);
39+
return;
40+
}
41+
}
42+
// 自动获取网页标题
3243

3344
const placeholder = "[Parsing URL...]";
3445
editor.replaceSelection(placeholder);
@@ -72,12 +83,15 @@ export default class MyPlugin extends Plugin {
7283
async saveSettings() {
7384
await this.saveData(this.settings);
7485
}
86+
87+
// 需要跳过的情况
88+
ignore: RegExp[] = IGNORE_REG;
7589
}
7690

7791
class SettingTab extends PluginSettingTab {
78-
plugin: MyPlugin;
92+
plugin: EasyLinkPlugin;
7993

80-
constructor(app: App, plugin: MyPlugin) {
94+
constructor(app: App, plugin: EasyLinkPlugin) {
8195
super(app, plugin);
8296
this.plugin = plugin;
8397
}

0 commit comments

Comments
 (0)