1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-31 02:49:56 +02:00

fix: isVoid, isBlock, isInline types (#5254)

* fix: isVoid, isBlock, isInline types

* fix: remove isElement check with isEditor
This commit is contained in:
Ravi Lamkoti
2023-01-26 05:05:46 +05:30
committed by GitHub
parent e9c9d9f4db
commit c691bb3aae
46 changed files with 159 additions and 126 deletions

View File

@@ -521,7 +521,7 @@ export const Editable = (props: EditableProps) => {
) {
const block = Editor.above(editor, {
at: anchor.path,
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
})
if (block && Node.string(block[0]).includes('\t')) {
@@ -1009,9 +1009,12 @@ export const Editable = (props: EditableProps) => {
if (event.detail === TRIPLE_CLICK && path.length >= 1) {
let blockPath = path
if (!Editor.isBlock(editor, node)) {
if (
!(Element.isElement(node) && Editor.isBlock(editor, node))
) {
const block = Editor.above(editor, {
match: n => Editor.isBlock(editor, n),
match: n =>
Element.isElement(n) && Editor.isBlock(editor, n),
at: path,
})
@@ -1131,7 +1134,8 @@ export const Editable = (props: EditableProps) => {
return
}
const inline = Editor.above(editor, {
match: n => Editor.isInline(editor, n),
match: n =>
Element.isElement(n) && Editor.isInline(editor, n),
mode: 'highest',
})
if (inline) {
@@ -1205,7 +1209,7 @@ export const Editable = (props: EditableProps) => {
// default, and calling `preventDefault` hides the cursor.
const node = ReactEditor.toSlateNode(editor, event.target)
if (Editor.isVoid(editor, node)) {
if (Element.isElement(node) && Editor.isVoid(editor, node)) {
event.preventDefault()
}
}
@@ -1222,7 +1226,7 @@ export const Editable = (props: EditableProps) => {
const node = ReactEditor.toSlateNode(editor, event.target)
const path = ReactEditor.findPath(editor, node)
const voidMatch =
Editor.isVoid(editor, node) ||
(Element.isElement(node) && Editor.isVoid(editor, node)) ||
Editor.void(editor, { at: path, voids: true })
// If starting a drag on a void node, make sure it is selected

View File

@@ -7,6 +7,7 @@ import {
Range,
Scrubber,
Transforms,
Element,
} from 'slate'
import { Key } from '../utils/key'
@@ -477,7 +478,7 @@ export const ReactEditor = {
// If the drop target is inside a void node, move it into either the
// next or previous node, depending on which side the `x` and `y`
// coordinates are closest to.
if (Editor.isVoid(editor, node)) {
if (Element.isElement(node) && Editor.isVoid(editor, node)) {
const rect = target.getBoundingClientRect()
const isPrev = editor.isInline(node)
? x - rect.left < rect.left + rect.width - x
@@ -844,7 +845,7 @@ export const ReactEditor = {
const slateNode =
ReactEditor.hasTarget(editor, target) &&
ReactEditor.toSlateNode(editor, target)
return Editor.isVoid(editor, slateNode)
return Element.isElement(slateNode) && Editor.isVoid(editor, slateNode)
},
/**

View File

@@ -8,6 +8,7 @@ import {
Point,
Range,
Transforms,
Element,
} from 'slate'
import {
TextDiff,
@@ -91,7 +92,7 @@ export const withReact = <T extends BaseEditor>(editor: T): T & ReactEditor => {
if (e.selection && Range.isCollapsed(e.selection)) {
const parentBlockEntry = Editor.above(e, {
match: n => Editor.isBlock(e, n),
match: n => Element.isElement(n) && Editor.isBlock(e, n),
at: e.selection,
})

View File

@@ -1,4 +1,13 @@
import { Editor, Node, Operation, Path, Point, Range, Text } from 'slate'
import {
Editor,
Node,
Operation,
Path,
Point,
Range,
Text,
Element,
} from 'slate'
import { EDITOR_TO_PENDING_DIFFS } from './weak-maps'
export type StringDiff = {
@@ -166,7 +175,7 @@ export function normalizePoint(editor: Editor, point: Point): Point | null {
}
const parentBlock = Editor.above(editor, {
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
at: path,
})

View File

@@ -243,15 +243,15 @@ export interface EditorInterface {
insertFragment: (editor: Editor, fragment: Node[]) => void
insertNode: (editor: Editor, node: Node) => void
insertText: (editor: Editor, text: string) => void
isBlock: (editor: Editor, value: any) => value is Element
isBlock: (editor: Editor, value: Element) => boolean
isEditor: (value: any) => value is Editor
isEnd: (editor: Editor, point: Point, at: Location) => boolean
isEdge: (editor: Editor, point: Point, at: Location) => boolean
isEmpty: (editor: Editor, element: Element) => boolean
isInline: (editor: Editor, value: any) => value is Element
isInline: (editor: Editor, value: Element) => boolean
isNormalizing: (editor: Editor) => boolean
isStart: (editor: Editor, point: Point, at: Location) => boolean
isVoid: (editor: Editor, value: any) => value is Element
isVoid: (editor: Editor, value: Element) => boolean
last: (editor: Editor, at: Location) => NodeEntry
leaf: (
editor: Editor,
@@ -530,7 +530,9 @@ export const Editor: EditorInterface = {
*/
hasBlocks(editor: Editor, element: Element): boolean {
return element.children.some(n => Editor.isBlock(editor, n))
return element.children.some(
n => Element.isElement(n) && Editor.isBlock(editor, n)
)
},
/**
@@ -605,8 +607,8 @@ export const Editor: EditorInterface = {
* Check if a value is a block `Element` object.
*/
isBlock(editor: Editor, value: any): value is Element {
return Element.isElement(value) && !editor.isInline(value)
isBlock(editor: Editor, value: Element): boolean {
return !editor.isInline(value)
},
/**
@@ -685,8 +687,8 @@ export const Editor: EditorInterface = {
* Check if a value is an inline `Element` object.
*/
isInline(editor: Editor, value: any): value is Element {
return Element.isElement(value) && editor.isInline(value)
isInline(editor: Editor, value: Element): boolean {
return editor.isInline(value)
},
/**
@@ -716,8 +718,8 @@ export const Editor: EditorInterface = {
* Check if a value is a void `Element` object.
*/
isVoid(editor: Editor, value: any): value is Element {
return Element.isElement(value) && editor.isVoid(value)
isVoid(editor: Editor, value: Element): boolean {
return editor.isVoid(value)
},
/**
@@ -772,7 +774,7 @@ export const Editor: EditorInterface = {
levels.push([n, p])
if (!voids && Editor.isVoid(editor, n)) {
if (!voids && Element.isElement(n) && Editor.isVoid(editor, n)) {
break
}
}
@@ -818,11 +820,14 @@ export const Editor: EditorInterface = {
if (anchor.offset === 0) {
const prev = Editor.previous(editor, { at: path, match: Text.isText })
const markedVoid = Editor.above(editor, {
match: n => Editor.isVoid(editor, n) && editor.markableVoid(n),
match: n =>
Element.isElement(n) &&
Editor.isVoid(editor, n) &&
editor.markableVoid(n),
})
if (!markedVoid) {
const block = Editor.above(editor, {
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
})
if (prev && block) {
@@ -936,7 +941,8 @@ export const Editor: EditorInterface = {
reverse,
from,
to,
pass: ([n]) => (voids ? false : Editor.isVoid(editor, n)),
pass: ([n]) =>
voids ? false : Element.isElement(n) && Editor.isVoid(editor, n),
})
const matches: NodeEntry<T>[] = []
@@ -1649,7 +1655,7 @@ export const Editor: EditorInterface = {
const endBlock = Editor.above(editor, {
at: end,
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
voids,
})
const blockPath = endBlock ? endBlock[1] : []
@@ -1687,7 +1693,7 @@ export const Editor: EditorInterface = {
): NodeEntry<Element> | undefined {
return Editor.above(editor, {
...options,
match: n => Editor.isVoid(editor, n),
match: n => Element.isElement(n) && Editor.isVoid(editor, n),
})
},

View File

@@ -201,7 +201,7 @@ export const NodeTransforms: NodeTransforms = {
} else if (editor.isInline(node)) {
match = n => Text.isText(n) || Editor.isInline(editor, n)
} else {
match = n => Editor.isBlock(editor, n)
match = n => Element.isElement(n) && Editor.isBlock(editor, n)
}
}
@@ -270,7 +270,7 @@ export const NodeTransforms: NodeTransforms = {
if (match == null) {
match = Path.isPath(at)
? matchPath(editor, at)
: n => Editor.isBlock(editor, n)
: n => Element.isElement(n) && Editor.isBlock(editor, n)
}
if (!at) {
@@ -341,7 +341,7 @@ export const NodeTransforms: NodeTransforms = {
const [parent] = Editor.parent(editor, at)
match = n => parent.children.includes(n)
} else {
match = n => Editor.isBlock(editor, n)
match = n => Element.isElement(n) && Editor.isBlock(editor, n)
}
}
@@ -484,7 +484,7 @@ export const NodeTransforms: NodeTransforms = {
if (match == null) {
match = Path.isPath(at)
? matchPath(editor, at)
: n => Editor.isBlock(editor, n)
: n => Element.isElement(n) && Editor.isBlock(editor, n)
}
const toRef = Editor.pathRef(editor, to)
@@ -540,7 +540,7 @@ export const NodeTransforms: NodeTransforms = {
if (match == null) {
match = Path.isPath(at)
? matchPath(editor, at)
: n => Editor.isBlock(editor, n)
: n => Element.isElement(n) && Editor.isBlock(editor, n)
}
if (!hanging && Range.isRange(at)) {
@@ -595,7 +595,7 @@ export const NodeTransforms: NodeTransforms = {
if (match == null) {
match = Path.isPath(at)
? matchPath(editor, at)
: n => Editor.isBlock(editor, n)
: n => Element.isElement(n) && Editor.isBlock(editor, n)
}
if (!hanging && Range.isRange(at)) {
@@ -707,7 +707,7 @@ export const NodeTransforms: NodeTransforms = {
let { match, at = editor.selection, height = 0, always = false } = options
if (match == null) {
match = n => Editor.isBlock(editor, n)
match = n => Element.isElement(n) && Editor.isBlock(editor, n)
}
if (Range.isRange(at)) {
@@ -782,7 +782,7 @@ export const NodeTransforms: NodeTransforms = {
if (
path.length < highestPath.length ||
path.length === 0 ||
(!voids && Editor.isVoid(editor, node))
(!voids && Element.isElement(node) && Editor.isVoid(editor, node))
) {
break
}
@@ -870,7 +870,7 @@ export const NodeTransforms: NodeTransforms = {
if (match == null) {
match = Path.isPath(at)
? matchPath(editor, at)
: n => Editor.isBlock(editor, n)
: n => Element.isElement(n) && Editor.isBlock(editor, n)
}
if (Path.isPath(at)) {
@@ -937,9 +937,11 @@ export const NodeTransforms: NodeTransforms = {
if (Path.isPath(at)) {
match = matchPath(editor, at)
} else if (editor.isInline(element)) {
match = n => Editor.isInline(editor, n) || Text.isText(n)
match = n =>
(Element.isElement(n) && Editor.isInline(editor, n)) ||
Text.isText(n)
} else {
match = n => Editor.isBlock(editor, n)
match = n => Element.isElement(n) && Editor.isBlock(editor, n)
}
}
@@ -961,7 +963,7 @@ export const NodeTransforms: NodeTransforms = {
Editor.nodes(editor, {
at,
match: editor.isInline(element)
? n => Editor.isBlock(editor, n)
? n => Element.isElement(n) && Editor.isBlock(editor, n)
: n => Editor.isEditor(n),
mode: 'lowest',
voids,

View File

@@ -108,12 +108,12 @@ export const TextTransforms: TextTransforms = {
let [start, end] = Range.edges(at)
const startBlock = Editor.above(editor, {
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
at: start,
voids,
})
const endBlock = Editor.above(editor, {
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
at: end,
voids,
})
@@ -161,7 +161,7 @@ export const TextTransforms: TextTransforms = {
}
if (
(!voids && Editor.isVoid(editor, node)) ||
(!voids && Element.isElement(node) && Editor.isVoid(editor, node)) ||
(!Path.isCommon(path, start.path) && !Path.isCommon(path, end.path))
) {
matches.push(entry)
@@ -293,7 +293,7 @@ export const TextTransforms: TextTransforms = {
// instead since it will need to be split otherwise.
const inlineElementMatch = Editor.above(editor, {
at,
match: n => Editor.isInline(editor, n),
match: n => Element.isElement(n) && Editor.isInline(editor, n),
mode: 'highest',
voids,
})
@@ -311,7 +311,7 @@ export const TextTransforms: TextTransforms = {
}
const blockMatch = Editor.above(editor, {
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
at,
voids,
})!
@@ -410,7 +410,7 @@ export const TextTransforms: TextTransforms = {
at,
match: n =>
hasBlocks
? Editor.isBlock(editor, n)
? Element.isElement(n) && Editor.isBlock(editor, n)
: Text.isText(n) || Editor.isInline(editor, n),
mode: hasBlocks ? 'lowest' : 'highest',
always:
@@ -440,7 +440,7 @@ export const TextTransforms: TextTransforms = {
Transforms.insertNodes(editor, middles, {
at: middleRef.current!,
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
mode: 'lowest',
voids,
})

View File

@@ -1,5 +1,5 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { Editor, Element } from 'slate'
import { jsx } from '../../..'
export const input = (
@@ -12,7 +12,7 @@ export const input = (
export const test = editor => {
return Editor.above(editor, {
at: [0, 0, 0],
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
mode: 'highest',
})
}

View File

@@ -1,6 +1,6 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { Editor, Element } from 'slate'
import { jsx } from '../../..'
export const input = (
@@ -14,7 +14,7 @@ export const input = (
export const test = editor => {
return Editor.above(editor, {
at: [0, 0, 0],
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
mode: 'lowest',
})
}

View File

@@ -1,6 +1,6 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { Editor, Element } from 'slate'
import { jsx } from '../../..'
export const input = (
@@ -14,7 +14,7 @@ export const input = (
export const test = editor => {
return Editor.above(editor, {
at: [0, 1, 0],
match: n => Editor.isInline(editor, n),
match: n => Element.isElement(n) && Editor.isInline(editor, n),
})
}

View File

@@ -1,5 +1,5 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { Editor, Element } from 'slate'
import { jsx } from '../../..'
export const input = (
@@ -19,7 +19,7 @@ const range = {
export const test = editor => {
return Editor.above(editor, {
at: range,
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
})
}
export const output = [

View File

@@ -1,5 +1,5 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { Editor, Element } from 'slate'
import { jsx } from '../../..'
export const input = (
@@ -9,6 +9,6 @@ export const input = (
)
export const test = editor => {
const block = editor.children[0]
return Editor.isBlock(editor, block)
return Element.isElement(block) && Editor.isBlock(editor, block)
}
export const output = true

View File

@@ -1,5 +1,5 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { Editor, Element } from 'slate'
import { jsx } from '../../..'
export const input = (
@@ -11,6 +11,6 @@ export const input = (
)
export const test = editor => {
const inline = editor.children[0].children[1]
return Editor.isBlock(editor, inline)
return Element.isElement(inline) && Editor.isBlock(editor, inline)
}
export const output = false

View File

@@ -1,5 +1,5 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { Editor, Element } from 'slate'
import { jsx } from '../../..'
export const input = (
@@ -11,7 +11,7 @@ export const input = (
export const test = editor => {
return Editor.next(editor, {
at: [0],
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
})
}
export const output = [<block>two</block>, [1]]

View File

@@ -1,5 +1,5 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { Editor, Element } from 'slate'
import { jsx } from '../../../..'
export const input = (
@@ -11,7 +11,7 @@ export const test = editor => {
return Array.from(
Editor.nodes(editor, {
at: [],
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
})
)
}

View File

@@ -1,5 +1,5 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { Editor, Element } from 'slate'
import { jsx } from '../../../..'
export const input = (
@@ -13,7 +13,7 @@ export const test = editor => {
return Array.from(
Editor.nodes(editor, {
at: [],
match: n => Editor.isInline(editor, n),
match: n => Element.isElement(n) && Editor.isInline(editor, n),
})
)
}

View File

@@ -1,5 +1,5 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { Editor, Element } from 'slate'
import { jsx } from '../../..'
export const input = (
@@ -11,7 +11,7 @@ export const input = (
export const test = editor => {
return Editor.previous(editor, {
at: [1],
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
})
}
export const output = [<block>one</block>, [0]]

View File

@@ -1,5 +1,5 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const input = (
@@ -12,7 +12,9 @@ export const input = (
</editor>
)
export const run = editor => {
Transforms.mergeNodes(editor, { match: n => Editor.isBlock(editor, n) })
Transforms.mergeNodes(editor, {
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
})
}
export const output = (
<editor>

View File

@@ -1,10 +1,10 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.moveNodes(editor, {
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
to: [1],
})
}

View File

@@ -1,10 +1,10 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.moveNodes(editor, {
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
to: [0],
})
}

View File

@@ -1,10 +1,10 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.moveNodes(editor, {
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
to: [2],
})
}

View File

@@ -1,10 +1,10 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.moveNodes(editor, {
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
to: [0],
})
}

View File

@@ -1,5 +1,5 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const input = (
@@ -13,7 +13,7 @@ export const input = (
)
export const run = editor => {
Transforms.moveNodes(editor, {
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
to: [1],
})
}

View File

@@ -1,12 +1,12 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.setNodes(
editor,
{ someKey: true },
{ match: n => Editor.isBlock(editor, n) }
{ match: n => Element.isElement(n) && Editor.isBlock(editor, n) }
)
}
export const input = (

View File

@@ -1,12 +1,12 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.setNodes(
editor,
{ someKey: true },
{ match: n => Editor.isBlock(editor, n) }
{ match: n => Element.isElement(n) && Editor.isBlock(editor, n) }
)
}
export const input = (

View File

@@ -1,12 +1,12 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.setNodes(
editor,
{ someKey: true },
{ match: n => Editor.isBlock(editor, n) }
{ match: n => Element.isElement(n) && Editor.isBlock(editor, n) }
)
}
export const input = (

View File

@@ -1,12 +1,12 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.setNodes(
editor,
{ someKey: true },
{ match: n => Editor.isBlock(editor, n) }
{ match: n => Element.isElement(n) && Editor.isBlock(editor, n) }
)
}
export const input = (

View File

@@ -1,12 +1,12 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.setNodes(
editor,
{ someKey: true },
{ match: n => Editor.isBlock(editor, n) }
{ match: n => Element.isElement(n) && Editor.isBlock(editor, n) }
)
}
export const input = (

View File

@@ -1,12 +1,12 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.setNodes(
editor,
{ someKey: true },
{ match: n => Editor.isInline(editor, n) }
{ match: n => Element.isElement(n) && Editor.isInline(editor, n) }
)
}
export const input = (

View File

@@ -1,12 +1,12 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.setNodes(
editor,
{ someKey: true },
{ match: n => Editor.isInline(editor, n) }
{ match: n => Element.isElement(n) && Editor.isInline(editor, n) }
)
}
export const input = (

View File

@@ -1,12 +1,12 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.setNodes(
editor,
{ someKey: true },
{ match: n => Editor.isInline(editor, n) }
{ match: n => Element.isElement(n) && Editor.isInline(editor, n) }
)
}
export const input = (

View File

@@ -1,12 +1,12 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.setNodes(
editor,
{ someKey: true },
{ match: n => Editor.isInline(editor, n) }
{ match: n => Element.isElement(n) && Editor.isInline(editor, n) }
)
}
export const input = (

View File

@@ -1,12 +1,12 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.setNodes(
editor,
{ someKey: true },
{ match: n => Editor.isInline(editor, n) }
{ match: n => Element.isElement(n) && Editor.isInline(editor, n) }
)
}
export const input = (

View File

@@ -1,12 +1,12 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.setNodes(
editor,
{ someKey: true },
{ match: n => Editor.isInline(editor, n) }
{ match: n => Element.isElement(n) && Editor.isInline(editor, n) }
)
}
export const input = (

View File

@@ -1,12 +1,12 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.setNodes(
editor,
{ someKey: true },
{ match: n => Editor.isInline(editor, n) }
{ match: n => Element.isElement(n) && Editor.isInline(editor, n) }
)
}
export const input = (

View File

@@ -1,10 +1,10 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.splitNodes(editor, {
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
always: true,
})
}

View File

@@ -1,10 +1,10 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.splitNodes(editor, {
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
always: true,
})
}

View File

@@ -1,10 +1,10 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.splitNodes(editor, {
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
always: true,
})
}

View File

@@ -1,10 +1,10 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.splitNodes(editor, {
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
always: true,
})
}

View File

@@ -1,10 +1,10 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.splitNodes(editor, {
match: n => Editor.isBlock(editor, n),
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
always: true,
})
}

View File

@@ -1,9 +1,11 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.splitNodes(editor, { match: n => Editor.isBlock(editor, n) })
Transforms.splitNodes(editor, {
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
})
}
export const input = (
<editor>

View File

@@ -1,9 +1,11 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.splitNodes(editor, { match: n => Editor.isBlock(editor, n) })
Transforms.splitNodes(editor, {
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
})
}
export const input = (
<editor>

View File

@@ -1,9 +1,11 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.splitNodes(editor, { match: n => Editor.isBlock(editor, n) })
Transforms.splitNodes(editor, {
match: n => Element.isElement(n) && Editor.isBlock(editor, n),
})
}
export const input = (
<editor>

View File

@@ -1,10 +1,12 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.splitNodes(editor, { match: n => Editor.isInline(editor, n) })
Transforms.splitNodes(editor, {
match: n => Element.isElement(n) && Editor.isInline(editor, n),
})
}
export const input = (

View File

@@ -1,11 +1,11 @@
/** @jsx jsx */
import { Editor, Transforms } from 'slate'
import { Editor, Transforms, Element } from 'slate'
import { jsx } from '../../..'
export const run = editor => {
Transforms.splitNodes(editor, {
at: { path: [0, 1, 0], offset: 2 },
match: n => Editor.isInline(editor, n),
match: n => Element.isElement(n) && Editor.isInline(editor, n),
})
}
export const input = (