This commit is contained in:
Vanessa 2023-03-06 13:14:50 +08:00
parent 27a054c928
commit b399473b18
3 changed files with 17 additions and 24 deletions

View file

@ -25,7 +25,7 @@
max-height: none;
.b3-menu__submenu {
top: 54px;
top: 45px;
left: 0;
bottom: 0;
max-height: none;
@ -54,16 +54,7 @@
&__title {
padding: 8px;
line-height: 30px;
font-size: 18px;
color: var(--b3-theme-on-surface);
text-align: center;
svg {
height: 30px;
width: 20px;
float: left;
}
display: flex;
}
&__item {

View file

@ -92,7 +92,7 @@ export class Menu {
this.element.innerHTML = "";
this.element.classList.add("fn__none");
this.element.classList.remove("b3-menu--list");
this.element.classList.remove("b3-menu--list", "b3-menu--fullscreen");
this.element.removeAttribute("style"); // zIndex
window.siyuan.menus.menu.element.removeAttribute("data-name"); // 标识再次点击不消失
}
@ -121,8 +121,8 @@ export class Menu {
public fullscreen () {
this.element.classList.add("b3-menu--fullscreen");
this.element.insertAdjacentHTML("afterbegin", `<div class="b3-menu__title">
<svg><use xlink:href="#iconLeft"></use></svg>
${window.siyuan.languages.back}
<svg class="b3-menu__icon"><use xlink:href="#iconLeft"></use></svg>
<span class="b3-menu__label">${window.siyuan.languages.back}</span>
</div>`);
this.popup({x: 0, y: 0});
}

View file

@ -15,12 +15,6 @@ const renderSlashMenu = (protyle: IProtyle, toolbarElement: Element) => {
const utilElement = toolbarElement.querySelector(".keyboard__util") as HTMLElement
utilElement.innerHTML = protyle.hint.getHTMLByData(hintSlash("", protyle), false)
protyle.hint.bindUploadEvent(protyle, utilElement);
utilElement.addEventListener("click", (event) => {
const btnElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item");
if (btnElement) {
protyle.hint.fill(decodeURIComponent(btnElement.getAttribute("data-value")), protyle);
}
})
}
const renderKeyboardToolbarUtil = () => {
@ -186,6 +180,14 @@ export const initKeyboardToolbar = () => {
<div class="keyboard__util"></div>`;
toolbarElement.addEventListener("click", (event) => {
const target = event.target as HTMLElement;
const slashBtnElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item");
const protyle = window.siyuan.mobile.editor.protyle;
if (slashBtnElement) {
protyle.hint.fill(decodeURIComponent(slashBtnElement.getAttribute("data-value")), protyle);
event.preventDefault();
event.stopPropagation();
return;
}
const buttonElement = hasClosestByMatchTag(target, "BUTTON");
if (!buttonElement || buttonElement.getAttribute("disabled")) {
return;
@ -201,7 +203,6 @@ export const initKeyboardToolbar = () => {
if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly || !window.siyuan.mobile.editor) {
return;
}
const protyle = window.siyuan.mobile.editor.protyle;
if (type === "undo") {
protyle.undo.undo(protyle);
return;
@ -227,6 +228,7 @@ export const initKeyboardToolbar = () => {
const dynamicElements = document.querySelectorAll("#keyboardToolbar .keyboard__dynamic");
dynamicElements[0].classList.remove("fn__none");
dynamicElements[1].classList.add("fn__none");
range.collapse(true);
focusByRange(range);
return;
} else if (["a", "block-ref", "inline-math", "inline-memo", "text"].includes(type)) {
@ -256,12 +258,12 @@ export const initKeyboardToolbar = () => {
x: 0,
y: 0
});
hideKeyboardToolbar();
activeBlur();
return;
} else if (type === "block") {
protyle.gutter.renderMenu(protyle, nodeElement);
window.siyuan.menus.menu.popup({x: 0, y: 0}, true);
hideKeyboardToolbar();
window.siyuan.menus.menu.fullscreen();
activeBlur();
return;
} else if (type === "outdent") {
listOutdent(protyle, [nodeElement.parentElement], range);