mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
🚨
This commit is contained in:
parent
49e0dec799
commit
d1fad76bf8
6 changed files with 29 additions and 29 deletions
|
|
@ -111,7 +111,7 @@ export const insertEmptyBlock = (protyle: IProtyle, position: InsertPosition, id
|
||||||
updateListOrder(newElement.parentElement, orderIndex);
|
updateListOrder(newElement.parentElement, orderIndex);
|
||||||
updateTransaction(protyle, newElement.parentElement.getAttribute("data-node-id"), newElement.parentElement.outerHTML, parentOldHTML);
|
updateTransaction(protyle, newElement.parentElement.getAttribute("data-node-id"), newElement.parentElement.outerHTML, parentOldHTML);
|
||||||
} else {
|
} else {
|
||||||
let doOperations: IOperation[]
|
let doOperations: IOperation[];
|
||||||
if (position === "beforebegin") {
|
if (position === "beforebegin") {
|
||||||
doOperations = [{
|
doOperations = [{
|
||||||
action: "insert",
|
action: "insert",
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ export const appearance = {
|
||||||
_bindSnippet: (element: HTMLElement) => {
|
_bindSnippet: (element: HTMLElement) => {
|
||||||
const itemContentElement = hasClosestByClassName(element, "b3-label");
|
const itemContentElement = hasClosestByClassName(element, "b3-label");
|
||||||
if (!itemContentElement) {
|
if (!itemContentElement) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
fetchPost("/api/snippet/setSnippet", {
|
fetchPost("/api/snippet/setSnippet", {
|
||||||
id: itemContentElement.getAttribute("data-id"),
|
id: itemContentElement.getAttribute("data-id"),
|
||||||
|
|
@ -276,9 +276,9 @@ export const appearance = {
|
||||||
content: itemContentElement.querySelector("textarea").value,
|
content: itemContentElement.querySelector("textarea").value,
|
||||||
enabled: (itemContentElement.querySelector(".b3-switch") as HTMLInputElement).checked
|
enabled: (itemContentElement.querySelector(".b3-switch") as HTMLInputElement).checked
|
||||||
}, (response) => {
|
}, (response) => {
|
||||||
itemContentElement.setAttribute("data-id", response.data.id)
|
itemContentElement.setAttribute("data-id", response.data.id);
|
||||||
renderSnippet();
|
renderSnippet();
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
_genSnippet: (options: ISnippet) => {
|
_genSnippet: (options: ISnippet) => {
|
||||||
return `<div class="b3-label" style="margin: 0" data-id="${options.id || ""}">
|
return `<div class="b3-label" style="margin: 0" data-id="${options.id || ""}">
|
||||||
|
|
@ -295,7 +295,7 @@ export const appearance = {
|
||||||
</div>
|
</div>
|
||||||
<div class="fn__hr"></div>
|
<div class="fn__hr"></div>
|
||||||
<textarea class="fn__block b3-text-field" placeholder="${window.siyuan.languages.codeSnippet}"></textarea>
|
<textarea class="fn__block b3-text-field" placeholder="${window.siyuan.languages.codeSnippet}"></textarea>
|
||||||
</div>`
|
</div>`;
|
||||||
},
|
},
|
||||||
bindEvent: () => {
|
bindEvent: () => {
|
||||||
if (window.siyuan.config.appearance.customCSS) {
|
if (window.siyuan.config.appearance.customCSS) {
|
||||||
|
|
@ -329,19 +329,19 @@ export const appearance = {
|
||||||
});
|
});
|
||||||
codeSnippetPanelElement.innerHTML = html;
|
codeSnippetPanelElement.innerHTML = html;
|
||||||
response.data.snippets.forEach((item: ISnippet) => {
|
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;
|
nameElement.value = item.name;
|
||||||
const contentElement = codeSnippetPanelElement.querySelector(`[data-id="${item.id}"] textarea`) as HTMLTextAreaElement;
|
const contentElement = codeSnippetPanelElement.querySelector(`[data-id="${item.id}"] textarea`) as HTMLTextAreaElement;
|
||||||
contentElement.textContent = item.content;
|
contentElement.textContent = item.content;
|
||||||
nameElement.addEventListener("blur", (event) => {
|
nameElement.addEventListener("blur", () => {
|
||||||
appearance._bindSnippet(nameElement);
|
appearance._bindSnippet(nameElement);
|
||||||
})
|
});
|
||||||
contentElement.addEventListener("blur", (event) => {
|
contentElement.addEventListener("blur", () => {
|
||||||
appearance._bindSnippet(contentElement);
|
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);
|
appearance._bindSnippet(contentElement);
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -353,19 +353,19 @@ export const appearance = {
|
||||||
name: "",
|
name: "",
|
||||||
content: "",
|
content: "",
|
||||||
enabled: false
|
enabled: false
|
||||||
}))
|
}));
|
||||||
codeSnippetPanelElement.querySelector(".b3-text-field").addEventListener("blur", (event) => {
|
codeSnippetPanelElement.querySelector(".b3-text-field").addEventListener("blur", (event) => {
|
||||||
appearance._bindSnippet(event.target as HTMLElement);
|
appearance._bindSnippet(event.target as HTMLElement);
|
||||||
})
|
});
|
||||||
codeSnippetPanelElement.querySelector("textarea.b3-text-field").addEventListener("blur", (event) => {
|
codeSnippetPanelElement.querySelector("textarea.b3-text-field").addEventListener("blur", (event) => {
|
||||||
appearance._bindSnippet(event.target as HTMLElement);
|
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);
|
appearance._bindSnippet(event.target as HTMLElement);
|
||||||
})
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const removeElement = hasClosestByClassName(target, "b3-tooltips")
|
const removeElement = hasClosestByClassName(target, "b3-tooltips");
|
||||||
if (removeElement) {
|
if (removeElement) {
|
||||||
const id = removeElement.parentElement.parentElement.getAttribute("data-id");
|
const id = removeElement.parentElement.parentElement.getAttribute("data-id");
|
||||||
removeElement.parentElement.parentElement.remove();
|
removeElement.parentElement.parentElement.remove();
|
||||||
|
|
@ -379,9 +379,9 @@ export const appearance = {
|
||||||
if (exitElement) {
|
if (exitElement) {
|
||||||
exitElement.remove();
|
exitElement.remove();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
const appearanceCustomElement = appearance.element.querySelector("#appearanceCustom");
|
const appearanceCustomElement = appearance.element.querySelector("#appearanceCustom");
|
||||||
appearanceCustomElement.addEventListener("click", () => {
|
appearanceCustomElement.addEventListener("click", () => {
|
||||||
if (window.siyuan.config.appearance.customCSS) {
|
if (window.siyuan.config.appearance.customCSS) {
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ export class Layout {
|
||||||
if (this.direction === "lr") {
|
if (this.direction === "lr") {
|
||||||
// 向右分屏,左侧文档抖动,移除动画和边距
|
// 向右分屏,左侧文档抖动,移除动画和边距
|
||||||
item.element.querySelectorAll(".protyle-wysiwyg").forEach((element: HTMLElement) => {
|
item.element.querySelectorAll(".protyle-wysiwyg").forEach((element: HTMLElement) => {
|
||||||
element.style.transition = "none"
|
element.style.transition = "none";
|
||||||
element.style.paddingRight = "16px";
|
element.style.paddingRight = "16px";
|
||||||
element.style.paddingLeft = "24px";
|
element.style.paddingLeft = "24px";
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,7 @@ export const resizeTabs = () => {
|
||||||
}
|
}
|
||||||
item.editors.forEach(editorItem => {
|
item.editors.forEach(editorItem => {
|
||||||
hideElements(["gutter"], editorItem.protyle);
|
hideElements(["gutter"], editorItem.protyle);
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
pdfResize();
|
pdfResize();
|
||||||
}, 200);
|
}, 200);
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,10 @@ import {updateHotkeyTip} from "../util/compatibility";
|
||||||
import {isMobile} from "../../util/functions";
|
import {isMobile} from "../../util/functions";
|
||||||
import {hasClosestBlock, hasClosestByClassName} from "../util/hasClosest";
|
import {hasClosestBlock, hasClosestByClassName} from "../util/hasClosest";
|
||||||
|
|
||||||
let getIndexTimeout: number
|
let getIndexTimeout: number;
|
||||||
export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
|
export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
|
||||||
let elementRect = element.getBoundingClientRect();
|
let elementRect = element.getBoundingClientRect();
|
||||||
element.addEventListener("scroll", (event) => {
|
element.addEventListener("scroll", () => {
|
||||||
if (!protyle.toolbar.element.classList.contains("fn__none")) {
|
if (!protyle.toolbar.element.classList.contains("fn__none")) {
|
||||||
const initY = protyle.toolbar.element.getAttribute("data-inity").split(Constants.ZWSP);
|
const initY = protyle.toolbar.element.getAttribute("data-inity").split(Constants.ZWSP);
|
||||||
const top = parseInt(initY[0]) + (parseInt(initY[1]) - element.scrollTop);
|
const top = parseInt(initY[0]) + (parseInt(initY[1]) - element.scrollTop);
|
||||||
|
|
@ -46,7 +46,7 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
|
||||||
clearTimeout(getIndexTimeout);
|
clearTimeout(getIndexTimeout);
|
||||||
getIndexTimeout = window.setTimeout(() => {
|
getIndexTimeout = window.setTimeout(() => {
|
||||||
elementRect = element.getBoundingClientRect();
|
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);
|
const blockElement = hasClosestBlock(targetElement);
|
||||||
if (!blockElement) {
|
if (!blockElement) {
|
||||||
if (hasClosestByClassName(targetElement, "protyle-background") ||
|
if (hasClosestByClassName(targetElement, "protyle-background") ||
|
||||||
|
|
@ -61,7 +61,7 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
|
||||||
if (!response.data) {
|
if (!response.data) {
|
||||||
return;
|
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;
|
inputElement.value = response.data;
|
||||||
protyle.scroll.element.setAttribute("aria-label", `Blocks ${response.data}/${protyle.block.blockCount}`);
|
protyle.scroll.element.setAttribute("aria-label", `Blocks ${response.data}/${protyle.block.blockCount}`);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -160,17 +160,17 @@ export const onGetConfig = (isStart: boolean) => {
|
||||||
mountHelp();
|
mountHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
let para = {
|
const para = {
|
||||||
"version": Constants.SIYUAN_VERSION,
|
"version": Constants.SIYUAN_VERSION,
|
||||||
"isLoggedIn": "false",
|
"isLoggedIn": "false",
|
||||||
"subscriptionStatus": "-1",
|
"subscriptionStatus": "-1",
|
||||||
"subscriptionPlan": "-1",
|
"subscriptionPlan": "-1",
|
||||||
"subscriptionType": "-1",
|
"subscriptionType": "-1",
|
||||||
}
|
};
|
||||||
if (window.siyuan.user) {
|
if (window.siyuan.user) {
|
||||||
para.isLoggedIn = "true";
|
para.isLoggedIn = "true";
|
||||||
if (0 === window.siyuan.user.userSiYuanSubscriptionStatus) {
|
if (0 === window.siyuan.user.userSiYuanSubscriptionStatus) {
|
||||||
console.log(window.siyuan.user)
|
console.log(window.siyuan.user);
|
||||||
para.subscriptionStatus = window.siyuan.user.userSiYuanSubscriptionStatus.toString();
|
para.subscriptionStatus = window.siyuan.user.userSiYuanSubscriptionStatus.toString();
|
||||||
para.subscriptionPlan = window.siyuan.user.userSiYuanSubscriptionPlan.toString();
|
para.subscriptionPlan = window.siyuan.user.userSiYuanSubscriptionPlan.toString();
|
||||||
para.subscriptionType = window.siyuan.user.userSiYuanSubscriptionType.toString();
|
para.subscriptionType = window.siyuan.user.userSiYuanSubscriptionType.toString();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue