@prosekit/extensions 0.14.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/{drop-indicator-B_oMfeVP.js → drop-indicator-DJq8pF92.js} +1 -1
  2. package/dist/{drop-indicator-B_oMfeVP.js.map → drop-indicator-DJq8pF92.js.map} +1 -1
  3. package/dist/{file-iLVR0eM0.js → file-upload-I9m1EJAM.js} +1 -1
  4. package/dist/file-upload-I9m1EJAM.js.map +1 -0
  5. package/dist/{index-cp1u4e0e.d.ts → file-upload-dr3IXUty.d.ts} +1 -1
  6. package/dist/file-upload-dr3IXUty.d.ts.map +1 -0
  7. package/dist/{paste-rule-BaDghcaU.js → mark-paste-rule-n_2Ehmb5.js} +1 -1
  8. package/dist/mark-paste-rule-n_2Ehmb5.js.map +1 -0
  9. package/dist/{mark-rule-CYe8zk4q.js → mark-rule-CUnXwBuy.js} +1 -1
  10. package/dist/{mark-rule-CYe8zk4q.js.map → mark-rule-CUnXwBuy.js.map} +1 -1
  11. package/dist/prosekit-extensions-blockquote.js +1 -1
  12. package/dist/prosekit-extensions-bold.js +1 -1
  13. package/dist/prosekit-extensions-code-block.d.ts +1 -1
  14. package/dist/prosekit-extensions-code-block.js +2 -2
  15. package/dist/prosekit-extensions-code.js +1 -1
  16. package/dist/prosekit-extensions-drop-indicator.js +1 -1
  17. package/dist/prosekit-extensions-enter-rule.d.ts +6 -78
  18. package/dist/prosekit-extensions-enter-rule.d.ts.map +1 -1
  19. package/dist/prosekit-extensions-enter-rule.js +37 -2
  20. package/dist/prosekit-extensions-enter-rule.js.map +1 -0
  21. package/dist/prosekit-extensions-file.d.ts +2 -2
  22. package/dist/prosekit-extensions-file.js +1 -1
  23. package/dist/prosekit-extensions-heading.js +1 -1
  24. package/dist/prosekit-extensions-horizontal-rule.js +1 -1
  25. package/dist/prosekit-extensions-image.d.ts +2 -1
  26. package/dist/prosekit-extensions-image.d.ts.map +1 -1
  27. package/dist/prosekit-extensions-image.js +1 -1
  28. package/dist/prosekit-extensions-input-rule.js +89 -2
  29. package/dist/prosekit-extensions-input-rule.js.map +1 -0
  30. package/dist/prosekit-extensions-italic.js +1 -1
  31. package/dist/prosekit-extensions-link.js +4 -4
  32. package/dist/prosekit-extensions-list.js +2 -2
  33. package/dist/prosekit-extensions-mark-rule.js +1 -1
  34. package/dist/prosekit-extensions-math.d.ts +154 -0
  35. package/dist/prosekit-extensions-math.d.ts.map +1 -0
  36. package/dist/prosekit-extensions-math.js +104 -0
  37. package/dist/prosekit-extensions-math.js.map +1 -0
  38. package/dist/prosekit-extensions-paste-rule.js +1 -1
  39. package/dist/prosekit-extensions-placeholder.js +1 -1
  40. package/dist/prosekit-extensions-strike.js +1 -1
  41. package/dist/prosekit-extensions-table.js +1 -1
  42. package/dist/prosekit-extensions-yjs.d.ts.map +1 -1
  43. package/dist/shiki-highlighter-chunk.d.ts +19 -2
  44. package/dist/shiki-highlighter-chunk.d.ts.map +1 -0
  45. package/dist/{table-4oHfV-Ql.js → table-UJVYsrB7.js} +2 -2
  46. package/dist/{table-4oHfV-Ql.js.map → table-UJVYsrB7.js.map} +1 -1
  47. package/package.json +19 -8
  48. package/src/enter-rule/index.ts +18 -191
  49. package/src/math/index.ts +22 -0
  50. package/src/math/math-block.ts +89 -0
  51. package/src/math/math-inline.ts +89 -0
  52. package/src/math/math-plugin.ts +8 -0
  53. package/src/math/math.ts +39 -0
  54. package/src/testing/index.ts +3 -0
  55. package/src/testing/katex.ts +9 -0
  56. package/src/yjs/yjs-types.ts +0 -2
  57. package/dist/enter-rule-D-p4ykfv.js +0 -96
  58. package/dist/enter-rule-D-p4ykfv.js.map +0 -1
  59. package/dist/file-iLVR0eM0.js.map +0 -1
  60. package/dist/index-cp1u4e0e.d.ts.map +0 -1
  61. package/dist/input-rule-COGr_GBb.js +0 -90
  62. package/dist/input-rule-COGr_GBb.js.map +0 -1
  63. package/dist/paste-rule-BaDghcaU.js.map +0 -1
  64. package/dist/shiki-highlighter-chunk-DNNm2Vow.d.ts +0 -19
  65. package/dist/shiki-highlighter-chunk-DNNm2Vow.d.ts.map +0 -1
@@ -0,0 +1,154 @@
1
+ import { Extension, PlainExtension, Union } from "@prosekit/core";
2
+ import { Attrs } from "@prosekit/pm/model";
3
+ import { RenderMathBlock, RenderMathInline } from "prosemirror-math";
4
+
5
+ //#region src/math/math-block.d.ts
6
+ /**
7
+ * @internal
8
+ */
9
+ type MathBlockSpecExtension = Extension<{
10
+ Nodes: {
11
+ mathBlock: Attrs;
12
+ };
13
+ }>;
14
+ /**
15
+ * @internal
16
+ */
17
+ declare function defineMathBlockSpec(): MathBlockSpecExtension;
18
+ /**
19
+ * Options for {@link defineMathBlockView}.
20
+ *
21
+ * @internal
22
+ */
23
+ interface MathBlockViewOptions {
24
+ /**
25
+ * The function to render the math block.
26
+ */
27
+ render: RenderMathBlock;
28
+ }
29
+ /**
30
+ * Defines an extension that renders a math block using a custom node view.
31
+ *
32
+ * @param options
33
+ * @internal
34
+ */
35
+ declare function defineMathBlockView({
36
+ render
37
+ }: MathBlockViewOptions): Extension;
38
+ /**
39
+ * @internal
40
+ */
41
+ declare function defineMathBlockEnterRule(): PlainExtension;
42
+ /**
43
+ * Options for {@link defineMathBlock}.
44
+ *
45
+ * @internal
46
+ */
47
+ interface MathBlockOptions {
48
+ /**
49
+ * The function to render the math block.
50
+ */
51
+ render: RenderMathBlock;
52
+ }
53
+ /**
54
+ * @internal
55
+ */
56
+ type MathBlockExtension = Union<[MathBlockSpecExtension]>;
57
+ /**
58
+ * Defines node `mathBlock` and related functionalities.
59
+ *
60
+ * @param options
61
+ * @public
62
+ */
63
+ declare function defineMathBlock(options: MathBlockOptions): MathBlockExtension;
64
+ //#endregion
65
+ //#region src/math/math-inline.d.ts
66
+ /**
67
+ * @internal
68
+ */
69
+ type MathInlineSpecExtension = Extension<{
70
+ Nodes: {
71
+ mathInline: Attrs;
72
+ };
73
+ }>;
74
+ /**
75
+ * @internal
76
+ */
77
+ declare function defineMathInlineSpec(): MathInlineSpecExtension;
78
+ /**
79
+ * Options for {@link defineMathInlineView}.
80
+ *
81
+ * @internal
82
+ */
83
+ interface MathInlineViewOptions {
84
+ /**
85
+ * The function to render the math inline.
86
+ */
87
+ render: RenderMathInline;
88
+ }
89
+ /**
90
+ * Defines an extension that renders a math inline using a custom node view.
91
+ *
92
+ * @param options
93
+ * @internal
94
+ */
95
+ declare function defineMathInlineView({
96
+ render
97
+ }: MathInlineViewOptions): Extension;
98
+ /**
99
+ * @internal
100
+ */
101
+ declare function defineMathInlineInputRule(): PlainExtension;
102
+ /**
103
+ * Options for {@link defineMathInline}.
104
+ *
105
+ * @internal
106
+ */
107
+ interface MathInlineOptions {
108
+ /**
109
+ * The function to render the math inline.
110
+ */
111
+ render: RenderMathInline;
112
+ }
113
+ /**
114
+ * @internal
115
+ */
116
+ type MathInlineExtension = Union<[MathInlineSpecExtension]>;
117
+ /**
118
+ * Defines node `mathInline` and related functionalities.
119
+ *
120
+ * @param options
121
+ * @public
122
+ */
123
+ declare function defineMathInline(options: MathInlineOptions): MathInlineExtension;
124
+ //#endregion
125
+ //#region src/math/math.d.ts
126
+ /**
127
+ * @public
128
+ */
129
+ type MathExtension = Union<[MathInlineExtension, MathBlockExtension]>;
130
+ /**
131
+ * Options for {@link defineMath}.
132
+ *
133
+ * @public
134
+ */
135
+ interface MathOptions {
136
+ /**
137
+ * The function to render the math block.
138
+ */
139
+ renderMathBlock: RenderMathBlock;
140
+ /**
141
+ * The function to render the math inline.
142
+ */
143
+ renderMathInline: RenderMathInline;
144
+ }
145
+ /**
146
+ * @public
147
+ */
148
+ declare function defineMath(options: MathOptions): MathExtension;
149
+ //#endregion
150
+ //#region src/math/math-plugin.d.ts
151
+ declare function defineMathPlugin(): PlainExtension;
152
+ //#endregion
153
+ export { type MathBlockExtension, type MathBlockOptions, type MathBlockSpecExtension, type MathBlockViewOptions, type MathExtension, type MathInlineExtension, type MathInlineOptions, type MathInlineSpecExtension, type MathInlineViewOptions, type MathOptions, defineMath, defineMathBlock, defineMathBlockEnterRule, defineMathBlockSpec, defineMathBlockView, defineMathInline, defineMathInlineInputRule, defineMathInlineSpec, defineMathInlineView, defineMathPlugin };
154
+ //# sourceMappingURL=prosekit-extensions-math.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prosekit-extensions-math.d.ts","names":[],"sources":["../src/math/math-block.ts","../src/math/math-inline.ts","../src/math/math.ts","../src/math/math-plugin.ts"],"mappings":";;;;;;;AASA;KAAY,sBAAA,GAAyB,SAAA;EACnC,KAAA;IACE,SAAA,EAAW,KAAA;EAAA;AAAA;;;;iBAOC,mBAAA,CAAA,GAAuB,sBAAA;AAAvC;;;;;AAAA,UAYiB,oBAAA;EAAoB;;;EAInC,MAAA,EAAQ,eAAA;AAAA;;;;;;;iBASM,mBAAA,CAAA;EAAsB;AAAA,GAAU,oBAAA,GAAuB,SAAA;;;;iBAYvD,wBAAA,CAAA,GAA4B,cAAA;;;AAA5C;;;UASiB,gBAAA;EATyC;AAS1D;;EAIE,MAAA,EAAQ,eAAA;AAAA;;AAMV;;KAAY,kBAAA,GAAqB,KAAA,EAAO,sBAAA;;;AAQxC;;;;iBAAgB,eAAA,CAAgB,OAAA,EAAS,gBAAA,GAAmB,kBAAA;;;;;AAzE5D;KCAY,uBAAA,GAA0B,SAAA;EACpC,KAAA;IACE,UAAA,EAAY,KAAA;EAAA;AAAA;;;;iBAOA,oBAAA,CAAA,GAAwB,uBAAA;ADAxC;;;;;AAAA,UCYiB,qBAAA;EDAoB;;;ECInC,MAAA,EAAQ,gBAAA;AAAA;;;;;;;iBASM,oBAAA,CAAA;EAAuB;AAAA,GAAU,qBAAA,GAAwB,SAAA;;;;iBAYzD,yBAAA,CAAA,GAA6B,cAAA;;;ADA7C;;;UCSiB,iBAAA;EDTyC;AAS1D;;ECIE,MAAA,EAAQ,gBAAA;AAAA;;ADMV;;KCAY,mBAAA,GAAsB,KAAA,EAAO,uBAAA;;;ADQzC;;;;iBCAgB,gBAAA,CAAiB,OAAA,EAAS,iBAAA,GAAoB,mBAAA;;;;ADzE9D;;KECY,aAAA,GAAgB,KAAA,EAAO,mBAAA,EAAqB,kBAAA;;;;;;UAOvC,WAAA;EFNG;AAOpB;;EEGE,eAAA,EAAiB,eAAA;EFHoB;;AAYvC;EEJE,gBAAA,EAAkB,gBAAA;AAAA;;;AFiBpB;iBEXgB,UAAA,CAAW,OAAA,EAAS,WAAA,GAAc,aAAA;;;iBC7BlC,gBAAA,CAAA,GAAoB,cAAA"}
@@ -0,0 +1,104 @@
1
+ import { defineInputRule } from "./prosekit-extensions-input-rule.js";
2
+ import { defineEnterRule } from "./prosekit-extensions-enter-rule.js";
3
+ import { defineNodeSpec, defineNodeView, definePlugin, union } from "@prosekit/core";
4
+ import { createCursorInsidePlugin, createMathBlockView, createMathInlineInputRule, createMathInlineView, mathBlockEnterRule, mathBlockSpec, mathInlineSpec } from "prosemirror-math";
5
+
6
+ //#region src/math/math-block.ts
7
+ /**
8
+ * @internal
9
+ */
10
+ function defineMathBlockSpec() {
11
+ return defineNodeSpec({
12
+ ...mathBlockSpec,
13
+ name: "mathBlock"
14
+ });
15
+ }
16
+ /**
17
+ * Defines an extension that renders a math block using a custom node view.
18
+ *
19
+ * @param options
20
+ * @internal
21
+ */
22
+ function defineMathBlockView({ render }) {
23
+ return defineNodeView({
24
+ name: "mathBlock",
25
+ constructor: (node, view, getPos, decorations) => {
26
+ return createMathBlockView(render, node, decorations);
27
+ }
28
+ });
29
+ }
30
+ /**
31
+ * @internal
32
+ */
33
+ function defineMathBlockEnterRule() {
34
+ return defineEnterRule(mathBlockEnterRule);
35
+ }
36
+ /**
37
+ * Defines node `mathBlock` and related functionalities.
38
+ *
39
+ * @param options
40
+ * @public
41
+ */
42
+ function defineMathBlock(options) {
43
+ return union(defineMathBlockSpec(), defineMathBlockView(options), defineMathBlockEnterRule());
44
+ }
45
+
46
+ //#endregion
47
+ //#region src/math/math-inline.ts
48
+ /**
49
+ * @internal
50
+ */
51
+ function defineMathInlineSpec() {
52
+ return defineNodeSpec({
53
+ ...mathInlineSpec,
54
+ name: "mathInline"
55
+ });
56
+ }
57
+ /**
58
+ * Defines an extension that renders a math inline using a custom node view.
59
+ *
60
+ * @param options
61
+ * @internal
62
+ */
63
+ function defineMathInlineView({ render }) {
64
+ return defineNodeView({
65
+ name: "mathInline",
66
+ constructor: (node, view, getPos, decorations) => {
67
+ return createMathInlineView(render, node, decorations);
68
+ }
69
+ });
70
+ }
71
+ /**
72
+ * @internal
73
+ */
74
+ function defineMathInlineInputRule() {
75
+ return defineInputRule(createMathInlineInputRule("mathInline"));
76
+ }
77
+ /**
78
+ * Defines node `mathInline` and related functionalities.
79
+ *
80
+ * @param options
81
+ * @public
82
+ */
83
+ function defineMathInline(options) {
84
+ return union(defineMathInlineSpec(), defineMathInlineView(options), defineMathInlineInputRule());
85
+ }
86
+
87
+ //#endregion
88
+ //#region src/math/math-plugin.ts
89
+ function defineMathPlugin() {
90
+ return definePlugin(createCursorInsidePlugin());
91
+ }
92
+
93
+ //#endregion
94
+ //#region src/math/math.ts
95
+ /**
96
+ * @public
97
+ */
98
+ function defineMath(options) {
99
+ return union(defineMathBlock({ render: options.renderMathBlock }), defineMathInline({ render: options.renderMathInline }), defineMathPlugin());
100
+ }
101
+
102
+ //#endregion
103
+ export { defineMath, defineMathBlock, defineMathBlockEnterRule, defineMathBlockSpec, defineMathBlockView, defineMathInline, defineMathInlineInputRule, defineMathInlineSpec, defineMathInlineView, defineMathPlugin };
104
+ //# sourceMappingURL=prosekit-extensions-math.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prosekit-extensions-math.js","names":[],"sources":["../src/math/math-block.ts","../src/math/math-inline.ts","../src/math/math-plugin.ts","../src/math/math.ts"],"sourcesContent":["import { defineNodeSpec, defineNodeView, union, type Extension, type PlainExtension, type Union } from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\nimport { createMathBlockView, mathBlockEnterRule, mathBlockSpec, type RenderMathBlock } from 'prosemirror-math'\n\nimport { defineEnterRule } from '../enter-rule'\n\n/**\n * @internal\n */\nexport type MathBlockSpecExtension = Extension<{\n Nodes: {\n mathBlock: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineMathBlockSpec(): MathBlockSpecExtension {\n return defineNodeSpec<'mathBlock', Attrs>({\n ...mathBlockSpec,\n name: 'mathBlock',\n })\n}\n\n/**\n * Options for {@link defineMathBlockView}.\n *\n * @internal\n */\nexport interface MathBlockViewOptions {\n /**\n * The function to render the math block.\n */\n render: RenderMathBlock\n}\n\n/**\n * Defines an extension that renders a math block using a custom node view.\n *\n * @param options\n * @internal\n */\nexport function defineMathBlockView({ render }: MathBlockViewOptions): Extension {\n return defineNodeView({\n name: 'mathBlock',\n constructor: (node, view, getPos, decorations) => {\n return createMathBlockView(render, node, decorations)\n },\n })\n}\n\n/**\n * @internal\n */\nexport function defineMathBlockEnterRule(): PlainExtension {\n return defineEnterRule(mathBlockEnterRule)\n}\n\n/**\n * Options for {@link defineMathBlock}.\n *\n * @internal\n */\nexport interface MathBlockOptions {\n /**\n * The function to render the math block.\n */\n render: RenderMathBlock\n}\n\n/**\n * @internal\n */\nexport type MathBlockExtension = Union<[MathBlockSpecExtension]>\n\n/**\n * Defines node `mathBlock` and related functionalities.\n *\n * @param options\n * @public\n */\nexport function defineMathBlock(options: MathBlockOptions): MathBlockExtension {\n return union(\n defineMathBlockSpec(),\n defineMathBlockView(options),\n defineMathBlockEnterRule(),\n )\n}\n","import { defineNodeSpec, defineNodeView, union, type Extension, type PlainExtension, type Union } from '@prosekit/core'\nimport type { Attrs } from '@prosekit/pm/model'\nimport { createMathInlineInputRule, createMathInlineView, mathInlineSpec, type RenderMathInline } from 'prosemirror-math'\n\nimport { defineInputRule } from '../input-rule'\n\n/**\n * @internal\n */\nexport type MathInlineSpecExtension = Extension<{\n Nodes: {\n mathInline: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineMathInlineSpec(): MathInlineSpecExtension {\n return defineNodeSpec<'mathInline', Attrs>({\n ...mathInlineSpec,\n name: 'mathInline',\n })\n}\n\n/**\n * Options for {@link defineMathInlineView}.\n *\n * @internal\n */\nexport interface MathInlineViewOptions {\n /**\n * The function to render the math inline.\n */\n render: RenderMathInline\n}\n\n/**\n * Defines an extension that renders a math inline using a custom node view.\n *\n * @param options\n * @internal\n */\nexport function defineMathInlineView({ render }: MathInlineViewOptions): Extension {\n return defineNodeView({\n name: 'mathInline',\n constructor: (node, view, getPos, decorations) => {\n return createMathInlineView(render, node, decorations)\n },\n })\n}\n\n/**\n * @internal\n */\nexport function defineMathInlineInputRule(): PlainExtension {\n return defineInputRule(createMathInlineInputRule('mathInline'))\n}\n\n/**\n * Options for {@link defineMathInline}.\n *\n * @internal\n */\nexport interface MathInlineOptions {\n /**\n * The function to render the math inline.\n */\n render: RenderMathInline\n}\n\n/**\n * @internal\n */\nexport type MathInlineExtension = Union<[MathInlineSpecExtension]>\n\n/**\n * Defines node `mathInline` and related functionalities.\n *\n * @param options\n * @public\n */\nexport function defineMathInline(options: MathInlineOptions): MathInlineExtension {\n return union(\n defineMathInlineSpec(),\n defineMathInlineView(options),\n defineMathInlineInputRule(),\n )\n}\n","import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport { createCursorInsidePlugin } from 'prosemirror-math'\n\nexport function defineMathPlugin(): PlainExtension {\n return definePlugin(\n createCursorInsidePlugin(),\n )\n}\n","import { union, type Union } from '@prosekit/core'\nimport type { RenderMathBlock, RenderMathInline } from 'prosemirror-math'\n\nimport { defineMathBlock, type MathBlockExtension } from './math-block'\nimport { defineMathInline, type MathInlineExtension } from './math-inline'\nimport { defineMathPlugin } from './math-plugin'\n\n/**\n * @public\n */\nexport type MathExtension = Union<[MathInlineExtension, MathBlockExtension]>\n\n/**\n * Options for {@link defineMath}.\n *\n * @public\n */\nexport interface MathOptions {\n /**\n * The function to render the math block.\n */\n renderMathBlock: RenderMathBlock\n\n /**\n * The function to render the math inline.\n */\n renderMathInline: RenderMathInline\n}\n\n/**\n * @public\n */\nexport function defineMath(options: MathOptions): MathExtension {\n return union(\n defineMathBlock({ render: options.renderMathBlock }),\n defineMathInline({ render: options.renderMathInline }),\n defineMathPlugin(),\n )\n}\n"],"mappings":";;;;;;;;;AAkBA,SAAgB,sBAA8C;AAC5D,QAAO,eAAmC;EACxC,GAAG;EACH,MAAM;EACP,CAAC;;;;;;;;AAqBJ,SAAgB,oBAAoB,EAAE,UAA2C;AAC/E,QAAO,eAAe;EACpB,MAAM;EACN,cAAc,MAAM,MAAM,QAAQ,gBAAgB;AAChD,UAAO,oBAAoB,QAAQ,MAAM,YAAY;;EAExD,CAAC;;;;;AAMJ,SAAgB,2BAA2C;AACzD,QAAO,gBAAgB,mBAAmB;;;;;;;;AA0B5C,SAAgB,gBAAgB,SAA+C;AAC7E,QAAO,MACL,qBAAqB,EACrB,oBAAoB,QAAQ,EAC5B,0BAA0B,CAC3B;;;;;;;;ACrEH,SAAgB,uBAAgD;AAC9D,QAAO,eAAoC;EACzC,GAAG;EACH,MAAM;EACP,CAAC;;;;;;;;AAqBJ,SAAgB,qBAAqB,EAAE,UAA4C;AACjF,QAAO,eAAe;EACpB,MAAM;EACN,cAAc,MAAM,MAAM,QAAQ,gBAAgB;AAChD,UAAO,qBAAqB,QAAQ,MAAM,YAAY;;EAEzD,CAAC;;;;;AAMJ,SAAgB,4BAA4C;AAC1D,QAAO,gBAAgB,0BAA0B,aAAa,CAAC;;;;;;;;AA0BjE,SAAgB,iBAAiB,SAAiD;AAChF,QAAO,MACL,sBAAsB,EACtB,qBAAqB,QAAQ,EAC7B,2BAA2B,CAC5B;;;;;ACpFH,SAAgB,mBAAmC;AACjD,QAAO,aACL,0BAA0B,CAC3B;;;;;;;;AC0BH,SAAgB,WAAW,SAAqC;AAC9D,QAAO,MACL,gBAAgB,EAAE,QAAQ,QAAQ,iBAAiB,CAAC,EACpD,iBAAiB,EAAE,QAAQ,QAAQ,kBAAkB,CAAC,EACtD,kBAAkB,CACnB"}
@@ -1,3 +1,3 @@
1
- import { n as definePasteRule, t as defineMarkPasteRule } from "./paste-rule-BaDghcaU.js";
1
+ import { n as definePasteRule, t as defineMarkPasteRule } from "./mark-paste-rule-n_2Ehmb5.js";
2
2
 
