Skip to content

Commit 9431bbc

Browse files
committed
修正 因为匹配笔记属性错误导致笔记内容被忽略
1 parent 0cf51b9 commit 9431bbc

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "custom-image-auto-uploader",
33
"name": "Custom Image Auto Uploader",
4-
"version": "2.7.13",
4+
"version": "2.7.14",
55
"minAppVersion": "1.6.5",
66
"description": "You can batch download images from your notes on desktop, iOS, and Android platforms, and batch upload and save them to a remote server, home NAS, or cloud storage (such as Alibaba Cloud OSS, Amazon S3, Cloudflare R2, MinIO). Additionally, you can stretch, crop, and resize the images.",
77
"author": "HaierKeys",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Custom Image Auto Uploader",
3-
"version": "2.7.13",
3+
"version": "2.7.14",
44
"description": "You can upload and save images from your notes to your remote server, home NAS, or sync them to your cloud storage (Alibaba Cloud OSS, Amazon S3, Cloudflare R2).",
55
"main": "main.js",
66
"scripts": {

src/main.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ export default class CustomImageAutoUploader extends Plugin {
135135
let filePropertyContent = ""
136136
let filePropertyContentEndLine = 0
137137
let fileContent = ""
138-
const propertyMatch = fileFullContent.match(/^---\n((?:.|\n)*)---\n/gm)
138+
const propertyMatch = fileFullContent.match(/^---\s*\r?\n([\s\S]*?)\r?\n---\s*\r?\n?/g)
139+
139140
if (propertyMatch) {
140141
fileContent = fileFullContent.substring(propertyMatch[0].length)
141142
filePropertyContent = propertyMatch[0]
@@ -213,14 +214,22 @@ export default class CustomImageAutoUploader extends Plugin {
213214

214215
let filePropertyContent = ""
215216
let fileContent = ""
216-
const propertyMatch = fileFullContent.match(/^---\n((?:.|\n)*)---\n/gm)
217+
218+
// 统一换行为 \n
219+
220+
// 仅匹配文件开头的 front matter(独立一行的 --- 开始和结束)
221+
const propertyMatch = fileFullContent.match(/^---\s*\r?\n([\s\S]*?)\r?\n---\s*\r?\n?/g)
222+
223+
217224
if (propertyMatch) {
218225
fileContent = fileFullContent.substring(propertyMatch[0].length)
219226
filePropertyContent = propertyMatch[0]
220227
} else {
221228
fileContent = fileFullContent
222229
}
223230

231+
232+
224233
const uploadTasks: UploadTask[] = []
225234
// Upload only supports Wikilink format now: ![[image.png]]
226235
const matches = fileContent.matchAll(wikilinkImageRegex)

0 commit comments

Comments
 (0)