mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🚨
This commit is contained in:
parent
2894cd2578
commit
fd64882595
7 changed files with 40 additions and 40 deletions
|
|
@ -17,7 +17,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||
const addElement = hasClosestByAttribute(event.target, "data-type", "av-header-add");
|
||||
if (addElement) {
|
||||
const addMenu = addCol(protyle, blockElement);
|
||||
const addRect = addElement.getBoundingClientRect()
|
||||
const addRect = addElement.getBoundingClientRect();
|
||||
addMenu.open({
|
||||
x: addRect.left,
|
||||
y: addRect.bottom,
|
||||
|
|
|
|||
|
|
@ -99,4 +99,4 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
|
|||
}
|
||||
});
|
||||
return menu;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ export const showHeaderCellMenu = (protyle: IProtyle, blockElement: HTMLElement,
|
|||
y: cellRect.bottom,
|
||||
h: cellRect.height
|
||||
});
|
||||
const inputElement = window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement
|
||||
const inputElement = window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement;
|
||||
if (inputElement) {
|
||||
inputElement.select();
|
||||
inputElement.focus();
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type
|
|||
return;
|
||||
}
|
||||
window.siyuan.menus.menu.remove();
|
||||
const avId = blockElement.getAttribute("data-av-id")
|
||||
const avId = blockElement.getAttribute("data-av-id");
|
||||
fetchPost("/api/av/renderAttributeView", {id: avId}, (response) => {
|
||||
const data = response.data.av as IAV;
|
||||
const tabRect = blockElement.querySelector(".layout-tab-bar").getBoundingClientRect()
|
||||
let html
|
||||
const tabRect = blockElement.querySelector(".layout-tab-bar").getBoundingClientRect();
|
||||
let html;
|
||||
if (type === "config") {
|
||||
html = getConfigHTML(data, tabRect);
|
||||
} else if (type === "properties") {
|
||||
|
|
@ -51,8 +51,8 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type
|
|||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "showAllCol") {
|
||||
const doOperations: IOperation[] = []
|
||||
const undoOperations: IOperation[] = []
|
||||
const doOperations: IOperation[] = [];
|
||||
const undoOperations: IOperation[] = [];
|
||||
data.columns.forEach((item: IAVColumn) => {
|
||||
if (item.hidden) {
|
||||
doOperations.push({
|
||||
|
|
@ -60,16 +60,16 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type
|
|||
id: item.id,
|
||||
parentID: avId,
|
||||
data: false
|
||||
})
|
||||
});
|
||||
undoOperations.push({
|
||||
action: "setAttrViewColHidden",
|
||||
id: item.id,
|
||||
parentID: avId,
|
||||
data: true
|
||||
})
|
||||
item.hidden = false
|
||||
});
|
||||
item.hidden = false;
|
||||
}
|
||||
})
|
||||
});
|
||||
if (doOperations.length > 0) {
|
||||
transaction(protyle, doOperations, undoOperations);
|
||||
avMenuPanel.innerHTML = getPropertiesHTML(data, tabRect);
|
||||
|
|
@ -77,8 +77,8 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type
|
|||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "hideAllCol") {
|
||||
const doOperations: IOperation[] = []
|
||||
const undoOperations: IOperation[] = []
|
||||
const doOperations: IOperation[] = [];
|
||||
const undoOperations: IOperation[] = [];
|
||||
data.columns.forEach((item: IAVColumn) => {
|
||||
if (!item.hidden && item.type !== "block") {
|
||||
doOperations.push({
|
||||
|
|
@ -86,16 +86,16 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type
|
|||
id: item.id,
|
||||
parentID: avId,
|
||||
data: true
|
||||
})
|
||||
});
|
||||
undoOperations.push({
|
||||
action: "setAttrViewColHidden",
|
||||
id: item.id,
|
||||
parentID: avId,
|
||||
data: false
|
||||
})
|
||||
item.hidden = true
|
||||
});
|
||||
item.hidden = true;
|
||||
}
|
||||
})
|
||||
});
|
||||
if (doOperations.length > 0) {
|
||||
transaction(protyle, doOperations, undoOperations);
|
||||
avMenuPanel.innerHTML = getPropertiesHTML(data, tabRect);
|
||||
|
|
@ -141,7 +141,7 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type
|
|||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const getConfigHTML = (data: IAV, tabRect: DOMRect) => {
|
||||
return `<div class="b3-dialog__scrim" data-type="close"></div>
|
||||
|
|
@ -175,8 +175,8 @@ const getConfigHTML = (data: IAV, tabRect: DOMRect) => {
|
|||
<span class="b3-menu__accelerator">50</span>
|
||||
<svg class="b3-menu__icon b3-menu__icon--arrow"><use xlink:href="#iconRight"></use></svg>
|
||||
</button>
|
||||
</div>`
|
||||
}
|
||||
</div>`;
|
||||
};
|
||||
|
||||
const getPropertiesHTML = (data: IAV, tabRect: DOMRect) => {
|
||||
let showHTML = "";
|
||||
|
|
@ -187,13 +187,13 @@ const getPropertiesHTML = (data: IAV, tabRect: DOMRect) => {
|
|||
<svg class="b3-menu__icon"><use xlink:href="#${getColIconByType(item.type)}"></use></svg>
|
||||
<span class="b3-menu__label">${item.name}</span>
|
||||
<svg class="b3-menu__action" data-type="showCol" data-id="${item.id}"><use xlink:href="#iconEyeoff"></use></svg>
|
||||
</button>`
|
||||
</button>`;
|
||||
} else {
|
||||
showHTML += `<button class="b3-menu__item">
|
||||
<svg class="b3-menu__icon"><use xlink:href="#${getColIconByType(item.type)}"></use></svg>
|
||||
<span class="b3-menu__label">${item.name}</span>
|
||||
<svg class="b3-menu__action${item.type === "block" ? " fn__none" : ""}" data-type="hideCol" data-id="${item.id}"><use xlink:href="#iconEye"></use></svg>
|
||||
</button>`
|
||||
</button>`;
|
||||
}
|
||||
});
|
||||
if (hideHTML) {
|
||||
|
|
@ -235,5 +235,5 @@ ${hideHTML}`;
|
|||
<svg class="b3-menu__icon"><use xlink:href="#iconAdd"></use></svg>
|
||||
<span class="b3-menu__label">${window.siyuan.languages.new}</span>
|
||||
</button>
|
||||
</div>`
|
||||
}
|
||||
</div>`;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -129,11 +129,11 @@ ${cell.color ? `color:${cell.color};` : ""}"><span class="av__celltext">${text}<
|
|||
}
|
||||
};
|
||||
|
||||
let lastParentID: string
|
||||
let lastElement: HTMLElement
|
||||
let lastParentID: string;
|
||||
let lastElement: HTMLElement;
|
||||
export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
|
||||
if (lastParentID === operation.parentID && protyle.contentElement.isSameNode(lastElement)) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
lastElement = protyle.contentElement;
|
||||
lastParentID = operation.parentID;
|
||||
|
|
@ -148,12 +148,12 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
|
|||
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.parentID}"]`)).forEach((item: HTMLElement) => {
|
||||
const cellElement = item.querySelector(`.av__cell[data-id="${operation.id}"]`) as HTMLElement;
|
||||
if (!cellElement || cellElement.style.width === operation.data) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
const index = cellElement.dataset.index;
|
||||
item.querySelectorAll(".av__row").forEach(rowItem => {
|
||||
(rowItem.querySelector(`[data-index="${index}"]`) as HTMLElement).style.width = operation.data;
|
||||
})
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.parentID}"]`)).forEach((item: HTMLElement) => {
|
||||
|
|
|
|||
|
|
@ -723,13 +723,13 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
return;
|
||||
}
|
||||
const rowElement = target.parentElement;
|
||||
const selectIds = []
|
||||
const selectIds = [];
|
||||
if (rowElement.classList.contains("av__row--select")) {
|
||||
rowElement.parentElement.querySelectorAll(".av__row--select:not(.av__row--header)").forEach((item) => {
|
||||
selectIds.push(item.getAttribute("data-id"))
|
||||
})
|
||||
selectIds.push(item.getAttribute("data-id"));
|
||||
});
|
||||
} else {
|
||||
selectIds.push(rowElement.getAttribute("data-id"))
|
||||
selectIds.push(rowElement.getAttribute("data-id"));
|
||||
}
|
||||
if (selectIds.length === 1) {
|
||||
event.dataTransfer.setDragImage(rowElement, 0, 0);
|
||||
|
|
@ -823,7 +823,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
if (!blockElement) {
|
||||
return;
|
||||
}
|
||||
const avId = blockElement.getAttribute("data-av-id")
|
||||
const avId = blockElement.getAttribute("data-av-id");
|
||||
transaction(protyle, [{
|
||||
action: "sortAttrViewCol",
|
||||
parentID: avId,
|
||||
|
|
@ -849,7 +849,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
} else {
|
||||
previousID = targetElement.previousElementSibling?.getAttribute("data-id") || "";
|
||||
}
|
||||
const avId = blockElement.getAttribute("data-av-id")
|
||||
const avId = blockElement.getAttribute("data-av-id");
|
||||
if (gutterTypes[0] === "nodeattributeview" && gutterTypes[1] === "row") {
|
||||
// 行内拖拽
|
||||
const doOperations: IOperation[] = [];
|
||||
|
|
@ -861,13 +861,13 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
parentID: avId,
|
||||
previousID,
|
||||
id: item,
|
||||
})
|
||||
});
|
||||
undoOperations.push({
|
||||
action: "sortAttrViewRow",
|
||||
parentID: avId,
|
||||
previousID: undoPreviousId,
|
||||
id: item,
|
||||
})
|
||||
});
|
||||
});
|
||||
transaction(protyle, doOperations, undoOperations);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -356,12 +356,12 @@ export class WYSIWYG {
|
|||
const dragElement = target.parentElement;
|
||||
const oldWidth = dragElement.clientWidth;
|
||||
const dragIndex = dragElement.getAttribute("data-index");
|
||||
let newWidth: string
|
||||
let newWidth: string;
|
||||
documentSelf.onmousemove = (moveEvent: MouseEvent) => {
|
||||
newWidth = oldWidth + (moveEvent.clientX - event.clientX) + "px";
|
||||
dragElement.parentElement.parentElement.querySelectorAll(".av__row").forEach(item => {
|
||||
(item.querySelector(`[data-index="${dragIndex}"]`) as HTMLElement).style.width = newWidth;
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
documentSelf.onmouseup = () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue