1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-01 19:22:35 +02:00

Do not store focus/blur in history (#3616)

This commit is contained in:
Mateusz Burzyński
2021-03-31 21:46:53 +02:00
committed by GitHub
parent c20855ff52
commit 42d99af6fa
2 changed files with 54 additions and 11 deletions

View File

@@ -0,0 +1,49 @@
/** @jsx jsx */
import assert from 'assert'
import { Transforms, Editor } from 'slate'
import { jsx } from '../..'
export const run = editor => {
// focus at the end
Transforms.select(editor, {
anchor: { path: [0, 0], offset: 5 },
focus: { path: [0, 0], offset: 5 },
})
// select all
Transforms.select(editor, {
anchor: { path: [0, 0], offset: 5 },
focus: { path: [0, 0], offset: 0 },
})
// remove
Editor.deleteFragment(editor)
// blur
Transforms.deselect(editor)
// focus back
Transforms.select(editor, {
anchor: { path: [0, 0], offset: 0 },
focus: { path: [0, 0], offset: 0 },
})
}
export const input = (
<editor>
<block>Hello</block>
</editor>
)
export const output = {
children: [
{
children: [
{
text: 'Hello',
},
],
},
],
selection: {
anchor: { path: [0, 0], offset: 5 },
focus: { path: [0, 0], offset: 5 },
},
}