mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-28 19:26:09 +01:00
This commit is contained in:
parent
4047f95016
commit
33dfa0de4e
3 changed files with 37 additions and 5 deletions
|
|
@ -125,10 +125,10 @@ export const pasteText = (protyle: IProtyle, textPlain: string, nodeElement: Ele
|
|||
export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEvent) & { target: HTMLElement }) => {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
let textHTML;
|
||||
let textPlain;
|
||||
let siyuanHTML;
|
||||
let files;
|
||||
let textHTML: string;
|
||||
let textPlain: string;
|
||||
let siyuanHTML: string;
|
||||
let files: FileList | DataTransferItemList;
|
||||
if ("clipboardData" in event) {
|
||||
textHTML = event.clipboardData.getData("text/html");
|
||||
textPlain = event.clipboardData.getData("text/plain");
|
||||
|
|
@ -194,6 +194,37 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
|
|||
textHTML = Lute.Sanitize(textHTML);
|
||||
}
|
||||
|
||||
if (protyle && protyle.app && protyle.app.plugins) {
|
||||
for (let i = 0; i < protyle.app.plugins.length; i++) {
|
||||
const response: IObject & { files: FileList } = await new Promise((resolve) => {
|
||||
const emitResult = protyle.app.plugins[i].eventBus.emit("paste", {
|
||||
protyle,
|
||||
resolve,
|
||||
textHTML,
|
||||
textPlain,
|
||||
siyuanHTML,
|
||||
files
|
||||
});
|
||||
if (emitResult) {
|
||||
resolve(undefined);
|
||||
}
|
||||
});
|
||||
|
||||
if (response?.textHTML) {
|
||||
textHTML = response.textHTML;
|
||||
}
|
||||
if (response?.textPlain) {
|
||||
textPlain = response.textPlain;
|
||||
}
|
||||
if (response?.siyuanHTML) {
|
||||
siyuanHTML = response.siyuanHTML;
|
||||
}
|
||||
if (response?.files) {
|
||||
files = response.files as FileList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const nodeElement = hasClosestBlock(event.target);
|
||||
if (!nodeElement) {
|
||||
if (files && files.length > 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue