@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,8 +1,71 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
import { Extension, PlainExtension, Union } from "@prosekit/core";
|
2
|
+
import { Command } from "@prosekit/pm/state";
|
3
|
+
|
4
|
+
//#region src/text-align/index.d.ts
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @public
|
8
|
+
*/
|
9
|
+
interface TextAlignOptions<NodeName extends string = string> {
|
10
|
+
/**
|
11
|
+
* The names of node to add the attribute to.
|
12
|
+
*
|
13
|
+
* @example
|
14
|
+
*
|
15
|
+
* ["paragraph", "heading"]
|
16
|
+
*/
|
17
|
+
types: NodeName[];
|
18
|
+
/**
|
19
|
+
* The default value for the attribute.
|
20
|
+
*
|
21
|
+
* @default "left"
|
22
|
+
*/
|
23
|
+
default?: string;
|
24
|
+
}
|
25
|
+
/**
|
26
|
+
* @internal
|
27
|
+
*/
|
28
|
+
type TextAlignAttrsExtension<NodeName extends string> = Extension<{
|
29
|
+
Nodes: { [K in NodeName]: {
|
30
|
+
textAlign: string | null;
|
31
|
+
} };
|
32
|
+
}>;
|
33
|
+
/**
|
34
|
+
* @internal
|
35
|
+
*/
|
36
|
+
declare function setTextAlign({
|
37
|
+
types,
|
38
|
+
value
|
39
|
+
}: {
|
40
|
+
types: string[];
|
41
|
+
value: string | null;
|
42
|
+
}): Command;
|
43
|
+
/**
|
44
|
+
* @internal
|
45
|
+
*/
|
46
|
+
type TextAlignCommandsExtension = Extension<{
|
47
|
+
Commands: {
|
48
|
+
setTextAlign: [value: string | null];
|
49
|
+
};
|
50
|
+
}>;
|
51
|
+
/**
|
52
|
+
* @internal
|
53
|
+
*/
|
54
|
+
declare function defineTextAlignCommands(types: string[]): TextAlignCommandsExtension;
|
55
|
+
/**
|
56
|
+
* @internal
|
57
|
+
*/
|
58
|
+
declare function defineTextAlignKeymap(types: string[]): PlainExtension;
|
59
|
+
/**
|
60
|
+
* @internal
|
61
|
+
*/
|
62
|
+
type TextAlignExtension<NodeName extends string> = Union<[TextAlignAttrsExtension<NodeName>, TextAlignCommandsExtension]>;
|
63
|
+
/**
|
64
|
+
* Adds a `textAlign` attribute to the specified nodes. This will be rendered as
|
65
|
+
* a CSS `text-align` style.
|
66
|
+
*
|
67
|
+
* @public
|
68
|
+
*/
|
69
|
+
declare function defineTextAlign<NodeName extends string = string>(options: TextAlignOptions<NodeName>): TextAlignExtension<NodeName>;
|
70
|
+
//#endregion
|
71
|
+
export { TextAlignAttrsExtension, TextAlignCommandsExtension, TextAlignExtension, TextAlignOptions, defineTextAlign, defineTextAlignCommands, defineTextAlignKeymap, setTextAlign };
|
@@ -1,55 +1,74 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
defineKeymap,
|
5
|
-
defineNodeAttr,
|
6
|
-
setNodeAttrs,
|
7
|
-
union
|
8
|
-
} from "@prosekit/core";
|
1
|
+
import { defineCommands, defineKeymap, defineNodeAttr, setNodeAttrs, union } from "@prosekit/core";
|
2
|
+
|
3
|
+
//#region src/text-align/index.ts
|
9
4
|
function defineTextAlignAttr(type, defaultValue) {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
5
|
+
return defineNodeAttr({
|
6
|
+
type,
|
7
|
+
attr: "textAlign",
|
8
|
+
default: defaultValue,
|
9
|
+
splittable: true,
|
10
|
+
toDOM: (value) => value ? ["style", `text-align:${value};`] : null,
|
11
|
+
parseDOM: (node) => {
|
12
|
+
return node.style.getPropertyValue("text-align") || null;
|
13
|
+
}
|
14
|
+
});
|
20
15
|
}
|
16
|
+
/**
|
17
|
+
* @internal
|
18
|
+
*/
|
21
19
|
function defineTextAlignAttrs(types, defaultValue) {
|
22
|
-
|
20
|
+
return union(types.map((type) => defineTextAlignAttr(type, defaultValue)));
|
23
21
|
}
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}) {
|
28
|
-
|
22
|
+
/**
|
23
|
+
* @internal
|
24
|
+
*/
|
25
|
+
function setTextAlign({ types, value }) {
|
26
|
+
return setNodeAttrs({
|
27
|
+
type: types,
|
28
|
+
attrs: { textAlign: value }
|
29
|
+
});
|
29
30
|
}
|
31
|
+
/**
|
32
|
+
* @internal
|
33
|
+
*/
|
30
34
|
function defineTextAlignCommands(types) {
|
31
|
-
|
32
|
-
|
33
|
-
|
35
|
+
return defineCommands({ setTextAlign: (value) => setTextAlign({
|
36
|
+
types,
|
37
|
+
value
|
38
|
+
}) });
|
34
39
|
}
|
40
|
+
/**
|
41
|
+
* @internal
|
42
|
+
*/
|
35
43
|
function defineTextAlignKeymap(types) {
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
44
|
+
return defineKeymap({
|
45
|
+
"mod-shift-l": setTextAlign({
|
46
|
+
types,
|
47
|
+
value: "left"
|
48
|
+
}),
|
49
|
+
"mod-shift-e": setTextAlign({
|
50
|
+
types,
|
51
|
+
value: "center"
|
52
|
+
}),
|
53
|
+
"mod-shift-r": setTextAlign({
|
54
|
+
types,
|
55
|
+
value: "right"
|
56
|
+
}),
|
57
|
+
"mod-shift-j": setTextAlign({
|
58
|
+
types,
|
59
|
+
value: "justify"
|
60
|
+
})
|
61
|
+
});
|
42
62
|
}
|
63
|
+
/**
|
64
|
+
* Adds a `textAlign` attribute to the specified nodes. This will be rendered as
|
65
|
+
* a CSS `text-align` style.
|
66
|
+
*
|
67
|
+
* @public
|
68
|
+
*/
|
43
69
|
function defineTextAlign(options) {
|
44
|
-
|
45
|
-
defineTextAlignAttrs(options.types, options.default || "left"),
|
46
|
-
defineTextAlignKeymap(options.types),
|
47
|
-
defineTextAlignCommands(options.types)
|
48
|
-
);
|
70
|
+
return union(defineTextAlignAttrs(options.types, options.default || "left"), defineTextAlignKeymap(options.types), defineTextAlignCommands(options.types));
|
49
71
|
}
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
defineTextAlignKeymap,
|
54
|
-
setTextAlign
|
55
|
-
};
|
72
|
+
|
73
|
+
//#endregion
|
74
|
+
export { defineTextAlign, defineTextAlignCommands, defineTextAlignKeymap, setTextAlign };
|
@@ -1,2 +1,19 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import { Extension } from "@prosekit/core";
|
2
|
+
import { Attrs } from "@prosekit/pm/model";
|
3
|
+
|
4
|
+
//#region src/text/index.d.ts
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @internal
|
8
|
+
*/
|
9
|
+
type TextExtension = Extension<{
|
10
|
+
Nodes: {
|
11
|
+
text: Attrs;
|
12
|
+
};
|
13
|
+
}>;
|
14
|
+
/**
|
15
|
+
* @public
|
16
|
+
*/
|
17
|
+
declare function defineText(): TextExtension;
|
18
|
+
//#endregion
|
19
|
+
export { TextExtension, defineText };
|
@@ -1,13 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import { defineNodeSpec } from "@prosekit/core";
|
2
|
+
|
3
|
+
//#region src/text/index.ts
|
4
|
+
/**
|
5
|
+
* @public
|
6
|
+
*/
|
5
7
|
function defineText() {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
return defineNodeSpec({
|
9
|
+
name: "text",
|
10
|
+
group: "inline"
|
11
|
+
});
|
10
12
|
}
|
11
|
-
|
12
|
-
|
13
|
-
};
|
13
|
+
|
14
|
+
//#endregion
|
15
|
+
export { defineText };
|
@@ -1,7 +1,43 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
import { Extension, PlainExtension, Union } from "@prosekit/core";
|
2
|
+
import { Attrs } from "@prosekit/pm/model";
|
3
|
+
|
4
|
+
//#region src/underline/index.d.ts
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @internal
|
8
|
+
*/
|
9
|
+
type UnderlineSpecExtension = Extension<{
|
10
|
+
Marks: {
|
11
|
+
underline: Attrs;
|
12
|
+
};
|
13
|
+
}>;
|
14
|
+
/**
|
15
|
+
* @internal
|
16
|
+
*/
|
17
|
+
declare function defineUnderlineSpec(): UnderlineSpecExtension;
|
18
|
+
/**
|
19
|
+
* @internal
|
20
|
+
*/
|
21
|
+
type UnderlineCommandsExtension = Extension<{
|
22
|
+
Commands: {
|
23
|
+
toggleUnderline: [];
|
24
|
+
};
|
25
|
+
}>;
|
26
|
+
/**
|
27
|
+
* @internal
|
28
|
+
*/
|
29
|
+
declare function defineUnderlineCommands(): UnderlineCommandsExtension;
|
30
|
+
/**
|
31
|
+
* @internal
|
32
|
+
*/
|
33
|
+
declare function defineUnderlineKeymap(): PlainExtension;
|
34
|
+
/**
|
35
|
+
* @internal
|
36
|
+
*/
|
37
|
+
type UnderlineExtension = Union<[UnderlineSpecExtension, UnderlineCommandsExtension]>;
|
38
|
+
/**
|
39
|
+
* @public
|
40
|
+
*/
|
41
|
+
declare function defineUnderline(): UnderlineExtension;
|
42
|
+
//#endregion
|
43
|
+
export { UnderlineCommandsExtension, UnderlineExtension, UnderlineSpecExtension, defineUnderline, defineUnderlineCommands, defineUnderlineKeymap, defineUnderlineSpec };
|
@@ -1,45 +1,41 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
union
|
8
|
-
} from "@prosekit/core";
|
1
|
+
import { defineCommands, defineKeymap, defineMarkSpec, toggleMark, union } from "@prosekit/core";
|
2
|
+
|
3
|
+
//#region src/underline/index.ts
|
4
|
+
/**
|
5
|
+
* @internal
|
6
|
+
*/
|
9
7
|
function defineUnderlineSpec() {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
8
|
+
return defineMarkSpec({
|
9
|
+
name: "underline",
|
10
|
+
parseDOM: [
|
11
|
+
{ tag: "u" },
|
12
|
+
{ tag: "underline" },
|
13
|
+
{ style: "text-decoration=underline" },
|
14
|
+
{ style: "text-decoration-line=underline" }
|
15
|
+
],
|
16
|
+
toDOM() {
|
17
|
+
return ["u", 0];
|
18
|
+
}
|
19
|
+
});
|
22
20
|
}
|
21
|
+
/**
|
22
|
+
* @internal
|
23
|
+
*/
|
23
24
|
function defineUnderlineCommands() {
|
24
|
-
|
25
|
-
toggleUnderline: () => toggleMark({ type: "underline" })
|
26
|
-
});
|
25
|
+
return defineCommands({ toggleUnderline: () => toggleMark({ type: "underline" }) });
|
27
26
|
}
|
27
|
+
/**
|
28
|
+
* @internal
|
29
|
+
*/
|
28
30
|
function defineUnderlineKeymap() {
|
29
|
-
|
30
|
-
"Mod-u": toggleMark({ type: "underline" })
|
31
|
-
});
|
31
|
+
return defineKeymap({ "Mod-u": toggleMark({ type: "underline" }) });
|
32
32
|
}
|
33
|
+
/**
|
34
|
+
* @public
|
35
|
+
*/
|
33
36
|
function defineUnderline() {
|
34
|
-
|
35
|
-
defineUnderlineSpec(),
|
36
|
-
defineUnderlineCommands(),
|
37
|
-
defineUnderlineKeymap()
|
38
|
-
);
|
37
|
+
return union(defineUnderlineSpec(), defineUnderlineCommands(), defineUnderlineKeymap());
|
39
38
|
}
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
defineUnderlineKeymap,
|
44
|
-
defineUnderlineSpec
|
45
|
-
};
|
39
|
+
|
40
|
+
//#endregion
|
41
|
+
export { defineUnderline, defineUnderlineCommands, defineUnderlineKeymap, defineUnderlineSpec };
|
@@ -1,2 +1,21 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import { PlainExtension } from "@prosekit/core";
|
2
|
+
|
3
|
+
//#region src/virtual-selection/index.d.ts
|
4
|
+
|
5
|
+
/**
|
6
|
+
* @internal
|
7
|
+
*/
|
8
|
+
type VirtualSelectionExtension = PlainExtension;
|
9
|
+
/**
|
10
|
+
* Shows a virtual selection when the editor is not focused. When the editor is
|
11
|
+
* not focused, the selected inline content will be wrapped in a `<span>`
|
12
|
+
* element with the class `prosekit-virtual-selection`.
|
13
|
+
*
|
14
|
+
* This is useful when you want to move the focus to an element outside the
|
15
|
+
* editor, but still want to show the selection.
|
16
|
+
*
|
17
|
+
* @public
|
18
|
+
*/
|
19
|
+
declare function defineVirtualSelection(): VirtualSelectionExtension;
|
20
|
+
//#endregion
|
21
|
+
export { VirtualSelectionExtension, defineVirtualSelection };
|
@@ -1,61 +1,58 @@
|
|
1
|
-
|
2
|
-
import {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
import { definePlugin } from "@prosekit/core";
|
2
|
+
import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state";
|
3
|
+
import { Decoration, DecorationSet } from "@prosekit/pm/view";
|
4
|
+
|
5
|
+
//#region src/virtual-selection/index.ts
|
6
|
+
/**
|
7
|
+
* Shows a virtual selection when the editor is not focused. When the editor is
|
8
|
+
* not focused, the selected inline content will be wrapped in a `<span>`
|
9
|
+
* element with the class `prosekit-virtual-selection`.
|
10
|
+
*
|
11
|
+
* This is useful when you want to move the focus to an element outside the
|
12
|
+
* editor, but still want to show the selection.
|
13
|
+
*
|
14
|
+
* @public
|
15
|
+
*/
|
13
16
|
function defineVirtualSelection() {
|
14
|
-
|
17
|
+
return definePlugin(virtualSelectionPlugin);
|
15
18
|
}
|
16
|
-
|
19
|
+
const key = new PluginKey("prosekit-virtual-selection");
|
17
20
|
function getFocusMeta(tr) {
|
18
|
-
|
21
|
+
return tr.getMeta(key);
|
19
22
|
}
|
20
23
|
function setFocusMeta(tr, value) {
|
21
|
-
|
24
|
+
return tr.setMeta(key, value);
|
22
25
|
}
|
23
26
|
function getFocusState(state) {
|
24
|
-
|
27
|
+
return key.getState(state);
|
25
28
|
}
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
Decoration.inline(selection.from, selection.to, {
|
53
|
-
class: "prosekit-virtual-selection"
|
54
|
-
})
|
55
|
-
]);
|
56
|
-
}
|
57
|
-
}
|
29
|
+
const virtualSelectionPlugin = new ProseMirrorPlugin({
|
30
|
+
key,
|
31
|
+
state: {
|
32
|
+
init: () => false,
|
33
|
+
apply: (tr, value) => {
|
34
|
+
return getFocusMeta(tr) ?? value;
|
35
|
+
}
|
36
|
+
},
|
37
|
+
props: {
|
38
|
+
handleDOMEvents: {
|
39
|
+
focus: (view) => {
|
40
|
+
view.dispatch(setFocusMeta(view.state.tr, false));
|
41
|
+
},
|
42
|
+
blur: (view) => {
|
43
|
+
const { dom, root } = view;
|
44
|
+
const activeElement = root.activeElement;
|
45
|
+
if (activeElement === dom) return;
|
46
|
+
view.dispatch(setFocusMeta(view.state.tr, true));
|
47
|
+
}
|
48
|
+
},
|
49
|
+
decorations: (state) => {
|
50
|
+
const { selection, doc } = state;
|
51
|
+
if (selection.empty || !getFocusState(state)) return null;
|
52
|
+
return DecorationSet.create(doc, [Decoration.inline(selection.from, selection.to, { class: "prosekit-virtual-selection" })]);
|
53
|
+
}
|
54
|
+
}
|
58
55
|
});
|
59
|
-
|
60
|
-
|
61
|
-
};
|
56
|
+
|
57
|
+
//#endregion
|
58
|
+
export { defineVirtualSelection };
|
@@ -1,14 +1,90 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
import { Extension, PlainExtension, Union } from "@prosekit/core";
|
2
|
+
import { yCursorPlugin, ySyncPlugin, yUndoPlugin } from "y-prosemirror";
|
3
|
+
import { Awareness } from "y-protocols/awareness";
|
4
|
+
import * as Y$1 from "yjs";
|
5
|
+
import * as Y from "yjs";
|
6
|
+
|
7
|
+
//#region src/yjs/yjs-commands.d.ts
|
8
|
+
/**
|
9
|
+
* @internal
|
10
|
+
*/
|
11
|
+
type YjsCommandsExtension = Extension<{
|
12
|
+
Commands: {
|
13
|
+
undo: [];
|
14
|
+
redo: [];
|
15
|
+
};
|
16
|
+
}>;
|
17
|
+
declare function defineYjsCommands(): YjsCommandsExtension;
|
18
|
+
//#endregion
|
19
|
+
//#region src/yjs/yjs-cursor-plugin.d.ts
|
20
|
+
/**
|
21
|
+
* Options for `y-prosemirror`'s `yCursorPlugin`.
|
22
|
+
*/
|
23
|
+
type YjsCursorPluginOptions = NonNullable<Parameters<typeof yCursorPlugin>[1]>;
|
24
|
+
interface YjsCursorOptions extends YjsCursorPluginOptions {
|
25
|
+
awareness: Awareness;
|
26
|
+
}
|
27
|
+
declare function defineYjsCursorPlugin(options: YjsCursorOptions): PlainExtension;
|
28
|
+
//#endregion
|
29
|
+
//#region src/yjs/yjs-sync-plugin.d.ts
|
30
|
+
/**
|
31
|
+
* Options for `y-prosemirror`'s `ySyncPlugin`.
|
32
|
+
*/
|
33
|
+
type YjsSyncPluginOptions = NonNullable<Parameters<typeof ySyncPlugin>[1]>;
|
34
|
+
interface YjsSyncOptions extends YjsSyncPluginOptions {
|
35
|
+
fragment: Y$1.XmlFragment;
|
36
|
+
}
|
37
|
+
declare function defineYjsSyncPlugin(options: YjsSyncOptions): PlainExtension;
|
38
|
+
//#endregion
|
39
|
+
//#region src/yjs/yjs-undo-plugin.d.ts
|
40
|
+
/**
|
41
|
+
* Options for the `y-prosemirror`'s `yUndoPlugin`.
|
42
|
+
*/
|
43
|
+
type YjsUndoPluginOptions = NonNullable<Parameters<typeof yUndoPlugin>[0]>;
|
44
|
+
interface YjsUndoOptions extends YjsUndoPluginOptions {}
|
45
|
+
/**
|
46
|
+
* @internal
|
47
|
+
*/
|
48
|
+
declare function defineYjsUndoPlugin(options: YjsUndoOptions): PlainExtension;
|
49
|
+
//#endregion
|
50
|
+
//#region src/yjs/yjs.d.ts
|
51
|
+
interface YjsOptions {
|
52
|
+
/**
|
53
|
+
* The Yjs instance handles the state of shared data.
|
54
|
+
*/
|
55
|
+
doc: Y.Doc;
|
56
|
+
/**
|
57
|
+
* The Awareness instance.
|
58
|
+
*/
|
59
|
+
awareness: Awareness;
|
60
|
+
/**
|
61
|
+
* The Yjs XmlFragment to use. If not provided,
|
62
|
+
* `doc.getXmlFragment('prosemirror')` will be used.
|
63
|
+
*/
|
64
|
+
fragment?: Y.XmlFragment;
|
65
|
+
/**
|
66
|
+
* Options for `y-prosemirror`'s `ySyncPlugin`.
|
67
|
+
*/
|
68
|
+
sync?: YjsSyncPluginOptions;
|
69
|
+
/**
|
70
|
+
* Options for the `y-prosemirror`'s `yUndoPlugin`.
|
71
|
+
*/
|
72
|
+
undo?: YjsUndoPluginOptions;
|
73
|
+
/**
|
74
|
+
* Options for `y-prosemirror`'s `yCursorPlugin`.
|
75
|
+
*/
|
76
|
+
cursor?: YjsCursorPluginOptions;
|
77
|
+
}
|
78
|
+
/**
|
79
|
+
* @internal
|
80
|
+
*/
|
81
|
+
type YjsExtension = Union<[YjsCommandsExtension, PlainExtension]>;
|
82
|
+
/**
|
83
|
+
* @public
|
84
|
+
*/
|
85
|
+
declare function defineYjs(options: YjsOptions): YjsExtension;
|
86
|
+
//#endregion
|
87
|
+
//#region src/yjs/yjs-keymap.d.ts
|
88
|
+
declare function defineYjsKeymap(): PlainExtension;
|
89
|
+
//#endregion
|
90
|
+
export { YjsCursorOptions, YjsCursorPluginOptions, YjsExtension, YjsOptions, YjsSyncOptions, YjsSyncPluginOptions, YjsUndoOptions, YjsUndoPluginOptions, defineYjs, defineYjsCommands, defineYjsCursorPlugin, defineYjsKeymap, defineYjsSyncPlugin, defineYjsUndoPlugin };
|