mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	export stores note position and some other fixes
This commit is contained in:
		| @@ -87,6 +87,7 @@ async function exportToTar(branch, format, res) { | |||||||
|             isClone: false, |             isClone: false, | ||||||
|             noteId: note.noteId, |             noteId: note.noteId, | ||||||
|             title: note.title, |             title: note.title, | ||||||
|  |             notePosition: branch.notePosition, | ||||||
|             prefix: branch.prefix, |             prefix: branch.prefix, | ||||||
|             isExpanded: branch.isExpanded, |             isExpanded: branch.isExpanded, | ||||||
|             type: note.type, |             type: note.type, | ||||||
|   | |||||||
| @@ -47,7 +47,7 @@ async function importTar(fileBuffer, importRootNote) { | |||||||
|      |      | ||||||
|     function getMeta(filePath) { |     function getMeta(filePath) { | ||||||
|         if (!metaFile) { |         if (!metaFile) { | ||||||
|             return; |             return {}; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         const pathSegments = filePath.split(/[\/\\]/g); |         const pathSegments = filePath.split(/[\/\\]/g); | ||||||
| @@ -83,11 +83,14 @@ async function importTar(fileBuffer, importRootNote) { | |||||||
|         else { |         else { | ||||||
|             const parentPath = path.dirname(filePath); |             const parentPath = path.dirname(filePath); | ||||||
|  |  | ||||||
|             if (parentPath in createdPaths) { |             if (parentPath === '.') { | ||||||
|  |                 parentNoteId = importRootNote.noteId; | ||||||
|  |             } | ||||||
|  |             else if (parentPath in createdPaths) { | ||||||
|                 parentNoteId = createdPaths[parentPath]; |                 parentNoteId = createdPaths[parentPath]; | ||||||
|             } |             } | ||||||
|             else { |             else { | ||||||
|                 throw new Error(`Could not find existing path ${parentPath}.`); |                 throw new Error(`Could not find existing path ${parentPath} for ${filePath}.`); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -212,7 +215,8 @@ async function importTar(fileBuffer, importRootNote) { | |||||||
|                 noteId, |                 noteId, | ||||||
|                 parentNoteId, |                 parentNoteId, | ||||||
|                 isExpanded: noteMeta.isExpanded, |                 isExpanded: noteMeta.isExpanded, | ||||||
|                 prefix: noteMeta.prefix |                 prefix: noteMeta.prefix, | ||||||
|  |                 notePosition: noteMeta.notePosition | ||||||
|             }).save(); |             }).save(); | ||||||
|  |  | ||||||
|             return; |             return; | ||||||
| @@ -252,11 +256,28 @@ async function importTar(fileBuffer, importRootNote) { | |||||||
|                 type, |                 type, | ||||||
|                 mime, |                 mime, | ||||||
|                 prefix: noteMeta ? noteMeta.prefix : '', |                 prefix: noteMeta ? noteMeta.prefix : '', | ||||||
|                 isExpanded: noteMeta ? noteMeta.isExpanded : false |                 isExpanded: noteMeta ? noteMeta.isExpanded : false, | ||||||
|  |                 notePosition: noteMeta ? noteMeta.notePosition : false | ||||||
|             })); |             })); | ||||||
|  |  | ||||||
|             await saveAttributesAndLinks(note, noteMeta); |             await saveAttributesAndLinks(note, noteMeta); | ||||||
|  |  | ||||||
|  |             if (!noteMeta && (type === 'file' || type === 'image')) { | ||||||
|  |                 attributes.push({ | ||||||
|  |                     noteId, | ||||||
|  |                     type: 'label', | ||||||
|  |                     name: 'originalFileName', | ||||||
|  |                     value: path.basename(filePath) | ||||||
|  |                 }); | ||||||
|  |  | ||||||
|  |                 attributes.push({ | ||||||
|  |                     noteId, | ||||||
|  |                     type: 'label', | ||||||
|  |                     name: 'fileSize', | ||||||
|  |                     value: content.byteLength | ||||||
|  |                 }); | ||||||
|  |             } | ||||||
|  |  | ||||||
|             if (!firstNote) { |             if (!firstNote) { | ||||||
|                 firstNote = note; |                 firstNote = note; | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -49,7 +49,14 @@ async function triggerNoteTitleChanged(note) { | |||||||
|  * FIXME: noteData has mandatory property "target", it might be better to add it as parameter to reflect this |  * FIXME: noteData has mandatory property "target", it might be better to add it as parameter to reflect this | ||||||
|  */ |  */ | ||||||
| async function createNewNote(parentNoteId, noteData) { | async function createNewNote(parentNoteId, noteData) { | ||||||
|     const newNotePos = await getNewNotePosition(parentNoteId, noteData); |     let newNotePos; | ||||||
|  |  | ||||||
|  |     if (noteData.notePosition !== undefined) { | ||||||
|  |         newNotePos = noteData.notePosition; | ||||||
|  |     } | ||||||
|  |     else { | ||||||
|  |         newNotePos = await getNewNotePosition(parentNoteId, noteData); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     const parentNote = await repository.getNote(parentNoteId); |     const parentNote = await repository.getNote(parentNoteId); | ||||||
|  |  | ||||||
| @@ -130,7 +137,8 @@ async function createNote(parentNoteId, title, content = "", extraOptions = {}) | |||||||
|         type: extraOptions.type, |         type: extraOptions.type, | ||||||
|         mime: extraOptions.mime, |         mime: extraOptions.mime, | ||||||
|         dateCreated: extraOptions.dateCreated, |         dateCreated: extraOptions.dateCreated, | ||||||
|         isExpanded: extraOptions.isExpanded |         isExpanded: extraOptions.isExpanded, | ||||||
|  |         notePosition: extraOptions.notePosition | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|     if (extraOptions.json && !noteData.type) { |     if (extraOptions.json && !noteData.type) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user