mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
This commit is contained in:
parent
3c6d2fc417
commit
63156dd783
4 changed files with 25 additions and 4 deletions
|
|
@ -63,7 +63,7 @@ export const avRender = (element: Element, cb?: () => void) => {
|
|||
} else if (cell.valueType === "date") {
|
||||
text = cell.value?.date.content || "";
|
||||
}
|
||||
tableHTML += `<div class="av__cell" ${index === 0 ? 'data-block-id="' + (cell.value.block.id || "") + '"' : ""} data-id="${cell.id}" data-index="${index}" style="width: ${data.columns[index].width || 200}px;${cell.bgColor ? `background-color:${cell.bgColor};` : ""}${cell.color ? `color:${cell.color};` : ""}">${text}</div>`;
|
||||
tableHTML += `<div class="av__cell" ${cell.valueType === "block" ? 'data-block-id="' + (cell.value.block.id || "") + '"' : ""} data-id="${cell.id}" data-index="${index}" style="width: ${data.columns[index].width || 200}px;${cell.bgColor ? `background-color:${cell.bgColor};` : ""}${cell.color ? `color:${cell.color};` : ""}">${text}</div>`;
|
||||
});
|
||||
tableHTML += "<div></div></div>";
|
||||
});
|
||||
|
|
|
|||
|
|
@ -753,13 +753,14 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
event.stopPropagation();
|
||||
return;
|
||||
}
|
||||
const targetElement = hasClosestByClassName(event.target, "av__row") || hasClosestBlock(event.target);
|
||||
let gutterType = "";
|
||||
for (const item of event.dataTransfer.items) {
|
||||
if (item.type.startsWith(Constants.SIYUAN_DROP_GUTTER)) {
|
||||
gutterType = item.type;
|
||||
}
|
||||
}
|
||||
const targetElement = (gutterType.startsWith(`application/siyuan-gutternodeattributeview${Constants.ZWSP}col`) ? hasClosestByClassName(event.target, "av__cell") : hasClosestByClassName(event.target, "av__row")) ||
|
||||
hasClosestBlock(event.target);
|
||||
if (gutterType) {
|
||||
// gutter 或反链面板拖拽
|
||||
const sourceElements: Element[] = [];
|
||||
|
|
@ -817,7 +818,25 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
});
|
||||
|
||||
hideElements(["gutter"], protyle);
|
||||
const targetClass = targetElement.className.split(" ");
|
||||
if (targetElement.classList.contains("av__cell")) {
|
||||
const blockElement = hasClosestBlock(targetElement);
|
||||
if (!blockElement) {
|
||||
return;
|
||||
}
|
||||
const avId = blockElement.getAttribute("data-av-id")
|
||||
transaction(protyle, [{
|
||||
action: "sortAttrViewCol",
|
||||
parentID: avId,
|
||||
previousID: (targetElement.classList.contains("dragover__left") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "",
|
||||
id: gutterTypes[2],
|
||||
}], [{
|
||||
action: "sortAttrViewCol",
|
||||
parentID: avId,
|
||||
previousID: targetElement.parentElement.querySelector(`[data-id="${gutterTypes[2]}"`).previousElementSibling?.getAttribute("data-id") || "",
|
||||
id: gutterTypes[2],
|
||||
}]);
|
||||
return;
|
||||
}
|
||||
if (targetElement.classList.contains("av__row")) {
|
||||
// 拖拽到属性视图内
|
||||
const blockElement = hasClosestBlock(targetElement);
|
||||
|
|
@ -865,6 +884,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
}
|
||||
return;
|
||||
}
|
||||
const targetClass = targetElement.className.split(" ");
|
||||
targetElement.classList.remove("dragover__bottom", "dragover__top", "dragover__left", "dragover__right", "protyle-wysiwyg--select");
|
||||
if (targetElement.parentElement.getAttribute("data-type") === "NodeSuperBlock" &&
|
||||
targetElement.parentElement.getAttribute("data-sb-layout") === "col") {
|
||||
|
|
|
|||
|
|
@ -651,7 +651,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
|
|||
updateRef(protyle, operation.id);
|
||||
} else if (operation.action === "append") {
|
||||
reloadProtyle(protyle, false);
|
||||
} else if (["addAttrViewCol", "insertAttrViewBlock", "updateAttrViewCol", "updateAttrViewCell", "sortAttrViewRow"].includes(operation.action)) {
|
||||
} else if (["addAttrViewCol", "insertAttrViewBlock", "updateAttrViewCol", "updateAttrViewCell", "sortAttrViewRow", "sortAttrViewCol"].includes(operation.action)) {
|
||||
refreshAV(protyle, operation);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -25,6 +25,7 @@ type TOperation =
|
|||
| "updateAttrViewCell"
|
||||
| "updateAttrViewCol"
|
||||
| "sortAttrViewRow"
|
||||
| "sortAttrViewCol"
|
||||
type TBazaarType = "templates" | "icons" | "widgets" | "themes" | "plugins"
|
||||
type TCardType = "doc" | "notebook" | "all"
|
||||
type TEventBus = "ws-main" |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue