mirror of
https://github.com/gosticks/flashcards-obsidian.git
synced 2025-10-16 12:05:33 +00:00
Merge branch 'ivan-lednev-default-tag' into main
This commit is contained in:
commit
c5bb409d94
13
.github/workflows/greetings.yml
vendored
Normal file
13
.github/workflows/greetings.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
name: Greetings
|
||||
|
||||
on: [pull_request, issues]
|
||||
|
||||
jobs:
|
||||
greeting:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/first-interaction@v1
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-message: 'Thank you for taking the time to report the issue and help me to make the project better! 🙂'
|
||||
pr-message: 'Thank you for helping me to make the project better! 🙂'
|
||||
22
.github/workflows/stale.yml
vendored
Normal file
22
.github/workflows/stale.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
name: Mark stale issues and pull requests
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 13 * * *"
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
with:
|
||||
any-of-labels: 'awaiting feedback'
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-issue-label: 'stale'
|
||||
stale-pr-label: 'stale'
|
||||
stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
|
||||
stale-pr-message: 'This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
|
||||
close-issue-message: 'This issue was closed because it has been stalled for 7 days with no activity.'
|
||||
close-pr-message: 'This PR was closed because it has been stalled for 7 days with no activity.'
|
||||
2
main.ts
2
main.ts
@ -56,7 +56,7 @@ export default class ObsidianFlashcard extends Plugin {
|
||||
}
|
||||
|
||||
private getDefaultSettings(): ISettings {
|
||||
return { contextAwareMode: true, sourceSupport: false, codeHighlightSupport: false, contextSeparator: " > ", deck: "Default", flashcardsTag: "card" }
|
||||
return { contextAwareMode: true, sourceSupport: false, codeHighlightSupport: false, contextSeparator: " > ", deck: "Default", flashcardsTag: "card", defaultAnkiTag: "obsidian" }
|
||||
}
|
||||
|
||||
private generateCards(activeFile: TFile) {
|
||||
|
||||
@ -16,7 +16,6 @@ export abstract class Card {
|
||||
containsCode: boolean
|
||||
modelName: string
|
||||
|
||||
// TODO set "obsidian as optional in the settings", this means that the tag should be outside
|
||||
constructor(id: number, deckName: string, initialContent: string, fields: Record<string, string>, reversed: boolean, endOffset: number, tags: string[], inserted: boolean, mediaNames: string[], containsCode: boolean = false) {
|
||||
this.id = id
|
||||
this.deckName = deckName
|
||||
@ -25,7 +24,6 @@ export abstract class Card {
|
||||
this.reversed = reversed
|
||||
this.endOffset = endOffset
|
||||
this.tags = tags
|
||||
this.tags.unshift("obsidian")
|
||||
this.inserted = inserted
|
||||
this.mediaNames = mediaNames
|
||||
this.mediaBase64Encoded = []
|
||||
|
||||
@ -3,7 +3,8 @@ import { Card } from "src/entities/card";
|
||||
|
||||
export class Inlinecard extends Card {
|
||||
constructor(id: number = -1, deckName: string, initialContent: string, fields: Record<string, string>, reversed: boolean, endOffset: number, tags: string[] = [], inserted: boolean = false, mediaNames: string[], containsCode: boolean) {
|
||||
super(id, deckName, initialContent, fields, reversed, endOffset, tags, inserted, mediaNames, [], containsCode) // ! CHANGE []
|
||||
super(id, deckName, initialContent, fields, reversed, endOffset, tags, inserted, mediaNames, containsCode) // ! CHANGE []
|
||||
|
||||
this.modelName = this.reversed ? `Obsidian-basic-reversed` : `Obsidian-basic`
|
||||
if (fields["Source"]) {
|
||||
this.modelName += sourceDeckExtension
|
||||
|
||||
@ -88,6 +88,18 @@ export class SettingsTab extends PluginSettingTab {
|
||||
})
|
||||
})
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Default Anki tag")
|
||||
.setDesc("This tag will be added to each generated card on Anki")
|
||||
.addText((text) => {
|
||||
text.setValue(plugin.settings.defaultAnkiTag)
|
||||
.setPlaceholder("Anki tag")
|
||||
.onChange((value) => {
|
||||
if (!value) new Notice("No default tags will be added")
|
||||
plugin.settings.defaultAnkiTag = value.toLowerCase()
|
||||
plugin.saveData(plugin.settings)
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
@ -148,6 +148,12 @@ export class CardsService {
|
||||
if (cardsToCreate.length) {
|
||||
let insertedCards = 0
|
||||
try {
|
||||
let defaultAnkiTag = this.settings.defaultAnkiTag
|
||||
if (defaultAnkiTag) {
|
||||
for (const card of cardsToCreate) {
|
||||
card.tags.push(defaultAnkiTag)
|
||||
}
|
||||
}
|
||||
let ids = await this.anki.addCards(cardsToCreate)
|
||||
// Add IDs from response to Flashcard[]
|
||||
ids.map((id: number, index: number) => {
|
||||
|
||||
@ -5,4 +5,5 @@ export interface ISettings {
|
||||
contextSeparator: string
|
||||
deck: string
|
||||
flashcardsTag: string
|
||||
defaultAnkiTag: string
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user