Skip to content

Commit

Permalink
fix(placeholder): just use inline-flex on firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
pubuzhixing8 committed Feb 9, 2022
1 parent ca2e4fe commit 4ee6bff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions packages/src/components/editable/editable.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ import {
DOMSelection,
getDefaultView
} from '../../utils/dom';
import { Subject, interval } from 'rxjs';
import { takeUntil, throttle } from 'rxjs/operators';
import { Subject } from 'rxjs';
import { IS_FIREFOX, IS_SAFARI, IS_EDGE_LEGACY, IS_CHROME_LEGACY, IS_CHROME } from '../../utils/environment';
import Hotkeys from '../../utils/hotkeys';
import { BeforeInputEvent, extractBeforeInputEvent } from '../../custom-event/BeforeInputEventPlugin';
Expand Down Expand Up @@ -182,6 +181,10 @@ export class SlateEditableComponent implements OnInit, OnChanges, OnDestroy, Aft

// remove unused DOM, just keep templateComponent instance
this.templateElementRef.nativeElement.remove();

// add browser class
let browserClass = IS_FIREFOX ? 'firefox' : (IS_SAFARI ? 'safari' : '');
browserClass && this.elementRef.nativeElement.classList.add(browserClass);
}

ngOnChanges(simpleChanges: SimpleChanges) {
Expand Down
14 changes: 10 additions & 4 deletions packages/src/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@
& [data-slate-leaf="true"] {
&.leaf-with-placeholder {
position: relative;
// Compatible for firefox, there are two problems with using inline-block
// Issue-1: paragraph height becomes taller
// Issue-2: blocks focus movement on key down
display: inline-flex;
display: inline-block;
width: 100%;
}
}
&.firefox {
// Compatible for firefox, there are two problems with using inline-block
// Issue-1: paragraph height becomes taller
// Issue-2: blocks focus movement on key down
.leaf-with-placeholder {
display: inline-flex !important;
}

}
}

.slate-spacer {
Expand Down

0 comments on commit 4ee6bff

Please sign in to comment.