This commit is contained in:
parent
72e79b05fb
commit
d7407b74a5
4 changed files with 34 additions and 18 deletions
|
@ -365,8 +365,10 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
|||
icon: "iconOpen",
|
||||
accelerator: window.siyuan.config.keymap.editor.general.openBy.custom + "/" + window.siyuan.languages.click,
|
||||
click() {
|
||||
checkFold(refBlockId, (zoomIn, action) => {
|
||||
action.push(Constants.CB_GET_HL);
|
||||
checkFold(refBlockId, (zoomIn, action, isRoot) => {
|
||||
if (!isRoot) {
|
||||
action.push(Constants.CB_GET_HL);
|
||||
}
|
||||
openFileById({
|
||||
app: protyle.app,
|
||||
id: refBlockId,
|
||||
|
@ -397,8 +399,10 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
|||
icon: "iconLayoutRight",
|
||||
accelerator: window.siyuan.config.keymap.editor.general.insertRight.custom + "/⌥" + window.siyuan.languages.click,
|
||||
click() {
|
||||
checkFold(refBlockId, (zoomIn, action) => {
|
||||
action.push(Constants.CB_GET_HL);
|
||||
checkFold(refBlockId, (zoomIn, action, isRoot) => {
|
||||
if (!isRoot) {
|
||||
action.push(Constants.CB_GET_HL);
|
||||
}
|
||||
openFileById({
|
||||
app: protyle.app,
|
||||
id: refBlockId,
|
||||
|
@ -414,8 +418,10 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
|||
icon: "iconLayoutBottom",
|
||||
accelerator: window.siyuan.config.keymap.editor.general.insertBottom.custom + (window.siyuan.config.keymap.editor.general.insertBottom.custom ? "/" : "") + "⇧" + window.siyuan.languages.click,
|
||||
click() {
|
||||
checkFold(refBlockId, (zoomIn, action) => {
|
||||
action.push(Constants.CB_GET_HL);
|
||||
checkFold(refBlockId, (zoomIn, action, isRoot) => {
|
||||
if (!isRoot) {
|
||||
action.push(Constants.CB_GET_HL);
|
||||
}
|
||||
openFileById({
|
||||
app: protyle.app,
|
||||
id: refBlockId,
|
||||
|
|
|
@ -2072,9 +2072,11 @@ export class WYSIWYG {
|
|||
} else if (aElement) {
|
||||
refBlockId = aLink.substring(16, 38);
|
||||
}
|
||||
checkFold(refBlockId, (zoomIn, action) => {
|
||||
checkFold(refBlockId, (zoomIn, action, isRoot) => {
|
||||
// 块引用跳转后需要短暂高亮目标块 https://github.com/siyuan-note/siyuan/issues/11542
|
||||
action.push(Constants.CB_GET_HL);
|
||||
if (!isRoot) {
|
||||
action.push(Constants.CB_GET_HL);
|
||||
}
|
||||
/// #if MOBILE
|
||||
openMobileFileById(protyle.app, refBlockId, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
|
||||
activeBlur();
|
||||
|
|
|
@ -638,7 +638,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
if (getSelectionPosition(nodeElement, range).top - protyle.wysiwyg.element.getBoundingClientRect().top < 40 || nodeElement.classList.contains("av")) {
|
||||
if (protyle.title && protyle.title.editElement &&
|
||||
(protyle.wysiwyg.element.firstElementChild.getAttribute("data-eof") === "1" ||
|
||||
protyle.contentElement.scrollTop === 0)) {
|
||||
protyle.contentElement.scrollTop === 0)) {
|
||||
protyle.title.editElement.focus();
|
||||
} else {
|
||||
protyle.contentElement.scrollTop = 0;
|
||||
|
@ -1525,8 +1525,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
if (refElement) {
|
||||
const id = refElement.getAttribute("data-id");
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.openBy.custom, event)) {
|
||||
checkFold(id, (zoomIn, action) => {
|
||||
action.push(Constants.CB_GET_HL);
|
||||
checkFold(id, (zoomIn, action, isRoot) => {
|
||||
if (!isRoot) {
|
||||
action.push(Constants.CB_GET_HL);
|
||||
}
|
||||
openFileById({
|
||||
app: protyle.app,
|
||||
id,
|
||||
|
@ -1552,8 +1554,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
event.stopPropagation();
|
||||
return true;
|
||||
} else if (matchHotKey(window.siyuan.config.keymap.editor.general.insertRight.custom, event)) {
|
||||
checkFold(id, (zoomIn, action) => {
|
||||
action.push(Constants.CB_GET_HL);
|
||||
checkFold(id, (zoomIn, action, isRoot) => {
|
||||
if (!isRoot) {
|
||||
action.push(Constants.CB_GET_HL);
|
||||
}
|
||||
openFileById({
|
||||
app: protyle.app,
|
||||
id,
|
||||
|
@ -1566,8 +1570,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
event.stopPropagation();
|
||||
return true;
|
||||
} else if (matchHotKey(window.siyuan.config.keymap.editor.general.insertBottom.custom, event)) {
|
||||
checkFold(id, (zoomIn, action) => {
|
||||
action.push(Constants.CB_GET_HL);
|
||||
checkFold(id, (zoomIn, action, isRoot) => {
|
||||
if (!isRoot) {
|
||||
action.push(Constants.CB_GET_HL);
|
||||
}
|
||||
openFileById({
|
||||
app: protyle.app,
|
||||
id,
|
||||
|
|
|
@ -12,7 +12,7 @@ export const renameTag = (labelName: string) => {
|
|||
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
|
||||
<button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
|
||||
</div>`,
|
||||
width: isMobile() ? "92vw": "520px",
|
||||
width: isMobile() ? "92vw" : "520px",
|
||||
});
|
||||
dialog.element.setAttribute("data-key", Constants.DIALOG_RENAMETAG);
|
||||
const btnsElement = dialog.element.querySelectorAll(".b3-button");
|
||||
|
@ -34,11 +34,13 @@ export const getWorkspaceName = () => {
|
|||
return window.siyuan.config.system.workspaceDir.replace(/^.*[\\\/]/, "");
|
||||
};
|
||||
|
||||
export const checkFold = (id: string, cb: (zoomIn: boolean, action: string[]) => void) => {
|
||||
export const checkFold = (id: string, cb: (zoomIn: boolean, action: string[], isRoot: boolean) => void) => {
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
|
||||
cb(foldResponse.data, foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
|
||||
cb(foldResponse.data.isFolded,
|
||||
foldResponse.data.isFolded ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL],
|
||||
foldResponse.data.isRoot);
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue