Benature/obsidian-text-format

[FR] Format on paste

Benature opened this issue · 1 comments

https://github.com/obsidianmd/obsidian-api/blob/9754fc87dd9a417f198a5cad7f08959206d2f69c/obsidian.d.ts#L4697-L4703

    /**
     * Triggered when the editor receives a paste event.
     * Check for `evt.defaultPrevented` before attempting to handle this event, and return if it has been already handled.
     * Use `evt.preventDefault()` to indicate that you've handled the event.
     * @public
     */
    on(name: 'editor-paste', callback: (evt: ClipboardEvent, editor: Editor, info: MarkdownView | MarkdownFileInfo) => any, ctx?: any): EventRef;

This feature only works on notes that contain metadata tfFormatOnPaste

for example:

---
tfFormatOnPaste: ['lowercase', 'convert-bullet-list', 'easy-typing-format']
---

easy-typing-format called function formatSelectionOrCurLine(editor, view) of Easy Typing