Vanessa 2024-11-13 15:29:09 +08:00
parent 56904648b9
commit 1eaa79c999
2 changed files with 17 additions and 18 deletions

View file

@ -1716,21 +1716,20 @@ export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => {
label: window.siyuan.languages.copy,
icon: "iconCopy",
click() {
writeText(protyle.lute.BlockDOM2StdMd(tagElement.outerHTML));
const range = document.createRange()
range.selectNode(tagElement);
focusByRange(range)
document.execCommand("copy");
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.cut,
icon: "iconCut",
click() {
writeText(protyle.lute.BlockDOM2StdMd(tagElement.outerHTML));
const oldHTML = nodeElement.outerHTML;
tagElement.insertAdjacentHTML("afterend", "<wbr>");
tagElement.remove();
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);
focusByWbr(nodeElement, protyle.toolbar.range);
const range = document.createRange()
range.selectNode(tagElement);
focusByRange(range)
document.execCommand("cut");
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
@ -1781,7 +1780,10 @@ export const inlineMathMenu = (protyle: IProtyle, element: Element) => {
label: window.siyuan.languages.copy,
icon: "iconCopy",
click() {
writeText(protyle.lute.BlockDOM2StdMd(element.outerHTML));
const range = document.createRange()
range.selectNode(element);
focusByRange(range)
document.execCommand("copy");
}
}).element);
if (!protyle.disabled) {
@ -1789,13 +1791,10 @@ export const inlineMathMenu = (protyle: IProtyle, element: Element) => {
icon: "iconCut",
label: window.siyuan.languages.cut,
click() {
writeText(protyle.lute.BlockDOM2StdMd(element.outerHTML));
element.insertAdjacentHTML("afterend", "<wbr>");
element.remove();
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
updateTransaction(protyle, id, nodeElement.outerHTML, html);
focusByWbr(nodeElement, protyle.toolbar.range);
const range = document.createRange()
range.selectNode(element);
focusByRange(range)
document.execCommand("cut");
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({

View file

@ -1775,7 +1775,7 @@ export class WYSIWYG {
protyle.toolbar.range = getEditorRange(protyle.element);
if (target.tagName === "SPAN" && !isNotEditBlock(nodeElement)) { // https://ld246.com/article/1665141518103
let types = target.getAttribute("data-type")?.split(" ");
let types = target.getAttribute("data-type")?.split(" ") || [];
if (types.length === 0) {
// https://github.com/siyuan-note/siyuan/issues/8960
types = (target.dataset.type || "").split(" ");