Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Oct 1, 2023
1 parent 6e475e1 commit b981fa0
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 22 deletions.
5 changes: 1 addition & 4 deletions app/appearance/icons/ant/icon.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/appearance/icons/ant/icon.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"name": "ant",
"author": "Vanessa",
"url": "https://github.com/Vanessa219",
"version": "1.23.0"
"version": "1.23.1"
}
6 changes: 0 additions & 6 deletions app/appearance/icons/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,6 @@ <h2>SiYuan</h2>
</svg>
iconBazaar
</div>
<div>
<svg>
<use xlink:href="#iconCalendar"></use>
</svg>
iconCalendar
</div>
<div>
<svg>
<use xlink:href="#iconKeymap"></use>
Expand Down
3 changes: 0 additions & 3 deletions app/appearance/icons/material/icon.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/appearance/icons/material/icon.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"name": "material",
"author": "Vanessa",
"url": "https://github.com/Vanessa219",
"version": "1.23.0"
"version": "1.23.1"
}
2 changes: 1 addition & 1 deletion app/src/menus/Menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class MenuItem {
if (typeof options.iconHTML === "string") {
html = options.iconHTML + html;
} else {
html = `<svg class="b3-menu__icon${["HTML (SiYuan)", window.siyuan.languages.template].includes(options.label) ? " ft__error" : ""}" style="${options.icon === "iconClose" ? "height:10px;" : ""}"><use xlink:href="#${options.icon || ""}"></use></svg>${html}`;
html = `<svg class="b3-menu__icon ${options.iconClass || ""}" style="${options.icon === "iconClose" ? "height:10px;" : ""}"><use xlink:href="#${options.icon || ""}"></use></svg>${html}`;
}
if (options.accelerator) {
html += `<span class="b3-menu__accelerator">${updateHotkeyTip(options.accelerator)}</span>`;
Expand Down
2 changes: 2 additions & 0 deletions app/src/menus/commonMenuItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ export const exportMd = (id: string) => {
icon: "iconUpload",
submenu: [{
label: window.siyuan.languages.template,
iconClass: "ft__error",
icon: "iconMarkdown",
click: async () => {
const result = await fetchSyncPost("/api/block/getRefText", {id: id});
Expand Down Expand Up @@ -536,6 +537,7 @@ export const exportMd = (id: string) => {
}
}, {
label: "HTML (SiYuan)",
iconClass: "ft__error",
icon: "iconHTML5",
click: () => {
saveExport({type: "html", id});
Expand Down
25 changes: 25 additions & 0 deletions app/src/protyle/render/av/addCol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,30 @@ export const addCol = (protyle: IProtyle, blockElement: Element) => {
});
}
});
menu.addItem({
icon: "iconMath",
label: window.siyuan.languages.template,
click() {
const id = Lute.NewNodeID();
transaction(protyle, [{
action: "addAttrViewCol",
name: window.siyuan.languages.template,
avID,
type: "template",
id
}], [{
action: "removeAttrViewCol",
id,
avID,
}]);
addAttrViewColAnimation({
blockElement: blockElement,
protyle: protyle,
type: "template",
name: window.siyuan.languages.template,
id
});
}
});
return menu;
};
7 changes: 5 additions & 2 deletions app/src/protyle/render/av/blockAttr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export const genAVValueHTML = (value: IAVCellValue) => {
<span class="fn__space"></span>
<a href="tel:${value.phone.content}" target="_blank" aria-label="${window.siyuan.languages.openBy}" class="block__icon block__icon--show fn__flex-center b3-tooltips__w b3-tooltips"><svg><use xlink:href="#iconPhone"></use></svg></a>`;
break;
case "template":
html = `<input value="${value.template.content}" class="b3-text-field b3-text-field--text fn__flex-1">`;
break;
case "email":
html = `<input value="${value.email.content}" class="b3-text-field b3-text-field--text fn__flex-1">
<span class="fn__space"></span>
Expand Down Expand Up @@ -83,7 +86,7 @@ export const renderAVAttribute = (element: HTMLElement, id: string, protyle?: IP
</div>
<div data-av-id="${table.avID}" data-col-id="${item.values[0].keyID}" data-block-id="${item.values[0].blockID}" data-id="${item.values[0].id}" data-type="${item.values[0].type}"
data-options="${item.key?.options ? escapeAttr(JSON.stringify(item.key.options)) : "[]"}"
class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone"].includes(item.values[0].type) ? "" : " custom-attr__avvalue"}">
class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone", "template"].includes(item.values[0].type) ? "" : " custom-attr__avvalue"}">
${genAVValueHTML(item.values[0])}
</div>
</div>`;
Expand Down Expand Up @@ -117,7 +120,7 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone"].includes
element.querySelectorAll(".b3-text-field--text").forEach((item: HTMLInputElement) => {
item.addEventListener("change", () => {
let value;
if (["url", "text", "email", "phone"].includes(item.parentElement.dataset.type)) {
if (["url", "text", "email", "phone", "template"].includes(item.parentElement.dataset.type)) {
value = {
[item.parentElement.dataset.type]: {
content: item.value
Expand Down
6 changes: 4 additions & 2 deletions app/src/protyle/render/av/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {
}
};
}
} else if (["text", "block", "url", "phone", "email"].includes(colType)) {
} else if (["text", "block", "url", "phone", "email", "template"].includes(colType)) {
cellValue = {
type: colType,
[colType]: {
Expand Down Expand Up @@ -353,7 +353,9 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
const blockElement = hasClosestBlock(cellElements[0]);
if (["text", "url", "email", "phone", "block"].includes(type)) {
html = `<textarea ${style} class="b3-text-field">${cellElements[0].firstElementChild.textContent}</textarea>`;
} else if (type === "number") {
} else if (type === "template") {
html = `<textarea ${style} class="b3-text-field">${cellElements[0].firstElementChild.getAttribute("data-content")}</textarea>`;
}else if (type === "number") {
html = `<input type="number" value="${cellElements[0].firstElementChild.getAttribute("data-content")}" ${style} class="b3-text-field">`;
} else if (["select", "mSelect"].includes(type) && blockElement) {
openMenuPanel({protyle, blockElement, type: "select", cellElements});
Expand Down
2 changes: 2 additions & 0 deletions app/src/protyle/render/av/col.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ export const getColIconByType = (type: TAVCol) => {
return "iconEmail";
case "phone":
return "iconPhone";
case "template":
return "iconMath";
}
};

Expand Down
5 changes: 3 additions & 2 deletions app/src/protyle/render/av/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const getDefaultOperatorByType = (type: TAVCol) => {
if (type === "number" || type === "select") {
return "=";
}
if (["text", "mSelect", "url", "block", "email", "phone"].includes(type)) {
if (["text", "mSelect", "url", "block", "email", "phone", "template"].includes(type)) {
return "Contains";
}
};
Expand Down Expand Up @@ -140,6 +140,7 @@ export const setFilter = (options: {
case "text":
case "url":
case "phone":
case "template":
case "email":
selectHTML = `<option ${"=" === options.filter.operator ? "selected" : ""} value="=">${window.siyuan.languages.filterOperatorIs}</option>
<option ${"!=" === options.filter.operator ? "selected" : ""} value="!=">${window.siyuan.languages.filterOperatorIsNot}</option>
Expand Down Expand Up @@ -214,7 +215,7 @@ export const setFilter = (options: {
}
});
});
} else if (["text", "url", "block", "email", "phone"].includes(colData.type)) {
} else if (["text", "url", "block", "email", "phone", "template"].includes(colData.type)) {
menu.addItem({
iconHTML: "",
label: `<input style="margin: 4px 0" value="${options.filter.value ? options.filter.value[colData.type as "text"].content : ""}" class="b3-text-field fn__size200">`
Expand Down
2 changes: 2 additions & 0 deletions app/src/protyle/render/av/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
let text = "";
if (cell.valueType === "text") {
text = `<span class="av__celltext">${cell.value?.text.content || ""}</span>`;
} else if (cell.valueType === "template") {
text = `<span class="av__celltext" data-content="${cell.value?.template.content || ""}">${cell.value?.template.renderedContent || ""}</span>`;
} else if (["url", "email", "phone"].includes(cell.valueType)) {
const urlContent = cell.value ? cell.value[cell.valueType as "url"].content : "";
// https://github.com/siyuan-note/siyuan/issues/9291
Expand Down
6 changes: 6 additions & 0 deletions app/src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type TAVCol =
| "email"
| "phone"
| "mAsset"
| "template"
type THintSource = "search" | "av" | "hint";
type TAVFilterOperator =
"="
Expand Down Expand Up @@ -929,6 +930,7 @@ interface IModels {
}

interface IMenu {
iconClass?: string,
label?: string,
click?: (element: HTMLElement, event: MouseEvent) => boolean | void | Promise<boolean | void>
type?: "separator" | "submenu" | "readonly",
Expand Down Expand Up @@ -1071,6 +1073,10 @@ interface IAVCellValue {
email?: {
content: string
}
template?: {
content: string
renderedContent?:string
}
date?: IAVCellDateValue
}

Expand Down

0 comments on commit b981fa0

Please sign in to comment.