@prosekit/extensions 0.8.0 → 0.9.0

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.
Files changed (100) hide show
  1. package/dist/commit/style.css +2 -1
  2. package/dist/commit/style.js +0 -0
  3. package/dist/enter-rule-RdhEA900.js +96 -0
  4. package/dist/gap-cursor/style.css +8 -5
  5. package/dist/gap-cursor/style.js +0 -0
  6. package/dist/input-rule-Gji4N7Oe.js +93 -0
  7. package/dist/list/style.css +7 -7
  8. package/dist/list/style.js +0 -0
  9. package/dist/loro/style.css +21 -17
  10. package/dist/loro/style.js +0 -0
  11. package/dist/mark-rule-wEOcDt6i.js +160 -0
  12. package/dist/placeholder/style.css +5 -5
  13. package/dist/placeholder/style.js +0 -0
  14. package/dist/prosekit-extensions-autocomplete.d.ts +33 -3
  15. package/dist/prosekit-extensions-autocomplete.js +122 -174
  16. package/dist/prosekit-extensions-blockquote.d.ts +51 -8
  17. package/dist/prosekit-extensions-blockquote.js +64 -78
  18. package/dist/prosekit-extensions-bold.d.ts +61 -8
  19. package/dist/prosekit-extensions-bold.js +61 -73
  20. package/dist/prosekit-extensions-code-block.d.ts +172 -20
  21. package/dist/prosekit-extensions-code-block.js +201 -184
  22. package/dist/prosekit-extensions-code.d.ts +61 -8
  23. package/dist/prosekit-extensions-code.js +44 -56
  24. package/dist/prosekit-extensions-commit.d.ts +53 -4
  25. package/dist/prosekit-extensions-commit.js +142 -183
  26. package/dist/prosekit-extensions-doc.d.ts +22 -2
  27. package/dist/prosekit-extensions-doc.js +14 -12
  28. package/dist/prosekit-extensions-drop-cursor.d.ts +34 -3
  29. package/dist/prosekit-extensions-drop-cursor.js +14 -8
  30. package/dist/prosekit-extensions-enter-rule.d.ts +106 -5
  31. package/dist/prosekit-extensions-enter-rule.js +3 -8
  32. package/dist/prosekit-extensions-file.d.ts +126 -8
  33. package/dist/prosekit-extensions-file.js +111 -132
  34. package/dist/prosekit-extensions-gap-cursor.d.ts +29 -2
  35. package/dist/prosekit-extensions-gap-cursor.js +21 -9
  36. package/dist/prosekit-extensions-hard-break.d.ts +58 -0
  37. package/dist/prosekit-extensions-hard-break.js +58 -0
  38. package/dist/prosekit-extensions-heading.d.ts +69 -9
  39. package/dist/prosekit-extensions-heading.js +121 -95
  40. package/dist/prosekit-extensions-horizontal-rule.d.ts +41 -8
  41. package/dist/prosekit-extensions-horizontal-rule.js +53 -71
  42. package/dist/prosekit-extensions-image.d.ts +53 -7
  43. package/dist/prosekit-extensions-image.js +71 -62
  44. package/dist/prosekit-extensions-input-rule.d.ts +134 -6
  45. package/dist/prosekit-extensions-input-rule.js +3 -14
  46. package/dist/prosekit-extensions-italic.d.ts +61 -8
  47. package/dist/prosekit-extensions-italic.js +51 -63
  48. package/dist/prosekit-extensions-link.d.ts +65 -10
  49. package/dist/prosekit-extensions-link.js +95 -100
  50. package/dist/prosekit-extensions-list.d.ts +114 -17
  51. package/dist/prosekit-extensions-list.js +115 -158
  52. package/dist/prosekit-extensions-loro.d.ts +78 -11
  53. package/dist/prosekit-extensions-loro.js +49 -77
  54. package/dist/prosekit-extensions-mark-rule.d.ts +41 -2
  55. package/dist/prosekit-extensions-mark-rule.js +3 -6
  56. package/dist/prosekit-extensions-mention.d.ts +40 -4
  57. package/dist/prosekit-extensions-mention.js +52 -50
  58. package/dist/prosekit-extensions-mod-click-prevention.d.ts +20 -2
  59. package/dist/prosekit-extensions-mod-click-prevention.js +20 -16
  60. package/dist/prosekit-extensions-paragraph.d.ts +65 -7
  61. package/dist/prosekit-extensions-paragraph.js +46 -45
  62. package/dist/prosekit-extensions-placeholder.d.ts +32 -2
  63. package/dist/prosekit-extensions-placeholder.js +39 -56
  64. package/dist/prosekit-extensions-readonly.d.ts +13 -1
  65. package/dist/prosekit-extensions-readonly.js +13 -14
  66. package/dist/prosekit-extensions-search.d.ts +77 -3
  67. package/dist/prosekit-extensions-search.js +48 -47
  68. package/dist/prosekit-extensions-strike.d.ts +50 -8
  69. package/dist/prosekit-extensions-strike.js +44 -49
  70. package/dist/prosekit-extensions-table.d.ts +237 -26
  71. package/dist/prosekit-extensions-table.js +3 -34
  72. package/dist/prosekit-extensions-text-align.d.ts +72 -8
  73. package/dist/prosekit-extensions-text-align.js +63 -44
  74. package/dist/prosekit-extensions-text.d.ts +22 -2
  75. package/dist/prosekit-extensions-text.js +13 -11
  76. package/dist/prosekit-extensions-underline.d.ts +46 -7
  77. package/dist/prosekit-extensions-underline.js +33 -37
  78. package/dist/prosekit-extensions-virtual-selection.d.ts +24 -2
  79. package/dist/prosekit-extensions-virtual-selection.js +49 -52
  80. package/dist/prosekit-extensions-yjs.d.ts +99 -14
  81. package/dist/prosekit-extensions-yjs.js +88 -131
  82. package/dist/prosekit-extensions.d.ts +1 -1
  83. package/dist/search/style.css +5 -5
  84. package/dist/search/style.js +0 -0
  85. package/dist/shiki-highlighter-chunk-Cd3WeOKL.d.ts +19 -0
  86. package/dist/shiki-highlighter-chunk.d.ts +2 -0
  87. package/dist/shiki-highlighter-chunk.js +32 -39
  88. package/dist/table/style.css +18 -17
  89. package/dist/table/style.js +0 -0
  90. package/dist/table-DnVliJ6E.js +287 -0
  91. package/dist/virtual-selection/style.css +2 -2
  92. package/dist/virtual-selection/style.js +0 -0
  93. package/dist/yjs/style.css +15 -17
  94. package/dist/yjs/style.js +0 -0
  95. package/package.json +80 -53
  96. package/dist/_tsup-dts-rollup.d.ts +0 -2459
  97. package/dist/chunk-6UYLCVBX.js +0 -185
  98. package/dist/chunk-D54VSLLS.js +0 -105
  99. package/dist/chunk-I2UMHK3L.js +0 -99
  100. package/dist/chunk-QVFEYPQ6.js +0 -306
@@ -1,17 +1,114 @@
1
- export { ListDOMSerializer } from './_tsup-dts-rollup.js';
2
- export { DedentListOptions } from './_tsup-dts-rollup.js';
3
- export { IndentListOptions } from './_tsup-dts-rollup.js';
4
- export { ToggleCollapsedOptions } from './_tsup-dts-rollup.js';
5
- export { UnwrapListOptions } from './_tsup-dts-rollup.js';
6
- export { WrapInListGetAttrs } from './_tsup-dts-rollup.js';
7
- export { defineList } from './_tsup-dts-rollup.js';
8
- export { ListExtension } from './_tsup-dts-rollup.js';
9
- export { defineListCommands } from './_tsup-dts-rollup.js';
10
- export { ListCommandsExtension } from './_tsup-dts-rollup.js';
11
- export { defineListInputRules } from './_tsup-dts-rollup.js';
12
- export { defineListKeymap } from './_tsup-dts-rollup.js';
13
- export { defineListPlugins } from './_tsup-dts-rollup.js';
14
- export { defineListSerializer } from './_tsup-dts-rollup.js';
15
- export { defineListSpec } from './_tsup-dts-rollup.js';
16
- export { ListSpecExtension } from './_tsup-dts-rollup.js';
17
- export { ListAttrs } from './_tsup-dts-rollup.js';
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
+ * @internal
7
+ */
8
+ /**
9
+ * @internal
10
+ */
11
+ type ListCommandsExtension = Extension<{
12
+ Commands: {
13
+ dedentList: [options?: DedentListOptions$1];
14
+ indentList: [options?: IndentListOptions$1];
15
+ moveList: [direction: "up" | "down"];
16
+ splitList: [];
17
+ toggleCollapsed: [options?: ToggleCollapsedOptions$1];
18
+ unwrapList: [options?: UnwrapListOptions$1];
19
+ toggleList: [attrs?: ListAttributes];
20
+ wrapInList: [attrs?: ListAttributes];
21
+ insertList: [attrs?: ListAttributes];
22
+ };
23
+ }>;
24
+ /**
25
+ * Defines list commands.
26
+ *
27
+ * @internal
28
+ */
29
+ declare function defineListCommands(): ListCommandsExtension;
30
+
31
+ //#endregion
32
+ //#region src/list/list-input-rules.d.ts
33
+ /**
34
+ * @internal
35
+ */
36
+ declare function defineListInputRules(): Extension;
37
+
38
+ //#endregion
39
+ //#region src/list/list-keymap.d.ts
40
+ /**
41
+ * Returns a extension that adds key bindings for list.
42
+ *
43
+ * @internal
44
+ */
45
+ declare function defineListKeymap(): PlainExtension;
46
+
47
+ //#endregion
48
+ //#region src/list/list-plugins.d.ts
49
+ /**
50
+ * @internal
51
+ */
52
+ declare function defineListPlugins(): PlainExtension;
53
+
54
+ //#endregion
55
+ //#region src/list/list-types.d.ts
56
+ /**
57
+ * The attributes of a list node.
58
+ *
59
+ * @public
60
+ */
61
+ interface ListAttrs {
62
+ /**
63
+ * The kind of list node.
64
+ */
65
+ kind?: "bullet" | "ordered" | "task" | "toggle";
66
+ /**
67
+ * The optional order of the list node.
68
+ */
69
+ order?: number | null;
70
+ /**
71
+ * Whether the list node is checked if its `kind` is `"task"`.
72
+ */
73
+ checked?: boolean;
74
+ /**
75
+ * Whether the list node is collapsed if its `kind` is `"toggle"`.
76
+ */
77
+ collapsed?: boolean;
78
+ }
79
+
80
+ //#endregion
81
+ //#region src/list/list-spec.d.ts
82
+ /**
83
+ * @internal
84
+ */
85
+ type ListSpecExtension = Extension<{
86
+ Nodes: {
87
+ list: ListAttrs;
88
+ };
89
+ }>;
90
+ /**
91
+ * @internal
92
+ */
93
+ declare function defineListSpec(): ListSpecExtension;
94
+
95
+ //#endregion
96
+ //#region src/list/list.d.ts
97
+ /**
98
+ * @internal
99
+ */
100
+ type ListExtension = Union<[ListSpecExtension, ListCommandsExtension]>;
101
+ /**
102
+ * @public
103
+ */
104
+ declare function defineList(): ListExtension;
105
+
106
+ //#endregion
107
+ //#region src/list/list-serializer.d.ts
108
+ /**
109
+ * @internal
110
+ */
111
+ declare function defineListSerializer(): PlainExtension;
112
+
113
+ //#endregion
114
+ 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
- defineInputRule
3
- } from "./chunk-I2UMHK3L.js";
4
-
5
- // src/list/index.ts
6
- import { ListDOMSerializer as ListDOMSerializer2 } from "prosemirror-flat-list";
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
- // src/list/list-commands.ts
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
- return insertNode({ type: "list", attrs });
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
- return defineCommands({
33
- dedentList,
34
- indentList,
35
- moveList,
36
- splitList,
37
- toggleCollapsed,
38
- unwrapList,
39
- toggleList,
40
- wrapInList,
41
- insertList
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
- // src/list/list-input-rules.ts
46
- import {
47
- union
48
- } from "@prosekit/core";
49
- import { listInputRules } from "prosemirror-flat-list";
34
+ //#endregion
35
+ //#region src/list/list-input-rules.ts
36
+ /**
37
+ * @internal
38
+ */
50
39
  function defineListInputRules() {
51
- return union(listInputRules.map(defineInputRule));
40
+ return union(listInputRules.map(defineInputRule));
52
41
  }
53
42
 
54
- // src/list/list-keymap.ts
55
- import { defineKeymap } from "@prosekit/core";
56
- import {
57
- chainCommands,
58
- deleteSelection
59
- } from "@prosekit/pm/commands";
60
- import {
61
- createDedentListCommand,
62
- createIndentListCommand,
63
- deleteCommand,
64
- enterCommand,
65
- joinCollapsedListBackward,
66
- joinListUp,
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
- return defineKeymap(listKeymap);
63
+ return defineKeymap(listKeymap);
88
64
  }
89
65
 
90
- // src/list/list-plugins.ts
91
- import { definePlugin } from "@prosekit/core";
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
- return new Plugin({
101
- props: {
102
- transformCopied: unwrapListSlice
103
- }
104
- });
69
+ return new Plugin({ props: { transformCopied: unwrapListSlice } });
105
70
  }
106
71
  function createListPlugins() {
107
- return [
108
- createListEventPlugin(),
109
- createListRenderingPlugin(),
110
- createListClipboardPlugin(),
111
- createSafariInputMethodWorkaroundPlugin()
112
- ];
72
+ return [
73
+ createListEventPlugin(),
74
+ createListRenderingPlugin(),
75
+ createListClipboardPlugin(),
76
+ createSafariInputMethodWorkaroundPlugin()
77
+ ];
113
78
  }
79
+ /**
80
+ * @internal
81
+ */
114
82
  function defineListPlugins() {
115
- return definePlugin(createListPlugins);
83
+ return definePlugin(createListPlugins);
116
84
  }
117
85
 
118
- // src/list/list-serializer.ts
119
- import {
120
- defineClipboardSerializer,
121
- isElement
122
- } from "@prosekit/core";
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
- return defineClipboardSerializer({
129
- serializeFragmentWrapper: (fn) => {
130
- return (...args) => {
131
- const dom = fn(...args);
132
- return joinListElements(dom);
133
- };
134
- },
135
- serializeNodeWrapper: (fn) => {
136
- return (...args) => {
137
- const dom = fn(...args);
138
- return isElement(dom) ? joinListElements(dom) : dom;
139
- };
140
- },
141
- nodesFromSchemaWrapper: (fn) => {
142
- return (...args) => {
143
- const nodes = fn(...args);
144
- return {
145
- ...nodes,
146
- list: (node) => listToDOM({ node, nativeList: true, getMarkers: () => null })
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
- // src/list/list-spec.ts
154
- import {
155
- defineNodeSpec
156
- } from "@prosekit/core";
157
- import { createListSpec } from "prosemirror-flat-list";
121
+ //#endregion
122
+ //#region src/list/list-spec.ts
123
+ /**
124
+ * @internal
125
+ */
158
126
  function defineListSpec() {
159
- return defineNodeSpec({
160
- ...createListSpec(),
161
- name: "list"
162
- });
127
+ return defineNodeSpec({
128
+ ...createListSpec(),
129
+ name: "list"
130
+ });
163
131
  }
164
132
 
165
- // src/list/list.ts
166
- import { ListDOMSerializer } from "prosemirror-flat-list";
133
+ //#endregion
134
+ //#region src/list/list.ts
135
+ /**
136
+ * @public
137
+ */
167
138
  function defineList() {
168
- return union2(
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
- export {
178
- ListDOMSerializer2 as ListDOMSerializer,
179
- defineList,
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,78 @@
1
- export { LoroSyncPluginProps } from './_tsup-dts-rollup.js';
2
- export { LoroUndoPluginProps } from './_tsup-dts-rollup.js';
3
- export { defineLoro } from './_tsup-dts-rollup.js';
4
- export { LoroExtension } from './_tsup-dts-rollup.js';
5
- export { LoroOptions } from './_tsup-dts-rollup.js';
6
- export { defineLoroCommands } from './_tsup-dts-rollup.js';
7
- export { defineLoroCursorPlugin } from './_tsup-dts-rollup.js';
8
- export { LoroCursorOptions } from './_tsup-dts-rollup.js';
9
- export { defineLoroKeymap } from './_tsup-dts-rollup.js';
10
- export { defineLoroSyncPlugin } from './_tsup-dts-rollup.js';
11
- export { defineLoroUndoPlugin } from './_tsup-dts-rollup.js';
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
+ /**
12
+ * @internal
13
+ */
14
+ type LoroCommandsExtension = Extension<{
15
+ Commands: {
16
+ undo: [];
17
+ redo: [];
18
+ };
19
+ }>;
20
+ declare function defineLoroCommands(): LoroCommandsExtension;
21
+
22
+ //#endregion
23
+ //#region src/loro/loro-cursor-plugin.d.ts
24
+ interface LoroCursorOptions {
25
+ awareness: CursorAwareness;
26
+ getSelection?: (state: EditorState) => Selection;
27
+ createCursor?: (user: PeerID) => Element;
28
+ createSelection?: (user: PeerID) => DecorationAttrs;
29
+ }
30
+ declare function defineLoroCursorPlugin(options: LoroCursorOptions): PlainExtension;
31
+
32
+ //#endregion
33
+ //#region src/loro/loro-keymap.d.ts
34
+ declare function defineLoroKeymap(): PlainExtension;
35
+
36
+ //#endregion
37
+ //#region src/loro/loro-sync-plugin.d.ts
38
+ declare function defineLoroSyncPlugin(options: LoroSyncPluginProps$1): PlainExtension;
39
+
40
+ //#endregion
41
+ //#region src/loro/loro-undo-plugin.d.ts
42
+ declare function defineLoroUndoPlugin(options: LoroUndoPluginProps$1): PlainExtension;
43
+
44
+ //#endregion
45
+ //#region src/loro/loro.d.ts
46
+ interface LoroOptions {
47
+ /**
48
+ * The Loro instance handles the state of shared data.
49
+ */
50
+ doc: LoroDocType;
51
+ /**
52
+ * The Awareness instance.
53
+ */
54
+ awareness: CursorAwareness;
55
+ /**
56
+ * Extra options for `LoroSyncPlugin`.
57
+ */
58
+ sync?: Omit<LoroSyncPluginProps$2, "doc">;
59
+ /**
60
+ * Extra options for the `LoroUndoPlugin`.
61
+ */
62
+ undo?: Omit<LoroUndoPluginProps$2, "doc">;
63
+ /**
64
+ * Extra options for `LoroCursorPlugin`.
65
+ */
66
+ cursor?: Omit<LoroCursorOptions, "awareness">;
67
+ }
68
+ /**
69
+ * @internal
70
+ */
71
+ type LoroExtension = Union<[LoroCommandsExtension, PlainExtension]>;
72
+ /**
73
+ * @public
74
+ */
75
+ declare function defineLoro(options: LoroOptions): LoroExtension;
76
+
77
+ //#endregion
78
+ export { LoroCursorOptions, LoroExtension, LoroOptions, LoroSyncPluginProps, LoroUndoPluginProps, defineLoro, defineLoroCommands, defineLoroCursorPlugin, defineLoroKeymap, defineLoroSyncPlugin, defineLoroUndoPlugin };
@@ -1,97 +1,69 @@
1
- // src/loro/loro.ts
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
- // src/loro/loro-commands.ts
9
- import {
10
- defineCommands
11
- } from "@prosekit/core";
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
- return defineCommands(commands);
10
+ return defineCommands(commands);
22
11
  }
23
12
 
24
- // src/loro/loro-cursor-plugin.ts
25
- import {
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
- const { awareness, ...rest } = options;
33
- return definePlugin(LoroCursorPlugin(awareness, rest));
16
+ const { awareness,...rest } = options;
17
+ return definePlugin(LoroCursorPlugin(awareness, rest));
34
18
  }
35
19
 
36
- // src/loro/loro-keymap.ts
37
- import {
38
- defineKeymap,
39
- isApple
40
- } from "@prosekit/core";
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
- return defineKeymap(keymap);
28
+ return defineKeymap(keymap);
54
29
  }
55
30
 
56
- // src/loro/loro-sync-plugin.ts
57
- import {
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
- return definePlugin2(LoroSyncPlugin(options));
34
+ return definePlugin(LoroSyncPlugin(options));
65
35
  }
66
36
 
67
- // src/loro/loro-undo-plugin.ts
68
- import { definePlugin as definePlugin3 } from "@prosekit/core";
69
- import {
70
- LoroUndoPlugin
71
- } from "loro-prosemirror";
37
+ //#endregion
38
+ //#region src/loro/loro-undo-plugin.ts
72
39
  function defineLoroUndoPlugin(options) {
73
- return definePlugin3(LoroUndoPlugin(options));
40
+ return definePlugin(LoroUndoPlugin(options));
74
41
  }
75
42
 
76
- // src/loro/loro.ts
43
+ //#endregion
44
+ //#region src/loro/loro.ts
45
+ /**
46
+ * @public
47
+ */
77
48
  function defineLoro(options) {
78
- const { doc, awareness, sync, undo: undo3, cursor } = options;
79
- return withPriority(
80
- union([
81
- defineLoroKeymap(),
82
- defineLoroCommands(),
83
- defineLoroCursorPlugin({ ...cursor, awareness }),
84
- defineLoroUndoPlugin({ ...undo3, doc }),
85
- defineLoroSyncPlugin({ ...sync, doc })
86
- ]),
87
- Priority.high
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
- export {
91
- defineLoro,
92
- defineLoroCommands,
93
- defineLoroCursorPlugin,
94
- defineLoroKeymap,
95
- defineLoroSyncPlugin,
96
- defineLoroUndoPlugin
97
- };
67
+
68
+ //#endregion
69
+ export { defineLoro, defineLoroCommands, defineLoroCursorPlugin, defineLoroKeymap, defineLoroSyncPlugin, defineLoroUndoPlugin };