Skip to content

Commit

Permalink
Added options to show/hide (1) ribbon icon, (2) status bar, (3) file …
Browse files Browse the repository at this point in the history
…menu options (st3v3nmw#1066)

* Added options in the settings to hide icon and status bar.

* - Enabled the possibility to disable file menu options without restarting Obsidian or reloading the plugin.
- Changed the phrasing for the user from `Disable` to `Enable` to make it easier to understand and aligned with the other options.

* Adjusted the translation in the different languages.

* removing unnecessary logs

* Fixed bug st3v3nmw#1072
  • Loading branch information
alberti42 authored and Newdea committed Sep 25, 2024
1 parent d4bb40c commit ffc08c0
Show file tree
Hide file tree
Showing 16 changed files with 217 additions and 147 deletions.
30 changes: 16 additions & 14 deletions src/generateParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
}
}
Expand All @@ -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 */
Expand All @@ -104,15 +103,15 @@ 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);
}
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);
}
Expand All @@ -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
= "\`\`\`" "\`"*
Expand Down Expand Up @@ -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
= $("<!--SR:" (!"-->" .)+ "-->")
nonempty_text_till_newline
= $non_newline+
= $(inline_code / non_newline)+
text_till_newline
= $non_newline*
Expand Down
8 changes: 4 additions & 4 deletions src/lang/locale/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: "يرجى تقديم رقم صالح",
Expand Down
10 changes: 5 additions & 5 deletions src/lang/locale/cz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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ěď",
Expand Down Expand Up @@ -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.",
Expand Down
12 changes: 6 additions & 6 deletions src/lang/locale/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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.",
Expand Down
13 changes: 9 additions & 4 deletions src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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.",
Expand Down
8 changes: 4 additions & 4 deletions src/lang/locale/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
8 changes: 4 additions & 4 deletions src/lang/locale/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
8 changes: 4 additions & 4 deletions src/lang/locale/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: "有効な数字を入力してください。",
Expand Down
8 changes: 4 additions & 4 deletions src/lang/locale/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: "유효한 숫자를 입력해주세요.",
Expand Down
8 changes: 4 additions & 4 deletions src/lang/locale/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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ę.",
Expand Down
8 changes: 4 additions & 4 deletions src/lang/locale/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
8 changes: 4 additions & 4 deletions src/lang/locale/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: "Пожалуйста, введите подходящее число.",
Expand Down
Loading

0 comments on commit ffc08c0

Please sign in to comment.