mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
🚨
This commit is contained in:
parent
6a4ed3c92b
commit
aac7fa8101
14 changed files with 37 additions and 37 deletions
|
|
@ -1313,7 +1313,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
||||||
// 需放在 dialog 前,否则属性面板中修改日期会先关闭 dialog,只剩修改界面
|
// 需放在 dialog 前,否则属性面板中修改日期会先关闭 dialog,只剩修改界面
|
||||||
const avElement = document.querySelector(".av__panel");
|
const avElement = document.querySelector(".av__panel");
|
||||||
if (avElement) {
|
if (avElement) {
|
||||||
const selectCellElement = document.querySelector(".av__cell--select")
|
const selectCellElement = document.querySelector(".av__cell--select");
|
||||||
if (selectCellElement) {
|
if (selectCellElement) {
|
||||||
focusBlock(hasClosestBlock(selectCellElement) as HTMLElement);
|
focusBlock(hasClosestBlock(selectCellElement) as HTMLElement);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ export class Dock {
|
||||||
documentSelf.onselect = null;
|
documentSelf.onselect = null;
|
||||||
this.setSize();
|
this.setSize();
|
||||||
this.element.querySelectorAll(".dock__item--active").forEach(item => {
|
this.element.querySelectorAll(".dock__item--active").forEach(item => {
|
||||||
const customModel = this.data[item.getAttribute("data-type")]
|
const customModel = this.data[item.getAttribute("data-type")];
|
||||||
if (customModel && customModel instanceof Custom && customModel.resize) {
|
if (customModel && customModel instanceof Custom && customModel.resize) {
|
||||||
customModel.resize();
|
customModel.resize();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
||||||
|
|
||||||
const copyElement = hasClosestByAttribute(event.target, "data-type", "copy");
|
const copyElement = hasClosestByAttribute(event.target, "data-type", "copy");
|
||||||
if (copyElement) {
|
if (copyElement) {
|
||||||
const textElement = copyElement.previousElementSibling
|
const textElement = copyElement.previousElementSibling;
|
||||||
if (textElement.querySelector(".av__cellicon")) {
|
if (textElement.querySelector(".av__cellicon")) {
|
||||||
writeText(`${textElement.firstChild.textContent} → ${textElement.lastChild.textContent}`);
|
writeText(`${textElement.firstChild.textContent} → ${textElement.lastChild.textContent}`);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -72,7 +72,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
||||||
if (gutterElement && gutterElement.parentElement.classList.contains("av__gutters")) {
|
if (gutterElement && gutterElement.parentElement.classList.contains("av__gutters")) {
|
||||||
const rowElement = hasClosestByClassName(gutterElement, "av__row");
|
const rowElement = hasClosestByClassName(gutterElement, "av__row");
|
||||||
if (!rowElement) {
|
if (!rowElement) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (gutterElement.dataset.action === "add") {
|
if (gutterElement.dataset.action === "add") {
|
||||||
const avID = blockElement.getAttribute("data-av-id");
|
const avID = blockElement.getAttribute("data-av-id");
|
||||||
|
|
@ -204,9 +204,9 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
||||||
|
|
||||||
const cellElement = hasClosestByClassName(event.target, "av__cell");
|
const cellElement = hasClosestByClassName(event.target, "av__cell");
|
||||||
if (cellElement && !hasClosestByClassName(cellElement, "av__row--header")) {
|
if (cellElement && !hasClosestByClassName(cellElement, "av__row--header")) {
|
||||||
const scrollElement = hasClosestByClassName(cellElement, "av__scroll")
|
const scrollElement = hasClosestByClassName(cellElement, "av__scroll");
|
||||||
if (!scrollElement) {
|
if (!scrollElement) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
const rowElement = hasClosestByClassName(cellElement, "av__row");
|
const rowElement = hasClosestByClassName(cellElement, "av__row");
|
||||||
if (!rowElement) {
|
if (!rowElement) {
|
||||||
|
|
|
||||||
|
|
@ -363,7 +363,7 @@ export const cellScrollIntoView = (blockElement: HTMLElement, cellElement: Eleme
|
||||||
if (rowElement) {
|
if (rowElement) {
|
||||||
const stickyElement = rowElement.querySelector(".av__colsticky");
|
const stickyElement = rowElement.querySelector(".av__colsticky");
|
||||||
if (stickyElement) {
|
if (stickyElement) {
|
||||||
const stickyRight = stickyElement.getBoundingClientRect().right
|
const stickyRight = stickyElement.getBoundingClientRect().right;
|
||||||
if (stickyRight > cellRect.left) {
|
if (stickyRight > cellRect.left) {
|
||||||
avScrollElement.scrollLeft = avScrollElement.scrollLeft + cellRect.left - stickyRight;
|
avScrollElement.scrollLeft = avScrollElement.scrollLeft + cellRect.left - stickyRight;
|
||||||
}
|
}
|
||||||
|
|
@ -396,16 +396,16 @@ export const cellScrollIntoView = (blockElement: HTMLElement, cellElement: Eleme
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getTypeByCellElement = (cellElement: Element) => {
|
export const getTypeByCellElement = (cellElement: Element) => {
|
||||||
const scrollElement = hasClosestByClassName(cellElement, "av__scroll")
|
const scrollElement = hasClosestByClassName(cellElement, "av__scroll");
|
||||||
if (!scrollElement) {
|
if (!scrollElement) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return scrollElement.querySelector(".av__row--header").querySelector(`[data-col-id="${cellElement.getAttribute("data-col-id")}"]`).getAttribute("data-dtype") as TAVCol;
|
return scrollElement.querySelector(".av__row--header").querySelector(`[data-col-id="${cellElement.getAttribute("data-col-id")}"]`).getAttribute("data-dtype") as TAVCol;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type?: TAVCol) => {
|
export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type?: TAVCol) => {
|
||||||
if (!type) {
|
if (!type) {
|
||||||
type = getTypeByCellElement(cellElements[0])
|
type = getTypeByCellElement(cellElements[0]);
|
||||||
}
|
}
|
||||||
if (type === "updated" || type === "created") {
|
if (type === "updated" || type === "created") {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -578,7 +578,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const isPin = cellElement.dataset.pin === "true"
|
const isPin = cellElement.dataset.pin === "true";
|
||||||
menu.addItem({
|
menu.addItem({
|
||||||
icon: "iconPin",
|
icon: "iconPin",
|
||||||
label: isPin ? window.siyuan.languages.unfreezeCol : window.siyuan.languages.freezeCol,
|
label: isPin ? window.siyuan.languages.unfreezeCol : window.siyuan.languages.freezeCol,
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl
|
||||||
newCellElement = selectCellElement.previousElementSibling.lastElementChild;
|
newCellElement = selectCellElement.previousElementSibling.lastElementChild;
|
||||||
}
|
}
|
||||||
} else if (previousRowElement && !previousRowElement.classList.contains("av__row--header")) {
|
} else if (previousRowElement && !previousRowElement.classList.contains("av__row--header")) {
|
||||||
const previousCellElements = previousRowElement.querySelectorAll(".av__cell")
|
const previousCellElements = previousRowElement.querySelectorAll(".av__cell");
|
||||||
newCellElement = previousCellElements[previousCellElements.length - 1];
|
newCellElement = previousCellElements[previousCellElements.length - 1];
|
||||||
}
|
}
|
||||||
if (newCellElement) {
|
if (newCellElement) {
|
||||||
|
|
|
||||||
|
|
@ -69,11 +69,11 @@ export const avRender = (element: Element, protyle: IProtyle, cb?: () => void) =
|
||||||
pinMaxIndex = index;
|
pinMaxIndex = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
pinIndex = Math.min(pinIndex, pinMaxIndex);
|
pinIndex = Math.min(pinIndex, pinMaxIndex);
|
||||||
if (pinIndex > -1) {
|
if (pinIndex > -1) {
|
||||||
tableHTML = '<div class="av__row av__row--header"><div class="av__colsticky"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div>'
|
tableHTML = '<div class="av__row av__row--header"><div class="av__colsticky"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div>';
|
||||||
calcHTML = '<div class="av__colsticky"><div style="width: 24px"></div>'
|
calcHTML = '<div class="av__colsticky"><div style="width: 24px"></div>';
|
||||||
}
|
}
|
||||||
data.columns.forEach((column: IAVColumn, index: number) => {
|
data.columns.forEach((column: IAVColumn, index: number) => {
|
||||||
if (column.hidden) {
|
if (column.hidden) {
|
||||||
|
|
@ -90,12 +90,12 @@ ${column.wrap ? "" : "white-space: nowrap;"}">
|
||||||
<div class="av__widthdrag"></div>
|
<div class="av__widthdrag"></div>
|
||||||
</div>`;
|
</div>`;
|
||||||
if (pinIndex === index) {
|
if (pinIndex === index) {
|
||||||
tableHTML += '</div>'
|
tableHTML += "</div>";
|
||||||
}
|
}
|
||||||
calcHTML += `<div class="av__calc${calcHTML ? "" : " av__calc--show"}${column.calc && column.calc.operator !== "" ? " av__calc--ashow" : ""}" data-col-id="${column.id}" data-dtype="${column.type}" data-operator="${column.calc?.operator || ""}"
|
calcHTML += `<div class="av__calc${calcHTML ? "" : " av__calc--show"}${column.calc && column.calc.operator !== "" ? " av__calc--ashow" : ""}" data-col-id="${column.id}" data-dtype="${column.type}" data-operator="${column.calc?.operator || ""}"
|
||||||
style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use xlink:href="#iconDown"></use></svg>' + window.siyuan.languages.calc}</div>`;
|
style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use xlink:href="#iconDown"></use></svg>' + window.siyuan.languages.calc}</div>`;
|
||||||
if (pinIndex === index) {
|
if (pinIndex === index) {
|
||||||
calcHTML += '</div>'
|
calcHTML += "</div>";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tableHTML += `<div class="block__icons" style="min-height: auto">
|
tableHTML += `<div class="block__icons" style="min-height: auto">
|
||||||
|
|
@ -112,9 +112,9 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
|
||||||
<button class="ariaLabel" draggable="true" data-position="right" aria-label="${window.siyuan.languages.rowTip}"><svg><use xlink:href="#iconDrag"></use></svg></button>
|
<button class="ariaLabel" draggable="true" data-position="right" aria-label="${window.siyuan.languages.rowTip}"><svg><use xlink:href="#iconDrag"></use></svg></button>
|
||||||
</div>`;
|
</div>`;
|
||||||
if (pinIndex > -1) {
|
if (pinIndex > -1) {
|
||||||
tableHTML += '<div class="av__colsticky"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div>'
|
tableHTML += '<div class="av__colsticky"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div>';
|
||||||
} else {
|
} else {
|
||||||
tableHTML += `<div class="av__firstcol av__colsticky"><svg><use xlink:href="#iconUncheck"></use></svg></div>`
|
tableHTML += "<div class=\"av__firstcol av__colsticky\"><svg><use xlink:href=\"#iconUncheck\"></use></svg></div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
row.cells.forEach((cell, index) => {
|
row.cells.forEach((cell, index) => {
|
||||||
|
|
@ -194,7 +194,7 @@ ${cell.valueType !== "number" ? "" : "flex-direction: row-reverse;"}
|
||||||
${cell.color ? `color:${cell.color};` : ""}">${text}</div>`;
|
${cell.color ? `color:${cell.color};` : ""}">${text}</div>`;
|
||||||
|
|
||||||
if (pinIndex === index) {
|
if (pinIndex === index) {
|
||||||
tableHTML += '</div>'
|
tableHTML += "</div>";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tableHTML += "<div></div></div>";
|
tableHTML += "<div></div></div>";
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import {focusBlock} from "../../util/selection";
|
||||||
export const selectRow = (checkElement: Element, type: "toggle" | "select" | "unselect" | "unselectAll") => {
|
export const selectRow = (checkElement: Element, type: "toggle" | "select" | "unselect" | "unselectAll") => {
|
||||||
const rowElement = hasClosestByClassName(checkElement, "av__row");
|
const rowElement = hasClosestByClassName(checkElement, "av__row");
|
||||||
if (!rowElement) {
|
if (!rowElement) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
const useElement = checkElement.querySelector("use");
|
const useElement = checkElement.querySelector("use");
|
||||||
if (rowElement.classList.contains("av__row--header") || type === "unselectAll") {
|
if (rowElement.classList.contains("av__row--header") || type === "unselectAll") {
|
||||||
|
|
@ -72,12 +72,12 @@ export const insertAttrViewBlockAnimation = (blockElement: Element, size: number
|
||||||
let colHTML = '<div style="width: 24px"></div>';
|
let colHTML = '<div style="width: 24px"></div>';
|
||||||
const pinIndex = previousElement.querySelectorAll(".av__colsticky .av__cell").length - 1;
|
const pinIndex = previousElement.querySelectorAll(".av__colsticky .av__cell").length - 1;
|
||||||
if (pinIndex > -1) {
|
if (pinIndex > -1) {
|
||||||
colHTML = `<div class="av__colsticky"><div style="width: 24px"></div>`;
|
colHTML = "<div class=\"av__colsticky\"><div style=\"width: 24px\"></div>";
|
||||||
}
|
}
|
||||||
previousElement.querySelectorAll(".av__cell").forEach((item: HTMLElement, index) => {
|
previousElement.querySelectorAll(".av__cell").forEach((item: HTMLElement, index) => {
|
||||||
colHTML += `<div class="av__cell" style="width: ${item.style.width}" ${(item.getAttribute("data-block-id") || item.dataset.dtype === "block") ? ' data-detached="true"' : ""}><span class="av__pulse"></span></div>`;
|
colHTML += `<div class="av__cell" style="width: ${item.style.width}" ${(item.getAttribute("data-block-id") || item.dataset.dtype === "block") ? ' data-detached="true"' : ""}><span class="av__pulse"></span></div>`;
|
||||||
if (pinIndex === index) {
|
if (pinIndex === index) {
|
||||||
colHTML += `</div>`;
|
colHTML += "</div>";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
|
||||||
if (item.dataset.render !== "true") {
|
if (item.dataset.render !== "true") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const scrollRect = item.querySelector(".av__scroll").getBoundingClientRect()
|
const scrollRect = item.querySelector(".av__scroll").getBoundingClientRect();
|
||||||
const headerElement = item.querySelector(".av__row--header") as HTMLElement;
|
const headerElement = item.querySelector(".av__row--header") as HTMLElement;
|
||||||
if (headerElement) {
|
if (headerElement) {
|
||||||
const distance = Math.floor(elementRect.top - scrollRect.top);
|
const distance = Math.floor(elementRect.top - scrollRect.top);
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,8 @@ export const isNotCtrl = (event: KeyboardEvent | MouseEvent) => {
|
||||||
if (!event.metaKey && !event.ctrlKey) {
|
if (!event.metaKey && !event.ctrlKey) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const isHuawei = () => {
|
export const isHuawei = () => {
|
||||||
return window.siyuan.config.system.osPlatform.toLowerCase().indexOf("huawei") > -1;
|
return window.siyuan.config.system.osPlatform.toLowerCase().indexOf("huawei") > -1;
|
||||||
|
|
|
||||||
|
|
@ -856,23 +856,23 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
if (targetClass.includes("dragover__left")) {
|
if (targetClass.includes("dragover__left")) {
|
||||||
if (targetElement.previousElementSibling) {
|
if (targetElement.previousElementSibling) {
|
||||||
if (targetElement.previousElementSibling.classList.contains("av__colsticky")) {
|
if (targetElement.previousElementSibling.classList.contains("av__colsticky")) {
|
||||||
previousID = targetElement.previousElementSibling.lastElementChild.getAttribute("data-col-id")
|
previousID = targetElement.previousElementSibling.lastElementChild.getAttribute("data-col-id");
|
||||||
} else {
|
} else {
|
||||||
previousID = targetElement.previousElementSibling.getAttribute("data-col-id")
|
previousID = targetElement.previousElementSibling.getAttribute("data-col-id");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
previousID = targetElement.getAttribute("data-col-id")
|
previousID = targetElement.getAttribute("data-col-id");
|
||||||
}
|
}
|
||||||
let oldPreviousID = "";
|
let oldPreviousID = "";
|
||||||
const rowElement = hasClosestByClassName(targetElement, "av__row");
|
const rowElement = hasClosestByClassName(targetElement, "av__row");
|
||||||
if (rowElement) {
|
if (rowElement) {
|
||||||
const oldPreviousElement = rowElement.querySelector(`[data-col-id="${gutterTypes[2]}"`)?.previousElementSibling
|
const oldPreviousElement = rowElement.querySelector(`[data-col-id="${gutterTypes[2]}"`)?.previousElementSibling;
|
||||||
if (oldPreviousElement) {
|
if (oldPreviousElement) {
|
||||||
if (oldPreviousElement.classList.contains("av__colsticky")) {
|
if (oldPreviousElement.classList.contains("av__colsticky")) {
|
||||||
oldPreviousID = oldPreviousElement.lastElementChild.getAttribute("data-col-id")
|
oldPreviousID = oldPreviousElement.lastElementChild.getAttribute("data-col-id");
|
||||||
} else {
|
} else {
|
||||||
oldPreviousID = oldPreviousElement.getAttribute("data-col-id")
|
oldPreviousID = oldPreviousElement.getAttribute("data-col-id");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1136,8 +1136,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
// 表头只能拖拽到当前 av 的表头中
|
// 表头只能拖拽到当前 av 的表头中
|
||||||
targetElement = hasClosestByClassName(event.target, "av__cell");
|
targetElement = hasClosestByClassName(event.target, "av__cell");
|
||||||
if (targetElement) {
|
if (targetElement) {
|
||||||
const targetRowElement = hasClosestByClassName(targetElement, "av__row--header")
|
const targetRowElement = hasClosestByClassName(targetElement, "av__row--header");
|
||||||
const dragRowElement = hasClosestByClassName(window.siyuan.dragElement, "av__row--header")
|
const dragRowElement = hasClosestByClassName(window.siyuan.dragElement, "av__row--header");
|
||||||
if (!targetRowElement || !dragRowElement ||
|
if (!targetRowElement || !dragRowElement ||
|
||||||
(targetRowElement && dragRowElement && !targetRowElement.isSameNode(dragRowElement))
|
(targetRowElement && dragRowElement && !targetRowElement.isSameNode(dragRowElement))
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -384,7 +384,7 @@ export class WYSIWYG {
|
||||||
let newWidth: string;
|
let newWidth: string;
|
||||||
documentSelf.onmousemove = (moveEvent: MouseEvent) => {
|
documentSelf.onmousemove = (moveEvent: MouseEvent) => {
|
||||||
newWidth = Math.max(oldWidth + (moveEvent.clientX - event.clientX), 58) + "px";
|
newWidth = Math.max(oldWidth + (moveEvent.clientX - event.clientX), 58) + "px";
|
||||||
const scrollElement = hasClosestByClassName(dragElement, "av__scroll")
|
const scrollElement = hasClosestByClassName(dragElement, "av__scroll");
|
||||||
if (scrollElement) {
|
if (scrollElement) {
|
||||||
scrollElement.querySelectorAll(".av__row, .av__row--footer").forEach(item => {
|
scrollElement.querySelectorAll(".av__row, .av__row--footer").forEach(item => {
|
||||||
(item.querySelector(`[data-col-id="${dragColId}"]`) as HTMLElement).style.width = newWidth;
|
(item.querySelector(`[data-col-id="${dragColId}"]`) as HTMLElement).style.width = newWidth;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import {hideElements} from "../ui/hideElements";
|
import {hideElements} from "../ui/hideElements";
|
||||||
import {copyPlainText, isMac, isNotCtrl, isOnlyMeta, writeText} from "../util/compatibility";
|
import {isMac, isNotCtrl, isOnlyMeta, writeText} from "../util/compatibility";
|
||||||
import {
|
import {
|
||||||
focusBlock,
|
focusBlock,
|
||||||
focusByRange,
|
focusByRange,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
export const upDownHint = (listElement: Element, event: KeyboardEvent, classActiveName = "b3-list-item--focus") => {
|
export const upDownHint = (listElement: Element, event: KeyboardEvent, classActiveName = "b3-list-item--focus") => {
|
||||||
let currentHintElement: HTMLElement = listElement.querySelector("." + classActiveName);
|
let currentHintElement: HTMLElement = listElement.querySelector("." + classActiveName);
|
||||||
if (!currentHintElement) {
|
if (!currentHintElement) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
const className = classActiveName.split("--")[0];
|
const className = classActiveName.split("--")[0];
|
||||||
if (event.key === "ArrowDown") {
|
if (event.key === "ArrowDown") {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue