mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-21 19:41:05 +08:00
This commit is contained in:
parent
cbcc8141a8
commit
3f21eda746
@ -47,6 +47,14 @@
|
|||||||
&__views {
|
&__views {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
box-shadow: 0px -1px inset var(--b3-theme-background-light);
|
box-shadow: 0px -1px inset var(--b3-theme-background-light);
|
||||||
|
|
||||||
|
&--show .block__icon {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.b3-text-field {
|
||||||
|
transition: var(--b3-width-transition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__title {
|
&__title {
|
||||||
|
@ -115,6 +115,15 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return true;
|
return true;
|
||||||
|
} else if (type === "av-search-icon") {
|
||||||
|
const searchElement = blockElement.querySelector('input[data-type="av-search"]') as HTMLInputElement;
|
||||||
|
searchElement.style.width = "128px";
|
||||||
|
searchElement.style.paddingLeft = "";
|
||||||
|
searchElement.style.paddingRight = "";
|
||||||
|
searchElement.focus();
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
return true;
|
||||||
} else if (type === "av-filter") {
|
} else if (type === "av-filter") {
|
||||||
openMenuPanel({protyle, blockElement, type: "filters"});
|
openMenuPanel({protyle, blockElement, type: "filters"});
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -9,6 +9,7 @@ import {stickyRow} from "./row";
|
|||||||
import {getCalcValue} from "./calc";
|
import {getCalcValue} from "./calc";
|
||||||
import {renderAVAttribute} from "./blockAttr";
|
import {renderAVAttribute} from "./blockAttr";
|
||||||
import {showMessage} from "../../../dialog/message";
|
import {showMessage} from "../../../dialog/message";
|
||||||
|
import {addClearButton} from "../../../util/addClearButton";
|
||||||
|
|
||||||
export const avRender = (element: Element, protyle: IProtyle, cb?: () => void, viewID?: string) => {
|
export const avRender = (element: Element, protyle: IProtyle, cb?: () => void, viewID?: string) => {
|
||||||
let avElements: Element[] = [];
|
let avElements: Element[] = [];
|
||||||
@ -62,7 +63,8 @@ export const avRender = (element: Element, protyle: IProtyle, cb?: () => void, v
|
|||||||
created,
|
created,
|
||||||
snapshot,
|
snapshot,
|
||||||
pageSize: parseInt(e.dataset.pageSize) || undefined,
|
pageSize: parseInt(e.dataset.pageSize) || undefined,
|
||||||
viewID: newViewID
|
viewID: newViewID,
|
||||||
|
query: (e.querySelector('.b3-text-field[data-type="av-search"]') as HTMLInputElement)?.value || ""
|
||||||
}, (response) => {
|
}, (response) => {
|
||||||
const data = response.data.view as IAVTable;
|
const data = response.data.view as IAVTable;
|
||||||
if (!e.dataset.pageSize) {
|
if (!e.dataset.pageSize) {
|
||||||
@ -197,6 +199,13 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value)}</div>`;
|
|||||||
<svg><use xlink:href="#iconSort"></use></svg>
|
<svg><use xlink:href="#iconSort"></use></svg>
|
||||||
</span>
|
</span>
|
||||||
<div class="fn__space"></div>
|
<div class="fn__space"></div>
|
||||||
|
<span data-type="av-search-icon" class="block__icon">
|
||||||
|
<svg><use xlink:href="#iconSearch"></use></svg>
|
||||||
|
</span>
|
||||||
|
<div style="position: relative">
|
||||||
|
<input style="width:0;padding-left: 0;padding-right: 0;" data-type="av-search" class="b3-text-field b3-text-field--text" placeholder="${window.siyuan.languages.search}">
|
||||||
|
</div>
|
||||||
|
<div class="fn__space"></div>
|
||||||
<span data-type="av-more" class="block__icon">
|
<span data-type="av-more" class="block__icon">
|
||||||
<svg><use xlink:href="#iconMore"></use></svg>
|
<svg><use xlink:href="#iconMore"></use></svg>
|
||||||
</span>
|
</span>
|
||||||
@ -280,6 +289,56 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value)}</div>`;
|
|||||||
if (cb) {
|
if (cb) {
|
||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
|
const viewsElement = e.querySelector(".av__views") as HTMLElement;
|
||||||
|
const searchInputElement = e.querySelector('[data-type="av-search"]') as HTMLInputElement;
|
||||||
|
searchInputElement.addEventListener("input", (event: KeyboardEvent) => {
|
||||||
|
if (event.isComposing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (searchInputElement.value) {
|
||||||
|
viewsElement.classList.add("av__views--show");
|
||||||
|
} else {
|
||||||
|
viewsElement.classList.remove("av__views--show");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
searchInputElement.addEventListener("keydown", (event: KeyboardEvent) => {
|
||||||
|
if (event.isComposing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.key === "Enter") {
|
||||||
|
e.removeAttribute("data-render");
|
||||||
|
avRender(e, protyle)
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
searchInputElement.addEventListener("compositionend", (event: KeyboardEvent) => {
|
||||||
|
if (event.key === "Enter") {
|
||||||
|
// todo
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
searchInputElement.addEventListener("blur", (event: KeyboardEvent) => {
|
||||||
|
if (event.isComposing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!searchInputElement.value) {
|
||||||
|
viewsElement.classList.remove("av__views--show");
|
||||||
|
searchInputElement.style.width = "0";
|
||||||
|
searchInputElement.style.paddingLeft = "0";
|
||||||
|
searchInputElement.style.paddingRight = "0";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
addClearButton({
|
||||||
|
inputElement: searchInputElement,
|
||||||
|
right: 0,
|
||||||
|
height: searchInputElement.clientHeight,
|
||||||
|
clearCB() {
|
||||||
|
viewsElement.classList.remove("av__views--show");
|
||||||
|
searchInputElement.style.width = "0";
|
||||||
|
searchInputElement.style.paddingLeft = "0";
|
||||||
|
searchInputElement.style.paddingRight = "0";
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ export const getContentByInlineHTML = (range: Range, cb: (content: string) => vo
|
|||||||
|
|
||||||
export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
editorElement.addEventListener("keydown", (event: KeyboardEvent & { target: HTMLElement }) => {
|
editorElement.addEventListener("keydown", (event: KeyboardEvent & { target: HTMLElement }) => {
|
||||||
if (event.target.localName === "protyle-html") {
|
if (event.target.localName === "protyle-html" || event.target.localName === "input") {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
const update = (inputElement: HTMLInputElement, clearElement: Element, right: number) => {
|
const update = (inputElement: HTMLInputElement, clearElement: Element, right: number) => {
|
||||||
if (inputElement.value === "") {
|
if (inputElement.value === "") {
|
||||||
clearElement.classList.add("fn__none");
|
clearElement.classList.add("fn__none");
|
||||||
if (right) {
|
if (typeof right === "number") {
|
||||||
inputElement.style.paddingRight = "";
|
inputElement.style.paddingRight = inputElement.dataset.oldPaddingRight;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
clearElement.classList.remove("fn__none");
|
clearElement.classList.remove("fn__none");
|
||||||
if (right) {
|
if (typeof right === "number") {
|
||||||
inputElement.style.setProperty("padding-right", `${right * 2 + clearElement.clientWidth}px`, "important");
|
inputElement.style.setProperty("padding-right", `${right * 2 + clearElement.clientWidth}px`, "important");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -18,6 +18,7 @@ export const addClearButton = (options: {
|
|||||||
height?: number
|
height?: number
|
||||||
className?: string
|
className?: string
|
||||||
}) => {
|
}) => {
|
||||||
|
options.inputElement.dataset.oldPaddingRight = options.inputElement.style.paddingRight;
|
||||||
options.inputElement.insertAdjacentHTML("afterend",
|
options.inputElement.insertAdjacentHTML("afterend",
|
||||||
`<svg class="${options.className || "b3-form__icon-clear"} ariaLabel" aria-label="${window.siyuan.languages.clear}" style="${options.right ? "right: " + options.right + "px;" : ""}${options.height ? "height:" + options.height + "px" : ""}">
|
`<svg class="${options.className || "b3-form__icon-clear"} ariaLabel" aria-label="${window.siyuan.languages.clear}" style="${options.right ? "right: " + options.right + "px;" : ""}${options.height ? "height:" + options.height + "px" : ""}">
|
||||||
<use xlink:href="#iconCloseRound"></use></svg>`);
|
<use xlink:href="#iconCloseRound"></use></svg>`);
|
||||||
|
Loading…
Reference in New Issue
Block a user