@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,17 +1,104 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
1
|
+
import { Extension, PlainExtension, Union } from "@prosekit/core";
|
2
|
+
import { DedentListOptions, DedentListOptions as DedentListOptions$1, IndentListOptions, IndentListOptions as IndentListOptions$1, ListAttributes, ListDOMSerializer, ToggleCollapsedOptions, ToggleCollapsedOptions as ToggleCollapsedOptions$1, UnwrapListOptions, UnwrapListOptions as UnwrapListOptions$1, WrapInListGetAttrs } from "prosemirror-flat-list";
|
3
|
+
|
4
|
+
//#region src/list/list-commands.d.ts
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @internal
|
8
|
+
*/
|
9
|
+
type ListCommandsExtension = Extension<{
|
10
|
+
Commands: {
|
11
|
+
dedentList: [options?: DedentListOptions$1];
|
12
|
+
indentList: [options?: IndentListOptions$1];
|
13
|
+
moveList: [direction: "up" | "down"];
|
14
|
+
splitList: [];
|
15
|
+
toggleCollapsed: [options?: ToggleCollapsedOptions$1];
|
16
|
+
unwrapList: [options?: UnwrapListOptions$1];
|
17
|
+
toggleList: [attrs?: ListAttributes];
|
18
|
+
wrapInList: [attrs?: ListAttributes];
|
19
|
+
insertList: [attrs?: ListAttributes];
|
20
|
+
};
|
21
|
+
}>;
|
22
|
+
/**
|
23
|
+
* Defines list commands.
|
24
|
+
*
|
25
|
+
* @internal
|
26
|
+
*/
|
27
|
+
declare function defineListCommands(): ListCommandsExtension;
|
28
|
+
//#endregion
|
29
|
+
//#region src/list/list-input-rules.d.ts
|
30
|
+
/**
|
31
|
+
* @internal
|
32
|
+
*/
|
33
|
+
declare function defineListInputRules(): Extension;
|
34
|
+
//#endregion
|
35
|
+
//#region src/list/list-keymap.d.ts
|
36
|
+
/**
|
37
|
+
* Returns a extension that adds key bindings for list.
|
38
|
+
*
|
39
|
+
* @internal
|
40
|
+
*/
|
41
|
+
declare function defineListKeymap(): PlainExtension;
|
42
|
+
//#endregion
|
43
|
+
//#region src/list/list-plugins.d.ts
|
44
|
+
/**
|
45
|
+
* @internal
|
46
|
+
*/
|
47
|
+
declare function defineListPlugins(): PlainExtension;
|
48
|
+
//#endregion
|
49
|
+
//#region src/list/list-types.d.ts
|
50
|
+
/**
|
51
|
+
* The attributes of a list node.
|
52
|
+
*
|
53
|
+
* @public
|
54
|
+
*/
|
55
|
+
interface ListAttrs {
|
56
|
+
/**
|
57
|
+
* The kind of list node.
|
58
|
+
*/
|
59
|
+
kind?: "bullet" | "ordered" | "task" | "toggle";
|
60
|
+
/**
|
61
|
+
* The optional order of the list node.
|
62
|
+
*/
|
63
|
+
order?: number | null;
|
64
|
+
/**
|
65
|
+
* Whether the list node is checked if its `kind` is `"task"`.
|
66
|
+
*/
|
67
|
+
checked?: boolean;
|
68
|
+
/**
|
69
|
+
* Whether the list node is collapsed if its `kind` is `"toggle"`.
|
70
|
+
*/
|
71
|
+
collapsed?: boolean;
|
72
|
+
}
|
73
|
+
//#endregion
|
74
|
+
//#region src/list/list-spec.d.ts
|
75
|
+
/**
|
76
|
+
* @internal
|
77
|
+
*/
|
78
|
+
type ListSpecExtension = Extension<{
|
79
|
+
Nodes: {
|
80
|
+
list: ListAttrs;
|
81
|
+
};
|
82
|
+
}>;
|
83
|
+
/**
|
84
|
+
* @internal
|
85
|
+
*/
|
86
|
+
declare function defineListSpec(): ListSpecExtension;
|
87
|
+
//#endregion
|
88
|
+
//#region src/list/list.d.ts
|
89
|
+
/**
|
90
|
+
* @internal
|
91
|
+
*/
|
92
|
+
type ListExtension = Union<[ListSpecExtension, ListCommandsExtension]>;
|
93
|
+
/**
|
94
|
+
* @public
|
95
|
+
*/
|
96
|
+
declare function defineList(): ListExtension;
|
97
|
+
//#endregion
|
98
|
+
//#region src/list/list-serializer.d.ts
|
99
|
+
/**
|
100
|
+
* @internal
|
101
|
+
*/
|
102
|
+
declare function defineListSerializer(): PlainExtension;
|
103
|
+
//#endregion
|
104
|
+
export { DedentListOptions, IndentListOptions, ListAttrs, ListCommandsExtension, ListDOMSerializer, ListExtension, ListSpecExtension, ToggleCollapsedOptions, UnwrapListOptions, WrapInListGetAttrs, defineList, defineListCommands, defineListInputRules, defineListKeymap, defineListPlugins, defineListSerializer, defineListSpec };
|
@@ -1,186 +1,143 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
} from "
|
4
|
-
|
5
|
-
|
6
|
-
import {
|
7
|
-
|
8
|
-
// src/list/list.ts
|
9
|
-
import {
|
10
|
-
union as union2
|
11
|
-
} from "@prosekit/core";
|
1
|
+
import { defineInputRule } from "./input-rule-Gji4N7Oe.js";
|
2
|
+
import { defineClipboardSerializer, defineCommands, defineKeymap, defineNodeSpec, definePlugin, insertNode, union } from "@prosekit/core";
|
3
|
+
import { Plugin } from "@prosekit/pm/state";
|
4
|
+
import { chainCommands, deleteSelection } from "@prosekit/pm/commands";
|
5
|
+
import { ListDOMSerializer, createDedentListCommand, createIndentListCommand, createListEventPlugin, createListRenderingPlugin, createListSpec, createMoveListCommand, createSafariInputMethodWorkaroundPlugin, createSplitListCommand, createToggleCollapsedCommand, createToggleListCommand, createUnwrapListCommand, createWrapInListCommand, deleteCommand, enterCommand, joinCollapsedListBackward, joinListElements, joinListUp, listInputRules, listToDOM, protectCollapsed, unwrapListSlice } from "prosemirror-flat-list";
|
6
|
+
import { isElementLike } from "@ocavue/utils";
|
12
7
|
|
13
|
-
|
14
|
-
import {
|
15
|
-
defineCommands,
|
16
|
-
insertNode
|
17
|
-
} from "@prosekit/core";
|
18
|
-
import {
|
19
|
-
createDedentListCommand as dedentList,
|
20
|
-
createIndentListCommand as indentList,
|
21
|
-
createMoveListCommand as moveList,
|
22
|
-
createSplitListCommand as splitList,
|
23
|
-
createToggleCollapsedCommand as toggleCollapsed,
|
24
|
-
createToggleListCommand as toggleList,
|
25
|
-
createUnwrapListCommand as unwrapList,
|
26
|
-
createWrapInListCommand as wrapInList
|
27
|
-
} from "prosemirror-flat-list";
|
8
|
+
//#region src/list/list-commands.ts
|
28
9
|
function insertList(attrs) {
|
29
|
-
|
10
|
+
return insertNode({
|
11
|
+
type: "list",
|
12
|
+
attrs
|
13
|
+
});
|
30
14
|
}
|
15
|
+
/**
|
16
|
+
* Defines list commands.
|
17
|
+
*
|
18
|
+
* @internal
|
19
|
+
*/
|
31
20
|
function defineListCommands() {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
21
|
+
return defineCommands({
|
22
|
+
dedentList: createDedentListCommand,
|
23
|
+
indentList: createIndentListCommand,
|
24
|
+
moveList: createMoveListCommand,
|
25
|
+
splitList: createSplitListCommand,
|
26
|
+
toggleCollapsed: createToggleCollapsedCommand,
|
27
|
+
unwrapList: createUnwrapListCommand,
|
28
|
+
toggleList: createToggleListCommand,
|
29
|
+
wrapInList: createWrapInListCommand,
|
30
|
+
insertList
|
31
|
+
});
|
43
32
|
}
|
44
33
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
34
|
+
//#endregion
|
35
|
+
//#region src/list/list-input-rules.ts
|
36
|
+
/**
|
37
|
+
* @internal
|
38
|
+
*/
|
50
39
|
function defineListInputRules() {
|
51
|
-
|
40
|
+
return union(listInputRules.map(defineInputRule));
|
52
41
|
}
|
53
42
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
protectCollapsed
|
68
|
-
} from "prosemirror-flat-list";
|
69
|
-
var backspaceCommand = chainCommands(
|
70
|
-
protectCollapsed,
|
71
|
-
deleteSelection,
|
72
|
-
joinListUp,
|
73
|
-
joinCollapsedListBackward
|
74
|
-
);
|
75
|
-
var dedentListCommand = createDedentListCommand();
|
76
|
-
var indentListCommand = createIndentListCommand();
|
77
|
-
var listKeymap = {
|
78
|
-
"Enter": enterCommand,
|
79
|
-
"Backspace": backspaceCommand,
|
80
|
-
"Delete": deleteCommand,
|
81
|
-
"Mod-]": indentListCommand,
|
82
|
-
"Mod-[": dedentListCommand,
|
83
|
-
"Tab": indentListCommand,
|
84
|
-
"Shift-Tab": dedentListCommand
|
43
|
+
//#endregion
|
44
|
+
//#region src/list/list-keymap.ts
|
45
|
+
const backspaceCommand = chainCommands(protectCollapsed, deleteSelection, joinListUp, joinCollapsedListBackward);
|
46
|
+
const dedentListCommand = createDedentListCommand();
|
47
|
+
const indentListCommand = createIndentListCommand();
|
48
|
+
const listKeymap = {
|
49
|
+
"Enter": enterCommand,
|
50
|
+
"Backspace": backspaceCommand,
|
51
|
+
"Delete": deleteCommand,
|
52
|
+
"Mod-]": indentListCommand,
|
53
|
+
"Mod-[": dedentListCommand,
|
54
|
+
"Tab": indentListCommand,
|
55
|
+
"Shift-Tab": dedentListCommand
|
85
56
|
};
|
57
|
+
/**
|
58
|
+
* Returns a extension that adds key bindings for list.
|
59
|
+
*
|
60
|
+
* @internal
|
61
|
+
*/
|
86
62
|
function defineListKeymap() {
|
87
|
-
|
63
|
+
return defineKeymap(listKeymap);
|
88
64
|
}
|
89
65
|
|
90
|
-
|
91
|
-
|
92
|
-
import { Plugin } from "@prosekit/pm/state";
|
93
|
-
import {
|
94
|
-
createListEventPlugin,
|
95
|
-
createListRenderingPlugin,
|
96
|
-
createSafariInputMethodWorkaroundPlugin,
|
97
|
-
unwrapListSlice
|
98
|
-
} from "prosemirror-flat-list";
|
66
|
+
//#endregion
|
67
|
+
//#region src/list/list-plugins.ts
|
99
68
|
function createListClipboardPlugin() {
|
100
|
-
|
101
|
-
props: {
|
102
|
-
transformCopied: unwrapListSlice
|
103
|
-
}
|
104
|
-
});
|
69
|
+
return new Plugin({ props: { transformCopied: unwrapListSlice } });
|
105
70
|
}
|
106
71
|
function createListPlugins() {
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
72
|
+
return [
|
73
|
+
createListEventPlugin(),
|
74
|
+
createListRenderingPlugin(),
|
75
|
+
createListClipboardPlugin(),
|
76
|
+
createSafariInputMethodWorkaroundPlugin()
|
77
|
+
];
|
113
78
|
}
|
79
|
+
/**
|
80
|
+
* @internal
|
81
|
+
*/
|
114
82
|
function defineListPlugins() {
|
115
|
-
|
83
|
+
return definePlugin(createListPlugins);
|
116
84
|
}
|
117
85
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
import {
|
124
|
-
joinListElements,
|
125
|
-
listToDOM
|
126
|
-
} from "prosemirror-flat-list";
|
86
|
+
//#endregion
|
87
|
+
//#region src/list/list-serializer.ts
|
88
|
+
/**
|
89
|
+
* @internal
|
90
|
+
*/
|
127
91
|
function defineListSerializer() {
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
92
|
+
return defineClipboardSerializer({
|
93
|
+
serializeFragmentWrapper: (fn) => {
|
94
|
+
return (...args) => {
|
95
|
+
const dom = fn(...args);
|
96
|
+
return joinListElements(dom);
|
97
|
+
};
|
98
|
+
},
|
99
|
+
serializeNodeWrapper: (fn) => {
|
100
|
+
return (...args) => {
|
101
|
+
const dom = fn(...args);
|
102
|
+
return isElementLike(dom) ? joinListElements(dom) : dom;
|
103
|
+
};
|
104
|
+
},
|
105
|
+
nodesFromSchemaWrapper: (fn) => {
|
106
|
+
return (...args) => {
|
107
|
+
const nodes = fn(...args);
|
108
|
+
return {
|
109
|
+
...nodes,
|
110
|
+
list: (node) => listToDOM({
|
111
|
+
node,
|
112
|
+
nativeList: true,
|
113
|
+
getMarkers: () => null
|
114
|
+
})
|
115
|
+
};
|
116
|
+
};
|
117
|
+
}
|
118
|
+
});
|
151
119
|
}
|
152
120
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
121
|
+
//#endregion
|
122
|
+
//#region src/list/list-spec.ts
|
123
|
+
/**
|
124
|
+
* @internal
|
125
|
+
*/
|
158
126
|
function defineListSpec() {
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
127
|
+
return defineNodeSpec({
|
128
|
+
...createListSpec(),
|
129
|
+
name: "list"
|
130
|
+
});
|
163
131
|
}
|
164
132
|
|
165
|
-
|
166
|
-
|
133
|
+
//#endregion
|
134
|
+
//#region src/list/list.ts
|
135
|
+
/**
|
136
|
+
* @public
|
137
|
+
*/
|
167
138
|
function defineList() {
|
168
|
-
|
169
|
-
defineListSpec(),
|
170
|
-
defineListPlugins(),
|
171
|
-
defineListKeymap(),
|
172
|
-
defineListInputRules(),
|
173
|
-
defineListCommands(),
|
174
|
-
defineListSerializer()
|
175
|
-
);
|
139
|
+
return union(defineListSpec(), defineListPlugins(), defineListKeymap(), defineListInputRules(), defineListCommands(), defineListSerializer());
|
176
140
|
}
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
defineListCommands,
|
181
|
-
defineListInputRules,
|
182
|
-
defineListKeymap,
|
183
|
-
defineListPlugins,
|
184
|
-
defineListSerializer,
|
185
|
-
defineListSpec
|
186
|
-
};
|
141
|
+
|
142
|
+
//#endregion
|
143
|
+
export { ListDOMSerializer, defineList, defineListCommands, defineListInputRules, defineListKeymap, defineListPlugins, defineListSerializer, defineListSpec };
|
@@ -1,11 +1,69 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
import { Extension, PlainExtension, Union } from "@prosekit/core";
|
2
|
+
import { EditorState, Selection } from "@prosekit/pm/state";
|
3
|
+
import { DecorationAttrs } from "@prosekit/pm/view";
|
4
|
+
import { CursorAwareness, LoroDocType, LoroSyncPluginProps, LoroSyncPluginProps as LoroSyncPluginProps$1, LoroSyncPluginProps as LoroSyncPluginProps$2, LoroUndoPluginProps, LoroUndoPluginProps as LoroUndoPluginProps$1, LoroUndoPluginProps as LoroUndoPluginProps$2 } from "loro-prosemirror";
|
5
|
+
import { PeerID } from "loro-crdt";
|
6
|
+
|
7
|
+
//#region src/loro/loro-commands.d.ts
|
8
|
+
/**
|
9
|
+
* @internal
|
10
|
+
*/
|
11
|
+
type LoroCommandsExtension = Extension<{
|
12
|
+
Commands: {
|
13
|
+
undo: [];
|
14
|
+
redo: [];
|
15
|
+
};
|
16
|
+
}>;
|
17
|
+
declare function defineLoroCommands(): LoroCommandsExtension;
|
18
|
+
//#endregion
|
19
|
+
//#region src/loro/loro-cursor-plugin.d.ts
|
20
|
+
interface LoroCursorOptions {
|
21
|
+
awareness: CursorAwareness;
|
22
|
+
getSelection?: (state: EditorState) => Selection;
|
23
|
+
createCursor?: (user: PeerID) => Element;
|
24
|
+
createSelection?: (user: PeerID) => DecorationAttrs;
|
25
|
+
}
|
26
|
+
declare function defineLoroCursorPlugin(options: LoroCursorOptions): PlainExtension;
|
27
|
+
//#endregion
|
28
|
+
//#region src/loro/loro-keymap.d.ts
|
29
|
+
declare function defineLoroKeymap(): PlainExtension;
|
30
|
+
//#endregion
|
31
|
+
//#region src/loro/loro-sync-plugin.d.ts
|
32
|
+
declare function defineLoroSyncPlugin(options: LoroSyncPluginProps$1): PlainExtension;
|
33
|
+
//#endregion
|
34
|
+
//#region src/loro/loro-undo-plugin.d.ts
|
35
|
+
declare function defineLoroUndoPlugin(options: LoroUndoPluginProps$1): PlainExtension;
|
36
|
+
//#endregion
|
37
|
+
//#region src/loro/loro.d.ts
|
38
|
+
interface LoroOptions {
|
39
|
+
/**
|
40
|
+
* The Loro instance handles the state of shared data.
|
41
|
+
*/
|
42
|
+
doc: LoroDocType;
|
43
|
+
/**
|
44
|
+
* The Awareness instance.
|
45
|
+
*/
|
46
|
+
awareness: CursorAwareness;
|
47
|
+
/**
|
48
|
+
* Extra options for `LoroSyncPlugin`.
|
49
|
+
*/
|
50
|
+
sync?: Omit<LoroSyncPluginProps$2, "doc">;
|
51
|
+
/**
|
52
|
+
* Extra options for the `LoroUndoPlugin`.
|
53
|
+
*/
|
54
|
+
undo?: Omit<LoroUndoPluginProps$2, "doc">;
|
55
|
+
/**
|
56
|
+
* Extra options for `LoroCursorPlugin`.
|
57
|
+
*/
|
58
|
+
cursor?: Omit<LoroCursorOptions, "awareness">;
|
59
|
+
}
|
60
|
+
/**
|
61
|
+
* @internal
|
62
|
+
*/
|
63
|
+
type LoroExtension = Union<[LoroCommandsExtension, PlainExtension]>;
|
64
|
+
/**
|
65
|
+
* @public
|
66
|
+
*/
|
67
|
+
declare function defineLoro(options: LoroOptions): LoroExtension;
|
68
|
+
//#endregion
|
69
|
+
export { LoroCursorOptions, LoroExtension, LoroOptions, LoroSyncPluginProps, LoroUndoPluginProps, defineLoro, defineLoroCommands, defineLoroCursorPlugin, defineLoroKeymap, defineLoroSyncPlugin, defineLoroUndoPlugin };
|
@@ -1,97 +1,69 @@
|
|
1
|
-
|
2
|
-
import {
|
3
|
-
Priority,
|
4
|
-
union,
|
5
|
-
withPriority
|
6
|
-
} from "@prosekit/core";
|
1
|
+
import { Priority, defineCommands, defineKeymap, definePlugin, isApple, union, withPriority } from "@prosekit/core";
|
2
|
+
import { LoroCursorPlugin, LoroSyncPlugin, LoroUndoPlugin, redo, undo } from "loro-prosemirror";
|
7
3
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
import {
|
13
|
-
redo,
|
14
|
-
undo
|
15
|
-
} from "loro-prosemirror";
|
16
|
-
var commands = {
|
17
|
-
undo: () => undo,
|
18
|
-
redo: () => redo
|
4
|
+
//#region src/loro/loro-commands.ts
|
5
|
+
const commands = {
|
6
|
+
undo: () => undo,
|
7
|
+
redo: () => redo
|
19
8
|
};
|
20
9
|
function defineLoroCommands() {
|
21
|
-
|
10
|
+
return defineCommands(commands);
|
22
11
|
}
|
23
12
|
|
24
|
-
|
25
|
-
|
26
|
-
definePlugin
|
27
|
-
} from "@prosekit/core";
|
28
|
-
import {
|
29
|
-
LoroCursorPlugin
|
30
|
-
} from "loro-prosemirror";
|
13
|
+
//#endregion
|
14
|
+
//#region src/loro/loro-cursor-plugin.ts
|
31
15
|
function defineLoroCursorPlugin(options) {
|
32
|
-
|
33
|
-
|
16
|
+
const { awareness,...rest } = options;
|
17
|
+
return definePlugin(LoroCursorPlugin(awareness, rest));
|
34
18
|
}
|
35
19
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
import {
|
42
|
-
redo as redo2,
|
43
|
-
undo as undo2
|
44
|
-
} from "loro-prosemirror";
|
45
|
-
var keymap = {
|
46
|
-
"Mod-z": undo2,
|
47
|
-
"Shift-Mod-z": redo2
|
20
|
+
//#endregion
|
21
|
+
//#region src/loro/loro-keymap.ts
|
22
|
+
const keymap = {
|
23
|
+
"Mod-z": undo,
|
24
|
+
"Shift-Mod-z": redo
|
48
25
|
};
|
49
|
-
if (!isApple)
|
50
|
-
keymap["Mod-y"] = redo2;
|
51
|
-
}
|
26
|
+
if (!isApple) keymap["Mod-y"] = redo;
|
52
27
|
function defineLoroKeymap() {
|
53
|
-
|
28
|
+
return defineKeymap(keymap);
|
54
29
|
}
|
55
30
|
|
56
|
-
|
57
|
-
|
58
|
-
definePlugin as definePlugin2
|
59
|
-
} from "@prosekit/core";
|
60
|
-
import {
|
61
|
-
LoroSyncPlugin
|
62
|
-
} from "loro-prosemirror";
|
31
|
+
//#endregion
|
32
|
+
//#region src/loro/loro-sync-plugin.ts
|
63
33
|
function defineLoroSyncPlugin(options) {
|
64
|
-
|
34
|
+
return definePlugin(LoroSyncPlugin(options));
|
65
35
|
}
|
66
36
|
|
67
|
-
|
68
|
-
|
69
|
-
import {
|
70
|
-
LoroUndoPlugin
|
71
|
-
} from "loro-prosemirror";
|
37
|
+
//#endregion
|
38
|
+
//#region src/loro/loro-undo-plugin.ts
|
72
39
|
function defineLoroUndoPlugin(options) {
|
73
|
-
|
40
|
+
return definePlugin(LoroUndoPlugin(options));
|
74
41
|
}
|
75
42
|
|
76
|
-
|
43
|
+
//#endregion
|
44
|
+
//#region src/loro/loro.ts
|
45
|
+
/**
|
46
|
+
* @public
|
47
|
+
*/
|
77
48
|
function defineLoro(options) {
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
49
|
+
const { doc, awareness, sync, undo: undo$1, cursor } = options;
|
50
|
+
return withPriority(union([
|
51
|
+
defineLoroKeymap(),
|
52
|
+
defineLoroCommands(),
|
53
|
+
defineLoroCursorPlugin({
|
54
|
+
...cursor,
|
55
|
+
awareness
|
56
|
+
}),
|
57
|
+
defineLoroUndoPlugin({
|
58
|
+
...undo$1,
|
59
|
+
doc
|
60
|
+
}),
|
61
|
+
defineLoroSyncPlugin({
|
62
|
+
...sync,
|
63
|
+
doc
|
64
|
+
})
|
65
|
+
]), Priority.high);
|
89
66
|
}
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
defineLoroCursorPlugin,
|
94
|
-
defineLoroKeymap,
|
95
|
-
defineLoroSyncPlugin,
|
96
|
-
defineLoroUndoPlugin
|
97
|
-
};
|
67
|
+
|
68
|
+
//#endregion
|
69
|
+
export { defineLoro, defineLoroCommands, defineLoroCursorPlugin, defineLoroKeymap, defineLoroSyncPlugin, defineLoroUndoPlugin };
|