index
int64
0
0
repo_id
stringlengths
16
181
file_path
stringlengths
28
270
content
stringlengths
1
11.6M
__index_level_0__
int64
0
10k
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/focusEditor.ts
import { deselect, select, Value, withoutNormalizing } from '@udecode/slate'; import { Location } from 'slate'; import { ReactEditor } from 'slate-react'; import { TReactEditor } from '../types/TReactEditor'; /** * Focus the editor. Extension: * * If `target` is defined: * - deselect the editor (otherwise it will...
400
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/getEditorWindow.ts
import { Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; import { TReactEditor } from '../types/TReactEditor'; /** * Return the host window of the current editor. */ export const getEditorWindow = <V extends Value>(editor: TReactEditor<V>) => { try { return ReactEditor.getWindow(edit...
401
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/hasEditorDOMNode.ts
import { Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; import { DOMNode } from 'slate-react/dist/utils/dom'; import { TReactEditor } from '../types/TReactEditor'; /** * Check if a DOM node is within the editor. */ export const hasEditorDOMNode = <V extends Value>( editor: TReactEditor<...
402
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/hasEditorEditableTarget.ts
import { Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; import { TReactEditor } from '../types/TReactEditor'; /** * Check if the target is editable and in the editor. */ export const hasEditorEditableTarget = <V extends Value>( editor: TReactEditor<V>, target: EventTarget | null ): ta...
403
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/hasEditorSelectableTarget.ts
import { Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; import { TReactEditor } from '../types/TReactEditor'; /** * Check if the target can be selectable. */ export const hasEditorSelectableTarget = <V extends Value>( editor: TReactEditor<V>, target: EventTarget | null ) => { try { ...
404
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/hasEditorTarget.ts
import { Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; import { TReactEditor } from '../types/TReactEditor'; /** * Check if the target is in the editor. */ export const hasEditorTarget = <V extends Value>( editor: TReactEditor<V>, target: EventTarget | null ): target is Node => { t...
405
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/index.ts
/** * @file Automatically generated by barrelsby. */ export * from './blurEditor'; export * from './deselectEditor'; export * from './findEditorDocumentOrShadowRoot'; export * from './findEventRange'; export * from './findNodeKey'; export * from './findNodePath'; export * from './focusEditor'; export * from './getEd...
406
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/insertData.ts
import { Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; import { TReactEditor } from '../types/TReactEditor'; /** * Insert data from a `DataTransfer` into the editor. */ export const insertData = <V extends Value>( editor: TReactEditor<V>, data: DataTransfer ) => ReactEditor.insertDat...
407
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/isComposing.ts
import { Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; import { TReactEditor } from '../types/TReactEditor'; /** * Check if the user is currently composing inside the editor. */ export const isComposing = <V extends Value>(editor: TReactEditor<V>) => ReactEditor.isComposing(editor as a...
408
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/isEditorFocused.ts
import { Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; import { TReactEditor } from '../types/TReactEditor'; /** * Check if the editor is focused. */ export const isEditorFocused = <V extends Value>(editor: TReactEditor<V>) => ReactEditor.isFocused(editor as any);
409
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/isEditorReadOnly.ts
import { Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; import { TReactEditor } from '../types/TReactEditor'; /** * Check if the editor is in read-only mode. */ export const isEditorReadOnly = <V extends Value>(editor: TReactEditor<V>) => ReactEditor.isReadOnly(editor as any);
410
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/isTargetInsideNonReadonlyVoidEditor.ts
import { Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; import { TReactEditor } from '../types/TReactEditor'; /** * Check if the target is inside void and in an non-readonly editor. */ export const isTargetInsideNonReadonlyVoid = <V extends Value>( editor: TReactEditor<V>, target: Eve...
411
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/setFragmentData.ts
import { Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; import { TReactEditor } from '../types/TReactEditor'; /** * Sets data from the currently selected fragment on a `DataTransfer`. */ export const setFragmentData = <V extends Value>( editor: TReactEditor<V>, data: DataTransfer ) =>...
412
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/toDOMNode.ts
import { TNode, Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; import { TReactEditor } from '../types/TReactEditor'; /** * Find the native DOM element from a Slate node. */ export const toDOMNode = <V extends Value>( editor: TReactEditor<V>, node: TNode ) => { try { return React...
413
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/toDOMPoint.ts
import { Value } from '@udecode/slate'; import { Point } from 'slate'; import { ReactEditor } from 'slate-react'; import { TReactEditor } from '../types/TReactEditor'; /** * Find a native DOM selection point from a Slate point. */ export const toDOMPoint = <V extends Value>( editor: TReactEditor<V>, point: Poin...
414
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/toDOMRange.ts
import { Value } from '@udecode/slate/dist'; import { Range } from 'slate'; import { ReactEditor } from 'slate-react'; import { TReactEditor } from '../types/TReactEditor'; /** * {@link ReactEditor.toDOMRange} */ export const toDOMRange = <V extends Value>( editor: TReactEditor<V>, range: Range ) => { try { ...
415
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/toSlateNode.ts
import { TNode, Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; import { DOMNode } from 'slate-react/dist/utils/dom'; import { TReactEditor } from '../types/TReactEditor'; /** * {@link ReactEditor.toSlateNode} */ export const toSlateNode = <V extends Value>( editor: TReactEditor<V>, do...
416
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/toSlatePoint.ts
import { Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; import { DOMPoint } from 'slate-react/dist/utils/dom'; import { TReactEditor } from '../types/TReactEditor'; /** * {@link ReactEditor.toSlatePoint} */ export const toSlatePoint = <V extends Value>( editor: TReactEditor<V>, domPoi...
417
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/react-editor/toSlateRange.ts
import { Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; import { TReactEditor } from '../types/TReactEditor'; /** * {@link ReactEditor.toSlateRange} */ export const toSlateRange = <V extends Value>( editor: TReactEditor<V>, domRange: Parameters<typeof ReactEditor.toSlateRange>[1], o...
418
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/types/SlateProps.ts
import React from 'react'; import { TDescendant } from '@udecode/slate'; import { UnknownObject } from '@udecode/utils'; import { ReactEditor } from 'slate-react'; export interface SlateProps extends UnknownObject { editor: ReactEditor; value: TDescendant[]; children: React.ReactNode; onChange: (value: SlatePr...
419
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/types/TReactEditor.ts
import { TEditor, Value } from '@udecode/slate'; import { ReactEditor } from 'slate-react'; export type TReactEditor<V extends Value = Value> = TEditor<V> & Pick< ReactEditor, | 'insertData' | 'insertFragmentData' | 'insertTextData' | 'setFragmentData' | 'hasRange' | 'hasTarget' | 'ha...
420
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/types/TRenderLeafProps.ts
import { EText, TText, Value } from '@udecode/slate'; import { Modify } from '@udecode/utils'; import { RenderLeafProps } from 'slate-react'; export type TRenderLeafProps< V extends Value = Value, N extends TText = EText<V>, > = Modify< RenderLeafProps, { leaf: N; text: N; } >; export type RenderLea...
421
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/types/index.ts
/** * @file Automatically generated by barrelsby. */ export * from './SlateProps'; export * from './TReactEditor'; export * from './TRenderLeafProps';
422
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/utils/focusEditorEdge.ts
import { getEndPoint, getStartPoint, Value } from '@udecode/slate'; import { focusEditor } from '../react-editor/index'; import { TReactEditor } from '../types/index'; /** * Focus an editor edge. */ export const focusEditorEdge = <V extends Value>( editor: TReactEditor<V>, { edge = 'start', }: { edge?...
423
0
petrpan-code/udecode/plate/packages/slate-react/src
petrpan-code/udecode/plate/packages/slate-react/src/utils/index.ts
/** * @file Automatically generated by barrelsby. */ export * from './focusEditorEdge';
424
0
petrpan-code/udecode/plate/packages
petrpan-code/udecode/plate/packages/slate-utils/.npmignore
__tests__ __test-utils__ __mocks__
425
0
petrpan-code/udecode/plate/packages
petrpan-code/udecode/plate/packages/slate-utils/CHANGELOG.md
# @udecode/slate-utils ## 25.0.0 ## 24.3.6 ## 24.3.5 ## 24.3.2 ## 24.3.1 ## 24.3.0 ## 24.2.0 ### Minor Changes - [`18f9778c`](https://github.com/udecode/plate/commit/18f9778cda9450cd99a71c47ab0767b64813db1a) by [@zbeyens](https://github.com/zbeyens) – Add replaceNode ## 24.0.0 ### Minor Changes - [#2629](ht...
426
0
petrpan-code/udecode/plate/packages
petrpan-code/udecode/plate/packages/slate-utils/README.md
# Slate utils ## Documentation WIP ## License [MIT](../../LICENSE)
427
0
petrpan-code/udecode/plate/packages
petrpan-code/udecode/plate/packages/slate-utils/package.json
{ "name": "@udecode/slate-utils", "version": "25.0.0", "description": "Slate utils", "license": "MIT", "homepage": "https://platejs.org", "repository": { "type": "git", "url": "https://github.com/udecode/plate.git", "directory": "packages/utils" }, "bugs": { "url": "https://github.com/ud...
428
0
petrpan-code/udecode/plate/packages
petrpan-code/udecode/plate/packages/slate-utils/tsconfig.json
{ "extends": "../../config/tsconfig.build.json", "compilerOptions": { "declarationDir": "./dist", "outDir": "./dist" }, "include": ["src"] }
429
0
petrpan-code/udecode/plate/packages/slate-utils
petrpan-code/udecode/plate/packages/slate-utils/src/index.ts
/** * @file Automatically generated by barrelsby. */ export * from './queries/index'; export * from './transforms/index'; export * from './utils/index';
430
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/findDescendant.ts
/** * Iterate through all of the nodes in the editor and return the first match. If * no match is found, return undefined. */ import { EDescendant, ENodeEntry, FindNodeOptions, getNodeDescendants, getNodeEntry, getPath, isVoid, match, TEditor, TNodeEntry, Value, } from '@udecode/slate'; import ...
431
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getBlockAbove.ts
import { EAncestor, getAboveNode, GetAboveNodeOptions, TEditor, Value, } from '@udecode/slate'; /** * Get the block above a location (default: selection). */ export const getBlockAbove = <N extends EAncestor<V>, V extends Value = Value>( editor: TEditor<V>, options: GetAboveNodeOptions<V> = {} ) => g...
432
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getChildren.ts
import { ChildOf, isAncestor, TNode, TNodeEntry } from '@udecode/slate'; import { Path } from 'slate'; /** * Get children node entries of a node entry. * TODO: try Node.children */ export const getChildren = <N extends ChildOf<R>, R extends TNode = TNode>( nodeEntry: TNodeEntry<R> ): TNodeEntry<N>[] => { const ...
433
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getEdgeBlocksAbove.ts
import { EAncestor, GetAboveNodeOptions, getEdgePoints, TEditor, TNodeEntry, Value, } from '@udecode/slate'; import { getBlockAbove } from './getBlockAbove'; /** * Get the edge blocks above a location (default: selection). */ export const getEdgeBlocksAbove = < N1 extends EAncestor<V>, N2 extends EA...
434
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getLastChild.ts
import { ChildOf, isText, TNode, TNodeEntry } from '@udecode/slate'; import { Path } from 'slate'; /** * Get the last child of a node or null if no children. */ export const getLastChild = <N extends ChildOf<R>, R extends TNode>( nodeEntry: TNodeEntry<R> ): TNodeEntry<N> | null => { const [node, path] = nodeEntr...
435
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getLastNodeByLevel.ts
import { ChildOf, EElementOrText, getLastNode, isAncestor, TEditor, TNode, TNodeEntry, Value, } from '@udecode/slate'; const getLastChild = <N extends ChildOf<R>, R extends TNode>( node: R, level: number ): R | N => { if (!(level + 1) || !isAncestor(node)) return node; const { children } = nod...
436
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getMark.ts
import { getMarks, TEditor, Value } from '@udecode/slate'; /** * Get selection mark value by key. */ export const getMark = <V extends Value>(editor: TEditor<V>, key: string) => { if (!editor) return; const marks = getMarks(editor); return (marks as any)?.[key] as unknown; };
437
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getNextNodeStartPoint.ts
import { getNextNode, getStartPoint, TEditor, Value } from '@udecode/slate'; import { Path } from 'slate'; /** * Get the start point of the next node. */ export const getNextNodeStartPoint = <V extends Value = Value>( editor: TEditor<V>, at: Path ) => { const nextEntry = getNextNode(editor, { at, }); i...
438
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getNextSiblingNodes.ts
import { EAncestorEntry, EElementOrText, Value } from '@udecode/slate'; import { Path } from 'slate'; /** * Get the next sibling nodes after a path. * @param ancestorEntry Ancestor of the sibling nodes * @param path Path of the reference node */ export const getNextSiblingNodes = <V extends Value>( ancestorEntry...
439
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getOperations.ts
import { EDescendant, TEditor, TOperation, Value } from '@udecode/slate'; /** * Get typed editor operations. */ export const getOperations = <V extends Value>(editor: TEditor<V>) => editor.operations as TOperation<EDescendant<V>>[];
440
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getPointBeforeLocation.ts
/* eslint-disable no-constant-condition */ import { getEditorString, getPoint, getPointBefore, TEditor, Value, } from '@udecode/slate'; import castArray from 'lodash/castArray.js'; import map from 'lodash/map.js'; import { Location, Point } from 'slate'; import { isRangeAcrossBlocks } from './isRangeAcrossBl...
441
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getPointFromLocation.ts
import { TEditor, Value } from '@udecode/slate'; import { Location, Path, Point, Range } from 'slate'; /** * Get the point from a location (default: selection). * If the location is a range, get the anchor point. * If the location is a path, get the point at this path with offset 0. * If `focus` is true, get the f...
442
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getPointNextToVoid.ts
import { getPointAfter, getPointBefore, getVoidNode, TEditor, Value, } from '@udecode/slate'; import { Path, Point } from 'slate'; import { getBlockAbove } from './getBlockAbove'; /** * If the start point is inside an inline void, get the point before or after it. */ export const getPointNextToVoid = <V e...
443
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getPreviousBlockById.spec.ts
import { createTEditor } from '@udecode/slate'; import { getPreviousBlockById } from './getPreviousBlockById'; const nodesFixture5 = [ { children: [{ text: '' }], id: '1', type: 'p', }, { children: [{ text: '' }], id: '2', type: 'p', }, { children: [{ text: '' }], id: '3', ...
444
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getPreviousBlockById.ts
import { EElement, findNode, getNodeEntries, getPreviousNode, isBlock, queryNode, QueryNodeOptions, TEditor, TElement, TNodeEntry, Value, } from '@udecode/slate'; /** * Find the block before a block by id. * If not found, find the first block by id and return [null, its previous path] */ expor...
445
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getPreviousNodeEndPoint.ts
import { getEndPoint, getPreviousNode, TEditor, Value } from '@udecode/slate'; import { Path } from 'slate'; /** * Get the end point of the previous node. */ export const getPreviousNodeEndPoint = <V extends Value = Value>( editor: TEditor<V>, at: Path ) => { const prevEntry = getPreviousNode(editor, { at,...
446
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getPreviousPath.ts
import { Path } from 'slate'; export const getPreviousPath = (path: Path): Path | undefined => { if (path.length === 0) return; const last = path.at(-1)!; if (last <= 0) return; return path.slice(0, -1).concat(last - 1); };
447
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getPreviousSiblingNode.ts
import { getNode, TEditor, Value } from '@udecode/slate'; import last from 'lodash/last.js'; import { Path } from 'slate'; export const getPreviousSiblingNode = <V extends Value = Value>( editor: TEditor<V>, path: Path ) => { const index = last(path)!; if (index > 0) { const previousSiblingIndex = index -...
448
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getRangeBefore.ts
import { getPoint, TEditor, Value } from '@udecode/slate'; import { Location, Range } from 'slate'; import { getPointBeforeLocation, PointBeforeOptions, } from './getPointBeforeLocation'; export interface RangeBeforeOptions extends PointBeforeOptions {} /** * Get range from {@link getPointBeforeLocation} to the...
449
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getRangeFromBlockStart.ts
import { GetAboveNodeOptions, getStartPoint, TEditor, Value, } from '@udecode/slate'; import { getBlockAbove } from './getBlockAbove'; import { getPointFromLocation } from './getPointFromLocation'; /** * Get the range from the start of the block above a location (default: selection) to the location. */ expo...
450
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/getSelectionText.ts
import { getEditorString, TEditor, Value } from '@udecode/slate'; /** * Get the selected text. * Return empty string if no selection. */ export const getSelectionText = <V extends Value>(editor: TEditor<V>) => getEditorString(editor, editor.selection);
451
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/index.ts
/** * @file Automatically generated by barrelsby. */ export * from './findDescendant'; export * from './getBlockAbove'; export * from './getChildren'; export * from './getEdgeBlocksAbove'; export * from './getLastChild'; export * from './getLastNodeByLevel'; export * from './getMark'; export * from './getNextNodeSta...
452
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isAncestorEmpty.ts
import { getNodeString, isInline, TAncestor, TEditor, Value, } from '@udecode/slate'; /** * Is an ancestor empty (empty text and no inline children). */ export const isAncestorEmpty = <V extends Value>( editor: TEditor<V>, node: TAncestor ) => !getNodeString(node) && !node.children.some((n) => isInline...
453
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isBlockAboveEmpty.ts
import { TEditor, Value } from '@udecode/slate'; import { getBlockAbove } from './getBlockAbove'; import { isAncestorEmpty } from './isAncestorEmpty'; /** * Is the block above the selection empty. */ export const isBlockAboveEmpty = <V extends Value>(editor: TEditor<V>) => { const block = getBlockAbove(editor)?.[...
454
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isBlockTextEmptyAfterSelection.ts
import { getParentNode, isEndPoint, isText, TEditor, Value, } from '@udecode/slate'; import { getBlockAbove } from './getBlockAbove'; import { getNextSiblingNodes } from './getNextSiblingNodes'; /** * Is there empty text after the selection. * If there is no leaf after the selected leaf, return {@link isE...
455
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isDocumentEnd.ts
import { getEndPoint, isEndPoint, TEditor, Value } from '@udecode/slate'; import { Path } from 'slate'; export const isDocumentEnd = <V extends Value = Value>(editor: TEditor<V>) => { if (editor.selection) { const point = editor.selection.focus; const endPoint = getEndPoint(editor, []); return ( e...
456
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isEditorEmpty.ts
import { isElementEmpty, TEditor, Value } from '@udecode/slate'; /** * Whether the editor is empty. An editor is empty if it has only one empty element. */ export const isEditorEmpty = <V extends Value>(editor: TEditor<V>) => { return ( editor.children.length === 1 && isElementEmpty(editor, editor.children...
457
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isFirstChild.ts
import { Path } from 'slate'; /** * Is it the first child of the parent */ export const isFirstChild = (path: Path) => path.at(-1) === 0;
458
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isMarkActive.ts
import { TEditor, Value } from '@udecode/slate'; import { isDefined } from '@udecode/utils'; import { getMark } from './getMark'; /** * Is the mark defined in the selection. */ export const isMarkActive = <V extends Value>( editor: TEditor<V>, type: string ) => { return isDefined(getMark(editor, type)); };
459
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isPointAtWordEnd.ts
import { getEditorString, getPointAfter, getRange, TEditor, Value, } from '@udecode/slate'; import { Point } from 'slate'; // Starts with whitespace char or nothing const AFTER_MATCH_REGEX = /^(\s|$)/; /** * Is a point at the end of a word */ export const isPointAtWordEnd = <V extends Value>( editor: TE...
460
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isRangeAcrossBlocks.spec.tsx
/** @jsx jsx */ import { jsx } from '@udecode/plate-test-utils'; import { TEditor } from '@udecode/slate'; import { isRangeAcrossBlocks } from './isRangeAcrossBlocks'; jsx; describe('when selection is in the same block', () => { describe('when one text', () => { it('should be false', () => { const input...
461
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isRangeAcrossBlocks.ts
import { GetAboveNodeOptions, TEditor, Value } from '@udecode/slate'; import { Path, Range } from 'slate'; import { getBlockAbove } from './getBlockAbove'; /** * Is the range (default: selection) across blocks. * - return undefined if block not found * - return boolean whether one of the block is not found, but th...
462
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isRangeInSameBlock.ts
import { GetAboveNodeOptions, TEditor, Value } from '@udecode/slate'; import { Path, Range } from 'slate'; import { getBlockAbove } from './getBlockAbove'; /** * Whether the range is in the same block. */ export const isRangeInSameBlock = <V extends Value>( editor: TEditor<V>, { at, ...options }: Omit...
463
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isRangeInSingleText.ts
import { Path, Range } from 'slate'; /** * Is the range in the same single text path. */ export const isRangeInSingleText = (at: Range) => { const [start, end] = Range.edges(at); return Path.equals(start.path, end.path); };
464
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isSelectionAtBlockEnd.ts
import { GetAboveNodeOptions, isEndPoint, TEditor, Value, } from '@udecode/slate'; import { getBlockAbove } from './getBlockAbove'; /** * Is the selection focus at the end of its parent block. */ export const isSelectionAtBlockEnd = <V extends Value>( editor: TEditor<V>, options?: GetAboveNodeOptions<V>...
465
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isSelectionAtBlockStart.ts
import { GetAboveNodeOptions, isExpanded, isStartPoint, TEditor, Value, } from '@udecode/slate'; import { getBlockAbove } from './getBlockAbove'; /** * Is the selection anchor or focus at the start of its parent block. * * Supports the same options provided by {@link getBlockAbove}. */ export const isSe...
466
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isSelectionExpanded.ts
import { isExpanded, TEditor, Value } from '@udecode/slate'; /** * Is the selection expanded. */ export const isSelectionExpanded = <V extends Value>(editor: TEditor<V>) => isExpanded(editor.selection);
467
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isTextByPath.ts
import { getNode, isText, TEditor, Value } from '@udecode/slate'; import { Path } from 'slate'; export const isTextByPath = <V extends Value>( editor: TEditor<V>, path: Path ) => { const node = getNode(editor, path); return isText(node); };
468
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/isWordAfterTrigger.ts
import { getEditorString, getPointBefore, getRange, TEditor, Value, } from '@udecode/slate'; import { escapeRegExp } from '@udecode/utils'; import { Point } from 'slate'; /** * Is the word at the point after a trigger (punctuation character) * https://github.com/ianstormtaylor/slate/blob/main/packages/slat...
469
0
petrpan-code/udecode/plate/packages/slate-utils/src
petrpan-code/udecode/plate/packages/slate-utils/src/queries/queryEditor.ts
import { QueryEditorOptions, someNode, TEditor, Value } from '@udecode/slate'; import castArray from 'lodash/castArray.js'; import { isSelectionAtBlockEnd } from './isSelectionAtBlockEnd'; import { isSelectionAtBlockStart } from './isSelectionAtBlockStart'; /** * Query the editor state. */ export const queryEditor ...
470
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getBlockAboveSelection/block.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-common'; import { jsx } from '@udecode/plate-test-utils'; import { getBlockAbove } from '../../getBlockAbove'; jsx; const input = ( <editor> <hh1> <hp> test <cursor /> </hp> </hh1> </editor> ) as any as PlateEditor; ...
471
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getLastNode/level-1.spec.tsx
/** @jsx jsx */ import { jsx } from '@udecode/plate-test-utils'; import { getLastNodeByLevel } from '../../getLastNodeByLevel'; jsx; const input = ( <editor> <hh1> <hp>test</hp> </hh1> <hh1> <hp>test2</hp> </hh1> </editor> ) as any; const output = <hp>test2</hp>; it('should be', ()...
472
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getNextSiblingNodes/no-sibling.spec.tsx
/** @jsx jsx */ import { createPlateEditor, PlateEditor } from '@udecode/plate-common'; import { createLinkPlugin } from '@udecode/plate-link'; import { jsx } from '@udecode/plate-test-utils'; import { TDescendant } from '@udecode/slate'; import { Range } from 'slate'; import { getBlockAbove } from '../../getBlockAbo...
473
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getNextSiblingNodes/two-siblings.spec.tsx
/** @jsx jsx */ import { createPlateEditor, getBlockAbove, PlateEditor, } from '@udecode/plate-common'; import { createLinkPlugin } from '@udecode/plate-link'; import { jsx } from '@udecode/plate-test-utils'; import { Range } from 'slate'; import { getNextSiblingNodes } from '../../getNextSiblingNodes'; jsx; ...
474
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getNode/found.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-core'; import { jsx } from '@udecode/plate-test-utils'; import { getNode } from '@udecode/slate'; jsx; const input = ( <editor> <hp> test <cursor /> </hp> </editor> ) as any as PlateEditor; it('should be', () => { expect(getNode(i...
475
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getNode/not-found.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-core'; import { jsx } from '@udecode/plate-test-utils'; import { getNode } from '@udecode/slate'; jsx; const input = ( <editor> <hp> test <cursor /> </hp> </editor> ) as any as PlateEditor; it('should be', () => { expect(getNode(i...
476
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getParent/not-root.spec.ts
import { createTEditor, getParentNode } from '@udecode/slate'; it('should be', () => { expect(getParentNode(createTEditor(), [0])?.[1]).toEqual([]); });
477
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getParent/root.spec.ts
import { createTEditor, getParentNode } from '@udecode/slate'; it('should be', () => { expect(getParentNode(createTEditor(), [])).toEqual(undefined); });
478
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore/default.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-core'; import { jsx } from '@udecode/plate-test-utils'; import { getPointBeforeLocation } from '../../getPointBeforeLocation'; jsx; const input = ( <editor> <hp> test <cursor /> </hp> </editor> ) as any as PlateEditor; const output...
479
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore/matchString.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-core'; import { jsx } from '@udecode/plate-test-utils'; import { getPointBeforeLocation } from '../../getPointBeforeLocation'; jsx; describe('when skipInvalid is true', () => { describe('when matchString is a character', () => { it('should be', () =>...
480
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore/afterMatch/character.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-core'; import { jsx } from '@udecode/plate-test-utils'; import { getPointBeforeLocation } from '../../../getPointBeforeLocation'; jsx; const input = ( <editor> <hp> test http://google.com <cursor /> </hp> </editor> ) as any as Plate...
481
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore/afterMatch/string.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-core'; import { jsx } from '@udecode/plate-test-utils'; import { getPointBeforeLocation } from '../../../getPointBeforeLocation'; jsx; const input = ( <editor> <hp> find **test <cursor /> </hp> </editor> ) as any as PlateEditor; co...
482
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore/match/default.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-core'; import { jsx } from '@udecode/plate-test-utils'; import { getPointBeforeLocation } from '../../../getPointBeforeLocation'; jsx; const input = ( <editor> <hp> test <cursor /> </hp> </editor> ) as any as PlateEditor; const out...
483
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore/multiPaths/true.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-core'; import { jsx } from '@udecode/plate-test-utils'; import { getPointBeforeLocation } from '../../../getPointBeforeLocation'; jsx; const input = ( <editor> <hp>find z</hp> <hp> test http://google.com <cursor /> </hp> </edito...
484
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore/skipInvalid/false.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-core'; import { jsx } from '@udecode/plate-test-utils'; import { getPointBeforeLocation } from '../../../getPointBeforeLocation'; jsx; const input = ( <editor> <hp> test http://google.com <cursor /> </hp> </editor> ) as any as Plate...
485
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore/skipInvalid/true.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-common'; import { jsx } from '@udecode/plate-test-utils'; import { getPointBeforeLocation } from '../../../getPointBeforeLocation'; jsx; const input = ( <editor> <hp> test http://google.com <cursor /> </hp> </editor> ) as any as Pla...
486
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointBefore/unit/word.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-common'; import { jsx } from '@udecode/plate-test-utils'; import { getPointBeforeLocation } from '../../../getPointBeforeLocation'; jsx; const input = ( <editor> <hp> test <cursor /> </hp> </editor> ) as any as PlateEditor; const o...
487
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointFromLocation/path.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-common'; import { jsx } from '@udecode/plate-test-utils'; import { getPointFromLocation } from '../../getPointFromLocation'; jsx; const input = ( <editor> <hp> test <cursor /> </hp> </editor> ) as any as PlateEditor; const output =...
488
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointFromLocation/point.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-common'; import { jsx } from '@udecode/plate-test-utils'; import { getPointFromLocation } from '../../getPointFromLocation'; jsx; const input = ( <editor> <hp> test <cursor /> </hp> </editor> ) as any as PlateEditor; const output =...
489
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointFromLocation/range-focus.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-core'; import { jsx } from '@udecode/plate-test-utils'; import { getPointFromLocation } from '../../getPointFromLocation'; jsx; const input = ( <editor> <hp> tes <anchor /> tt <focus /> </hp> </editor> ) as any as PlateE...
490
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getPointFromLocation/range.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-common'; import { jsx } from '@udecode/plate-test-utils'; import { getPointFromLocation } from '../../getPointFromLocation'; jsx; const input = ( <editor> <hp> test <cursor /> </hp> </editor> ) as any as PlateEditor; const output =...
491
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getRangeBefore/default.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-core'; import { jsx } from '@udecode/plate-test-utils'; import { getRangeBefore } from '../../getRangeBefore'; jsx; const input = ( <editor> <hp> test <cursor /> </hp> </editor> ) as any as PlateEditor; const output = { anchor: {...
492
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getRangeBefore/undefined.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-core'; import { jsx } from '@udecode/plate-test-utils'; import { getRangeBefore } from '../../getRangeBefore'; jsx; const input = ( <editor> <hp> <cursor /> test </hp> </editor> ) as any as PlateEditor; const output = undefined; i...
493
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getRangeFromBlockStart/no-block.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-common'; import { jsx } from '@udecode/plate-test-utils'; import { getRangeFromBlockStart } from '../../getRangeFromBlockStart'; jsx; const input = ( <editor> te <cursor /> st </editor> ) as any as PlateEditor; it('should be', () => { ex...
494
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getRangeFromBlockStart/no-selection.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-core'; import { jsx } from '@udecode/plate-test-utils'; import { getRangeFromBlockStart } from '../../getRangeFromBlockStart'; jsx; const input = ( <editor> <hp>test</hp> </editor> ) as any as PlateEditor; const output = undefined; it('should be'...
495
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getRangeFromBlockStart/selection.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-common'; import { jsx } from '@udecode/plate-test-utils'; import { getRangeFromBlockStart } from '../../getRangeFromBlockStart'; jsx; const input = ( <editor> <hp> te <cursor /> st </hp> </editor> ) as any as PlateEditor; con...
496
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/getSelectionText/true.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-core'; import { jsx } from '@udecode/plate-test-utils'; import { getSelectionText } from '../../getSelectionText'; jsx; const input = ( <editor> <hp> <anchor /> test <focus /> </hp> </editor> ) as any as PlateEditor; const ou...
497
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/isAncestorEmpty/empty.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-common'; import { jsx } from '@udecode/plate-test-utils'; import { isAncestorEmpty } from '../../isAncestorEmpty'; jsx; const input = ( <hp> <cursor /> </hp> ) as any as PlateEditor; const output = true; it('should be', () => { expect(isAncesto...
498
0
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__
petrpan-code/udecode/plate/packages/slate-utils/src/queries/__tests__/isAncestorEmpty/string.spec.tsx
/** @jsx jsx */ import { PlateEditor } from '@udecode/plate-core'; import { jsx } from '@udecode/plate-test-utils'; import { isAncestorEmpty } from '../../isAncestorEmpty'; jsx; const input = ( <hp> test <cursor /> </hp> ) as any as PlateEditor; const output = false; it('should be', () => { expect(i...
499