mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-19 02:21:38 +08:00
🚨
This commit is contained in:
parent
e93fd2ba10
commit
c8604cf19e
@ -220,7 +220,7 @@ export class Outline extends Model {
|
||||
|
||||
public setCurrent(nodeElement: HTMLElement) {
|
||||
if (nodeElement.getAttribute("data-type") === "NodeHeading") {
|
||||
this.setCurrentById(nodeElement.getAttribute("data-node-id"))
|
||||
this.setCurrentById(nodeElement.getAttribute("data-node-id"));
|
||||
} else {
|
||||
let previousElement = getPreviousBlock(nodeElement);
|
||||
while (previousElement) {
|
||||
@ -231,7 +231,7 @@ export class Outline extends Model {
|
||||
}
|
||||
}
|
||||
if (previousElement) {
|
||||
this.setCurrentById(previousElement.getAttribute("data-node-id"))
|
||||
this.setCurrentById(previousElement.getAttribute("data-node-id"));
|
||||
} else {
|
||||
fetchPost("/api/block/getBlockBreadcrumb", {
|
||||
id: nodeElement.getAttribute("data-node-id"),
|
||||
|
@ -8,7 +8,6 @@ import {fetchPost} from "../../util/fetch";
|
||||
import {setInlineStyle} from "../../util/assets";
|
||||
import {renderSnippet} from "../../config/util/snippets";
|
||||
import {setEmpty} from "./setEmpty";
|
||||
import {disabledProtyle, enableProtyle} from "../../protyle/util/onGet";
|
||||
import {getOpenNotebookCount} from "../../util/pathName";
|
||||
import {popMenu} from "./menu";
|
||||
import {MobileFiles} from "./MobileFiles";
|
||||
@ -76,7 +75,7 @@ export const initFramework = () => {
|
||||
});
|
||||
});
|
||||
window.siyuan.mobile.files = new MobileFiles();
|
||||
document.getElementById("toolbarFile").addEventListener("click", (event) => {
|
||||
document.getElementById("toolbarFile").addEventListener("click", () => {
|
||||
hideKeyboardToolbar();
|
||||
hideKeyboard();
|
||||
sidebarElement.style.left = "0";
|
||||
|
@ -55,7 +55,7 @@ export const renderKeyboardToolbar = (protyle: IProtyle, range: Range) => {
|
||||
<button data-type="tag"><svg><use xlink:href="#iconTags"></use></svg></button>
|
||||
<button data-type="inline-math"><svg><use xlink:href="#iconMath"></use></svg></button>
|
||||
<button data-type="inline-memo"><svg><use xlink:href="#iconM"></use></svg></button>
|
||||
<button data-type="indent"><svg><use xlink:href="#iconClose"></use></svg></button>`
|
||||
<button data-type="indent"><svg><use xlink:href="#iconClose"></use></svg></button>`;
|
||||
const html = `<button data-type="add"><svg><use xlink:href="#iconAdd"></use></svg></button>
|
||||
<button data-type="indent"><svg class="keyboard__svg--big"><use xlink:href="#iconBIU"></use></svg></button>
|
||||
<button data-type="indent"><svg><use xlink:href="#iconTrashcan"></use></svg></button>
|
||||
@ -69,14 +69,14 @@ export const renderKeyboardToolbar = (protyle: IProtyle, range: Range) => {
|
||||
<button data-type="redo"><svg><use xlink:href="#iconOutdent"></use></svg></button>
|
||||
<button data-type="redo"><svg><use xlink:href="#iconUp"></use></svg></button>
|
||||
<button data-type="redo"><svg><use xlink:href="#iconDown"></use></svg></button>
|
||||
`
|
||||
`;
|
||||
toolbarElement.innerHTML = `<div class="fn__flex-1">
|
||||
<div class="keyboard__dynamic">${html}</div>
|
||||
<div class="fn__none keyboard__dynamic">${inlineHTML}</div>
|
||||
</div>
|
||||
<span class="keyboard__split"></span>
|
||||
<button data-type="done"><svg style="width: 36px"><use xlink:href="#iconKeyboardHide"></use></svg></button>`
|
||||
}
|
||||
<button data-type="done"><svg style="width: 36px"><use xlink:href="#iconKeyboardHide"></use></svg></button>`;
|
||||
};
|
||||
|
||||
export const hideKeyboardToolbar = () => {
|
||||
const toolbarElement = document.getElementById("keyboardToolbar");
|
||||
@ -93,21 +93,21 @@ const disabledKeyboardToolbar = () => {
|
||||
item.setAttribute("disabled", "disabled");
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const enKeyboardToolbar = () => {
|
||||
document.querySelectorAll("#keyboardToolbar button").forEach(item => {
|
||||
item.removeAttribute("disabled");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const initKeyboardToolbar = () => {
|
||||
window.addEventListener('focus', (event) => {
|
||||
const target = event.target as HTMLElement
|
||||
window.addEventListener("focus", (event) => {
|
||||
const target = event.target as HTMLElement;
|
||||
if (["INPUT", "TEXTAREA"].includes(target.tagName)) {
|
||||
disabledKeyboardToolbar()
|
||||
disabledKeyboardToolbar();
|
||||
} else if (target.classList.contains("protyle-wysiwyg")) {
|
||||
enKeyboardToolbar()
|
||||
enKeyboardToolbar();
|
||||
}
|
||||
}, true);
|
||||
|
||||
|
@ -778,7 +778,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||
});
|
||||
}
|
||||
|
||||
const sourceIds: string [] = []
|
||||
const sourceIds: string [] = [];
|
||||
sourceElements.forEach(item => {
|
||||
item.classList.remove("protyle-wysiwyg--select", "protyle-wysiwyg--hl");
|
||||
item.removeAttribute("select-start");
|
||||
|
@ -213,7 +213,7 @@ export const getSelectionPosition = (nodeElement: Element, range?: Range) => {
|
||||
return { // 选中多行不应遮挡第一行 https://github.com/siyuan-note/siyuan/issues/7541
|
||||
left: rects[rects.length - 1].left,
|
||||
top: rects[0].top
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -176,7 +176,7 @@ export class WYSIWYG {
|
||||
if (protyle.model) {
|
||||
getAllModels().outline.forEach(item => {
|
||||
if (item.blockId === protyle.block.rootID) {
|
||||
item.setCurrent(nodeElement)
|
||||
item.setCurrent(nodeElement);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user