@prosekit/extensions 0.8.0 → 0.9.1
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/commit/style.css +1 -1
- package/dist/commit/style.js +0 -0
- package/dist/enter-rule-RdhEA900.js +96 -0
- package/dist/gap-cursor/style.css +6 -3
- package/dist/gap-cursor/style.js +0 -0
- package/dist/input-rule-Gji4N7Oe.js +93 -0
- package/dist/list/style.css +7 -7
- package/dist/list/style.js +0 -0
- package/dist/loro/style.css +13 -9
- package/dist/loro/style.js +0 -0
- package/dist/mark-rule-wEOcDt6i.js +160 -0
- package/dist/placeholder/style.css +3 -3
- package/dist/placeholder/style.js +0 -0
- package/dist/prosekit-extensions-autocomplete.d.ts +33 -3
- package/dist/prosekit-extensions-autocomplete.js +126 -174
- package/dist/prosekit-extensions-blockquote.d.ts +48 -8
- package/dist/prosekit-extensions-blockquote.js +64 -78
- package/dist/prosekit-extensions-bold.d.ts +54 -8
- package/dist/prosekit-extensions-bold.js +61 -73
- package/dist/prosekit-extensions-code-block.d.ts +159 -20
- package/dist/prosekit-extensions-code-block.js +201 -184
- package/dist/prosekit-extensions-code.d.ts +54 -8
- package/dist/prosekit-extensions-code.js +44 -56
- package/dist/prosekit-extensions-commit.d.ts +52 -4
- package/dist/prosekit-extensions-commit.js +140 -183
- package/dist/prosekit-extensions-doc.d.ts +19 -2
- package/dist/prosekit-extensions-doc.js +14 -12
- package/dist/prosekit-extensions-drop-cursor.d.ts +35 -3
- package/dist/prosekit-extensions-drop-cursor.js +14 -8
- package/dist/prosekit-extensions-enter-rule.d.ts +105 -5
- package/dist/prosekit-extensions-enter-rule.js +3 -8
- package/dist/prosekit-extensions-file.d.ts +129 -8
- package/dist/prosekit-extensions-file.js +124 -132
- package/dist/prosekit-extensions-gap-cursor.d.ts +26 -2
- package/dist/prosekit-extensions-gap-cursor.js +21 -9
- package/dist/prosekit-extensions-hard-break.d.ts +53 -0
- package/dist/prosekit-extensions-hard-break.js +58 -0
- package/dist/prosekit-extensions-heading.d.ts +63 -9
- package/dist/prosekit-extensions-heading.js +121 -95
- package/dist/prosekit-extensions-horizontal-rule.d.ts +38 -8
- package/dist/prosekit-extensions-horizontal-rule.js +53 -71
- package/dist/prosekit-extensions-image.d.ts +50 -7
- package/dist/prosekit-extensions-image.js +71 -62
- package/dist/prosekit-extensions-input-rule.d.ts +129 -6
- package/dist/prosekit-extensions-input-rule.js +3 -14
- package/dist/prosekit-extensions-italic.d.ts +54 -8
- package/dist/prosekit-extensions-italic.js +51 -63
- package/dist/prosekit-extensions-link.d.ts +62 -10
- package/dist/prosekit-extensions-link.js +95 -100
- package/dist/prosekit-extensions-list.d.ts +104 -17
- package/dist/prosekit-extensions-list.js +115 -158
- package/dist/prosekit-extensions-loro.d.ts +69 -11
- package/dist/prosekit-extensions-loro.js +49 -77
- package/dist/prosekit-extensions-mark-rule.d.ts +37 -2
- package/dist/prosekit-extensions-mark-rule.js +3 -6
- package/dist/prosekit-extensions-mention.d.ts +39 -4
- package/dist/prosekit-extensions-mention.js +52 -50
- package/dist/prosekit-extensions-mod-click-prevention.d.ts +17 -2
- package/dist/prosekit-extensions-mod-click-prevention.js +20 -16
- package/dist/prosekit-extensions-paragraph.d.ts +60 -7
- package/dist/prosekit-extensions-paragraph.js +46 -45
- package/dist/prosekit-extensions-placeholder.d.ts +33 -2
- package/dist/prosekit-extensions-placeholder.js +39 -56
- package/dist/prosekit-extensions-readonly.d.ts +10 -1
- package/dist/prosekit-extensions-readonly.js +13 -14
- package/dist/prosekit-extensions-search.d.ts +74 -3
- package/dist/prosekit-extensions-search.js +48 -47
- package/dist/prosekit-extensions-strike.d.ts +47 -8
- package/dist/prosekit-extensions-strike.js +44 -49
- package/dist/prosekit-extensions-table.d.ts +231 -26
- package/dist/prosekit-extensions-table.js +3 -34
- package/dist/prosekit-extensions-text-align.d.ts +71 -8
- package/dist/prosekit-extensions-text-align.js +63 -44
- package/dist/prosekit-extensions-text.d.ts +19 -2
- package/dist/prosekit-extensions-text.js +13 -11
- package/dist/prosekit-extensions-underline.d.ts +43 -7
- package/dist/prosekit-extensions-underline.js +33 -37
- package/dist/prosekit-extensions-virtual-selection.d.ts +21 -2
- package/dist/prosekit-extensions-virtual-selection.js +49 -52
- package/dist/prosekit-extensions-yjs.d.ts +90 -14
- package/dist/prosekit-extensions-yjs.js +88 -131
- package/dist/prosekit-extensions.d.ts +1 -1
- package/dist/search/style.css +4 -3
- package/dist/search/style.js +0 -0
- package/dist/shiki-highlighter-chunk-CZGvZlhf.d.ts +18 -0
- package/dist/shiki-highlighter-chunk.d.ts +2 -0
- package/dist/shiki-highlighter-chunk.js +32 -39
- package/dist/table/style.css +10 -13
- package/dist/table/style.js +0 -0
- package/dist/table-DnVliJ6E.js +287 -0
- package/dist/virtual-selection/style.css +2 -2
- package/dist/virtual-selection/style.js +0 -0
- package/dist/yjs/style.css +9 -8
- package/dist/yjs/style.js +0 -0
- package/package.json +81 -54
- package/dist/_tsup-dts-rollup.d.ts +0 -2459
- package/dist/chunk-6UYLCVBX.js +0 -185
- package/dist/chunk-D54VSLLS.js +0 -105
- package/dist/chunk-I2UMHK3L.js +0 -99
- package/dist/chunk-QVFEYPQ6.js +0 -306
@@ -1,206 +1,163 @@
|
|
1
|
-
|
2
|
-
import {
|
3
|
-
|
4
|
-
|
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
|
-
|
21
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
37
|
-
|
15
|
+
const document = view.dom.ownerDocument;
|
16
|
+
return document.createElement("div");
|
38
17
|
}
|
39
18
|
function decorateDeletionSlice(slice) {
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
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
|
-
|
69
|
+
return Decoration.inline(from, to, { class: "prosekit-commit-addition" });
|
102
70
|
}
|
103
71
|
function decorateChange(prev, change) {
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
-
|
116
|
-
|
117
|
-
|
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
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
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
|
-
|
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
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
apply(tr) {
|
182
|
-
this.steps.push(...tr.steps);
|
183
|
-
this.doc = tr.doc;
|
184
|
-
}
|
111
|
+
parent = null;
|
112
|
+
doc = null;
|
113
|
+
steps = [];
|
114
|
+
/**
|
115
|
+
* Return a commit object including all changes since the last commit. `null`
|
116
|
+
* will be returned if there is no change.
|
117
|
+
*/
|
118
|
+
commit() {
|
119
|
+
if (!this.parent || !this.doc || this.steps.length === 0 || this.parent.eq(this.doc)) return null;
|
120
|
+
const commit = {
|
121
|
+
doc: jsonFromNode(this.doc),
|
122
|
+
parent: jsonFromNode(this.parent),
|
123
|
+
steps: this.steps.map((step) => step.toJSON())
|
124
|
+
};
|
125
|
+
this.init(this.doc);
|
126
|
+
return commit;
|
127
|
+
}
|
128
|
+
/**
|
129
|
+
* @internal
|
130
|
+
*/
|
131
|
+
init(doc) {
|
132
|
+
this.doc = doc;
|
133
|
+
this.parent = doc;
|
134
|
+
this.steps = [];
|
135
|
+
}
|
136
|
+
/**
|
137
|
+
* @internal
|
138
|
+
*/
|
139
|
+
apply(tr) {
|
140
|
+
this.steps.push(...tr.steps);
|
141
|
+
this.doc = tr.doc;
|
142
|
+
}
|
185
143
|
};
|
144
|
+
/**
|
145
|
+
* Define an extension that can record the changes in the editor.
|
146
|
+
*/
|
186
147
|
function defineCommitRecorder(commitRecorder) {
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
})
|
200
|
-
);
|
148
|
+
const key = new PluginKey("prosekit-commit-recorder");
|
149
|
+
return definePlugin(new ProseMirrorPlugin({
|
150
|
+
key,
|
151
|
+
state: {
|
152
|
+
init: (_, state) => {
|
153
|
+
commitRecorder.init(state.doc);
|
154
|
+
},
|
155
|
+
apply: (tr) => {
|
156
|
+
commitRecorder.apply(tr);
|
157
|
+
}
|
158
|
+
}
|
159
|
+
}));
|
201
160
|
}
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
defineCommitViewer
|
206
|
-
};
|
161
|
+
|
162
|
+
//#endregion
|
163
|
+
export { CommitRecorder, defineCommitRecorder, defineCommitViewer };
|
@@ -1,2 +1,19 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import { Extension } from "@prosekit/core";
|
2
|
+
import { Attrs } from "@prosekit/pm/model";
|
3
|
+
|
4
|
+
//#region src/doc/index.d.ts
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @internal
|
8
|
+
*/
|
9
|
+
type DocExtension = Extension<{
|
10
|
+
Nodes: {
|
11
|
+
doc: Attrs;
|
12
|
+
};
|
13
|
+
}>;
|
14
|
+
/**
|
15
|
+
* @public
|
16
|
+
*/
|
17
|
+
declare function defineDoc(): DocExtension;
|
18
|
+
//#endregion
|
19
|
+
export { DocExtension, defineDoc };
|
@@ -1,14 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import { defineNodeSpec } from "@prosekit/core";
|
2
|
+
|
3
|
+
//#region src/doc/index.ts
|
4
|
+
/**
|
5
|
+
* @public
|
6
|
+
*/
|
5
7
|
function defineDoc() {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
return defineNodeSpec({
|
9
|
+
name: "doc",
|
10
|
+
content: "block+",
|
11
|
+
topNode: true
|
12
|
+
});
|
11
13
|
}
|
12
|
-
|
13
|
-
|
14
|
-
};
|
14
|
+
|
15
|
+
//#endregion
|
16
|
+
export { defineDoc };
|
@@ -1,3 +1,35 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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;
|
34
|
+
//#endregion
|
35
|
+
export { DropCursorExtension, DropCursorOptions, defineDropCursor };
|
@@ -1,11 +1,17 @@
|
|
1
|
-
|
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
|
-
|
13
|
+
return definePlugin(() => dropCursor(options));
|
8
14
|
}
|
9
|
-
|
10
|
-
|
11
|
-
};
|
15
|
+
|
16
|
+
//#endregion
|
17
|
+
export { defineDropCursor };
|
@@ -1,5 +1,105 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
+
/**
|
8
|
+
* @public
|
9
|
+
*/
|
10
|
+
type EnterRuleHandler = (options: {
|
11
|
+
/**
|
12
|
+
* The current editor state.
|
13
|
+
*/
|
14
|
+
state: EditorState;
|
15
|
+
/**
|
16
|
+
* The start position of the matched text.
|
17
|
+
*/
|
18
|
+
from: number;
|
19
|
+
/**
|
20
|
+
* The end position of the matched text.
|
21
|
+
*/
|
22
|
+
to: number;
|
23
|
+
/**
|
24
|
+
* The matched result from the regular expression.
|
25
|
+
*/
|
26
|
+
match: RegExpExecArray;
|
27
|
+
}) => Transaction | null;
|
28
|
+
/**
|
29
|
+
* Options for {@link defineEnterRule}.
|
30
|
+
*
|
31
|
+
* @public
|
32
|
+
*/
|
33
|
+
type EnterRuleOptions = {
|
34
|
+
/**
|
35
|
+
* The regular expression to match against. It should end with `$`.
|
36
|
+
*/
|
37
|
+
regex: RegExp;
|
38
|
+
/**
|
39
|
+
* A function to be called when an enter rule is triggered.
|
40
|
+
*/
|
41
|
+
handler: EnterRuleHandler;
|
42
|
+
/**
|
43
|
+
* Whether to stop further handlers from being called if this rule is triggered.
|
44
|
+
*
|
45
|
+
* @default false
|
46
|
+
*/
|
47
|
+
stop?: boolean;
|
48
|
+
};
|
49
|
+
/**
|
50
|
+
* Options for {@link defineTextBlockEnterRule}.
|
51
|
+
*
|
52
|
+
* @public
|
53
|
+
*/
|
54
|
+
type TextBlockEnterRuleOptions = {
|
55
|
+
/**
|
56
|
+
* The regular expression to match against. It should end with `$`.
|
57
|
+
*/
|
58
|
+
regex: RegExp;
|
59
|
+
/**
|
60
|
+
* The node type to replace the matched text with.
|
61
|
+
*/
|
62
|
+
type: string | NodeType;
|
63
|
+
/**
|
64
|
+
* Attributes to set on the node. If a function is provided, it will be called
|
65
|
+
* with the matched result from the regular expression.
|
66
|
+
*/
|
67
|
+
attrs?: Attrs | null | ((match: RegExpMatchArray) => Attrs | null);
|
68
|
+
/**
|
69
|
+
* Whether to stop further handlers from being called if this rule is triggered.
|
70
|
+
*
|
71
|
+
* @default true
|
72
|
+
*/
|
73
|
+
stop?: boolean;
|
74
|
+
};
|
75
|
+
/**
|
76
|
+
* Defines an enter rule. An enter rule applies when the text directly in front of
|
77
|
+
* the cursor matches `regex` and user presses Enter. The `regex` should end
|
78
|
+
* with `$`.
|
79
|
+
*
|
80
|
+
* @param options
|
81
|
+
*
|
82
|
+
* @public
|
83
|
+
*/
|
84
|
+
declare function defineEnterRule({
|
85
|
+
regex,
|
86
|
+
handler,
|
87
|
+
stop
|
88
|
+
}: EnterRuleOptions): PlainExtension;
|
89
|
+
/**
|
90
|
+
* Defines an enter rule that replaces the matched text with a block node.
|
91
|
+
*
|
92
|
+
* See also {@link defineEnterRule}.
|
93
|
+
*
|
94
|
+
* @param options
|
95
|
+
*
|
96
|
+
* @public
|
97
|
+
*/
|
98
|
+
declare function defineTextBlockEnterRule({
|
99
|
+
regex,
|
100
|
+
type,
|
101
|
+
attrs,
|
102
|
+
stop
|
103
|
+
}: TextBlockEnterRuleOptions): PlainExtension;
|
104
|
+
//#endregion
|
105
|
+
export { EnterRuleHandler, EnterRuleOptions, TextBlockEnterRuleOptions, defineEnterRule, defineTextBlockEnterRule };
|
@@ -1,8 +1,3 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
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 };
|