Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

app: Emit bus paste event for pasteText as well (#13927)

Davide Garberi1415aa1d8f67
diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts
index 5c0d79d8d2..a99cd7ec8f 100644
--- a/app/src/protyle/util/paste.ts
+++ b/app/src/protyle/util/paste.ts
@@ -227,7 +227,25 @@ export const restoreLuteMarkdownSyntax = (protyle: IProtyle) => {
protyle.lute.SetInlineUnderscore(window.siyuan.config.editor.markdown.inlineUnderscore);
};
-export const pasteText = (protyle: IProtyle, textPlain: string, nodeElement: Element, toBlockDOM = true) => {
+export const pasteText = async (protyle: IProtyle, textPlain: string, nodeElement: Element, toBlockDOM = true) => {
+ if (protyle && protyle.app && protyle.app.plugins) {
+ for (let i = 0; i < protyle.app.plugins.length; i++) {
+ const response: IObject = await new Promise((resolve) => {
+ const emitResult = protyle.app.plugins[i].eventBus.emit("paste", {
+ protyle,
+ resolve,
+ textHTML: "",
+ textPlain: textPlain,
+ siyuanHTML: "",
+ files: []
+ });
+ if (emitResult) {
+ resolve(undefined);
+ }
+ });
+ }
+ }
+
const range = getEditorRange(protyle.wysiwyg.element);
if (nodeElement.getAttribute("data-type") === "NodeCodeBlock") {
// 粘贴在代码位置