This commit is contained in:
Vanessa 2024-12-24 10:45:10 +08:00
parent 11b02fdfed
commit 0a1ad2ec34
5 changed files with 12 additions and 12 deletions

View file

@ -6,4 +6,4 @@ export const img3115 = (imgElement: HTMLElement) => {
} else { } else {
imgElement.removeAttribute("style"); imgElement.removeAttribute("style");
} }
} };

View file

@ -1189,7 +1189,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
rangeElement.value = "0"; rangeElement.value = "0";
rangeElement.parentElement.setAttribute("aria-label", inputElement.value ? (inputElement.value + "px") : window.siyuan.languages.default); rangeElement.parentElement.setAttribute("aria-label", inputElement.value ? (inputElement.value + "px") : window.siyuan.languages.default);
img3115(assetElement) img3115(assetElement);
imgElement.parentElement.style.width = inputElement.value ? (inputElement.value + "px") : ""; imgElement.parentElement.style.width = inputElement.value ? (inputElement.value + "px") : "";
imgElement.style.height = ""; imgElement.style.height = "";
}); });
@ -1220,7 +1220,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
bind(element) { bind(element) {
rangeElement = element.querySelector("input"); rangeElement = element.querySelector("input");
rangeElement.addEventListener("input", () => { rangeElement.addEventListener("input", () => {
img3115(assetElement) img3115(assetElement);
imgElement.parentElement.style.width = rangeElement.value + "%"; imgElement.parentElement.style.width = rangeElement.value + "%";
imgElement.style.height = ""; imgElement.style.height = "";
rangeElement.parentElement.setAttribute("aria-label", `${rangeElement.value}%`); rangeElement.parentElement.setAttribute("aria-label", `${rangeElement.value}%`);
@ -1254,7 +1254,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
rangeHeightElement.parentElement.setAttribute("aria-label", inputElement.value ? (inputElement.value + "px") : window.siyuan.languages.default); rangeHeightElement.parentElement.setAttribute("aria-label", inputElement.value ? (inputElement.value + "px") : window.siyuan.languages.default);
imgElement.style.height = inputElement.value ? (inputElement.value + "px") : ""; imgElement.style.height = inputElement.value ? (inputElement.value + "px") : "";
img3115(assetElement) img3115(assetElement);
imgElement.parentElement.style.width = ""; imgElement.parentElement.style.width = "";
}); });
inputElement.addEventListener("blur", () => { inputElement.addEventListener("blur", () => {
@ -1284,7 +1284,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
bind(element) { bind(element) {
rangeHeightElement = element.querySelector("input"); rangeHeightElement = element.querySelector("input");
rangeHeightElement.addEventListener("input", () => { rangeHeightElement.addEventListener("input", () => {
img3115(assetElement) img3115(assetElement);
imgElement.parentElement.style.width = ""; imgElement.parentElement.style.width = "";
imgElement.style.height = rangeHeightElement.value + "vh"; imgElement.style.height = rangeHeightElement.value + "vh";
rangeHeightElement.parentElement.setAttribute("aria-label", `${rangeHeightElement.value}%`); rangeHeightElement.parentElement.setAttribute("aria-label", `${rangeHeightElement.value}%`);
@ -1825,7 +1825,7 @@ const genImageWidthMenu = (label: string, imgElement: HTMLElement, protyle: IPro
label, label,
click() { click() {
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss")); nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
img3115(imgElement.parentElement.parentElement) img3115(imgElement.parentElement.parentElement);
imgElement.parentElement.style.width = label === window.siyuan.languages.default ? "" : label; imgElement.parentElement.style.width = label === window.siyuan.languages.default ? "" : label;
imgElement.style.height = ""; imgElement.style.height = "";
updateTransaction(protyle, id, nodeElement.outerHTML, html); updateTransaction(protyle, id, nodeElement.outerHTML, html);
@ -1841,7 +1841,7 @@ const genImageHeightMenu = (label: string, imgElement: HTMLElement, protyle: IPr
click() { click() {
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss")); nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
imgElement.style.height = label === window.siyuan.languages.default ? "" : parseInt(label) + "vh"; imgElement.style.height = label === window.siyuan.languages.default ? "" : parseInt(label) + "vh";
img3115(imgElement.parentElement.parentElement) img3115(imgElement.parentElement.parentElement);
imgElement.parentElement.style.width = ""; imgElement.parentElement.style.width = "";
updateTransaction(protyle, id, nodeElement.outerHTML, html); updateTransaction(protyle, id, nodeElement.outerHTML, html);
focusBlock(nodeElement); focusBlock(nodeElement);

View file

@ -1006,7 +1006,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
target = target.parentElement; target = target.parentElement;
} }
}); });
dialog.element.querySelector("button").focus() dialog.element.querySelector("button").focus();
dialog.element.setAttribute("data-key", Constants.DIALOG_CONFIRM); dialog.element.setAttribute("data-key", Constants.DIALOG_CONFIRM);
return; return;
} }

View file

@ -208,7 +208,7 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
if (textJSON.length === 1 && textJSON[0].length === 1) { if (textJSON.length === 1 && textJSON[0].length === 1) {
updateCellsValue(protyle, blockElement as HTMLElement, text, cellElements, columns, html); updateCellsValue(protyle, blockElement as HTMLElement, text, cellElements, columns, html);
} else { } else {
let currentRowElement:Element let currentRowElement:Element;
const firstColIndex = cellElements[0].getAttribute("data-col-id"); const firstColIndex = cellElements[0].getAttribute("data-col-id");
textJSON.forEach((rowValue, rowIndex) => { textJSON.forEach((rowValue, rowIndex) => {
if (!currentRowElement) { if (!currentRowElement) {
@ -231,7 +231,7 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
} }
updateCellsValue(protyle, blockElement as HTMLElement, cellValue, [cellElement], columns, html); updateCellsValue(protyle, blockElement as HTMLElement, cellValue, [cellElement], columns, html);
}); });
}) });
} }
document.querySelector(".av__panel")?.remove(); document.querySelector(".av__panel")?.remove();
} else if (hasClosestByClassName(range.startContainer, "av__title")) { } else if (hasClosestByClassName(range.startContainer, "av__title")) {

View file

@ -671,9 +671,9 @@ export class WYSIWYG {
const dragWidth = dragElement.clientWidth; const dragWidth = dragElement.clientWidth;
const dragHeight = dragElement.clientHeight; const dragHeight = dragElement.clientHeight;
const imgElement = dragElement.parentElement.parentElement const imgElement = dragElement.parentElement.parentElement;
if (dragElement.tagName === "IMG") { if (dragElement.tagName === "IMG") {
img3115(imgElement) img3115(imgElement);
} }
documentSelf.onmousemove = (moveEvent: MouseEvent) => { documentSelf.onmousemove = (moveEvent: MouseEvent) => {
if (dragElement.tagName === "IMG") { if (dragElement.tagName === "IMG") {