mirror of
https://github.com/woodchen-ink/obsidian-publish-to-discourse.git
synced 2025-07-18 05:42:05 +08:00
回退图片部分正则表达式, 保留activefile修改
This commit is contained in:
parent
836c9d9661
commit
08ad35babe
34
src/main.ts
34
src/main.ts
@ -342,6 +342,12 @@ export default class DiscourseSyncPlugin extends Plugin {
|
||||
}
|
||||
|
||||
await this.app.vault.modify(activeFile, newContent);
|
||||
// 更新 activeFile 对象,确保它反映最新状态
|
||||
this.activeFile = {
|
||||
name: activeFile.basename,
|
||||
content: newContent,
|
||||
postId: postId
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
message: "Error",
|
||||
@ -517,23 +523,21 @@ export default class DiscourseSyncPlugin extends Plugin {
|
||||
}
|
||||
|
||||
private async openCategoryModal() {
|
||||
// 确保activeFile已设置
|
||||
if (!this.activeFile) {
|
||||
const activeFile = this.app.workspace.getActiveFile();
|
||||
if (!activeFile) {
|
||||
new NotifyUser(this.app, t('NO_ACTIVE_FILE')).open();
|
||||
return;
|
||||
}
|
||||
|
||||
const content = await this.app.vault.read(activeFile);
|
||||
const fm = this.getFrontMatter(content);
|
||||
this.activeFile = {
|
||||
name: activeFile.basename,
|
||||
content: content,
|
||||
postId: fm?.discourse_post_id
|
||||
};
|
||||
// 每次都重新获取 activeFile 的最新内容,不使用缓存
|
||||
const activeFile = this.app.workspace.getActiveFile();
|
||||
if (!activeFile) {
|
||||
new NotifyUser(this.app, t('NO_ACTIVE_FILE')).open();
|
||||
return;
|
||||
}
|
||||
|
||||
const content = await this.app.vault.read(activeFile);
|
||||
const fm = this.getFrontMatter(content);
|
||||
this.activeFile = {
|
||||
name: activeFile.basename,
|
||||
content: content,
|
||||
postId: fm?.discourse_post_id
|
||||
};
|
||||
|
||||
const [categories, tags] = await Promise.all([
|
||||
this.fetchCategories(),
|
||||
this.fetchTags()
|
||||
|
Loading…
x
Reference in New Issue
Block a user