mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 01:50:12 +01:00
This commit is contained in:
parent
0cf13cca8f
commit
2bcf4dcf71
3 changed files with 22 additions and 5 deletions
|
|
@ -30,7 +30,8 @@ export const openMenuPanel = (options: {
|
||||||
blockElement: Element,
|
blockElement: Element,
|
||||||
type: "select" | "properties" | "config" | "sorts" | "filters" | "edit" | "date" | "asset",
|
type: "select" | "properties" | "config" | "sorts" | "filters" | "edit" | "date" | "asset",
|
||||||
colId?: string, // for edit
|
colId?: string, // for edit
|
||||||
cellElements?: HTMLElement[] // for select & date
|
cellElements?: HTMLElement[], // for select & date
|
||||||
|
cb?: (avPanelElement: Element) => void
|
||||||
}) => {
|
}) => {
|
||||||
let avPanelElement = document.querySelector(".av__panel");
|
let avPanelElement = document.querySelector(".av__panel");
|
||||||
if (avPanelElement) {
|
if (avPanelElement) {
|
||||||
|
|
@ -97,6 +98,9 @@ export const openMenuPanel = (options: {
|
||||||
bindViewEvent({protyle: options.protyle, data, menuElement});
|
bindViewEvent({protyle: options.protyle, data, menuElement});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (options.cb) {
|
||||||
|
options.cb(avPanelElement);
|
||||||
|
}
|
||||||
avPanelElement.addEventListener("dragstart", (event: DragEvent) => {
|
avPanelElement.addEventListener("dragstart", (event: DragEvent) => {
|
||||||
window.siyuan.dragElement = event.target as HTMLElement;
|
window.siyuan.dragElement = event.target as HTMLElement;
|
||||||
window.siyuan.dragElement.style.opacity = ".1";
|
window.siyuan.dragElement.style.opacity = ".1";
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,17 @@ export const avRender = (element: Element, protyle: IProtyle, cb?: () => void, v
|
||||||
}
|
}
|
||||||
const created = protyle.options.history?.created;
|
const created = protyle.options.history?.created;
|
||||||
const snapshot = protyle.options.history?.snapshot;
|
const snapshot = protyle.options.history?.snapshot;
|
||||||
|
let newViewID = "";
|
||||||
|
if (typeof viewID === "string") {
|
||||||
|
newViewID = viewID;
|
||||||
|
} else if (typeof viewID === "undefined") {
|
||||||
|
newViewID = e.querySelector(".av__header .item--focus")?.getAttribute("data-id")
|
||||||
|
}
|
||||||
fetchPost(created ? "/api/av/renderHistoryAttributeView" : (snapshot ? "/api/av/renderSnapshotAttributeView" : "/api/av/renderAttributeView"), {
|
fetchPost(created ? "/api/av/renderHistoryAttributeView" : (snapshot ? "/api/av/renderSnapshotAttributeView" : "/api/av/renderAttributeView"), {
|
||||||
id: e.getAttribute("data-av-id"),
|
id: e.getAttribute("data-av-id"),
|
||||||
created,
|
created,
|
||||||
snapshot,
|
snapshot,
|
||||||
viewID: viewID || e.querySelector(".av__header .item--focus")?.getAttribute("data-id")
|
viewID: newViewID
|
||||||
}, (response) => {
|
}, (response) => {
|
||||||
const data = response.data.view as IAVTable;
|
const data = response.data.view as IAVTable;
|
||||||
// header
|
// header
|
||||||
|
|
@ -322,7 +328,8 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation, isUndo: bool
|
||||||
if (!isUndo && operation.action === "insertAttrViewBlock" && operation.isDetached) {
|
if (!isUndo && operation.action === "insertAttrViewBlock" && operation.isDetached) {
|
||||||
popTextCell(protyle, [item.querySelector(`.av__row[data-id="${operation.srcIDs[0]}"] .av__cell[data-detached="true"]`)], "block");
|
popTextCell(protyle, [item.querySelector(`.av__row[data-id="${operation.srcIDs[0]}"] .av__cell[data-detached="true"]`)], "block");
|
||||||
}
|
}
|
||||||
});
|
}, ["addAttrViewView", "duplicateAttrViewView"].includes(operation.action) ? operation.id :
|
||||||
|
(operation.action === "removeAttrViewView" ? null : undefined));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,14 @@ export const openViewMenu = (options: { protyle: IProtyle, blockElement: HTMLEle
|
||||||
icon: "iconEdit",
|
icon: "iconEdit",
|
||||||
label: window.siyuan.languages.rename,
|
label: window.siyuan.languages.rename,
|
||||||
click() {
|
click() {
|
||||||
openMenuPanel({protyle: options.protyle, blockElement: options.blockElement, type: "config"});
|
openMenuPanel({
|
||||||
(document.querySelector('.av__panel .b3-text-field[data-type="name"]') as HTMLInputElement).focus()
|
protyle: options.protyle,
|
||||||
|
blockElement: options.blockElement,
|
||||||
|
type: "config",
|
||||||
|
cb: (avPanelElement) => {
|
||||||
|
(avPanelElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement).focus()
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
menu.addItem({
|
menu.addItem({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue