@prosekit/core 0.8.2 → 0.8.3

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.
@@ -241,66 +241,66 @@ function toReversed(arr) {
241
241
  //#endregion
242
242
  //#region src/utils/type-assertion.ts
243
243
  /**
244
- * Checks if the given object is a `ProseMirrorNode` instance.
244
+ * Checks if the given object is a {@link ProseMirrorNode} instance.
245
245
  */
246
- function isProseMirrorNode(node) {
247
- return node instanceof ProseMirrorNode;
246
+ function isProseMirrorNode(value) {
247
+ return value instanceof ProseMirrorNode;
248
248
  }
249
249
  /**
250
- * Checks if the given object is a `Mark` instance.
250
+ * Checks if the given object is a {@link Mark} instance.
251
251
  *
252
252
  * @public
253
253
  */
254
- function isMark(mark) {
255
- return mark instanceof Mark;
254
+ function isMark(value) {
255
+ return value instanceof Mark;
256
256
  }
257
257
  /**
258
- * Checks if the given object is a `Fragment` instance.
258
+ * Checks if the given object is a {@link Fragment} instance.
259
259
  *
260
260
  * @public
261
261
  */
262
- function isFragment(fragment) {
263
- return fragment instanceof Fragment;
262
+ function isFragment(value) {
263
+ return value instanceof Fragment;
264
264
  }
265
265
  /**
266
- * Checks if the given object is a `Slice` instance.
266
+ * Checks if the given object is a {@link Slice} instance.
267
267
  *
268
268
  * @public
269
269
  */
270
- function isSlice(slice) {
271
- return slice instanceof Slice;
270
+ function isSlice(value) {
271
+ return value instanceof Slice;
272
272
  }
273
273
  /**
274
- * Checks if the given object is a `Selection` instance.
274
+ * Checks if the given object is a {@link Selection} instance.
275
275
  *
276
276
  * @public
277
277
  */
278
- function isSelection(sel) {
279
- return sel instanceof Selection;
278
+ function isSelection(value) {
279
+ return value instanceof Selection;
280
280
  }
281
281
  /**
282
- * Checks if the given object is a `TextSelection` instance.
282
+ * Checks if the given object is a {@link TextSelection} instance.
283
283
  *
284
284
  * @public
285
285
  */
286
- function isTextSelection(sel) {
287
- return sel instanceof TextSelection;
286
+ function isTextSelection(value) {
287
+ return value instanceof TextSelection;
288
288
  }
289
289
  /**
290
- * Checks if the given object is a `NodeSelection` instance.
290
+ * Checks if the given object is a {@link NodeSelection} instance.
291
291
  *
292
292
  * @public
293
293
  */
294
- function isNodeSelection(sel) {
295
- return sel instanceof NodeSelection;
294
+ function isNodeSelection(value) {
295
+ return value instanceof NodeSelection;
296
296
  }
297
297
  /**
298
- * Checks if the given object is a `AllSelection` instance.
298
+ * Checks if the given object is a {@link AllSelection} instance.
299
299
  *
300
300
  * @public
301
301
  */
302
- function isAllSelection(sel) {
303
- return sel instanceof AllSelection;
302
+ function isAllSelection(value) {
303
+ return value instanceof AllSelection;
304
304
  }
305
305
  /**
306
306
  * @internal
@@ -620,6 +620,7 @@ function nodeFromJSON(json, options) {
620
620
  * ```ts
621
621
  * const element = document.getElementById('content')
622
622
  * const node = nodeFromElement(element, { schema: editor.schema })
623
+ * ```
623
624
  */
624
625
  function nodeFromElement(element, options) {
625
626
  const { DOMParser: CustomDOMParser, schema,...parseOptions } = options;
@@ -671,6 +672,7 @@ function htmlFromElement(element) {
671
672
  * ```ts
672
673
  * const html = '<p>Hello, world!</p>'
673
674
  * const node = nodeFromHTML(html, { schema: editor.schema })
675
+ * ```
674
676
  */
675
677
  function nodeFromHTML(html, options) {
676
678
  return nodeFromElement(elementFromHTML(html, options), options);
@@ -50,7 +50,13 @@ type NodeChild = ProseMirrorNode | string | NodeChild[];
50
50
  * @public
51
51
  */
52
52
  interface NodeAction<Attrs extends AnyAttrs = AnyAttrs> {
53
+ /**
54
+ * Creates a node with attributes and any number of children.
55
+ */
53
56
  (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode;
57
+ /**
58
+ * Creates a node with any number of children.
59
+ */
54
60
  (...children: NodeChild[]): ProseMirrorNode;
55
61
  /**
56
62
  * Checks if the node is active in the current editor selection. If the
@@ -60,7 +66,7 @@ interface NodeAction<Attrs extends AnyAttrs = AnyAttrs> {
60
66
  isActive: (attrs?: Attrs) => boolean;
61
67
  }
62
68
  /**
63
- * A function for creating a mark with optional attributes and any number of
69
+ * A function for applying a mark with optional attributes and any number of
64
70
  * children.
65
71
  *
66
72
  * It also has a `isActive` method for checking if the mark is active in the
@@ -69,7 +75,13 @@ interface NodeAction<Attrs extends AnyAttrs = AnyAttrs> {
69
75
  * @public
70
76
  */
71
77
  interface MarkAction<Attrs extends AnyAttrs = AnyAttrs> {
78
+ /**
79
+ * Applies a mark with attributes and any number of children.
80
+ */
72
81
  (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode[];
82
+ /**
83
+ * Applies a mark with any number of children.
84
+ */
73
85
  (...children: NodeChild[]): ProseMirrorNode[];
74
86
  /**
75
87
  * Checks if the mark is active in the current editor selection. If the
@@ -203,13 +215,14 @@ interface ExtensionTyping<N extends NodeTyping = never, M extends MarkTyping = n
203
215
  interface Extension<T extends ExtensionTyping<any, any, any> = ExtensionTyping<any, any, any>> {
204
216
  extension: Extension | Extension[];
205
217
  priority?: Priority;
206
- _type?: T;
207
218
  /**
208
219
  * @public
209
220
  *
210
221
  * The schema that this extension represents.
211
222
  */
212
223
  schema: Schema | null;
224
+ /** @internal */
225
+ _type?: T;
213
226
  }
214
227
  /**
215
228
  * @internal
@@ -438,6 +451,7 @@ declare function nodeFromJSON(json: NodeJSON, options: JSONParserOptions): Prose
438
451
  * ```ts
439
452
  * const element = document.getElementById('content')
440
453
  * const node = nodeFromElement(element, { schema: editor.schema })
454
+ * ```
441
455
  */
442
456
  declare function nodeFromElement(element: DOMNode, options: DOMParserOptions & JSONParserOptions): ProseMirrorNode;
443
457
  /**
@@ -471,6 +485,7 @@ declare function elementFromNode(node: ProseMirrorNode, options?: DOMSerializerO
471
485
  * ```ts
472
486
  * const html = '<p>Hello, world!</p>'
473
487
  * const node = nodeFromHTML(html, { schema: editor.schema })
488
+ * ```
474
489
  */
475
490
  declare function nodeFromHTML(html: string, options: DOMParserOptions & JSONParserOptions & DOMDocumentOptions): ProseMirrorNode;
476
491
  /**
@@ -1,4 +1,4 @@
1
- import { Editor, EditorInstance, EditorOptions, Extension } from "./editor-CjVyjJqw.js";
1
+ import { Editor, EditorInstance, EditorOptions, Extension } from "./editor-OUH5V8BA.js";
2
2
  import { ProseMirrorNode } from "@prosekit/pm/model";
3
3
 
4
4
  //#region src/test/test-editor.d.ts
@@ -1,4 +1,4 @@
1
- import { Editor, EditorInstance, assert, createMarkActions, createNodeActions, isProseMirrorNode, setupEditorExtension } from "./editor-DbMrpnmL.js";
1
+ import { Editor, EditorInstance, assert, createMarkActions, createNodeActions, isProseMirrorNode, setupEditorExtension } from "./editor-DlGlYOp-.js";
2
2
  import { NodeSelection, TextSelection } from "@prosekit/pm/state";
3
3
 
4
4
  //#region src/test/test-builder.ts
@@ -1,4 +1,4 @@
1
- import { AnyAttrs, AttrSpec, CommandAction, CommandCreator, CommandTyping, DOMDocumentOptions, DOMParserOptions, DOMSerializerOptions, Editor, EditorOptions, Extension, ExtensionTyping, ExtractCommandActions, ExtractCommandAppliers, ExtractCommandCreators, ExtractMarkActions, ExtractMarks, ExtractNodeActions, ExtractNodes, JSONParserOptions, MarkAction, MarkBuilder, MarkTyping, NodeAction, NodeBuilder, NodeChild, NodeJSON, NodeTyping, PickSubType, PlainExtension, Priority, SelectionJSON, SimplifyDeeper, SimplifyUnion, StateJSON, StepJSON, ToMarkAction, ToNodeAction, Union, UnionExtension, createEditor, elementFromJSON, elementFromNode, htmlFromJSON, htmlFromNode, jsonFromHTML, jsonFromNode, jsonFromState, nodeFromElement, nodeFromHTML, nodeFromJSON, stateFromJSON } from "./editor-CjVyjJqw.js";
1
+ import { AnyAttrs, AttrSpec, CommandAction, CommandCreator, CommandTyping, DOMDocumentOptions, DOMParserOptions, DOMSerializerOptions, Editor, EditorOptions, Extension, ExtensionTyping, ExtractCommandActions, ExtractCommandAppliers, ExtractCommandCreators, ExtractMarkActions, ExtractMarks, ExtractNodeActions, ExtractNodes, JSONParserOptions, MarkAction, MarkBuilder, MarkTyping, NodeAction, NodeBuilder, NodeChild, NodeJSON, NodeTyping, PickSubType, PlainExtension, Priority, SelectionJSON, SimplifyDeeper, SimplifyUnion, StateJSON, StepJSON, ToMarkAction, ToNodeAction, Union, UnionExtension, createEditor, elementFromJSON, elementFromNode, htmlFromJSON, htmlFromNode, jsonFromHTML, jsonFromNode, jsonFromState, nodeFromElement, nodeFromHTML, nodeFromJSON, stateFromJSON } from "./editor-OUH5V8BA.js";
2
2
  import { AllSelection, Command, EditorState, EditorStateConfig, NodeSelection, Plugin, Selection, TextSelection, Transaction } from "@prosekit/pm/state";
3
3
  import { Attrs as Attrs$1, ContentMatch, DOMSerializer, Fragment, Mark as Mark$1, MarkSpec, MarkType as MarkType$1, Node as Node$1, NodeSpec, NodeType as NodeType$1, ProseMirrorFragment, ProseMirrorNode, ResolvedPos, Schema, Slice } from "@prosekit/pm/model";
4
4
  import { DOMEventMap, EditorView, MarkViewConstructor, NodeView, NodeViewConstructor } from "@prosekit/pm/view";
@@ -1249,13 +1249,15 @@ declare const clsx: (...args: Array<string | boolean | null | undefined>) => str
1249
1249
  /**
1250
1250
  * Collects all children of a node or a fragment, and returns them as an array.
1251
1251
  *
1252
- * @public
1252
+ * @deprecated Use `node.children` or `fragment.content` instead.
1253
+ *
1254
+ * @hidden
1253
1255
  */
1254
1256
  declare function collectChildren(parent: ProseMirrorNode | Fragment): ProseMirrorNode[];
1255
1257
  //#endregion
1256
1258
  //#region src/utils/collect-nodes.d.ts
1257
1259
  /**
1258
- * @public
1260
+ * @hidden
1259
1261
  *
1260
1262
  * @deprecated
1261
1263
  */
@@ -1265,7 +1267,7 @@ type NodeContent = ProseMirrorNode | ProseMirrorFragment | NodeContent[];
1265
1267
  *
1266
1268
  * @deprecated Use `collectChildren` instead.
1267
1269
  *
1268
- * @public
1270
+ * @hidden
1269
1271
  */
1270
1272
  declare function collectNodes(content: NodeContent): ProseMirrorNode[];
1271
1273
  //#endregion
@@ -1387,51 +1389,51 @@ declare function setSelectionAround(tr: Transaction, pos: number): void;
1387
1389
  //#endregion
1388
1390
  //#region src/utils/type-assertion.d.ts
1389
1391
  /**
1390
- * Checks if the given object is a `ProseMirrorNode` instance.
1392
+ * Checks if the given object is a {@link ProseMirrorNode} instance.
1391
1393
  */
1392
- declare function isProseMirrorNode(node: unknown): node is ProseMirrorNode;
1394
+ declare function isProseMirrorNode(value: unknown): value is ProseMirrorNode;
1393
1395
  /**
1394
- * Checks if the given object is a `Mark` instance.
1396
+ * Checks if the given object is a {@link Mark} instance.
1395
1397
  *
1396
1398
  * @public
1397
1399
  */
1398
- declare function isMark(mark: unknown): mark is Mark$1;
1400
+ declare function isMark(value: unknown): value is Mark$1;
1399
1401
  /**
1400
- * Checks if the given object is a `Fragment` instance.
1402
+ * Checks if the given object is a {@link Fragment} instance.
1401
1403
  *
1402
1404
  * @public
1403
1405
  */
1404
- declare function isFragment(fragment: unknown): fragment is Fragment;
1406
+ declare function isFragment(value: unknown): value is Fragment;
1405
1407
  /**
1406
- * Checks if the given object is a `Slice` instance.
1408
+ * Checks if the given object is a {@link Slice} instance.
1407
1409
  *
1408
1410
  * @public
1409
1411
  */
1410
- declare function isSlice(slice: unknown): slice is Slice;
1412
+ declare function isSlice(value: unknown): value is Slice;
1411
1413
  /**
1412
- * Checks if the given object is a `Selection` instance.
1414
+ * Checks if the given object is a {@link Selection} instance.
1413
1415
  *
1414
1416
  * @public
1415
1417
  */
1416
- declare function isSelection(sel: unknown): sel is Selection;
1418
+ declare function isSelection(value: unknown): value is Selection;
1417
1419
  /**
1418
- * Checks if the given object is a `TextSelection` instance.
1420
+ * Checks if the given object is a {@link TextSelection} instance.
1419
1421
  *
1420
1422
  * @public
1421
1423
  */
1422
- declare function isTextSelection(sel: Selection): sel is TextSelection;
1424
+ declare function isTextSelection(value: Selection): value is TextSelection;
1423
1425
  /**
1424
- * Checks if the given object is a `NodeSelection` instance.
1426
+ * Checks if the given object is a {@link NodeSelection} instance.
1425
1427
  *
1426
1428
  * @public
1427
1429
  */
1428
- declare function isNodeSelection(sel: Selection): sel is NodeSelection;
1430
+ declare function isNodeSelection(value: Selection): value is NodeSelection;
1429
1431
  /**
1430
- * Checks if the given object is a `AllSelection` instance.
1432
+ * Checks if the given object is a {@link AllSelection} instance.
1431
1433
  *
1432
1434
  * @public
1433
1435
  */
1434
- declare function isAllSelection(sel: Selection): sel is AllSelection;
1436
+ declare function isAllSelection(value: Selection): value is AllSelection;
1435
1437
  /**
1436
1438
  * @internal
1437
1439
  */
@@ -1,4 +1,4 @@
1
- import { Editor, EditorNotFoundError, Priority, ProseKitError, assert, createEditor, defineDefaultState, defineFacet, defineFacetPayload, elementFromJSON, elementFromNode, getMarkType, getNodeType, htmlFromJSON, htmlFromNode, isAllSelection, isFragment, isMark, isMarkAbsent, isMarkActive, isNodeActive, isNodeSelection, isNotNullish, isProseMirrorNode, isSelection, isSlice, isTextSelection, jsonFromHTML, jsonFromNode, jsonFromState, nodeFromElement, nodeFromHTML, nodeFromJSON, rootFacet, schemaFacet, stateFacet, stateFromJSON, toReversed, union } from "./editor-DbMrpnmL.js";
1
+ import { Editor, EditorNotFoundError, Priority, ProseKitError, assert, createEditor, defineDefaultState, defineFacet, defineFacetPayload, elementFromJSON, elementFromNode, getMarkType, getNodeType, htmlFromJSON, htmlFromNode, isAllSelection, isFragment, isMark, isMarkAbsent, isMarkActive, isNodeActive, isNodeSelection, isNotNullish, isProseMirrorNode, isSelection, isSlice, isTextSelection, jsonFromHTML, jsonFromNode, jsonFromState, nodeFromElement, nodeFromHTML, nodeFromJSON, rootFacet, schemaFacet, stateFacet, stateFromJSON, toReversed, union } from "./editor-DlGlYOp-.js";
2
2
  import { AllSelection, Plugin, PluginKey, ProseMirrorPlugin, TextSelection } from "@prosekit/pm/state";
3
3
  import { ReplaceAroundStep, findWrapping, insertPoint } from "@prosekit/pm/transform";
4
4
  import { baseKeymap, chainCommands, createParagraphNear, deleteSelection, joinTextblockBackward, lift, liftEmptyBlock, newlineInCode, selectNodeBackward, setBlockType as setBlockType$1, toggleMark as toggleMark$1 } from "@prosekit/pm/commands";
@@ -1509,7 +1509,9 @@ const clsx = clsxLite;
1509
1509
  /**
1510
1510
  * Collects all children of a node or a fragment, and returns them as an array.
1511
1511
  *
1512
- * @public
1512
+ * @deprecated Use `node.children` or `fragment.content` instead.
1513
+ *
1514
+ * @hidden
1513
1515
  */
1514
1516
  function collectChildren(parent) {
1515
1517
  const children = [];
@@ -1524,7 +1526,7 @@ function collectChildren(parent) {
1524
1526
  *
1525
1527
  * @deprecated Use `collectChildren` instead.
1526
1528
  *
1527
- * @public
1529
+ * @hidden
1528
1530
  */
1529
1531
  function collectNodes(content) {
1530
1532
  if (Array.isArray(content)) return content.flatMap(collectNodes);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/core",
3
3
  "type": "module",
4
- "version": "0.8.2",
4
+ "version": "0.8.3",
5
5
  "private": false,
6
6
  "description": "Core features for ProseKit",
7
7
  "author": {
@@ -49,10 +49,10 @@
49
49
  "@prosekit/pm": "^0.1.11"
50
50
  },
51
51
  "devDependencies": {
52
- "@vitest/browser": "^3.2.3",
53
- "tsdown": "^0.12.7",
52
+ "@vitest/browser": "^3.2.4",
53
+ "tsdown": "^0.12.9",
54
54
  "typescript": "~5.8.3",
55
- "vitest": "^3.2.3",
55
+ "vitest": "^3.2.4",
56
56
  "@prosekit/config-tsdown": "0.0.0",
57
57
  "@prosekit/config-vitest": "0.0.0"
58
58
  },