@prosekit/extensions 0.2.5 → 0.3.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/_tsup-dts-rollup.d.ts +24 -10
- package/dist/list/style.css +1 -1
- package/dist/prosekit-extensions-blockquote.d.ts +1 -0
- package/dist/prosekit-extensions-blockquote.js +12 -1
- package/dist/prosekit-extensions-code-block.js +0 -7
- package/dist/prosekit-extensions-link.js +4 -2
- package/dist/prosekit-extensions-placeholder.js +1 -9
- package/dist/prosekit-extensions-virtual-selection.d.ts +1 -0
- package/dist/prosekit-extensions-virtual-selection.js +59 -0
- package/dist/virtual-selection/style.css +6 -0
- package/package.json +17 -6
- package/src/index.ts +0 -1
@@ -15,7 +15,6 @@ import { Parser } from 'prosemirror-highlight';
|
|
15
15
|
import { Plugin as Plugin_2 } from '@prosekit/pm/state';
|
16
16
|
import { PluginKey } from '@prosekit/pm/state';
|
17
17
|
import { ProseMirrorNode } from '@prosekit/pm/model';
|
18
|
-
import type { Selection as Selection_2 } from '@prosekit/pm/state';
|
19
18
|
import { ToggleCollapsedOptions } from 'prosemirror-flat-list';
|
20
19
|
import { Transaction } from '@prosekit/pm/state';
|
21
20
|
import { UnwrapListOptions } from 'prosemirror-flat-list';
|
@@ -75,6 +74,12 @@ export declare function defineBlockquote(): Extension< {
|
|
75
74
|
NODES: "blockquote";
|
76
75
|
}>;
|
77
76
|
|
77
|
+
/**
|
78
|
+
* Wraps the text block in a blockquote when `>` is typed at the start of a new
|
79
|
+
* line followed by a space.
|
80
|
+
*/
|
81
|
+
export declare function defineBlockquoteInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
82
|
+
|
78
83
|
export declare function defineBlockquoteSpec(): Extension< {
|
79
84
|
NODES: "blockquote";
|
80
85
|
}>;
|
@@ -129,7 +134,6 @@ setCodeBlock: [attrs?: CodeBlockAttrs | undefined];
|
|
129
134
|
insertCodeBlock: [attrs?: CodeBlockAttrs | undefined];
|
130
135
|
toggleCodeBlock: [attrs?: CodeBlockAttrs | undefined];
|
131
136
|
setCodeBlockAttrs: [attrs: CodeBlockAttrs];
|
132
|
-
setCodeBlockLanguage: [language: string];
|
133
137
|
};
|
134
138
|
}>;
|
135
139
|
|
@@ -144,7 +148,6 @@ setCodeBlock: [attrs?: CodeBlockAttrs | undefined];
|
|
144
148
|
insertCodeBlock: [attrs?: CodeBlockAttrs | undefined];
|
145
149
|
toggleCodeBlock: [attrs?: CodeBlockAttrs | undefined];
|
146
150
|
setCodeBlockAttrs: [attrs: CodeBlockAttrs];
|
147
|
-
setCodeBlockLanguage: [language: string];
|
148
151
|
};
|
149
152
|
}>;
|
150
153
|
export { defineCodeBlockCommands }
|
@@ -265,6 +268,10 @@ toggleHeading: [attrs?: HeadingAttrs | undefined];
|
|
265
268
|
};
|
266
269
|
}>;
|
267
270
|
|
271
|
+
/**
|
272
|
+
* Converts the text block to a heading when `#` is typed at the start of a new
|
273
|
+
* line followed by a space.
|
274
|
+
*/
|
268
275
|
export declare function defineHeadingInputRule(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
269
276
|
|
270
277
|
export declare function defineHeadingKeymap(): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
@@ -335,6 +342,7 @@ COMMAND_ARGS: {
|
|
335
342
|
addLink: [attrs: LinkAttrs];
|
336
343
|
removeLink: [];
|
337
344
|
toggleLink: [attrs: LinkAttrs];
|
345
|
+
expandLink: [];
|
338
346
|
};
|
339
347
|
}>;
|
340
348
|
|
@@ -343,6 +351,7 @@ COMMAND_ARGS: {
|
|
343
351
|
addLink: [attrs: LinkAttrs];
|
344
352
|
removeLink: [];
|
345
353
|
toggleLink: [attrs: LinkAttrs];
|
354
|
+
expandLink: [];
|
346
355
|
};
|
347
356
|
}>;
|
348
357
|
|
@@ -508,6 +517,18 @@ export declare function defineUnderlineSpec(): Extension< {
|
|
508
517
|
MARKS: "underline";
|
509
518
|
}>;
|
510
519
|
|
520
|
+
/**
|
521
|
+
* Shows a virtual selection when the editor is not focused. When the editor is
|
522
|
+
* not focused, the selected inline content will be wrapped in a `<span>`
|
523
|
+
* element with the class `prosekit-virtual-selection`.
|
524
|
+
*
|
525
|
+
* This is useful when you want to move the focus to an element outside the
|
526
|
+
* editor, but still want to show the selection.
|
527
|
+
*
|
528
|
+
* @public
|
529
|
+
*/
|
530
|
+
export declare function defineVirtualSelection(): Extension;
|
531
|
+
|
511
532
|
/**
|
512
533
|
* Defines an input rule for automatically wrapping a textblock when a given
|
513
534
|
* string is typed.
|
@@ -607,13 +628,6 @@ export declare interface ImageAttrs {
|
|
607
628
|
src?: string | null;
|
608
629
|
}
|
609
630
|
|
610
|
-
/**
|
611
|
-
* @internal
|
612
|
-
*
|
613
|
-
* @deprecated Use the one from `@prosekit/core` instead.
|
614
|
-
*/
|
615
|
-
export declare function isInCodeBlock(selection: Selection_2): boolean | undefined;
|
616
|
-
|
617
631
|
/**
|
618
632
|
* @public
|
619
633
|
*/
|
package/dist/list/style.css
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* ../../node_modules/.pnpm/prosemirror-flat-list@0.4.
|
1
|
+
/* ../../node_modules/.pnpm/prosemirror-flat-list@0.4.6/node_modules/prosemirror-flat-list/dist/style.css */
|
2
2
|
.prosemirror-flat-list {
|
3
3
|
padding: 0;
|
4
4
|
margin-top: 0;
|
@@ -1,3 +1,7 @@
|
|
1
|
+
import {
|
2
|
+
defineWrappingInputRule
|
3
|
+
} from "./chunk-DYFRBXUX.js";
|
4
|
+
|
1
5
|
// src/blockquote/index.ts
|
2
6
|
import { defineNodeSpec, union } from "@prosekit/core";
|
3
7
|
function defineBlockquoteSpec() {
|
@@ -12,10 +16,17 @@ function defineBlockquoteSpec() {
|
|
12
16
|
}
|
13
17
|
});
|
14
18
|
}
|
19
|
+
function defineBlockquoteInputRule() {
|
20
|
+
return defineWrappingInputRule({
|
21
|
+
regex: /^>\s/,
|
22
|
+
type: "blockquote"
|
23
|
+
});
|
24
|
+
}
|
15
25
|
function defineBlockquote() {
|
16
|
-
return union([defineBlockquoteSpec()]);
|
26
|
+
return union([defineBlockquoteSpec(), defineBlockquoteInputRule()]);
|
17
27
|
}
|
18
28
|
export {
|
19
29
|
defineBlockquote,
|
30
|
+
defineBlockquoteInputRule,
|
20
31
|
defineBlockquoteSpec
|
21
32
|
};
|
@@ -26,13 +26,6 @@ function defineCodeBlockCommands() {
|
|
26
26
|
},
|
27
27
|
setCodeBlockAttrs: (attrs) => {
|
28
28
|
return setNodeAttrs({ type: "codeBlock", attrs });
|
29
|
-
},
|
30
|
-
/**
|
31
|
-
* @deprecated Use `setCodeBlockAttrs` instead.
|
32
|
-
*/
|
33
|
-
setCodeBlockLanguage: (language) => {
|
34
|
-
const attrs = { language };
|
35
|
-
return setNodeAttrs({ type: "codeBlock", attrs });
|
36
29
|
}
|
37
30
|
});
|
38
31
|
}
|
@@ -5,7 +5,8 @@ import {
|
|
5
5
|
defineMarkSpec,
|
6
6
|
union,
|
7
7
|
removeMark,
|
8
|
-
toggleMark
|
8
|
+
toggleMark,
|
9
|
+
expandMark
|
9
10
|
} from "@prosekit/core";
|
10
11
|
function defineLinkSpec() {
|
11
12
|
return defineMarkSpec({
|
@@ -33,7 +34,8 @@ function defineLinkCommands() {
|
|
33
34
|
return defineCommands({
|
34
35
|
addLink: (attrs) => addMark({ type: "link", attrs }),
|
35
36
|
removeLink: () => removeMark({ type: "link" }),
|
36
|
-
toggleLink: (attrs) => toggleMark({ type: "link", attrs })
|
37
|
+
toggleLink: (attrs) => toggleMark({ type: "link", attrs }),
|
38
|
+
expandLink: () => expandMark({ type: "link" })
|
37
39
|
});
|
38
40
|
}
|
39
41
|
function defineLink() {
|
@@ -1,16 +1,8 @@
|
|
1
1
|
// src/placeholder/index.ts
|
2
|
-
import { definePlugin } from "@prosekit/core";
|
2
|
+
import { definePlugin, isInCodeBlock } from "@prosekit/core";
|
3
3
|
import "@prosekit/pm/model";
|
4
4
|
import { Plugin, PluginKey } from "@prosekit/pm/state";
|
5
5
|
import { Decoration, DecorationSet } from "@prosekit/pm/view";
|
6
|
-
|
7
|
-
// src/utils/is-in-code-block.ts
|
8
|
-
function isInCodeBlock(selection) {
|
9
|
-
const type = selection.$from.parent.type;
|
10
|
-
return type.spec.code && type.isBlock;
|
11
|
-
}
|
12
|
-
|
13
|
-
// src/placeholder/index.ts
|
14
6
|
function definePlaceholder(options) {
|
15
7
|
return definePlugin(createPlaceholderPlugin(options));
|
16
8
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { defineVirtualSelection } from './_tsup-dts-rollup';
|
@@ -0,0 +1,59 @@
|
|
1
|
+
// src/virtual-selection/index.ts
|
2
|
+
import { definePlugin } from "@prosekit/core";
|
3
|
+
import {
|
4
|
+
PluginKey,
|
5
|
+
ProseMirrorPlugin
|
6
|
+
} from "@prosekit/pm/state";
|
7
|
+
import { Decoration, DecorationSet } from "@prosekit/pm/view";
|
8
|
+
function defineVirtualSelection() {
|
9
|
+
return definePlugin(virtualSelectionPlugin);
|
10
|
+
}
|
11
|
+
var key = new PluginKey("prosekit-virtual-selection");
|
12
|
+
function getFocusMeta(tr) {
|
13
|
+
return tr.getMeta(key);
|
14
|
+
}
|
15
|
+
function setFocusMeta(tr, value) {
|
16
|
+
return tr.setMeta(key, value);
|
17
|
+
}
|
18
|
+
function getFocusState(state) {
|
19
|
+
return key.getState(state);
|
20
|
+
}
|
21
|
+
var virtualSelectionPlugin = new ProseMirrorPlugin({
|
22
|
+
key,
|
23
|
+
state: {
|
24
|
+
init: () => false,
|
25
|
+
apply: (tr, value) => {
|
26
|
+
var _a;
|
27
|
+
return (_a = getFocusMeta(tr)) != null ? _a : value;
|
28
|
+
}
|
29
|
+
},
|
30
|
+
props: {
|
31
|
+
handleDOMEvents: {
|
32
|
+
focus: (view) => {
|
33
|
+
view.dispatch(setFocusMeta(view.state.tr, false));
|
34
|
+
},
|
35
|
+
blur: (view) => {
|
36
|
+
var _a;
|
37
|
+
const dom = view.dom;
|
38
|
+
const activeElement = (_a = dom == null ? void 0 : dom.ownerDocument) == null ? void 0 : _a.activeElement;
|
39
|
+
if (activeElement === dom)
|
40
|
+
return;
|
41
|
+
view.dispatch(setFocusMeta(view.state.tr, true));
|
42
|
+
}
|
43
|
+
},
|
44
|
+
decorations: (state) => {
|
45
|
+
const { selection, doc } = state;
|
46
|
+
if (selection.empty || !getFocusState(state)) {
|
47
|
+
return null;
|
48
|
+
}
|
49
|
+
return DecorationSet.create(doc, [
|
50
|
+
Decoration.inline(selection.from, selection.to, {
|
51
|
+
class: "prosekit-virtual-selection"
|
52
|
+
})
|
53
|
+
]);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
});
|
57
|
+
export {
|
58
|
+
defineVirtualSelection
|
59
|
+
};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/extensions",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.3.0",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -120,17 +120,25 @@
|
|
120
120
|
"types": "./dist/prosekit-extensions-underline.d.ts",
|
121
121
|
"import": "./dist/prosekit-extensions-underline.js",
|
122
122
|
"default": "./dist/prosekit-extensions-underline.js"
|
123
|
+
},
|
124
|
+
"./virtual-selection": {
|
125
|
+
"types": "./dist/prosekit-extensions-virtual-selection.d.ts",
|
126
|
+
"import": "./dist/prosekit-extensions-virtual-selection.js",
|
127
|
+
"default": "./dist/prosekit-extensions-virtual-selection.js"
|
128
|
+
},
|
129
|
+
"./virtual-selection/style.css": {
|
130
|
+
"default": "./dist/virtual-selection/style.css"
|
123
131
|
}
|
124
132
|
},
|
125
133
|
"files": [
|
126
134
|
"dist"
|
127
135
|
],
|
128
136
|
"dependencies": {
|
129
|
-
"@prosekit/core": "^0.
|
137
|
+
"@prosekit/core": "^0.3.0",
|
130
138
|
"@prosekit/pm": "^0.1.1",
|
131
139
|
"prosemirror-dropcursor": "^1.8.1",
|
132
|
-
"prosemirror-flat-list": "^0.4.
|
133
|
-
"prosemirror-highlight": "^0.4.
|
140
|
+
"prosemirror-flat-list": "^0.4.6",
|
141
|
+
"prosemirror-highlight": "^0.4.1"
|
134
142
|
},
|
135
143
|
"peerDependencies": {
|
136
144
|
"shikiji": ">= 0.9.0"
|
@@ -142,10 +150,10 @@
|
|
142
150
|
},
|
143
151
|
"devDependencies": {
|
144
152
|
"@prosekit/dev": "*",
|
145
|
-
"shikiji": "^0.
|
153
|
+
"shikiji": "^0.10.2",
|
146
154
|
"tsup": "^8.0.1",
|
147
155
|
"typescript": "^5.3.3",
|
148
|
-
"vitest": "^1.2.
|
156
|
+
"vitest": "^1.2.2"
|
149
157
|
},
|
150
158
|
"scripts": {
|
151
159
|
"build:tsup": "tsup",
|
@@ -207,6 +215,9 @@
|
|
207
215
|
],
|
208
216
|
"underline": [
|
209
217
|
"./dist/prosekit-extensions-underline.d.ts"
|
218
|
+
],
|
219
|
+
"virtual-selection": [
|
220
|
+
"./dist/prosekit-extensions-virtual-selection.d.ts"
|
210
221
|
]
|
211
222
|
}
|
212
223
|
}
|
package/src/index.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {}
|