Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

slate

Package Overview
Dependencies
Maintainers
5
Versions
748
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slate - npm Package Compare versions

Comparing version 0.93.1-202331812837 to 0.94.0-202332012421

dist/core/apply.d.ts

22

dist/index.d.ts

@@ -0,17 +1,9 @@

export * from './core';
export * from './create-editor';
export * from './interfaces/custom-types';
export * from './interfaces/editor';
export * from './interfaces/element';
export * from './interfaces/location';
export * from './interfaces/node';
export * from './interfaces/operation';
export * from './interfaces/path';
export * from './interfaces/path-ref';
export * from './interfaces/point';
export * from './interfaces/point-ref';
export * from './interfaces/range';
export * from './interfaces/range-ref';
export * from './interfaces/scrubber';
export * from './interfaces/text';
export * from './transforms';
export * from './editor';
export * from './interfaces';
export * from './transforms-node';
export * from './transforms-selection';
export * from './transforms-text';
export * from './types';
//# sourceMappingURL=index.d.ts.map

@@ -1,8 +0,5 @@

import { Ancestor, ExtendedType, Location, Node, NodeEntry, Operation, Path, PathRef, Point, PointRef, Range, RangeRef, Span, Text } from '..';
import { Element } from './element';
import { Descendant } from './node';
import { LeafEdge, MaximizeMode, RangeDirection, SelectionMode, TextDirection, TextUnit, TextUnitAdjustment } from './types';
export declare type BaseSelection = Range | null;
export declare type Selection = ExtendedType<'Selection', BaseSelection>;
export declare type EditorMarks = Omit<Text, 'text'>;
import { Ancestor, Descendant, Element, ExtendedType, Location, Node, NodeEntry, Operation, Path, PathRef, Point, PointRef, Range, RangeRef, Span, Text, Transforms } from '..';
import { LeafEdge, MaximizeMode, RangeDirection, SelectionMode, TextDirection, TextUnit, TextUnitAdjustment } from '../types/types';
import { OmitFirstArg } from '../utils/types';
import { TextInsertTextOptions } from './transforms/text';
/**

@@ -17,6 +14,7 @@ * The `Editor` interface stores all the state of a Slate editor. It is extended

marks: EditorMarks | null;
apply: (operation: Operation) => void;
getDirtyPaths: (operation: Operation) => Path[];
getFragment: () => Descendant[];
isElementReadOnly: (element: Element) => boolean;
isInline: (element: Element) => boolean;
isSelectable: (element: Element) => boolean;
isVoid: (element: Element) => boolean;
markableVoid: (element: Element) => boolean;

@@ -29,15 +27,2 @@ normalizeNode: (entry: NodeEntry, options?: {

}) => void;
addMark: (key: string, value: any) => void;
apply: (operation: Operation) => void;
deleteBackward: (unit: TextUnit) => void;
deleteForward: (unit: TextUnit) => void;
deleteFragment: (direction?: TextDirection) => void;
getFragment: () => Descendant[];
insertBreak: () => void;
insertSoftBreak: () => void;
insertFragment: (fragment: Node[]) => void;
insertNode: (node: Node) => void;
insertText: (text: string) => void;
removeMark: (key: string) => void;
getDirtyPaths: (operation: Operation) => Path[];
shouldNormalize: ({ iteration, dirtyPaths, operation, }: {

@@ -49,4 +34,89 @@ iteration: number;

}) => boolean;
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>;
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>;
}
export declare type Editor = ExtendedType<'Editor', BaseEditor>;
export declare type BaseSelection = Range | null;
export declare type Selection = ExtendedType<'Selection', BaseSelection>;
export declare type EditorMarks = Omit<Text, 'text'>;
export interface EditorAboveOptions<T extends Ancestor> {

@@ -157,60 +227,269 @@ at?: Location;

export interface EditorInterface {
/**
* Get the ancestor above a location in the document.
*/
above: <T extends Ancestor>(editor: Editor, options?: EditorAboveOptions<T>) => NodeEntry<T> | undefined;
/**
* Add a custom property to the leaf text nodes in the current selection.
*
* If the selection is currently collapsed, the marks will be added to the
* `editor.marks` property instead, and applied when text is inserted next.
*/
addMark: (editor: Editor, key: string, value: any) => void;
/**
* Get the point after a location.
*/
after: (editor: Editor, at: Location, options?: EditorAfterOptions) => Point | undefined;
/**
* Get the point before a location.
*/
before: (editor: Editor, at: Location, options?: EditorBeforeOptions) => Point | undefined;
/**
* Delete content in the editor backward from the current selection.
*/
deleteBackward: (editor: Editor, options?: EditorDirectedDeletionOptions) => void;
/**
* Delete content in the editor forward from the current selection.
*/
deleteForward: (editor: Editor, options?: EditorDirectedDeletionOptions) => void;
/**
* Delete the content in the current selection.
*/
deleteFragment: (editor: Editor, options?: EditorFragmentDeletionOptions) => void;
/**
* Get the start and end points of a location.
*/
edges: (editor: Editor, at: Location) => [Point, Point];
/**
* Match a read-only element in the current branch of the editor.
*/
elementReadOnly: (editor: Editor, options?: EditorElementReadOnlyOptions) => NodeEntry<Element> | undefined;
/**
* Get the end point of a location.
*/
end: (editor: Editor, at: Location) => Point;
/**
* Get the first node at a location.
*/
first: (editor: Editor, at: Location) => NodeEntry;
/**
* Get the fragment at a location.
*/
fragment: (editor: Editor, at: Location) => Descendant[];
/**
* Check if a node has block children.
*/
hasBlocks: (editor: Editor, element: Element) => boolean;
/**
* Check if a node has inline and text children.
*/
hasInlines: (editor: Editor, element: Element) => boolean;
hasPath: (editor: Editor, path: Path) => boolean;
/**
* Check if a node has text children.
*/
hasTexts: (editor: Editor, element: Element) => boolean;
/**
* Insert a block break at the current selection.
*
* If the selection is currently expanded, it will be deleted first.
*/
insertBreak: (editor: Editor) => void;
insertSoftBreak: (editor: Editor) => void;
/**
* Insert a fragment at the current selection.
*
* If the selection is currently expanded, it will be deleted first.
*/
insertFragment: (editor: Editor, fragment: Node[]) => void;
/**
* Insert a node at the current selection.
*
* If the selection is currently expanded, it will be deleted first.
*/
insertNode: (editor: Editor, node: Node) => void;
insertText: (editor: Editor, text: string) => void;
/**
* Insert a soft break at the current selection.
*
* If the selection is currently expanded, it will be deleted first.
*/
insertSoftBreak: (editor: Editor) => void;
/**
* Insert text at the current selection.
*
* If the selection is currently expanded, it will be deleted first.
*/
insertText: (editor: Editor, text: string, options?: TextInsertTextOptions) => void;
/**
* Check if a value is a block `Element` object.
*/
isBlock: (editor: Editor, value: Element) => boolean;
/**
* Check if a point is an edge of a location.
*/
isEdge: (editor: Editor, point: Point, at: Location) => boolean;
/**
* Check if a value is an `Editor` object.
*/
isEditor: (value: any) => value is Editor;
isEnd: (editor: Editor, point: Point, at: Location) => boolean;
isEdge: (editor: Editor, point: Point, at: Location) => boolean;
/**
* Check if a value is a read-only `Element` object.
*/
isElementReadOnly: (editor: Editor, element: Element) => boolean;
/**
* Check if an element is empty, accounting for void nodes.
*/
isEmpty: (editor: Editor, element: Element) => boolean;
/**
* Check if a point is the end point of a location.
*/
isEnd: (editor: Editor, point: Point, at: Location) => boolean;
/**
* Check if a value is an inline `Element` object.
*/
isInline: (editor: Editor, value: Element) => boolean;
/**
* Check if the editor is currently normalizing after each operation.
*/
isNormalizing: (editor: Editor) => boolean;
/**
* Check if a value is a selectable `Element` object.
*/
isSelectable: (editor: Editor, element: Element) => boolean;
/**
* Check if a point is the start point of a location.
*/
isStart: (editor: Editor, point: Point, at: Location) => boolean;
/**
* Check if a value is a void `Element` object.
*/
isVoid: (editor: Editor, value: Element) => boolean;
/**
* Get the last node at a location.
*/
last: (editor: Editor, at: Location) => NodeEntry;
/**
* Get the leaf text node at a location.
*/
leaf: (editor: Editor, at: Location, options?: EditorLeafOptions) => NodeEntry<Text>;
/**
* Iterate through all of the levels at a location.
*/
levels: <T extends Node>(editor: Editor, options?: EditorLevelsOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
/**
* Get the marks that would be added to text at the current selection.
*/
marks: (editor: Editor) => Omit<Text, 'text'> | null;
/**
* Get the matching node in the branch of the document after a location.
*/
next: <T extends Descendant>(editor: Editor, options?: EditorNextOptions<T>) => NodeEntry<T> | undefined;
/**
* Get the node at a location.
*/
node: (editor: Editor, at: Location, options?: EditorNodeOptions) => NodeEntry;
/**
* Iterate through all of the nodes in the Editor.
*/
nodes: <T extends Node>(editor: Editor, options?: EditorNodesOptions<T>) => Generator<NodeEntry<T>, void, undefined>;
/**
* Normalize any dirty objects in the editor.
*/
normalize: (editor: Editor, options?: EditorNormalizeOptions) => void;
/**
* Get the parent node of a location.
*/
parent: (editor: Editor, at: Location, options?: EditorParentOptions) => NodeEntry<Ancestor>;
/**
* Get the path of a location.
*/
path: (editor: Editor, at: Location, options?: EditorPathOptions) => Path;
/**
* Create a mutable ref for a `Path` object, which will stay in sync as new
* operations are applied to the editor.
*/
pathRef: (editor: Editor, path: Path, options?: EditorPathRefOptions) => PathRef;
/**
* Get the set of currently tracked path refs of the editor.
*/
pathRefs: (editor: Editor) => Set<PathRef>;
/**
* Get the start or end point of a location.
*/
point: (editor: Editor, at: Location, options?: EditorPointOptions) => Point;
/**
* Create a mutable ref for a `Point` object, which will stay in sync as new
* operations are applied to the editor.
*/
pointRef: (editor: Editor, point: Point, options?: EditorPointRefOptions) => PointRef;
/**
* Get the set of currently tracked point refs of the editor.
*/
pointRefs: (editor: Editor) => Set<PointRef>;
/**
* Return all the positions in `at` range where a `Point` can be placed.
*
* By default, moves forward by individual offsets at a time, but
* the `unit` option can be used to to move by character, word, line, or block.
*
* The `reverse` option can be used to change iteration direction.
*
* Note: By default void nodes are treated as a single point and iteration
* will not happen inside their content unless you pass in true for the
* `voids` option, then iteration will occur.
*/
positions: (editor: Editor, options?: EditorPositionsOptions) => Generator<Point, void, undefined>;
/**
* Get the matching node in the branch of the document before a location.
*/
previous: <T extends Node>(editor: Editor, options?: EditorPreviousOptions<T>) => NodeEntry<T> | undefined;
/**
* Get a range of a location.
*/
range: (editor: Editor, at: Location, to?: Location) => Range;
/**
* Create a mutable ref for a `Range` object, which will stay in sync as new
* operations are applied to the editor.
*/
rangeRef: (editor: Editor, range: Range, options?: EditorRangeRefOptions) => RangeRef;
/**
* Get the set of currently tracked range refs of the editor.
*/
rangeRefs: (editor: Editor) => Set<RangeRef>;
/**
* Remove a custom property from all of the leaf text nodes in the current
* selection.
*
* If the selection is currently collapsed, the removal will be stored on
* `editor.marks` and applied to the text inserted next.
*/
removeMark: (editor: Editor, key: string) => void;
/**
* Manually set if the editor should currently be normalizing.
*
* Note: Using this incorrectly can leave the editor in an invalid state.
*
*/
setNormalizing: (editor: Editor, isNormalizing: boolean) => void;
/**
* Get the start point of a location.
*/
start: (editor: Editor, at: Location) => Point;
/**
* Get the text string content of a location.
*
* Note: by default the text of void nodes is considered to be an empty
* string, regardless of content, unless you pass in true for the voids option
*/
string: (editor: Editor, at: Location, options?: EditorStringOptions) => string;
/**
* Convert a range into a non-hanging one.
*/
unhangRange: (editor: Editor, range: Range, options?: EditorUnhangRangeOptions) => Range;
/**
* Match a void node in the current branch of the editor.
*/
void: (editor: Editor, options?: EditorVoidOptions) => NodeEntry<Element> | undefined;
/**
* Call a function, deferring normalization until after it completes.
*/
withoutNormalizing: (editor: Editor, fn: () => void) => void;

@@ -217,0 +496,0 @@ }

@@ -1,2 +0,2 @@

import { Path, Descendant, ExtendedType, Ancestor } from '..';
import { Ancestor, Descendant, ExtendedType, Path } from '..';
/**

@@ -12,7 +12,29 @@ * `Element` objects are a type of node in a Slate document that contain other

export interface ElementInterface {
/**
* Check if a value implements the 'Ancestor' interface.
*/
isAncestor: (value: any) => value is Ancestor;
/**
* Check if a value implements the `Element` interface.
*/
isElement: (value: any) => value is Element;
/**
* Check if a value is an array of `Element` objects.
*/
isElementList: (value: any) => value is Element[];
/**
* Check if a set of props is a partial of Element.
*/
isElementProps: (props: any) => props is Partial<Element>;
/**
* Check if a value implements the `Element` interface and has elementKey with selected value.
* Default it check to `type` key value
*/
isElementType: <T extends Element>(value: any, elementVal: string, elementKey?: string) => value is T;
/**
* Check if an element matches set of properties.
*
* Note: this checks custom properties, and it does not ensure that any
* children are equivalent.
*/
matches: (element: Element, props: Partial<Element>) => boolean;

@@ -19,0 +41,0 @@ }

@@ -12,2 +12,5 @@ import { Path, Point, Range } from '..';

export interface LocationInterface {
/**
* Check if a value implements the `Location` interface.
*/
isLocation: (value: any) => value is Location;

@@ -22,2 +25,5 @@ }

