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