diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts
index 3565662d6..dba0aecb2 100644
--- a/app/src/mobile/util/keyboardToolbar.ts
+++ b/app/src/mobile/util/keyboardToolbar.ts
@@ -1,6 +1,5 @@
import {listIndent, listOutdent} from "../../protyle/wysiwyg/list";
import {hasClosestBlock, hasClosestByClassName, hasClosestByMatchTag} from "../../protyle/util/hasClosest";
-import {insertEmptyBlock} from "../../block/util";
import {moveToDown, moveToUp} from "../../protyle/wysiwyg/move";
import {Constants} from "../../constants";
import {focusByRange, getSelectionPosition} from "../../protyle/util/selection";
@@ -62,6 +61,19 @@ export const renderKeyboardToolbar = () => {
} else {
dynamicElements[0].querySelector('[data-type="redo"]').removeAttribute("disabled");
}
+ const nodeElement = hasClosestBlock(range.startContainer);
+ if (nodeElement) {
+ const indentElement = dynamicElements[0].querySelector('[data-type="indent"]')
+ if (nodeElement.parentElement.classList.contains("li")) {
+ indentElement.classList.remove("fn__none");
+ indentElement.nextElementSibling.classList.remove("fn__none");
+ indentElement.nextElementSibling.nextElementSibling.classList.remove("fn__none");
+ } else {
+ indentElement.classList.add("fn__none");
+ indentElement.nextElementSibling.classList.add("fn__none");
+ indentElement.nextElementSibling.nextElementSibling.classList.add("fn__none");
+ }
+ }
}
if (selectText && isProtyle) {
dynamicElements[1].classList.remove("fn__none");
@@ -88,19 +100,20 @@ export const initKeyboardToolbar = () => {
const toolbarElement = document.getElementById("keyboardToolbar");
toolbarElement.innerHTML = `
+
+
+
-
-
+
+
-
-
-
-
+
+
@@ -145,24 +158,20 @@ export const initKeyboardToolbar = () => {
if (type === "undo") {
protyle.undo.undo(protyle);
return;
- }
- if (type === "redo") {
+ } else if (type === "redo") {
protyle.undo.redo(protyle);
return;
- }
- if (type === "goback") {
+ } else if (type === "goback") {
const dynamicElements = document.querySelectorAll("#keyboardToolbar .keyboard__dynamic");
dynamicElements[0].classList.remove("fn__none");
dynamicElements[1].classList.add("fn__none");
return;
- }
- if (type === "goinline") {
+ } else if (type === "goinline") {
const dynamicElements = document.querySelectorAll("#keyboardToolbar .keyboard__dynamic");
dynamicElements[1].classList.remove("fn__none");
dynamicElements[0].classList.add("fn__none");
return;
}
-
if (getSelection().rangeCount === 0) {
return;
}
@@ -174,53 +183,34 @@ export const initKeyboardToolbar = () => {
// inline element
if (["a", "block-ref", "inline-math", "inline-memo", "text"].includes(type)) {
protyle.toolbar.element.querySelector(`[data-type="${type}"]`).dispatchEvent(new CustomEvent("text" === type ? getEventName() : "click"));
- return true;
- }
- if (["strong", "em", "s", "code", "mark", "tag", "u", "sup", "clear", "sub", "kbd"].includes(type)) {
+ return;
+ } else if (["strong", "em", "s", "code", "mark", "tag", "u", "sup", "clear", "sub", "kbd"].includes(type)) {
protyle.toolbar.setInlineMark(protyle, type, "toolbar");
return;
- }
- // TODO block element
- if (type === "up") {
+ } else if (type === "moveup") {
moveToUp(protyle, nodeElement, range);
focusByRange(range);
return;
- }
- if (type === "down") {
+ } else if (type === "movedown") {
moveToDown(protyle, nodeElement, range);
focusByRange(range);
return;
- }
-
- if (type === "before") {
- insertEmptyBlock(protyle, "beforebegin");
+ } else if (type === "remove") {
+ // TODO
return;
- }
- if (type === "after") {
- insertEmptyBlock(protyle, "afterend");
+ } else if (type === "add") {
+ // TODO
return;
- }
-
- if (type === "clear") {
- if (range.toString()) {
- protyle.toolbar.setInlineMark(protyle, "clear", "toolbar");
- } else if (range.startContainer.nodeType === 3 && range.startContainer.parentElement.tagName === "SPAN") {
- range.setStartAfter(range.startContainer.parentElement);
- range.collapse(false);
- range.insertNode(document.createTextNode(Constants.ZWSP));
- range.collapse(false);
- }
- focusByRange(range);
+ } else if (type === "appearance") {
+ // TODO
return;
- }
-
- if (!nodeElement.parentElement.classList.contains("li") || nodeElement.getAttribute("data-type") === "NodeCodeBlock") {
- focusByRange(range);
+ } else if (type === "block") {
+ // TODO
return;
- }
- if (type === "outdent") {
+ } else if (type === "outdent") {
listOutdent(protyle, [nodeElement.parentElement], range);
focusByRange(range);
+ return;
} else if (type === "indent") {
listIndent(protyle, [nodeElement.parentElement], range);
focusByRange(range);