@prosekit/extensions 0.7.1 → 0.7.2
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 +96 -116
- package/dist/list/style.css +1 -1
- package/dist/prosekit-extensions-heading.d.ts +4 -4
- package/dist/prosekit-extensions-heading.js +54 -34
- package/dist/prosekit-extensions-list.d.ts +8 -2
- package/dist/prosekit-extensions-list.js +62 -34
- package/package.json +6 -6
@@ -1,5 +1,5 @@
|
|
1
|
+
import { AddMarkOptions } from '@prosekit/core';
|
1
2
|
import { Attrs } from '@prosekit/pm/model';
|
2
|
-
import { Attrs as Attrs_2 } from 'prosemirror-model';
|
3
3
|
import { BundledLanguage } from 'shiki';
|
4
4
|
import { BundledLanguageInfo } from 'shiki';
|
5
5
|
import { bundledLanguagesInfo } from 'shiki';
|
@@ -18,28 +18,33 @@ import { getSingletonHighlighter } from 'shiki/bundle/full';
|
|
18
18
|
import type { Highlighter } from 'shiki';
|
19
19
|
import { IndentListOptions } from 'prosemirror-flat-list';
|
20
20
|
import { InputRule } from '@prosekit/pm/inputrules';
|
21
|
+
import { InsertNodeOptions } from '@prosekit/core';
|
21
22
|
import { ListAttributes } from 'prosemirror-flat-list';
|
22
23
|
import { ListDOMSerializer } from 'prosemirror-flat-list';
|
23
24
|
import { MarkBuilder } from '@prosekit/core';
|
24
25
|
import { MarkType } from '@prosekit/pm/model';
|
25
|
-
import { MarkType as MarkType_2 } from 'prosemirror-model';
|
26
|
-
import { Node as Node_2 } from 'prosemirror-model';
|
27
26
|
import { NodeBuilder } from '@prosekit/core';
|
28
27
|
import { NodeJSON } from '@prosekit/core';
|
29
|
-
import { NodeRange } from 'prosemirror-model';
|
30
28
|
import { NodeType } from '@prosekit/pm/model';
|
31
|
-
import { NodeType as NodeType_2 } from 'prosemirror-model';
|
32
29
|
import { Options } from 'tsup';
|
33
30
|
import { Parser } from 'prosemirror-highlight';
|
34
31
|
import { Plugin as Plugin_2 } from '@prosekit/pm/state';
|
35
32
|
import { PluginKey } from '@prosekit/pm/state';
|
36
33
|
import { ProseMirrorNode } from '@prosekit/pm/model';
|
34
|
+
import { RemoveMarkOptions } from '@prosekit/core';
|
35
|
+
import { RemoveNodeOptions } from '@prosekit/core';
|
36
|
+
import { SetBlockTypeOptions } from '@prosekit/core';
|
37
|
+
import { SetNodeAttrsOptions } from '@prosekit/core';
|
37
38
|
import type { SpecialLanguage } from 'shiki';
|
38
39
|
import { StepJSON } from '@prosekit/core';
|
39
40
|
import { TestEditor } from '@prosekit/core/test';
|
40
41
|
import { ToggleCollapsedOptions } from 'prosemirror-flat-list';
|
41
42
|
import { Transaction } from '@prosekit/pm/state';
|
43
|
+
import { UnsetBlockTypeOptions } from '@prosekit/core';
|
44
|
+
import { UnsetMarkOptions } from '@prosekit/core';
|
42
45
|
import { UnwrapListOptions } from 'prosemirror-flat-list';
|
46
|
+
import { WrapInListGetAttrs } from 'prosemirror-flat-list';
|
47
|
+
import { WrapOptions } from '@prosekit/core';
|
43
48
|
|
44
49
|
export declare function applyMarkRules(rules: MarkRuleOptions[], transactions: readonly Transaction[], oldState: EditorState, newState: EditorState): Transaction | null;
|
45
50
|
|
@@ -174,6 +179,8 @@ export declare function createLazyParser(highlighterOptions: HighlighterOptions)
|
|
174
179
|
*/
|
175
180
|
export declare function createMarkInputRule({ regex, type, attrs, }: MarkInputRuleOptions): InputRule;
|
176
181
|
|
182
|
+
export { DedentListOptions }
|
183
|
+
|
177
184
|
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
178
185
|
|
179
186
|
export { default_alias_1 }
|
@@ -412,7 +419,7 @@ toggleHeading: [attrs?: HeadingAttrs | undefined];
|
|
412
419
|
};
|
413
420
|
}>;
|
414
421
|
|
415
|
-
|
422
|
+
declare function defineHeadingCommands(): Extension< {
|
416
423
|
Commands: {
|
417
424
|
setHeading: [attrs?: HeadingAttrs | undefined];
|
418
425
|
insertHeading: [attrs?: HeadingAttrs | undefined];
|
@@ -421,20 +428,28 @@ toggleHeading: [attrs?: HeadingAttrs | undefined];
|
|
421
428
|
Nodes: never;
|
422
429
|
Marks: never;
|
423
430
|
}>;
|
431
|
+
export { defineHeadingCommands }
|
432
|
+
export { defineHeadingCommands as defineHeadingCommands_alias_1 }
|
424
433
|
|
425
434
|
/**
|
426
435
|
* Converts the text block to a heading when `#` is typed at the start of a new
|
427
436
|
* line followed by a space.
|
428
437
|
*/
|
429
|
-
|
438
|
+
declare function defineHeadingInputRule(): Extension<ExtensionTyping<any, any, any>>;
|
439
|
+
export { defineHeadingInputRule }
|
440
|
+
export { defineHeadingInputRule as defineHeadingInputRule_alias_1 }
|
430
441
|
|
431
|
-
|
442
|
+
declare function defineHeadingKeymap(): Extension<ExtensionTyping<any, any, any>>;
|
443
|
+
export { defineHeadingKeymap }
|
444
|
+
export { defineHeadingKeymap as defineHeadingKeymap_alias_1 }
|
432
445
|
|
433
|
-
|
446
|
+
declare function defineHeadingSpec(): Extension< {
|
434
447
|
Nodes: "heading";
|
435
448
|
Marks: never;
|
436
449
|
Commands: never;
|
437
450
|
}>;
|
451
|
+
export { defineHeadingSpec }
|
452
|
+
export { defineHeadingSpec as defineHeadingSpec_alias_1 }
|
438
453
|
|
439
454
|
/**
|
440
455
|
* @public
|
@@ -559,26 +574,31 @@ export declare function defineList(): Extension<{
|
|
559
574
|
toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
|
560
575
|
toggleList: [attrs: ListAttributes];
|
561
576
|
unwrapList: [options?: UnwrapListOptions | undefined];
|
562
|
-
wrapInList: [getAttrs: ListAttributes
|
577
|
+
wrapInList: [getAttrs: WrapInListGetAttrs<ListAttributes>];
|
563
578
|
insertList: [attrs?: ListAttributes | undefined];
|
564
579
|
};
|
565
580
|
}>;
|
566
581
|
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
582
|
+
/**
|
583
|
+
* Defines list commands
|
584
|
+
*/
|
585
|
+
declare function defineListCommands(): Extension< {
|
586
|
+
Commands: {
|
587
|
+
dedentList: [options?: DedentListOptions | undefined];
|
588
|
+
indentList: [options?: IndentListOptions | undefined];
|
589
|
+
moveList: [direction: "up" | "down"];
|
590
|
+
splitList: [];
|
591
|
+
toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
|
592
|
+
toggleList: [attrs: ListAttributes];
|
593
|
+
unwrapList: [options?: UnwrapListOptions | undefined];
|
594
|
+
wrapInList: [getAttrs: WrapInListGetAttrs<ListAttributes>];
|
595
|
+
insertList: [attrs?: ListAttributes | undefined];
|
596
|
+
};
|
597
|
+
Nodes: never;
|
598
|
+
Marks: never;
|
581
599
|
}>;
|
600
|
+
export { defineListCommands }
|
601
|
+
export { defineListCommands as defineListCommands_alias_1 }
|
582
602
|
|
583
603
|
export declare function defineListInputRules(): Extension;
|
584
604
|
|
@@ -587,7 +607,9 @@ export declare function defineListInputRules(): Extension;
|
|
587
607
|
*
|
588
608
|
* @public
|
589
609
|
*/
|
590
|
-
|
610
|
+
declare function defineListKeymap(): Extension<ExtensionTyping<any, any, any>>;
|
611
|
+
export { defineListKeymap }
|
612
|
+
export { defineListKeymap as defineListKeymap_alias_1 }
|
591
613
|
|
592
614
|
export declare function defineListPlugins(): Extension<ExtensionTyping<any, any, any>>;
|
593
615
|
|
@@ -803,50 +825,16 @@ export declare function defineTestExtension(): Extension<{
|
|
803
825
|
from?: number;
|
804
826
|
to?: number;
|
805
827
|
}];
|
806
|
-
insertNode: [options:
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
} | {
|
812
|
-
node?: undefined;
|
813
|
-
pos?: number;
|
814
|
-
type: string;
|
815
|
-
attrs?: Attrs_2;
|
816
|
-
}];
|
817
|
-
removeNode: [options: {
|
818
|
-
type: string | NodeType_2;
|
819
|
-
pos?: number;
|
820
|
-
}];
|
821
|
-
wrap: [{
|
822
|
-
nodeType: NodeType_2;
|
823
|
-
attrs?: Attrs_2 | null;
|
824
|
-
}];
|
825
|
-
setBlockType: [options: {
|
826
|
-
type: NodeType_2 | string;
|
827
|
-
attrs?: Attrs_2 | null;
|
828
|
-
from?: number;
|
829
|
-
to?: number;
|
830
|
-
}];
|
831
|
-
setNodeAttrs: [options: {
|
832
|
-
type: string | NodeType_2 | string[] | NodeType_2[];
|
833
|
-
attrs: Attrs_2;
|
834
|
-
pos?: number;
|
835
|
-
}];
|
828
|
+
insertNode: [options: InsertNodeOptions];
|
829
|
+
removeNode: [options: RemoveNodeOptions];
|
830
|
+
wrap: [WrapOptions];
|
831
|
+
setBlockType: [options: SetBlockTypeOptions];
|
832
|
+
setNodeAttrs: [options: SetNodeAttrsOptions];
|
836
833
|
selectAll: [];
|
837
|
-
addMark: [options:
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
to?: number;
|
842
|
-
}];
|
843
|
-
removeMark: [options: {
|
844
|
-
type: string | MarkType_2;
|
845
|
-
attrs?: Attrs_2 | null;
|
846
|
-
from?: number;
|
847
|
-
to?: number;
|
848
|
-
}];
|
849
|
-
toggleItalic: [];
|
834
|
+
addMark: [options: AddMarkOptions];
|
835
|
+
removeMark: [options: RemoveMarkOptions];
|
836
|
+
unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
|
837
|
+
unsetMark: [options?: UnsetMarkOptions | undefined];
|
850
838
|
undo: [];
|
851
839
|
redo: [];
|
852
840
|
toggleBold: [];
|
@@ -855,6 +843,7 @@ export declare function defineTestExtension(): Extension<{
|
|
855
843
|
insertHeading: [attrs?: HeadingAttrs | undefined];
|
856
844
|
toggleHeading: [attrs?: HeadingAttrs | undefined];
|
857
845
|
insertImage: [attrs?: ImageAttrs | undefined];
|
846
|
+
toggleItalic: [];
|
858
847
|
addLink: [attrs: LinkAttrs];
|
859
848
|
removeLink: [];
|
860
849
|
toggleLink: [attrs: LinkAttrs];
|
@@ -866,7 +855,7 @@ export declare function defineTestExtension(): Extension<{
|
|
866
855
|
toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
|
867
856
|
toggleList: [attrs: ListAttributes];
|
868
857
|
unwrapList: [options?: UnwrapListOptions | undefined];
|
869
|
-
wrapInList: [getAttrs: ListAttributes
|
858
|
+
wrapInList: [getAttrs: WrapInListGetAttrs<ListAttributes>];
|
870
859
|
insertList: [attrs?: ListAttributes | undefined];
|
871
860
|
toggleStrike: [];
|
872
861
|
insertTable: [{
|
@@ -1095,9 +1084,11 @@ export { getSingletonHighlighter }
|
|
1095
1084
|
|
1096
1085
|
export declare function getTrMeta(tr: Transaction): PredictionPluginState;
|
1097
1086
|
|
1098
|
-
|
1087
|
+
declare interface HeadingAttrs {
|
1099
1088
|
level: number;
|
1100
1089
|
}
|
1090
|
+
export { HeadingAttrs }
|
1091
|
+
export { HeadingAttrs as HeadingAttrs_alias_1 }
|
1101
1092
|
|
1102
1093
|
export declare type HighlighterOptions = {
|
1103
1094
|
themes: BundledTheme[];
|
@@ -1126,6 +1117,8 @@ export declare interface ImageAttrs {
|
|
1126
1117
|
src?: string | null;
|
1127
1118
|
}
|
1128
1119
|
|
1120
|
+
export { IndentListOptions }
|
1121
|
+
|
1129
1122
|
/**
|
1130
1123
|
* Insert a table node with the given number of rows and columns, and optionally
|
1131
1124
|
* a header row.
|
@@ -1151,6 +1144,8 @@ export declare interface LinkAttrs {
|
|
1151
1144
|
href: string;
|
1152
1145
|
}
|
1153
1146
|
|
1147
|
+
export { ListAttributes }
|
1148
|
+
|
1154
1149
|
export { ListDOMSerializer }
|
1155
1150
|
|
1156
1151
|
/**
|
@@ -1248,6 +1243,18 @@ export declare interface PredictionPluginState {
|
|
1248
1243
|
|
1249
1244
|
export declare function prepareHighlighter(options: HighlighterOptions): HighlighterResult;
|
1250
1245
|
|
1246
|
+
/**
|
1247
|
+
* @example
|
1248
|
+
*
|
1249
|
+
* ```ts
|
1250
|
+
* await pressKey('mod-1')
|
1251
|
+
* await pressKey('Backspace')
|
1252
|
+
* ```
|
1253
|
+
*
|
1254
|
+
* @internal
|
1255
|
+
*/
|
1256
|
+
export declare function pressKey(input: string): Promise<void>;
|
1257
|
+
|
1251
1258
|
/**
|
1252
1259
|
* Options for {@link defineSearchQuery}
|
1253
1260
|
*
|
@@ -1303,7 +1310,7 @@ export declare function setTrMeta(tr: Transaction, meta: PredictionPluginState):
|
|
1303
1310
|
/**
|
1304
1311
|
* @internal
|
1305
1312
|
*/
|
1306
|
-
export declare function
|
1313
|
+
export declare function setupTest(): {
|
1307
1314
|
editor: TestEditor<Extension<{
|
1308
1315
|
Nodes: "blockquote" | "table" | "text" | "doc" | "paragraph" | "heading" | "image" | "list" | "tableRow" | "tableCell" | "tableHeaderCell";
|
1309
1316
|
Marks: "code" | "link" | "bold" | "strike" | "italic" | "underline";
|
@@ -1313,50 +1320,16 @@ export declare function setupDefaultTest(): {
|
|
1313
1320
|
from?: number;
|
1314
1321
|
to?: number;
|
1315
1322
|
}];
|
1316
|
-
insertNode: [options:
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
} | {
|
1322
|
-
node?: undefined;
|
1323
|
-
pos?: number;
|
1324
|
-
type: string;
|
1325
|
-
attrs?: Attrs_2;
|
1326
|
-
}];
|
1327
|
-
removeNode: [options: {
|
1328
|
-
type: string | NodeType_2;
|
1329
|
-
pos?: number;
|
1330
|
-
}];
|
1331
|
-
wrap: [{
|
1332
|
-
nodeType: NodeType_2;
|
1333
|
-
attrs?: Attrs_2 | null;
|
1334
|
-
}];
|
1335
|
-
setBlockType: [options: {
|
1336
|
-
type: NodeType_2 | string;
|
1337
|
-
attrs?: Attrs_2 | null;
|
1338
|
-
from?: number;
|
1339
|
-
to?: number;
|
1340
|
-
}];
|
1341
|
-
setNodeAttrs: [options: {
|
1342
|
-
type: string | NodeType_2 | string[] | NodeType_2[];
|
1343
|
-
attrs: Attrs_2;
|
1344
|
-
pos?: number;
|
1345
|
-
}];
|
1323
|
+
insertNode: [options: InsertNodeOptions];
|
1324
|
+
removeNode: [options: RemoveNodeOptions];
|
1325
|
+
wrap: [WrapOptions];
|
1326
|
+
setBlockType: [options: SetBlockTypeOptions];
|
1327
|
+
setNodeAttrs: [options: SetNodeAttrsOptions];
|
1346
1328
|
selectAll: [];
|
1347
|
-
addMark: [options:
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
to?: number;
|
1352
|
-
}];
|
1353
|
-
removeMark: [options: {
|
1354
|
-
type: string | MarkType_2;
|
1355
|
-
attrs?: Attrs_2 | null;
|
1356
|
-
from?: number;
|
1357
|
-
to?: number;
|
1358
|
-
}];
|
1359
|
-
toggleItalic: [];
|
1329
|
+
addMark: [options: AddMarkOptions];
|
1330
|
+
removeMark: [options: RemoveMarkOptions];
|
1331
|
+
unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
|
1332
|
+
unsetMark: [options?: UnsetMarkOptions | undefined];
|
1360
1333
|
undo: [];
|
1361
1334
|
redo: [];
|
1362
1335
|
toggleBold: [];
|
@@ -1365,6 +1338,7 @@ export declare function setupDefaultTest(): {
|
|
1365
1338
|
insertHeading: [attrs?: HeadingAttrs | undefined];
|
1366
1339
|
toggleHeading: [attrs?: HeadingAttrs | undefined];
|
1367
1340
|
insertImage: [attrs?: ImageAttrs | undefined];
|
1341
|
+
toggleItalic: [];
|
1368
1342
|
addLink: [attrs: LinkAttrs];
|
1369
1343
|
removeLink: [];
|
1370
1344
|
toggleLink: [attrs: LinkAttrs];
|
@@ -1376,7 +1350,7 @@ export declare function setupDefaultTest(): {
|
|
1376
1350
|
toggleCollapsed: [(ToggleCollapsedOptions | undefined)?];
|
1377
1351
|
toggleList: [attrs: ListAttributes];
|
1378
1352
|
unwrapList: [options?: UnwrapListOptions | undefined];
|
1379
|
-
wrapInList: [getAttrs: ListAttributes
|
1353
|
+
wrapInList: [getAttrs: WrapInListGetAttrs<ListAttributes>];
|
1380
1354
|
insertList: [attrs?: ListAttributes | undefined];
|
1381
1355
|
toggleStrike: [];
|
1382
1356
|
insertTable: [{
|
@@ -1395,7 +1369,7 @@ export declare function setupDefaultTest(): {
|
|
1395
1369
|
/**
|
1396
1370
|
* @internal
|
1397
1371
|
*/
|
1398
|
-
export declare function
|
1372
|
+
export declare function setupTestFromExtension<E extends Extension>(extension: E): {
|
1399
1373
|
editor: TestEditor<E>;
|
1400
1374
|
n: Record<ExtractNodes<E>, NodeBuilder>;
|
1401
1375
|
m: Record<ExtractMarks<E>, MarkBuilder>;
|
@@ -1445,4 +1419,10 @@ export declare type TextBlockEnterRuleOptions = {
|
|
1445
1419
|
stop?: boolean;
|
1446
1420
|
};
|
1447
1421
|
|
1422
|
+
export { ToggleCollapsedOptions }
|
1423
|
+
|
1424
|
+
export { UnwrapListOptions }
|
1425
|
+
|
1426
|
+
export { WrapInListGetAttrs }
|
1427
|
+
|
1448
1428
|
export { }
|
package/dist/list/style.css
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* ../../node_modules/.pnpm/prosemirror-flat-list@0.5.
|
1
|
+
/* ../../node_modules/.pnpm/prosemirror-flat-list@0.5.2/node_modules/prosemirror-flat-list/dist/style.css */
|
2
2
|
.prosemirror-flat-list {
|
3
3
|
padding: 0;
|
4
4
|
margin-top: 0;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
export { defineHeadingSpec } from './_tsup-dts-rollup';
|
2
|
-
export { defineHeadingKeymap } from './_tsup-dts-rollup';
|
3
|
-
export { defineHeadingInputRule } from './_tsup-dts-rollup';
|
4
|
-
export { defineHeadingCommands } from './_tsup-dts-rollup';
|
5
1
|
export { defineHeading } from './_tsup-dts-rollup';
|
2
|
+
export { defineHeadingCommands_alias_1 as defineHeadingCommands } from './_tsup-dts-rollup';
|
3
|
+
export { defineHeadingInputRule } from './_tsup-dts-rollup';
|
4
|
+
export { defineHeadingKeymap } from './_tsup-dts-rollup';
|
5
|
+
export { defineHeadingSpec } from './_tsup-dts-rollup';
|
6
6
|
export { HeadingAttrs } from './_tsup-dts-rollup';
|
@@ -3,16 +3,64 @@ import {
|
|
3
3
|
} from "./chunk-PYT3MOTF.js";
|
4
4
|
|
5
5
|
// src/heading/index.ts
|
6
|
+
import { union } from "@prosekit/core";
|
7
|
+
|
8
|
+
// src/heading/commands.ts
|
6
9
|
import {
|
7
10
|
defineCommands,
|
8
|
-
defineKeymap,
|
9
|
-
defineNodeSpec,
|
10
11
|
insertNode,
|
11
12
|
setBlockType,
|
12
|
-
toggleNode
|
13
|
-
|
13
|
+
toggleNode
|
14
|
+
} from "@prosekit/core";
|
15
|
+
function defineHeadingCommands() {
|
16
|
+
return defineCommands({
|
17
|
+
setHeading: (attrs) => setBlockType({ type: "heading", attrs }),
|
18
|
+
insertHeading: (attrs) => insertNode({ type: "heading", attrs }),
|
19
|
+
toggleHeading: (attrs) => toggleNode({ type: "heading", attrs })
|
20
|
+
});
|
21
|
+
}
|
22
|
+
|
23
|
+
// src/heading/input-rule.ts
|
24
|
+
function defineHeadingInputRule() {
|
25
|
+
return defineTextBlockInputRule({
|
26
|
+
regex: /^(#{1,6})\s$/,
|
27
|
+
type: "heading",
|
28
|
+
attrs: (match) => {
|
29
|
+
var _a, _b;
|
30
|
+
return { level: (_b = (_a = match[1]) == null ? void 0 : _a.length) != null ? _b : 1 };
|
31
|
+
}
|
32
|
+
});
|
33
|
+
}
|
34
|
+
|
35
|
+
// src/heading/keymap.ts
|
36
|
+
import {
|
37
|
+
defineKeymap,
|
38
|
+
isAtBlockStart,
|
39
|
+
toggleNode as toggleNode2,
|
40
|
+
unsetBlockType,
|
14
41
|
withSkipCodeBlock
|
15
42
|
} from "@prosekit/core";
|
43
|
+
function toggleHeadingKeybinding(level) {
|
44
|
+
return withSkipCodeBlock(toggleNode2({ type: "heading", attrs: { level } }));
|
45
|
+
}
|
46
|
+
var backspaceUnsetHeading = (state, dispatch, view) => {
|
47
|
+
let $pos = isAtBlockStart(state, view);
|
48
|
+
return ($pos == null ? void 0 : $pos.parent.type.name) === "heading" ? unsetBlockType()(state, dispatch, view) : !1;
|
49
|
+
};
|
50
|
+
function defineHeadingKeymap() {
|
51
|
+
return defineKeymap({
|
52
|
+
"mod-1": toggleHeadingKeybinding(1),
|
53
|
+
"mod-2": toggleHeadingKeybinding(2),
|
54
|
+
"mod-3": toggleHeadingKeybinding(3),
|
55
|
+
"mod-4": toggleHeadingKeybinding(4),
|
56
|
+
"mod-5": toggleHeadingKeybinding(5),
|
57
|
+
"mod-6": toggleHeadingKeybinding(6),
|
58
|
+
Backspace: backspaceUnsetHeading
|
59
|
+
});
|
60
|
+
}
|
61
|
+
|
62
|
+
// src/heading/spec.ts
|
63
|
+
import { defineNodeSpec } from "@prosekit/core";
|
16
64
|
function defineHeadingSpec() {
|
17
65
|
return defineNodeSpec({
|
18
66
|
name: "heading",
|
@@ -33,36 +81,8 @@ function defineHeadingSpec() {
|
|
33
81
|
}
|
34
82
|
});
|
35
83
|
}
|
36
|
-
|
37
|
-
|
38
|
-
"mod-1": toggleHeadingKeybinding(1),
|
39
|
-
"mod-2": toggleHeadingKeybinding(2),
|
40
|
-
"mod-3": toggleHeadingKeybinding(3),
|
41
|
-
"mod-4": toggleHeadingKeybinding(4),
|
42
|
-
"mod-5": toggleHeadingKeybinding(5),
|
43
|
-
"mod-6": toggleHeadingKeybinding(6)
|
44
|
-
});
|
45
|
-
}
|
46
|
-
function toggleHeadingKeybinding(level) {
|
47
|
-
return withSkipCodeBlock(toggleNode({ type: "heading", attrs: { level } }));
|
48
|
-
}
|
49
|
-
function defineHeadingInputRule() {
|
50
|
-
return defineTextBlockInputRule({
|
51
|
-
regex: /^(#{1,6})\s$/,
|
52
|
-
type: "heading",
|
53
|
-
attrs: (match) => {
|
54
|
-
var _a, _b;
|
55
|
-
return { level: (_b = (_a = match[1]) == null ? void 0 : _a.length) != null ? _b : 1 };
|
56
|
-
}
|
57
|
-
});
|
58
|
-
}
|
59
|
-
function defineHeadingCommands() {
|
60
|
-
return defineCommands({
|
61
|
-
setHeading: (attrs) => setBlockType({ type: "heading", attrs }),
|
62
|
-
insertHeading: (attrs) => insertNode({ type: "heading", attrs }),
|
63
|
-
toggleHeading: (attrs) => toggleNode({ type: "heading", attrs })
|
64
|
-
});
|
65
|
-
}
|
84
|
+
|
85
|
+
// src/heading/index.ts
|
66
86
|
function defineHeading() {
|
67
87
|
return union([
|
68
88
|
defineHeadingSpec(),
|
@@ -1,7 +1,13 @@
|
|
1
1
|
export { defineListSpec } from './_tsup-dts-rollup';
|
2
2
|
export { defineListPlugins } from './_tsup-dts-rollup';
|
3
|
-
export { defineListKeymap } from './_tsup-dts-rollup';
|
4
3
|
export { defineListInputRules } from './_tsup-dts-rollup';
|
5
|
-
export { defineListCommands } from './_tsup-dts-rollup';
|
6
4
|
export { defineList } from './_tsup-dts-rollup';
|
7
5
|
export { ListDOMSerializer } from './_tsup-dts-rollup';
|
6
|
+
export { DedentListOptions } from './_tsup-dts-rollup';
|
7
|
+
export { IndentListOptions } from './_tsup-dts-rollup';
|
8
|
+
export { ListAttributes } from './_tsup-dts-rollup';
|
9
|
+
export { ToggleCollapsedOptions } from './_tsup-dts-rollup';
|
10
|
+
export { UnwrapListOptions } from './_tsup-dts-rollup';
|
11
|
+
export { WrapInListGetAttrs } from './_tsup-dts-rollup';
|
12
|
+
export { defineListCommands_alias_1 as defineListCommands } from './_tsup-dts-rollup';
|
13
|
+
export { defineListKeymap } from './_tsup-dts-rollup';
|
@@ -4,29 +4,74 @@ import {
|
|
4
4
|
|
5
5
|
// src/list/index.ts
|
6
6
|
import {
|
7
|
-
Priority,
|
8
|
-
defineCommands,
|
9
|
-
defineKeymap,
|
10
7
|
defineNodeSpec,
|
11
8
|
definePlugin,
|
12
|
-
|
13
|
-
union,
|
14
|
-
withPriority
|
9
|
+
union
|
15
10
|
} from "@prosekit/core";
|
16
11
|
import {
|
17
|
-
createDedentListCommand,
|
18
|
-
createIndentListCommand,
|
19
12
|
createListPlugins,
|
20
13
|
createListSpec,
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
14
|
+
listInputRules
|
15
|
+
} from "prosemirror-flat-list";
|
16
|
+
|
17
|
+
// src/list/commands.ts
|
18
|
+
import { defineCommands, insertNode } from "@prosekit/core";
|
19
|
+
import {
|
20
|
+
createDedentListCommand as dedentList,
|
21
|
+
createIndentListCommand as indentList,
|
22
|
+
createMoveListCommand as moveList,
|
23
|
+
createSplitListCommand as splitList,
|
24
|
+
createToggleCollapsedCommand as toggleCollapsed,
|
25
|
+
createToggleListCommand as toggleList,
|
26
|
+
createUnwrapListCommand as unwrapList,
|
27
|
+
createWrapInListCommand as wrapInList
|
28
|
+
} from "prosemirror-flat-list";
|
29
|
+
function insertList(attrs) {
|
30
|
+
return insertNode({ type: "list", attrs });
|
31
|
+
}
|
32
|
+
function defineListCommands() {
|
33
|
+
return defineCommands({
|
34
|
+
dedentList,
|
35
|
+
indentList,
|
36
|
+
moveList,
|
37
|
+
splitList,
|
38
|
+
toggleCollapsed,
|
39
|
+
toggleList,
|
40
|
+
unwrapList,
|
41
|
+
wrapInList,
|
42
|
+
insertList
|
43
|
+
});
|
44
|
+
}
|
45
|
+
|
46
|
+
// src/list/keymap.ts
|
47
|
+
import { defineKeymap } from "@prosekit/core";
|
48
|
+
import { chainCommands, deleteSelection } from "@prosekit/pm/commands";
|
49
|
+
import {
|
50
|
+
createDedentListCommand,
|
51
|
+
createIndentListCommand,
|
52
|
+
deleteCommand,
|
53
|
+
enterCommand,
|
54
|
+
joinCollapsedListBackward,
|
55
|
+
joinListUp,
|
56
|
+
protectCollapsed
|
29
57
|
} from "prosemirror-flat-list";
|
58
|
+
var backspaceCommand = chainCommands(
|
59
|
+
protectCollapsed,
|
60
|
+
deleteSelection,
|
61
|
+
joinListUp,
|
62
|
+
joinCollapsedListBackward
|
63
|
+
), listKeymap = {
|
64
|
+
Enter: enterCommand,
|
65
|
+
Backspace: backspaceCommand,
|
66
|
+
Delete: deleteCommand,
|
67
|
+
"Mod-[": createDedentListCommand(),
|
68
|
+
"Mod-]": createIndentListCommand()
|
69
|
+
};
|
70
|
+
function defineListKeymap() {
|
71
|
+
return defineKeymap(listKeymap);
|
72
|
+
}
|
73
|
+
|
74
|
+
// src/list/index.ts
|
30
75
|
import { ListDOMSerializer } from "prosemirror-flat-list";
|
31
76
|
function defineListSpec() {
|
32
77
|
return defineNodeSpec({ ...createListSpec(), name: "list" });
|
@@ -34,31 +79,14 @@ function defineListSpec() {
|
|
34
79
|
function defineListPlugins() {
|
35
80
|
return definePlugin(({ schema }) => createListPlugins({ schema }));
|
36
81
|
}
|
37
|
-
function defineListKeymap() {
|
38
|
-
return defineKeymap(listKeymap);
|
39
|
-
}
|
40
82
|
function defineListInputRules() {
|
41
83
|
return union(listInputRules.map(defineInputRule));
|
42
84
|
}
|
43
|
-
function defineListCommands() {
|
44
|
-
return defineCommands({
|
45
|
-
dedentList: createDedentListCommand,
|
46
|
-
indentList: createIndentListCommand,
|
47
|
-
moveList: createMoveListCommand,
|
48
|
-
splitList: createSplitListCommand,
|
49
|
-
toggleCollapsed: createToggleCollapsedCommand,
|
50
|
-
toggleList: createToggleListCommand,
|
51
|
-
unwrapList: createUnwrapListCommand,
|
52
|
-
wrapInList: createWrapInListCommand,
|
53
|
-
insertList: (attrs) => insertNode({ type: "list", attrs })
|
54
|
-
});
|
55
|
-
}
|
56
85
|
function defineList() {
|
57
86
|
return union([
|
58
87
|
defineListSpec(),
|
59
88
|
defineListPlugins(),
|
60
|
-
|
61
|
-
withPriority(defineListKeymap(), Priority.high),
|
89
|
+
defineListKeymap(),
|
62
90
|
defineListInputRules(),
|
63
91
|
defineListCommands()
|
64
92
|
]);
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/extensions",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.7.
|
4
|
+
"version": "0.7.2",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -180,19 +180,19 @@
|
|
180
180
|
"dependencies": {
|
181
181
|
"prosemirror-changeset": "^2.2.1",
|
182
182
|
"prosemirror-dropcursor": "^1.8.1",
|
183
|
-
"prosemirror-flat-list": "^0.5.
|
183
|
+
"prosemirror-flat-list": "^0.5.2",
|
184
184
|
"prosemirror-highlight": "^0.8.0",
|
185
185
|
"prosemirror-search": "^0.1.0",
|
186
186
|
"prosemirror-tables": "^1.3.7",
|
187
|
-
"shiki": "^1.10.
|
188
|
-
"@prosekit/core": "^0.7.
|
187
|
+
"shiki": "^1.10.3",
|
188
|
+
"@prosekit/core": "^0.7.2",
|
189
189
|
"@prosekit/pm": "^0.1.5"
|
190
190
|
},
|
191
191
|
"devDependencies": {
|
192
|
-
"@vitest/browser": "^2.0.
|
192
|
+
"@vitest/browser": "^2.0.2",
|
193
193
|
"tsup": "^8.1.0",
|
194
194
|
"typescript": "^5.5.3",
|
195
|
-
"vitest": "^2.0.
|
195
|
+
"vitest": "^2.0.2",
|
196
196
|
"@prosekit/dev": "0.0.0"
|
197
197
|
},
|
198
198
|
"scripts": {
|