GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — plugins/helpers/NPFileExtensions.js at main · NotePlan/plugins Expand file tree/ Copy pathNPFileExtensions.jsMore file actions 46 lines (42 loc) · 1.96 KB / Copy pathNPFileExtensions.jsFile metadata and controls46 lines (42 loc) · 1.96 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 // @flow //---------------------------------------------------------------------------- // NotePlan note file extension helpers // Last updated 2026-08-28 by @CursorAI directed by @jgclark //---------------------------------------------------------------------------- /** Regex fragment for supported note file extensions at end of string. */ export const FILE_EXTENSIONS_GROUP = `\\.(md|txt)$` // and tie to end of string export const RE_NOTE_FILE_EXTENSION: RegExp = new RegExp(FILE_EXTENSIONS_GROUP, 'i') /** * Supported note file extensions (without dot), parsed from RE_NOTE_FILE_EXTENSION. */ export const SUPPORTED_NOTE_FILE_EXTENSIONS: Array<string> = ((): Array<string> => { const match = FILE_EXTENSIONS_GROUP.match(/\(([^)]+)\)/) return match ? match[1].split('|') : ['md'] })() /** Fallback note file extension when DataStore.defaultFileExtension is unavailable. */ export const DEFAULT_NOTE_FILE_EXTENSION: string = SUPPORTED_NOTE_FILE_EXTENSIONS[0] /** * User's note file extension without leading dot (DataStore preference, or DEFAULT_NOTE_FILE_EXTENSION). * Note: in a React/HTML window `DataStore` is an async bridge proxy, so every property access returns a * function rather than the underlying value. Only an actual non-empty string is trusted here; anything * else (function, Promise, empty string, missing DataStore) falls back to DEFAULT_NOTE_FILE_EXTENSION. * @returns {string} */ export function getUsersNoteFileExtension(): string { try { const ext = DataStore.defaultFileExtension if (typeof ext === 'string' && ext.trim() !== '') { return ext.trim().replace(/^\./, '') } } catch { /* use fallback */ } return DEFAULT_NOTE_FILE_EXTENSION } /** * Build a calendar note filename for the current vault's default extension. * @param {string} dateStr - YYYYMMDD, YYYY-Wnn, YYYY-MM, or YYYY-Qn * @returns {string} */ export function makeCalendarFilename(dateStr: string): string { return `${dateStr}.${getUsersNoteFileExtension()}` } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |