@udecode/slate
Advanced tools
Comparing version 38.0.4 to 40.3.1
import { UnknownObject, Simplify, UnionToIntersection, Modify } from '@udecode/utils'; | ||
import * as slate from 'slate'; | ||
import { Path, Location, Range, Selection, Span, Editor, Point, EditorLevelsOptions, NodeAncestorsOptions, NodeChildrenOptions, NodeDescendantsOptions, NodeElementsOptions, NodeLevelsOptions, NodeTextsOptions, NodeNodesOptions, EditorNextOptions, EditorUnhangRangeOptions, EditorNodesOptions, EditorNodeOptions, EditorParentOptions, EditorPathOptions, EditorPointOptions, EditorAfterOptions, EditorBeforeOptions, EditorPositionsOptions, EditorPreviousOptions, EditorVoidOptions, EditorNormalizeOptions, Transforms } from 'slate'; | ||
import { HistoryEditor } from 'slate-history'; | ||
import { Path, Location, Range, Selection, Span, DecoratedRange, Editor, Point, EditorLevelsOptions, NodeAncestorsOptions, NodeChildrenOptions, NodeDescendantsOptions, NodeElementsOptions, NodeLevelsOptions, NodeTextsOptions, NodeNodesOptions, EditorNextOptions, EditorUnhangRangeOptions, EditorNodesOptions, EditorNodeOptions, EditorParentOptions, EditorPathOptions, EditorPointOptions, EditorAfterOptions, EditorBeforeOptions, EditorPositionsOptions, EditorPreviousOptions, EditorVoidOptions, EditorNormalizeOptions, Transforms, Operation, BaseEditor } from 'slate'; | ||
import { HistoryEditor as HistoryEditor$1 } from 'slate-history'; | ||
import { EditorPathRefOptions, EditorPointRefOptions, EditorRangeRefOptions, EditorDirectedDeletionOptions, EditorFragmentDeletionOptions, EditorAboveOptions, EditorStringOptions, EditorLeafOptions } from 'slate/dist/interfaces/editor'; | ||
@@ -66,2 +66,3 @@ import { SelectionCollapseOptions, SelectionMoveOptions, SelectionSetPointOptions } from 'slate/dist/interfaces/transforms/selection'; | ||
type TSpan = Span; | ||
type TDecoratedRange = DecoratedRange; | ||
@@ -213,3 +214,3 @@ type TInsertNodeOperation<N extends TDescendant = TDescendant> = { | ||
operations: TOperation[]; | ||
}> & Pick<HistoryEditor, 'history' | 'redo' | 'undo' | 'writeHistory'> & UnknownObject; | ||
}> & Pick<HistoryEditor$1, 'history' | 'redo' | 'undo' | 'writeHistory'> & UnknownObject; | ||
@@ -619,2 +620,5 @@ declare const createTEditor: <V extends Value>() => TEditor<V>; | ||
/** {@link HistoryEditor.withMerging} */ | ||
declare const withNewBatch: (editor: TEditor, fn: () => void) => void; | ||
/** {@link HistoryEditor.withoutMerging} */ | ||
@@ -796,2 +800,79 @@ declare const withoutMergingHistory: (editor: TEditor, fn: () => void) => void; | ||
interface Batch { | ||
operations: Operation[]; | ||
selectionBefore: Range | null; | ||
} | ||
/** | ||
* `History` objects hold all of the operations that are applied to a value, so | ||
* they can be undone or redone as necessary. | ||
*/ | ||
interface History { | ||
redos: Batch[]; | ||
undos: Batch[]; | ||
} | ||
declare const History: { | ||
/** Check if a value is a `History` object. */ | ||
isHistory(value: any): value is History; | ||
}; | ||
/** Weakmaps for attaching state to the editor. */ | ||
declare const HISTORY: WeakMap<BaseEditor, History>; | ||
declare const SAVING: WeakMap<BaseEditor, boolean | undefined>; | ||
declare const MERGING: WeakMap<BaseEditor, boolean | undefined>; | ||
declare const SPLITTING_ONCE: WeakMap<BaseEditor, boolean | undefined>; | ||
/** `HistoryEditor` contains helpers for history-enabled editors. */ | ||
interface HistoryEditor extends BaseEditor { | ||
history: History; | ||
redo: () => void; | ||
undo: () => void; | ||
writeHistory: (stack: 'redos' | 'undos', batch: any) => void; | ||
} | ||
declare const HistoryEditor: { | ||
/** Check if a value is a `HistoryEditor` object. */ | ||
isHistoryEditor(value: any): value is HistoryEditor; | ||
/** Get the merge flag's current value. */ | ||
isMerging(editor: HistoryEditor): boolean | undefined; | ||
/** Get the splitting once flag's current value. */ | ||
isSaving(editor: HistoryEditor): boolean | undefined; | ||
isSplittingOnce(editor: HistoryEditor): boolean | undefined; | ||
/** Get the saving flag's current value. */ | ||
redo(editor: HistoryEditor): void; | ||
/** Redo to the previous saved state. */ | ||
setSplittingOnce(editor: HistoryEditor, value: boolean | undefined): void; | ||
/** Undo to the previous saved state. */ | ||
undo(editor: HistoryEditor): void; | ||
/** | ||
* Apply a series of changes inside a synchronous `fn`, These operations will | ||
* be merged into the previous history. | ||
*/ | ||
withMerging(editor: HistoryEditor, fn: () => void): void; | ||
/** | ||
* Apply a series of changes inside a synchronous `fn`, ensuring that the | ||
* first operation starts a new batch in the history. Subsequent operations | ||
* will be merged as usual. | ||
*/ | ||
withNewBatch(editor: HistoryEditor, fn: () => void): void; | ||
/** | ||
* Apply a series of changes inside a synchronous `fn`, without merging any of | ||
* the new operations into previous save point in the history. | ||
*/ | ||
withoutMerging(editor: HistoryEditor, fn: () => void): void; | ||
/** | ||
* Apply a series of changes inside a synchronous `fn`, without saving any of | ||
* their operations into the history. | ||
*/ | ||
withoutSaving(editor: HistoryEditor, fn: () => void): void; | ||
}; | ||
/** | ||
* The `withHistory` plugin keeps track of the operation history of a Slate | ||
* editor as operations are applied to it, using undo and redo stacks. | ||
* | ||
* If you are using TypeScript, you must extend Slate's CustomTypes to use this | ||
* plugin. | ||
* | ||
* See https://docs.slatejs.org/concepts/11-typescript to learn how. | ||
*/ | ||
declare const withHistory: <T extends Editor>(editor: T) => T & HistoryEditor; | ||
/** Add marks to each node of a range. */ | ||
@@ -813,2 +894,2 @@ declare const addRangeMarks: (editor: TEditor, props: any, { at, }?: { | ||
export { type AncestorEntryOf, type AncestorOf, type ChildOf, type DescendantEntryOf, type DescendantOf, type ENodeMatch, type ENodeMatchOptions, type ElementEntryOf, type ElementOf, type ElementOrTextOf, type FindNodeOptions, type GetAboveNodeOptions, type GetLevelsOptions, type GetNextNodeOptions, type GetNodeEntriesOptions, type GetPreviousNodeOptions, type InsertNodesOptions, type LiftNodesOptions, type MarkKeysOf, type MarksOf, type MergeNodesOptions, type MoveNodesOptions, type NodeEntryOf, type NodeMatchOption, type NodeOf, type Predicate, type PredicateFn, type PredicateObj, type QueryEditorOptions, type QueryNodeOptions, type RemoveNodesOptions, type SetNodesOptions, type SplitNodesOptions, type TAncestor, type TAncestorEntry, type TDescendant, type TDescendantEntry, type TEditor, type TElement, type TElementEntry, type TInsertNodeOperation, type TInsertTextOperation, type TLocation, type TMergeNodeOperation, type TMoveNodeOperation, type TNode, type TNodeChildEntry, type TNodeEntry, type TNodeMatch, type TNodeOperation, type TNodeProps, type TOperation, type TPath, type TRange, type TRemoveNodeOperation, type TRemoveTextOperation, type TSelection, type TSelectionOperation, type TSetNodeOperation, type TSetSelectionOperation, type TSpan, type TSplitNodeOperation, type TText, type TTextEntry, type TTextOperation, type TextEntryOf, type TextOf, type UnhangRangeOptions, type UnsetNodesOptions, type UnwrapNodesOptions, type Value, type ValueOf, type WrapNodesOptions, addMark, addRangeMarks, collapseSelection, createPathRef, createPointRef, createRangeRef, createTEditor, deleteBackward, deleteForward, deleteFragment, deleteMerge, deleteText, deselect, elementMatches, findNode, getAboveNode, getCommonNode, getEdgePoints, getEditorString, getEndPoint, getFirstNode, getFragment, getLastNode, getLeafNode, getLevels, getMarks, getNextNode, getNode, getNodeAncestor, getNodeAncestors, getNodeChild, getNodeChildren, getNodeDescendant, getNodeDescendants, getNodeElements, getNodeEntries, getNodeEntry, getNodeFirstNode, getNodeFragment, getNodeLastNode, getNodeLeaf, getNodeLevels, getNodeParent, getNodeProps, getNodeString, getNodeTexts, getNodes, getParentNode, getPath, getPathRefs, getPoint, getPointAfter, getPointBefore, getPointRefs, getPositions, getPreviousNode, getQueryOptions, getRange, getRangeRefs, getStartPoint, getVoidNode, hasBlocks, hasInlines, hasNode, hasSingleChild, hasTexts, insertBreak, insertFragment, insertNode, insertNodes, insertText, isAncestor, isBlock, isCollapsed, isDescendant, isEdgePoint, isEditor, isEditorNormalizing, isElement, isElementEmpty, isElementList, isEndPoint, isExpanded, isHistoryEditor, isHistoryMerging, isHistorySaving, isInline, isMarkableVoid, isNode, isNodeList, isStartPoint, isText, isTextList, isVoid, liftNodes, match, mergeNodes, moveNodes, moveSelection, nodeMatches, normalizeEditor, queryNode, removeEditorMark, removeNodes, select, setElements, setNodes, setPoint, setSelection, someNode, splitNodes, textEquals, textMatches, unhangCharacterRange, unhangRange, unsetNodes, unwrapNodes, withMerging, withoutMergingHistory, withoutNormalizing, withoutSavingHistory, wrapNodes }; | ||
export { type AncestorEntryOf, type AncestorOf, type ChildOf, type DescendantEntryOf, type DescendantOf, type ENodeMatch, type ENodeMatchOptions, type ElementEntryOf, type ElementOf, type ElementOrTextOf, type FindNodeOptions, type GetAboveNodeOptions, type GetLevelsOptions, type GetNextNodeOptions, type GetNodeEntriesOptions, type GetPreviousNodeOptions, HISTORY, History, HistoryEditor, type InsertNodesOptions, type LiftNodesOptions, MERGING, type MarkKeysOf, type MarksOf, type MergeNodesOptions, type MoveNodesOptions, type NodeEntryOf, type NodeMatchOption, type NodeOf, type Predicate, type PredicateFn, type PredicateObj, type QueryEditorOptions, type QueryNodeOptions, type RemoveNodesOptions, SAVING, SPLITTING_ONCE, type SetNodesOptions, type SplitNodesOptions, type TAncestor, type TAncestorEntry, type TDecoratedRange, type TDescendant, type TDescendantEntry, type TEditor, type TElement, type TElementEntry, type TInsertNodeOperation, type TInsertTextOperation, type TLocation, type TMergeNodeOperation, type TMoveNodeOperation, type TNode, type TNodeChildEntry, type TNodeEntry, type TNodeMatch, type TNodeOperation, type TNodeProps, type TOperation, type TPath, type TRange, type TRemoveNodeOperation, type TRemoveTextOperation, type TSelection, type TSelectionOperation, type TSetNodeOperation, type TSetSelectionOperation, type TSpan, type TSplitNodeOperation, type TText, type TTextEntry, type TTextOperation, type TextEntryOf, type TextOf, type UnhangRangeOptions, type UnsetNodesOptions, type UnwrapNodesOptions, type Value, type ValueOf, type WrapNodesOptions, addMark, addRangeMarks, collapseSelection, createPathRef, createPointRef, createRangeRef, createTEditor, deleteBackward, deleteForward, deleteFragment, deleteMerge, deleteText, deselect, elementMatches, findNode, getAboveNode, getCommonNode, getEdgePoints, getEditorString, getEndPoint, getFirstNode, getFragment, getLastNode, getLeafNode, getLevels, getMarks, getNextNode, getNode, getNodeAncestor, getNodeAncestors, getNodeChild, getNodeChildren, getNodeDescendant, getNodeDescendants, getNodeElements, getNodeEntries, getNodeEntry, getNodeFirstNode, getNodeFragment, getNodeLastNode, getNodeLeaf, getNodeLevels, getNodeParent, getNodeProps, getNodeString, getNodeTexts, getNodes, getParentNode, getPath, getPathRefs, getPoint, getPointAfter, getPointBefore, getPointRefs, getPositions, getPreviousNode, getQueryOptions, getRange, getRangeRefs, getStartPoint, getVoidNode, hasBlocks, hasInlines, hasNode, hasSingleChild, hasTexts, insertBreak, insertFragment, insertNode, insertNodes, insertText, isAncestor, isBlock, isCollapsed, isDescendant, isEdgePoint, isEditor, isEditorNormalizing, isElement, isElementEmpty, isElementList, isEndPoint, isExpanded, isHistoryEditor, isHistoryMerging, isHistorySaving, isInline, isMarkableVoid, isNode, isNodeList, isStartPoint, isText, isTextList, isVoid, liftNodes, match, mergeNodes, moveNodes, moveSelection, nodeMatches, normalizeEditor, queryNode, removeEditorMark, removeNodes, select, setElements, setNodes, setPoint, setSelection, someNode, splitNodes, textEquals, textMatches, unhangCharacterRange, unhangRange, unsetNodes, unwrapNodes, withHistory, withMerging, withNewBatch, withoutMergingHistory, withoutNormalizing, withoutSavingHistory, wrapNodes }; |
@@ -52,2 +52,8 @@ "use strict"; | ||
__export(src_exports, { | ||
HISTORY: () => HISTORY, | ||
History: () => History, | ||
HistoryEditor: () => HistoryEditor, | ||
MERGING: () => MERGING, | ||
SAVING: () => SAVING, | ||
SPLITTING_ONCE: () => SPLITTING_ONCE, | ||
addMark: () => addMark, | ||
@@ -170,3 +176,5 @@ addRangeMarks: () => addRangeMarks, | ||
unwrapNodes: () => unwrapNodes, | ||
withHistory: () => withHistory, | ||
withMerging: () => withMerging, | ||
withNewBatch: () => withNewBatch, | ||
withoutMergingHistory: () => withoutMergingHistory, | ||
@@ -755,25 +763,219 @@ withoutNormalizing: () => withoutNormalizing, | ||
// src/slate-history/history-editor.ts | ||
var import_slate64 = require("slate"); | ||
// src/slate-history/history.ts | ||
var import_is_plain_object = require("is-plain-object"); | ||
var import_slate63 = require("slate"); | ||
var History = { | ||
/** Check if a value is a `History` object. */ | ||
isHistory(value) { | ||
return (0, import_is_plain_object.isPlainObject)(value) && Array.isArray(value.redos) && Array.isArray(value.undos) && (value.redos.length === 0 || import_slate63.Operation.isOperationList(value.redos[0].operations)) && (value.undos.length === 0 || import_slate63.Operation.isOperationList(value.undos[0].operations)); | ||
} | ||
}; | ||
// src/slate-history/history-editor.ts | ||
var HISTORY = /* @__PURE__ */ new WeakMap(); | ||
var SAVING = /* @__PURE__ */ new WeakMap(); | ||
var MERGING = /* @__PURE__ */ new WeakMap(); | ||
var SPLITTING_ONCE = /* @__PURE__ */ new WeakMap(); | ||
var HistoryEditor = { | ||
/** Check if a value is a `HistoryEditor` object. */ | ||
isHistoryEditor(value) { | ||
return History.isHistory(value.history) && import_slate64.Editor.isEditor(value); | ||
}, | ||
/** Get the merge flag's current value. */ | ||
isMerging(editor) { | ||
return MERGING.get(editor); | ||
}, | ||
/** Get the splitting once flag's current value. */ | ||
isSaving(editor) { | ||
return SAVING.get(editor); | ||
}, | ||
isSplittingOnce(editor) { | ||
return SPLITTING_ONCE.get(editor); | ||
}, | ||
/** Get the saving flag's current value. */ | ||
redo(editor) { | ||
editor.redo(); | ||
}, | ||
/** Redo to the previous saved state. */ | ||
setSplittingOnce(editor, value) { | ||
SPLITTING_ONCE.set(editor, value); | ||
}, | ||
/** Undo to the previous saved state. */ | ||
undo(editor) { | ||
editor.undo(); | ||
}, | ||
/** | ||
* Apply a series of changes inside a synchronous `fn`, These operations will | ||
* be merged into the previous history. | ||
*/ | ||
withMerging(editor, fn) { | ||
const prev = HistoryEditor.isMerging(editor); | ||
MERGING.set(editor, true); | ||
fn(); | ||
MERGING.set(editor, prev); | ||
}, | ||
/** | ||
* Apply a series of changes inside a synchronous `fn`, ensuring that the | ||
* first operation starts a new batch in the history. Subsequent operations | ||
* will be merged as usual. | ||
*/ | ||
withNewBatch(editor, fn) { | ||
const prev = HistoryEditor.isMerging(editor); | ||
MERGING.set(editor, true); | ||
SPLITTING_ONCE.set(editor, true); | ||
fn(); | ||
MERGING.set(editor, prev); | ||
SPLITTING_ONCE.delete(editor); | ||
}, | ||
/** | ||
* Apply a series of changes inside a synchronous `fn`, without merging any of | ||
* the new operations into previous save point in the history. | ||
*/ | ||
withoutMerging(editor, fn) { | ||
const prev = HistoryEditor.isMerging(editor); | ||
MERGING.set(editor, false); | ||
fn(); | ||
MERGING.set(editor, prev); | ||
}, | ||
/** | ||
* Apply a series of changes inside a synchronous `fn`, without saving any of | ||
* their operations into the history. | ||
*/ | ||
withoutSaving(editor, fn) { | ||
const prev = HistoryEditor.isSaving(editor); | ||
SAVING.set(editor, false); | ||
fn(); | ||
SAVING.set(editor, prev); | ||
} | ||
}; | ||
// src/slate-history/with-history.ts | ||
var import_slate65 = require("slate"); | ||
var withHistory = (editor) => { | ||
const e = editor; | ||
const { apply } = e; | ||
e.history = { redos: [], undos: [] }; | ||
e.redo = () => { | ||
const { history } = e; | ||
const { redos } = history; | ||
if (redos.length > 0) { | ||
const batch = redos.at(-1); | ||
if (batch.selectionBefore) { | ||
import_slate65.Transforms.setSelection(e, batch.selectionBefore); | ||
} | ||
HistoryEditor.withoutSaving(e, () => { | ||
import_slate65.Editor.withoutNormalizing(e, () => { | ||
for (const op of batch.operations) { | ||
e.apply(op); | ||
} | ||
}); | ||
}); | ||
history.redos.pop(); | ||
e.writeHistory("undos", batch); | ||
} | ||
}; | ||
e.undo = () => { | ||
const { history } = e; | ||
const { undos } = history; | ||
if (undos.length > 0) { | ||
const batch = undos.at(-1); | ||
HistoryEditor.withoutSaving(e, () => { | ||
import_slate65.Editor.withoutNormalizing(e, () => { | ||
const inverseOps = batch.operations.map(import_slate65.Operation.inverse).reverse(); | ||
for (const op of inverseOps) { | ||
e.apply(op); | ||
} | ||
if (batch.selectionBefore) { | ||
import_slate65.Transforms.setSelection(e, batch.selectionBefore); | ||
} | ||
}); | ||
}); | ||
e.writeHistory("redos", batch); | ||
history.undos.pop(); | ||
} | ||
}; | ||
e.apply = (op) => { | ||
const { history, operations } = e; | ||
const { undos } = history; | ||
const lastBatch = undos.at(-1); | ||
const lastOp = lastBatch == null ? void 0 : lastBatch.operations.at(-1); | ||
let save = HistoryEditor.isSaving(e); | ||
let merge = HistoryEditor.isMerging(e); | ||
if (save == null) { | ||
save = shouldSave(op, lastOp); | ||
} | ||
if (save) { | ||
if (merge == null) { | ||
if (lastBatch == null) { | ||
merge = false; | ||
} else if (operations.length > 0) { | ||
merge = true; | ||
} else { | ||
merge = shouldMerge(op, lastOp); | ||
} | ||
} | ||
if (HistoryEditor.isSplittingOnce(e)) { | ||
merge = false; | ||
HistoryEditor.setSplittingOnce(e, void 0); | ||
} | ||
if (lastBatch && merge) { | ||
lastBatch.operations.push(op); | ||
} else { | ||
const batch = { | ||
operations: [op], | ||
selectionBefore: e.selection | ||
}; | ||
e.writeHistory("undos", batch); | ||
} | ||
while (undos.length > 100) { | ||
undos.shift(); | ||
} | ||
history.redos = []; | ||
} | ||
apply(op); | ||
}; | ||
e.writeHistory = (stack, batch) => { | ||
e.history[stack].push(batch); | ||
}; | ||
return e; | ||
}; | ||
var shouldMerge = (op, prev) => { | ||
if (prev && op.type === "insert_text" && prev.type === "insert_text" && op.offset === prev.offset + prev.text.length && import_slate65.Path.equals(op.path, prev.path)) { | ||
return true; | ||
} | ||
if (prev && op.type === "remove_text" && prev.type === "remove_text" && op.offset + op.text.length === prev.offset && import_slate65.Path.equals(op.path, prev.path)) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
var shouldSave = (op, _) => { | ||
if (op.type === "set_selection") { | ||
return false; | ||
} | ||
return true; | ||
}; | ||
// src/interfaces/history-editor/isHistoryEditor.ts | ||
var import_slate_history = require("slate-history"); | ||
var isHistoryEditor = (value) => import_slate_history.HistoryEditor.isHistoryEditor(value); | ||
var isHistoryEditor = (value) => HistoryEditor.isHistoryEditor(value); | ||
// src/interfaces/history-editor/isHistoryMerging.ts | ||
var import_slate_history2 = require("slate-history"); | ||
var isHistoryMerging = (editor) => import_slate_history2.HistoryEditor.isMerging(editor); | ||
var isHistoryMerging = (editor) => HistoryEditor.isMerging(editor); | ||
// src/interfaces/history-editor/isHistorySaving.ts | ||
var import_slate_history3 = require("slate-history"); | ||
var isHistorySaving = (editor) => import_slate_history3.HistoryEditor.isSaving(editor); | ||
var isHistorySaving = (editor) => HistoryEditor.isSaving(editor); | ||
// src/interfaces/history-editor/withMerging.ts | ||
var import_slate_history4 = require("slate-history"); | ||
var withMerging = (editor, fn) => import_slate_history4.HistoryEditor.withMerging(editor, fn); | ||
var withMerging = (editor, fn) => HistoryEditor.withMerging(editor, fn); | ||
// src/interfaces/history-editor/withNewBatch.ts | ||
var withNewBatch = (editor, fn) => HistoryEditor.withNewBatch(editor, fn); | ||
// src/interfaces/history-editor/withoutMergingHistory.ts | ||
var import_slate_history5 = require("slate-history"); | ||
var withoutMergingHistory = (editor, fn) => import_slate_history5.HistoryEditor.withoutMerging(editor, fn); | ||
var withoutMergingHistory = (editor, fn) => HistoryEditor.withoutMerging(editor, fn); | ||
// src/interfaces/history-editor/withoutSavingHistory.ts | ||
var import_slate_history6 = require("slate-history"); | ||
var withoutSavingHistory = (editor, fn) => import_slate_history6.HistoryEditor.withoutSaving(editor, fn); | ||
var withoutSavingHistory = (editor, fn) => HistoryEditor.withoutSaving(editor, fn); | ||
@@ -784,16 +986,16 @@ // src/interfaces/node/TDescendant.ts | ||
// src/interfaces/node/getCommonNode.ts | ||
var import_slate63 = require("slate"); | ||
var getCommonNode = (root, path, another) => import_slate63.Node.common(root, path, another); | ||
var import_slate66 = require("slate"); | ||
var getCommonNode = (root, path, another) => import_slate66.Node.common(root, path, another); | ||
// src/interfaces/text/isTextList.ts | ||
var import_slate64 = require("slate"); | ||
var isTextList = (value) => import_slate64.Text.isTextList(value); | ||
var import_slate67 = require("slate"); | ||
var isTextList = (value) => import_slate67.Text.isTextList(value); | ||
// src/interfaces/text/textEquals.ts | ||
var import_slate65 = require("slate"); | ||
var textEquals = (text, another) => import_slate65.Text.equals(text, another); | ||
var import_slate68 = require("slate"); | ||
var textEquals = (text, another) => import_slate68.Text.equals(text, another); | ||
// src/interfaces/text/textMatches.ts | ||
var import_slate66 = require("slate"); | ||
var textMatches = (text, props) => import_slate66.Text.matches(text, props); | ||
var import_slate69 = require("slate"); | ||
var textMatches = (text, props) => import_slate69.Text.matches(text, props); | ||
@@ -817,117 +1019,117 @@ // src/interfaces/node/getNode.ts | ||
// src/interfaces/node/getNodeAncestor.ts | ||
var import_slate67 = require("slate"); | ||
var getNodeAncestor = (root, path) => import_slate67.Node.ancestor(root, path); | ||
var import_slate70 = require("slate"); | ||
var getNodeAncestor = (root, path) => import_slate70.Node.ancestor(root, path); | ||
// src/interfaces/node/getNodeAncestors.ts | ||
var import_slate68 = require("slate"); | ||
var getNodeAncestors = (root, path, options) => import_slate68.Node.ancestors(root, path, options); | ||
var import_slate71 = require("slate"); | ||
var getNodeAncestors = (root, path, options) => import_slate71.Node.ancestors(root, path, options); | ||
// src/interfaces/node/getNodeChild.ts | ||
var import_slate69 = require("slate"); | ||
var getNodeChild = (root, index) => import_slate69.Node.child(root, index); | ||
var import_slate72 = require("slate"); | ||
var getNodeChild = (root, index) => import_slate72.Node.child(root, index); | ||
// src/interfaces/node/getNodeChildren.ts | ||
var import_slate70 = require("slate"); | ||
var getNodeChildren = (root, path, options) => import_slate70.Node.children(root, path, options); | ||
var import_slate73 = require("slate"); | ||
var getNodeChildren = (root, path, options) => import_slate73.Node.children(root, path, options); | ||
// src/interfaces/node/getNodeDescendant.ts | ||
var import_slate71 = require("slate"); | ||
var getNodeDescendant = (root, path) => import_slate71.Node.descendant(root, path); | ||
var import_slate74 = require("slate"); | ||
var getNodeDescendant = (root, path) => import_slate74.Node.descendant(root, path); | ||
// src/interfaces/node/getNodeDescendants.ts | ||
var import_slate72 = require("slate"); | ||
var getNodeDescendants = (root, options) => import_slate72.Node.descendants(root, options); | ||
var import_slate75 = require("slate"); | ||
var getNodeDescendants = (root, options) => import_slate75.Node.descendants(root, options); | ||
// src/interfaces/node/getNodeElements.ts | ||
var import_slate73 = require("slate"); | ||
var getNodeElements = (root, options) => import_slate73.Node.elements(root, options); | ||
var import_slate76 = require("slate"); | ||
var getNodeElements = (root, options) => import_slate76.Node.elements(root, options); | ||
// src/interfaces/node/getNodeFirstNode.ts | ||
var import_slate74 = require("slate"); | ||
var getNodeFirstNode = (root, path) => import_slate74.Node.first(root, path); | ||
var import_slate77 = require("slate"); | ||
var getNodeFirstNode = (root, path) => import_slate77.Node.first(root, path); | ||
// src/interfaces/node/getNodeFragment.ts | ||
var import_slate75 = require("slate"); | ||
var getNodeFragment = (root, range) => import_slate75.Node.fragment(root, range); | ||
var import_slate78 = require("slate"); | ||
var getNodeFragment = (root, range) => import_slate78.Node.fragment(root, range); | ||
// src/interfaces/node/getNodeLastNode.ts | ||
var import_slate76 = require("slate"); | ||
var getNodeLastNode = (root, path) => import_slate76.Node.last(root, path); | ||
var import_slate79 = require("slate"); | ||
var getNodeLastNode = (root, path) => import_slate79.Node.last(root, path); | ||
// src/interfaces/node/getNodeLeaf.ts | ||
var import_slate77 = require("slate"); | ||
var getNodeLeaf = (root, path) => import_slate77.Node.leaf(root, path); | ||
var import_slate80 = require("slate"); | ||
var getNodeLeaf = (root, path) => import_slate80.Node.leaf(root, path); | ||
// src/interfaces/node/getNodeLevels.ts | ||
var import_slate78 = require("slate"); | ||
var getNodeLevels = (root, path, options) => import_slate78.Node.levels(root, path, options); | ||
var import_slate81 = require("slate"); | ||
var getNodeLevels = (root, path, options) => import_slate81.Node.levels(root, path, options); | ||
// src/interfaces/node/getNodeParent.ts | ||
var import_slate79 = require("slate"); | ||
var getNodeParent = (root, path) => import_slate79.Node.parent(root, path); | ||
var import_slate82 = require("slate"); | ||
var getNodeParent = (root, path) => import_slate82.Node.parent(root, path); | ||
// src/interfaces/node/getNodeProps.ts | ||
var import_slate80 = require("slate"); | ||
var getNodeProps = (node) => import_slate80.Node.extractProps(node); | ||
var import_slate83 = require("slate"); | ||
var getNodeProps = (node) => import_slate83.Node.extractProps(node); | ||
// src/interfaces/node/getNodeString.ts | ||
var import_slate81 = require("slate"); | ||
var getNodeString = (node) => import_slate81.Node.string(node); | ||
var import_slate84 = require("slate"); | ||
var getNodeString = (node) => import_slate84.Node.string(node); | ||
// src/interfaces/node/getNodeTexts.ts | ||
var import_slate82 = require("slate"); | ||
var getNodeTexts = (root, options) => import_slate82.Node.texts(root, options); | ||
var import_slate85 = require("slate"); | ||
var getNodeTexts = (root, options) => import_slate85.Node.texts(root, options); | ||
// src/interfaces/node/getNodes.ts | ||
var import_slate83 = require("slate"); | ||
var getNodes = (root, options) => import_slate83.Node.nodes(root, options); | ||
var import_slate86 = require("slate"); | ||
var getNodes = (root, options) => import_slate86.Node.nodes(root, options); | ||
// src/interfaces/node/hasNode.ts | ||
var import_slate84 = require("slate"); | ||
var hasNode = (root, path) => import_slate84.Node.has(root, path); | ||
var import_slate87 = require("slate"); | ||
var hasNode = (root, path) => import_slate87.Node.has(root, path); | ||
// src/interfaces/node/isAncestor.ts | ||
var import_slate85 = require("slate"); | ||
var isAncestor = (value) => import_slate85.Element.isAncestor(value); | ||
var import_slate88 = require("slate"); | ||
var isAncestor = (value) => import_slate88.Element.isAncestor(value); | ||
// src/interfaces/node/isNode.ts | ||
var import_slate86 = require("slate"); | ||
var isNode = (value) => import_slate86.Node.isNode(value); | ||
var import_slate89 = require("slate"); | ||
var isNode = (value) => import_slate89.Node.isNode(value); | ||
// src/interfaces/node/isNodeList.ts | ||
var import_slate87 = require("slate"); | ||
var isNodeList = (value) => import_slate87.Node.isNodeList(value); | ||
var import_slate90 = require("slate"); | ||
var isNodeList = (value) => import_slate90.Node.isNodeList(value); | ||
// src/interfaces/node/nodeMatches.ts | ||
var import_slate88 = require("slate"); | ||
var nodeMatches = (node, props) => import_slate88.Node.matches(node, props); | ||
var import_slate91 = require("slate"); | ||
var nodeMatches = (node, props) => import_slate91.Node.matches(node, props); | ||
// src/interfaces/range/isCollapsed.ts | ||
var import_slate89 = require("slate"); | ||
var isCollapsed = (range) => !!range && import_slate89.Range.isCollapsed(range); | ||
var import_slate92 = require("slate"); | ||
var isCollapsed = (range) => !!range && import_slate92.Range.isCollapsed(range); | ||
// src/interfaces/range/isExpanded.ts | ||
var import_slate90 = require("slate"); | ||
var isExpanded = (range) => !!range && import_slate90.Range.isExpanded(range); | ||
var import_slate93 = require("slate"); | ||
var isExpanded = (range) => !!range && import_slate93.Range.isExpanded(range); | ||
// src/interfaces/transforms/collapseSelection.ts | ||
var import_slate91 = require("slate"); | ||
var import_slate94 = require("slate"); | ||
var collapseSelection = (editor, options) => { | ||
import_slate91.Transforms.collapse(editor, options); | ||
import_slate94.Transforms.collapse(editor, options); | ||
}; | ||
// src/interfaces/transforms/deselect.ts | ||
var import_slate92 = require("slate"); | ||
var import_slate95 = require("slate"); | ||
var deselect = (editor) => { | ||
import_slate92.Transforms.deselect(editor); | ||
import_slate95.Transforms.deselect(editor); | ||
}; | ||
// src/interfaces/transforms/insertFragment.ts | ||
var import_slate93 = require("slate"); | ||
var import_slate96 = require("slate"); | ||
var insertFragment = (editor, fragment, options) => { | ||
import_slate93.Transforms.insertFragment(editor, fragment, options); | ||
import_slate96.Transforms.insertFragment(editor, fragment, options); | ||
}; | ||
// src/interfaces/transforms/insertNodes.ts | ||
var import_slate94 = require("slate"); | ||
var import_slate97 = require("slate"); | ||
@@ -971,3 +1173,3 @@ // src/utils/queryNode.ts | ||
var _b = _a, { nextBlock, removeEmpty } = _b, options = __objRest(_b, ["nextBlock", "removeEmpty"]); | ||
(0, import_slate94.withoutNormalizing)(editor, () => { | ||
(0, import_slate97.withoutNormalizing)(editor, () => { | ||
if (removeEmpty) { | ||
@@ -987,3 +1189,3 @@ const blockEntry = getAboveNode(editor, { at: options.at }); | ||
if (queryNode(blockEntry, queryNodeOptions)) { | ||
(0, import_slate94.removeNodes)(editor, { at: blockEntry[1] }); | ||
(0, import_slate97.removeNodes)(editor, { at: blockEntry[1] }); | ||
nextBlock = false; | ||
@@ -1002,7 +1204,7 @@ } | ||
if (blockEntry) { | ||
options.at = import_slate94.Path.next(blockEntry[1]); | ||
options.at = import_slate97.Path.next(blockEntry[1]); | ||
} | ||
} | ||
} | ||
import_slate94.Transforms.insertNodes(editor, nodes, options); | ||
import_slate97.Transforms.insertNodes(editor, nodes, options); | ||
}); | ||
@@ -1012,54 +1214,54 @@ }; | ||
// src/interfaces/transforms/insertText.ts | ||
var import_slate95 = require("slate"); | ||
var import_slate98 = require("slate"); | ||
var insertText = (editor, text, options) => { | ||
import_slate95.Transforms.insertText(editor, text, options); | ||
import_slate98.Transforms.insertText(editor, text, options); | ||
}; | ||
// src/interfaces/transforms/liftNodes.ts | ||
var import_slate96 = require("slate"); | ||
var liftNodes = (editor, options) => import_slate96.Transforms.liftNodes(editor, options); | ||
var import_slate99 = require("slate"); | ||
var liftNodes = (editor, options) => import_slate99.Transforms.liftNodes(editor, options); | ||
// src/interfaces/transforms/moveSelection.ts | ||
var import_slate97 = require("slate"); | ||
var import_slate100 = require("slate"); | ||
var moveSelection = (editor, options) => { | ||
import_slate97.Transforms.move(editor, options); | ||
import_slate100.Transforms.move(editor, options); | ||
}; | ||
// src/interfaces/transforms/setNodes.ts | ||
var import_slate98 = require("slate"); | ||
var setNodes = (editor, props, options) => import_slate98.Transforms.setNodes(editor, props, options); | ||
var import_slate101 = require("slate"); | ||
var setNodes = (editor, props, options) => import_slate101.Transforms.setNodes(editor, props, options); | ||
// src/interfaces/transforms/setPoint.ts | ||
var import_slate99 = require("slate"); | ||
var import_slate102 = require("slate"); | ||
var setPoint = (editor, props, options) => { | ||
import_slate99.Transforms.setPoint(editor, props, options); | ||
import_slate102.Transforms.setPoint(editor, props, options); | ||
}; | ||
// src/interfaces/transforms/setSelection.ts | ||
var import_slate100 = require("slate"); | ||
var import_slate103 = require("slate"); | ||
var setSelection = (editor, props) => { | ||
import_slate100.Transforms.setSelection(editor, props); | ||
import_slate103.Transforms.setSelection(editor, props); | ||
}; | ||
// src/interfaces/transforms/splitNodes.ts | ||
var import_slate101 = require("slate"); | ||
var splitNodes = (editor, options) => import_slate101.Transforms.splitNodes(editor, options); | ||
var import_slate104 = require("slate"); | ||
var splitNodes = (editor, options) => import_slate104.Transforms.splitNodes(editor, options); | ||
// src/interfaces/transforms/unsetNodes.ts | ||
var import_slate102 = require("slate"); | ||
var import_slate105 = require("slate"); | ||
var unsetNodes = (editor, props, options) => { | ||
return import_slate102.Transforms.unsetNodes(editor, props, options); | ||
return import_slate105.Transforms.unsetNodes(editor, props, options); | ||
}; | ||
// src/interfaces/transforms/unwrapNodes.ts | ||
var import_slate103 = require("slate"); | ||
var import_slate106 = require("slate"); | ||
var unwrapNodes = (editor, options) => { | ||
import_slate103.Transforms.unwrapNodes(editor, getQueryOptions(editor, options)); | ||
import_slate106.Transforms.unwrapNodes(editor, getQueryOptions(editor, options)); | ||
}; | ||
// src/interfaces/transforms/wrapNodes.ts | ||
var import_slate104 = require("slate"); | ||
var import_slate107 = require("slate"); | ||
var wrapNodes = (editor, element, options) => { | ||
unhangRange(editor, options == null ? void 0 : options.at, options); | ||
import_slate104.Transforms.wrapNodes(editor, element, options); | ||
import_slate107.Transforms.wrapNodes(editor, element, options); | ||
}; | ||
@@ -1087,3 +1289,3 @@ | ||
// src/transforms/addRangeMarks.ts | ||
var import_slate105 = require("slate"); | ||
var import_slate108 = require("slate"); | ||
var addRangeMarks = (editor, props, { | ||
@@ -1093,10 +1295,10 @@ at = editor.selection | ||
if (at) { | ||
if (import_slate105.Path.isPath(at)) { | ||
if (import_slate108.Path.isPath(at)) { | ||
at = getRange(editor, at); | ||
} | ||
const match2 = (node, path) => { | ||
if (!import_slate105.Text.isText(node)) { | ||
if (!import_slate108.Text.isText(node)) { | ||
return false; | ||
} | ||
const parentEntry = import_slate105.Editor.parent(editor, path); | ||
const parentEntry = import_slate108.Editor.parent(editor, path); | ||
if (!parentEntry) return false; | ||
@@ -1106,10 +1308,10 @@ const [parentNode] = parentEntry; | ||
}; | ||
const isExpandedRange = import_slate105.Range.isExpanded(at); | ||
const isExpandedRange = import_slate108.Range.isExpanded(at); | ||
let markAcceptingVoidSelected = false; | ||
if (!isExpandedRange) { | ||
const selectedEntry = import_slate105.Editor.node(editor, at); | ||
const selectedEntry = import_slate108.Editor.node(editor, at); | ||
if (!selectedEntry) return; | ||
const [selectedNode, selectedPath] = selectedEntry; | ||
if (selectedNode && match2(selectedNode, selectedPath)) { | ||
const parentEntry = import_slate105.Editor.parent(editor, selectedPath); | ||
const parentEntry = import_slate108.Editor.parent(editor, selectedPath); | ||
if (!parentEntry) return; | ||
@@ -1121,3 +1323,3 @@ const [parentNode] = parentEntry; | ||
if (isExpandedRange || markAcceptingVoidSelected) { | ||
import_slate105.Transforms.setNodes(editor, props, { | ||
import_slate108.Transforms.setNodes(editor, props, { | ||
at, | ||
@@ -1136,6 +1338,6 @@ match: match2, | ||
// src/transforms/unhangCharacterRange.ts | ||
var import_slate106 = require("slate"); | ||
var import_slate109 = require("slate"); | ||
var unhangCharacterRange = (editor, at) => { | ||
let [start, end] = import_slate106.Range.edges(at); | ||
if (!import_slate106.Path.equals(start.path, end.path)) { | ||
let [start, end] = import_slate109.Range.edges(at); | ||
if (!import_slate109.Path.equals(start.path, end.path)) { | ||
if (end.offset === 0) { | ||
@@ -1157,2 +1359,8 @@ const pointAfter = getPointAfter(editor, start); | ||
0 && (module.exports = { | ||
HISTORY, | ||
History, | ||
HistoryEditor, | ||
MERGING, | ||
SAVING, | ||
SPLITTING_ONCE, | ||
addMark, | ||
@@ -1275,3 +1483,5 @@ addRangeMarks, | ||
unwrapNodes, | ||
withHistory, | ||
withMerging, | ||
withNewBatch, | ||
withoutMergingHistory, | ||
@@ -1278,0 +1488,0 @@ withoutNormalizing, |
{ | ||
"name": "@udecode/slate", | ||
"version": "38.0.4", | ||
"version": "40.3.1", | ||
"description": "Slate extension", | ||
@@ -45,6 +45,7 @@ "keywords": [ | ||
"dependencies": { | ||
"@udecode/utils": "37.0.0" | ||
"@udecode/utils": "37.0.0", | ||
"is-plain-object": "^5.0.0" | ||
}, | ||
"peerDependencies": { | ||
"slate": ">=0.103.0", | ||
"slate": ">=0.112.0", | ||
"slate-history": ">=0.93.0" | ||
@@ -51,0 +52,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 not supported yet
Sorry, the diff of this file is not supported yet
400501
3313
4
+ Addedis-plain-object@^5.0.0