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

View file

@ -92,7 +92,7 @@ export class Menu {
this.element.innerHTML = ""; this.element.innerHTML = "";
this.element.classList.add("fn__none"); 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 this.element.removeAttribute("style"); // zIndex
window.siyuan.menus.menu.element.removeAttribute("data-name"); // 标识再次点击不消失 window.siyuan.menus.menu.element.removeAttribute("data-name"); // 标识再次点击不消失
} }
@ -121,8 +121,8 @@ export class Menu {
public fullscreen () { public fullscreen () {
this.element.classList.add("b3-menu--fullscreen"); this.element.classList.add("b3-menu--fullscreen");
this.element.insertAdjacentHTML("afterbegin", `<div class="b3-menu__title"> this.element.insertAdjacentHTML("afterbegin", `<div class="b3-menu__title">
<svg><use xlink:href="#iconLeft"></use></svg> <svg class="b3-menu__icon"><use xlink:href="#iconLeft"></use></svg>
${window.siyuan.languages.back} <span class="b3-menu__label">${window.siyuan.languages.back}</span>
</div>`); </div>`);
this.popup({x: 0, y: 0}); 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 const utilElement = toolbarElement.querySelector(".keyboard__util") as HTMLElement
utilElement.innerHTML = protyle.hint.getHTMLByData(hintSlash("", protyle), false) utilElement.innerHTML = protyle.hint.getHTMLByData(hintSlash("", protyle), false)
protyle.hint.bindUploadEvent(protyle, utilElement); 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 = () => { const renderKeyboardToolbarUtil = () => {
@ -186,6 +180,14 @@ export const initKeyboardToolbar = () => {
<div class="keyboard__util"></div>`; <div class="keyboard__util"></div>`;
toolbarElement.addEventListener("click", (event) => { toolbarElement.addEventListener("click", (event) => {
const target = event.target as HTMLElement; 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"); const buttonElement = hasClosestByMatchTag(target, "BUTTON");
if (!buttonElement || buttonElement.getAttribute("disabled")) { if (!buttonElement || buttonElement.getAttribute("disabled")) {
return; return;
@ -201,7 +203,6 @@ export const initKeyboardToolbar = () => {
if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly || !window.siyuan.mobile.editor) { if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly || !window.siyuan.mobile.editor) {
return; return;
} }
const protyle = window.siyuan.mobile.editor.protyle;
if (type === "undo") { if (type === "undo") {
protyle.undo.undo(protyle); protyle.undo.undo(protyle);
return; return;
@ -227,6 +228,7 @@ export const initKeyboardToolbar = () => {
const dynamicElements = document.querySelectorAll("#keyboardToolbar .keyboard__dynamic"); const dynamicElements = document.querySelectorAll("#keyboardToolbar .keyboard__dynamic");
dynamicElements[0].classList.remove("fn__none"); dynamicElements[0].classList.remove("fn__none");
dynamicElements[1].classList.add("fn__none"); dynamicElements[1].classList.add("fn__none");
range.collapse(true);
focusByRange(range); focusByRange(range);
return; return;
} else if (["a", "block-ref", "inline-math", "inline-memo", "text"].includes(type)) { } else if (["a", "block-ref", "inline-math", "inline-memo", "text"].includes(type)) {
@ -256,12 +258,12 @@ export const initKeyboardToolbar = () => {
x: 0, x: 0,
y: 0 y: 0
}); });
hideKeyboardToolbar(); activeBlur();
return; return;
} else if (type === "block") { } else if (type === "block") {
protyle.gutter.renderMenu(protyle, nodeElement); protyle.gutter.renderMenu(protyle, nodeElement);
window.siyuan.menus.menu.popup({x: 0, y: 0}, true); window.siyuan.menus.menu.fullscreen();
hideKeyboardToolbar(); activeBlur();
return; return;
} else if (type === "outdent") { } else if (type === "outdent") {
listOutdent(protyle, [nodeElement.parentElement], range); listOutdent(protyle, [nodeElement.parentElement], range);