Skip to content

Commit

Permalink
🎨 #9294
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Sep 27, 2023
1 parent 85aca52 commit 587668a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
27 changes: 27 additions & 0 deletions app/src/protyle/render/av/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {focusByRange} from "../../util/selection";
import {writeText} from "../../util/compatibility";
import {showMessage} from "../../../dialog/message";
import {previewImage} from "../../preview/image";
import {fetchPost} from "../../../util/fetch";
import {pathPosix} from "../../../util/pathName";

export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLElement }) => {
const blockElement = hasClosestBlock(event.target);
Expand Down Expand Up @@ -190,6 +192,31 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
event.stopPropagation();
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;
};

Expand Down
4 changes: 2 additions & 2 deletions app/src/protyle/render/av/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,14 @@ 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") {
if (type === "block" && (cellElements.length > 0 || !cellElements[0].getAttribute("data-detached"))) {
return;
}
const cellRect = cellElements[0].getBoundingClientRect();
let html = "";
const style = `style="position:absolute;left: ${cellRect.left}px;top: ${cellRect.top}px;width:${Math.max(cellRect.width, 200)}px;height: ${cellRect.height}px"`;
const blockElement = hasClosestBlock(cellElements[0]);
if (["text", "url", "email", "phone"].includes(type)) {
if (["text", "url", "email", "phone", "block"].includes(type)) {
html = `<textarea ${style} class="b3-text-field">${cellElements[0].firstElementChild.textContent}</textarea>`;
} else if (type === "number") {
html = `<input type="number" value="${cellElements[0].firstElementChild.getAttribute("data-content")}" ${style} class="b3-text-field">`;
Expand Down
6 changes: 4 additions & 2 deletions app/src/protyle/render/av/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ 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?.block.content || ""}</span>`;
if (cell.value?.block.id) {
text = `<span class="av__celltext"${cell.value.isDetached ? ' data-detached="true""' : ""}>${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 {
text += `<span class="b3-chip b3-chip--info b3-chip--small" data-type="block-ref" data-id="${cell.value.block.id}" data-subtype="s">${window.siyuan.languages.openBy}</span>`;
}
} else if (cell.valueType === "number") {
Expand Down
1 change: 1 addition & 0 deletions app/src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,7 @@ interface IAVCell {

interface IAVCellValue {
type?: TAVCol,
isDetached?: boolean,
text?: {
content: string
},
Expand Down

0 comments on commit 587668a

Please sign in to comment.