mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-19 21:48:06 +01:00
🚨
This commit is contained in:
parent
5b4ad7ae17
commit
d6481711af
7 changed files with 30 additions and 30 deletions
|
|
@ -58,9 +58,9 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||
return false;
|
||||
}
|
||||
|
||||
let target = event.target
|
||||
let target = event.target;
|
||||
while (target && !target.isEqualNode(blockElement)) {
|
||||
const type = target.getAttribute("data-type")
|
||||
const type = target.getAttribute("data-type");
|
||||
if (type === "av-header-add") {
|
||||
const addMenu = addCol(protyle, blockElement);
|
||||
const addRect = target.getBoundingClientRect();
|
||||
|
|
@ -242,7 +242,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
|||
return true;
|
||||
} else if (target.classList.contains("item") && target.parentElement.classList.contains("layout-tab-bar")) {
|
||||
if (target.classList.contains("item--focus")) {
|
||||
openViewMenu({protyle, blockElement, element:target})
|
||||
openViewMenu({protyle, blockElement, element:target});
|
||||
} else {
|
||||
blockElement.removeAttribute("data-render");
|
||||
avRender(blockElement, protyle, undefined, target.dataset.id);
|
||||
|
|
|
|||
|
|
@ -541,7 +541,7 @@ export const openMenuPanel = (options: {
|
|||
data: target.dataset.icon,
|
||||
}]);
|
||||
target.innerHTML = unicode ? unicode2Emoji(unicode) : '<svg><use xlink:href="#iconTable"></use></svg>';
|
||||
target.dataset.icon = unicode
|
||||
target.dataset.icon = unicode;
|
||||
});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
|
@ -564,7 +564,7 @@ export const openMenuPanel = (options: {
|
|||
break;
|
||||
} else if (type === "delete-view") {
|
||||
if (data.views.length === 1) {
|
||||
removeBlock(options.protyle, options.blockElement, getEditorRange(options.blockElement))
|
||||
removeBlock(options.protyle, options.blockElement, getEditorRange(options.blockElement));
|
||||
} else {
|
||||
transaction(options.protyle, [{
|
||||
action: "removeAttrViewView",
|
||||
|
|
@ -598,7 +598,7 @@ export const openMenuPanel = (options: {
|
|||
}]);
|
||||
target.innerHTML = unicode ? unicode2Emoji(unicode) : `<svg><use xlink:href="#${getColIconByType(target.dataset.colType as TAVCol)}"></use></svg>`;
|
||||
updateAttrViewCellAnimation(options.blockElement.querySelector(`.av__row--header .av__cell[data-col-id="${colId}"]`));
|
||||
target.dataset.icon = unicode
|
||||
target.dataset.icon = unicode;
|
||||
});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ export const avRender = (element: Element, protyle: IProtyle, cb?: () => void, v
|
|||
if (typeof viewID === "string") {
|
||||
newViewID = viewID;
|
||||
} else if (typeof viewID === "undefined") {
|
||||
newViewID = e.querySelector(".av__header .item--focus")?.getAttribute("data-id")
|
||||
newViewID = e.querySelector(".av__header .item--focus")?.getAttribute("data-id");
|
||||
}
|
||||
fetchPost(created ? "/api/av/renderHistoryAttributeView" : (snapshot ? "/api/av/renderSnapshotAttributeView" : "/api/av/renderAttributeView"), {
|
||||
id: e.getAttribute("data-av-id"),
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ export const openViewMenu = (options: { protyle: IProtyle, blockElement: HTMLEle
|
|||
blockElement: options.blockElement,
|
||||
type: "config",
|
||||
cb: (avPanelElement) => {
|
||||
(avPanelElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement).focus()
|
||||
(avPanelElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement).focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
menu.addItem({
|
||||
icon: "iconSettings",
|
||||
label: window.siyuan.languages.config,
|
||||
|
|
@ -34,7 +34,7 @@ export const openViewMenu = (options: { protyle: IProtyle, blockElement: HTMLEle
|
|||
type: "config"
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
menu.addSeparator();
|
||||
menu.addItem({
|
||||
icon: "iconCopy",
|
||||
|
|
@ -52,13 +52,13 @@ export const openViewMenu = (options: { protyle: IProtyle, blockElement: HTMLEle
|
|||
id
|
||||
}]);
|
||||
}
|
||||
})
|
||||
});
|
||||
menu.addItem({
|
||||
icon: "iconTrashcan",
|
||||
label: window.siyuan.languages.delete,
|
||||
click() {
|
||||
if (options.element.parentElement.querySelectorAll("item").length === 1) {
|
||||
removeBlock(options.protyle, options.blockElement, getEditorRange(options.blockElement))
|
||||
removeBlock(options.protyle, options.blockElement, getEditorRange(options.blockElement));
|
||||
} else {
|
||||
transaction(options.protyle, [{
|
||||
action: "removeAttrViewView",
|
||||
|
|
@ -67,20 +67,20 @@ export const openViewMenu = (options: { protyle: IProtyle, blockElement: HTMLEle
|
|||
}]);
|
||||
}
|
||||
}
|
||||
})
|
||||
const rect = options.element.getBoundingClientRect()
|
||||
});
|
||||
const rect = options.element.getBoundingClientRect();
|
||||
menu.open({
|
||||
x: rect.left,
|
||||
y: rect.bottom
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const bindViewEvent = (options: {
|
||||
protyle: IProtyle,
|
||||
data: IAV,
|
||||
menuElement: HTMLElement
|
||||
}) => {
|
||||
const inputElement = options.menuElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement
|
||||
const inputElement = options.menuElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement;
|
||||
inputElement.addEventListener("blur", () => {
|
||||
if (inputElement.value !== inputElement.dataset.value) {
|
||||
transaction(options.protyle, [{
|
||||
|
|
@ -93,11 +93,11 @@ export const bindViewEvent = (options: {
|
|||
avID: options.data.id,
|
||||
id: options.data.viewID,
|
||||
data: inputElement.dataset.value
|
||||
}])
|
||||
inputElement.dataset.value = inputElement.value
|
||||
}]);
|
||||
inputElement.dataset.value = inputElement.value;
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const getViewHTML = (data: IAVTable) => {
|
||||
return `<div class="b3-menu__items">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue