braft-extensions icon indicating copy to clipboard operation
braft-extensions copied to clipboard

表格全选后,内容设置靠左对齐,富文本框崩溃

Open kingller opened this issue 3 years ago • 1 comments

Hi,

import BraftEditor, { EditorState, DraftEditorProps } from 'braft-editor';
import Table from 'braft-extensions/dist/table';
import 'braft-extensions/dist/table.css';

我使用braft-extensions中的table,全选table中的内容,设置靠左对齐,富文本框崩溃 image

报错如下

Uncaught TypeError: Cannot read property 'key' of undefined
    at table.js:1837
    at Array.map (<anonymous>)
    at Table.createRowTools (table.js:1834)
    at Table.render (table.js:1937)
    at finishClassComponent (react-dom.development.js:17160)
    at updateClassComponent (react-dom.development.js:17110)
    at beginWork (react-dom.development.js:18620)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
    at invokeGuardedCallback (react-dom.development.js:292)
(anonymous) @ table.js:1837
createRowTools @ table.js:1834
render @ table.js:1937
finishClassComponent @ react-dom.development.js:17160
updateClassComponent @ react-dom.development.js:17110
beginWork @ react-dom.development.js:18620
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
beginWork$1 @ react-dom.development.js:23203
performUnitOfWork @ react-dom.development.js:22154
workLoopSync @ react-dom.development.js:22130
performSyncWorkOnRoot @ react-dom.development.js:21756
(anonymous) @ react-dom.development.js:11089
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushSyncCallbackQueueImpl @ react-dom.development.js:11084
flushSyncCallbackQueue @ react-dom.development.js:11072
discreteUpdates$1 @ react-dom.development.js:21893
discreteUpdates @ react-dom.development.js:806
dispatchDiscreteEvent @ react-dom.development.js:4168
react_devtools_backend.js:2557 

The above error occurred in the <Table> component:
    in Table (created by BraftEditor)
    in div (created by DraftEditorContents)
    in DraftEditorContents (created by DraftEditor)
    in div (created by DraftEditor)
    in div (created by DraftEditor)
    in div (created by DraftEditor)
    in DraftEditor (created by BraftEditor)
    in div (created by BraftEditor)
    in div (created by BraftEditor)
    in BraftEditor (created by ContractEditor)
    in div (created by ContractEditor)
    in div (created by ContractEditor)
    in ContractEditor (created by Box)
    in div (created by CodeBox)
    in div (created by CodeBox)
    in section (created by CodeBox)
    in CodeBox (created by Box)
    in Box (created by RichEditor)
    in div (created by Page)
    in Page (created by RichEditor)
    in div (created by DemoPage)
    in DemoPage (created by RichEditor)
    in RichEditor (created by Context.Consumer)
    in Route (created by Main)
    in Switch (created by Main)
    in div (created by Main)
    in div (created by Main)
    in div (created by Main)
    in div (created by Main)
    in div (created by Main)
    in div (created by Loadable)
    in div (created by Loadable)
    in Loadable (created by Main)
    in div (created by Main)
    in div (created by Framework)
    in Framework (created by Main)
    in Main (created by Context.Consumer)
    in withRouter(Main)
    in Router
    in Theme
    in I18nextProvider

React will try to recreate this component tree from scratch using the error boundary you provided, ContractEditor.

请问我该如何解决这个问题

kingller avatar Apr 25 '21 07:04 kingller

这个问题我已经解决了,是draft.js中DraftModif.js遍历全部全部单元格将选中的起始格属性赋值给所有单元格导致的,典型的插件和draft配合的不是很好,希望你已经脱离braft的苦海。

fakeou avatar May 10 '22 01:05 fakeou