mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
29cb04db7e
commit
ed345aca36
1 changed files with 18 additions and 15 deletions
|
|
@ -14,6 +14,19 @@ import {insertHTML} from "./insertHTML";
|
||||||
import {scrollCenter} from "../../util/highlightById";
|
import {scrollCenter} from "../../util/highlightById";
|
||||||
import {getContenteditableElement} from "../wysiwyg/getBlock";
|
import {getContenteditableElement} from "../wysiwyg/getBlock";
|
||||||
|
|
||||||
|
const filterClipboardHint = (protyle: IProtyle, textPlain: string) => {
|
||||||
|
let needRender = true;
|
||||||
|
protyle.options.hint.extend.find(item => {
|
||||||
|
if (item.key === textPlain) {
|
||||||
|
needRender = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (needRender) {
|
||||||
|
protyle.hint.render(protyle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const pasteText = (protyle: IProtyle, textPlain: string, nodeElement: Element) => {
|
export const pasteText = (protyle: IProtyle, textPlain: string, nodeElement: Element) => {
|
||||||
const range = getEditorRange(protyle.wysiwyg.element);
|
const range = getEditorRange(protyle.wysiwyg.element);
|
||||||
const id = nodeElement.getAttribute("data-node-id");
|
const id = nodeElement.getAttribute("data-node-id");
|
||||||
|
|
@ -46,9 +59,7 @@ export const pasteText = (protyle: IProtyle, textPlain: string, nodeElement: Ele
|
||||||
blockRender(protyle, protyle.wysiwyg.element);
|
blockRender(protyle, protyle.wysiwyg.element);
|
||||||
processRender(protyle.wysiwyg.element);
|
processRender(protyle.wysiwyg.element);
|
||||||
highlightRender(protyle.wysiwyg.element);
|
highlightRender(protyle.wysiwyg.element);
|
||||||
if (textPlain.indexOf("[[") === -1 && textPlain.indexOf("((") === -1 && textPlain.indexOf("【【") === -1 && textPlain.indexOf("((") === -1) {
|
filterClipboardHint(protyle, textPlain)
|
||||||
protyle.hint.render(protyle);
|
|
||||||
}
|
|
||||||
scrollCenter(protyle);
|
scrollCenter(protyle);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -188,9 +199,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
|
||||||
// 转换为 md,避免再次粘贴 ID 重复
|
// 转换为 md,避免再次粘贴 ID 重复
|
||||||
const tempMd = protyle.lute.BlockDOM2StdMd(tempElement.innerHTML);
|
const tempMd = protyle.lute.BlockDOM2StdMd(tempElement.innerHTML);
|
||||||
writeText(tempMd);
|
writeText(tempMd);
|
||||||
if (tempMd.indexOf("[[") === -1 && tempMd.indexOf("((") === -1 && tempMd.indexOf("【【") === -1 && tempMd.indexOf("((") === -1) {
|
filterClipboardHint(protyle, tempMd)
|
||||||
protyle.hint.render(protyle);
|
|
||||||
}
|
|
||||||
} else if (textHTML.endsWith(Constants.ZWSP)) {
|
} else if (textHTML.endsWith(Constants.ZWSP)) {
|
||||||
// 编辑器内部粘贴
|
// 编辑器内部粘贴
|
||||||
tempElement.innerHTML = textHTML.substr(0, textHTML.length - 1);
|
tempElement.innerHTML = textHTML.substr(0, textHTML.length - 1);
|
||||||
|
|
@ -204,9 +213,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
|
||||||
});
|
});
|
||||||
const tempInnerHTML = tempElement.innerHTML;
|
const tempInnerHTML = tempElement.innerHTML;
|
||||||
insertHTML(tempInnerHTML, protyle);
|
insertHTML(tempInnerHTML, protyle);
|
||||||
if (tempInnerHTML.indexOf("[[") === -1 && tempInnerHTML.indexOf("((") === -1 && tempInnerHTML.indexOf("【【") === -1 && tempInnerHTML.indexOf("((") === -1) {
|
filterClipboardHint(protyle, tempInnerHTML)
|
||||||
protyle.hint.render(protyle);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
tempElement.innerHTML = textHTML;
|
tempElement.innerHTML = textHTML;
|
||||||
tempElement.querySelectorAll("[style]").forEach((e) => {
|
tempElement.querySelectorAll("[style]").forEach((e) => {
|
||||||
|
|
@ -232,9 +239,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
|
||||||
blockRender(protyle, protyle.wysiwyg.element);
|
blockRender(protyle, protyle.wysiwyg.element);
|
||||||
processRender(protyle.wysiwyg.element);
|
processRender(protyle.wysiwyg.element);
|
||||||
highlightRender(protyle.wysiwyg.element);
|
highlightRender(protyle.wysiwyg.element);
|
||||||
if (response.data.indexOf("[[") === -1 && response.data.indexOf("((") === -1 && response.data.indexOf("【【") === -1 && response.data.indexOf("((") === -1) {
|
filterClipboardHint(protyle, response.data)
|
||||||
protyle.hint.render(protyle);
|
|
||||||
}
|
|
||||||
scrollCenter(protyle);
|
scrollCenter(protyle);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
@ -253,9 +258,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
|
||||||
}
|
}
|
||||||
const textPlainDom = protyle.lute.Md2BlockDOM(textPlain);
|
const textPlainDom = protyle.lute.Md2BlockDOM(textPlain);
|
||||||
insertHTML(textPlainDom, protyle);
|
insertHTML(textPlainDom, protyle);
|
||||||
if (textPlainDom.indexOf("[[") === -1 && textPlainDom.indexOf("((") === -1 && textPlainDom.indexOf("【【") === -1 && textPlainDom.indexOf("((") === -1) {
|
filterClipboardHint(protyle, textPlainDom)
|
||||||
protyle.hint.render(protyle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
blockRender(protyle, protyle.wysiwyg.element);
|
blockRender(protyle, protyle.wysiwyg.element);
|
||||||
processRender(protyle.wysiwyg.element);
|
processRender(protyle.wysiwyg.element);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue