修复弹出框里面的 rich-text 默认宽度不正确的问题

This commit is contained in:
2betop 2020-04-20 17:31:07 +08:00
parent 9332656924
commit 62d6f8e3a7
3 changed files with 28 additions and 1 deletions

View File

@ -9,6 +9,10 @@
border: 0;
}
> textarea {
width: 100%;
}
min-height: px2rem(200px);
height: auto;
border: $Form-input-borderWidth solid $Form-input-borderColor;

View File

@ -49,6 +49,7 @@ import $ from 'jquery';
// Require Editor CSS files.
import 'froala-editor/css/froala_style.min.css';
import 'froala-editor/css/froala_editor.pkgd.min.css';
import {resizeSensor} from '../utils/resize-sensor';
export default class FroalaEditor extends React.Component<any, any> {
listeningEvents: Array<any> = [];
@ -87,6 +88,16 @@ export default class FroalaEditor extends React.Component<any, any> {
this.$element = $(ref);
this.setContent(true);
this.registerEvents();
resizeSensor(
ref.parentElement,
() => {
$(ref)
.prev('.fr-box')
.find('.fr-toolbar')
.css('width', '');
},
true
);
this.$editor = this.$element
.froalaEditor(this.config)
.data('froala.editor').$el;

View File

@ -122,7 +122,19 @@ function detach(element: HTMLElement) {
}
}
export function resizeSensor(element: HTMLElement, callback: Function) {
export function resizeSensor(
element: HTMLElement,
callback: Function,
once: boolean = false
) {
if (once) {
attachResizeEvent(element, function(this: any) {
callback.apply(this, arguments);
detach(element);
});
return;
}
attachResizeEvent(element, callback);
let detached = false;