This commit is contained in:
Vanessa 2022-10-27 11:34:34 +08:00
parent 49e0dec799
commit d1fad76bf8
6 changed files with 29 additions and 29 deletions

View file

@ -111,7 +111,7 @@ export const insertEmptyBlock = (protyle: IProtyle, position: InsertPosition, id
updateListOrder(newElement.parentElement, orderIndex);
updateTransaction(protyle, newElement.parentElement.getAttribute("data-node-id"), newElement.parentElement.outerHTML, parentOldHTML);
} else {
let doOperations: IOperation[]
let doOperations: IOperation[];
if (position === "beforebegin") {
doOperations = [{
action: "insert",

View file

@ -267,7 +267,7 @@ export const appearance = {
_bindSnippet: (element: HTMLElement) => {
const itemContentElement = hasClosestByClassName(element, "b3-label");
if (!itemContentElement) {
return
return;
}
fetchPost("/api/snippet/setSnippet", {
id: itemContentElement.getAttribute("data-id"),
@ -276,9 +276,9 @@ export const appearance = {
content: itemContentElement.querySelector("textarea").value,
enabled: (itemContentElement.querySelector(".b3-switch") as HTMLInputElement).checked
}, (response) => {
itemContentElement.setAttribute("data-id", response.data.id)
itemContentElement.setAttribute("data-id", response.data.id);
renderSnippet();
})
});
},
_genSnippet: (options: ISnippet) => {
return `<div class="b3-label" style="margin: 0" data-id="${options.id || ""}">
@ -295,7 +295,7 @@ export const appearance = {
</div>
<div class="fn__hr"></div>
<textarea class="fn__block b3-text-field" placeholder="${window.siyuan.languages.codeSnippet}"></textarea>
</div>`
</div>`;
},
bindEvent: () => {
if (window.siyuan.config.appearance.customCSS) {
@ -329,19 +329,19 @@ export const appearance = {
});
codeSnippetPanelElement.innerHTML = html;
response.data.snippets.forEach((item: ISnippet) => {
const nameElement = (codeSnippetPanelElement.querySelector(`[data-id="${item.id}"] input`) as HTMLInputElement)
const nameElement = (codeSnippetPanelElement.querySelector(`[data-id="${item.id}"] input`) as HTMLInputElement);
nameElement.value = item.name;
const contentElement = codeSnippetPanelElement.querySelector(`[data-id="${item.id}"] textarea`) as HTMLTextAreaElement;
contentElement.textContent = item.content;
nameElement.addEventListener("blur", (event) => {
nameElement.addEventListener("blur", () => {
appearance._bindSnippet(nameElement);
})
contentElement.addEventListener("blur", (event) => {
});
contentElement.addEventListener("blur", () => {
appearance._bindSnippet(contentElement);
})
codeSnippetPanelElement.querySelector(`[data-id="${item.id}"] .b3-switch`).addEventListener("change", (event) => {
});
codeSnippetPanelElement.querySelector(`[data-id="${item.id}"] .b3-switch`).addEventListener("change", () => {
appearance._bindSnippet(contentElement);
})
});
});
});
});
@ -353,19 +353,19 @@ export const appearance = {
name: "",
content: "",
enabled: false
}))
}));
codeSnippetPanelElement.querySelector(".b3-text-field").addEventListener("blur", (event) => {
appearance._bindSnippet(event.target as HTMLElement);
})
});
codeSnippetPanelElement.querySelector("textarea.b3-text-field").addEventListener("blur", (event) => {
appearance._bindSnippet(event.target as HTMLElement);
})
codeSnippetPanelElement.querySelector('.b3-switch').addEventListener("change", (event) => {
});
codeSnippetPanelElement.querySelector(".b3-switch").addEventListener("change", (event) => {
appearance._bindSnippet(event.target as HTMLElement);
})
});
return;
}
const removeElement = hasClosestByClassName(target, "b3-tooltips")
const removeElement = hasClosestByClassName(target, "b3-tooltips");
if (removeElement) {
const id = removeElement.parentElement.parentElement.getAttribute("data-id");
removeElement.parentElement.parentElement.remove();
@ -379,9 +379,9 @@ export const appearance = {
if (exitElement) {
exitElement.remove();
}
})
});
}
})
});
const appearanceCustomElement = appearance.element.querySelector("#appearanceCustom");
appearanceCustomElement.addEventListener("click", () => {
if (window.siyuan.config.appearance.customCSS) {

View file

@ -82,7 +82,7 @@ export class Layout {
if (this.direction === "lr") {
// 向右分屏,左侧文档抖动,移除动画和边距
item.element.querySelectorAll(".protyle-wysiwyg").forEach((element: HTMLElement) => {
element.style.transition = "none"
element.style.transition = "none";
element.style.paddingRight = "16px";
element.style.paddingLeft = "24px";
});

View file

@ -455,7 +455,7 @@ export const resizeTabs = () => {
}
item.editors.forEach(editorItem => {
hideElements(["gutter"], editorItem.protyle);
})
});
});
pdfResize();
}, 200);

View file

@ -7,10 +7,10 @@ import {updateHotkeyTip} from "../util/compatibility";
import {isMobile} from "../../util/functions";
import {hasClosestBlock, hasClosestByClassName} from "../util/hasClosest";
let getIndexTimeout: number
let getIndexTimeout: number;
export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
let elementRect = element.getBoundingClientRect();
element.addEventListener("scroll", (event) => {
element.addEventListener("scroll", () => {
if (!protyle.toolbar.element.classList.contains("fn__none")) {
const initY = protyle.toolbar.element.getAttribute("data-inity").split(Constants.ZWSP);
const top = parseInt(initY[0]) + (parseInt(initY[1]) - element.scrollTop);
@ -46,7 +46,7 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
clearTimeout(getIndexTimeout);
getIndexTimeout = window.setTimeout(() => {
elementRect = element.getBoundingClientRect();
const targetElement = document.elementFromPoint(elementRect.left + elementRect.width / 2, elementRect.top + 10)
const targetElement = document.elementFromPoint(elementRect.left + elementRect.width / 2, elementRect.top + 10);
const blockElement = hasClosestBlock(targetElement);
if (!blockElement) {
if (hasClosestByClassName(targetElement, "protyle-background") ||
@ -61,7 +61,7 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
if (!response.data) {
return;
}
const inputElement = protyle.scroll.element.querySelector(".b3-slider") as HTMLInputElement
const inputElement = protyle.scroll.element.querySelector(".b3-slider") as HTMLInputElement;
inputElement.value = response.data;
protyle.scroll.element.setAttribute("aria-label", `Blocks ${response.data}/${protyle.block.blockCount}`);
});

View file

@ -160,17 +160,17 @@ export const onGetConfig = (isStart: boolean) => {
mountHelp();
}
let para = {
const para = {
"version": Constants.SIYUAN_VERSION,
"isLoggedIn": "false",
"subscriptionStatus": "-1",
"subscriptionPlan": "-1",
"subscriptionType": "-1",
}
};
if (window.siyuan.user) {
para.isLoggedIn = "true";
if (0 === window.siyuan.user.userSiYuanSubscriptionStatus) {
console.log(window.siyuan.user)
console.log(window.siyuan.user);
para.subscriptionStatus = window.siyuan.user.userSiYuanSubscriptionStatus.toString();
para.subscriptionPlan = window.siyuan.user.userSiYuanSubscriptionPlan.toString();
para.subscriptionType = window.siyuan.user.userSiYuanSubscriptionType.toString();