diff --git a/src/controllers/CardOptionsController/CardOptionDetail.ts b/src/controllers/CardOptionsController/CardOptionDetail.ts
new file mode 100644
index 00000000..03359bf2
--- /dev/null
+++ b/src/controllers/CardOptionsController/CardOptionDetail.ts
@@ -0,0 +1,21 @@
+export class CardOptionDetail {
+ key: string;
+
+ label: string;
+
+ value: boolean;
+
+ description: string;
+
+ constructor(
+ key: string,
+ label: string,
+ description: string,
+ defaultValue: boolean
+ ) {
+ this.key = key;
+ this.label = label;
+ this.description = description;
+ this.value = defaultValue;
+ }
+}
diff --git a/src/controllers/CardOptionsController/CardOptionsController.ts b/src/controllers/CardOptionsController/CardOptionsController.ts
index d4b9ef8c..cf023a6a 100644
--- a/src/controllers/CardOptionsController/CardOptionsController.ts
+++ b/src/controllers/CardOptionsController/CardOptionsController.ts
@@ -2,8 +2,8 @@ import { Request, Response } from 'express';
import { sendError } from '../../lib/error/sendError';
import { IServiceSettings } from '../../services/SettingsService';
import { getOwner } from '../../lib/User/getOwner';
-import supportedOptions, { CardOption } from './supportedOptions';
-import Settings from '../../lib/parser/Settings';
+import supportedOptions from './supportedOptions';
+import CardOption from '../../lib/parser/Settings/CardOption';
class CardOptionsController {
constructor(private readonly service: IServiceSettings) {}
@@ -66,7 +66,7 @@ class CardOptionsController {
return { ...accumulator, ...current };
}, {});
}
- return Settings.LoadDefaultOptions();
+ return CardOption.LoadDefaultOptions();
}
getDefaultOptions() {
diff --git a/src/controllers/CardOptionsController/supportedOptions.ts b/src/controllers/CardOptionsController/supportedOptions.ts
index 1f8cbe4f..c89b0f9d 100644
--- a/src/controllers/CardOptionsController/supportedOptions.ts
+++ b/src/controllers/CardOptionsController/supportedOptions.ts
@@ -1,136 +1,116 @@
-export class CardOption {
- key: string;
+import { CardOptionDetail } from './CardOptionDetail';
- label: string;
-
- value: boolean;
-
- description: string;
-
- constructor(
- key: string,
- label: string,
- description: string,
- defaultValue: boolean
- ) {
- this.key = key;
- this.label = label;
- this.description = description;
- this.value = defaultValue;
- }
-}
-
-const supportedOptions = (): CardOption[] => {
+const supportedOptions = (): CardOptionDetail[] => {
const v = [
- new CardOption(
+ new CardOptionDetail(
'add-notion-link',
'Add Notion Link',
'Add a link to the Notion page where the toggle was created. Please use this with the (Use Notion ID) to avoid duplicates.',
false
),
- new CardOption(
+ new CardOptionDetail(
'use-notion-id',
'Use Notion ID',
'By default we create a new id from your fields. This can cause duplicates and in those cases you want to enable the Notion ID which is more reliable and avoid duplicates.',
true
),
- new CardOption(
+ new CardOptionDetail(
'all',
'Use All Toggle Lists',
'By default we only check for toggle lists in the first page. Use this option to retreive toggle lists from anywhere in the page.',
true
),
- new CardOption(
+ new CardOptionDetail(
'paragraph',
'Use Plain Text for Back',
'This option will remove formatting and get the text content only.',
false
),
- new CardOption(
+ new CardOptionDetail(
'cherry',
'Enable Cherry Picking Using 🍒 Emoji',
'This will Only create flashcards from the toggle lists that include 🍒 in the toggle (header or body)',
false
),
- new CardOption(
+ new CardOptionDetail(
'avocado',
"Only Create Flashcards From Toggles That Don't Have The 🥑 Emoji",
"This option enables you to ignore certain toggles when creating flashcards from pages that you don't want to change too much.",
false
),
- new CardOption(
+ new CardOptionDetail(
'tags',
'Treat Strikethrough as Tags',
'This will go treat the strikethroughs in the page as global ones. The ones inside of a toggle will be treated as locally to the toggle.',
false
),
- new CardOption(
+ new CardOptionDetail(
'cloze',
'Cloze Deletion',
'Create cloze flashcards from code blocks.',
true
),
- new CardOption(
+ new CardOptionDetail(
'enable-input',
'Treat Bold Text as Input',
'Words marked as bold will be removed and you will have to enter them in when reviewing the card. This is useful when you need to type out the answer.',
false
),
- new CardOption(
+ new CardOptionDetail(
'basic-reversed',
'Basic and Reversed',
'Create the question and answer flashcards but also reversed ones. Where the answer and question change places.',
false
),
- new CardOption(
+ new CardOptionDetail(
'reversed',
'Just the Reversed Flashcards',
'Only create flashcards from the reverse. This is useful when you want to say show an image first.',
false
),
- new CardOption(
+ new CardOptionDetail(
'no-underline',
'Remove Underlines',
'Disable underline. This is an option that was created due to changes in the way Notion handles underlines.',
false
),
- new CardOption(
+ new CardOptionDetail(
'max-one-toggle-per-card',
'Maximum One Toggle Per Card',
"This will limit to 1 card so you don't see too many toggles in one card. When you combine this with 'Use all toggle lists' you can create flashcards from everything in your upload, regardless of how deeply nested they are.",
true
),
- new CardOption(
+ new CardOptionDetail(
'remove-mp3-links',
'Remove the MP3 Links Created From Audio Files',
"Due to backwards-compatability we leave links untouched but this option let's you remove mp3 links",
true
),
- new CardOption(
+ new CardOptionDetail(
'perserve-newlines',
'Preserve Newlines in the Toggle Header and Body',
'This will allow you to use SHIFT-Enter in the toggles to create multiple lines for all card types (Basic, Cloze, etc.)',
true
),
- new CardOption(
+ new CardOptionDetail(
'markdown-nested-bullet-points',
'Markdown Nested Bullet Points',
'Enable conversion of bullet and sub bullet points in Markdown. If you are a Obsidian user, enable this',
false
),
- new CardOption(
+ new CardOptionDetail(
'vertex-ai-pdf-questions',
'Generate Questions from Single PDF File Uploads',
'Use Vertex AI API to generate questions from PDFs. This is a paid feature and if enabled will send your notes to Google Cloud.',
false
),
- new CardOption(
+ new CardOptionDetail(
'disable-indented-bullets',
'Disable Indented Bullets',
'Disable indented bullets from becoming separate cards. This applies to bullet lists.',
false
),
- new CardOption(
+ new CardOptionDetail(
'image-quiz-html-to-anki',
'Convert Image Quiz HTML to Anki Cards',
'Use OCR to extract images and answers from HTML quizzes and convert them into Anki flashcards for review. This is a premium experimental feature.',
diff --git a/src/controllers/NotionController.ts b/src/controllers/NotionController.ts
index 574bba35..e0d17617 100644
--- a/src/controllers/NotionController.ts
+++ b/src/controllers/NotionController.ts
@@ -2,7 +2,7 @@ import { Request, Response } from 'express';
import { sendError } from '../lib/error/sendError';
import performConversion from '../lib/storage/jobs/helpers/performConversion';
-import Settings from '../lib/parser/Settings';
+import CardOption from '../lib/parser/Settings';
import BlockHandler from '../services/NotionService/BlockHandler/BlockHandler';
import CustomExporter from '../lib/parser/exporters/CustomExporter';
import { BlockObjectResponse } from '@notionhq/client/build/src/api-endpoints';
@@ -149,7 +149,7 @@ class NotionController {
const api = await this.service.getNotionAPI(res.locals.owner);
const blockId = getNotionId(query) ?? query;
const block = await api.getBlock(blockId);
- const settings = new Settings(Settings.LoadDefaultOptions());
+ const settings = new CardOption(CardOption.LoadDefaultOptions());
let handler = new BlockHandler(
new CustomExporter('x', new Workspace(true, 'fs').location),
api,
diff --git a/src/lib/parser/Deck.ts b/src/lib/parser/Deck.ts
index 2982d28c..0438c2be 100644
--- a/src/lib/parser/Deck.ts
+++ b/src/lib/parser/Deck.ts
@@ -1,5 +1,5 @@
import Note from './Note';
-import Settings from './Settings';
+import CardOption from './Settings';
export default class Deck {
name: string;
@@ -12,7 +12,7 @@ export default class Deck {
id: number;
- settings: Settings | null;
+ settings: CardOption | null;
get cardCount() {
return this.cards.length;
@@ -24,7 +24,7 @@ export default class Deck {
image: string | undefined,
style: string | null,
id: number,
- settings: Settings
+ settings: CardOption
) {
this.settings = settings;
this.name = name;
diff --git a/src/lib/parser/DeckParser.test.ts b/src/lib/parser/DeckParser.test.ts
index 30fc136e..493c9046 100644
--- a/src/lib/parser/DeckParser.test.ts
+++ b/src/lib/parser/DeckParser.test.ts
@@ -1,13 +1,13 @@
import { setupTests } from '../../test/configure-jest';
import { getDeck } from '../../test/test-utils';
-import Settings from './Settings/';
+import CardOption from './Settings/CardOption';
beforeEach(() => setupTests());
test('Toggle Headings', async () => {
const deck = await getDeck(
'Toggle Hea 0e02b 2.html',
- new Settings({ cherry: 'false' })
+ new CardOption({ cherry: 'false' })
);
expect(deck.cards.length).toBeGreaterThan(0);
});
@@ -15,7 +15,7 @@ test('Toggle Headings', async () => {
test('Grouped cloze deletions', async () => {
const deck = await getDeck(
'Grouped Cloze Deletions fbf856ad7911423dbef0bfd3e3c5ce5c 3.html',
- new Settings({ cherry: 'false', cloze: 'true', reversed: 'true', 'basic-reversed': 'true' })
+ new CardOption({ cherry: 'false', cloze: 'true', reversed: 'true', 'basic-reversed': 'true' })
);
expect(deck.name).toBe('Grouped Cloze Deletions');
expect(deck.cards.length).toBe(20);
@@ -24,7 +24,7 @@ test('Grouped cloze deletions', async () => {
test('Cloze Deletions', async () => {
const deck = await getDeck(
'Some Cloze Deletions 1a118169ada841a99a9aaccc7eaa6775.html',
- new Settings({ cherry: 'false', reversed: 'true', 'basic-reversed': 'true' })
+ new CardOption({ cherry: 'false', reversed: 'true', 'basic-reversed': 'true' })
);
expect(deck.cards[0].back).toBe(
"
{{c2::Canberra}} was founded in {{c1::1913}}.
"
@@ -49,7 +49,7 @@ test('Cloze Deletions', async () => {
test('Colours', async () => {
const deck = await getDeck(
'Colours 0519bf7e86d84ee4ba710c1b7ff7438e.html',
- new Settings({ cherry: 'false' })
+ new CardOption({ cherry: 'false' })
);
expect(deck.cards[0].back.includes('block-color')).toBe(true);
});
@@ -63,7 +63,7 @@ test.skip('HTML Regression Test', (t) => {
test('Nested Toggles', async () => {
const deck = await getDeck(
'Nested Toggles.html',
- new Settings({ cherry: 'true', reversed: 'true', 'basic-reversed': 'true' })
+ new CardOption({ cherry: 'true', reversed: 'true', 'basic-reversed': 'true' })
);
expect(deck.cards.length).toBe(12);
});
@@ -71,7 +71,7 @@ test('Nested Toggles', async () => {
test('Global Tags', async () => {
const deck = await getDeck(
'Global Tag Support.html',
- new Settings({ tags: 'true', cherry: 'false' })
+ new CardOption({ tags: 'true', cherry: 'false' })
);
// use toContain
expect(deck.cards[0].tags.includes('global')).toBe(true);
@@ -82,7 +82,7 @@ test.todo('Multiple File Uploads');
test.todo('Test Basic Card');
test('Markdown empty deck', async () => {
- const deck = await getDeck('empty-deck.md', new Settings({
+ const deck = await getDeck('empty-deck.md', new CardOption({
"markdown-nested-bullet-points": "true"
}));
expect(deck.name).toBe('Empty Deck');
@@ -90,7 +90,7 @@ test('Markdown empty deck', async () => {
})
test('Markdown nested bullet points', async () => {
- const deck = await getDeck('simple-deck.md', new Settings({
+ const deck = await getDeck('simple-deck.md', new CardOption({
"markdown-nested-bullet-points": "true",
"reversed": "false",
"basic-reversed": "false",
diff --git a/src/lib/parser/DeckParser.ts b/src/lib/parser/DeckParser.ts
index 31c4d8a3..22ee1a73 100644
--- a/src/lib/parser/DeckParser.ts
+++ b/src/lib/parser/DeckParser.ts
@@ -5,7 +5,7 @@ import sanitizeTags from '../anki/sanitizeTags';
import { File } from '../zip/zip';
import Deck from './Deck';
import Note from './Note';
-import Settings from './Settings';
+import CardOption from './Settings';
import Workspace from './WorkSpace';
import CustomExporter from './exporters/CustomExporter';
import handleClozeDeletions from './helpers/handleClozeDeletions';
@@ -35,7 +35,7 @@ import { NO_PACKAGE_ERROR } from '../error/constants';
export interface DeckParserInput {
name: string;
- settings: Settings;
+ settings: CardOption;
files: File[];
noLimits: boolean;
workspace: Workspace;
@@ -46,7 +46,7 @@ export class DeckParser {
firstDeckName: string;
- settings: Settings;
+ settings: CardOption;
payload: Deck[];
diff --git a/src/lib/parser/Settings/Settings.ts b/src/lib/parser/Settings/CardOption.ts
similarity index 98%
rename from src/lib/parser/Settings/Settings.ts
rename to src/lib/parser/Settings/CardOption.ts
index 2d628d42..1ab10e39 100644
--- a/src/lib/parser/Settings/Settings.ts
+++ b/src/lib/parser/Settings/CardOption.ts
@@ -3,7 +3,7 @@ import { parseTemplate } from './helpers/parseTemplate';
import { UserSuppliedTemplateFile } from './types';
import { sendError } from '../../error/sendError';
-export class Settings {
+class CardOption {
readonly deckName: string | undefined;
readonly useInput: boolean;
@@ -150,3 +150,5 @@ export class Settings {
};
}
}
+
+export default CardOption;
diff --git a/src/lib/parser/Settings/index.ts b/src/lib/parser/Settings/index.ts
index dca180dc..d01b01d3 100644
--- a/src/lib/parser/Settings/index.ts
+++ b/src/lib/parser/Settings/index.ts
@@ -1,3 +1,3 @@
-import { Settings } from './Settings';
+import { CardOption } from './CardOption';
-export default Settings;
+export default CardOption;
diff --git a/src/lib/parser/Settings/loadSettingsFromDatabase.ts b/src/lib/parser/Settings/loadSettingsFromDatabase.ts
index e293d0d1..10f76ef8 100644
--- a/src/lib/parser/Settings/loadSettingsFromDatabase.ts
+++ b/src/lib/parser/Settings/loadSettingsFromDatabase.ts
@@ -1,14 +1,14 @@
import { Knex } from 'knex';
import { getCustomTemplate } from './helpers/getCustomTemplate';
-import { Settings } from './Settings';
+import { CardOption } from './CardOption';
import { sendError } from '../../error/sendError';
export const loadSettingsFromDatabase = async (
DB: Knex,
owner: string,
id: string
-): Promise => {
+): Promise => {
try {
const result = await DB('settings')
.where({ object_id: id, owner })
@@ -16,10 +16,10 @@ export const loadSettingsFromDatabase = async (
.first();
if (!result) {
console.log('using default settings');
- return new Settings(Settings.LoadDefaultOptions());
+ return new CardOption(CardOption.LoadDefaultOptions());
}
- const settings = new Settings(result.payload.payload);
+ const settings = new CardOption(result.payload.payload);
const templates = await DB('templates')
.where({ owner: owner })
.returning(['payload'])
@@ -44,5 +44,5 @@ export const loadSettingsFromDatabase = async (
} catch (error: unknown) {
sendError(error);
}
- return new Settings(Settings.LoadDefaultOptions());
+ return new CardOption(CardOption.LoadDefaultOptions());
};
diff --git a/src/lib/parser/experimental/FallbackParser.ts b/src/lib/parser/experimental/FallbackParser.ts
index 8236a814..d705fd90 100644
--- a/src/lib/parser/experimental/FallbackParser.ts
+++ b/src/lib/parser/experimental/FallbackParser.ts
@@ -9,7 +9,7 @@ import {
} from '../../storage/checks';
import Deck from '../Deck';
import Note from '../Note';
-import Settings from '../Settings';
+import CardOption from '../Settings';
import { PlainTextParser } from './PlainTextParser/PlainTextParser';
import { Flashcard, isClozeFlashcard } from './PlainTextParser/types';
import get16DigitRandomId from '../../../shared/helpers/get16DigitRandomId';
@@ -104,7 +104,7 @@ class FallbackParser {
});
}
- run(settings: Settings) {
+ run(settings: CardOption) {
const decks = [];
let clean = true;
diff --git a/src/lib/parser/findNotionToggleLists.ts b/src/lib/parser/findNotionToggleLists.ts
index 8a3532f9..86ce4ced 100644
--- a/src/lib/parser/findNotionToggleLists.ts
+++ b/src/lib/parser/findNotionToggleLists.ts
@@ -1,10 +1,10 @@
import cheerio from 'cheerio';
-import Settings from './Settings';
+import CardOption from './Settings';
export function findNotionToggleLists(
dom: cheerio.Root,
- context: Pick
+ context: Pick
): cheerio.Element[] {
if (context.isCherry || context.isAll) {
return dom('.toggle').toArray();
diff --git a/src/lib/parser/handleNestedBulletPointsInMarkdown.ts b/src/lib/parser/handleNestedBulletPointsInMarkdown.ts
index d39e191c..8df61c6f 100644
--- a/src/lib/parser/handleNestedBulletPointsInMarkdown.ts
+++ b/src/lib/parser/handleNestedBulletPointsInMarkdown.ts
@@ -4,7 +4,7 @@ import get16DigitRandomId from '../../shared/helpers/get16DigitRandomId';
import Note from './Note';
import { markdownToHTML } from '../markdown';
-import Settings from './Settings';
+import CardOption from './Settings';
const BULLET_POINT_REGEX = /^-/;
@@ -13,7 +13,7 @@ export const handleNestedBulletPointsInMarkdown = (
contents: string | undefined,
deckName: string | undefined,
decks: Deck[],
- settings: Settings
+ settings: CardOption
) => {
const deck = new Deck(
deckName ?? getTitleFromMarkdown(contents) ?? name,
diff --git a/src/lib/storage/jobs/ConversionJob.ts b/src/lib/storage/jobs/ConversionJob.ts
index 740c166b..8cdf8034 100644
--- a/src/lib/storage/jobs/ConversionJob.ts
+++ b/src/lib/storage/jobs/ConversionJob.ts
@@ -16,7 +16,7 @@ import { FileSizeInMegaBytes } from '../../misc/file';
import CustomExporter from '../../parser/exporters/CustomExporter';
import Deck from '../../parser/Deck';
import ParserRules from '../../parser/ParserRules';
-import Settings from '../../parser/Settings';
+import CardOption from '../../parser/Settings';
import { loadSettingsFromDatabase } from '../../parser/Settings/loadSettingsFromDatabase';
import Workspace from '../../parser/WorkSpace';
import StorageHandler from '../StorageHandler';
@@ -136,7 +136,7 @@ export default class ConversionJob {
bl: BlockHandler,
id: string,
rules: ParserRules,
- settings: Settings,
+ settings: CardOption,
type?: string
) => {
await this.setStatus('step2_creating_flashcards');
@@ -155,7 +155,7 @@ export default class ConversionJob {
exporter: CustomExporter,
decks: Deck[],
ws: Workspace,
- settings: Settings,
+ settings: CardOption,
storage: StorageHandler,
id: string,
owner: string
diff --git a/src/lib/zip/zip.tsx b/src/lib/zip/zip.tsx
index 850c410a..540af82a 100644
--- a/src/lib/zip/zip.tsx
+++ b/src/lib/zip/zip.tsx
@@ -10,7 +10,7 @@ import {
} from '../storage/checks';
import { processAndPrepareArchiveData } from './fallback/processAndPrepareArchiveData';
import { convertImageToHTML } from '../parser/experimental/VertexAPI/convertImageToHTML';
-import Settings from '../parser/Settings';
+import CardOption from '../parser/Settings';
import { getRandomUUID } from '../../shared/helpers/getRandomUUID';
interface File {
@@ -31,7 +31,7 @@ class ZipHandler {
this.combinedHTML = '';
}
- async build(zipData: Uint8Array, paying: boolean, settings: Settings) {
+ async build(zipData: Uint8Array, paying: boolean, settings: CardOption) {
const size = Buffer.byteLength(zipData);
const limits = getUploadLimits(paying);
@@ -54,7 +54,7 @@ class ZipHandler {
private async processZip(
zipData: Uint8Array,
paying: boolean,
- settings: Settings
+ settings: CardOption
) {
if (this.zipFileCount >= this.maxZipFiles) {
throw new Error('Too many zip files in the upload.');
@@ -80,7 +80,7 @@ class ZipHandler {
name: string,
file: Uint8Array,
paying: boolean,
- settings: Settings
+ settings: CardOption
) {
if (name.includes('__MACOSX/') || isPDFFile(name)) return;
@@ -102,7 +102,7 @@ class ZipHandler {
console.log('Converted image to HTML:', name, html);
}
- private addCombinedHTMLToFiles(paying: boolean, settings: Settings) {
+ private addCombinedHTMLToFiles(paying: boolean, settings: CardOption) {
if (this.combinedHTML && paying) {
const finalHTML = `
diff --git a/src/services/NotionService/BlockHandler/BlockHandler.test.ts b/src/services/NotionService/BlockHandler/BlockHandler.test.ts
index 52a00c94..38d41bd0 100644
--- a/src/services/NotionService/BlockHandler/BlockHandler.test.ts
+++ b/src/services/NotionService/BlockHandler/BlockHandler.test.ts
@@ -3,7 +3,7 @@ import CustomExporter from '../../../lib/parser/exporters/CustomExporter';
import Note from '../../../lib/parser/Note';
import ParserRules from '../../../lib/parser/ParserRules';
-import Settings from '../../../lib/parser/Settings';
+import CardOption from '../../../lib/parser/Settings/CardOption';
import Workspace from '../../../lib/parser/WorkSpace';
import { setupTests } from '../../../test/configure-jest';
import { pageId as examplId } from '../../../test/test-utils';
@@ -22,7 +22,7 @@ const loadCards = async (
ws: Workspace,
rules?: ParserRules
): Promise => {
- const settings = new Settings(options);
+ const settings = new CardOption(options);
const r = rules || new ParserRules();
const exporter = new CustomExporter('', ws.location);
const bl = new BlockHandler(exporter, api, settings);
@@ -58,7 +58,7 @@ jest.mock('get-notion-object-title', () => ({
describe('BlockHandler', () => {
test.skip('Get Notion Page', async () => {
const page = await api.getPage('446d09aa05d041058c16e56232188e2b');
- const title = await api.getPageTitle(page, new Settings({}));
+ const title = await api.getPageTitle(page, new CardOption({}));
expect(title).toBe('Testing');
});
@@ -89,7 +89,7 @@ describe('BlockHandler', () => {
});
test.skip('Subpages', async () => {
- const settings = new Settings({ all: 'true' });
+ const settings = new CardOption({ all: 'true' });
const rules = new ParserRules();
const exporter = new CustomExporter('', new Workspace(true, 'fs').location);
const bl = new BlockHandler(exporter, api, settings);
diff --git a/src/services/NotionService/BlockHandler/BlockHandler.ts b/src/services/NotionService/BlockHandler/BlockHandler.ts
index 32b1f932..1e479425 100644
--- a/src/services/NotionService/BlockHandler/BlockHandler.ts
+++ b/src/services/NotionService/BlockHandler/BlockHandler.ts
@@ -18,7 +18,7 @@ import getUniqueFileName from '../../../lib/misc/getUniqueFileName';
import Deck from '../../../lib/parser/Deck';
import Note from '../../../lib/parser/Note';
import ParserRules from '../../../lib/parser/ParserRules';
-import Settings from '../../../lib/parser/Settings';
+import CardOption from '../../../lib/parser/Settings';
import TagRegistry from '../../../lib/parser/TagRegistry';
import CustomExporter from '../../../lib/parser/exporters/CustomExporter';
import get16DigitRandomId from '../../../shared/helpers/get16DigitRandomId';
@@ -59,12 +59,12 @@ class BlockHandler {
useAll: boolean = false;
- settings: Settings;
+ settings: CardOption;
constructor(
exporter: CustomExporter,
api: NotionAPIWrapper,
- settings: Settings
+ settings: CardOption
) {
this.exporter = exporter;
this.api = api;
diff --git a/src/services/NotionService/NotionAPIWrapper.ts b/src/services/NotionService/NotionAPIWrapper.ts
index 0900ce7a..cf5a17d8 100644
--- a/src/services/NotionService/NotionAPIWrapper.ts
+++ b/src/services/NotionService/NotionAPIWrapper.ts
@@ -12,7 +12,7 @@ import { getNotionObjectTitle } from 'get-notion-object-title';
import sanitizeTags from '../../lib/anki/sanitizeTags';
import ParserRules from '../../lib/parser/ParserRules';
-import Settings from '../../lib/parser/Settings';
+import CardOption from '../../lib/parser/Settings/CardOption';
import { getParagraphBlocks } from './helpers/getParagraphBlocks';
import renderIcon from './helpers/renderIcon';
import getBlockIcon, { WithIcon } from './blocks/getBlockIcon';
@@ -266,7 +266,7 @@ class NotionAPIWrapper {
return sanitizeTags(globalTags);
}
- getBlockTitle(icon: string | null, title: string, settings: Settings) {
+ getBlockTitle(icon: string | null, title: string, settings: CardOption) {
if (!icon) {
return title;
}
@@ -279,7 +279,7 @@ class NotionAPIWrapper {
async getPageTitle(
page: GetPageResponse | null,
- settings: Settings
+ settings: CardOption
): Promise {
if (!page) {
return '';
@@ -294,7 +294,7 @@ class NotionAPIWrapper {
async getDatabaseTitle(
database: GetDatabaseResponse,
- settings: Settings
+ settings: CardOption
): Promise {
let icon = await renderIcon(
getBlockIcon(database as WithIcon, settings.pageEmoji)
diff --git a/src/services/NotionService/helpers/preserveNewlinesIfApplicable.ts b/src/services/NotionService/helpers/preserveNewlinesIfApplicable.ts
index 05eef171..ffce6c98 100644
--- a/src/services/NotionService/helpers/preserveNewlinesIfApplicable.ts
+++ b/src/services/NotionService/helpers/preserveNewlinesIfApplicable.ts
@@ -1,8 +1,8 @@
-import Settings from '../../../lib/parser/Settings';
+import CardOption from '../../../lib/parser/Settings';
export default function preserveNewlinesIfApplicable(
text: string,
- settings: Settings
+ settings: CardOption
): string {
if (settings.perserveNewLines) {
return text.replace(/\n/g, '
');
diff --git a/src/services/NotionService/helpers/renderTextChildren.tsx b/src/services/NotionService/helpers/renderTextChildren.tsx
index b37aeb3f..56802808 100644
--- a/src/services/NotionService/helpers/renderTextChildren.tsx
+++ b/src/services/NotionService/helpers/renderTextChildren.tsx
@@ -3,7 +3,7 @@ import {
RichTextItemResponse,
} from '@notionhq/client/build/src/api-endpoints';
import ReactDOMServer from 'react-dom/server';
-import Settings from '../../../lib/parser/Settings';
+import CardOption from '../../../lib/parser/Settings';
import BlockEquation from '../blocks/BlockEquation';
import HandleBlockAnnotations from '../blocks/HandleBlockAnnotations';
@@ -13,7 +13,7 @@ import preserveNewlinesIfApplicable from './preserveNewlinesIfApplicable';
export default function renderTextChildren(
text: RichTextItemResponse[] | undefined,
- settings: Settings
+ settings: CardOption
): string {
if (!text || text?.length === 0) {
return '';
diff --git a/src/services/UploadService.ts b/src/services/UploadService.ts
index 66e0d024..c0fa53ed 100644
--- a/src/services/UploadService.ts
+++ b/src/services/UploadService.ts
@@ -3,7 +3,7 @@ import express from 'express';
import { IUploadRepository } from '../data_layer/UploadRespository';
import { sendError } from '../lib/error/sendError';
import ErrorHandler from '../routes/middleware/ErrorHandler';
-import Settings from '../lib/parser/Settings';
+import CardOption from '../lib/parser/Settings';
import Workspace from '../lib/parser/WorkSpace';
import StorageHandler from '../lib/storage/StorageHandler';
import { UploadedFile } from '../lib/storage/types';
@@ -31,7 +31,7 @@ class UploadService {
try {
let payload;
let plen;
- const settings = new Settings(req.body || {});
+ const settings = new CardOption(req.body || {});
const ws = new Workspace(true, 'fs');
const useCase = new GeneratePackagesUseCase();
diff --git a/src/test/test-utils.ts b/src/test/test-utils.ts
index 11f1d3a2..a9f90fae 100644
--- a/src/test/test-utils.ts
+++ b/src/test/test-utils.ts
@@ -5,7 +5,7 @@ import path from 'path';
import fs from 'fs';
import { DeckParser } from '../lib/parser/DeckParser';
-import Settings from '../lib/parser/Settings';
+import CardOption from '../lib/parser/Settings';
import Workspace from '../lib/parser/WorkSpace';
function mockPayload(name: string, contents: string) {
@@ -18,7 +18,7 @@ function loadFixture(fileName: string) {
return mockPayload(fileName, html);
}
-function configureParser(fileName: string, opts: Settings) {
+function configureParser(fileName: string, opts: CardOption) {
const info = loadFixture(fileName);
return new DeckParser({
name: fileName,
@@ -29,7 +29,7 @@ function configureParser(fileName: string, opts: Settings) {
});
}
-export async function getDeck(fileName: string, opts: Settings) {
+export async function getDeck(fileName: string, opts: CardOption) {
const p = configureParser(fileName, opts);
await p.build(new Workspace(true, 'fs'));
return p.payload[0];
diff --git a/src/usecases/uploads/GeneratePackagesUseCase.ts b/src/usecases/uploads/GeneratePackagesUseCase.ts
index c1c3a4d5..989a0cba 100644
--- a/src/usecases/uploads/GeneratePackagesUseCase.ts
+++ b/src/usecases/uploads/GeneratePackagesUseCase.ts
@@ -1,5 +1,5 @@
import Package from '../../lib/parser/Package';
-import Settings from '../../lib/parser/Settings';
+import CardOption from '../../lib/parser/Settings/CardOption';
import { UploadedFile } from '../../lib/storage/types';
import { Worker } from 'worker_threads';
import path from 'path';
@@ -13,7 +13,7 @@ class GeneratePackagesUseCase {
execute(
paying: boolean,
files: UploadedFile[],
- settings: Settings,
+ settings: CardOption,
workspace: Workspace
): Promise {
return new Promise((resolve, reject) => {
diff --git a/src/usecases/uploads/getPackagesFromZip.ts b/src/usecases/uploads/getPackagesFromZip.ts
index bd25d258..6b24c225 100644
--- a/src/usecases/uploads/getPackagesFromZip.ts
+++ b/src/usecases/uploads/getPackagesFromZip.ts
@@ -1,5 +1,5 @@
import { Body } from 'aws-sdk/clients/s3';
-import Settings from '../../lib/parser/Settings';
+import CardOption from '../../lib/parser/Settings/CardOption';
import { ZipHandler } from '../../lib/zip/zip';
import { PrepareDeck } from '../../lib/parser/PrepareDeck';
import Package from '../../lib/parser/Package';
@@ -13,7 +13,7 @@ import { isZipContentFileSupported } from './isZipContentFileSupported';
export const getPackagesFromZip = async (
fileContents: Body | undefined,
paying: boolean,
- settings: Settings,
+ settings: CardOption,
workspace: Workspace
): Promise => {
const zipHandler = new ZipHandler(getMaxUploadCount(paying));
diff --git a/src/usecases/uploads/worker.ts b/src/usecases/uploads/worker.ts
index cabe92ff..3ae58be6 100644
--- a/src/usecases/uploads/worker.ts
+++ b/src/usecases/uploads/worker.ts
@@ -1,6 +1,6 @@
import { parentPort, workerData } from 'worker_threads';
import { UploadedFile } from '../../lib/storage/types';
-import Settings from '../../lib/parser/Settings';
+import CardOption from '../../lib/parser/Settings/CardOption';
import Package from '../../lib/parser/Package';
import fs from 'fs';
import { PrepareDeck } from '../../lib/parser/PrepareDeck';
@@ -17,7 +17,7 @@ import { isZipContentFileSupported } from './isZipContentFileSupported';
interface GenerationData {
paying: boolean;
files: UploadedFile[];
- settings: Settings;
+ settings: CardOption;
workspace: Workspace;
}