mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-04 11:50:15 +01:00
This commit is contained in:
parent
7881d97e84
commit
0e23e2c04b
12 changed files with 39 additions and 53 deletions
|
|
@ -170,8 +170,7 @@ export class Gutter {
|
|||
openAttr(protyle.wysiwyg.element.querySelector(`[data-node-id="${id}"]`), protyle);
|
||||
} else {
|
||||
this.renderMenu(protyle, buttonElement);
|
||||
window.siyuan.menus.menu.element.classList.remove("fn__none");
|
||||
setPosition(window.siyuan.menus.menu.element, event.clientX - window.siyuan.menus.menu.element.clientWidth - 16, event.clientY - 16);
|
||||
window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16}, true)
|
||||
// https://ld246.com/article/1648433751993
|
||||
if (!protyle.toolbar.range) {
|
||||
protyle.toolbar.range = getEditorRange(protyle.wysiwyg.element.firstElementChild);
|
||||
|
|
@ -186,8 +185,7 @@ export class Gutter {
|
|||
}
|
||||
if (!window.siyuan.ctrlIsPressed && !window.siyuan.altIsPressed && !window.siyuan.shiftIsPressed) {
|
||||
this.renderMenu(protyle, buttonElement);
|
||||
window.siyuan.menus.menu.element.classList.remove("fn__none");
|
||||
setPosition(window.siyuan.menus.menu.element, event.clientX - window.siyuan.menus.menu.element.clientWidth - 16, event.clientY - 16);
|
||||
window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16}, true)
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
|
|
|||
|
|
@ -422,9 +422,8 @@ export class Background {
|
|||
}
|
||||
this.addTags(listItemElement.textContent);
|
||||
});
|
||||
window.siyuan.menus.menu.element.classList.remove("fn__none");
|
||||
const rect = this.iconElement.nextElementSibling.getBoundingClientRect();
|
||||
setPosition(window.siyuan.menus.menu.element, rect.left, rect.top + rect.height);
|
||||
window.siyuan.menus.menu.popup({x: rect.left, y: rect.top + rect.height})
|
||||
inputElement.focus();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,8 +192,7 @@ export class Title {
|
|||
focusByRange(range);
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.element.classList.remove("fn__none");
|
||||
setPosition(window.siyuan.menus.menu.element, event.clientX, event.clientY);
|
||||
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY})
|
||||
});
|
||||
this.element.querySelector(".protyle-attr").addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
|
||||
fetchPost("/api/block/getDocInfo", {
|
||||
|
|
|
|||
|
|
@ -601,9 +601,11 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
|
|||
highlightRender(nodeElement);
|
||||
} else if (value.startsWith("<iframe") || value.startsWith("<video") || value.startsWith("<audio")) {
|
||||
protyle.gutter.renderMenu(protyle, nodeElement);
|
||||
window.siyuan.menus.menu.element.classList.remove("fn__none");
|
||||
const rect = nodeElement.getBoundingClientRect();
|
||||
setPosition(window.siyuan.menus.menu.element, rect.left - window.siyuan.menus.menu.element.clientWidth, rect.top);
|
||||
window.siyuan.menus.menu.popup({
|
||||
x: rect.left,
|
||||
y: rect.top
|
||||
}, true)
|
||||
window.siyuan.menus.menu.element.querySelector('[data-id="assetSubMenu"]').classList.add("b3-menu__item--show");
|
||||
window.siyuan.menus.menu.element.querySelectorAll("input")[0].focus();
|
||||
} else if (value === "---") {
|
||||
|
|
|
|||
|
|
@ -272,8 +272,6 @@ export class Toolbar {
|
|||
if (type === "link") {
|
||||
this.element.classList.add("fn__none");
|
||||
linkMenu(protyle, this.range.startContainer.parentElement);
|
||||
const rect = this.range.startContainer.parentElement.getBoundingClientRect();
|
||||
setPosition(window.siyuan.menus.menu.element, rect.left, rect.top + 13, 26);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -334,8 +332,6 @@ export class Toolbar {
|
|||
if (types.length > 0 && types.includes("link") && action === "range") {
|
||||
// 链接快捷键不应取消,应该显示链接信息
|
||||
linkMenu(protyle, this.range.startContainer.parentElement);
|
||||
const rect = this.range.startContainer.parentElement.getBoundingClientRect();
|
||||
setPosition(window.siyuan.menus.menu.element, rect.left, rect.top + 13, 26);
|
||||
return;
|
||||
}
|
||||
const wbrElement = document.createElement("wbr");
|
||||
|
|
@ -515,8 +511,6 @@ export class Toolbar {
|
|||
}
|
||||
if (needShowLink) {
|
||||
linkMenu(protyle, newElement as HTMLElement, focusText);
|
||||
const rect = newElement.getBoundingClientRect();
|
||||
setPosition(window.siyuan.menus.menu.element, rect.left, rect.top + 13, 26);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -427,8 +427,7 @@ export class WYSIWYG {
|
|||
// 多选块
|
||||
hideElements(["util"], protyle);
|
||||
protyle.gutter.renderMenu(protyle, selectElements[0]);
|
||||
window.siyuan.menus.menu.element.classList.remove("fn__none");
|
||||
setPosition(window.siyuan.menus.menu.element, event.clientX, event.clientY);
|
||||
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY})
|
||||
return;
|
||||
}
|
||||
const target = event.target as HTMLElement;
|
||||
|
|
@ -438,8 +437,7 @@ export class WYSIWYG {
|
|||
focusSideBlock(embedElement);
|
||||
}
|
||||
protyle.gutter.renderMenu(protyle, embedElement);
|
||||
window.siyuan.menus.menu.element.classList.remove("fn__none");
|
||||
setPosition(window.siyuan.menus.menu.element, event.clientX, event.clientY);
|
||||
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY})
|
||||
return false;
|
||||
}
|
||||
if (protyle.disabled) {
|
||||
|
|
@ -449,8 +447,6 @@ export class WYSIWYG {
|
|||
const type = target.getAttribute("data-type");
|
||||
if (type === "block-ref") {
|
||||
refMenu(protyle, target);
|
||||
const rect = target.getBoundingClientRect();
|
||||
setPosition(window.siyuan.menus.menu.element, rect.left, rect.top + 13, 26);
|
||||
// 阻止 popover
|
||||
target.setAttribute("prevent-popover", "true");
|
||||
setTimeout(() => {
|
||||
|
|
@ -464,8 +460,6 @@ export class WYSIWYG {
|
|||
}
|
||||
if (type === "a") {
|
||||
linkMenu(protyle, target);
|
||||
const rect = target.getBoundingClientRect();
|
||||
setPosition(window.siyuan.menus.menu.element, rect.left, rect.top + 13, 26);
|
||||
if (target.getAttribute("data-href")?.startsWith("siyuan://blocks")) {
|
||||
// 阻止 popover
|
||||
target.setAttribute("prevent-popover", "true");
|
||||
|
|
@ -490,8 +484,7 @@ export class WYSIWYG {
|
|||
(isMobile() || beforeContextmenuRange && nodeElement.contains(beforeContextmenuRange.startContainer))) {
|
||||
if (!isMobile() || protyle.toolbar?.element.classList.contains("fn__none")) {
|
||||
contentMenu(protyle, nodeElement);
|
||||
window.siyuan.menus.menu.element.classList.remove("fn__none");
|
||||
setPosition(window.siyuan.menus.menu.element, event.clientX, event.clientY + 13, 26);
|
||||
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY + 13, h: 26})
|
||||
protyle.toolbar?.element.classList.add("fn__none");
|
||||
if (nodeElement.classList.contains("table")) {
|
||||
nodeElement.querySelector("table").classList.remove("select");
|
||||
|
|
@ -501,8 +494,7 @@ export class WYSIWYG {
|
|||
} else if (protyle.toolbar.range.toString() === "") {
|
||||
hideElements(["util"], protyle);
|
||||
protyle.gutter.renderMenu(protyle, nodeElement);
|
||||
window.siyuan.menus.menu.element.classList.remove("fn__none");
|
||||
setPosition(window.siyuan.menus.menu.element, event.clientX, event.clientY);
|
||||
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY})
|
||||
protyle.toolbar?.element.classList.add("fn__none");
|
||||
}
|
||||
});
|
||||
|
|
@ -1140,8 +1132,7 @@ export class WYSIWYG {
|
|||
}
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.element.classList.remove("fn__none");
|
||||
setPosition(window.siyuan.menus.menu.element, mouseUpEvent.clientX - 8, mouseUpEvent.clientY - 16);
|
||||
window.siyuan.menus.menu.popup({x: mouseUpEvent.clientX - 8, y: mouseUpEvent.clientY - 16})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1575,9 +1566,11 @@ export class WYSIWYG {
|
|||
const menuElement = hasClosestByClassName(event.target, "protyle-action__menu");
|
||||
if (menuElement && !protyle.disabled) {
|
||||
protyle.gutter.renderMenu(protyle, menuElement.parentElement.parentElement);
|
||||
window.siyuan.menus.menu.element.classList.remove("fn__none");
|
||||
const rect = menuElement.getBoundingClientRect();
|
||||
setPosition(window.siyuan.menus.menu.element, rect.left - window.siyuan.menus.menu.element.clientWidth, rect.top);
|
||||
window.siyuan.menus.menu.popup({
|
||||
x: rect.left,
|
||||
y: rect.top
|
||||
}, true)
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return;
|
||||
|
|
@ -1666,8 +1659,10 @@ export class WYSIWYG {
|
|||
updateTransaction(protyle, actionElement.parentElement.getAttribute("data-node-id"), actionElement.parentElement.outerHTML, html);
|
||||
} else {
|
||||
protyle.gutter.renderMenu(protyle, actionElement.parentElement);
|
||||
window.siyuan.menus.menu.element.classList.remove("fn__none");
|
||||
setPosition(window.siyuan.menus.menu.element, event.clientX - window.siyuan.menus.menu.element.clientWidth - 16, event.clientY - 16);
|
||||
window.siyuan.menus.menu.popup({
|
||||
x: event.clientX - 16,
|
||||
y: event.clientY - 16
|
||||
}, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -513,16 +513,12 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
const type = inlineElement.getAttribute("data-type");
|
||||
if (type === "block-ref") {
|
||||
refMenu(protyle, inlineElement);
|
||||
const rect = inlineElement.getBoundingClientRect();
|
||||
setPosition(window.siyuan.menus.menu.element, rect.left, rect.top + 13, 26);
|
||||
return;
|
||||
} else if (type === "file-annotation-ref") {
|
||||
protyle.toolbar.showFileAnnotationRef(protyle, inlineElement);
|
||||
return;
|
||||
} else if (type === "a") {
|
||||
linkMenu(protyle, inlineElement);
|
||||
const rect = inlineElement.getBoundingClientRect();
|
||||
setPosition(window.siyuan.menus.menu.element, rect.left, rect.top + 13, 26);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -544,9 +540,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
actionElement = selectElements[0] as HTMLElement;
|
||||
}
|
||||
protyle.gutter.renderMenu(protyle, actionElement);
|
||||
window.siyuan.menus.menu.element.classList.remove("fn__none");
|
||||
const rect = nodeElement.getBoundingClientRect();
|
||||
setPosition(window.siyuan.menus.menu.element, rect.left - window.siyuan.menus.menu.element.clientWidth, rect.top);
|
||||
window.siyuan.menus.menu.popup({x: rect.left, y: rect.top}, true)
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue