@prosekit/extensions 0.7.9 → 0.7.11
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/_tsup-dts-rollup.d.ts +128 -7
- package/dist/{chunk-GPSAJOJA.js → chunk-GITDYNLT.js} +0 -3
- package/dist/{chunk-J57QWYYX.js → chunk-LAQZC3ZM.js} +0 -1
- package/dist/prosekit-extensions-autocomplete.js +3 -2
- package/dist/prosekit-extensions-blockquote.js +2 -2
- package/dist/prosekit-extensions-bold.js +3 -3
- package/dist/prosekit-extensions-code-block.js +3 -3
- package/dist/prosekit-extensions-code.js +3 -3
- package/dist/prosekit-extensions-commit.js +6 -3
- package/dist/prosekit-extensions-heading.d.ts +1 -1
- package/dist/prosekit-extensions-heading.js +3 -3
- package/dist/prosekit-extensions-image.js +1 -1
- package/dist/prosekit-extensions-input-rule.js +1 -1
- package/dist/prosekit-extensions-italic.js +3 -3
- package/dist/prosekit-extensions-link.js +4 -4
- package/dist/prosekit-extensions-list.js +3 -3
- package/dist/prosekit-extensions-mark-rule.js +1 -1
- package/dist/prosekit-extensions-mention.js +1 -1
- package/dist/prosekit-extensions-placeholder.js +0 -1
- package/dist/prosekit-extensions-strike.js +3 -3
- package/dist/prosekit-extensions-table.js +2 -2
- package/dist/prosekit-extensions-text-align.js +2 -2
- package/dist/prosekit-extensions-underline.js +2 -2
- package/dist/prosekit-extensions-yjs.d.ts +14 -0
- package/dist/prosekit-extensions-yjs.js +143 -0
- package/dist/yjs/style.css +31 -0
- package/package.json +34 -8
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Attrs } from '@prosekit/pm/model';
|
2
2
|
import { Attrs as Attrs_2 } from 'prosemirror-model';
|
3
|
+
import type { Awareness } from 'y-protocols/awareness';
|
3
4
|
import { BaseCommandsExtension } from '@prosekit/core';
|
4
5
|
import { BundledLanguage } from 'shiki';
|
5
6
|
import { BundledLanguageInfo } from 'shiki';
|
@@ -23,14 +24,14 @@ import { HistoryExtension } from '@prosekit/core';
|
|
23
24
|
import { IndentListOptions } from 'prosemirror-flat-list';
|
24
25
|
import { InputRule } from '@prosekit/pm/inputrules';
|
25
26
|
import type { IsEqual } from 'type-fest';
|
26
|
-
import
|
27
|
+
import { ListAttributes } from 'prosemirror-flat-list';
|
27
28
|
import { ListDOMSerializer } from 'prosemirror-flat-list';
|
28
29
|
import { MarkType } from '@prosekit/pm/model';
|
29
30
|
import { Node as Node_2 } from 'prosemirror-model';
|
30
31
|
import { NodeAction } from '@prosekit/core';
|
31
32
|
import { NodeChild } from '@prosekit/core';
|
32
33
|
import { NodeJSON } from '@prosekit/core';
|
33
|
-
import { NodeType } from '@prosekit/pm/model';
|
34
|
+
import type { NodeType } from '@prosekit/pm/model';
|
34
35
|
import { Options } from 'tsup';
|
35
36
|
import { Parser } from 'prosemirror-highlight';
|
36
37
|
import { PlainExtension } from '@prosekit/core';
|
@@ -48,6 +49,10 @@ import { Transaction } from '@prosekit/pm/state';
|
|
48
49
|
import { Union } from '@prosekit/core';
|
49
50
|
import { UnwrapListOptions } from 'prosemirror-flat-list';
|
50
51
|
import { WrapInListGetAttrs } from 'prosemirror-flat-list';
|
52
|
+
import type * as Y from 'yjs';
|
53
|
+
import { yCursorPlugin } from 'y-prosemirror';
|
54
|
+
import { ySyncPlugin } from 'y-prosemirror';
|
55
|
+
import { yUndoPlugin } from 'y-prosemirror';
|
51
56
|
|
52
57
|
export declare function applyMarkRules(rules: MarkRuleOptions[], transactions: readonly Transaction[], oldState: EditorState, newState: EditorState): Transaction | null;
|
53
58
|
|
@@ -950,6 +955,31 @@ export declare function defineWrappingInputRule({ regex, type, attrs, join, }: {
|
|
950
955
|
join?: (match: RegExpMatchArray, node: ProseMirrorNode) => boolean;
|
951
956
|
}): PlainExtension;
|
952
957
|
|
958
|
+
/**
|
959
|
+
* @public
|
960
|
+
*/
|
961
|
+
export declare function defineYjs(options: YjsOptions): YjsExtension;
|
962
|
+
|
963
|
+
declare function defineYjsCommands(): YjsCommandsExtension;
|
964
|
+
export { defineYjsCommands }
|
965
|
+
export { defineYjsCommands as defineYjsCommands_alias_1 }
|
966
|
+
|
967
|
+
declare function defineYjsCursorPlugin(options: YjsCursorOptions): PlainExtension;
|
968
|
+
export { defineYjsCursorPlugin }
|
969
|
+
export { defineYjsCursorPlugin as defineYjsCursorPlugin_alias_1 }
|
970
|
+
|
971
|
+
declare function defineYjsKeymap(): PlainExtension;
|
972
|
+
export { defineYjsKeymap }
|
973
|
+
export { defineYjsKeymap as defineYjsKeymap_alias_1 }
|
974
|
+
|
975
|
+
declare function defineYjsSyncPlugin(options: YjsSyncOptions): PlainExtension;
|
976
|
+
export { defineYjsSyncPlugin }
|
977
|
+
export { defineYjsSyncPlugin as defineYjsSyncPlugin_alias_1 }
|
978
|
+
|
979
|
+
declare function defineYjsUndoPlugin(options: YjsUndoOptions): PlainExtension;
|
980
|
+
export { defineYjsUndoPlugin }
|
981
|
+
export { defineYjsUndoPlugin as defineYjsUndoPlugin_alias_1 }
|
982
|
+
|
953
983
|
/**
|
954
984
|
* @internal
|
955
985
|
*/
|
@@ -1391,6 +1421,11 @@ export declare function prepareHighlighter(options: HighlighterOptions): Highlig
|
|
1391
1421
|
*/
|
1392
1422
|
export declare function pressKey(input: string): Promise<void>;
|
1393
1423
|
|
1424
|
+
/**
|
1425
|
+
* @internal
|
1426
|
+
*/
|
1427
|
+
export declare const redo: Command;
|
1428
|
+
|
1394
1429
|
/**
|
1395
1430
|
* Options for {@link defineSearchQuery}
|
1396
1431
|
*
|
@@ -1504,13 +1539,13 @@ export declare function setupTest(): {
|
|
1504
1539
|
level: number;
|
1505
1540
|
}>;
|
1506
1541
|
image: NodeAction< {
|
1507
|
-
src?: string | null;
|
1542
|
+
src?: (string | null) | undefined;
|
1508
1543
|
}>;
|
1509
1544
|
list: NodeAction< {
|
1510
|
-
kind?: "bullet" | "ordered" | "task" | "toggle";
|
1511
|
-
order?: number | null;
|
1512
|
-
checked?: boolean;
|
1513
|
-
collapsed?: boolean;
|
1545
|
+
kind?: ("bullet" | "ordered" | "task" | "toggle") | undefined;
|
1546
|
+
order?: (number | null) | undefined;
|
1547
|
+
checked?: boolean | undefined;
|
1548
|
+
collapsed?: boolean | undefined;
|
1514
1549
|
}>;
|
1515
1550
|
table: NodeAction< {
|
1516
1551
|
readonly [x: string]: any;
|
@@ -1736,6 +1771,11 @@ export declare type UnderlineSpecExtension = Extension<{
|
|
1736
1771
|
};
|
1737
1772
|
}>;
|
1738
1773
|
|
1774
|
+
/**
|
1775
|
+
* @internal
|
1776
|
+
*/
|
1777
|
+
export declare const undo: Command;
|
1778
|
+
|
1739
1779
|
export { UnwrapListOptions }
|
1740
1780
|
|
1741
1781
|
/**
|
@@ -1745,4 +1785,85 @@ export declare type VirtualSelectionExtension = PlainExtension;
|
|
1745
1785
|
|
1746
1786
|
export { WrapInListGetAttrs }
|
1747
1787
|
|
1788
|
+
/**
|
1789
|
+
* @internal
|
1790
|
+
*/
|
1791
|
+
export declare type YjsCommandsExtension = Extension<{
|
1792
|
+
Commands: {
|
1793
|
+
undo: [];
|
1794
|
+
redo: [];
|
1795
|
+
};
|
1796
|
+
}>;
|
1797
|
+
|
1798
|
+
declare interface YjsCursorOptions extends YjsCursorPluginOptions {
|
1799
|
+
awareness: Awareness;
|
1800
|
+
}
|
1801
|
+
export { YjsCursorOptions }
|
1802
|
+
export { YjsCursorOptions as YjsCursorOptions_alias_1 }
|
1803
|
+
|
1804
|
+
/**
|
1805
|
+
* Options for `y-prosemirror`'s `yCursorPlugin`.
|
1806
|
+
*/
|
1807
|
+
declare type YjsCursorPluginOptions = NonNullable<Parameters<typeof yCursorPlugin>[1]>;
|
1808
|
+
export { YjsCursorPluginOptions }
|
1809
|
+
export { YjsCursorPluginOptions as YjsCursorPluginOptions_alias_1 }
|
1810
|
+
|
1811
|
+
/**
|
1812
|
+
* @internal
|
1813
|
+
*/
|
1814
|
+
export declare type YjsExtension = Union<[YjsCommandsExtension, PlainExtension]>;
|
1815
|
+
|
1816
|
+
export declare interface YjsOptions {
|
1817
|
+
/**
|
1818
|
+
* The Yjs instance handles the state of shared data.
|
1819
|
+
*/
|
1820
|
+
doc: Y.Doc;
|
1821
|
+
/**
|
1822
|
+
* The Awareness instance.
|
1823
|
+
*/
|
1824
|
+
awareness: Awareness;
|
1825
|
+
/**
|
1826
|
+
* The Yjs XmlFragment to use. If not provided,
|
1827
|
+
* `doc.getXmlFragment('prosemirror')` will be used.
|
1828
|
+
*/
|
1829
|
+
fragment?: Y.XmlFragment;
|
1830
|
+
/**
|
1831
|
+
* Options for `y-prosemirror`'s `ySyncPlugin`.
|
1832
|
+
*/
|
1833
|
+
sync?: YjsSyncPluginOptions;
|
1834
|
+
/**
|
1835
|
+
* Options for the `y-prosemirror`'s `yUndoPlugin`.
|
1836
|
+
*/
|
1837
|
+
undo?: YjsUndoPluginOptions;
|
1838
|
+
/**
|
1839
|
+
* Options for `y-prosemirror`'s `yCursorPlugin`.
|
1840
|
+
*/
|
1841
|
+
cursor?: YjsCursorPluginOptions;
|
1842
|
+
}
|
1843
|
+
|
1844
|
+
declare interface YjsSyncOptions extends YjsSyncPluginOptions {
|
1845
|
+
fragment: Y.XmlFragment;
|
1846
|
+
}
|
1847
|
+
export { YjsSyncOptions }
|
1848
|
+
export { YjsSyncOptions as YjsSyncOptions_alias_1 }
|
1849
|
+
|
1850
|
+
/**
|
1851
|
+
* Options for `y-prosemirror`'s `ySyncPlugin`.
|
1852
|
+
*/
|
1853
|
+
declare type YjsSyncPluginOptions = NonNullable<Parameters<typeof ySyncPlugin>[1]>;
|
1854
|
+
export { YjsSyncPluginOptions }
|
1855
|
+
export { YjsSyncPluginOptions as YjsSyncPluginOptions_alias_1 }
|
1856
|
+
|
1857
|
+
declare interface YjsUndoOptions extends YjsUndoPluginOptions {
|
1858
|
+
}
|
1859
|
+
export { YjsUndoOptions }
|
1860
|
+
export { YjsUndoOptions as YjsUndoOptions_alias_1 }
|
1861
|
+
|
1862
|
+
/**
|
1863
|
+
* Options for the `y-prosemirror`'s `yUndoPlugin`.
|
1864
|
+
*/
|
1865
|
+
declare type YjsUndoPluginOptions = NonNullable<Parameters<typeof yUndoPlugin>[0]>;
|
1866
|
+
export { YjsUndoPluginOptions }
|
1867
|
+
export { YjsUndoPluginOptions as YjsUndoPluginOptions_alias_1 }
|
1868
|
+
|
1748
1869
|
export { }
|
@@ -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) {
|
@@ -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
|
15
|
-
|
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-
|
3
|
+
} from "./chunk-LAQZC3ZM.js";
|
4
4
|
|
5
5
|
// src/blockquote/index.ts
|
6
6
|
import {
|
@@ -26,7 +26,7 @@ function defineBlockquoteInputRule() {
|
|
26
26
|
});
|
27
27
|
}
|
28
28
|
function defineBlockquote() {
|
29
|
-
return union(
|
29
|
+
return union(defineBlockquoteSpec(), defineBlockquoteInputRule());
|
30
30
|
}
|
31
31
|
export {
|
32
32
|
defineBlockquote,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
2
|
defineMarkInputRule
|
3
|
-
} from "./chunk-
|
3
|
+
} from "./chunk-LAQZC3ZM.js";
|
4
4
|
|
5
5
|
// src/bold/index.ts
|
6
6
|
import {
|
@@ -55,12 +55,12 @@ function defineBoldInputRule() {
|
|
55
55
|
});
|
56
56
|
}
|
57
57
|
function defineBold() {
|
58
|
-
return union(
|
58
|
+
return union(
|
59
59
|
defineBoldSpec(),
|
60
60
|
defineBoldCommands(),
|
61
61
|
defineBoldKeymap(),
|
62
62
|
defineBoldInputRule()
|
63
|
-
|
63
|
+
);
|
64
64
|
}
|
65
65
|
export {
|
66
66
|
defineBold,
|
@@ -3,7 +3,7 @@ import {
|
|
3
3
|
} from "./chunk-RE23OQPF.js";
|
4
4
|
import {
|
5
5
|
defineTextBlockInputRule
|
6
|
-
} from "./chunk-
|
6
|
+
} from "./chunk-LAQZC3ZM.js";
|
7
7
|
|
8
8
|
// src/code-block/code-block.ts
|
9
9
|
import { union } from "@prosekit/core";
|
@@ -118,13 +118,13 @@ function defineCodeBlockSpec() {
|
|
118
118
|
|
119
119
|
// src/code-block/code-block.ts
|
120
120
|
function defineCodeBlock() {
|
121
|
-
return union(
|
121
|
+
return union(
|
122
122
|
defineCodeBlockSpec(),
|
123
123
|
defineCodeBlockInputRule(),
|
124
124
|
defineCodeBlockEnterRule(),
|
125
125
|
defineCodeBlockKeymap(),
|
126
126
|
defineCodeBlockCommands()
|
127
|
-
|
127
|
+
);
|
128
128
|
}
|
129
129
|
|
130
130
|
// src/code-block/code-block-highlight.ts
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
2
|
defineMarkInputRule
|
3
|
-
} from "./chunk-
|
3
|
+
} from "./chunk-LAQZC3ZM.js";
|
4
4
|
|
5
5
|
// src/code/index.ts
|
6
6
|
import {
|
@@ -37,12 +37,12 @@ function defineCodeInputRule() {
|
|
37
37
|
});
|
38
38
|
}
|
39
39
|
function defineCode() {
|
40
|
-
return union(
|
40
|
+
return union(
|
41
41
|
defineCodeSpec(),
|
42
42
|
defineCodeCommands(),
|
43
43
|
defineCodeKeymap(),
|
44
44
|
defineCodeInputRule()
|
45
|
-
|
45
|
+
);
|
46
46
|
}
|
47
47
|
export {
|
48
48
|
defineCode,
|
@@ -11,7 +11,10 @@ import {
|
|
11
11
|
Fragment,
|
12
12
|
Slice
|
13
13
|
} from "@prosekit/pm/model";
|
14
|
-
import {
|
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";
|
@@ -134,10 +137,10 @@ function defineCommitDecoration(commit) {
|
|
134
137
|
});
|
135
138
|
}
|
136
139
|
function defineCommitViewer(commit) {
|
137
|
-
return union(
|
140
|
+
return union(
|
138
141
|
defineDefaultState({ defaultDoc: commit.doc }),
|
139
142
|
defineCommitDecoration(commit)
|
140
|
-
|
143
|
+
);
|
141
144
|
}
|
142
145
|
var CommitRecorder = class {
|
143
146
|
constructor() {
|
@@ -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-
|
3
|
+
} from "./chunk-LAQZC3ZM.js";
|
4
4
|
|
5
5
|
// src/heading/index.ts
|
6
6
|
import { union } from "@prosekit/core";
|
@@ -94,12 +94,12 @@ function defineHeadingSpec() {
|
|
94
94
|
|
95
95
|
// src/heading/index.ts
|
96
96
|
function defineHeading() {
|
97
|
-
return union(
|
97
|
+
return union(
|
98
98
|
defineHeadingSpec(),
|
99
99
|
defineHeadingInputRule(),
|
100
100
|
defineHeadingKeymap(),
|
101
101
|
defineHeadingCommands()
|
102
|
-
|
102
|
+
);
|
103
103
|
}
|
104
104
|
export {
|
105
105
|
defineHeading,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
2
|
defineMarkInputRule
|
3
|
-
} from "./chunk-
|
3
|
+
} from "./chunk-LAQZC3ZM.js";
|
4
4
|
|
5
5
|
// src/italic/index.ts
|
6
6
|
import {
|
@@ -45,12 +45,12 @@ function defineItalicInputRule() {
|
|
45
45
|
});
|
46
46
|
}
|
47
47
|
function defineItalic() {
|
48
|
-
return union(
|
48
|
+
return union(
|
49
49
|
defineItalicSpec(),
|
50
50
|
defineItalicCommands(),
|
51
51
|
defineItalicKeymap(),
|
52
52
|
defineItalicInputRule()
|
53
|
-
|
53
|
+
);
|
54
54
|
}
|
55
55
|
export {
|
56
56
|
defineItalic,
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import {
|
2
2
|
defineMarkRule
|
3
|
-
} from "./chunk-
|
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-
|
9
|
+
} from "./chunk-LAQZC3ZM.js";
|
10
10
|
|
11
11
|
// src/link/index.ts
|
12
12
|
import {
|
@@ -98,12 +98,12 @@ function defineLinkMarkRule() {
|
|
98
98
|
});
|
99
99
|
}
|
100
100
|
function defineLink() {
|
101
|
-
return union(
|
101
|
+
return union(
|
102
102
|
defineLinkSpec(),
|
103
103
|
defineLinkCommands(),
|
104
104
|
defineLinkInputRule(),
|
105
105
|
defineLinkEnterRule()
|
106
|
-
|
106
|
+
);
|
107
107
|
}
|
108
108
|
export {
|
109
109
|
defineLink,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
2
|
defineInputRule
|
3
|
-
} from "./chunk-
|
3
|
+
} from "./chunk-LAQZC3ZM.js";
|
4
4
|
|
5
5
|
// src/list/index.ts
|
6
6
|
import { union as union2 } from "@prosekit/core";
|
@@ -94,13 +94,13 @@ function defineListSpec() {
|
|
94
94
|
// src/list/index.ts
|
95
95
|
import { ListDOMSerializer } from "prosemirror-flat-list";
|
96
96
|
function defineList() {
|
97
|
-
return union2(
|
97
|
+
return union2(
|
98
98
|
defineListSpec(),
|
99
99
|
defineListPlugins(),
|
100
100
|
defineListKeymap(),
|
101
101
|
defineListInputRules(),
|
102
102
|
defineListCommands()
|
103
|
-
|
103
|
+
);
|
104
104
|
}
|
105
105
|
export {
|
106
106
|
ListDOMSerializer,
|
@@ -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-
|
3
|
+
} from "./chunk-LAQZC3ZM.js";
|
4
4
|
|
5
5
|
// src/strike/index.ts
|
6
6
|
import {
|
@@ -44,12 +44,12 @@ function defineStrikeInputRule() {
|
|
44
44
|
});
|
45
45
|
}
|
46
46
|
function defineStrike() {
|
47
|
-
return union(
|
47
|
+
return union(
|
48
48
|
defineStrikeSpec(),
|
49
49
|
defineStrikeCommands(),
|
50
50
|
defineStrikeKeymap(),
|
51
51
|
defineStrikeInputRule()
|
52
|
-
|
52
|
+
);
|
53
53
|
}
|
54
54
|
export {
|
55
55
|
defineStrike,
|
@@ -172,14 +172,14 @@ function defineTableHeaderCellSpec() {
|
|
172
172
|
|
173
173
|
// src/table/index.ts
|
174
174
|
function defineTable() {
|
175
|
-
return union(
|
175
|
+
return union(
|
176
176
|
defineTableSpec(),
|
177
177
|
defineTableRowSpec(),
|
178
178
|
defineTableCellSpec(),
|
179
179
|
defineTableHeaderCellSpec(),
|
180
180
|
defineTablePlugins(),
|
181
181
|
defineTableCommands()
|
182
|
-
|
182
|
+
);
|
183
183
|
}
|
184
184
|
export {
|
185
185
|
defineTable,
|
@@ -41,11 +41,11 @@ function defineTextAlignKeymap(types) {
|
|
41
41
|
});
|
42
42
|
}
|
43
43
|
function defineTextAlign(options) {
|
44
|
-
return union(
|
44
|
+
return union(
|
45
45
|
defineTextAlignAttrs(options.types, options.default || "left"),
|
46
46
|
defineTextAlignKeymap(options.types),
|
47
47
|
defineTextAlignCommands(options.types)
|
48
|
-
|
48
|
+
);
|
49
49
|
}
|
50
50
|
export {
|
51
51
|
defineTextAlign,
|
@@ -31,11 +31,11 @@ function defineUnderlineKeymap() {
|
|
31
31
|
});
|
32
32
|
}
|
33
33
|
function defineUnderline() {
|
34
|
-
return union(
|
34
|
+
return union(
|
35
35
|
defineUnderlineSpec(),
|
36
36
|
defineUnderlineCommands(),
|
37
37
|
defineUnderlineKeymap()
|
38
|
-
|
38
|
+
);
|
39
39
|
}
|
40
40
|
export {
|
41
41
|
defineUnderline,
|
@@ -0,0 +1,14 @@
|
|
1
|
+
export { defineYjs } from './_tsup-dts-rollup';
|
2
|
+
export { YjsOptions } from './_tsup-dts-rollup';
|
3
|
+
export { YjsExtension } from './_tsup-dts-rollup';
|
4
|
+
export { defineYjsCommands_alias_1 as defineYjsCommands } from './_tsup-dts-rollup';
|
5
|
+
export { defineYjsCursorPlugin_alias_1 as defineYjsCursorPlugin } from './_tsup-dts-rollup';
|
6
|
+
export { defineYjsKeymap } from './_tsup-dts-rollup';
|
7
|
+
export { defineYjsSyncPlugin } from './_tsup-dts-rollup';
|
8
|
+
export { defineYjsUndoPlugin } from './_tsup-dts-rollup';
|
9
|
+
export { YjsCursorOptions_alias_1 as YjsCursorOptions } from './_tsup-dts-rollup';
|
10
|
+
export { YjsCursorPluginOptions_alias_1 as YjsCursorPluginOptions } from './_tsup-dts-rollup';
|
11
|
+
export { YjsSyncOptions } from './_tsup-dts-rollup';
|
12
|
+
export { YjsSyncPluginOptions } from './_tsup-dts-rollup';
|
13
|
+
export { YjsUndoOptions } from './_tsup-dts-rollup';
|
14
|
+
export { YjsUndoPluginOptions } from './_tsup-dts-rollup';
|
@@ -0,0 +1,143 @@
|
|
1
|
+
// src/yjs/index.ts
|
2
|
+
import {
|
3
|
+
Priority,
|
4
|
+
union,
|
5
|
+
withPriority
|
6
|
+
} from "@prosekit/core";
|
7
|
+
|
8
|
+
// src/yjs/commands.ts
|
9
|
+
import { defineCommands } from "@prosekit/core";
|
10
|
+
|
11
|
+
// src/yjs/undo-plugin.ts
|
12
|
+
import { definePlugin } from "@prosekit/core";
|
13
|
+
import {
|
14
|
+
yUndoPluginKey,
|
15
|
+
yUndoPlugin as originalYUndoPlugin,
|
16
|
+
undo as yUndo,
|
17
|
+
redo as yRedo
|
18
|
+
} from "y-prosemirror";
|
19
|
+
function fixYUndoPlugin(yUndoPluginInstance) {
|
20
|
+
const originalUndoPluginView = yUndoPluginInstance.spec.view;
|
21
|
+
yUndoPluginInstance.spec.view = (view) => {
|
22
|
+
const { undoManager } = yUndoPluginKey.getState(view.state);
|
23
|
+
if (undoManager.restore) {
|
24
|
+
undoManager.restore();
|
25
|
+
undoManager.restore = () => {
|
26
|
+
};
|
27
|
+
}
|
28
|
+
const viewRet = originalUndoPluginView ? originalUndoPluginView(view) : void 0;
|
29
|
+
return {
|
30
|
+
destroy: () => {
|
31
|
+
const hasUndoManSelf = undoManager.trackedOrigins.has(undoManager);
|
32
|
+
const observers = undoManager._observers;
|
33
|
+
undoManager.restore = () => {
|
34
|
+
if (hasUndoManSelf) {
|
35
|
+
undoManager.trackedOrigins.add(undoManager);
|
36
|
+
}
|
37
|
+
undoManager.doc.on(
|
38
|
+
"afterTransaction",
|
39
|
+
undoManager.afterTransactionHandler
|
40
|
+
);
|
41
|
+
undoManager._observers = observers;
|
42
|
+
};
|
43
|
+
if (viewRet == null ? void 0 : viewRet.destroy) {
|
44
|
+
viewRet.destroy();
|
45
|
+
}
|
46
|
+
}
|
47
|
+
};
|
48
|
+
};
|
49
|
+
}
|
50
|
+
function yUndoPlugin(options) {
|
51
|
+
const yUndoPluginInstance = originalYUndoPlugin(options);
|
52
|
+
fixYUndoPlugin(yUndoPluginInstance);
|
53
|
+
return yUndoPluginInstance;
|
54
|
+
}
|
55
|
+
var undo = (state, dispatch) => {
|
56
|
+
const { undoManager } = yUndoPluginKey.getState(state);
|
57
|
+
if (undoManager.undoStack.length === 0) {
|
58
|
+
return false;
|
59
|
+
}
|
60
|
+
if (!dispatch) {
|
61
|
+
return true;
|
62
|
+
}
|
63
|
+
return yUndo(state);
|
64
|
+
};
|
65
|
+
var redo = (state, dispatch) => {
|
66
|
+
const { undoManager } = yUndoPluginKey.getState(state);
|
67
|
+
if (undoManager.redoStack.length === 0) {
|
68
|
+
return false;
|
69
|
+
}
|
70
|
+
if (!dispatch) {
|
71
|
+
return true;
|
72
|
+
}
|
73
|
+
return yRedo(state);
|
74
|
+
};
|
75
|
+
function defineYjsUndoPlugin(options) {
|
76
|
+
return definePlugin(yUndoPlugin(options));
|
77
|
+
}
|
78
|
+
|
79
|
+
// src/yjs/commands.ts
|
80
|
+
var commands = {
|
81
|
+
undo: () => undo,
|
82
|
+
redo: () => redo
|
83
|
+
};
|
84
|
+
function defineYjsCommands() {
|
85
|
+
return defineCommands(commands);
|
86
|
+
}
|
87
|
+
|
88
|
+
// src/yjs/cursor-plugin.ts
|
89
|
+
import { definePlugin as definePlugin2 } from "@prosekit/core";
|
90
|
+
import { yCursorPlugin } from "y-prosemirror";
|
91
|
+
function defineYjsCursorPlugin(options) {
|
92
|
+
const { awareness, ...rest } = options;
|
93
|
+
return definePlugin2(yCursorPlugin(awareness, rest));
|
94
|
+
}
|
95
|
+
|
96
|
+
// src/yjs/keymap.ts
|
97
|
+
import {
|
98
|
+
defineKeymap,
|
99
|
+
isApple
|
100
|
+
} from "@prosekit/core";
|
101
|
+
var keymap = {
|
102
|
+
"Mod-z": undo,
|
103
|
+
"Shift-Mod-z": redo
|
104
|
+
};
|
105
|
+
if (!isApple) {
|
106
|
+
keymap["Mod-y"] = redo;
|
107
|
+
}
|
108
|
+
function defineYjsKeymap() {
|
109
|
+
return defineKeymap(keymap);
|
110
|
+
}
|
111
|
+
|
112
|
+
// src/yjs/sync-plugin.ts
|
113
|
+
import { definePlugin as definePlugin3 } from "@prosekit/core";
|
114
|
+
import { ySyncPlugin } from "y-prosemirror";
|
115
|
+
function defineYjsSyncPlugin(options) {
|
116
|
+
const { fragment, ...rest } = options;
|
117
|
+
return definePlugin3(ySyncPlugin(fragment, rest));
|
118
|
+
}
|
119
|
+
|
120
|
+
// src/yjs/index.ts
|
121
|
+
function defineYjs(options) {
|
122
|
+
var _a;
|
123
|
+
const { doc, awareness, sync, undo: undo2, cursor } = options;
|
124
|
+
const fragment = (_a = options.fragment) != null ? _a : doc.getXmlFragment("prosemirror");
|
125
|
+
return withPriority(
|
126
|
+
union([
|
127
|
+
defineYjsKeymap(),
|
128
|
+
defineYjsCommands(),
|
129
|
+
defineYjsCursorPlugin({ ...cursor, awareness }),
|
130
|
+
defineYjsUndoPlugin({ ...undo2 }),
|
131
|
+
defineYjsSyncPlugin({ ...sync, fragment })
|
132
|
+
]),
|
133
|
+
Priority.high
|
134
|
+
);
|
135
|
+
}
|
136
|
+
export {
|
137
|
+
defineYjs,
|
138
|
+
defineYjsCommands,
|
139
|
+
defineYjsCursorPlugin,
|
140
|
+
defineYjsKeymap,
|
141
|
+
defineYjsSyncPlugin,
|
142
|
+
defineYjsUndoPlugin
|
143
|
+
};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
/* src/yjs/style.css */
|
2
|
+
.ProseMirror .ProseMirror-yjs-cursor {
|
3
|
+
position: absolute;
|
4
|
+
border-left: black;
|
5
|
+
border-left-style: solid;
|
6
|
+
border-left-width: 2px;
|
7
|
+
border-color: orange;
|
8
|
+
height: 1em;
|
9
|
+
word-break: normal;
|
10
|
+
pointer-events: none;
|
11
|
+
}
|
12
|
+
.ProseMirror .ProseMirror-yjs-cursor > div {
|
13
|
+
position: relative;
|
14
|
+
top: -1.05em;
|
15
|
+
font-size: 13px;
|
16
|
+
background-color: rgb(250, 129, 0);
|
17
|
+
font-family: serif;
|
18
|
+
font-style: normal;
|
19
|
+
font-weight: normal;
|
20
|
+
line-height: normal;
|
21
|
+
-webkit-user-select: none;
|
22
|
+
-moz-user-select: none;
|
23
|
+
-ms-user-select: none;
|
24
|
+
user-select: none;
|
25
|
+
color: white;
|
26
|
+
padding-left: 2px;
|
27
|
+
padding-right: 2px;
|
28
|
+
}
|
29
|
+
.ProseMirror > .ProseMirror-yjs-cursor:first-child {
|
30
|
+
margin-top: 16px;
|
31
|
+
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/extensions",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.7.
|
4
|
+
"version": "0.7.11",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -180,6 +180,14 @@
|
|
180
180
|
},
|
181
181
|
"./virtual-selection/style.css": {
|
182
182
|
"default": "./dist/virtual-selection/style.css"
|
183
|
+
},
|
184
|
+
"./yjs": {
|
185
|
+
"types": "./dist/prosekit-extensions-yjs.d.ts",
|
186
|
+
"import": "./dist/prosekit-extensions-yjs.js",
|
187
|
+
"default": "./dist/prosekit-extensions-yjs.js"
|
188
|
+
},
|
189
|
+
"./yjs/style.css": {
|
190
|
+
"default": "./dist/yjs/style.css"
|
183
191
|
}
|
184
192
|
},
|
185
193
|
"files": [
|
@@ -193,16 +201,31 @@
|
|
193
201
|
"prosemirror-highlight": "^0.8.0",
|
194
202
|
"prosemirror-search": "^1.0.0",
|
195
203
|
"prosemirror-tables": "^1.4.0",
|
196
|
-
"shiki": "^1.
|
197
|
-
"@prosekit/core": "^0.7.
|
204
|
+
"shiki": "^1.14.1",
|
205
|
+
"@prosekit/core": "^0.7.9",
|
198
206
|
"@prosekit/pm": "^0.1.8"
|
199
207
|
},
|
208
|
+
"peerDependencies": {
|
209
|
+
"y-prosemirror": ">= 1.2.9",
|
210
|
+
"yjs": ">= 13.6.18"
|
211
|
+
},
|
212
|
+
"peerDependenciesMeta": {
|
213
|
+
"y-prosemirror": {
|
214
|
+
"optional": true
|
215
|
+
},
|
216
|
+
"yjs": {
|
217
|
+
"optional": true
|
218
|
+
}
|
219
|
+
},
|
200
220
|
"devDependencies": {
|
201
|
-
"@vitest/browser": "^2.0.
|
202
|
-
"tsup": "^8.2.
|
203
|
-
"type-fest": "^4.
|
204
|
-
"typescript": "^5.5.
|
205
|
-
"vitest": "^2.0.
|
221
|
+
"@vitest/browser": "^2.0.5",
|
222
|
+
"tsup": "^8.2.4",
|
223
|
+
"type-fest": "^4.25.0",
|
224
|
+
"typescript": "^5.5.4",
|
225
|
+
"vitest": "^2.0.5",
|
226
|
+
"y-prosemirror": "^1.2.12",
|
227
|
+
"y-protocols": "^1.0.6",
|
228
|
+
"yjs": "^13.6.18",
|
206
229
|
"@prosekit/dev": "0.0.0"
|
207
230
|
},
|
208
231
|
"scripts": {
|
@@ -292,6 +315,9 @@
|
|
292
315
|
],
|
293
316
|
"virtual-selection": [
|
294
317
|
"./dist/prosekit-extensions-virtual-selection.d.ts"
|
318
|
+
],
|
319
|
+
"yjs": [
|
320
|
+
"./dist/prosekit-extensions-yjs.d.ts"
|
295
321
|
]
|
296
322
|
}
|
297
323
|
}
|