perf: memo GridCard, fuse save fns, fix slash tab active color
This commit is contained in:
@@ -60,12 +60,18 @@ export function asArray<T = unknown>(val: unknown, fallback: T[] = []): T[] {
|
||||
* Guarantees array fields are always real arrays or null.
|
||||
*/
|
||||
export function parseNote(dbNote: any): Note {
|
||||
if (!dbNote) return null as any
|
||||
let noteType: NoteType = dbNote.type || 'text'
|
||||
if (noteType === 'text' && dbNote.isMarkdown) {
|
||||
noteType = 'markdown'
|
||||
}
|
||||
let content = dbNote.content
|
||||
if (content && typeof content === 'string') {
|
||||
content = content.replace(/(https?:\/\/(?:note\.parsanet\.org|memento-note\.com|www\.memento-note\.com|localhost:3000))?\/uploads\/notes\//gi, '/uploads/notes/')
|
||||
}
|
||||
return {
|
||||
...dbNote,
|
||||
content,
|
||||
type: noteType,
|
||||
isMarkdown: noteType === 'markdown',
|
||||
checkItems: asArray(dbNote.checkItems, null as any) ?? null,
|
||||
|
||||
Reference in New Issue
Block a user