@prosekit/extensions 0.16.0-beta.0 → 0.16.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.
- package/dist/{prosekit-extensions-autocomplete.d.ts → autocomplete.d.ts} +1 -6
- package/dist/autocomplete.d.ts.map +1 -0
- package/dist/{prosekit-extensions-autocomplete.js → autocomplete.js} +1 -9
- package/dist/autocomplete.js.map +1 -0
- package/dist/{prosekit-extensions-background-color.d.ts → background-color.d.ts} +1 -8
- package/dist/background-color.d.ts.map +1 -0
- package/dist/{prosekit-extensions-background-color.js → background-color.js} +1 -7
- package/dist/background-color.js.map +1 -0
- package/dist/{prosekit-extensions-blockquote.d.ts → blockquote.d.ts} +1 -12
- package/dist/blockquote.d.ts.map +1 -0
- package/dist/{prosekit-extensions-blockquote.js → blockquote.js} +2 -12
- package/dist/blockquote.js.map +1 -0
- package/dist/{prosekit-extensions-bold.d.ts → bold.d.ts} +1 -12
- package/dist/bold.d.ts.map +1 -0
- package/dist/{prosekit-extensions-bold.js → bold.js} +2 -12
- package/dist/bold.js.map +1 -0
- package/dist/{prosekit-extensions-code-block.d.ts → code-block.d.ts} +1 -20
- package/dist/code-block.d.ts.map +1 -0
- package/dist/{prosekit-extensions-code-block.js → code-block.js} +3 -21
- package/dist/code-block.js.map +1 -0
- package/dist/{prosekit-extensions-code.d.ts → code.d.ts} +1 -12
- package/dist/code.d.ts.map +1 -0
- package/dist/{prosekit-extensions-code.js → code.js} +2 -12
- package/dist/code.js.map +1 -0
- package/dist/{prosekit-extensions-commit.d.ts → commit.d.ts} +1 -4
- package/dist/commit.d.ts.map +1 -0
- package/dist/{prosekit-extensions-commit.js → commit.js} +1 -3
- package/dist/commit.js.map +1 -0
- package/dist/{prosekit-extensions-doc.d.ts → doc.d.ts} +1 -4
- package/dist/doc.d.ts.map +1 -0
- package/dist/{prosekit-extensions-doc.js → doc.js} +1 -3
- package/dist/doc.js.map +1 -0
- package/dist/{prosekit-extensions-drop-cursor.d.ts → drop-cursor.d.ts} +1 -4
- package/dist/drop-cursor.d.ts.map +1 -0
- package/dist/{prosekit-extensions-drop-cursor.js → drop-cursor.js} +1 -3
- package/dist/drop-cursor.js.map +1 -0
- package/dist/{prosekit-extensions-drop-indicator.d.ts → drop-indicator.d.ts} +1 -4
- package/dist/drop-indicator.d.ts.map +1 -0
- package/dist/drop-indicator.js +2 -57
- package/dist/drop-indicator2.js +53 -0
- package/dist/drop-indicator2.js.map +1 -0
- package/dist/{prosekit-extensions-enter-rule.d.ts → enter-rule.d.ts} +1 -4
- package/dist/enter-rule.d.ts.map +1 -0
- package/dist/{prosekit-extensions-enter-rule.js → enter-rule.js} +1 -3
- package/dist/enter-rule.js.map +1 -0
- package/dist/file.js +2 -128
- package/dist/file2.js +120 -0
- package/dist/file2.js.map +1 -0
- package/dist/{prosekit-extensions-gap-cursor.d.ts → gap-cursor.d.ts} +1 -4
- package/dist/gap-cursor.d.ts.map +1 -0
- package/dist/{prosekit-extensions-gap-cursor.js → gap-cursor.js} +1 -3
- package/dist/gap-cursor.js.map +1 -0
- package/dist/{prosekit-extensions-hard-break.d.ts → hard-break.d.ts} +1 -10
- package/dist/hard-break.d.ts.map +1 -0
- package/dist/{prosekit-extensions-hard-break.js → hard-break.js} +1 -9
- package/dist/hard-break.js.map +1 -0
- package/dist/{prosekit-extensions-heading.d.ts → heading.d.ts} +1 -14
- package/dist/heading.d.ts.map +1 -0
- package/dist/{prosekit-extensions-heading.js → heading.js} +2 -12
- package/dist/heading.js.map +1 -0
- package/dist/{prosekit-extensions-horizontal-rule.d.ts → horizontal-rule.d.ts} +1 -10
- package/dist/horizontal-rule.d.ts.map +1 -0
- package/dist/{prosekit-extensions-horizontal-rule.js → horizontal-rule.js} +2 -10
- package/dist/horizontal-rule.js.map +1 -0
- package/dist/{prosekit-extensions-image.d.ts → image.d.ts} +1 -14
- package/dist/image.d.ts.map +1 -0
- package/dist/{prosekit-extensions-image.js → image.js} +2 -14
- package/dist/image.js.map +1 -0
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/{prosekit-extensions-input-rule.d.ts → input-rule.d.ts} +1 -4
- package/dist/input-rule.d.ts.map +1 -0
- package/dist/{prosekit-extensions-input-rule.js → input-rule.js} +1 -3
- package/dist/input-rule.js.map +1 -0
- package/dist/{prosekit-extensions-italic.d.ts → italic.d.ts} +1 -12
- package/dist/italic.d.ts.map +1 -0
- package/dist/{prosekit-extensions-italic.js → italic.js} +2 -12
- package/dist/italic.js.map +1 -0
- package/dist/{prosekit-extensions-link.d.ts → link.d.ts} +1 -8
- package/dist/link.d.ts.map +1 -0
- package/dist/{prosekit-extensions-link.js → link.js} +5 -11
- package/dist/link.js.map +1 -0
- package/dist/{prosekit-extensions-list.d.ts → list.d.ts} +1 -18
- package/dist/list.d.ts.map +1 -0
- package/dist/{prosekit-extensions-list.js → list.js} +3 -19
- package/dist/list.js.map +1 -0
- package/dist/{prosekit-extensions-loro.d.ts → loro.d.ts} +1 -14
- package/dist/loro.d.ts.map +1 -0
- package/dist/{prosekit-extensions-loro.js → loro.js} +1 -13
- package/dist/loro.js.map +1 -0
- package/dist/{prosekit-extensions-mark-rule.d.ts → mark-rule.d.ts} +1 -6
- package/dist/mark-rule.d.ts.map +1 -0
- package/dist/mark-rule.js +2 -157
- package/dist/mark-rule2.js +151 -0
- package/dist/mark-rule2.js.map +1 -0
- package/dist/{prosekit-extensions-math.d.ts → math.d.ts} +1 -10
- package/dist/math.d.ts.map +1 -0
- package/dist/{prosekit-extensions-math.js → math.js} +3 -11
- package/dist/math.js.map +1 -0
- package/dist/{prosekit-extensions-mention.d.ts → mention.d.ts} +1 -4
- package/dist/mention.d.ts.map +1 -0
- package/dist/{prosekit-extensions-mention.js → mention.js} +1 -3
- package/dist/mention.js.map +1 -0
- package/dist/{prosekit-extensions-mod-click-prevention.d.ts → mod-click-prevention.d.ts} +1 -4
- package/dist/mod-click-prevention.d.ts.map +1 -0
- package/dist/{prosekit-extensions-mod-click-prevention.js → mod-click-prevention.js} +1 -3
- package/dist/mod-click-prevention.js.map +1 -0
- package/dist/{prosekit-extensions-page.d.ts → page.d.ts} +1 -12
- package/dist/page.d.ts.map +1 -0
- package/dist/{prosekit-extensions-page.js → page.js} +3 -15
- package/dist/page.js.map +1 -0
- package/dist/{prosekit-extensions-paragraph.d.ts → paragraph.d.ts} +1 -10
- package/dist/paragraph.d.ts.map +1 -0
- package/dist/{prosekit-extensions-paragraph.js → paragraph.js} +1 -9
- package/dist/paragraph.js.map +1 -0
- package/dist/{prosekit-extensions-paste-rule.d.ts → paste-rule.d.ts} +1 -6
- package/dist/paste-rule.d.ts.map +1 -0
- package/dist/paste-rule.js +2 -158
- package/dist/paste-rule2.js +150 -0
- package/dist/paste-rule2.js.map +1 -0
- package/dist/{prosekit-extensions-placeholder.d.ts → placeholder.d.ts} +1 -4
- package/dist/placeholder.d.ts.map +1 -0
- package/dist/{prosekit-extensions-placeholder.js → placeholder.js} +2 -4
- package/dist/placeholder.js.map +1 -0
- package/dist/{prosekit-extensions-readonly.d.ts → readonly.d.ts} +1 -4
- package/dist/readonly.d.ts.map +1 -0
- package/dist/{prosekit-extensions-readonly.js → readonly.js} +6 -3
- package/dist/readonly.js.map +1 -0
- package/dist/{prosekit-extensions-search.d.ts → search.d.ts} +1 -4
- package/dist/search.d.ts.map +1 -0
- package/dist/{prosekit-extensions-search.js → search.js} +1 -3
- package/dist/search.js.map +1 -0
- package/dist/shiki-highlighter-chunk.js +0 -2
- package/dist/shiki-highlighter-chunk.js.map +1 -1
- package/dist/{prosekit-extensions-strike.d.ts → strike.d.ts} +1 -4
- package/dist/strike.d.ts.map +1 -0
- package/dist/{prosekit-extensions-strike.js → strike.js} +2 -4
- package/dist/strike.js.map +1 -0
- package/dist/{prosekit-extensions-table.d.ts → table.d.ts} +1 -26
- package/dist/table.d.ts.map +1 -0
- package/dist/table.js +2 -276
- package/dist/table2.js +252 -0
- package/dist/table2.js.map +1 -0
- package/dist/{prosekit-extensions-text-align.d.ts → text-align.d.ts} +1 -4
- package/dist/text-align.d.ts.map +1 -0
- package/dist/{prosekit-extensions-text-align.js → text-align.js} +1 -3
- package/dist/text-align.js.map +1 -0
- package/dist/{prosekit-extensions-text-color.d.ts → text-color.d.ts} +1 -8
- package/dist/text-color.d.ts.map +1 -0
- package/dist/{prosekit-extensions-text-color.js → text-color.js} +1 -7
- package/dist/text-color.js.map +1 -0
- package/dist/{prosekit-extensions-text.d.ts → text.d.ts} +1 -4
- package/dist/text.d.ts.map +1 -0
- package/dist/{prosekit-extensions-text.js → text.js} +1 -3
- package/dist/text.js.map +1 -0
- package/dist/{prosekit-extensions-underline.d.ts → underline.d.ts} +1 -4
- package/dist/underline.d.ts.map +1 -0
- package/dist/{prosekit-extensions-underline.js → underline.js} +1 -3
- package/dist/underline.js.map +1 -0
- package/dist/{prosekit-extensions-virtual-selection.d.ts → virtual-selection.d.ts} +1 -4
- package/dist/virtual-selection.d.ts.map +1 -0
- package/dist/{prosekit-extensions-virtual-selection.js → virtual-selection.js} +1 -3
- package/dist/virtual-selection.js.map +1 -0
- package/dist/{prosekit-extensions-yjs.d.ts → yjs.d.ts} +1 -16
- package/dist/yjs.d.ts.map +1 -0
- package/dist/{prosekit-extensions-yjs.js → yjs.js} +1 -13
- package/dist/yjs.js.map +1 -0
- package/package.json +136 -194
- package/src/page/page-element.ts +2 -2
- package/src/readonly/index.ts +6 -0
- package/dist/drop-indicator.js.map +0 -1
- package/dist/file.js.map +0 -1
- package/dist/mark-rule.js.map +0 -1
- package/dist/paste-rule.js.map +0 -1
- package/dist/prosekit-extensions-autocomplete.d.ts.map +0 -1
- package/dist/prosekit-extensions-autocomplete.js.map +0 -1
- package/dist/prosekit-extensions-background-color.d.ts.map +0 -1
- package/dist/prosekit-extensions-background-color.js.map +0 -1
- package/dist/prosekit-extensions-blockquote.d.ts.map +0 -1
- package/dist/prosekit-extensions-blockquote.js.map +0 -1
- package/dist/prosekit-extensions-bold.d.ts.map +0 -1
- package/dist/prosekit-extensions-bold.js.map +0 -1
- package/dist/prosekit-extensions-code-block.d.ts.map +0 -1
- package/dist/prosekit-extensions-code-block.js.map +0 -1
- package/dist/prosekit-extensions-code.d.ts.map +0 -1
- package/dist/prosekit-extensions-code.js.map +0 -1
- package/dist/prosekit-extensions-commit.d.ts.map +0 -1
- package/dist/prosekit-extensions-commit.js.map +0 -1
- package/dist/prosekit-extensions-doc.d.ts.map +0 -1
- package/dist/prosekit-extensions-doc.js.map +0 -1
- package/dist/prosekit-extensions-drop-cursor.d.ts.map +0 -1
- package/dist/prosekit-extensions-drop-cursor.js.map +0 -1
- package/dist/prosekit-extensions-drop-indicator.d.ts.map +0 -1
- package/dist/prosekit-extensions-drop-indicator.js +0 -2
- package/dist/prosekit-extensions-enter-rule.d.ts.map +0 -1
- package/dist/prosekit-extensions-enter-rule.js.map +0 -1
- package/dist/prosekit-extensions-file.js +0 -2
- package/dist/prosekit-extensions-gap-cursor.d.ts.map +0 -1
- package/dist/prosekit-extensions-gap-cursor.js.map +0 -1
- package/dist/prosekit-extensions-hard-break.d.ts.map +0 -1
- package/dist/prosekit-extensions-hard-break.js.map +0 -1
- package/dist/prosekit-extensions-heading.d.ts.map +0 -1
- package/dist/prosekit-extensions-heading.js.map +0 -1
- package/dist/prosekit-extensions-horizontal-rule.d.ts.map +0 -1
- package/dist/prosekit-extensions-horizontal-rule.js.map +0 -1
- package/dist/prosekit-extensions-image.d.ts.map +0 -1
- package/dist/prosekit-extensions-image.js.map +0 -1
- package/dist/prosekit-extensions-input-rule.d.ts.map +0 -1
- package/dist/prosekit-extensions-input-rule.js.map +0 -1
- package/dist/prosekit-extensions-italic.d.ts.map +0 -1
- package/dist/prosekit-extensions-italic.js.map +0 -1
- package/dist/prosekit-extensions-link.d.ts.map +0 -1
- package/dist/prosekit-extensions-link.js.map +0 -1
- package/dist/prosekit-extensions-list.d.ts.map +0 -1
- package/dist/prosekit-extensions-list.js.map +0 -1
- package/dist/prosekit-extensions-loro.d.ts.map +0 -1
- package/dist/prosekit-extensions-loro.js.map +0 -1
- package/dist/prosekit-extensions-mark-rule.d.ts.map +0 -1
- package/dist/prosekit-extensions-mark-rule.js +0 -2
- package/dist/prosekit-extensions-math.d.ts.map +0 -1
- package/dist/prosekit-extensions-math.js.map +0 -1
- package/dist/prosekit-extensions-mention.d.ts.map +0 -1
- package/dist/prosekit-extensions-mention.js.map +0 -1
- package/dist/prosekit-extensions-mod-click-prevention.d.ts.map +0 -1
- package/dist/prosekit-extensions-mod-click-prevention.js.map +0 -1
- package/dist/prosekit-extensions-page.d.ts.map +0 -1
- package/dist/prosekit-extensions-page.js.map +0 -1
- package/dist/prosekit-extensions-paragraph.d.ts.map +0 -1
- package/dist/prosekit-extensions-paragraph.js.map +0 -1
- package/dist/prosekit-extensions-paste-rule.d.ts.map +0 -1
- package/dist/prosekit-extensions-paste-rule.js +0 -2
- package/dist/prosekit-extensions-placeholder.d.ts.map +0 -1
- package/dist/prosekit-extensions-placeholder.js.map +0 -1
- package/dist/prosekit-extensions-readonly.d.ts.map +0 -1
- package/dist/prosekit-extensions-readonly.js.map +0 -1
- package/dist/prosekit-extensions-search.d.ts.map +0 -1
- package/dist/prosekit-extensions-search.js.map +0 -1
- package/dist/prosekit-extensions-strike.d.ts.map +0 -1
- package/dist/prosekit-extensions-strike.js.map +0 -1
- package/dist/prosekit-extensions-table.d.ts.map +0 -1
- package/dist/prosekit-extensions-table.js +0 -2
- package/dist/prosekit-extensions-text-align.d.ts.map +0 -1
- package/dist/prosekit-extensions-text-align.js.map +0 -1
- package/dist/prosekit-extensions-text-color.d.ts.map +0 -1
- package/dist/prosekit-extensions-text-color.js.map +0 -1
- package/dist/prosekit-extensions-text.d.ts.map +0 -1
- package/dist/prosekit-extensions-text.js.map +0 -1
- package/dist/prosekit-extensions-underline.d.ts.map +0 -1
- package/dist/prosekit-extensions-underline.js.map +0 -1
- package/dist/prosekit-extensions-virtual-selection.d.ts.map +0 -1
- package/dist/prosekit-extensions-virtual-selection.js.map +0 -1
- package/dist/prosekit-extensions-yjs.d.ts.map +0 -1
- package/dist/prosekit-extensions-yjs.js.map +0 -1
- package/dist/table.js.map +0 -1
- /package/dist/{prosekit-extensions-file.d.ts → file.d.ts} +0 -0
- /package/dist/{prosekit-extensions.js → index.js} +0 -0
- /package/dist/{prosekit-extensions.d.ts → index2.d.ts} +0 -0
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Extension, PlainExtension, Union } from "@prosekit/core";
|
|
2
2
|
import { Attrs } from "@prosekit/pm/model";
|
|
3
|
-
|
|
4
|
-
//#region src/code/code-commands.d.ts
|
|
5
3
|
/**
|
|
6
4
|
* @internal
|
|
7
5
|
*/
|
|
@@ -14,20 +12,14 @@ type CodeCommandsExtension = Extension<{
|
|
|
14
12
|
* @internal
|
|
15
13
|
*/
|
|
16
14
|
declare function defineCodeCommands(): CodeCommandsExtension;
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/code/code-input-rule.d.ts
|
|
19
15
|
/**
|
|
20
16
|
* @internal
|
|
21
17
|
*/
|
|
22
18
|
declare function defineCodeInputRule(): PlainExtension;
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/code/code-keymap.d.ts
|
|
25
19
|
/**
|
|
26
20
|
* @internal
|
|
27
21
|
*/
|
|
28
22
|
declare function defineCodeKeymap(): PlainExtension;
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region src/code/code-spec.d.ts
|
|
31
23
|
/**
|
|
32
24
|
* @internal
|
|
33
25
|
*/
|
|
@@ -40,8 +32,6 @@ type CodeSpecExtension = Extension<{
|
|
|
40
32
|
* @internal
|
|
41
33
|
*/
|
|
42
34
|
declare function defineCodeSpec(): CodeSpecExtension;
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/code/code.d.ts
|
|
45
35
|
/**
|
|
46
36
|
* @internal
|
|
47
37
|
*/
|
|
@@ -50,6 +40,5 @@ type CodeExtension = Union<[CodeSpecExtension, CodeCommandsExtension]>;
|
|
|
50
40
|
* @public
|
|
51
41
|
*/
|
|
52
42
|
declare function defineCode(): CodeExtension;
|
|
53
|
-
//#endregion
|
|
54
43
|
export { type CodeCommandsExtension, type CodeExtension, type CodeSpecExtension, defineCode, defineCodeCommands, defineCodeInputRule, defineCodeKeymap, defineCodeSpec };
|
|
55
|
-
//# sourceMappingURL=
|
|
44
|
+
//# sourceMappingURL=code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.d.ts","names":[],"sources":["../src/code/code-commands.ts","../src/code/code-input-rule.ts","../src/code/code-keymap.ts","../src/code/code-spec.ts","../src/code/code.ts"],"mappings":";;;;AAKA;KAAY,qBAAA,GAAwB,SAAA;EAClC,QAAA;IACE,UAAA;EAAA;AAAA;;;;iBAOY,kBAAA,CAAA,GAAsB,qBAAA;;;AATtC;iBCEgB,mBAAA,CAAA,GAAuB,cAAA;;;ADFvC;iBEAgB,gBAAA,CAAA,GAAoB,cAAA;;AFApC;;KGCY,iBAAA,GAAoB,SAAA;EAC9B,KAAA;IACE,IAAA,EAAM,KAAA;EAAA;AAAA;;;AHMV;iBGCgB,cAAA,CAAA,GAAkB,iBAAA;AHVlC;;;AAAA,KIKY,aAAA,GAAgB,KAAA,EAAO,iBAAA,EAAmB,qBAAA;;;;iBAKtC,UAAA,CAAA,GAAc,aAAA"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { defineMarkInputRule } from "./
|
|
1
|
+
import { defineMarkInputRule } from "./input-rule.js";
|
|
2
2
|
import { canUseRegexLookbehind, defineCommands, defineKeymap, defineMarkSpec, toggleMark, union } from "@prosekit/core";
|
|
3
|
-
//#region src/code/code-commands.ts
|
|
4
3
|
/**
|
|
5
4
|
* @internal
|
|
6
5
|
*/
|
|
7
6
|
function defineCodeCommands() {
|
|
8
7
|
return defineCommands({ toggleCode: () => toggleMark({ type: "code" }) });
|
|
9
8
|
}
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/code/code-input-rule.ts
|
|
12
9
|
/**
|
|
13
10
|
* @internal
|
|
14
11
|
*/
|
|
@@ -18,16 +15,12 @@ function defineCodeInputRule() {
|
|
|
18
15
|
type: "code"
|
|
19
16
|
});
|
|
20
17
|
}
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/code/code-keymap.ts
|
|
23
18
|
/**
|
|
24
19
|
* @internal
|
|
25
20
|
*/
|
|
26
21
|
function defineCodeKeymap() {
|
|
27
22
|
return defineKeymap({ "Mod-e": toggleMark({ type: "code" }) });
|
|
28
23
|
}
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region src/code/code-spec.ts
|
|
31
24
|
/**
|
|
32
25
|
* @internal
|
|
33
26
|
*/
|
|
@@ -41,15 +34,12 @@ function defineCodeSpec() {
|
|
|
41
34
|
}
|
|
42
35
|
});
|
|
43
36
|
}
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/code/code.ts
|
|
46
37
|
/**
|
|
47
38
|
* @public
|
|
48
39
|
*/
|
|
49
40
|
function defineCode() {
|
|
50
41
|
return union(defineCodeSpec(), defineCodeCommands(), defineCodeKeymap(), defineCodeInputRule());
|
|
51
42
|
}
|
|
52
|
-
//#endregion
|
|
53
43
|
export { defineCode, defineCodeCommands, defineCodeInputRule, defineCodeKeymap, defineCodeSpec };
|
|
54
44
|
|
|
55
|
-
//# sourceMappingURL=
|
|
45
|
+
//# sourceMappingURL=code.js.map
|
package/dist/code.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.js","names":[],"sources":["../src/code/code-commands.ts","../src/code/code-input-rule.ts","../src/code/code-keymap.ts","../src/code/code-spec.ts","../src/code/code.ts"],"sourcesContent":["import { defineCommands, toggleMark, type Extension } from '@prosekit/core'\n\n/**\n * @internal\n */\nexport type CodeCommandsExtension = Extension<{\n Commands: {\n toggleCode: []\n }\n}>\n\n/**\n * @internal\n */\nexport function defineCodeCommands(): CodeCommandsExtension {\n return defineCommands({\n toggleCode: () => toggleMark({ type: 'code' }),\n })\n}\n","import { canUseRegexLookbehind, type PlainExtension } from '@prosekit/core'\n\nimport { defineMarkInputRule } from '../input-rule/index.ts'\n\n/**\n * @internal\n */\nexport function defineCodeInputRule(): PlainExtension {\n return defineMarkInputRule({\n regex: canUseRegexLookbehind()\n ? /(?<=\\s|^)`([^\\s`]|[^\\s`][^`]*[^\\s`])`$/\n : /`([^\\s`]|[^\\s`][^`]*[^\\s`])`$/,\n type: 'code',\n })\n}\n","import { defineKeymap, toggleMark, type PlainExtension } from '@prosekit/core'\n\n/**\n * @internal\n */\nexport function defineCodeKeymap(): PlainExtension {\n return defineKeymap({\n 'Mod-e': toggleMark({ type: 'code' }),\n })\n}\n","import { defineMarkSpec, type Extension } from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport type CodeSpecExtension = Extension<{\n Marks: {\n code: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineCodeSpec(): CodeSpecExtension {\n return defineMarkSpec({\n name: 'code',\n parseDOM: [{ tag: 'code' }],\n code: true,\n toDOM() {\n return ['code', 0]\n },\n })\n}\n","import { union, type Union } from '@prosekit/core'\n\nimport { defineCodeCommands, type CodeCommandsExtension } from './code-commands.ts'\nimport { defineCodeInputRule } from './code-input-rule.ts'\nimport { defineCodeKeymap } from './code-keymap.ts'\nimport { defineCodeSpec, type CodeSpecExtension } from './code-spec.ts'\n\n/**\n * @internal\n */\nexport type CodeExtension = Union<[CodeSpecExtension, CodeCommandsExtension]>\n\n/**\n * @public\n */\nexport function defineCode(): CodeExtension {\n return union(\n defineCodeSpec(),\n defineCodeCommands(),\n defineCodeKeymap(),\n defineCodeInputRule(),\n )\n}\n"],"mappings":";;;;;AAcA,SAAgB,qBAA4C;AAC1D,QAAO,eAAe,EACpB,kBAAkB,WAAW,EAAE,MAAM,QAAQ,CAAC,EAC/C,CAAC;;;;;ACVJ,SAAgB,sBAAsC;AACpD,QAAO,oBAAoB;EACzB,OAAO,uBAAuB,GAC1B,2CACA;EACJ,MAAM;EACP,CAAC;;;;;ACRJ,SAAgB,mBAAmC;AACjD,QAAO,aAAa,EAClB,SAAS,WAAW,EAAE,MAAM,QAAQ,CAAC,EACtC,CAAC;;;;;ACOJ,SAAgB,iBAAoC;AAClD,QAAO,eAAe;EACpB,MAAM;EACN,UAAU,CAAC,EAAE,KAAK,QAAQ,CAAC;EAC3B,MAAM;EACN,QAAQ;AACN,UAAO,CAAC,QAAQ,EAAE;;EAErB,CAAC;;;;;ACRJ,SAAgB,aAA4B;AAC1C,QAAO,MACL,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,CACtB"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Transaction } from "@prosekit/pm/state";
|
|
2
2
|
import { NodeJSON, PlainExtension, StepJSON } from "@prosekit/core";
|
|
3
3
|
import { ProseMirrorNode } from "@prosekit/pm/model";
|
|
4
|
-
|
|
5
|
-
//#region src/commit/index.d.ts
|
|
6
4
|
/**
|
|
7
5
|
* A JSON representation of a commit.
|
|
8
6
|
*/
|
|
@@ -47,6 +45,5 @@ declare class CommitRecorder {
|
|
|
47
45
|
* Define an extension that can record the changes in the editor.
|
|
48
46
|
*/
|
|
49
47
|
declare function defineCommitRecorder(commitRecorder: CommitRecorder): PlainExtension;
|
|
50
|
-
//#endregion
|
|
51
48
|
export { type Commit, CommitRecorder, defineCommitRecorder, defineCommitViewer };
|
|
52
|
-
//# sourceMappingURL=
|
|
49
|
+
//# sourceMappingURL=commit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit.d.ts","names":[],"sources":["../src/commit/index.ts"],"mappings":";;;;AAEmF;;UAQzE,MAAA;EAIH;;;EAAL,GAAA,EAAK,QAAA;EASU;;;EALf,MAAA,EAAQ,QAAA;EAAA;;;;EAKR,KAAA,EAAO,QAAA;AAAA;;;;iBA2MA,kBAAA,CAAmB,MAAA,EAAQ,MAAA,GAAS,cAAA;AAAA,cAOvC,cAAA;EAAA,QACI,MAAA;EAAA,QACA,GAAA;EAAA,QACA,KAAA;EAHJ;;;;EASJ,MAAA,CAAA,GAAU,MAAA;EA+BA;;;EATV,IAAA,CAAK,GAAA,EAAK,eAAA;EA7BF;;;EAsCR,KAAA,CAAM,EAAA,EAAI,WAAA;AAAA;;;;iBASH,oBAAA,CAAqB,cAAA,EAAgB,cAAA,GAAiB,cAAA"}
|
|
@@ -4,7 +4,6 @@ import { Decoration, DecorationSet } from "@prosekit/pm/view";
|
|
|
4
4
|
import { DOMSerializer, Fragment, Slice } from "@prosekit/pm/model";
|
|
5
5
|
import { Step } from "@prosekit/pm/transform";
|
|
6
6
|
import { ChangeSet } from "prosemirror-changeset";
|
|
7
|
-
//#region src/commit/index.ts
|
|
8
7
|
function getChanges(doc, parent, steps) {
|
|
9
8
|
return ChangeSet.create(parent).addSteps(doc, steps.map((step) => step.getMap()), null).changes;
|
|
10
9
|
}
|
|
@@ -152,7 +151,6 @@ function defineCommitRecorder(commitRecorder) {
|
|
|
152
151
|
}
|
|
153
152
|
}));
|
|
154
153
|
}
|
|
155
|
-
//#endregion
|
|
156
154
|
export { CommitRecorder, defineCommitRecorder, defineCommitViewer };
|
|
157
155
|
|
|
158
|
-
//# sourceMappingURL=
|
|
156
|
+
//# sourceMappingURL=commit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit.js","names":[],"sources":["../src/commit/index.ts"],"sourcesContent":["import { defineDefaultState, definePlugin, jsonFromNode, union, type NodeJSON, type PlainExtension, type StepJSON } from '@prosekit/core'\nimport { DOMSerializer, Fragment, Slice, type ProseMirrorNode } from '@prosekit/pm/model'\nimport { PluginKey, ProseMirrorPlugin, type Transaction } from '@prosekit/pm/state'\nimport { Step } from '@prosekit/pm/transform'\nimport { Decoration, DecorationSet, type EditorView } from '@prosekit/pm/view'\nimport { ChangeSet, type Change } from 'prosemirror-changeset'\n\n/**\n * A JSON representation of a commit.\n */\ninterface Commit {\n /**\n * The current doc node in the JSON format\n */\n doc: NodeJSON\n /**\n * The parent node in the JSON format\n */\n parent: NodeJSON\n /**\n * An array of steps in the JSON format that transform the parent node to the\n * current doc node.\n */\n steps: StepJSON[]\n}\n\nfunction getChanges(\n doc: ProseMirrorNode,\n parent: ProseMirrorNode,\n steps: Step[],\n): readonly Change[] {\n const initSet = ChangeSet.create(parent)\n const currSet = initSet.addSteps(\n doc,\n steps.map((step) => step.getMap()),\n null,\n )\n return currSet.changes\n}\n\nfunction renderDivWeight(view: EditorView): HTMLElement {\n const document = view.dom.ownerDocument\n return document.createElement('div')\n}\n\nfunction decorateDeletionSlice(\n slice: Slice,\n): Array<(view: EditorView) => HTMLElement> {\n // Get the fragment of the deleted content\n let { openStart, openEnd, content } = slice\n\n while (openStart > 0 && openEnd > 0 && content.childCount === 1) {\n openStart--\n openEnd--\n content = content.child(0).content\n }\n\n // Nothing to render\n if (content.childCount === 0) {\n return []\n }\n\n // For example, if the slice is\n // {\n // openStart: 1,\n // openEnd: 1,\n // content: <p>Hello</p><p>World</p>\n // }\n // We should render the following decorations:\n // <span>Hello</span>\n // <div></div>\n // <span>World</span>\n if (openStart > 0 && openEnd > 0 && content.childCount === 2) {\n const head = Fragment.from([content.child(0)])\n const tail = Fragment.from([content.child(1)])\n return [\n ...decorateDeletionSlice(new Slice(head, openStart, openStart)),\n renderDivWeight,\n ...decorateDeletionSlice(new Slice(tail, openEnd, openEnd)),\n ]\n }\n\n // For example, if the slice is\n // {\n // openStart: 1,\n // openEnd: 0,\n // content: <p>Hello</p><p>World</p>\n // }\n // We should render the following decorations:\n // <span>Hello</span>\n // <div><p>World</p></div>\n if (openStart > 0 && content.childCount >= 2) {\n const nodes = content.content\n const head = Fragment.from(nodes.slice(0, 1))\n const body = Fragment.from(nodes.slice(1))\n\n return [\n ...decorateDeletionSlice(new Slice(head, openStart, openStart)),\n ...decorateDeletionSlice(new Slice(body, 0, openEnd)),\n ]\n }\n\n // For example, if the slice is\n // {\n // openStart: 0,\n // openEnd: 1,\n // content: <p>Hello</p><p>World</p>\n // }\n // We should render the following decorations:\n // <div><p>Hello</p></div>\n // <span>World</span>\n if (openEnd > 0 && content.childCount >= 2) {\n const nodes = content.content\n const body = Fragment.from(nodes.slice(0, -1))\n const tail = Fragment.from(nodes.slice(-1))\n return [\n ...decorateDeletionSlice(new Slice(body, openStart, 0)),\n ...decorateDeletionSlice(new Slice(tail, openEnd, openEnd)),\n ]\n }\n\n const schema = content.child(0).type.schema\n const isInline = content.child(0).isInline\n\n const render = (view: EditorView): HTMLElement => {\n const document = view.dom.ownerDocument\n\n // Render the fragment to HTML\n const element = document.createElement(isInline ? 'span' : 'div')\n const serializer = DOMSerializer.fromSchema(schema)\n serializer.serializeFragment(content, { document }, element)\n\n // Add the class to the element\n element.classList.add('prosekit-commit-deletion')\n return element\n }\n\n return [render]\n}\n\nfunction decorateDeletion(\n /** The doc node before the deletion */\n doc: ProseMirrorNode,\n /** The start position of the deleted text in the doc node */\n from: number,\n /** The end position of the deleted text in the doc node */\n to: number,\n /** The insert position of the decoration in the doc node after the change */\n pos: number,\n): Decoration[] {\n const slice = doc.slice(from, to)\n\n const renders = decorateDeletionSlice(slice)\n const count = renders.length\n\n return renders.map((render, index) =>\n Decoration.widget(pos, render, {\n side: -20 - count + index,\n // Ensure the text in the decoration is able to be selected.\n ignoreSelection: true,\n })\n )\n}\n\nfunction decorateAddition(\n /** The start position of the inserted text in the doc node */\n from: number,\n /** The end position of the inserted text in the doc node */\n to: number,\n): Decoration {\n return Decoration.inline(from, to, { class: 'prosekit-commit-addition' })\n}\n\nfunction decorateChange(prev: ProseMirrorNode, change: Change): Decoration[] {\n const { fromA, toA, fromB, toB } = change\n const decorations: Decoration[] = []\n\n if (fromA < toA) {\n decorations.push(...decorateDeletion(prev, fromA, toA, fromB))\n }\n if (fromB < toB) {\n decorations.push(decorateAddition(fromB, toB))\n }\n\n return decorations\n}\n\nfunction decorateCommit(\n doc: ProseMirrorNode,\n parent: ProseMirrorNode,\n steps: Step[],\n): DecorationSet {\n const changes = getChanges(doc, parent, steps)\n const decorations = changes.flatMap((change) => decorateChange(parent, change))\n return DecorationSet.create(doc, decorations)\n}\n\nfunction defineCommitDecoration(commit: Commit): PlainExtension {\n const key = new PluginKey<DecorationSet>('prosekit-commit-decoration')\n\n return definePlugin(({ schema }): ProseMirrorPlugin => {\n const parent = schema.nodeFromJSON(commit.parent)\n const steps = commit.steps.map((step) => Step.fromJSON(schema, step))\n\n return new ProseMirrorPlugin({\n key,\n state: {\n init: (_, instance): DecorationSet => {\n return decorateCommit(instance.doc, parent, steps)\n },\n apply: (tr, deco: DecorationSet): DecorationSet => {\n return deco.map(tr.mapping, tr.doc)\n },\n },\n props: {\n decorations: (state): DecorationSet | undefined => {\n return key.getState(state)\n },\n },\n })\n })\n}\n\n/**\n * Define an extension to display the changes from the given commit in the editor.\n */\nfunction defineCommitViewer(commit: Commit): PlainExtension {\n return union(\n defineDefaultState({ defaultContent: commit.doc }),\n defineCommitDecoration(commit),\n )\n}\n\nclass CommitRecorder {\n private parent: ProseMirrorNode | null = null\n private doc: ProseMirrorNode | null = null\n private steps: Step[] = []\n\n /**\n * Return a commit object including all changes since the last commit. `null`\n * will be returned if there is no change.\n */\n commit(): Commit | null {\n if (\n !this.parent\n || !this.doc\n || this.steps.length === 0\n || this.parent.eq(this.doc)\n ) {\n return null\n }\n\n const commit: Commit = {\n doc: jsonFromNode(this.doc),\n parent: jsonFromNode(this.parent),\n steps: this.steps.map((step) => step.toJSON() as StepJSON),\n }\n this.init(this.doc)\n return commit\n }\n\n /**\n * @internal\n */\n init(doc: ProseMirrorNode): void {\n this.doc = doc\n this.parent = doc\n this.steps = []\n }\n\n /**\n * @internal\n */\n apply(tr: Transaction): void {\n this.steps.push(...tr.steps)\n this.doc = tr.doc\n }\n}\n\n/**\n * Define an extension that can record the changes in the editor.\n */\nfunction defineCommitRecorder(commitRecorder: CommitRecorder): PlainExtension {\n const key = new PluginKey<DecorationSet>('prosekit-commit-recorder')\n\n return definePlugin(\n new ProseMirrorPlugin({\n key,\n state: {\n init: (_, state): void => {\n commitRecorder.init(state.doc)\n },\n apply: (tr): void => {\n commitRecorder.apply(tr)\n },\n },\n }),\n )\n}\n\nexport { CommitRecorder, defineCommitRecorder, defineCommitViewer, type Commit }\n"],"mappings":"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"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Extension } from "@prosekit/core";
|
|
2
2
|
import { Attrs } from "@prosekit/pm/model";
|
|
3
|
-
|
|
4
|
-
//#region src/doc/index.d.ts
|
|
5
3
|
/**
|
|
6
4
|
* @internal
|
|
7
5
|
*/
|
|
@@ -14,6 +12,5 @@ type DocExtension = Extension<{
|
|
|
14
12
|
* @public
|
|
15
13
|
*/
|
|
16
14
|
declare function defineDoc(): DocExtension;
|
|
17
|
-
//#endregion
|
|
18
15
|
export { DocExtension, defineDoc };
|
|
19
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=doc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc.d.ts","names":[],"sources":["../src/doc/index.ts"],"mappings":";;;AAMA;;KAAY,YAAA,GAAe,SAAA;EAAY,KAAA;IAAS,GAAA,EAAK,KAAA;EAAA;AAAA;;;;iBAKrC,SAAA,CAAA,GAAa,YAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { defineNodeSpec } from "@prosekit/core";
|
|
2
|
-
//#region src/doc/index.ts
|
|
3
2
|
/**
|
|
4
3
|
* @public
|
|
5
4
|
*/
|
|
@@ -10,7 +9,6 @@ function defineDoc() {
|
|
|
10
9
|
topNode: true
|
|
11
10
|
});
|
|
12
11
|
}
|
|
13
|
-
//#endregion
|
|
14
12
|
export { defineDoc };
|
|
15
13
|
|
|
16
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=doc.js.map
|
package/dist/doc.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc.js","names":[],"sources":["../src/doc/index.ts"],"sourcesContent":["import { defineNodeSpec, type Extension } from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\n\n/**\n * @internal\n */\nexport type DocExtension = Extension<{ Nodes: { doc: Attrs } }>\n\n/**\n * @public\n */\nexport function defineDoc(): DocExtension {\n return defineNodeSpec({\n name: 'doc',\n content: 'block+',\n topNode: true,\n })\n}\n"],"mappings":";;;;AAWA,SAAgB,YAA0B;AACxC,QAAO,eAAe;EACpB,MAAM;EACN,SAAS;EACT,SAAS;EACV,CAAC"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { PlainExtension } from "@prosekit/core";
|
|
2
|
-
|
|
3
|
-
//#region src/drop-cursor/drop-cursor.d.ts
|
|
4
2
|
interface DropCursorOptions {
|
|
5
3
|
/**
|
|
6
4
|
* The color of the cursor. Use `false` to apply no color and rely only on class.
|
|
@@ -33,6 +31,5 @@ type DropCursorExtension = PlainExtension;
|
|
|
33
31
|
* @public
|
|
34
32
|
*/
|
|
35
33
|
declare function defineDropCursor(options?: DropCursorOptions): DropCursorExtension;
|
|
36
|
-
//#endregion
|
|
37
34
|
export { type DropCursorExtension, type DropCursorOptions, defineDropCursor };
|
|
38
|
-
//# sourceMappingURL=
|
|
35
|
+
//# sourceMappingURL=drop-cursor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-cursor.d.ts","names":[],"sources":["../src/drop-cursor/drop-cursor.ts"],"mappings":";UAGiB,iBAAA;EAAA;;;;;EAMf,KAAA;EAYA;;;AAMF;;EAXE,KAAA;EAWgC;;AAWlC;EAjBE,KAAA;AAAA;;;;KAMU,mBAAA,GAAsB,cAAA;;;;;;;;;;iBAWlB,gBAAA,CACd,OAAA,GAAU,iBAAA,GACT,mBAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { definePlugin } from "@prosekit/core";
|
|
2
2
|
import { dropCursor } from "prosemirror-dropcursor";
|
|
3
|
-
//#region src/drop-cursor/drop-cursor.ts
|
|
4
3
|
/**
|
|
5
4
|
* Show up a decoration at the drop position when something is dragged over the editor.
|
|
6
5
|
*
|
|
@@ -13,7 +12,6 @@ import { dropCursor } from "prosemirror-dropcursor";
|
|
|
13
12
|
function defineDropCursor(options) {
|
|
14
13
|
return definePlugin(() => dropCursor(options));
|
|
15
14
|
}
|
|
16
|
-
//#endregion
|
|
17
15
|
export { defineDropCursor };
|
|
18
16
|
|
|
19
|
-
//# sourceMappingURL=
|
|
17
|
+
//# sourceMappingURL=drop-cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-cursor.js","names":[],"sources":["../src/drop-cursor/drop-cursor.ts"],"sourcesContent":["import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport { dropCursor } from 'prosemirror-dropcursor'\n\nexport interface DropCursorOptions {\n /**\n * The color of the cursor. Use `false` to apply no color and rely only on class.\n *\n * @default 'black'\n */\n color?: string | false\n\n /**\n * The precise width of the cursor in pixels.\n *\n * @default 1\n */\n width?: number\n\n /**\n * A CSS class name to add to the cursor element.\n */\n class?: string\n}\n\n/**\n * @internal\n */\nexport type DropCursorExtension = PlainExtension\n\n/**\n * Show up a decoration at the drop position when something is dragged over the editor.\n *\n * See [prosemirror-dropcursor](https://github.com/ProseMirror/prosemirror-dropcursor) for more information.\n *\n * You probably want to use `<DropIndicator />` component instead of this extension.\n *\n * @public\n */\nexport function defineDropCursor(\n options?: DropCursorOptions,\n): DropCursorExtension {\n return definePlugin(() => dropCursor(options))\n}\n"],"mappings":";;;;;;;;;;;AAsCA,SAAgB,iBACd,SACqB;AACrB,QAAO,mBAAmB,WAAW,QAAQ,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { PlainExtension } from "@prosekit/core";
|
|
2
2
|
import { DragEventHandler, DragEventHandlerOptions, DropIndicatorPluginOptions, Line, Point, ShowHandler, ShowHandlerOptions, ViewDragging } from "prosemirror-drop-indicator";
|
|
3
|
-
|
|
4
|
-
//#region src/drop-indicator/drop-indicator.d.ts
|
|
5
3
|
/**
|
|
6
4
|
* @internal
|
|
7
5
|
*/
|
|
@@ -26,6 +24,5 @@ declare function defineDropIndicator(options?: DropIndicatorOptions): DropIndica
|
|
|
26
24
|
* @public
|
|
27
25
|
*/
|
|
28
26
|
interface DropIndicatorOptions extends DropIndicatorPluginOptions {}
|
|
29
|
-
//#endregion
|
|
30
27
|
export { type DragEventHandler, type DragEventHandlerOptions, type DropIndicatorExtension, type DropIndicatorOptions, type Line, type Point, type ShowHandler, type ShowHandlerOptions, type ViewDragging, defineDropIndicator };
|
|
31
|
-
//# sourceMappingURL=
|
|
28
|
+
//# sourceMappingURL=drop-indicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-indicator.d.ts","names":[],"sources":["../src/drop-indicator/drop-indicator.ts"],"mappings":";;;AAQA;;KAAY,sBAAA,GAAyB,cAAA;;;AAerC;;;;;;;;;AAWA;;iBAXgB,mBAAA,CACd,OAAA,GAAU,oBAAA,GACT,sBAAA;;;;;;UASc,oBAAA,SAA6B,0BAAA"}
|
package/dist/drop-indicator.js
CHANGED
|
@@ -1,57 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { createDropIndicatorPlugin } from "prosemirror-drop-indicator";
|
|
4
|
-
//#region src/drop-indicator/drop-indicator-facet.ts
|
|
5
|
-
/**
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
function defineDropIndicatorPayload(payload) {
|
|
9
|
-
return defineFacetPayload(dropIndicatorFacet, [payload]);
|
|
10
|
-
}
|
|
11
|
-
const dropIndicatorFacet = defineFacet({
|
|
12
|
-
parent: pluginFacet,
|
|
13
|
-
singleton: true,
|
|
14
|
-
reducer: (payloads) => {
|
|
15
|
-
const showHandlers = payloads.map((p) => p.onShow).filter(isNotNullish);
|
|
16
|
-
const hideHandlers = payloads.map((p) => p.onHide).filter(isNotNullish);
|
|
17
|
-
const dragHandlers = payloads.map((p) => p.onDrag).filter(isNotNullish);
|
|
18
|
-
const showHandler = (options) => {
|
|
19
|
-
for (const fn of showHandlers) fn(options);
|
|
20
|
-
};
|
|
21
|
-
const hideHandler = () => {
|
|
22
|
-
for (const fn of hideHandlers) fn();
|
|
23
|
-
};
|
|
24
|
-
const dragHandler = (options) => {
|
|
25
|
-
for (const fn of dragHandlers) if (fn(options) === false) return false;
|
|
26
|
-
return true;
|
|
27
|
-
};
|
|
28
|
-
if (showHandlers.length === 0) return [];
|
|
29
|
-
return createDropIndicatorPlugin({
|
|
30
|
-
onDrag: dragHandler,
|
|
31
|
-
onShow: showHandler,
|
|
32
|
-
onHide: hideHandler
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
//#endregion
|
|
37
|
-
//#region src/drop-indicator/drop-indicator.ts
|
|
38
|
-
/**
|
|
39
|
-
* Defines an extension that controls the behavior of the drop indicator.
|
|
40
|
-
*
|
|
41
|
-
* This extension itself doesn't draw the drop indicator, but it provides the
|
|
42
|
-
* necessary callbacks to do so. You probably don't want to use this extension
|
|
43
|
-
* directly, but rather use the `<DropIndicator>` component.
|
|
44
|
-
*
|
|
45
|
-
* You can add this extension multiple times. If any extension has `onDrag`
|
|
46
|
-
* callback defined, and it returns `false`, then the drop point will be
|
|
47
|
-
* discarded.
|
|
48
|
-
*
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
function defineDropIndicator(options) {
|
|
52
|
-
return defineDropIndicatorPayload(options ?? {});
|
|
53
|
-
}
|
|
54
|
-
//#endregion
|
|
55
|
-
export { defineDropIndicator as t };
|
|
56
|
-
|
|
57
|
-
//# sourceMappingURL=drop-indicator.js.map
|
|
1
|
+
import { t as defineDropIndicator } from "./drop-indicator2.js";
|
|
2
|
+
export { defineDropIndicator };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { defineFacet, defineFacetPayload, pluginFacet } from "@prosekit/core";
|
|
2
|
+
import { isNotNullish } from "@ocavue/utils";
|
|
3
|
+
import { createDropIndicatorPlugin } from "prosemirror-drop-indicator";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
function defineDropIndicatorPayload(payload) {
|
|
8
|
+
return defineFacetPayload(dropIndicatorFacet, [payload]);
|
|
9
|
+
}
|
|
10
|
+
const dropIndicatorFacet = defineFacet({
|
|
11
|
+
parent: pluginFacet,
|
|
12
|
+
singleton: true,
|
|
13
|
+
reducer: (payloads) => {
|
|
14
|
+
const showHandlers = payloads.map((p) => p.onShow).filter(isNotNullish);
|
|
15
|
+
const hideHandlers = payloads.map((p) => p.onHide).filter(isNotNullish);
|
|
16
|
+
const dragHandlers = payloads.map((p) => p.onDrag).filter(isNotNullish);
|
|
17
|
+
const showHandler = (options) => {
|
|
18
|
+
for (const fn of showHandlers) fn(options);
|
|
19
|
+
};
|
|
20
|
+
const hideHandler = () => {
|
|
21
|
+
for (const fn of hideHandlers) fn();
|
|
22
|
+
};
|
|
23
|
+
const dragHandler = (options) => {
|
|
24
|
+
for (const fn of dragHandlers) if (fn(options) === false) return false;
|
|
25
|
+
return true;
|
|
26
|
+
};
|
|
27
|
+
if (showHandlers.length === 0) return [];
|
|
28
|
+
return createDropIndicatorPlugin({
|
|
29
|
+
onDrag: dragHandler,
|
|
30
|
+
onShow: showHandler,
|
|
31
|
+
onHide: hideHandler
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Defines an extension that controls the behavior of the drop indicator.
|
|
37
|
+
*
|
|
38
|
+
* This extension itself doesn't draw the drop indicator, but it provides the
|
|
39
|
+
* necessary callbacks to do so. You probably don't want to use this extension
|
|
40
|
+
* directly, but rather use the `<DropIndicator>` component.
|
|
41
|
+
*
|
|
42
|
+
* You can add this extension multiple times. If any extension has `onDrag`
|
|
43
|
+
* callback defined, and it returns `false`, then the drop point will be
|
|
44
|
+
* discarded.
|
|
45
|
+
*
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
function defineDropIndicator(options) {
|
|
49
|
+
return defineDropIndicatorPayload(options ?? {});
|
|
50
|
+
}
|
|
51
|
+
export { defineDropIndicator as t };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=drop-indicator2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-indicator2.js","names":[],"sources":["../src/drop-indicator/drop-indicator-facet.ts","../src/drop-indicator/drop-indicator.ts"],"sourcesContent":["import { isNotNullish } from '@ocavue/utils'\nimport { defineFacet, defineFacetPayload, pluginFacet, type PlainExtension, type PluginPayload } from '@prosekit/core'\nimport type { DragEventHandler, DropIndicatorPluginOptions, ShowHandler } from 'prosemirror-drop-indicator'\nimport { createDropIndicatorPlugin } from 'prosemirror-drop-indicator'\n\n/**\n * @internal\n */\nexport function defineDropIndicatorPayload(\n payload: DropIndicatorPluginOptions,\n): PlainExtension {\n return defineFacetPayload(dropIndicatorFacet, [payload]) as PlainExtension\n}\n\nconst dropIndicatorFacet = defineFacet<DropIndicatorPluginOptions, PluginPayload>({\n parent: pluginFacet,\n singleton: true,\n reducer: (payloads: DropIndicatorPluginOptions[]): PluginPayload => {\n const showHandlers = payloads.map(p => p.onShow).filter(isNotNullish)\n const hideHandlers = payloads.map(p => p.onHide).filter(isNotNullish)\n const dragHandlers = payloads.map(p => p.onDrag).filter(isNotNullish)\n\n const showHandler: ShowHandler = (options) => {\n for (const fn of showHandlers) {\n fn(options)\n }\n }\n\n const hideHandler: VoidFunction = () => {\n for (const fn of hideHandlers) {\n fn()\n }\n }\n\n const dragHandler: DragEventHandler = (options): boolean => {\n for (const fn of dragHandlers) {\n if (fn(options) === false) return false\n }\n return true\n }\n\n if (showHandlers.length === 0) {\n // No `onShow` event handler, so we don't need to create a plugin.\n return []\n }\n\n return createDropIndicatorPlugin({\n onDrag: dragHandler,\n onShow: showHandler,\n onHide: hideHandler,\n })\n },\n})\n","import type { PlainExtension } from '@prosekit/core'\nimport type { DropIndicatorPluginOptions } from 'prosemirror-drop-indicator'\n\nimport { defineDropIndicatorPayload } from './drop-indicator-facet.ts'\n\n/**\n * @internal\n */\nexport type DropIndicatorExtension = PlainExtension\n\n/**\n * Defines an extension that controls the behavior of the drop indicator.\n *\n * This extension itself doesn't draw the drop indicator, but it provides the\n * necessary callbacks to do so. You probably don't want to use this extension\n * directly, but rather use the `<DropIndicator>` component.\n *\n * You can add this extension multiple times. If any extension has `onDrag`\n * callback defined, and it returns `false`, then the drop point will be\n * discarded.\n *\n * @public\n */\nexport function defineDropIndicator(\n options?: DropIndicatorOptions,\n): DropIndicatorExtension {\n return defineDropIndicatorPayload(options ?? {})\n}\n\n/**\n * Options for {@link defineDropIndicator}.\n *\n * @public\n */\nexport interface DropIndicatorOptions extends DropIndicatorPluginOptions {}\n"],"mappings":";;;;;;AAQA,SAAgB,2BACd,SACgB;AAChB,QAAO,mBAAmB,oBAAoB,CAAC,QAAQ,CAAC;;AAG1D,MAAM,qBAAqB,YAAuD;CAChF,QAAQ;CACR,WAAW;CACX,UAAU,aAA0D;EAClE,MAAM,eAAe,SAAS,KAAI,MAAK,EAAE,OAAO,CAAC,OAAO,aAAa;EACrE,MAAM,eAAe,SAAS,KAAI,MAAK,EAAE,OAAO,CAAC,OAAO,aAAa;EACrE,MAAM,eAAe,SAAS,KAAI,MAAK,EAAE,OAAO,CAAC,OAAO,aAAa;EAErE,MAAM,eAA4B,YAAY;AAC5C,QAAK,MAAM,MAAM,aACf,IAAG,QAAQ;;EAIf,MAAM,oBAAkC;AACtC,QAAK,MAAM,MAAM,aACf,KAAI;;EAIR,MAAM,eAAiC,YAAqB;AAC1D,QAAK,MAAM,MAAM,aACf,KAAI,GAAG,QAAQ,KAAK,MAAO,QAAO;AAEpC,UAAO;;AAGT,MAAI,aAAa,WAAW,EAE1B,QAAO,EAAE;AAGX,SAAO,0BAA0B;GAC/B,QAAQ;GACR,QAAQ;GACR,QAAQ;GACT,CAAC;;CAEL,CAAC;;;;;;;;;;;;;;AC7BF,SAAgB,oBACd,SACwB;AACxB,QAAO,2BAA2B,WAAW,EAAE,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { PlainExtension } from "@prosekit/core";
|
|
2
2
|
import { EnterRule, EnterRuleHandler, EnterRuleHandlerOptions, TextBlockEnterRuleOptions as TextBlockEnterRuleOptions$1 } from "prosemirror-enter-rules";
|
|
3
|
-
|
|
4
|
-
//#region src/enter-rule/index.d.ts
|
|
5
3
|
/**
|
|
6
4
|
* Options for {@link defineEnterRule}.
|
|
7
5
|
*
|
|
@@ -34,6 +32,5 @@ declare function defineEnterRule(options: EnterRuleOptions): PlainExtension;
|
|
|
34
32
|
* @public
|
|
35
33
|
*/
|
|
36
34
|
declare function defineTextBlockEnterRule(options: TextBlockEnterRuleOptions): PlainExtension;
|
|
37
|
-
//#endregion
|
|
38
35
|
export { type EnterRuleHandler, type EnterRuleHandlerOptions, EnterRuleOptions, TextBlockEnterRuleOptions, defineEnterRule, defineTextBlockEnterRule };
|
|
39
|
-
//# sourceMappingURL=
|
|
36
|
+
//# sourceMappingURL=enter-rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enter-rule.d.ts","names":[],"sources":["../src/enter-rule/index.ts"],"mappings":";;AAiBA;;;;;AAAA,UAAiB,gBAAA,SAAyB,SAAA;;;;AAkB1C;;UAXiB,yBAAA,SAAkC,2BAAA;;;;;;AAwBnD;;;;iBAbgB,eAAA,CAAgB,OAAA,EAAS,gBAAA,GAAmB,cAAA;;;;;;;;;;iBAa5C,wBAAA,CAAyB,OAAA,EAAS,yBAAA,GAA4B,cAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { defineFacet, defineFacetPayload, pluginFacet } from "@prosekit/core";
|
|
2
2
|
import { createEnterRulePlugin, createTextBlockEnterRule } from "prosemirror-enter-rules";
|
|
3
|
-
//#region src/enter-rule/index.ts
|
|
4
3
|
/**
|
|
5
4
|
* Defines an enter rule. An enter rule applies when the text directly in front of
|
|
6
5
|
* the cursor matches `regex` and user presses Enter. The `regex` should end
|
|
@@ -31,7 +30,6 @@ const enterRuleFacet = defineFacet({
|
|
|
31
30
|
},
|
|
32
31
|
parent: pluginFacet
|
|
33
32
|
});
|
|
34
|
-
//#endregion
|
|
35
33
|
export { defineEnterRule, defineTextBlockEnterRule };
|
|
36
34
|
|
|
37
|
-
//# sourceMappingURL=
|
|
35
|
+
//# sourceMappingURL=enter-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enter-rule.js","names":[],"sources":["../src/enter-rule/index.ts"],"sourcesContent":["import { defineFacet, defineFacetPayload, pluginFacet, type PlainExtension, type PluginPayload } from '@prosekit/core'\nimport {\n createEnterRulePlugin,\n createTextBlockEnterRule,\n type EnterRule,\n type EnterRuleHandler,\n type EnterRuleHandlerOptions,\n type TextBlockEnterRuleOptions as TextBlockEnterRuleOptionsBase,\n} from 'prosemirror-enter-rules'\n\nexport type { EnterRuleHandler, EnterRuleHandlerOptions }\n\n/**\n * Options for {@link defineEnterRule}.\n *\n * @public\n */\nexport interface EnterRuleOptions extends EnterRule {}\n\n/**\n * Options for {@link defineTextBlockEnterRule}.\n *\n * @public\n */\nexport interface TextBlockEnterRuleOptions extends TextBlockEnterRuleOptionsBase {}\n\n/**\n * Defines an enter rule. An enter rule applies when the text directly in front of\n * the cursor matches `regex` and user presses Enter. The `regex` should end\n * with `$`.\n *\n * @param options\n *\n * @public\n */\nexport function defineEnterRule(options: EnterRuleOptions): PlainExtension {\n return defineFacetPayload(enterRuleFacet, [options]) as PlainExtension\n}\n\n/**\n * Defines an enter rule that replaces the matched text with a block node.\n *\n * See also {@link defineEnterRule}.\n *\n * @param options\n *\n * @public\n */\nexport function defineTextBlockEnterRule(options: TextBlockEnterRuleOptions): PlainExtension {\n return defineEnterRule(createTextBlockEnterRule(options))\n}\n\nconst enterRuleFacet = defineFacet<EnterRule, PluginPayload>({\n reducer: (rules: EnterRule[]): PluginPayload => {\n return createEnterRulePlugin({ rules })\n },\n\n parent: pluginFacet,\n})\n"],"mappings":";;;;;;;;;;;AAmCA,SAAgB,gBAAgB,SAA2C;AACzE,QAAO,mBAAmB,gBAAgB,CAAC,QAAQ,CAAC;;;;;;;;;;;AAYtD,SAAgB,yBAAyB,SAAoD;AAC3F,QAAO,gBAAgB,yBAAyB,QAAQ,CAAC;;AAG3D,MAAM,iBAAiB,YAAsC;CAC3D,UAAU,UAAsC;AAC9C,SAAO,sBAAsB,EAAE,OAAO,CAAC;;CAGzC,QAAQ;CACT,CAAC"}
|
package/dist/file.js
CHANGED
|
@@ -1,128 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function handleFile(view, event, file, handlers) {
|
|
4
|
-
for (let i = handlers.length - 1; i >= 0; i--) {
|
|
5
|
-
const handler = handlers[i];
|
|
6
|
-
if (handler({
|
|
7
|
-
view,
|
|
8
|
-
event,
|
|
9
|
-
file
|
|
10
|
-
})) return true;
|
|
11
|
-
}
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
function handleEvent(view, event, handlers, getFiles) {
|
|
15
|
-
const files = getFiles(event);
|
|
16
|
-
let handled = false;
|
|
17
|
-
for (const file of files) if (handleFile(view, event, file, handlers)) handled = true;
|
|
18
|
-
return handled;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/file/file-drop-handler.ts
|
|
22
|
-
function defineFileDropHandler(handler) {
|
|
23
|
-
return defineFacetPayload(facet$1, [handler]);
|
|
24
|
-
}
|
|
25
|
-
function getFiles$1(event) {
|
|
26
|
-
return Array.from(event.dataTransfer?.files ?? []);
|
|
27
|
-
}
|
|
28
|
-
const facet$1 = defineFacet({
|
|
29
|
-
parent: editorEventFacet,
|
|
30
|
-
singleton: true,
|
|
31
|
-
reducer: (handlers) => {
|
|
32
|
-
const dropHandler = (view, event) => {
|
|
33
|
-
const position = view.posAtCoords({
|
|
34
|
-
left: event.x,
|
|
35
|
-
top: event.y
|
|
36
|
-
});
|
|
37
|
-
if (!position) return false;
|
|
38
|
-
const pos = position.inside > 0 ? position.inside : position.pos;
|
|
39
|
-
return handleEvent(view, event, handlers.map((handler) => (options) => handler({
|
|
40
|
-
...options,
|
|
41
|
-
pos
|
|
42
|
-
})), getFiles$1);
|
|
43
|
-
};
|
|
44
|
-
return ["drop", dropHandler];
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/file/file-paste-handler.ts
|
|
49
|
-
function defineFilePasteHandler(handler) {
|
|
50
|
-
return defineFacetPayload(facet, [handler]);
|
|
51
|
-
}
|
|
52
|
-
function getFiles(event) {
|
|
53
|
-
return Array.from(event.clipboardData?.files ?? []);
|
|
54
|
-
}
|
|
55
|
-
const facet = defineFacet({
|
|
56
|
-
parent: editorEventFacet,
|
|
57
|
-
singleton: true,
|
|
58
|
-
reducer: (handlers) => {
|
|
59
|
-
const pasteHandler = (view, event) => {
|
|
60
|
-
return handleEvent(view, event, handlers, getFiles);
|
|
61
|
-
};
|
|
62
|
-
return ["paste", pasteHandler];
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/file/file-upload.ts
|
|
67
|
-
/**
|
|
68
|
-
* A class that represents a upload task.
|
|
69
|
-
*/
|
|
70
|
-
var UploadTask = class {
|
|
71
|
-
/**
|
|
72
|
-
* Creates a new upload task. You can find the upload task by its object URL
|
|
73
|
-
* later using `UploadTask.get()`.
|
|
74
|
-
*
|
|
75
|
-
* @param options - The options for the upload task.
|
|
76
|
-
*/
|
|
77
|
-
constructor({ file, uploader }) {
|
|
78
|
-
this.done = false;
|
|
79
|
-
this.subscribers = [];
|
|
80
|
-
this.objectURL = URL.createObjectURL(file);
|
|
81
|
-
this.finished = new Promise((resolve, reject) => {
|
|
82
|
-
const maybePromise = uploader({
|
|
83
|
-
file,
|
|
84
|
-
onProgress: (progress) => {
|
|
85
|
-
for (const subscriber of this.subscribers) subscriber(progress);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
Promise.resolve(maybePromise).then((result) => {
|
|
89
|
-
this.done = true;
|
|
90
|
-
URL.revokeObjectURL(this.objectURL);
|
|
91
|
-
this.result = result;
|
|
92
|
-
resolve(result);
|
|
93
|
-
}, (err) => {
|
|
94
|
-
this.done = true;
|
|
95
|
-
const error = new ProseKitError("[prosekit] Failed to upload file", { cause: err });
|
|
96
|
-
this.error = error;
|
|
97
|
-
reject(error);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
store.set(this.objectURL, this);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Subscribes to progress updates. Returns a function to unsubscribe.
|
|
104
|
-
*/
|
|
105
|
-
subscribeProgress(callback) {
|
|
106
|
-
this.subscribers.push(callback);
|
|
107
|
-
return () => {
|
|
108
|
-
this.subscribers = this.subscribers.filter((subscriber) => subscriber !== callback);
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Finds an upload task from the global store by its object URL.
|
|
113
|
-
*/
|
|
114
|
-
static get(objectURL) {
|
|
115
|
-
return store.get(objectURL);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Deletes an upload task from the global store by its object URL.
|
|
119
|
-
*/
|
|
120
|
-
static delete(objectURL) {
|
|
121
|
-
store.delete(objectURL);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
const store = /* @__PURE__ */ new Map();
|
|
125
|
-
//#endregion
|
|
126
|
-
export { defineFilePasteHandler as n, defineFileDropHandler as r, UploadTask as t };
|
|
127
|
-
|
|
128
|
-
//# sourceMappingURL=file.js.map
|
|
1
|
+
import { n as defineFilePasteHandler, r as defineFileDropHandler, t as UploadTask } from "./file2.js";
|
|
2
|
+
export { UploadTask, defineFileDropHandler, defineFilePasteHandler };
|