@prosekit/extensions 0.7.10 → 0.7.12

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.
@@ -1,6 +1,6 @@
1
1
  import { Attrs } from '@prosekit/pm/model';
2
2
  import { Attrs as Attrs_2 } from 'prosemirror-model';
3
- import { Awareness } from 'y-protocols/awareness';
3
+ import type { Awareness } from 'y-protocols/awareness';
4
4
  import { BaseCommandsExtension } from '@prosekit/core';
5
5
  import { BundledLanguage } from 'shiki';
6
6
  import { BundledLanguageInfo } from 'shiki';
@@ -9,6 +9,8 @@ import { BundledTheme } from 'shiki';
9
9
  import { BundledThemeInfo } from 'shiki';
10
10
  import { bundledThemesInfo } from 'shiki';
11
11
  import { Command } from '@prosekit/pm/state';
12
+ import { CursorAwareness } from 'loro-prosemirror';
13
+ import type { DecorationAttrs } from '@prosekit/pm/view';
12
14
  import { DedentListOptions } from 'prosemirror-flat-list';
13
15
  import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
14
16
  import { DocExtension } from '@prosekit/core';
@@ -24,20 +26,25 @@ import { HistoryExtension } from '@prosekit/core';
24
26
  import { IndentListOptions } from 'prosemirror-flat-list';
25
27
  import { InputRule } from '@prosekit/pm/inputrules';
26
28
  import type { IsEqual } from 'type-fest';
27
- import type { ListAttributes } from 'prosemirror-flat-list';
29
+ import { ListAttributes } from 'prosemirror-flat-list';
28
30
  import { ListDOMSerializer } from 'prosemirror-flat-list';
31
+ import type { LoroDocType } from 'loro-prosemirror';
32
+ import { LoroSyncPluginProps } from 'loro-prosemirror';
33
+ import { LoroUndoPluginProps } from 'loro-prosemirror';
29
34
  import { MarkType } from '@prosekit/pm/model';
30
35
  import { Node as Node_2 } from 'prosemirror-model';
31
36
  import { NodeAction } from '@prosekit/core';
32
37
  import { NodeChild } from '@prosekit/core';
33
38
  import { NodeJSON } from '@prosekit/core';
34
- import { NodeType } from '@prosekit/pm/model';
39
+ import type { NodeType } from '@prosekit/pm/model';
35
40
  import { Options } from 'tsup';
36
41
  import { Parser } from 'prosemirror-highlight';
42
+ import type { PeerID } from 'loro-crdt';
37
43
  import { PlainExtension } from '@prosekit/core';
38
44
  import { Plugin as Plugin_2 } from '@prosekit/pm/state';
39
45
  import { PluginKey } from '@prosekit/pm/state';
40
46
  import { ProseMirrorNode } from '@prosekit/pm/model';
47
+ import type { Selection as Selection_2 } from '@prosekit/pm/state';
41
48
  import { SimplifyDeeper } from '@prosekit/core';
42
49
  import type { SpecialLanguage } from 'shiki';
43
50
  import { StepJSON } from '@prosekit/core';
@@ -49,7 +56,7 @@ import { Transaction } from '@prosekit/pm/state';
49
56
  import { Union } from '@prosekit/core';
50
57
  import { UnwrapListOptions } from 'prosemirror-flat-list';
51
58
  import { WrapInListGetAttrs } from 'prosemirror-flat-list';
52
- import * as Y from 'yjs';
59
+ import type * as Y from 'yjs';
53
60
  import { yCursorPlugin } from 'y-prosemirror';
54
61
  import { ySyncPlugin } from 'y-prosemirror';
55
62
  import { yUndoPlugin } from 'y-prosemirror';
@@ -663,6 +670,31 @@ declare function defineListSpec(): ListSpecExtension;
663
670
  export { defineListSpec }
664
671
  export { defineListSpec as defineListSpec_alias_1 }
665
672
 
673
+ /**
674
+ * @public
675
+ */
676
+ export declare function defineLoro(options: LoroOptions): LoroExtension;
677
+
678
+ declare function defineLoroCommands(): LoroCommandsExtension;
679
+ export { defineLoroCommands }
680
+ export { defineLoroCommands as defineLoroCommands_alias_1 }
681
+
682
+ declare function defineLoroCursorPlugin(options: LoroCursorOptions): PlainExtension;
683
+ export { defineLoroCursorPlugin }
684
+ export { defineLoroCursorPlugin as defineLoroCursorPlugin_alias_1 }
685
+
686
+ declare function defineLoroKeymap(): PlainExtension;
687
+ export { defineLoroKeymap }
688
+ export { defineLoroKeymap as defineLoroKeymap_alias_1 }
689
+
690
+ declare function defineLoroSyncPlugin(options: LoroSyncPluginProps): PlainExtension;
691
+ export { defineLoroSyncPlugin }
692
+ export { defineLoroSyncPlugin as defineLoroSyncPlugin_alias_1 }
693
+
694
+ declare function defineLoroUndoPlugin(options: LoroUndoPluginProps): PlainExtension;
695
+ export { defineLoroUndoPlugin }
696
+ export { defineLoroUndoPlugin as defineLoroUndoPlugin_alias_1 }
697
+
666
698
  /**
667
699
  * Defines an input rule for automatically adding inline marks when a given
668
700
  * pattern is typed.
@@ -1309,6 +1341,57 @@ declare type ListSpecExtension = Extension<{
1309
1341
  export { ListSpecExtension }
1310
1342
  export { ListSpecExtension as ListSpecExtension_alias_1 }
1311
1343
 
1344
+ /**
1345
+ * @internal
1346
+ */
1347
+ export declare type LoroCommandsExtension = Extension<{
1348
+ Commands: {
1349
+ undo: [];
1350
+ redo: [];
1351
+ };
1352
+ }>;
1353
+
1354
+ declare interface LoroCursorOptions {
1355
+ awareness: CursorAwareness;
1356
+ getSelection?: (state: EditorState) => Selection_2;
1357
+ createCursor?: (user: PeerID) => Element;
1358
+ createSelection?: (user: PeerID) => DecorationAttrs;
1359
+ }
1360
+ export { LoroCursorOptions }
1361
+ export { LoroCursorOptions as LoroCursorOptions_alias_1 }
1362
+
1363
+ /**
1364
+ * @internal
1365
+ */
1366
+ export declare type LoroExtension = Union<[LoroCommandsExtension, PlainExtension]>;
1367
+
1368
+ export declare interface LoroOptions {
1369
+ /**
1370
+ * The Loro instance handles the state of shared data.
1371
+ */
1372
+ doc: LoroDocType;
1373
+ /**
1374
+ * The Awareness instance.
1375
+ */
1376
+ awareness: CursorAwareness;
1377
+ /**
1378
+ * Extra options for `LoroSyncPlugin`.
1379
+ */
1380
+ sync?: Omit<LoroSyncPluginProps, 'doc'>;
1381
+ /**
1382
+ * Extra options for the `LoroUndoPlugin`.
1383
+ */
1384
+ undo?: Omit<LoroUndoPluginProps, 'doc'>;
1385
+ /**
1386
+ * Extra options for `LoroCursorPlugin`.
1387
+ */
1388
+ cursor?: Omit<LoroCursorOptions, 'awareness'>;
1389
+ }
1390
+
1391
+ export { LoroSyncPluginProps }
1392
+
1393
+ export { LoroUndoPluginProps }
1394
+
1312
1395
  /**
1313
1396
  * Options for {@link defineMarkInputRule}.
1314
1397
  *
@@ -15,11 +15,8 @@ import {
15
15
  getMarkType,
16
16
  maybeRun
17
17
  } from "@prosekit/core";
18
- import "@prosekit/pm/model";
19
- import "@prosekit/pm/state";
20
18
 
21
19
  // src/mark-rule/range.ts
22
- import "@prosekit/pm/state";
23
20
  function getSpanTextRanges($from, $to) {
24
21
  const nodeRange = $from.blockRange($to);
25
22
  if (!nodeRange) {
@@ -14,7 +14,6 @@ import {
14
14
  textblockTypeInputRule,
15
15
  wrappingInputRule
16
16
  } from "@prosekit/pm/inputrules";
17
- import "@prosekit/pm/model";
18
17
  import "@prosekit/pm/state";
19
18
  function defineInputRule(rule) {
20
19
  return defineInputRuleFacetPayload(() => rule);
@@ -0,0 +1,30 @@
1
+ /* src/loro/style.css */
2
+ .ProseMirror-loro-cursor:first-child {
3
+ margin-top: 16px;
4
+ }
5
+ .ProseMirror-loro-cursor {
6
+ position: relative;
7
+ margin-left: -1px;
8
+ margin-right: -1px;
9
+ border-left: 1px solid black;
10
+ border-right: 1px solid black;
11
+ border-color: orange;
12
+ word-break: normal;
13
+ pointer-events: none;
14
+ }
15
+ .ProseMirror-loro-cursor > div {
16
+ position: absolute;
17
+ top: -1.05em;
18
+ left: -1px;
19
+ font-size: 13px;
20
+ background-color: rgb(250, 129, 0);
21
+ font-family: serif;
22
+ font-style: normal;
23
+ font-weight: normal;
24
+ line-height: normal;
25
+ user-select: none;
26
+ color: white;
27
+ padding-left: 2px;
28
+ padding-right: 2px;
29
+ white-space: nowrap;
30
+ }
@@ -11,8 +11,9 @@ import { Plugin } from "@prosekit/pm/state";
11
11
  import { Decoration, DecorationSet } from "@prosekit/pm/view";
12
12
 
13
13
  // src/autocomplete/helpers.ts
14
- import "@prosekit/pm/model";
15
- import { PluginKey } from "@prosekit/pm/state";
14
+ import {
15
+ PluginKey
16
+ } from "@prosekit/pm/state";
16
17
  function defaultCanMatch({ state }) {
17
18
  return state.selection.empty && !isInsideCode(state.selection.$from);
18
19
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineWrappingInputRule
3
- } from "./chunk-J57QWYYX.js";
3
+ } from "./chunk-LAQZC3ZM.js";
4
4
 
5
5
  // src/blockquote/index.ts
6
6
  import {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineMarkInputRule
3
- } from "./chunk-J57QWYYX.js";
3
+ } from "./chunk-LAQZC3ZM.js";
4
4
 
5
5
  // src/bold/index.ts
6
6
  import {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-RE23OQPF.js";
4
4
  import {
5
5
  defineTextBlockInputRule
6
- } from "./chunk-J57QWYYX.js";
6
+ } from "./chunk-LAQZC3ZM.js";
7
7
 
8
8
  // src/code-block/code-block.ts
9
9
  import { union } from "@prosekit/core";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineMarkInputRule
3
- } from "./chunk-J57QWYYX.js";
3
+ } from "./chunk-LAQZC3ZM.js";
4
4
 
5
5
  // src/code/index.ts
6
6
  import {
@@ -11,7 +11,10 @@ import {
11
11
  Fragment,
12
12
  Slice
13
13
  } from "@prosekit/pm/model";
14
- import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state";
14
+ import {
15
+ PluginKey,
16
+ ProseMirrorPlugin
17
+ } from "@prosekit/pm/state";
15
18
  import { Step } from "@prosekit/pm/transform";
16
19
  import { Decoration, DecorationSet } from "@prosekit/pm/view";
17
20
  import { ChangeSet } from "prosemirror-changeset";
@@ -4,6 +4,6 @@ export { defineHeadingCommands_alias_1 as defineHeadingCommands } from './_tsup-
4
4
  export { defineHeadingInputRule } from './_tsup-dts-rollup';
5
5
  export { defineHeadingKeymap } from './_tsup-dts-rollup';
6
6
  export { defineHeadingSpec } from './_tsup-dts-rollup';
7
+ export { HeadingAttrs } from './_tsup-dts-rollup';
7
8
  export { HeadingCommandsExtension_alias_1 as HeadingCommandsExtension } from './_tsup-dts-rollup';
8
9
  export { HeadingSpecExtension } from './_tsup-dts-rollup';
9
- export { HeadingAttrs } from './_tsup-dts-rollup';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineTextBlockInputRule
3
- } from "./chunk-J57QWYYX.js";
3
+ } from "./chunk-LAQZC3ZM.js";
4
4
 
5
5
  // src/heading/index.ts
6
6
  import { union } from "@prosekit/core";
@@ -4,7 +4,7 @@ import {
4
4
  defineMarkInputRule,
5
5
  defineTextBlockInputRule,
6
6
  defineWrappingInputRule
7
- } from "./chunk-J57QWYYX.js";
7
+ } from "./chunk-LAQZC3ZM.js";
8
8
  export {
9
9
  createMarkInputRule,
10
10
  defineInputRule,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineMarkInputRule
3
- } from "./chunk-J57QWYYX.js";
3
+ } from "./chunk-LAQZC3ZM.js";
4
4
 
5
5
  // src/italic/index.ts
6
6
  import {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  defineMarkRule
3
- } from "./chunk-GPSAJOJA.js";
3
+ } from "./chunk-GITDYNLT.js";
4
4
  import {
5
5
  defineEnterRule
6
6
  } from "./chunk-RE23OQPF.js";
7
7
  import {
8
8
  defineInputRule
9
- } from "./chunk-J57QWYYX.js";
9
+ } from "./chunk-LAQZC3ZM.js";
10
10
 
11
11
  // src/link/index.ts
12
12
  import {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineInputRule
3
- } from "./chunk-J57QWYYX.js";
3
+ } from "./chunk-LAQZC3ZM.js";
4
4
 
5
5
  // src/list/index.ts
6
6
  import { union as union2 } from "@prosekit/core";
@@ -0,0 +1,11 @@
1
+ export { defineLoro } from './_tsup-dts-rollup';
2
+ export { LoroOptions } from './_tsup-dts-rollup';
3
+ export { LoroExtension } from './_tsup-dts-rollup';
4
+ export { defineLoroCommands_alias_1 as defineLoroCommands } from './_tsup-dts-rollup';
5
+ export { defineLoroCursorPlugin_alias_1 as defineLoroCursorPlugin } from './_tsup-dts-rollup';
6
+ export { defineLoroKeymap } from './_tsup-dts-rollup';
7
+ export { defineLoroSyncPlugin } from './_tsup-dts-rollup';
8
+ export { defineLoroUndoPlugin } from './_tsup-dts-rollup';
9
+ export { LoroCursorOptions_alias_1 as LoroCursorOptions } from './_tsup-dts-rollup';
10
+ export { LoroSyncPluginProps } from './_tsup-dts-rollup';
11
+ export { LoroUndoPluginProps } from './_tsup-dts-rollup';
@@ -0,0 +1,79 @@
1
+ // src/loro/index.ts
2
+ import {
3
+ Priority,
4
+ union,
5
+ withPriority
6
+ } from "@prosekit/core";
7
+
8
+ // src/loro/commands.ts
9
+ import { defineCommands } from "@prosekit/core";
10
+ import { redo, undo } from "loro-prosemirror";
11
+ var commands = {
12
+ undo: () => undo,
13
+ redo: () => redo
14
+ };
15
+ function defineLoroCommands() {
16
+ return defineCommands(commands);
17
+ }
18
+
19
+ // src/loro/cursor-plugin.ts
20
+ import { definePlugin } from "@prosekit/core";
21
+ import { LoroCursorPlugin } from "loro-prosemirror";
22
+ function defineLoroCursorPlugin(options) {
23
+ const { awareness, ...rest } = options;
24
+ return definePlugin(LoroCursorPlugin(awareness, rest));
25
+ }
26
+
27
+ // src/loro/keymap.ts
28
+ import {
29
+ defineKeymap,
30
+ isApple
31
+ } from "@prosekit/core";
32
+ import { redo as redo2, undo as undo2 } from "loro-prosemirror";
33
+ var keymap = {
34
+ "Mod-z": undo2,
35
+ "Shift-Mod-z": redo2
36
+ };
37
+ if (!isApple) {
38
+ keymap["Mod-y"] = redo2;
39
+ }
40
+ function defineLoroKeymap() {
41
+ return defineKeymap(keymap);
42
+ }
43
+
44
+ // src/loro/sync-plugin.ts
45
+ import { definePlugin as definePlugin2 } from "@prosekit/core";
46
+ import { LoroSyncPlugin } from "loro-prosemirror";
47
+ function defineLoroSyncPlugin(options) {
48
+ return definePlugin2(LoroSyncPlugin(options));
49
+ }
50
+
51
+ // src/loro/undo-plugin.ts
52
+ import { definePlugin as definePlugin3 } from "@prosekit/core";
53
+ import { LoroUndoPlugin } from "loro-prosemirror";
54
+ function defineLoroUndoPlugin(options) {
55
+ return definePlugin3(LoroUndoPlugin(options));
56
+ }
57
+
58
+ // src/loro/index.ts
59
+ function defineLoro(options) {
60
+ const { doc, awareness, sync, undo: undo3, cursor } = options;
61
+ return withPriority(
62
+ union([
63
+ defineLoroKeymap(),
64
+ defineLoroCommands(),
65
+ defineLoroCursorPlugin({ ...cursor, awareness }),
66
+ defineLoroUndoPlugin({ ...undo3, doc }),
67
+ defineLoroSyncPlugin({ ...sync, doc })
68
+ ]),
69
+ Priority.high
70
+ );
71
+ }
72
+ export {
73
+ defineLoro,
74
+ defineLoroCommands,
75
+ defineLoroCursorPlugin,
76
+ defineLoroKeymap,
77
+ defineLoroSyncPlugin,
78
+ defineLoroUndoPlugin
79
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineMarkRule
3
- } from "./chunk-GPSAJOJA.js";
3
+ } from "./chunk-GITDYNLT.js";
4
4
  export {
5
5
  defineMarkRule
6
6
  };
@@ -1,6 +1,5 @@
1
1
  // src/placeholder/index.ts
2
2
  import { definePlugin, isInCodeBlock } from "@prosekit/core";
3
- import "@prosekit/pm/model";
4
3
  import { Plugin, PluginKey } from "@prosekit/pm/state";
5
4
  import { Decoration, DecorationSet } from "@prosekit/pm/view";
6
5
  function definePlaceholder(options) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineMarkInputRule
3
- } from "./chunk-J57QWYYX.js";
3
+ } from "./chunk-LAQZC3ZM.js";
4
4
 
5
5
  // src/strike/index.ts
6
6
  import {
@@ -5,12 +5,6 @@ import {
5
5
  withPriority
6
6
  } from "@prosekit/core";
7
7
 
8
- // ../../node_modules/.pnpm/y-protocols@1.0.6_yjs@13.6.18/node_modules/y-protocols/awareness.js
9
- import * as Y from "yjs";
10
-
11
- // src/yjs/index.ts
12
- import "yjs";
13
-
14
8
  // src/yjs/commands.ts
15
9
  import { defineCommands } from "@prosekit/core";
16
10
 
@@ -118,7 +112,6 @@ function defineYjsKeymap() {
118
112
  // src/yjs/sync-plugin.ts
119
113
  import { definePlugin as definePlugin3 } from "@prosekit/core";
120
114
  import { ySyncPlugin } from "y-prosemirror";
121
- import "yjs";
122
115
  function defineYjsSyncPlugin(options) {
123
116
  const { fragment, ...rest } = options;
124
117
  return definePlugin3(ySyncPlugin(fragment, rest));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/extensions",
3
3
  "type": "module",
4
- "version": "0.7.10",
4
+ "version": "0.7.12",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -114,6 +114,14 @@
114
114
  "./list/style.css": {
115
115
  "default": "./dist/list/style.css"
116
116
  },
117
+ "./loro": {
118
+ "types": "./dist/prosekit-extensions-loro.d.ts",
119
+ "import": "./dist/prosekit-extensions-loro.js",
120
+ "default": "./dist/prosekit-extensions-loro.js"
121
+ },
122
+ "./loro/style.css": {
123
+ "default": "./dist/loro/style.css"
124
+ },
117
125
  "./mark-rule": {
118
126
  "types": "./dist/prosekit-extensions-mark-rule.d.ts",
119
127
  "import": "./dist/prosekit-extensions-mark-rule.js",
@@ -201,15 +209,23 @@
201
209
  "prosemirror-highlight": "^0.8.0",
202
210
  "prosemirror-search": "^1.0.0",
203
211
  "prosemirror-tables": "^1.4.0",
204
- "shiki": "^1.12.1",
205
- "@prosekit/core": "^0.7.8",
212
+ "shiki": "^1.14.1",
213
+ "@prosekit/core": "^0.7.9",
206
214
  "@prosekit/pm": "^0.1.8"
207
215
  },
208
216
  "peerDependencies": {
217
+ "loro-crdt": ">= 0.16.7",
218
+ "loro-prosemirror": ">= 0.0.7",
209
219
  "y-prosemirror": ">= 1.2.9",
210
220
  "yjs": ">= 13.6.18"
211
221
  },
212
222
  "peerDependenciesMeta": {
223
+ "loro-crdt": {
224
+ "optional": true
225
+ },
226
+ "loro-prosemirror": {
227
+ "optional": true
228
+ },
213
229
  "y-prosemirror": {
214
230
  "optional": true
215
231
  },
@@ -219,11 +235,13 @@
219
235
  },
220
236
  "devDependencies": {
221
237
  "@vitest/browser": "^2.0.5",
238
+ "loro-crdt": "^0.16.7",
239
+ "loro-prosemirror": "^0.0.7",
222
240
  "tsup": "^8.2.4",
223
- "type-fest": "^4.23.0",
241
+ "type-fest": "^4.25.0",
224
242
  "typescript": "^5.5.4",
225
243
  "vitest": "^2.0.5",
226
- "y-prosemirror": "^1.2.9",
244
+ "y-prosemirror": "^1.2.12",
227
245
  "y-protocols": "^1.0.6",
228
246
  "yjs": "^13.6.18",
229
247
  "@prosekit/dev": "0.0.0"
@@ -283,6 +301,9 @@
283
301
  "list": [
284
302
  "./dist/prosekit-extensions-list.d.ts"
285
303
  ],
304
+ "loro": [
305
+ "./dist/prosekit-extensions-loro.d.ts"
306
+ ],
286
307
  "mark-rule": [
287
308
  "./dist/prosekit-extensions-mark-rule.d.ts"
288
309
  ],