mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-16 20:24:01 +02:00
implement scrubber for end user data in exceptions (#4999)
This commit is contained in:
committed by
GitHub
parent
25be3b7031
commit
fe13a8f9e7
@@ -1,5 +1,5 @@
|
||||
import React, { useMemo, useState, useCallback, useEffect, useRef } from 'react'
|
||||
import { Editor, Node, Element, Descendant } from 'slate'
|
||||
import React, { useState, useCallback, useEffect, useRef } from 'react'
|
||||
import { Editor, Node, Descendant, Scrubber } from 'slate'
|
||||
import { ReactEditor } from '../plugin/react-editor'
|
||||
import { FocusedContext } from '../hooks/use-focused'
|
||||
import { EditorContext } from '../hooks/use-slate-static'
|
||||
@@ -30,12 +30,13 @@ export const Slate = (props: {
|
||||
if (!Node.isNodeList(value)) {
|
||||
throw new Error(
|
||||
`[Slate] value is invalid! Expected a list of elements` +
|
||||
`but got: ${JSON.stringify(value)}`
|
||||
`but got: ${Scrubber.stringify(value)}`
|
||||
)
|
||||
}
|
||||
if (!Editor.isEditor(editor)) {
|
||||
throw new Error(
|
||||
`[Slate] editor is invalid! you passed:` + `${JSON.stringify(editor)}`
|
||||
`[Slate] editor is invalid! you passed:` +
|
||||
`${Scrubber.stringify(editor)}`
|
||||
)
|
||||
}
|
||||
editor.children = value
|
||||
|
@@ -1,4 +1,13 @@
|
||||
import { Editor, Node, Path, Point, Range, Transforms, BaseEditor } from 'slate'
|
||||
import {
|
||||
BaseEditor,
|
||||
Editor,
|
||||
Node,
|
||||
Path,
|
||||
Point,
|
||||
Range,
|
||||
Scrubber,
|
||||
Transforms,
|
||||
} from 'slate'
|
||||
|
||||
import { Key } from '../utils/key'
|
||||
import {
|
||||
@@ -108,7 +117,7 @@ export const ReactEditor = {
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Unable to find the path for Slate node: ${JSON.stringify(node)}`
|
||||
`Unable to find the path for Slate node: ${Scrubber.stringify(node)}`
|
||||
)
|
||||
},
|
||||
|
||||
@@ -285,7 +294,7 @@ export const ReactEditor = {
|
||||
|
||||
if (!domNode) {
|
||||
throw new Error(
|
||||
`Cannot resolve a DOM node from Slate node: ${JSON.stringify(node)}`
|
||||
`Cannot resolve a DOM node from Slate node: ${Scrubber.stringify(node)}`
|
||||
)
|
||||
}
|
||||
|
||||
@@ -337,7 +346,9 @@ export const ReactEditor = {
|
||||
|
||||
if (!domPoint) {
|
||||
throw new Error(
|
||||
`Cannot resolve a DOM point from Slate point: ${JSON.stringify(point)}`
|
||||
`Cannot resolve a DOM point from Slate point: ${Scrubber.stringify(
|
||||
point
|
||||
)}`
|
||||
)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user