|
@@ -28,8 +28,9 @@ import {Menu} from "../../plugin/Menu";
|
|
import {getNoContainerElement} from "../wysiwyg/getBlock";
|
|
import {getNoContainerElement} from "../wysiwyg/getBlock";
|
|
import {openTitleMenu} from "../header/openTitleMenu";
|
|
import {openTitleMenu} from "../header/openTitleMenu";
|
|
import {emitOpenMenu} from "../../plugin/EventBus";
|
|
import {emitOpenMenu} from "../../plugin/EventBus";
|
|
-import {isInAndroid, isMac, updateHotkeyTip} from "../util/compatibility";
|
|
|
|
|
|
+import {isInAndroid, isIPad, isMac, updateHotkeyTip} from "../util/compatibility";
|
|
import {resize} from "../util/resize";
|
|
import {resize} from "../util/resize";
|
|
|
|
+import {listIndent, listOutdent} from "../wysiwyg/list";
|
|
|
|
|
|
export class Breadcrumb {
|
|
export class Breadcrumb {
|
|
public element: HTMLElement;
|
|
public element: HTMLElement;
|
|
@@ -40,18 +41,25 @@ export class Breadcrumb {
|
|
constructor(protyle: IProtyle) {
|
|
constructor(protyle: IProtyle) {
|
|
const element = document.createElement("div");
|
|
const element = document.createElement("div");
|
|
element.className = "protyle-breadcrumb";
|
|
element.className = "protyle-breadcrumb";
|
|
|
|
+ let padHTML = ""
|
|
|
|
+ /// #if BROWSER
|
|
|
|
+ if (isIPad() || isInAndroid()) {
|
|
|
|
+ padHTML = `<button class="block__icon fn__flex-center ariaLabel" disabled aria-label="${window.siyuan.languages.undo}" data-type="undo"><svg><use xlink:href="#iconUndo"></use></svg></button>
|
|
|
|
+<button class="block__icon fn__flex-center ariaLabel" disabled aria-label="${window.siyuan.languages.redo}" data-type="redo"><svg><use xlink:href="#iconRedo"></use></svg></button>
|
|
|
|
+<button class="block__icon fn__flex-center ariaLabel" disabled aria-label="${window.siyuan.languages.outdent}" data-type="outdent"><svg><use xlink:href="#iconOutdent"></use></svg></button>
|
|
|
|
+<button class="block__icon fn__flex-center ariaLabel" disabled aria-label="${window.siyuan.languages.indent}" data-type="indent"><svg><use xlink:href="#iconIndent"></use></svg></button>`;
|
|
|
|
+ }
|
|
|
|
+ /// #endif
|
|
element.innerHTML = `${isMobile() ?
|
|
element.innerHTML = `${isMobile() ?
|
|
`<button class="protyle-breadcrumb__icon" data-type="mobile-menu">${window.siyuan.languages.breadcrumb}</button>` :
|
|
`<button class="protyle-breadcrumb__icon" data-type="mobile-menu">${window.siyuan.languages.breadcrumb}</button>` :
|
|
'<div class="protyle-breadcrumb__bar"></div>'}
|
|
'<div class="protyle-breadcrumb__bar"></div>'}
|
|
<span class="protyle-breadcrumb__space"></span>
|
|
<span class="protyle-breadcrumb__space"></span>
|
|
<button class="protyle-breadcrumb__icon fn__none ariaLabel" aria-label="${updateHotkeyTip(window.siyuan.config.keymap.editor.general.exitFocus.custom)}" data-type="exit-focus">${window.siyuan.languages.exitFocus}</button>
|
|
<button class="protyle-breadcrumb__icon fn__none ariaLabel" aria-label="${updateHotkeyTip(window.siyuan.config.keymap.editor.general.exitFocus.custom)}" data-type="exit-focus">${window.siyuan.languages.exitFocus}</button>
|
|
-<button class="block__icon block__icon--show fn__flex-center ariaLabel${window.siyuan.config.readonly ? " fn__none" : ""}" aria-label="${window.siyuan.languages.lockEdit}" data-type="readonly"><svg><use xlink:href="#iconUnlock"></use></svg></button>
|
|
|
|
-<span class="fn__space${window.siyuan.config.readonly ? " fn__none" : ""}"></span>
|
|
|
|
-<button class="block__icon block__icon--show fn__flex-center ariaLabel" data-type="doc" aria-label="${isMac() ? window.siyuan.languages.gutterTip2 : window.siyuan.languages.gutterTip2.replace("⇧", "Shift+")}"><svg><use xlink:href="#iconFile"></use></svg></button>
|
|
|
|
-<span class="fn__space"></span>
|
|
|
|
-<button class="block__icon block__icon--show fn__flex-center ariaLabel" data-type="more" aria-label="${window.siyuan.languages.more}"><svg><use xlink:href="#iconMore"></use></svg></button>
|
|
|
|
-<button class="block__icon block__icon--show fn__flex-center fn__none ariaLabel" style="margin-left: 8px" data-type="context" aria-label="${window.siyuan.languages.context}"><svg><use xlink:href="#iconAlignCenter"></use></svg></button>`;
|
|
|
|
-
|
|
|
|
|
|
+${padHTML}
|
|
|
|
+<button class="block__icon fn__flex-center ariaLabel${window.siyuan.config.readonly ? " fn__none" : ""}" aria-label="${window.siyuan.languages.lockEdit}" data-type="readonly"><svg><use xlink:href="#iconUnlock"></use></svg></button>
|
|
|
|
+<button class="block__icon fn__flex-center ariaLabel" data-type="doc" aria-label="${isMac() ? window.siyuan.languages.gutterTip2 : window.siyuan.languages.gutterTip2.replace("⇧", "Shift+")}"><svg><use xlink:href="#iconFile"></use></svg></button>
|
|
|
|
+<button class="block__icon fn__flex-center ariaLabel" data-type="more" aria-label="${window.siyuan.languages.more}"><svg><use xlink:href="#iconMore"></use></svg></button>
|
|
|
|
+<button class="block__icon fn__flex-center fn__none ariaLabel" data-type="context" aria-label="${window.siyuan.languages.context}"><svg><use xlink:href="#iconAlignCenter"></use></svg></button>`;
|
|
this.element = element.firstElementChild as HTMLElement;
|
|
this.element = element.firstElementChild as HTMLElement;
|
|
element.addEventListener("click", (event) => {
|
|
element.addEventListener("click", (event) => {
|
|
/// #if !MOBILE
|
|
/// #if !MOBILE
|
|
@@ -133,6 +141,36 @@ export class Breadcrumb {
|
|
target.classList.add("block__icon--active");
|
|
target.classList.add("block__icon--active");
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+ } else if (type === "undo") {
|
|
|
|
+ protyle.undo.undo(protyle);
|
|
|
|
+ event.preventDefault();
|
|
|
|
+ event.stopPropagation();
|
|
|
|
+ break;
|
|
|
|
+ } else if (type === "redo") {
|
|
|
|
+ protyle.undo.redo(protyle);
|
|
|
|
+ event.preventDefault();
|
|
|
|
+ event.stopPropagation();
|
|
|
|
+ break;
|
|
|
|
+ } else if (type === "outdent") {
|
|
|
|
+ if (protyle.toolbar.range) {
|
|
|
|
+ const blockElement = hasClosestBlock(protyle.toolbar.range.startContainer);
|
|
|
|
+ if (blockElement) {
|
|
|
|
+ listOutdent(protyle, [blockElement.parentElement], protyle.toolbar.range);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ event.preventDefault();
|
|
|
|
+ event.stopPropagation();
|
|
|
|
+ break;
|
|
|
|
+ } else if (type === "indent") {
|
|
|
|
+ if (protyle.toolbar.range) {
|
|
|
|
+ const blockElement = hasClosestBlock(protyle.toolbar.range.startContainer);
|
|
|
|
+ if (blockElement) {
|
|
|
|
+ listIndent(protyle, [blockElement.parentElement], protyle.toolbar.range);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ event.preventDefault();
|
|
|
|
+ event.stopPropagation();
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
target = target.parentElement;
|
|
target = target.parentElement;
|
|
}
|
|
}
|
|
@@ -528,9 +566,7 @@ export class Breadcrumb {
|
|
}
|
|
}
|
|
|
|
|
|
public render(protyle: IProtyle, update = false) {
|
|
public render(protyle: IProtyle, update = false) {
|
|
- if (isMobile()) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ /// #if !MOBILE
|
|
let range: Range;
|
|
let range: Range;
|
|
let blockElement: Element;
|
|
let blockElement: Element;
|
|
if (getSelection().rangeCount > 0) {
|
|
if (getSelection().rangeCount > 0) {
|
|
@@ -614,6 +650,7 @@ export class Breadcrumb {
|
|
this.element.scrollLeft = (this.element.lastElementChild as HTMLElement).offsetLeft - this.element.clientWidth + 14;
|
|
this.element.scrollLeft = (this.element.lastElementChild as HTMLElement).offsetLeft - this.element.clientWidth + 14;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ /// #endif
|
|
}
|
|
}
|
|
|
|
|
|
public hide() {
|
|
public hide() {
|