mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-10 22:52:34 +01:00
This commit is contained in:
parent
78cba22910
commit
e0e803d743
21 changed files with 135 additions and 71 deletions
|
|
@ -69,7 +69,7 @@ export const exportImage = (id: string) => {
|
|||
});
|
||||
});
|
||||
});
|
||||
}, Constants.TIMEOUT_TRANSITION);
|
||||
}, Constants.TIMEOUT_LOAD);
|
||||
});
|
||||
const previewElement = exportDialog.element.querySelector("#preview") as HTMLElement;
|
||||
const foldElement = (exportDialog.element.querySelector("#keepFold") as HTMLInputElement);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,13 @@ export class Title {
|
|||
this.editElement.addEventListener("click", () => {
|
||||
if (protyle.model) {
|
||||
setPanelFocus(protyle.model.element.parentElement.parentElement);
|
||||
updatePanelByEditor(protyle, false);
|
||||
updatePanelByEditor({
|
||||
protyle: protyle,
|
||||
focus: false,
|
||||
pushBackStack: false,
|
||||
reload: false,
|
||||
resize: false,
|
||||
});
|
||||
}
|
||||
protyle.toolbar?.element.classList.add("fn__none");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -116,7 +116,13 @@ export class Protyle {
|
|||
/// #if !MOBILE
|
||||
if (data.cmd === "heading2doc") {
|
||||
// 文档标题互转后,需更新大纲
|
||||
updatePanelByEditor(this.protyle, false, false, true);
|
||||
updatePanelByEditor({
|
||||
protyle: this.protyle,
|
||||
focus: false,
|
||||
pushBackStack: false,
|
||||
reload: true,
|
||||
resize: false
|
||||
});
|
||||
}
|
||||
/// #endif
|
||||
}
|
||||
|
|
@ -200,7 +206,13 @@ export class Protyle {
|
|||
if (mergedOptions.action?.includes(Constants.CB_GET_FOCUS)) {
|
||||
setPanelFocus(this.protyle.model.element.parentElement.parentElement);
|
||||
}
|
||||
updatePanelByEditor(this.protyle, false);
|
||||
updatePanelByEditor({
|
||||
protyle: this.protyle,
|
||||
focus: false,
|
||||
pushBackStack: false,
|
||||
reload: false,
|
||||
resize: false
|
||||
});
|
||||
/// #endif
|
||||
}
|
||||
|
||||
|
|
@ -217,7 +229,13 @@ export class Protyle {
|
|||
return;
|
||||
}
|
||||
setPanelFocus(this.protyle.model.element.parentElement.parentElement);
|
||||
updatePanelByEditor(this.protyle, false);
|
||||
updatePanelByEditor({
|
||||
protyle: this.protyle,
|
||||
focus: false,
|
||||
pushBackStack: false,
|
||||
reload: false,
|
||||
resize: false,
|
||||
});
|
||||
} else {
|
||||
// 悬浮层应移除其余面板高亮,否则按键会被面板监听到
|
||||
document.querySelectorAll(".layout__tab--active").forEach(item => {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ const initMermaid = (mermaidElements: Element[]) => {
|
|||
renderElement.textContent = Lute.UnEscapeHTMLStr(item.getAttribute("data-content"));
|
||||
setTimeout(() => {
|
||||
mermaid.init(undefined, renderElement);
|
||||
}, Constants.TIMEOUT_BLOCKLOAD * index);
|
||||
}, Constants.TIMEOUT_LOAD * index);
|
||||
item.setAttribute("data-render", "true");
|
||||
renderElement.setAttribute("contenteditable", "false");
|
||||
if (!item.textContent.endsWith(Constants.ZWSP)) {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
|
|||
inputElement.value = response.data;
|
||||
protyle.scroll.element.setAttribute("aria-label", `Blocks ${response.data}/${protyle.block.blockCount}`);
|
||||
});
|
||||
}, Constants.TIMEOUT_BLOCKLOAD);
|
||||
}, Constants.TIMEOUT_LOAD);
|
||||
}
|
||||
if (protyle.wysiwyg.element.getAttribute("data-top") || protyle.block.showAll ||
|
||||
(protyle.scroll && protyle.scroll.element.classList.contains("fn__none")) || !protyle.scroll ||
|
||||
|
|
|
|||
|
|
@ -988,7 +988,7 @@ export class Toolbar {
|
|||
}
|
||||
setTimeout(() => {
|
||||
addScript("stage/protyle/js/html2canvas.min.js?v=1.4.1", "protyleHtml2canvas").then(() => {
|
||||
window.html2canvas(renderElement).then((canvas) => {
|
||||
window.html2canvas(renderElement, {useCORS: true}).then((canvas) => {
|
||||
canvas.toBlob((blob: Blob) => {
|
||||
const formData = new FormData();
|
||||
formData.append("file", blob);
|
||||
|
|
@ -1000,7 +1000,7 @@ export class Toolbar {
|
|||
});
|
||||
});
|
||||
});
|
||||
}, Constants.TIMEOUT_TRANSITION);
|
||||
}, Constants.TIMEOUT_LOAD);
|
||||
};
|
||||
headerElement.addEventListener("mousedown", (event: MouseEvent) => {
|
||||
if (hasClosestByClassName(event.target as HTMLElement, "block__icon")) {
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ export const addLoading = (protyle: IProtyle) => {
|
|||
if (protyle.element.getAttribute("data-loading") !== "finished") {
|
||||
protyle.element.insertAdjacentHTML("beforeend", '<div style="background-color: var(--b3-theme-background)" class="fn__loading wysiwygLoading"><img width="48px" src="/stage/loading-pure.svg"></div>');
|
||||
}
|
||||
}, Constants.TIMEOUT_BLOCKLOAD);
|
||||
}, Constants.TIMEOUT_LOAD);
|
||||
};
|
||||
|
||||
export const removeLoading = (protyle: IProtyle) => {
|
||||
|
|
|
|||
|
|
@ -855,13 +855,19 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
onGet(getResponse, protyle);
|
||||
/// #if !MOBILE
|
||||
// 文档标题互转后,需更新大纲
|
||||
updatePanelByEditor(protyle, false, false, true);
|
||||
updatePanelByEditor({
|
||||
protyle,
|
||||
focus: false,
|
||||
pushBackStack: false,
|
||||
reload: true,
|
||||
resize: false,
|
||||
});
|
||||
/// #endif
|
||||
// 文档标题互转后,编辑区会跳转到开头 https://github.com/siyuan-note/siyuan/issues/2939
|
||||
setTimeout(() => {
|
||||
protyle.contentElement.scrollTop = scrollTop;
|
||||
protyle.scroll.lastScrollTop = scrollTop - 1;
|
||||
}, Constants.TIMEOUT_BLOCKLOAD);
|
||||
}, Constants.TIMEOUT_LOAD);
|
||||
});
|
||||
targetElement.classList.remove("dragover__bottom", "dragover__top");
|
||||
} else if (!window.siyuan.dragElement && (event.dataTransfer.types[0] === "Files" || event.dataTransfer.types.includes("text/html"))) {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
|
|||
updateTransaction(protyle, id, blockElement.outerHTML, oldHTML);
|
||||
setTimeout(() => {
|
||||
scrollCenter(protyle, blockElement, false, "smooth");
|
||||
}, Constants.TIMEOUT_BLOCKLOAD);
|
||||
}, Constants.TIMEOUT_LOAD);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ const setHTML = (options: {
|
|||
// 减少抖动 https://ld246.com/article/1654263598088
|
||||
setTimeout(() => {
|
||||
focusElement.scrollIntoView();
|
||||
}, Constants.TIMEOUT_BLOCKLOAD);
|
||||
}, Constants.TIMEOUT_LOAD);
|
||||
} else {
|
||||
focusBlock(protyle.wysiwyg.element.firstElementChild);
|
||||
/// #if !MOBILE
|
||||
|
|
|
|||
|
|
@ -1,33 +1,36 @@
|
|||
import {hideElements} from "../ui/hideElements";
|
||||
import {setPadding} from "../ui/initUI";
|
||||
import {hasClosestBlock} from "./hasClosest";
|
||||
import {Constants} from "../../constants";
|
||||
|
||||
export const resize = (protyle: IProtyle) => {
|
||||
hideElements(["gutter"], protyle);
|
||||
setPadding(protyle);
|
||||
if (typeof echarts !== "undefined") {
|
||||
protyle.wysiwyg.element.querySelectorAll('[data-subtype="echarts"], [data-subtype="mindmap"]').forEach((chartItem: HTMLElement) => {
|
||||
const chartInstance = echarts.getInstanceById(chartItem.firstElementChild.nextElementSibling.getAttribute("_echarts_instance_"));
|
||||
if (chartInstance) {
|
||||
chartInstance.resize();
|
||||
setTimeout(() => {
|
||||
if (typeof echarts !== "undefined") {
|
||||
protyle.wysiwyg.element.querySelectorAll('[data-subtype="echarts"], [data-subtype="mindmap"]').forEach((chartItem: HTMLElement) => {
|
||||
const chartInstance = echarts.getInstanceById(chartItem.firstElementChild.nextElementSibling.getAttribute("_echarts_instance_"));
|
||||
if (chartInstance) {
|
||||
chartInstance.resize();
|
||||
}
|
||||
});
|
||||
}
|
||||
// 保持光标位置不变 https://ld246.com/article/1673704873983/comment/1673765814595#comments
|
||||
if (protyle.toolbar.range) {
|
||||
let rangeRect = protyle.toolbar.range.getBoundingClientRect();
|
||||
if (rangeRect.height === 0) {
|
||||
const blockElement = hasClosestBlock(protyle.toolbar.range.startContainer);
|
||||
if (blockElement) {
|
||||
rangeRect = blockElement.getBoundingClientRect();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// 保持光标位置不变 https://ld246.com/article/1673704873983/comment/1673765814595#comments
|
||||
if (protyle.toolbar.range) {
|
||||
let rangeRect = protyle.toolbar.range.getBoundingClientRect();
|
||||
if (rangeRect.height === 0) {
|
||||
const blockElement = hasClosestBlock(protyle.toolbar.range.startContainer);
|
||||
if (blockElement) {
|
||||
rangeRect = blockElement.getBoundingClientRect();
|
||||
if (rangeRect.height === 0) {
|
||||
return;
|
||||
}
|
||||
const protyleRect = protyle.element.getBoundingClientRect();
|
||||
if (protyleRect.top + 30 > rangeRect.top || protyleRect.bottom < rangeRect.bottom) {
|
||||
protyle.toolbar.range.startContainer.parentElement.scrollIntoView(protyleRect.top > rangeRect.top);
|
||||
}
|
||||
}
|
||||
if (rangeRect.height === 0) {
|
||||
return;
|
||||
}
|
||||
const protyleRect = protyle.element.getBoundingClientRect();
|
||||
if (protyleRect.top + 30 > rangeRect.top || protyleRect.bottom < rangeRect.bottom) {
|
||||
protyle.toolbar.range.startContainer.parentElement.scrollIntoView(protyleRect.top > rangeRect.top);
|
||||
}
|
||||
}
|
||||
}, Constants.TIMEOUT_TRANSITION); // 等待 setPadding 动画结束
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue