Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

4.6 KB
Raw Blame
import type { Locale } from 'vue-i18n';

import type { TreeItem } from '~/helpers/TreeBuilder';

export type ANode<ID = number | string> = Omit<TreeItem<unknown, ID>, 'data' | 'route'>;

export const DEFAULT_PREFERENCES = {
  locale: 'en' as Locale,
  readAnnouncements: [] as string[],
  printMode: false as boolean,
  darkMode: false as boolean,
  hideTOC: false as boolean,
  compactMode: false as boolean,
  normalizeFileIcons: false as boolean,
  displayFeatureTags: true as boolean,
  displayUncategorizedResources: true as boolean,
  displayTabs: false as boolean,
  advancedView: false as boolean,
  datatableItemsCount: 10 as number,
  view_dock: true as boolean,
  primaryColor: -2 as number, // -2 default primary; -1 unset; >= 0 app color index
  docSize: 1 as number, // 0 = small, 1 = large
  style: 'default' as 'default' | 'glassmorphism',
  theme: 'alexandrie' as string,
  documentAutoSave: true as boolean, // Enable automatic saving of documents
  documentFontSize: 16 as number,
  documentFontFamily: 'Poppins' as string,
  documentLineHeight: 1.5 as number,
  documentTitlesNumbering: false as boolean,
  documentColoredTags: true as boolean,
  documentShowAttachments: false as boolean,
  documentDefaultThumbnail: false as boolean,
  documentUseParentThumbnail: false as boolean,
  sidebarItems: {
    manageCategories: true as boolean,
    cdn: true as boolean,
    settings: true as boolean,
    home: true as boolean,
    teams: true as boolean,
    importation: false as boolean,
    documents: false as boolean,
    newPage: false as boolean,
  } as const,
  navbarItems: {
    breadcrumbNav: false as boolean,
    search: true as boolean,
    theme: true as boolean,
    navigation: true as boolean,
  } as const,
  snippets: [
    { id: '!blue', label: ':::blue\n${0}\n:::' },
    { id: '!green', label: ':::green\n${0}\n:::' },
    { id: '!yellow', label: ':::yellow\n${0}\n:::' },
    { id: '!red', label: ':::red\n${0}\n:::' },
    { id: '!grey', label: ':::grey\n${0}\n:::' },
    { id: '!teal', label: ':::teal\n${0}\n:::' },
    { id: '!details', label: ':::details\n${0}\n:::' },
    { id: '!info-red', label: ':::info-red\n${0}\n:::' },
    { id: '!info-blue', label: ':::info-blue\n${0}\n:::' },
    { id: '!info-teal', label: ':::info-teal\n${0}\n:::' },
    { id: '!center', label: ':::center\n${0}\n:::' },
    { id: '!columns', label: ':::columns\n${0}\n:::' },
    { id: '!column', label: ':::column\n${0}\n:::' },
    { id: '!no-print', label: ':::no-print\n${0}\n:::' },
    { id: '!property', label: ':::property ${0}\n\n:::' },
    { id: '!warning', label: ':::warning ${0}\n\n:::' },
    { id: '!frame', label: ':::frame ${0}\n\n:::' },
    { id: '!card', label: ':::card ${0}\n\n:::' },
    { id: '!pannel', label: ':::pannel ${0}\n\n:::' },
  ] as ANode<string>[],
  editorFontFamily: 'JetBrains Mono' as string,
  editorFontSize: 14 as number,
  editorSpellCheck: true as boolean,
  editorDisplayStats: false as boolean,
  editorSnippetsEnabled: true as boolean,
  editorScrollBeyondLastLine: true as boolean,
  editorSimplifiedViewOnMobile: true as boolean,
  developerMode: false as boolean,
  sortKey: 'name' as 'name' | 'created' | 'modified',
  sortOrder: 'ascending' as 'ascending' | 'descending',
  stylesInjectionEnabled: false as boolean,
  stylesInjection: '' as string,
  stylesDocumentsInjection: '' as string,
  defaultUploadFolder: null as string | null,
};

export type Preferences = {
  [K in keyof typeof DEFAULT_PREFERENCES]: (typeof DEFAULT_PREFERENCES)[K];
};
export type PreferenceKey = keyof Preferences;

// ─── Key mapping: which preference keys go to which backend JSON column ───
export const GENERAL_KEYS: PreferenceKey[] = [
  'locale',
  'readAnnouncements',
  'printMode',
  'darkMode',
  'hideTOC',
  'compactMode',
  'normalizeFileIcons',
  'displayFeatureTags',
  'displayUncategorizedResources',
  'displayTabs',
  'advancedView',
  'datatableItemsCount',
  'view_dock',
  'primaryColor',
  'docSize',
  'style',
  'theme',
  'sidebarItems',
  'navbarItems',
];

export const EDITOR_KEYS: PreferenceKey[] = [
  'documentAutoSave',
  'documentFontSize',
  'documentFontFamily',
  'documentLineHeight',
  'documentTitlesNumbering',
  'documentColoredTags',
  'documentShowAttachments',
  'documentDefaultThumbnail',
  'documentUseParentThumbnail',
  'editorFontFamily',
  'editorFontSize',
  'editorSpellCheck',
  'editorDisplayStats',
  'editorSnippetsEnabled',
  'editorScrollBeyondLastLine',
  'editorSimplifiedViewOnMobile',
];

export const ADVANCED_KEYS: PreferenceKey[] = [
  'snippets',
  'developerMode',
  'stylesInjectionEnabled',
  'stylesInjection',
  'stylesDocumentsInjection',
  'defaultUploadFolder',
  'sortKey',
  'sortOrder',
];