This commit is contained in:
parent
b244f8aed1
commit
d4f94b9b1b
3 changed files with 7 additions and 12 deletions
|
@ -343,13 +343,6 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
|
|||
const range = getEditorRange(protyle.wysiwyg.element);
|
||||
if (nodeElement.getAttribute("data-type") === "NodeCodeBlock" ||
|
||||
protyle.toolbar.getCurrentType(range).includes("code")) {
|
||||
// 粘贴在代码位置
|
||||
// https://github.com/siyuan-note/siyuan/issues/9142
|
||||
// https://github.com/siyuan-note/siyuan/issues/9323
|
||||
// 需排除行内代码 https://github.com/siyuan-note/siyuan/issues/9369
|
||||
if (nodeElement.querySelector(".protyle-action")?.contains(range.startContainer)) {
|
||||
range.setStart(nodeElement.querySelector(".hljs").firstChild, 0);
|
||||
}
|
||||
insertHTML(textPlain, protyle);
|
||||
return;
|
||||
} else if (siyuanHTML) {
|
||||
|
|
|
@ -2080,6 +2080,12 @@ export class WYSIWYG {
|
|||
protyle.breadcrumb.render(protyle, false, hasClosestBlock(event.target));
|
||||
}
|
||||
const range = getEditorRange(this.element);
|
||||
// https://github.com/siyuan-note/siyuan/issues/12317
|
||||
if (range.startContainer.nodeType !== 3 &&
|
||||
(range.startContainer as Element).classList.contains("protyle-action") &&
|
||||
range.startContainer.parentElement.classList.contains("code-block")) {
|
||||
setFirstNodeRange(range.startContainer.parentElement.querySelector(".hljs").lastElementChild, range);
|
||||
}
|
||||
// 需放在嵌入块之前,否则嵌入块内的引用、链接、pdf 双链无法点击打开 https://ld246.com/article/1630479789513
|
||||
const aElement = hasClosestByAttribute(event.target, "data-type", "a") ||
|
||||
hasClosestByClassName(event.target, "av__celltext--url"); // 数据库中资源文件、链接、电话、邮箱单元格
|
||||
|
|
|
@ -1570,10 +1570,6 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
const tabSpace = window.siyuan.config.editor.codeTabSpaces === 0 ? "\t" : "".padStart(window.siyuan.config.editor.codeTabSpaces, " ");
|
||||
if (nodeElement.getAttribute("data-type") === "NodeCodeBlock" && selectText !== "") {
|
||||
const wbrElement = document.createElement("wbr");
|
||||
// https://github.com/siyuan-note/siyuan/issues/8911
|
||||
if (range.startContainer.nodeType !== 3 && (range.startContainer as Element).classList.contains("protyle-action")) {
|
||||
range.setStart(nodeElement.querySelector(".hljs").firstChild, 0);
|
||||
}
|
||||
range.insertNode(wbrElement);
|
||||
range.setStartAfter(wbrElement);
|
||||
const oldHTML = nodeElement.outerHTML;
|
||||
|
@ -1601,7 +1597,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
}).value + "<br>");
|
||||
range.setStart(wbrElement.nextSibling, 0);
|
||||
const brElement = wbrElement.parentElement.querySelector("br");
|
||||
range.setEnd(brElement.previousSibling, brElement.previousSibling.textContent.length);
|
||||
setLastNodeRange(brElement.previousSibling as Element, range, false);
|
||||
brElement.remove();
|
||||
updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, oldHTML);
|
||||
wbrElement.remove();
|
||||
|
|
Loading…
Add table
Reference in a new issue