@prosekit/extensions 0.2.2 → 0.2.4
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 +39 -11
- package/dist/prosekit-extensions-autocomplete.js +1 -4
- package/dist/prosekit-extensions-code-block.js +3 -17
- package/dist/prosekit-extensions-drop-cursor.d.ts +2 -0
- package/dist/prosekit-extensions-drop-cursor.js +9 -0
- package/dist/prosekit-extensions-heading.js +2 -16
- package/dist/prosekit-extensions-image.js +1 -0
- package/dist/prosekit-extensions-link.js +2 -0
- package/dist/prosekit-extensions-placeholder.js +8 -4
- package/package.json +13 -4
- package/dist/chunk-DI46QWLX.js +0 -9
- package/dist/chunk-HQZORKGY.js +0 -6
@@ -1,8 +1,6 @@
|
|
1
1
|
import { Attrs } from '@prosekit/pm/model';
|
2
2
|
import type { BundledTheme } from 'shikiji';
|
3
|
-
import type { Command } from '@prosekit/pm/state';
|
4
3
|
import { CommandArgs } from '@prosekit/core';
|
5
|
-
import type { ContentMatch } from '@prosekit/pm/model';
|
6
4
|
import { DedentListOptions } from 'prosemirror-flat-list';
|
7
5
|
import { EditorState } from '@prosekit/pm/state';
|
8
6
|
import { Extension } from '@prosekit/core';
|
@@ -12,7 +10,6 @@ import { InputRule } from '@prosekit/pm/inputrules';
|
|
12
10
|
import { ListAttributes } from 'prosemirror-flat-list';
|
13
11
|
import { NodeRange } from 'prosemirror-model';
|
14
12
|
import { NodeType } from '@prosekit/pm/model';
|
15
|
-
import { NodeType as NodeType_2 } from 'prosemirror-model';
|
16
13
|
import { Options } from 'tsup';
|
17
14
|
import { Parser } from 'prosemirror-highlight';
|
18
15
|
import { Plugin as Plugin_2 } from '@prosekit/pm/state';
|
@@ -65,8 +62,6 @@ export declare const default_alias_1: {
|
|
65
62
|
};
|
66
63
|
};
|
67
64
|
|
68
|
-
export declare function defaultBlockAt(match: ContentMatch): NodeType_2 | null;
|
69
|
-
|
70
65
|
export declare function defaultCanMatch({ state }: {
|
71
66
|
state: EditorState;
|
72
67
|
}): boolean;
|
@@ -224,6 +219,15 @@ export declare function defineCodeSpec(): Extension< {
|
|
224
219
|
MARKS: "code";
|
225
220
|
}>;
|
226
221
|
|
222
|
+
/**
|
223
|
+
* Show up a decoration at the drop position when something is dragged over the editor.
|
224
|
+
*
|
225
|
+
* See [prosemirror-dropcursor](https://github.com/ProseMirror/prosemirror-dropcursor) for more information.
|
226
|
+
*
|
227
|
+
* @public
|
228
|
+
*/
|
229
|
+
export declare function defineDropCursor(options?: DropCursorOptions): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
230
|
+
|
227
231
|
/**
|
228
232
|
* Defines an enter rule. An enter rule applies when the text directly in front of
|
229
233
|
* the cursor matches `regex` and user presses Enter. The `regex` should end
|
@@ -321,6 +325,7 @@ export declare function defineLink(): Extension< {
|
|
321
325
|
MARKS: "link";
|
322
326
|
COMMAND_ARGS: {
|
323
327
|
addLink: [attrs: LinkAttrs];
|
328
|
+
removeLink: [];
|
324
329
|
toggleLink: [attrs: LinkAttrs];
|
325
330
|
};
|
326
331
|
}>;
|
@@ -328,6 +333,7 @@ toggleLink: [attrs: LinkAttrs];
|
|
328
333
|
export declare function defineLinkCommands(): Extension< {
|
329
334
|
COMMAND_ARGS: {
|
330
335
|
addLink: [attrs: LinkAttrs];
|
336
|
+
removeLink: [];
|
331
337
|
toggleLink: [attrs: LinkAttrs];
|
332
338
|
};
|
333
339
|
}>;
|
@@ -453,6 +459,8 @@ export declare function defineTextBlockEnterRule({ regex, type, attrs, }: TextBl
|
|
453
459
|
* text is typed into it.
|
454
460
|
*
|
455
461
|
* See also [textblockTypeInputRule](https://prosemirror.net/docs/ref/#inputrules.textblockTypeInputRule)
|
462
|
+
*
|
463
|
+
* @public
|
456
464
|
*/
|
457
465
|
export declare function defineTextBlockInputRule({ regex, type, attrs, }: {
|
458
466
|
/**
|
@@ -497,6 +505,8 @@ MARKS: "underline";
|
|
497
505
|
* string is typed.
|
498
506
|
*
|
499
507
|
* See also [wrappingInputRule](https://prosemirror.net/docs/ref/#inputrules.wrappingInputRule)
|
508
|
+
*
|
509
|
+
* @public
|
500
510
|
*/
|
501
511
|
export declare function defineWrappingInputRule({ regex, type, attrs, join, }: {
|
502
512
|
/**
|
@@ -523,6 +533,25 @@ export declare function defineWrappingInputRule({ regex, type, attrs, join, }: {
|
|
523
533
|
join?: (match: RegExpMatchArray, node: ProseMirrorNode) => boolean;
|
524
534
|
}): Extension;
|
525
535
|
|
536
|
+
export declare interface DropCursorOptions {
|
537
|
+
/**
|
538
|
+
* The color of the cursor. Use `false` to apply no color and rely only on class.
|
539
|
+
*
|
540
|
+
* @default 'black'
|
541
|
+
*/
|
542
|
+
color?: string | false;
|
543
|
+
/**
|
544
|
+
* The precise width of the cursor in pixels.
|
545
|
+
*
|
546
|
+
* @default 1
|
547
|
+
*/
|
548
|
+
width?: number;
|
549
|
+
/**
|
550
|
+
* A CSS class name to add to the cursor element.
|
551
|
+
*/
|
552
|
+
class?: string;
|
553
|
+
}
|
554
|
+
|
526
555
|
/**
|
527
556
|
* @public
|
528
557
|
*/
|
@@ -570,6 +599,11 @@ export declare interface ImageAttrs {
|
|
570
599
|
src?: string | null;
|
571
600
|
}
|
572
601
|
|
602
|
+
/**
|
603
|
+
* @internal
|
604
|
+
*
|
605
|
+
* @deprecated Use the one from `@prosekit/core` instead.
|
606
|
+
*/
|
573
607
|
export declare function isInCodeBlock(selection: Selection_2): boolean | undefined;
|
574
608
|
|
575
609
|
/**
|
@@ -596,10 +630,6 @@ export declare interface MentionAttrs {
|
|
596
630
|
value: string;
|
597
631
|
}
|
598
632
|
|
599
|
-
export declare const NO_BREAK_SPACE = "\u00A0";
|
600
|
-
|
601
|
-
export declare const OBJECT_REPLACEMENT_CHARACTER = "\uFFFC";
|
602
|
-
|
603
633
|
export declare interface PlaceholderOptions {
|
604
634
|
/**
|
605
635
|
* The placeholder text to use.
|
@@ -650,6 +680,4 @@ export declare type TextBlockEnterRuleOptions = {
|
|
650
680
|
attrs?: Attrs | null | ((match: RegExpMatchArray) => Attrs | null);
|
651
681
|
};
|
652
682
|
|
653
|
-
export declare function withSkipCodeBlock(command: Command): Command;
|
654
|
-
|
655
683
|
export { }
|
@@ -1,7 +1,3 @@
|
|
1
|
-
import {
|
2
|
-
OBJECT_REPLACEMENT_CHARACTER
|
3
|
-
} from "./chunk-HQZORKGY.js";
|
4
|
-
|
5
1
|
// src/autocomplete/index.ts
|
6
2
|
import {
|
7
3
|
Facet,
|
@@ -9,6 +5,7 @@ import {
|
|
9
5
|
} from "@prosekit/core";
|
10
6
|
|
11
7
|
// src/autocomplete/plugin.ts
|
8
|
+
import { OBJECT_REPLACEMENT_CHARACTER } from "@prosekit/core";
|
12
9
|
import { Plugin } from "@prosekit/pm/state";
|
13
10
|
import { Decoration, DecorationSet } from "@prosekit/pm/view";
|
14
11
|
|
@@ -1,6 +1,3 @@
|
|
1
|
-
import {
|
2
|
-
OBJECT_REPLACEMENT_CHARACTER
|
3
|
-
} from "./chunk-HQZORKGY.js";
|
4
1
|
import {
|
5
2
|
defineTextBlockInputRule
|
6
3
|
} from "./chunk-DYFRBXUX.js";
|
@@ -42,7 +39,8 @@ import {
|
|
42
39
|
Facet,
|
43
40
|
getNodeType,
|
44
41
|
isTextSelection,
|
45
|
-
keymapFacet
|
42
|
+
keymapFacet,
|
43
|
+
OBJECT_REPLACEMENT_CHARACTER
|
46
44
|
} from "@prosekit/core";
|
47
45
|
function defineEnterRule({
|
48
46
|
regex,
|
@@ -141,20 +139,8 @@ function getAttrs(match) {
|
|
141
139
|
}
|
142
140
|
|
143
141
|
// src/code-block/code-block-keymap.ts
|
144
|
-
import { defineKeymap } from "@prosekit/core";
|
142
|
+
import { defaultBlockAt, defineKeymap } from "@prosekit/core";
|
145
143
|
import { TextSelection } from "@prosekit/pm/state";
|
146
|
-
|
147
|
-
// src/utils/default-block-at.ts
|
148
|
-
function defaultBlockAt(match) {
|
149
|
-
for (let i = 0; i < match.edgeCount; i++) {
|
150
|
-
const { type } = match.edge(i);
|
151
|
-
if (type.isTextblock && !type.hasRequiredAttrs())
|
152
|
-
return type;
|
153
|
-
}
|
154
|
-
return null;
|
155
|
-
}
|
156
|
-
|
157
|
-
// src/code-block/code-block-keymap.ts
|
158
144
|
function defineCodeBlockKeymap() {
|
159
145
|
return defineKeymap({
|
160
146
|
Enter: existCodeBlock
|
@@ -1,6 +1,3 @@
|
|
1
|
-
import {
|
2
|
-
isInCodeBlock
|
3
|
-
} from "./chunk-DI46QWLX.js";
|
4
1
|
import {
|
5
2
|
defineTextBlockInputRule
|
6
3
|
} from "./chunk-DYFRBXUX.js";
|
@@ -13,20 +10,9 @@ import {
|
|
13
10
|
insertNode,
|
14
11
|
setBlockType,
|
15
12
|
toggleNode,
|
16
|
-
union
|
13
|
+
union,
|
14
|
+
withSkipCodeBlock
|
17
15
|
} from "@prosekit/core";
|
18
|
-
|
19
|
-
// src/utils/with-skip-code-block.ts
|
20
|
-
function withSkipCodeBlock(command) {
|
21
|
-
return (state, dispatch, view) => {
|
22
|
-
if (isInCodeBlock(state.selection)) {
|
23
|
-
return false;
|
24
|
-
}
|
25
|
-
return command(state, dispatch, view);
|
26
|
-
};
|
27
|
-
}
|
28
|
-
|
29
|
-
// src/heading/index.ts
|
30
16
|
function defineHeadingSpec() {
|
31
17
|
return defineNodeSpec({
|
32
18
|
name: "heading",
|
@@ -4,6 +4,7 @@ import {
|
|
4
4
|
addMark,
|
5
5
|
defineMarkSpec,
|
6
6
|
union,
|
7
|
+
removeMark,
|
7
8
|
toggleMark
|
8
9
|
} from "@prosekit/core";
|
9
10
|
function defineLinkSpec() {
|
@@ -31,6 +32,7 @@ function defineLinkSpec() {
|
|
31
32
|
function defineLinkCommands() {
|
32
33
|
return defineCommands({
|
33
34
|
addLink: (attrs) => addMark({ type: "link", attrs }),
|
35
|
+
removeLink: () => removeMark({ type: "link" }),
|
34
36
|
toggleLink: (attrs) => toggleMark({ type: "link", attrs })
|
35
37
|
});
|
36
38
|
}
|
@@ -1,12 +1,16 @@
|
|
1
|
-
import {
|
2
|
-
isInCodeBlock
|
3
|
-
} from "./chunk-DI46QWLX.js";
|
4
|
-
|
5
1
|
// src/placeholder/index.ts
|
6
2
|
import { definePlugin } from "@prosekit/core";
|
7
3
|
import "@prosekit/pm/model";
|
8
4
|
import { Plugin, PluginKey } from "@prosekit/pm/state";
|
9
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
|
10
14
|
function definePlaceholder(options) {
|
11
15
|
return definePlugin(createPlaceholderPlugin(options));
|
12
16
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/extensions",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.2.
|
4
|
+
"version": "0.2.4",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -55,6 +55,11 @@
|
|
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
|
+
},
|
58
63
|
"./heading": {
|
59
64
|
"types": "./dist/prosekit-extensions-heading.d.ts",
|
60
65
|
"import": "./dist/prosekit-extensions-heading.js",
|
@@ -121,8 +126,9 @@
|
|
121
126
|
"dist"
|
122
127
|
],
|
123
128
|
"dependencies": {
|
124
|
-
"@prosekit/core": "^0.2.
|
129
|
+
"@prosekit/core": "^0.2.4",
|
125
130
|
"@prosekit/pm": "^0.1.1",
|
131
|
+
"prosemirror-dropcursor": "^1.8.1",
|
126
132
|
"prosemirror-flat-list": "^0.4.5",
|
127
133
|
"prosemirror-highlight": "^0.4.0"
|
128
134
|
},
|
@@ -136,10 +142,10 @@
|
|
136
142
|
},
|
137
143
|
"devDependencies": {
|
138
144
|
"@prosekit/dev": "*",
|
139
|
-
"shikiji": "^0.9.
|
145
|
+
"shikiji": "^0.9.18",
|
140
146
|
"tsup": "^8.0.1",
|
141
147
|
"typescript": "^5.3.3",
|
142
|
-
"vitest": "^1.1.
|
148
|
+
"vitest": "^1.1.3"
|
143
149
|
},
|
144
150
|
"scripts": {
|
145
151
|
"build:tsup": "tsup",
|
@@ -166,6 +172,9 @@
|
|
166
172
|
"code-block": [
|
167
173
|
"./dist/prosekit-extensions-code-block.d.ts"
|
168
174
|
],
|
175
|
+
"drop-cursor": [
|
176
|
+
"./dist/prosekit-extensions-drop-cursor.d.ts"
|
177
|
+
],
|
169
178
|
"heading": [
|
170
179
|
"./dist/prosekit-extensions-heading.d.ts"
|
171
180
|
],
|
package/dist/chunk-DI46QWLX.js
DELETED