mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
🎨 resize
This commit is contained in:
parent
da369e391a
commit
268b928267
14 changed files with 99 additions and 87 deletions
|
|
@ -118,26 +118,31 @@ export const removeLoading = (protyle: IProtyle) => {
|
|||
|
||||
export const setPadding = (protyle: IProtyle) => {
|
||||
if (protyle.options.action.includes(Constants.CB_GET_HISTORY)) {
|
||||
return;
|
||||
return {
|
||||
width: 0,
|
||||
padding: 0
|
||||
};
|
||||
}
|
||||
let min16 = 16;
|
||||
let min24 = 24;
|
||||
const oldLeft = parseInt(protyle.wysiwyg.element.style.paddingLeft)
|
||||
let left = 16;
|
||||
let right = 24;
|
||||
if (!isMobile()) {
|
||||
let padding = (protyle.element.clientWidth - Constants.SIZE_EDITOR_WIDTH) / 2;
|
||||
let isFullWidth = protyle.wysiwyg.element.getAttribute(Constants.CUSTOM_SY_FULLWIDTH);
|
||||
if (!isFullWidth) {
|
||||
isFullWidth = window.siyuan.config.editor.fullWidth ? "true" : "false";
|
||||
}
|
||||
let padding = (protyle.element.clientWidth - Constants.SIZE_EDITOR_WIDTH) / 2;
|
||||
if (isFullWidth === "false" && padding > 96) {
|
||||
if (padding > Constants.SIZE_EDITOR_WIDTH) {
|
||||
// 超宽屏调整 https://ld246.com/article/1668266637363
|
||||
padding = protyle.element.clientWidth * .382 / 1.382;
|
||||
}
|
||||
min16 = padding;
|
||||
min24 = padding;
|
||||
padding = Math.ceil(padding);
|
||||
left = padding;
|
||||
right = padding;
|
||||
} else if (protyle.element.clientWidth > Constants.SIZE_EDITOR_WIDTH) {
|
||||
min16 = 96;
|
||||
min24 = 96;
|
||||
left = 96;
|
||||
right = 96;
|
||||
}
|
||||
}
|
||||
let bottomHeight = "16px";
|
||||
|
|
@ -149,37 +154,28 @@ export const setPadding = (protyle: IProtyle) => {
|
|||
}
|
||||
}
|
||||
if (protyle.options.backlinkData) {
|
||||
if ((min16 === min24 && protyle.wysiwyg.element.style.padding === `4px ${min16}px`) ||
|
||||
(min16 !== min24 && protyle.wysiwyg.element.style.padding === `4px ${min16}px 4px ${min24}px`)) {
|
||||
return true;
|
||||
}
|
||||
protyle.wysiwyg.element.style.padding = `4px ${min16}px 4px ${min24}px`;
|
||||
protyle.wysiwyg.element.style.padding = `4px ${left}px 4px ${right}px`;
|
||||
} else {
|
||||
// https://github.com/siyuan-note/siyuan/issues/8859
|
||||
if ((min16 === min24 && protyle.wysiwyg.element.style.padding === `16px ${min16}px ${bottomHeight}`) ||
|
||||
(min16 !== min24 && protyle.wysiwyg.element.style.padding === `16px ${min16}px ${bottomHeight} ${min24}px`)) {
|
||||
return true;
|
||||
}
|
||||
protyle.wysiwyg.element.style.padding = `16px ${min16}px ${bottomHeight} ${min24}px`;
|
||||
protyle.wysiwyg.element.style.padding = `16px ${left}px ${bottomHeight} ${right}px`;
|
||||
}
|
||||
if (protyle.options.render.background) {
|
||||
protyle.background.element.lastElementChild.setAttribute("style", `left:${min16}px`);
|
||||
protyle.background.element.querySelector(".protyle-background__img .protyle-icons").setAttribute("style", `right:${min16}px`);
|
||||
protyle.background.element.lastElementChild.setAttribute("style", `left:${left}px`);
|
||||
protyle.background.element.querySelector(".protyle-background__img .protyle-icons").setAttribute("style", `right:${left}px`);
|
||||
}
|
||||
if (protyle.options.render.title) {
|
||||
protyle.title.element.style.margin = `16px ${min16}px 0 ${min24}px`;
|
||||
}
|
||||
if (window.siyuan.config.editor.codeSyntaxHighlightLineNum) {
|
||||
setTimeout(() => { // https://github.com/siyuan-note/siyuan/issues/5612
|
||||
protyle.wysiwyg.element.querySelectorAll('.code-block [contenteditable="true"]').forEach((block: HTMLElement) => {
|
||||
lineNumberRender(block);
|
||||
});
|
||||
}, 300);
|
||||
protyle.title.element.style.margin = `16px ${left}px 0 ${right}px`;
|
||||
}
|
||||
if (window.siyuan.config.editor.displayBookmarkIcon) {
|
||||
const editorAttrElement = document.getElementById("editorAttr");
|
||||
if (editorAttrElement) {
|
||||
editorAttrElement.innerHTML = `.protyle-wysiwyg--attr .b3-tooltips:after { max-width: ${protyle.wysiwyg.element.clientWidth - min16 - min24}px; }`;
|
||||
editorAttrElement.innerHTML = `.protyle-wysiwyg--attr .b3-tooltips:after { max-width: ${protyle.wysiwyg.element.clientWidth - left - right}px; }`;
|
||||
}
|
||||
}
|
||||
const oldWidth = protyle.wysiwyg.element.getAttribute("data-realwidth");
|
||||
const newWidth = protyle.wysiwyg.element.clientWidth - parseInt(protyle.wysiwyg.element.style.paddingLeft) - parseInt(protyle.wysiwyg.element.style.paddingRight)
|
||||
protyle.wysiwyg.element.setAttribute("data-realwidth", newWidth.toString());
|
||||
return {
|
||||
width: Math.abs(parseInt(oldWidth) - newWidth),
|
||||
padding: Math.abs(oldLeft - parseInt(protyle.wysiwyg.element.style.paddingLeft))
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue