fix(table): 只读模式下仍然可以编辑

This commit is contained in:
yanmao 2022-01-19 22:19:32 +08:00
parent f75d8f76b4
commit cd594762f8
1 changed files with 8 additions and 0 deletions

View File

@ -94,6 +94,7 @@ 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'] = [];
@ -333,6 +334,12 @@ 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 [
@ -924,6 +931,7 @@ 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);
}
}