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