diff --git a/src/generateParser.ts b/src/generateParser.ts index 9ce11d75..4780027a 100644 --- a/src/generateParser.ts +++ b/src/generateParser.ts @@ -72,11 +72,10 @@ function generateGrammar(options: ParserOptions): string { }; const CardType = options.CardType ? options.CardType : CardTypeFallBack; - CardType.Ignore=null; const createParsedQuestionInfo = options.createParsedQuestionInfo ? options.createParsedQuestionInfo : createParsedQuestionInfoFallBack; function filterBlocks(b) { - return b.filter( (d) => d.cardType === CardType.Ignore ? false : true ) + return b.filter( (d) => d !== null ) } } @@ -86,11 +85,11 @@ main /* The input text to the parser contains arbitrary text, not just card definitions. Hence we fallback to matching on loose_line. The result from loose_line is filtered out by filterBlocks() */ block - = html_comment / inline_rev_card / inline_card / multiline_rev_card / multiline_card / close_card / loose_line + = html_comment / tilde_code / backprime_code / inline_rev_card / inline_card / multiline_rev_card / multiline_card / close_card / loose_line html_comment = $("" (html_comment / .))* "-->" newline?) { - return createParsedQuestionInfo(CardType.Ignore,"",0,0); + return null; } /* Obsidian tag definition: https://help.obsidian.md/Editing+and+formatting/Tags#Tag+format */ @@ -104,7 +103,7 @@ inline_card = e:inline newline? { return e; } inline - = left:(!inline_mark non_newline)+ inline_mark right:text_till_newline (newline annotation)? { + = $(left:(!inline_mark (inline_code / non_newline))+ inline_mark right:text_till_newline (newline annotation)?) { return createParsedQuestionInfo(CardType.SingleLineBasic,text(),location().start.line-1,location().end.line-1); } @@ -112,7 +111,7 @@ inline_rev_card = e:inline_rev newline? { return e; } inline_rev - = left:(!inline_rev_mark non_newline)+ inline_rev_mark right:text_till_newline (newline annotation)? { + = left:(!inline_rev_mark (inline_code / non_newline))+ inline_rev_mark right:text_till_newline (newline annotation)? { return createParsedQuestionInfo(CardType.SingleLineReversed,text(),location().start.line-1,location().end.line-1); } @@ -132,24 +131,27 @@ multiline_before multiline_after = $(!separator_line (tilde_code / backprime_code / text_line))+ +inline_code + = $("\`" (!"\`" .)* "\`") + tilde_code = $( - left:$tilde_marker text_line - t:$(!(middle:$tilde_marker &{ return left.length===middle.length;}) (tilde_code / text_line))* + " "* left:$tilde_marker text_line + (!(middle:$tilde_marker &{ return left.length===middle.length;}) (tilde_code / text_line))* (right:$tilde_marker &{ return left.length===right.length; }) newline - ) + ) { return null; } tilde_marker = "~~~" "~"* backprime_code = $( - left:$backprime_marker text_line - t:$(!(middle:$backprime_marker &{ return left.length===middle.length;}) (backprime_code / text_line))* + " "* left:$backprime_marker text_line + (!(middle:$backprime_marker &{ return left.length===middle.length;}) (backprime_code / text_line))* (right:$backprime_marker &{ return left.length===right.length; }) newline - ) + ) { return null; } backprime_marker = "\`\`\`" "\`"* @@ -239,14 +241,14 @@ text_line1 loose_line = $((text_till_newline newline) / nonempty_text_till_newline) { - return createParsedQuestionInfo(CardType.Ignore,"",0,0); + return null; } annotation = $("" .)+ "-->") nonempty_text_till_newline - = $non_newline+ + = $(inline_code / non_newline)+ text_till_newline = $non_newline* diff --git a/src/lang/locale/ar.ts b/src/lang/locale/ar.ts index 28517d4f..1a125938 100644 --- a/src/lang/locale/ar.ts +++ b/src/lang/locale/ar.ts @@ -127,10 +127,10 @@ Note that this setting is common to both Flashcards and Notes. : أدخل مسا OPEN_RANDOM_NOTE: "افتح ملاحظة عشوائية للمراجعة", OPEN_RANDOM_NOTE_DESC: "(Pagerank) عند تعطيل هذا الخيار ،الملاحظات سيتم ترتيبُها حسب الأهمية", AUTO_NEXT_NOTE: "افتح الملاحظة التالية تلقائيًا بعد المراجعة", - DISABLE_FILE_MENU_REVIEW_OPTIONS: - "تعطيل خيارات المراجعة في قائمة الملفات ، أي المراجعة:السهل الصعب الجيد", - DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC: - "عند تغيير هذا الخيار Obsidian أعد تشغيل , command hotkeys. بعد التعطيل ، يمكنك المراجعة باستخدام", + ENABLE_FILE_MENU_REVIEW_OPTIONS: + "فعّل خيارات المراجعة في قائمة الملف (مثال: مراجعة: سهل، جيد، صعب)", + ENABLE_FILE_MENU_REVIEW_OPTIONS_DESC: + "إذا قمت بتعطيل خيارات المراجعة في قائمة الملف، يمكنك مراجعة ملاحظاتك باستخدام أوامر الإضافة وإذا كنت قد حددتها، باستخدام مفاتيح الاختصار المرتبطة.", MAX_N_DAYS_REVIEW_QUEUE: "الحد الأقصى لعدد الأيام التي يجب عرضها على اللوحة اليمنى", MIN_ONE_DAY: "يجب أن يكون عدد الأيام 1 على الأقل", VALID_NUMBER_WARNING: "يرجى تقديم رقم صالح", diff --git a/src/lang/locale/cz.ts b/src/lang/locale/cz.ts index aca4680c..ea2bf301 100644 --- a/src/lang/locale/cz.ts +++ b/src/lang/locale/cz.ts @@ -10,7 +10,7 @@ export default { SKIP: "Skip", EDIT_CARD: "Edit Card", RESET_CARD_PROGRESS: "Vynulovat pokrok kartičky", - HARD: "Težké", + HARD: "Těžké", GOOD: "Dobré", EASY: "Jednoduché", SHOW_ANSWER: "Ukázat odpověď", @@ -131,10 +131,10 @@ Note that this setting is common to both Flashcards and Notes.`, OPEN_RANDOM_NOTE: "Otevřít náhodnou poznámku pro revizi", OPEN_RANDOM_NOTE_DESC: "Pokud toto vypnete, poznámky budou řazeny dle důležitosti (PageRank).", AUTO_NEXT_NOTE: "Otevřít automaticky další poznámku po dokončení revize", - DISABLE_FILE_MENU_REVIEW_OPTIONS: - "Vypnout volby revize v menu souboru například 'Revize: Jednoduché'", - DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC: - "Po vypnutí můžete používat klávesové zkratky. Restartujte Obsidian po změně nastavení.", + ENABLE_FILE_MENU_REVIEW_OPTIONS: + "Povolte možnosti revize v nabídce souboru (např. Revize: Jednoduché, Dobré, Těžké)", + ENABLE_FILE_MENU_REVIEW_OPTIONS_DESC: + "Pokud v nabídce souboru zakážete možnosti revize, můžete své poznámky revidovat pomocí příkazů pluginu a, pokud jste je definovali, pomocí přiřazených klávesových zkratek.", MAX_N_DAYS_REVIEW_QUEUE: "Maximální počet dní zobrazených v pravém panelu", MIN_ONE_DAY: "Počet dní musí být minimálně 1.", VALID_NUMBER_WARNING: "Prosím zadejte validní číslo.", diff --git a/src/lang/locale/de.ts b/src/lang/locale/de.ts index a16afadd..4b76efff 100644 --- a/src/lang/locale/de.ts +++ b/src/lang/locale/de.ts @@ -28,8 +28,8 @@ export default { // main.ts OPEN_NOTE_FOR_REVIEW: "Notiz zur Wiederholung öffnen", REVIEW_CARDS: "Lernkarten wiederholen", - REVIEW_DIFFICULTY_FILE_MENU: "Notiz abschliessen als: ${difficulty}", - REVIEW_NOTE_DIFFICULTY_CMD: "Notiz abschliessen als: ${difficulty}", + REVIEW_DIFFICULTY_FILE_MENU: "Notizen wiederholen als: ${difficulty}", + REVIEW_NOTE_DIFFICULTY_CMD: "Notizen wiederholen als: ${difficulty}", REVIEW_ALL_CARDS: "Alle Lernkarten wiederholen", CRAM_ALL_CARDS: "Wähle ein Stapel zum pauken", REVIEW_CARDS_IN_NOTE: "Lernkarten in dieser Notiz wiederholen", @@ -145,10 +145,10 @@ Note that this setting is common to both Flashcards and Notes.`, OPEN_RANDOM_NOTE_DESC: "Wenn dies deaktiviert wird, dann werden die Notizen nach Wichtigkeit wiederholt (PageRank).", AUTO_NEXT_NOTE: "Nach einer Wiederholung automatisch die nächste Karte öffnen", - DISABLE_FILE_MENU_REVIEW_OPTIONS: - "Optionen zur Wiederholung im Menü einer Datei deaktivieren. Bsp. Wiederholen: Einfach Gut Schwer", - DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC: - "Nach dem Deaktivieren können die Tastenkürzel zur Wiederholung verwendet werden. Obsidian muss nach einer Änderung neu geladen weren.", + ENABLE_FILE_MENU_REVIEW_OPTIONS: + "Aktiviere die Überprüfungsoptionen im Dateimenü (z. B. Notizen wiederholen als: Einfach, Gut, Schwer)", + ENABLE_FILE_MENU_REVIEW_OPTIONS_DESC: + "Wenn du die Überprüfungsoptionen im Dateimenü deaktivierst, kannst du deine Notizen mit den Plugin-Befehlen und, falls definiert, den zugehörigen Tastenkombinationen überprüfen.", MAX_N_DAYS_REVIEW_QUEUE: "Maximale Anzahl anstehender Notizen, die im rechten Fensterbereich angezeigt werden", MIN_ONE_DAY: "Anzahl der Tage muss mindestens 1 sein.", diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index 8152b319..e8f9bf22 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -73,6 +73,7 @@ export default { FOLDERS_TO_IGNORE: "Folders to ignore", FOLDERS_TO_IGNORE_DESC: `Enter folder paths separated by newlines e.g. Templates Meta/Scripts. Note that this setting is common to both Flashcards and Notes.`, + OBSIDIAN_INTEGRATION: "Integration into Obsidian", FLASHCARDS: "Flashcards", FLASHCARD_EASY_LABEL: "Easy Button Text", FLASHCARD_GOOD_LABEL: "Good Button Text", @@ -130,14 +131,18 @@ Note that this setting is common to both Flashcards and Notes.`, OPEN_RANDOM_NOTE: "Open a random note for review", OPEN_RANDOM_NOTE_DESC: "When you turn this off, notes are ordered by importance (PageRank).", AUTO_NEXT_NOTE: "Open next note automatically after a review", - DISABLE_FILE_MENU_REVIEW_OPTIONS: - "Disable review options in the file menu i.e. Review: Easy Good Hard", - DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC: - "After disabling, you can review using the command hotkeys. Reload Obsidian after changing this.", MAX_N_DAYS_REVIEW_QUEUE: "Maximum number of days to display on right panel", MIN_ONE_DAY: "The number of days must be at least 1.", VALID_NUMBER_WARNING: "Please provide a valid number.", UI_PREFERENCES: "UI Preferences", + SHOW_STATUS_BAR: "Show status bar", + SHOW_STATUS_BAR_DESC: "Turn this off to hide the flashcard's review status in Obsidian's status bar", + SHOW_RIBBON_ICON: "Show icon in the ribbon bar", + SHOW_RIBBON_ICON_DESC: "Turn this off to hide the plugin icon from Obsidian's ribbon bar", + ENABLE_FILE_MENU_REVIEW_OPTIONS: + "Enable the review options in the file menu (e.g. Review: Easy, Good, Hard)", + ENABLE_FILE_MENU_REVIEW_OPTIONS_DESC: + "If you disable the review options in the file menu, you can review your notes using the plugin commands and, if you defined them, the associated command hotkeys.", INITIALLY_EXPAND_SUBDECKS_IN_TREE: "Deck trees should be initially displayed as expanded", INITIALLY_EXPAND_SUBDECKS_IN_TREE_DESC: "Turn this off to collapse nested decks in the same card. Useful if you have cards which belong to many decks in the same file.", diff --git a/src/lang/locale/es.ts b/src/lang/locale/es.ts index e679f10b..a954a5f3 100644 --- a/src/lang/locale/es.ts +++ b/src/lang/locale/es.ts @@ -135,10 +135,10 @@ Note that this setting is common to both Flashcards and Notes.`, OPEN_RANDOM_NOTE_DESC: "Cuando deshabilita esto, las notas son ordenadas por importancia (Algoritmo PageRank).", AUTO_NEXT_NOTE: "Abrir la siguiente nota automáticamente después de una revisión", - DISABLE_FILE_MENU_REVIEW_OPTIONS: - "Deshabilitar opciones de revisión en el menú de archivo, por ejemplo, Revisión: Fácil Bien Difícil", - DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC: - "Después de deshabilitarlo, puede hacer las revisiones utilizando atajos de teclado. Reinicie Obsidian después de cambiar esto.", + ENABLE_FILE_MENU_REVIEW_OPTIONS: + "Habilita las opciones de revisión en el menú Archivo (por ejemplo: Revisar: Fácil, Bien, Difícil)", + ENABLE_FILE_MENU_REVIEW_OPTIONS_DESC: + "Si desactivas las opciones de revisión en el menú Archivo, puedes revisar tus notas usando los comandos del plugin y, si los definiste, las teclas rápidas asociadas.", MAX_N_DAYS_REVIEW_QUEUE: "Número máximo de días a mostrar en el panel derecho.", MIN_ONE_DAY: "El número de días debe ser al menos uno.", VALID_NUMBER_WARNING: "Por favor especifique un número válido.", diff --git a/src/lang/locale/it.ts b/src/lang/locale/it.ts index e8164498..451eb9d7 100644 --- a/src/lang/locale/it.ts +++ b/src/lang/locale/it.ts @@ -138,10 +138,10 @@ Note that this setting is common to both Flashcards and Notes.`, OPEN_RANDOM_NOTE_DESC: "Quando lo disabiliti, le note saranno ordinate per importanza (PageRank).", AUTO_NEXT_NOTE: "Apri la prossima nota automaticamente dopo la revisione", - DISABLE_FILE_MENU_REVIEW_OPTIONS: - "Disabilita le opzioni di revisioni nel menù di file, per esempio Revisione: Facile Buono Difficile", - DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC: - "Dopo avermi disattivato, puoi iniziare una revisione con le combinazioni di testi per il comando. Riavvia Obsidian dopo avermi cambiato.", + ENABLE_FILE_MENU_REVIEW_OPTIONS: + "Abilita le opzioni di revisione nel menu File (es.: Rivisita: Facile, Buono, Difficile)", + ENABLE_FILE_MENU_REVIEW_OPTIONS_DESC: + "Se disabiliti le opzioni di revisione nel menu File, puoi rivedere le tue note utilizzando i comandi del plugin e, se li hai definiti, le scorciatoie da tastiera associate.", MAX_N_DAYS_REVIEW_QUEUE: "Numero di giorni massimi da visualizzare nel pannello di destra", MIN_ONE_DAY: "Il numero di giorni deve essere almeno 1.", VALID_NUMBER_WARNING: "Per favore, mettere un numero valido.", diff --git a/src/lang/locale/ja.ts b/src/lang/locale/ja.ts index f97c3c45..ab700984 100644 --- a/src/lang/locale/ja.ts +++ b/src/lang/locale/ja.ts @@ -135,10 +135,10 @@ Note that this setting is common to both Flashcards and Notes.`, OPEN_RANDOM_NOTE_DESC: "このオプションが無効化されている状態では、ノートは重要度(ページランク)による順番で表示されます。", AUTO_NEXT_NOTE: "レビュー後に次のノートを自動的に開く", - DISABLE_FILE_MENU_REVIEW_OPTIONS: - "ファイルメニューでのレビューオプションを無効化(「レビュー: Easy」等の項目を非表示にする)", - DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC: - "無効化した後、コマンドホットキーを使ってレビューすることが可能になります。このオプションを変更した場合にはObsidianをリロードしてください。", + ENABLE_FILE_MENU_REVIEW_OPTIONS: + "ファイルメニューでレビューオプションを有効にしてください(例: Easy, Good, Hard)", + ENABLE_FILE_MENU_REVIEW_OPTIONS_DESC: + "ファイルメニューでレビューオプションを無効にした場合、プラグインコマンドや、設定している場合は対応するホットキーを使用してメモをレビューできます。", MAX_N_DAYS_REVIEW_QUEUE: "右パネルに表示する最大の日数", MIN_ONE_DAY: "日数には1以上の数字を指定してください。", VALID_NUMBER_WARNING: "有効な数字を入力してください。", diff --git a/src/lang/locale/ko.ts b/src/lang/locale/ko.ts index e5390321..3ebdd42c 100644 --- a/src/lang/locale/ko.ts +++ b/src/lang/locale/ko.ts @@ -132,10 +132,10 @@ Note that this setting is common to both Flashcards and Notes.`, OPEN_RANDOM_NOTE: "리뷰를 위해 랜덤 노트를 엽니다.", OPEN_RANDOM_NOTE_DESC: "이 옵션이 꺼져있으면, 노트는 중요도(페이지 랭크)에 따라 정렬됩니다.", AUTO_NEXT_NOTE: "리뷰 후에 다음 노트를 자동으로 엽니다.", - DISABLE_FILE_MENU_REVIEW_OPTIONS: - "파일 메뉴에서의 리뷰 옵션을 비활성화 합니다. 예) 리뷰: Easy Good Hard", - DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC: - "이 옵션을 비활성화 한 후, 명령 단축키를 이용해 리뷰하실 수 있습니다. 이 옵션을 변경한 후에 옵시디언을 새로고침 하십시오.", + ENABLE_FILE_MENU_REVIEW_OPTIONS: + "파일 메뉴에서 검토 옵션을 활성화하세요 (예: 검토: 쉬움, 좋음, 어려움)", + ENABLE_FILE_MENU_REVIEW_OPTIONS_DESC: + "파일 메뉴에서 검토 옵션을 비활성화하면 플러그인 명령을 사용해 노트를 검토할 수 있으며, 정의된 경우에는 관련된 단축키도 사용할 수 있습니다.", MAX_N_DAYS_REVIEW_QUEUE: "오른쪽 패널에 표시할 최대 일수", MIN_ONE_DAY: "적어도 1이상이어야 합니다.", VALID_NUMBER_WARNING: "유효한 숫자를 입력해주세요.", diff --git a/src/lang/locale/pl.ts b/src/lang/locale/pl.ts index 8c9a59d5..4d987597 100644 --- a/src/lang/locale/pl.ts +++ b/src/lang/locale/pl.ts @@ -136,10 +136,10 @@ Note that this setting is common to both Flashcards and Notes.`, OPEN_RANDOM_NOTE_DESC: "Po wyłączeniu tej opcji notatki są uporządkowane według istotności (PageRank).", AUTO_NEXT_NOTE: "Automatycznie otwierać następną notatkę po przeglądzie", - DISABLE_FILE_MENU_REVIEW_OPTIONS: - "Wyłączyć opcje przeglądu w menu pliku, tj. Przegląd: Łatwe Dobrze Trudne", - DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC: - "Po wyłączeniu możesz przeglądać za pomocą skrótów klawiszowych. Po zmianie tej opcji konieczne jest ponowne załadowanie Obsidian.", + ENABLE_FILE_MENU_REVIEW_OPTIONS: + "Wyłączyć opcje przeglądu w menu pliku, tj. Przeglądaj: Łatwe Dobrze Trudne", + ENABLE_FILE_MENU_REVIEW_OPTIONS_DESC: + "Jeśli wyłączysz opcje przeglądu w menu Plik, możesz przeglądać swoje notatki za pomocą poleceń wtyczki i, jeśli je zdefiniowałeś, przypisanych skrótów klawiszowych.", MAX_N_DAYS_REVIEW_QUEUE: "Maksymalna liczba dni do wyświetlenia w panelu prawym", MIN_ONE_DAY: "Liczba dni musi wynosić co najmniej 1.", VALID_NUMBER_WARNING: "Podaj prawidłową liczbę.", diff --git a/src/lang/locale/pt-br.ts b/src/lang/locale/pt-br.ts index 0e66cb1e..2264427f 100644 --- a/src/lang/locale/pt-br.ts +++ b/src/lang/locale/pt-br.ts @@ -135,10 +135,10 @@ Note that this setting is common to both Flashcards and Notes.`, OPEN_RANDOM_NOTE_DESC: "Quando você desabilitar isso, as notas vão ser ordenadas por importância (PageRank).", AUTO_NEXT_NOTE: "Abrir a próxima nota automaticamente depois de uma revisão", - DISABLE_FILE_MENU_REVIEW_OPTIONS: - "Desabilitar opções de revisão no menu de arquivos ex: Revisão: Fácil OK Difícil", - DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC: - "Depois de desabilitar, você pode revisar usando os atalhos de comando. Reinicie Obsidian depois de mudar isso.", + ENABLE_FILE_MENU_REVIEW_OPTIONS: + "Ative as opções de revisão no menu Arquivo (ex.: Revisão: Fácil, OK, Difícil)", + ENABLE_FILE_MENU_REVIEW_OPTIONS_DESC: + "Se você desativar as opções de revisão no menu Arquivo, poderá revisar suas anotações usando os comandos do plugin e, se os tiver definido, as teclas de atalho associadas.", MAX_N_DAYS_REVIEW_QUEUE: "Número máximo de dias para exibir no painel direito", MIN_ONE_DAY: "O número de dias deve ser pelo menos 1.", VALID_NUMBER_WARNING: "Por favor Insira um número válido.", diff --git a/src/lang/locale/ru.ts b/src/lang/locale/ru.ts index dec63f83..dc99a619 100644 --- a/src/lang/locale/ru.ts +++ b/src/lang/locale/ru.ts @@ -142,10 +142,10 @@ Note that this setting is common to both Flashcards and Notes.`, OPEN_RANDOM_NOTE: "Открыть случайную заметку для изучения", OPEN_RANDOM_NOTE_DESC: "Если выключить, то заметки будут отсортированы по важности (PageRank).", AUTO_NEXT_NOTE: "После изучения автоматически открывать следующую заметку", - DISABLE_FILE_MENU_REVIEW_OPTIONS: - "Выключить выбор сложности изучения в меню файла, т.е.: Изучение: Легко Нормально Сложно", - DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC: - "После выключения вы сможете изучать карточки при помощи горячих клавиш. Перезагрузите Obsidian после изменения этой настройки.", + ENABLE_FILE_MENU_REVIEW_OPTIONS: + "Включите параметры обзора в меню Файл (т.е.: Изучение: Легко, Нормально, Сложно)", + ENABLE_FILE_MENU_REVIEW_OPTIONS_DESC: + "Если вы отключите параметры обзора в меню Файл, вы сможете просматривать свои заметки с помощью команд плагина и, если вы их задали, соответствующих горячих клавиш.", MAX_N_DAYS_REVIEW_QUEUE: "Наибольшее количество дней для отображение на панели справа", MIN_ONE_DAY: "Количество дней не меньше 1.", VALID_NUMBER_WARNING: "Пожалуйста, введите подходящее число.", diff --git a/src/lang/locale/zh-cn.ts b/src/lang/locale/zh-cn.ts index 383a4bba..a15fd3d2 100644 --- a/src/lang/locale/zh-cn.ts +++ b/src/lang/locale/zh-cn.ts @@ -122,9 +122,9 @@ Note that this setting is common to both Flashcards and Notes.`, OPEN_RANDOM_NOTE: "复习随机笔记", OPEN_RANDOM_NOTE_DESC: "关闭此选项,笔记将以重要度(PageRank)排序。", AUTO_NEXT_NOTE: "复习后自动打开下一个笔记", - DISABLE_FILE_MENU_REVIEW_OPTIONS: "关闭文件选单中的复习选项 例如:复习:简单 记得 较难", - DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC: - "关闭此选项后你可以使用快捷键开始复习。重新启动Obsidian使本选项生效。", + ENABLE_FILE_MENU_REVIEW_OPTIONS: "请在文件菜单中启用复习选项(例如:复习:简单、良好、困难", + ENABLE_FILE_MENU_REVIEW_OPTIONS_DESC: + "如果您在文件菜单中禁用复习选项,您可以使用插件命令来复习笔记,如果您定义了相关快捷键,也可以使用它们。", MAX_N_DAYS_REVIEW_QUEUE: "右边栏中显示的最大天数", MIN_ONE_DAY: "天数最小值为1", VALID_NUMBER_WARNING: "请输入有效的数字。", diff --git a/src/lang/locale/zh-tw.ts b/src/lang/locale/zh-tw.ts index 640b578f..adab7fc9 100644 --- a/src/lang/locale/zh-tw.ts +++ b/src/lang/locale/zh-tw.ts @@ -122,8 +122,8 @@ Note that this setting is common to both Flashcards and Notes.`, OPEN_RANDOM_NOTE: "復習隨機筆記", OPEN_RANDOM_NOTE_DESC: "關閉此選項,筆記將以重要度(PageRank)排序。", AUTO_NEXT_NOTE: "復習後自動打開下一個筆記", - DISABLE_FILE_MENU_REVIEW_OPTIONS: "關閉檔案選單中的復習選項 例如:復習:簡單 記得 較難", - DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC: "關閉檔案選單的復習選項,例如:復習: 簡單 記得 較難。", + ENABLE_FILE_MENU_REVIEW_OPTIONS: "請在檔案選單中啟用檢視選項(例如:檢視:簡單、記得、較難)", + ENABLE_FILE_MENU_REVIEW_OPTIONS_DESC: "如果您在檔案選單中停用檢視選項,您可以使用插件指令檢視筆記,如果有設定,也可以使用相關的快捷鍵。", MAX_N_DAYS_REVIEW_QUEUE: "右邊面板顯示的最大天數", MIN_ONE_DAY: "天數最小值為1", VALID_NUMBER_WARNING: "請輸入有效的數字。", diff --git a/src/main.ts b/src/main.ts index 42dcfd06..3d144efa 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -import { Notice, Plugin, TAbstractFile, TFile } from "obsidian"; +import { EventRef, Menu, Notice, Plugin, TAbstractFile, TFile, WorkspaceLeaf } from "obsidian"; import { SRSettingTab, SRSettings, @@ -47,7 +47,6 @@ import { setDebugParser } from "./parser"; import { generateParser } from "./generateParser"; export default class SRPlugin extends Plugin { - private statusBar: HTMLElement; public data: PluginData; private osrAppCore: OsrAppCore; private osrSidebar: OsrSidebar; @@ -55,6 +54,10 @@ export default class SRPlugin extends Plugin { private debouncedGenerateParserTimeout: number | null = null; + private ribbonIcon: HTMLElement | null = null; + private statusBar: HTMLElement | null = null; + private fileMenuHandler:((menu:Menu,file:TAbstractFile, source:string, leaf?:WorkspaceLeaf)=>void); + async onload(): Promise { console.log("onload: Branch: feat-878-support-multiple-sched, Date: 2024-07-24"); await this.loadPluginData(); @@ -92,29 +95,11 @@ export default class SRPlugin extends Plugin { ); appIcon(); - this.statusBar = this.addStatusBarItem(); - this.statusBar.classList.add("mod-clickable"); - this.statusBar.setAttribute("aria-label", t("OPEN_NOTE_FOR_REVIEW")); - this.statusBar.setAttribute("aria-label-position", "top"); - this.statusBar.addEventListener("click", async () => { - if (!this.osrAppCore.syncLock) { - await this.sync(); - this.nextNoteReviewHandler.reviewNextNoteModal(); - } - }); - - this.addRibbonIcon("SpacedRepIcon", t("REVIEW_CARDS"), async () => { - if (!this.osrAppCore.syncLock) { - await this.sync(); - this.openFlashcardModal( - this.osrAppCore.reviewableDeckTree, - this.osrAppCore.remainingDeckTree, - FlashcardReviewMode.Review, - ); - } - }); + this.showStatusBar(this.data.settings.showStatusBar); + + this.showRibbonIcon(this.data.settings.showRibbonIcon); - this.addFileMenuItems(); + this.showFileMenuItems(!this.data.settings.disableFileMenuReviewOptions); this.addPluginCommands(); @@ -131,49 +116,54 @@ export default class SRPlugin extends Plugin { }); } - private addFileMenuItems() { - if (!this.data.settings.disableFileMenuReviewOptions) { - this.registerEvent( - this.app.workspace.on("file-menu", (menu, fileish: TAbstractFile) => { - if (fileish instanceof TFile && fileish.extension === "md") { - menu.addItem((item) => { - item.setTitle( - t("REVIEW_DIFFICULTY_FILE_MENU", { - difficulty: this.data.settings.flashcardEasyText, - }), - ) - .setIcon("SpacedRepIcon") - .onClick(() => { - this.saveNoteReviewResponse(fileish, ReviewResponse.Easy); - }); - }); - - menu.addItem((item) => { - item.setTitle( - t("REVIEW_DIFFICULTY_FILE_MENU", { - difficulty: this.data.settings.flashcardGoodText, - }), - ) - .setIcon("SpacedRepIcon") - .onClick(() => { - this.saveNoteReviewResponse(fileish, ReviewResponse.Good); - }); - }); - - menu.addItem((item) => { - item.setTitle( - t("REVIEW_DIFFICULTY_FILE_MENU", { - difficulty: this.data.settings.flashcardHardText, - }), - ) - .setIcon("SpacedRepIcon") - .onClick(() => { - this.saveNoteReviewResponse(fileish, ReviewResponse.Hard); - }); - }); - } - }), - ); + showFileMenuItems(status:boolean) { + + if(this.fileMenuHandler===undefined) { // define the handler if it was not defined yet + this.fileMenuHandler = (menu, fileish: TAbstractFile) => { + if (fileish instanceof TFile && fileish.extension === "md") { + menu.addItem((item) => { + item.setTitle( + t("REVIEW_DIFFICULTY_FILE_MENU", { + difficulty: this.data.settings.flashcardEasyText, + }), + ) + .setIcon("SpacedRepIcon") + .onClick(() => { + this.saveNoteReviewResponse(fileish, ReviewResponse.Easy); + }); + }); + + menu.addItem((item) => { + item.setTitle( + t("REVIEW_DIFFICULTY_FILE_MENU", { + difficulty: this.data.settings.flashcardGoodText, + }), + ) + .setIcon("SpacedRepIcon") + .onClick(() => { + this.saveNoteReviewResponse(fileish, ReviewResponse.Good); + }); + }); + + menu.addItem((item) => { + item.setTitle( + t("REVIEW_DIFFICULTY_FILE_MENU", { + difficulty: this.data.settings.flashcardHardText, + }), + ) + .setIcon("SpacedRepIcon") + .onClick(() => { + this.saveNoteReviewResponse(fileish, ReviewResponse.Hard); + }); + }); + } + }; + } + + if(status){ + this.registerEvent(this.app.workspace.on("file-menu", this.fileMenuHandler)); + } else { + this.app.workspace.off("file-menu", this.fileMenuHandler); } } @@ -480,4 +470,44 @@ export default class SRPlugin extends Plugin { this.debouncedGenerateParserTimeout = null; }, timeout_ms); } + + showRibbonIcon(status:boolean) { + if(!this.ribbonIcon) { // if it does not exit, we create it + this.ribbonIcon = this.addRibbonIcon("SpacedRepIcon", t("REVIEW_CARDS"), async () => { + if (!this.osrAppCore.syncLock) { + await this.sync(); + this.openFlashcardModal( + this.osrAppCore.reviewableDeckTree, + this.osrAppCore.remainingDeckTree, + FlashcardReviewMode.Review, + ); + } + }); + } + if(status) { + this.ribbonIcon.style.display = ""; + } else { + this.ribbonIcon.style.display = "none"; + } + } + + showStatusBar(status:boolean) { + if(!this.statusBar) { // if it does not exit, we create it + this.statusBar = this.addStatusBarItem(); + this.statusBar.classList.add("mod-clickable"); + this.statusBar.setAttribute("aria-label", t("OPEN_NOTE_FOR_REVIEW")); + this.statusBar.setAttribute("aria-label-position", "top"); + this.statusBar.addEventListener("click", async () => { + if (!this.osrAppCore.syncLock) { + await this.sync(); + this.nextNoteReviewHandler.reviewNextNoteModal(); + } + }); + } + if(status) { + this.statusBar.style.display = ""; + } else { + this.statusBar.style.display = "none"; + } + } } diff --git a/src/settings.ts b/src/settings.ts index 2a0786b8..2eea5da6 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -37,6 +37,8 @@ export interface SRSettings { disableFileMenuReviewOptions: boolean; maxNDaysNotesReviewQueue: number; // UI preferences + showRibbonIcon: boolean; + showStatusBar: boolean; initiallyExpandAllSubdecksInTree: boolean; // algorithm baseEase: number; @@ -83,6 +85,8 @@ export const DEFAULT_SETTINGS: SRSettings = { disableFileMenuReviewOptions: false, maxNDaysNotesReviewQueue: 365, // UI settings + showRibbonIcon: true, + showStatusBar: true, initiallyExpandAllSubdecksInTree: false, // algorithm baseEase: 250, @@ -173,11 +177,11 @@ export class SRSettingTab extends PluginSettingTab { // eslint-disable-next-line @typescript-eslint/no-explicit-any hide(): any { - console.log("SRSettingTab: hide()"); + // console.log("SRSettingTab: hide()"); } display(): void { - console.log("SRSettingTab: display()"); + // console.log("SRSettingTab: display()"); const { containerEl } = this; containerEl.empty(); @@ -569,18 +573,6 @@ export class SRSettingTab extends PluginSettingTab { }), ); - new Setting(containerEl) - .setName(t("DISABLE_FILE_MENU_REVIEW_OPTIONS")) - .setDesc(t("DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC")) - .addToggle((toggle) => - toggle - .setValue(this.plugin.data.settings.disableFileMenuReviewOptions) - .onChange(async (value) => { - this.plugin.data.settings.disableFileMenuReviewOptions = value; - await this.plugin.savePluginData(); - }), - ); - new Setting(containerEl) .setName(t("MAX_N_DAYS_REVIEW_QUEUE")) .addText((text) => @@ -639,6 +631,47 @@ export class SRSettingTab extends PluginSettingTab { } private async tabUiPreferences(containerEl: HTMLElement): Promise { + + containerEl.createEl("h3", { text: t("OBSIDIAN_INTEGRATION") }); + new Setting(containerEl) + .setName(t("SHOW_RIBBON_ICON")) + .setDesc(t("SHOW_RIBBON_ICON_DESC")) + .addToggle((toggle) => + toggle + .setValue(this.plugin.data.settings.showRibbonIcon) + .onChange(async (value) => { + this.plugin.data.settings.showRibbonIcon = value; + await this.plugin.savePluginData(); + this.plugin.showRibbonIcon(value); + }), + ); + + new Setting(containerEl) + .setName(t("SHOW_STATUS_BAR")) + .setDesc(t("SHOW_STATUS_BAR_DESC")) + .addToggle((toggle) => + toggle + .setValue(this.plugin.data.settings.showStatusBar) + .onChange(async (value) => { + this.plugin.data.settings.showStatusBar = value; + await this.plugin.savePluginData(); + this.plugin.showStatusBar(value); + }), + ); + + new Setting(containerEl) + .setName(t("ENABLE_FILE_MENU_REVIEW_OPTIONS")) + .setDesc(t("ENABLE_FILE_MENU_REVIEW_OPTIONS_DESC")) + .addToggle((toggle) => + toggle + .setValue(!this.plugin.data.settings.disableFileMenuReviewOptions) + .onChange(async (value) => { + this.plugin.data.settings.disableFileMenuReviewOptions = !value; + await this.plugin.savePluginData(); + this.plugin.showFileMenuItems(value); + }), + ); + containerEl.createEl("h3", { text: t("FLASHCARDS") }); new Setting(containerEl) .setName(t("INITIALLY_EXPAND_SUBDECKS_IN_TREE"))