@prosekit/core 0.0.11 → 0.0.12
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 +128 -128
- package/dist/prosekit-core.d.ts +16 -16
- package/dist/prosekit-core.js +48 -47
- package/dist/style.css +4 -1
- package/package.json +3 -3
- package/src/index.ts +18 -14
@@ -30,12 +30,90 @@ declare type Action = (options: {
|
|
30
30
|
view?: EditorView;
|
31
31
|
}) => boolean;
|
32
32
|
|
33
|
+
declare function addMark(options: AddMarkOptions): Command;
|
34
|
+
export { addMark }
|
35
|
+
export { addMark as addMark_alias_1 }
|
36
|
+
|
37
|
+
declare interface AddMarkOptions {
|
38
|
+
type: string | MarkType;
|
39
|
+
attrs?: Attrs | null;
|
40
|
+
/**
|
41
|
+
* The start position of the mark. By default it will be the start position of current selection.
|
42
|
+
*/
|
43
|
+
from?: number;
|
44
|
+
/**
|
45
|
+
* The end position of the mark. By default it will be the end position of current selection.
|
46
|
+
*/
|
47
|
+
to?: number;
|
48
|
+
}
|
49
|
+
export { AddMarkOptions }
|
50
|
+
export { AddMarkOptions as AddMarkOptions_alias_1 }
|
51
|
+
|
52
|
+
export declare type AnySlot = Slot<any, any>;
|
53
|
+
|
54
|
+
export declare function applyAction(operator: Action): Command;
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Utility function assert that two types are equal in tests.
|
58
|
+
*/
|
59
|
+
export declare function assertTypeEqual<T, U>(_val: IsEqual<T, U>): void;
|
60
|
+
|
61
|
+
export declare function collectNodes(content: NodeContent): ProseMirrorNode[];
|
62
|
+
|
63
|
+
export declare interface CommandApplier<Args extends any[] = any[]> {
|
64
|
+
(...args: Args): boolean;
|
65
|
+
canApply(...args: Args): boolean;
|
66
|
+
}
|
67
|
+
|
68
|
+
/** @internal */
|
69
|
+
declare interface CommandArgs {
|
70
|
+
[name: string]: any[];
|
71
|
+
}
|
72
|
+
export { CommandArgs }
|
73
|
+
export { CommandArgs as CommandArgs_alias_1 }
|
74
|
+
|
75
|
+
export declare type CommandCreator<Args extends any[] = any[]> = (...arg: Args) => Command;
|
76
|
+
|
77
|
+
export declare interface CommandCreators {
|
78
|
+
[name: string]: CommandCreator;
|
79
|
+
}
|
80
|
+
|
81
|
+
export declare const commandSlot: Facet<CommandSlotInput, CommandSlotInput>;
|
82
|
+
|
83
|
+
export declare type CommandSlotInput = Record<string, CommandCreator<any>>;
|
84
|
+
|
85
|
+
/** @public */
|
86
|
+
declare function createEditor<E extends Extension>({ extension, defaultDoc, defaultSelection, }: EditorOptions<E>): Editor<E>;
|
87
|
+
export { createEditor }
|
88
|
+
export { createEditor as createEditor_alias_1 }
|
89
|
+
|
90
|
+
export declare function createMarkBuilder(getState: () => EditorState | null | undefined, type: MarkType): MarkBuilder;
|
91
|
+
|
92
|
+
export declare function createNodeBuilder(getState: () => EditorState | null | undefined, type: NodeType): NodeBuilder;
|
93
|
+
|
94
|
+
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
95
|
+
|
96
|
+
export declare const default_alias_1: UserProjectConfigExport;
|
97
|
+
|
98
|
+
declare interface DefaultStateOptions {
|
99
|
+
/**
|
100
|
+
* A JSON representation of a ProseMirror document.
|
101
|
+
*/
|
102
|
+
doc?: NodeJson;
|
103
|
+
/**
|
104
|
+
* A JSON representation of a ProseMirror selection.
|
105
|
+
*/
|
106
|
+
selection?: SelectionJson;
|
107
|
+
}
|
108
|
+
export { DefaultStateOptions }
|
109
|
+
export { DefaultStateOptions as DefaultStateOptions_alias_1 }
|
110
|
+
|
33
111
|
/**
|
34
112
|
* Add some base commands
|
35
113
|
*
|
36
114
|
* @public
|
37
115
|
*/
|
38
|
-
declare function
|
116
|
+
declare function defineBaseCommands(): Extension<{
|
39
117
|
COMMAND_ARGS: {
|
40
118
|
insertText: [{
|
41
119
|
text: string;
|
@@ -59,115 +137,96 @@ declare function addBaseCommands(): Extension<{
|
|
59
137
|
selectAll: [];
|
60
138
|
};
|
61
139
|
}>;
|
62
|
-
export {
|
63
|
-
export {
|
140
|
+
export { defineBaseCommands }
|
141
|
+
export { defineBaseCommands as defineBaseCommands_alias_1 }
|
64
142
|
|
65
143
|
/** @public */
|
66
|
-
declare function
|
67
|
-
export {
|
68
|
-
export {
|
144
|
+
declare function defineBaseKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
145
|
+
export { defineBaseKeymap }
|
146
|
+
export { defineBaseKeymap as defineBaseKeymap_alias_1 }
|
69
147
|
|
70
|
-
declare function
|
148
|
+
declare function defineCommands<T extends Record<string, CommandCreator> = Record<string, CommandCreator>>(commands: T): Extension<{
|
71
149
|
COMMAND_ARGS: {
|
72
150
|
[K in keyof T]: Parameters<T[K]>;
|
73
151
|
};
|
74
152
|
}>;
|
75
|
-
export {
|
76
|
-
export {
|
153
|
+
export { defineCommands }
|
154
|
+
export { defineCommands as defineCommands_alias_1 }
|
77
155
|
|
78
|
-
declare function
|
79
|
-
export {
|
80
|
-
export {
|
156
|
+
declare function defineDefaultState(options: DefaultStateOptions): Extension;
|
157
|
+
export { defineDefaultState }
|
158
|
+
export { defineDefaultState as defineDefaultState_alias_1 }
|
81
159
|
|
82
160
|
/** @public */
|
83
|
-
declare function
|
161
|
+
declare function defineDoc(): Extension< {
|
84
162
|
NODES: "doc";
|
85
163
|
}>;
|
86
|
-
export {
|
87
|
-
export {
|
164
|
+
export { defineDoc }
|
165
|
+
export { defineDoc as defineDoc_alias_1 }
|
88
166
|
|
89
167
|
/**
|
90
168
|
* @internal
|
91
169
|
*/
|
92
|
-
declare function
|
170
|
+
declare function defineEventHandler(options: {
|
93
171
|
update?: VoidFunction;
|
94
172
|
}): FacetExtension<VoidFunction, PluginFacetInput>;
|
95
|
-
export {
|
96
|
-
export {
|
173
|
+
export { defineEventHandler }
|
174
|
+
export { defineEventHandler as defineEventHandler_alias_1 }
|
97
175
|
|
98
176
|
/**
|
99
177
|
* Add undo/redo history to the editor.
|
100
178
|
*/
|
101
|
-
declare function
|
179
|
+
declare function defineHistory(): Extension< {
|
102
180
|
COMMAND_ARGS: {
|
103
181
|
undo: [];
|
104
182
|
redo: [];
|
105
183
|
};
|
106
184
|
}>;
|
107
|
-
export {
|
108
|
-
export {
|
185
|
+
export { defineHistory }
|
186
|
+
export { defineHistory as defineHistory_alias_1 }
|
109
187
|
|
110
188
|
/**
|
111
189
|
* @public
|
112
190
|
*/
|
113
|
-
declare function
|
191
|
+
declare function defineInputRule(rules: (context: {
|
114
192
|
schema: Schema;
|
115
193
|
}) => InputRule[]): Extension;
|
116
|
-
export {
|
117
|
-
export {
|
194
|
+
export { defineInputRule }
|
195
|
+
export { defineInputRule as defineInputRule_alias_1 }
|
118
196
|
|
119
197
|
/** @public */
|
120
|
-
declare function
|
121
|
-
export {
|
122
|
-
export {
|
123
|
-
|
124
|
-
declare function addMark(options: AddMarkOptions): Command;
|
125
|
-
export { addMark }
|
126
|
-
export { addMark as addMark_alias_1 }
|
127
|
-
|
128
|
-
declare interface AddMarkOptions {
|
129
|
-
type: string | MarkType;
|
130
|
-
attrs?: Attrs | null;
|
131
|
-
/**
|
132
|
-
* The start position of the mark. By default it will be the start position of current selection.
|
133
|
-
*/
|
134
|
-
from?: number;
|
135
|
-
/**
|
136
|
-
* The end position of the mark. By default it will be the end position of current selection.
|
137
|
-
*/
|
138
|
-
to?: number;
|
139
|
-
}
|
140
|
-
export { AddMarkOptions }
|
141
|
-
export { AddMarkOptions as AddMarkOptions_alias_1 }
|
198
|
+
declare function defineKeymap(keymap: Keymap): Extension;
|
199
|
+
export { defineKeymap }
|
200
|
+
export { defineKeymap as defineKeymap_alias_1 }
|
142
201
|
|
143
202
|
/**
|
144
203
|
* @public
|
145
204
|
*/
|
146
|
-
declare function
|
205
|
+
declare function defineMarkSpec<Mark extends string>(options: MarkSpecOptions<Mark>): Extension<{
|
147
206
|
MARKS: Mark;
|
148
207
|
}>;
|
149
|
-
export {
|
150
|
-
export {
|
208
|
+
export { defineMarkSpec }
|
209
|
+
export { defineMarkSpec as defineMarkSpec_alias_1 }
|
151
210
|
|
152
211
|
/**
|
153
212
|
* @public
|
154
213
|
*/
|
155
|
-
declare function
|
214
|
+
declare function defineNodeSpec<NodeName extends string>(options: NodeSpecOptions<NodeName>): Extension<{
|
156
215
|
NODES: NodeName;
|
157
216
|
}>;
|
158
|
-
export {
|
159
|
-
export {
|
217
|
+
export { defineNodeSpec }
|
218
|
+
export { defineNodeSpec as defineNodeSpec_alias_1 }
|
160
219
|
|
161
|
-
declare function
|
162
|
-
export {
|
163
|
-
export {
|
220
|
+
declare function defineNodeView(options: NodeViewOptions): Extension;
|
221
|
+
export { defineNodeView }
|
222
|
+
export { defineNodeView as defineNodeView_alias_1 }
|
164
223
|
|
165
224
|
/** @public */
|
166
|
-
declare function
|
225
|
+
declare function defineParagraph(): Extension< {
|
167
226
|
NODES: "paragraph";
|
168
227
|
}>;
|
169
|
-
export {
|
170
|
-
export {
|
228
|
+
export { defineParagraph }
|
229
|
+
export { defineParagraph as defineParagraph_alias_1 }
|
171
230
|
|
172
231
|
/**
|
173
232
|
* Adds a ProseMirror plugin to the editor.
|
@@ -177,81 +236,18 @@ export { addParagraph as addParagraph_alias_1 }
|
|
177
236
|
*
|
178
237
|
* @public
|
179
238
|
*/
|
180
|
-
declare function
|
239
|
+
declare function definePlugin(plugin: Plugin_2 | Plugin_2[] | ((context: {
|
181
240
|
schema: Schema;
|
182
241
|
}) => Plugin_2[])): Extension;
|
183
|
-
export {
|
184
|
-
export {
|
242
|
+
export { definePlugin }
|
243
|
+
export { definePlugin as definePlugin_alias_1 }
|
185
244
|
|
186
245
|
/** @public */
|
187
|
-
declare function
|
246
|
+
declare function defineText(): Extension< {
|
188
247
|
NODES: "text";
|
189
248
|
}>;
|
190
|
-
export {
|
191
|
-
export {
|
192
|
-
|
193
|
-
export declare type AnySlot = Slot<any, any>;
|
194
|
-
|
195
|
-
export declare function applyAction(operator: Action): Command;
|
196
|
-
|
197
|
-
/**
|
198
|
-
* Utility function assert that two types are equal in tests.
|
199
|
-
*/
|
200
|
-
export declare function assertTypeEqual<T, U>(_val: IsEqual<T, U>): void;
|
201
|
-
|
202
|
-
export declare function collectNodes(content: NodeContent): ProseMirrorNode[];
|
203
|
-
|
204
|
-
export declare interface CommandApplier<Args extends any[] = any[]> {
|
205
|
-
(...args: Args): boolean;
|
206
|
-
canApply(...args: Args): boolean;
|
207
|
-
}
|
208
|
-
|
209
|
-
/** @internal */
|
210
|
-
declare interface CommandArgs {
|
211
|
-
[name: string]: any[];
|
212
|
-
}
|
213
|
-
export { CommandArgs }
|
214
|
-
export { CommandArgs as CommandArgs_alias_1 }
|
215
|
-
|
216
|
-
export declare type CommandCreator<Args extends any[] = any[]> = (...arg: Args) => Command;
|
217
|
-
|
218
|
-
export declare interface CommandCreators {
|
219
|
-
[name: string]: CommandCreator;
|
220
|
-
}
|
221
|
-
|
222
|
-
export declare const commandSlot: Facet<CommandSlotInput, CommandSlotInput>;
|
223
|
-
|
224
|
-
export declare type CommandSlotInput = Record<string, CommandCreator<any>>;
|
225
|
-
|
226
|
-
/** @public */
|
227
|
-
declare function createEditor<E extends Extension>({ extension, defaultDoc, defaultSelection, }: EditorOptions<E>): Editor<E>;
|
228
|
-
export { createEditor }
|
229
|
-
export { createEditor as createEditor_alias_1 }
|
230
|
-
|
231
|
-
export declare function createMarkBuilder(getState: () => EditorState | null | undefined, type: MarkType): MarkBuilder;
|
232
|
-
|
233
|
-
export declare function createNodeBuilder(getState: () => EditorState | null | undefined, type: NodeType): NodeBuilder;
|
234
|
-
|
235
|
-
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
236
|
-
|
237
|
-
export declare const default_alias_1: UserProjectConfigExport;
|
238
|
-
|
239
|
-
declare interface DefaultStateOptions {
|
240
|
-
/**
|
241
|
-
* A JSON representation of a ProseMirror document.
|
242
|
-
*/
|
243
|
-
doc?: NodeJson;
|
244
|
-
/**
|
245
|
-
* A JSON representation of a ProseMirror selection.
|
246
|
-
*/
|
247
|
-
selection?: SelectionJson;
|
248
|
-
}
|
249
|
-
export { DefaultStateOptions }
|
250
|
-
export { DefaultStateOptions as DefaultStateOptions_alias_1 }
|
251
|
-
|
252
|
-
declare function defineExtension<E extends Extension | Extension[]>(extension: E): SimplifyExtension<E>;
|
253
|
-
export { defineExtension }
|
254
|
-
export { defineExtension as defineExtension_alias_1 }
|
249
|
+
export { defineText }
|
250
|
+
export { defineText as defineText_alias_1 }
|
255
251
|
|
256
252
|
/** @public */
|
257
253
|
declare class Editor<E extends Extension = any> {
|
@@ -301,7 +297,7 @@ declare interface EditorOptions<E extends Extension> {
|
|
301
297
|
export { EditorOptions }
|
302
298
|
export { EditorOptions as EditorOptions_alias_1 }
|
303
299
|
|
304
|
-
declare type EmptyValue =
|
300
|
+
declare type EmptyValue = undefined | null | EmptyObject;
|
305
301
|
|
306
302
|
export declare type ExceptEmptyValue<T> = ConditionalExcept<T, EmptyValue>;
|
307
303
|
|
@@ -662,6 +658,10 @@ declare interface ToggleNodeOptions {
|
|
662
658
|
export { ToggleNodeOptions }
|
663
659
|
export { ToggleNodeOptions as ToggleNodeOptions_alias_1 }
|
664
660
|
|
661
|
+
declare function union<E extends Extension | Extension[]>(extension: E): SimplifyExtension<E>;
|
662
|
+
export { union }
|
663
|
+
export { union as union_alias_1 }
|
664
|
+
|
665
665
|
export declare function uniqPush<T>(prev: readonly T[], next: readonly T[]): T[];
|
666
666
|
|
667
667
|
export declare function uniqRemove<T>(prev: T[], next: T[]): T[];
|
package/dist/prosekit-core.d.ts
CHANGED
@@ -10,31 +10,31 @@ export { EditorOptions } from './_tsup-dts-rollup';
|
|
10
10
|
export { Facet } from './_tsup-dts-rollup';
|
11
11
|
export { FacetExtension } from './_tsup-dts-rollup';
|
12
12
|
export { FacetOptions } from './_tsup-dts-rollup';
|
13
|
-
export {
|
13
|
+
export { union } from './_tsup-dts-rollup';
|
14
14
|
export { withPriority } from './_tsup-dts-rollup';
|
15
15
|
export { ProseKitError_alias_1 as ProseKitError } from './_tsup-dts-rollup';
|
16
|
-
export {
|
17
|
-
export {
|
18
|
-
export {
|
16
|
+
export { defineBaseCommands } from './_tsup-dts-rollup';
|
17
|
+
export { defineCommands } from './_tsup-dts-rollup';
|
18
|
+
export { defineDefaultState } from './_tsup-dts-rollup';
|
19
19
|
export { DefaultStateOptions } from './_tsup-dts-rollup';
|
20
|
-
export {
|
21
|
-
export {
|
22
|
-
export {
|
23
|
-
export {
|
24
|
-
export {
|
25
|
-
export {
|
20
|
+
export { defineDoc } from './_tsup-dts-rollup';
|
21
|
+
export { defineEventHandler } from './_tsup-dts-rollup';
|
22
|
+
export { defineHistory } from './_tsup-dts-rollup';
|
23
|
+
export { defineInputRule } from './_tsup-dts-rollup';
|
24
|
+
export { defineBaseKeymap } from './_tsup-dts-rollup';
|
25
|
+
export { defineKeymap } from './_tsup-dts-rollup';
|
26
26
|
export { Keymap } from './_tsup-dts-rollup';
|
27
|
-
export {
|
27
|
+
export { defineMarkSpec } from './_tsup-dts-rollup';
|
28
28
|
export { MarkSpecOptions } from './_tsup-dts-rollup';
|
29
|
-
export {
|
29
|
+
export { defineNodeSpec } from './_tsup-dts-rollup';
|
30
30
|
export { NodeSpecOptions } from './_tsup-dts-rollup';
|
31
|
-
export {
|
31
|
+
export { defineNodeView } from './_tsup-dts-rollup';
|
32
32
|
export { NodeViewOptions } from './_tsup-dts-rollup';
|
33
|
-
export {
|
34
|
-
export {
|
33
|
+
export { defineParagraph } from './_tsup-dts-rollup';
|
34
|
+
export { definePlugin } from './_tsup-dts-rollup';
|
35
35
|
export { pluginFacet } from './_tsup-dts-rollup';
|
36
36
|
export { PluginFacetInput } from './_tsup-dts-rollup';
|
37
|
-
export {
|
37
|
+
export { defineText } from './_tsup-dts-rollup';
|
38
38
|
export { CommandArgs } from './_tsup-dts-rollup';
|
39
39
|
export { Extension } from './_tsup-dts-rollup';
|
40
40
|
export { ExtractCommandAppliers } from './_tsup-dts-rollup';
|
package/dist/prosekit-core.js
CHANGED
@@ -306,7 +306,7 @@ var commandSlot = Facet.defineSlot({
|
|
306
306
|
});
|
307
307
|
|
308
308
|
// src/extensions/default-state.ts
|
309
|
-
function
|
309
|
+
function defineDefaultState(options) {
|
310
310
|
return stateSlot.extension([
|
311
311
|
({ schema }) => {
|
312
312
|
const config = {};
|
@@ -597,7 +597,7 @@ function updateExtension(prevInputs, prevSlots, extension, mode) {
|
|
597
597
|
}
|
598
598
|
|
599
599
|
// src/editor/type-utils.ts
|
600
|
-
function
|
600
|
+
function union(extension) {
|
601
601
|
if (extension && Array.isArray(extension)) {
|
602
602
|
return { extension };
|
603
603
|
}
|
@@ -611,9 +611,9 @@ function createEditor({
|
|
611
611
|
defaultSelection
|
612
612
|
}) {
|
613
613
|
if (defaultDoc) {
|
614
|
-
extension =
|
614
|
+
extension = union([
|
615
615
|
extension,
|
616
|
-
|
616
|
+
defineDefaultState({
|
617
617
|
doc: defaultDoc,
|
618
618
|
selection: defaultSelection
|
619
619
|
})
|
@@ -638,7 +638,7 @@ var EditorInstance = class {
|
|
638
638
|
const state = EditorState.create(stateConfig);
|
639
639
|
if (commandInput) {
|
640
640
|
for (const [name, commandCreator] of Object.entries(commandInput)) {
|
641
|
-
this.
|
641
|
+
this.defineCommand(name, commandCreator);
|
642
642
|
}
|
643
643
|
}
|
644
644
|
this.directEditorProps = { state, ...viewInput };
|
@@ -682,7 +682,7 @@ var EditorInstance = class {
|
|
682
682
|
if (commandInput) {
|
683
683
|
const names = Object.keys(commandInput);
|
684
684
|
for (const name of names) {
|
685
|
-
this.
|
685
|
+
this.defineCommand(name, commandInput[name]);
|
686
686
|
}
|
687
687
|
}
|
688
688
|
}
|
@@ -707,7 +707,7 @@ var EditorInstance = class {
|
|
707
707
|
throw new ProseKitError("Editor is not mounted");
|
708
708
|
return this.view;
|
709
709
|
}
|
710
|
-
|
710
|
+
definePlugins(plugins) {
|
711
711
|
const view = this.assertView;
|
712
712
|
const state = view.state;
|
713
713
|
const newPlugins = [...plugins, ...state.plugins];
|
@@ -723,7 +723,7 @@ var EditorInstance = class {
|
|
723
723
|
const newState = state.reconfigure({ plugins: newPlugins });
|
724
724
|
view.setProps({ state: newState });
|
725
725
|
}
|
726
|
-
|
726
|
+
defineCommand(name, commandCreator) {
|
727
727
|
const applier = (...args) => {
|
728
728
|
const view = this.view;
|
729
729
|
if (!view) {
|
@@ -828,11 +828,11 @@ function withPriority(extension, priority) {
|
|
828
828
|
import "@prosekit/pm/model";
|
829
829
|
import { AllSelection } from "@prosekit/pm/state";
|
830
830
|
import { findWrapping, insertPoint } from "@prosekit/pm/transform";
|
831
|
-
function
|
831
|
+
function defineCommands(commands) {
|
832
832
|
return commandSlot.extension([commands]);
|
833
833
|
}
|
834
|
-
function
|
835
|
-
return
|
834
|
+
function defineBaseCommands() {
|
835
|
+
return defineCommands({
|
836
836
|
insertText: ({
|
837
837
|
text,
|
838
838
|
from,
|
@@ -900,7 +900,7 @@ function addBaseCommands() {
|
|
900
900
|
}
|
901
901
|
|
902
902
|
// src/extensions/node-spec.ts
|
903
|
-
function
|
903
|
+
function defineNodeSpec(options) {
|
904
904
|
return nodeSpecFacet.extension([options]);
|
905
905
|
}
|
906
906
|
var nodeSpecFacet = Facet.define({
|
@@ -922,8 +922,8 @@ var nodeSpecFacet = Facet.define({
|
|
922
922
|
});
|
923
923
|
|
924
924
|
// src/extensions/doc.ts
|
925
|
-
function
|
926
|
-
return
|
925
|
+
function defineDoc() {
|
926
|
+
return defineNodeSpec({
|
927
927
|
name: "doc",
|
928
928
|
content: "block+"
|
929
929
|
});
|
@@ -939,7 +939,7 @@ function voidFunction() {
|
|
939
939
|
// src/extensions/plugin.ts
|
940
940
|
import "@prosekit/pm/model";
|
941
941
|
import { Plugin as Plugin2 } from "@prosekit/pm/state";
|
942
|
-
function
|
942
|
+
function definePlugin(plugin) {
|
943
943
|
if (plugin instanceof Plugin2) {
|
944
944
|
return pluginFacet.extension([() => [plugin]]);
|
945
945
|
}
|
@@ -962,7 +962,7 @@ var pluginFacet = Facet.define({
|
|
962
962
|
});
|
963
963
|
|
964
964
|
// src/extensions/event-handler.ts
|
965
|
-
function
|
965
|
+
function defineEventHandler(options) {
|
966
966
|
var _a;
|
967
967
|
const updateHandler = (_a = options == null ? void 0 : options.update) != null ? _a : voidFunction;
|
968
968
|
return eventFacet.extension([updateHandler]);
|
@@ -973,6 +973,7 @@ var eventFacet = Facet.define({
|
|
973
973
|
const plugin = new ProseMirrorPlugin({
|
974
974
|
key: pluginKey,
|
975
975
|
view: () => {
|
976
|
+
updateHandlers.forEach((fn) => fn());
|
976
977
|
return {
|
977
978
|
update: (_view, _prevState) => {
|
978
979
|
updateHandlers.forEach((fn) => fn());
|
@@ -1007,11 +1008,11 @@ var isMac = typeof navigator !== "undefined" ? /Mac|iP(hone|[ao]d)/.test(navigat
|
|
1007
1008
|
import { baseKeymap, chainCommands } from "@prosekit/pm/commands";
|
1008
1009
|
import { keydownHandler } from "@prosekit/pm/keymap";
|
1009
1010
|
import { Plugin as Plugin3, PluginKey as PluginKey2 } from "@prosekit/pm/state";
|
1010
|
-
function
|
1011
|
+
function defineKeymap(keymap) {
|
1011
1012
|
return keymapFacet.extension([keymap]);
|
1012
1013
|
}
|
1013
|
-
function
|
1014
|
-
return
|
1014
|
+
function defineBaseKeymap() {
|
1015
|
+
return defineKeymap(baseKeymap);
|
1015
1016
|
}
|
1016
1017
|
var keymapFacet = Facet.define({
|
1017
1018
|
slot: () => {
|
@@ -1058,7 +1059,7 @@ function mergeKeymaps(keymaps) {
|
|
1058
1059
|
var keymapPluginKey = new PluginKey2("prosekit-keymap");
|
1059
1060
|
|
1060
1061
|
// src/extensions/history.ts
|
1061
|
-
function
|
1062
|
+
function defineHistory() {
|
1062
1063
|
const keymap = {
|
1063
1064
|
"Mod-z": undo,
|
1064
1065
|
"Shift-Mod-z": redo
|
@@ -1066,10 +1067,10 @@ function addHistory() {
|
|
1066
1067
|
if (!isMac) {
|
1067
1068
|
keymap["Mod-y"] = redo;
|
1068
1069
|
}
|
1069
|
-
return
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1070
|
+
return union([
|
1071
|
+
definePlugin(history()),
|
1072
|
+
defineKeymap(keymap),
|
1073
|
+
defineCommands({
|
1073
1074
|
undo: () => undo,
|
1074
1075
|
redo: () => redo
|
1075
1076
|
})
|
@@ -1080,7 +1081,7 @@ function addHistory() {
|
|
1080
1081
|
import { inputRules } from "@prosekit/pm/inputrules";
|
1081
1082
|
import "@prosekit/pm/model";
|
1082
1083
|
import "@prosekit/pm/state";
|
1083
|
-
function
|
1084
|
+
function defineInputRule(rules) {
|
1084
1085
|
return inputRuleFacet.extension([rules]);
|
1085
1086
|
}
|
1086
1087
|
var inputRuleFacet = Facet.define({
|
@@ -1094,7 +1095,7 @@ var inputRuleFacet = Facet.define({
|
|
1094
1095
|
});
|
1095
1096
|
|
1096
1097
|
// src/extensions/mark-spec.ts
|
1097
|
-
function
|
1098
|
+
function defineMarkSpec(options) {
|
1098
1099
|
return markSpecFacet.extension([options]);
|
1099
1100
|
}
|
1100
1101
|
var markSpecFacet = Facet.define({
|
@@ -1114,7 +1115,7 @@ var markSpecFacet = Facet.define({
|
|
1114
1115
|
// src/extensions/node-view.ts
|
1115
1116
|
import { Plugin as Plugin5 } from "@prosekit/pm/state";
|
1116
1117
|
import "@prosekit/pm/view";
|
1117
|
-
function
|
1118
|
+
function defineNodeView(options) {
|
1118
1119
|
return nodeViewFacet.extension([options]);
|
1119
1120
|
}
|
1120
1121
|
var nodeViewFacet = Facet.define({
|
@@ -1131,8 +1132,8 @@ var nodeViewFacet = Facet.define({
|
|
1131
1132
|
});
|
1132
1133
|
|
1133
1134
|
// src/extensions/paragraph.ts
|
1134
|
-
function
|
1135
|
-
return
|
1135
|
+
function defineParagraph() {
|
1136
|
+
return defineNodeSpec({
|
1136
1137
|
name: "paragraph",
|
1137
1138
|
content: "inline*",
|
1138
1139
|
group: "block",
|
@@ -1144,8 +1145,8 @@ function addParagraph() {
|
|
1144
1145
|
}
|
1145
1146
|
|
1146
1147
|
// src/extensions/text.ts
|
1147
|
-
function
|
1148
|
-
return
|
1148
|
+
function defineText() {
|
1149
|
+
return defineNodeSpec({
|
1149
1150
|
name: "text",
|
1150
1151
|
group: "inline"
|
1151
1152
|
});
|
@@ -1156,28 +1157,28 @@ export {
|
|
1156
1157
|
FacetExtension,
|
1157
1158
|
Priority,
|
1158
1159
|
ProseKitError,
|
1159
|
-
addBaseCommands,
|
1160
|
-
addBaseKeymap,
|
1161
|
-
addCommands,
|
1162
|
-
addDefaultState,
|
1163
|
-
addDoc,
|
1164
|
-
addEventHandler,
|
1165
|
-
addHistory,
|
1166
|
-
addInputRule,
|
1167
|
-
addKeymap,
|
1168
1160
|
addMark,
|
1169
|
-
addMarkSpec,
|
1170
|
-
addNodeSpec,
|
1171
|
-
addNodeView,
|
1172
|
-
addParagraph,
|
1173
|
-
addPlugin,
|
1174
|
-
addText,
|
1175
1161
|
createEditor,
|
1176
|
-
|
1162
|
+
defineBaseCommands,
|
1163
|
+
defineBaseKeymap,
|
1164
|
+
defineCommands,
|
1165
|
+
defineDefaultState,
|
1166
|
+
defineDoc,
|
1167
|
+
defineEventHandler,
|
1168
|
+
defineHistory,
|
1169
|
+
defineInputRule,
|
1170
|
+
defineKeymap,
|
1171
|
+
defineMarkSpec,
|
1172
|
+
defineNodeSpec,
|
1173
|
+
defineNodeView,
|
1174
|
+
defineParagraph,
|
1175
|
+
definePlugin,
|
1176
|
+
defineText,
|
1177
1177
|
getMarkType,
|
1178
1178
|
getNodeType,
|
1179
1179
|
pluginFacet,
|
1180
1180
|
toggleMark,
|
1181
1181
|
toggleNode,
|
1182
|
+
union,
|
1182
1183
|
withPriority
|
1183
1184
|
};
|
package/dist/style.css
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* ../../node_modules/.pnpm/prosemirror-view@1.
|
1
|
+
/* ../../node_modules/.pnpm/prosemirror-view@1.32.1/node_modules/prosemirror-view/style/prosemirror.css */
|
2
2
|
.ProseMirror {
|
3
3
|
position: relative;
|
4
4
|
}
|
@@ -25,6 +25,9 @@
|
|
25
25
|
.ProseMirror-hideselection {
|
26
26
|
caret-color: transparent;
|
27
27
|
}
|
28
|
+
.ProseMirror [draggable][contenteditable=false] {
|
29
|
+
user-select: text;
|
30
|
+
}
|
28
31
|
.ProseMirror-selectednode {
|
29
32
|
outline: 2px solid #8cf;
|
30
33
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.
|
4
|
+
"version": "0.0.12",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -40,13 +40,13 @@
|
|
40
40
|
"dependencies": {
|
41
41
|
"@prosekit/pm": "^0.0.6",
|
42
42
|
"orderedmap": "^2.1.1",
|
43
|
-
"type-fest": "^4.
|
43
|
+
"type-fest": "^4.4.0"
|
44
44
|
},
|
45
45
|
"devDependencies": {
|
46
46
|
"@prosekit/dev": "*",
|
47
47
|
"tsup": "^7.2.0",
|
48
48
|
"typescript": "^5.2.2",
|
49
|
-
"vitest": "^0.34.
|
49
|
+
"vitest": "^0.34.6"
|
50
50
|
},
|
51
51
|
"scripts": {
|
52
52
|
"build:tsup": "tsup",
|
package/src/index.ts
CHANGED
@@ -3,29 +3,33 @@ export { toggleMark, type ToggleMarkOptions } from './commands/toggle-mark'
|
|
3
3
|
export { toggleNode, type ToggleNodeOptions } from './commands/toggle-node'
|
4
4
|
export { Editor, createEditor, type EditorOptions } from './editor/editor'
|
5
5
|
export { Facet, FacetExtension, type FacetOptions } from './editor/facet'
|
6
|
-
export {
|
6
|
+
export { union } from './editor/type-utils'
|
7
7
|
export { withPriority } from './editor/with-priority'
|
8
8
|
export { ProseKitError } from './error'
|
9
|
-
export {
|
9
|
+
export { defineBaseCommands, defineCommands } from './extensions/command'
|
10
10
|
export {
|
11
|
-
|
11
|
+
defineDefaultState,
|
12
12
|
type DefaultStateOptions,
|
13
13
|
} from './extensions/default-state'
|
14
|
-
export {
|
15
|
-
export {
|
16
|
-
export {
|
17
|
-
export {
|
18
|
-
export { addBaseKeymap, addKeymap, type Keymap } from './extensions/keymap'
|
19
|
-
export { addMarkSpec, type MarkSpecOptions } from './extensions/mark-spec'
|
20
|
-
export { addNodeSpec, type NodeSpecOptions } from './extensions/node-spec'
|
21
|
-
export { addNodeView, type NodeViewOptions } from './extensions/node-view'
|
22
|
-
export { addParagraph } from './extensions/paragraph'
|
14
|
+
export { defineDoc } from './extensions/doc'
|
15
|
+
export { defineEventHandler } from './extensions/event-handler'
|
16
|
+
export { defineHistory } from './extensions/history'
|
17
|
+
export { defineInputRule } from './extensions/input-rules'
|
23
18
|
export {
|
24
|
-
|
19
|
+
defineBaseKeymap,
|
20
|
+
defineKeymap,
|
21
|
+
type Keymap,
|
22
|
+
} from './extensions/keymap'
|
23
|
+
export { defineMarkSpec, type MarkSpecOptions } from './extensions/mark-spec'
|
24
|
+
export { defineNodeSpec, type NodeSpecOptions } from './extensions/node-spec'
|
25
|
+
export { defineNodeView, type NodeViewOptions } from './extensions/node-view'
|
26
|
+
export { defineParagraph } from './extensions/paragraph'
|
27
|
+
export {
|
28
|
+
definePlugin,
|
25
29
|
pluginFacet,
|
26
30
|
type PluginFacetInput,
|
27
31
|
} from './extensions/plugin'
|
28
|
-
export {
|
32
|
+
export { defineText } from './extensions/text'
|
29
33
|
export { type CommandArgs as CommandArgs } from './types/command'
|
30
34
|
export * from './types/editor'
|
31
35
|
export {
|