mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
🚨
This commit is contained in:
parent
d6dda080a8
commit
0152459bb9
6 changed files with 28 additions and 28 deletions
|
|
@ -111,9 +111,9 @@ export const openSnippets = () => {
|
|||
});
|
||||
fetchPost("/api/snippet/setSnippet", {snippets}, () => {
|
||||
removeIds.forEach(item => {
|
||||
const rmElement = document.querySelector(item)
|
||||
const rmElement = document.querySelector(item);
|
||||
if (rmElement) {
|
||||
rmElement.remove()
|
||||
rmElement.remove();
|
||||
}
|
||||
});
|
||||
renderSnippet();
|
||||
|
|
@ -138,8 +138,8 @@ export const openSnippets = () => {
|
|||
}
|
||||
const removeElement = hasClosestByClassName(target, "b3-tooltips");
|
||||
if (removeElement) {
|
||||
const itemElement = removeElement.parentElement.parentElement
|
||||
removeIds.push("#snippet" + (itemElement.getAttribute("data-type") === "css" ? "CSS" : "JS") + itemElement.getAttribute("data-id"))
|
||||
const itemElement = removeElement.parentElement.parentElement;
|
||||
removeIds.push("#snippet" + (itemElement.getAttribute("data-type") === "css" ? "CSS" : "JS") + itemElement.getAttribute("data-id"));
|
||||
itemElement.nextElementSibling.remove();
|
||||
itemElement.remove();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import {blockRender} from "../markdown/blockRender";
|
|||
import {openBy} from "../../editor/util";
|
||||
/// #endif
|
||||
import {fetchPost} from "../../util/fetch";
|
||||
import {isArrayEqual, isBrowser, isMobile} from "../../util/functions";
|
||||
import {isArrayEqual, isMobile} from "../../util/functions";
|
||||
import * as dayjs from "dayjs";
|
||||
import {insertEmptyBlock} from "../../block/util";
|
||||
import {matchHotKey} from "../util/hotKey";
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export const moveToUp = (protyle: IProtyle, nodeElement: HTMLElement, range: Ran
|
|||
if (!previousElement) {
|
||||
const newId = Lute.NewNodeID();
|
||||
sourceElements[0].parentElement.parentElement.previousElementSibling.lastElementChild.insertAdjacentHTML("beforebegin", `<div data-subtype="${sourceElements[0].getAttribute("data-subtype")}" data-node-id="${newId}" data-type="NodeList" class="list" updated="${newId.split("-")[0]}"><div id="moveTempLi"></div><div class="protyle-attr" contenteditable="false">​</div></div>`);
|
||||
previousElement = sourceElements[0].parentElement.parentElement.previousElementSibling.querySelector(".list")
|
||||
previousElement = sourceElements[0].parentElement.parentElement.previousElementSibling.querySelector(".list");
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
|
|
@ -48,7 +48,7 @@ export const moveToUp = (protyle: IProtyle, nodeElement: HTMLElement, range: Ran
|
|||
if (!previousElement) {
|
||||
const newId = Lute.NewNodeID();
|
||||
sourceElements[0].parentElement.previousElementSibling.lastElementChild.insertAdjacentHTML("beforebegin", `<div data-subtype="${sourceElements[0].getAttribute("data-subtype")}" data-node-id="${newId}" data-type="NodeList" class="list" updated="${newId.split("-")[0]}"><div id="moveTempLi"></div><div class="protyle-attr" contenteditable="false">​</div></div>`);
|
||||
previousElement = sourceElements[0].parentElement.previousElementSibling.querySelector(".list")
|
||||
previousElement = sourceElements[0].parentElement.previousElementSibling.querySelector(".list");
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
|
|
@ -136,10 +136,10 @@ export const moveToDown = (protyle: IProtyle, nodeElement: HTMLElement, range: R
|
|||
if (!nextElement) {
|
||||
const newId = Lute.NewNodeID();
|
||||
sourceElements[0].parentElement.parentElement.nextElementSibling.lastElementChild.insertAdjacentHTML("beforebegin", `<div data-subtype="${sourceElements[0].getAttribute("data-subtype")}" data-node-id="${newId}" data-type="NodeList" class="list" updated="${newId.split("-")[0]}"><div class="protyle-attr" contenteditable="false">​</div></div>`);
|
||||
nextElement = sourceElements[0].parentElement.parentElement.nextElementSibling.querySelector(".list > div")
|
||||
nextElement = sourceElements[0].parentElement.parentElement.nextElementSibling.querySelector(".list > div");
|
||||
}
|
||||
} else {
|
||||
return
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (type === "NodeList" && sourceElements[sourceElements.length - 1].nextElementSibling.classList.contains("protyle-attr") &&
|
||||
|
|
|
|||
|
|
@ -731,7 +731,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
|||
}
|
||||
return;
|
||||
}
|
||||
const dialogElement = hasClosestByClassName(element, "b3-dialog--open")
|
||||
const dialogElement = hasClosestByClassName(element, "b3-dialog--open");
|
||||
if (dialogElement && dialogElement.getAttribute("data-key") === window.siyuan.config.keymap.general.search.custom) {
|
||||
// https://github.com/siyuan-note/siyuan/issues/6828
|
||||
item.hPath = config.hPath;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {
|
|||
import {newFile} from "./newFile";
|
||||
import {Constants} from "../constants";
|
||||
import {openSetting} from "../config";
|
||||
import {exportLayout, getDockByType, getInstanceById, setPanelFocus} from "../layout/util";
|
||||
import {exportLayout, getDockByType, getInstanceById} from "../layout/util";
|
||||
import {Tab} from "../layout/Tab";
|
||||
import {Editor} from "../editor";
|
||||
import {setEditMode} from "../protyle/util/setEditMode";
|
||||
|
|
@ -453,7 +453,7 @@ export const globalShortcut = () => {
|
|||
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.recentDocs.custom) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
});
|
||||
if (openRecentDocsDialog) {
|
||||
event.preventDefault();
|
||||
dialogArrow(openRecentDocsDialog.element, event);
|
||||
|
|
@ -465,7 +465,7 @@ export const globalShortcut = () => {
|
|||
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.recentDocs.custom) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
});
|
||||
if (openRecentDocsDialog) {
|
||||
hideElements(["dialog"]);
|
||||
return;
|
||||
|
|
@ -793,20 +793,20 @@ const dialogArrow = (element: HTMLElement, event: KeyboardEvent) => {
|
|||
if (currentType) {
|
||||
getDockByType(currentType).toggleModel(currentType, true);
|
||||
} else {
|
||||
let actionString = currentLiElement.getAttribute("data-action")
|
||||
let actionString = currentLiElement.getAttribute("data-action");
|
||||
if (actionString.indexOf(Constants.CB_GET_SCROLL) === -1) {
|
||||
actionString = actionString ? (actionString + "," + Constants.CB_GET_SCROLL) : Constants.CB_GET_SCROLL
|
||||
actionString = actionString ? (actionString + "," + Constants.CB_GET_SCROLL) : Constants.CB_GET_SCROLL;
|
||||
}
|
||||
openFileById({
|
||||
id: currentLiElement.getAttribute("data-block-id") || currentLiElement.getAttribute("data-node-id"),
|
||||
mode: currentLiElement.getAttribute("data-mode") as TEditorMode,
|
||||
action: actionString.split(",")
|
||||
})
|
||||
});
|
||||
}
|
||||
hideElements(["dialog"])
|
||||
hideElements(["dialog"]);
|
||||
return;
|
||||
}
|
||||
currentLiElement = element.querySelector(".b3-list-item--focus")
|
||||
currentLiElement = element.querySelector(".b3-list-item--focus");
|
||||
const rootId = currentLiElement.getAttribute("data-node-id");
|
||||
if (rootId) {
|
||||
fetchPost("/api/filetree/getFullHPathByID", {
|
||||
|
|
@ -825,15 +825,15 @@ const dialogArrow = (element: HTMLElement, event: KeyboardEvent) => {
|
|||
currentLiElement.scrollIntoView(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const openRecentDocs = () => {
|
||||
fetchPost("/api/storage/getRecentDocs", {}, (response) => {
|
||||
let range: Range
|
||||
let range: Range;
|
||||
if (getSelection().rangeCount > 0) {
|
||||
range = getSelection().getRangeAt(0)
|
||||
range = getSelection().getRangeAt(0);
|
||||
}
|
||||
let tabHtml = ""
|
||||
let tabHtml = "";
|
||||
response.data.forEach((item: any, index: number) => {
|
||||
tabHtml += `<li data-index="${index}" data-action="${item.action}" data-node-id="${item.rootID}" data-block-id="${item.id || ""}" data-mode="${item.mode}" class="b3-list-item${index === 0 ? " b3-list-item--focus" : ""}">
|
||||
${unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_FILE, false, "b3-list-item__graphic", true)}
|
||||
|
|
@ -873,19 +873,19 @@ ${unicode2Emoji(item.icon || Constants.SIYUAN_IMAGE_FILE, false, "b3-list-item__
|
|||
dialog.element.querySelector(".dialog__path").innerHTML = dialog.element.querySelector(".b3-list-item--focus").textContent;
|
||||
}
|
||||
dialog.element.querySelector("input").focus();
|
||||
dialog.element.setAttribute("data-key", window.siyuan.config.keymap.general.recentDocs.custom)
|
||||
dialog.element.setAttribute("data-key", window.siyuan.config.keymap.general.recentDocs.custom);
|
||||
dialog.element.addEventListener("click", (event) => {
|
||||
const liElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item");
|
||||
if (liElement) {
|
||||
dialog.element.querySelector(".b3-list-item--focus").classList.remove("b3-list-item--focus");
|
||||
liElement.classList.add("b3-list-item--focus");
|
||||
window.dispatchEvent(new KeyboardEvent("keydown", {key: "Enter"}))
|
||||
window.dispatchEvent(new KeyboardEvent("keydown", {key: "Enter"}));
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const editKeydown = (event: KeyboardEvent) => {
|
||||
const activeTabElement = document.querySelector(".layout__wnd--active .item--focus");
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export const upDownHint = (listElement: Element, event: KeyboardEvent) => {
|
|||
currentHintElement = listElement.querySelector(".b3-list-item--focus");
|
||||
if (listElement.scrollTop < currentHintElement.offsetTop - listElement.clientHeight + currentHintElement.clientHeight ||
|
||||
listElement.scrollTop > currentHintElement.offsetTop) {
|
||||
currentHintElement.scrollIntoView(listElement.scrollTop > currentHintElement.offsetTop)
|
||||
currentHintElement.scrollIntoView(listElement.scrollTop > currentHintElement.offsetTop);
|
||||
}
|
||||
return currentHintElement;
|
||||
} else if (event.key === "ArrowUp") {
|
||||
|
|
@ -36,7 +36,7 @@ export const upDownHint = (listElement: Element, event: KeyboardEvent) => {
|
|||
currentHintElement = listElement.querySelector(".b3-list-item--focus");
|
||||
if (listElement.scrollTop < currentHintElement.offsetTop - listElement.clientHeight + currentHintElement.clientHeight ||
|
||||
listElement.scrollTop > currentHintElement.offsetTop - currentHintElement.clientHeight * 2) {
|
||||
currentHintElement.scrollIntoView(listElement.scrollTop > currentHintElement.offsetTop - currentHintElement.clientHeight * 2)
|
||||
currentHintElement.scrollIntoView(listElement.scrollTop > currentHintElement.offsetTop - currentHintElement.clientHeight * 2);
|
||||
}
|
||||
return currentHintElement;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue