This commit is contained in:
parent
f404d7fe85
commit
c1de5e1488
4 changed files with 23 additions and 1 deletions
|
@ -245,6 +245,9 @@ export const openFileAttr = (attrs: IObject, focusName = "bookmark", protyle?: I
|
|||
(dialog.element.querySelector('.b3-text-field[data-name="alias"]') as HTMLInputElement).value = attrs.alias || "";
|
||||
dialog.element.addEventListener("click", (event) => {
|
||||
let target = event.target as HTMLElement;
|
||||
if (typeof event.detail === "string") {
|
||||
target = dialog.element.querySelector('.item--full[data-type="NodeAttributeView"]')
|
||||
}
|
||||
while (!target.isSameNode(dialog.element)) {
|
||||
const type = target.dataset.action;
|
||||
if (target.classList.contains("item--full")) {
|
||||
|
@ -342,11 +345,14 @@ export const openFileAttr = (attrs: IObject, focusName = "bookmark", protyle?: I
|
|||
}
|
||||
});
|
||||
dialog.element.querySelectorAll(".b3-text-field").forEach((item: HTMLInputElement) => {
|
||||
if (focusName === item.getAttribute("data-name")) {
|
||||
if (focusName !== "av" && focusName === item.getAttribute("data-name")) {
|
||||
item.focus();
|
||||
}
|
||||
bindAttrInput(item, attrs.id);
|
||||
});
|
||||
if (focusName === "av") {
|
||||
dialog.element.dispatchEvent(new CustomEvent("click", {detail: "av"}));
|
||||
}
|
||||
};
|
||||
|
||||
export const openAttr = (nodeElement: Element, focusName = "bookmark", protyle?: IProtyle) => {
|
||||
|
|
|
@ -299,6 +299,9 @@ export class Title {
|
|||
if (response.data.ial.memo) {
|
||||
nodeAttrHTML += `<div class="protyle-attr--memo b3-tooltips b3-tooltips__sw" aria-label="${Lute.EscapeHTMLStr(response.data.ial.memo)}"><svg><use xlink:href="#iconM"></use></svg></div>`;
|
||||
}
|
||||
if (response.data.ial["custom-avs"]) {
|
||||
nodeAttrHTML += '<div class="protyle-attr--av"><svg><use xlink:href="#iconDatabase"></use></svg></div>';
|
||||
}
|
||||
this.element.querySelector(".protyle-attr").innerHTML = nodeAttrHTML;
|
||||
if (response.data.refCount !== 0) {
|
||||
this.element.querySelector(".protyle-attr").insertAdjacentHTML("beforeend", `<div class="protyle-attr--refcount popover__block" data-defids='${JSON.stringify([protyle.block.rootID])}' data-id='${JSON.stringify(response.data.refIDs)}'>${response.data.refCount}</div>`);
|
||||
|
|
|
@ -43,6 +43,17 @@ export const commonClick = (event: MouseEvent & {
|
|||
return true;
|
||||
}
|
||||
|
||||
const avElement = hasClosestByClassName(event.target, "protyle-attr--av");
|
||||
if (avElement) {
|
||||
if (data) {
|
||||
openFileAttr(data, "av", protyle);
|
||||
} else {
|
||||
openAttr(avElement.parentElement.parentElement, "av", protyle);
|
||||
}
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
}
|
||||
|
||||
const attrAliasElement = hasClosestByClassName(event.target, "protyle-attr--alias");
|
||||
if (attrAliasElement) {
|
||||
if (!isM && (event.ctrlKey || event.metaKey)) {
|
||||
|
|
|
@ -482,6 +482,8 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
|
|||
aliasHTML = `<div class="protyle-attr--alias"><svg><use xlink:href="#iconA"></use></svg>${escapeHTML}</div>`;
|
||||
} else if (key === "memo") {
|
||||
memoHTML = `<div class="protyle-attr--memo b3-tooltips b3-tooltips__sw" aria-label="${escapeHTML}"><svg><use xlink:href="#iconM"></use></svg></div>`;
|
||||
} else if (key === "custom-avs") {
|
||||
memoHTML = `<div class="protyle-attr--av"><svg><use xlink:href="#iconDatabase"></use></svg></div>`;
|
||||
}
|
||||
});
|
||||
let nodeAttrHTML = bookmarkHTML + nameHTML + aliasHTML + memoHTML;
|
||||
|
|
Loading…
Add table
Reference in a new issue