diff --git a/src/content/prefs/notero-pref.ts b/src/content/prefs/notero-pref.ts
index c23e32ae..8a5ace0f 100644
--- a/src/content/prefs/notero-pref.ts
+++ b/src/content/prefs/notero-pref.ts
@@ -8,6 +8,7 @@ export enum NoteroPref {
pageTitleFormat = 'pageTitleFormat',
syncNotes = 'syncNotes',
syncOnModifyItems = 'syncOnModifyItems',
+ urlSchema = 'urlSchema',
}
export enum PageTitleFormat {
@@ -19,6 +20,11 @@ export enum PageTitleFormat {
itemTitle = 'itemTitle',
}
+export enum UrlSchema {
+ notion = 'notion',
+ https = 'https',
+}
+
export const PAGE_TITLE_FORMAT_L10N_IDS: Record<
PageTitleFormat,
FluentMessageId
@@ -42,6 +48,7 @@ type NoteroPrefValue = Partial<{
[NoteroPref.pageTitleFormat]: PageTitleFormat;
[NoteroPref.syncNotes]: boolean;
[NoteroPref.syncOnModifyItems]: boolean;
+ [NoteroPref.urlSchema]: UrlSchema;
}>;
function buildFullPrefName(pref: NoteroPref): string {
@@ -56,6 +63,12 @@ function getStringPref(value: Zotero.Prefs.Value): string | undefined {
return typeof value === 'string' && value ? value : undefined;
}
+function getUrlSchemaPref(value: Zotero.Prefs.Value): UrlSchema | undefined {
+ return Object.values(UrlSchema).includes(value as UrlSchema)
+ ? (value as UrlSchema)
+ : undefined;
+}
+
function isPageTitleFormat(
value: Zotero.Prefs.Value,
): value is PageTitleFormat {
@@ -82,6 +95,9 @@ function convertRawPrefValue
(
(pref === NoteroPref.pageTitleFormat && getPageTitleFormatPref(value)) ||
undefined;
+ const urlSchemaPref =
+ (pref === NoteroPref.urlSchema && getUrlSchemaPref(value)) || undefined;
+
return {
[NoteroPref.collectionSyncConfigs]: stringPref,
[NoteroPref.notionDatabaseID]: stringPref,
@@ -89,6 +105,7 @@ function convertRawPrefValue
(
[NoteroPref.pageTitleFormat]: pageTitleFormatPref,
[NoteroPref.syncNotes]: booleanPref,
[NoteroPref.syncOnModifyItems]: booleanPref,
+ [NoteroPref.urlSchema]: urlSchemaPref,
}[pref];
}
diff --git a/src/content/prefs/preferences.tsx b/src/content/prefs/preferences.tsx
index 61391c2f..a6b6231b 100644
--- a/src/content/prefs/preferences.tsx
+++ b/src/content/prefs/preferences.tsx
@@ -18,7 +18,11 @@ import {
logger,
} from '../utils';
-import { PAGE_TITLE_FORMAT_L10N_IDS, PageTitleFormat } from './notero-pref';
+import {
+ PAGE_TITLE_FORMAT_L10N_IDS,
+ PageTitleFormat,
+ UrlSchema,
+} from './notero-pref';
import { SyncConfigsTable } from './sync-configs-table';
type ReactDOMClient = typeof ReactDOM & { createRoot: typeof createRoot };
@@ -57,6 +61,7 @@ class Preferences {
private notionError!: XUL.LabelElement;
private notionWorkspaceLabel!: XUL.LabelElement;
private pageTitleFormatMenu!: XUL.MenuListElement;
+ private urlSchemaMenu!: XUL.MenuListElement;
public async init(): Promise {
await Zotero.uiReadyPromise;
@@ -79,6 +84,7 @@ class Preferences {
this.notionDatabaseMenu = getXULElementById('notero-notionDatabase')!;
this.notionError = getXULElementById('notero-notionError')!;
this.pageTitleFormatMenu = getXULElementById('notero-pageTitleFormat')!;
+ this.urlSchemaMenu = getXULElementById('notero-urlSchema')!;
/* eslint-enable @typescript-eslint/no-non-null-assertion */
window.addEventListener('unload', () => {
@@ -87,6 +93,7 @@ class Preferences {
await this.initPageTitleFormatMenu();
await this.initSyncConfigsTable();
+ this.initUrlSchemaMenu();
// Don't block window from loading while waiting for network responses
setTimeout(() => {
@@ -106,6 +113,18 @@ class Preferences {
);
}
+ private initUrlSchemaMenu(): void {
+ const menuItems = Object.values(UrlSchema).map