2022-05-26 15:18:53 +08:00
|
|
|
|
import {Constants} from "../../constants";
|
|
|
|
|
|
import {uploadFiles, uploadLocalFiles} from "../upload";
|
|
|
|
|
|
import {processPasteCode, processRender} from "./processCode";
|
|
|
|
|
|
import {writeText} from "./compatibility";
|
2022-08-23 20:57:39 +08:00
|
|
|
|
/// #if !BROWSER
|
|
|
|
|
|
import {clipboard} from "electron";
|
|
|
|
|
|
/// #endif
|
2022-05-26 15:18:53 +08:00
|
|
|
|
import {hasClosestBlock} from "./hasClosest";
|
|
|
|
|
|
import {focusByWbr, getEditorRange} from "./selection";
|
|
|
|
|
|
import {blockRender} from "../markdown/blockRender";
|
|
|
|
|
|
import * as dayjs from "dayjs";
|
|
|
|
|
|
import {highlightRender} from "../markdown/highlightRender";
|
2022-09-02 19:41:59 +08:00
|
|
|
|
import {updateTransaction} from "../wysiwyg/transaction";
|
2022-05-26 15:18:53 +08:00
|
|
|
|
import {fetchPost, fetchSyncPost} from "../../util/fetch";
|
|
|
|
|
|
import {isDynamicRef, isFileAnnotation} from "../../util/functions";
|
|
|
|
|
|
import {insertHTML} from "./insertHTML";
|
|
|
|
|
|
import {scrollCenter} from "../../util/highlightById";
|
|
|
|
|
|
import {getContenteditableElement} from "../wysiwyg/getBlock";
|
2022-10-22 11:31:41 +08:00
|
|
|
|
import {hideElements} from "../ui/hideElements";
|
2022-05-26 15:18:53 +08:00
|
|
|
|
|
2022-07-08 09:24:54 +08:00
|
|
|
|
const filterClipboardHint = (protyle: IProtyle, textPlain: string) => {
|
|
|
|
|
|
let needRender = true;
|
|
|
|
|
|
protyle.options.hint.extend.find(item => {
|
|
|
|
|
|
if (item.key === textPlain) {
|
|
|
|
|
|
needRender = false;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2022-07-08 10:38:11 +08:00
|
|
|
|
});
|
2022-07-08 09:24:54 +08:00
|
|
|
|
if (needRender) {
|
|
|
|
|
|
protyle.hint.render(protyle);
|
|
|
|
|
|
}
|
2022-07-08 10:38:11 +08:00
|
|
|
|
};
|
2022-07-08 09:24:54 +08:00
|
|
|
|
|
2022-09-19 11:33:11 +08:00
|
|
|
|
export const pasteAsPlainText = async (protyle:IProtyle) => {
|
|
|
|
|
|
/// #if !BROWSER && !MOBILE
|
|
|
|
|
|
let localFiles: string[] = [];
|
|
|
|
|
|
if ("darwin" === window.siyuan.config.system.os) {
|
|
|
|
|
|
const xmlString = clipboard.read("NSFilenamesPboardType");
|
|
|
|
|
|
const domParser = new DOMParser();
|
|
|
|
|
|
const xmlDom = domParser.parseFromString(xmlString, "application/xml");
|
|
|
|
|
|
Array.from(xmlDom.getElementsByTagName("string")).forEach(item => {
|
|
|
|
|
|
localFiles.push(item.childNodes[0].nodeValue);
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
const xmlString = await fetchSyncPost("/api/clipboard/readFilePaths", {});
|
|
|
|
|
|
if (xmlString.data.length > 0) {
|
|
|
|
|
|
localFiles = xmlString.data;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (localFiles.length > 0) {
|
2022-09-27 14:57:25 +08:00
|
|
|
|
uploadLocalFiles(localFiles, protyle, false);
|
|
|
|
|
|
writeText("");
|
2022-09-19 11:33:11 +08:00
|
|
|
|
} else {
|
2022-10-16 17:21:08 +08:00
|
|
|
|
protyle.lute.SetHTMLTag2TextMark(true); // 临时设置 Lute 解析参数,行级元素键盘和下划线无法粘贴为纯文本 https://github.com/siyuan-note/siyuan/issues/6220
|
2022-10-19 21:47:47 +08:00
|
|
|
|
const dom = protyle.lute.InlineMd2BlockDOM(clipboard.readText());
|
2022-10-16 17:21:08 +08:00
|
|
|
|
protyle.lute.SetHTMLTag2TextMark(false);
|
|
|
|
|
|
insertHTML(protyle.lute.BlockDOM2Content(dom), protyle, false);
|
2022-09-19 11:33:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// #endif
|
2022-09-19 15:33:30 +08:00
|
|
|
|
};
|
2022-09-19 11:33:11 +08:00
|
|
|
|
|
2022-05-26 15:18:53 +08:00
|
|
|
|
export const pasteText = (protyle: IProtyle, textPlain: string, nodeElement: Element) => {
|
|
|
|
|
|
const range = getEditorRange(protyle.wysiwyg.element);
|
|
|
|
|
|
const id = nodeElement.getAttribute("data-node-id");
|
|
|
|
|
|
if (nodeElement.getAttribute("data-type") === "NodeCodeBlock") {
|
|
|
|
|
|
// 粘贴在代码位置
|
|
|
|
|
|
range.insertNode(document.createElement("wbr"));
|
|
|
|
|
|
const html = nodeElement.outerHTML;
|
|
|
|
|
|
range.deleteContents();
|
|
|
|
|
|
range.insertNode(document.createTextNode(textPlain.replace(/\r\n|\r|\u2028|\u2029/g, "\n")));
|
|
|
|
|
|
range.collapse(false);
|
|
|
|
|
|
range.insertNode(document.createElement("wbr"));
|
|
|
|
|
|
nodeElement.outerHTML = protyle.lute.SpinBlockDOM(nodeElement.outerHTML);
|
|
|
|
|
|
nodeElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${id}"]`) as HTMLElement;
|
|
|
|
|
|
highlightRender(nodeElement);
|
|
|
|
|
|
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
|
|
|
|
|
updateTransaction(protyle, id, nodeElement.outerHTML, html);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (range.toString() !== "") {
|
|
|
|
|
|
if (isDynamicRef(textPlain)) {
|
|
|
|
|
|
textPlain = textPlain.replace(/'.+'\)\)$/, ` "${range.toString()}"))`);
|
|
|
|
|
|
} else if (isFileAnnotation(textPlain)) {
|
|
|
|
|
|
textPlain = textPlain.replace(/".+">>$/, `"${range.toString()}">>`);
|
|
|
|
|
|
} else if (protyle.lute.IsValidLinkDest(textPlain)) {
|
|
|
|
|
|
textPlain = `[${range.toString()}](${textPlain})`;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
insertHTML(protyle.lute.Md2BlockDOM(textPlain), protyle);
|
|
|
|
|
|
|
|
|
|
|
|
blockRender(protyle, protyle.wysiwyg.element);
|
|
|
|
|
|
processRender(protyle.wysiwyg.element);
|
|
|
|
|
|
highlightRender(protyle.wysiwyg.element);
|
2022-07-08 10:38:11 +08:00
|
|
|
|
filterClipboardHint(protyle, textPlain);
|
2022-05-26 15:18:53 +08:00
|
|
|
|
scrollCenter(protyle);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEvent) & { target: HTMLElement }) => {
|
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
let textHTML;
|
|
|
|
|
|
let textPlain;
|
|
|
|
|
|
let files;
|
|
|
|
|
|
if ("clipboardData" in event) {
|
|
|
|
|
|
textHTML = event.clipboardData.getData("text/html");
|
|
|
|
|
|
textPlain = event.clipboardData.getData("text/plain");
|
|
|
|
|
|
files = event.clipboardData.files;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
textHTML = event.dataTransfer.getData("text/html");
|
|
|
|
|
|
textPlain = event.dataTransfer.getData("text/plain");
|
|
|
|
|
|
if (event.dataTransfer.types[0] === "Files") {
|
|
|
|
|
|
files = event.dataTransfer.items;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-09-27 23:36:07 +08:00
|
|
|
|
// 复制标题及其下方块使用 writeText,需将 textPLain 转换为 textHTML
|
|
|
|
|
|
if (textPlain.endsWith(Constants.ZWSP) && !textHTML) {
|
2022-09-28 12:14:18 +08:00
|
|
|
|
textHTML = textPlain;
|
2022-09-27 23:36:07 +08:00
|
|
|
|
}
|
2022-05-26 15:18:53 +08:00
|
|
|
|
/// #if !MOBILE
|
2022-08-23 20:57:39 +08:00
|
|
|
|
if (!textHTML && !textPlain && ("clipboardData" in event)) {
|
|
|
|
|
|
if ("darwin" === window.siyuan.config.system.os) {
|
2022-08-24 17:10:18 +08:00
|
|
|
|
/// #if !BROWSER
|
2022-08-23 20:57:39 +08:00
|
|
|
|
const xmlString = clipboard.read("NSFilenamesPboardType");
|
|
|
|
|
|
const domParser = new DOMParser();
|
|
|
|
|
|
const xmlDom = domParser.parseFromString(xmlString, "application/xml");
|
|
|
|
|
|
const localFiles: string[] = [];
|
|
|
|
|
|
Array.from(xmlDom.getElementsByTagName("string")).forEach(item => {
|
|
|
|
|
|
localFiles.push(item.childNodes[0].nodeValue);
|
|
|
|
|
|
});
|
2022-08-26 23:49:07 +08:00
|
|
|
|
if (localFiles.length > 0) {
|
2022-09-27 14:57:25 +08:00
|
|
|
|
uploadLocalFiles(localFiles, protyle, true);
|
2022-08-26 23:49:07 +08:00
|
|
|
|
writeText("");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2022-08-24 17:10:18 +08:00
|
|
|
|
/// #endif
|
2022-08-23 20:57:39 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
const xmlString = await fetchSyncPost("/api/clipboard/readFilePaths", {});
|
|
|
|
|
|
if (xmlString.data.length > 0) {
|
2022-09-27 14:57:25 +08:00
|
|
|
|
uploadLocalFiles(xmlString.data, protyle, true);
|
2022-08-23 20:57:39 +08:00
|
|
|
|
writeText("");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2022-05-26 15:18:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// #endif
|
|
|
|
|
|
|
|
|
|
|
|
// 浏览器地址栏拷贝处理
|
|
|
|
|
|
if (textHTML.replace(/&/g, "&").replace(/<(|\/)(html|body|meta)[^>]*?>/ig, "").trim() ===
|
|
|
|
|
|
`<a href="${textPlain}">${textPlain}</a>` ||
|
|
|
|
|
|
textHTML.replace(/&/g, "&").replace(/<(|\/)(html|body|meta)[^>]*?>/ig, "").trim() ===
|
|
|
|
|
|
`<!--StartFragment--><a href="${textPlain}">${textPlain}</a><!--EndFragment-->`) {
|
|
|
|
|
|
textHTML = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-08-18 12:36:24 +08:00
|
|
|
|
// 剪切复制中首位包含空格或仅有空格 https://github.com/siyuan-note/siyuan/issues/5667
|
2022-08-18 12:32:49 +08:00
|
|
|
|
if (!textHTML.endsWith(Constants.ZWSP) && !textHTML.startsWith(Constants.ZWSP)) {
|
|
|
|
|
|
// process word
|
|
|
|
|
|
const doc = new DOMParser().parseFromString(textHTML, "text/html");
|
|
|
|
|
|
if (doc.body && doc.body.innerHTML) {
|
|
|
|
|
|
textHTML = doc.body.innerHTML;
|
|
|
|
|
|
}
|
2022-08-18 19:39:53 +08:00
|
|
|
|
// windows 剪切板
|
|
|
|
|
|
if (textHTML.startsWith("\n<!--StartFragment-->") && textHTML.endsWith("<!--EndFragment-->\n\n")) {
|
|
|
|
|
|
textHTML = doc.body.innerHTML.trim().replace("<!--StartFragment-->", "").replace("<!--EndFragment-->", "");
|
|
|
|
|
|
}
|
2022-05-26 15:18:53 +08:00
|
|
|
|
}
|
2022-08-18 12:32:49 +08:00
|
|
|
|
|
2022-05-26 15:18:53 +08:00
|
|
|
|
textHTML = Lute.Sanitize(textHTML);
|
|
|
|
|
|
|
|
|
|
|
|
const nodeElement = hasClosestBlock(event.target);
|
|
|
|
|
|
if (!nodeElement) {
|
2022-06-03 11:42:54 +08:00
|
|
|
|
if (files && files.length > 0) {
|
2022-05-26 15:18:53 +08:00
|
|
|
|
uploadFiles(protyle, files);
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2022-10-22 11:31:41 +08:00
|
|
|
|
hideElements(["select"], protyle);
|
|
|
|
|
|
protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--hl").forEach(item => {
|
|
|
|
|
|
item.classList.remove("protyle-wysiwyg--hl");
|
2022-05-26 15:18:53 +08:00
|
|
|
|
});
|
|
|
|
|
|
const code = processPasteCode(textHTML, textPlain);
|
|
|
|
|
|
const range = getEditorRange(protyle.wysiwyg.element);
|
|
|
|
|
|
const id = nodeElement.getAttribute("data-node-id");
|
|
|
|
|
|
// process code
|
|
|
|
|
|
if (nodeElement.getAttribute("data-type") === "NodeCodeBlock") {
|
|
|
|
|
|
// 粘贴在代码位置
|
|
|
|
|
|
range.insertNode(document.createElement("wbr"));
|
|
|
|
|
|
const html = nodeElement.outerHTML;
|
|
|
|
|
|
range.deleteContents();
|
|
|
|
|
|
range.insertNode(document.createTextNode(textPlain.replace(/\r\n|\r|\u2028|\u2029/g, "\n")));
|
|
|
|
|
|
range.collapse(false);
|
|
|
|
|
|
range.insertNode(document.createElement("wbr"));
|
|
|
|
|
|
getContenteditableElement(nodeElement).removeAttribute("data-render");
|
|
|
|
|
|
highlightRender(nodeElement);
|
|
|
|
|
|
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
|
|
|
|
|
updateTransaction(protyle, id, nodeElement.outerHTML, html);
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
scrollCenter(protyle, nodeElement as Element);
|
|
|
|
|
|
}, Constants.TIMEOUT_BLOCKLOAD);
|
|
|
|
|
|
return;
|
|
|
|
|
|
} else if (code) {
|
|
|
|
|
|
if (!code.startsWith('<div data-type="NodeCodeBlock" class="code-block" data-node-id="')) {
|
|
|
|
|
|
const wbrElement = document.createElement("wbr");
|
|
|
|
|
|
range.insertNode(wbrElement);
|
|
|
|
|
|
const html = nodeElement.outerHTML;
|
|
|
|
|
|
wbrElement.remove();
|
|
|
|
|
|
range.deleteContents();
|
|
|
|
|
|
const tempElement = document.createElement("code");
|
|
|
|
|
|
tempElement.textContent = code;
|
|
|
|
|
|
range.insertNode(document.createElement("wbr"));
|
|
|
|
|
|
range.insertNode(tempElement);
|
|
|
|
|
|
updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, html);
|
|
|
|
|
|
focusByWbr(protyle.wysiwyg.element, range);
|
|
|
|
|
|
} else {
|
2022-08-31 21:57:12 +08:00
|
|
|
|
insertHTML(code, protyle, true);
|
|
|
|
|
|
highlightRender(protyle.wysiwyg.element);
|
2022-05-26 15:18:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
let isHTML = false;
|
|
|
|
|
|
if (textHTML.startsWith(Constants.ZWSP) || textHTML.endsWith(Constants.ZWSP)) {
|
|
|
|
|
|
isHTML = true;
|
|
|
|
|
|
} else if (textHTML.replace("<!--StartFragment--><!--EndFragment-->", "").trim() !== "") {
|
|
|
|
|
|
textHTML = textHTML.replace("<!--StartFragment-->", "").replace("<!--EndFragment-->", "").trim();
|
|
|
|
|
|
// 浏览器上复制当个图片应拷贝到本地,excel 中的复制需粘贴
|
2022-06-03 11:42:54 +08:00
|
|
|
|
if (files && files.length === 1 && textHTML.indexOf("<img") > -1) {
|
2022-05-26 15:18:53 +08:00
|
|
|
|
isHTML = false;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
isHTML = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (isHTML) {
|
|
|
|
|
|
const tempElement = document.createElement("div");
|
|
|
|
|
|
if (textHTML.startsWith(Constants.ZWSP)) {
|
|
|
|
|
|
// 剪切块内容后粘贴
|
2022-08-30 20:24:54 +08:00
|
|
|
|
// mac 复制后会带有 <meta charset="utf-8"> https://github.com/siyuan-note/siyuan/issues/5751
|
|
|
|
|
|
tempElement.innerHTML = textHTML.substr(1).replace('<meta charset="utf-8">', "");
|
2022-05-26 15:18:53 +08:00
|
|
|
|
let isBlock = false;
|
|
|
|
|
|
tempElement.querySelectorAll("[data-node-id]").forEach((e) => {
|
2022-08-07 09:39:55 +08:00
|
|
|
|
e.classList.remove("protyle-wysiwyg--select", "protyle-wysiwyg--hl");
|
2022-05-26 15:18:53 +08:00
|
|
|
|
isBlock = true;
|
|
|
|
|
|
});
|
|
|
|
|
|
if (nodeElement.classList.contains("table")) {
|
|
|
|
|
|
isBlock = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
insertHTML(tempElement.innerHTML, protyle, isBlock);
|
|
|
|
|
|
// 转换为 md,避免再次粘贴 ID 重复
|
|
|
|
|
|
const tempMd = protyle.lute.BlockDOM2StdMd(tempElement.innerHTML);
|
|
|
|
|
|
writeText(tempMd);
|
2022-07-08 10:38:11 +08:00
|
|
|
|
filterClipboardHint(protyle, tempMd);
|
2022-05-26 15:18:53 +08:00
|
|
|
|
} else if (textHTML.endsWith(Constants.ZWSP)) {
|
|
|
|
|
|
// 编辑器内部粘贴
|
2022-08-30 20:24:54 +08:00
|
|
|
|
tempElement.innerHTML = textHTML.substr(0, textHTML.length - 1).replace('<meta charset="utf-8">', "");
|
2022-05-26 15:18:53 +08:00
|
|
|
|
tempElement.querySelectorAll("[data-node-id]").forEach((e) => {
|
|
|
|
|
|
const newId = Lute.NewNodeID();
|
|
|
|
|
|
e.setAttribute("data-node-id", newId);
|
2022-08-07 09:39:55 +08:00
|
|
|
|
e.classList.remove("protyle-wysiwyg--select", "protyle-wysiwyg--hl");
|
2022-05-26 15:18:53 +08:00
|
|
|
|
if (e.getAttribute("updated")) {
|
|
|
|
|
|
e.setAttribute("updated", newId.split("-")[0]);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2022-08-31 22:36:53 +08:00
|
|
|
|
// 从历史中复制后粘贴
|
|
|
|
|
|
tempElement.querySelectorAll('[spellcheck="false"][contenteditable="false"]').forEach((e) => {
|
|
|
|
|
|
e.setAttribute("contenteditable", "true");
|
|
|
|
|
|
});
|
2022-05-26 15:18:53 +08:00
|
|
|
|
const tempInnerHTML = tempElement.innerHTML;
|
|
|
|
|
|
insertHTML(tempInnerHTML, protyle);
|
2022-07-08 10:38:11 +08:00
|
|
|
|
filterClipboardHint(protyle, tempInnerHTML);
|
2022-05-26 15:18:53 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
tempElement.innerHTML = textHTML;
|
|
|
|
|
|
tempElement.querySelectorAll("[style]").forEach((e) => {
|
|
|
|
|
|
e.removeAttribute("style");
|
|
|
|
|
|
});
|
|
|
|
|
|
// 移除空的 A 标签
|
|
|
|
|
|
tempElement.querySelectorAll("a").forEach((e) => {
|
|
|
|
|
|
if (e.innerHTML.trim() === "") {
|
|
|
|
|
|
e.remove();
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
fetchPost("/api/lute/html2BlockDOM", {
|
|
|
|
|
|
dom: tempElement.innerHTML
|
|
|
|
|
|
}, (response) => {
|
|
|
|
|
|
insertHTML(response.data, protyle);
|
2022-09-14 23:26:02 +08:00
|
|
|
|
protyle.wysiwyg.element.querySelectorAll('[data-type~="block-ref"]').forEach(item => {
|
2022-05-26 15:18:53 +08:00
|
|
|
|
if (item.textContent === "") {
|
|
|
|
|
|
fetchPost("/api/block/getRefText", {id: item.getAttribute("data-id")}, (response) => {
|
2022-08-31 18:17:43 +08:00
|
|
|
|
item.innerHTML = response.data;
|
2022-05-26 15:18:53 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
blockRender(protyle, protyle.wysiwyg.element);
|
|
|
|
|
|
processRender(protyle.wysiwyg.element);
|
|
|
|
|
|
highlightRender(protyle.wysiwyg.element);
|
2022-07-08 10:38:11 +08:00
|
|
|
|
filterClipboardHint(protyle, response.data);
|
2022-05-26 15:18:53 +08:00
|
|
|
|
scrollCenter(protyle);
|
|
|
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2022-06-03 11:42:54 +08:00
|
|
|
|
} else if (files && files.length > 0) {
|
2022-05-26 15:18:53 +08:00
|
|
|
|
uploadFiles(protyle, files);
|
2022-06-03 11:42:54 +08:00
|
|
|
|
} else if (textPlain.trim() !== "" && files && files.length === 0) {
|
2022-05-26 15:18:53 +08:00
|
|
|
|
if (range.toString() !== "") {
|
|
|
|
|
|
if (isDynamicRef(textPlain)) {
|
|
|
|
|
|
textPlain = textPlain.replace(/'.*'\)\)$/, ` "${Lute.EscapeHTMLStr(range.toString())}"))`);
|
|
|
|
|
|
} else if (isFileAnnotation(textPlain)) {
|
|
|
|
|
|
textPlain = textPlain.replace(/".+">>$/, `"${Lute.EscapeHTMLStr(range.toString())}">>`);
|
|
|
|
|
|
} else if (protyle.lute.IsValidLinkDest(textPlain)) {
|
|
|
|
|
|
textPlain = `[${range.toString()}](${textPlain})`;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
const textPlainDom = protyle.lute.Md2BlockDOM(textPlain);
|
|
|
|
|
|
insertHTML(textPlainDom, protyle);
|
2022-07-08 10:38:11 +08:00
|
|
|
|
filterClipboardHint(protyle, textPlainDom);
|
2022-05-26 15:18:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
blockRender(protyle, protyle.wysiwyg.element);
|
|
|
|
|
|
processRender(protyle.wysiwyg.element);
|
|
|
|
|
|
highlightRender(protyle.wysiwyg.element);
|
|
|
|
|
|
}
|
|
|
|
|
|
scrollCenter(protyle);
|
|
|
|
|
|
};
|