From a0b52ad855f838a5d07344b12f19d71f79ee573c Mon Sep 17 00:00:00 2001 From: Connor Payne Date: Sat, 13 Apr 2024 17:04:02 +0100 Subject: [PATCH 1/2] Update case.notes.js --- .../app/static/assets/js/iris/case.notes.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/source/app/static/assets/js/iris/case.notes.js b/source/app/static/assets/js/iris/case.notes.js index aae0b4ab3..524751034 100644 --- a/source/app/static/assets/js/iris/case.notes.js +++ b/source/app/static/assets/js/iris/case.notes.js @@ -21,6 +21,10 @@ const preventFormDefaultBehaviourOnSubmit = (event) => { return false; }; +var editor = ace.edit("editor_detail", + {autoScrollEditorIntoView: true, + minLines: 4 + }); function Collaborator( session_id, n_id ) { this.collaboration_socket = collaborator_socket; @@ -358,6 +362,45 @@ async function note_detail(id) { }); } +function handle_ed_paste(event) { + filename = null; + const { items } = event.originalEvent.clipboardData; + for (let i = 0; i < items.length; i += 1) { + const item = items[i]; + + if (item.kind === 'string') { + item.getAsString(function (s){ + filename = $.trim(s.replace(/\t|\n|\r/g, '')).substring(0, 40); + }); + } + + if (item.kind === 'file') { + const blob = item.getAsFile(); + + if (blob !== null) { + const reader = new FileReader(); + reader.onload = (e) => { + notify_success('The file is uploading in background. Don\'t leave the page'); + + if (filename === null) { + filename = random_filename(25); + } + + upload_interactive_data(e.target.result, filename, function(data){ + url = data.data.file_url + case_param(); + event.preventDefault(); + editor.insertSnippet(`\n![${filename}](${url} =40%x40%)\n`); + }); + }; + reader.readAsDataURL(blob); + } else { + notify_error('Unsupported direct paste of this item. Use datastore to upload.'); + } + } + } +} + + function refresh_ppl_list() { $('#ppl_list_viewing').empty(); for (let [key, value] of ppl_viewing) { From decaf5126e5e6df36d19de1f7a81977d1596b8d0 Mon Sep 17 00:00:00 2001 From: whitekernel <74464599+whikernel@users.noreply.github.com> Date: Mon, 22 Apr 2024 16:10:18 +0200 Subject: [PATCH 2/2] Update source/app/static/assets/js/iris/case.notes.js --- source/app/static/assets/js/iris/case.notes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/app/static/assets/js/iris/case.notes.js b/source/app/static/assets/js/iris/case.notes.js index 524751034..91a9917fc 100644 --- a/source/app/static/assets/js/iris/case.notes.js +++ b/source/app/static/assets/js/iris/case.notes.js @@ -389,7 +389,7 @@ function handle_ed_paste(event) { upload_interactive_data(e.target.result, filename, function(data){ url = data.data.file_url + case_param(); event.preventDefault(); - editor.insertSnippet(`\n![${filename}](${url} =40%x40%)\n`); + note_editor.insertSnippet(`\n![${filename}](${url} =100%x40%)\n`); }); }; reader.readAsDataURL(blob);