Socket
Socket
Sign inDemoInstall

@udecode/slate-utils

Package Overview
Dependencies
Maintainers
0
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@udecode/slate-utils - npm Package Compare versions

Comparing version 37.0.0 to 38.0.3

40

dist/index.d.ts

@@ -62,7 +62,2 @@ import * as _udecode_slate from '@udecode/slate';

interface PointBeforeOptions extends BeforeOptions {
/**
* If true, get the point after the matching point. If false, get the matching
* point.
*/
afterMatch?: boolean;
/** Lookup before the location until this predicate is true */

@@ -75,2 +70,7 @@ match?: (value: {

/**
* If true, get the point after the matching point. If false, get the matching
* point.
*/
afterMatch?: boolean;
/**
* If true, `matchString` will be interpreted as regex expression(s).

@@ -83,3 +83,3 @@ * Otherwise, it will be compared by string equality.

/** Lookup before the location for `matchString`. */
matchString?: string | string[];
matchString?: string[] | string;
/**

@@ -103,4 +103,4 @@ * If true, lookup until the start of the editor value. If false, lookup until

declare const getPointFromLocation: (editor: TEditor, { at, focus, }?: {
at?: Location | null | undefined;
focus?: boolean | undefined;
at?: Location | null;
focus?: boolean;
}) => slate.BasePoint | undefined;

@@ -113,5 +113,5 @@

declare const getPointNextToVoid: (editor: TEditor, { after, at, }: {
at: Point;
/** Get the point after (instead of before) the void node. */
after?: boolean | undefined;
at: Point;
after?: boolean;
}) => slate.BasePoint;

@@ -141,3 +141,3 @@

*/
declare const getRangeFromBlockStart: <E extends TEditor>(editor: E, options?: Omit<GetAboveNodeOptions<E>, 'match'>) => {
declare const getRangeFromBlockStart: <E extends TEditor>(editor: E, options?: Omit<GetAboveNodeOptions<E>, "match">) => {
anchor: slate.BasePoint;

@@ -190,3 +190,3 @@ focus: slate.BasePoint;

declare const isRangeAcrossBlocks: <E extends TEditor>(editor: E, { at, ...options }?: {
at?: slate.BaseRange | null | undefined;
at?: Range | null;
} & Omit<GetAboveNodeOptions<E>, "at">) => boolean | undefined;

@@ -196,3 +196,3 @@

declare const isRangeInSameBlock: <E extends TEditor>(editor: E, { at, ...options }?: {
at?: slate.BaseRange | null | undefined;
at?: Range | null;
} & Omit<GetAboveNodeOptions<E>, "at">) => boolean | undefined;

@@ -214,3 +214,3 @@

declare const isSelectionCoverBlock: <E extends TEditor>(editor: E, { at, ...options }?: {
at?: slate.BaseRange | null | undefined;
at?: Range | null;
} & Omit<GetAboveNodeOptions<E>, "at">) => boolean | undefined;

@@ -260,3 +260,3 @@

/** Mark or the array of marks that will be removed */
key: string | string[];
key: string[] | string;
/** Range where the mark(s) will be removed */

@@ -273,6 +273,6 @@ at?: Range;

/** Remove mark and trigger `onChange` if collapsed selection. */
declare const removeMark: <E extends TEditor>(editor: E, { at, key, shouldChange, ...rest }: RemoveMarkOptions<E>) => void;
declare const removeMark: <E extends TEditor>(editor: E, { key, at, shouldChange, ...rest }: RemoveMarkOptions<E>) => void;
/** Remove node children. */
declare const removeNodeChildren: <E extends TEditor>(editor: E, path: Path, options?: Omit<RemoveNodesOptions<E>, 'at'>) => void;
declare const removeNodeChildren: <E extends TEditor>(editor: E, path: Path, options?: Omit<RemoveNodesOptions<E>, "at">) => void;

@@ -297,3 +297,3 @@ /** Remove selection marks. */

/** Set marks to selected text. */
declare const setMarks: <E extends TEditor>(editor: E, marks: MarksOf<E>, clear?: string | string[]) => void;
declare const setMarks: <E extends TEditor>(editor: E, marks: MarksOf<E>, clear?: string[] | string) => void;

@@ -304,6 +304,6 @@ interface ToggleMarkOptions {

/** Mark keys to clear when adding the mark. */
clear?: string | string[];
clear?: string[] | string;
}
/** Add or remove marks in the selection. */
declare const toggleMark: (editor: TEditor, { clear, key }: ToggleMarkOptions) => void;
declare const toggleMark: (editor: TEditor, { key, clear }: ToggleMarkOptions) => void;

@@ -310,0 +310,0 @@ /** Unwrap if the node type is in selection. Wrap otherwise. */

@@ -133,4 +133,3 @@ "use strict";

} = options;
if (!at)
return;
if (!at) return;
let from;

@@ -172,4 +171,3 @@ let to;

const at = path ? path[0] : (_a = selection == null ? void 0 : selection.focus) == null ? void 0 : _a.path[0];
if (typeof at !== "number")
return;
if (typeof at !== "number") return;
return (0, import_slate3.getNodeEntry)(editor, [at]);

@@ -203,4 +201,3 @@ };

const at = _at != null ? _at : editor.selection;
if (!at)
return null;
if (!at) return null;
const [start, end] = (0, import_slate6.getEdgePoints)(editor, at != null ? at : editor.selection);

@@ -210,9 +207,7 @@ const startBlock = getBlockAbove(editor, __spreadValues({

}, options));
if (!startBlock)
return null;
if (!startBlock) return null;
const endBlock = getBlockAbove(editor, __spreadValues({
at: end
}, options));
if (!endBlock)
return null;
if (!endBlock) return null;
return [startBlock, endBlock];

@@ -226,6 +221,4 @@ };

const [node, path] = nodeEntry;
if ((0, import_slate7.isText)(node))
return null;
if (node.children.length === 0)
return null;
if ((0, import_slate7.isText)(node)) return null;
if (node.children.length === 0) return null;
const children = node.children;

@@ -236,4 +229,3 @@ return [children.at(-1), path.concat([children.length - 1])];

const lastChild = getLastChild(nodeEntry);
if (!lastChild)
return nodeEntry[1].concat([-1]);
if (!lastChild) return nodeEntry[1].concat([-1]);
return lastChild[1];

@@ -249,4 +241,3 @@ };

var getLastChild2 = (node, level) => {
if (!(level + 1) || !(0, import_slate9.isAncestor)(node))
return node;
if (!(level + 1) || !(0, import_slate9.isAncestor)(node)) return node;
const { children } = node;

@@ -259,4 +250,3 @@ const lastNode = children.at(-1);

const lastNode = children.at(-1);
if (!lastNode)
return;
if (!lastNode) return;
const [, lastPath] = (0, import_slate9.getLastNode)(editor, []);

@@ -269,4 +259,3 @@ return [getLastChild2(lastNode, level - 1), lastPath.slice(0, level + 1)];

var getMark = (editor, key) => {
if (!editor)
return;
if (!editor) return;
const marks = (0, import_slate10.getMarks)(editor);

@@ -282,4 +271,3 @@ return marks == null ? void 0 : marks[key];

});
if (!nextEntry)
return;
if (!nextEntry) return;
return (0, import_slate11.getStartPoint)(editor, nextEntry[1]);

@@ -305,4 +293,3 @@ };

var getNodesRange = (editor, nodeEntries) => {
if (nodeEntries.length === 0)
return;
if (nodeEntries.length === 0) return;
const firstBlockPath = nodeEntries[0][1];

@@ -329,6 +316,4 @@ const lastBlockPath = nodeEntries.at(-1)[1];

]);
if (!at)
at = editor.selection;
if (!at)
return;
if (!at) at = editor.selection;
if (!at) return;
const [start, end] = import_slate13.Range.edges(at);

@@ -341,6 +326,4 @@ const startBlock = getBlockAbove(editor, __spreadValues({

}, options));
if (!startBlock && !endBlock)
return;
if (!startBlock || !endBlock)
return true;
if (!startBlock && !endBlock) return;
if (!startBlock || !endBlock) return true;
return !import_slate13.Path.equals(startBlock[1], endBlock[1]);

@@ -368,4 +351,3 @@ };

const beforePoint = (0, import_slate14.getPointBefore)(editor, beforeAt, options);
if (!beforePoint)
return;
if (!beforePoint) return;
if (isRangeAcrossBlocks(editor, {

@@ -422,8 +404,5 @@ at: {

let point;
if (import_slate15.Range.isRange(at))
point = focus ? at.focus : at.anchor;
if (import_slate15.Point.isPoint(at))
point = at;
if (import_slate15.Path.isPath(at))
point = { offset: 0, path: at };
if (import_slate15.Range.isRange(at)) point = focus ? at.focus : at.anchor;
if (import_slate15.Point.isPoint(at)) point = at;
if (import_slate15.Path.isPath(at)) point = { offset: 0, path: at };
return point;

@@ -468,4 +447,3 @@ };

match: (n) => {
if (!(0, import_slate18.isBlock)(editor, n) || !n.id)
return false;
if (!(0, import_slate18.isBlock)(editor, n) || !n.id) return false;
if (n.id === id) {

@@ -484,4 +462,3 @@ found = true;

}
if (!found)
return;
if (!found) return;
const _entries = (0, import_slate18.getNodeEntries)(editor, {

@@ -508,4 +485,3 @@ at: [],

});
if (!prevEntry)
return;
if (!prevEntry) return;
return (0, import_slate19.getEndPoint)(editor, prevEntry[1]);

@@ -516,7 +492,5 @@ };

var getPreviousPath = (path) => {
if (path.length === 0)
return;
if (path.length === 0) return;
const last2 = path.at(-1);
if (last2 <= 0)
return;
if (last2 <= 0) return;
return path.slice(0, -1).concat(last2 - 1);

@@ -542,4 +516,3 @@ };

const anchor = getPointBeforeLocation(editor, at, options);
if (!anchor)
return;
if (!anchor) return;
const focus = (0, import_slate21.getPoint)(editor, at, { edge: "end" });

@@ -557,8 +530,6 @@ return {

const path = (_a = getBlockAbove(editor, options)) == null ? void 0 : _a[1];
if (!path)
return;
if (!path) return;
const start = (0, import_slate22.getStartPoint)(editor, path);
const focus = getPointFromLocation(editor, options);
if (!focus)
return;
if (!focus) return;
return { anchor: start, focus };

@@ -579,4 +550,3 @@ };

const block = (_a = getBlockAbove(editor)) == null ? void 0 : _a[0];
if (!block)
return false;
if (!block) return false;
return isAncestorEmpty(editor, block);

@@ -588,14 +558,10 @@ };

var isBlockTextEmptyAfterSelection = (editor) => {
if (!editor.selection)
return false;
if (!editor.selection) return false;
const blockAbove = getBlockAbove(editor);
if (!blockAbove)
return false;
if (!blockAbove) return false;
const cursor = editor.selection.focus;
const selectionParentEntry = (0, import_slate25.getParentNode)(editor, editor.selection);
if (!selectionParentEntry)
return false;
if (!selectionParentEntry) return false;
const [, selectionParentPath] = selectionParentEntry;
if (!(0, import_slate25.isEndPoint)(editor, cursor, selectionParentPath))
return false;
if (!(0, import_slate25.isEndPoint)(editor, cursor, selectionParentPath)) return false;
const siblingNodes = getNextSiblingNodes(blockAbove, cursor.path);

@@ -648,3 +614,3 @@ if (siblingNodes.length > 0) {

const afterText = (0, import_slate29.getEditorString)(editor, afterRange);
return !!afterText.match(AFTER_MATCH_REGEX);
return !!AFTER_MATCH_REGEX.exec(afterText);
};

@@ -660,6 +626,4 @@

]);
if (!at)
at = editor.selection;
if (!at)
return;
if (!at) at = editor.selection;
if (!at) return;
const [start, end] = import_slate30.Range.edges(at);

@@ -672,4 +636,3 @@ const startBlock = getBlockAbove(editor, __spreadValues({

}, options));
if (!startBlock || !endBlock)
return;
if (!startBlock || !endBlock) return;
return import_slate30.Path.equals(startBlock[1], endBlock[1]);

@@ -698,7 +661,5 @@ };

const { selection } = editor;
if (!selection)
return false;
if (!selection) return false;
const path = (_a = getBlockAbove(editor, options)) == null ? void 0 : _a[1];
if (!path)
return false;
if (!path) return false;
return (0, import_slate33.isStartPoint)(editor, selection.focus, path) || (0, import_slate33.isExpanded)(editor.selection) && (0, import_slate33.isStartPoint)(editor, selection.anchor, path);

@@ -798,6 +759,4 @@ };

const parentNode = import_slate41.Path.isPath(at) ? (0, import_slate40.getNode)(editor, parentPath) : at[0];
if (!parentNode)
return moved;
if (!(0, import_slate40.isBlock)(editor, parentNode))
return moved;
if (!parentNode) return moved;
if (!(0, import_slate40.isBlock)(editor, parentNode)) return moved;
for (let i = parentNode.children.length - 1; i >= fromStartIndex; i--) {

@@ -819,3 +778,3 @@ const childPath = [...parentPath, i];

var removeMark = (editor, _a) => {
var _b = _a, { at, key, shouldChange = true } = _b, rest = __objRest(_b, ["at", "key", "shouldChange"]);
var _b = _a, { key, at, shouldChange = true } = _b, rest = __objRest(_b, ["key", "at", "shouldChange"]);
var _a2;

@@ -858,4 +817,3 @@ const selection = at != null ? at : editor.selection;

const marks = (0, import_slate45.getMarks)(editor);
if (!marks)
return;
if (!marks) return;
Object.keys(marks).forEach((key) => {

@@ -900,4 +858,3 @@ (0, import_slate45.removeEditorMark)(editor, key);

var setMarks = (editor, marks, clear = []) => {
if (!editor.selection)
return;
if (!editor.selection) return;
(0, import_slate49.withoutNormalizing)(editor, () => {

@@ -916,5 +873,4 @@ const clears = (0, import_castArray4.default)(clear);

var import_castArray5 = __toESM(require("lodash/castArray.js"));
var toggleMark = (editor, { clear, key }) => {
if (!editor.selection)
return;
var toggleMark = (editor, { key, clear }) => {
if (!editor.selection) return;
(0, import_slate50.withoutNormalizing)(editor, () => {

@@ -952,4 +908,3 @@ const isActive = isMarkActive(editor, key);

const node = (0, import_slate52.getNode)(editor, path);
if (!(node == null ? void 0 : node.children))
return;
if (!(node == null ? void 0 : node.children)) return;
(0, import_slate52.withoutNormalizing)(editor, () => {

@@ -960,4 +915,3 @@ const firstChildPath = path.concat([0]);

}));
if (node.children.length < 2)
return;
if (node.children.length < 2) return;
moveChildren(editor, {

@@ -964,0 +918,0 @@ at: path,

{
"name": "@udecode/slate-utils",
"version": "37.0.0",
"version": "38.0.3",
"description": "Slate utils",

@@ -45,3 +45,3 @@ "keywords": [

"dependencies": {
"@udecode/slate": "37.0.0",
"@udecode/slate": "38.0.3",
"@udecode/utils": "37.0.0",

@@ -48,0 +48,0 @@ "lodash": "^4.17.21"

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

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