mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-21 22:44:06 +01:00
This commit is contained in:
parent
fba386be71
commit
19d9c455a7
4 changed files with 25 additions and 19 deletions
|
|
@ -222,7 +222,8 @@ export const windowMouseMove = (event: MouseEvent, mouseIsEnter: boolean) => {
|
|||
const cellElement = (hasClosestByTag(target, "TH") || hasClosestByTag(target, "TD")) as HTMLTableCellElement;
|
||||
const tableElement = blockElement.querySelector("table");
|
||||
if (cellElement && tableElement && tableElement.getAttribute("contenteditable") === "true") {
|
||||
const tableHeight = blockElement.querySelector("table").clientHeight;
|
||||
const tableHeight = blockElement.querySelector("colgroup").clientHeight;
|
||||
const captionHeight = blockElement.querySelector("caption")?.clientHeight || 0;
|
||||
const resizeElement = blockElement.querySelector(".table__resize");
|
||||
if (blockElement.style.textAlign === "center" || blockElement.style.textAlign === "right") {
|
||||
resizeElement.parentElement.style.left = tableElement.offsetLeft + "px";
|
||||
|
|
@ -232,10 +233,10 @@ export const windowMouseMove = (event: MouseEvent, mouseIsEnter: boolean) => {
|
|||
const rect = cellElement.getBoundingClientRect();
|
||||
if (rect.right - event.clientX < 3 && rect.right - event.clientX > 0) {
|
||||
resizeElement.setAttribute("data-col-index", (getColIndex(cellElement) + cellElement.colSpan - 1).toString());
|
||||
resizeElement.setAttribute("style", `height:${tableHeight}px;left: ${Math.round(cellElement.offsetWidth + cellElement.offsetLeft - blockElement.firstElementChild.scrollLeft - 3)}px;display:block`);
|
||||
resizeElement.setAttribute("style", `top:${captionHeight}px;height:${tableHeight}px;left: ${Math.round(cellElement.offsetWidth + cellElement.offsetLeft - blockElement.firstElementChild.scrollLeft - 3)}px;display:block`);
|
||||
} else if (event.clientX - rect.left < 3 && event.clientX - rect.left > 0 && cellElement.previousElementSibling) {
|
||||
resizeElement.setAttribute("data-col-index", (getColIndex(cellElement) - 1).toString());
|
||||
resizeElement.setAttribute("style", `height:${tableHeight}px;left: ${Math.round(cellElement.offsetLeft - blockElement.firstElementChild.scrollLeft - 3)}px;display:block`);
|
||||
resizeElement.setAttribute("style", `top:${captionHeight}px;height:${tableHeight}px;left: ${Math.round(cellElement.offsetLeft - blockElement.firstElementChild.scrollLeft - 3)}px;display:block`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -716,6 +716,7 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
|
|||
/// #else
|
||||
const oldHTML = nodeElement.outerHTML;
|
||||
const id = nodeElement.getAttribute("data-node-id");
|
||||
const captionElement = hasClosestByTag(range.startContainer, "CAPTION");
|
||||
if (range.toString() !== "" || (range.cloneContents().childNodes[0] as HTMLElement)?.classList?.contains("emoji")) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
id: "copy",
|
||||
|
|
@ -737,7 +738,7 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
|
|||
copyPlainText(getSelection().getRangeAt(0).toString());
|
||||
}
|
||||
}).element);
|
||||
if (protyle.disabled) {
|
||||
if (protyle.disabled || captionElement) {
|
||||
return;
|
||||
}
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
|
|
@ -820,7 +821,7 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!protyle.disabled) {
|
||||
if (!protyle.disabled && !captionElement) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
id: "paste",
|
||||
label: window.siyuan.languages.paste,
|
||||
|
|
@ -858,15 +859,17 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
|
|||
}
|
||||
}).element);
|
||||
}
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
id: "selectAll",
|
||||
label: window.siyuan.languages.selectAll,
|
||||
icon: "iconSelect",
|
||||
accelerator: "⌘A",
|
||||
click() {
|
||||
selectAll(protyle, nodeElement, range);
|
||||
}
|
||||
}).element);
|
||||
if (!captionElement) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
id: "selectAll",
|
||||
label: window.siyuan.languages.selectAll,
|
||||
icon: "iconSelect",
|
||||
accelerator: "⌘A",
|
||||
click() {
|
||||
selectAll(protyle, nodeElement, range);
|
||||
}
|
||||
}).element);
|
||||
}
|
||||
if (nodeElement.classList.contains("table") && !protyle.disabled) {
|
||||
const cellElement = hasClosestByTag(range.startContainer, "TD") || hasClosestByTag(range.startContainer, "TH");
|
||||
if (cellElement) {
|
||||
|
|
|
|||
|
|
@ -1627,7 +1627,8 @@ export class Gutter {
|
|||
if (!tableElement.contains(range.startContainer)) {
|
||||
range = getEditorRange(tableElement.querySelector("th"));
|
||||
}
|
||||
const cellElement = hasClosestByTag(range.startContainer, "TD") || hasClosestByTag(range.startContainer, "TH");
|
||||
const cellElement = hasClosestByTag(range.startContainer, "TD") ||
|
||||
hasClosestByTag(range.startContainer, "TH") || nodeElement.querySelector("th, td");
|
||||
if (cellElement) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({id: "separator_table", type: "separator"}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import {
|
|||
setFirstNodeRange,
|
||||
setLastNodeRange
|
||||
} from "../util/selection";
|
||||
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName} from "../util/hasClosest";
|
||||
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName, hasClosestByTag} from "../util/hasClosest";
|
||||
import {Link} from "./Link";
|
||||
import {setPosition} from "../../util/setPosition";
|
||||
import {transaction, updateTransaction} from "../wysiwyg/transaction";
|
||||
|
|
@ -114,7 +114,8 @@ export class Toolbar {
|
|||
public render(protyle: IProtyle, range: Range, event?: KeyboardEvent) {
|
||||
this.range = range;
|
||||
let nodeElement = hasClosestBlock(range.startContainer);
|
||||
if (isMobile() || !nodeElement || protyle.disabled || nodeElement.classList.contains("av")) {
|
||||
if (isMobile() || !nodeElement || protyle.disabled || nodeElement.classList.contains("av") ||
|
||||
hasClosestByTag(range.startContainer, "CAPTION")) {
|
||||
this.element.classList.add("fn__none");
|
||||
return;
|
||||
}
|
||||
|
|
@ -1115,7 +1116,7 @@ export class Toolbar {
|
|||
focusBlock(renderElement);
|
||||
renderElement.classList.add("protyle-wysiwyg--select");
|
||||
}
|
||||
protyle.wysiwyg.element.focus({ preventScroll: true});
|
||||
protyle.wysiwyg.element.focus({preventScroll: true});
|
||||
return;
|
||||
}
|
||||
let inlineLastNode: Element;
|
||||
|
|
@ -1221,7 +1222,7 @@ export class Toolbar {
|
|||
}
|
||||
}
|
||||
updateTransaction(protyle, id, nodeElement.outerHTML, html);
|
||||
protyle.wysiwyg.element.focus({ preventScroll: true});
|
||||
protyle.wysiwyg.element.focus({preventScroll: true});
|
||||
};
|
||||
this.subElement.style.zIndex = (++window.siyuan.zIndex).toString();
|
||||
this.subElement.classList.remove("fn__none");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue