mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
This commit is contained in:
parent
f965ef0945
commit
37892e786b
4 changed files with 47 additions and 3 deletions
|
|
@ -109,7 +109,7 @@ export const getEditHTML = (options: {
|
||||||
html += `<button class="b3-menu__separator"></button>
|
html += `<button class="b3-menu__separator"></button>
|
||||||
<button class="b3-menu__item">
|
<button class="b3-menu__item">
|
||||||
<svg class="b3-menu__icon" style=""><use xlink:href="#iconAdd"></use></svg>
|
<svg class="b3-menu__icon" style=""><use xlink:href="#iconAdd"></use></svg>
|
||||||
<span class="b3-menu__label"><input data-type="addOption" style="margin: 4px 0" class="b3-text-field" type="text" placeholder="Enter ${window.siyuan.languages.addAttr}"></span>
|
<span class="b3-menu__label"><input data-type="addOption" style="margin: 4px 0" class="b3-text-field fn__block" type="text" placeholder="Enter ${window.siyuan.languages.addAttr}"></span>
|
||||||
</button>`;
|
</button>`;
|
||||||
colData.options.forEach(item => {
|
colData.options.forEach(item => {
|
||||||
html += `<button class="b3-menu__item${html ? "" : " b3-menu__item--current"}" draggable="true" data-name="${item.name}" data-color="${item.color}">
|
html += `<button class="b3-menu__item${html ? "" : " b3-menu__item--current"}" draggable="true" data-name="${item.name}" data-color="${item.color}">
|
||||||
|
|
@ -129,6 +129,11 @@ export const getEditHTML = (options: {
|
||||||
<svg class="b3-menu__icon"><use xlink:href="#iconFormat"></use></svg>
|
<svg class="b3-menu__icon"><use xlink:href="#iconFormat"></use></svg>
|
||||||
<span class="b3-menu__label">${window.siyuan.languages.format}</span>
|
<span class="b3-menu__label">${window.siyuan.languages.format}</span>
|
||||||
<span class="b3-menu__accelerator">${getLabelByNumberFormat(colData.numberFormat)}</span>
|
<span class="b3-menu__accelerator">${getLabelByNumberFormat(colData.numberFormat)}</span>
|
||||||
|
</button>`;
|
||||||
|
} else if (colData.type === "template") {
|
||||||
|
html += `<button class="b3-menu__separator"></button>
|
||||||
|
<button class="b3-menu__item">
|
||||||
|
<textarea placeholder="${window.siyuan.languages.template}" data-type="updateTemplate" style="margin: 4px 0" cols="1" class="fn__block b3-text-field">${colData.template}</textarea>
|
||||||
</button>`;
|
</button>`;
|
||||||
}
|
}
|
||||||
return `<div class="b3-menu__items">
|
return `<div class="b3-menu__items">
|
||||||
|
|
@ -185,6 +190,42 @@ export const bindEditEvent = (options: { protyle: IProtyle, data: IAV, menuEleme
|
||||||
options.menuElement.parentElement.remove();
|
options.menuElement.parentElement.remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const tplElement = options.menuElement.querySelector('[data-type="updateTemplate"]') as HTMLTextAreaElement
|
||||||
|
if (tplElement) {
|
||||||
|
tplElement.addEventListener("blur", () => {
|
||||||
|
const newValue = tplElement.value;
|
||||||
|
if (newValue === colData.template) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
transaction(options.protyle, [{
|
||||||
|
action: "updateAttrViewColTemplate",
|
||||||
|
id: colId,
|
||||||
|
avID,
|
||||||
|
data: newValue,
|
||||||
|
type: colData.type,
|
||||||
|
}], [{
|
||||||
|
action: "updateAttrViewColTemplate",
|
||||||
|
id: colId,
|
||||||
|
avID,
|
||||||
|
data: colData.template,
|
||||||
|
type: colData.type,
|
||||||
|
}]);
|
||||||
|
colData.template = newValue;
|
||||||
|
});
|
||||||
|
tplElement.addEventListener("keydown", (event: KeyboardEvent) => {
|
||||||
|
if (event.isComposing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.key === "Escape") {
|
||||||
|
options.menuElement.parentElement.remove();
|
||||||
|
} else if (event.key === "Enter") {
|
||||||
|
tplElement.dispatchEvent(new CustomEvent("blur"));
|
||||||
|
options.menuElement.parentElement.remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const addOptionElement = options.menuElement.querySelector('[data-type="addOption"]') as HTMLInputElement;
|
const addOptionElement = options.menuElement.querySelector('[data-type="addOption"]') as HTMLInputElement;
|
||||||
if (!addOptionElement) {
|
if (!addOptionElement) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
|
||||||
}
|
}
|
||||||
let text = "";
|
let text = "";
|
||||||
if (["text", "template"].includes(cell.valueType)) {
|
if (["text", "template"].includes(cell.valueType)) {
|
||||||
text = `<span class="av__celltext">${cell.value ? cell.value[cell.valueType as "text"].content : ""}</span>`;
|
text = `<span class="av__celltext">${cell.value ? (cell.value[cell.valueType as "text"].content || "") : ""}</span>`;
|
||||||
} else if (["url", "email", "phone"].includes(cell.valueType)) {
|
} else if (["url", "email", "phone"].includes(cell.valueType)) {
|
||||||
const urlContent = cell.value ? cell.value[cell.valueType as "url"].content : "";
|
const urlContent = cell.value ? cell.value[cell.valueType as "url"].content : "";
|
||||||
// https://github.com/siyuan-note/siyuan/issues/9291
|
// https://github.com/siyuan-note/siyuan/issues/9291
|
||||||
|
|
|
||||||
|
|
@ -708,7 +708,8 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
|
||||||
} else if (["addAttrViewCol", "insertAttrViewBlock", "updateAttrViewCol", "updateAttrViewColOptions",
|
} else if (["addAttrViewCol", "insertAttrViewBlock", "updateAttrViewCol", "updateAttrViewColOptions",
|
||||||
"updateAttrViewColOption", "updateAttrViewCell", "sortAttrViewRow", "sortAttrViewCol", "setAttrViewColHidden",
|
"updateAttrViewColOption", "updateAttrViewCell", "sortAttrViewRow", "sortAttrViewCol", "setAttrViewColHidden",
|
||||||
"setAttrViewColWrap", "setAttrViewColWidth", "removeAttrViewColOption", "setAttrViewName", "setAttrViewFilters",
|
"setAttrViewColWrap", "setAttrViewColWidth", "removeAttrViewColOption", "setAttrViewName", "setAttrViewFilters",
|
||||||
"setAttrViewSorts", "setAttrViewColCalc", "removeAttrViewCol", "updateAttrViewColNumberFormat", "replaceAttrViewBlock"].includes(operation.action)) {
|
"setAttrViewSorts", "setAttrViewColCalc", "removeAttrViewCol", "updateAttrViewColNumberFormat",
|
||||||
|
"replaceAttrViewBlock", "updateAttrViewColTemplate"].includes(operation.action)) {
|
||||||
refreshAV(protyle, operation);
|
refreshAV(protyle, operation);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
2
app/src/types/index.d.ts
vendored
2
app/src/types/index.d.ts
vendored
|
|
@ -24,6 +24,7 @@ type TOperation =
|
||||||
| "removeFlashcards"
|
| "removeFlashcards"
|
||||||
| "updateAttrViewCell"
|
| "updateAttrViewCell"
|
||||||
| "updateAttrViewCol"
|
| "updateAttrViewCol"
|
||||||
|
| "updateAttrViewColTemplate"
|
||||||
| "sortAttrViewRow"
|
| "sortAttrViewRow"
|
||||||
| "sortAttrViewCol"
|
| "sortAttrViewCol"
|
||||||
| "setAttrViewColHidden"
|
| "setAttrViewColHidden"
|
||||||
|
|
@ -1022,6 +1023,7 @@ interface IAVColumn {
|
||||||
hidden: boolean,
|
hidden: boolean,
|
||||||
type: TAVCol,
|
type: TAVCol,
|
||||||
numberFormat: string,
|
numberFormat: string,
|
||||||
|
template: string,
|
||||||
calc: {
|
calc: {
|
||||||
operator: string,
|
operator: string,
|
||||||
result: IAVCellValue
|
result: IAVCellValue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue