mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
7a203eabdd
commit
9c416cbcea
4 changed files with 39 additions and 31 deletions
|
|
@ -16,7 +16,7 @@
|
|||
position: absolute;
|
||||
z-index: 1;
|
||||
animation: 1s linear infinite keyframes-pulse;
|
||||
background: linear-gradient(90deg,transparent 0,rgba(255,255,255,.4) 50%,transparent 100%);
|
||||
background: linear-gradient(90deg, transparent 0, rgba(255, 255, 255, .4) 50%, transparent 100%);
|
||||
display: block;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
|
@ -87,7 +87,8 @@
|
|||
font-size: 87.5%;
|
||||
|
||||
&:hover {
|
||||
[data-type="block-ref"] {
|
||||
[data-type="block-ref"],
|
||||
[data-type="createdoc"] {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
|
@ -198,7 +199,8 @@
|
|||
align-items: center;
|
||||
transition: var(--b3-transition);
|
||||
|
||||
[data-type="block-ref"] {
|
||||
[data-type="block-ref"],
|
||||
[data-type="createdoc"] {
|
||||
display: none;
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
|
|
|
|||
|
|
@ -151,6 +151,35 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||
return true;
|
||||
}
|
||||
|
||||
const createDocElement = hasClosestByAttribute(event.target, "data-type", "createdoc");
|
||||
if (createDocElement) {
|
||||
fetchPost("/api/filetree/getHPathByPath", {
|
||||
notebook: protyle.notebookId,
|
||||
path: protyle.path,
|
||||
}, (response) => {
|
||||
fetchPost("/api/filetree/createDocWithMd", {
|
||||
notebook: protyle.notebookId,
|
||||
path: pathPosix().join(response.data, createDocElement.previousElementSibling.textContent.trim() || "Untitled"),
|
||||
parentID: protyle.block.rootID,
|
||||
markdown: ""
|
||||
}, response => {
|
||||
transaction(protyle, [{
|
||||
action: "updateAttrViewCell",
|
||||
id: createDocElement.parentElement.dataset.id,
|
||||
avID: blockElement.getAttribute("data-av-id"),
|
||||
keyID: createDocElement.parentElement.dataset.colId,
|
||||
rowID: createDocElement.parentElement.parentElement.dataset.id,
|
||||
data: {
|
||||
isDetached: false
|
||||
}
|
||||
}]);
|
||||
});
|
||||
});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
}
|
||||
|
||||
const cellElement = hasClosestByClassName(event.target, "av__cell");
|
||||
if (cellElement && !cellElement.parentElement.classList.contains("av__row--header")) {
|
||||
cellElement.parentElement.parentElement.querySelectorAll(".av__row--select").forEach(item => {
|
||||
|
|
@ -175,7 +204,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||
if (addRowElement) {
|
||||
const avID = blockElement.getAttribute("data-av-id");
|
||||
const srcIDs = [Lute.NewNodeID()];
|
||||
const previousID = addRowElement.getAttribute("data-id") || "";
|
||||
const previousID = addRowElement.previousElementSibling.getAttribute("data-id") || "";
|
||||
transaction(protyle, [{
|
||||
action: "insertAttrViewBlock",
|
||||
avID,
|
||||
|
|
@ -193,30 +222,6 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||
return true;
|
||||
}
|
||||
|
||||
const createDocElement = hasClosestByAttribute(event.target, "data-type","createdoc");
|
||||
if (createDocElement) {
|
||||
// fetchPost("/api/filetree/createDocWithMd", {
|
||||
// notebook: protyle.notebookId,
|
||||
// path: pathPosix().join(pathString, realFileName),
|
||||
// parentID: protyle.block.rootID,
|
||||
// markdown: ""
|
||||
// }, response => {
|
||||
// transaction(protyle, [{
|
||||
// action: "updateAttrViewCell",
|
||||
// id: cellId,
|
||||
// avID,
|
||||
// keyID: colId,
|
||||
// rowID,
|
||||
// data: {
|
||||
// isDetached: false
|
||||
// }
|
||||
// }]);
|
||||
// });
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
|
|||
if (!type) {
|
||||
type = cellElements[0].parentElement.parentElement.firstElementChild.querySelector(`[data-col-id="${cellElements[0].getAttribute("data-col-id")}"]`).getAttribute("data-dtype") as TAVCol;
|
||||
}
|
||||
if (type === "block" && (cellElements.length > 0 || !cellElements[0].getAttribute("data-detached"))) {
|
||||
if (type === "block" && (cellElements.length > 1 || !cellElements[0].getAttribute("data-detached"))) {
|
||||
return;
|
||||
}
|
||||
const cellRect = cellElements[0].getBoundingClientRect();
|
||||
|
|
@ -416,7 +416,7 @@ const updateCellValue = (protyle: IProtyle, type: TAVCol, cellElements: HTMLElem
|
|||
content: (avMaskElement.querySelector(".b3-text-field") as HTMLInputElement).value
|
||||
};
|
||||
const oldValue: { content: string | number, isNotEmpty?: boolean } = {
|
||||
content: item.textContent.trim()
|
||||
content: type === "block" ? item.firstElementChild.textContent.trim() : item.textContent.trim()
|
||||
};
|
||||
if (type === "number") {
|
||||
oldValue.content = parseFloat(oldValue.content as string);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
|
|||
text += `<span data-type="copy" class="b3-tooltips b3-tooltips__n block__icon" aria-label="${window.siyuan.languages.copy}"><svg><use xlink:href="#iconCopy"></use></svg></span>`;
|
||||
}
|
||||
} else if (cell.valueType === "block") {
|
||||
text = `<span class="av__celltext"${cell.value.isDetached ? ' data-detached="true""' : ""}>${cell.value.block.content || ""}</span>`;
|
||||
text = `<span class="av__celltext">${cell.value.block.content || ""}</span>`;
|
||||
if (cell.value?.isDetached) {
|
||||
text += `<span class="b3-chip b3-chip--info b3-chip--small" data-type="createdoc" >${window.siyuan.languages.new}</span>`;
|
||||
} else {
|
||||
|
|
@ -112,6 +112,7 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
|
|||
}
|
||||
tableHTML += `<div class="av__cell" data-id="${cell.id}" data-col-id="${data.columns[index].id}"
|
||||
${cell.valueType === "block" ? 'data-block-id="' + (cell.value.block.id || "") + '"' : ""}
|
||||
${cell.value?.isDetached ? ' data-detached="true"' : ""}
|
||||
style="width: ${data.columns[index].width || "200px"};
|
||||
${cell.bgColor ? `background-color:${cell.bgColor};` : ""}
|
||||
${data.columns[index].wrap ? "" : "white-space: nowrap;"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue