@prosekit/extensions 0.0.18 → 0.0.20

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.
@@ -1,12 +1,18 @@
1
1
  import { CommandArgs } from '@prosekit/core';
2
+ import { DedentListOptions } from 'prosemirror-flat-list';
2
3
  import { EditorState } from '@prosekit/pm/state';
3
4
  import { Extension } from '@prosekit/core';
4
5
  import { ExtensionTyping } from '@prosekit/core';
5
6
  import type { HLJSApi } from 'highlight.js';
7
+ import { IndentListOptions } from 'prosemirror-flat-list';
8
+ import { ListAttributes } from 'prosemirror-flat-list';
9
+ import { NodeRange } from 'prosemirror-model';
6
10
  import { Options } from 'tsup';
7
11
  import { Plugin as Plugin_2 } from '@prosekit/pm/state';
8
12
  import { PluginKey } from '@prosekit/pm/state';
13
+ import { ToggleCollapsedOptions } from 'prosemirror-flat-list';
9
14
  import { Transaction } from '@prosekit/pm/state';
15
+ import { UnwrapListOptions } from 'prosemirror-flat-list';
10
16
  import { UserProjectConfigExport } from 'vitest/dist/config.js';
11
17
 
12
18
  declare class AutocompleteRule {
@@ -54,7 +60,9 @@ export declare function defaultIsValid({ state }: {
54
60
 
55
61
  export declare function defineAutocomplete(rule: AutocompleteRule): Extension;
56
62
 
57
- /** @public */
63
+ /**
64
+ * @public
65
+ */
58
66
  export declare function defineBlockquote(): Extension< {
59
67
  NODES: "blockquote";
60
68
  }>;
@@ -63,7 +71,9 @@ export declare function defineBlockquoteSpec(): Extension< {
63
71
  NODES: "blockquote";
64
72
  }>;
65
73
 
66
- /** @public */
74
+ /**
75
+ * @public
76
+ */
67
77
  export declare function defineBold(): Extension< {
68
78
  MARKS: "bold";
69
79
  COMMAND_ARGS: {
@@ -88,9 +98,14 @@ MARKS: "bold";
88
98
  */
89
99
  export declare function defineCode(): Extension< {
90
100
  MARKS: "code";
101
+ COMMAND_ARGS: {
102
+ toggleCode: [];
103
+ };
91
104
  }>;
92
105
 
93
- /** @public */
106
+ /**
107
+ * @public
108
+ */
94
109
  export declare function defineCodeBlock(options?: {
95
110
  hljs?: HLJSApi;
96
111
  }): Extension< {
@@ -116,6 +131,12 @@ export declare function defineCodeBlockSpec(): Extension< {
116
131
  NODES: "codeBlock";
117
132
  }>;
118
133
 
134
+ export declare function defineCodeCommands(): Extension< {
135
+ COMMAND_ARGS: {
136
+ toggleCode: [];
137
+ };
138
+ }>;
139
+
119
140
  /**
120
141
  * @public
121
142
  */
@@ -123,7 +144,9 @@ export declare function defineCodeSpec(): Extension< {
123
144
  MARKS: "code";
124
145
  }>;
125
146
 
126
- /** @public */
147
+ /**
148
+ * @public
149
+ */
127
150
  export declare function defineHeading(): Extension< {
128
151
  NODES: "heading";
129
152
  COMMAND_ARGS: {
@@ -149,7 +172,9 @@ export declare function defineHeadingSpec(): Extension< {
149
172
  NODES: "heading";
150
173
  }>;
151
174
 
152
- /** @public */
175
+ /**
176
+ * @public
177
+ */
153
178
  export declare function defineImage(): Extension< {
154
179
  NODES: "image";
155
180
  COMMAND_ARGS: {
@@ -167,7 +192,9 @@ export declare function defineImageSpec(): Extension< {
167
192
  NODES: "image";
168
193
  }>;
169
194
 
170
- /** @public */
195
+ /**
196
+ * @public
197
+ */
171
198
  export declare function defineItalic(): Extension< {
172
199
  MARKS: "italic";
173
200
  COMMAND_ARGS: {
@@ -175,15 +202,6 @@ toggleItalic: [];
175
202
  };
176
203
  }>;
177
204
 
178
- /** @public */
179
- export declare function defineItalic_alias_1(): Extension< {
180
- MARKS: "link";
181
- COMMAND_ARGS: {
182
- addLink: [attrs: LinkAttrs];
183
- toggleLink: [attrs: LinkAttrs];
184
- };
185
- }>;
186
-
187
205
  export declare function defineItalicCommands(): Extension< {
188
206
  COMMAND_ARGS: {
189
207
  toggleItalic: [];
@@ -192,10 +210,23 @@ toggleItalic: [];
192
210
 
193
211
  export declare function defineItalicKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
194
212
 
213
+ export declare function defineItalicKeymap_alias_1(): Extension<ExtensionTyping<string, string, CommandArgs>>;
214
+
195
215
  export declare function defineItalicSpec(): Extension< {
196
216
  MARKS: "italic";
197
217
  }>;
198
218
 
219
+ /**
220
+ * @public
221
+ */
222
+ export declare function defineLink(): Extension< {
223
+ MARKS: "link";
224
+ COMMAND_ARGS: {
225
+ addLink: [attrs: LinkAttrs];
226
+ toggleLink: [attrs: LinkAttrs];
227
+ };
228
+ }>;
229
+
199
230
  export declare function defineLinkCommands(): Extension< {
200
231
  COMMAND_ARGS: {
201
232
  addLink: [attrs: LinkAttrs];
@@ -207,13 +238,43 @@ export declare function defineLinkSpec(): Extension< {
207
238
  MARKS: "link";
208
239
  }>;
209
240
 
210
- /** @public */
241
+ /**
242
+ * @public
243
+ */
211
244
  export declare function defineList(): Extension< {
212
245
  NODES: "list";
246
+ COMMAND_ARGS: {
247
+ dedentList: [options?: DedentListOptions | undefined];
248
+ indentList: [options?: IndentListOptions | undefined];
249
+ moveList: [direction: "up" | "down"];
250
+ splitList: [];
251
+ toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
252
+ toggleList: [attrs: ListAttributes];
253
+ unwrapList: [options?: UnwrapListOptions | undefined];
254
+ wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
255
+ };
256
+ }>;
257
+
258
+ export declare function defineListCommands(): Extension< {
259
+ COMMAND_ARGS: {
260
+ dedentList: [options?: DedentListOptions | undefined];
261
+ indentList: [options?: IndentListOptions | undefined];
262
+ moveList: [direction: "up" | "down"];
263
+ splitList: [];
264
+ toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
265
+ toggleList: [attrs: ListAttributes];
266
+ unwrapList: [options?: UnwrapListOptions | undefined];
267
+ wrapInList: [getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)];
268
+ };
213
269
  }>;
214
270
 
215
271
  export declare function defineListInputRules(): Extension<ExtensionTyping<string, string, CommandArgs>>;
216
272
 
273
+ /**
274
+ * Returns a extension that adds key bindings for list.
275
+ *
276
+ * @public
277
+ */
217
278
  export declare function defineListKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
218
279
 
219
280
  export declare function defineListPlugins(): Extension<ExtensionTyping<string, string, CommandArgs>>;
@@ -242,8 +303,52 @@ NODES: "mention";
242
303
  */
243
304
  export declare function definePlaceholder(options: PlaceholderOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
244
305
 
306
+ /**
307
+ * @public
308
+ */
309
+ export declare function defineStrike(): Extension< {
310
+ MARKS: "strike";
311
+ COMMAND_ARGS: {
312
+ toggleStrike: [];
313
+ };
314
+ }>;
315
+
316
+ export declare function defineStrikeCommands(): Extension< {
317
+ COMMAND_ARGS: {
318
+ toggleStrike: [];
319
+ };
320
+ }>;
321
+
322
+ export declare function defineStrikeKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
323
+
324
+ export declare function defineStrikeSpec(): Extension< {
325
+ MARKS: "strike";
326
+ }>;
327
+
245
328
  export declare function defineSuggestion(options: SuggestionOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
246
329
 
330
+ /**
331
+ * @public
332
+ */
333
+ export declare function defineUnderline(): Extension< {
334
+ MARKS: "underline";
335
+ COMMAND_ARGS: {
336
+ toggleUnderline: [];
337
+ };
338
+ }>;
339
+
340
+ export declare function defineUnderlineCommands(): Extension< {
341
+ COMMAND_ARGS: {
342
+ toggleUnderline: [];
343
+ };
344
+ }>;
345
+
346
+ export declare function defineUnderlineKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
347
+
348
+ export declare function defineUnderlineSpec(): Extension< {
349
+ MARKS: "underline";
350
+ }>;
351
+
247
352
  export declare function getPluginState(state: EditorState): PredictionPluginState | undefined;
248
353
 
249
354
  export declare function getTrMeta(tr: Transaction): PredictionPluginState;
@@ -256,7 +361,9 @@ export declare interface ImageAttrs {
256
361
  src?: string | null;
257
362
  }
258
363
 
259
- /** @public */
364
+ /**
365
+ * @public
366
+ */
260
367
  export declare interface LinkAttrs {
261
368
  href: string;
262
369
  }
@@ -1,2 +1,4 @@
1
1
  export { defineCodeSpec } from './_tsup-dts-rollup';
2
+ export { defineCodeCommands } from './_tsup-dts-rollup';
3
+ export { defineItalicKeymap } from './_tsup-dts-rollup';
2
4
  export { defineCode } from './_tsup-dts-rollup';
@@ -1,5 +1,11 @@
1
1
  // src/code/index.ts
2
- import { defineMarkSpec, union } from "@prosekit/core";
2
+ import {
3
+ defineCommands,
4
+ defineKeymap,
5
+ defineMarkSpec,
6
+ toggleMark,
7
+ union
8
+ } from "@prosekit/core";
3
9
  function defineCodeSpec() {
4
10
  return defineMarkSpec({
5
11
  name: "code",
@@ -9,10 +15,22 @@ function defineCodeSpec() {
9
15
  }
10
16
  });
11
17
  }
18
+ function defineCodeCommands() {
19
+ return defineCommands({
20
+ toggleCode: () => toggleMark({ type: "code" })
21
+ });
22
+ }
23
+ function defineItalicKeymap() {
24
+ return defineKeymap({
25
+ "Mod-e": toggleMark({ type: "code" })
26
+ });
27
+ }
12
28
  function defineCode() {
13
- return union([defineCodeSpec()]);
29
+ return union([defineCodeSpec(), defineCodeCommands(), defineItalicKeymap()]);
14
30
  }
15
31
  export {
16
32
  defineCode,
17
- defineCodeSpec
33
+ defineCodeCommands,
34
+ defineCodeSpec,
35
+ defineItalicKeymap
18
36
  };
@@ -1,4 +1,4 @@
1
1
  export { defineItalicSpec } from './_tsup-dts-rollup';
2
2
  export { defineItalicCommands } from './_tsup-dts-rollup';
3
- export { defineItalicKeymap } from './_tsup-dts-rollup';
3
+ export { defineItalicKeymap_alias_1 as defineItalicKeymap } from './_tsup-dts-rollup';
4
4
  export { defineItalic } from './_tsup-dts-rollup';
@@ -1,4 +1,4 @@
1
1
  export { defineLinkSpec } from './_tsup-dts-rollup';
2
2
  export { defineLinkCommands } from './_tsup-dts-rollup';
3
- export { defineItalic_alias_1 as defineItalic } from './_tsup-dts-rollup';
3
+ export { defineLink } from './_tsup-dts-rollup';
4
4
  export { LinkAttrs } from './_tsup-dts-rollup';
@@ -34,11 +34,11 @@ function defineLinkCommands() {
34
34
  toggleLink: (attrs) => toggleMark({ type: "link", attrs })
35
35
  });
36
36
  }
37
- function defineItalic() {
37
+ function defineLink() {
38
38
  return union([defineLinkSpec(), defineLinkCommands()]);
39
39
  }
40
40
  export {
41
- defineItalic,
41
+ defineLink,
42
42
  defineLinkCommands,
43
43
  defineLinkSpec
44
44
  };
@@ -2,4 +2,5 @@ export { defineListSpec } from './_tsup-dts-rollup';
2
2
  export { defineListPlugins } from './_tsup-dts-rollup';
3
3
  export { defineListKeymap } from './_tsup-dts-rollup';
4
4
  export { defineListInputRules } from './_tsup-dts-rollup';
5
+ export { defineListCommands } from './_tsup-dts-rollup';
5
6
  export { defineList } from './_tsup-dts-rollup';
@@ -1,14 +1,25 @@
1
1
  // src/list/index.ts
2
2
  import {
3
+ Priority,
4
+ defineCommands,
3
5
  defineInputRule,
4
6
  defineKeymap,
5
7
  defineNodeSpec,
6
8
  definePlugin,
7
- union
9
+ union,
10
+ withPriority
8
11
  } from "@prosekit/core";
9
12
  import {
13
+ createDedentListCommand,
14
+ createIndentListCommand,
10
15
  createListPlugins,
11
16
  createListSpec,
17
+ createMoveListCommand,
18
+ createSplitListCommand,
19
+ createToggleCollapsedCommand,
20
+ createToggleListCommand,
21
+ createUnwrapListCommand,
22
+ createWrapInListCommand,
12
23
  listInputRules,
13
24
  listKeymap
14
25
  } from "prosemirror-flat-list";
@@ -24,16 +35,31 @@ function defineListKeymap() {
24
35
  function defineListInputRules() {
25
36
  return defineInputRule(() => listInputRules);
26
37
  }
38
+ function defineListCommands() {
39
+ return defineCommands({
40
+ dedentList: createDedentListCommand,
41
+ indentList: createIndentListCommand,
42
+ moveList: createMoveListCommand,
43
+ splitList: createSplitListCommand,
44
+ toggleCollapsed: createToggleCollapsedCommand,
45
+ toggleList: createToggleListCommand,
46
+ unwrapList: createUnwrapListCommand,
47
+ wrapInList: createWrapInListCommand
48
+ });
49
+ }
27
50
  function defineList() {
28
51
  return union([
29
52
  defineListSpec(),
30
53
  defineListPlugins(),
31
- defineListKeymap(),
32
- defineListInputRules()
54
+ // Use a high priority to override the default key bindings.
55
+ withPriority(defineListKeymap(), Priority.high),
56
+ defineListInputRules(),
57
+ defineListCommands()
33
58
  ]);
34
59
  }
35
60
  export {
36
61
  defineList,
62
+ defineListCommands,
37
63
  defineListInputRules,
38
64
  defineListKeymap,
39
65
  defineListPlugins,
@@ -0,0 +1,4 @@
1
+ export { defineStrikeSpec } from './_tsup-dts-rollup';
2
+ export { defineStrikeCommands } from './_tsup-dts-rollup';
3
+ export { defineStrikeKeymap } from './_tsup-dts-rollup';
4
+ export { defineStrike } from './_tsup-dts-rollup';
@@ -0,0 +1,47 @@
1
+ // src/strike/index.ts
2
+ import {
3
+ defineCommands,
4
+ defineKeymap,
5
+ defineMarkSpec,
6
+ union,
7
+ toggleMark
8
+ } from "@prosekit/core";
9
+ function defineStrikeSpec() {
10
+ return defineMarkSpec({
11
+ name: "strike",
12
+ parseDOM: [
13
+ { tag: "s" },
14
+ { tag: "strike" },
15
+ { tag: "del" },
16
+ { style: "text-decoration=line-through" },
17
+ { style: "text-decoration-line=line-through" }
18
+ ],
19
+ toDOM() {
20
+ return ["s", 0];
21
+ }
22
+ });
23
+ }
24
+ function defineStrikeCommands() {
25
+ return defineCommands({
26
+ toggleStrike: () => toggleMark({ type: "strike" })
27
+ });
28
+ }
29
+ function defineStrikeKeymap() {
30
+ return defineKeymap({
31
+ "Mod-shift-s": toggleMark({ type: "strike" }),
32
+ "Mod-shift-x": toggleMark({ type: "strike" })
33
+ });
34
+ }
35
+ function defineStrike() {
36
+ return union([
37
+ defineStrikeSpec(),
38
+ defineStrikeCommands(),
39
+ defineStrikeKeymap()
40
+ ]);
41
+ }
42
+ export {
43
+ defineStrike,
44
+ defineStrikeCommands,
45
+ defineStrikeKeymap,
46
+ defineStrikeSpec
47
+ };
@@ -0,0 +1,4 @@
1
+ export { defineUnderlineSpec } from './_tsup-dts-rollup';
2
+ export { defineUnderlineCommands } from './_tsup-dts-rollup';
3
+ export { defineUnderlineKeymap } from './_tsup-dts-rollup';
4
+ export { defineUnderline } from './_tsup-dts-rollup';
@@ -0,0 +1,45 @@
1
+ // src/underline/index.ts
2
+ import {
3
+ defineCommands,
4
+ defineKeymap,
5
+ defineMarkSpec,
6
+ union,
7
+ toggleMark
8
+ } from "@prosekit/core";
9
+ function defineUnderlineSpec() {
10
+ return defineMarkSpec({
11
+ name: "underline",
12
+ parseDOM: [
13
+ { tag: "u" },
14
+ { tag: "underline" },
15
+ { style: "text-decoration=underline" },
16
+ { style: "text-decoration-line=underline" }
17
+ ],
18
+ toDOM() {
19
+ return ["u", 0];
20
+ }
21
+ });
22
+ }
23
+ function defineUnderlineCommands() {
24
+ return defineCommands({
25
+ toggleUnderline: () => toggleMark({ type: "underline" })
26
+ });
27
+ }
28
+ function defineUnderlineKeymap() {
29
+ return defineKeymap({
30
+ "Mod-u": toggleMark({ type: "underline" })
31
+ });
32
+ }
33
+ function defineUnderline() {
34
+ return union([
35
+ defineUnderlineSpec(),
36
+ defineUnderlineCommands(),
37
+ defineUnderlineKeymap()
38
+ ]);
39
+ }
40
+ export {
41
+ defineUnderline,
42
+ defineUnderlineCommands,
43
+ defineUnderlineKeymap,
44
+ defineUnderlineSpec
45
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/extensions",
3
3
  "type": "module",
4
- "version": "0.0.18",
4
+ "version": "0.0.20",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -96,18 +96,28 @@
96
96
  "./placeholder/style.css": {
97
97
  "default": "./dist/placeholder/style.css"
98
98
  },
99
+ "./strike": {
100
+ "types": "./dist/prosekit-extensions-strike.d.ts",
101
+ "import": "./dist/prosekit-extensions-strike.js",
102
+ "default": "./dist/prosekit-extensions-strike.js"
103
+ },
99
104
  "./suggestion": {
100
105
  "types": "./dist/prosekit-extensions-suggestion.d.ts",
101
106
  "import": "./dist/prosekit-extensions-suggestion.js",
102
107
  "default": "./dist/prosekit-extensions-suggestion.js"
108
+ },
109
+ "./underline": {
110
+ "types": "./dist/prosekit-extensions-underline.d.ts",
111
+ "import": "./dist/prosekit-extensions-underline.js",
112
+ "default": "./dist/prosekit-extensions-underline.js"
103
113
  }
104
114
  },
105
115
  "files": [
106
116
  "dist"
107
117
  ],
108
118
  "dependencies": {
109
- "@prosekit/core": "^0.0.16",
110
- "@prosekit/pm": "^0.0.6",
119
+ "@prosekit/core": "^0.0.18",
120
+ "@prosekit/pm": "^0.0.7",
111
121
  "highlight.js": "^11.9.0",
112
122
  "prosemirror-flat-list": "^0.4.3",
113
123
  "prosemirror-highlightjs": "^0.9.1"
@@ -164,8 +174,14 @@
164
174
  "placeholder": [
165
175
  "./dist/prosekit-extensions-placeholder.d.ts"
166
176
  ],
177
+ "strike": [
178
+ "./dist/prosekit-extensions-strike.d.ts"
179
+ ],
167
180
  "suggestion": [
168
181
  "./dist/prosekit-extensions-suggestion.d.ts"
182
+ ],
183
+ "underline": [
184
+ "./dist/prosekit-extensions-underline.d.ts"
169
185
  ]
170
186
  }
171
187
  }
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export {}