Skip to content

Commit

Permalink
Add description to cloze settings
Browse files Browse the repository at this point in the history
  • Loading branch information
MotaOcimar committed Nov 1, 2024
1 parent b4aede7 commit 1e0696e
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 33 deletions.
87 changes: 54 additions & 33 deletions src/gui/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,24 @@ export class SRSettingTab extends PluginSettingTab {
);

containerEl.createEl("h3", { text: t("GROUP_FLASHCARD_SEPARATORS") });
new Setting(containerEl).setName(t("CONVERT_HIGHLIGHTS_TO_CLOZES")).addToggle((toggle) =>
const convertHighlightsToClozesEl = new Setting(containerEl).setName(
t("CONVERT_HIGHLIGHTS_TO_CLOZES"),
);
convertHighlightsToClozesEl.descEl.insertAdjacentHTML(
"beforeend",
t("CONVERT_HIGHLIGHTS_TO_CLOZES_DESC", { defaultPattern: "==[123;;]answer[;;hint]==" }),
);
convertHighlightsToClozesEl.addToggle((toggle) =>
toggle
.setValue(this.plugin.data.settings.convertHighlightsToClozes)
.onChange(async (value) => {
const hightlightPattern = "==[123;;]answer[;;hint]==";
const defaultHightlightPattern = "==[123;;]answer[;;hint]==";
const clozePatternSet = new Set(this.plugin.data.settings.clozePatterns);

if (value) {
clozePatternSet.add(hightlightPattern);
clozePatternSet.add(defaultHightlightPattern);
} else {
clozePatternSet.delete(hightlightPattern);
clozePatternSet.delete(defaultHightlightPattern);
}

this.plugin.data.settings.clozePatterns = [...clozePatternSet];
Expand All @@ -218,17 +225,24 @@ export class SRSettingTab extends PluginSettingTab {
}),
);

new Setting(containerEl).setName(t("CONVERT_BOLD_TEXT_TO_CLOZES")).addToggle((toggle) =>
const convertBoldTextToClozesEl = new Setting(containerEl).setName(
t("CONVERT_BOLD_TEXT_TO_CLOZES"),
);
convertBoldTextToClozesEl.descEl.insertAdjacentHTML(
"beforeend",
t("CONVERT_BOLD_TEXT_TO_CLOZES_DESC", { defaultPattern: "**[123;;]answer[;;hint]**" }),
);
convertBoldTextToClozesEl.addToggle((toggle) =>
toggle
.setValue(this.plugin.data.settings.convertBoldTextToClozes)
.onChange(async (value) => {
const boldPattern = "**[123;;]answer[;;hint]**";
const defaultBoldPattern = "**[123;;]answer[;;hint]**";
const clozePatternSet = new Set(this.plugin.data.settings.clozePatterns);

if (value) {
clozePatternSet.add(boldPattern);
clozePatternSet.add(defaultBoldPattern);
} else {
clozePatternSet.delete(boldPattern);
clozePatternSet.delete(defaultBoldPattern);
}

this.plugin.data.settings.clozePatterns = [...clozePatternSet];
Expand All @@ -239,28 +253,35 @@ export class SRSettingTab extends PluginSettingTab {
}),
);

new Setting(containerEl)
.setName(t("CONVERT_CURLY_BRACKETS_TO_CLOZES"))
.addToggle((toggle) =>
toggle
.setValue(this.plugin.data.settings.convertCurlyBracketsToClozes)
.onChange(async (value) => {
const curlyBracketsPattern = "{{[123;;]answer[;;hint]}}";
const clozePatternSet = new Set(this.plugin.data.settings.clozePatterns);
const convertCurlyBracketsToClozesEl = new Setting(containerEl).setName(
t("CONVERT_CURLY_BRACKETS_TO_CLOZES"),
);
convertCurlyBracketsToClozesEl.descEl.insertAdjacentHTML(
"beforeend",
t("CONVERT_CURLY_BRACKETS_TO_CLOZES_DESC", {
defaultPattern: "{{[123;;]answer[;;hint]}}",
}),
);
convertCurlyBracketsToClozesEl.addToggle((toggle) =>
toggle
.setValue(this.plugin.data.settings.convertCurlyBracketsToClozes)
.onChange(async (value) => {
const defaultCurlyBracketsPattern = "{{[123;;]answer[;;hint]}}";
const clozePatternSet = new Set(this.plugin.data.settings.clozePatterns);

if (value) {
clozePatternSet.add(curlyBracketsPattern);
} else {
clozePatternSet.delete(curlyBracketsPattern);
}
if (value) {
clozePatternSet.add(defaultCurlyBracketsPattern);
} else {
clozePatternSet.delete(defaultCurlyBracketsPattern);
}

this.plugin.data.settings.clozePatterns = [...clozePatternSet];
this.plugin.data.settings.convertCurlyBracketsToClozes = value;
await this.plugin.savePluginData();
this.plugin.data.settings.clozePatterns = [...clozePatternSet];
this.plugin.data.settings.convertCurlyBracketsToClozes = value;
await this.plugin.savePluginData();

this.display();
}),
);
this.display();
}),
);

const clozePatternsEl = new Setting(containerEl).setName(t("CLOZE_PATTERNS"));
clozePatternsEl.descEl.insertAdjacentHTML(
Expand All @@ -278,9 +299,9 @@ export class SRSettingTab extends PluginSettingTab {
.setValue(this.plugin.data.settings.clozePatterns.join("\n"))
.onChange((value) => {
applySettingsUpdate(async () => {
const hightlightPattern = "==[123;;]answer[;;hint]==";
const boldPattern = "**[123;;]answer[;;hint]**";
const curlyBracketsPattern = "{{[123;;]answer[;;hint]}}";
const defaultHightlightPattern = "==[123;;]answer[;;hint]==";
const defaultBoldPattern = "**[123;;]answer[;;hint]**";
const defaultCurlyBracketsPattern = "{{[123;;]answer[;;hint]}}";

const clozePatternSet = new Set(
value
Expand All @@ -289,19 +310,19 @@ export class SRSettingTab extends PluginSettingTab {
.filter((v) => v),
);

if (clozePatternSet.has(hightlightPattern)) {
if (clozePatternSet.has(defaultHightlightPattern)) {
this.plugin.data.settings.convertHighlightsToClozes = true;
} else {
this.plugin.data.settings.convertHighlightsToClozes = false;
}

if (clozePatternSet.has(boldPattern)) {
if (clozePatternSet.has(defaultBoldPattern)) {
this.plugin.data.settings.convertBoldTextToClozes = true;
} else {
this.plugin.data.settings.convertBoldTextToClozes = false;
}

if (clozePatternSet.has(curlyBracketsPattern)) {
if (clozePatternSet.has(defaultCurlyBracketsPattern)) {
this.plugin.data.settings.convertCurlyBracketsToClozes = true;
} else {
this.plugin.data.settings.convertCurlyBracketsToClozes = false;
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,14 @@ export default {
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "Random card from random deck",
DISABLE_CLOZE_CARDS: "؟cloze تعطيل بطاقات",
CONVERT_HIGHLIGHTS_TO_CLOZES: "Convert ==highlights== to clozes",
CONVERT_HIGHLIGHTS_TO_CLOZES_DESC:
'Add/remove the <code>${defaultPattern}</code> from your "Cloze Patterns"',
CONVERT_BOLD_TEXT_TO_CLOZES: "Convert **bolded text** to clozes",
CONVERT_BOLD_TEXT_TO_CLOZES_DESC:
'Add/remove the <code>${defaultPattern}</code> from your "Cloze Patterns"',
CONVERT_CURLY_BRACKETS_TO_CLOZES: "Convert {{curly brackets}} to clozes",
CONVERT_CURLY_BRACKETS_TO_CLOZES_DESC:
'Add/remove the <code>${defaultPattern}</code> from your "Cloze Patterns"',
CLOZE_PATTERNS: "Cloze Patterns",
CLOZE_PATTERNS_DESC:
'Enter cloze patterns separated by newlines. Check the <a href="${docsUrl}">wiki</a> for guidance.',
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/cz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,14 @@ export default {
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "Random card from random deck",
DISABLE_CLOZE_CARDS: "Vypnout cloze kartičky?",
CONVERT_HIGHLIGHTS_TO_CLOZES: "Převést ==zvýraznění== na clozes?",
CONVERT_HIGHLIGHTS_TO_CLOZES_DESC:
'Přidat/odstranit <code>${defaultPattern}</code> z vašich "Cloze vzorů"',
CONVERT_BOLD_TEXT_TO_CLOZES: "Převést **tučný text** na clozes?",
CONVERT_BOLD_TEXT_TO_CLOZES_DESC:
'Přidat/odstranit <code>${defaultPattern}</code> z vašich "Cloze vzorů"',
CONVERT_CURLY_BRACKETS_TO_CLOZES: "Převést {{složené závorky}} na clozes?",
CONVERT_CURLY_BRACKETS_TO_CLOZES_DESC:
'Přidat/odstranit <code>${defaultPattern}</code> z vašich "Cloze vzorů"',
CLOZE_PATTERNS: "Cloze vzory",
CLOZE_PATTERNS_DESC:
'Zadejte cloze vzory oddělené odřádkováním. Check the <a href="${docsUrl}">wiki</a> for guidance.',
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,15 @@ export default {
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "Zufällige Karte von zufälligem Stapel",
DISABLE_CLOZE_CARDS: "Lückentextkarten deaktivieren?",
CONVERT_HIGHLIGHTS_TO_CLOZES: "==Hervorgehobenen== Text in Lückentextkarten umwandeln?",
CONVERT_HIGHLIGHTS_TO_CLOZES_DESC:
'Füge/entferne das <code>${defaultPattern}</code> zu deinen "Lückentextmuster" hinzu',
CONVERT_BOLD_TEXT_TO_CLOZES: "**Fettgedruckten** Text in Lückentextkarten umwandeln?",
CONVERT_BOLD_TEXT_TO_CLOZES_DESC:
'Füge/entferne das <code>${defaultPattern}</code> zu deinen "Lückentextmuster" hinzu',
CONVERT_CURLY_BRACKETS_TO_CLOZES:
"{{Geschweifte Klammern}} Text in Lückentextkarten umwandeln?",
CONVERT_CURLY_BRACKETS_TO_CLOZES_DESC:
'Füge/entferne das <code>${defaultPattern}</code> zu deinen "Lückentextmuster" hinzu',
CLOZE_PATTERNS: "Lückentextmuster",
CLOZE_PATTERNS_DESC:
'Geben Sie Lückentextmuster durch Zeilenumbrüche getrennt ein. Check the <a href="${docsUrl}">wiki</a> for guidance.',
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,14 @@ export default {
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "Random card from random deck",
DISABLE_CLOZE_CARDS: "Disable cloze cards?",
CONVERT_HIGHLIGHTS_TO_CLOZES: "Convert ==highlights== to clozes",
CONVERT_HIGHLIGHTS_TO_CLOZES_DESC:
'Add/remove the <code>${defaultPattern}</code> from your "Cloze Patterns"',
CONVERT_BOLD_TEXT_TO_CLOZES: "Convert **bolded text** to clozes",
CONVERT_BOLD_TEXT_TO_CLOZES_DESC:
'Add/remove the <code>${defaultPattern}</code> from your "Cloze Patterns"',
CONVERT_CURLY_BRACKETS_TO_CLOZES: "Convert {{curly brackets}} to clozes",
CONVERT_CURLY_BRACKETS_TO_CLOZES_DESC:
'Add/remove the <code>${defaultPattern}</code> from your "Cloze Patterns"',
CLOZE_PATTERNS: "Cloze Patterns",
CLOZE_PATTERNS_DESC:
'Enter cloze patterns separated by newlines. Check the <a href="${docsUrl}">wiki</a> for guidance.',
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,14 @@ export default {
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "Random card from random deck",
DISABLE_CLOZE_CARDS: "¿Deshabilitar deletreo de huecos en las tarjetas?",
CONVERT_HIGHLIGHTS_TO_CLOZES: "¿Convertir ==resaltados== a deletreo de huecos?",
CONVERT_HIGHLIGHTS_TO_CLOZES_DESC:
'Añadir/eliminar el <code>${defaultPattern}</code> de tus "Patrones de Deletreo de Huecos"',
CONVERT_BOLD_TEXT_TO_CLOZES: "¿Convertir **texto en negrita** a deletreo de huecos?",
CONVERT_BOLD_TEXT_TO_CLOZES_DESC:
'Añadir/eliminar el <code>${defaultPattern}</code> de tus "Patrones de Deletreo de Huecos"',
CONVERT_CURLY_BRACKETS_TO_CLOZES: "¿Convertir {{llaves rizadas}} a deletreo de huecos?",
CONVERT_CURLY_BRACKETS_TO_CLOZES_DESC:
'Añadir/eliminar el <code>${defaultPattern}</code> de tus "Patrones de Deletreo de Huecos"',
CLOZE_PATTERNS: "Patrones de deletreo de huecos",
CLOZE_PATTERNS_DESC:
'Escriba los patrones de deletreo de huecos separados por saltos de línea. . Check the <a href="${docsUrl}">wiki</a> for guidance.',
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,14 @@ export default {
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "Carte au hasard dans un paquet au hasard",
DISABLE_CLOZE_CARDS: "Désactiver les textes à trous ?",
CONVERT_HIGHLIGHTS_TO_CLOZES: "Convertir ==soulignages== en trous ?",
CONVERT_HIGHLIGHTS_TO_CLOZES_DESC:
'Ajouter/supprimer le <code>${defaultPattern}</code> de vos "Cloze Patterns"',
CONVERT_BOLD_TEXT_TO_CLOZES: "Convertir **gras** en trous ?",
CONVERT_BOLD_TEXT_TO_CLOZES_DESC:
'Ajouter/supprimer le <code>${defaultPattern}</code> de vos "Cloze Patterns"',
CONVERT_CURLY_BRACKETS_TO_CLOZES: "Convertir {{crochets}} en trous ?",
CONVERT_CURLY_BRACKETS_TO_CLOZES_DESC:
'Ajouter/supprimer le <code>${defaultPattern}</code> de vos "Cloze Patterns"',
CLOZE_PATTERNS: "Cloze Patterns",
CLOZE_PATTERNS_DESC:
'Enter cloze patterns separated by newlines. Check the <a href="${docsUrl}">wiki</a> for guidance.',
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,14 @@ export default {
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "Scheda a caso da mazzo a caso",
DISABLE_CLOZE_CARDS: "Disabilita schede con spazi da riempire?",
CONVERT_HIGHLIGHTS_TO_CLOZES: "Convertire ==testo evidenziato== in spazi da riempire?",
CONVERT_HIGHLIGHTS_TO_CLOZES_DESC:
'Aggiungi/rimuovi <code>${defaultPattern}</code> dai tuoi "Modelli per spazi da riempire"',
CONVERT_BOLD_TEXT_TO_CLOZES: "Convertire **testo in grassetto** in spazi da riempire",
CONVERT_BOLD_TEXT_TO_CLOZES_DESC:
'Aggiungi/rimuovi <code>${defaultPattern}</code> dai tuoi "Modelli per spazi da riempire"',
CONVERT_CURLY_BRACKETS_TO_CLOZES: "Convertire {{parentesi graffe}} in spazi da riempire?",
CONVERT_CURLY_BRACKETS_TO_CLOZES_DESC:
'Aggiungi/rimuovi <code>${defaultPattern}</code> dai tuoi "Modelli per spazi da riempire"',
CLOZE_PATTERNS: "Modelli di spazi da riempire",
CLOZE_PATTERNS_DESC:
'Inserisci i modelli di spazi da riempire separati da a capo. Check the <a href="${docsUrl}">wiki</a> for guidance.',
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,14 @@ export default {
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "Random card from random deck",
DISABLE_CLOZE_CARDS: "穴埋めカードを無効化しますか?",
CONVERT_HIGHLIGHTS_TO_CLOZES: "==ハイライト==を穴埋めとして使用しますか?",
CONVERT_HIGHLIGHTS_TO_CLOZES_DESC:
"このオプションを有効化すると、「穴埋めパターン」に${defaultPattern}が追加されます。",
CONVERT_BOLD_TEXT_TO_CLOZES: "**ボールド体**を穴埋めとして使用しますか?",
CONVERT_BOLD_TEXT_TO_CLOZES_DESC:
"このオプションを有効化すると、「穴埋めパターン」に${defaultPattern}が追加されます。",
CONVERT_CURLY_BRACKETS_TO_CLOZES: "{{中括弧}}を穴埋めとして使用しますか?",
CONVERT_CURLY_BRACKETS_TO_CLOZES_DESC:
"このオプションを有効化すると、「穴埋めパターン」に${defaultPattern}が追加されます。",
CLOZE_PATTERNS: "穴埋めパターン",
CLOZE_PATTERNS_DESC:
'改行で区切って穴埋めパターンを入力してください。 Check the <a href="${docsUrl}">wiki</a> for guidance.',
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,14 @@ export default {
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "Random card from random deck",
DISABLE_CLOZE_CARDS: "빈 칸 채우기 카드를 비활성화하시겠습니까?",
CONVERT_HIGHLIGHTS_TO_CLOZES: "==highlights== 를 빈 칸 채우기로 전환하시겠습니까?",
CONVERT_HIGHLIGHTS_TO_CLOZES_DESC:
'"빈 칸 채우기 패턴" 에서 <code>${defaultPattern}</code> 를 추가/제거하시겠습니까?',
CONVERT_BOLD_TEXT_TO_CLOZES: "**bolded text** 를 빈 칸 채우기로 전환하시겠습니까?",
CONVERT_BOLD_TEXT_TO_CLOZES_DESC:
'"빈 칸 채우기 패턴" 에서 <code>${defaultPattern}</code> 를 추가/제거하시겠습니까?',
CONVERT_CURLY_BRACKETS_TO_CLOZES: "{{curly brackets}} 를 빈 칸 채우기로 전환하시겠습니까?",
CONVERT_CURLY_BRACKETS_TO_CLOZES_DESC:
'"빈 칸 채우기 패턴" 에서 <code>${defaultPattern}</code> 를 추가/제거하시겠습니까?',
CLOZE_PATTERNS: "빈 칸 채우기 패턴",
CLOZE_PATTERNS_DESC:
'빈 칸 채우기 패턴을 입력해주세요. 줄바꿈으로 구분합니다. Check the <a href="${docsUrl}">wiki</a> for guidance.',
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,14 @@ export default {
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "Losowa karta z losowej talii",
DISABLE_CLOZE_CARDS: "Wyłączyć karty zamaskowane?",
CONVERT_HIGHLIGHTS_TO_CLOZES: "Konwertować ==podświetlenia== na karty zamaskowane?",
CONVERT_HIGHLIGHTS_TO_CLOZES_DESC:
'Dodaj/usuń <code>${defaultPattern}</code> z "Wzory kart zamaskowanych"',
CONVERT_BOLD_TEXT_TO_CLOZES: "Konwertować pogrubiony tekst na karty zamaskowane?",
CONVERT_BOLD_TEXT_TO_CLOZES_DESC:
'Dodaj/usuń <code>${defaultPattern}</code> z "Wzory kart zamaskowanych"',
CONVERT_CURLY_BRACKETS_TO_CLOZES: "Konwertować {{klamry}} na karty zamaskowane?",
CONVERT_CURLY_BRACKETS_TO_CLOZES_DESC:
'Dodaj/usuń <code>${defaultPattern}</code> z "Wzory kart zamaskowanych"',
CLOZE_PATTERNS: "Wzory kart zamaskowanych",
CLOZE_PATTERNS_DESC:
'Wprowadź wzory kart zamaskowanych oddzielone nowymi liniami. Check the <a href="${docsUrl}">wiki</a> for guidance.',
Expand Down
6 changes: 6 additions & 0 deletions src/lang/locale/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,14 @@ export default {
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "Random card from random deck",
DISABLE_CLOZE_CARDS: "Desabilitar cartas que usam omissão de palavras?",
CONVERT_HIGHLIGHTS_TO_CLOZES: "Converter ==marca-texto== em omissões?",
CONVERT_HIGHLIGHTS_TO_CLOZES_DESC:
'Adiciona/remove o <code>${defaultPattern}</code> dos seus "Padrões de Omissão"',
CONVERT_BOLD_TEXT_TO_CLOZES: "Converter **texto em negrito** em omissões?",
CONVERT_BOLD_TEXT_TO_CLOZES_DESC:
'Adiciona/remove o <code>${defaultPattern}</code> dos seus "Padrões de Omissão"',
CONVERT_CURLY_BRACKETS_TO_CLOZES: "Converter {{chaves}} em omissões?",
CONVERT_CURLY_BRACKETS_TO_CLOZES_DESC:
'Adiciona/remove o <code>${defaultPattern}</code> dos seus "Padrões de Omissão"',
CLOZE_PATTERNS: "Padrões de Omissão",
CLOZE_PATTERNS_DESC:
'Entre os padrões de omissão separados por quebras de linha. Check the <a href="${docsUrl}">wiki</a> for guidance.',
Expand Down
Loading

0 comments on commit 1e0696e

Please sign in to comment.