@prosekit/extensions 0.0.13 → 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 +82 -82
- 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 +2 -2
- package/dist/prosekit-extensions-image.js +7 -7
- 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 +3 -3
@@ -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,62 +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< {
|
107
150
|
NODES: "image";
|
108
151
|
}>;
|
109
152
|
|
110
|
-
export declare function
|
153
|
+
export declare function defineImageSpec(): Extension< {
|
111
154
|
NODES: "image";
|
112
155
|
}>;
|
113
156
|
|
114
157
|
/** @public */
|
115
|
-
export declare function
|
158
|
+
export declare function defineItalic(): Extension< {
|
116
159
|
MARKS: "italic";
|
117
160
|
COMMAND_ARGS: {
|
118
161
|
toggleItalic: [];
|
@@ -120,7 +163,7 @@ toggleItalic: [];
|
|
120
163
|
}>;
|
121
164
|
|
122
165
|
/** @public */
|
123
|
-
export declare function
|
166
|
+
export declare function defineItalic_alias_1(): Extension< {
|
124
167
|
MARKS: "link";
|
125
168
|
COMMAND_ARGS: {
|
126
169
|
addLink: [attrs: LinkAttrs];
|
@@ -128,55 +171,55 @@ toggleLink: [attrs: LinkAttrs];
|
|
128
171
|
};
|
129
172
|
}>;
|
130
173
|
|
131
|
-
export declare function
|
174
|
+
export declare function defineItalicCommands(): Extension< {
|
132
175
|
COMMAND_ARGS: {
|
133
176
|
toggleItalic: [];
|
134
177
|
};
|
135
178
|
}>;
|
136
179
|
|
137
|
-
export declare function
|
180
|
+
export declare function defineItalicKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
138
181
|
|
139
|
-
export declare function
|
182
|
+
export declare function defineItalicSpec(): Extension< {
|
140
183
|
MARKS: "italic";
|
141
184
|
}>;
|
142
185
|
|
143
|
-
export declare function
|
186
|
+
export declare function defineLinkCommands(): Extension< {
|
144
187
|
COMMAND_ARGS: {
|
145
188
|
addLink: [attrs: LinkAttrs];
|
146
189
|
toggleLink: [attrs: LinkAttrs];
|
147
190
|
};
|
148
191
|
}>;
|
149
192
|
|
150
|
-
export declare function
|
193
|
+
export declare function defineLinkSpec(): Extension< {
|
151
194
|
MARKS: "link";
|
152
195
|
}>;
|
153
196
|
|
154
197
|
/** @public */
|
155
|
-
export declare function
|
198
|
+
export declare function defineList(): Extension< {
|
156
199
|
NODES: "list";
|
157
200
|
}>;
|
158
201
|
|
159
|
-
export declare function
|
202
|
+
export declare function defineListInputRules(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
160
203
|
|
161
|
-
export declare function
|
204
|
+
export declare function defineListKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
162
205
|
|
163
|
-
export declare function
|
206
|
+
export declare function defineListPlugins(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
164
207
|
|
165
|
-
export declare function
|
208
|
+
export declare function defineListSpec(): Extension< {
|
166
209
|
NODES: "list";
|
167
210
|
}>;
|
168
211
|
|
169
212
|
/**
|
170
213
|
* @public
|
171
214
|
*/
|
172
|
-
export declare function
|
215
|
+
export declare function defineMention(): Extension< {
|
173
216
|
NODES: "mention";
|
174
217
|
}>;
|
175
218
|
|
176
219
|
/**
|
177
220
|
* @public
|
178
221
|
*/
|
179
|
-
export declare function
|
222
|
+
export declare function defineMentionSpec(): Extension< {
|
180
223
|
NODES: "mention";
|
181
224
|
}>;
|
182
225
|
|
@@ -184,52 +227,9 @@ NODES: "mention";
|
|
184
227
|
* Add a placeholder text to the editor when the current block or document is
|
185
228
|
* empty.
|
186
229
|
*/
|
187
|
-
export declare function
|
188
|
-
|
189
|
-
export declare function addSuggestion(options: SuggestionOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
230
|
+
export declare function definePlaceholder(options: PlaceholderOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
190
231
|
|
191
|
-
declare
|
192
|
-
readonly regex: RegExp;
|
193
|
-
readonly onMatch: MatchHandler;
|
194
|
-
readonly onLeave?: VoidFunction;
|
195
|
-
readonly canMatch: (options: {
|
196
|
-
state: EditorState;
|
197
|
-
}) => boolean;
|
198
|
-
constructor(options: {
|
199
|
-
regex: RegExp;
|
200
|
-
onEnter: MatchHandler;
|
201
|
-
onLeave?: VoidFunction;
|
202
|
-
canMatch?: (options: {
|
203
|
-
state: EditorState;
|
204
|
-
}) => boolean;
|
205
|
-
});
|
206
|
-
}
|
207
|
-
export { AutocompleteRule }
|
208
|
-
export { AutocompleteRule as AutocompleteRule_alias_1 }
|
209
|
-
|
210
|
-
declare interface CodeBlockAttrs {
|
211
|
-
language?: string;
|
212
|
-
}
|
213
|
-
export { CodeBlockAttrs }
|
214
|
-
export { CodeBlockAttrs as CodeBlockAttrs_alias_1 }
|
215
|
-
|
216
|
-
export declare function createAutocompletePlugin({ getRules, }: {
|
217
|
-
getRules: () => AutocompleteRule[];
|
218
|
-
}): Plugin_2;
|
219
|
-
|
220
|
-
export declare function createPredictionPlugin(options: SuggestionOptions): Plugin_2;
|
221
|
-
|
222
|
-
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
223
|
-
|
224
|
-
export declare const default_alias_1: UserProjectConfigExport;
|
225
|
-
|
226
|
-
export declare function defaultCanMatch({ state }: {
|
227
|
-
state: EditorState;
|
228
|
-
}): boolean;
|
229
|
-
|
230
|
-
export declare function defaultIsValid({ state }: {
|
231
|
-
state: EditorState;
|
232
|
-
}): boolean;
|
232
|
+
export declare function defineSuggestion(options: SuggestionOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
233
233
|
|
234
234
|
export declare function getPluginState(state: EditorState): PredictionPluginState | undefined;
|
235
235
|
|
@@ -296,7 +296,7 @@ export declare interface PlaceholderOptions {
|
|
296
296
|
|
297
297
|
export declare const pluginKey: PluginKey<PredictionPluginState>;
|
298
298
|
|
299
|
-
export declare
|
299
|
+
export declare interface PredictionPluginState {
|
300
300
|
active: boolean;
|
301
301
|
ignore: number | null;
|
302
302
|
matching: {
|
@@ -305,7 +305,7 @@ export declare type PredictionPluginState = {
|
|
305
305
|
to: number;
|
306
306
|
match: RegExpExecArray;
|
307
307
|
} | null;
|
308
|
-
}
|
308
|
+
}
|
309
309
|
|
310
310
|
declare interface PredictionRule {
|
311
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
|
};
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export {
|
2
|
-
export {
|
1
|
+
export { defineImageSpec } from './_tsup-dts-rollup';
|
2
|
+
export { defineImage } from './_tsup-dts-rollup';
|
3
3
|
export { ImageAttrs } from './_tsup-dts-rollup';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// src/image/index.ts
|
2
|
-
import {
|
3
|
-
function
|
4
|
-
return
|
2
|
+
import { defineNodeSpec, union } from "@prosekit/core";
|
3
|
+
function defineImageSpec() {
|
4
|
+
return defineNodeSpec({
|
5
5
|
name: "image",
|
6
6
|
attrs: {
|
7
7
|
src: { default: null }
|
@@ -26,10 +26,10 @@ function addImageSpec() {
|
|
26
26
|
}
|
27
27
|
});
|
28
28
|
}
|
29
|
-
function
|
30
|
-
return
|
29
|
+
function defineImage() {
|
30
|
+
return union([defineImageSpec()]);
|
31
31
|
}
|
32
32
|
export {
|
33
|
-
|
34
|
-
|
33
|
+
defineImage,
|
34
|
+
defineImageSpec
|
35
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",
|
@@ -106,10 +106,10 @@
|
|
106
106
|
"dist"
|
107
107
|
],
|
108
108
|
"dependencies": {
|
109
|
-
"@prosekit/core": "^0.0.
|
109
|
+
"@prosekit/core": "^0.0.12",
|
110
110
|
"@prosekit/pm": "^0.0.6",
|
111
111
|
"highlight.js": "^11.9.0",
|
112
|
-
"prosemirror-flat-list": "^0.4.
|
112
|
+
"prosemirror-flat-list": "^0.4.3",
|
113
113
|
"prosemirror-highlightjs": "^0.9.1"
|
114
114
|
},
|
115
115
|
"devDependencies": {
|