aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/anki-note-builder.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/anki-note-builder.js')
-rw-r--r--ext/bg/js/anki-note-builder.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/ext/bg/js/anki-note-builder.js b/ext/bg/js/anki-note-builder.js
index f04a6bf7..aa76ecd9 100644
--- a/ext/bg/js/anki-note-builder.js
+++ b/ext/bg/js/anki-note-builder.js
@@ -44,6 +44,14 @@ class AnkiNoteBuilder {
await this._injectMedia(anki, definition, fields, mode, audioDetails, screenshotDetails, clipboardDetails);
}
+ let duplicateScopeDeckName = null;
+ let duplicateScopeCheckChildren = false;
+ if (duplicateScope === 'deck-root') {
+ duplicateScope = 'deck';
+ duplicateScopeDeckName = this.getRootDeckName(deck);
+ duplicateScopeCheckChildren = true;
+ }
+
const fieldEntries = Object.entries(fields);
const noteFields = {};
const note = {
@@ -51,7 +59,13 @@ class AnkiNoteBuilder {
tags,
deckName: deck,
modelName: model,
- options: {duplicateScope}
+ options: {
+ duplicateScope,
+ duplicateScopeOptions: {
+ deckName: duplicateScopeDeckName,
+ checkChildren: duplicateScopeCheckChildren
+ }
+ }
};
const data = this._createNoteData(definition, mode, context, resultOutputMode, compactGlossaries);
@@ -81,6 +95,11 @@ class AnkiNoteBuilder {
return false;
}
+ getRootDeckName(deckName) {
+ const index = deckName.indexOf('::');
+ return index >= 0 ? deckName.substring(0, index) : deckName;
+ }
+
// Private
_createNoteData(definition, mode, context, resultOutputMode, compactGlossaries) {