export interface SpanInterface {
/**
* Check if a value implements the `Span` interface.
*/
isSpan: (value: any) => value is Span;

@@ -24,0 +30,0 @@ }

@@ -43,24 +43,108 @@ import { Editor, Path, Range, Text } from '..';

export interface NodeInterface {
/**
* Get the node at a specific path, asserting that it's an ancestor node.
*/
ancestor: (root: Node, path: Path) => Ancestor;
/**
* Return a generator of all the ancestor nodes above a specific path.
*
* By default the order is top-down, from highest to lowest ancestor in
* the tree, but you can pass the `reverse: true` option to go bottom-up.
*/
ancestors: (root: Node, path: Path, options?: NodeAncestorsOptions) => Generator<NodeEntry<Ancestor>, void, undefined>;
/**
* Get the child of a node at a specific index.
*/
child: (root: Node, index: number) => Descendant;
/**
* Iterate over the children of a node at a specific path.
*/
children: (root: Node, path: Path, options?: NodeChildrenOptions) => Generator<NodeEntry<Descendant>, void, undefined>;
/**
* Get an entry for the common ancesetor node of two paths.
*/
common: (root: Node, path: Path, another: Path) => NodeEntry;
/**
* Get the node at a specific path, asserting that it's a descendant node.
*/
descendant: (root: Node, path: Path) => Descendant;
/**
* Return a generator of all the descendant node entries inside a root node.
*/
descendants: (root: Node, options?: NodeDescendantsOptions) => Generator<NodeEntry<Descendant>, void, undefined>;
/**
* Return a generator of all the element nodes inside a root node. Each iteration
* will return an `ElementEntry` tuple consisting of `[Element, Path]`. If the
* root node is an element it will be included in the iteration as well.
*/
elements: (root: Node, options?: NodeElementsOptions) => Generator<ElementEntry, void, undefined>;
/**
* Extract props from a Node.
*/
extractProps: (node: Node) => NodeProps;
/**
* Get the first node entry in a root node from a path.
*/
first: (root: Node, path: Path) => NodeEntry;
/**
* Get the sliced fragment represented by a range inside a root node.
*/
fragment: (root: Node, range: Range) => Descendant[];
/**
* Get the descendant node referred to by a specific path. If the path is an
* empty array, it refers to the root node itself.
*/
get: (root: Node, path: Path) => Node;
/**
* Check if a descendant node exists at a specific path.
*/
has: (root: Node, path: Path) => boolean;
/**
* Check if a value implements the `Node` interface.
*/
isNode: (value: any) => value is Node;
/**
* Check if a value is a list of `Node` objects.
*/
isNodeList: (value: any) => value is Node[];
/**
* Get the last node entry in a root node from a path.
*/
last: (root: Node, path: Path) => NodeEntry;
/**
* Get the node at a specific path, ensuring it's a leaf text node.
*/
leaf: (root: Node, path: Path) => Text;
/**
* Return a generator of the in a branch of the tree, from a specific path.
*
* By default the order is top-down, from highest to lowest node in the tree,
* but you can pass the `reverse: true` option to go bottom-up.
*/
levels: (root: Node, path: Path, options?: NodeLevelsOptions) => Generator<NodeEntry, void, undefined>;
/**
* Check if a node matches a set of props.
*/
matches: (node: Node, props: Partial<Node>) => boolean;
/**
* Return a generator of all the node entries of a root node. Each entry is
* returned as a `[Node, Path]` tuple, with the path referring to the node's
* position inside the root node.
*/
nodes: (root: Node, options?: NodeNodesOptions) => Generator<NodeEntry, void, undefined>;
/**
* Get the parent of a node at a specific path.
*/
parent: (root: Node, path: Path) => Ancestor;
/**
* Get the concatenated text string of a node's content.
*
* Note that this will not include spaces or line breaks between block nodes.
* It is not a user-facing string, but a string for performing offset-related
* computations for a node.
*/
string: (node: Node) => string;
/**
* Return a generator of all leaf text nodes in a root node.
*/
texts: (root: Node, options?: NodeTextsOptions) => Generator<NodeEntry<Text>, void, undefined>;

@@ -67,0 +151,0 @@ }

@@ -81,7 +81,26 @@ import { ExtendedType, Node, Path, Range } from '..';

export interface OperationInterface {
/**
* Check if a value is a `NodeOperation` object.
*/
isNodeOperation: (value: any) => value is NodeOperation;
/**
* Check if a value is an `Operation` object.
*/
isOperation: (value: any) => value is Operation;
/**
* Check if a value is a list of `Operation` objects.
*/
isOperationList: (value: any) => value is Operation[];
/**
* Check if a value is a `SelectionOperation` object.
*/
isSelectionOperation: (value: any) => value is SelectionOperation;
/**
* Check if a value is a `TextOperation` object.
*/
isTextOperation: (value: any) => value is TextOperation;
/**
* Invert an operation, returning a new operation that will exactly undo the
* original when applied.
*/
inverse: (op: Operation) => Operation;

@@ -88,0 +107,0 @@ }

@@ -13,2 +13,5 @@ import { Operation, Path } from '..';

export interface PathRefInterface {
/**
* Transform the path ref's current value by an operation.
*/
transform: (ref: PathRef, op: Operation) => void;

@@ -15,0 +18,0 @@ }

@@ -1,3 +0,3 @@

import { InsertNodeOperation, MergeNodeOperation, MoveNodeOperation, RemoveNodeOperation, SplitNodeOperation, Operation } from '..';
import { TextDirection } from './types';
import { InsertNodeOperation, MergeNodeOperation, MoveNodeOperation, Operation, RemoveNodeOperation, SplitNodeOperation } from '..';
import { TextDirection } from '../types/types';
/**

@@ -19,25 +19,113 @@ * `Path` arrays are a list of indexes that describe a node's exact position in

export interface PathInterface {
/**
* Get a list of ancestor paths for a given path.
*
* The paths are sorted from shallowest to deepest ancestor. However, if the
* `reverse: true` option is passed, they are reversed.
*/
ancestors: (path: Path, options?: PathAncestorsOptions) => Path[];
/**
* Get the common ancestor path of two paths.
*/
common: (path: Path, another: Path) => Path;
/**
* Compare a path to another, returning an integer indicating whether the path
* was before, at, or after the other.
*
* Note: Two paths of unequal length can still receive a `0` result if one is
* directly above or below the other. If you want exact matching, use
* [[Path.equals]] instead.
*/
compare: (path: Path, another: Path) => -1 | 0 | 1;
/**
* Check if a path ends after one of the indexes in another.
*/
endsAfter: (path: Path, another: Path) => boolean;
/**
* Check if a path ends at one of the indexes in another.
*/
endsAt: (path: Path, another: Path) => boolean;
/**
* Check if a path ends before one of the indexes in another.
*/
endsBefore: (path: Path, another: Path) => boolean;
/**
* Check if a path is exactly equal to another.
*/
equals: (path: Path, another: Path) => boolean;
/**
* Check if the path of previous sibling node exists
*/
hasPrevious: (path: Path) => boolean;
/**
* Check if a path is after another.
*/
isAfter: (path: Path, another: Path) => boolean;
/**
* Check if a path is an ancestor of another.
*/
isAncestor: (path: Path, another: Path) => boolean;
/**
* Check if a path is before another.
*/
isBefore: (path: Path, another: Path) => boolean;
/**
* Check if a path is a child of another.
*/
isChild: (path: Path, another: Path) => boolean;
/**
* Check if a path is equal to or an ancestor of another.
*/
isCommon: (path: Path, another: Path) => boolean;
/**
* Check if a path is a descendant of another.
*/
isDescendant: (path: Path, another: Path) => boolean;
/**
* Check if a path is the parent of another.
*/
isParent: (path: Path, another: Path) => boolean;
/**
* Check is a value implements the `Path` interface.
*/
isPath: (value: any) => value is Path;
/**
* Check if a path is a sibling of another.
*/
isSibling: (path: Path, another: Path) => boolean;
/**
* Get a list of paths at every level down to a path. Note: this is the same
* as `Path.ancestors`, but including the path itself.
*
* The paths are sorted from shallowest to deepest. However, if the `reverse:
* true` option is passed, they are reversed.
*/
levels: (path: Path, options?: PathLevelsOptions) => Path[];
/**
* Given a path, get the path to the next sibling node.
*/
next: (path: Path) => Path;
/**
* Returns whether this operation can affect paths or not. Used as an
* optimization when updating dirty paths during normalization
*
* NOTE: This *must* be kept in sync with the implementation of 'transform'
* below
*/
operationCanTransformPath: (operation: Operation) => operation is InsertNodeOperation | RemoveNodeOperation | MergeNodeOperation | SplitNodeOperation | MoveNodeOperation;
/**
* Given a path, return a new path referring to the parent node above it.
*/
parent: (path: Path) => Path;
/**
* Given a path, get the path to the previous sibling node.
*/
previous: (path: Path) => Path;
/**
* Get a path relative to an ancestor.
*/
relative: (path: Path, ancestor: Path) => Path;
/**
* Transform a path by an operation.
*/
transform: (path: Path, operation: Operation, options?: PathTransformOptions) => Path | null;

@@ -44,0 +132,0 @@ }

import { Operation, Point } from '..';
import { TextDirection } from './types';
import { TextDirection } from '../types/types';
/**

@@ -14,2 +14,5 @@ * `PointRef` objects keep a specific point in a document synced over time as new

export interface PointRefInterface {
/**
* Transform the point ref's current value by an operation.
*/
transform: (ref: PointRef, op: Operation) => void;

@@ -16,0 +19,0 @@ }

import { ExtendedType, Operation, Path } from '..';
import { TextDirection } from './types';
import { TextDirection } from '../types/types';
/**

@@ -18,7 +18,26 @@ * `Point` objects refer to a specific location in a text node in a Slate

export interface PointInterface {
/**
* Compare a point to another, returning an integer indicating whether the
* point was before, at, or after the other.
*/
compare: (point: Point, another: Point) => -1 | 0 | 1;
/**
* Check if a point is after another.
*/
isAfter: (point: Point, another: Point) => boolean;
/**
* Check if a point is before another.
*/
isBefore: (point: Point, another: Point) => boolean;
/**
* Check if a point is exactly equal to another.
*/
equals: (point: Point, another: Point) => boolean;
/**
* Check if a value implements the `Point` interface.
*/
isPoint: (value: any) => value is Point;
/**
* Transform a point by an operation.
*/
transform: (point: Point, op: Operation, options?: PointTransformOptions) => Point | null;

@@ -25,0 +44,0 @@ }

@@ -13,2 +13,5 @@ import { Operation, Range } from '..';

export interface RangeRefInterface {
/**
* Transform the range ref's current value by an operation.
*/
transform: (ref: RangeRef, op: Operation) => void;

@@ -15,0 +18,0 @@ }

import { ExtendedType, Operation, Path, Point, PointEntry } from '..';
import { RangeDirection } from './types';
import { RangeDirection } from '../types/types';
/**

@@ -20,14 +20,60 @@ * `Range` objects are a set of points that refer to a specific span of a Slate

export interface RangeInterface {
/**
* Get the start and end points of a range, in the order in which they appear
* in the document.
*/
edges: (range: Range, options?: RangeEdgesOptions) => [Point, Point];
/**
* Get the end point of a range.
*/
end: (range: Range) => Point;
/**
* Check if a range is exactly equal to another.
*/
equals: (range: Range, another: Range) => boolean;
/**
* Check if a range includes a path, a point or part of another range.
*/
includes: (range: Range, target: Path | Point | Range) => boolean;
/**
* Get the intersection of a range with another.
*/
intersection: (range: Range, another: Range) => Range | null;
/**
* Check if a range is backward, meaning that its anchor point appears in the
* document _after_ its focus point.
*/
isBackward: (range: Range) => boolean;
/**
* Check if a range is collapsed, meaning that both its anchor and focus
* points refer to the exact same position in the document.
*/
isCollapsed: (range: Range) => boolean;
/**
* Check if a range is expanded.
*
* This is the opposite of [[Range.isCollapsed]] and is provided for legibility.
*/
isExpanded: (range: Range) => boolean;
/**
* Check if a range is forward.
*
* This is the opposite of [[Range.isBackward]] and is provided for legibility.
*/
isForward: (range: Range) => boolean;
/**
* Check if a value implements the [[Range]] interface.
*/
isRange: (value: any) => value is Range;
/**
* Iterate through all of the point entries in a range.
*/
points: (range: Range) => Generator<PointEntry, void, undefined>;
/**
* Get the start point of a range.
*/
start: (range: Range) => Point;
/**
* Transform a range by an operation.
*/
transform: (range: Range, op: Operation, options?: RangeTransformOptions) => Range | null;

