aboutsummaryrefslogtreecommitdiff
path: root/ext/js/data/anki-note-builder.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/data/anki-note-builder.js')
-rw-r--r--ext/js/data/anki-note-builder.js30
1 files changed, 5 insertions, 25 deletions
diff --git a/ext/js/data/anki-note-builder.js b/ext/js/data/anki-note-builder.js
index e1399f66..f12846b1 100644
--- a/ext/js/data/anki-note-builder.js
+++ b/ext/js/data/anki-note-builder.js
@@ -16,13 +16,14 @@
*/
/* global
+ * AnkiUtil
* TemplateRendererProxy
*/
class AnkiNoteBuilder {
- constructor(enabled) {
- this._markerPattern = /\{([\w-]+)\}/g;
- this._templateRenderer = enabled ? new TemplateRendererProxy() : null;
+ constructor() {
+ this._markerPattern = AnkiUtil.cloneFieldMarkerPattern(true);
+ this._templateRenderer = new TemplateRendererProxy();
}
async createNote({
@@ -46,7 +47,7 @@ class AnkiNoteBuilder {
let duplicateScopeCheckChildren = false;
if (duplicateScope === 'deck-root') {
duplicateScope = 'deck';
- duplicateScopeDeckName = this.getRootDeckName(deckName);
+ duplicateScopeDeckName = AnkiUtil.getRootDeckName(deckName);
duplicateScopeCheckChildren = true;
}
@@ -89,27 +90,6 @@ class AnkiNoteBuilder {
};
}
- containsMarker(fields, marker) {
- marker = `{${marker}}`;
- for (const [, fieldValue] of fields) {
- if (fieldValue.includes(marker)) {
- return true;
- }
- }
- return false;
- }
-
- containsAnyMarker(field) {
- const result = this._markerPattern.test(field);
- this._markerPattern.lastIndex = 0;
- return result;
- }
-
- getRootDeckName(deckName) {
- const index = deckName.indexOf('::');
- return index >= 0 ? deckName.substring(0, index) : deckName;
- }
-
// Private
async _formatField(field, data, templates, errors=null) {