@prosekit/extensions 0.0.0-next-20231120040948 → 0.0.0-next-20240421132240

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 (37) hide show
  1. package/dist/_tsup-dts-rollup.d.ts +521 -91
  2. package/dist/chunk-ASTUC4KT.js +111 -0
  3. package/dist/chunk-DYFRBXUX.js +56 -0
  4. package/dist/list/style.css +17 -12
  5. package/dist/prosekit-extensions-autocomplete.js +8 -4
  6. package/dist/prosekit-extensions-blockquote.d.ts +1 -0
  7. package/dist/prosekit-extensions-blockquote.js +12 -1
  8. package/dist/prosekit-extensions-code-block.d.ts +14 -4
  9. package/dist/prosekit-extensions-code-block.js +171 -75
  10. package/dist/prosekit-extensions-drop-cursor.d.ts +2 -0
  11. package/dist/prosekit-extensions-drop-cursor.js +9 -0
  12. package/dist/prosekit-extensions-enter-rule.d.ts +5 -0
  13. package/dist/prosekit-extensions-enter-rule.js +8 -0
  14. package/dist/prosekit-extensions-heading.js +20 -14
  15. package/dist/prosekit-extensions-image.js +1 -0
  16. package/dist/prosekit-extensions-input-rule.d.ts +3 -0
  17. package/dist/prosekit-extensions-input-rule.js +10 -0
  18. package/dist/prosekit-extensions-link.d.ts +2 -0
  19. package/dist/prosekit-extensions-link.js +63 -5
  20. package/dist/prosekit-extensions-list.d.ts +1 -0
  21. package/dist/prosekit-extensions-list.js +7 -2
  22. package/dist/prosekit-extensions-mention.d.ts +1 -0
  23. package/dist/prosekit-extensions-mention.js +15 -2
  24. package/dist/prosekit-extensions-placeholder.js +4 -1
  25. package/dist/prosekit-extensions-readonly.d.ts +1 -0
  26. package/dist/prosekit-extensions-readonly.js +16 -0
  27. package/dist/prosekit-extensions-table.d.ts +7 -0
  28. package/dist/prosekit-extensions-table.js +197 -0
  29. package/dist/prosekit-extensions-virtual-selection.d.ts +1 -0
  30. package/dist/prosekit-extensions-virtual-selection.js +58 -0
  31. package/dist/shiki-import-25BJYIO2.js +5 -0
  32. package/dist/table/style.css +34 -0
  33. package/dist/virtual-selection/style.css +6 -0
  34. package/package.json +63 -15
  35. package/dist/prosekit-extensions-suggestion.d.ts +0 -3
  36. package/dist/prosekit-extensions-suggestion.js +0 -161
  37. package/src/index.ts +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/extensions",
3
3
  "type": "module",
4
- "version": "0.0.0-next-20231120040948",
4
+ "version": "0.0.0-next-20240421132240",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -55,6 +55,16 @@
55
55
  "import": "./dist/prosekit-extensions-code-block.js",
56
56
  "default": "./dist/prosekit-extensions-code-block.js"
57
57
  },
58
+ "./drop-cursor": {
59
+ "types": "./dist/prosekit-extensions-drop-cursor.d.ts",
60
+ "import": "./dist/prosekit-extensions-drop-cursor.js",
61
+ "default": "./dist/prosekit-extensions-drop-cursor.js"
62
+ },
63
+ "./enter-rule": {
64
+ "types": "./dist/prosekit-extensions-enter-rule.d.ts",
65
+ "import": "./dist/prosekit-extensions-enter-rule.js",
66
+ "default": "./dist/prosekit-extensions-enter-rule.js"
67
+ },
58
68
  "./heading": {
59
69
  "types": "./dist/prosekit-extensions-heading.d.ts",
60
70
  "import": "./dist/prosekit-extensions-heading.js",
@@ -65,6 +75,11 @@
65
75
  "import": "./dist/prosekit-extensions-image.js",
66
76
  "default": "./dist/prosekit-extensions-image.js"
67
77
  },
78
+ "./input-rule": {
79
+ "types": "./dist/prosekit-extensions-input-rule.d.ts",
80
+ "import": "./dist/prosekit-extensions-input-rule.js",
81
+ "default": "./dist/prosekit-extensions-input-rule.js"
82
+ },
68
83
  "./italic": {
69
84
  "types": "./dist/prosekit-extensions-italic.d.ts",
70
85
  "import": "./dist/prosekit-extensions-italic.js",
@@ -96,37 +111,55 @@
96
111
  "./placeholder/style.css": {
97
112
  "default": "./dist/placeholder/style.css"
98
113
  },
114
+ "./readonly": {
115
+ "types": "./dist/prosekit-extensions-readonly.d.ts",
116
+ "import": "./dist/prosekit-extensions-readonly.js",
117
+ "default": "./dist/prosekit-extensions-readonly.js"
118
+ },
99
119
  "./strike": {
100
120
  "types": "./dist/prosekit-extensions-strike.d.ts",
101
121
  "import": "./dist/prosekit-extensions-strike.js",
102
122
  "default": "./dist/prosekit-extensions-strike.js"
103
123
  },
104
- "./suggestion": {
105
- "types": "./dist/prosekit-extensions-suggestion.d.ts",
106
- "import": "./dist/prosekit-extensions-suggestion.js",
107
- "default": "./dist/prosekit-extensions-suggestion.js"
124
+ "./table": {
125
+ "types": "./dist/prosekit-extensions-table.d.ts",
126
+ "import": "./dist/prosekit-extensions-table.js",
127
+ "default": "./dist/prosekit-extensions-table.js"
128
+ },
129
+ "./table/style.css": {
130
+ "default": "./dist/table/style.css"
108
131
  },
109
132
  "./underline": {
110
133
  "types": "./dist/prosekit-extensions-underline.d.ts",
111
134
  "import": "./dist/prosekit-extensions-underline.js",
112
135
  "default": "./dist/prosekit-extensions-underline.js"
136
+ },
137
+ "./virtual-selection": {
138
+ "types": "./dist/prosekit-extensions-virtual-selection.d.ts",
139
+ "import": "./dist/prosekit-extensions-virtual-selection.js",
140
+ "default": "./dist/prosekit-extensions-virtual-selection.js"
141
+ },
142
+ "./virtual-selection/style.css": {
143
+ "default": "./dist/virtual-selection/style.css"
113
144
  }
114
145
  },
115
146
  "files": [
116
147
  "dist"
117
148
  ],
118
149
  "dependencies": {
119
- "@prosekit/core": "0.0.0-next-20231120040948",
120
- "@prosekit/pm": "0.0.0-next-20231120040948",
121
- "highlight.js": "^11.9.0",
122
- "prosemirror-flat-list": "^0.4.3",
123
- "prosemirror-highlightjs": "^0.9.1"
150
+ "@prosekit/core": "0.0.0-next-20240421132240",
151
+ "@prosekit/pm": "0.0.0-next-20240421132240",
152
+ "prosemirror-dropcursor": "^1.8.1",
153
+ "prosemirror-flat-list": "^0.5.0",
154
+ "prosemirror-highlight": "^0.5.0",
155
+ "prosemirror-tables": "^1.3.7",
156
+ "shiki": "^1.3.0"
124
157
  },
125
158
  "devDependencies": {
126
159
  "@prosekit/dev": "*",
127
- "tsup": "^8.0.0",
128
- "typescript": "^5.2.2",
129
- "vitest": "^0.34.6"
160
+ "tsup": "^8.0.2",
161
+ "typescript": "^5.4.5",
162
+ "vitest": "^1.5.0"
130
163
  },
131
164
  "scripts": {
132
165
  "build:tsup": "tsup",
@@ -153,12 +186,21 @@
153
186
  "code-block": [
154
187
  "./dist/prosekit-extensions-code-block.d.ts"
155
188
  ],
189
+ "drop-cursor": [
190
+ "./dist/prosekit-extensions-drop-cursor.d.ts"
191
+ ],
192
+ "enter-rule": [
193
+ "./dist/prosekit-extensions-enter-rule.d.ts"
194
+ ],
156
195
  "heading": [
157
196
  "./dist/prosekit-extensions-heading.d.ts"
158
197
  ],
159
198
  "image": [
160
199
  "./dist/prosekit-extensions-image.d.ts"
161
200
  ],
201
+ "input-rule": [
202
+ "./dist/prosekit-extensions-input-rule.d.ts"
203
+ ],
162
204
  "italic": [
163
205
  "./dist/prosekit-extensions-italic.d.ts"
164
206
  ],
@@ -174,14 +216,20 @@
174
216
  "placeholder": [
175
217
  "./dist/prosekit-extensions-placeholder.d.ts"
176
218
  ],
219
+ "readonly": [
220
+ "./dist/prosekit-extensions-readonly.d.ts"
221
+ ],
177
222
  "strike": [
178
223
  "./dist/prosekit-extensions-strike.d.ts"
179
224
  ],
180
- "suggestion": [
181
- "./dist/prosekit-extensions-suggestion.d.ts"
225
+ "table": [
226
+ "./dist/prosekit-extensions-table.d.ts"
182
227
  ],
183
228
  "underline": [
184
229
  "./dist/prosekit-extensions-underline.d.ts"
230
+ ],
231
+ "virtual-selection": [
232
+ "./dist/prosekit-extensions-virtual-selection.d.ts"
185
233
  ]
186
234
  }
187
235
  }
@@ -1,3 +0,0 @@
1
- export { defineSuggestion } from './_tsup-dts-rollup';
2
- export { PredictionRule } from './_tsup-dts-rollup';
3
- export { SuggestionOptions } from './_tsup-dts-rollup';
@@ -1,161 +0,0 @@
1
- // src/suggestion/index.ts
2
- import { definePlugin } from "@prosekit/core";
3
-
4
- // src/suggestion/plugin.ts
5
- import { ProseKitError } from "@prosekit/core";
6
- import { Plugin, PluginKey } from "@prosekit/pm/state";
7
- import { Decoration, DecorationSet } from "@prosekit/pm/view";
8
-
9
- // src/suggestion/is-valid.ts
10
- import "@prosekit/pm/model";
11
- import "@prosekit/pm/state";
12
- function defaultIsValid({ state }) {
13
- return state.selection.empty && !isInsideCode(state.selection.$from);
14
- }
15
- function isInsideCode($pos) {
16
- for (let d = $pos.depth; d > 0; d--) {
17
- if ($pos.node(d).type.spec.code) {
18
- return true;
19
- }
20
- }
21
- return $pos.marks().some((mark) => mark.type.name === "code");
22
- }
23
-
24
- // src/suggestion/plugin.ts
25
- var pluginKey = new PluginKey("prosemirror-prediction");
26
- function getPluginState(state) {
27
- return pluginKey.getState(state);
28
- }
29
- function getTrMeta(tr) {
30
- return tr.getMeta(pluginKey);
31
- }
32
- function setTrMeta(tr, meta) {
33
- return tr.setMeta(pluginKey, meta);
34
- }
35
- function createPredictionPlugin(options) {
36
- if (options.rules.length === 0) {
37
- throw new ProseKitError(
38
- "You can't create a prediction plugin without rules"
39
- );
40
- }
41
- const { onMatch, onDeactivate, isValid = defaultIsValid } = options;
42
- return new Plugin({
43
- key: pluginKey,
44
- state: {
45
- init: () => {
46
- return { active: false, ignore: null, matching: null };
47
- },
48
- apply: (tr, prevValue, oldState, newState) => {
49
- var _a;
50
- const meta = getTrMeta(tr);
51
- if (!tr.docChanged && oldState.selection.eq(newState.selection) && !meta) {
52
- return prevValue;
53
- }
54
- if (meta) {
55
- return meta;
56
- }
57
- if (!isValid({ state: newState })) {
58
- return { active: false, ignore: null, matching: null };
59
- }
60
- const nextValue = calcPluginState(newState, options.rules);
61
- if (nextValue.active && prevValue.ignore != null && ((_a = nextValue.matching) == null ? void 0 : _a.from) === prevValue.ignore) {
62
- return prevValue;
63
- }
64
- return nextValue;
65
- }
66
- },
67
- view: () => ({
68
- update: (view, prevState) => {
69
- const prevPluginState = getPluginState(prevState);
70
- const currPluginState = getPluginState(view.state);
71
- if ((currPluginState == null ? void 0 : currPluginState.active) && currPluginState.matching && currPluginState.matching.from !== currPluginState.ignore) {
72
- const { from, to } = currPluginState.matching;
73
- const dismiss = () => {
74
- view.dispatch(
75
- setTrMeta(view.state.tr, {
76
- active: false,
77
- ignore: from,
78
- matching: null
79
- })
80
- );
81
- };
82
- const textContent = view.state.doc.textBetween(from, to, "\uFFFC");
83
- const deleteMatch = () => {
84
- if (view.state.doc.textBetween(from, to, "\uFFFC") === textContent) {
85
- view.dispatch(view.state.tr.delete(from, to));
86
- }
87
- };
88
- onMatch({
89
- rule: currPluginState.matching.rule,
90
- match: currPluginState.matching.match,
91
- matchAfter: currPluginState.matching.matchAfter,
92
- state: view.state,
93
- dismiss,
94
- deleteMatch
95
- });
96
- } else if (prevPluginState == null ? void 0 : prevPluginState.active) {
97
- onDeactivate();
98
- }
99
- }
100
- }),
101
- props: {
102
- decorations: (state) => {
103
- const pluginState = getPluginState(state);
104
- if ((pluginState == null ? void 0 : pluginState.active) && pluginState.matching) {
105
- const { from, to } = pluginState.matching;
106
- const deco = Decoration.inline(from, to, {
107
- class: "prosemirror-prediction-match"
108
- });
109
- return DecorationSet.create(state.doc, [deco]);
110
- }
111
- return null;
112
- }
113
- }
114
- });
115
- }
116
- function calcPluginState(state, rules) {
117
- const { $anchor } = state.selection;
118
- const matchAfter = rules.some((rule) => rule.matchAfter);
119
- const parentOffset = $anchor.parentOffset;
120
- const textBefore = $anchor.parent.textBetween(
121
- Math.max(0, parentOffset - MAX_MATCH),
122
- parentOffset,
123
- null,
124
- "\uFFFC"
125
- );
126
- const textAfter = matchAfter ? $anchor.parent.textBetween(
127
- parentOffset,
128
- Math.min(parentOffset + MAX_MATCH, $anchor.parent.content.size),
129
- null
130
- ) : "";
131
- for (const rule of rules) {
132
- const match = textBefore.match(rule.match);
133
- const matchAfter2 = rule.matchAfter ? textAfter.match(rule.matchAfter) : null;
134
- if ((match == null ? void 0 : match.index) != null) {
135
- const from = $anchor.pos - textBefore.length + match.index;
136
- const to = $anchor.pos + (matchAfter2 ? matchAfter2[0].length : 0);
137
- return {
138
- active: true,
139
- ignore: null,
140
- matching: {
141
- rule,
142
- from,
143
- to,
144
- match,
145
- matchAfter: matchAfter2
146
- }
147
- };
148
- }
149
- }
150
- return { active: false };
151
- }
152
- var MAX_MATCH = 200;
153
-
154
- // src/suggestion/index.ts
155
- function defineSuggestion(options) {
156
- const plugin = createPredictionPlugin(options);
157
- return definePlugin(plugin);
158
- }
159
- export {
160
- defineSuggestion
161
- };
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export {}