@prosekit/extensions 0.11.1 → 0.11.3
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/{drop-indicator-QKkPzJIx.js → drop-indicator-B8P652g2.js} +13 -2
- package/dist/paste-rule-Cca3n5TA.js +173 -0
- package/dist/prosekit-extensions-autocomplete.d.ts +47 -47
- package/dist/prosekit-extensions-blockquote.d.ts +11 -11
- package/dist/prosekit-extensions-bold.d.ts +16 -16
- package/dist/prosekit-extensions-code-block.d.ts +82 -82
- package/dist/prosekit-extensions-code.d.ts +16 -16
- package/dist/prosekit-extensions-commit.d.ts +20 -20
- package/dist/prosekit-extensions-doc.d.ts +4 -4
- package/dist/prosekit-extensions-drop-cursor.d.ts +20 -20
- package/dist/prosekit-extensions-drop-indicator.d.ts +68 -68
- package/dist/prosekit-extensions-drop-indicator.js +1 -1
- package/dist/prosekit-extensions-enter-rule.d.ts +57 -57
- package/dist/prosekit-extensions-file.d.ts +54 -54
- package/dist/prosekit-extensions-gap-cursor.d.ts +15 -15
- package/dist/prosekit-extensions-hard-break.d.ts +16 -16
- package/dist/prosekit-extensions-heading.d.ts +19 -19
- package/dist/prosekit-extensions-horizontal-rule.d.ts +6 -6
- package/dist/prosekit-extensions-image.d.ts +14 -14
- package/dist/prosekit-extensions-input-rule.d.ts +70 -70
- package/dist/prosekit-extensions-italic.d.ts +16 -16
- package/dist/prosekit-extensions-link.d.ts +34 -26
- package/dist/prosekit-extensions-link.js +19 -2
- package/dist/prosekit-extensions-list.d.ts +38 -38
- package/dist/prosekit-extensions-list.js +1 -1
- package/dist/prosekit-extensions-loro.d.ts +19 -19
- package/dist/prosekit-extensions-mark-rule.d.ts +17 -17
- package/dist/prosekit-extensions-mention.d.ts +10 -10
- package/dist/prosekit-extensions-mod-click-prevention.d.ts +7 -7
- package/dist/prosekit-extensions-paragraph.d.ts +23 -23
- package/dist/prosekit-extensions-paste-rule.d.ts +93 -0
- package/dist/prosekit-extensions-paste-rule.js +3 -0
- package/dist/prosekit-extensions-placeholder.d.ts +20 -20
- package/dist/prosekit-extensions-placeholder.js +1 -1
- package/dist/prosekit-extensions-readonly.d.ts +2 -2
- package/dist/prosekit-extensions-search.d.ts +36 -36
- package/dist/prosekit-extensions-strike.d.ts +16 -16
- package/dist/prosekit-extensions-table.d.ts +134 -134
- package/dist/prosekit-extensions-table.js +1 -1
- package/dist/prosekit-extensions-text-align.d.ts +29 -29
- package/dist/prosekit-extensions-text.d.ts +4 -4
- package/dist/prosekit-extensions-underline.d.ts +14 -14
- package/dist/prosekit-extensions-virtual-selection.d.ts +11 -11
- package/dist/prosekit-extensions-yjs.d.ts +27 -27
- package/dist/{shiki-highlighter-chunk-NV2F_Qjl.d.ts → shiki-highlighter-chunk-DSPM0T27.d.ts} +1 -1
- package/dist/shiki-highlighter-chunk.d.ts +1 -1
- package/package.json +16 -8
- /package/dist/{table-3rDWFyBH.js → table-C_qAMj5-.js} +0 -0
|
@@ -52,7 +52,7 @@ function buildGetTarget(view, onDrag) {
|
|
|
52
52
|
prevTargets = getTargetsByView(view);
|
|
53
53
|
return prevTargets;
|
|
54
54
|
};
|
|
55
|
-
const
|
|
55
|
+
const getTargetImpl = (point, event) => {
|
|
56
56
|
if (!view.editable || view.isDestroyed) return;
|
|
57
57
|
const compare = (p1, p2) => {
|
|
58
58
|
const [pos1, line1] = p1;
|
|
@@ -71,7 +71,18 @@ function buildGetTarget(view, onDrag) {
|
|
|
71
71
|
if (target && isDraggingToItself(view, target[0])) return void 0;
|
|
72
72
|
return target;
|
|
73
73
|
};
|
|
74
|
-
|
|
74
|
+
let prevPoint;
|
|
75
|
+
let prevTarget;
|
|
76
|
+
const getTargetCached = (point, event) => {
|
|
77
|
+
if (prevPoint && pointEqual(prevPoint, point)) return prevTarget;
|
|
78
|
+
prevPoint = point;
|
|
79
|
+
prevTarget = getTargetImpl(point, event);
|
|
80
|
+
return prevTarget;
|
|
81
|
+
};
|
|
82
|
+
return getTargetCached;
|
|
83
|
+
}
|
|
84
|
+
function pointEqual(a, b) {
|
|
85
|
+
return a[0] === b[0] && a[1] === b[1];
|
|
75
86
|
}
|
|
76
87
|
function pointPointDistance(a, b) {
|
|
77
88
|
return Math.abs(a[0] - b[0]) + Math.abs(a[1] - b[1]);
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { defineFacet, defineFacetPayload, getMarkType, pluginFacet } from "@prosekit/core";
|
|
2
|
+
import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state";
|
|
3
|
+
import { Fragment, Slice } from "@prosekit/pm/model";
|
|
4
|
+
|
|
5
|
+
//#region src/paste-rule/paste-rule-plugin.ts
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
const pasteRuleFacet = defineFacet({
|
|
10
|
+
reduce: () => {
|
|
11
|
+
let handlers = [];
|
|
12
|
+
let isPlainText = false;
|
|
13
|
+
const transformPasted = (slice, view) => {
|
|
14
|
+
for (const handler of handlers) slice = handler({
|
|
15
|
+
slice,
|
|
16
|
+
view,
|
|
17
|
+
plain: isPlainText
|
|
18
|
+
});
|
|
19
|
+
return slice;
|
|
20
|
+
};
|
|
21
|
+
const plugin = new ProseMirrorPlugin({
|
|
22
|
+
key: new PluginKey("prosekit-paste-rule"),
|
|
23
|
+
props: {
|
|
24
|
+
transformPasted,
|
|
25
|
+
transformPastedText: (text, plain) => {
|
|
26
|
+
isPlainText = plain;
|
|
27
|
+
return text;
|
|
28
|
+
},
|
|
29
|
+
transformPastedHTML(html) {
|
|
30
|
+
isPlainText = false;
|
|
31
|
+
return html;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return (inputs) => {
|
|
36
|
+
handlers = [...inputs].reverse();
|
|
37
|
+
return plugin;
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
singleton: true,
|
|
41
|
+
parent: pluginFacet
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
function definePasteRulePlugin(payload) {
|
|
47
|
+
return defineFacetPayload(pasteRuleFacet, [payload]);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/paste-rule/paste-rule.ts
|
|
52
|
+
/**
|
|
53
|
+
* Defines a paste rule. This rule allows you to modify pasted or dragged
|
|
54
|
+
* content before it is inserted into the document.
|
|
55
|
+
*
|
|
56
|
+
* @param options
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
function definePasteRule({ handler }) {
|
|
61
|
+
return definePasteRulePlugin(handler);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/paste-rule/split-text-by-regex.ts
|
|
66
|
+
/**
|
|
67
|
+
* Splits text into chunks based on regex matches, preserving both matched and unmatched segments.
|
|
68
|
+
* Returns an array of tuples where each tuple contains a text segment and either the match data
|
|
69
|
+
* (for matched segments) or undefined (for unmatched segments).
|
|
70
|
+
*/
|
|
71
|
+
function splitTextByRegex(text, regex) {
|
|
72
|
+
regex.lastIndex = 0;
|
|
73
|
+
const chunks = [];
|
|
74
|
+
let lastIndex = 0;
|
|
75
|
+
let match;
|
|
76
|
+
let matched = false;
|
|
77
|
+
while (match = regex.exec(text)) {
|
|
78
|
+
const start = match.index;
|
|
79
|
+
const end = regex.lastIndex;
|
|
80
|
+
if (start > lastIndex) chunks.push([text.slice(lastIndex, start), void 0]);
|
|
81
|
+
chunks.push([text.slice(start, end), match]);
|
|
82
|
+
matched = true;
|
|
83
|
+
if (lastIndex === end) return;
|
|
84
|
+
lastIndex = end;
|
|
85
|
+
}
|
|
86
|
+
if (matched && lastIndex < text.length) chunks.push([text.slice(lastIndex), void 0]);
|
|
87
|
+
regex.lastIndex = 0;
|
|
88
|
+
return matched ? chunks : void 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/paste-rule/mark-paste-rule.ts
|
|
93
|
+
/**
|
|
94
|
+
* Defines a paste rule that applies marks based on regex patterns.
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
function defineMarkPasteRule(options) {
|
|
99
|
+
return definePasteRule({ handler: ({ slice, view, plain }) => {
|
|
100
|
+
if (plain) return slice;
|
|
101
|
+
const markType = getMarkType(view.state.schema, options.type);
|
|
102
|
+
return replaceMarkInSlice({
|
|
103
|
+
markType,
|
|
104
|
+
regex: options.regex,
|
|
105
|
+
getAttrs: options.getAttrs,
|
|
106
|
+
shouldSkip: options.shouldSkip
|
|
107
|
+
}, slice);
|
|
108
|
+
} });
|
|
109
|
+
}
|
|
110
|
+
function replaceMarkInSlice(options, slice) {
|
|
111
|
+
const newFragment = replaceMarkInFragment(options, slice.content);
|
|
112
|
+
if (!newFragment) return slice;
|
|
113
|
+
return new Slice(newFragment, slice.openStart, slice.openEnd);
|
|
114
|
+
}
|
|
115
|
+
function replaceMarkInFragment(options, fragment) {
|
|
116
|
+
let changed = false;
|
|
117
|
+
let children = [];
|
|
118
|
+
for (const child of fragment.content) {
|
|
119
|
+
const newChild = replaceMarkInNode(options, child);
|
|
120
|
+
if (newChild) changed = true;
|
|
121
|
+
children.push(newChild || child);
|
|
122
|
+
}
|
|
123
|
+
if (changed) return Fragment.from(children);
|
|
124
|
+
}
|
|
125
|
+
function replaceMarkInNode(options, node) {
|
|
126
|
+
if (node.type.spec.code) return;
|
|
127
|
+
if (node.type.isInline) return;
|
|
128
|
+
if (node.type.isTextblock) return replaceMarkInTextblockNode(options, node);
|
|
129
|
+
const newChildren = replaceMarkInFragment(options, node.content);
|
|
130
|
+
if (!newChildren) return;
|
|
131
|
+
return node.copy(newChildren);
|
|
132
|
+
}
|
|
133
|
+
function replaceMarkInTextblockNode(options, node) {
|
|
134
|
+
const newChildren = [];
|
|
135
|
+
let changed = false;
|
|
136
|
+
for (const inlineNode of node.content.content) {
|
|
137
|
+
const newInlineNodes = replaceMarkInInlineNode(options, inlineNode);
|
|
138
|
+
if (newInlineNodes) {
|
|
139
|
+
changed = true;
|
|
140
|
+
newChildren.push(...newInlineNodes);
|
|
141
|
+
} else newChildren.push(inlineNode);
|
|
142
|
+
}
|
|
143
|
+
if (changed) return node.copy(Fragment.from(newChildren));
|
|
144
|
+
}
|
|
145
|
+
function replaceMarkInInlineNode(options, node) {
|
|
146
|
+
const text = node.text;
|
|
147
|
+
if (!text) return;
|
|
148
|
+
const { markType, shouldSkip } = options;
|
|
149
|
+
if (shouldSkip) {
|
|
150
|
+
if (shouldSkip(node)) return;
|
|
151
|
+
} else {
|
|
152
|
+
if (node.marks.some((mark) => mark.type === markType)) return;
|
|
153
|
+
if (node.marks.some((mark) => mark.type.spec.code)) return;
|
|
154
|
+
}
|
|
155
|
+
const chunks = splitTextByRegex(text, options.regex);
|
|
156
|
+
if (!chunks) return;
|
|
157
|
+
const schema = node.type.schema;
|
|
158
|
+
const nodes = [];
|
|
159
|
+
for (const [text$1, match] of chunks) {
|
|
160
|
+
if (!text$1) continue;
|
|
161
|
+
if (match) {
|
|
162
|
+
const attrs = options.getAttrs?.(match) ?? null;
|
|
163
|
+
if (attrs !== false) {
|
|
164
|
+
const mark = markType.create(attrs);
|
|
165
|
+
nodes.push(schema.text(text$1, [...node.marks, mark]));
|
|
166
|
+
} else nodes.push(schema.text(text$1, node.marks));
|
|
167
|
+
} else nodes.push(schema.text(text$1, node.marks));
|
|
168
|
+
}
|
|
169
|
+
return nodes;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
export { defineMarkPasteRule, definePasteRule };
|
|
@@ -3,88 +3,88 @@ import { EditorState } from "@prosekit/pm/state";
|
|
|
3
3
|
|
|
4
4
|
//#region src/autocomplete/autocomplete-rule.d.ts
|
|
5
5
|
/**
|
|
6
|
-
* Options for the {@link MatchHandler} callback.
|
|
7
|
-
*/
|
|
6
|
+
* Options for the {@link MatchHandler} callback.
|
|
7
|
+
*/
|
|
8
8
|
interface MatchHandlerOptions {
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
* The editor state.
|
|
11
|
+
*/
|
|
12
12
|
state: EditorState;
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
* The result of `RegExp.exec`.
|
|
15
|
+
*/
|
|
16
16
|
match: RegExpExecArray;
|
|
17
17
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
* The start position of the matched text.
|
|
19
|
+
*/
|
|
20
20
|
from: number;
|
|
21
21
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
* The end position of the matched text.
|
|
23
|
+
*/
|
|
24
24
|
to: number;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
* Call this function to ignore the match. You probably want to call this
|
|
27
|
+
* function when the user presses the `Escape` key.
|
|
28
|
+
*/
|
|
29
29
|
ignoreMatch: () => void;
|
|
30
30
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
* Call this function to delete the matched text. For example, in a slash
|
|
32
|
+
* menu, you might want to delete the matched text first then do something
|
|
33
|
+
* else when the user presses the `Enter` key.
|
|
34
|
+
*/
|
|
35
35
|
deleteMatch: () => void;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* A callback that is called when the rule starts to match, and also on
|
|
39
|
-
* subsequent updates while the rule continues to match.
|
|
40
|
-
*/
|
|
38
|
+
* A callback that is called when the rule starts to match, and also on
|
|
39
|
+
* subsequent updates while the rule continues to match.
|
|
40
|
+
*/
|
|
41
41
|
type MatchHandler = (options: MatchHandlerOptions) => void;
|
|
42
42
|
/**
|
|
43
|
-
* Options for the {@link CanMatchPredicate} callback.
|
|
44
|
-
*/
|
|
43
|
+
* Options for the {@link CanMatchPredicate} callback.
|
|
44
|
+
*/
|
|
45
45
|
interface CanMatchOptions {
|
|
46
46
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
* The editor state.
|
|
48
|
+
*/
|
|
49
49
|
state: EditorState;
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
|
-
* A predicate to determine if the rule can be applied in the current editor state.
|
|
53
|
-
*/
|
|
52
|
+
* A predicate to determine if the rule can be applied in the current editor state.
|
|
53
|
+
*/
|
|
54
54
|
type CanMatchPredicate = (options: CanMatchOptions) => boolean;
|
|
55
55
|
/**
|
|
56
|
-
* Options for creating an {@link AutocompleteRule}
|
|
57
|
-
*/
|
|
56
|
+
* Options for creating an {@link AutocompleteRule}
|
|
57
|
+
*/
|
|
58
58
|
interface AutocompleteRuleOptions {
|
|
59
59
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
* The regular expression to match against the text before the cursor. The
|
|
61
|
+
* last match before the cursor is used.
|
|
62
|
+
*
|
|
63
|
+
* For a slash menu, you might use `/(?<!\S)\/(|\S.*)$/u`.
|
|
64
|
+
* For a mention, you might use `/@\w*$/`
|
|
65
|
+
*/
|
|
66
66
|
regex: RegExp;
|
|
67
67
|
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
* A callback that is called when the rule starts to match, and also on
|
|
69
|
+
* subsequent updates while the rule continues to match.
|
|
70
|
+
*/
|
|
71
71
|
onEnter: MatchHandler;
|
|
72
72
|
/**
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
* A callback that is called when the rule stops matching.
|
|
74
|
+
*/
|
|
75
75
|
onLeave?: VoidFunction;
|
|
76
76
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
* A predicate to determine if the rule can be applied in the current editor
|
|
78
|
+
* state. If not provided, it defaults to only allowing matches in empty
|
|
79
|
+
* selections that are not inside a code block or code mark.
|
|
80
|
+
*/
|
|
81
81
|
canMatch?: CanMatchPredicate;
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
* An autocomplete rule that can be used to create an autocomplete extension.
|
|
85
|
-
*
|
|
86
|
-
* @public
|
|
87
|
-
*/
|
|
84
|
+
* An autocomplete rule that can be used to create an autocomplete extension.
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
88
|
declare class AutocompleteRule {
|
|
89
89
|
/** @internal */
|
|
90
90
|
readonly regex: RegExp;
|
|
@@ -10,8 +10,8 @@ type BlockquoteCommandsExtension = Extension<{
|
|
|
10
10
|
};
|
|
11
11
|
}>;
|
|
12
12
|
/**
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
15
|
declare function defineBlockquoteCommands(): BlockquoteCommandsExtension;
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region src/blockquote/blockquote-spec.d.ts
|
|
@@ -24,25 +24,25 @@ declare function defineBlockquoteSpec(): BlockquoteSpecExtension;
|
|
|
24
24
|
//#endregion
|
|
25
25
|
//#region src/blockquote/blockquote.d.ts
|
|
26
26
|
/**
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
29
|
type BlockquoteExtension = Union<[BlockquoteSpecExtension, BlockquoteCommandsExtension]>;
|
|
30
30
|
/**
|
|
31
|
-
* @public
|
|
32
|
-
*/
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
33
|
declare function defineBlockquote(): BlockquoteExtension;
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region src/blockquote/blockquote-input-rule.d.ts
|
|
36
36
|
/**
|
|
37
|
-
* Wraps the text block in a blockquote when `>` is typed at the start of a new
|
|
38
|
-
* line followed by a space.
|
|
39
|
-
*/
|
|
37
|
+
* Wraps the text block in a blockquote when `>` is typed at the start of a new
|
|
38
|
+
* line followed by a space.
|
|
39
|
+
*/
|
|
40
40
|
declare function defineBlockquoteInputRule(): PlainExtension;
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region src/blockquote/blockquote-keymap.d.ts
|
|
43
43
|
/**
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
46
|
declare function defineBlockquoteKeymap(): PlainExtension;
|
|
47
47
|
//#endregion
|
|
48
48
|
export { type BlockquoteCommandsExtension, type BlockquoteExtension, type BlockquoteSpecExtension, defineBlockquote, defineBlockquoteCommands, defineBlockquoteInputRule, defineBlockquoteKeymap, defineBlockquoteSpec };
|
|
@@ -3,52 +3,52 @@ import { Attrs } from "@prosekit/pm/model";
|
|
|
3
3
|
|
|
4
4
|
//#region src/bold/bold-commands.d.ts
|
|
5
5
|
/**
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
8
|
type BoldCommandsExtension = Extension<{
|
|
9
9
|
Commands: {
|
|
10
10
|
toggleBold: [];
|
|
11
11
|
};
|
|
12
12
|
}>;
|
|
13
13
|
/**
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
16
|
declare function defineBoldCommands(): BoldCommandsExtension;
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/bold/bold-spec.d.ts
|
|
19
19
|
/**
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
22
|
type BoldSpecExtension = Extension<{
|
|
23
23
|
Marks: {
|
|
24
24
|
bold: Attrs;
|
|
25
25
|
};
|
|
26
26
|
}>;
|
|
27
27
|
/**
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
30
|
declare function defineBoldSpec(): BoldSpecExtension;
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region src/bold/bold.d.ts
|
|
33
33
|
/**
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
36
|
type BoldExtension = Union<[BoldSpecExtension, BoldCommandsExtension]>;
|
|
37
37
|
/**
|
|
38
|
-
* @public
|
|
39
|
-
*/
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
40
|
declare function defineBold(): BoldExtension;
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region src/bold/bold-input-rule.d.ts
|
|
43
43
|
/**
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
46
|
declare function defineBoldInputRule(): PlainExtension;
|
|
47
47
|
//#endregion
|
|
48
48
|
//#region src/bold/bold-keymap.d.ts
|
|
49
49
|
/**
|
|
50
|
-
* @internal
|
|
51
|
-
*/
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
52
|
declare function defineBoldKeymap(): PlainExtension;
|
|
53
53
|
//#endregion
|
|
54
54
|
export { type BoldCommandsExtension, type BoldExtension, type BoldSpecExtension, defineBold, defineBoldCommands, defineBoldInputRule, defineBoldKeymap, defineBoldSpec };
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { ShikiHighlighterOptions } from "./shiki-highlighter-chunk-
|
|
1
|
+
import { ShikiHighlighterOptions } from "./shiki-highlighter-chunk-DSPM0T27.js";
|
|
2
2
|
import { Extension, PlainExtension, Union } from "@prosekit/core";
|
|
3
3
|
import { Parser } from "prosemirror-highlight";
|
|
4
4
|
import { BundledLanguage as ShikiBundledLanguage, BundledLanguageInfo as ShikiBundledLanguageInfo, BundledTheme as ShikiBundledTheme, BundledThemeInfo as ShikiBundledThemeInfo, SpecialLanguage, bundledLanguagesInfo as shikiBundledLanguagesInfo, bundledThemesInfo as shikiBundledThemesInfo } from "shiki";
|
|
5
5
|
|
|
6
6
|
//#region src/code-block/code-block-types.d.ts
|
|
7
7
|
/**
|
|
8
|
-
* The attributes for the `codeBlock` node.
|
|
9
|
-
*
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
8
|
+
* The attributes for the `codeBlock` node.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
12
|
interface CodeBlockAttrs {
|
|
13
13
|
language: string;
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/code-block/code-block-commands.d.ts
|
|
17
17
|
/**
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
20
|
type CodeBlockCommandsExtension = Extension<{
|
|
21
21
|
Commands: {
|
|
22
22
|
setCodeBlock: [attrs?: CodeBlockAttrs];
|
|
@@ -26,130 +26,130 @@ type CodeBlockCommandsExtension = Extension<{
|
|
|
26
26
|
};
|
|
27
27
|
}>;
|
|
28
28
|
/**
|
|
29
|
-
* Adds commands for working with `codeBlock` nodes.
|
|
30
|
-
*
|
|
31
|
-
* @public
|
|
32
|
-
*/
|
|
29
|
+
* Adds commands for working with `codeBlock` nodes.
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
33
|
declare function defineCodeBlockCommands(): CodeBlockCommandsExtension;
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region src/code-block/code-block-spec.d.ts
|
|
36
36
|
/**
|
|
37
|
-
* @internal
|
|
38
|
-
*/
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
39
|
type CodeBlockSpecExtension = Extension<{
|
|
40
40
|
Nodes: {
|
|
41
41
|
codeBlock: CodeBlockAttrs;
|
|
42
42
|
};
|
|
43
43
|
}>;
|
|
44
44
|
/**
|
|
45
|
-
* Defines the `codeBlock` node spec.
|
|
46
|
-
*
|
|
47
|
-
* @public
|
|
48
|
-
*/
|
|
45
|
+
* Defines the `codeBlock` node spec.
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
49
|
declare function defineCodeBlockSpec(): CodeBlockSpecExtension;
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region src/code-block/code-block.d.ts
|
|
52
52
|
/**
|
|
53
|
-
* @internal
|
|
54
|
-
*/
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
55
|
type CodeBlockExtension = Union<[CodeBlockSpecExtension, CodeBlockCommandsExtension]>;
|
|
56
56
|
/**
|
|
57
|
-
* Adds `codeBlock` nodes to the editor. This includes the following extensions:
|
|
58
|
-
*
|
|
59
|
-
* - {@link defineCodeBlockSpec}
|
|
60
|
-
* - {@link defineCodeBlockInputRule}
|
|
61
|
-
* - {@link defineCodeBlockEnterRule}
|
|
62
|
-
* - {@link defineCodeBlockKeymap}
|
|
63
|
-
* - {@link defineCodeBlockCommands}.
|
|
64
|
-
*
|
|
65
|
-
* @public
|
|
66
|
-
*/
|
|
57
|
+
* Adds `codeBlock` nodes to the editor. This includes the following extensions:
|
|
58
|
+
*
|
|
59
|
+
* - {@link defineCodeBlockSpec}
|
|
60
|
+
* - {@link defineCodeBlockInputRule}
|
|
61
|
+
* - {@link defineCodeBlockEnterRule}
|
|
62
|
+
* - {@link defineCodeBlockKeymap}
|
|
63
|
+
* - {@link defineCodeBlockCommands}.
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
67
|
declare function defineCodeBlock(): CodeBlockExtension;
|
|
68
68
|
//#endregion
|
|
69
69
|
//#region src/code-block/code-block-highlight.d.ts
|
|
70
70
|
/**
|
|
71
|
-
* @public
|
|
72
|
-
*
|
|
73
|
-
* An alias for the `Parser` type from the `prosemirror-highlight` package.
|
|
74
|
-
*/
|
|
71
|
+
* @public
|
|
72
|
+
*
|
|
73
|
+
* An alias for the `Parser` type from the `prosemirror-highlight` package.
|
|
74
|
+
*/
|
|
75
75
|
type HighlightParser = Parser;
|
|
76
76
|
/**
|
|
77
|
-
* @public
|
|
78
|
-
*/
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
79
|
type CodeBlockHighlightOptions = {
|
|
80
80
|
parser: HighlightParser;
|
|
81
81
|
};
|
|
82
82
|
/**
|
|
83
|
-
* Adds syntax highlighting to code blocks. This function requires a `Parser`
|
|
84
|
-
* instance from the `prosemirror-highlight` package. See the
|
|
85
|
-
* [documentation](https://github.com/ocavue/prosemirror-highlight) for more
|
|
86
|
-
* information.
|
|
87
|
-
*
|
|
88
|
-
* @param options
|
|
89
|
-
*
|
|
90
|
-
* @public
|
|
91
|
-
*/
|
|
83
|
+
* Adds syntax highlighting to code blocks. This function requires a `Parser`
|
|
84
|
+
* instance from the `prosemirror-highlight` package. See the
|
|
85
|
+
* [documentation](https://github.com/ocavue/prosemirror-highlight) for more
|
|
86
|
+
* information.
|
|
87
|
+
*
|
|
88
|
+
* @param options
|
|
89
|
+
*
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
92
|
declare function defineCodeBlockHighlight({
|
|
93
93
|
parser
|
|
94
94
|
}: CodeBlockHighlightOptions): Extension;
|
|
95
95
|
//#endregion
|
|
96
96
|
//#region src/code-block/code-block-input-rule.d.ts
|
|
97
97
|
/**
|
|
98
|
-
* Adds input rules for `codeBlock` nodes.
|
|
99
|
-
*
|
|
100
|
-
* @public
|
|
101
|
-
*/
|
|
98
|
+
* Adds input rules for `codeBlock` nodes.
|
|
99
|
+
*
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
102
|
declare function defineCodeBlockInputRule(): PlainExtension;
|
|
103
103
|
/**
|
|
104
|
-
* Adds enter rules for `codeBlock` nodes.
|
|
105
|
-
*
|
|
106
|
-
* @public
|
|
107
|
-
*/
|
|
104
|
+
* Adds enter rules for `codeBlock` nodes.
|
|
105
|
+
*
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
108
|
declare function defineCodeBlockEnterRule(): PlainExtension;
|
|
109
109
|
//#endregion
|
|
110
110
|
//#region src/code-block/code-block-keymap.d.ts
|
|
111
111
|
/**
|
|
112
|
-
* Defines the keymap for code blocks.
|
|
113
|
-
*/
|
|
112
|
+
* Defines the keymap for code blocks.
|
|
113
|
+
*/
|
|
114
114
|
declare function defineCodeBlockKeymap(): PlainExtension;
|
|
115
115
|
//#endregion
|
|
116
116
|
//#region src/code-block/code-block-shiki.d.ts
|
|
117
117
|
/**
|
|
118
|
-
* The options to configure the Shiki highlighter.
|
|
119
|
-
*
|
|
120
|
-
* @public
|
|
121
|
-
*/
|
|
122
|
-
interface CodeBlockShikiOptions extends Omit<ShikiHighlighterOptions,
|
|
118
|
+
* The options to configure the Shiki highlighter.
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
interface CodeBlockShikiOptions extends Omit<ShikiHighlighterOptions, 'themes' | 'langs' | 'engine'> {
|
|
123
123
|
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
* A list of Shiki themes to pre-load. The first theme in the list will be
|
|
125
|
+
* used to render the code block.
|
|
126
|
+
*
|
|
127
|
+
* @default ['one-dark-pro']
|
|
128
|
+
*/
|
|
129
129
|
themes?: ShikiBundledTheme[];
|
|
130
130
|
/**
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
* A list of Shiki languages to pre-load.
|
|
132
|
+
*
|
|
133
|
+
* @default ['text']
|
|
134
|
+
*/
|
|
135
135
|
langs?: (ShikiBundledLanguage | SpecialLanguage)[];
|
|
136
136
|
/**
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
engine?: ShikiHighlighterOptions[
|
|
137
|
+
* The RegExp engine to use. By default, the JavaScript engine is used.
|
|
138
|
+
*/
|
|
139
|
+
engine?: ShikiHighlighterOptions['engine'];
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
|
-
* Adds syntax highlighting to code blocks using the [Shiki](https://github.com/shikijs/shiki) package.
|
|
143
|
-
*
|
|
144
|
-
* It will set two CSS variables on the code block elements:
|
|
145
|
-
*
|
|
146
|
-
* - `--prosemirror-highlight`: sets text color
|
|
147
|
-
* - `--prosemirror-highlight-bg`: sets background color
|
|
148
|
-
*
|
|
149
|
-
* @param options - The options to configure the Shiki highlighter.
|
|
150
|
-
*
|
|
151
|
-
* @public
|
|
152
|
-
*/
|
|
142
|
+
* Adds syntax highlighting to code blocks using the [Shiki](https://github.com/shikijs/shiki) package.
|
|
143
|
+
*
|
|
144
|
+
* It will set two CSS variables on the code block elements:
|
|
145
|
+
*
|
|
146
|
+
* - `--prosemirror-highlight`: sets text color
|
|
147
|
+
* - `--prosemirror-highlight-bg`: sets background color
|
|
148
|
+
*
|
|
149
|
+
* @param options - The options to configure the Shiki highlighter.
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
153
|
declare function defineCodeBlockShiki({
|
|
154
154
|
themes,
|
|
155
155
|
langs,
|