3
3
  export { defineMarkPasteRule, definePasteRule };
@@ -1,4 +1,4 @@
1
- import { p as findTable } from "./table-4oHfV-Ql.js";
1
+ import { p as findTable } from "./table-UJVYsrB7.js";
2
2
  import { definePlugin, isInCodeBlock, isTextSelection, maybeRun } from "@prosekit/core";
3
3
  import { Plugin, PluginKey } from "@prosekit/pm/state";
4
4
  import { Decoration, DecorationSet } from "@prosekit/pm/view";
@@ -1,4 +1,4 @@
1
- import { r as defineMarkInputRule } from "./input-rule-COGr_GBb.js";
1
+ import { defineMarkInputRule } from "./prosekit-extensions-input-rule.js";
2
2
  import { canUseRegexLookbehind, defineCommands, defineKeymap, defineMarkSpec, toggleMark, union } from "@prosekit/core";
3
3
 
4
4
  //#region src/strike/index.ts
@@ -1,3 +1,3 @@
1
- import { _ as insertTable, a as defineTableSpec, c as defineTableCommands, d as selectTableCell, f as selectTable, g as moveTableColumn, h as moveTableRow, i as defineTableRowSpec, l as selectTableRow, m as isCellSelection, n as defineTableCellSpec, o as defineTablePlugins, p as findTable, r as defineTableHeaderCellSpec, s as defineTableDropIndicator, t as defineTable, u as selectTableColumn, v as exitTable } from "./table-4oHfV-Ql.js";
1
+ import { _ as insertTable, a as defineTableSpec, c as defineTableCommands, d as selectTableCell, f as selectTable, g as moveTableColumn, h as moveTableRow, i as defineTableRowSpec, l as selectTableRow, m as isCellSelection, n as defineTableCellSpec, o as defineTablePlugins, p as findTable, r as defineTableHeaderCellSpec, s as defineTableDropIndicator, t as defineTable, u as selectTableColumn, v as exitTable } from "./table-UJVYsrB7.js";
2
2
 
3
3
  export { defineTable, defineTableCellSpec, defineTableCommands, defineTableDropIndicator, defineTableHeaderCellSpec, defineTablePlugins, defineTableRowSpec, defineTableSpec, exitTable, findTable, insertTable, isCellSelection, moveTableColumn, moveTableRow, selectTable, selectTableCell, selectTableColumn, selectTableRow };
@@ -1 +1 @@
1
- {"version":3,"file":"prosekit-extensions-yjs.d.ts","names":[],"sources":["../src/yjs/yjs-commands.ts","../src/yjs/yjs-types.ts","../src/yjs/yjs-cursor-plugin.ts","../src/yjs/yjs-sync-plugin.ts","../src/yjs/yjs-undo-plugin.ts","../src/yjs/yjs.ts","../src/yjs/yjs-keymap.ts"],"mappings":";;;;;;;;KAWY,oBAAA,GAAuB,SAAA;EACjC,QAAA;IACE,IAAA;IACA,IAAA;EAAA;AAAA;AAAA,iBAIY,iBAAA,CAAA,GAAqB,oBAAA;;;;;;;AAPrC;KCFY,SAAA,GAAY,UAAA,QAAkB,aAAA;;;;;ADE1C;KEFY,sBAAA,GAAyB,WAAA,CACnC,UAAA,QAAkB,aAAA;AAAA,UAGH,gBAAA,SAAyB,sBAAA;EACxC,SAAA,EAAW,SAAA;AAAA;AAAA,iBAGG,qBAAA,CACd,OAAA,EAAS,gBAAA,GACR,cAAA;;;;;AFRH;KGHY,oBAAA,GAAuB,WAAA,CACjC,UAAA,QAAkB,WAAA;AAAA,UAGH,cAAA,SAAuB,oBAAA;EACtC,QAAA,EAAU,CAAA,CAAE,WAAA;AAAA;AAAA,iBAGE,mBAAA,CAAoB,OAAA,EAAS,cAAA,GAAiB,cAAA;;;;;;KC4ClD,oBAAA,GAAuB,WAAA,CACjC,UAAA,QAAkB,WAAA;AAAA,UAGH,cAAA,SAAuB,oBAAA;;;;iBAcxB,mBAAA,CAAoB,OAAA,EAAS,cAAA,GAAiB,cAAA;;;UCpE7C,UAAA;ELC2B;;;EKG1C,GAAA,EAAK,CAAA,CAAE,GAAA;ELAL;;;EKKF,SAAA,EAAW,SAAA;ELDoB;;;;EKO/B,QAAA,GAAW,CAAA,CAAE,WAAA;;;AJhBf;EIqBE,IAAA,GAAO,oBAAA;;;;EAKP,IAAA,GAAO,oBAAA;;;AH1BT;EG+BE,MAAA,GAAS,sBAAA;AAAA;;;;KAMC,YAAA,GAAe,KAAA,EAAO,oBAAA,EAAsB,cAAA;;;;iBAKxC,SAAA,CAAU,OAAA,EAAS,UAAA,GAAa,YAAA;;;iBCvChC,eAAA,CAAA,GAAmB,cAAA"}
1
+ {"version":3,"file":"prosekit-extensions-yjs.d.ts","names":[],"sources":["../src/yjs/yjs-commands.ts","../src/yjs/yjs-types.ts","../src/yjs/yjs-cursor-plugin.ts","../src/yjs/yjs-sync-plugin.ts","../src/yjs/yjs-undo-plugin.ts","../src/yjs/yjs.ts","../src/yjs/yjs-keymap.ts"],"mappings":";;;;;;;;KAWY,oBAAA,GAAuB,SAAA;EACjC,QAAA;IACE,IAAA;IACA,IAAA;EAAA;AAAA;AAAA,iBAIY,iBAAA,CAAA,GAAqB,oBAAA;;;;;;;AAPrC;KCJY,SAAA,GAAY,UAAA,QAAkB,aAAA;;;;;ADI1C;KEFY,sBAAA,GAAyB,WAAA,CACnC,UAAA,QAAkB,aAAA;AAAA,UAGH,gBAAA,SAAyB,sBAAA;EACxC,SAAA,EAAW,SAAA;AAAA;AAAA,iBAGG,qBAAA,CACd,OAAA,EAAS,gBAAA,GACR,cAAA;;;;;AFRH;KGHY,oBAAA,GAAuB,WAAA,CACjC,UAAA,QAAkB,WAAA;AAAA,UAGH,cAAA,SAAuB,oBAAA;EACtC,QAAA,EAAU,CAAA,CAAE,WAAA;AAAA;AAAA,iBAGE,mBAAA,CAAoB,OAAA,EAAS,cAAA,GAAiB,cAAA;;;;;;KC4ClD,oBAAA,GAAuB,WAAA,CACjC,UAAA,QAAkB,WAAA;AAAA,UAGH,cAAA,SAAuB,oBAAA;;;;iBAcxB,mBAAA,CAAoB,OAAA,EAAS,cAAA,GAAiB,cAAA;;;UCpE7C,UAAA;ELC2B;;;EKG1C,GAAA,EAAK,CAAA,CAAE,GAAA;ELAL;;;EKKF,SAAA,EAAW,SAAA;ELDoB;;;;EKO/B,QAAA,GAAW,CAAA,CAAE,WAAA;;;AJlBf;EIuBE,IAAA,GAAO,oBAAA;;;;EAKP,IAAA,GAAO,oBAAA;;;AH1BT;EG+BE,MAAA,GAAS,sBAAA;AAAA;;;;KAMC,YAAA,GAAe,KAAA,EAAO,oBAAA,EAAsB,cAAA;;;;iBAKxC,SAAA,CAAU,OAAA,EAAS,UAAA,GAAa,YAAA;;;iBCvChC,eAAA,CAAA,GAAmB,cAAA"}
@@ -1,2 +1,19 @@
1
- import { i as createOrGetHighlighter, n as HighlighterResult, r as ShikiHighlighterOptions, t as HighlighterOptions } from "./shiki-highlighter-chunk-DNNm2Vow.js";
2
- export { HighlighterOptions, HighlighterResult, ShikiHighlighterOptions, createOrGetHighlighter };
1
+ import { BundledHighlighterOptions, BundledLanguage, BundledTheme, Highlighter, SpecialLanguage } from "shiki";
2
+
3
+ //#region src/code-block/shiki-highlighter-chunk.d.ts
4
+ interface ShikiHighlighterOptions extends BundledHighlighterOptions<BundledLanguage, BundledTheme> {}
5
+ interface HighlighterOptions extends Omit<ShikiHighlighterOptions, 'langs' | 'themes'> {
6
+ themes: BundledTheme[];
7
+ langs: (BundledLanguage | SpecialLanguage)[];
8
+ }
9
+ type HighlighterResult = {
10
+ highlighter: Highlighter;
11
+ promise?: undefined;
12
+ } | {
13
+ highlighter?: undefined;
14
+ promise: Promise<void>;
15
+ };
16
+ declare function createOrGetHighlighter(options: HighlighterOptions): HighlighterResult;
17
+ //#endregion
18
+ export { HighlighterOptions, HighlighterResult, ShikiHighlighterOptions, createOrGetHighlighter };
19
+ //# sourceMappingURL=shiki-highlighter-chunk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shiki-highlighter-chunk.d.ts","names":[],"sources":["../src/code-block/shiki-highlighter-chunk.ts"],"mappings":";;;UASiB,uBAAA,SAAgC,yBAAA,CAA0B,eAAA,EAAiB,YAAA;AAAA,UAE3E,kBAAA,SAA2B,IAAA,CAAK,uBAAA;EAC/C,MAAA,EAAQ,YAAA;EACR,KAAA,GAAQ,eAAA,GAAkB,eAAA;AAAA;AAAA,KAoChB,iBAAA;EAER,WAAA,EAAa,WAAA;EACb,OAAA;AAAA;EAGA,WAAA;EACA,OAAA,EAAS,OAAA;AAAA;AAAA,iBAGG,sBAAA,CACd,OAAA,EAAS,kBAAA,GACR,iBAAA"}
@@ -1,4 +1,4 @@
1
- import { t as defineDropIndicator } from "./drop-indicator-B_oMfeVP.js";
1
+ import { t as defineDropIndicator } from "./drop-indicator-DJq8pF92.js";
2
2
  import { defaultBlockAt, defineCommands, defineNodeSpec, definePlugin, getNodeType, insertNode, union } from "@prosekit/core";
3
3
  import { TextSelection } from "@prosekit/pm/state";
4
4
  import { CellSelection, TableMap, addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, columnResizing, deleteCellSelection, deleteColumn, deleteRow, deleteTable, findCellPos, findCellRange, findTable, mergeCells, moveTableColumn, moveTableRow, splitCell, tableEditing, tableNodes } from "prosemirror-tables";
