@udecode/slate
Advanced tools
Comparing version 37.0.0 to 38.0.3
@@ -6,3 +6,2 @@ import { UnknownObject, Simplify, UnionToIntersection, Modify } from '@udecode/utils'; | ||
import { EditorPathRefOptions, EditorPointRefOptions, EditorRangeRefOptions, EditorDirectedDeletionOptions, EditorFragmentDeletionOptions, EditorAboveOptions, EditorStringOptions, EditorLeafOptions } from 'slate/dist/interfaces/editor'; | ||
import * as slate_dist_interfaces_path from 'slate/dist/interfaces/path'; | ||
import { SelectionCollapseOptions, SelectionMoveOptions, SelectionSetPointOptions } from 'slate/dist/interfaces/transforms/selection'; | ||
@@ -190,4 +189,6 @@ import { TextDeleteOptions, TextInsertFragmentOptions, TextInsertTextOptions } from 'slate/dist/interfaces/transforms/text'; | ||
hasEditableTarget: (editor: TEditor<V>, target: EventTarget | null) => target is Node; | ||
hasSelectableTarget: (editor: TEditor<V>, target: EventTarget | null) => boolean; | ||
isTargetInsideNonReadonlyVoid: (editor: TEditor<V>, target: EventTarget | null) => boolean; | ||
setFragmentData: (data: DataTransfer, originEvent?: 'copy' | 'cut' | 'drag') => void; | ||
hasRange: (editor: TEditor<V>, range: Range) => boolean; | ||
hasSelectableTarget: (editor: TEditor<V>, target: EventTarget | null) => boolean; | ||
hasTarget: (editor: TEditor<V>, target: EventTarget | null) => target is Node; | ||
@@ -197,5 +198,4 @@ insertData: (data: DataTransfer) => void; | ||
insertTextData: (data: DataTransfer) => boolean; | ||
isTargetInsideNonReadonlyVoid: (editor: TEditor<V>, target: EventTarget | null) => boolean; | ||
setFragmentData: (data: DataTransfer, originEvent?: 'copy' | 'cut' | 'drag') => void; | ||
} & Modify<Editor, { | ||
id: any; | ||
apply: <N extends TDescendant>(operation: TOperation<N>) => void; | ||
@@ -205,3 +205,2 @@ children: V; | ||
getFragment: () => TDescendant[]; | ||
id: any; | ||
insertFragment: <N extends TDescendant>(fragment: N[]) => void; | ||
@@ -212,6 +211,6 @@ insertNode: <N extends TDescendant>(node: N) => void; | ||
markableVoid: <N extends TElement>(element: N) => boolean; | ||
marks: Record<string, any> | null; | ||
normalizeNode: <N extends TNode>(entry: TNodeEntry<N>, options?: { | ||
operation?: TOperation; | ||
}) => void; | ||
marks: Record<string, any> | null; | ||
operations: TOperation[]; | ||
@@ -263,7 +262,7 @@ }> & Pick<HistoryEditor, 'history' | 'redo' | 'undo' | 'writeHistory'> & UnknownObject; | ||
test?: any; | ||
unit?: 'block' | 'character' | 'line' | 'word'; | ||
unit?: "block" | "character" | "line" | "word"; | ||
voids?: boolean; | ||
}) => void; | ||
type PredicateObj = Record<string, any | any[]>; | ||
type PredicateObj = Record<string, any[] | any>; | ||
type PredicateFn<T extends TNode> = (obj: T, path: TPath) => boolean; | ||
@@ -277,3 +276,3 @@ type Predicate<T extends TNode> = PredicateFn<T> | PredicateObj; | ||
*/ | ||
declare const match: <T extends TNode>(obj: T, path: slate_dist_interfaces_path.Path, predicate?: Predicate<T>) => boolean; | ||
declare const match: <T extends TNode>(obj: T, path: TPath, predicate?: Predicate<T>) => boolean; | ||
/** | ||
@@ -364,5 +363,5 @@ * Extended query options for slate queries: | ||
/** Return a generator of all the descendant node entries inside a root node. */ | ||
declare const getNodeDescendants: <N extends DescendantOf<R>, R extends TNode = TNode>(root: R, options?: Modify<NodeDescendantsOptions, { | ||
pass?: ((node: TDescendantEntry<N>) => boolean) | undefined; | ||
}> | undefined) => Generator<TNodeEntry<N>, void, undefined>; | ||
declare const getNodeDescendants: <N extends DescendantOf<R>, R extends TNode = TNode>(root: R, options?: Modify<NonNullable<NodeDescendantsOptions>, { | ||
pass?: (node: TDescendantEntry<N>) => boolean; | ||
}>) => Generator<TNodeEntry<N>, void, undefined>; | ||
@@ -375,5 +374,5 @@ /** | ||
*/ | ||
declare const getNodeElements: <N extends ElementOf<R>, R extends TNode = TNode>(root: R, options?: Modify<NodeElementsOptions, { | ||
pass?: ((node: TElementEntry<N>) => boolean) | undefined; | ||
}> | undefined) => Generator<TNodeEntry<N>, void, undefined>; | ||
declare const getNodeElements: <N extends ElementOf<R>, R extends TNode = TNode>(root: R, options?: Modify<NonNullable<NodeElementsOptions>, { | ||
pass?: (node: TElementEntry<N>) => boolean; | ||
}>) => Generator<TNodeEntry<N>, void, undefined>; | ||
@@ -416,5 +415,5 @@ /** Get the first node entry in a root node from a path. */ | ||
/** Return a generator of all leaf text nodes in a root node. */ | ||
declare const getNodeTexts: <N extends TextOf<R>, R extends TNode = TNode>(root: R, options?: Modify<NodeTextsOptions, { | ||
pass?: ((entry: TNodeEntry<NodeOf<N>>) => boolean) | undefined; | ||
}> | undefined) => Generator<TNodeEntry<N>, void, undefined>; | ||
declare const getNodeTexts: <N extends TextOf<R>, R extends TNode = TNode>(root: R, options?: Modify<NonNullable<NodeTextsOptions>, { | ||
pass?: (entry: TNodeEntry<NodeOf<N>>) => boolean; | ||
}>) => Generator<TNodeEntry<N>, void, undefined>; | ||
@@ -426,5 +425,5 @@ /** | ||
*/ | ||
declare const getNodes: <N extends NodeOf<R>, R extends TNode = TNode>(root: R, options?: Modify<NodeNodesOptions, { | ||
pass?: ((entry: TNodeEntry<NodeOf<N>>) => boolean) | undefined; | ||
}> | undefined) => Generator<TNodeEntry<N>, void, undefined>; | ||
declare const getNodes: <N extends NodeOf<R>, R extends TNode = TNode>(root: R, options?: Modify<NonNullable<NodeNodesOptions>, { | ||
pass?: (entry: TNodeEntry<NodeOf<N>>) => boolean; | ||
}>) => Generator<TNodeEntry<N>, void, undefined>; | ||
@@ -463,3 +462,3 @@ /** Check if a descendant node exists at a specific path. */ | ||
*/ | ||
declare const unhangRange: <E extends TEditor, R extends Path | slate.BasePoint | slate.BaseRange | Span | null | undefined>(editor: E, range: R, options?: UnhangRangeOptions) => R; | ||
declare const unhangRange: <E extends TEditor, R extends Path | Point | Range | Span | null | undefined>(editor: E, range: R, options?: UnhangRangeOptions) => R; | ||
@@ -675,11 +674,11 @@ type GetNodeEntriesOptions<E extends TEditor = TEditor> = Modify<NonNullable<EditorNodesOptions<TNode>>, ENodeMatchOptions<E>> & UnhangRangeOptions; | ||
/** List of types that are valid. If empty or undefined - allow all. */ | ||
allow?: null | string | string[]; | ||
allow?: string[] | string | null; | ||
/** List of types that are invalid. */ | ||
exclude?: null | string | string[]; | ||
exclude?: string[] | string | null; | ||
/** Query the node entry. */ | ||
filter?: <N extends TNode>(entry: TNodeEntry<N>) => boolean; | ||
/** Valid path levels. */ | ||
level?: null | number | number[]; | ||
level?: number[] | number | null; | ||
/** Paths above that value are invalid. */ | ||
maxLevel?: null | number; | ||
maxLevel?: number | null; | ||
} | ||
@@ -806,3 +805,3 @@ | ||
declare const addRangeMarks: (editor: TEditor, props: any, { at, }?: { | ||
at?: Location | null | undefined; | ||
at?: Location | null; | ||
}) => void; | ||
@@ -809,0 +808,0 @@ |
@@ -265,4 +265,3 @@ "use strict"; | ||
var match = (obj, path, predicate) => { | ||
if (!predicate) | ||
return true; | ||
if (!predicate) return true; | ||
if (typeof predicate === "object") { | ||
@@ -628,7 +627,6 @@ return Object.entries(predicate).every(([key, value]) => { | ||
var getEditorString = (editor, at, options) => { | ||
if (!at) | ||
return ""; | ||
if (!at) return ""; | ||
try { | ||
return import_slate35.Editor.string(editor, at, options); | ||
} catch (error) { | ||
} catch (e) { | ||
return ""; | ||
@@ -933,4 +931,3 @@ } | ||
var queryNode = (entry, { allow, exclude, filter, level, maxLevel } = {}) => { | ||
if (!entry) | ||
return false; | ||
if (!entry) return false; | ||
const [node, path] = entry; | ||
@@ -976,7 +973,5 @@ if (level) { | ||
queryNodeOptions.filter = ([node, path]) => { | ||
if (getNodeString(node)) | ||
return false; | ||
if (getNodeString(node)) return false; | ||
const children = node.children; | ||
if (children.some((n) => isInline(editor, n))) | ||
return false; | ||
if (children.some((n) => isInline(editor, n))) return false; | ||
return !filter || filter([node, path]); | ||
@@ -1095,4 +1090,3 @@ }; | ||
const parentEntry = import_slate105.Editor.parent(editor, path); | ||
if (!parentEntry) | ||
return false; | ||
if (!parentEntry) return false; | ||
const [parentNode] = parentEntry; | ||
@@ -1105,9 +1099,7 @@ return !editor.isVoid(parentNode) || editor.markableVoid(parentNode); | ||
const selectedEntry = import_slate105.Editor.node(editor, at); | ||
if (!selectedEntry) | ||
return; | ||
if (!selectedEntry) return; | ||
const [selectedNode, selectedPath] = selectedEntry; | ||
if (selectedNode && match2(selectedNode, selectedPath)) { | ||
const parentEntry = import_slate105.Editor.parent(editor, selectedPath); | ||
if (!parentEntry) | ||
return; | ||
if (!parentEntry) return; | ||
const [parentNode] = parentEntry; | ||
@@ -1114,0 +1106,0 @@ markAcceptingVoidSelected = parentNode && editor.markableVoid(parentNode); |
{ | ||
"name": "@udecode/slate", | ||
"version": "37.0.0", | ||
"version": "38.0.3", | ||
"description": "Slate extension", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
355520
2821