Just realized I can reply to my own posts, and post links and whatnot where the Forum wouldn’t let me before. Here’s the rest of the information:
Plugins:
- Text Format: GitHub - Benature/obsidian-text-format: Format seleted text in Obsdidian.md
- User Plugins: GitHub - mnowotnik/obsidian-user-plugins: Allows user scripts to use plugin API
Code:
plugin.addCommand({
name: 'Paste and Select',
id: "paste-and-select",
callback: async () => {
const activeFile = app.workspace.getActiveFile();
const activeView = app.workspace.activeLeaf.view;
if (!activeView) {
console.warn("No active view!");
return;
}
const editor = activeView.editor;
const currPos = editor.getCursor();
const clipboard = await navigator.clipboard.readText();
if (!clipboard) {
window.alert("No text in clipboard");
return;
}
editor.replaceRange(clipboard, currPos);
const endPos = editor.offsetToPos(editor.posToOffset(currPos) + clipboard.length);
console.log(currPos, endPos);
editor.setSelection(currPos, endPos);
}
});
Setup:
- Paste the code into the User Plugins’
Snippets
field, then press the>
symbol on the left. - QuickAdd: Create Macro “Single-Line Paste”
- Steps within the macro: 1.)
User Plugins: Paste and Select
, 2.)Wait for 10ms
, 3.)Text Format: Merge broken paragraph(s) in selection
- Bind the Macro sequence to a hotkey.