mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 00:20: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}, () => {
|
fetchPost("/api/snippet/setSnippet", {snippets}, () => {
|
||||||
removeIds.forEach(item => {
|
removeIds.forEach(item => {
|
||||||
const rmElement = document.querySelector(item)
|
const rmElement = document.querySelector(item);
|
||||||
if (rmElement) {
|
if (rmElement) {
|
||||||
rmElement.remove()
|
rmElement.remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
renderSnippet();
|
renderSnippet();
|
||||||
|
|
@ -138,8 +138,8 @@ export const openSnippets = () => {
|
||||||
}
|
}
|
||||||
const removeElement = hasClosestByClassName(target, "b3-tooltips");
|
const removeElement = hasClosestByClassName(target, "b3-tooltips");
|
||||||
if (removeElement) {
|
if (removeElement) {
|
||||||
const itemElement = removeElement.parentElement.parentElement
|
const itemElement = removeElement.parentElement.parentElement;
|
||||||
removeIds.push("#snippet" + (itemElement.getAttribute("data-type") === "css" ? "CSS" : "JS") + itemElement.getAttribute("data-id"))
|
removeIds.push("#snippet" + (itemElement.getAttribute("data-type") === "css" ? "CSS" : "JS") + itemElement.getAttribute("data-id"));
|
||||||
itemElement.nextElementSibling.remove();
|
itemElement.nextElementSibling.remove();
|
||||||
itemElement.remove();
|
itemElement.remove();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import {blockRender} from "../markdown/blockRender";
|
||||||
import {openBy} from "../../editor/util";
|
import {openBy} from "../../editor/util";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {isArrayEqual, isBrowser, isMobile} from "../../util/functions";
|
import {isArrayEqual, isMobile} from "../../util/functions";
|
||||||
import * as dayjs from "dayjs";
|
import * as dayjs from "dayjs";
|
||||||
import {insertEmptyBlock} from "../../block/util";
|
import {insertEmptyBlock} from "../../block/util";
|
||||||
import {matchHotKey} from "../util/hotKey";
|
import {matchHotKey} from "../util/hotKey";
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export const moveToUp = (protyle: IProtyle, nodeElement: HTMLElement, range: Ran
|
||||||
if (!previousElement) {
|
if (!previousElement) {
|
||||||
const newId = Lute.NewNodeID();
|
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>`);
|
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 {
|
} else {
|
||||||
return;
|
return;
|
||||||
|
|
@ -48,7 +48,7 @@ export const moveToUp = (protyle: IProtyle, nodeElement: HTMLElement, range: Ran
|
||||||
if (!previousElement) {
|
if (!previousElement) {
|
||||||
const newId = Lute.NewNodeID();
|
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>`);
|
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 {
|
} else {
|
||||||
return;
|
return;
|
||||||
|
|
@ -136,10 +136,10 @@ export const moveToDown = (protyle: IProtyle, nodeElement: HTMLElement, range: R
|
||||||
if (!nextElement) {
|
if (!nextElement) {
|
||||||
const newId = Lute.NewNodeID();
|
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>`);
|
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 {
|
} else {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type === "NodeList" && sourceElements[sourceElements.length - 1].nextElementSibling.classList.contains("protyle-attr") &&
|
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;
|
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) {
|
if (dialogElement && dialogElement.getAttribute("data-key") === window.siyuan.config.keymap.general.search.custom) {
|
||||||
// https://github.com/siyuan-note/siyuan/issues/6828
|
// https://github.com/siyuan-note/siyuan/issues/6828
|
||||||
item.hPath = config.hPath;
|
item.hPath = config.hPath;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import {
|
||||||
import {newFile} from "./newFile";
|
import {newFile} from "./newFile";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {openSetting} from "../config";
|
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 {Tab} from "../layout/Tab";
|
||||||
import {Editor} from "../editor";
|
import {Editor} from "../editor";
|
||||||
import {setEditMode} from "../protyle/util/setEditMode";
|
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) {
|
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.recentDocs.custom) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
if (openRecentDocsDialog) {
|
if (openRecentDocsDialog) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
dialogArrow(openRecentDocsDialog.element, event);
|
dialogArrow(openRecentDocsDialog.element, event);
|
||||||
|
|
@ -465,7 +465,7 @@ export const globalShortcut = () => {
|
||||||
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.recentDocs.custom) {
|
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.recentDocs.custom) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
if (openRecentDocsDialog) {
|
if (openRecentDocsDialog) {
|
||||||
hideElements(["dialog"]);
|
hideElements(["dialog"]);
|
||||||
return;
|
return;
|
||||||
|
|
@ -793,20 +793,20 @@ const dialogArrow = (element: HTMLElement, event: KeyboardEvent) => {
|
||||||
if (currentType) {
|
if (currentType) {
|
||||||
getDockByType(currentType).toggleModel(currentType, true);
|
getDockByType(currentType).toggleModel(currentType, true);
|
||||||
} else {
|
} else {
|
||||||
let actionString = currentLiElement.getAttribute("data-action")
|
let actionString = currentLiElement.getAttribute("data-action");
|
||||||
if (actionString.indexOf(Constants.CB_GET_SCROLL) === -1) {
|
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({
|
openFileById({
|
||||||
id: currentLiElement.getAttribute("data-block-id") || currentLiElement.getAttribute("data-node-id"),
|
id: currentLiElement.getAttribute("data-block-id") || currentLiElement.getAttribute("data-node-id"),
|
||||||
mode: currentLiElement.getAttribute("data-mode") as TEditorMode,
|
mode: currentLiElement.getAttribute("data-mode") as TEditorMode,
|
||||||
action: actionString.split(",")
|
action: actionString.split(",")
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
hideElements(["dialog"])
|
hideElements(["dialog"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
currentLiElement = element.querySelector(".b3-list-item--focus")
|
currentLiElement = element.querySelector(".b3-list-item--focus");
|
||||||
const rootId = currentLiElement.getAttribute("data-node-id");
|
const rootId = currentLiElement.getAttribute("data-node-id");
|
||||||
if (rootId) {
|
if (rootId) {
|
||||||
fetchPost("/api/filetree/getFullHPathByID", {
|
fetchPost("/api/filetree/getFullHPathByID", {
|
||||||
|
|
@ -825,15 +825,15 @@ const dialogArrow = (element: HTMLElement, event: KeyboardEvent) => {
|
||||||
currentLiElement.scrollIntoView(false);
|
currentLiElement.scrollIntoView(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const openRecentDocs = () => {
|
const openRecentDocs = () => {
|
||||||
fetchPost("/api/storage/getRecentDocs", {}, (response) => {
|
fetchPost("/api/storage/getRecentDocs", {}, (response) => {
|
||||||
let range: Range
|
let range: Range;
|
||||||
if (getSelection().rangeCount > 0) {
|
if (getSelection().rangeCount > 0) {
|
||||||
range = getSelection().getRangeAt(0)
|
range = getSelection().getRangeAt(0);
|
||||||
}
|
}
|
||||||
let tabHtml = ""
|
let tabHtml = "";
|
||||||
response.data.forEach((item: any, index: number) => {
|
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" : ""}">
|
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)}
|
${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(".dialog__path").innerHTML = dialog.element.querySelector(".b3-list-item--focus").textContent;
|
||||||
}
|
}
|
||||||
dialog.element.querySelector("input").focus();
|
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) => {
|
dialog.element.addEventListener("click", (event) => {
|
||||||
const liElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item");
|
const liElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item");
|
||||||
if (liElement) {
|
if (liElement) {
|
||||||
dialog.element.querySelector(".b3-list-item--focus").classList.remove("b3-list-item--focus");
|
dialog.element.querySelector(".b3-list-item--focus").classList.remove("b3-list-item--focus");
|
||||||
liElement.classList.add("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.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
const editKeydown = (event: KeyboardEvent) => {
|
const editKeydown = (event: KeyboardEvent) => {
|
||||||
const activeTabElement = document.querySelector(".layout__wnd--active .item--focus");
|
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");
|
currentHintElement = listElement.querySelector(".b3-list-item--focus");
|
||||||
if (listElement.scrollTop < currentHintElement.offsetTop - listElement.clientHeight + currentHintElement.clientHeight ||
|
if (listElement.scrollTop < currentHintElement.offsetTop - listElement.clientHeight + currentHintElement.clientHeight ||
|
||||||
listElement.scrollTop > currentHintElement.offsetTop) {
|
listElement.scrollTop > currentHintElement.offsetTop) {
|
||||||
currentHintElement.scrollIntoView(listElement.scrollTop > currentHintElement.offsetTop)
|
currentHintElement.scrollIntoView(listElement.scrollTop > currentHintElement.offsetTop);
|
||||||
}
|
}
|
||||||
return currentHintElement;
|
return currentHintElement;
|
||||||
} else if (event.key === "ArrowUp") {
|
} else if (event.key === "ArrowUp") {
|
||||||
|
|
@ -36,7 +36,7 @@ export const upDownHint = (listElement: Element, event: KeyboardEvent) => {
|
||||||
currentHintElement = listElement.querySelector(".b3-list-item--focus");
|
currentHintElement = listElement.querySelector(".b3-list-item--focus");
|
||||||
if (listElement.scrollTop < currentHintElement.offsetTop - listElement.clientHeight + currentHintElement.clientHeight ||
|
if (listElement.scrollTop < currentHintElement.offsetTop - listElement.clientHeight + currentHintElement.clientHeight ||
|
||||||
listElement.scrollTop > currentHintElement.offsetTop - currentHintElement.clientHeight * 2) {
|
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;
|
return currentHintElement;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue