Skip to content

Commit 27754f3

Browse files
committed
完成基本功能
1 parent 02f9157 commit 27754f3

File tree

11 files changed

+1584
-257
lines changed

11 files changed

+1584
-257
lines changed

.editorconfig

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# top-most EditorConfig file
2-
root = true
3-
4-
[*]
5-
charset = utf-8
6-
end_of_line = lf
7-
insert_final_newline = true
8-
indent_style = tab
9-
indent_size = 4
10-
tab_width = 4
1+
# top-most EditorConfig file
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
insert_final_newline = true
8+
indent_style = tab
9+
indent_size = 2
10+
tab_width = 2

README.md

Lines changed: 9 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,14 @@
1-
# Obsidian Sample Plugin
1+
# Eazy Link for Obsidian
22

3-
This is a sample plugin for Obsidian (https://obsidian.md).
3+
[中文版](./README_zh.md)
44

5-
This project uses TypeScript to provide type checking and documentation.
6-
The repo depends on the latest plugin API (obsidian.d.ts) in TypeScript Definition format, which contains TSDoc comments describing what it does.
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.
76

8-
This sample plugin demonstrates some of the basic functionality the plugin API can do.
9-
- Adds a ribbon icon, which shows a Notice when clicked.
10-
- Adds a command "Open Sample Modal" which opens a Modal.
11-
- Adds a plugin setting tab to the settings page.
12-
- Registers a global click event and output 'click' to the console.
13-
- Registers a global interval which logs 'setInterval' to the console.
7+
![Eazy Link Demo](https://raw.githubusercontent.com/mnao/eazy-link-obsidian/master/demo.gif)
148

15-
## First time developing plugins?
9+
## Core Features
1610

17-
Quick starting guide for new plugin devs:
18-
19-
- Check if [someone already developed a plugin for what you want](https://obsidian.md/plugins)! There might be an existing plugin similar enough that you can partner up with.
20-
- Make a copy of this repo as a template with the "Use this template" button (login to GitHub if you don't see it).
21-
- Clone your repo to a local development folder. For convenience, you can place this folder in your `.obsidian/plugins/your-plugin-name` folder.
22-
- Install NodeJS, then run `npm i` in the command line under your repo folder.
23-
- Run `npm run dev` to compile your plugin from `main.ts` to `main.js`.
24-
- Make changes to `main.ts` (or create new `.ts` files). Those changes should be automatically compiled into `main.js`.
25-
- Reload Obsidian to load the new version of your plugin.
26-
- Enable plugin in settings window.
27-
- For updates to the Obsidian API run `npm update` in the command line under your repo folder.
28-
29-
## Releasing new releases
30-
31-
- Update your `manifest.json` with your new version number, such as `1.0.1`, and the minimum Obsidian version required for your latest release.
32-
- Update your `versions.json` file with `"new-plugin-version": "minimum-obsidian-version"` so older versions of Obsidian can download an older version of your plugin that's compatible.
33-
- Create new GitHub release using your new version number as the "Tag version". Use the exact version number, don't include a prefix `v`. See here for an example: https://github.com/obsidianmd/obsidian-sample-plugin/releases
34-
- Upload the files `manifest.json`, `main.js`, `styles.css` as binary attachments. Note: The manifest.json file must be in two places, first the root path of your repository and also in the release.
35-
- Publish the release.
36-
37-
> You can simplify the version bump process by running `npm version patch`, `npm version minor` or `npm version major` after updating `minAppVersion` manually in `manifest.json`.
38-
> The command will bump version in `manifest.json` and `package.json`, and add the entry for the new version to `versions.json`
39-
40-
## Adding your plugin to the community plugin list
41-
42-
- Check the [plugin guidelines](https://docs.obsidian.md/Plugins/Releasing/Plugin+guidelines).
43-
- Publish an initial version.
44-
- Make sure you have a `README.md` file in the root of your repo.
45-
- Make a pull request at https://github.com/obsidianmd/obsidian-releases to add your plugin.
46-
47-
## How to use
48-
49-
- Clone this repo.
50-
- Make sure your NodeJS is at least v16 (`node --version`).
51-
- `npm i` or `yarn` to install dependencies.
52-
- `npm run dev` to start compilation in watch mode.
53-
54-
## Manually installing the plugin
55-
56-
- Copy over `main.js`, `styles.css`, `manifest.json` to your vault `VaultFolder/.obsidian/plugins/your-plugin-id/`.
57-
58-
## Improve code quality with eslint (optional)
59-
- [ESLint](https://eslint.org/) is a tool that analyzes your code to quickly find problems. You can run ESLint against your plugin to find common bugs and ways to improve your code.
60-
- To use eslint with this project, make sure to install eslint from terminal:
61-
- `npm install -g eslint`
62-
- To use eslint to analyze this project use this command:
63-
- `eslint main.ts`
64-
- eslint will then create a report with suggestions for code improvement by file and line number.
65-
- If your source code is in a folder, such as `src`, you can use eslint with this command to analyze all files in that folder:
66-
- `eslint ./src/`
67-
68-
## Funding URL
69-
70-
You can include funding URLs where people who use your plugin can financially support it.
71-
72-
The simple way is to set the `fundingUrl` field to your link in your `manifest.json` file:
73-
74-
```json
75-
{
76-
"fundingUrl": "https://buymeacoffee.com"
77-
}
78-
```
79-
80-
If you have multiple URLs, you can also do:
81-
82-
```json
83-
{
84-
"fundingUrl": {
85-
"Buy Me a Coffee": "https://buymeacoffee.com",
86-
"GitHub Sponsor": "https://github.com/sponsors",
87-
"Patreon": "https://www.patreon.com/"
88-
}
89-
}
90-
```
91-
92-
## API Documentation
93-
94-
See https://github.com/obsidianmd/obsidian-api
11+
- **Automatic Title Fetching**: When you paste a URL, the plugin intelligently fetches the webpage's title and uses it as the link's display text.
12+
- **Image Link Optimization**: If you paste an image link, the plugin automatically recognizes and converts it into Markdown image format (`![Image Name](link)`).
13+
- **Custom Link Text**: If you have text selected before pasting a URL, that text will be used as the link's title, with the URL as its destination.
14+
- **Smart Fallback**: If the plugin fails to fetch a title or process the link, it will paste the original URL, ensuring your workflow is not interrupted.

README_zh.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Eazy Link for Obsidian (中文版)
2+
3+
[English Version](./README.md)
4+
5+
Eazy Link 是一款为 Obsidian 设计的插件,它能自动将 URL 转换为带标题的 Markdown 链接、格式化图片链接,或将链接应用到您选中的文本上,从而提升您的笔记效率。
6+
7+
![Eazy Link Demo](https://raw.githubusercontent.com/mnao/eazy-link-obsidian/master/demo.gif)
8+
9+
## 核心功能
10+
11+
- **自动获取网页标题**: 当您粘贴一个 URL 时,插件会智能地抓取该网页的标题,并将其作为链接的显示文本。
12+
- **图片链接优化**: 若粘贴的是图片链接,插件能自动识别并将其转换为 Markdown 图片格式 (`![图片名](链接)`).
13+
- **自定义链接文本**: 如果在粘贴 URL 之前您已选中一段文字,这段文字将被用作链接的标题,URL 则作为链接地址。
14+
- **智能回退机制**: 在无法获取网页标题或处理链接的情况下,插件将直接粘贴原始 URL,确保您的工作流程不受影响。

esbuild.config.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@ import esbuild from "esbuild";
22
import process from "process";
33
import builtins from "builtin-modules";
44

5-
const banner =
6-
`/*
5+
const banner = `/*
76
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
87
if you want to view the source, please visit the github repository of this plugin
98
*/
109
`;
1110

12-
const prod = (process.argv[2] === "production");
11+
const prod = process.argv[2] === "production";
1312

1413
const context = await esbuild.context({
1514
banner: {
1615
js: banner,
1716
},
18-
entryPoints: ["main.ts"],
17+
entryPoints: ["src/main.ts"],
1918
bundle: true,
2019
external: [
2120
"obsidian",
@@ -31,7 +30,8 @@ const context = await esbuild.context({
3130
"@lezer/common",
3231
"@lezer/highlight",
3332
"@lezer/lr",
34-
...builtins],
33+
...builtins,
34+
],
3535
format: "cjs",
3636
target: "es2018",
3737
logLevel: "info",

main.ts

Lines changed: 0 additions & 134 deletions
This file was deleted.

manifest.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"id": "sample-plugin",
3-
"name": "Sample Plugin",
4-
"version": "1.0.0",
5-
"minAppVersion": "0.15.0",
6-
"description": "Demonstrates some of the capabilities of the Obsidian API.",
7-
"author": "Obsidian",
8-
"authorUrl": "https://obsidian.md",
9-
"fundingUrl": "https://obsidian.md/pricing",
2+
"id": "easy-link-obsidian",
3+
"name": "Easy Link",
4+
"version": "1.0.1",
5+
"minAppVersion": "1.1.0",
6+
"description": "Automatically converts pasted URLs into titled Markdown links.",
7+
"author": "poenl",
8+
"authorUrl": "https://github.com/poenl",
9+
"fundingUrl": "https://github.com/poenl/eazy-link",
1010
"isDesktopOnly": false
1111
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "obsidian-sample-plugin",
2+
"name": "easy-link-obsidian",
33
"version": "1.0.0",
4-
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
4+
"description": "Automatically converts pasted URLs into titled Markdown links.",
55
"main": "main.js",
66
"scripts": {
77
"dev": "node esbuild.config.mjs",

0 commit comments

Comments
 (0)