mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 00:20:12 +01:00
🚨
This commit is contained in:
parent
1444f12f0d
commit
b1bb3f1fa6
5 changed files with 16 additions and 17 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {hasClosestByClassName} from "../../protyle/util/hasClosest";
|
|
||||||
import {Dialog} from "../../dialog";
|
import {Dialog} from "../../dialog";
|
||||||
import {objEquals} from "../../util/functions";
|
import {objEquals} from "../../util/functions";
|
||||||
import {confirmDialog} from "../../dialog/confirmDialog";
|
import {confirmDialog} from "../../dialog/confirmDialog";
|
||||||
|
|
|
||||||
|
|
@ -583,7 +583,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
||||||
y: rect.top + 26,
|
y: rect.top + 26,
|
||||||
h: 26
|
h: 26
|
||||||
});
|
});
|
||||||
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app")
|
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");
|
||||||
if (!protyle.disabled) {
|
if (!protyle.disabled) {
|
||||||
window.siyuan.menus.menu.element.querySelector("input").select();
|
window.siyuan.menus.menu.element.querySelector("input").select();
|
||||||
window.siyuan.menus.menu.removeCB = () => {
|
window.siyuan.menus.menu.removeCB = () => {
|
||||||
|
|
@ -1063,7 +1063,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
|
||||||
}
|
}
|
||||||
|
|
||||||
window.siyuan.menus.menu.popup({x: position.clientX, y: position.clientY});
|
window.siyuan.menus.menu.popup({x: position.clientX, y: position.clientY});
|
||||||
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app")
|
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");
|
||||||
if (!protyle.disabled) {
|
if (!protyle.disabled) {
|
||||||
const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea");
|
const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea");
|
||||||
textElements[0].focus();
|
textElements[0].focus();
|
||||||
|
|
@ -1250,7 +1250,7 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
|
||||||
y: rect.top + 26,
|
y: rect.top + 26,
|
||||||
h: 26
|
h: 26
|
||||||
});
|
});
|
||||||
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app")
|
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");
|
||||||
const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea");
|
const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea");
|
||||||
if (focusText || protyle.lute.IsValidLinkDest(linkAddress)) {
|
if (focusText || protyle.lute.IsValidLinkDest(linkAddress)) {
|
||||||
textElements[1].select();
|
textElements[1].select();
|
||||||
|
|
@ -1387,7 +1387,7 @@ export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => {
|
||||||
y: rect.top + 26,
|
y: rect.top + 26,
|
||||||
h: 26
|
h: 26
|
||||||
});
|
});
|
||||||
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app")
|
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");
|
||||||
window.siyuan.menus.menu.element.querySelector("input").select();
|
window.siyuan.menus.menu.element.querySelector("input").select();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,7 @@ export class Gutter {
|
||||||
window.siyuan.menus.menu.fullscreen();
|
window.siyuan.menus.menu.fullscreen();
|
||||||
} else {
|
} else {
|
||||||
window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16, isLeft: true});
|
window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16, isLeft: true});
|
||||||
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app")
|
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");
|
||||||
focusByRange(protyle.toolbar.range);
|
focusByRange(protyle.toolbar.range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -260,7 +260,7 @@ export class Gutter {
|
||||||
if (!window.siyuan.ctrlIsPressed && !window.siyuan.altIsPressed && !window.siyuan.shiftIsPressed) {
|
if (!window.siyuan.ctrlIsPressed && !window.siyuan.altIsPressed && !window.siyuan.shiftIsPressed) {
|
||||||
this.renderMenu(protyle, buttonElement);
|
this.renderMenu(protyle, buttonElement);
|
||||||
window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16, isLeft: true});
|
window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16, isLeft: true});
|
||||||
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app")
|
window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
|
||||||
|
|
@ -589,7 +589,7 @@ export const renderCell = (cellValue: IAVCellValue, wrap: boolean) => {
|
||||||
text += `<span ${cellValue.type !== "number" ? "" : 'style="right:auto;left:5px"'} data-type="copy" class="block__icon"><svg><use xlink:href="#iconCopy"></use></svg></span>`;
|
text += `<span ${cellValue.type !== "number" ? "" : 'style="right:auto;left:5px"'} data-type="copy" class="block__icon"><svg><use xlink:href="#iconCopy"></use></svg></span>`;
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const updateHeaderCell = (cellElement: HTMLElement, headerValue: {
|
export const updateHeaderCell = (cellElement: HTMLElement, headerValue: {
|
||||||
icon?: string,
|
icon?: string,
|
||||||
|
|
@ -598,16 +598,16 @@ export const updateHeaderCell = (cellElement: HTMLElement, headerValue: {
|
||||||
}) => {
|
}) => {
|
||||||
if (typeof headerValue.icon !== "undefined") {
|
if (typeof headerValue.icon !== "undefined") {
|
||||||
cellElement.dataset.icon = headerValue.icon;
|
cellElement.dataset.icon = headerValue.icon;
|
||||||
cellElement.querySelector(".av__cellheadericon").outerHTML = headerValue.icon ? unicode2Emoji(headerValue.icon, "av__cellheadericon", true) : `<svg class="av__cellheadericon"><use xlink:href="#${getColIconByType(cellElement.dataset.dtype as TAVCol)}"></use></svg>`
|
cellElement.querySelector(".av__cellheadericon").outerHTML = headerValue.icon ? unicode2Emoji(headerValue.icon, "av__cellheadericon", true) : `<svg class="av__cellheadericon"><use xlink:href="#${getColIconByType(cellElement.dataset.dtype as TAVCol)}"></use></svg>`;
|
||||||
}
|
}
|
||||||
if (typeof headerValue.name !== "undefined") {
|
if (typeof headerValue.name !== "undefined") {
|
||||||
cellElement.querySelector(".av__celltext").textContent = headerValue.name;
|
cellElement.querySelector(".av__celltext").textContent = headerValue.name;
|
||||||
}
|
}
|
||||||
if (typeof headerValue.pin !== "undefined") {
|
if (typeof headerValue.pin !== "undefined") {
|
||||||
const textElement = cellElement.querySelector(".av__celltext")
|
const textElement = cellElement.querySelector(".av__celltext");
|
||||||
if (headerValue.pin) {
|
if (headerValue.pin) {
|
||||||
if (!textElement.nextElementSibling) {
|
if (!textElement.nextElementSibling) {
|
||||||
textElement.insertAdjacentHTML("afterend", '<div class="fn__flex-1"></div><svg class="av__cellheadericon"><use xlink:href="#iconPin"></use></svg>')
|
textElement.insertAdjacentHTML("afterend", '<div class="fn__flex-1"></div><svg class="av__cellheadericon"><use xlink:href="#iconPin"></use></svg>');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (textElement.nextElementSibling) {
|
if (textElement.nextElementSibling) {
|
||||||
|
|
@ -616,4 +616,4 @@ export const updateHeaderCell = (cellElement: HTMLElement, headerValue: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
||||||
|
|
@ -389,12 +389,12 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
|
||||||
action: "update",
|
action: "update",
|
||||||
data: blockElement.outerHTML,
|
data: blockElement.outerHTML,
|
||||||
id: id,
|
id: id,
|
||||||
}]
|
}];
|
||||||
const undoOperation: IOperation[] = [{
|
const undoOperation: IOperation[] = [{
|
||||||
action: "update",
|
action: "update",
|
||||||
data: html,
|
data: html,
|
||||||
id: id,
|
id: id,
|
||||||
}]
|
}];
|
||||||
let previousElement = blockElement;
|
let previousElement = blockElement;
|
||||||
Array.from(newElement.children).forEach((item: HTMLElement) => {
|
Array.from(newElement.children).forEach((item: HTMLElement) => {
|
||||||
const newId = item.getAttribute("data-node-id");
|
const newId = item.getAttribute("data-node-id");
|
||||||
|
|
@ -403,15 +403,15 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
|
||||||
data: item.outerHTML,
|
data: item.outerHTML,
|
||||||
id: newId,
|
id: newId,
|
||||||
previousID: previousElement.getAttribute("data-node-id"),
|
previousID: previousElement.getAttribute("data-node-id"),
|
||||||
})
|
});
|
||||||
undoOperation.push({
|
undoOperation.push({
|
||||||
action: "delete",
|
action: "delete",
|
||||||
id: newId,
|
id: newId,
|
||||||
})
|
});
|
||||||
previousElement.insertAdjacentElement("afterend", item);
|
previousElement.insertAdjacentElement("afterend", item);
|
||||||
mathRender(previousElement.nextElementSibling);
|
mathRender(previousElement.nextElementSibling);
|
||||||
previousElement = item;
|
previousElement = item;
|
||||||
})
|
});
|
||||||
transaction(protyle, doOperation, undoOperation);
|
transaction(protyle, doOperation, undoOperation);
|
||||||
focusBlock(blockElement.nextElementSibling);
|
focusBlock(blockElement.nextElementSibling);
|
||||||
scrollCenter(protyle);
|
scrollCenter(protyle);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue