Skip to content

Commit

Permalink
support easy-typing-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Benature committed Mar 19, 2024
1 parent 81c2319 commit e91a0c3
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export default class TextFormat extends Plugin {
//: Event was triggered by this plugin, don't handle it again
return;
}
// console.log(evt.defaultPrevented)
// @ts-ignore
const formatOnPasteCmdList = info.metadataEditor.properties.find(m => m.key === "tfFormatOnPaste")?.value;
// console.log(formatOnPasteCmdList)
if (formatOnPasteCmdList === undefined || formatOnPasteCmdList?.length == 0) { return; }
let clipboard = evt.clipboardData.getData('text/html');
let clipboard = evt.clipboardData.getData('text/html') || evt.clipboardData.getData('text/plain');
if (!clipboard) { return; }

evt.preventDefault()
Expand All @@ -89,7 +89,21 @@ export default class TextFormat extends Plugin {
clipboardData: dat,
});
// @ts-ignore
info.currentMode.clipboardManager.handlePaste(e, editor, info)
await info.currentMode.clipboardManager.handlePaste(e, editor, info);

if (formatOnPasteCmdList.includes("easy-typing-format")) {
// @ts-ignore
const activePlugins = this.app.plugins.plugins;
if (activePlugins["easy-typing-obsidian"]) {
try {
const pluginEasyTyping = activePlugins["easy-typing-obsidian"]
// console.log(.formatSelectionOrCurLine);
const cursorTo = editor.getCursor("to");
editor.setSelection(editor.offsetToPos(editor.posToOffset(cursorTo) - clipboard.length), cursorTo);
pluginEasyTyping.formatSelectionOrCurLine(editor, info);
} catch (e) { console.error(e) }
}
}
}))

LetterCaseCommands.forEach(command => {
Expand Down

0 comments on commit e91a0c3

Please sign in to comment.