@prosekit/core 0.1.7 → 0.1.9
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 +55 -10
- package/dist/prosekit-core.d.ts +4 -2
- package/dist/prosekit-core.js +13 -5
- package/dist/style.css +1 -1
- package/package.json +5 -5
- package/src/index.ts +4 -2
@@ -19,6 +19,7 @@ import { NodeSelection } from '@prosekit/pm/state';
|
|
19
19
|
import type { NodeSpec } from '@prosekit/pm/model';
|
20
20
|
import { NodeType } from '@prosekit/pm/model';
|
21
21
|
import { NodeType as NodeType_2 } from 'prosemirror-model';
|
22
|
+
import { NodeView } from '@prosekit/pm/view';
|
22
23
|
import { NodeViewConstructor } from '@prosekit/pm/view';
|
23
24
|
import { Options } from 'tsup';
|
24
25
|
import { Plugin as Plugin_2 } from '@prosekit/pm/state';
|
@@ -32,7 +33,6 @@ import type { Simplify } from 'type-fest';
|
|
32
33
|
import { TextSelection } from '@prosekit/pm/state';
|
33
34
|
import { Transaction } from '@prosekit/pm/state';
|
34
35
|
import type { UnionToIntersection } from 'type-fest';
|
35
|
-
import { UserProjectConfigExport } from 'vitest/dist/config.js';
|
36
36
|
|
37
37
|
declare type Action = (options: {
|
38
38
|
tr: Transaction;
|
@@ -94,6 +94,32 @@ export declare abstract class BaseExtension<T extends ExtensionTyping = Extensio
|
|
94
94
|
abstract schema: Schema | null;
|
95
95
|
}
|
96
96
|
|
97
|
+
/**
|
98
|
+
* Some basic props for custom node views.
|
99
|
+
*
|
100
|
+
* @public
|
101
|
+
*/
|
102
|
+
declare interface BaseNodeViewOptions {
|
103
|
+
/**
|
104
|
+
* The wrapping DOM element for the node view. Defaults to `div` for block nodes and `span` for inline nodes.
|
105
|
+
*/
|
106
|
+
as?: string | HTMLElement | ((node: ProseMirrorNode) => HTMLElement);
|
107
|
+
/**
|
108
|
+
* The wrapping DOM element for the node view's content. Defaults to `div` for block nodes and `span` for inline nodes.
|
109
|
+
*/
|
110
|
+
contentAs?: string | HTMLElement | ((node: ProseMirrorNode) => HTMLElement);
|
111
|
+
update?: NodeView['update'];
|
112
|
+
ignoreMutation?: NodeView['ignoreMutation'];
|
113
|
+
selectNode?: NodeView['selectNode'];
|
114
|
+
deselectNode?: NodeView['deselectNode'];
|
115
|
+
setSelection?: NodeView['setSelection'];
|
116
|
+
stopEvent?: NodeView['stopEvent'];
|
117
|
+
destroy?: NodeView['destroy'];
|
118
|
+
onUpdate?: () => void;
|
119
|
+
}
|
120
|
+
export { BaseNodeViewOptions }
|
121
|
+
export { BaseNodeViewOptions as BaseNodeViewOptions_alias_1 }
|
122
|
+
|
97
123
|
export declare function collectNodes(content: NodeContent): ProseMirrorNode[];
|
98
124
|
|
99
125
|
export declare interface CommandApplier<Args extends any[] = any[]> {
|
@@ -137,7 +163,11 @@ export declare function createNodeBuilder(getState: () => EditorState | null | u
|
|
137
163
|
|
138
164
|
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
139
165
|
|
140
|
-
export declare const default_alias_1:
|
166
|
+
export declare const default_alias_1: {
|
167
|
+
test: {
|
168
|
+
environment: "jsdom";
|
169
|
+
};
|
170
|
+
};
|
141
171
|
|
142
172
|
declare interface DefaultStateOptions {
|
143
173
|
/**
|
@@ -302,9 +332,12 @@ declare function defineNodeView(options: NodeViewOptions): Extension;
|
|
302
332
|
export { defineNodeView }
|
303
333
|
export { defineNodeView as defineNodeView_alias_1 }
|
304
334
|
|
305
|
-
|
306
|
-
|
307
|
-
|
335
|
+
/**
|
336
|
+
* @internal
|
337
|
+
*/
|
338
|
+
declare function defineNodeViewFactory<T>(options: NodeViewFactoryOptions<T>): Extension;
|
339
|
+
export { defineNodeViewFactory }
|
340
|
+
export { defineNodeViewFactory as defineNodeViewFactory_alias_1 }
|
308
341
|
|
309
342
|
/**
|
310
343
|
* @public
|
@@ -578,6 +611,15 @@ export declare function getCustomSelection(state: EditorState, from?: number | n
|
|
578
611
|
|
579
612
|
export declare function getFacetCount(): number;
|
580
613
|
|
614
|
+
/**
|
615
|
+
* Returns a unique id in the current process that can be used in various places.
|
616
|
+
*
|
617
|
+
* @internal
|
618
|
+
*/
|
619
|
+
declare function getId(): string;
|
620
|
+
export { getId as _getId }
|
621
|
+
export { getId }
|
622
|
+
|
581
623
|
/**
|
582
624
|
* @internal
|
583
625
|
*/
|
@@ -782,17 +824,20 @@ declare interface NodeSpecOptions<NodeName extends string = string> extends Node
|
|
782
824
|
export { NodeSpecOptions }
|
783
825
|
export { NodeSpecOptions as NodeSpecOptions_alias_1 }
|
784
826
|
|
785
|
-
|
827
|
+
/**
|
828
|
+
* @internal
|
829
|
+
*/
|
830
|
+
declare type NodeViewFactoryOptions<T> = {
|
786
831
|
group: string;
|
787
832
|
name: string;
|
788
|
-
args:
|
833
|
+
args: T;
|
789
834
|
} | {
|
790
835
|
group: string;
|
791
836
|
name?: undefined;
|
792
|
-
factory: (args:
|
837
|
+
factory: (args: T) => NodeViewConstructor;
|
793
838
|
};
|
794
|
-
export {
|
795
|
-
export {
|
839
|
+
export { NodeViewFactoryOptions }
|
840
|
+
export { NodeViewFactoryOptions as NodeViewFactoryOptions_alias_1 }
|
796
841
|
|
797
842
|
declare interface NodeViewOptions {
|
798
843
|
name: string;
|
package/dist/prosekit-core.d.ts
CHANGED
@@ -26,8 +26,8 @@ export { defineNodeSpec } from './_tsup-dts-rollup';
|
|
26
26
|
export { NodeSpecOptions } from './_tsup-dts-rollup';
|
27
27
|
export { defineNodeView } from './_tsup-dts-rollup';
|
28
28
|
export { NodeViewOptions } from './_tsup-dts-rollup';
|
29
|
-
export {
|
30
|
-
export {
|
29
|
+
export { defineNodeViewFactory } from './_tsup-dts-rollup';
|
30
|
+
export { NodeViewFactoryOptions } from './_tsup-dts-rollup';
|
31
31
|
export { defineParagraph } from './_tsup-dts-rollup';
|
32
32
|
export { definePlugin } from './_tsup-dts-rollup';
|
33
33
|
export { pluginFacet } from './_tsup-dts-rollup';
|
@@ -36,6 +36,7 @@ export { defineText } from './_tsup-dts-rollup';
|
|
36
36
|
export { defineUpdateHandler } from './_tsup-dts-rollup';
|
37
37
|
export { Facet } from './_tsup-dts-rollup';
|
38
38
|
export { FacetOptions } from './_tsup-dts-rollup';
|
39
|
+
export { BaseNodeViewOptions } from './_tsup-dts-rollup';
|
39
40
|
export { CommandArgs } from './_tsup-dts-rollup';
|
40
41
|
export { Extension } from './_tsup-dts-rollup';
|
41
42
|
export { ExtractCommandAppliers } from './_tsup-dts-rollup';
|
@@ -49,6 +50,7 @@ export { SelectionJSON } from './_tsup-dts-rollup';
|
|
49
50
|
export { StateJSON } from './_tsup-dts-rollup';
|
50
51
|
export { Priority } from './_tsup-dts-rollup';
|
51
52
|
export { SimplifyUnion } from './_tsup-dts-rollup';
|
53
|
+
export { _getId } from './_tsup-dts-rollup';
|
52
54
|
export { getMarkType } from './_tsup-dts-rollup';
|
53
55
|
export { getNodeType } from './_tsup-dts-rollup';
|
54
56
|
export { jsonFromElement } from './_tsup-dts-rollup';
|
package/dist/prosekit-core.js
CHANGED
@@ -1325,10 +1325,10 @@ var nodeViewFacet = Facet.define({
|
|
1325
1325
|
// src/extensions/node-view-effect.ts
|
1326
1326
|
import { ProseMirrorPlugin as ProseMirrorPlugin2 } from "@prosekit/pm/state";
|
1327
1327
|
import "@prosekit/pm/view";
|
1328
|
-
function
|
1329
|
-
return
|
1328
|
+
function defineNodeViewFactory(options) {
|
1329
|
+
return nodeViewFactoryFacet.extension([options]);
|
1330
1330
|
}
|
1331
|
-
var
|
1331
|
+
var nodeViewFactoryFacet = Facet.define({
|
1332
1332
|
convert: (inputs) => {
|
1333
1333
|
const nodeViews = {};
|
1334
1334
|
const options = {};
|
@@ -1351,7 +1351,7 @@ var nodeViewEffectFacet = Facet.define({
|
|
1351
1351
|
nodeViews[name] = factory(args);
|
1352
1352
|
}
|
1353
1353
|
}
|
1354
|
-
return () =>
|
1354
|
+
return () => [new ProseMirrorPlugin2({ props: { nodeViews } })];
|
1355
1355
|
},
|
1356
1356
|
next: pluginFacet
|
1357
1357
|
});
|
@@ -1422,11 +1422,19 @@ var updateHandlerFacet = Facet.define({
|
|
1422
1422
|
singleton: true
|
1423
1423
|
});
|
1424
1424
|
var pluginKey = new PluginKey2("prosekit-event-handler");
|
1425
|
+
|
1426
|
+
// src/utils/get-id.ts
|
1427
|
+
var id = 0;
|
1428
|
+
function getId() {
|
1429
|
+
id = (id + 1) % Number.MAX_SAFE_INTEGER;
|
1430
|
+
return `id:${id}`;
|
1431
|
+
}
|
1425
1432
|
export {
|
1426
1433
|
Editor,
|
1427
1434
|
Facet,
|
1428
1435
|
Priority,
|
1429
1436
|
ProseKitError,
|
1437
|
+
getId as _getId,
|
1430
1438
|
addMark,
|
1431
1439
|
createEditor,
|
1432
1440
|
defineBaseCommands,
|
@@ -1440,7 +1448,7 @@ export {
|
|
1440
1448
|
defineMarkSpec,
|
1441
1449
|
defineNodeSpec,
|
1442
1450
|
defineNodeView,
|
1443
|
-
|
1451
|
+
defineNodeViewFactory,
|
1444
1452
|
defineParagraph,
|
1445
1453
|
definePlugin,
|
1446
1454
|
defineText,
|
package/dist/style.css
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.1.
|
4
|
+
"version": "0.1.9",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -38,15 +38,15 @@
|
|
38
38
|
"dist"
|
39
39
|
],
|
40
40
|
"dependencies": {
|
41
|
-
"@prosekit/pm": "^0.1.
|
41
|
+
"@prosekit/pm": "^0.1.1",
|
42
42
|
"orderedmap": "^2.1.1",
|
43
|
-
"type-fest": "^4.8.
|
43
|
+
"type-fest": "^4.8.3"
|
44
44
|
},
|
45
45
|
"devDependencies": {
|
46
46
|
"@prosekit/dev": "*",
|
47
47
|
"tsup": "^8.0.1",
|
48
|
-
"typescript": "^5.3.
|
49
|
-
"vitest": "^0.
|
48
|
+
"typescript": "^5.3.3",
|
49
|
+
"vitest": "^1.0.4"
|
50
50
|
},
|
51
51
|
"scripts": {
|
52
52
|
"build:tsup": "tsup",
|
package/src/index.ts
CHANGED
@@ -25,8 +25,8 @@ export { defineMarkSpec, type MarkSpecOptions } from './extensions/mark-spec'
|
|
25
25
|
export { defineNodeSpec, type NodeSpecOptions } from './extensions/node-spec'
|
26
26
|
export { defineNodeView, type NodeViewOptions } from './extensions/node-view'
|
27
27
|
export {
|
28
|
-
|
29
|
-
type
|
28
|
+
defineNodeViewFactory,
|
29
|
+
type NodeViewFactoryOptions,
|
30
30
|
} from './extensions/node-view-effect'
|
31
31
|
export { defineParagraph } from './extensions/paragraph'
|
32
32
|
export {
|
@@ -37,6 +37,7 @@ export {
|
|
37
37
|
export { defineText } from './extensions/text'
|
38
38
|
export { defineUpdateHandler } from './extensions/update-handler'
|
39
39
|
export { Facet, type FacetOptions } from './facets/facet'
|
40
|
+
export type { BaseNodeViewOptions } from './types/base-node-view-options'
|
40
41
|
export { type CommandArgs } from './types/command'
|
41
42
|
export {
|
42
43
|
type Extension,
|
@@ -50,6 +51,7 @@ export { type ExtensionTyping } from './types/extension-typing'
|
|
50
51
|
export type { NodeJSON, SelectionJSON, StateJSON } from './types/model'
|
51
52
|
export { Priority } from './types/priority'
|
52
53
|
export { type SimplifyUnion } from './types/simplify-union'
|
54
|
+
export { getId as _getId } from './utils/get-id'
|
53
55
|
export { getMarkType } from './utils/get-mark-type'
|
54
56
|
export { getNodeType } from './utils/get-node-type'
|
55
57
|
export {
|