@@ -9,7 +9,7 @@ import * as dt from '@helpers/dateTime'
99import { clo , JSP , logDebug , logError , logInfo , logTimer , logWarn , timer } from '@helpers/dev'
1010import { getFolderDisplayName , getFolderFromFilename , getRegularNotesInFolder } from '@helpers/folders'
1111import { displayTitle , isDecoratedCommandBarAvailable , isValidUUID } from '@helpers/general'
12- import { calendarNotesSortedByChanged , noteType } from '@helpers/note'
12+ import { calendarNotesSortedByChanged , noteType } from '@helpers/note'
1313import { displayTitleWithRelDate , getDateStrFromRelativeDateString , getRelativeDates } from '@helpers/NPdateTime'
1414import { endOfFrontmatterLineIndex , ensureFrontmatter , getFrontmatterAttributes , getFrontmatterAttribute } from '@helpers/NPFrontMatter'
1515import { findStartOfActivePartOfNote , findEndOfActivePartOfNote } from '@helpers/paragraph'
@@ -54,7 +54,7 @@ const pluginJson = 'NPnote.js'
5454 * Note: no try-catch, so that failure can stop processing.
5555 * Note: This used to live in helpers/userInput.js, but was moved here to avoid a circular dependency.
5656 * @author @jgclark , heavily extending earlier function by @dwertheimer
57- *
57+ *
5858 * @param {string? } promptText - text to display in the CommandBar
5959 * @param {Array<TNote>? } regularNotes - a list of regular notes to choose from. If not provided, all regular notes will be used.
6060 * @param {boolean? } includeCalendarNotes - include calendar notes in the list
@@ -115,7 +115,7 @@ export async function chooseNoteV2(
115115 icon : userSetIcon ? userSetIcon : folderIconDetails . icon ,
116116 // Note: icon-color isn't used by NP in CommandBar, so I won't use it either for now. But if that changes, here's the line:
117117 // color: (possTeamspaceDetails.isTeamspace) ? TEAMSPACE_ICON_COLOR : userSetIconColor ? userSetIconColor : folderIconDetails.color,
118- color : ( possTeamspaceDetails . isTeamspace ) ? TEAMSPACE_ICON_COLOR : folderIconDetails . color ,
118+ color : possTeamspaceDetails . isTeamspace ? TEAMSPACE_ICON_COLOR : folderIconDetails . color ,
119119 shortDescription : note . type === 'Notes' ? getFolderDisplayName ( getFolderFromFilename ( note . filename ) ?? '' ) : '' ,
120120 alpha : folderIconDetails . alpha ?? 0.7 ,
121121 darkAlpha : folderIconDetails . darkAlpha ?? 0.7 ,
@@ -206,12 +206,12 @@ export async function chooseNoteV2(
206206// eslint-disable-next-line require-await
207207export async function printNote ( noteIn : ?TNote , alsoShowParagraphs : boolean = false ) : Promise < void > {
208208 try {
209- const note = ( noteIn == null ) ? Editor . note : noteIn
209+ const note = noteIn == null ? Editor . note : noteIn
210210 if ( ! note ) {
211211 logWarn ( 'note/printNote()' , `No valid note found. Stopping.` )
212212 return
213213 }
214- const usingEditor = ( noteIn == null || note . filename === Editor . filename )
214+ const usingEditor = noteIn == null || note . filename === Editor . filename
215215
216216 console . log ( `# '${ displayTitle ( note ) } '${ usingEditor ? ' (from Editor)' : '' } :` )
217217 console . log ( `- type ${ note . type } ` )
@@ -231,8 +231,7 @@ export async function printNote(noteIn: ?TNote, alsoShowParagraphs: boolean = fa
231231 } else {
232232 // Calendar note
233233 console . log ( dt . getDateStringFromCalendarFilename ( note . filename ) )
234- console . log ( `- # paragraphs: ${ note . paragraphs . length
235- } `)
234+ console . log ( `- # paragraphs: ${ note . paragraphs . length } ` )
236235 }
237236 console.log(`- created: ${ String ( note . createdDate ) ?? '(not set!)' } `)
238237 console.log(`- changed: ${ String ( note . changedDate ) ?? '(not set!' } `)
@@ -249,7 +248,7 @@ export async function printNote(noteIn: ?TNote, alsoShowParagraphs: boolean = fa
249248 console . log ( `Paragraphs:` )
250249 note . paragraphs . map ( ( p ) => {
251250 const referencedParas = DataStore . referencedBlocks ( p )
252- console . log ( ` ${ p . lineIndex } : ${ p . type } ${ p . rawContent } ${ ( referencedParas . length >= 1 ) ? ` 🆔 has ${ referencedParas . length } sync copies` : '' } ` )
251+ console . log ( ` ${ p . lineIndex } : ${ p . type } ${ p . rawContent } ${ referencedParas . length >= 1 ? ` 🆔 has ${ referencedParas . length } sync copies` : '' } ` )
253252 } )
254253 }
255254 }
@@ -309,7 +308,10 @@ export async function printNote(noteIn: ?TNote, alsoShowParagraphs: boolean = fa
309308 */
310309export function getTeamspaceDetailsFromNote(note: TNote): TTeamspace | null {
311310 try {
312- if ( ( NotePlan . environment . buildVersion < 1366 && NotePlan . environment . platform === 'macOS' ) || ( NotePlan . environment . buildVersion < 1295 && NotePlan . environment . platform !== 'macOS' ) ) {
311+ if (
312+ ( NotePlan . environment . buildVersion < 1366 && NotePlan . environment . platform === 'macOS' ) ||
313+ ( NotePlan . environment . buildVersion < 1295 && NotePlan . environment . platform !== 'macOS' )
314+ ) {
313315 return null
314316 }
315317 if (note.isTeamspaceNote) {
@@ -351,9 +353,7 @@ export function getNoteFromFilename(filenameIn: string): TNote | null {
351353 }
352354 // FIXME(Eduard): projectNoteByFilename() is not working for teamspace notes
353355 // So we have to do it this way ...
354- foundNote = DataStore . noteByFilename ( filenameIn , 'Notes' , teamspaceID )
355- ?? DataStore . noteByFilename ( filenameIn , 'Calendar' , teamspaceID )
356- ?? null
356+ foundNote = DataStore . noteByFilename ( filenameIn , 'Notes' , teamspaceID ) ?? DataStore . noteByFilename ( filenameIn , 'Calendar' , teamspaceID ) ?? null
357357 if ( foundNote != null ) {
358358 logDebug ( 'NPnote/getNoteFromFilename' , `Found teamspace note '${ displayTitle ( foundNote ) } ' from ${ filenameIn } ` )
359359 } else {
@@ -626,8 +626,11 @@ export function getReferencedParagraphs(calNote: Note, includeHeadings: boolean
626626 backlinkParas . forEach ( ( para ) => {
627627 // If we want to filter out the headings, then check the subItem content actually includes the date of the note of interest.
628628 if ( ! para ) {
629- logWarn ( 'getReferencedParagraphs' , ` - referenced para is null. Found in one of ${ backlinkParas . length } backlink paras for note '${ displayTitle ( calNote ) } ' at ${ calNote . filename } .` )
630- }
629+ logWarn (
630+ 'getReferencedParagraphs' ,
631+ ` - referenced para is null. Found in one of ${ backlinkParas . length } backlink paras for note '${ displayTitle ( calNote ) } ' at ${ calNote . filename } .` ,
632+ )
633+ }
631634 if ( includeHeadings ) {
632635 // logDebug(`getReferencedParagraphs`, `- adding "${para.content}" as we want headings`)
633636 } else if ( para . content . includes ( `>${ thisDateStr } ` ) || para . content . includes ( `>today` ) ) {
@@ -637,7 +640,7 @@ export function getReferencedParagraphs(calNote: Note, includeHeadings: boolean
637640 }
638641 wantedParas . push ( para )
639642 } else {
640- // logDebug(`getReferencedParagraphs`, `- skipping "${para.content}" as it doesn't include >${thisDateStr}`)
643+ // logDebug(`getReferencedParagraphs`, `- skipping "${para.content}" as it doesn't include >${thisDateStr}`)
641644 }
642645 } )
643646
@@ -795,11 +798,9 @@ export function getAllNotesOfType(noteTypesToInclude: Array<string> = ['Calendar
795798 let notesToReturn : Array < TNote > = [ ]
796799 if ( noteTypesToInclude . includes ( 'Calendar' ) && noteTypesToInclude . includes ( 'Notes' ) ) {
797800 notesToReturn = DataStore . calendarNotes . slice ( ) . concat ( DataStore . projectNotes . slice ( ) )
798- }
799- else if ( noteTypesToInclude . includes ( 'Calendar' ) ) {
801+ } else if ( noteTypesToInclude . includes ( 'Calendar' ) ) {
800802 notesToReturn = DataStore . calendarNotes . slice ( )
801- }
802- else if ( noteTypesToInclude . includes ( 'Notes' ) ) {
803+ } else if ( noteTypesToInclude . includes ( 'Notes' ) ) {
803804 notesToReturn = DataStore . projectNotes . slice ( )
804805 }
805806 return notesToReturn
@@ -832,7 +833,9 @@ export function getNotesChangedInInterval(numDays: number, noteTypesToInclude: A
832833 const jsdateToStartLooking = momentToStartLooking . toDate ( )
833834
834835 matchingNotes = allNotesToCheck . filter ( ( f ) => f . changedDate >= jsdateToStartLooking )
835- logTimer ( 'getNotesChangedInInterval' , startTime ,
836+ logTimer (
837+ 'getNotesChangedInInterval' ,
838+ startTime ,
836839 `from ${ allNotesToCheck . length } notes of type ${ String ( noteTypesToInclude ) } found ${ matchingNotes . length } changed after ${ String ( momentToStartLooking ) } :` ,
837840 )
838841 return matchingNotes
@@ -964,9 +967,7 @@ export function findNotesMatchingHashtagOrMention(
964967 } else {
965968 notesWithItem = notesInFolder . filter ( ( n ) => {
966969 const correctedHashtags = getCorrectedHashtagsFromNote ( n )
967- return isHashtag
968- ? correctedHashtags . includes ( item )
969- : n . mentions . includes ( item )
970+ return isHashtag ? correctedHashtags . includes ( item ) : n . mentions . includes ( item )
970971 } )
971972 }
972973 if ( notesWithItem . length === 0 ) {
@@ -979,7 +980,10 @@ export function findNotesMatchingHashtagOrMention(
979980 // Restrict to certain para types, if wanted
980981 if ( wantedParaTypes . length > 0 ) {
981982 notesWithItem = notesWithItem . filter ( ( n ) => filterTagsOrMentionsInNoteByWantedParaTypes ( n , [ item ] , wantedParaTypes , includeInFrontmatterValues ) . length > 0 )
982- logDebug ( 'NPnote/findNotesMatchingHashtagOrMention' , `After filtering to only include notes with wanted para types [${ String ( wantedParaTypes ) } ] -> ${ String ( notesWithItem . length ) } notes` )
983+ logDebug (
984+ 'NPnote/findNotesMatchingHashtagOrMention' ,
985+ `After filtering to only include notes with wanted para types [${ String ( wantedParaTypes ) } ] -> ${ String ( notesWithItem . length ) } notes` ,
986+ )
983987 // logDebug('NPnote/findNotesMatchingHashtagOrMention', `= ${String(notesWithItem.map((n) => n.title))}`)
984988 }
985989
@@ -1018,17 +1022,17 @@ function filterTagsOrMentionsInNoteByWantedParaTypes(
10181022) : Array < string > {
10191023 try {
10201024 // Filter items based on paragraph types and note tags
1021- const filteredItems = tagsOrMentions . filter ( item => {
1022- const paragraphsWithItem = note . paragraphs . filter ( p => caseInsensitiveSubstringMatch ( item , p . content ) )
1025+ const filteredItems = tagsOrMentions . filter ( ( item ) => {
1026+ const paragraphsWithItem = note . paragraphs . filter ( ( p ) => caseInsensitiveSubstringMatch ( item , p . content ) )
10231027 // logDebug('NPnote/filterTagsOMINBWPT', `Found ${paragraphsWithItem.length} paragraphs with item ${item} in ${note.filename}:`)
10241028 if ( includeInFrontmatterValues ) {
10251029 const noteTagAttribute = getFrontmatterAttribute ( note , 'note-tag' ) ?? ''
1026- if ( tagsOrMentions . some ( tm => noteTagAttribute . includes ( tm ) ) ) {
1030+ if ( tagsOrMentions . some ( ( tm ) => noteTagAttribute . includes ( tm ) ) ) {
10271031 logDebug ( 'NPNote/filterTagsOMINBWPT' , `Found matching noteTag(s) in '${ noteTagAttribute } ' in ${ note . filename } ` )
10281032 return true
10291033 }
10301034 }
1031- const hasValidParagraphType = paragraphsWithItem . some ( p => wantedParaTypes . includes ( p . type ) )
1035+ const hasValidParagraphType = paragraphsWithItem . some ( ( p ) => wantedParaTypes . includes ( p . type ) )
10321036 return hasValidParagraphType
10331037 } )
10341038
@@ -1251,9 +1255,7 @@ export function getFSSafeFilenameFromNoteTitle(note: TNote): string {
12511255 // Replace multiple underscores with a single underscore
12521256 filesystemSafeTitle = filesystemSafeTitle . replace ( / _ + / g, '_' )
12531257 if ( filesystemSafeTitle !== '' ) {
1254- const newName = justFolderName !== '/'
1255- ? `${ justFolderName } /${ filesystemSafeTitle } .${ defaultFileExtension } `
1256- : `${ filesystemSafeTitle } .${ defaultFileExtension } `
1258+ const newName = justFolderName !== '/' ? `${ justFolderName } /${ filesystemSafeTitle } .${ defaultFileExtension } ` : `${ filesystemSafeTitle } .${ defaultFileExtension } `
12571259 return newName
12581260 } else {
12591261 logWarn ( 'NPnote.js' , `getFSSafeFilenameFromNoteTitle(): No title found in note ${ note . filename } . Returning empty string.` )
@@ -1274,11 +1276,7 @@ export function getFSSafeFilenameFromNoteTitle(note: TNote): string {
12741276 * @param {Array<TNote>? } notesIn
12751277 * @returns {TNote } note
12761278 */
1277- export async function getNoteFromParamOrUser (
1278- purpose : string ,
1279- noteTitleArg : string = '' ,
1280- notesIn ?: Array < TNote > ,
1281- ) : Promise < ?TNote > {
1279+ export async function getNoteFromParamOrUser ( purpose : string , noteTitleArg : string = '' , notesIn ?: Array < TNote > ) : Promise < ?TNote > {
12821280 // Note: deliberately no try/catch so that failure can stop processing
12831281 const startTime = new Date ( )
12841282 let note : ?TNote
@@ -1485,7 +1483,7 @@ export function getNoteTypeByFilename(filename: string): ?NoteType {
14851483 * Archive a note using its current folder, replicating the folder structure if needed.
14861484 * If 'archiveRootFolder' is supplied, archive under that folder, otherwise default to the built-in @Archive folder.
14871485 * @author @jgclark
1488- *
1486+ *
14891487 * @param {TNote } noteIn
14901488 * @param {string? } archiveRootFolder optional; if not given, then use the built-in @Archive folder
14911489 * @returns {string | void } newFilename, if success
@@ -1523,8 +1521,7 @@ export function archiveNoteUsingFolder(note: TNote, archiveRootFolder?: string):
15231521 } else {
15241522 throw new Error ( `archiveNoteUsingFolder(): Failed when moving '${ displayTitle ( note ) } ' to folder ${ archiveFolderToMoveTo } ` )
15251523 }
1526- }
1527- catch ( error ) {
1524+ } catch ( error ) {
15281525 logError ( pluginJson , error . message )
15291526 return
15301527 }
0 commit comments