mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
This commit is contained in:
parent
4222102c32
commit
1b6d831a07
2 changed files with 41 additions and 13 deletions
|
|
@ -56,12 +56,12 @@ export const getLayoutHTML = (data: IAV) => {
|
|||
<button class="b3-menu__separator"></button>
|
||||
<button class="b3-menu__item" data-type="nobg">
|
||||
<div class="av__layout">
|
||||
<div data-type="set-layoyt" data-view-type="${data.viewType}" class="av__layout-item${data.viewType === "table" ? " av__layout-item--select" : ""}">
|
||||
<div data-type="set-layout" data-view-type="table" class="av__layout-item${data.viewType === "table" ? " av__layout-item--select" : ""}">
|
||||
<svg><use xlink:href="#iconTable"></use></svg>
|
||||
<div class="fn__hr"></div>
|
||||
<div>${window.siyuan.languages.table}</div>
|
||||
</div>
|
||||
<div data-type="set-layoyt" data-view-type="${data.viewType}" class="av__layout-item${data.viewType === "gallery" ? " av__layout-item--select" : ""}">
|
||||
<div data-type="set-layout" data-view-type="gallery" class="av__layout-item${data.viewType === "gallery" ? " av__layout-item--select" : ""}">
|
||||
<svg><use xlink:href="#iconGallery"></use></svg>
|
||||
<div class="fn__hr"></div>
|
||||
<div>${window.siyuan.languages.gallery}</div>
|
||||
|
|
@ -134,13 +134,13 @@ export const bindLayoutEvent = (options: {
|
|||
blockID,
|
||||
data: !checked
|
||||
}]);
|
||||
options.blockElement.querySelectorAll(".av__gallery-img").forEach(item => {
|
||||
if (checked) {
|
||||
item.classList.add("av__gallery-img--fit");
|
||||
} else {
|
||||
item.classList.remove("av__gallery-img--fit");
|
||||
}
|
||||
})
|
||||
options.blockElement.querySelectorAll(".av__gallery-img").forEach(item => {
|
||||
if (checked) {
|
||||
item.classList.add("av__gallery-img--fit");
|
||||
} else {
|
||||
item.classList.remove("av__gallery-img--fit");
|
||||
}
|
||||
});
|
||||
});
|
||||
const toggleIconElement = options.menuElement.querySelector('.b3-switch[data-type="toggle-gallery-icon"]') as HTMLInputElement;
|
||||
toggleIconElement.addEventListener("change", () => {
|
||||
|
|
@ -177,3 +177,31 @@ export const bindLayoutEvent = (options: {
|
|||
}]);
|
||||
});
|
||||
};
|
||||
|
||||
export const updateLayout = (options: {
|
||||
view: IAVGallery
|
||||
nodeElement: Element,
|
||||
protyle: IProtyle,
|
||||
target: HTMLElement
|
||||
}) => {
|
||||
if (options.target.classList.contains("av__layout-item--select")) {
|
||||
return;
|
||||
}
|
||||
const avID = options.nodeElement.getAttribute("data-av-id");
|
||||
const blockID = options.nodeElement.getAttribute("data-node-id");
|
||||
const layout = options.target.getAttribute("data-view-type");
|
||||
transaction(options.protyle, [{
|
||||
action: "changeAttrViewLayout",
|
||||
avID,
|
||||
blockID,
|
||||
layout
|
||||
}], [{
|
||||
action: "changeAttrViewLayout",
|
||||
avID,
|
||||
blockID,
|
||||
layout: options.view.type
|
||||
}]);
|
||||
options.nodeElement.setAttribute("data-view-type", layout);
|
||||
options.target.parentElement.querySelector(".av__layout-item--select").classList.remove("av__layout-item--select");
|
||||
options.target.classList.add("av__layout-item--select");
|
||||
};
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import {updateCellsValue} from "./cell";
|
|||
import {openCalcMenu} from "./calc";
|
||||
import {escapeAttr, escapeHtml} from "../../../util/escape";
|
||||
import {Dialog} from "../../../dialog";
|
||||
import {bindLayoutEvent, getLayoutHTML} from "./layout";
|
||||
import {bindLayoutEvent, getLayoutHTML, updateLayout} from "./layout";
|
||||
import {setGalleryCover, setGallerySize} from "./gallery/util";
|
||||
|
||||
export const openMenuPanel = (options: {
|
||||
|
|
@ -1382,11 +1382,11 @@ export const openMenuPanel = (options: {
|
|||
event.stopPropagation();
|
||||
break;
|
||||
} else if (type === "set-layout") {
|
||||
setPageSize({
|
||||
updateLayout({
|
||||
target,
|
||||
protyle: options.protyle,
|
||||
avID,
|
||||
nodeElement: options.blockElement
|
||||
nodeElement: options.blockElement,
|
||||
view: data.view as IAVGallery
|
||||
});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue