mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 01:20:12 +01:00
This commit is contained in:
parent
c976b705af
commit
9574085b03
5 changed files with 59 additions and 39 deletions
|
|
@ -222,7 +222,7 @@
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#keyboardToolbar {
|
.keyboard {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
@ -232,7 +232,23 @@
|
||||||
z-index: 212;
|
z-index: 212;
|
||||||
display: flex;
|
display: flex;
|
||||||
border-top: 1px solid var(--b3-theme-surface-lighter);
|
border-top: 1px solid var(--b3-theme-surface-lighter);
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
&__dynamic {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__split {
|
||||||
|
width: 1px;
|
||||||
|
height: 70%;
|
||||||
|
background: var(--b3-border-color);
|
||||||
|
align-self: center;
|
||||||
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
|
@ -242,8 +258,7 @@
|
||||||
svg {
|
svg {
|
||||||
height: 16px;
|
height: 16px;
|
||||||
width: 16px;
|
width: 16px;
|
||||||
padding: 5px;
|
padding: 12px;
|
||||||
margin: 3px;
|
|
||||||
color: var(--b3-theme-on-surface);
|
color: var(--b3-theme-on-surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,24 +55,7 @@
|
||||||
<div id="commonMenu" class="b3-menu fn__none"></div>
|
<div id="commonMenu" class="b3-menu fn__none"></div>
|
||||||
<div id="message" class="b3-snackbars"></div>
|
<div id="message" class="b3-snackbars"></div>
|
||||||
<div id="status" class="status status--hide"></div>
|
<div id="status" class="status status--hide"></div>
|
||||||
<div id="keyboardToolbar" class="fn__none">
|
<div id="keyboardToolbar" class="keyboard"></div>
|
||||||
<span class="fn__flex-1"></span>
|
|
||||||
<button data-type="indent"><svg><use xlink:href="#iconIndent"></use></svg></button>
|
|
||||||
<button data-type="outdent"><svg><use xlink:href="#iconOutdent"></use></svg></button>
|
|
||||||
|
|
||||||
<button data-type="up"><svg><use xlink:href="#iconUp"></use></svg></button>
|
|
||||||
<button data-type="down"><svg><use xlink:href="#iconDown"></use></svg></button>
|
|
||||||
|
|
||||||
<button data-type="before"><svg><use xlink:href="#iconBefore"></use></svg></button>
|
|
||||||
<button data-type="after"><svg><use xlink:href="#iconAfter"></use></svg></button>
|
|
||||||
|
|
||||||
<button data-type="clear"><svg><use xlink:href="#iconClear"></use></svg></button>
|
|
||||||
|
|
||||||
<button data-type="undo"><svg><use xlink:href="#iconUndo"></use></svg></button>
|
|
||||||
<button data-type="redo"><svg><use xlink:href="#iconRedo"></use></svg></button>
|
|
||||||
<span class="fn__flex-1"></span>
|
|
||||||
<button data-type="done"><svg><use xlink:href="#iconRedo"></use></svg></button>
|
|
||||||
</div>
|
|
||||||
<div id="transactionTip" class="fn__none"></div>
|
<div id="transactionTip" class="fn__none"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -193,24 +193,18 @@ export const transactionError = (data: { code: number, data: string }) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
let progressStatusTimeoutId: number;
|
|
||||||
export const progressStatus = (data: IWebSocketData) => {
|
export const progressStatus = (data: IWebSocketData) => {
|
||||||
const statusElement = document.querySelector("#status") as HTMLElement;
|
const statusElement = document.querySelector("#status") as HTMLElement;
|
||||||
if (!statusElement) {
|
if (!statusElement) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isMobile()) {
|
if (isMobile()) {
|
||||||
clearTimeout(progressStatusTimeoutId);
|
if (!document.querySelector("#keyboardToolbar").classList.contains("fn__none")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
statusElement.innerHTML = data.msg;
|
statusElement.innerHTML = data.msg;
|
||||||
statusElement.classList.remove("status--hide");
|
statusElement.classList.remove("status--hide");
|
||||||
if (document.querySelector("#keyboardToolbar").classList.contains("fn__none")) {
|
|
||||||
statusElement.style.bottom = "0";
|
statusElement.style.bottom = "0";
|
||||||
} else {
|
|
||||||
statusElement.style.bottom = "30px";
|
|
||||||
}
|
|
||||||
progressStatusTimeoutId = window.setTimeout(() => {
|
|
||||||
statusElement.style.bottom = "";
|
|
||||||
}, 6000);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const msgElement = statusElement.querySelector(".status__msg");
|
const msgElement = statusElement.querySelector(".status__msg");
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,14 @@ import {Constants} from "../../constants";
|
||||||
import {focusByRange, getSelectionPosition} from "../../protyle/util/selection";
|
import {focusByRange, getSelectionPosition} from "../../protyle/util/selection";
|
||||||
|
|
||||||
export const showKeyboardToolbar = (bottom = 0) => {
|
export const showKeyboardToolbar = (bottom = 0) => {
|
||||||
if (getSelection().rangeCount > 0) {
|
if (getSelection().rangeCount === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const range = getSelection().getRangeAt(0);
|
const range = getSelection().getRangeAt(0);
|
||||||
if (!window.siyuan.mobile.editor ||
|
if (!window.siyuan.mobile.editor ||
|
||||||
!window.siyuan.mobile.editor.protyle.wysiwyg.element.contains(range.startContainer)) {
|
!window.siyuan.mobile.editor.protyle.wysiwyg.element.contains(range.startContainer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const toolbarElement = document.getElementById("keyboardToolbar");
|
const toolbarElement = document.getElementById("keyboardToolbar");
|
||||||
if (!toolbarElement.classList.contains("fn__none")) {
|
if (!toolbarElement.classList.contains("fn__none")) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -36,6 +35,28 @@ export const showKeyboardToolbar = (bottom = 0) => {
|
||||||
}, Constants.TIMEOUT_TRANSITION);
|
}, Constants.TIMEOUT_TRANSITION);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const renderKeyboardToolbar = (protyle: IProtyle, range: Range) => {
|
||||||
|
const toolbarElement = document.getElementById("keyboardToolbar");
|
||||||
|
toolbarElement.innerHTML = `<div class="keyboard__dynamic">
|
||||||
|
<button data-type="indent"><svg><use xlink:href="#iconIndent"></use></svg></button>
|
||||||
|
<button data-type="outdent"><svg><use xlink:href="#iconOutdent"></use></svg></button>
|
||||||
|
|
||||||
|
<button data-type="up"><svg><use xlink:href="#iconUp"></use></svg></button>
|
||||||
|
<button data-type="down"><svg><use xlink:href="#iconDown"></use></svg></button>
|
||||||
|
|
||||||
|
<button data-type="before"><svg><use xlink:href="#iconBefore"></use></svg></button>
|
||||||
|
<button data-type="after"><svg><use xlink:href="#iconAfter"></use></svg></button>
|
||||||
|
|
||||||
|
<button data-type="clear"><svg><use xlink:href="#iconClear"></use></svg></button>
|
||||||
|
|
||||||
|
<button data-type="undo"><svg><use xlink:href="#iconUndo"></use></svg></button>
|
||||||
|
<button data-type="redo"><svg><use xlink:href="#iconRedo"></use></svg></button>
|
||||||
|
</div>
|
||||||
|
<span class="fn__flex-1"></span>
|
||||||
|
<span class="keyboard__split"></span>
|
||||||
|
<button data-type="done"><svg style="width: 36px"><use xlink:href="#iconRedo"></use></svg></button>`
|
||||||
|
}
|
||||||
|
|
||||||
export const hideKeyboardToolbar = () => {
|
export const hideKeyboardToolbar = () => {
|
||||||
const toolbarElement = document.getElementById("keyboardToolbar");
|
const toolbarElement = document.getElementById("keyboardToolbar");
|
||||||
toolbarElement.classList.add("fn__none");
|
toolbarElement.classList.add("fn__none");
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,8 @@ import {getAllModels} from "../../layout/getAll";
|
||||||
import {pushBack} from "../../util/backForward";
|
import {pushBack} from "../../util/backForward";
|
||||||
import {openAsset, openBy, openFileById} from "../../editor/util";
|
import {openAsset, openBy, openFileById} from "../../editor/util";
|
||||||
import {openGlobalSearch} from "../../search/util";
|
import {openGlobalSearch} from "../../search/util";
|
||||||
|
/// #else
|
||||||
|
import {renderKeyboardToolbar} from "../../mobile/util/showKeyboardToolbar";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {BlockPanel} from "../../block/Panel";
|
import {BlockPanel} from "../../block/Panel";
|
||||||
import {isCtrl, openByMobile} from "../util/compatibility";
|
import {isCtrl, openByMobile} from "../util/compatibility";
|
||||||
|
|
@ -1895,11 +1897,16 @@ export class WYSIWYG {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// 选中后,在选中的文字上点击需等待 range 更新
|
// 选中后,在选中的文字上点击需等待 range 更新
|
||||||
const newRange = getEditorRange(this.element);
|
const newRange = getEditorRange(this.element);
|
||||||
|
/// #if !MOBILE
|
||||||
if (newRange.toString().replace(Constants.ZWSP, "") !== "") {
|
if (newRange.toString().replace(Constants.ZWSP, "") !== "") {
|
||||||
protyle.toolbar.render(protyle, newRange);
|
protyle.toolbar.render(protyle, newRange);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
hideElements(["toolbar"], protyle);
|
hideElements(["toolbar"], protyle);
|
||||||
}
|
}
|
||||||
|
/// #else
|
||||||
|
renderKeyboardToolbar(protyle, newRange);
|
||||||
|
/// #endif
|
||||||
if (!protyle.wysiwyg.element.querySelector(".protyle-wysiwyg--select")) {
|
if (!protyle.wysiwyg.element.querySelector(".protyle-wysiwyg--select")) {
|
||||||
countSelectWord(newRange, protyle.block.rootID);
|
countSelectWord(newRange, protyle.block.rootID);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue