Skip to content
This repository was archived by the owner on Sep 1, 2024. It is now read-only.

Commit 346eb57

Browse files
committed
fix: fix connector can't be set None
fix #36
1 parent 1bf558a commit 346eb57

File tree

5 files changed

+49
-30
lines changed

5 files changed

+49
-30
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## [2.1.9](https://github.com/JYC333/obsidian-file-structure-format/compare/2.1.7...2.1.9) (2024-08-12)
2+
3+
4+
### Bug Fixes
5+
6+
* fix broken bug in 2.1.7 ([1bf558a](https://github.com/JYC333/obsidian-file-structure-format/commit/1bf558ac726b5070407450dc6437fccccb3f32dc)), closes [#35](https://github.com/JYC333/obsidian-file-structure-format/issues/35)
7+
* fix connector can't be set None ([bcec760](https://github.com/JYC333/obsidian-file-structure-format/commit/bcec760c31f222801c69479bb05b359b5cc32bfd)), closes [#36](https://github.com/JYC333/obsidian-file-structure-format/issues/36)
8+
* no active editor won't break plugin now, set a minimum time for plugin run the second time ([c11e44a](https://github.com/JYC333/obsidian-file-structure-format/commit/c11e44ab14d3f5ab0eac50f568322e5f1bf86b3e)), closes [#29](https://github.com/JYC333/obsidian-file-structure-format/issues/29)
9+
10+
11+
112
## [2.1.8](https://github.com/JYC333/obsidian-attachment-name-formatting/compare/2.1.7...2.1.8) (2023-12-28)
213

314

manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-attachment-name-formatting",
33
"name": "Attachment Name Formatting",
4-
"version": "2.1.8",
4+
"version": "2.1.9",
55
"minAppVersion": "0.12.0",
66
"description": "Obsidian plugin for formatting attachments name (filename attachmentType indexNumber.xxx)",
77
"author": "JYC333",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-attachment-name-formattion",
3-
"version": "2.1.8",
3+
"version": "2.1.9",
44
"description": "Obsidian plugin for formatting attachments name (filename attachmentType indexNumber.xxx)",
55
"main": "main.js",
66
"scripts": {

src/main.ts

+34-27
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,9 @@ export default class AttachmentNameFormatting extends Plugin {
171171
for (const fileIndex in fileList) {
172172
progress.empty();
173173
progress.createEl("span", {
174-
text: `Attachment renaming: ${fileIndex + 1
175-
}/${fileList.length}`,
174+
text: `Attachment renaming: ${
175+
fileIndex + 1
176+
}/${fileList.length}`,
176177
});
177178

178179
await this.handleAttachmentNameFormatting(
@@ -304,7 +305,7 @@ export default class AttachmentNameFormatting extends Plugin {
304305
item.link,
305306
file.basename,
306307
this.settings[
307-
fileType as keyof ANFSettings
308+
fileType as keyof ANFSettings
308309
] as string,
309310
this.settings
310311
) &&
@@ -330,7 +331,7 @@ export default class AttachmentNameFormatting extends Plugin {
330331
attachmentFile.path.replace(
331332
path.extname(attachmentFile.path),
332333
"_copy" +
333-
path.extname(attachmentFile.path)
334+
path.extname(attachmentFile.path)
334335
);
335336

336337
await this.app.vault.adapter.copy(
@@ -385,7 +386,7 @@ export default class AttachmentNameFormatting extends Plugin {
385386
let parent_path = this.vaultAttachmentFolderPath;
386387

387388
if (parent_path === undefined) {
388-
parent_path = '/'
389+
parent_path = "/";
389390
}
390391

391392
if (parent_path.startsWith("./")) {
@@ -398,7 +399,7 @@ export default class AttachmentNameFormatting extends Plugin {
398399
// Fetch subfolder setting
399400
const subfolder =
400401
this.settings.subfolders[
401-
ATTACHMENT_TYPE.indexOf(fileType)
402+
ATTACHMENT_TYPE.indexOf(fileType)
402403
];
403404

404405
const baseNameComponent = [
@@ -466,9 +467,15 @@ export default class AttachmentNameFormatting extends Plugin {
466467

467468
let connectors = [];
468469
for (let i of optionIndex) {
469-
connectors.push(
470-
this.settings.multipleConnectors[i]
471-
);
470+
if (
471+
this.settings.multipleConnectorsEnabled[i]
472+
) {
473+
connectors.push(
474+
this.settings.multipleConnectors[i]
475+
);
476+
} else {
477+
connectors.push("");
478+
}
472479
}
473480

474481
for (let i = 1; i < baseNameComponent.length; i++) {
@@ -516,7 +523,7 @@ export default class AttachmentNameFormatting extends Plugin {
516523
destinationFile.path.substring(
517524
0,
518525
destinationFile.path.length -
519-
destinationFile.name.length
526+
destinationFile.name.length
520527
);
521528
const tmpName =
522529
"tmp" + Date.now() + "_" + destinationFile.name;
@@ -525,11 +532,11 @@ export default class AttachmentNameFormatting extends Plugin {
525532
);
526533
console.log(
527534
'Rename attachment "' +
528-
destinationFile.name +
529-
'" to "' +
530-
destinationFile_path +
531-
tmpName +
532-
'"'
535+
destinationFile.name +
536+
'" to "' +
537+
destinationFile_path +
538+
tmpName +
539+
'"'
533540
);
534541
await this.app.fileManager.renameFile(
535542
destinationFile,
@@ -542,10 +549,10 @@ export default class AttachmentNameFormatting extends Plugin {
542549
);
543550
console.log(
544551
'Rename attachment "' +
545-
attachmentFile.path +
546-
'" to "' +
547-
fullName +
548-
'"'
552+
attachmentFile.path +
553+
'" to "' +
554+
fullName +
555+
'"'
549556
);
550557

551558
const oldName = attachmentFile.name;
@@ -599,8 +606,8 @@ export default class AttachmentNameFormatting extends Plugin {
599606
const file_path = normalizePath(
600607
// @ts-ignore
601608
this.app.vault.adapter.basePath +
602-
"\\" +
603-
attachement.path
609+
"\\" +
610+
attachement.path
604611
);
605612
console.log("Get attachment", file_path);
606613
// Get the attachment and write into JSZip instance
@@ -623,9 +630,9 @@ export default class AttachmentNameFormatting extends Plugin {
623630
normalizePath(
624631
// @ts-ignore
625632
this.app.vault.adapter.basePath +
626-
"/" +
627-
file.basename +
628-
"_Attachments.zip"
633+
"/" +
634+
file.basename +
635+
"_Attachments.zip"
629636
)
630637
)
631638
)
@@ -695,8 +702,8 @@ export default class AttachmentNameFormatting extends Plugin {
695702
const file_path = normalizePath(
696703
// @ts-ignore
697704
this.app.vault.adapter.basePath +
698-
"\\" +
699-
parseLinktext(file.path).path
705+
"\\" +
706+
parseLinktext(file.path).path
700707
);
701708
await FileSystemAdapter.readLocalFile(file_path).then((data) =>
702709
zip.file(normalizePath(file.name), data)
@@ -711,7 +718,7 @@ export default class AttachmentNameFormatting extends Plugin {
711718
normalizePath(
712719
// @ts-ignore
713720
this.app.vault.adapter.basePath +
714-
"/Unused_Attachments.zip"
721+
"/Unused_Attachments.zip"
715722
)
716723
)
717724
)

versions.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@
2929
"2.1.4": "0.12.0",
3030
"2.1.5": "0.12.0",
3131
"2.1.7": "0.12.0",
32-
"2.1.8": "0.12.0"
32+
"2.1.8": "0.12.0",
33+
"2.1.9": "0.12.0"
3334
}

0 commit comments

Comments
 (0)