mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 04:51:31 +08:00 
			
		
		
		
	fix for icon change when creating note / changing type/mime
This commit is contained in:
		
							parent
							
								
									7ca0445bae
								
							
						
					
					
						commit
						e8f8341ef9
					
				| @ -150,12 +150,12 @@ const noteEditor = (function() { | |||||||
| 
 | 
 | ||||||
|             noteDetailEl.show(); |             noteDetailEl.show(); | ||||||
|             noteDetailCodeEl.hide(); |             noteDetailCodeEl.hide(); | ||||||
|             noteDetailRenderEl.hide(); |             noteDetailRenderEl.html('').hide(); | ||||||
|         } |         } | ||||||
|         else if (currentNote.detail.type === 'code') { |         else if (currentNote.detail.type === 'code') { | ||||||
|             noteDetailEl.hide(); |             noteDetailEl.hide(); | ||||||
|             noteDetailCodeEl.show(); |             noteDetailCodeEl.show(); | ||||||
|             noteDetailRenderEl.hide(); |             noteDetailRenderEl.html('').hide(); | ||||||
| 
 | 
 | ||||||
|             // this needs to happen after the element is shown, otherwise the editor won't be refresheds
 |             // this needs to happen after the element is shown, otherwise the editor won't be refresheds
 | ||||||
|             codeEditor.setValue(currentNote.detail.note_text); |             codeEditor.setValue(currentNote.detail.note_text); | ||||||
| @ -170,7 +170,7 @@ const noteEditor = (function() { | |||||||
|         else if (currentNote.detail.type === 'render') { |         else if (currentNote.detail.type === 'render') { | ||||||
|             noteDetailEl.hide(); |             noteDetailEl.hide(); | ||||||
|             noteDetailCodeEl.hide(); |             noteDetailCodeEl.hide(); | ||||||
|             noteDetailRenderEl.show(); |             noteDetailRenderEl.html('').show(); | ||||||
| 
 | 
 | ||||||
|             const subTree = await server.get('script/subtree/' + getCurrentNoteId()); |             const subTree = await server.get('script/subtree/' + getCurrentNoteId()); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -756,16 +756,6 @@ const noteTree = (function() { | |||||||
|             is_protected: isProtected |             is_protected: isProtected | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         const newNode = { |  | ||||||
|             title: newNoteName, |  | ||||||
|             note_id: result.note_id, |  | ||||||
|             parent_note_id: parentNoteId, |  | ||||||
|             refKey: result.note_id, |  | ||||||
|             note_tree_id: result.note_tree_id, |  | ||||||
|             is_protected: isProtected, |  | ||||||
|             extraClasses: isProtected ? "protected" : "" |  | ||||||
|         }; |  | ||||||
| 
 |  | ||||||
|         setParentChildRelation(result.note_tree_id, parentNoteId, result.note_id); |         setParentChildRelation(result.note_tree_id, parentNoteId, result.note_id); | ||||||
| 
 | 
 | ||||||
|         notesTreeMap[result.note_tree_id] = result; |         notesTreeMap[result.note_tree_id] = result; | ||||||
| @ -774,6 +764,16 @@ const noteTree = (function() { | |||||||
| 
 | 
 | ||||||
|         noteEditor.newNoteCreated(); |         noteEditor.newNoteCreated(); | ||||||
| 
 | 
 | ||||||
|  |         const newNode = { | ||||||
|  |             title: newNoteName, | ||||||
|  |             note_id: result.note_id, | ||||||
|  |             parent_note_id: parentNoteId, | ||||||
|  |             refKey: result.note_id, | ||||||
|  |             note_tree_id: result.note_tree_id, | ||||||
|  |             is_protected: isProtected, | ||||||
|  |             extraClasses: getExtraClasses(result.note) | ||||||
|  |         }; | ||||||
|  | 
 | ||||||
|         if (target === 'after') { |         if (target === 'after') { | ||||||
|             node.appendSibling(newNode).setActive(true); |             node.appendSibling(newNode).setActive(true); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -79,6 +79,9 @@ const noteType = (function() { | |||||||
| 
 | 
 | ||||||
|             await noteEditor.reload(); |             await noteEditor.reload(); | ||||||
| 
 | 
 | ||||||
|  |             // for the note icon to be updated in the tree
 | ||||||
|  |             await noteTree.reload(); | ||||||
|  | 
 | ||||||
|             self.updateExecuteScriptButtonVisibility(); |             self.updateExecuteScriptButtonVisibility(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -33,14 +33,15 @@ router.get('/:noteId', auth.checkApiAuth, wrap(async (req, res, next) => { | |||||||
| router.post('/:parentNoteId/children', auth.checkApiAuth, wrap(async (req, res, next) => { | router.post('/:parentNoteId/children', auth.checkApiAuth, wrap(async (req, res, next) => { | ||||||
|     const sourceId = req.headers.source_id; |     const sourceId = req.headers.source_id; | ||||||
|     const parentNoteId = req.params.parentNoteId; |     const parentNoteId = req.params.parentNoteId; | ||||||
|     const note = req.body; |     const newNote = req.body; | ||||||
| 
 | 
 | ||||||
|     await sql.doInTransaction(async () => { |     await sql.doInTransaction(async () => { | ||||||
|         const { noteId, noteTreeId } = await notes.createNewNote(parentNoteId, note, req, sourceId); |         const { noteId, noteTreeId, note } = await notes.createNewNote(parentNoteId, newNote, req, sourceId); | ||||||
| 
 | 
 | ||||||
|         res.send({ |         res.send({ | ||||||
|             'note_id': noteId, |             'note_id': noteId, | ||||||
|             'note_tree_id': noteTreeId |             'note_tree_id': noteTreeId, | ||||||
|  |             'note': note | ||||||
|         }); |         }); | ||||||
|     }); |     }); | ||||||
| })); | })); | ||||||
|  | |||||||
| @ -49,7 +49,7 @@ async function getNoteWithSubtreeScript(noteId, req) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| async function getSubTreeScripts(parentId, includedNoteIds, dataKey) { | async function getSubTreeScripts(parentId, includedNoteIds, dataKey) { | ||||||
|     const children = await sql.getAll(`SELECT notes.note_id, notes.note_title, notes.note_text, notes.is_protected 
 |     const children = await sql.getAll(`SELECT notes.note_id, notes.note_title, notes.note_text, notes.is_protected, notes.mime 
 | ||||||
|                                      FROM notes JOIN notes_tree USING(note_id) |                                      FROM notes JOIN notes_tree USING(note_id) | ||||||
|                                      WHERE notes_tree.is_deleted = 0 AND notes.is_deleted = 0 |                                      WHERE notes_tree.is_deleted = 0 AND notes.is_deleted = 0 | ||||||
|                                            AND notes_tree.parent_note_id = ? AND notes.type = 'code' |                                            AND notes_tree.parent_note_id = ? AND notes.type = 'code' | ||||||
| @ -68,6 +68,12 @@ async function getSubTreeScripts(parentId, includedNoteIds, dataKey) { | |||||||
| 
 | 
 | ||||||
|         script += await getSubTreeScripts(child.note_id, includedNoteIds, dataKey); |         script += await getSubTreeScripts(child.note_id, includedNoteIds, dataKey); | ||||||
| 
 | 
 | ||||||
|  |         console.log('MIME: ', child.mime); | ||||||
|  | 
 | ||||||
|  |         if (child.mime === 'application/javascript') { | ||||||
|  |             child.note_text = '<script>' + child.note_text + '</script>'; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         script += child.note_text + "\r\n"; |         script += child.note_text + "\r\n"; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -119,7 +119,8 @@ async function createNewNote(parentNoteId, noteOpts, dataKey, sourceId) { | |||||||
| 
 | 
 | ||||||
|     return { |     return { | ||||||
|         noteId, |         noteId, | ||||||
|         noteTreeId |         noteTreeId, | ||||||
|  |         note | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner