🎨 av enable and disable

This commit is contained in:
Vanessa 2023-12-08 21:21:57 +08:00
parent d6128d9af5
commit 6b490db0eb

View file

@ -17,6 +17,7 @@ import {foldPassiveType} from "../wysiwyg/renderBacklink";
import {showMessage} from "../../dialog/message";
import {avRender} from "../render/av/render";
import {hideTooltip} from "../../dialog/tooltip";
import {stickyRow} from "../render/av/row";
export const onGet = (options: {
data: IWebSocketData,
@ -329,6 +330,13 @@ export const disabledProtyle = (protyle: IProtyle) => {
protyle.wysiwyg.element.querySelectorAll('.protyle-action[draggable="true"]').forEach(item => {
item.setAttribute("draggable", "false");
});
protyle.wysiwyg.element.querySelectorAll('.av').forEach((item: HTMLElement) => {
const headerElement = item.querySelector(".av__row--header") as HTMLElement;
if (headerElement) {
headerElement.style.transform = "";
(item.querySelector(".av__row--footer") as HTMLElement).style.transform = "";
}
});
if (protyle.breadcrumb) {
protyle.breadcrumb.element.parentElement.querySelector('[data-type="readonly"] use').setAttribute("xlink:href", "#iconLock");
protyle.breadcrumb.element.parentElement.querySelector('[data-type="readonly"]').setAttribute("aria-label", window.siyuan.config.editor.readOnly ? window.siyuan.languages.tempUnlock : window.siyuan.languages.unlockEdit);
@ -366,6 +374,10 @@ export const enableProtyle = (protyle: IProtyle) => {
protyle.wysiwyg.element.querySelectorAll('.protyle-action[draggable="false"]').forEach(item => {
item.setAttribute("draggable", "true");
});
const contentRect = protyle.contentElement.getBoundingClientRect();
protyle.wysiwyg.element.querySelectorAll('.av').forEach((item: HTMLElement) => {
stickyRow(item, contentRect, "all");
});
if (protyle.breadcrumb) {
protyle.breadcrumb.element.parentElement.querySelector('[data-type="readonly"] use').setAttribute("xlink:href", "#iconUnlock");
protyle.breadcrumb.element.parentElement.querySelector('[data-type="readonly"]').setAttribute("aria-label", window.siyuan.config.editor.readOnly ? window.siyuan.languages.cancelTempUnlock : window.siyuan.languages.lockEdit);