From 9c3039543824fce8b4856daba9a9844e52781ba6 Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 13 Sep 2023 02:20:39 +0300 Subject: [PATCH] fix this https://rdrama.net/h/toomanyxchromosomes/post/203894/coomer-foid-marseyfans-running-for-a/4981351#context --- files/assets/js/core.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/files/assets/js/core.js b/files/assets/js/core.js index f095aa4cb..38fcf70ae 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -497,11 +497,17 @@ function handle_files(input, newfiles) { oldfiles[ta.id] = new DataTransfer(); } - for (const file of newfiles) { + for (let file of newfiles) { + if (file.name == 'image.png') { + const blob = file.slice(0, file.size, 'image/png'); + const new_name = Math.random().toString(32).substring(2,10) + '.png' + file = new File([blob], new_name, {type: 'image/png'}); + } oldfiles[ta.id].items.add(file); + insertText(ta, `[${file.name}]`); } - input.files = oldfiles[ta.id].files; + input.files = oldfiles[ta.id].files; if (input.files.length > 20) { @@ -511,9 +517,6 @@ function handle_files(input, newfiles) { return } - for (const file of newfiles) { - insertText(ta, `[${file.name}]`); - } markdown(ta) autoExpand(ta) @@ -581,13 +584,6 @@ document.onpaste = function(event) { const files = structuredClone(event.clipboardData.files); if (!files.length) return - for (let file of files) { - Object.defineProperty(file, 'name', { - writable: true, - value: Math.random().toString(32).substring(2,10) + '.png' - }); - } - const focused = document.activeElement; let input;