@lyra/form-builder
Version:
Lyra form builder
25 lines (22 loc) • 791 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = createSelectionOperation;
var _slate = require('slate');
/*:: import type {SlateChange} from '../typeDefs'*/
function createSelectionOperation(change /*: SlateChange*/) {
const focusPath = change.value.focusKey ? change.value.document.getPath(change.value.focusKey) : undefined;
const anchorPath = change.value.anchorKey ? change.value.document.getPath(change.value.anchorKey) : undefined;
return _slate.Operation.create({
type: 'set_selection',
properties: {
anchorPath,
focusPath,
focusOffset: change.value.selection.focusOffset,
anchorOffset: change.value.selection.anchorOffset
},
value: change.value,
selection: change.selection
});
}