Preserve external history option (#22)

* feat: handle node text in remove_text op

* feat: add preserveExternalHistory option
This commit is contained in:
George
2020-07-02 00:56:48 +03:00
committed by GitHub
parent b49cf33464
commit 55b1b2ca5a
10 changed files with 72 additions and 36 deletions

View File

@@ -1,10 +1,10 @@
import { Node, Path } from 'slate'
import { Element, Node, Path } from 'slate'
import { SyncValue } from '../model'
export const isTree = (node: Node): boolean => Boolean(node?.children)
export const getTarget = (doc: SyncValue, path: Path) => {
export const getTarget = (doc: SyncValue | Element, path: Path) => {
const iterate = (current: any, idx: number) => {
if (!(isTree(current) || current[idx])) {
throw new TypeError(
@@ -30,7 +30,7 @@ export const getParentPath = (
}
export const getParent = (
doc: SyncValue,
doc: SyncValue | Element,
path: Path,
level = 1
): [any, number] => {