@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,206 +1,165 @@
1
- // src/commit/index.ts
2
- import {
3
- collectChildren,
4
- defineDefaultState,
5
- definePlugin,
6
- jsonFromNode,
7
- union
8
- } from "@prosekit/core";
9
- import {
10
- DOMSerializer,
11
- Fragment,
12
- Slice
13
- } from "@prosekit/pm/model";
14
- import {
15
- PluginKey,
16
- ProseMirrorPlugin
17
- } from "@prosekit/pm/state";
1
+ import { collectChildren, defineDefaultState, definePlugin, jsonFromNode, union } from "@prosekit/core";
2
+ import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state";
3
+ import { Decoration, DecorationSet } from "@prosekit/pm/view";
4
+ import { DOMSerializer, Fragment, Slice } from "@prosekit/pm/model";
18
5
  import { Step } from "@prosekit/pm/transform";
19
- import {
20
- Decoration,
21
- DecorationSet
22
- } from "@prosekit/pm/view";
23
- import {
24
- ChangeSet
25
- } from "prosemirror-changeset";
6
+ import { ChangeSet } from "prosemirror-changeset";
7
+
8
+ //#region src/commit/index.ts
26
9
  function getChanges(doc, parent, steps) {
27
- const initSet = ChangeSet.create(parent);
28
- const currSet = initSet.addSteps(
29
- doc,
30
- steps.map((step) => step.getMap()),
31
- null
32
- );
33
- return currSet.changes;
10
+ const initSet = ChangeSet.create(parent);
11
+ const currSet = initSet.addSteps(doc, steps.map((step) => step.getMap()), null);
12
+ return currSet.changes;
34
13
  }
35
14
  function renderDivWeight(view) {
36
- const document = view.dom.ownerDocument;
37
- return document.createElement("div");
15
+ const document = view.dom.ownerDocument;
16
+ return document.createElement("div");
38
17
  }
39
18
  function decorateDeletionSlice(slice) {
40
- let { openStart, openEnd, content } = slice;
41
- while (openStart > 0 && openEnd > 0 && content.childCount === 1) {
42
- openStart--;
43
- openEnd--;
44
- content = content.child(0).content;
45
- }
46
- if (content.childCount === 0) {
47
- return [];
48
- }
49
- if (openStart > 0 && openEnd > 0 && content.childCount === 2) {
50
- const head = Fragment.from([content.child(0)]);
51
- const tail = Fragment.from([content.child(1)]);
52
- return [
53
- ...decorateDeletionSlice(new Slice(head, openStart, openStart)),
54
- renderDivWeight,
55
- ...decorateDeletionSlice(new Slice(tail, openEnd, openEnd))
56
- ];
57
- }
58
- if (openStart > 0 && content.childCount >= 2) {
59
- const nodes = collectChildren(content);
60
- const head = Fragment.from(nodes.slice(0, 1));
61
- const body = Fragment.from(nodes.slice(1));
62
- return [
63
- ...decorateDeletionSlice(new Slice(head, openStart, openStart)),
64
- ...decorateDeletionSlice(new Slice(body, 0, openEnd))
65
- ];
66
- }
67
- if (openEnd > 0 && content.childCount >= 2) {
68
- const nodes = collectChildren(content);
69
- const body = Fragment.from(nodes.slice(0, -1));
70
- const tail = Fragment.from(nodes.slice(-1));
71
- return [
72
- ...decorateDeletionSlice(new Slice(body, openStart, 0)),
73
- ...decorateDeletionSlice(new Slice(tail, openEnd, openEnd))
74
- ];
75
- }
76
- const schema = content.child(0).type.schema;
77
- const isInline = content.child(0).isInline;
78
- const render = (view) => {
79
- const document = view.dom.ownerDocument;
80
- const element = document.createElement(isInline ? "span" : "div");
81
- const serializer = DOMSerializer.fromSchema(schema);
82
- serializer.serializeFragment(content, { document }, element);
83
- element.classList.add("prosekit-commit-deletion");
84
- return element;
85
- };
86
- return [render];
19
+ let { openStart, openEnd, content } = slice;
20
+ while (openStart > 0 && openEnd > 0 && content.childCount === 1) {
21
+ openStart--;
22
+ openEnd--;
23
+ content = content.child(0).content;
24
+ }
25
+ if (content.childCount === 0) return [];
26
+ if (openStart > 0 && openEnd > 0 && content.childCount === 2) {
27
+ const head = Fragment.from([content.child(0)]);
28
+ const tail = Fragment.from([content.child(1)]);
29
+ return [
30
+ ...decorateDeletionSlice(new Slice(head, openStart, openStart)),
31
+ renderDivWeight,
32
+ ...decorateDeletionSlice(new Slice(tail, openEnd, openEnd))
33
+ ];
34
+ }
35
+ if (openStart > 0 && content.childCount >= 2) {
36
+ const nodes = collectChildren(content);
37
+ const head = Fragment.from(nodes.slice(0, 1));
38
+ const body = Fragment.from(nodes.slice(1));
39
+ return [...decorateDeletionSlice(new Slice(head, openStart, openStart)), ...decorateDeletionSlice(new Slice(body, 0, openEnd))];
40
+ }
41
+ if (openEnd > 0 && content.childCount >= 2) {
42
+ const nodes = collectChildren(content);
43
+ const body = Fragment.from(nodes.slice(0, -1));
44
+ const tail = Fragment.from(nodes.slice(-1));
45
+ return [...decorateDeletionSlice(new Slice(body, openStart, 0)), ...decorateDeletionSlice(new Slice(tail, openEnd, openEnd))];
46
+ }
47
+ const schema = content.child(0).type.schema;
48
+ const isInline = content.child(0).isInline;
49
+ const render = (view) => {
50
+ const document = view.dom.ownerDocument;
51
+ const element = document.createElement(isInline ? "span" : "div");
52
+ const serializer = DOMSerializer.fromSchema(schema);
53
+ serializer.serializeFragment(content, { document }, element);
54
+ element.classList.add("prosekit-commit-deletion");
55
+ return element;
56
+ };
57
+ return [render];
87
58
  }
88
59
  function decorateDeletion(doc, from, to, pos) {
89
- const slice = doc.slice(from, to);
90
- const renders = decorateDeletionSlice(slice);
91
- const count = renders.length;
92
- return renders.map(
93
- (render, index) => Decoration.widget(pos, render, {
94
- side: -20 - count + index,
95
- // Ensure the text in the decoration is able to be selected.
96
- ignoreSelection: true
97
- })
98
- );
60
+ const slice = doc.slice(from, to);
61
+ const renders = decorateDeletionSlice(slice);
62
+ const count = renders.length;
63
+ return renders.map((render, index) => Decoration.widget(pos, render, {
64
+ side: -20 - count + index,
65
+ ignoreSelection: true
66
+ }));
99
67
  }
100
68
  function decorateAddition(from, to) {
101
- return Decoration.inline(from, to, { class: "prosekit-commit-addition" });
69
+ return Decoration.inline(from, to, { class: "prosekit-commit-addition" });
102
70
  }
103
71
  function decorateChange(prev, change) {
104
- const { fromA, toA, fromB, toB } = change;
105
- const decorations = [];
106
- if (fromA < toA) {
107
- decorations.push(...decorateDeletion(prev, fromA, toA, fromB));
108
- }
109
- if (fromB < toB) {
110
- decorations.push(decorateAddition(fromB, toB));
111
- }
112
- return decorations;
72
+ const { fromA, toA, fromB, toB } = change;
73
+ const decorations = [];
74
+ if (fromA < toA) decorations.push(...decorateDeletion(prev, fromA, toA, fromB));
75
+ if (fromB < toB) decorations.push(decorateAddition(fromB, toB));
76
+ return decorations;
113
77
  }
114
78
  function decorateCommit(doc, parent, steps) {
115
- const changes = getChanges(doc, parent, steps);
116
- const decorations = changes.flatMap((change) => decorateChange(parent, change));
117
- return DecorationSet.create(doc, decorations);
79
+ const changes = getChanges(doc, parent, steps);
80
+ const decorations = changes.flatMap((change) => decorateChange(parent, change));
81
+ return DecorationSet.create(doc, decorations);
118
82
  }
119
83
  function defineCommitDecoration(commit) {
120
- const key = new PluginKey("prosekit-commit-decoration");
121
- return definePlugin(({ schema }) => {
122
- const parent = schema.nodeFromJSON(commit.parent);
123
- const steps = commit.steps.map((step) => Step.fromJSON(schema, step));
124
- return new ProseMirrorPlugin({
125
- key,
126
- state: {
127
- init: (_, instance) => {
128
- return decorateCommit(instance.doc, parent, steps);
129
- },
130
- apply: (tr, deco) => {
131
- return deco.map(tr.mapping, tr.doc);
132
- }
133
- },
134
- props: {
135
- decorations: (state) => {
136
- return key.getState(state);
137
- }
138
- }
139
- });
140
- });
84
+ const key = new PluginKey("prosekit-commit-decoration");
85
+ return definePlugin(({ schema }) => {
86
+ const parent = schema.nodeFromJSON(commit.parent);
87
+ const steps = commit.steps.map((step) => Step.fromJSON(schema, step));
88
+ return new ProseMirrorPlugin({
89
+ key,
90
+ state: {
91
+ init: (_, instance) => {
92
+ return decorateCommit(instance.doc, parent, steps);
93
+ },
94
+ apply: (tr, deco) => {
95
+ return deco.map(tr.mapping, tr.doc);
96
+ }
97
+ },
98
+ props: { decorations: (state) => {
99
+ return key.getState(state);
100
+ } }
101
+ });
102
+ });
141
103
  }
104
+ /**
105
+ * Define an extension to display the changes from the given commit in the editor.
106
+ */
142
107
  function defineCommitViewer(commit) {
143
- return union(
144
- defineDefaultState({ defaultDoc: commit.doc }),
145
- defineCommitDecoration(commit)
146
- );
108
+ return union(defineDefaultState({ defaultDoc: commit.doc }), defineCommitDecoration(commit));
147
109
  }
148
110
  var CommitRecorder = class {
149
- constructor() {
150
- this.parent = null;
151
- this.doc = null;
152
- this.steps = [];
153
- }
154
- /**
155
- * Return a commit object including all changes since the last commit. `null`
156
- * will be returned if there is no change.
157
- */
158
- commit() {
159
- if (!this.parent || !this.doc || this.steps.length === 0 || this.parent.eq(this.doc)) {
160
- return null;
161
- }
162
- const commit = {
163
- doc: jsonFromNode(this.doc),
164
- parent: jsonFromNode(this.parent),
165
- steps: this.steps.map((step) => step.toJSON())
166
- };
167
- this.init(this.doc);
168
- return commit;
169
- }
170
- /**
171
- * @internal
172
- */
173
- init(doc) {
174
- this.doc = doc;
175
- this.parent = doc;
176
- this.steps = [];
177
- }
178
- /**
179
- * @internal
180
- */
181
- apply(tr) {
182
- this.steps.push(...tr.steps);
183
- this.doc = tr.doc;
184
- }
111
+ constructor() {
112
+ this.parent = null;
113
+ this.doc = null;
114
+ this.steps = [];
115
+ }
116
+ /**
117
+ * Return a commit object including all changes since the last commit. `null`
118
+ * will be returned if there is no change.
119
+ */
120
+ commit() {
121
+ if (!this.parent || !this.doc || this.steps.length === 0 || this.parent.eq(this.doc)) return null;
122
+ const commit = {
123
+ doc: jsonFromNode(this.doc),
124
+ parent: jsonFromNode(this.parent),
125
+ steps: this.steps.map((step) => step.toJSON())
126
+ };
127
+ this.init(this.doc);
128
+ return commit;
129
+ }
130
+ /**
131
+ * @internal
132
+ */
133
+ init(doc) {
134
+ this.doc = doc;
135
+ this.parent = doc;
136
+ this.steps = [];
137
+ }
138
+ /**
139
+ * @internal
140
+ */
141
+ apply(tr) {
142
+ this.steps.push(...tr.steps);
143
+ this.doc = tr.doc;
144
+ }
185
145
  };
146
+ /**
147
+ * Define an extension that can record the changes in the editor.
148
+ */
186
149
  function defineCommitRecorder(commitRecorder) {
187
- const key = new PluginKey("prosekit-commit-recorder");
188
- return definePlugin(
189
- new ProseMirrorPlugin({
190
- key,
191
- state: {
192
- init: (_, state) => {
193
- commitRecorder.init(state.doc);
194
- },
195
- apply: (tr) => {
196
- commitRecorder.apply(tr);
197
- }
198
- }
199
- })
200
- );
150
+ const key = new PluginKey("prosekit-commit-recorder");
151
+ return definePlugin(new ProseMirrorPlugin({
152
+ key,
153
+ state: {
154
+ init: (_, state) => {
155
+ commitRecorder.init(state.doc);
156
+ },
157
+ apply: (tr) => {
158
+ commitRecorder.apply(tr);
159
+ }
160
+ }
161
+ }));
201
162
  }
202
- export {
203
- CommitRecorder,
204
- defineCommitRecorder,
205
- defineCommitViewer
206
- };
163
+
164
+ //#endregion
165
+ export { CommitRecorder, defineCommitRecorder, defineCommitViewer };
@@ -0,0 +1,22 @@
1
+ import { Extension } from "@prosekit/core";
2
+ import { Attrs } from "@prosekit/pm/model";
3
+
4
+ //#region src/doc/index.d.ts
5
+ /**
6
+ * @internal
7
+ */
8
+ /**
9
+ * @internal
10
+ */
11
+ type DocExtension = Extension<{
12
+ Nodes: {
13
+ doc: Attrs;
14
+ };
15
+ }>;
16
+ /**
17
+ * @public
18
+ */
19
+ declare function defineDoc(): DocExtension;
20
+
21
+ //#endregion
22
+ export { DocExtension, defineDoc };
@@ -0,0 +1,16 @@
1
+ import { defineNodeSpec } from "@prosekit/core";
2
+
3
+ //#region src/doc/index.ts
4
+ /**
5
+ * @public
6
+ */
7
+ function defineDoc() {
8
+ return defineNodeSpec({
9
+ name: "doc",
10
+ content: "block+",
11
+ topNode: true
12
+ });
13
+ }
14
+
15
+ //#endregion
16
+ export { defineDoc };
@@ -1,3 +1,34 @@
1
- export { defineDropCursor_alias_1 as defineDropCursor } from './_tsup-dts-rollup.js';
2
- export { DropCursorExtension_alias_1 as DropCursorExtension } from './_tsup-dts-rollup.js';
3
- export { DropCursorOptions_alias_1 as DropCursorOptions } from './_tsup-dts-rollup.js';
1
+ import { PlainExtension } from "@prosekit/core";
2
+
3
+ //#region src/drop-cursor/drop-cursor.d.ts
4
+ interface DropCursorOptions {
5
+ /**
6
+ * The color of the cursor. Use `false` to apply no color and rely only on class.
7
+ *
8
+ * @default 'black'
9
+ */
10
+ color?: string | false;
11
+ /**
12
+ * The precise width of the cursor in pixels.
13
+ *
14
+ * @default 1
15
+ */
16
+ width?: number;
17
+ /**
18
+ * A CSS class name to add to the cursor element.
19
+ */
20
+ class?: string;
21
+ }
22
+ /**
23
+ * @internal
24
+ */
25
+ type DropCursorExtension = PlainExtension;
26
+ /**
27
+ * Show up a decoration at the drop position when something is dragged over the editor.
28
+ *
29
+ * See [prosemirror-dropcursor](https://github.com/ProseMirror/prosemirror-dropcursor) for more information.
30
+ *
31
+ * @public
32
+ */
33
+ declare function defineDropCursor(options?: DropCursorOptions): DropCursorExtension; //#endregion
34
+ export { DropCursorExtension, DropCursorOptions, defineDropCursor };
@@ -1,11 +1,17 @@
1
- // src/drop-cursor/drop-cursor.ts
2
- import {
3
- definePlugin
4
- } from "@prosekit/core";
1
+ import { definePlugin } from "@prosekit/core";
5
2
  import { dropCursor } from "prosemirror-dropcursor";
3
+
4
+ //#region src/drop-cursor/drop-cursor.ts
5
+ /**
6
+ * Show up a decoration at the drop position when something is dragged over the editor.
7
+ *
8
+ * See [prosemirror-dropcursor](https://github.com/ProseMirror/prosemirror-dropcursor) for more information.
9
+ *
10
+ * @public
11
+ */
6
12
  function defineDropCursor(options) {
7
- return definePlugin(() => dropCursor(options));
13
+ return definePlugin(() => dropCursor(options));
8
14
  }
9
- export {
10
- defineDropCursor
11
- };
15
+
16
+ //#endregion
17
+ export { defineDropCursor };
@@ -1,5 +1,106 @@
1
- export { defineEnterRule } from './_tsup-dts-rollup.js';
2
- export { defineTextBlockEnterRule } from './_tsup-dts-rollup.js';
3
- export { EnterRuleHandler } from './_tsup-dts-rollup.js';
4
- export { EnterRuleOptions } from './_tsup-dts-rollup.js';
5
- export { TextBlockEnterRuleOptions } from './_tsup-dts-rollup.js';
1
+ import { PlainExtension } from "@prosekit/core";
2
+ import { EditorState, Transaction } from "@prosekit/pm/state";
3
+ import { Attrs, NodeType } from "@prosekit/pm/model";
4
+
5
+ //#region src/enter-rule/index.d.ts
6
+ /**
7
+ * @public
8
+ */
9
+ /**
10
+ * @public
11
+ */
12
+ type EnterRuleHandler = (options: {
13
+ /**
14
+ * The current editor state.
15
+ */
16
+ state: EditorState;
17
+ /**
18
+ * The start position of the matched text.
19
+ */
20
+ from: number;
21
+ /**
22
+ * The end position of the matched text.
23
+ */
24
+ to: number;
25
+ /**
26
+ * The matched result from the regular expression.
27
+ */
28
+ match: RegExpExecArray;
29
+ }) => Transaction | null;
30
+ /**
31
+ * Options for {@link defineEnterRule}.
32
+ *
33
+ * @public
34
+ */
35
+ type EnterRuleOptions = {
36
+ /**
37
+ * The regular expression to match against. It should end with `$`.
38
+ */
39
+ regex: RegExp;
40
+ /**
41
+ * A function to be called when an enter rule is triggered.
42
+ */
43
+ handler: EnterRuleHandler;
44
+ /**
45
+ * Whether to stop further handlers from being called if this rule is triggered.
46
+ *
47
+ * @default false
48
+ */
49
+ stop?: boolean;
50
+ };
51
+ /**
52
+ * Options for {@link defineTextBlockEnterRule}.
53
+ *
54
+ * @public
55
+ */
56
+ type TextBlockEnterRuleOptions = {
57
+ /**
58
+ * The regular expression to match against. It should end with `$`.
59
+ */
60
+ regex: RegExp;
61
+ /**
62
+ * The node type to replace the matched text with.
63
+ */
64
+ type: string | NodeType;
65
+ /**
66
+ * Attributes to set on the node. If a function is provided, it will be called
67
+ * with the matched result from the regular expression.
68
+ */
69
+ attrs?: Attrs | null | ((match: RegExpMatchArray) => Attrs | null);
70
+ /**
71
+ * Whether to stop further handlers from being called if this rule is triggered.
72
+ *
73
+ * @default true
74
+ */
75
+ stop?: boolean;
76
+ };
77
+ /**
78
+ * Defines an enter rule. An enter rule applies when the text directly in front of
79
+ * the cursor matches `regex` and user presses Enter. The `regex` should end
80
+ * with `$`.
81
+ *
82
+ * @param options
83
+ *
84
+ * @public
85
+ */
86
+ declare function defineEnterRule({
87
+ regex,
88
+ handler,
89
+ stop
90
+ }: EnterRuleOptions): PlainExtension;
91
+ /**
92
+ * Defines an enter rule that replaces the matched text with a block node.
93
+ *
94
+ * See also {@link defineEnterRule}.
95
+ *
96
+ * @param options
97
+ *
98
+ * @public
99
+ */
100
+ declare function defineTextBlockEnterRule({
101
+ regex,
102
+ type,
103
+ attrs,
104
+ stop
105
+ }: TextBlockEnterRuleOptions): PlainExtension; //#endregion
106
+ export { EnterRuleHandler, EnterRuleOptions, TextBlockEnterRuleOptions, defineEnterRule, defineTextBlockEnterRule };
@@ -1,8 +1,3 @@
1
- import {
2
- defineEnterRule,
3
- defineTextBlockEnterRule
4
- } from "./chunk-D54VSLLS.js";
5
- export {
6
- defineEnterRule,
7
- defineTextBlockEnterRule
8
- };
1
+ import { defineEnterRule, defineTextBlockEnterRule } from "./enter-rule-RdhEA900.js";
2
+
3
+ export { defineEnterRule, defineTextBlockEnterRule };