chore: allow tags to be overwritten by md header template
Revert "add: auto-sync tags"
This reverts commit 2d5b78f648.
This commit is contained in:
parent
79a761e05b
commit
156c145715
|
|
@ -71,11 +71,6 @@
|
||||||
preference="__prefsPrefix__.syncAttachmentFolder"
|
preference="__prefsPrefix__.syncAttachmentFolder"
|
||||||
></html:input>
|
></html:input>
|
||||||
</hbox>
|
</hbox>
|
||||||
<checkbox
|
|
||||||
data-l10n-id="sync-updateTags"
|
|
||||||
native="true"
|
|
||||||
preference="__prefsPrefix__.sync.updateTags"
|
|
||||||
/>
|
|
||||||
<hbox align="center">
|
<hbox align="center">
|
||||||
<button
|
<button
|
||||||
onclick="Zotero.__addonInstance__.hooks.onShowSyncManager()"
|
onclick="Zotero.__addonInstance__.hooks.onShowSyncManager()"
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,6 @@ sync-period-label = Auto-sync period (seconds)
|
||||||
sync-attachmentFolder-label = Attachment folder
|
sync-attachmentFolder-label = Attachment folder
|
||||||
sync-manager =
|
sync-manager =
|
||||||
.label = Open Sync Manager
|
.label = Open Sync Manager
|
||||||
sync-updateTags =
|
|
||||||
.label = Always update tags
|
|
||||||
.tooltiptext = Keep note tags in sync with tags in YAML header of the markdown file
|
|
||||||
|
|
||||||
template-title = Template
|
template-title = Template
|
||||||
template-editor =
|
template-editor =
|
||||||
.label = Open Template Editor
|
.label = Open Template Editor
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,6 @@ sync-period-label = Intervallo della sincronizzazione automatica (secondi)
|
||||||
sync-attachmentFolder-label = Cartella degli allegati
|
sync-attachmentFolder-label = Cartella degli allegati
|
||||||
sync-manager =
|
sync-manager =
|
||||||
.label = Apri Manager di sincronizzazione
|
.label = Apri Manager di sincronizzazione
|
||||||
sync-updateTags =
|
|
||||||
.label = Aggiorna sempre i tag
|
|
||||||
.tooltiptext = Keep note tags in sync with tags in YAML header of the markdown file
|
|
||||||
|
|
||||||
template-title = Template
|
template-title = Template
|
||||||
template-editor =
|
template-editor =
|
||||||
.label = Apri Editor dei template
|
.label = Apri Editor dei template
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,6 @@ sync-period-label = Авто-синк период (сек)
|
||||||
sync-attachmentFolder-label = Attachment folder
|
sync-attachmentFolder-label = Attachment folder
|
||||||
sync-manager =
|
sync-manager =
|
||||||
.label = Открыть Синк менеджер
|
.label = Открыть Синк менеджер
|
||||||
sync-updateTags =
|
|
||||||
.label = Всегда обновлять теги
|
|
||||||
.tooltiptext = Keep note tags in sync with tags in YAML header of the markdown file
|
|
||||||
|
|
||||||
template-title = Шаблон
|
template-title = Шаблон
|
||||||
template-editor =
|
template-editor =
|
||||||
.label = Открыть редактор шаблонов
|
.label = Открыть редактор шаблонов
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,6 @@ sync-period-label = Oto-Senkronize aralığı (saniye)
|
||||||
sync-attachmentFolder-label = Ek Klasörü
|
sync-attachmentFolder-label = Ek Klasörü
|
||||||
sync-manager =
|
sync-manager =
|
||||||
.label = Senkronizasyon Yönetimini Aç
|
.label = Senkronizasyon Yönetimini Aç
|
||||||
sync-updateTags =
|
|
||||||
.label = Her zaman etiketleri güncelle
|
|
||||||
.tooltiptext = Keep note tags in sync with tags in YAML header of the markdown file
|
|
||||||
|
|
||||||
template-title = Şablon
|
template-title = Şablon
|
||||||
template-editor =
|
template-editor =
|
||||||
.label = Şablon Düzenleyiciyi Aç
|
.label = Şablon Düzenleyiciyi Aç
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,6 @@ sync-period-label = 自动同步周期 (秒)
|
||||||
sync-attachmentFolder-label = 附件文件夹
|
sync-attachmentFolder-label = 附件文件夹
|
||||||
sync-manager =
|
sync-manager =
|
||||||
.label = 打开同步管理器
|
.label = 打开同步管理器
|
||||||
sync-updateTags =
|
|
||||||
.label = 总是更新标签
|
|
||||||
.tooltiptext = 保持笔记标签与 markdown 的 YAML 头标签同步
|
|
||||||
|
|
||||||
template-title = 模板
|
template-title = 模板
|
||||||
template-editor =
|
template-editor =
|
||||||
.label = 打开模板编辑器
|
.label = 打开模板编辑器
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
pref("__prefsPrefix__.syncNoteIds", "");
|
pref("__prefsPrefix__.syncNoteIds", "");
|
||||||
pref("__prefsPrefix__.syncPeriodSeconds", 30);
|
pref("__prefsPrefix__.syncPeriodSeconds", 30);
|
||||||
pref("__prefsPrefix__.syncAttachmentFolder", "attachments");
|
pref("__prefsPrefix__.syncAttachmentFolder", "attachments");
|
||||||
pref("__prefsPrefix__.sync.updateTags", false);
|
|
||||||
|
|
||||||
pref("__prefsPrefix__.autoAnnotation", false);
|
pref("__prefsPrefix__.autoAnnotation", false);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { addLineToNote } from "../../utils/note";
|
import { addLineToNote } from "../../utils/note";
|
||||||
import { config } from "../../../package.json";
|
import { config } from "../../../package.json";
|
||||||
import { getPref } from "../../utils/prefs";
|
|
||||||
|
|
||||||
export async function fromMD(
|
export async function fromMD(
|
||||||
filepath: string,
|
filepath: string,
|
||||||
|
|
@ -68,15 +67,5 @@ export async function fromMD(
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getPref("sync.updateTags")) {
|
|
||||||
const tags = mdStatus.meta?.tags || [];
|
|
||||||
noteItem.setTags(tags);
|
|
||||||
await noteItem.saveTx({
|
|
||||||
notifierData: {
|
|
||||||
autoSyncDelay: Zotero.Notes.AUTO_SYNC_DELAY,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return noteItem;
|
return noteItem;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -246,18 +246,19 @@ async function doCompare(
|
||||||
} else if (MDAhead) {
|
} else if (MDAhead) {
|
||||||
return SyncCode.MDAhead;
|
return SyncCode.MDAhead;
|
||||||
} else {
|
} else {
|
||||||
const maxLastModifiedPeriod = 3000;
|
// const maxLastModifiedPeriod = 3000;
|
||||||
if (
|
// if (
|
||||||
mdStatus.lastmodify &&
|
// mdStatus.lastmodify &&
|
||||||
syncStatus.lastsync &&
|
// syncStatus.lastsync &&
|
||||||
// If the file is modified after the last sync, it's ahead
|
// // If the file is modified after the last sync, it's ahead
|
||||||
Math.abs(mdStatus.lastmodify.getTime() - syncStatus.lastsync) >
|
// Math.abs(mdStatus.lastmodify.getTime() - syncStatus.lastsync) >
|
||||||
maxLastModifiedPeriod
|
// maxLastModifiedPeriod
|
||||||
) {
|
// ) {
|
||||||
return SyncCode.MDAhead;
|
// return SyncCode.MDAhead;
|
||||||
} else {
|
// } else {
|
||||||
return SyncCode.UpToDate;
|
// return SyncCode.UpToDate;
|
||||||
}
|
// }
|
||||||
|
return SyncCode.UpToDate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import YAML = require("yamljs");
|
import YAML = require("yamljs");
|
||||||
import { getNoteLink } from "../../utils/link";
|
import { getNoteLink } from "../../utils/link";
|
||||||
import { getPref } from "../../utils/prefs";
|
|
||||||
|
|
||||||
export { renderTemplatePreview };
|
export { renderTemplatePreview };
|
||||||
|
|
||||||
|
|
@ -56,12 +55,6 @@ async function renderTemplatePreview(
|
||||||
libraryID: data.libraryID,
|
libraryID: data.libraryID,
|
||||||
itemKey: data.key,
|
itemKey: data.key,
|
||||||
});
|
});
|
||||||
if (getPref("sync.updateTags")) {
|
|
||||||
const tags = data.getTags();
|
|
||||||
if (tags.length) {
|
|
||||||
header.tags = tags.map((tag) => tag.tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
html = `<pre>${YAML.stringify(header, 10)}</pre>`;
|
html = `<pre>${YAML.stringify(header, 10)}</pre>`;
|
||||||
}
|
}
|
||||||
} else if (templateName.includes("ExportMDFileContent")) {
|
} else if (templateName.includes("ExportMDFileContent")) {
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ async function note2md(
|
||||||
);
|
);
|
||||||
const cachedHeader = options.cachedYAMLHeader || {};
|
const cachedHeader = options.cachedYAMLHeader || {};
|
||||||
for (const key in cachedHeader) {
|
for (const key in cachedHeader) {
|
||||||
if (key.startsWith("$") && key in header) {
|
if ((key === "tags" || key.startsWith("$")) && key in header) {
|
||||||
// generated header overwrites cached header
|
// generated header overwrites cached header
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -126,13 +126,6 @@ async function note2md(
|
||||||
$libraryID: noteItem.libraryID,
|
$libraryID: noteItem.libraryID,
|
||||||
$itemKey: noteItem.key,
|
$itemKey: noteItem.key,
|
||||||
});
|
});
|
||||||
if (getPref("sync.updateTags")) {
|
|
||||||
const tags = noteItem.getTags();
|
|
||||||
header.tags = [];
|
|
||||||
if (tags.length) {
|
|
||||||
tags.forEach((tag) => header.tags.push(tag.tag));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const yamlFrontMatter = `---\n${YAML.stringify(header, 10)}\n---`;
|
const yamlFrontMatter = `---\n${YAML.stringify(header, 10)}\n---`;
|
||||||
md = `${yamlFrontMatter}\n${md}`;
|
md = `${yamlFrontMatter}\n${md}`;
|
||||||
}
|
}
|
||||||
|
|
@ -199,7 +192,7 @@ async function link2html(
|
||||||
usePosition?: boolean;
|
usePosition?: boolean;
|
||||||
} = {},
|
} = {},
|
||||||
) {
|
) {
|
||||||
ztoolkit.log("link2html", link);
|
ztoolkit.log("link2html", link, options);
|
||||||
const linkParams = getNoteLinkParams(link);
|
const linkParams = getNoteLinkParams(link);
|
||||||
if (!linkParams.noteItem) {
|
if (!linkParams.noteItem) {
|
||||||
return "";
|
return "";
|
||||||
|
|
@ -1230,7 +1223,7 @@ async function processM2NRehypeImageNodes(
|
||||||
src = jointPath(fileDir, src);
|
src = jointPath(fileDir, src);
|
||||||
}
|
}
|
||||||
if (!(await fileExists(src))) {
|
if (!(await fileExists(src))) {
|
||||||
ztoolkit.log("parse image, path invalid", src.slice(0, 50));
|
ztoolkit.log("parse image, path invalid", src);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ declare interface MDStatus {
|
||||||
$version: number;
|
$version: number;
|
||||||
$libraryID?: number;
|
$libraryID?: number;
|
||||||
$itemKey?: string;
|
$itemKey?: string;
|
||||||
tags?: string[];
|
|
||||||
} | null;
|
} | null;
|
||||||
content: string;
|
content: string;
|
||||||
filedir: string;
|
filedir: string;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue