mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
🚨
This commit is contained in:
parent
6104ba3035
commit
f5d9958a93
8 changed files with 44 additions and 44 deletions
|
|
@ -444,44 +444,44 @@ export class Asset extends Model {
|
||||||
</div> <!-- outerContainer -->
|
</div> <!-- outerContainer -->
|
||||||
<div id="printContainer"></div>`;
|
<div id="printContainer"></div>`;
|
||||||
const localPDF = JSON.parse(localStorage.getItem(Constants.LOCAL_PDFTHEME) || "{}");
|
const localPDF = JSON.parse(localStorage.getItem(Constants.LOCAL_PDFTHEME) || "{}");
|
||||||
let pdfTheme
|
let pdfTheme;
|
||||||
if (window.siyuan.config.appearance.mode === 0) {
|
if (window.siyuan.config.appearance.mode === 0) {
|
||||||
pdfTheme = localPDF.light || "light"
|
pdfTheme = localPDF.light || "light";
|
||||||
} else {
|
} else {
|
||||||
pdfTheme = localPDF.dark || "dark"
|
pdfTheme = localPDF.dark || "dark";
|
||||||
}
|
}
|
||||||
const darkElement = this.element.querySelector("#pdfDark")
|
const darkElement = this.element.querySelector("#pdfDark");
|
||||||
const lightElement = this.element.querySelector("#pdfLight")
|
const lightElement = this.element.querySelector("#pdfLight");
|
||||||
if (pdfTheme === "dark") {
|
if (pdfTheme === "dark") {
|
||||||
this.element.firstElementChild.classList.add("pdf__outer--dark");
|
this.element.firstElementChild.classList.add("pdf__outer--dark");
|
||||||
lightElement.classList.remove("toggled")
|
lightElement.classList.remove("toggled");
|
||||||
darkElement.classList.add("toggled")
|
darkElement.classList.add("toggled");
|
||||||
} else {
|
} else {
|
||||||
lightElement.classList.add("toggled")
|
lightElement.classList.add("toggled");
|
||||||
darkElement.classList.remove("toggled")
|
darkElement.classList.remove("toggled");
|
||||||
}
|
}
|
||||||
lightElement.addEventListener("click", () => {
|
lightElement.addEventListener("click", () => {
|
||||||
if (window.siyuan.config.appearance.mode === 0) {
|
if (window.siyuan.config.appearance.mode === 0) {
|
||||||
localPDF.light = "light"
|
localPDF.light = "light";
|
||||||
} else {
|
} else {
|
||||||
localPDF.dark = "light"
|
localPDF.dark = "light";
|
||||||
}
|
}
|
||||||
this.element.firstElementChild.classList.remove("pdf__outer--dark");
|
this.element.firstElementChild.classList.remove("pdf__outer--dark");
|
||||||
localStorage.setItem(Constants.LOCAL_PDFTHEME, JSON.stringify(localPDF));
|
localStorage.setItem(Constants.LOCAL_PDFTHEME, JSON.stringify(localPDF));
|
||||||
lightElement.classList.add("toggled")
|
lightElement.classList.add("toggled");
|
||||||
darkElement.classList.remove("toggled")
|
darkElement.classList.remove("toggled");
|
||||||
})
|
});
|
||||||
darkElement.addEventListener("click", () => {
|
darkElement.addEventListener("click", () => {
|
||||||
if (window.siyuan.config.appearance.mode === 0) {
|
if (window.siyuan.config.appearance.mode === 0) {
|
||||||
localPDF.light = "dark"
|
localPDF.light = "dark";
|
||||||
} else {
|
} else {
|
||||||
localPDF.dark = "dark"
|
localPDF.dark = "dark";
|
||||||
}
|
}
|
||||||
this.element.firstElementChild.classList.add("pdf__outer--dark");
|
this.element.firstElementChild.classList.add("pdf__outer--dark");
|
||||||
localStorage.setItem(Constants.LOCAL_PDFTHEME, JSON.stringify(localPDF));
|
localStorage.setItem(Constants.LOCAL_PDFTHEME, JSON.stringify(localPDF));
|
||||||
lightElement.classList.remove("toggled")
|
lightElement.classList.remove("toggled");
|
||||||
darkElement.classList.add("toggled")
|
darkElement.classList.add("toggled");
|
||||||
})
|
});
|
||||||
// 初始化完成后需等待页签是否显示设置完成,才可以判断 pdf 是否能进行渲染
|
// 初始化完成后需等待页签是否显示设置完成,才可以判断 pdf 是否能进行渲染
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.element.clientWidth === 0) {
|
if (this.element.clientWidth === 0) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName} from "../
|
||||||
import {fetchSyncPost} from "../util/fetch";
|
import {fetchSyncPost} from "../util/fetch";
|
||||||
import {hideTooltip, showTooltip} from "../dialog/tooltip";
|
import {hideTooltip, showTooltip} from "../dialog/tooltip";
|
||||||
|
|
||||||
let popoverTargetElement: HTMLElement
|
let popoverTargetElement: HTMLElement;
|
||||||
export const initBlockPopover = () => {
|
export const initBlockPopover = () => {
|
||||||
let timeout: number;
|
let timeout: number;
|
||||||
let timeoutHide: number;
|
let timeoutHide: number;
|
||||||
|
|
@ -41,7 +41,7 @@ export const initBlockPopover = () => {
|
||||||
if (window.siyuan.config.editor.floatWindowMode === 1) {
|
if (window.siyuan.config.editor.floatWindowMode === 1) {
|
||||||
clearTimeout(timeoutHide);
|
clearTimeout(timeoutHide);
|
||||||
timeoutHide = window.setTimeout(() => {
|
timeoutHide = window.setTimeout(() => {
|
||||||
hidePopover(event)
|
hidePopover(event);
|
||||||
}, 200);
|
}, 200);
|
||||||
|
|
||||||
if (!getTarget(event, aElement)) {
|
if (!getTarget(event, aElement)) {
|
||||||
|
|
@ -49,7 +49,7 @@ export const initBlockPopover = () => {
|
||||||
}
|
}
|
||||||
if (window.siyuan.ctrlIsPressed) {
|
if (window.siyuan.ctrlIsPressed) {
|
||||||
clearTimeout(timeoutHide);
|
clearTimeout(timeoutHide);
|
||||||
showPopover()
|
showPopover();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -69,7 +69,7 @@ export const initBlockPopover = () => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clearTimeout(timeoutHide);
|
clearTimeout(timeoutHide);
|
||||||
showPopover()
|
showPopover();
|
||||||
}, 620);
|
}, 620);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -134,7 +134,7 @@ const hidePopover = (event: MouseEvent & { target: HTMLElement }) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const getTarget = (event: MouseEvent & { target: HTMLElement }, aElement: false | HTMLElement) => {
|
const getTarget = (event: MouseEvent & { target: HTMLElement }, aElement: false | HTMLElement) => {
|
||||||
if (hasClosestByClassName(event.target, "history__repo", true)) {
|
if (hasClosestByClassName(event.target, "history__repo", true)) {
|
||||||
|
|
@ -164,8 +164,8 @@ const getTarget = (event: MouseEvent & { target: HTMLElement }, aElement: false
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const showPopover = async () => {
|
export const showPopover = async () => {
|
||||||
if (!popoverTargetElement) {
|
if (!popoverTargetElement) {
|
||||||
|
|
@ -231,4 +231,4 @@ export const showPopover = async () => {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
popoverTargetElement = undefined;
|
popoverTargetElement = undefined;
|
||||||
}
|
};
|
||||||
|
|
|
||||||
|
|
@ -86,13 +86,13 @@ export const hideMessage = (id?: string) => {
|
||||||
}
|
}
|
||||||
}, Constants.TIMEOUT_INPUT);
|
}, Constants.TIMEOUT_INPUT);
|
||||||
}
|
}
|
||||||
let hasShowItem = false
|
let hasShowItem = false;
|
||||||
Array.from(messagesElement.children).find(item => {
|
Array.from(messagesElement.children).find(item => {
|
||||||
if (!item.classList.contains("b3-snackbar--hide")) {
|
if (!item.classList.contains("b3-snackbar--hide")) {
|
||||||
hasShowItem = true
|
hasShowItem = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
if (hasShowItem) {
|
if (hasShowItem) {
|
||||||
messagesElement.parentElement.classList.add("b3-snackbars--show");
|
messagesElement.parentElement.classList.add("b3-snackbars--show");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ export const initUI = (protyle: IProtyle) => {
|
||||||
protyle.background.element.classList.toggle("protyle-background--mobileshow");
|
protyle.background.element.classList.toggle("protyle-background--mobileshow");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const embedBlockElement = hasClosestByAttribute(target, "data-type", "NodeBlockQueryEmbed")
|
const embedBlockElement = hasClosestByAttribute(target, "data-type", "NodeBlockQueryEmbed");
|
||||||
if (embedBlockElement) {
|
if (embedBlockElement) {
|
||||||
embedBlockElement.firstElementChild.classList.toggle("protyle-icons--show");
|
embedBlockElement.firstElementChild.classList.toggle("protyle-icons--show");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -309,7 +309,7 @@ export const disabledProtyle = (protyle: IProtyle) => {
|
||||||
}
|
}
|
||||||
protyle.wysiwyg.element.querySelectorAll(".protyle-icons--show").forEach(item => {
|
protyle.wysiwyg.element.querySelectorAll(".protyle-icons--show").forEach(item => {
|
||||||
item.classList.remove("protyle-icons--show");
|
item.classList.remove("protyle-icons--show");
|
||||||
})
|
});
|
||||||
protyle.wysiwyg.element.style.userSelect = "text";
|
protyle.wysiwyg.element.style.userSelect = "text";
|
||||||
protyle.wysiwyg.element.setAttribute("contenteditable", "false");
|
protyle.wysiwyg.element.setAttribute("contenteditable", "false");
|
||||||
protyle.wysiwyg.element.querySelectorAll('[contenteditable="true"][spellcheck="false"]').forEach(item => {
|
protyle.wysiwyg.element.querySelectorAll('[contenteditable="true"][spellcheck="false"]').forEach(item => {
|
||||||
|
|
|
||||||
|
|
@ -1408,7 +1408,7 @@ export class WYSIWYG {
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
const backlinkBreadcrumbItemElement = hasClosestByClassName(event.target, "protyle-breadcrumb__item");
|
const backlinkBreadcrumbItemElement = hasClosestByClassName(event.target, "protyle-breadcrumb__item");
|
||||||
if (backlinkBreadcrumbItemElement) {
|
if (backlinkBreadcrumbItemElement) {
|
||||||
const breadcrumbId = backlinkBreadcrumbItemElement.getAttribute("data-id")
|
const breadcrumbId = backlinkBreadcrumbItemElement.getAttribute("data-id");
|
||||||
if (breadcrumbId) {
|
if (breadcrumbId) {
|
||||||
if (window.siyuan.ctrlIsPressed) {
|
if (window.siyuan.ctrlIsPressed) {
|
||||||
openFileById({id: breadcrumbId, action: [Constants.CB_GET_FOCUS]});
|
openFileById({id: breadcrumbId, action: [Constants.CB_GET_FOCUS]});
|
||||||
|
|
|
||||||
|
|
@ -54,25 +54,25 @@ export const loadAssets = (data: IAppearance) => {
|
||||||
item.searchGraph(false);
|
item.searchGraph(false);
|
||||||
});
|
});
|
||||||
const localPDF = JSON.parse(localStorage.getItem(Constants.LOCAL_PDFTHEME) || "{}");
|
const localPDF = JSON.parse(localStorage.getItem(Constants.LOCAL_PDFTHEME) || "{}");
|
||||||
let pdfTheme: string
|
let pdfTheme: string;
|
||||||
if (window.siyuan.config.appearance.mode === 0) {
|
if (window.siyuan.config.appearance.mode === 0) {
|
||||||
pdfTheme = localPDF.light || "light"
|
pdfTheme = localPDF.light || "light";
|
||||||
} else {
|
} else {
|
||||||
pdfTheme = localPDF.dark || "dark"
|
pdfTheme = localPDF.dark || "dark";
|
||||||
}
|
}
|
||||||
document.querySelectorAll(".pdf__outer").forEach(item => {
|
document.querySelectorAll(".pdf__outer").forEach(item => {
|
||||||
const darkElement = item.querySelector("#pdfDark")
|
const darkElement = item.querySelector("#pdfDark");
|
||||||
const lightElement = item.querySelector("#pdfLight")
|
const lightElement = item.querySelector("#pdfLight");
|
||||||
if (pdfTheme === "dark") {
|
if (pdfTheme === "dark") {
|
||||||
item.classList.add("pdf__outer--dark");
|
item.classList.add("pdf__outer--dark");
|
||||||
lightElement.classList.remove("toggled")
|
lightElement.classList.remove("toggled");
|
||||||
darkElement.classList.add("toggled")
|
darkElement.classList.add("toggled");
|
||||||
} else {
|
} else {
|
||||||
item.classList.remove("pdf__outer--dark");
|
item.classList.remove("pdf__outer--dark");
|
||||||
lightElement.classList.add("toggled")
|
lightElement.classList.add("toggled");
|
||||||
darkElement.classList.remove("toggled")
|
darkElement.classList.remove("toggled");
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
setCodeTheme();
|
setCodeTheme();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -340,7 +340,7 @@ export const globalShortcut = () => {
|
||||||
if (event.key === "Meta" || event.key === "Control" || event.ctrlKey || event.metaKey) {
|
if (event.key === "Meta" || event.key === "Control" || event.ctrlKey || event.metaKey) {
|
||||||
window.siyuan.ctrlIsPressed = true;
|
window.siyuan.ctrlIsPressed = true;
|
||||||
if (window.siyuan.config.editor.floatWindowMode === 1 && !event.repeat) {
|
if (window.siyuan.config.editor.floatWindowMode === 1 && !event.repeat) {
|
||||||
showPopover()
|
showPopover();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
window.siyuan.ctrlIsPressed = false;
|
window.siyuan.ctrlIsPressed = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue