@prosekit/extensions 0.0.12 → 0.0.14
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 +93 -80
- package/dist/list/style.css +1 -1
- package/dist/prosekit-extensions-autocomplete.d.ts +1 -1
- package/dist/prosekit-extensions-autocomplete.js +2 -2
- package/dist/prosekit-extensions-blockquote.d.ts +2 -2
- package/dist/prosekit-extensions-blockquote.js +7 -7
- package/dist/prosekit-extensions-bold.d.ts +4 -4
- package/dist/prosekit-extensions-bold.js +16 -16
- package/dist/prosekit-extensions-code-block.d.ts +4 -4
- package/dist/prosekit-extensions-code-block.js +23 -23
- package/dist/prosekit-extensions-code.d.ts +2 -2
- package/dist/prosekit-extensions-code.js +7 -7
- package/dist/prosekit-extensions-heading.d.ts +5 -5
- package/dist/prosekit-extensions-heading.js +24 -24
- package/dist/prosekit-extensions-image.d.ts +3 -0
- package/dist/prosekit-extensions-image.js +35 -0
- package/dist/prosekit-extensions-italic.d.ts +4 -4
- package/dist/prosekit-extensions-italic.js +19 -19
- package/dist/prosekit-extensions-link.d.ts +3 -3
- package/dist/prosekit-extensions-link.js +12 -12
- package/dist/prosekit-extensions-list.d.ts +5 -5
- package/dist/prosekit-extensions-list.js +24 -24
- package/dist/prosekit-extensions-mention.d.ts +2 -2
- package/dist/prosekit-extensions-mention.js +7 -7
- package/dist/prosekit-extensions-placeholder.d.ts +1 -1
- package/dist/prosekit-extensions-placeholder.js +4 -4
- package/dist/prosekit-extensions-suggestion.d.ts +1 -1
- package/dist/prosekit-extensions-suggestion.js +5 -5
- package/package.json +13 -5
@@ -9,46 +9,89 @@ import { PluginKey } from '@prosekit/pm/state';
|
|
9
9
|
import { Transaction } from '@prosekit/pm/state';
|
10
10
|
import { UserProjectConfigExport } from 'vitest/dist/config.js';
|
11
11
|
|
12
|
-
|
12
|
+
declare class AutocompleteRule {
|
13
|
+
readonly regex: RegExp;
|
14
|
+
readonly onMatch: MatchHandler;
|
15
|
+
readonly onLeave?: VoidFunction;
|
16
|
+
readonly canMatch: (options: {
|
17
|
+
state: EditorState;
|
18
|
+
}) => boolean;
|
19
|
+
constructor(options: {
|
20
|
+
regex: RegExp;
|
21
|
+
onEnter: MatchHandler;
|
22
|
+
onLeave?: VoidFunction;
|
23
|
+
canMatch?: (options: {
|
24
|
+
state: EditorState;
|
25
|
+
}) => boolean;
|
26
|
+
});
|
27
|
+
}
|
28
|
+
export { AutocompleteRule }
|
29
|
+
export { AutocompleteRule as AutocompleteRule_alias_1 }
|
30
|
+
|
31
|
+
declare interface CodeBlockAttrs {
|
32
|
+
language?: string;
|
33
|
+
}
|
34
|
+
export { CodeBlockAttrs }
|
35
|
+
export { CodeBlockAttrs as CodeBlockAttrs_alias_1 }
|
36
|
+
|
37
|
+
export declare function createAutocompletePlugin({ getRules, }: {
|
38
|
+
getRules: () => AutocompleteRule[];
|
39
|
+
}): Plugin_2;
|
40
|
+
|
41
|
+
export declare function createPredictionPlugin(options: SuggestionOptions): Plugin_2;
|
42
|
+
|
43
|
+
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
44
|
+
|
45
|
+
export declare const default_alias_1: UserProjectConfigExport;
|
46
|
+
|
47
|
+
export declare function defaultCanMatch({ state }: {
|
48
|
+
state: EditorState;
|
49
|
+
}): boolean;
|
50
|
+
|
51
|
+
export declare function defaultIsValid({ state }: {
|
52
|
+
state: EditorState;
|
53
|
+
}): boolean;
|
54
|
+
|
55
|
+
export declare function defineAutocomplete(rule: AutocompleteRule): Extension;
|
13
56
|
|
14
57
|
/** @public */
|
15
|
-
export declare function
|
58
|
+
export declare function defineBlockquote(): Extension< {
|
16
59
|
NODES: "blockquote";
|
17
60
|
}>;
|
18
61
|
|
19
|
-
export declare function
|
62
|
+
export declare function defineBlockquoteSpec(): Extension< {
|
20
63
|
NODES: "blockquote";
|
21
64
|
}>;
|
22
65
|
|
23
66
|
/** @public */
|
24
|
-
export declare function
|
67
|
+
export declare function defineBold(): Extension< {
|
25
68
|
MARKS: "bold";
|
26
69
|
COMMAND_ARGS: {
|
27
70
|
toggleBold: [];
|
28
71
|
};
|
29
72
|
}>;
|
30
73
|
|
31
|
-
export declare function
|
74
|
+
export declare function defineBoldCommands(): Extension< {
|
32
75
|
COMMAND_ARGS: {
|
33
76
|
toggleBold: [];
|
34
77
|
};
|
35
78
|
}>;
|
36
79
|
|
37
|
-
export declare function
|
80
|
+
export declare function defineBoldKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
38
81
|
|
39
|
-
export declare function
|
82
|
+
export declare function defineBoldSpec(): Extension< {
|
40
83
|
MARKS: "bold";
|
41
84
|
}>;
|
42
85
|
|
43
86
|
/**
|
44
87
|
* @public
|
45
88
|
*/
|
46
|
-
export declare function
|
89
|
+
export declare function defineCode(): Extension< {
|
47
90
|
MARKS: "code";
|
48
91
|
}>;
|
49
92
|
|
50
93
|
/** @public */
|
51
|
-
export declare function
|
94
|
+
export declare function defineCodeBlock(options?: {
|
52
95
|
hljs?: HLJSApi;
|
53
96
|
}): Extension< {
|
54
97
|
NODES: "codeBlock";
|
@@ -57,53 +100,62 @@ setCodeBlockLanguage: [language: string];
|
|
57
100
|
};
|
58
101
|
}>;
|
59
102
|
|
60
|
-
export declare function
|
103
|
+
export declare function defineCodeBlockCommands(): Extension< {
|
61
104
|
COMMAND_ARGS: {
|
62
105
|
setCodeBlockLanguage: [language: string];
|
63
106
|
};
|
64
107
|
}>;
|
65
108
|
|
66
|
-
export declare function
|
109
|
+
export declare function defineCodeBlockHighlight(options: {
|
67
110
|
hljs?: HLJSApi;
|
68
111
|
}): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
69
112
|
|
70
|
-
export declare function
|
113
|
+
export declare function defineCodeBlockInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
71
114
|
|
72
|
-
export declare function
|
115
|
+
export declare function defineCodeBlockSpec(): Extension< {
|
73
116
|
NODES: "codeBlock";
|
74
117
|
}>;
|
75
118
|
|
76
119
|
/**
|
77
120
|
* @public
|
78
121
|
*/
|
79
|
-
export declare function
|
122
|
+
export declare function defineCodeSpec(): Extension< {
|
80
123
|
MARKS: "code";
|
81
124
|
}>;
|
82
125
|
|
83
126
|
/** @public */
|
84
|
-
export declare function
|
127
|
+
export declare function defineHeading(): Extension< {
|
85
128
|
NODES: "heading";
|
86
129
|
COMMAND_ARGS: {
|
87
130
|
toggleHeading: [attrs?: HeadingAttrs | undefined];
|
88
131
|
};
|
89
132
|
}>;
|
90
133
|
|
91
|
-
export declare function
|
134
|
+
export declare function defineHeadingCommands(): Extension< {
|
92
135
|
COMMAND_ARGS: {
|
93
136
|
toggleHeading: [attrs?: HeadingAttrs | undefined];
|
94
137
|
};
|
95
138
|
}>;
|
96
139
|
|
97
|
-
export declare function
|
140
|
+
export declare function defineHeadingInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
98
141
|
|
99
|
-
export declare function
|
142
|
+
export declare function defineHeadingKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
100
143
|
|
101
|
-
export declare function
|
144
|
+
export declare function defineHeadingSpec(): Extension< {
|
102
145
|
NODES: "heading";
|
103
146
|
}>;
|
104
147
|
|
105
148
|
/** @public */
|
106
|
-
export declare function
|
149
|
+
export declare function defineImage(): Extension< {
|
150
|
+
NODES: "image";
|
151
|
+
}>;
|
152
|
+
|
153
|
+
export declare function defineImageSpec(): Extension< {
|
154
|
+
NODES: "image";
|
155
|
+
}>;
|
156
|
+
|
157
|
+
/** @public */
|
158
|
+
export declare function defineItalic(): Extension< {
|
107
159
|
MARKS: "italic";
|
108
160
|
COMMAND_ARGS: {
|
109
161
|
toggleItalic: [];
|
@@ -111,7 +163,7 @@ toggleItalic: [];
|
|
111
163
|
}>;
|
112
164
|
|
113
165
|
/** @public */
|
114
|
-
export declare function
|
166
|
+
export declare function defineItalic_alias_1(): Extension< {
|
115
167
|
MARKS: "link";
|
116
168
|
COMMAND_ARGS: {
|
117
169
|
addLink: [attrs: LinkAttrs];
|
@@ -119,55 +171,55 @@ toggleLink: [attrs: LinkAttrs];
|
|
119
171
|
};
|
120
172
|
}>;
|
121
173
|
|
122
|
-
export declare function
|
174
|
+
export declare function defineItalicCommands(): Extension< {
|
123
175
|
COMMAND_ARGS: {
|
124
176
|
toggleItalic: [];
|
125
177
|
};
|
126
178
|
}>;
|
127
179
|
|
128
|
-
export declare function
|
180
|
+
export declare function defineItalicKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
129
181
|
|
130
|
-
export declare function
|
182
|
+
export declare function defineItalicSpec(): Extension< {
|
131
183
|
MARKS: "italic";
|
132
184
|
}>;
|
133
185
|
|
134
|
-
export declare function
|
186
|
+
export declare function defineLinkCommands(): Extension< {
|
135
187
|
COMMAND_ARGS: {
|
136
188
|
addLink: [attrs: LinkAttrs];
|
137
189
|
toggleLink: [attrs: LinkAttrs];
|
138
190
|
};
|
139
191
|
}>;
|
140
192
|
|
141
|
-
export declare function
|
193
|
+
export declare function defineLinkSpec(): Extension< {
|
142
194
|
MARKS: "link";
|
143
195
|
}>;
|
144
196
|
|
145
197
|
/** @public */
|
146
|
-
export declare function
|
198
|
+
export declare function defineList(): Extension< {
|
147
199
|
NODES: "list";
|
148
200
|
}>;
|
149
201
|
|
150
|
-
export declare function
|
202
|
+
export declare function defineListInputRules(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
151
203
|
|
152
|
-
export declare function
|
204
|
+
export declare function defineListKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
153
205
|
|
154
|
-
export declare function
|
206
|
+
export declare function defineListPlugins(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
155
207
|
|
156
|
-
export declare function
|
208
|
+
export declare function defineListSpec(): Extension< {
|
157
209
|
NODES: "list";
|
158
210
|
}>;
|
159
211
|
|
160
212
|
/**
|
161
213
|
* @public
|
162
214
|
*/
|
163
|
-
export declare function
|
215
|
+
export declare function defineMention(): Extension< {
|
164
216
|
NODES: "mention";
|
165
217
|
}>;
|
166
218
|
|
167
219
|
/**
|
168
220
|
* @public
|
169
221
|
*/
|
170
|
-
export declare function
|
222
|
+
export declare function defineMentionSpec(): Extension< {
|
171
223
|
NODES: "mention";
|
172
224
|
}>;
|
173
225
|
|
@@ -175,52 +227,9 @@ NODES: "mention";
|
|
175
227
|
* Add a placeholder text to the editor when the current block or document is
|
176
228
|
* empty.
|
177
229
|
*/
|
178
|
-
export declare function
|
230
|
+
export declare function definePlaceholder(options: PlaceholderOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
179
231
|
|
180
|
-
export declare function
|
181
|
-
|
182
|
-
declare class AutocompleteRule {
|
183
|
-
readonly regex: RegExp;
|
184
|
-
readonly onMatch: MatchHandler;
|
185
|
-
readonly onLeave?: VoidFunction;
|
186
|
-
readonly canMatch: (options: {
|
187
|
-
state: EditorState;
|
188
|
-
}) => boolean;
|
189
|
-
constructor(options: {
|
190
|
-
regex: RegExp;
|
191
|
-
onEnter: MatchHandler;
|
192
|
-
onLeave?: VoidFunction;
|
193
|
-
canMatch?: (options: {
|
194
|
-
state: EditorState;
|
195
|
-
}) => boolean;
|
196
|
-
});
|
197
|
-
}
|
198
|
-
export { AutocompleteRule }
|
199
|
-
export { AutocompleteRule as AutocompleteRule_alias_1 }
|
200
|
-
|
201
|
-
declare interface CodeBlockAttrs {
|
202
|
-
language?: string;
|
203
|
-
}
|
204
|
-
export { CodeBlockAttrs }
|
205
|
-
export { CodeBlockAttrs as CodeBlockAttrs_alias_1 }
|
206
|
-
|
207
|
-
export declare function createAutocompletePlugin({ getRules, }: {
|
208
|
-
getRules: () => AutocompleteRule[];
|
209
|
-
}): Plugin_2;
|
210
|
-
|
211
|
-
export declare function createPredictionPlugin(options: SuggestionOptions): Plugin_2;
|
212
|
-
|
213
|
-
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
214
|
-
|
215
|
-
export declare const default_alias_1: UserProjectConfigExport;
|
216
|
-
|
217
|
-
export declare function defaultCanMatch({ state }: {
|
218
|
-
state: EditorState;
|
219
|
-
}): boolean;
|
220
|
-
|
221
|
-
export declare function defaultIsValid({ state }: {
|
222
|
-
state: EditorState;
|
223
|
-
}): boolean;
|
232
|
+
export declare function defineSuggestion(options: SuggestionOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
224
233
|
|
225
234
|
export declare function getPluginState(state: EditorState): PredictionPluginState | undefined;
|
226
235
|
|
@@ -230,6 +239,10 @@ export declare interface HeadingAttrs {
|
|
230
239
|
level: number;
|
231
240
|
}
|
232
241
|
|
242
|
+
export declare interface ImageAttrs {
|
243
|
+
src?: string | null;
|
244
|
+
}
|
245
|
+
|
233
246
|
/** @public */
|
234
247
|
export declare interface LinkAttrs {
|
235
248
|
href: string;
|
@@ -283,7 +296,7 @@ export declare interface PlaceholderOptions {
|
|
283
296
|
|
284
297
|
export declare const pluginKey: PluginKey<PredictionPluginState>;
|
285
298
|
|
286
|
-
export declare
|
299
|
+
export declare interface PredictionPluginState {
|
287
300
|
active: boolean;
|
288
301
|
ignore: number | null;
|
289
302
|
matching: {
|
@@ -292,7 +305,7 @@ export declare type PredictionPluginState = {
|
|
292
305
|
to: number;
|
293
306
|
match: RegExpExecArray;
|
294
307
|
} | null;
|
295
|
-
}
|
308
|
+
}
|
296
309
|
|
297
310
|
declare interface PredictionRule {
|
298
311
|
match: RegExp;
|
package/dist/list/style.css
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* ../../node_modules/.pnpm/prosemirror-flat-list@0.4.
|
1
|
+
/* ../../node_modules/.pnpm/prosemirror-flat-list@0.4.3/node_modules/prosemirror-flat-list/dist/style.css */
|
2
2
|
.prosemirror-flat-list {
|
3
3
|
padding: 0;
|
4
4
|
margin-top: 0;
|
@@ -163,7 +163,7 @@ var AutocompleteRule = class {
|
|
163
163
|
};
|
164
164
|
|
165
165
|
// src/autocomplete/index.ts
|
166
|
-
function
|
166
|
+
function defineAutocomplete(rule) {
|
167
167
|
return autocompleteFacet.extension([rule]);
|
168
168
|
}
|
169
169
|
var autocompleteFacet = Facet.define({
|
@@ -186,5 +186,5 @@ var autocompleteFacet = Facet.define({
|
|
186
186
|
});
|
187
187
|
export {
|
188
188
|
AutocompleteRule,
|
189
|
-
|
189
|
+
defineAutocomplete
|
190
190
|
};
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export {
|
2
|
-
export {
|
1
|
+
export { defineBlockquoteSpec } from './_tsup-dts-rollup';
|
2
|
+
export { defineBlockquote } from './_tsup-dts-rollup';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// src/blockquote/index.ts
|
2
|
-
import {
|
3
|
-
function
|
4
|
-
return
|
2
|
+
import { defineNodeSpec, union } from "@prosekit/core";
|
3
|
+
function defineBlockquoteSpec() {
|
4
|
+
return defineNodeSpec({
|
5
5
|
name: "blockquote",
|
6
6
|
content: "block+",
|
7
7
|
group: "block",
|
@@ -12,10 +12,10 @@ function addBlockquoteSpec() {
|
|
12
12
|
}
|
13
13
|
});
|
14
14
|
}
|
15
|
-
function
|
16
|
-
return
|
15
|
+
function defineBlockquote() {
|
16
|
+
return union([defineBlockquoteSpec()]);
|
17
17
|
}
|
18
18
|
export {
|
19
|
-
|
20
|
-
|
19
|
+
defineBlockquote,
|
20
|
+
defineBlockquoteSpec
|
21
21
|
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export {
|
2
|
-
export {
|
3
|
-
export {
|
4
|
-
export {
|
1
|
+
export { defineBoldSpec } from './_tsup-dts-rollup';
|
2
|
+
export { defineBoldCommands } from './_tsup-dts-rollup';
|
3
|
+
export { defineBoldKeymap } from './_tsup-dts-rollup';
|
4
|
+
export { defineBold } from './_tsup-dts-rollup';
|
@@ -1,13 +1,13 @@
|
|
1
1
|
// src/bold/index.ts
|
2
2
|
import {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
defineCommands,
|
4
|
+
defineKeymap,
|
5
|
+
defineMarkSpec,
|
6
|
+
union,
|
7
7
|
toggleMark
|
8
8
|
} from "@prosekit/core";
|
9
|
-
function
|
10
|
-
return
|
9
|
+
function defineBoldSpec() {
|
10
|
+
return defineMarkSpec({
|
11
11
|
name: "bold",
|
12
12
|
parseDOM: [
|
13
13
|
{ tag: "strong" },
|
@@ -33,22 +33,22 @@ function addBoldSpec() {
|
|
33
33
|
}
|
34
34
|
});
|
35
35
|
}
|
36
|
-
function
|
37
|
-
return
|
36
|
+
function defineBoldCommands() {
|
37
|
+
return defineCommands({
|
38
38
|
toggleBold: () => toggleMark({ type: "bold" })
|
39
39
|
});
|
40
40
|
}
|
41
|
-
function
|
42
|
-
return
|
41
|
+
function defineBoldKeymap() {
|
42
|
+
return defineKeymap({
|
43
43
|
"Mod-b": toggleMark({ type: "bold" })
|
44
44
|
});
|
45
45
|
}
|
46
|
-
function
|
47
|
-
return
|
46
|
+
function defineBold() {
|
47
|
+
return union([defineBoldSpec(), defineBoldCommands(), defineBoldKeymap()]);
|
48
48
|
}
|
49
49
|
export {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
defineBold,
|
51
|
+
defineBoldCommands,
|
52
|
+
defineBoldKeymap,
|
53
|
+
defineBoldSpec
|
54
54
|
};
|
@@ -1,5 +1,5 @@
|
|
1
|
-
export {
|
2
|
-
export {
|
3
|
-
export {
|
4
|
-
export {
|
1
|
+
export { defineCodeBlockSpec } from './_tsup-dts-rollup';
|
2
|
+
export { defineCodeBlockInputRule } from './_tsup-dts-rollup';
|
3
|
+
export { defineCodeBlockCommands } from './_tsup-dts-rollup';
|
4
|
+
export { defineCodeBlock } from './_tsup-dts-rollup';
|
5
5
|
export { CodeBlockAttrs_alias_1 as CodeBlockAttrs } from './_tsup-dts-rollup';
|
@@ -1,19 +1,19 @@
|
|
1
1
|
// src/code-block/index.ts
|
2
2
|
import {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
defineCommands,
|
4
|
+
defineInputRule,
|
5
|
+
defineNodeSpec,
|
6
|
+
union,
|
7
7
|
getNodeType
|
8
8
|
} from "@prosekit/core";
|
9
9
|
import { textblockTypeInputRule } from "@prosekit/pm/inputrules";
|
10
10
|
|
11
11
|
// src/code-block/code-block-highlight.ts
|
12
|
-
import {
|
12
|
+
import { definePlugin } from "@prosekit/core";
|
13
13
|
import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state";
|
14
14
|
import { DecorationSet } from "@prosekit/pm/view";
|
15
15
|
import { getHighlightDecorations } from "prosemirror-highlightjs";
|
16
|
-
function
|
16
|
+
function defineCodeBlockHighlight(options) {
|
17
17
|
const hljs = options.hljs;
|
18
18
|
const plugin = new ProseMirrorPlugin({
|
19
19
|
key,
|
@@ -41,7 +41,7 @@ function addCodeBlockHighlight(options) {
|
|
41
41
|
}
|
42
42
|
}
|
43
43
|
});
|
44
|
-
return
|
44
|
+
return definePlugin(plugin);
|
45
45
|
}
|
46
46
|
var key = new PluginKey("prosekit-code-block-highlight");
|
47
47
|
var blockTypes = ["codeBlock"];
|
@@ -50,8 +50,8 @@ function languageExtractor(node) {
|
|
50
50
|
}
|
51
51
|
|
52
52
|
// src/code-block/index.ts
|
53
|
-
function
|
54
|
-
return
|
53
|
+
function defineCodeBlockSpec() {
|
54
|
+
return defineNodeSpec({
|
55
55
|
name: "codeBlock",
|
56
56
|
content: "text*",
|
57
57
|
group: "block",
|
@@ -78,8 +78,8 @@ function addCodeBlockSpec() {
|
|
78
78
|
}
|
79
79
|
});
|
80
80
|
}
|
81
|
-
function
|
82
|
-
return
|
81
|
+
function defineCodeBlockInputRule() {
|
82
|
+
return defineInputRule(({ schema }) => {
|
83
83
|
const nodeType = getNodeType(schema, "codeBlock");
|
84
84
|
const getAttrs = (match) => {
|
85
85
|
return { language: match[1] || "" };
|
@@ -88,8 +88,8 @@ function addCodeBlockInputRule() {
|
|
88
88
|
return [inputRule];
|
89
89
|
});
|
90
90
|
}
|
91
|
-
function
|
92
|
-
return
|
91
|
+
function defineCodeBlockCommands() {
|
92
|
+
return defineCommands({
|
93
93
|
setCodeBlockLanguage: (language) => (state, dispatch) => {
|
94
94
|
const pos = state.selection.$from.before();
|
95
95
|
const codeBlock = state.doc.nodeAt(pos);
|
@@ -103,17 +103,17 @@ function addCodeBlockCommands() {
|
|
103
103
|
}
|
104
104
|
});
|
105
105
|
}
|
106
|
-
function
|
107
|
-
return
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
106
|
+
function defineCodeBlock(options) {
|
107
|
+
return union([
|
108
|
+
defineCodeBlockSpec(),
|
109
|
+
defineCodeBlockInputRule(),
|
110
|
+
defineCodeBlockHighlight({ hljs: options == null ? void 0 : options.hljs }),
|
111
|
+
defineCodeBlockCommands()
|
112
112
|
]);
|
113
113
|
}
|
114
114
|
export {
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
115
|
+
defineCodeBlock,
|
116
|
+
defineCodeBlockCommands,
|
117
|
+
defineCodeBlockInputRule,
|
118
|
+
defineCodeBlockSpec
|
119
119
|
};
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export {
|
2
|
-
export {
|
1
|
+
export { defineCodeSpec } from './_tsup-dts-rollup';
|
2
|
+
export { defineCode } from './_tsup-dts-rollup';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// src/code/index.ts
|
2
|
-
import {
|
3
|
-
function
|
4
|
-
return
|
2
|
+
import { defineMarkSpec, union } from "@prosekit/core";
|
3
|
+
function defineCodeSpec() {
|
4
|
+
return defineMarkSpec({
|
5
5
|
name: "code",
|
6
6
|
parseDOM: [{ tag: "code" }],
|
7
7
|
toDOM() {
|
@@ -9,10 +9,10 @@ function addCodeSpec() {
|
|
9
9
|
}
|
10
10
|
});
|
11
11
|
}
|
12
|
-
function
|
13
|
-
return
|
12
|
+
function defineCode() {
|
13
|
+
return union([defineCodeSpec()]);
|
14
14
|
}
|
15
15
|
export {
|
16
|
-
|
17
|
-
|
16
|
+
defineCode,
|
17
|
+
defineCodeSpec
|
18
18
|
};
|
@@ -1,6 +1,6 @@
|
|
1
|
-
export {
|
2
|
-
export {
|
3
|
-
export {
|
4
|
-
export {
|
5
|
-
export {
|
1
|
+
export { defineHeadingSpec } from './_tsup-dts-rollup';
|
2
|
+
export { defineHeadingKeymap } from './_tsup-dts-rollup';
|
3
|
+
export { defineHeadingInputRule } from './_tsup-dts-rollup';
|
4
|
+
export { defineHeadingCommands } from './_tsup-dts-rollup';
|
5
|
+
export { defineHeading } from './_tsup-dts-rollup';
|
6
6
|
export { HeadingAttrs } from './_tsup-dts-rollup';
|
@@ -1,16 +1,16 @@
|
|
1
1
|
// src/heading/index.ts
|
2
2
|
import {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
defineCommands,
|
4
|
+
defineInputRule,
|
5
|
+
defineKeymap,
|
6
|
+
defineNodeSpec,
|
7
|
+
union,
|
8
8
|
getNodeType,
|
9
9
|
toggleNode
|
10
10
|
} from "@prosekit/core";
|
11
11
|
import { textblockTypeInputRule } from "@prosekit/pm/inputrules";
|
12
|
-
function
|
13
|
-
return
|
12
|
+
function defineHeadingSpec() {
|
13
|
+
return defineNodeSpec({
|
14
14
|
name: "heading",
|
15
15
|
attrs: { level: { default: 1 } },
|
16
16
|
content: "inline*",
|
@@ -29,8 +29,8 @@ function addHeadingSpec() {
|
|
29
29
|
}
|
30
30
|
});
|
31
31
|
}
|
32
|
-
function
|
33
|
-
return
|
32
|
+
function defineHeadingKeymap() {
|
33
|
+
return defineKeymap({
|
34
34
|
"mod-1": toggleNode({ type: "heading", attrs: { level: 1 } }),
|
35
35
|
"mod-2": toggleNode({ type: "heading", attrs: { level: 2 } }),
|
36
36
|
"mod-3": toggleNode({ type: "heading", attrs: { level: 3 } }),
|
@@ -39,8 +39,8 @@ function addHeadingKeymap() {
|
|
39
39
|
"mod-6": toggleNode({ type: "heading", attrs: { level: 6 } })
|
40
40
|
});
|
41
41
|
}
|
42
|
-
function
|
43
|
-
return
|
42
|
+
function defineHeadingInputRule() {
|
43
|
+
return defineInputRule(({ schema }) => {
|
44
44
|
const nodeSpec = getNodeType(schema, "heading");
|
45
45
|
const inputRule = textblockTypeInputRule(
|
46
46
|
/^(#{1,6})\s/,
|
@@ -54,25 +54,25 @@ function addHeadingInputRule() {
|
|
54
54
|
return [inputRule];
|
55
55
|
});
|
56
56
|
}
|
57
|
-
function
|
58
|
-
return
|
57
|
+
function defineHeadingCommands() {
|
58
|
+
return defineCommands({
|
59
59
|
toggleHeading: (attrs) => {
|
60
60
|
return toggleNode({ type: "heading", attrs });
|
61
61
|
}
|
62
62
|
});
|
63
63
|
}
|
64
|
-
function
|
65
|
-
return
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
function defineHeading() {
|
65
|
+
return union([
|
66
|
+
defineHeadingSpec(),
|
67
|
+
defineHeadingInputRule(),
|
68
|
+
defineHeadingKeymap(),
|
69
|
+
defineHeadingCommands()
|
70
70
|
]);
|
71
71
|
}
|
72
72
|
export {
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
73
|
+
defineHeading,
|
74
|
+
defineHeadingCommands,
|
75
|
+
defineHeadingInputRule,
|
76
|
+
defineHeadingKeymap,
|
77
|
+
defineHeadingSpec
|
78
78
|
};
|
@@ -0,0 +1,35 @@
|
|
1
|
+
// src/image/index.ts
|
2
|
+
import { defineNodeSpec, union } from "@prosekit/core";
|
3
|
+
function defineImageSpec() {
|
4
|
+
return defineNodeSpec({
|
5
|
+
name: "image",
|
6
|
+
attrs: {
|
7
|
+
src: { default: null }
|
8
|
+
},
|
9
|
+
group: "block",
|
10
|
+
defining: true,
|
11
|
+
parseDOM: [
|
12
|
+
{
|
13
|
+
tag: "img[src]",
|
14
|
+
getAttrs: (element) => {
|
15
|
+
if (typeof element === "string") {
|
16
|
+
return { src: null };
|
17
|
+
}
|
18
|
+
const src = element.getAttribute("src") || null;
|
19
|
+
return { src };
|
20
|
+
}
|
21
|
+
}
|
22
|
+
],
|
23
|
+
toDOM(node) {
|
24
|
+
const attrs = node.attrs;
|
25
|
+
return ["img", attrs];
|
26
|
+
}
|
27
|
+
});
|
28
|
+
}
|
29
|
+
function defineImage() {
|
30
|
+
return union([defineImageSpec()]);
|
31
|
+
}
|
32
|
+
export {
|
33
|
+
defineImage,
|
34
|
+
defineImageSpec
|
35
|
+
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export {
|
2
|
-
export {
|
3
|
-
export {
|
4
|
-
export {
|
1
|
+
export { defineItalicSpec } from './_tsup-dts-rollup';
|
2
|
+
export { defineItalicCommands } from './_tsup-dts-rollup';
|
3
|
+
export { defineItalicKeymap } from './_tsup-dts-rollup';
|
4
|
+
export { defineItalic } from './_tsup-dts-rollup';
|
@@ -1,13 +1,13 @@
|
|
1
1
|
// src/italic/index.ts
|
2
2
|
import {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
defineCommands,
|
4
|
+
defineKeymap,
|
5
|
+
defineMarkSpec,
|
6
|
+
union,
|
7
7
|
toggleMark
|
8
8
|
} from "@prosekit/core";
|
9
|
-
function
|
10
|
-
return
|
9
|
+
function defineItalicSpec() {
|
10
|
+
return defineMarkSpec({
|
11
11
|
name: "italic",
|
12
12
|
parseDOM: [
|
13
13
|
{ tag: "i" },
|
@@ -23,26 +23,26 @@ function addItalicSpec() {
|
|
23
23
|
}
|
24
24
|
});
|
25
25
|
}
|
26
|
-
function
|
27
|
-
return
|
26
|
+
function defineItalicCommands() {
|
27
|
+
return defineCommands({
|
28
28
|
toggleItalic: () => toggleMark({ type: "italic" })
|
29
29
|
});
|
30
30
|
}
|
31
|
-
function
|
32
|
-
return
|
31
|
+
function defineItalicKeymap() {
|
32
|
+
return defineKeymap({
|
33
33
|
"Mod-i": toggleMark({ type: "italic" })
|
34
34
|
});
|
35
35
|
}
|
36
|
-
function
|
37
|
-
return
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
function defineItalic() {
|
37
|
+
return union([
|
38
|
+
defineItalicSpec(),
|
39
|
+
defineItalicCommands(),
|
40
|
+
defineItalicKeymap()
|
41
41
|
]);
|
42
42
|
}
|
43
43
|
export {
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
defineItalic,
|
45
|
+
defineItalicCommands,
|
46
|
+
defineItalicKeymap,
|
47
|
+
defineItalicSpec
|
48
48
|
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export {
|
2
|
-
export {
|
3
|
-
export {
|
1
|
+
export { defineLinkSpec } from './_tsup-dts-rollup';
|
2
|
+
export { defineLinkCommands } from './_tsup-dts-rollup';
|
3
|
+
export { defineItalic_alias_1 as defineItalic } from './_tsup-dts-rollup';
|
4
4
|
export { LinkAttrs } from './_tsup-dts-rollup';
|
@@ -1,13 +1,13 @@
|
|
1
1
|
// src/link/index.ts
|
2
2
|
import {
|
3
|
-
|
3
|
+
defineCommands,
|
4
4
|
addMark,
|
5
|
-
|
6
|
-
|
5
|
+
defineMarkSpec,
|
6
|
+
union,
|
7
7
|
toggleMark
|
8
8
|
} from "@prosekit/core";
|
9
|
-
function
|
10
|
-
return
|
9
|
+
function defineLinkSpec() {
|
10
|
+
return defineMarkSpec({
|
11
11
|
name: "link",
|
12
12
|
parseDOM: [
|
13
13
|
{
|
@@ -28,17 +28,17 @@ function addLinkSpec() {
|
|
28
28
|
}
|
29
29
|
});
|
30
30
|
}
|
31
|
-
function
|
32
|
-
return
|
31
|
+
function defineLinkCommands() {
|
32
|
+
return defineCommands({
|
33
33
|
addLink: (attrs) => addMark({ type: "link", attrs }),
|
34
34
|
toggleLink: (attrs) => toggleMark({ type: "link", attrs })
|
35
35
|
});
|
36
36
|
}
|
37
|
-
function
|
38
|
-
return
|
37
|
+
function defineItalic() {
|
38
|
+
return union([defineLinkSpec(), defineLinkCommands()]);
|
39
39
|
}
|
40
40
|
export {
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
defineItalic,
|
42
|
+
defineLinkCommands,
|
43
|
+
defineLinkSpec
|
44
44
|
};
|
@@ -1,5 +1,5 @@
|
|
1
|
-
export {
|
2
|
-
export {
|
3
|
-
export {
|
4
|
-
export {
|
5
|
-
export {
|
1
|
+
export { defineListSpec } from './_tsup-dts-rollup';
|
2
|
+
export { defineListPlugins } from './_tsup-dts-rollup';
|
3
|
+
export { defineListKeymap } from './_tsup-dts-rollup';
|
4
|
+
export { defineListInputRules } from './_tsup-dts-rollup';
|
5
|
+
export { defineList } from './_tsup-dts-rollup';
|
@@ -1,10 +1,10 @@
|
|
1
1
|
// src/list/index.ts
|
2
2
|
import {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
defineInputRule,
|
4
|
+
defineKeymap,
|
5
|
+
defineNodeSpec,
|
6
|
+
definePlugin,
|
7
|
+
union
|
8
8
|
} from "@prosekit/core";
|
9
9
|
import {
|
10
10
|
createListPlugins,
|
@@ -12,30 +12,30 @@ import {
|
|
12
12
|
listInputRules,
|
13
13
|
listKeymap
|
14
14
|
} from "prosemirror-flat-list";
|
15
|
-
function
|
16
|
-
return
|
15
|
+
function defineListSpec() {
|
16
|
+
return defineNodeSpec({ ...createListSpec(), name: "list" });
|
17
17
|
}
|
18
|
-
function
|
19
|
-
return
|
18
|
+
function defineListPlugins() {
|
19
|
+
return definePlugin(({ schema }) => createListPlugins({ schema }));
|
20
20
|
}
|
21
|
-
function
|
22
|
-
return
|
21
|
+
function defineListKeymap() {
|
22
|
+
return defineKeymap(listKeymap);
|
23
23
|
}
|
24
|
-
function
|
25
|
-
return
|
24
|
+
function defineListInputRules() {
|
25
|
+
return defineInputRule(() => listInputRules);
|
26
26
|
}
|
27
|
-
function
|
28
|
-
return
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
function defineList() {
|
28
|
+
return union([
|
29
|
+
defineListSpec(),
|
30
|
+
defineListPlugins(),
|
31
|
+
defineListKeymap(),
|
32
|
+
defineListInputRules()
|
33
33
|
]);
|
34
34
|
}
|
35
35
|
export {
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
defineList,
|
37
|
+
defineListInputRules,
|
38
|
+
defineListKeymap,
|
39
|
+
defineListPlugins,
|
40
|
+
defineListSpec
|
41
41
|
};
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export {
|
2
|
-
export {
|
1
|
+
export { defineMentionSpec } from './_tsup-dts-rollup';
|
2
|
+
export { defineMention } from './_tsup-dts-rollup';
|
3
3
|
export { MentionAttrs } from './_tsup-dts-rollup';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// src/mention/index.ts
|
2
|
-
import {
|
3
|
-
function
|
4
|
-
return
|
2
|
+
import { defineNodeSpec, union } from "@prosekit/core";
|
3
|
+
function defineMentionSpec() {
|
4
|
+
return defineNodeSpec({
|
5
5
|
name: "mention",
|
6
6
|
atom: true,
|
7
7
|
group: "inline",
|
@@ -34,10 +34,10 @@ function addMentionSpec() {
|
|
34
34
|
}
|
35
35
|
});
|
36
36
|
}
|
37
|
-
function
|
38
|
-
return
|
37
|
+
function defineMention() {
|
38
|
+
return union([defineMentionSpec()]);
|
39
39
|
}
|
40
40
|
export {
|
41
|
-
|
42
|
-
|
41
|
+
defineMention,
|
42
|
+
defineMentionSpec
|
43
43
|
};
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export {
|
1
|
+
export { definePlaceholder } from './_tsup-dts-rollup';
|
2
2
|
export { PlaceholderOptions } from './_tsup-dts-rollup';
|
@@ -1,10 +1,10 @@
|
|
1
1
|
// src/placeholder/index.ts
|
2
|
-
import {
|
2
|
+
import { definePlugin } from "@prosekit/core";
|
3
3
|
import "@prosekit/pm/model";
|
4
4
|
import { Plugin, PluginKey } from "@prosekit/pm/state";
|
5
5
|
import { Decoration, DecorationSet } from "@prosekit/pm/view";
|
6
|
-
function
|
7
|
-
return
|
6
|
+
function definePlaceholder(options) {
|
7
|
+
return definePlugin(createPlaceholderPlugin(options));
|
8
8
|
}
|
9
9
|
function createPlaceholderPlugin(options) {
|
10
10
|
return new Plugin({
|
@@ -44,5 +44,5 @@ function createPlaceholderDecoration(state, placeholderText) {
|
|
44
44
|
});
|
45
45
|
}
|
46
46
|
export {
|
47
|
-
|
47
|
+
definePlaceholder
|
48
48
|
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
// src/suggestion/index.ts
|
2
|
-
import {
|
2
|
+
import { definePlugin } from "@prosekit/core";
|
3
3
|
|
4
4
|
// src/suggestion/plugin.ts
|
5
5
|
import { ProseKitError } from "@prosekit/core";
|
@@ -131,7 +131,7 @@ function calcPluginState(state, rules) {
|
|
131
131
|
for (const rule of rules) {
|
132
132
|
const match = textBefore.match(rule.match);
|
133
133
|
const matchAfter2 = rule.matchAfter ? textAfter.match(rule.matchAfter) : null;
|
134
|
-
if (match
|
134
|
+
if ((match == null ? void 0 : match.index) != null) {
|
135
135
|
const from = $anchor.pos - textBefore.length + match.index;
|
136
136
|
const to = $anchor.pos + (matchAfter2 ? matchAfter2[0].length : 0);
|
137
137
|
return {
|
@@ -152,10 +152,10 @@ function calcPluginState(state, rules) {
|
|
152
152
|
var MAX_MATCH = 200;
|
153
153
|
|
154
154
|
// src/suggestion/index.ts
|
155
|
-
function
|
155
|
+
function defineSuggestion(options) {
|
156
156
|
const plugin = createPredictionPlugin(options);
|
157
|
-
return
|
157
|
+
return definePlugin(plugin);
|
158
158
|
}
|
159
159
|
export {
|
160
|
-
|
160
|
+
defineSuggestion
|
161
161
|
};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/extensions",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.
|
4
|
+
"version": "0.0.14",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -60,6 +60,11 @@
|
|
60
60
|
"import": "./dist/prosekit-extensions-heading.js",
|
61
61
|
"default": "./dist/prosekit-extensions-heading.js"
|
62
62
|
},
|
63
|
+
"./image": {
|
64
|
+
"types": "./dist/prosekit-extensions-image.d.ts",
|
65
|
+
"import": "./dist/prosekit-extensions-image.js",
|
66
|
+
"default": "./dist/prosekit-extensions-image.js"
|
67
|
+
},
|
63
68
|
"./italic": {
|
64
69
|
"types": "./dist/prosekit-extensions-italic.d.ts",
|
65
70
|
"import": "./dist/prosekit-extensions-italic.js",
|
@@ -101,17 +106,17 @@
|
|
101
106
|
"dist"
|
102
107
|
],
|
103
108
|
"dependencies": {
|
104
|
-
"@prosekit/core": "^0.0.
|
109
|
+
"@prosekit/core": "^0.0.12",
|
105
110
|
"@prosekit/pm": "^0.0.6",
|
106
|
-
"highlight.js": "^11.
|
107
|
-
"prosemirror-flat-list": "^0.4.
|
111
|
+
"highlight.js": "^11.9.0",
|
112
|
+
"prosemirror-flat-list": "^0.4.3",
|
108
113
|
"prosemirror-highlightjs": "^0.9.1"
|
109
114
|
},
|
110
115
|
"devDependencies": {
|
111
116
|
"@prosekit/dev": "*",
|
112
117
|
"tsup": "^7.2.0",
|
113
118
|
"typescript": "^5.2.2",
|
114
|
-
"vitest": "^0.34.
|
119
|
+
"vitest": "^0.34.6"
|
115
120
|
},
|
116
121
|
"scripts": {
|
117
122
|
"build:tsup": "tsup",
|
@@ -141,6 +146,9 @@
|
|
141
146
|
"heading": [
|
142
147
|
"./dist/prosekit-extensions-heading.d.ts"
|
143
148
|
],
|
149
|
+
"image": [
|
150
|
+
"./dist/prosekit-extensions-image.d.ts"
|
151
|
+
],
|
144
152
|
"italic": [
|
145
153
|
"./dist/prosekit-extensions-italic.d.ts"
|
146
154
|
],
|