mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
This commit is contained in:
parent
591d65b973
commit
4dfea2f9a6
2 changed files with 5 additions and 3 deletions
|
|
@ -7,7 +7,7 @@ import {focusBlock, getEditorRange, focusByWbr, fixTableRange} from "./selection
|
||||||
import {mathRender} from "../markdown/mathRender";
|
import {mathRender} from "../markdown/mathRender";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
|
|
||||||
export const insertHTML = (html: string, protyle: IProtyle, isBlock = false, splitSpan = true) => {
|
export const insertHTML = (html: string, protyle: IProtyle, isBlock = false) => {
|
||||||
if (html === "") {
|
if (html === "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +73,9 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false, spl
|
||||||
}
|
}
|
||||||
// 粘贴带样式的行内元素到另一个行内元素中需进行切割
|
// 粘贴带样式的行内元素到另一个行内元素中需进行切割
|
||||||
const spanElement = range.startContainer.nodeType === 3 ? range.startContainer.parentElement: range.startContainer as HTMLElement;
|
const spanElement = range.startContainer.nodeType === 3 ? range.startContainer.parentElement: range.startContainer as HTMLElement;
|
||||||
if (splitSpan && spanElement.tagName === "SPAN" && spanElement.isSameNode( range.endContainer.nodeType === 3 ? range.endContainer.parentElement: range.endContainer)) {
|
if (spanElement.tagName === "SPAN" && spanElement.isSameNode( range.endContainer.nodeType === 3 ? range.endContainer.parentElement: range.endContainer) &&
|
||||||
|
tempElement.content.querySelector("span") // 粘贴纯文本不需切割 https://ld246.com/article/1665556907936
|
||||||
|
) {
|
||||||
const afterElement = document.createElement("span");
|
const afterElement = document.createElement("span");
|
||||||
const attributes = spanElement.attributes;
|
const attributes = spanElement.attributes;
|
||||||
for (let i = 0; i < attributes.length; i++) {
|
for (let i = 0; i < attributes.length; i++) {
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ export const pasteAsPlainText = async (protyle:IProtyle) => {
|
||||||
uploadLocalFiles(localFiles, protyle, false);
|
uploadLocalFiles(localFiles, protyle, false);
|
||||||
writeText("");
|
writeText("");
|
||||||
} else {
|
} else {
|
||||||
insertHTML(protyle.lute.BlockDOM2Content(protyle.lute.InlineMd2BlockDOM(clipboard.readText())), protyle, false, false);
|
insertHTML(protyle.lute.BlockDOM2Content(protyle.lute.InlineMd2BlockDOM(clipboard.readText())), protyle, false);
|
||||||
}
|
}
|
||||||
/// #endif
|
/// #endif
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue