mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
9edcd3f3a7
commit
9cb6e9ec25
10 changed files with 198 additions and 118 deletions
33
app/src/protyle/util/resize.ts
Normal file
33
app/src/protyle/util/resize.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import {hideElements} from "../ui/hideElements";
|
||||
import {setPadding} from "../ui/initUI";
|
||||
import {hasClosestBlock} from "./hasClosest";
|
||||
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
// 保持光标位置不变 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);
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue