@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,88 +1,76 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
} from "./chunk-I2UMHK3L.js";
|
1
|
+
import { defineMarkInputRule } from "./input-rule-Gji4N7Oe.js";
|
2
|
+
import { canUseRegexLookbehind, defineCommands, defineKeymap, defineMarkSpec, toggleMark, union } from "@prosekit/core";
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
// src/bold/bold-commands.ts
|
11
|
-
import {
|
12
|
-
defineCommands,
|
13
|
-
toggleMark
|
14
|
-
} from "@prosekit/core";
|
4
|
+
//#region src/bold/bold-commands.ts
|
5
|
+
/**
|
6
|
+
* @internal
|
7
|
+
*/
|
15
8
|
function defineBoldCommands() {
|
16
|
-
|
17
|
-
toggleBold: () => toggleMark({ type: "bold" })
|
18
|
-
});
|
9
|
+
return defineCommands({ toggleBold: () => toggleMark({ type: "bold" }) });
|
19
10
|
}
|
20
11
|
|
21
|
-
|
22
|
-
|
12
|
+
//#endregion
|
13
|
+
//#region src/bold/bold-input-rule.ts
|
14
|
+
/**
|
15
|
+
* @internal
|
16
|
+
*/
|
23
17
|
function defineBoldInputRule() {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
18
|
+
return defineMarkInputRule({
|
19
|
+
regex: canUseRegexLookbehind() ? /(?<=\s|^)\*\*([^\s*]|[^\s*][^*]*[^\s*])\*\*$/ : /\*\*([^\s*]|[^\s*][^*]*[^\s*])\*\*$/,
|
20
|
+
type: "bold"
|
21
|
+
});
|
28
22
|
}
|
29
23
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
//#endregion
|
25
|
+
//#region src/bold/bold-keymap.ts
|
26
|
+
/**
|
27
|
+
* @internal
|
28
|
+
*/
|
35
29
|
function defineBoldKeymap() {
|
36
|
-
|
37
|
-
"Mod-b": toggleMark2({ type: "bold" })
|
38
|
-
});
|
30
|
+
return defineKeymap({ "Mod-b": toggleMark({ type: "bold" }) });
|
39
31
|
}
|
40
32
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
33
|
+
//#endregion
|
34
|
+
//#region src/bold/bold-spec.ts
|
35
|
+
/**
|
36
|
+
* @internal
|
37
|
+
*/
|
45
38
|
function defineBoldSpec() {
|
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
|
-
|
39
|
+
return defineMarkSpec({
|
40
|
+
name: "bold",
|
41
|
+
parseDOM: [
|
42
|
+
{ tag: "strong" },
|
43
|
+
{
|
44
|
+
tag: "b",
|
45
|
+
getAttrs: (node) => {
|
46
|
+
return typeof node !== "string" && node.style.fontWeight !== "normal" && null;
|
47
|
+
}
|
48
|
+
},
|
49
|
+
{
|
50
|
+
style: "font-weight=400",
|
51
|
+
clearMark: (m) => m.type.name == "strong"
|
52
|
+
},
|
53
|
+
{
|
54
|
+
style: "font-weight",
|
55
|
+
getAttrs: (value) => {
|
56
|
+
return typeof value === "string" && /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
],
|
60
|
+
toDOM() {
|
61
|
+
return ["strong", 0];
|
62
|
+
}
|
63
|
+
});
|
71
64
|
}
|
72
65
|
|
73
|
-
|
66
|
+
//#endregion
|
67
|
+
//#region src/bold/bold.ts
|
68
|
+
/**
|
69
|
+
* @public
|
70
|
+
*/
|
74
71
|
function defineBold() {
|
75
|
-
|
76
|
-
defineBoldSpec(),
|
77
|
-
defineBoldCommands(),
|
78
|
-
defineBoldKeymap(),
|
79
|
-
defineBoldInputRule()
|
80
|
-
);
|
72
|
+
return union(defineBoldSpec(), defineBoldCommands(), defineBoldKeymap(), defineBoldInputRule());
|
81
73
|
}
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
defineBoldInputRule,
|
86
|
-
defineBoldKeymap,
|
87
|
-
defineBoldSpec
|
88
|
-
};
|
74
|
+
|
75
|
+
//#endregion
|
76
|
+
export { defineBold, defineBoldCommands, defineBoldInputRule, defineBoldKeymap, defineBoldSpec };
|
@@ -1,20 +1,159 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
1
|
+
import { ShikiHighlighterOptions } from "./shiki-highlighter-chunk-CZGvZlhf.js";
|
2
|
+
import { Extension, PlainExtension, Union } from "@prosekit/core";
|
3
|
+
import { Parser } from "prosemirror-highlight";
|
4
|
+
import { BundledLanguage as ShikiBundledLanguage, BundledLanguageInfo as ShikiBundledLanguageInfo, BundledTheme as ShikiBundledTheme, BundledThemeInfo as ShikiBundledThemeInfo, SpecialLanguage, bundledLanguagesInfo as shikiBundledLanguagesInfo, bundledThemesInfo as shikiBundledThemesInfo } from "shiki";
|
5
|
+
|
6
|
+
//#region src/code-block/code-block-types.d.ts
|
7
|
+
/**
|
8
|
+
* The attributes for the `codeBlock` node.
|
9
|
+
*
|
10
|
+
* @public
|
11
|
+
*/
|
12
|
+
interface CodeBlockAttrs {
|
13
|
+
language: string;
|
14
|
+
}
|
15
|
+
//#endregion
|
16
|
+
//#region src/code-block/code-block-commands.d.ts
|
17
|
+
/**
|
18
|
+
* @internal
|
19
|
+
*/
|
20
|
+
type CodeBlockCommandsExtension = Extension<{
|
21
|
+
Commands: {
|
22
|
+
setCodeBlock: [attrs?: CodeBlockAttrs];
|
23
|
+
insertCodeBlock: [attrs?: CodeBlockAttrs];
|
24
|
+
toggleCodeBlock: [attrs?: CodeBlockAttrs];
|
25
|
+
setCodeBlockAttrs: [attrs: CodeBlockAttrs];
|
26
|
+
};
|
27
|
+
}>;
|
28
|
+
/**
|
29
|
+
* Adds commands for working with `codeBlock` nodes.
|
30
|
+
*
|
31
|
+
* @public
|
32
|
+
*/
|
33
|
+
declare function defineCodeBlockCommands(): CodeBlockCommandsExtension;
|
34
|
+
//#endregion
|
35
|
+
//#region src/code-block/code-block-spec.d.ts
|
36
|
+
/**
|
37
|
+
* @internal
|
38
|
+
*/
|
39
|
+
type CodeBlockSpecExtension = Extension<{
|
40
|
+
Nodes: {
|
41
|
+
codeBlock: CodeBlockAttrs;
|
42
|
+
};
|
43
|
+
}>;
|
44
|
+
/**
|
45
|
+
* Defines the `codeBlock` node spec.
|
46
|
+
*
|
47
|
+
* @public
|
48
|
+
*/
|
49
|
+
declare function defineCodeBlockSpec(): CodeBlockSpecExtension;
|
50
|
+
//#endregion
|
51
|
+
//#region src/code-block/code-block.d.ts
|
52
|
+
/**
|
53
|
+
* @internal
|
54
|
+
*/
|
55
|
+
type CodeBlockExtension = Union<[CodeBlockSpecExtension, CodeBlockCommandsExtension]>;
|
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
|
+
*/
|
67
|
+
declare function defineCodeBlock(): CodeBlockExtension;
|
68
|
+
//#endregion
|
69
|
+
//#region src/code-block/code-block-highlight.d.ts
|
70
|
+
/**
|
71
|
+
* @public
|
72
|
+
*
|
73
|
+
* An alias for the `Parser` type from the `prosemirror-highlight` package.
|
74
|
+
*/
|
75
|
+
type HighlightParser = Parser;
|
76
|
+
/**
|
77
|
+
* @public
|
78
|
+
*/
|
79
|
+
type CodeBlockHighlightOptions = {
|
80
|
+
parser: HighlightParser;
|
81
|
+
};
|
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
|
+
*/
|
92
|
+
declare function defineCodeBlockHighlight({
|
93
|
+
parser
|
94
|
+
}: CodeBlockHighlightOptions): Extension;
|
95
|
+
//#endregion
|
96
|
+
//#region src/code-block/code-block-input-rule.d.ts
|
97
|
+
/**
|
98
|
+
* Adds input rules for `codeBlock` nodes.
|
99
|
+
*
|
100
|
+
* @public
|
101
|
+
*/
|
102
|
+
declare function defineCodeBlockInputRule(): PlainExtension;
|
103
|
+
/**
|
104
|
+
* Adds enter rules for `codeBlock` nodes.
|
105
|
+
*
|
106
|
+
* @public
|
107
|
+
*/
|
108
|
+
declare function defineCodeBlockEnterRule(): PlainExtension;
|
109
|
+
//#endregion
|
110
|
+
//#region src/code-block/code-block-keymap.d.ts
|
111
|
+
/**
|
112
|
+
* Defines the keymap for code blocks.
|
113
|
+
*/
|
114
|
+
declare function defineCodeBlockKeymap(): PlainExtension;
|
115
|
+
//#endregion
|
116
|
+
//#region src/code-block/code-block-shiki.d.ts
|
117
|
+
/**
|
118
|
+
* The options to configure the Shiki highlighter.
|
119
|
+
*
|
120
|
+
* @public
|
121
|
+
*/
|
122
|
+
interface CodeBlockShikiOptions extends Omit<ShikiHighlighterOptions, "themes" | "langs" | "engine"> {
|
123
|
+
/**
|
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
|
+
themes?: ShikiBundledTheme[];
|
130
|
+
/**
|
131
|
+
* A list of Shiki languages to pre-load.
|
132
|
+
*
|
133
|
+
* @default ['text']
|
134
|
+
*/
|
135
|
+
langs?: (ShikiBundledLanguage | SpecialLanguage)[];
|
136
|
+
/**
|
137
|
+
* The RegExp engine to use. By default, the JavaScript engine is used.
|
138
|
+
*/
|
139
|
+
engine?: ShikiHighlighterOptions["engine"];
|
140
|
+
}
|
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
|
+
*/
|
153
|
+
declare function defineCodeBlockShiki({
|
154
|
+
themes,
|
155
|
+
langs,
|
156
|
+
...rest
|
157
|
+
}?: CodeBlockShikiOptions): Extension;
|
158
|
+
//#endregion
|
159
|
+
export { CodeBlockAttrs, CodeBlockCommandsExtension, CodeBlockExtension, CodeBlockHighlightOptions, CodeBlockSpecExtension, HighlightParser, ShikiBundledLanguage, ShikiBundledLanguageInfo, ShikiBundledTheme, ShikiBundledThemeInfo, defineCodeBlock, defineCodeBlockCommands, defineCodeBlockEnterRule, defineCodeBlockHighlight, defineCodeBlockInputRule, defineCodeBlockKeymap, defineCodeBlockShiki, defineCodeBlockSpec, shikiBundledLanguagesInfo, shikiBundledThemesInfo };
|