Skip to content

Commit

Permalink
🐛 typewriterMode 中心位置
Browse files Browse the repository at this point in the history
  • Loading branch information
stevapple committed Apr 9, 2020
1 parent 2845b17 commit 99795a6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/assets/scss/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@
}

&:after {
$height: var(--editor-bottom);
content: "";
height: var(--editor-bottom);
height: var(--editor-bottom-actual, $height);
display: block;
}
}
Expand Down Expand Up @@ -211,14 +212,14 @@

&__close {
position: absolute;
color: var(--toolbar-icon-color);
color: var(--toolbar-icon-color);
top: -7px;
right: -15px;
font-weight: bold;
cursor: pointer;

&:hover {
color: var(--toolbar-icon-hover-color);
color: var(--toolbar-icon-hover-color);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/assets/scss/_ir.scss
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@
}

&:after {
$height: var(--editor-bottom);
content: "";
height: var(--editor-bottom);
height: var(--editor-bottom-actual, $height);
display: block;
}

Expand Down
3 changes: 2 additions & 1 deletion src/assets/scss/_wysiwyg.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
}

&:after {
$height: var(--editor-bottom);
content: "";
height: var(--editor-bottom);
height: var(--editor-bottom-actual, $height);
display: block;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/ts/toolbar/Fullscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ export class Fullscreen extends MenuItem {
public _bindEvent(vditor: IVditor, menuItem: IMenuItem) {
this.element.children[0].addEventListener(getEventName(), function(event) {
event.preventDefault();
if (vditor.element.className.indexOf("vditor--fullscreen") > -1) {
if (vditor.element.className.includes("vditor--fullscreen")) {
this.innerHTML = menuItem.icon || fullscreenSVG;
vditor.element.style.removeProperty("--editor-bottom-actual");
vditor.element.classList.remove("vditor--fullscreen");
Object.keys(vditor.toolbar.elements).forEach((key) => {
const svgElement = vditor.toolbar.elements[key].firstChild as HTMLElement;
Expand All @@ -25,6 +26,7 @@ export class Fullscreen extends MenuItem {
});
} else {
this.innerHTML = menuItem.icon || contractSVG;
vditor.element.style.setProperty("--editor-bottom-actual", "50%");
vditor.element.classList.add("vditor--fullscreen");
Object.keys(vditor.toolbar.elements).forEach((key) => {
const svgElement = vditor.toolbar.elements[key].firstChild as HTMLElement;
Expand Down
2 changes: 1 addition & 1 deletion src/ts/ui/initUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const afterRender = (vditor: IVditor, contentElement: HTMLElement) => {
height = vditor.options.height - 37;
}

if (vditor.options.typewriterMode) {
if (vditor.options.typewriterMode && typeof vditor.options.height === "number") {
// 由于 Firefox padding-bottom bug,只能使用 :after
contentElement.style.setProperty("--editor-bottom", height / 2 + "px");
}
Expand Down

0 comments on commit 99795a6

Please sign in to comment.