( candidate: NoteImportCandidate, folderId: number, )
| 143 | } |
| 144 | |
| 145 | function createNote( |
| 146 | candidate: NoteImportCandidate, |
| 147 | folderId: number, |
| 148 | ): { name: string, tagCount: number } { |
| 149 | const storage = useNotesStorage() |
| 150 | const name = getUniqueNoteName( |
| 151 | storage.notes.getNotes({ folderId, isDeleted: 0 }), |
| 152 | normalizeImportEntryName(candidate.name, 'Untitled note'), |
| 153 | ) |
| 154 | const { id } = storage.notes.createNote({ folderId, name }) |
| 155 | |
| 156 | storage.notes.updateNoteContent(id, candidate.content) |
| 157 | |
| 158 | const { created, tagIds } = getOrCreateTagIds(candidate.tags) |
| 159 | tagIds.forEach((tagId) => { |
| 160 | storage.notes.addTagToNote(id, tagId) |
| 161 | }) |
| 162 | |
| 163 | return { name, tagCount: created } |
| 164 | } |
| 165 | |
| 166 | export function applyNotesImportResult( |
| 167 | result: NoteImportParseResult, |
no test coverage detected