@prosekit/core 0.7.0 → 0.7.1
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.
- package/dist/_tsup-dts-rollup.d.ts +16 -3
- package/dist/prosekit-core.d.ts +4 -2
- package/dist/prosekit-core.js +25 -29
- package/package.json +1 -1
@@ -584,6 +584,13 @@ declare function defineNodeView(options: NodeViewOptions): Extension;
|
|
584
584
|
export { defineNodeView }
|
585
585
|
export { defineNodeView as defineNodeView_alias_1 }
|
586
586
|
|
587
|
+
/**
|
588
|
+
* @internal
|
589
|
+
*/
|
590
|
+
declare function defineNodeViewComponent<T>(options: NodeViewComponentOptions<T>): Extension;
|
591
|
+
export { defineNodeViewComponent }
|
592
|
+
export { defineNodeViewComponent as defineNodeViewComponent_alias_1 }
|
593
|
+
|
587
594
|
/**
|
588
595
|
* @internal
|
589
596
|
*/
|
@@ -1611,13 +1618,19 @@ export { NodeSpecOptions as NodeSpecOptions_alias_1 }
|
|
1611
1618
|
/**
|
1612
1619
|
* @internal
|
1613
1620
|
*/
|
1614
|
-
declare type
|
1621
|
+
declare type NodeViewComponentOptions<T> = {
|
1615
1622
|
group: string;
|
1616
1623
|
name: string;
|
1617
1624
|
args: T;
|
1618
|
-
}
|
1625
|
+
};
|
1626
|
+
export { NodeViewComponentOptions }
|
1627
|
+
export { NodeViewComponentOptions as NodeViewComponentOptions_alias_1 }
|
1628
|
+
|
1629
|
+
/**
|
1630
|
+
* @internal
|
1631
|
+
*/
|
1632
|
+
declare type NodeViewFactoryOptions<T> = {
|
1619
1633
|
group: string;
|
1620
|
-
name?: undefined;
|
1621
1634
|
factory: (args: T) => NodeViewConstructor;
|
1622
1635
|
};
|
1623
1636
|
export { NodeViewFactoryOptions }
|
package/dist/prosekit-core.d.ts
CHANGED
@@ -18,8 +18,6 @@ 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';
|
23
21
|
export { defineDefaultState } from './_tsup-dts-rollup';
|
24
22
|
export { DefaultStateOptions } from './_tsup-dts-rollup';
|
25
23
|
export { defineDoc } from './_tsup-dts-rollup';
|
@@ -75,7 +73,9 @@ export { NodeAttrOptions } from './_tsup-dts-rollup';
|
|
75
73
|
export { NodeSpecOptions } from './_tsup-dts-rollup';
|
76
74
|
export { defineNodeView } from './_tsup-dts-rollup';
|
77
75
|
export { NodeViewOptions } from './_tsup-dts-rollup';
|
76
|
+
export { defineNodeViewComponent } from './_tsup-dts-rollup';
|
78
77
|
export { defineNodeViewFactory } from './_tsup-dts-rollup';
|
78
|
+
export { NodeViewComponentOptions } from './_tsup-dts-rollup';
|
79
79
|
export { NodeViewFactoryOptions } from './_tsup-dts-rollup';
|
80
80
|
export { defineParagraph } from './_tsup-dts-rollup';
|
81
81
|
export { definePlugin } from './_tsup-dts-rollup';
|
@@ -103,6 +103,8 @@ export { SimplifyUnion } from './_tsup-dts-rollup';
|
|
103
103
|
export { assert } from './_tsup-dts-rollup';
|
104
104
|
export { canUseRegexLookbehind } from './_tsup-dts-rollup';
|
105
105
|
export { clsx } from './_tsup-dts-rollup';
|
106
|
+
export { collectNodes } from './_tsup-dts-rollup';
|
107
|
+
export { NodeContent } from './_tsup-dts-rollup';
|
106
108
|
export { defaultBlockAt } from './_tsup-dts-rollup';
|
107
109
|
export { isApple } from './_tsup-dts-rollup';
|
108
110
|
export { _getId } from './_tsup-dts-rollup';
|
package/dist/prosekit-core.js
CHANGED
@@ -358,22 +358,6 @@ 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
|
-
|
377
361
|
// src/extensions/node-spec.ts
|
378
362
|
import OrderedMap2 from "orderedmap";
|
379
363
|
|
@@ -875,22 +859,17 @@ var nodeViewFacet = defineFacet({
|
|
875
859
|
import { PluginKey as PluginKey6, ProseMirrorPlugin as ProseMirrorPlugin6 } from "@prosekit/pm/state";
|
876
860
|
import "@prosekit/pm/view";
|
877
861
|
function defineNodeViewFactory(options) {
|
878
|
-
return defineFacetPayload(nodeViewFactoryFacet, [options]);
|
862
|
+
return defineFacetPayload(nodeViewFactoryFacet, [[options, null]]);
|
863
|
+
}
|
864
|
+
function defineNodeViewComponent(options) {
|
865
|
+
return defineFacetPayload(nodeViewFactoryFacet, [[null, options]]);
|
879
866
|
}
|
880
867
|
var nodeViewFactoryFacet = defineFacet({
|
881
868
|
reducer: (inputs) => {
|
882
|
-
let nodeViews = {},
|
883
|
-
for (let
|
884
|
-
let
|
885
|
-
|
886
|
-
name: input.name,
|
887
|
-
args: input.args
|
888
|
-
}));
|
889
|
-
}
|
890
|
-
for (let [group, factory] of Object.entries(factories)) {
|
891
|
-
let groupOptions = options[group] || [];
|
892
|
-
for (let { name, args } of groupOptions)
|
893
|
-
nodeViews[name] = factory(args);
|
869
|
+
let nodeViews = {}, factories = inputs.map((x) => x[0]).filter(isNotNull), options = inputs.map((x) => x[1]).filter(isNotNull);
|
870
|
+
for (let { group, name, args } of options) {
|
871
|
+
let factory = factories.find((factory2) => factory2.group === group);
|
872
|
+
factory && (nodeViews[name] = factory.factory(args));
|
894
873
|
}
|
895
874
|
return () => [
|
896
875
|
new ProseMirrorPlugin6({
|
@@ -945,6 +924,22 @@ var canUseRegexLookbehind = cache(() => {
|
|
945
924
|
import clsxLite from "clsx/lite";
|
946
925
|
var clsx = clsxLite;
|
947
926
|
|
927
|
+
// src/utils/collect-nodes.ts
|
928
|
+
import { ProseMirrorFragment, ProseMirrorNode as ProseMirrorNode2 } from "@prosekit/pm/model";
|
929
|
+
function collectNodes(content) {
|
930
|
+
if (Array.isArray(content))
|
931
|
+
return content.flatMap(collectNodes);
|
932
|
+
if (content instanceof ProseMirrorNode2)
|
933
|
+
return [content];
|
934
|
+
if (content instanceof ProseMirrorFragment) {
|
935
|
+
let nodes = [];
|
936
|
+
for (let i = 0; i < content.childCount; i++)
|
937
|
+
nodes.push(content.child(i));
|
938
|
+
return nodes;
|
939
|
+
}
|
940
|
+
throw new ProseKitError(`Invalid node content: ${typeof content}`);
|
941
|
+
}
|
942
|
+
|
948
943
|
// src/utils/default-block-at.ts
|
949
944
|
function defaultBlockAt(match) {
|
950
945
|
for (let i = 0; i < match.edgeCount; i++) {
|
@@ -1019,6 +1014,7 @@ export {
|
|
1019
1014
|
defineNodeAttr,
|
1020
1015
|
defineNodeSpec,
|
1021
1016
|
defineNodeView,
|
1017
|
+
defineNodeViewComponent,
|
1022
1018
|
defineNodeViewFactory,
|
1023
1019
|
defineParagraph,
|
1024
1020
|
definePasteHandler,
|