@@ -34,0 +80,0 @@ }

import { Range } from '..';
import { ExtendedType } from './custom-types';
import { ExtendedType } from '../types/custom-types';
/**

@@ -16,7 +16,31 @@ * `Text` objects represent the nodes that contain the actual text content of a

export interface TextInterface {
/**
* Check if two text nodes are equal.
*
* When loose is set, the text is not compared. This is
* used to check whether sibling text nodes can be merged.
*/
equals: (text: Text, another: Text, options?: TextEqualsOptions) => boolean;
/**
* Check if a value implements the `Text` interface.
*/
isText: (value: any) => value is Text;
/**
* Check if a value is a list of `Text` objects.
*/
isTextList: (value: any) => value is Text[];
/**
* Check if some props are a partial of Text.
*/
isTextProps: (props: any) => props is Partial<Text>;
/**
* Check if an text matches set of properties.
*
* Note: this is for matching custom properties, and it does not ensure that
* the `text` property are two nodes equal.
*/
matches: (text: Text, props: Partial<Text>) => boolean;
/**
* Get the leaves for a text node given decorations.
*/
decorations: (node: Text, decorations: Range[]) => Text[];

@@ -23,0 +47,0 @@ }

{
"name": "slate",
"description": "A completely customizable framework for building rich text editors.",
"version": "0.93.1-202331812837",
"version": "0.94.0-202332012421",
"license": "MIT",

@@ -24,3 +24,3 @@ "repository": "git://github.com/ianstormtaylor/slate.git",

"lodash": "^4.17.21",
"slate-hyperscript": "^0.81.3",
"slate-hyperscript": "^0.81.3-202332012421",
"source-map-loader": "^4.0.0"

@@ -27,0 +27,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc