@prosekit/core 0.5.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,6 +27,7 @@ import { Options } from 'tsup';
27
27
  import { Plugin as Plugin_2 } from '@prosekit/pm/state';
28
28
  import { ProseMirrorFragment } from '@prosekit/pm/model';
29
29
  import { ProseMirrorNode } from '@prosekit/pm/model';
30
+ import type { ResolvedPos } from '@prosekit/pm/model';
30
31
  import { Schema } from '@prosekit/pm/model';
31
32
  import { SchemaSpec } from '@prosekit/pm/model';
32
33
  import { Selection as Selection_2 } from '@prosekit/pm/state';
@@ -257,47 +258,51 @@ declare function defineBaseCommands(): Extension<{
257
258
  Commands: {
258
259
  insertText: [{
259
260
  text: string;
260
- from?: number | undefined;
261
- to?: number | undefined;
261
+ from?: number;
262
+ to?: number;
262
263
  }];
263
264
  insertNode: [options: {
264
265
  node: Node_2;
265
- pos?: number | undefined;
266
+ pos?: number;
266
267
  type?: undefined;
267
268
  attrs?: undefined;
268
269
  } | {
269
270
  node?: undefined;
270
- pos?: number | undefined;
271
+ pos?: number;
271
272
  type: string;
272
- attrs?: Attrs_2 | undefined;
273
+ attrs?: Attrs_2;
274
+ }];
275
+ removeNode: [options: {
276
+ type: string | NodeType_2;
277
+ pos?: number;
273
278
  }];
274
279
  wrap: [{
275
280
  nodeType: NodeType_2;
276
- attrs?: Attrs_2 | null | undefined;
281
+ attrs?: Attrs_2 | null;
277
282
  }];
278
283
  setBlockType: [options: {
279
- type: string | NodeType_2;
280
- attrs?: Attrs_2 | null | undefined;
281
- from?: number | undefined;
282
- to?: number | undefined;
284
+ type: NodeType_2 | string;
285
+ attrs?: Attrs_2 | null;
286
+ from?: number;
287
+ to?: number;
283
288
  }];
284
289
  setNodeAttrs: [options: {
285
290
  type: string | NodeType_2 | string[] | NodeType_2[];
286
291
  attrs: Attrs_2;
287
- pos?: number | undefined;
292
+ pos?: number;
288
293
  }];
289
294
  selectAll: [];
290
295
  addMark: [options: {
291
296
  type: string | MarkType_2;
292
- attrs?: Attrs_2 | null | undefined;
293
- from?: number | undefined;
294
- to?: number | undefined;
297
+ attrs?: Attrs_2 | null;
298
+ from?: number;
299
+ to?: number;
295
300
  }];
296
301
  removeMark: [options: {
297
302
  type: string | MarkType_2;
298
- attrs?: Attrs_2 | null | undefined;
299
- from?: number | undefined;
300
- to?: number | undefined;
303
+ attrs?: Attrs_2 | null;
304
+ from?: number;
305
+ to?: number;
301
306
  }];
302
307
  };
303
308
  Nodes: never;
@@ -987,9 +992,9 @@ export declare class FacetNode<I = any, O = any> {
987
992
  readonly facet: Facet<I, O>;
988
993
  readonly inputs: Tuple5<I[] | null>;
989
994
  readonly children: Map<number, FacetNode>;
990
- reducers: Tuple5<FacetReducer<I, O> | null>;
995
+ readonly reducers: Tuple5<FacetReducer<I, O> | null>;
991
996
  output: Tuple5<O | null> | null;
992
- constructor(facet: Facet<I, O>, inputs?: Tuple5<I[] | null>, children?: Map<number, FacetNode>);
997
+ constructor(facet: Facet<I, O>, inputs?: Tuple5<I[] | null>, children?: Map<number, FacetNode>, reducers?: Tuple5<FacetReducer<I, O> | null>);
993
998
  private calcOutput;
994
999
  getOutput(): Tuple5<O | null>;
995
1000
  getSingletonOutput(): O | null;
@@ -1010,6 +1015,11 @@ export declare function findBrowserWindow(options?: {
1010
1015
  document?: Document;
1011
1016
  }): (Window & typeof globalThis) | null | undefined;
1012
1017
 
1018
+ export declare function findParentNode(nodeType: NodeType, $pos: ResolvedPos): {
1019
+ from: number | null;
1020
+ to: number | null;
1021
+ };
1022
+
1013
1023
  /**
1014
1024
  * A function that is called when the editor gains or loses focus.
1015
1025
  *
@@ -1558,6 +1568,24 @@ declare function removeMark(options: {
1558
1568
  export { removeMark }
1559
1569
  export { removeMark as removeMark_alias_1 }
1560
1570
 
1571
+ /**
1572
+ * Returns a command to remove the nearest ancestor node of a specific type from the current position.
1573
+ *
1574
+ * @public
1575
+ */
1576
+ declare function removeNode(options: {
1577
+ /**
1578
+ * The type of the node to remove.
1579
+ */
1580
+ type: string | NodeType;
1581
+ /**
1582
+ * The document position to start searching node. By default it will be the anchor position of current selection.
1583
+ */
1584
+ pos?: number;
1585
+ }): Command;
1586
+ export { removeNode }
1587
+ export { removeNode as removeNode_alias_1 }
1588
+
1561
1589
  export declare const rootFacet: Facet<RootPayload, RootOutput>;
1562
1590
 
1563
1591
  export declare type RootOutput = {
@@ -1652,7 +1680,7 @@ export declare function setSelectionAround(tr: Transaction, pos: number): void;
1652
1680
  export declare type Setter<T> = (value: T) => void;
1653
1681
 
1654
1682
  /**
1655
- * @intneral
1683
+ * @internal
1656
1684
  */
1657
1685
  declare type SimplifyUnion<T> = Simplify<UnionToIntersection<T>>;
1658
1686
  export { SimplifyUnion }
@@ -1691,6 +1719,14 @@ export declare type StatePayload = (ctx: {
1691
1719
  schema: Schema;
1692
1720
  }) => EditorStateConfig;
1693
1721
 
1722
+ /**
1723
+ * Takes two facet nodes and returns a new facet node containing inputs and
1724
+ * children from the first node but not the second.
1725
+ *
1726
+ * The reducers of the first facet node will be reused.
1727
+ *
1728
+ * @internal
1729
+ */
1694
1730
  export declare function subtractFacetNode<I, O>(a: FacetNode<I, O>, b: FacetNode<I, O>): FacetNode<I, O>;
1695
1731
 
1696
1732
  declare type TextInputHandler = (view: EditorView, from: number, to: number, text: string) => boolean | void;
@@ -1748,6 +1784,8 @@ export declare type Tuple5<T> = [T, T, T, T, T];
1748
1784
  /**
1749
1785
  * Merge multiple extensions into one.
1750
1786
  *
1787
+ * @throws If no extensions are provided.
1788
+ *
1751
1789
  * @public
1752
1790
  */
1753
1791
  declare function union<E extends Extension | Extension[]>(extension: E): UnionExtension<E>;
@@ -1777,6 +1815,14 @@ export declare class UnionExtensionImpl<T extends ExtensionTyping = ExtensionTyp
1777
1815
  createTree(priority: Priority): FacetNode;
1778
1816
  }
1779
1817
 
1818
+ /**
1819
+ * Takes two facet nodes and returns a new facet node containing inputs and
1820
+ * children from both nodes.
1821
+ *
1822
+ * The reducers of the first facet node will be reused.
1823
+ *
1824
+ * @internal
1825
+ */
1780
1826
  export declare function unionFacetNode<I, O>(a: FacetNode<I, O>, b: FacetNode<I, O>): FacetNode<I, O>;
1781
1827
 
1782
1828
  export declare function uniqPush<T>(prev: readonly T[], next: readonly T[]): T[];
@@ -1,6 +1,7 @@
1
1
  export { addMark } from './_tsup-dts-rollup';
2
2
  export { expandMark } from './_tsup-dts-rollup';
3
3
  export { insertNode } from './_tsup-dts-rollup';
4
+ export { removeNode } from './_tsup-dts-rollup';
4
5
  export { removeMark } from './_tsup-dts-rollup';
5
6
  export { setBlockType } from './_tsup-dts-rollup';
6
7
  export { setNodeAttrs } from './_tsup-dts-rollup';