mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	added "include note" widget to text notes, WIP
This commit is contained in:
		
							
								
								
									
										2
									
								
								libraries/ckeditor/ckeditor.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								libraries/ckeditor/ckeditor.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										164
									
								
								libraries/ckeditor/inspector.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										164
									
								
								libraries/ckeditor/inspector.js
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -41,6 +41,7 @@ window.glob.isMobile = utils.isMobile; | |||||||
| window.glob.getActiveNode = treeService.getActiveNode; | window.glob.getActiveNode = treeService.getActiveNode; | ||||||
| window.glob.getHeaders = server.getHeaders; | window.glob.getHeaders = server.getHeaders; | ||||||
| window.glob.showAddLinkDialog = () => import('./dialogs/add_link.js').then(d => d.showDialog()); | window.glob.showAddLinkDialog = () => import('./dialogs/add_link.js').then(d => d.showDialog()); | ||||||
|  | window.glob.showIncludeNoteDialog = cb => import('./dialogs/include_note.js').then(d => d.showDialog(cb)); | ||||||
| // this is required by CKEditor when uploading images | // this is required by CKEditor when uploading images | ||||||
| window.glob.noteChanged = noteDetailService.noteChanged; | window.glob.noteChanged = noteDetailService.noteChanged; | ||||||
| window.glob.refreshTree = treeService.reload; | window.glob.refreshTree = treeService.reload; | ||||||
|   | |||||||
							
								
								
									
										40
									
								
								src/public/javascripts/dialogs/include_note.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/public/javascripts/dialogs/include_note.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | |||||||
|  | import treeUtils from '../services/tree_utils.js'; | ||||||
|  | import noteAutocompleteService from '../services/note_autocomplete.js'; | ||||||
|  | import utils from "../services/utils.js"; | ||||||
|  |  | ||||||
|  | const $dialog = $("#include-note-dialog"); | ||||||
|  | const $form = $("#include-note-form"); | ||||||
|  | const $autoComplete = $("#include-note-autocomplete"); | ||||||
|  | let callback = null; | ||||||
|  |  | ||||||
|  | export async function showDialog(cb) { | ||||||
|  |     callback = cb; | ||||||
|  |  | ||||||
|  |     utils.closeActiveDialog(); | ||||||
|  |  | ||||||
|  |     glob.activeDialog = $dialog; | ||||||
|  |  | ||||||
|  |     $autoComplete.val(''); | ||||||
|  |  | ||||||
|  |     $dialog.modal(); | ||||||
|  |  | ||||||
|  |     noteAutocompleteService.initNoteAutocomplete($autoComplete, { hideGoToSelectedNoteButton: true }); | ||||||
|  |     noteAutocompleteService.showRecentNotes($autoComplete); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | $form.on('submit', () => { | ||||||
|  |     const notePath = $autoComplete.getSelectedPath(); | ||||||
|  |  | ||||||
|  |     if (notePath) { | ||||||
|  |         $dialog.modal('hide'); | ||||||
|  |  | ||||||
|  |         if (callback) { | ||||||
|  |             callback(treeUtils.getNoteIdFromNotePath(notePath)); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     else { | ||||||
|  |         console.error("No noteId to include."); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     return false; | ||||||
|  | }); | ||||||
| @@ -61,7 +61,7 @@ class NoteDetailText { | |||||||
|             else { |             else { | ||||||
|                 window.open(src, '_blank'); |                 window.open(src, '_blank'); | ||||||
|             } |             } | ||||||
|         }) |         }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     async render() { |     async render() { | ||||||
| @@ -94,6 +94,11 @@ class NoteDetailText { | |||||||
|                     } |                     } | ||||||
|                 }); |                 }); | ||||||
|  |  | ||||||
|  |                 if (glob.isDev) { | ||||||
|  |                     await import('../../libraries/ckeditor/inspector.js'); | ||||||
|  |                     CKEditorInspector.attach(this.textEditor); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|                 this.onNoteChange(() => this.ctx.noteChanged()); |                 this.onNoteChange(() => this.ctx.noteChanged()); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ const attributeService = require('../services/attributes'); | |||||||
| const config = require('../services/config'); | const config = require('../services/config'); | ||||||
| const optionService = require('../services/options'); | const optionService = require('../services/options'); | ||||||
| const log = require('../services/log'); | const log = require('../services/log'); | ||||||
|  | const env = require('../services/env'); | ||||||
|  |  | ||||||
| async function index(req, res) { | async function index(req, res) { | ||||||
|     const options = await optionService.getOptionsMap(); |     const options = await optionService.getOptionsMap(); | ||||||
| @@ -24,7 +25,8 @@ async function index(req, res) { | |||||||
|         sourceId: await sourceIdService.generateSourceId(), |         sourceId: await sourceIdService.generateSourceId(), | ||||||
|         maxSyncIdAtLoad: await sql.getValue("SELECT MAX(id) FROM sync"), |         maxSyncIdAtLoad: await sql.getValue("SELECT MAX(id) FROM sync"), | ||||||
|         instanceName: config.General ? config.General.instanceName : null, |         instanceName: config.General ? config.General.instanceName : null, | ||||||
|         appCssNoteIds: await getAppCssNoteIds() |         appCssNoteIds: await getAppCssNoteIds(), | ||||||
|  |         isDev: env.isDev() | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -210,6 +210,7 @@ | |||||||
|     <% include dialogs/clone_to.ejs %> |     <% include dialogs/clone_to.ejs %> | ||||||
|     <% include dialogs/move_to.ejs %> |     <% include dialogs/move_to.ejs %> | ||||||
|     <% include dialogs/backend_log.ejs %> |     <% include dialogs/backend_log.ejs %> | ||||||
|  |     <% include dialogs/include_note.ejs %> | ||||||
| </div> | </div> | ||||||
|  |  | ||||||
| <script type="text/javascript"> | <script type="text/javascript"> | ||||||
| @@ -220,7 +221,8 @@ | |||||||
|         sourceId: '<%= sourceId %>', |         sourceId: '<%= sourceId %>', | ||||||
|         maxSyncIdAtLoad: <%= maxSyncIdAtLoad %>, |         maxSyncIdAtLoad: <%= maxSyncIdAtLoad %>, | ||||||
|         instanceName: '<%= instanceName %>', |         instanceName: '<%= instanceName %>', | ||||||
|         csrfToken: '<%= csrfToken %>' |         csrfToken: '<%= csrfToken %>', | ||||||
|  |         isDev: '<%= isDev %>' | ||||||
|     }; |     }; | ||||||
|     window.appCssNoteIds = <%- JSON.stringify(appCssNoteIds) %>; |     window.appCssNoteIds = <%- JSON.stringify(appCssNoteIds) %>; | ||||||
| </script> | </script> | ||||||
|   | |||||||
							
								
								
									
										25
									
								
								src/views/dialogs/include_note.ejs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/views/dialogs/include_note.ejs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | |||||||
|  | <div id="include-note-dialog" class="modal mx-auto" tabindex="-1" role="dialog"> | ||||||
|  |     <div class="modal-dialog modal-lg" role="document"> | ||||||
|  |         <div class="modal-content"> | ||||||
|  |             <div class="modal-header"> | ||||||
|  |                 <h5 class="modal-title">Include note</h5> | ||||||
|  |                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||||||
|  |                     <span aria-hidden="true">×</span> | ||||||
|  |                 </button> | ||||||
|  |             </div> | ||||||
|  |             <form id="include-note-form"> | ||||||
|  |                 <div class="modal-body"> | ||||||
|  |                     <div class="form-group"> | ||||||
|  |                         <label for="include-note-autocomplete">Note</label> | ||||||
|  |                         <div class="input-group"> | ||||||
|  |                             <input id="include-note-autocomplete" class="form-control" placeholder="search for note by its name"> | ||||||
|  |                         </div> | ||||||
|  |                     </div> | ||||||
|  |                 </div> | ||||||
|  |                 <div class="modal-footer"> | ||||||
|  |                     <button type="submit" class="btn btn-primary">Include note <kbd>enter</kbd></button> | ||||||
|  |                 </div> | ||||||
|  |             </form> | ||||||
|  |         </div> | ||||||
|  |     </div> | ||||||
|  | </div> | ||||||
| @@ -97,7 +97,8 @@ | |||||||
|         sourceId: '<%= sourceId %>', |         sourceId: '<%= sourceId %>', | ||||||
|         maxSyncIdAtLoad: <%= maxSyncIdAtLoad %>, |         maxSyncIdAtLoad: <%= maxSyncIdAtLoad %>, | ||||||
|         instanceName: '<%= instanceName %>', |         instanceName: '<%= instanceName %>', | ||||||
|         csrfToken: '<%= csrfToken %>' |         csrfToken: '<%= csrfToken %>', | ||||||
|  |         isDev: '<%= isDev %>' | ||||||
|     }; |     }; | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user