mirror of
https://github.com/panatgithub/AnkiHeadingSync.git
synced 2026-07-22 06:51:43 +00:00
chore(settings): refine sync content copy and plugin dist sync
中文: 收束同步内容设置文案,并调整插件构建产物同步逻辑。 English: Refines sync content settings copy and plugin distribution sync behavior.
This commit is contained in:
parent
60ef462ad1
commit
354e25b4ae
7 changed files with 58 additions and 22 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import esbuild from "esbuild";
|
||||
import process from "node:process";
|
||||
import builtins from "builtin-modules";
|
||||
import { copyFile } from "node:fs/promises";
|
||||
|
||||
const banner = `/*\nTHIS IS A GENERATED/BUNDLED FILE BY ESBUILD\n*/`;
|
||||
|
||||
|
|
@ -38,6 +39,7 @@ const context = await esbuild.context({
|
|||
|
||||
if (production) {
|
||||
await context.rebuild();
|
||||
await copyFile(outfile, "main.js");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
55
main.js
55
main.js
File diff suppressed because one or more lines are too long
|
|
@ -1,4 +1,4 @@
|
|||
import { copyFile, mkdir } from "node:fs/promises";
|
||||
import { access, copyFile, mkdir } from "node:fs/promises";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
|
|
@ -11,8 +11,14 @@ const sourceDir = join(rootDir, "dist", "plugin");
|
|||
await mkdir(OBSIDIAN_PLUGIN_DIR, { recursive: true });
|
||||
|
||||
await Promise.all([
|
||||
copyFile(join(sourceDir, "README.md"), join(OBSIDIAN_PLUGIN_DIR, "README.md")),
|
||||
copyFile(join(sourceDir, "main.js"), join(OBSIDIAN_PLUGIN_DIR, "main.js")),
|
||||
copyFile(join(sourceDir, "manifest.json"), join(OBSIDIAN_PLUGIN_DIR, "manifest.json")),
|
||||
copyFile(join(sourceDir, "versions.json"), join(OBSIDIAN_PLUGIN_DIR, "versions.json")),
|
||||
]);
|
||||
]);
|
||||
|
||||
const stylesPath = join(sourceDir, "styles.css");
|
||||
try {
|
||||
await access(stylesPath);
|
||||
await copyFile(stylesPath, join(OBSIDIAN_PLUGIN_DIR, "styles.css"));
|
||||
} catch {
|
||||
// This plugin currently has no stylesheet build artifact.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ export const en = {
|
|||
},
|
||||
},
|
||||
syncContent: {
|
||||
title: "Sync content",
|
||||
title: "Card body sync content",
|
||||
desc: "These options affect rendered content only. Updating them refreshes this card only.",
|
||||
sections: {
|
||||
bodyRange: "1. Choose the card body range",
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ export const zh = {
|
|||
},
|
||||
},
|
||||
syncContent: {
|
||||
title: "同步内容",
|
||||
title: "卡片正文同步内容",
|
||||
desc: "这些选项只影响卡片渲染内容,修改后仅刷新这一张卡片。",
|
||||
sections: {
|
||||
bodyRange: "1. 确定「卡片正文」范围",
|
||||
|
|
|
|||
|
|
@ -746,6 +746,9 @@ describe("PluginSettingTab", () => {
|
|||
tab.display();
|
||||
await expandCard(tab, "sync-content");
|
||||
|
||||
expect(queryByDataset(tab.containerEl, "settingsCardToggle", "sync-content").textContent).toContain("卡片正文同步内容");
|
||||
expect(collectTexts(tab.containerEl)).not.toContain("这些选项只影响卡片渲染内容,修改后仅刷新这一张卡片。");
|
||||
|
||||
const sectionTitles = queryAllByDataset(tab.containerEl, "syncContentSectionTitle").map((element) => element.textContent || element.text);
|
||||
expect(sectionTitles).toEqual([
|
||||
"1. 确定「卡片正文」范围",
|
||||
|
|
|
|||
|
|
@ -495,8 +495,6 @@ export class AnkiHeadingSyncSettingTab extends PluginSettingTab {
|
|||
}
|
||||
|
||||
private renderSyncContentCard(containerEl: HTMLElement): void {
|
||||
containerEl.createEl("p", { text: t("settings.cards.syncContent.desc") });
|
||||
|
||||
const bodyRangeSection = this.createSyncContentSection(containerEl, "body-range", t("settings.cards.syncContent.sections.bodyRange"));
|
||||
new Setting(bodyRangeSection)
|
||||
.setName(t("settings.cardAnswerCutoffMode.name"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue