mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	create note inline
This commit is contained in:
		| @@ -42,7 +42,9 @@ export async function showDialog(widget) { | ||||
|  | ||||
|     noteAutocompleteService.initNoteAutocomplete($autoComplete); | ||||
|  | ||||
|     $autoComplete.on('autocomplete:selected', function(event, suggestion, dataset) { | ||||
|     $autoComplete.on('autocomplete:noteselected', function(event, suggestion, dataset) { | ||||
|         console.log("SELECTED", suggestion); | ||||
|  | ||||
|         if (!suggestion.notePath) { | ||||
|             return false; | ||||
|         } | ||||
|   | ||||
| @@ -1,16 +1,31 @@ | ||||
| import server from "./server.js"; | ||||
| import appContext from "./app_context.js"; | ||||
| import utils from './utils.js'; | ||||
| import noteCreateService from './note_create.js'; | ||||
| import treeService from './tree.js'; | ||||
|  | ||||
| // this key needs to have this value so it's hit by the tooltip | ||||
| const SELECTED_NOTE_PATH_KEY = "data-note-path"; | ||||
|  | ||||
| async function autocompleteSource(term, cb) { | ||||
|     const result = await server.get('autocomplete' | ||||
|         + '?query=' + encodeURIComponent(term) | ||||
|         + '&activeNoteId=' + appContext.tabManager.getActiveTabNoteId()); | ||||
|     const activeNoteId = appContext.tabManager.getActiveTabNoteId(); | ||||
|  | ||||
|     cb(result); | ||||
|     let results = await server.get('autocomplete' | ||||
|             + '?query=' + encodeURIComponent(term) | ||||
|             + '&activeNoteId=' + activeNoteId); | ||||
|  | ||||
|     if (term.trim().length >= 1) { | ||||
|         results = [ | ||||
|             { | ||||
|                 action: 'create', | ||||
|                 noteTitle: term, | ||||
|                 parentNoteId: activeNoteId, | ||||
|                 highlightedNotePathTitle: `Create and link child note "${term}"` | ||||
|             } | ||||
|         ].concat(results); | ||||
|     } | ||||
|  | ||||
|     cb(results); | ||||
| } | ||||
|  | ||||
| function clearText($el) { | ||||
| @@ -86,19 +101,30 @@ function initNoteAutocomplete($el, options) { | ||||
|             source: autocompleteSource, | ||||
|             displayKey: 'notePathTitle', | ||||
|             templates: { | ||||
|                 suggestion: function(suggestion) { | ||||
|                     return suggestion.highlightedNotePathTitle; | ||||
|                 } | ||||
|                 suggestion: suggestion => suggestion.highlightedNotePathTitle | ||||
|             }, | ||||
|             // we can't cache identical searches because notes can be created / renamed, new recent notes can be added | ||||
|             cache: false | ||||
|         } | ||||
|     ]); | ||||
|  | ||||
|     $el.on('autocomplete:selected', (event, suggestion) => { | ||||
|     $el.on('autocomplete:selected', async (event, suggestion) => { | ||||
|         if (suggestion.action === 'create') { | ||||
|             const {note} = await noteCreateService.createNote(suggestion.parentNoteId, { | ||||
|                 title: suggestion.noteTitle, | ||||
|                 activate: false | ||||
|             }); | ||||
|  | ||||
|             suggestion.notePath = treeService.getSomeNotePath(note); | ||||
|         } | ||||
|  | ||||
|         $el.setSelectedNotePath(suggestion.notePath); | ||||
|  | ||||
|         $el.autocomplete("val", suggestion.noteTitle); | ||||
|  | ||||
|         $el.autocomplete("close"); | ||||
|  | ||||
|         $el.trigger('autocomplete:noteselected', [event, suggestion]); | ||||
|     }); | ||||
|  | ||||
|     $el.on('autocomplete:closed', () => { | ||||
|   | ||||
| @@ -666,10 +666,14 @@ a.external:not(.no-arrow):after, a[href^="http://"]:not(.no-arrow):after, a[href | ||||
| } | ||||
|  | ||||
| .ck-mentions .ck-button { | ||||
|     font-size: var(--main-font-size) !important; | ||||
|     font-size: var(--detail-font-size) !important; | ||||
|     padding: 5px; | ||||
| } | ||||
|  | ||||
| .ck-mentions .ck-button b { | ||||
|     font-size: var(--detail-font-size) !important; | ||||
| } | ||||
|  | ||||
| .ck-mentions .ck-button.ck-on { | ||||
|     background-color: var(--active-item-background-color) !important; | ||||
|     color: var(--active-item-text-color) !important; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user