@@ -285,4 +285,4 @@ function defineTable() {
285
285
 
286
286
  //#endregion
287
287
  export { insertTable as _, defineTableSpec as a, defineTableCommands as c, selectTableCell as d, selectTable as f, moveTableColumn as g, moveTableRow as h, defineTableRowSpec as i, selectTableRow as l, isCellSelection as m, defineTableCellSpec as n, defineTablePlugins as o, findTable as p, defineTableHeaderCellSpec as r, defineTableDropIndicator as s, defineTable as t, selectTableColumn as u, exitTable as v };
288
- //# sourceMappingURL=table-4oHfV-Ql.js.map
288
+ //# sourceMappingURL=table-UJVYsrB7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"table-4oHfV-Ql.js","names":[],"sources":["../src/table/table-commands/exit-table.ts","../src/table/table-commands/insert-table.ts","../src/table/table-utils.ts","../src/table/table-commands/select-table.ts","../src/table/table-commands/select-table-cell.ts","../src/table/table-commands/select-table-column.ts","../src/table/table-commands/select-table-row.ts","../src/table/table-commands.ts","../src/table/table-drop-indicator.ts","../src/table/table-plugins.ts","../src/table/table-spec.ts","../src/table/table.ts"],"sourcesContent":["import { defaultBlockAt } from '@prosekit/core'\nimport { TextSelection } from '@prosekit/pm/state'\nimport type { Command } from '@prosekit/pm/state'\nimport type { TableRole } from 'prosemirror-tables'\n\n/**\n * When the selection is in a table node, create a default block after the table\n * table, and move the cursor there.\n *\n * @public\n */\nexport const exitTable: Command = (state, dispatch) => {\n const { $head, $anchor } = state.selection\n\n if (!$head.sameParent($anchor)) {\n return false\n }\n\n let tableStart = -1\n let tableDepth = -1\n for (let depth = $head.depth; depth >= 0; depth--) {\n const node = $head.node(depth)\n if ((node.type.spec.tableRole as TableRole) === 'table') {\n tableStart = $head.before(depth)\n tableDepth = depth\n }\n }\n\n if (tableStart < 0 || tableDepth <= 0) {\n return false\n }\n\n const above = $head.node(tableDepth - 1)\n const after = $head.indexAfter(tableDepth - 1)\n const type = defaultBlockAt(above.contentMatchAt(after))\n const node = type?.createAndFill()\n\n if (!type || !node || !above.canReplaceWith(after, after, type)) {\n return false\n }\n\n if (dispatch) {\n const pos = $head.after(tableDepth)\n const tr = state.tr.replaceWith(pos, pos, node)\n tr.setSelection(TextSelection.near(tr.doc.resolve(pos), 1))\n dispatch(tr.scrollIntoView())\n }\n return true\n}\n","import { getNodeType, insertNode } from '@prosekit/core'\nimport type { Schema } from '@prosekit/pm/model'\nimport type { Command } from '@prosekit/pm/state'\n\nfunction createEmptyTable(\n schema: Schema,\n row: number,\n col: number,\n header: boolean,\n) {\n const tableType = getNodeType(schema, 'table')\n const tableRowType = getNodeType(schema, 'tableRow')\n const tableCellType = getNodeType(schema, 'tableCell')\n const tableHeaderCellType = getNodeType(schema, 'tableHeaderCell')\n\n if (header) {\n const headerCell = tableHeaderCellType.createAndFill()!\n const headerCells = repeat(headerCell, col)\n const headerRow = tableRowType.createAndFill(null, headerCells)!\n\n const bodyCell = tableCellType.createAndFill()!\n const bodyCells = repeat(bodyCell, col)\n const bodyRow = tableRowType.createAndFill(null, bodyCells)!\n const bodyRows = repeat(bodyRow, row - 1)\n\n return tableType.createAndFill(null, [headerRow, ...bodyRows])!\n } else {\n const bodyCell = tableCellType.createAndFill()!\n const bodyCells = repeat(bodyCell, col)\n const bodyRow = tableRowType.createAndFill(null, bodyCells)!\n const bodyRows = repeat(bodyRow, row)\n\n return tableType.createAndFill(null, bodyRows)!\n }\n}\n\nfunction repeat<T>(node: T, length: number): T[] {\n return Array<T>(length).fill(node)\n}\n\n/**\n * @public\n */\nexport interface InsertTableOptions {\n /**\n * The number of rows in the table.\n */\n row: number\n\n /**\n * The number of columns in the table.\n */\n col: number\n\n /**\n * Whether the table has a header row.\n *\n * @default false\n */\n header?: boolean\n}\n\n/**\n * Insert a table node with the given number of rows and columns, and optionally\n * a header row.\n *\n * @param options\n *\n * @public\n */\nexport function insertTable(options: InsertTableOptions): Command {\n return (state, dispatch, view) => {\n const { row, col, header = false } = options\n const table = createEmptyTable(state.schema, row, col, header)\n return insertNode({ node: table })(state, dispatch, view)\n }\n}\n","import { CellSelection, findCellPos, findCellRange, findTable } from 'prosemirror-tables'\n\nexport { findCellPos, findCellRange, findTable }\n\n/**\n * Checks if the given object is a `CellSelection` instance.\n *\n * @public\n */\nexport function isCellSelection(value: unknown): value is CellSelection {\n return value instanceof CellSelection\n}\n","import type { Command } from '@prosekit/pm/state'\nimport { CellSelection, TableMap } from 'prosemirror-tables'\n\nimport { findTable } from '../table-utils'\n\n/**\n * @public\n */\nexport interface SelectTableOptions {\n /**\n * A hit position of the table to select from. By default, the selection\n * anchor will be used.\n */\n pos?: number\n}\n\n/**\n * @public\n */\nexport function selectTable(options?: SelectTableOptions): Command {\n return (state, dispatch) => {\n const $pos = options?.pos\n ? state.doc.resolve(options.pos)\n : state.selection.$anchor\n const table = findTable($pos)\n if (!table) {\n return false\n }\n const map = TableMap.get(table.node)\n if (map.map.length === 0) {\n return false\n }\n if (dispatch) {\n let tr = state.tr\n const firstCellPosInTable = map.map[0]\n const lastCellPosInTable = map.map[map.map.length - 1]\n const firstCellPos = table.pos + firstCellPosInTable + 1\n const lastCellPos = table.pos + lastCellPosInTable + 1\n const $firstCellPos = tr.doc.resolve(firstCellPos)\n const $lastCellPos = tr.doc.resolve(lastCellPos)\n const selection = new CellSelection($firstCellPos, $lastCellPos)\n tr = tr.setSelection(selection)\n dispatch?.(tr)\n }\n return true\n }\n}\n","import type { Command } from '@prosekit/pm/state'\nimport { CellSelection } from 'prosemirror-tables'\n\nimport { findCellPos } from '../table-utils'\n\n/**\n * @public\n */\nexport interface SelectTableCellOptions {\n /**\n * A hit position of the table cell to select from. By default, the selection\n * anchor will be used.\n */\n pos?: number\n}\n\n/**\n * @public\n */\nexport function selectTableCell(options?: SelectTableCellOptions): Command {\n return (state, dispatch) => {\n const $cellPos = findCellPos(\n state.doc,\n options?.pos ?? state.selection.anchor,\n )\n if (!$cellPos) {\n return false\n }\n if (dispatch) {\n const selection = new CellSelection($cellPos)\n dispatch(state.tr.setSelection(selection))\n }\n return true\n }\n}\n","import type { Command } from '@prosekit/pm/state'\nimport { CellSelection } from 'prosemirror-tables'\n\nimport { findCellRange } from '../table-utils'\n\n/**\n * @public\n */\nexport interface SelectTableColumnOptions {\n /**\n * A hit position of the table cell to select from. By default, the selection\n * anchor will be used.\n */\n anchor?: number\n\n /**\n * A hit position of the table cell to select to. By default, the selection\n * head will be used.\n */\n head?: number\n}\n\n/**\n * @public\n */\nexport function selectTableColumn(options?: SelectTableColumnOptions): Command {\n return (state, dispatch) => {\n const range = findCellRange(state.selection, options?.anchor, options?.head)\n if (!range) {\n return false\n }\n if (dispatch) {\n const [$anchorCell, $headCell] = range\n const selection = CellSelection.colSelection($anchorCell, $headCell)\n dispatch(state.tr.setSelection(selection))\n }\n return true\n }\n}\n","import type { Command } from '@prosekit/pm/state'\nimport { CellSelection } from 'prosemirror-tables'\n\nimport { findCellRange } from '../table-utils'\n\n/**\n * @public\n */\nexport interface SelectTableRowOptions {\n /**\n * A hit position of the table cell to select from. By default, the selection\n * anchor will be used.\n */\n anchor?: number\n\n /**\n * A hit position of the table cell to select to. By default, the selection\n * head will be used.\n */\n head?: number\n}\n\n/**\n * @public\n */\nexport function selectTableRow(options?: SelectTableRowOptions): Command {\n return (state, dispatch) => {\n const range = findCellRange(state.selection, options?.anchor, options?.head)\n if (!range) {\n return false\n }\n if (dispatch) {\n const [$anchorCell, $headCell] = range\n const selection = CellSelection.rowSelection($anchorCell, $headCell)\n dispatch(state.tr.setSelection(selection))\n }\n return true\n }\n}\n","import { defineCommands, type Extension } from '@prosekit/core'\nimport {\n addColumnAfter,\n addColumnBefore,\n addRowAfter,\n addRowBefore,\n deleteColumn,\n deleteRow,\n deleteTable,\n mergeCells,\n splitCell,\n} from 'prosemirror-tables'\n\nimport { deleteCellSelection } from './table-commands/delete-cell-selection'\nimport { exitTable } from './table-commands/exit-table'\nimport { insertTable, type InsertTableOptions } from './table-commands/insert-table'\nimport { moveTableColumn, type MoveTableColumnOptions } from './table-commands/move-table-column'\nimport { moveTableRow, type MoveTableRowOptions } from './table-commands/move-table-row'\nimport { selectTable, type SelectTableOptions } from './table-commands/select-table'\nimport { selectTableCell, type SelectTableCellOptions } from './table-commands/select-table-cell'\nimport { selectTableColumn, type SelectTableColumnOptions } from './table-commands/select-table-column'\nimport { selectTableRow, type SelectTableRowOptions } from './table-commands/select-table-row'\n\n/**\n * @internal\n */\nexport type TableCommandsExtension = Extension<{\n Commands: {\n insertTable: [options: InsertTableOptions]\n exitTable: []\n\n selectTable: [options?: SelectTableOptions]\n selectTableCell: [options?: SelectTableCellOptions]\n selectTableColumn: [options?: SelectTableColumnOptions]\n selectTableRow: [options?: SelectTableRowOptions]\n\n addTableColumnBefore: []\n addTableColumnAfter: []\n addTableRowAbove: []\n addTableRowBelow: []\n\n deleteTable: []\n deleteTableColumn: []\n deleteTableRow: []\n deleteCellSelection: []\n\n mergeTableCells: []\n splitTableCell: []\n\n moveTableRow: [options: MoveTableRowOptions]\n moveTableColumn: [options: MoveTableColumnOptions]\n }\n}>\n\n/**\n * Adds commands for working with `table` nodes.\n *\n * @public\n */\nexport function defineTableCommands(): TableCommandsExtension {\n return defineCommands({\n insertTable,\n exitTable: () => exitTable,\n\n selectTable,\n selectTableCell,\n selectTableColumn,\n selectTableRow,\n\n addTableColumnBefore: () => addColumnBefore,\n addTableColumnAfter: () => addColumnAfter,\n addTableRowAbove: () => addRowBefore,\n addTableRowBelow: () => addRowAfter,\n\n deleteTable: () => deleteTable,\n deleteTableColumn: () => deleteColumn,\n deleteTableRow: () => deleteRow,\n deleteCellSelection: () => deleteCellSelection,\n\n mergeTableCells: () => mergeCells,\n splitTableCell: () => splitCell,\n\n moveTableRow,\n moveTableColumn,\n })\n}\n","import type { PlainExtension } from '@prosekit/core'\n\nimport type { DragEventHandler } from '../drop-indicator'\nimport { defineDropIndicator } from '../drop-indicator'\n\n/**\n * Hides the drop indicator when dragging a table column or row by using the\n * table handle.\n *\n * @internal\n */\nexport function defineTableDropIndicator(): PlainExtension {\n return defineDropIndicator({\n onDrag,\n })\n}\n\nconst matchMap = new WeakMap<DataTransfer, boolean>()\n\nconst onDrag: DragEventHandler = ({ event }): boolean => {\n const dataTransfer = event.dataTransfer\n if (!dataTransfer) return true\n\n let match: boolean\n\n if (matchMap.has(dataTransfer)) {\n match = matchMap.get(dataTransfer)!\n } else {\n // On Safari, accessing `dataTransfer.types` is more than 10x slower than in\n // Chrome. This becomes a bottleneck when `onDrag` is called frequently, so\n // we cache the result in a WeakMap.\n const types = dataTransfer.types\n match = types.includes('application/x-prosekit-table-handle-drag')\n matchMap.set(dataTransfer, match)\n }\n\n // Don't show the drop indicator when the drag event has\n // \"application/x-prosekit-table-handle-drag\" type.\n return !match\n}\n","import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport { columnResizing, tableEditing } from 'prosemirror-tables'\n\n/**\n * @public\n */\nexport function defineTablePlugins(): PlainExtension {\n return definePlugin([tableEditing(), columnResizing()])\n}\n","import { defineNodeSpec, type Extension } from '@prosekit/core'\nimport type { AttributeSpec, Attrs } from '@prosekit/pm/model'\nimport { tableNodes } from 'prosemirror-tables'\n\nconst cellContent = 'block+'\n\n/**\n * @public\n */\nexport interface CellAttrs {\n colspan?: number\n rowspan?: number\n colwidth?: number[] | null\n}\n\nconst cellAttrs = {\n colspan: { default: 1 },\n rowspan: { default: 1 },\n colwidth: { default: null },\n} satisfies Record<string, AttributeSpec>\n\n/**\n * @internal\n */\nexport type TableSpecExtension = Extension<{\n Nodes: {\n table: Attrs\n }\n}>\n\nconst specs = tableNodes({\n tableGroup: 'block',\n cellContent,\n cellAttributes: {},\n})\n\n/**\n * @internal\n */\nexport function defineTableSpec(): TableSpecExtension {\n return defineNodeSpec({\n ...specs['table'],\n content: 'tableRow+',\n name: 'table',\n })\n}\n\n/**\n * @internal\n */\nexport type TableRowSpecExtension = Extension<{\n Nodes: {\n tableRow: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineTableRowSpec(): TableRowSpecExtension {\n return defineNodeSpec({\n ...specs['table_row'],\n content: '(tableCell | tableHeaderCell)*',\n name: 'tableRow',\n })\n}\n\n/**\n * @internal\n */\nexport type TableCellSpecExtension = Extension<{\n Nodes: {\n tableCell: CellAttrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineTableCellSpec(): TableCellSpecExtension {\n return defineNodeSpec({\n ...specs['table_cell'],\n name: 'tableCell',\n attrs: cellAttrs,\n })\n}\n\n/**\n * @internal\n */\nexport type TableHeaderCellSpecExtension = Extension<{\n Nodes: {\n tableHeaderCell: CellAttrs\n }\n}>\n\nexport function defineTableHeaderCellSpec(): TableHeaderCellSpecExtension {\n return defineNodeSpec({\n ...specs['table_header'],\n name: 'tableHeaderCell',\n attrs: cellAttrs,\n })\n}\n","import { union, type Union } from '@prosekit/core'\n\nimport { defineTableCommands, type TableCommandsExtension } from './table-commands'\nimport { defineTableDropIndicator } from './table-drop-indicator'\nimport { defineTablePlugins } from './table-plugins'\nimport {\n defineTableCellSpec,\n defineTableHeaderCellSpec,\n defineTableRowSpec,\n defineTableSpec,\n type TableCellSpecExtension,\n type TableHeaderCellSpecExtension,\n type TableRowSpecExtension,\n type TableSpecExtension,\n} from './table-spec'\n\n/**\n * @internal\n */\nexport type TableExtension = Union<\n [\n TableSpecExtension,\n TableRowSpecExtension,\n TableCellSpecExtension,\n TableHeaderCellSpecExtension,\n TableCommandsExtension,\n ]\n>\n\n/**\n * @public\n */\nexport function defineTable(): TableExtension {\n return union(\n defineTableSpec(),\n defineTableRowSpec(),\n defineTableCellSpec(),\n defineTableHeaderCellSpec(),\n defineTablePlugins(),\n defineTableCommands(),\n defineTableDropIndicator(),\n )\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,aAAsB,OAAO,aAAa;CACrD,MAAM,EAAE,OAAO,YAAY,MAAM;AAEjC,KAAI,CAAC,MAAM,WAAW,QAAQ,CAC5B,QAAO;CAGT,IAAI,aAAa;CACjB,IAAI,aAAa;AACjB,MAAK,IAAI,QAAQ,MAAM,OAAO,SAAS,GAAG,QAExC,KADa,MAAM,KAAK,MAAM,CACpB,KAAK,KAAK,cAA4B,SAAS;AACvD,eAAa,MAAM,OAAO,MAAM;AAChC,eAAa;;AAIjB,KAAI,aAAa,KAAK,cAAc,EAClC,QAAO;CAGT,MAAM,QAAQ,MAAM,KAAK,aAAa,EAAE;CACxC,MAAM,QAAQ,MAAM,WAAW,aAAa,EAAE;CAC9C,MAAM,OAAO,eAAe,MAAM,eAAe,MAAM,CAAC;CACxD,MAAM,OAAO,MAAM,eAAe;AAElC,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,eAAe,OAAO,OAAO,KAAK,CAC7D,QAAO;AAGT,KAAI,UAAU;EACZ,MAAM,MAAM,MAAM,MAAM,WAAW;EACnC,MAAM,KAAK,MAAM,GAAG,YAAY,KAAK,KAAK,KAAK;AAC/C,KAAG,aAAa,cAAc,KAAK,GAAG,IAAI,QAAQ,IAAI,EAAE,EAAE,CAAC;AAC3D,WAAS,GAAG,gBAAgB,CAAC;;AAE/B,QAAO;;;;;AC3CT,SAAS,iBACP,QACA,KACA,KACA,QACA;CACA,MAAM,Y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,QAAO,eAAe;EACpB,GAAG,MAAM;EACT,MAAM;EACN,OAAO;EACR,CAAC;;;;;;;;ACrEJ,SAAgB,cAA8B;AAC5C,QAAO,MACL,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,CAC3B"}
1
+ {"version":3,"file":"table-UJVYsrB7.js","names":[],"sources":["../src/table/table-commands/exit-table.ts","../src/table/table-commands/insert-table.ts","../src/table/table-utils.ts","../src/table/table-commands/select-table.ts","../src/table/table-commands/select-table-cell.ts","../src/table/table-commands/select-table-column.ts","../src/table/table-commands/select-table-row.ts","../src/table/table-commands.ts","../src/table/table-drop-indicator.ts","../src/table/table-plugins.ts","../src/table/table-spec.ts","../src/table/table.ts"],"sourcesContent":["import { defaultBlockAt } from '@prosekit/core'\nimport { TextSelection } from '@prosekit/pm/state'\nimport type { Command } from '@prosekit/pm/state'\nimport type { TableRole } from 'prosemirror-tables'\n\n/**\n * When the selection is in a table node, create a default block after the table\n * table, and move the cursor there.\n *\n * @public\n */\nexport const exitTable: Command = (state, dispatch) => {\n const { $head, $anchor } = state.selection\n\n if (!$head.sameParent($anchor)) {\n return false\n }\n\n let tableStart = -1\n let tableDepth = -1\n for (let depth = $head.depth; depth >= 0; depth--) {\n const node = $head.node(depth)\n if ((node.type.spec.tableRole as TableRole) === 'table') {\n tableStart = $head.before(depth)\n tableDepth = depth\n }\n }\n\n if (tableStart < 0 || tableDepth <= 0) {\n return false\n }\n\n const above = $head.node(tableDepth - 1)\n const after = $head.indexAfter(tableDepth - 1)\n const type = defaultBlockAt(above.contentMatchAt(after))\n const node = type?.createAndFill()\n\n if (!type || !node || !above.canReplaceWith(after, after, type)) {\n return false\n }\n\n if (dispatch) {\n const pos = $head.after(tableDepth)\n const tr = state.tr.replaceWith(pos, pos, node)\n tr.setSelection(TextSelection.near(tr.doc.resolve(pos), 1))\n dispatch(tr.scrollIntoView())\n }\n return true\n}\n","import { getNodeType, insertNode } from '@prosekit/core'\nimport type { Schema } from '@prosekit/pm/model'\nimport type { Command } from '@prosekit/pm/state'\n\nfunction createEmptyTable(\n schema: Schema,\n row: number,\n col: number,\n header: boolean,\n) {\n const tableType = getNodeType(schema, 'table')\n const tableRowType = getNodeType(schema, 'tableRow')\n const tableCellType = getNodeType(schema, 'tableCell')\n const tableHeaderCellType = getNodeType(schema, 'tableHeaderCell')\n\n if (header) {\n const headerCell = tableHeaderCellType.createAndFill()!\n const headerCells = repeat(headerCell, col)\n const headerRow = tableRowType.createAndFill(null, headerCells)!\n\n const bodyCell = tableCellType.createAndFill()!\n const bodyCells = repeat(bodyCell, col)\n const bodyRow = tableRowType.createAndFill(null, bodyCells)!\n const bodyRows = repeat(bodyRow, row - 1)\n\n return tableType.createAndFill(null, [headerRow, ...bodyRows])!\n } else {\n const bodyCell = tableCellType.createAndFill()!\n const bodyCells = repeat(bodyCell, col)\n const bodyRow = tableRowType.createAndFill(null, bodyCells)!\n const bodyRows = repeat(bodyRow, row)\n\n return tableType.createAndFill(null, bodyRows)!\n }\n}\n\nfunction repeat<T>(node: T, length: number): T[] {\n return Array<T>(length).fill(node)\n}\n\n/**\n * @public\n */\nexport interface InsertTableOptions {\n /**\n * The number of rows in the table.\n */\n row: number\n\n /**\n * The number of columns in the table.\n */\n col: number\n\n /**\n * Whether the table has a header row.\n *\n * @default false\n */\n header?: boolean\n}\n\n/**\n * Insert a table node with the given number of rows and columns, and optionally\n * a header row.\n *\n * @param options\n *\n * @public\n */\nexport function insertTable(options: InsertTableOptions): Command {\n return (state, dispatch, view) => {\n const { row, col, header = false } = options\n const table = createEmptyTable(state.schema, row, col, header)\n return insertNode({ node: table })(state, dispatch, view)\n }\n}\n","import { CellSelection, findCellPos, findCellRange, findTable } from 'prosemirror-tables'\n\nexport { findCellPos, findCellRange, findTable }\n\n/**\n * Checks if the given object is a `CellSelection` instance.\n *\n * @public\n */\nexport function isCellSelection(value: unknown): value is CellSelection {\n return value instanceof CellSelection\n}\n","import type { Command } from '@prosekit/pm/state'\nimport { CellSelection, TableMap } from 'prosemirror-tables'\n\nimport { findTable } from '../table-utils'\n\n/**\n * @public\n */\nexport interface SelectTableOptions {\n /**\n * A hit position of the table to select from. By default, the selection\n * anchor will be used.\n */\n pos?: number\n}\n\n/**\n * @public\n */\nexport function selectTable(options?: SelectTableOptions): Command {\n return (state, dispatch) => {\n const $pos = options?.pos\n ? state.doc.resolve(options.pos)\n : state.selection.$anchor\n const table = findTable($pos)\n if (!table) {\n return false\n }\n const map = TableMap.get(table.node)\n if (map.map.length === 0) {\n return false\n }\n if (dispatch) {\n let tr = state.tr\n const firstCellPosInTable = map.map[0]\n const lastCellPosInTable = map.map[map.map.length - 1]\n const firstCellPos = table.pos + firstCellPosInTable + 1\n const lastCellPos = table.pos + lastCellPosInTable + 1\n const $firstCellPos = tr.doc.resolve(firstCellPos)\n const $lastCellPos = tr.doc.resolve(lastCellPos)\n const selection = new CellSelection($firstCellPos, $lastCellPos)\n tr = tr.setSelection(selection)\n dispatch?.(tr)\n }\n return true\n }\n}\n","import type { Command } from '@prosekit/pm/state'\nimport { CellSelection } from 'prosemirror-tables'\n\nimport { findCellPos } from '../table-utils'\n\n/**\n * @public\n */\nexport interface SelectTableCellOptions {\n /**\n * A hit position of the table cell to select from. By default, the selection\n * anchor will be used.\n */\n pos?: number\n}\n\n/**\n * @public\n */\nexport function selectTableCell(options?: SelectTableCellOptions): Command {\n return (state, dispatch) => {\n const $cellPos = findCellPos(\n state.doc,\n options?.pos ?? state.selection.anchor,\n )\n if (!$cellPos) {\n return false\n }\n if (dispatch) {\n const selection = new CellSelection($cellPos)\n dispatch(state.tr.setSelection(selection))\n }\n return true\n }\n}\n","import type { Command } from '@prosekit/pm/state'\nimport { CellSelection } from 'prosemirror-tables'\n\nimport { findCellRange } from '../table-utils'\n\n/**\n * @public\n */\nexport interface SelectTableColumnOptions {\n /**\n * A hit position of the table cell to select from. By default, the selection\n * anchor will be used.\n */\n anchor?: number\n\n /**\n * A hit position of the table cell to select to. By default, the selection\n * head will be used.\n */\n head?: number\n}\n\n/**\n * @public\n */\nexport function selectTableColumn(options?: SelectTableColumnOptions): Command {\n return (state, dispatch) => {\n const range = findCellRange(state.selection, options?.anchor, options?.head)\n if (!range) {\n return false\n }\n if (dispatch) {\n const [$anchorCell, $headCell] = range\n const selection = CellSelection.colSelection($anchorCell, $headCell)\n dispatch(state.tr.setSelection(selection))\n }\n return true\n }\n}\n","import type { Command } from '@prosekit/pm/state'\nimport { CellSelection } from 'prosemirror-tables'\n\nimport { findCellRange } from '../table-utils'\n\n/**\n * @public\n */\nexport interface SelectTableRowOptions {\n /**\n * A hit position of the table cell to select from. By default, the selection\n * anchor will be used.\n */\n anchor?: number\n\n /**\n * A hit position of the table cell to select to. By default, the selection\n * head will be used.\n */\n head?: number\n}\n\n/**\n * @public\n */\nexport function selectTableRow(options?: SelectTableRowOptions): Command {\n return (state, dispatch) => {\n const range = findCellRange(state.selection, options?.anchor, options?.head)\n if (!range) {\n return false\n }\n if (dispatch) {\n const [$anchorCell, $headCell] = range\n const selection = CellSelection.rowSelection($anchorCell, $headCell)\n dispatch(state.tr.setSelection(selection))\n }\n return true\n }\n}\n","import { defineCommands, type Extension } from '@prosekit/core'\nimport {\n addColumnAfter,\n addColumnBefore,\n addRowAfter,\n addRowBefore,\n deleteColumn,\n deleteRow,\n deleteTable,\n mergeCells,\n splitCell,\n} from 'prosemirror-tables'\n\nimport { deleteCellSelection } from './table-commands/delete-cell-selection'\nimport { exitTable } from './table-commands/exit-table'\nimport { insertTable, type InsertTableOptions } from './table-commands/insert-table'\nimport { moveTableColumn, type MoveTableColumnOptions } from './table-commands/move-table-column'\nimport { moveTableRow, type MoveTableRowOptions } from './table-commands/move-table-row'\nimport { selectTable, type SelectTableOptions } from './table-commands/select-table'\nimport { selectTableCell, type SelectTableCellOptions } from './table-commands/select-table-cell'\nimport { selectTableColumn, type SelectTableColumnOptions } from './table-commands/select-table-column'\nimport { selectTableRow, type SelectTableRowOptions } from './table-commands/select-table-row'\n\n/**\n * @internal\n */\nexport type TableCommandsExtension = Extension<{\n Commands: {\n insertTable: [options: InsertTableOptions]\n exitTable: []\n\n selectTable: [options?: SelectTableOptions]\n selectTableCell: [options?: SelectTableCellOptions]\n selectTableColumn: [options?: SelectTableColumnOptions]\n selectTableRow: [options?: SelectTableRowOptions]\n\n addTableColumnBefore: []\n addTableColumnAfter: []\n addTableRowAbove: []\n addTableRowBelow: []\n\n deleteTable: []\n deleteTableColumn: []\n deleteTableRow: []\n deleteCellSelection: []\n\n mergeTableCells: []\n splitTableCell: []\n\n moveTableRow: [options: MoveTableRowOptions]\n moveTableColumn: [options: MoveTableColumnOptions]\n }\n}>\n\n/**\n * Adds commands for working with `table` nodes.\n *\n * @public\n */\nexport function defineTableCommands(): TableCommandsExtension {\n return defineCommands({\n insertTable,\n exitTable: () => exitTable,\n\n selectTable,\n selectTableCell,\n selectTableColumn,\n selectTableRow,\n\n addTableColumnBefore: () => addColumnBefore,\n addTableColumnAfter: () => addColumnAfter,\n addTableRowAbove: () => addRowBefore,\n addTableRowBelow: () => addRowAfter,\n\n deleteTable: () => deleteTable,\n deleteTableColumn: () => deleteColumn,\n deleteTableRow: () => deleteRow,\n deleteCellSelection: () => deleteCellSelection,\n\n mergeTableCells: () => mergeCells,\n splitTableCell: () => splitCell,\n\n moveTableRow,\n moveTableColumn,\n })\n}\n","import type { PlainExtension } from '@prosekit/core'\n\nimport type { DragEventHandler } from '../drop-indicator'\nimport { defineDropIndicator } from '../drop-indicator'\n\n/**\n * Hides the drop indicator when dragging a table column or row by using the\n * table handle.\n *\n * @internal\n */\nexport function defineTableDropIndicator(): PlainExtension {\n return defineDropIndicator({\n onDrag,\n })\n}\n\nconst matchMap = new WeakMap<DataTransfer, boolean>()\n\nconst onDrag: DragEventHandler = ({ event }): boolean => {\n const dataTransfer = event.dataTransfer\n if (!dataTransfer) return true\n\n let match: boolean\n\n if (matchMap.has(dataTransfer)) {\n match = matchMap.get(dataTransfer)!\n } else {\n // On Safari, accessing `dataTransfer.types` is more than 10x slower than in\n // Chrome. This becomes a bottleneck when `onDrag` is called frequently, so\n // we cache the result in a WeakMap.\n const types = dataTransfer.types\n match = types.includes('application/x-prosekit-table-handle-drag')\n matchMap.set(dataTransfer, match)\n }\n\n // Don't show the drop indicator when the drag event has\n // \"application/x-prosekit-table-handle-drag\" type.\n return !match\n}\n","import { definePlugin, type PlainExtension } from '@prosekit/core'\nimport { columnResizing, tableEditing } from 'prosemirror-tables'\n\n/**\n * @public\n */\nexport function defineTablePlugins(): PlainExtension {\n return definePlugin([tableEditing(), columnResizing()])\n}\n","import { defineNodeSpec, type Extension } from '@prosekit/core'\nimport type { AttributeSpec, Attrs } from '@prosekit/pm/model'\nimport { tableNodes } from 'prosemirror-tables'\n\nconst cellContent = 'block+'\n\n/**\n * @public\n */\nexport interface CellAttrs {\n colspan?: number\n rowspan?: number\n colwidth?: number[] | null\n}\n\nconst cellAttrs = {\n colspan: { default: 1 },\n rowspan: { default: 1 },\n colwidth: { default: null },\n} satisfies Record<string, AttributeSpec>\n\n/**\n * @internal\n */\nexport type TableSpecExtension = Extension<{\n Nodes: {\n table: Attrs\n }\n}>\n\nconst specs = tableNodes({\n tableGroup: 'block',\n cellContent,\n cellAttributes: {},\n})\n\n/**\n * @internal\n */\nexport function defineTableSpec(): TableSpecExtension {\n return defineNodeSpec({\n ...specs['table'],\n content: 'tableRow+',\n name: 'table',\n })\n}\n\n/**\n * @internal\n */\nexport type TableRowSpecExtension = Extension<{\n Nodes: {\n tableRow: Attrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineTableRowSpec(): TableRowSpecExtension {\n return defineNodeSpec({\n ...specs['table_row'],\n content: '(tableCell | tableHeaderCell)*',\n name: 'tableRow',\n })\n}\n\n/**\n * @internal\n */\nexport type TableCellSpecExtension = Extension<{\n Nodes: {\n tableCell: CellAttrs\n }\n}>\n\n/**\n * @internal\n */\nexport function defineTableCellSpec(): TableCellSpecExtension {\n return defineNodeSpec({\n ...specs['table_cell'],\n name: 'tableCell',\n attrs: cellAttrs,\n })\n}\n\n/**\n * @internal\n */\nexport type TableHeaderCellSpecExtension = Extension<{\n Nodes: {\n tableHeaderCell: CellAttrs\n }\n}>\n\nexport function defineTableHeaderCellSpec(): TableHeaderCellSpecExtension {\n return defineNodeSpec({\n ...specs['table_header'],\n name: 'tableHeaderCell',\n attrs: cellAttrs,\n })\n}\n","import { union, type Union } from '@prosekit/core'\n\nimport { defineTableCommands, type TableCommandsExtension } from './table-commands'\nimport { defineTableDropIndicator } from './table-drop-indicator'\nimport { defineTablePlugins } from './table-plugins'\nimport {\n defineTableCellSpec,\n defineTableHeaderCellSpec,\n defineTableRowSpec,\n defineTableSpec,\n type TableCellSpecExtension,\n type TableHeaderCellSpecExtension,\n type TableRowSpecExtension,\n type TableSpecExtension,\n} from './table-spec'\n\n/**\n * @internal\n */\nexport type TableExtension = Union<\n [\n TableSpecExtension,\n TableRowSpecExtension,\n TableCellSpecExtension,\n TableHeaderCellSpecExtension,\n TableCommandsExtension,\n ]\n>\n\n/**\n * @public\n */\nexport function defineTable(): TableExtension {\n return union(\n defineTableSpec(),\n defineTableRowSpec(),\n defineTableCellSpec(),\n defineTableHeaderCellSpec(),\n defineTablePlugins(),\n defineTableCommands(),\n defineTableDropIndicator(),\n )\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,aAAsB,OAAO,aAAa;CACrD,MAAM,EAAE,OAAO,YAAY,MAAM;AAEjC,KAAI,CAAC,MAAM,WAAW,QAAQ,CAC5B,QAAO;CAGT,IAAI,aAAa;CACjB,IAAI,aAAa;AACjB,MAAK,IAAI,QAAQ,MAAM,OAAO,SAAS,GAAG,QAExC,KADa,MAAM,KAAK,MAAM,CACpB,KAAK,KAAK,cAA4B,SAAS;AACvD,eAAa,MAAM,OAAO,MAAM;AAChC,eAAa;;AAIjB,KAAI,aAAa,KAAK,cAAc,EAClC,QAAO;CAGT,MAAM,QAAQ,MAAM,K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AAc;AAWpB,MAAM,YAAY;CAChB,SAAS,EAAE,SAAS,GAAG;CACvB,SAAS,EAAE,SAAS,GAAG;CACvB,UAAU,EAAE,SAAS,MAAM;CAC5B;AAWD,MAAM,QAAQ,WAAW;CACvB,YAAY;CACZ;CACA,gBAAgB,EAAE;CACnB,CAAC;;;;AAKF,SAAgB,kBAAsC;AACpD,QAAO,eAAe;EACpB,GAAG,MAAM;EACT,SAAS;EACT,MAAM;EACP,CAAC;;;;;AAeJ,SAAgB,qBAA4C;AAC1D,QAAO,eAAe;EACpB,GAAG,MAAM;EACT,SAAS;EACT,MAAM;EACP,CAAC;;;;;AAeJ,SAAgB,sBAA8C;AAC5D,QAAO,eAAe;EACpB,GAAG,MAAM;EACT,MAAM;EACN,OAAO;EACR,CAAC;;AAYJ,SAAgB,4BAA0D;AACxE,QAAO,eAAe;EACpB,GAAG,MAAM;EACT,MAAM;EACN,OAAO;EACR,CAAC;;;;;;;;ACrEJ,SAAgB,cAA8B;AAC5C,QAAO,MACL,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,CAC3B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/extensions",
3
3
  "type": "module",
4
- "version": "0.14.0",
4
+ "version": "0.14.1",
5
5
  "private": false,
6
6
  "description": "A collection of common extensions for ProseKit",
7
7
  "author": {
@@ -134,6 +134,10 @@
134
134
  "types": "./dist/prosekit-extensions-mark-rule.d.ts",
135
135
  "default": "./dist/prosekit-extensions-mark-rule.js"
136
136
  },
137
+ "./math": {
138
+ "types": "./dist/prosekit-extensions-math.d.ts",
139
+ "default": "./dist/prosekit-extensions-math.js"
140
+ },
137
141
  "./mention": {
138
142
  "types": "./dist/prosekit-extensions-mention.d.ts",
139
143
  "default": "./dist/prosekit-extensions-mention.js"
@@ -215,18 +219,20 @@
215
219
  "src"
216
220
  ],
217
221
  "dependencies": {
218
- "@ocavue/utils": "^1.4.0",
219
- "prosemirror-changeset": "^2.3.1",
222
+ "@ocavue/utils": "^1.5.0",
223
+ "prosemirror-changeset": "^2.4.0",
220
224
  "prosemirror-drop-indicator": "^0.1.3",
221
225
  "prosemirror-dropcursor": "^1.8.2",
222
226
  "prosemirror-flat-list": "^0.5.8",
223
227
  "prosemirror-gapcursor": "^1.4.0",
224
- "prosemirror-highlight": "^0.13.0",
228
+ "prosemirror-highlight": "^0.15.0",
225
229
  "prosemirror-search": "^1.1.0",
226
230
  "prosemirror-tables": "^1.8.5",
227
231
  "shiki": "^3.22.0",
228
232
  "@prosekit/core": "^0.10.0",
229
- "@prosekit/pm": "^0.1.15"
233
+ "@prosekit/pm": "^0.1.15",
234
+ "prosemirror-enter-rules": "^0.1.3",
235
+ "prosemirror-math": "^0.1.0"
230
236
  },
231
237
  "peerDependencies": {
232
238
  "loro-crdt": ">= 1.10.0",
@@ -251,7 +257,8 @@
251
257
  "devDependencies": {
252
258
  "diffable-html-snapshot": "^0.2.0",
253
259
  "just-pick": "^4.2.0",
254
- "loro-crdt": "^1.10.5",
260
+ "katex": "^0.16.28",
261
+ "loro-crdt": "^1.10.6",
255
262
  "loro-prosemirror": "^0.4.2",
256
263
  "rehype-parse": "^9.0.1",
257
264
  "rehype-remark": "^10.0.1",
@@ -259,8 +266,8 @@
259
266
  "remark-html": "^16.0.1",
260
267
  "remark-parse": "^11.0.0",
261
268
  "remark-stringify": "^11.0.0",
262
- "tsdown": "^0.20.1",
263
- "type-fest": "^5.4.3",
269
+ "tsdown": "^0.20.3",
270
+ "type-fest": "^5.4.4",
264
271
  "typescript": "~5.9.3",
265
272
  "unified": "^11.0.5",
266
273
  "vitest": "^4.0.18",
@@ -303,6 +310,7 @@
303
310
  "prosekit-extensions-loro": "./src/loro/index.ts",
304
311
  "loro/style": "./src/loro/style.css",
305
312
  "prosekit-extensions-mark-rule": "./src/mark-rule/index.ts",
313
+ "prosekit-extensions-math": "./src/math/index.ts",
306
314
  "prosekit-extensions-mention": "./src/mention/index.ts",
307
315
  "prosekit-extensions-mod-click-prevention": "./src/mod-click-prevention/index.ts",
308
316
  "prosekit-extensions-paragraph": "./src/paragraph/index.ts",
@@ -404,6 +412,9 @@
404
412
  "mark-rule": [
405
413
  "./dist/prosekit-extensions-mark-rule.d.ts"
406
414
  ],
415
+ "math": [
416
+ "./dist/prosekit-extensions-math.d.ts"
417
+ ],
407
418
  "mention": [
408
419
  "./dist/prosekit-extensions-mention.d.ts"
409
420
  ],