fix(table): 修复表格宽度问题

This commit is contained in:
yanmao 2022-01-19 23:14:28 +08:00
parent cd594762f8
commit d054c7402c
2 changed files with 5 additions and 12 deletions

View File

@ -775,7 +775,7 @@ class CardModel implements CardModelInterface {
if (card.contenteditable.length > 0) {
center.find(card.contenteditable.join(',')).each((node) => {
const child = $(node);
if (!child.attributes('contenteditable'))
if (child.attributes('contenteditable') !== undefined)
child.attributes(
'contenteditable',
!isEngine(this.editor) || this.editor.readonly

View File

@ -94,7 +94,6 @@ class TableComponent<V extends TableValue = TableValue>
if (isEngine(this.editor)) {
this.editor.on('undo', this.doChange);
this.editor.on('redo', this.doChange);
this.editor.on('readonly', this.handleReadonly);
// tab 键选择
if (!this.editor.event.listeners['keydown:tab'])
this.editor.event.listeners['keydown:tab'] = [];
@ -334,12 +333,6 @@ class TableComponent<V extends TableValue = TableValue>
this.onChange('remote');
};
handleReadonly = (readonly: boolean) => {
this.viewport
?.find('.table-main-content')
.attributes('contenteditable', readonly ? 'false' : 'true');
};
toolbar(): Array<ToolbarItemOptions | CardToolbarItemOptions> {
if (!isEngine(this.editor) || this.editor.readonly)
return [
@ -536,6 +529,7 @@ class TableComponent<V extends TableValue = TableValue>
});
const { rows, cols, height, width } = tableModel;
const html = parser.toValue(schema, conversion, false, false);
if (!isEngine(this.editor)) return { ...value, html };
return {
...value,
rows,
@ -626,7 +620,7 @@ class TableComponent<V extends TableValue = TableValue>
if (oldValue?.noBorder) {
this.noBorderToolButton?.addClass('active');
} else this.noBorderToolButton?.removeClass('active');
if (trigger === 'local') {
if (trigger === 'local' && isEngine(this.editor)) {
const value = this.getValue();
if (value) this.setValue(value);
}
@ -807,10 +801,10 @@ class TableComponent<V extends TableValue = TableValue>
const tableRoot = this.wrapper?.find(Template.TABLE_CLASS);
if (!tableRoot) return;
const value = this.getValue();
const value = super.getValue();
if (!value?.html) {
const tableValue = this.getValue();
if (tableValue) this.setValue(tableValue);
if (tableValue && isEngine(this.editor)) this.setValue(tableValue);
this.onChange();
}
if (tableOptions['maxRightWidth'])
@ -931,7 +925,6 @@ class TableComponent<V extends TableValue = TableValue>
this.conltrollBar.destroy();
this.editor.off('undo', this.doChange);
this.editor.off('redo', this.doChange);
this.editor.off('readonly', this.handleReadonly);
}
}