mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-09-03 04:02:33 +02:00
fix: isVoid, isBlock, isInline types (#5254)
* fix: isVoid, isBlock, isInline types * fix: remove isElement check with isEditor
This commit is contained in:
@@ -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),
|
||||
})
|
||||
},
|
||||
|
||||
|
@@ -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,
|
||||
|
@@ -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,
|
||||
})
|
||||
|
@@ -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',
|
||||
})
|
||||
}
|
||||
|
@@ -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',
|
||||
})
|
||||
}
|
||||
|
@@ -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),
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -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 = [
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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]]
|
||||
|
@@ -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),
|
||||
})
|
||||
)
|
||||
}
|
||||
|
@@ -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),
|
||||
})
|
||||
)
|
||||
}
|
||||
|
@@ -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]]
|
||||
|
@@ -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>
|
||||
|
@@ -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],
|
||||
})
|
||||
}
|
||||
|
@@ -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],
|
||||
})
|
||||
}
|
||||
|
@@ -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],
|
||||
})
|
||||
}
|
||||
|
@@ -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],
|
||||
})
|
||||
}
|
||||
|
@@ -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],
|
||||
})
|
||||
}
|
||||
|
@@ -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 = (
|
||||
|
@@ -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 = (
|
||||
|
@@ -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 = (
|
||||
|
@@ -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 = (
|
||||
|
@@ -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 = (
|
||||
|
@@ -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 = (
|
||||
|
@@ -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 = (
|
||||
|
@@ -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 = (
|
||||
|
@@ -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 = (
|
||||
|
@@ -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 = (
|
||||
|
@@ -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 = (
|
||||
|
@@ -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 = (
|
||||
|
@@ -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,
|
||||
})
|
||||
}
|
||||
|
@@ -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,
|
||||
})
|
||||
}
|
||||
|
@@ -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,
|
||||
})
|
||||
}
|
||||
|
@@ -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,
|
||||
})
|
||||
}
|
||||
|
@@ -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,
|
||||
})
|
||||
}
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
@@ -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 = (
|
||||
|
@@ -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 = (
|
||||
|
Reference in New Issue
Block a user