Fix Slate bug causing the composer to blur if you undo past the end of undo history

This commit is contained in:
Ben Gotow 2020-04-22 00:12:49 -05:00
parent 2703f99cdd
commit 34eccfa7df
3 changed files with 4 additions and 3 deletions

2
app/package-lock.json generated
View file

@ -2762,7 +2762,7 @@
}
},
"slate": {
"version": "github:bengotow/slate#398558065024005d2529f221c54144807a8ab4cf",
"version": "github:bengotow/slate#cd6f40e8db9058f518c091cffe364608b3c858e6",
"requires": {
"debug": "3.2.6",
"direction": "0.1.5",

View file

@ -60,7 +60,7 @@
"rtlcss": "2.4.0",
"runas": "getflywheel/node-runas#ca4f0714",
"rx-lite": "4.0.8",
"slate": "github:bengotow/slate#0.45.1",
"slate": "github:bengotow/slate#cd6f40e8",
"slate-auto-replace": "0.12.1",
"slate-base64-serializer": "0.2.100",
"slate-html-serializer": "0.7.39",

View file

@ -83,7 +83,8 @@ function hotwireDraftBodyState(draft: any, session: DraftEditingSession): Messag
.replaceNodeByKey(first.key, Block.create({ type: 'div' }))
.moveToRangeOfDocument()
.insertFragment(inHTMLEditorValue.document)
.moveToStart().value;
.moveToStart()
.focus().value;
} catch (err) {
// deleting and re-inserting the whole document seems to push Slate pretty hard and it
// sometimes fails with odd schema issues (undefined node, invalid range.) Just fall