@prosekit/core 0.1.1 → 0.1.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.
- package/dist/_tsup-dts-rollup.d.ts +16 -8
- package/dist/prosekit-core.d.ts +59 -1
- package/dist/prosekit-core.js +7 -26
- package/package.json +3 -3
- package/src/index.ts +71 -0
@@ -171,9 +171,16 @@ declare function defineBaseCommands(): Extension<{
|
|
171
171
|
from?: number | undefined;
|
172
172
|
to?: number | undefined;
|
173
173
|
}];
|
174
|
-
insertNode: [{
|
174
|
+
insertNode: [options: {
|
175
175
|
node: Node_2;
|
176
176
|
pos?: number | undefined;
|
177
|
+
type?: undefined;
|
178
|
+
attrs?: undefined;
|
179
|
+
} | {
|
180
|
+
node?: undefined;
|
181
|
+
pos?: number | undefined;
|
182
|
+
type: string;
|
183
|
+
attrs?: Attrs_2 | undefined;
|
177
184
|
}];
|
178
185
|
wrap: [{
|
179
186
|
nodeType: NodeType_2;
|
@@ -579,17 +586,18 @@ export { getNodeType as getNodeType_alias_1 }
|
|
579
586
|
declare function insertNode(options: {
|
580
587
|
node: ProseMirrorNode;
|
581
588
|
pos?: number;
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
type: string;
|
589
|
+
type?: undefined;
|
590
|
+
attrs?: undefined;
|
591
|
+
} | {
|
592
|
+
node?: undefined;
|
587
593
|
pos?: number;
|
594
|
+
type: string;
|
595
|
+
attrs?: Attrs;
|
588
596
|
}): Command;
|
589
597
|
export { insertNode }
|
590
598
|
export { insertNode as insertNode_alias_1 }
|
591
599
|
|
592
|
-
export declare function
|
600
|
+
export declare function insertNodeAction({ node, pos, }: {
|
593
601
|
node: ProseMirrorNode;
|
594
602
|
pos?: number;
|
595
603
|
}): Action;
|
@@ -990,7 +998,7 @@ export declare function updateExtension(prevInputs: Payloads, prevConverters: Co
|
|
990
998
|
|
991
999
|
export declare type UpdateHandler = (options: {
|
992
1000
|
view: EditorView;
|
993
|
-
prevState
|
1001
|
+
prevState?: EditorState;
|
994
1002
|
}) => void;
|
995
1003
|
|
996
1004
|
export declare const viewFacet: Facet<ViewPayload, ViewPayload>;
|
package/dist/prosekit-core.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
export { ProseKitError } from './_tsup-dts-rollup';
|
1
2
|
export { addMark } from './_tsup-dts-rollup';
|
2
3
|
export { insertNode } from './_tsup-dts-rollup';
|
3
4
|
export { removeMark } from './_tsup-dts-rollup';
|
@@ -9,7 +10,6 @@ export { createEditor } from './_tsup-dts-rollup';
|
|
9
10
|
export { EditorOptions } from './_tsup-dts-rollup';
|
10
11
|
export { union } from './_tsup-dts-rollup';
|
11
12
|
export { withPriority } from './_tsup-dts-rollup';
|
12
|
-
export { ProseKitError_alias_1 as ProseKitError } from './_tsup-dts-rollup';
|
13
13
|
export { defineBaseCommands } from './_tsup-dts-rollup';
|
14
14
|
export { defineCommands } from './_tsup-dts-rollup';
|
15
15
|
export { defineDefaultState } from './_tsup-dts-rollup';
|
@@ -64,3 +64,61 @@ export { isMark } from './_tsup-dts-rollup';
|
|
64
64
|
export { isNodeSelection } from './_tsup-dts-rollup';
|
65
65
|
export { isProseMirrorNode } from './_tsup-dts-rollup';
|
66
66
|
export { isTextSelection } from './_tsup-dts-rollup';
|
67
|
+
export { insertText } from './_tsup-dts-rollup';
|
68
|
+
export { selectAll } from './_tsup-dts-rollup';
|
69
|
+
export { wrap } from './_tsup-dts-rollup';
|
70
|
+
export { createNodeBuilder } from './_tsup-dts-rollup';
|
71
|
+
export { createMarkBuilder } from './_tsup-dts-rollup';
|
72
|
+
export { NodeChild } from './_tsup-dts-rollup';
|
73
|
+
export { NodeBuilder } from './_tsup-dts-rollup';
|
74
|
+
export { MarkBuilder } from './_tsup-dts-rollup';
|
75
|
+
export { applyAction } from './_tsup-dts-rollup';
|
76
|
+
export { insertNodeAction } from './_tsup-dts-rollup';
|
77
|
+
export { defineParagraphSpec } from './_tsup-dts-rollup';
|
78
|
+
export { UpdateHandler } from './_tsup-dts-rollup';
|
79
|
+
export { BaseExtension } from './_tsup-dts-rollup';
|
80
|
+
export { CommandPayload } from './_tsup-dts-rollup';
|
81
|
+
export { commandFacet } from './_tsup-dts-rollup';
|
82
|
+
export { getFacetCount } from './_tsup-dts-rollup';
|
83
|
+
export { FacetConverter } from './_tsup-dts-rollup';
|
84
|
+
export { FacetExtensionImpl } from './_tsup-dts-rollup';
|
85
|
+
export { updateExtension } from './_tsup-dts-rollup';
|
86
|
+
export { Payloads } from './_tsup-dts-rollup';
|
87
|
+
export { Converters } from './_tsup-dts-rollup';
|
88
|
+
export { SchemaPayload } from './_tsup-dts-rollup';
|
89
|
+
export { schemaFacet } from './_tsup-dts-rollup';
|
90
|
+
export { StatePayload } from './_tsup-dts-rollup';
|
91
|
+
export { stateFacet } from './_tsup-dts-rollup';
|
92
|
+
export { UnionExtensionImpl } from './_tsup-dts-rollup';
|
93
|
+
export { ViewPayload } from './_tsup-dts-rollup';
|
94
|
+
export { viewFacet } from './_tsup-dts-rollup';
|
95
|
+
export { assertTypeEqual } from './_tsup-dts-rollup';
|
96
|
+
export { CommandApplier } from './_tsup-dts-rollup';
|
97
|
+
export { CommandCreator } from './_tsup-dts-rollup';
|
98
|
+
export { CommandCreators } from './_tsup-dts-rollup';
|
99
|
+
export { ToCommandArgs } from './_tsup-dts-rollup';
|
100
|
+
export { ToCommandCreators } from './_tsup-dts-rollup';
|
101
|
+
export { ToCommandApplier } from './_tsup-dts-rollup';
|
102
|
+
export { ExceptEmptyValue } from './_tsup-dts-rollup';
|
103
|
+
export { ExtractNodesFromTyping } from './_tsup-dts-rollup';
|
104
|
+
export { ExtractMarksFromTyping } from './_tsup-dts-rollup';
|
105
|
+
export { ExtractCommandArgsFromTyping } from './_tsup-dts-rollup';
|
106
|
+
export { ExtractTyping } from './_tsup-dts-rollup';
|
107
|
+
export { ExtractCommandArgs } from './_tsup-dts-rollup';
|
108
|
+
export { ExtractKey } from './_tsup-dts-rollup';
|
109
|
+
export { voidFunction } from './_tsup-dts-rollup';
|
110
|
+
export { attrsMatch } from './_tsup-dts-rollup';
|
111
|
+
export { collectNodes } from './_tsup-dts-rollup';
|
112
|
+
export { NodeContent } from './_tsup-dts-rollup';
|
113
|
+
export { isMac } from './_tsup-dts-rollup';
|
114
|
+
export { getCustomSelection } from './_tsup-dts-rollup';
|
115
|
+
export { getBrowserDocument } from './_tsup-dts-rollup';
|
116
|
+
export { getBrowserWindow } from './_tsup-dts-rollup';
|
117
|
+
export { isMarkActive } from './_tsup-dts-rollup';
|
118
|
+
export { isNodeActive } from './_tsup-dts-rollup';
|
119
|
+
export { isNotNull } from './_tsup-dts-rollup';
|
120
|
+
export { objectEqual } from './_tsup-dts-rollup';
|
121
|
+
export { elementFromHTML } from './_tsup-dts-rollup';
|
122
|
+
export { uniqPush } from './_tsup-dts-rollup';
|
123
|
+
export { uniqRemove } from './_tsup-dts-rollup';
|
124
|
+
export { default_alias as default } from './_tsup-dts-rollup';
|
package/dist/prosekit-core.js
CHANGED
@@ -746,8 +746,8 @@ function flattenChildren(schema, children, mark) {
|
|
746
746
|
}
|
747
747
|
function normalizeArgs(args) {
|
748
748
|
const [attrs, ...children] = args;
|
749
|
-
if (isNodeChild(
|
750
|
-
children.unshift(
|
749
|
+
if (isNodeChild(attrs)) {
|
750
|
+
children.unshift(attrs);
|
751
751
|
return [null, children];
|
752
752
|
} else if (typeof attrs === "object") {
|
753
753
|
return [attrs, children];
|
@@ -1082,26 +1082,6 @@ function wrap({
|
|
1082
1082
|
};
|
1083
1083
|
}
|
1084
1084
|
|
1085
|
-
// src/extensions/actions.ts
|
1086
|
-
import "@prosekit/pm/model";
|
1087
|
-
import { Selection as Selection2 } from "@prosekit/pm/state";
|
1088
|
-
import { insertPoint as insertPoint2 } from "@prosekit/pm/transform";
|
1089
|
-
function insertNode2({
|
1090
|
-
node,
|
1091
|
-
pos
|
1092
|
-
}) {
|
1093
|
-
return ({ tr }) => {
|
1094
|
-
const insertPos = insertPoint2(tr.doc, pos != null ? pos : tr.selection.to, node.type);
|
1095
|
-
if (insertPos == null) {
|
1096
|
-
return false;
|
1097
|
-
}
|
1098
|
-
tr.insert(insertPos, node);
|
1099
|
-
const $pos = tr.doc.resolve(insertPos);
|
1100
|
-
tr.setSelection(Selection2.near($pos));
|
1101
|
-
return true;
|
1102
|
-
};
|
1103
|
-
}
|
1104
|
-
|
1105
1085
|
// src/extensions/command.ts
|
1106
1086
|
function defineCommands(commands) {
|
1107
1087
|
return commandFacet.extension([commands]);
|
@@ -1109,7 +1089,7 @@ function defineCommands(commands) {
|
|
1109
1089
|
function defineBaseCommands() {
|
1110
1090
|
return defineCommands({
|
1111
1091
|
insertText,
|
1112
|
-
insertNode
|
1092
|
+
insertNode,
|
1113
1093
|
wrap,
|
1114
1094
|
setBlockType,
|
1115
1095
|
selectAll,
|
@@ -1393,10 +1373,11 @@ var updateHandlerFacet = Facet.define({
|
|
1393
1373
|
let updateHandlers = [];
|
1394
1374
|
const plugin = new ProseMirrorPlugin3({
|
1395
1375
|
key: pluginKey,
|
1396
|
-
view: () => {
|
1376
|
+
view: (view) => {
|
1377
|
+
updateHandlers.forEach((fn) => fn({ view }));
|
1397
1378
|
return {
|
1398
|
-
update: (
|
1399
|
-
updateHandlers.forEach((fn) => fn({ view, prevState }));
|
1379
|
+
update: (view2, prevState) => {
|
1380
|
+
updateHandlers.forEach((fn) => fn({ view: view2, prevState }));
|
1400
1381
|
}
|
1401
1382
|
};
|
1402
1383
|
}
|
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.3",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -40,11 +40,11 @@
|
|
40
40
|
"dependencies": {
|
41
41
|
"@prosekit/pm": "^0.1.0",
|
42
42
|
"orderedmap": "^2.1.1",
|
43
|
-
"type-fest": "^4.
|
43
|
+
"type-fest": "^4.8.0"
|
44
44
|
},
|
45
45
|
"devDependencies": {
|
46
46
|
"@prosekit/dev": "*",
|
47
|
-
"tsup": "^7.
|
47
|
+
"tsup": "^7.3.0",
|
48
48
|
"typescript": "^5.2.2",
|
49
49
|
"vitest": "^0.34.6"
|
50
50
|
},
|
package/src/index.ts
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
export { addMark } from './commands/add-mark'
|
2
|
+
export { insertNode } from './commands/insert-node'
|
3
|
+
export { removeMark } from './commands/remove-mark'
|
4
|
+
export { setBlockType } from './commands/set-block-type'
|
5
|
+
export { toggleMark } from './commands/toggle-mark'
|
6
|
+
export { toggleNode } from './commands/toggle-node'
|
7
|
+
export { Editor, createEditor, type EditorOptions } from './editor/editor'
|
8
|
+
export { union } from './editor/union'
|
9
|
+
export { withPriority } from './editor/with-priority'
|
10
|
+
export { ProseKitError } from './error'
|
11
|
+
export { defineBaseCommands, defineCommands } from './extensions/command'
|
12
|
+
export {
|
13
|
+
defineDefaultState,
|
14
|
+
type DefaultStateOptions,
|
15
|
+
} from './extensions/default-state'
|
16
|
+
export { defineDoc } from './extensions/doc'
|
17
|
+
export { defineHistory } from './extensions/history'
|
18
|
+
export { defineInputRule } from './extensions/input-rules'
|
19
|
+
export {
|
20
|
+
defineBaseKeymap,
|
21
|
+
defineKeymap,
|
22
|
+
type Keymap,
|
23
|
+
} from './extensions/keymap'
|
24
|
+
export { defineMarkSpec, type MarkSpecOptions } from './extensions/mark-spec'
|
25
|
+
export { defineNodeSpec, type NodeSpecOptions } from './extensions/node-spec'
|
26
|
+
export { defineNodeView, type NodeViewOptions } from './extensions/node-view'
|
27
|
+
export {
|
28
|
+
defineNodeViewEffect,
|
29
|
+
type NodeViewEffectOptions,
|
30
|
+
} from './extensions/node-view-effect'
|
31
|
+
export { defineParagraph } from './extensions/paragraph'
|
32
|
+
export {
|
33
|
+
definePlugin,
|
34
|
+
pluginFacet,
|
35
|
+
type PluginPayload,
|
36
|
+
} from './extensions/plugin'
|
37
|
+
export { defineText } from './extensions/text'
|
38
|
+
export { defineUpdateHandler } from './extensions/update-handler'
|
39
|
+
export { Facet, type FacetOptions } from './facets/facet'
|
40
|
+
export { type CommandArgs } from './types/command'
|
41
|
+
export {
|
42
|
+
type Extension,
|
43
|
+
type ExtractCommandAppliers,
|
44
|
+
type ExtractCommandCreators,
|
45
|
+
type ExtractMarks,
|
46
|
+
type ExtractNodes,
|
47
|
+
type SimplifyExtension,
|
48
|
+
} from './types/extension'
|
49
|
+
export { type ExtensionTyping } from './types/extension-typing'
|
50
|
+
export type { NodeJSON, SelectionJSON, StateJSON } from './types/model'
|
51
|
+
export { Priority } from './types/priority'
|
52
|
+
export { type SimplifyUnion } from './types/simplify-union'
|
53
|
+
export { getMarkType } from './utils/get-mark-type'
|
54
|
+
export { getNodeType } from './utils/get-node-type'
|
55
|
+
export {
|
56
|
+
jsonFromElement,
|
57
|
+
jsonFromHTML,
|
58
|
+
jsonFromNode,
|
59
|
+
jsonFromState,
|
60
|
+
nodeFromElement,
|
61
|
+
nodeFromHTML,
|
62
|
+
nodeFromJSON,
|
63
|
+
stateFromJSON,
|
64
|
+
} from './utils/parse'
|
65
|
+
export {
|
66
|
+
isAllSelection,
|
67
|
+
isMark,
|
68
|
+
isNodeSelection,
|
69
|
+
isProseMirrorNode,
|
70
|
+
isTextSelection,
|
71
|
+
} from './utils/type-assertion'
|