@prosekit/core 0.0.0-next-20240626133927 → 0.0.0-next-20240707065442
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.
@@ -25,6 +25,7 @@ import { NodeType as NodeType_2 } from 'prosemirror-model';
|
|
25
25
|
import { NodeView } from '@prosekit/pm/view';
|
26
26
|
import { NodeViewConstructor } from '@prosekit/pm/view';
|
27
27
|
import { Options } from 'tsup';
|
28
|
+
import type { ParseOptions } from '@prosekit/pm/model';
|
28
29
|
import { Plugin as Plugin_2 } from '@prosekit/pm/state';
|
29
30
|
import { ProseMirrorFragment } from '@prosekit/pm/model';
|
30
31
|
import { ProseMirrorNode } from '@prosekit/pm/model';
|
@@ -183,7 +184,14 @@ declare const clsx: (...args: Array<string | boolean | null | undefined>) => str
|
|
183
184
|
export { clsx }
|
184
185
|
export { clsx as clsx_alias_1 }
|
185
186
|
|
186
|
-
|
187
|
+
/**
|
188
|
+
* Collects all nodes from a given content.
|
189
|
+
*
|
190
|
+
* @public
|
191
|
+
*/
|
192
|
+
declare function collectNodes(content: NodeContent): ProseMirrorNode[];
|
193
|
+
export { collectNodes }
|
194
|
+
export { collectNodes as collectNodes_alias_1 }
|
187
195
|
|
188
196
|
export declare function combineEventHandlers<Handler extends (...args: any[]) => boolean | void, Args extends Parameters<Handler> = Parameters<Handler>>(): readonly [(handlers: Handler[]) => void, (...args: Args) => boolean];
|
189
197
|
|
@@ -775,9 +783,9 @@ export declare class DOMDocumentNotFoundError extends ProseKitError {
|
|
775
783
|
}
|
776
784
|
|
777
785
|
/** @public */
|
778
|
-
declare
|
786
|
+
declare interface DOMDocumentOptions {
|
779
787
|
document?: Document;
|
780
|
-
}
|
788
|
+
}
|
781
789
|
export { DOMDocumentOptions }
|
782
790
|
export { DOMDocumentOptions as DOMDocumentOptions_alias_1 }
|
783
791
|
|
@@ -806,16 +814,16 @@ export declare type DOMEventPayload = [event: string, handler: DOMEventHandler];
|
|
806
814
|
export declare type DOMNode = InstanceType<typeof window.Node>;
|
807
815
|
|
808
816
|
/** @public */
|
809
|
-
declare
|
817
|
+
declare interface DOMParserOptions extends ParseOptions {
|
810
818
|
DOMParser?: typeof DOMParser_2;
|
811
|
-
}
|
819
|
+
}
|
812
820
|
export { DOMParserOptions }
|
813
821
|
export { DOMParserOptions as DOMParserOptions_alias_1 }
|
814
822
|
|
815
823
|
/** @public */
|
816
|
-
declare
|
824
|
+
declare interface DOMSerializerOptions {
|
817
825
|
DOMSerializer?: typeof DOMSerializer;
|
818
|
-
}
|
826
|
+
}
|
819
827
|
export { DOMSerializerOptions }
|
820
828
|
export { DOMSerializerOptions as DOMSerializerOptions_alias_1 }
|
821
829
|
|
@@ -1379,9 +1387,9 @@ export { jsonFromState }
|
|
1379
1387
|
export { jsonFromState as jsonFromState_alias_1 }
|
1380
1388
|
|
1381
1389
|
/** @public */
|
1382
|
-
declare
|
1390
|
+
declare interface JSONParserOptions {
|
1383
1391
|
schema: Schema;
|
1384
|
-
}
|
1392
|
+
}
|
1385
1393
|
export { JSONParserOptions }
|
1386
1394
|
export { JSONParserOptions as JSONParserOptions_alias_1 }
|
1387
1395
|
|
@@ -1541,7 +1549,12 @@ export { NodeBuilder as NodeBuilder_alias_1 }
|
|
1541
1549
|
*/
|
1542
1550
|
export declare type NodeChild = ProseMirrorNode | string | NodeChild[];
|
1543
1551
|
|
1544
|
-
|
1552
|
+
/**
|
1553
|
+
* @public
|
1554
|
+
*/
|
1555
|
+
declare type NodeContent = ProseMirrorNode | ProseMirrorFragment | NodeContent[];
|
1556
|
+
export { NodeContent }
|
1557
|
+
export { NodeContent as NodeContent_alias_1 }
|
1545
1558
|
|
1546
1559
|
/**
|
1547
1560
|
* Parse a HTML element to a ProseMirror node.
|
@@ -1885,6 +1898,21 @@ export declare type StatePayload = (ctx: {
|
|
1885
1898
|
schema: Schema;
|
1886
1899
|
}) => EditorStateConfig;
|
1887
1900
|
|
1901
|
+
/**
|
1902
|
+
* A JSON representation of the prosemirror step.
|
1903
|
+
*
|
1904
|
+
* @public
|
1905
|
+
*/
|
1906
|
+
declare interface StepJSON {
|
1907
|
+
/**
|
1908
|
+
* The type of the step.
|
1909
|
+
*/
|
1910
|
+
stepType: string;
|
1911
|
+
[x: string]: unknown;
|
1912
|
+
}
|
1913
|
+
export { StepJSON }
|
1914
|
+
export { StepJSON as StepJSON_alias_1 }
|
1915
|
+
|
1888
1916
|
/**
|
1889
1917
|
* Takes two facet nodes and returns a new facet node containing inputs and
|
1890
1918
|
* children from the first node but not the second.
|
@@ -1983,6 +2011,17 @@ export declare type Tuple5<T> = [T, T, T, T, T];
|
|
1983
2011
|
*
|
1984
2012
|
* @throws If no extensions are provided.
|
1985
2013
|
*
|
2014
|
+
* @example
|
2015
|
+
*
|
2016
|
+
* ```ts
|
2017
|
+
* function defineFancyNodes() {
|
2018
|
+
* return union([
|
2019
|
+
* defineFancyParagraph(),
|
2020
|
+
* defineFancyHeading(),
|
2021
|
+
* ])
|
2022
|
+
* }
|
2023
|
+
* ```
|
2024
|
+
*
|
1986
2025
|
* @public
|
1987
2026
|
*/
|
1988
2027
|
declare function union<const E extends Extension | readonly Extension[]>(extension: E): UnionExtension<E>;
|
@@ -2054,6 +2093,15 @@ export declare type ViewPayload = Omit<DirectEditorProps, 'state'>;
|
|
2054
2093
|
export declare function voidFunction(): void;
|
2055
2094
|
|
2056
2095
|
/**
|
2096
|
+
* Return an new extension with the given priority.
|
2097
|
+
*
|
2098
|
+
* @example
|
2099
|
+
* ```ts
|
2100
|
+
* import { Priority, withPriority } from 'prosekit/core'
|
2101
|
+
*
|
2102
|
+
* const extension = withPriority(defineMyExtension(), Priority.high)
|
2103
|
+
* ```
|
2104
|
+
*
|
2057
2105
|
* @public
|
2058
2106
|
*/
|
2059
2107
|
declare function withPriority<T extends Extension>(extension: T, priority: Priority): T;
|
@@ -341,8 +341,8 @@ function nodeFromJSON(json, options) {
|
|
341
341
|
return options.schema.nodeFromJSON(json);
|
342
342
|
}
|
343
343
|
function nodeFromElement(element, options) {
|
344
|
-
let
|
345
|
-
return
|
344
|
+
let { DOMParser: CustomDOMParser, schema, ...parseOptions } = options;
|
345
|
+
return (CustomDOMParser || DOMParser).fromSchema(schema).parse(element, parseOptions);
|
346
346
|
}
|
347
347
|
function elementFromNode(node, options) {
|
348
348
|
let Serializer = (options == null ? void 0 : options.DOMSerializer) || DOMSerializer, document2 = getBrowserDocument(options), schema = node.type.schema, serializer = Serializer.fromSchema(schema);
|
package/dist/prosekit-core.d.ts
CHANGED
@@ -18,6 +18,8 @@ export { EditorNotFoundError_alias_1 as EditorNotFoundError } from './_tsup-dts-
|
|
18
18
|
export { ProseKitError_alias_1 as ProseKitError } from './_tsup-dts-rollup';
|
19
19
|
export { defineBaseCommands } from './_tsup-dts-rollup';
|
20
20
|
export { defineCommands } from './_tsup-dts-rollup';
|
21
|
+
export { collectNodes } from './_tsup-dts-rollup';
|
22
|
+
export { NodeContent } from './_tsup-dts-rollup';
|
21
23
|
export { defineDefaultState } from './_tsup-dts-rollup';
|
22
24
|
export { DefaultStateOptions } from './_tsup-dts-rollup';
|
23
25
|
export { defineDoc } from './_tsup-dts-rollup';
|
@@ -95,6 +97,7 @@ export { UnionExtension } from './_tsup-dts-rollup';
|
|
95
97
|
export { NodeJSON } from './_tsup-dts-rollup';
|
96
98
|
export { SelectionJSON } from './_tsup-dts-rollup';
|
97
99
|
export { StateJSON } from './_tsup-dts-rollup';
|
100
|
+
export { StepJSON } from './_tsup-dts-rollup';
|
98
101
|
export { Priority } from './_tsup-dts-rollup';
|
99
102
|
export { SimplifyUnion } from './_tsup-dts-rollup';
|
100
103
|
export { assert } from './_tsup-dts-rollup';
|
package/dist/prosekit-core.js
CHANGED
@@ -35,7 +35,7 @@ import {
|
|
35
35
|
stateFromJSON,
|
36
36
|
toReversed,
|
37
37
|
union
|
38
|
-
} from "./chunk-
|
38
|
+
} from "./chunk-YWQGKV6X.js";
|
39
39
|
|
40
40
|
// src/commands/add-mark.ts
|
41
41
|
import "@prosekit/pm/model";
|
@@ -358,6 +358,22 @@ function defineBaseCommands() {
|
|
358
358
|
});
|
359
359
|
}
|
360
360
|
|
361
|
+
// src/utils/collect-nodes.ts
|
362
|
+
import { ProseMirrorFragment, ProseMirrorNode as ProseMirrorNode2 } from "@prosekit/pm/model";
|
363
|
+
function collectNodes(content) {
|
364
|
+
if (Array.isArray(content))
|
365
|
+
return content.flatMap(collectNodes);
|
366
|
+
if (content instanceof ProseMirrorNode2)
|
367
|
+
return [content];
|
368
|
+
if (content instanceof ProseMirrorFragment) {
|
369
|
+
let nodes = [];
|
370
|
+
for (let i = 0; i < content.childCount; i++)
|
371
|
+
nodes.push(content.child(i));
|
372
|
+
return nodes;
|
373
|
+
}
|
374
|
+
throw new ProseKitError(`Invalid node content: ${typeof content}`);
|
375
|
+
}
|
376
|
+
|
361
377
|
// src/extensions/node-spec.ts
|
362
378
|
import OrderedMap2 from "orderedmap";
|
363
379
|
|
@@ -584,7 +600,7 @@ function defineDOMEventHandler(event, handler) {
|
|
584
600
|
}
|
585
601
|
var domEventFacet = defineFacet({
|
586
602
|
reduce: () => {
|
587
|
-
let setHandlersMap = {}, combinedHandlerMap = {}, plugin
|
603
|
+
let setHandlersMap = {}, combinedHandlerMap = {}, plugin, update = (payloads) => {
|
588
604
|
var _a;
|
589
605
|
let hasNewEvent = !1;
|
590
606
|
for (let [event] of payloads)
|
@@ -728,7 +744,7 @@ function defineBaseKeymap(options) {
|
|
728
744
|
}
|
729
745
|
var keymapFacet = defineFacet({
|
730
746
|
reduce: () => {
|
731
|
-
let handler
|
747
|
+
let handler, handlerWrapper = (view, event) => handler ? handler(view, event) : !1, plugin = new Plugin2({
|
732
748
|
key: keymapPluginKey,
|
733
749
|
props: { handleKeyDown: handlerWrapper }
|
734
750
|
});
|
@@ -975,6 +991,7 @@ export {
|
|
975
991
|
assert,
|
976
992
|
canUseRegexLookbehind,
|
977
993
|
clsx,
|
994
|
+
collectNodes,
|
978
995
|
createEditor,
|
979
996
|
defaultBlockAt,
|
980
997
|
defineBaseCommands,
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next-
|
4
|
+
"version": "0.0.0-next-20240707065442",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -43,13 +43,13 @@
|
|
43
43
|
"clsx": "^2.1.1",
|
44
44
|
"orderedmap": "^2.1.1",
|
45
45
|
"prosemirror-splittable": "^0.1.1",
|
46
|
-
"type-fest": "^4.
|
47
|
-
"@prosekit/pm": "^0.0.0-next-
|
46
|
+
"type-fest": "^4.21.0",
|
47
|
+
"@prosekit/pm": "^0.0.0-next-20240707065442"
|
48
48
|
},
|
49
49
|
"devDependencies": {
|
50
50
|
"tsup": "^8.1.0",
|
51
|
-
"typescript": "^5.5.
|
52
|
-
"vitest": "^2.0.0-beta.
|
51
|
+
"typescript": "^5.5.3",
|
52
|
+
"vitest": "^2.0.0-beta.13",
|
53
53
|
"@prosekit/dev": "0.0.0"
|
54
54
|
},
|
55
55
|
"scripts": {
|