fix: 粘贴中的表格宽度是百分比会被压缩得很窄
This commit is contained in:
parent
5f8bd8ffb8
commit
fc1f1f5903
|
@ -503,7 +503,7 @@ class Helper implements HelperInterface {
|
|||
|
||||
if (parseInt(width) === 0) {
|
||||
table.css('width', 'auto');
|
||||
} else {
|
||||
} else if (!width.endsWith('%')) {
|
||||
// pt 直接转为 px, 因为 col 的 width 属性是没有单位的,会直接被理解为 px, 这里 table 的 width 也直接换成 px。
|
||||
table.css('width', parseInt(width, 10) + 'px');
|
||||
} // 表格 table 标签不允许有背景色,无法设置
|
||||
|
@ -516,7 +516,7 @@ class Helper implements HelperInterface {
|
|||
for (let c = cols.length - 1; c >= 0; c--) {
|
||||
const colElement = cols[c] as HTMLTableColElement;
|
||||
const _width = cols.eq(c)?.attributes('width');
|
||||
if (_width) {
|
||||
if (_width && !_width.endsWith('%')) {
|
||||
const widthValue = parseInt(_width);
|
||||
if (widthValue !== NaN)
|
||||
cols.eq(c)?.attributes('width', widthValue);
|
||||
|
|
|
@ -24,6 +24,12 @@ class Table<T extends TableOptions = TableOptions> extends Plugin<T> {
|
|||
|
||||
init() {
|
||||
const editor = this.editor;
|
||||
if (!this.options.colMinWidth) {
|
||||
this.options.colMinWidth = 40;
|
||||
}
|
||||
if (!this.options.rowMinHeight) {
|
||||
this.options.rowMinHeight = 30;
|
||||
}
|
||||
editor.language.add(locales);
|
||||
editor.schema.add(this.schema());
|
||||
editor.conversion.add('th', 'td');
|
||||
|
|
Loading…
Reference in New Issue