mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-02 21:51:49 +01:00
This commit is contained in:
parent
957a928959
commit
bb781add0a
1 changed files with 11 additions and 17 deletions
|
|
@ -147,7 +147,7 @@ export const initUI = (protyle: IProtyle) => {
|
|||
(lastElement.getAttribute("data-type") !== "NodeParagraph" && protyle.wysiwyg.element.getAttribute("data-doc-type") !== "NodeListItem") ||
|
||||
(lastElement.getAttribute("data-type") === "NodeParagraph" && getContenteditableElement(lastEditElement).innerHTML !== ""))
|
||||
) {
|
||||
let emptyElement:Element;
|
||||
let emptyElement: Element;
|
||||
if (lastElement.getAttribute("data-type") === "NodeHeading" && lastElement.getAttribute("fold") === "1") {
|
||||
emptyElement = genHeadingElement(lastElement) as Element;
|
||||
} else {
|
||||
|
|
@ -296,24 +296,10 @@ export const setPadding = (protyle: IProtyle) => {
|
|||
padding: 0
|
||||
};
|
||||
}
|
||||
const oldLeft = parseInt(protyle.wysiwyg.element.style.paddingLeft || "0");
|
||||
const padding = getPadding(protyle);
|
||||
const paddingLeft = padding.left;
|
||||
const paddingRight = padding.right;
|
||||
|
||||
const protyleWidth = protyle.element.clientWidth;
|
||||
const scrollbarWidth = protyle.contentElement.offsetWidth - protyle.contentElement.clientWidth;
|
||||
const contentWidth = protyleWidth - scrollbarWidth;
|
||||
|
||||
const wysiwygOldWidth = parseInt(protyle.wysiwyg.element.getAttribute("data-realwidth") || "0");
|
||||
const wysiwygNewWidth = contentWidth - paddingLeft - paddingRight;
|
||||
|
||||
// https://github.com/siyuan-note/siyuan/issues/15021
|
||||
protyle.element.style.setProperty("--b3-width-protyle", protyleWidth + "px");
|
||||
protyle.element.style.setProperty("--b3-width-protyle-content", contentWidth + "px");
|
||||
protyle.element.style.setProperty("--b3-width-protyle-wysiwyg", wysiwygNewWidth.toString() + "px");
|
||||
protyle.wysiwyg.element.setAttribute("data-realwidth", wysiwygNewWidth.toString());
|
||||
|
||||
if (protyle.options.backlinkData) {
|
||||
protyle.wysiwyg.element.style.padding = `4px ${paddingRight}px 4px ${paddingLeft}px`;
|
||||
} else {
|
||||
|
|
@ -327,9 +313,17 @@ export const setPadding = (protyle: IProtyle) => {
|
|||
protyle.title.element.style.margin = `16px ${paddingRight}px 0 ${paddingLeft}px`;
|
||||
}
|
||||
|
||||
// https://github.com/siyuan-note/siyuan/issues/15021
|
||||
protyle.element.style.setProperty("--b3-width-protyle", protyle.element.clientWidth + "px");
|
||||
protyle.element.style.setProperty("--b3-width-protyle-content", protyle.contentElement.clientWidth + "px");
|
||||
|
||||
const newWidth = protyle.wysiwyg.element.clientWidth - paddingLeft - paddingRight;
|
||||
protyle.wysiwyg.element.setAttribute("data-realwidth", newWidth.toString());
|
||||
protyle.element.style.setProperty("--b3-width-protyle-wysiwyg", newWidth.toString() + "px");
|
||||
|
||||
const realWidth = protyle.wysiwyg.element.getAttribute("data-realwidth");
|
||||
return {
|
||||
width: Math.abs(wysiwygOldWidth - wysiwygNewWidth),
|
||||
padding: Math.abs(oldLeft - paddingLeft)
|
||||
width: realWidth ? Math.abs(parseFloat(realWidth) - newWidth) : 0,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue