This commit is contained in:
Vanessa 2024-07-06 09:57:00 +08:00
parent 9a1c02e7e4
commit 8c36764686
17 changed files with 37 additions and 38 deletions

View file

@ -251,7 +251,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
let target = event.target as HTMLElement; let target = event.target as HTMLElement;
while (target && !target.isSameNode(element)) { while (target && !target.isSameNode(element)) {
if (target.classList.contains("b3-list-item__action")) { if (target.classList.contains("b3-list-item__action")) {
const subItem = window.siyuan.storage[Constants.LOCAL_AI][target.parentElement.dataset.index] const subItem = window.siyuan.storage[Constants.LOCAL_AI][target.parentElement.dataset.index];
editDialog(subItem.name, subItem.memo); editDialog(subItem.name, subItem.memo);
menu.close(); menu.close();
event.stopPropagation(); event.stopPropagation();

View file

@ -139,7 +139,7 @@ export const initBlockPopover = (app: App) => {
const hidePopover = (event: MouseEvent & { path: HTMLElement[] }) => { const hidePopover = (event: MouseEvent & { path: HTMLElement[] }) => {
// pad 端点击后 event.target 不会更新。 // pad 端点击后 event.target 不会更新。
const target = isTouchDevice() ? document.elementFromPoint(event.clientX, event.clientY) : event.target as HTMLElement const target = isTouchDevice() ? document.elementFromPoint(event.clientX, event.clientY) : event.target as HTMLElement;
if (!target) { if (!target) {
return false; return false;
} }

View file

@ -673,7 +673,7 @@ const emitEvent = (app: App, card: ICard, type: string) => {
export const openCard = (app: App) => { export const openCard = (app: App) => {
if (window.siyuan.config.readonly) { if (window.siyuan.config.readonly) {
return return;
} }
fetchPost("/api/riff/getRiffDueCards", {deckID: ""}, (cardsResponse) => { fetchPost("/api/riff/getRiffDueCards", {deckID: ""}, (cardsResponse) => {
openCardByData(app, cardsResponse.data, "all"); openCardByData(app, cardsResponse.data, "all");

View file

@ -295,10 +295,10 @@ export const refreshFileTree = (cb?: () => void) => {
setStorageVal(Constants.LOCAL_FILEPOSITION, window.siyuan.storage[Constants.LOCAL_FILEPOSITION]); setStorageVal(Constants.LOCAL_FILEPOSITION, window.siyuan.storage[Constants.LOCAL_FILEPOSITION]);
fetchPost("/api/filetree/refreshFiletree", {}, () => { fetchPost("/api/filetree/refreshFiletree", {}, () => {
if (cb) { if (cb) {
cb() cb();
} }
}); });
} };
let statusTimeout: number; let statusTimeout: number;
export const progressStatus = (data: IWebSocketData) => { export const progressStatus = (data: IWebSocketData) => {

View file

@ -139,10 +139,10 @@ export const renameAsset = (assetPath: string) => {
if (item.path === assetPath) { if (item.path === assetPath) {
item.parent.updateTitle(getDisplayName(response.data.newPath)); item.parent.updateTitle(getDisplayName(response.data.newPath));
} }
}) });
getAllEditor().forEach(item => { getAllEditor().forEach(item => {
item.reload(false); item.reload(false);
}) });
}); });
}); });
}; };

View file

@ -518,7 +518,7 @@ export const getEmojiDesc = (emoji: IEmojiItem) => {
return emoji.description_ja_jp; return emoji.description_ja_jp;
} }
return emoji.description; return emoji.description;
} };
export const getEmojiTitle = (index: number) => { export const getEmojiTitle = (index: number) => {

View file

@ -322,11 +322,11 @@ export class Graph extends Model {
this.searchGraph(false, undefined, true); this.searchGraph(false, undefined, true);
} else if (dataType === "fullscreen") { } else if (dataType === "fullscreen") {
fullscreen(this.element, target); fullscreen(this.element, target);
const minElement = this.element.querySelector('.block__icons .block__icon[data-type="min"]') const minElement = this.element.querySelector('.block__icons .block__icon[data-type="min"]');
if (this.element.className.includes("fullscreen")) { if (this.element.className.includes("fullscreen")) {
minElement.classList.add("fn__none") minElement.classList.add("fn__none");
} else { } else {
minElement.classList.remove("fn__none") minElement.classList.remove("fn__none");
} }
} }
break; break;

View file

@ -379,7 +379,7 @@ export class Outline extends Model {
if ((item.action === "update" || item.action === "insert") && if ((item.action === "update" || item.action === "insert") &&
(item.data.indexOf('data-type="NodeHeading"') > -1 || item.data.indexOf(`<div contenteditable="true" spellcheck="${window.siyuan.config.editor.spellcheck}"><wbr></div>`) > -1)) { (item.data.indexOf('data-type="NodeHeading"') > -1 || item.data.indexOf(`<div contenteditable="true" spellcheck="${window.siyuan.config.editor.spellcheck}"><wbr></div>`) > -1)) {
needReload = true; needReload = true;
return true return true;
} else if (item.action === "delete" || item.action === "move") { } else if (item.action === "delete" || item.action === "move") {
needReload = true; needReload = true;
return true; return true;

View file

@ -455,7 +455,7 @@ export class Dock {
return; return;
} }
// 关系图全屏不应该退出 & https://github.com/siyuan-note/siyuan/issues/11775 // 关系图全屏不应该退出 & https://github.com/siyuan-note/siyuan/issues/11775
const fullscreenElement = this.layout.element.querySelector(".fullscreen") const fullscreenElement = this.layout.element.querySelector(".fullscreen");
if (fullscreenElement && fullscreenElement.clientHeight > 0) { if (fullscreenElement && fullscreenElement.clientHeight > 0) {
return; return;
} }

View file

@ -654,7 +654,7 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
protyle.toolbar.showContent(protyle, range, nodeElement); protyle.toolbar.showContent(protyle, range, nodeElement);
/// #else /// #else
const oldHTML = nodeElement.outerHTML; const oldHTML = nodeElement.outerHTML;
const id = nodeElement.getAttribute("data-node-id") const id = nodeElement.getAttribute("data-node-id");
if (range.toString() !== "" || (range.cloneContents().childNodes[0] as HTMLElement)?.classList?.contains("emoji")) { if (range.toString() !== "" || (range.cloneContents().childNodes[0] as HTMLElement)?.classList?.contains("emoji")) {
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
icon: "iconCopy", icon: "iconCopy",
@ -1632,7 +1632,7 @@ export const inlineMathMenu = (protyle: IProtyle, element: Element) => {
y: rect.top + 26, y: rect.top + 26,
h: 26 h: 26
}); });
} };
const genImageWidthMenu = (label: string, assetElement: HTMLElement, imgElement: HTMLElement, protyle: IProtyle, id: string, nodeElement: HTMLElement, html: string) => { const genImageWidthMenu = (label: string, assetElement: HTMLElement, imgElement: HTMLElement, protyle: IProtyle, id: string, nodeElement: HTMLElement, html: string) => {
return { return {
@ -1874,7 +1874,7 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
} }
}); });
const menus: IMenu[] = []; const menus: IMenu[] = [];
menus.push(...otherMenus) menus.push(...otherMenus);
menus.push({ menus.push({
type: "separator" type: "separator"
}); });
@ -1950,7 +1950,7 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
return true; return true;
} }
}); });
const insertMenus = [] const insertMenus = [];
insertMenus.push({ insertMenus.push({
icon: "iconBefore", icon: "iconBefore",
label: window.siyuan.languages.insertRowAbove, label: window.siyuan.languages.insertRowAbove,
@ -1989,8 +1989,8 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
} }
}); });
} }
menus.push(...insertMenus) menus.push(...insertMenus);
const other2Menus: IMenu[] = [] const other2Menus: IMenu[] = [];
if (((!hasNone || (hasNone && !hasRowSpan && hasColSpan)) && if (((!hasNone || (hasNone && !hasRowSpan && hasColSpan)) &&
(!previousHasNone || (previousHasNone && !previousHasRowSpan && previousHasColSpan))) || (!previousHasNone || (previousHasNone && !previousHasRowSpan && previousHasColSpan))) ||
((!hasNone || (hasNone && !hasRowSpan && hasColSpan)) && ((!hasNone || (hasNone && !hasRowSpan && hasColSpan)) &&
@ -2052,7 +2052,7 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
type: "separator" type: "separator"
}); });
} }
const removeMenus = [] const removeMenus = [];
if (cellElement.parentElement.parentElement.tagName !== "THEAD" && if (cellElement.parentElement.parentElement.tagName !== "THEAD" &&
((!hasNone && !hasRowSpan) || (hasNone && !hasRowSpan && hasColSpan))) { ((!hasNone && !hasRowSpan) || (hasNone && !hasRowSpan && hasColSpan))) {
removeMenus.push({ removeMenus.push({

View file

@ -23,7 +23,6 @@ import {focusBlock, focusByRange, getEditorRange} from "../util/selection";
import {hideElements} from "../ui/hideElements"; import {hideElements} from "../ui/hideElements";
import {highlightRender} from "../render/highlightRender"; import {highlightRender} from "../render/highlightRender";
import {blockRender} from "../render/blockRender"; import {blockRender} from "../render/blockRender";
import {removeEmbed} from "../wysiwyg/removeEmbed";
import {getContenteditableElement, getTopAloneElement, isNotEditBlock} from "../wysiwyg/getBlock"; import {getContenteditableElement, getTopAloneElement, isNotEditBlock} from "../wysiwyg/getBlock";
import * as dayjs from "dayjs"; import * as dayjs from "dayjs";
import {fetchPost} from "../../util/fetch"; import {fetchPost} from "../../util/fetch";
@ -90,24 +89,24 @@ export class Gutter {
selectElements.push(item); selectElements.push(item);
}); });
} else { } else {
const gutterId = buttonElement.getAttribute("data-node-id") const gutterId = buttonElement.getAttribute("data-node-id");
selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select")); selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
let selectedIncludeGutter = false; let selectedIncludeGutter = false;
selectElements.forEach((item => { selectElements.forEach((item => {
const itemId = item.getAttribute("data-node-id") const itemId = item.getAttribute("data-node-id");
if (itemId === gutterId) { if (itemId === gutterId) {
selectedIncludeGutter = true selectedIncludeGutter = true;
} }
selectIds.push(itemId); selectIds.push(itemId);
})) }));
if (!selectedIncludeGutter) { if (!selectedIncludeGutter) {
const gutterNodeElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${gutterId}"]`) const gutterNodeElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${gutterId}"]`);
if (gutterNodeElement) { if (gutterNodeElement) {
selectElements.forEach((item => { selectElements.forEach((item => {
item.classList.remove("protyle-wysiwyg--select") item.classList.remove("protyle-wysiwyg--select");
})); }));
gutterNodeElement.classList.add("protyle-wysiwyg--select") gutterNodeElement.classList.add("protyle-wysiwyg--select");
selectElements = [gutterNodeElement] selectElements = [gutterNodeElement];
selectIds = [gutterId]; selectIds = [gutterId];
} }
} }

View file

@ -115,7 +115,7 @@ export class Title {
event.stopPropagation(); event.stopPropagation();
} }
} else if (event.key === "Enter") { } else if (event.key === "Enter") {
const editElment = getContenteditableElement(protyle.wysiwyg.element.firstElementChild) const editElment = getContenteditableElement(protyle.wysiwyg.element.firstElementChild);
if (editElment && editElment.textContent === "" && !protyle.wysiwyg.element.firstElementChild.classList.contains("av")) { if (editElment && editElment.textContent === "" && !protyle.wysiwyg.element.firstElementChild.classList.contains("av")) {
// 配合提示文本使用,避免提示文本挤压到第二个块中 // 配合提示文本使用,避免提示文本挤压到第二个块中
focusBlock(protyle.wysiwyg.element.firstElementChild, protyle.wysiwyg.element); focusBlock(protyle.wysiwyg.element.firstElementChild, protyle.wysiwyg.element);

View file

@ -132,7 +132,7 @@ ${getTypeByCellElement(item) === "block" ? ' data-detached="true"' : ""}><span c
}); });
let html = ""; let html = "";
srcIDs.forEach((id) => { srcIDs.forEach((id) => {
const blockCellElement = blockElement.querySelector(`[data-block-id="${id}"]`) const blockCellElement = blockElement.querySelector(`[data-block-id="${id}"]`);
if (!blockCellElement) { if (!blockCellElement) {
html += `<div class="av__row" data-type="ghost" data-id="${id}" data-avid="${avId}" data-previous-id="${previousId}"> html += `<div class="av__row" data-type="ghost" data-id="${id}" data-avid="${avId}" data-previous-id="${previousId}">
${colHTML} ${colHTML}

View file

@ -750,7 +750,7 @@ export class WYSIWYG {
this.element.querySelectorAll("iframe").forEach(item => { this.element.querySelectorAll("iframe").forEach(item => {
item.style.pointerEvents = "none"; item.style.pointerEvents = "none";
}); });
const needScroll = ["IMG", "VIDEO", "AUDIO"].includes(target.tagName) || target.classList.contains("img") const needScroll = ["IMG", "VIDEO", "AUDIO"].includes(target.tagName) || target.classList.contains("img");
documentSelf.onmousemove = (moveEvent: MouseEvent) => { documentSelf.onmousemove = (moveEvent: MouseEvent) => {
const moveTarget = moveEvent.target as HTMLElement; const moveTarget = moveEvent.target as HTMLElement;
// table cell select // table cell select

View file

@ -1182,7 +1182,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
// h1 - h6 hotkey // h1 - h6 hotkey
if (matchHotKey(window.siyuan.config.keymap.editor.heading.paragraph.custom, event)) { if (matchHotKey(window.siyuan.config.keymap.editor.heading.paragraph.custom, event)) {
const selectsElement = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select")) const selectsElement = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
if (selectsElement.length === 0) { if (selectsElement.length === 0) {
selectsElement.push(nodeElement); selectsElement.push(nodeElement);
} }

View file

@ -251,7 +251,7 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran
if (previousElement) { if (previousElement) {
if (previousElement.classList.contains("p") && getContenteditableElement(previousElement).textContent === "") { if (previousElement.classList.contains("p") && getContenteditableElement(previousElement).textContent === "") {
// 空块向后删除时移除改块 https://github.com/siyuan-note/siyuan/issues/11732 // 空块向后删除时移除改块 https://github.com/siyuan-note/siyuan/issues/11732
const ppElement = getPreviousBlock(previousElement) const ppElement = getPreviousBlock(previousElement);
transaction(protyle, [{ transaction(protyle, [{
action: "delete", action: "delete",
id: previousElement.getAttribute("data-node-id"), id: previousElement.getAttribute("data-node-id"),

View file

@ -1144,7 +1144,7 @@ export const transaction = (protyle: IProtyle, doOperations: IOperation[], undoO
}); });
} }
}); });
}) });
return; return;
} }
if (needDebounce) { if (needDebounce) {
@ -1166,10 +1166,10 @@ export const transaction = (protyle: IProtyle, doOperations: IOperation[], undoO
// 插入块后会导致高度变化,从而产生再次定位 https://github.com/siyuan-note/siyuan/issues/11798 // 插入块后会导致高度变化,从而产生再次定位 https://github.com/siyuan-note/siyuan/issues/11798
doOperations.find(item => { doOperations.find(item => {
if (item.action === "insert") { if (item.action === "insert") {
protyle.observerLoad?.disconnect() protyle.observerLoad?.disconnect();
return true; return true;
} }
}) });
}; };
const processFold = (operation: IOperation, protyle: IProtyle) => { const processFold = (operation: IOperation, protyle: IProtyle) => {
@ -1225,7 +1225,7 @@ const processFold = (operation: IOperation, protyle: IProtyle) => {
} }
return; return;
} }
} };
export const updateTransaction = (protyle: IProtyle, id: string, newHTML: string, html: string) => { export const updateTransaction = (protyle: IProtyle, id: string, newHTML: string, html: string) => {
if (newHTML === html) { if (newHTML === html) {