Open yy2012 opened 1 year ago
import { TextSelection } from "prosemirror-state";
youEditorInstance.on("changeMode", function (mode) {
console.log(mode)
let view, state;
if (mode == "markdown") {
view = that.editor.wwEditor.view
state = view.state
} else {
view = that.editor.mdEditor.view
state = view.state
}
if (state.selection.empty) {
console.log("state.selection is empty")
return
}
if (state.selection.constructor.name != "CellSelection") {
console.log("state.selection is not CellSelection")
return
}
view.dispatch(
state.tr.setSelection(
TextSelection.create(
state.apply(state.tr).doc,
state.selection.to
)
));
})
Describe the bug
select the table in WYSIWYG, switch back to Markdown, and click WYSIWYG, an error bug will appear
To Reproduce
You can reproduce this problem on this page https://ui.toast.com/tui-editor
Uncaught TypeError: Cannot read properties of null (reading 'totalColumnCount') at t.map (index.js:19100:47) at n.selection.get (index.es.js:701:45) at w.apply (index.es.js:907:15) at UxO+.S.applyInner (index.es.js:1095:37) at UxO+.S.applyTransaction (index.es.js:1028:23) at $t.dispatchTransaction (index.js:23602:38) at V2qZ.$t.dispatch (index.es.js:7400:25) at t.setModel (index.js:23724:15) at e.changeMode (index.js:27534:21) at index.js:23939:30