A completely customizable framework for building rich text editors. (Currently in beta.)
MIT License
Bot releases are visible (Hide)
Published by github-actions[bot] 12 months ago
Published by github-actions[bot] 12 months ago
Published by github-actions[bot] 12 months ago
Published by github-actions[bot] about 1 year ago
Published by github-actions[bot] about 1 year ago
13c7d271
Thanks @e1himself! - Remove an unused React refPublished by github-actions[bot] about 1 year ago
e308cd66
Thanks @janpaepke! - bugfix: slate breaks on load on safari < 16.4Published by github-actions[bot] about 1 year ago
76ba3759
Thanks @Dimitri-WEI-Lingfeng! - fix the bug that user cannot input chinese on mac wechat browser.Published by github-actions[bot] about 1 year ago
a5576e56
Thanks @WcaleNieWolny! - Fix firefox table selection if table is contentedtiablePublished by github-actions[bot] about 1 year ago
8b548fb5
Thanks @WcaleNieWolny! - Fix invalid usage of the selection API in firefoxPublished by github-actions[bot] over 1 year ago
Published by github-actions[bot] over 1 year ago
Published by github-actions[bot] over 1 year ago
Published by github-actions[bot] over 1 year ago
#5422 0b179909
Thanks @Chudesnov! - Prevents default focus styles from being removed in Editable
#5421 91e388ec
Thanks @e1himself! - Rename <Slate>
component prop from value
to initialValue
to emphasize uncontrolled nature of it
Published by github-actions[bot] over 1 year ago
Published by github-actions[bot] over 1 year ago
Published by github-actions[bot] over 1 year ago
Published by github-actions[bot] over 1 year ago
#5307 3243c7e3
Thanks @zbeyens! - New Features:
Editor
and Transforms
methods now call editor
methods. For example: Transforms.insertBreak
now calls editor.insertBreak
.editor.setNodes
now calls setNodes
, an exported function that implements the default editor behavior.editor.setNodes
with your own implementation.Editor.setNodes
or editor.setNodes
in your code, and both will use your overridden behavior.The editor
object now has many more methods:
export interface BaseEditor {
// Core state.
children: Descendant[]
selection: Selection
operations: Operation[]
marks: EditorMarks | null
// Overrideable core methods.
apply: (operation: Operation) => void
getDirtyPaths: (operation: Operation) => Path[]
getFragment: () => Descendant[]
isElementReadOnly: (element: Element) => boolean
isSelectable: (element: Element) => boolean
markableVoid: (element: Element) => boolean
normalizeNode: (
entry: NodeEntry,
options?: { operation?: Operation }
) => void
onChange: (options?: { operation?: Operation }) => void
shouldNormalize: ({
iteration,
dirtyPaths,
operation,
}: {
iteration: number
initialDirtyPathsLength: number
dirtyPaths: Path[]
operation?: Operation
}) => boolean
// Overrideable core transforms.
addMark: OmitFirstArg<typeof Editor.addMark>
collapse: OmitFirstArg<typeof Transforms.collapse>
delete: OmitFirstArg<typeof Transforms.delete>
deleteBackward: (unit: TextUnit) => void
deleteForward: (unit: TextUnit) => void
deleteFragment: OmitFirstArg<typeof Editor.deleteFragment>
deselect: OmitFirstArg<typeof Transforms.deselect>
insertBreak: OmitFirstArg<typeof Editor.insertBreak>
insertFragment: OmitFirstArg<typeof Transforms.insertFragment>
insertNode: OmitFirstArg<typeof Editor.insertNode>
insertNodes: OmitFirstArg<typeof Transforms.insertNodes>
insertSoftBreak: OmitFirstArg<typeof Editor.insertSoftBreak>
insertText: OmitFirstArg<typeof Transforms.insertText>
liftNodes: OmitFirstArg<typeof Transforms.liftNodes>
mergeNodes: OmitFirstArg<typeof Transforms.mergeNodes>
move: OmitFirstArg<typeof Transforms.move>
moveNodes: OmitFirstArg<typeof Transforms.moveNodes>
normalize: OmitFirstArg<typeof Editor.normalize>
removeMark: OmitFirstArg<typeof Editor.removeMark>
removeNodes: OmitFirstArg<typeof Transforms.removeNodes>
select: OmitFirstArg<typeof Transforms.select>
setNodes: <T extends Node>(
props: Partial<T>,
options?: {
at?: Location
match?: NodeMatch<T>
mode?: MaximizeMode
hanging?: boolean
split?: boolean
voids?: boolean
compare?: PropsCompare
merge?: PropsMerge
}
) => void
setNormalizing: OmitFirstArg<typeof Editor.setNormalizing>
setPoint: OmitFirstArg<typeof Transforms.setPoint>
setSelection: OmitFirstArg<typeof Transforms.setSelection>
splitNodes: OmitFirstArg<typeof Transforms.splitNodes>
unsetNodes: OmitFirstArg<typeof Transforms.unsetNodes>
unwrapNodes: OmitFirstArg<typeof Transforms.unwrapNodes>
withoutNormalizing: OmitFirstArg<typeof Editor.withoutNormalizing>
wrapNodes: OmitFirstArg<typeof Transforms.wrapNodes>
// Overrideable core queries.
above: <T extends Ancestor>(
options?: EditorAboveOptions<T>
) => NodeEntry<T> | undefined
after: OmitFirstArg<typeof Editor.after>
before: OmitFirstArg<typeof Editor.before>
edges: OmitFirstArg<typeof Editor.edges>
elementReadOnly: OmitFirstArg<typeof Editor.elementReadOnly>
end: OmitFirstArg<typeof Editor.end>
first: OmitFirstArg<typeof Editor.first>
fragment: OmitFirstArg<typeof Editor.fragment>
getMarks: OmitFirstArg<typeof Editor.marks>
hasBlocks: OmitFirstArg<typeof Editor.hasBlocks>
hasInlines: OmitFirstArg<typeof Editor.hasInlines>
hasPath: OmitFirstArg<typeof Editor.hasPath>
hasTexts: OmitFirstArg<typeof Editor.hasTexts>
isBlock: OmitFirstArg<typeof Editor.isBlock>
isEdge: OmitFirstArg<typeof Editor.isEdge>
isEmpty: OmitFirstArg<typeof Editor.isEmpty>
isEnd: OmitFirstArg<typeof Editor.isEnd>
isInline: OmitFirstArg<typeof Editor.isInline>
isNormalizing: OmitFirstArg<typeof Editor.isNormalizing>
isStart: OmitFirstArg<typeof Editor.isStart>
isVoid: OmitFirstArg<typeof Editor.isVoid>
last: OmitFirstArg<typeof Editor.last>
leaf: OmitFirstArg<typeof Editor.leaf>
levels: <T extends Node>(
options?: EditorLevelsOptions<T>
) => Generator<NodeEntry<T>, void, undefined>
next: <T extends Descendant>(
options?: EditorNextOptions<T>
) => NodeEntry<T> | undefined
node: OmitFirstArg<typeof Editor.node>
nodes: <T extends Node>(
options?: EditorNodesOptions<T>
) => Generator<NodeEntry<T>, void, undefined>
parent: OmitFirstArg<typeof Editor.parent>
path: OmitFirstArg<typeof Editor.path>
pathRef: OmitFirstArg<typeof Editor.pathRef>
pathRefs: OmitFirstArg<typeof Editor.pathRefs>
point: OmitFirstArg<typeof Editor.point>
pointRef: OmitFirstArg<typeof Editor.pointRef>
pointRefs: OmitFirstArg<typeof Editor.pointRefs>
positions: OmitFirstArg<typeof Editor.positions>
previous: <T extends Node>(
options?: EditorPreviousOptions<T>
) => NodeEntry<T> | undefined
range: OmitFirstArg<typeof Editor.range>
rangeRef: OmitFirstArg<typeof Editor.rangeRef>
rangeRefs: OmitFirstArg<typeof Editor.rangeRefs>
start: OmitFirstArg<typeof Editor.start>
string: OmitFirstArg<typeof Editor.string>
unhangRange: OmitFirstArg<typeof Editor.unhangRange>
void: OmitFirstArg<typeof Editor.void>
}
Note:
getMarks
is an exception, as there is already editor.marks
that stores the current marks.Transforms.insertText
has not been moved to editor
yet: there is already an editor.insertText
method with extended behavior. This may change in a future release, but this release is trying to avoid any breaking changes.editor.insertText
has a new argument (third): options?: TextInsertTextOptions
to match Transforms.insertText
.Bug Fixes:
Published by github-actions[bot] over 1 year ago
Published by github-actions[bot] over 1 year ago
#5374 b52e08b0
Thanks @12joan! - - Add isSelectable
to editor
(default true). A non-selectable element is skipped over when navigating using arrow keys.
ignoreNonSelectable
to Editor.nodes
, Editor.positions
, Editor.after
and Editor.before
(default false)Transforms.move
ignores non-selectable elements#5374 b52e08b0
Thanks @12joan! - - Add isElementReadOnly
to editor
. A read-only element behaves much like a void with regard to selection and deletion, but renders its children
the same as any other non-void node.