obsidian-confluence 5.6.12 → 5.6.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/CompletedModal.tsx +124 -132
- package/src/ConfluencePerPageForm.tsx +466 -469
- package/src/ConfluenceSettingTab.ts +108 -108
- package/src/MyBaseClient.ts +193 -200
- package/src/adaptors/obsidian.ts +124 -126
- package/src/custom.d.ts +8 -8
- package/src/main.ts +446 -478
package/src/adaptors/obsidian.ts
CHANGED
|
@@ -1,146 +1,144 @@
|
|
|
1
1
|
import { Vault, MetadataCache, App, TFile } from "obsidian";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
ConfluenceUploadSettings,
|
|
4
|
+
BinaryFile,
|
|
5
|
+
FilesToUpload,
|
|
6
|
+
LoaderAdaptor,
|
|
7
|
+
MarkdownFile,
|
|
8
|
+
ConfluencePageConfig,
|
|
9
9
|
} from "md-confluence-lib";
|
|
10
10
|
import { lookup } from "mime-types";
|
|
11
11
|
|
|
12
12
|
export default class ObsidianAdaptor implements LoaderAdaptor {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
vault: Vault;
|
|
14
|
+
metadataCache: MetadataCache;
|
|
15
|
+
settings: ConfluenceUploadSettings.ConfluenceSettings;
|
|
16
|
+
app: App;
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
constructor(
|
|
19
|
+
vault: Vault,
|
|
20
|
+
metadataCache: MetadataCache,
|
|
21
|
+
settings: ConfluenceUploadSettings.ConfluenceSettings,
|
|
22
|
+
app: App,
|
|
23
|
+
) {
|
|
24
|
+
this.vault = vault;
|
|
25
|
+
this.metadataCache = metadataCache;
|
|
26
|
+
this.settings = settings;
|
|
27
|
+
this.app = app;
|
|
28
|
+
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
async getMarkdownFilesToUpload(): Promise<FilesToUpload> {
|
|
31
|
+
const files = this.vault.getMarkdownFiles();
|
|
32
|
+
const filesToPublish = [];
|
|
33
|
+
for (const file of files) {
|
|
34
|
+
try {
|
|
35
|
+
if (file.path.endsWith(".excalidraw")) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
const fileFM = this.metadataCache.getCache(file.path);
|
|
40
|
+
if (!fileFM) {
|
|
41
|
+
throw new Error("Missing File in Metadata Cache");
|
|
42
|
+
}
|
|
43
|
+
const frontMatter = fileFM.frontmatter;
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const filesToUpload = [];
|
|
45
|
+
if (
|
|
46
|
+
(file.path.startsWith(this.settings.folderToPublish) &&
|
|
47
|
+
(!frontMatter || frontMatter["connie-publish"] !== false)) ||
|
|
48
|
+
(frontMatter && frontMatter["connie-publish"] === true)
|
|
49
|
+
) {
|
|
50
|
+
filesToPublish.push(file);
|
|
51
|
+
}
|
|
52
|
+
} catch {
|
|
53
|
+
//ignore
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const filesToUpload = [];
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
for (const file of filesToPublish) {
|
|
59
|
+
const markdownFile = await this.loadMarkdownFile(file.path);
|
|
60
|
+
filesToUpload.push(markdownFile);
|
|
61
|
+
}
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
return filesToUpload;
|
|
64
|
+
}
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
async loadMarkdownFile(absoluteFilePath: string): Promise<MarkdownFile> {
|
|
67
|
+
const file = this.app.vault.getAbstractFileByPath(absoluteFilePath);
|
|
68
|
+
if (!(file instanceof TFile)) {
|
|
69
|
+
throw new Error("Not a TFile");
|
|
70
|
+
}
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
const fileFM = this.metadataCache.getCache(file.path);
|
|
73
|
+
if (!fileFM) {
|
|
74
|
+
throw new Error("Missing File in Metadata Cache");
|
|
75
|
+
}
|
|
76
|
+
const frontMatter = fileFM.frontmatter;
|
|
78
77
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
const parsedFrontMatter: Record<string, unknown> = {};
|
|
79
|
+
if (frontMatter) {
|
|
80
|
+
for (const [key, value] of Object.entries(frontMatter)) {
|
|
81
|
+
parsedFrontMatter[key] = value;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
85
84
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
return {
|
|
86
|
+
pageTitle: file.basename,
|
|
87
|
+
folderName: file.parent.name,
|
|
88
|
+
absoluteFilePath: file.path,
|
|
89
|
+
fileName: file.name,
|
|
90
|
+
contents: await this.vault.cachedRead(file),
|
|
91
|
+
frontmatter: parsedFrontMatter,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
95
94
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
95
|
+
async readBinary(
|
|
96
|
+
path: string,
|
|
97
|
+
referencedFromFilePath: string,
|
|
98
|
+
): Promise<BinaryFile | false> {
|
|
99
|
+
const testing = this.metadataCache.getFirstLinkpathDest(
|
|
100
|
+
path,
|
|
101
|
+
referencedFromFilePath,
|
|
102
|
+
);
|
|
103
|
+
if (testing) {
|
|
104
|
+
const files = await this.vault.readBinary(testing);
|
|
105
|
+
const mimeType = lookup(testing.extension) || "application/octet-stream";
|
|
106
|
+
return {
|
|
107
|
+
contents: files,
|
|
108
|
+
filePath: testing.path,
|
|
109
|
+
filename: testing.name,
|
|
110
|
+
mimeType: mimeType,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
115
113
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
async updateMarkdownValues(
|
|
117
|
+
absoluteFilePath: string,
|
|
118
|
+
values: Partial<ConfluencePageConfig.ConfluencePerPageAllValues>,
|
|
119
|
+
): Promise<void> {
|
|
120
|
+
const config = ConfluencePageConfig.conniePerPageConfig;
|
|
121
|
+
const file = this.app.vault.getAbstractFileByPath(absoluteFilePath);
|
|
122
|
+
if (file instanceof TFile) {
|
|
123
|
+
this.app.fileManager.processFrontMatter(file, (fm) => {
|
|
124
|
+
for (const propertyKey in config) {
|
|
125
|
+
if (!config.hasOwnProperty(propertyKey)) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
130
128
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
129
|
+
const { key } =
|
|
130
|
+
config[
|
|
131
|
+
propertyKey as keyof ConfluencePageConfig.ConfluencePerPageConfig
|
|
132
|
+
];
|
|
133
|
+
const value =
|
|
134
|
+
values[
|
|
135
|
+
propertyKey as keyof ConfluencePageConfig.ConfluencePerPageAllValues
|
|
136
|
+
];
|
|
137
|
+
if (propertyKey in values) {
|
|
138
|
+
fm[key] = value;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
146
144
|
}
|
package/src/custom.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
declare module "*.txt" {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const content: string;
|
|
3
|
+
export default content;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
declare module "*.json" {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const content: unknown;
|
|
8
|
+
export default content;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
declare module "mermaid_renderer.esbuild" {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const content: Buffer;
|
|
13
|
+
export default content;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
declare module "sort-any" {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
export default function sortAny<T>(item: T): T;
|
|
19
19
|
}
|