So, I started making a plugin for this. Because I do not have any experience on js code, I just used GitHub - derwish-pro/obsidian-code-block-from-selection: Obsidian plugin. Adds code block for the selected text. plugin which seems simple enough to change it.
So I used the selected text command from the API and it seems to work. By using my plugin I can clean the selected text with the rules mentioned in my first post. So right now it works using two steps, paste text, select pasted text, press the registerd hotkey to clean it.
Does anyone know how I get the clipboard text directly? Right now I use this chunk
let text = editor.getSelection(); //need something looking like editor.getClipboard() which doesn't exist
text = text.replace(/[\n\r]/g, ' ');
text = text.replace(/- /g, '');
text = text.replace(/"|“|”|’+|‘+/g, '\'');
editor.replaceSelection(text, 'around');
Any help will be welcome 