@prosekit/extensions 0.7.24 → 0.9.0

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.
Files changed (100) hide show
  1. package/dist/commit/style.css +2 -1
  2. package/dist/commit/style.js +0 -0
  3. package/dist/enter-rule-RdhEA900.js +96 -0
  4. package/dist/gap-cursor/style.css +8 -5
  5. package/dist/gap-cursor/style.js +0 -0
  6. package/dist/input-rule-Gji4N7Oe.js +93 -0
  7. package/dist/list/style.css +7 -7
  8. package/dist/list/style.js +0 -0
  9. package/dist/loro/style.css +21 -17
  10. package/dist/loro/style.js +0 -0
  11. package/dist/mark-rule-wEOcDt6i.js +160 -0
  12. package/dist/placeholder/style.css +5 -5
  13. package/dist/placeholder/style.js +0 -0
  14. package/dist/prosekit-extensions-autocomplete.d.ts +33 -3
  15. package/dist/prosekit-extensions-autocomplete.js +122 -174
  16. package/dist/prosekit-extensions-blockquote.d.ts +51 -8
  17. package/dist/prosekit-extensions-blockquote.js +64 -78
  18. package/dist/prosekit-extensions-bold.d.ts +61 -8
  19. package/dist/prosekit-extensions-bold.js +61 -73
  20. package/dist/prosekit-extensions-code-block.d.ts +172 -20
  21. package/dist/prosekit-extensions-code-block.js +201 -184
  22. package/dist/prosekit-extensions-code.d.ts +61 -8
  23. package/dist/prosekit-extensions-code.js +44 -55
  24. package/dist/prosekit-extensions-commit.d.ts +53 -4
  25. package/dist/prosekit-extensions-commit.js +142 -183
  26. package/dist/prosekit-extensions-doc.d.ts +22 -0
  27. package/dist/prosekit-extensions-doc.js +16 -0
  28. package/dist/prosekit-extensions-drop-cursor.d.ts +34 -3
  29. package/dist/prosekit-extensions-drop-cursor.js +14 -8
  30. package/dist/prosekit-extensions-enter-rule.d.ts +106 -5
  31. package/dist/prosekit-extensions-enter-rule.js +3 -8
  32. package/dist/prosekit-extensions-file.d.ts +126 -8
  33. package/dist/prosekit-extensions-file.js +111 -132
  34. package/dist/prosekit-extensions-gap-cursor.d.ts +29 -2
  35. package/dist/prosekit-extensions-gap-cursor.js +21 -9
  36. package/dist/prosekit-extensions-hard-break.d.ts +58 -0
  37. package/dist/prosekit-extensions-hard-break.js +58 -0
  38. package/dist/prosekit-extensions-heading.d.ts +69 -9
  39. package/dist/prosekit-extensions-heading.js +121 -95
  40. package/dist/prosekit-extensions-horizontal-rule.d.ts +41 -8
  41. package/dist/prosekit-extensions-horizontal-rule.js +53 -71
  42. package/dist/prosekit-extensions-image.d.ts +53 -7
  43. package/dist/prosekit-extensions-image.js +71 -62
  44. package/dist/prosekit-extensions-input-rule.d.ts +134 -6
  45. package/dist/prosekit-extensions-input-rule.js +3 -14
  46. package/dist/prosekit-extensions-italic.d.ts +61 -8
  47. package/dist/prosekit-extensions-italic.js +51 -63
  48. package/dist/prosekit-extensions-link.d.ts +65 -10
  49. package/dist/prosekit-extensions-link.js +95 -100
  50. package/dist/prosekit-extensions-list.d.ts +114 -17
  51. package/dist/prosekit-extensions-list.js +115 -158
  52. package/dist/prosekit-extensions-loro.d.ts +78 -11
  53. package/dist/prosekit-extensions-loro.js +49 -77
  54. package/dist/prosekit-extensions-mark-rule.d.ts +41 -2
  55. package/dist/prosekit-extensions-mark-rule.js +3 -6
  56. package/dist/prosekit-extensions-mention.d.ts +40 -4
  57. package/dist/prosekit-extensions-mention.js +52 -50
  58. package/dist/prosekit-extensions-mod-click-prevention.d.ts +20 -2
  59. package/dist/prosekit-extensions-mod-click-prevention.js +20 -16
  60. package/dist/prosekit-extensions-paragraph.d.ts +65 -0
  61. package/dist/prosekit-extensions-paragraph.js +60 -0
  62. package/dist/prosekit-extensions-placeholder.d.ts +32 -2
  63. package/dist/prosekit-extensions-placeholder.js +39 -56
  64. package/dist/prosekit-extensions-readonly.d.ts +13 -1
  65. package/dist/prosekit-extensions-readonly.js +13 -14
  66. package/dist/prosekit-extensions-search.d.ts +77 -3
  67. package/dist/prosekit-extensions-search.js +48 -47
  68. package/dist/prosekit-extensions-strike.d.ts +50 -8
  69. package/dist/prosekit-extensions-strike.js +44 -49
  70. package/dist/prosekit-extensions-table.d.ts +237 -26
  71. package/dist/prosekit-extensions-table.js +3 -34
  72. package/dist/prosekit-extensions-text-align.d.ts +72 -8
  73. package/dist/prosekit-extensions-text-align.js +63 -44
  74. package/dist/prosekit-extensions-text.d.ts +22 -0
  75. package/dist/prosekit-extensions-text.js +15 -0
  76. package/dist/prosekit-extensions-underline.d.ts +46 -7
  77. package/dist/prosekit-extensions-underline.js +33 -37
  78. package/dist/prosekit-extensions-virtual-selection.d.ts +24 -2
  79. package/dist/prosekit-extensions-virtual-selection.js +49 -52
  80. package/dist/prosekit-extensions-yjs.d.ts +99 -14
  81. package/dist/prosekit-extensions-yjs.js +88 -131
  82. package/dist/prosekit-extensions.d.ts +1 -1
  83. package/dist/search/style.css +5 -5
  84. package/dist/search/style.js +0 -0
  85. package/dist/shiki-highlighter-chunk-Cd3WeOKL.d.ts +19 -0
  86. package/dist/shiki-highlighter-chunk.d.ts +2 -0
  87. package/dist/shiki-highlighter-chunk.js +34 -43
  88. package/dist/table/style.css +18 -17
  89. package/dist/table/style.js +0 -0
  90. package/dist/table-DnVliJ6E.js +287 -0
  91. package/dist/virtual-selection/style.css +2 -2
  92. package/dist/virtual-selection/style.js +0 -0
  93. package/dist/yjs/style.css +15 -17
  94. package/dist/yjs/style.js +0 -0
  95. package/package.json +103 -52
  96. package/dist/_tsup-dts-rollup.d.ts +0 -2500
  97. package/dist/chunk-6UYLCVBX.js +0 -185
  98. package/dist/chunk-BV3SHIMW.js +0 -98
  99. package/dist/chunk-D54VSLLS.js +0 -105
  100. package/dist/chunk-HFAZX2J3.js +0 -306
@@ -1,217 +1,234 @@
1
- import {
2
- defineTextBlockEnterRule
3
- } from "./chunk-D54VSLLS.js";
4
- import {
5
- defineTextBlockInputRule
6
- } from "./chunk-BV3SHIMW.js";
7
-
8
- // src/code-block/code-block.ts
9
- import {
10
- union
11
- } from "@prosekit/core";
1
+ import { defineTextBlockInputRule } from "./input-rule-Gji4N7Oe.js";
2
+ import { defineTextBlockEnterRule } from "./enter-rule-RdhEA900.js";
3
+ import { defaultBlockAt, defineCommands, defineKeymap, defineNodeSpec, definePlugin, insertNode, setBlockType, setNodeAttrs, toggleNode, union } from "@prosekit/core";
4
+ import { TextSelection } from "@prosekit/pm/state";
5
+ import { createHighlightPlugin } from "prosemirror-highlight";
6
+ import { createParser } from "prosemirror-highlight/shiki";
7
+ import { bundledLanguagesInfo as shikiBundledLanguagesInfo, bundledThemesInfo as shikiBundledThemesInfo } from "shiki";
12
8
 
13
- // src/code-block/code-block-commands.ts
14
- import {
15
- defineCommands,
16
- insertNode,
17
- setBlockType,
18
- setNodeAttrs,
19
- toggleNode
20
- } from "@prosekit/core";
9
+ //#region src/code-block/code-block-commands.ts
10
+ /**
11
+ * Adds commands for working with `codeBlock` nodes.
12
+ *
13
+ * @public
14
+ */
21
15
  function defineCodeBlockCommands() {
22
- return defineCommands({
23
- setCodeBlock: (attrs) => {
24
- return setBlockType({ type: "codeBlock", attrs });
25
- },
26
- insertCodeBlock: (attrs) => {
27
- return insertNode({ type: "codeBlock", attrs });
28
- },
29
- toggleCodeBlock: (attrs) => {
30
- return toggleNode({ type: "codeBlock", attrs });
31
- },
32
- setCodeBlockAttrs: (attrs) => {
33
- return setNodeAttrs({ type: "codeBlock", attrs });
34
- }
35
- });
16
+ return defineCommands({
17
+ setCodeBlock: (attrs) => {
18
+ return setBlockType({
19
+ type: "codeBlock",
20
+ attrs
21
+ });
22
+ },
23
+ insertCodeBlock: (attrs) => {
24
+ return insertNode({
25
+ type: "codeBlock",
26
+ attrs
27
+ });
28
+ },
29
+ toggleCodeBlock: (attrs) => {
30
+ return toggleNode({
31
+ type: "codeBlock",
32
+ attrs
33
+ });
34
+ },
35
+ setCodeBlockAttrs: (attrs) => {
36
+ return setNodeAttrs({
37
+ type: "codeBlock",
38
+ attrs
39
+ });
40
+ }
41
+ });
36
42
  }
37
43
 
38
- // src/code-block/code-block-input-rule.ts
44
+ //#endregion
45
+ //#region src/code-block/code-block-input-rule.ts
46
+ /**
47
+ * Adds input rules for `codeBlock` nodes.
48
+ *
49
+ * @public
50
+ */
39
51
  function defineCodeBlockInputRule() {
40
- return defineTextBlockInputRule({
41
- regex: /^```(\S*)\s$/,
42
- type: "codeBlock",
43
- attrs: getAttrs
44
- });
52
+ return defineTextBlockInputRule({
53
+ regex: /^```(\S*)\s$/,
54
+ type: "codeBlock",
55
+ attrs: getAttrs
56
+ });
45
57
  }
58
+ /**
59
+ * Adds enter rules for `codeBlock` nodes.
60
+ *
61
+ * @public
62
+ */
46
63
  function defineCodeBlockEnterRule() {
47
- return defineTextBlockEnterRule({
48
- regex: /^```(\S*)$/,
49
- type: "codeBlock",
50
- attrs: getAttrs
51
- });
64
+ return defineTextBlockEnterRule({
65
+ regex: /^```(\S*)$/,
66
+ type: "codeBlock",
67
+ attrs: getAttrs
68
+ });
52
69
  }
53
70
  function getAttrs(match) {
54
- return { language: match[1] || "" };
71
+ return { language: match[1] || "" };
55
72
  }
56
73
 
57
- // src/code-block/code-block-keymap.ts
58
- import {
59
- defaultBlockAt,
60
- defineKeymap
61
- } from "@prosekit/core";
62
- import {
63
- TextSelection
64
- } from "@prosekit/pm/state";
74
+ //#endregion
75
+ //#region src/code-block/code-block-keymap.ts
76
+ /**
77
+ * Defines the keymap for code blocks.
78
+ */
65
79
  function defineCodeBlockKeymap() {
66
- return defineKeymap({
67
- Enter: existCodeBlock
68
- });
80
+ return defineKeymap({ Enter: existCodeBlock });
69
81
  }
70
- var existCodeBlock = (state, dispatch) => {
71
- if (!state.selection.empty) {
72
- return false;
73
- }
74
- const { $head } = state.selection;
75
- const parent = $head.parent;
76
- if (parent.isTextblock && parent.type.spec.code && $head.parentOffset === parent.content.size && parent.textContent.endsWith("\n\n")) {
77
- const grandParent = $head.node(-1);
78
- const insertIndex = $head.indexAfter(-1);
79
- const type = defaultBlockAt(grandParent.contentMatchAt(insertIndex));
80
- if (!type || !grandParent.canReplaceWith(insertIndex, insertIndex, type)) {
81
- return false;
82
- }
83
- if (dispatch) {
84
- const { tr } = state;
85
- tr.delete($head.pos - 2, $head.pos);
86
- const pos = tr.selection.$head.after();
87
- const node = type.createAndFill();
88
- if (node) {
89
- tr.replaceWith(pos, pos, node);
90
- tr.setSelection(TextSelection.near(tr.doc.resolve(pos), 1));
91
- dispatch(tr.scrollIntoView());
92
- }
93
- }
94
- return true;
95
- }
96
- return false;
82
+ /**
83
+ * Exit a code block and insert a default block below if the cursor is at the
84
+ * end of the code block and the code block is ended with two new lines.
85
+ */
86
+ const existCodeBlock = (state, dispatch) => {
87
+ if (!state.selection.empty) return false;
88
+ const { $head } = state.selection;
89
+ const parent = $head.parent;
90
+ if (parent.isTextblock && parent.type.spec.code && $head.parentOffset === parent.content.size && parent.textContent.endsWith("\n\n")) {
91
+ const grandParent = $head.node(-1);
92
+ const insertIndex = $head.indexAfter(-1);
93
+ const type = defaultBlockAt(grandParent.contentMatchAt(insertIndex));
94
+ if (!type || !grandParent.canReplaceWith(insertIndex, insertIndex, type)) return false;
95
+ if (dispatch) {
96
+ const { tr } = state;
97
+ tr.delete($head.pos - 2, $head.pos);
98
+ const pos = tr.selection.$head.after();
99
+ const node = type.createAndFill();
100
+ if (node) {
101
+ tr.replaceWith(pos, pos, node);
102
+ tr.setSelection(TextSelection.near(tr.doc.resolve(pos), 1));
103
+ dispatch(tr.scrollIntoView());
104
+ }
105
+ }
106
+ return true;
107
+ }
108
+ return false;
97
109
  };
98
110
 
99
- // src/code-block/code-block-spec.ts
100
- import {
101
- defineNodeSpec
102
- } from "@prosekit/core";
111
+ //#endregion
112
+ //#region src/code-block/code-block-spec.ts
113
+ /**
114
+ * Defines the `codeBlock` node spec.
115
+ *
116
+ * @public
117
+ */
103
118
  function defineCodeBlockSpec() {
104
- return defineNodeSpec({
105
- name: "codeBlock",
106
- content: "text*",
107
- group: "block",
108
- code: true,
109
- defining: true,
110
- marks: "",
111
- attrs: { language: { default: "" } },
112
- parseDOM: [
113
- {
114
- tag: "pre",
115
- preserveWhitespace: "full",
116
- getAttrs: (node) => ({
117
- language: node.getAttribute("data-language") || ""
118
- })
119
- }
120
- ],
121
- toDOM(node) {
122
- const attrs = node.attrs;
123
- return ["pre", { "data-language": attrs.language }, ["code", 0]];
124
- }
125
- });
119
+ return defineNodeSpec({
120
+ name: "codeBlock",
121
+ content: "text*",
122
+ group: "block",
123
+ code: true,
124
+ defining: true,
125
+ marks: "",
126
+ attrs: { language: {
127
+ default: "",
128
+ validate: "string"
129
+ } },
130
+ parseDOM: [{
131
+ tag: "pre",
132
+ preserveWhitespace: "full",
133
+ getAttrs: (node) => ({ language: node.getAttribute("data-language") || "" })
134
+ }],
135
+ toDOM(node) {
136
+ const attrs = node.attrs;
137
+ return [
138
+ "pre",
139
+ { "data-language": attrs.language },
140
+ ["code", 0]
141
+ ];
142
+ }
143
+ });
126
144
  }
127
145
 
128
- // src/code-block/code-block.ts
146
+ //#endregion
147
+ //#region src/code-block/code-block.ts
148
+ /**
149
+ * Adds `codeBlock` nodes to the editor. This includes the following extensions:
150
+ *
151
+ * - {@link defineCodeBlockSpec}
152
+ * - {@link defineCodeBlockInputRule}
153
+ * - {@link defineCodeBlockEnterRule}
154
+ * - {@link defineCodeBlockKeymap}
155
+ * - {@link defineCodeBlockCommands}.
156
+ *
157
+ * @public
158
+ */
129
159
  function defineCodeBlock() {
130
- return union(
131
- defineCodeBlockSpec(),
132
- defineCodeBlockInputRule(),
133
- defineCodeBlockEnterRule(),
134
- defineCodeBlockKeymap(),
135
- defineCodeBlockCommands()
136
- );
160
+ return union(defineCodeBlockSpec(), defineCodeBlockInputRule(), defineCodeBlockEnterRule(), defineCodeBlockKeymap(), defineCodeBlockCommands());
137
161
  }
138
162
 
139
- // src/code-block/code-block-highlight.ts
140
- import {
141
- definePlugin
142
- } from "@prosekit/core";
143
- import {
144
- createHighlightPlugin
145
- } from "prosemirror-highlight";
146
- function defineCodeBlockHighlight({
147
- parser
148
- }) {
149
- return definePlugin(
150
- createHighlightPlugin({ parser })
151
- );
163
+ //#endregion
164
+ //#region src/code-block/code-block-highlight.ts
165
+ /**
166
+ * Adds syntax highlighting to code blocks. This function requires a `Parser`
167
+ * instance from the `prosemirror-highlight` package. See the
168
+ * [documentation](https://github.com/ocavue/prosemirror-highlight) for more
169
+ * information.
170
+ *
171
+ * @param options
172
+ *
173
+ * @public
174
+ */
175
+ function defineCodeBlockHighlight({ parser }) {
176
+ return definePlugin(createHighlightPlugin({ parser }));
152
177
  }
153
178
 
154
- // src/code-block/shiki-parser.ts
155
- import { createParser } from "prosemirror-highlight/shiki";
156
-
157
- // src/code-block/shiki-highlighter.ts
158
- var loaded;
179
+ //#endregion
180
+ //#region src/code-block/shiki-highlighter.ts
181
+ let loaded;
159
182
  async function load() {
160
- const { createOrGetHighlighter: createOrGetHighlighter2 } = await import("./shiki-highlighter-chunk.js");
161
- loaded = createOrGetHighlighter2;
183
+ const { createOrGetHighlighter: createOrGetHighlighter$1 } = await import("./shiki-highlighter-chunk.js");
184
+ loaded = createOrGetHighlighter$1;
162
185
  }
163
186
  function createOrGetHighlighter(options) {
164
- if (!loaded) {
165
- return { promise: load() };
166
- }
167
- return loaded(options);
187
+ if (!loaded) return { promise: load() };
188
+ return loaded(options);
168
189
  }
169
190
 
170
- // src/code-block/shiki-parser.ts
191
+ //#endregion
192
+ //#region src/code-block/shiki-parser.ts
193
+ /**
194
+ * @internal
195
+ */
171
196
  function createLazyParser(highlighterOptions) {
172
- let parser;
173
- return function lazyParser(options) {
174
- const language = options.language || "";
175
- const { highlighter, promise } = createOrGetHighlighter({
176
- ...highlighterOptions,
177
- langs: [language]
178
- });
179
- if (!highlighter) {
180
- return promise;
181
- }
182
- if (!parser) {
183
- parser = createParser(highlighter, {
184
- theme: highlighterOptions.themes[0]
185
- });
186
- }
187
- return parser(options);
188
- };
197
+ let parser;
198
+ return function lazyParser(options) {
199
+ const language = options.language || "";
200
+ const { highlighter, promise } = createOrGetHighlighter({
201
+ ...highlighterOptions,
202
+ langs: [language]
203
+ });
204
+ if (!highlighter) return promise;
205
+ if (!parser) parser = createParser(highlighter, { theme: highlighterOptions.themes[0] });
206
+ return parser(options);
207
+ };
189
208
  }
190
209
 
191
- // src/code-block/code-block-shiki.ts
192
- function defineCodeBlockShiki({
193
- themes = ["one-dark-pro"],
194
- langs = ["text"],
195
- ...rest
196
- } = {}) {
197
- const parser = createLazyParser({ themes, langs, ...rest });
198
- return defineCodeBlockHighlight({ parser });
210
+ //#endregion
211
+ //#region src/code-block/code-block-shiki.ts
212
+ /**
213
+ * Adds syntax highlighting to code blocks using the [Shiki](https://github.com/shikijs/shiki) package.
214
+ *
215
+ * It will set two CSS variables on the code block elements:
216
+ *
217
+ * - `--prosemirror-highlight`: sets text color
218
+ * - `--prosemirror-highlight-bg`: sets background color
219
+ *
220
+ * @param options - The options to configure the Shiki highlighter.
221
+ *
222
+ * @public
223
+ */
224
+ function defineCodeBlockShiki({ themes = ["one-dark-pro"], langs = ["text"],...rest } = {}) {
225
+ const parser = createLazyParser({
226
+ themes,
227
+ langs,
228
+ ...rest
229
+ });
230
+ return defineCodeBlockHighlight({ parser });
199
231
  }
200
232
 
201
- // src/code-block/shiki-bundle.ts
202
- import {
203
- bundledLanguagesInfo,
204
- bundledThemesInfo
205
- } from "shiki";
206
- export {
207
- defineCodeBlock,
208
- defineCodeBlockCommands,
209
- defineCodeBlockEnterRule,
210
- defineCodeBlockHighlight,
211
- defineCodeBlockInputRule,
212
- defineCodeBlockKeymap,
213
- defineCodeBlockShiki,
214
- defineCodeBlockSpec,
215
- bundledLanguagesInfo as shikiBundledLanguagesInfo,
216
- bundledThemesInfo as shikiBundledThemesInfo
217
- };
233
+ //#endregion
234
+ export { defineCodeBlock, defineCodeBlockCommands, defineCodeBlockEnterRule, defineCodeBlockHighlight, defineCodeBlockInputRule, defineCodeBlockKeymap, defineCodeBlockShiki, defineCodeBlockSpec, shikiBundledLanguagesInfo, shikiBundledThemesInfo };
@@ -1,8 +1,61 @@
1
- export { defineCode_alias_1 as defineCode } from './_tsup-dts-rollup.js';
2
- export { CodeExtension_alias_1 as CodeExtension } from './_tsup-dts-rollup.js';
3
- export { defineCodeCommands_alias_1 as defineCodeCommands } from './_tsup-dts-rollup.js';
4
- export { CodeCommandsExtension_alias_1 as CodeCommandsExtension } from './_tsup-dts-rollup.js';
5
- export { defineCodeInputRule_alias_1 as defineCodeInputRule } from './_tsup-dts-rollup.js';
6
- export { defineCodeKeymap_alias_1 as defineCodeKeymap } from './_tsup-dts-rollup.js';
7
- export { defineCodeSpec_alias_1 as defineCodeSpec } from './_tsup-dts-rollup.js';
8
- export { CodeSpecExtension_alias_1 as CodeSpecExtension } from './_tsup-dts-rollup.js';
1
+ import { Extension, PlainExtension, Union } from "@prosekit/core";
2
+ import { Attrs } from "@prosekit/pm/model";
3
+
4
+ //#region src/code/code-commands.d.ts
5
+ /**
6
+ * @internal
7
+ */
8
+ /**
9
+ * @internal
10
+ */
11
+ type CodeCommandsExtension = Extension<{
12
+ Commands: {
13
+ toggleCode: [];
14
+ };
15
+ }>;
16
+ /**
17
+ * @internal
18
+ */
19
+ declare function defineCodeCommands(): CodeCommandsExtension;
20
+ //#endregion
21
+ //#region src/code/code-spec.d.ts
22
+ /**
23
+ * @internal
24
+ */
25
+ type CodeSpecExtension = Extension<{
26
+ Marks: {
27
+ code: Attrs;
28
+ };
29
+ }>;
30
+ /**
31
+ * @internal
32
+ */
33
+ declare function defineCodeSpec(): CodeSpecExtension;
34
+
35
+ //#endregion
36
+ //#region src/code/code.d.ts
37
+ /**
38
+ * @internal
39
+ */
40
+ type CodeExtension = Union<[CodeSpecExtension, CodeCommandsExtension]>;
41
+ /**
42
+ * @public
43
+ */
44
+ declare function defineCode(): CodeExtension;
45
+
46
+ //#endregion
47
+ //#region src/code/code-input-rule.d.ts
48
+ /**
49
+ * @internal
50
+ */
51
+ declare function defineCodeInputRule(): PlainExtension;
52
+
53
+ //#endregion
54
+ //#region src/code/code-keymap.d.ts
55
+ /**
56
+ * @internal
57
+ */
58
+ declare function defineCodeKeymap(): PlainExtension;
59
+
60
+ //#endregion
61
+ export { CodeCommandsExtension, CodeExtension, CodeSpecExtension, defineCode, defineCodeCommands, defineCodeInputRule, defineCodeKeymap, defineCodeSpec };
@@ -1,70 +1,59 @@
1
- import {
2
- defineMarkInputRule
3
- } from "./chunk-BV3SHIMW.js";
1
+ import { defineMarkInputRule } from "./input-rule-Gji4N7Oe.js";
2
+ import { canUseRegexLookbehind, defineCommands, defineKeymap, defineMarkSpec, toggleMark, union } from "@prosekit/core";
4
3
 
5
- // src/code/code.ts
6
- import {
7
- union
8
- } from "@prosekit/core";
9
-
10
- // src/code/code-commands.ts
11
- import {
12
- defineCommands,
13
- toggleMark
14
- } from "@prosekit/core";
4
+ //#region src/code/code-commands.ts
5
+ /**
6
+ * @internal
7
+ */
15
8
  function defineCodeCommands() {
16
- return defineCommands({
17
- toggleCode: () => toggleMark({ type: "code" })
18
- });
9
+ return defineCommands({ toggleCode: () => toggleMark({ type: "code" }) });
19
10
  }
20
11
 
21
- // src/code/code-input-rule.ts
22
- import { canUseRegexLookbehind } from "@prosekit/core";
12
+ //#endregion
13
+ //#region src/code/code-input-rule.ts
14
+ /**
15
+ * @internal
16
+ */
23
17
  function defineCodeInputRule() {
24
- return defineMarkInputRule({
25
- regex: canUseRegexLookbehind() ? /(?<=\s|^)`([^\s`]|[^\s`][^`]*[^\s`])`$/ : /`([^\s`]|[^\s`][^`]*[^\s`])`$/,
26
- type: "code"
27
- });
18
+ return defineMarkInputRule({
19
+ regex: canUseRegexLookbehind() ? /(?<=\s|^)`([^\s`]|[^\s`][^`]*[^\s`])`$/ : /`([^\s`]|[^\s`][^`]*[^\s`])`$/,
20
+ type: "code"
21
+ });
28
22
  }
29
23
 
30
- // src/code/code-keymap.ts
31
- import {
32
- defineKeymap,
33
- toggleMark as toggleMark2
34
- } from "@prosekit/core";
24
+ //#endregion
25
+ //#region src/code/code-keymap.ts
26
+ /**
27
+ * @internal
28
+ */
35
29
  function defineCodeKeymap() {
36
- return defineKeymap({
37
- "Mod-e": toggleMark2({ type: "code" })
38
- });
30
+ return defineKeymap({ "Mod-e": toggleMark({ type: "code" }) });
39
31
  }
40
32
 
41
- // src/code/code-spec.ts
42
- import {
43
- defineMarkSpec
44
- } from "@prosekit/core";
33
+ //#endregion
34
+ //#region src/code/code-spec.ts
35
+ /**
36
+ * @internal
37
+ */
45
38
  function defineCodeSpec() {
46
- return defineMarkSpec({
47
- name: "code",
48
- parseDOM: [{ tag: "code" }],
49
- toDOM() {
50
- return ["code", 0];
51
- }
52
- });
39
+ return defineMarkSpec({
40
+ name: "code",
41
+ parseDOM: [{ tag: "code" }],
42
+ code: true,
43
+ toDOM() {
44
+ return ["code", 0];
45
+ }
46
+ });
53
47
  }
54
48
 
55
- // src/code/code.ts
49
+ //#endregion
50
+ //#region src/code/code.ts
51
+ /**
52
+ * @public
53
+ */
56
54
  function defineCode() {
57
- return union(
58
- defineCodeSpec(),
59
- defineCodeCommands(),
60
- defineCodeKeymap(),
61
- defineCodeInputRule()
62
- );
55
+ return union(defineCodeSpec(), defineCodeCommands(), defineCodeKeymap(), defineCodeInputRule());
63
56
  }
64
- export {
65
- defineCode,
66
- defineCodeCommands,
67
- defineCodeInputRule,
68
- defineCodeKeymap,
69
- defineCodeSpec
70
- };
57
+
58
+ //#endregion
59
+ export { defineCode, defineCodeCommands, defineCodeInputRule, defineCodeKeymap, defineCodeSpec };
@@ -1,4 +1,53 @@
1
- export { CommitRecorder } from './_tsup-dts-rollup.js';
2
- export { defineCommitRecorder } from './_tsup-dts-rollup.js';
3
- export { defineCommitViewer } from './_tsup-dts-rollup.js';
4
- export { Commit } from './_tsup-dts-rollup.js';
1
+ import { NodeJSON, PlainExtension, StepJSON } from "@prosekit/core";
2
+ import { Transaction } from "@prosekit/pm/state";
3
+ import { ProseMirrorNode } from "@prosekit/pm/model";
4
+
5
+ //#region src/commit/index.d.ts
6
+ /**
7
+ * A JSON representation of a commit.
8
+ */
9
+ /**
10
+ * A JSON representation of a commit.
11
+ */
12
+ interface Commit {
13
+ /**
14
+ * The current doc node in the JSON format
15
+ */
16
+ doc: NodeJSON;
17
+ /**
18
+ * The parent node in the JSON format
19
+ */
20
+ parent: NodeJSON;
21
+ /**
22
+ * An array of steps in the JSON format that transform the parent node to the
23
+ * current doc node.
24
+ */
25
+ steps: StepJSON[];
26
+ }
27
+ /**
28
+ * Define an extension to display the changes from the given commit in the editor.
29
+ */
30
+ declare function defineCommitViewer(commit: Commit): PlainExtension;
31
+ declare class CommitRecorder {
32
+ private parent;
33
+ private doc;
34
+ private steps;
35
+ /**
36
+ * Return a commit object including all changes since the last commit. `null`
37
+ * will be returned if there is no change.
38
+ */
39
+ commit(): Commit | null;
40
+ /**
41
+ * @internal
42
+ */
43
+ init(doc: ProseMirrorNode): void;
44
+ /**
45
+ * @internal
46
+ */
47
+ apply(tr: Transaction): void;
48
+ }
49
+ /**
50
+ * Define an extension that can record the changes in the editor.
51
+ */
52
+ declare function defineCommitRecorder(commitRecorder: CommitRecorder): PlainExtension; //#endregion
53
+ export { Commit, CommitRecorder, defineCommitRecorder, defineCommitViewer };