Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion ui/src/pages/case.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,43 @@ $(document).ready(function(){
collab_case = io.connect();
collab_case.emit('join-case-obj-notif', { 'channel': 'case-' + get_caseid() });
}
});
});

function handle_ed_paste(event, editor) {
let 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} =100%x40%)\n`);
});

};
reader.readAsDataURL(blob);
} else {
notify_error('Unsupported direct paste of this item. Use datastore to upload.');
}
}
}
}
43 changes: 1 addition & 42 deletions ui/src/pages/case.notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ async function note_detail(id) {
ed_details.off('paste');
ed_details.on('paste', (event) => {
event.preventDefault();
handle_ed_paste(event);
handle_ed_paste(event, note_editor);
});

setSharedLink(id);
Expand Down Expand Up @@ -1056,47 +1056,6 @@ function createDirectoryListItem(directory, directoryMap) {
return listItem;
}


function handle_ed_paste(event) {
let 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();
note_editor.insertSnippet(`\n![${filename}](${url} =100%x40%)\n`);
});

};
reader.readAsDataURL(blob);
} else {
notify_error('Unsupported direct paste of this item. Use datastore to upload.');
}
}
}
}


function note_interval_pinger() {
if (new Date() - last_ping > 2000) {
collaborator_socket.emit('ping-note',
Expand Down
7 changes: 7 additions & 0 deletions ui/src/pages/case.timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ function add_event(parent_event_id = null) {
$('#modal_add_event').modal({ show: true });
$('#event_title').focus();

let ed_event_description = $('#event_description');
ed_event_description.off('paste');
ed_event_description.on('paste', (event) => {
event.preventDefault();
handle_ed_paste(event, g_event_desc_editor);
});

});
}

Expand Down