mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🚨
This commit is contained in:
parent
0b5f9bce98
commit
87dcbcd58c
6 changed files with 31 additions and 32 deletions
|
|
@ -174,7 +174,7 @@ const genAttr = (attrs: IObject, focusName = "bookmark", cb: (dialog: Dialog, rm
|
|||
<input class="b3-text-field fn__block" type="datetime-local" readonly data-name="${item}" value="${dayjs(attrs[item]).format("YYYY-MM-DDTHH:mm")}">
|
||||
</label>`;
|
||||
} else if (item.indexOf("custom-av") > -1) {
|
||||
hasAV = true
|
||||
hasAV = true;
|
||||
// avHTML += `<label class="b3-label b3-label--noborder">
|
||||
// <div class="fn__flex">
|
||||
// <span class="fn__flex-1">${item.replace("custom-", "")}</span>
|
||||
|
|
@ -272,27 +272,27 @@ const genAttr = (attrs: IObject, focusName = "bookmark", cb: (dialog: Dialog, rm
|
|||
return;
|
||||
}
|
||||
while (!target.isSameNode(dialog.element)) {
|
||||
const type = target.dataset.action
|
||||
const type = target.dataset.action;
|
||||
if (target.classList.contains("item--full")) {
|
||||
target.parentElement.querySelector('.item--focus').classList.remove("item--focus")
|
||||
target.classList.add("item--focus")
|
||||
target.parentElement.querySelector(".item--focus").classList.remove("item--focus");
|
||||
target.classList.add("item--focus");
|
||||
dialog.element.querySelectorAll(".custom-attr").forEach((item: HTMLElement) => {
|
||||
if (item.dataset.type === target.dataset.type) {
|
||||
if (item.dataset.type === "av" && item.innerHTML === "") {
|
||||
renderAVAttribute(item, attrs.id);
|
||||
}
|
||||
item.classList.remove("fn__none")
|
||||
item.classList.remove("fn__none");
|
||||
} else {
|
||||
item.classList.add("fn__none")
|
||||
item.classList.add("fn__none");
|
||||
}
|
||||
})
|
||||
});
|
||||
} else if (type === "remove") {
|
||||
if (target.previousElementSibling.tagName === "SPAN") {
|
||||
removeAttrs.push(target.parentElement.parentElement.querySelector("textarea").getAttribute("data-name"));
|
||||
}
|
||||
target.parentElement.parentElement.remove();
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
break;
|
||||
} else if (type === "bookmark") {
|
||||
fetchPost("/api/attr/getBookmarkLabels", {}, (response) => {
|
||||
|
|
@ -317,8 +317,8 @@ const genAttr = (attrs: IObject, focusName = "bookmark", cb: (dialog: Dialog, rm
|
|||
window.siyuan.menus.menu.element.classList.add("b3-menu--list");
|
||||
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY + 16, w: 16});
|
||||
});
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
break;
|
||||
} else if (type === "addCustom") {
|
||||
target.parentElement.insertAdjacentHTML("beforebegin", `<div class="b3-label b3-label--noborder">
|
||||
|
|
@ -334,8 +334,8 @@ const genAttr = (attrs: IObject, focusName = "bookmark", cb: (dialog: Dialog, rm
|
|||
inputElements[inputElements.length - 2].focus();
|
||||
bindAttrInput(inputElements[inputElements.length - 1], dialog.element);
|
||||
bindAttrInput(inputElements[inputElements.length - 2], dialog.element);
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
break;
|
||||
} else if (type === "closeDialog") {
|
||||
dialog.destroy();
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import {uploadFiles} from "../upload";
|
|||
import {openFileById} from "../../editor/util";
|
||||
/// #endif
|
||||
import {openMobileFileById} from "../../mobile/editor";
|
||||
import {getIconByType} from "../../editor/getIcon";
|
||||
import {processRender} from "../util/processCode";
|
||||
import {AIChat} from "../../ai/chat";
|
||||
import {isMobile} from "../../util/functions";
|
||||
|
|
@ -279,7 +278,7 @@ ${unicode2Emoji(emoji.unicode)}</button>`;
|
|||
}
|
||||
this.element.style.width = Math.max(protyle.element.clientWidth / 2, 320) + "px";
|
||||
if (this.source === "av") {
|
||||
const blockElement = hasClosestBlock(protyle.toolbar.range.startContainer)
|
||||
const blockElement = hasClosestBlock(protyle.toolbar.range.startContainer);
|
||||
if (blockElement) {
|
||||
const rowAddRect = blockElement.querySelector(".av__row--add").getBoundingClientRect();
|
||||
setPosition(this.element, rowAddRect.left, rowAddRect.bottom, rowAddRect.height);
|
||||
|
|
@ -414,8 +413,8 @@ ${genHintItemHTML(item)}
|
|||
}
|
||||
if (this.source === "av") {
|
||||
const avID = nodeElement.getAttribute("data-av-id");
|
||||
const rowsElement = nodeElement.querySelectorAll(".av__row")
|
||||
const previousID = rowsElement[rowsElement.length - 1].getAttribute("data-id")
|
||||
const rowsElement = nodeElement.querySelectorAll(".av__row");
|
||||
const previousID = rowsElement[rowsElement.length - 1].getAttribute("data-id");
|
||||
let tempElement = document.createElement("div");
|
||||
tempElement.innerHTML = value.replace(/<mark>/g, "").replace(/<\/mark>/g, "");
|
||||
tempElement = tempElement.firstElementChild as HTMLDivElement;
|
||||
|
|
@ -442,7 +441,7 @@ ${genHintItemHTML(item)}
|
|||
});
|
||||
});
|
||||
} else {
|
||||
const sourceId = tempElement.getAttribute('data-id')
|
||||
const sourceId = tempElement.getAttribute("data-id");
|
||||
transaction(protyle, [{
|
||||
action: "insertAttrViewBlock",
|
||||
avID,
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ export const setFilter = (options: {
|
|||
const rectTarget = options.target.getBoundingClientRect();
|
||||
const menu = new Menu("set-filter-" + options.filter.column, () => {
|
||||
const oldFilters = JSON.parse(JSON.stringify(options.data.view.filters));
|
||||
const operator = (window.siyuan.menus.menu.element.querySelector(".b3-select") as HTMLSelectElement).value as TAVFilterOperator
|
||||
const operator = (window.siyuan.menus.menu.element.querySelector(".b3-select") as HTMLSelectElement).value as TAVFilterOperator;
|
||||
let hasMatch = false;
|
||||
let cellValue: IAVCellValue;
|
||||
if (textElements.length > 0) {
|
||||
|
|
@ -268,7 +268,7 @@ export const setFilter = (options: {
|
|||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
toggleEmpty(selectElement, selectElement.value, colData.type);
|
||||
menu.open({x: rectTarget.left, y: rectTarget.bottom});
|
||||
if (textElements.length > 0) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export const openMenuPanel = (options: {
|
|||
}
|
||||
window.siyuan.menus.menu.remove();
|
||||
const avID = options.blockElement.getAttribute("data-av-id");
|
||||
const nodeID = options.blockElement.getAttribute("data-node-id")
|
||||
const nodeID = options.blockElement.getAttribute("data-node-id");
|
||||
fetchPost("/api/av/renderAttributeView", {
|
||||
id: avID,
|
||||
nodeID
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
|
|||
};
|
||||
|
||||
const genAVValueHTML = (value: IAVCellValue) => {
|
||||
let html = ""
|
||||
let html = "";
|
||||
switch (value.type) {
|
||||
case "text":
|
||||
html = `<input value="${value.text.content}" class="b3-text-field b3-text-field--text fn__flex-1">`;
|
||||
|
|
@ -212,7 +212,7 @@ const genAVValueHTML = (value: IAVCellValue) => {
|
|||
case "select":
|
||||
value.mSelect?.forEach(item => {
|
||||
html += `<span class="b3-chip b3-chip--middle" style="background-color:var(--b3-font-background${item.color});color:var(--b3-font-color${item.color})">${item.content}</span>`;
|
||||
})
|
||||
});
|
||||
break;
|
||||
case "date":
|
||||
html = `<input value="${dayjs(value.date.content).format("YYYY-MM-DD HH:mm")}" type="datetime-local" class="b3-text-field b3-text-field--text fn__flex-1">`;
|
||||
|
|
@ -226,11 +226,11 @@ const genAVValueHTML = (value: IAVCellValue) => {
|
|||
break;
|
||||
}
|
||||
return html;
|
||||
}
|
||||
};
|
||||
|
||||
export const renderAVAttribute = (element: HTMLElement, id: string) => {
|
||||
fetchPost("/api/av/getAttributeViewKeys", {id}, (response) => {
|
||||
let html = ""
|
||||
let html = "";
|
||||
response.data.forEach((table: {
|
||||
keyValues: {
|
||||
key: {
|
||||
|
|
@ -254,9 +254,9 @@ export const renderAVAttribute = (element: HTMLElement, id: string) => {
|
|||
<div class="fn__flex-1 fn__flex">
|
||||
${genAVValueHTML(item.values[0])}
|
||||
</div>
|
||||
</div>`
|
||||
})
|
||||
})
|
||||
element.innerHTML = html
|
||||
})
|
||||
}
|
||||
</div>`;
|
||||
});
|
||||
});
|
||||
element.innerHTML = html;
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ export const bindSelectEvent = (protyle: IProtyle, data: IAV, menuElement: HTMLE
|
|||
if (!colData.options) {
|
||||
colData.options = [];
|
||||
}
|
||||
const listElement = menuElement.lastElementChild.lastElementChild as HTMLElement
|
||||
const listElement = menuElement.lastElementChild.lastElementChild as HTMLElement;
|
||||
inputElement.addEventListener("input", (event: InputEvent) => {
|
||||
if (event.isComposing) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue