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

* This allows having the emit function working properly on mobile
   as well, which means being able to trigger plugins that use this.
This commit is contained in:
Davide Garberi 2025-01-29 14:31:02 +01:00 committed by GitHub
parent 32b9b9919a
commit 1415aa1d8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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") {
// 粘贴在代码位置