mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
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:
parent
32b9b9919a
commit
1415aa1d8f
1 changed files with 19 additions and 1 deletions
|
|
@ -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") {
|
||||
// 粘贴在代码位置
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue