@prosekit/core 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 +266 -149
- package/dist/prosekit-core.d.ts +17 -1
- package/dist/prosekit-core.js +107 -49
- package/package.json +2 -2
@@ -1,6 +1,5 @@
|
|
1
1
|
import { AllSelection } from '@prosekit/pm/state';
|
2
2
|
import { Attrs } from '@prosekit/pm/model';
|
3
|
-
import { Attrs as Attrs_2 } from 'prosemirror-model';
|
4
3
|
import { Command } from '@prosekit/pm/state';
|
5
4
|
import type { ContentMatch } from '@prosekit/pm/model';
|
6
5
|
import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
|
@@ -15,9 +14,7 @@ import type { IsEqual } from 'type-fest';
|
|
15
14
|
import { Mark } from '@prosekit/pm/model';
|
16
15
|
import type { MarkSpec } from '@prosekit/pm/model';
|
17
16
|
import { MarkType } from '@prosekit/pm/model';
|
18
|
-
import {
|
19
|
-
import { Node as Node_2 } from 'prosemirror-model';
|
20
|
-
import type { Node as Node_3 } from '@prosekit/pm/model';
|
17
|
+
import type { Node as Node_2 } from '@prosekit/pm/model';
|
21
18
|
import { NodeSelection } from '@prosekit/pm/state';
|
22
19
|
import type { NodeSpec } from '@prosekit/pm/model';
|
23
20
|
import { NodeType } from '@prosekit/pm/model';
|
@@ -50,7 +47,14 @@ declare type Action = (options: {
|
|
50
47
|
*
|
51
48
|
* @public
|
52
49
|
*/
|
53
|
-
declare function addMark(options:
|
50
|
+
declare function addMark(options: AddMarkOptions): Command;
|
51
|
+
export { addMark }
|
52
|
+
export { addMark as addMark_alias_1 }
|
53
|
+
|
54
|
+
/**
|
55
|
+
* @public
|
56
|
+
*/
|
57
|
+
declare interface AddMarkOptions {
|
54
58
|
/**
|
55
59
|
* The type of the mark to add.
|
56
60
|
*/
|
@@ -67,9 +71,9 @@ declare function addMark(options: {
|
|
67
71
|
* The end position of the document. By default it will be the end position of current selection.
|
68
72
|
*/
|
69
73
|
to?: number;
|
70
|
-
}
|
71
|
-
export {
|
72
|
-
export {
|
74
|
+
}
|
75
|
+
export { AddMarkOptions }
|
76
|
+
export { AddMarkOptions as AddMarkOptions_alias_1 }
|
73
77
|
|
74
78
|
export declare function applyAction(operator: Action): Command;
|
75
79
|
|
@@ -169,7 +173,7 @@ declare type ClickHandler = (view: EditorView, pos: number, event: MouseEvent) =
|
|
169
173
|
export { ClickHandler }
|
170
174
|
export { ClickHandler as ClickHandler_alias_1 }
|
171
175
|
|
172
|
-
declare type ClickOnHandler = (view: EditorView, pos: number, node:
|
176
|
+
declare type ClickOnHandler = (view: EditorView, pos: number, node: Node_2, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
|
173
177
|
export { ClickOnHandler }
|
174
178
|
export { ClickOnHandler as ClickOnHandler_alias_1 }
|
175
179
|
|
@@ -295,49 +299,16 @@ declare function defineBaseCommands(): Extension<{
|
|
295
299
|
from?: number;
|
296
300
|
to?: number;
|
297
301
|
}];
|
298
|
-
insertNode: [options:
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
} | {
|
304
|
-
node?: undefined;
|
305
|
-
pos?: number;
|
306
|
-
type: string;
|
307
|
-
attrs?: Attrs_2;
|
308
|
-
}];
|
309
|
-
removeNode: [options: {
|
310
|
-
type: string | NodeType_2;
|
311
|
-
pos?: number;
|
312
|
-
}];
|
313
|
-
wrap: [{
|
314
|
-
nodeType: NodeType_2;
|
315
|
-
attrs?: Attrs_2 | null;
|
316
|
-
}];
|
317
|
-
setBlockType: [options: {
|
318
|
-
type: NodeType_2 | string;
|
319
|
-
attrs?: Attrs_2 | null;
|
320
|
-
from?: number;
|
321
|
-
to?: number;
|
322
|
-
}];
|
323
|
-
setNodeAttrs: [options: {
|
324
|
-
type: string | NodeType_2 | string[] | NodeType_2[];
|
325
|
-
attrs: Attrs_2;
|
326
|
-
pos?: number;
|
327
|
-
}];
|
302
|
+
insertNode: [options: InsertNodeOptions];
|
303
|
+
removeNode: [options: RemoveNodeOptions];
|
304
|
+
wrap: [WrapOptions];
|
305
|
+
setBlockType: [options: SetBlockTypeOptions];
|
306
|
+
setNodeAttrs: [options: SetNodeAttrsOptions];
|
328
307
|
selectAll: [];
|
329
|
-
addMark: [options:
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
to?: number;
|
334
|
-
}];
|
335
|
-
removeMark: [options: {
|
336
|
-
type: string | MarkType_2;
|
337
|
-
attrs?: Attrs_2 | null;
|
338
|
-
from?: number;
|
339
|
-
to?: number;
|
340
|
-
}];
|
308
|
+
addMark: [options: AddMarkOptions];
|
309
|
+
removeMark: [options: RemoveMarkOptions];
|
310
|
+
unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
|
311
|
+
unsetMark: [options?: UnsetMarkOptions | undefined];
|
341
312
|
};
|
342
313
|
Nodes: never;
|
343
314
|
Marks: never;
|
@@ -657,61 +628,28 @@ export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_
|
|
657
628
|
/**
|
658
629
|
* @internal
|
659
630
|
*/
|
660
|
-
export declare function defineTestExtension(): Extension<
|
661
|
-
Nodes: "text" | "doc" | "paragraph";
|
662
|
-
Marks: "bold";
|
663
|
-
Commands: {
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
}
|
682
|
-
removeNode: [options: {
|
683
|
-
type: string | NodeType_2;
|
684
|
-
pos?: number;
|
685
|
-
}];
|
686
|
-
wrap: [{
|
687
|
-
nodeType: NodeType_2;
|
688
|
-
attrs?: Attrs_2 | null;
|
689
|
-
}];
|
690
|
-
setBlockType: [options: {
|
691
|
-
type: NodeType_2 | string;
|
692
|
-
attrs?: Attrs_2 | null;
|
693
|
-
from?: number;
|
694
|
-
to?: number;
|
695
|
-
}];
|
696
|
-
setNodeAttrs: [options: {
|
697
|
-
type: string | NodeType_2 | string[] | NodeType_2[];
|
698
|
-
attrs: Attrs_2;
|
699
|
-
pos?: number;
|
700
|
-
}];
|
701
|
-
selectAll: [];
|
702
|
-
addMark: [options: {
|
703
|
-
type: string | MarkType_2;
|
704
|
-
attrs?: Attrs_2 | null;
|
705
|
-
from?: number;
|
706
|
-
to?: number;
|
707
|
-
}];
|
708
|
-
removeMark: [options: {
|
709
|
-
type: string | MarkType_2;
|
710
|
-
attrs?: Attrs_2 | null;
|
711
|
-
from?: number;
|
712
|
-
to?: number;
|
713
|
-
}];
|
714
|
-
};
|
631
|
+
export declare function defineTestExtension(): Extension<{
|
632
|
+
Nodes: "text" | "doc" | "paragraph" | "heading";
|
633
|
+
Marks: "bold" | "italic";
|
634
|
+
Commands: {
|
635
|
+
insertText: [{
|
636
|
+
text: string;
|
637
|
+
from?: number;
|
638
|
+
to?: number;
|
639
|
+
}];
|
640
|
+
insertNode: [options: InsertNodeOptions];
|
641
|
+
removeNode: [options: RemoveNodeOptions];
|
642
|
+
wrap: [WrapOptions];
|
643
|
+
setBlockType: [options: SetBlockTypeOptions];
|
644
|
+
setNodeAttrs: [options: SetNodeAttrsOptions];
|
645
|
+
selectAll: [];
|
646
|
+
addMark: [options: AddMarkOptions];
|
647
|
+
removeMark: [options: RemoveMarkOptions];
|
648
|
+
unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
|
649
|
+
unsetMark: [options?: UnsetMarkOptions | undefined];
|
650
|
+
undo: [];
|
651
|
+
redo: [];
|
652
|
+
};
|
715
653
|
}>;
|
716
654
|
|
717
655
|
/**
|
@@ -838,7 +776,7 @@ declare type DoubleClickHandler = (view: EditorView, pos: number, event: MouseEv
|
|
838
776
|
export { DoubleClickHandler }
|
839
777
|
export { DoubleClickHandler as DoubleClickHandler_alias_1 }
|
840
778
|
|
841
|
-
declare type DoubleClickOnHandler = (view: EditorView, pos: number, node:
|
779
|
+
declare type DoubleClickOnHandler = (view: EditorView, pos: number, node: Node_2, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
|
842
780
|
export { DoubleClickOnHandler }
|
843
781
|
export { DoubleClickOnHandler as DoubleClickOnHandler_alias_1 }
|
844
782
|
|
@@ -1012,14 +950,21 @@ export { elementFromNode as elementFromNode_alias_1 }
|
|
1012
950
|
*
|
1013
951
|
* @public
|
1014
952
|
*/
|
1015
|
-
declare function expandMark(options:
|
953
|
+
declare function expandMark(options: ExpandMarkOptions): Command;
|
954
|
+
export { expandMark }
|
955
|
+
export { expandMark as expandMark_alias_1 }
|
956
|
+
|
957
|
+
/**
|
958
|
+
* @public
|
959
|
+
*/
|
960
|
+
declare interface ExpandMarkOptions {
|
1016
961
|
/**
|
1017
962
|
* The type of the mark to expand.
|
1018
963
|
*/
|
1019
964
|
type: string | MarkType;
|
1020
|
-
}
|
1021
|
-
export {
|
1022
|
-
export {
|
965
|
+
}
|
966
|
+
export { ExpandMarkOptions }
|
967
|
+
export { ExpandMarkOptions as ExpandMarkOptions_alias_1 }
|
1023
968
|
|
1024
969
|
/**
|
1025
970
|
* @public
|
@@ -1255,17 +1200,7 @@ export { htmlFromNode as htmlFromNode_alias_1 }
|
|
1255
1200
|
*
|
1256
1201
|
* @public
|
1257
1202
|
*/
|
1258
|
-
declare function insertNode(options:
|
1259
|
-
node: ProseMirrorNode;
|
1260
|
-
pos?: number;
|
1261
|
-
type?: undefined;
|
1262
|
-
attrs?: undefined;
|
1263
|
-
} | {
|
1264
|
-
node?: undefined;
|
1265
|
-
pos?: number;
|
1266
|
-
type: string;
|
1267
|
-
attrs?: Attrs;
|
1268
|
-
}): Command;
|
1203
|
+
declare function insertNode(options: InsertNodeOptions): Command;
|
1269
1204
|
export { insertNode }
|
1270
1205
|
export { insertNode as insertNode_alias_1 }
|
1271
1206
|
|
@@ -1274,6 +1209,31 @@ export declare function insertNodeAction({ node, pos, }: {
|
|
1274
1209
|
pos?: number;
|
1275
1210
|
}): Action;
|
1276
1211
|
|
1212
|
+
/**
|
1213
|
+
* @public
|
1214
|
+
*/
|
1215
|
+
declare interface InsertNodeOptions {
|
1216
|
+
/**
|
1217
|
+
* The node to insert. Either this or `type` must be provided.
|
1218
|
+
*/
|
1219
|
+
node?: ProseMirrorNode;
|
1220
|
+
/**
|
1221
|
+
* The type of the node to insert. Either this or `node` must be provided.
|
1222
|
+
*/
|
1223
|
+
type?: string | NodeType;
|
1224
|
+
/**
|
1225
|
+
* When `type` is provided, the attributes of the node to insert.
|
1226
|
+
*/
|
1227
|
+
attrs?: Attrs;
|
1228
|
+
/**
|
1229
|
+
* The position to insert the node at. By default it will be the anchor
|
1230
|
+
* position of current selection.
|
1231
|
+
*/
|
1232
|
+
pos?: number;
|
1233
|
+
}
|
1234
|
+
export { InsertNodeOptions }
|
1235
|
+
export { InsertNodeOptions as InsertNodeOptions_alias_1 }
|
1236
|
+
|
1277
1237
|
/**
|
1278
1238
|
* Returns a command that inserts the given text.
|
1279
1239
|
*
|
@@ -1299,6 +1259,15 @@ declare const isApple: boolean;
|
|
1299
1259
|
export { isApple }
|
1300
1260
|
export { isApple as isApple_alias_1 }
|
1301
1261
|
|
1262
|
+
/**
|
1263
|
+
* Whether the selection is an empty text selection at the start of a block.
|
1264
|
+
*
|
1265
|
+
* @internal
|
1266
|
+
*/
|
1267
|
+
declare function isAtBlockStart(state: EditorState, view?: EditorView): ResolvedPos | null;
|
1268
|
+
export { isAtBlockStart }
|
1269
|
+
export { isAtBlockStart as isAtBlockStart_alias_1 }
|
1270
|
+
|
1302
1271
|
export declare function isElement(value: unknown): value is Element;
|
1303
1272
|
|
1304
1273
|
/**
|
@@ -1734,7 +1703,14 @@ export { ProseKitError as ProseKitError_alias_1 }
|
|
1734
1703
|
*
|
1735
1704
|
* @public
|
1736
1705
|
*/
|
1737
|
-
declare function removeMark(options:
|
1706
|
+
declare function removeMark(options: RemoveMarkOptions): Command;
|
1707
|
+
export { removeMark }
|
1708
|
+
export { removeMark as removeMark_alias_1 }
|
1709
|
+
|
1710
|
+
/**
|
1711
|
+
* @public
|
1712
|
+
*/
|
1713
|
+
declare interface RemoveMarkOptions {
|
1738
1714
|
/**
|
1739
1715
|
* The type of the mark to remove.
|
1740
1716
|
*/
|
@@ -1751,16 +1727,23 @@ declare function removeMark(options: {
|
|
1751
1727
|
* The end position of the document. By default it will be the end position of current selection.
|
1752
1728
|
*/
|
1753
1729
|
to?: number;
|
1754
|
-
}
|
1755
|
-
export {
|
1756
|
-
export {
|
1730
|
+
}
|
1731
|
+
export { RemoveMarkOptions }
|
1732
|
+
export { RemoveMarkOptions as RemoveMarkOptions_alias_1 }
|
1757
1733
|
|
1758
1734
|
/**
|
1759
1735
|
* Returns a command to remove the nearest ancestor node of a specific type from the current position.
|
1760
1736
|
*
|
1761
1737
|
* @public
|
1762
1738
|
*/
|
1763
|
-
declare function removeNode(options:
|
1739
|
+
declare function removeNode(options: RemoveNodeOptions): Command;
|
1740
|
+
export { removeNode }
|
1741
|
+
export { removeNode as removeNode_alias_1 }
|
1742
|
+
|
1743
|
+
/**
|
1744
|
+
* @public
|
1745
|
+
*/
|
1746
|
+
declare interface RemoveNodeOptions {
|
1764
1747
|
/**
|
1765
1748
|
* The type of the node to remove.
|
1766
1749
|
*/
|
@@ -1769,9 +1752,9 @@ declare function removeNode(options: {
|
|
1769
1752
|
* The document position to start searching node. By default it will be the anchor position of current selection.
|
1770
1753
|
*/
|
1771
1754
|
pos?: number;
|
1772
|
-
}
|
1773
|
-
export {
|
1774
|
-
export {
|
1755
|
+
}
|
1756
|
+
export { RemoveNodeOptions }
|
1757
|
+
export { RemoveNodeOptions as RemoveNodeOptions_alias_1 }
|
1775
1758
|
|
1776
1759
|
export declare const rootFacet: Facet<RootPayload, RootOutput>;
|
1777
1760
|
|
@@ -1825,21 +1808,35 @@ export { SelectionJSON as SelectionJSON_alias_1 }
|
|
1825
1808
|
*
|
1826
1809
|
* @public
|
1827
1810
|
*/
|
1828
|
-
declare function setBlockType(options:
|
1811
|
+
declare function setBlockType(options: SetBlockTypeOptions): Command;
|
1812
|
+
export { setBlockType }
|
1813
|
+
export { setBlockType as setBlockType_alias_1 }
|
1814
|
+
|
1815
|
+
/**
|
1816
|
+
* @public
|
1817
|
+
*/
|
1818
|
+
declare interface SetBlockTypeOptions {
|
1829
1819
|
type: NodeType | string;
|
1830
1820
|
attrs?: Attrs | null;
|
1831
1821
|
from?: number;
|
1832
1822
|
to?: number;
|
1833
|
-
}
|
1834
|
-
export {
|
1835
|
-
export {
|
1823
|
+
}
|
1824
|
+
export { SetBlockTypeOptions }
|
1825
|
+
export { SetBlockTypeOptions as SetBlockTypeOptions_alias_1 }
|
1836
1826
|
|
1837
1827
|
/**
|
1838
1828
|
* Returns a command that set the attributes of the current node.
|
1839
1829
|
*
|
1840
1830
|
* @public
|
1841
1831
|
*/
|
1842
|
-
declare function setNodeAttrs(options:
|
1832
|
+
declare function setNodeAttrs(options: SetNodeAttrsOptions): Command;
|
1833
|
+
export { setNodeAttrs }
|
1834
|
+
export { setNodeAttrs as setNodeAttrs_alias_1 }
|
1835
|
+
|
1836
|
+
/**
|
1837
|
+
* @public
|
1838
|
+
*/
|
1839
|
+
declare interface SetNodeAttrsOptions {
|
1843
1840
|
/**
|
1844
1841
|
* The type of node to set the attributes of.
|
1845
1842
|
*
|
@@ -1855,9 +1852,9 @@ declare function setNodeAttrs(options: {
|
|
1855
1852
|
* containing the current selection.
|
1856
1853
|
*/
|
1857
1854
|
pos?: number;
|
1858
|
-
}
|
1859
|
-
export {
|
1860
|
-
export {
|
1855
|
+
}
|
1856
|
+
export { SetNodeAttrsOptions }
|
1857
|
+
export { SetNodeAttrsOptions as SetNodeAttrsOptions_alias_1 }
|
1861
1858
|
|
1862
1859
|
export declare function setSelectionAround(tr: Transaction, pos: number): void;
|
1863
1860
|
|
@@ -1871,6 +1868,46 @@ export declare type Setter<T> = (value: T) => void;
|
|
1871
1868
|
*/
|
1872
1869
|
export declare function setupEditorExtension<E extends Extension>(options: EditorOptions<E>): E;
|
1873
1870
|
|
1871
|
+
/**
|
1872
|
+
* @internal
|
1873
|
+
*/
|
1874
|
+
export declare function setupTest(): {
|
1875
|
+
editor: TestEditor<Extension<{
|
1876
|
+
Nodes: "text" | "doc" | "paragraph" | "heading";
|
1877
|
+
Marks: "bold" | "italic";
|
1878
|
+
Commands: {
|
1879
|
+
insertText: [{
|
1880
|
+
text: string;
|
1881
|
+
from?: number;
|
1882
|
+
to?: number;
|
1883
|
+
}];
|
1884
|
+
insertNode: [options: InsertNodeOptions];
|
1885
|
+
removeNode: [options: RemoveNodeOptions];
|
1886
|
+
wrap: [WrapOptions];
|
1887
|
+
setBlockType: [options: SetBlockTypeOptions];
|
1888
|
+
setNodeAttrs: [options: SetNodeAttrsOptions];
|
1889
|
+
selectAll: [];
|
1890
|
+
addMark: [options: AddMarkOptions];
|
1891
|
+
removeMark: [options: RemoveMarkOptions];
|
1892
|
+
unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
|
1893
|
+
unsetMark: [options?: UnsetMarkOptions | undefined];
|
1894
|
+
undo: [];
|
1895
|
+
redo: [];
|
1896
|
+
};
|
1897
|
+
}>>;
|
1898
|
+
n: Record<"text" | "doc" | "paragraph" | "heading", NodeBuilder>;
|
1899
|
+
m: Record<"bold" | "italic", MarkBuilder>;
|
1900
|
+
};
|
1901
|
+
|
1902
|
+
/**
|
1903
|
+
* @internal
|
1904
|
+
*/
|
1905
|
+
export declare function setupTestFromExtension<E extends Extension>(extension: E): {
|
1906
|
+
editor: TestEditor<E>;
|
1907
|
+
n: Record<ExtractNodes<E>, NodeBuilder>;
|
1908
|
+
m: Record<ExtractMarks<E>, MarkBuilder>;
|
1909
|
+
};
|
1910
|
+
|
1874
1911
|
/**
|
1875
1912
|
* @internal
|
1876
1913
|
*/
|
@@ -1984,33 +2021,53 @@ export declare type ToCommandCreators<T extends CommandTyping> = {
|
|
1984
2021
|
*
|
1985
2022
|
* @public
|
1986
2023
|
*/
|
1987
|
-
declare function toggleMark({ type, attrs
|
1988
|
-
type: string | MarkType;
|
1989
|
-
attrs?: Attrs | null;
|
1990
|
-
}): Command;
|
2024
|
+
declare function toggleMark({ type, attrs }: ToggleMarkOptions): Command;
|
1991
2025
|
export { toggleMark }
|
1992
2026
|
export { toggleMark as toggleMark_alias_1 }
|
1993
2027
|
|
2028
|
+
/**
|
2029
|
+
* @public
|
2030
|
+
*/
|
2031
|
+
declare interface ToggleMarkOptions {
|
2032
|
+
type: string | MarkType;
|
2033
|
+
attrs?: Attrs | null;
|
2034
|
+
}
|
2035
|
+
export { ToggleMarkOptions }
|
2036
|
+
export { ToggleMarkOptions as ToggleMarkOptions_alias_1 }
|
2037
|
+
|
1994
2038
|
/**
|
1995
2039
|
* Returns a command that set the selected textblocks to the given node type
|
1996
2040
|
* with the given attributes.
|
1997
2041
|
*
|
1998
2042
|
* @public
|
1999
2043
|
*/
|
2000
|
-
declare function toggleNode({ type, attrs
|
2001
|
-
type: string | NodeType;
|
2002
|
-
attrs?: Attrs | null;
|
2003
|
-
}): Command;
|
2044
|
+
declare function toggleNode({ type, attrs }: ToggleNodeOptions): Command;
|
2004
2045
|
export { toggleNode }
|
2005
2046
|
export { toggleNode as toggleNode_alias_1 }
|
2006
2047
|
|
2048
|
+
/**
|
2049
|
+
* @public
|
2050
|
+
*/
|
2051
|
+
declare interface ToggleNodeOptions {
|
2052
|
+
/**
|
2053
|
+
* The type of the node to toggle.
|
2054
|
+
*/
|
2055
|
+
type: string | NodeType;
|
2056
|
+
/**
|
2057
|
+
* The attributes of the node to toggle.
|
2058
|
+
*/
|
2059
|
+
attrs?: Attrs | null;
|
2060
|
+
}
|
2061
|
+
export { ToggleNodeOptions }
|
2062
|
+
export { ToggleNodeOptions as ToggleNodeOptions_alias_1 }
|
2063
|
+
|
2007
2064
|
export declare function toReversed<T>(arr: T[]): T[];
|
2008
2065
|
|
2009
2066
|
declare type TripleClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
|
2010
2067
|
export { TripleClickHandler }
|
2011
2068
|
export { TripleClickHandler as TripleClickHandler_alias_1 }
|
2012
2069
|
|
2013
|
-
declare type TripleClickOnHandler = (view: EditorView, pos: number, node:
|
2070
|
+
declare type TripleClickOnHandler = (view: EditorView, pos: number, node: Node_2, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
|
2014
2071
|
export { TripleClickOnHandler }
|
2015
2072
|
export { TripleClickOnHandler as TripleClickOnHandler_alias_1 }
|
2016
2073
|
|
@@ -2087,6 +2144,57 @@ declare type UnmountHandler = () => void;
|
|
2087
2144
|
export { UnmountHandler }
|
2088
2145
|
export { UnmountHandler as UnmountHandler_alias_1 }
|
2089
2146
|
|
2147
|
+
/**
|
2148
|
+
* Returns a command that set the type of all textblocks between the given range
|
2149
|
+
* to the default type (usually `paragraph`).
|
2150
|
+
*
|
2151
|
+
* @public
|
2152
|
+
*/
|
2153
|
+
declare function unsetBlockType(options?: UnsetBlockTypeOptions): Command;
|
2154
|
+
export { unsetBlockType }
|
2155
|
+
export { unsetBlockType as unsetBlockType_alias_1 }
|
2156
|
+
|
2157
|
+
/**
|
2158
|
+
* @public
|
2159
|
+
*/
|
2160
|
+
declare interface UnsetBlockTypeOptions {
|
2161
|
+
/**
|
2162
|
+
* The start position of the document. By default it will be the start position of current selection.
|
2163
|
+
*/
|
2164
|
+
from?: number;
|
2165
|
+
/**
|
2166
|
+
* The end position of the document. By default it will be the end position of current selection.
|
2167
|
+
*/
|
2168
|
+
to?: number;
|
2169
|
+
}
|
2170
|
+
export { UnsetBlockTypeOptions }
|
2171
|
+
export { UnsetBlockTypeOptions as UnsetBlockTypeOptions_alias_1 }
|
2172
|
+
|
2173
|
+
/**
|
2174
|
+
* Returns a command that removes all marks.
|
2175
|
+
*
|
2176
|
+
* @public
|
2177
|
+
*/
|
2178
|
+
declare function unsetMark(options?: UnsetMarkOptions): Command;
|
2179
|
+
export { unsetMark }
|
2180
|
+
export { unsetMark as unsetMark_alias_1 }
|
2181
|
+
|
2182
|
+
/**
|
2183
|
+
* @public
|
2184
|
+
*/
|
2185
|
+
declare interface UnsetMarkOptions {
|
2186
|
+
/**
|
2187
|
+
* The start position of the document. By default it will be the start position of current selection.
|
2188
|
+
*/
|
2189
|
+
from?: number;
|
2190
|
+
/**
|
2191
|
+
* The end position of the document. By default it will be the end position of current selection.
|
2192
|
+
*/
|
2193
|
+
to?: number;
|
2194
|
+
}
|
2195
|
+
export { UnsetMarkOptions }
|
2196
|
+
export { UnsetMarkOptions as UnsetMarkOptions_alias_1 }
|
2197
|
+
|
2090
2198
|
/**
|
2091
2199
|
* A function that is called when the editor state is updated.
|
2092
2200
|
*
|
@@ -2134,10 +2242,19 @@ export { withSkipCodeBlock as withSkipCodeBlock_alias_1 }
|
|
2134
2242
|
*
|
2135
2243
|
* @public
|
2136
2244
|
*/
|
2137
|
-
|
2245
|
+
declare function wrap({ nodeType, attrs }: WrapOptions): Command;
|
2246
|
+
export { wrap }
|
2247
|
+
export { wrap as wrap_alias_1 }
|
2248
|
+
|
2249
|
+
/**
|
2250
|
+
* @public
|
2251
|
+
*/
|
2252
|
+
declare interface WrapOptions {
|
2138
2253
|
nodeType: NodeType;
|
2139
2254
|
attrs?: Attrs | null;
|
2140
|
-
}
|
2255
|
+
}
|
2256
|
+
export { WrapOptions }
|
2257
|
+
export { WrapOptions as WrapOptions_alias_1 }
|
2141
2258
|
|
2142
2259
|
export declare function zip<T, P>(a: T[], b: P[]): [T, P][];
|
2143
2260
|
|
package/dist/prosekit-core.d.ts
CHANGED
@@ -1,12 +1,27 @@
|
|
1
1
|
export { addMark } from './_tsup-dts-rollup';
|
2
|
+
export { AddMarkOptions } from './_tsup-dts-rollup';
|
2
3
|
export { expandMark } from './_tsup-dts-rollup';
|
4
|
+
export { ExpandMarkOptions } from './_tsup-dts-rollup';
|
3
5
|
export { insertNode } from './_tsup-dts-rollup';
|
6
|
+
export { InsertNodeOptions } from './_tsup-dts-rollup';
|
4
7
|
export { removeMark } from './_tsup-dts-rollup';
|
8
|
+
export { RemoveMarkOptions } from './_tsup-dts-rollup';
|
5
9
|
export { removeNode } from './_tsup-dts-rollup';
|
10
|
+
export { RemoveNodeOptions } from './_tsup-dts-rollup';
|
6
11
|
export { setBlockType } from './_tsup-dts-rollup';
|
12
|
+
export { SetBlockTypeOptions } from './_tsup-dts-rollup';
|
7
13
|
export { setNodeAttrs } from './_tsup-dts-rollup';
|
14
|
+
export { SetNodeAttrsOptions } from './_tsup-dts-rollup';
|
8
15
|
export { toggleMark } from './_tsup-dts-rollup';
|
16
|
+
export { ToggleMarkOptions } from './_tsup-dts-rollup';
|
9
17
|
export { toggleNode } from './_tsup-dts-rollup';
|
18
|
+
export { ToggleNodeOptions } from './_tsup-dts-rollup';
|
19
|
+
export { unsetBlockType } from './_tsup-dts-rollup';
|
20
|
+
export { UnsetBlockTypeOptions } from './_tsup-dts-rollup';
|
21
|
+
export { unsetMark } from './_tsup-dts-rollup';
|
22
|
+
export { UnsetMarkOptions } from './_tsup-dts-rollup';
|
23
|
+
export { wrap } from './_tsup-dts-rollup';
|
24
|
+
export { WrapOptions } from './_tsup-dts-rollup';
|
10
25
|
export { MarkBuilder } from './_tsup-dts-rollup';
|
11
26
|
export { NodeBuilder } from './_tsup-dts-rollup';
|
12
27
|
export { Editor } from './_tsup-dts-rollup';
|
@@ -58,11 +73,11 @@ export { MountHandler } from './_tsup-dts-rollup';
|
|
58
73
|
export { UnmountHandler } from './_tsup-dts-rollup';
|
59
74
|
export { UpdateHandler } from './_tsup-dts-rollup';
|
60
75
|
export { defineHistory } from './_tsup-dts-rollup';
|
61
|
-
export { defineBaseKeymap } from './_tsup-dts-rollup';
|
62
76
|
export { defineKeymap } from './_tsup-dts-rollup';
|
63
77
|
export { keymapFacet } from './_tsup-dts-rollup';
|
64
78
|
export { Keymap } from './_tsup-dts-rollup';
|
65
79
|
export { KeymapPayload } from './_tsup-dts-rollup';
|
80
|
+
export { defineBaseKeymap } from './_tsup-dts-rollup';
|
66
81
|
export { defineMarkAttr } from './_tsup-dts-rollup';
|
67
82
|
export { defineMarkSpec } from './_tsup-dts-rollup';
|
68
83
|
export { MarkAttrOptions } from './_tsup-dts-rollup';
|
@@ -110,6 +125,7 @@ export { isApple } from './_tsup-dts-rollup';
|
|
110
125
|
export { _getId } from './_tsup-dts-rollup';
|
111
126
|
export { getMarkType } from './_tsup-dts-rollup';
|
112
127
|
export { getNodeType } from './_tsup-dts-rollup';
|
128
|
+
export { isAtBlockStart } from './_tsup-dts-rollup';
|
113
129
|
export { isInCodeBlock } from './_tsup-dts-rollup';
|
114
130
|
export { isMarkAbsent } from './_tsup-dts-rollup';
|
115
131
|
export { isMarkActive } from './_tsup-dts-rollup';
|
package/dist/prosekit-core.js
CHANGED
@@ -94,7 +94,7 @@ function insertNode(options) {
|
|
94
94
|
assert(node, "You must provide either a node or a type");
|
95
95
|
let insertPos = insertPoint(
|
96
96
|
state.doc,
|
97
|
-
(_a = options.pos) != null ? _a : state.selection.
|
97
|
+
(_a = options.pos) != null ? _a : state.selection.anchor,
|
98
98
|
node.type
|
99
99
|
);
|
100
100
|
if (insertPos == null) return !1;
|
@@ -268,10 +268,7 @@ function baseToggleMark(markType, attrs = null, options) {
|
|
268
268
|
return !0;
|
269
269
|
};
|
270
270
|
}
|
271
|
-
function toggleMark({
|
272
|
-
type,
|
273
|
-
attrs
|
274
|
-
}) {
|
271
|
+
function toggleMark({ type, attrs }) {
|
275
272
|
return (state, dispatch, view) => baseToggleMark(getMarkType(state.schema, type), attrs, {
|
276
273
|
removeWhenPresent: !1
|
277
274
|
})(state, dispatch, view);
|
@@ -281,10 +278,7 @@ function toggleMark({
|
|
281
278
|
import { setBlockType as setBlockType2 } from "@prosekit/pm/commands";
|
282
279
|
import "@prosekit/pm/model";
|
283
280
|
import "@prosekit/pm/state";
|
284
|
-
function toggleNode({
|
285
|
-
type,
|
286
|
-
attrs
|
287
|
-
}) {
|
281
|
+
function toggleNode({ type, attrs }) {
|
288
282
|
return (state, dispatch, view) => {
|
289
283
|
if (isNodeActive(state, type, attrs)) {
|
290
284
|
let defaultType = state.schema.topNodeType.contentMatch.defaultType;
|
@@ -296,6 +290,63 @@ function toggleNode({
|
|
296
290
|
};
|
297
291
|
}
|
298
292
|
|
293
|
+
// src/commands/unset-block-type.ts
|
294
|
+
import { Fragment, Slice } from "@prosekit/pm/model";
|
295
|
+
import "@prosekit/pm/state";
|
296
|
+
import { ReplaceAroundStep } from "@prosekit/pm/transform";
|
297
|
+
function unsetBlockType(options) {
|
298
|
+
return (state, dispatch) => {
|
299
|
+
var _a, _b;
|
300
|
+
let from = (_a = options == null ? void 0 : options.from) != null ? _a : state.selection.from, to = (_b = options == null ? void 0 : options.to) != null ? _b : state.selection.to;
|
301
|
+
if (from > to) return !1;
|
302
|
+
let tr = state.tr;
|
303
|
+
return unsetTextBlockType(tr, from, to) ? (dispatch == null || dispatch(tr), !0) : !1;
|
304
|
+
};
|
305
|
+
}
|
306
|
+
function unsetTextBlockType(tr, from, to) {
|
307
|
+
let mapFrom = tr.steps.length;
|
308
|
+
return tr.doc.nodesBetween(from, to, (node, pos, parent, index) => {
|
309
|
+
if (!parent || !node.isTextblock) return !0;
|
310
|
+
let defaultType = parent.contentMatchAt(index).defaultType;
|
311
|
+
if (defaultType && defaultType.isTextblock && node.type !== defaultType && defaultType.validContent(node.content)) {
|
312
|
+
let mapping = tr.mapping.slice(mapFrom), start = mapping.map(pos, 1), end = mapping.map(pos + node.nodeSize, 1), step = new ReplaceAroundStep(
|
313
|
+
start,
|
314
|
+
end,
|
315
|
+
start + 1,
|
316
|
+
end - 1,
|
317
|
+
new Slice(Fragment.from(defaultType.create()), 0, 0),
|
318
|
+
1,
|
319
|
+
!0
|
320
|
+
);
|
321
|
+
tr.step(step);
|
322
|
+
}
|
323
|
+
return !1;
|
324
|
+
}), tr.steps.length > mapFrom;
|
325
|
+
}
|
326
|
+
|
327
|
+
// src/commands/unset-mark.ts
|
328
|
+
import "@prosekit/pm/state";
|
329
|
+
function unsetMark(options) {
|
330
|
+
return (state, dispatch) => {
|
331
|
+
var _a, _b;
|
332
|
+
let from = (_a = options == null ? void 0 : options.from) != null ? _a : state.selection.from, to = (_b = options == null ? void 0 : options.to) != null ? _b : state.selection.to;
|
333
|
+
return from > to ? !1 : (dispatch == null || dispatch(state.tr.removeMark(from, to)), !0);
|
334
|
+
};
|
335
|
+
}
|
336
|
+
|
337
|
+
// src/commands/wrap.ts
|
338
|
+
import "@prosekit/pm/model";
|
339
|
+
import "@prosekit/pm/state";
|
340
|
+
import { findWrapping } from "@prosekit/pm/transform";
|
341
|
+
function wrap({ nodeType, attrs }) {
|
342
|
+
return (state, dispatch) => {
|
343
|
+
let { $from, $to } = state.selection, range = $from.blockRange($to);
|
344
|
+
if (!range) return !1;
|
345
|
+
let wrapping = findWrapping(range, nodeType, attrs);
|
346
|
+
return wrapping ? (dispatch == null || dispatch(state.tr.wrap(range, wrapping)), !0) : !1;
|
347
|
+
};
|
348
|
+
}
|
349
|
+
|
299
350
|
// src/editor/with-priority.ts
|
300
351
|
function withPriority(extension, priority) {
|
301
352
|
let result = union(extension);
|
@@ -317,22 +368,6 @@ function selectAll() {
|
|
317
368
|
return (state, dispatch) => (dispatch == null || dispatch(state.tr.setSelection(new AllSelection(state.doc))), !0);
|
318
369
|
}
|
319
370
|
|
320
|
-
// src/commands/wrap.ts
|
321
|
-
import "@prosekit/pm/model";
|
322
|
-
import "@prosekit/pm/state";
|
323
|
-
import { findWrapping } from "@prosekit/pm/transform";
|
324
|
-
function wrap({
|
325
|
-
nodeType,
|
326
|
-
attrs
|
327
|
-
}) {
|
328
|
-
return (state, dispatch) => {
|
329
|
-
let { $from, $to } = state.selection, range = $from.blockRange($to);
|
330
|
-
if (!range) return !1;
|
331
|
-
let wrapping = findWrapping(range, nodeType, attrs);
|
332
|
-
return wrapping ? (dispatch == null || dispatch(state.tr.wrap(range, wrapping)), !0) : !1;
|
333
|
-
};
|
334
|
-
}
|
335
|
-
|
336
371
|
// src/facets/command.ts
|
337
372
|
var commandFacet = defineFacet({
|
338
373
|
reducer: (inputs) => ({ commands: Object.assign({}, ...inputs) }),
|
@@ -354,7 +389,9 @@ function defineBaseCommands() {
|
|
354
389
|
setNodeAttrs,
|
355
390
|
selectAll,
|
356
391
|
addMark,
|
357
|
-
removeMark
|
392
|
+
removeMark,
|
393
|
+
unsetBlockType,
|
394
|
+
unsetMark
|
358
395
|
});
|
359
396
|
}
|
360
397
|
|
@@ -699,33 +736,12 @@ import { history, redo, undo } from "@prosekit/pm/history";
|
|
699
736
|
var isApple = typeof navigator != "undefined" ? /Mac|iP(hone|[ao]d)/.test(navigator.platform) : !1;
|
700
737
|
|
701
738
|
// src/extensions/keymap.ts
|
702
|
-
import {
|
703
|
-
baseKeymap,
|
704
|
-
chainCommands,
|
705
|
-
createParagraphNear,
|
706
|
-
liftEmptyBlock,
|
707
|
-
newlineInCode
|
708
|
-
} from "@prosekit/pm/commands";
|
739
|
+
import { chainCommands } from "@prosekit/pm/commands";
|
709
740
|
import { keydownHandler } from "@prosekit/pm/keymap";
|
710
741
|
import { Plugin as Plugin2, PluginKey as PluginKey4 } from "@prosekit/pm/state";
|
711
|
-
import { splitSplittableBlock } from "prosemirror-splittable";
|
712
|
-
var customBaseKeymap = {
|
713
|
-
...baseKeymap,
|
714
|
-
Enter: chainCommands(
|
715
|
-
newlineInCode,
|
716
|
-
createParagraphNear,
|
717
|
-
liftEmptyBlock,
|
718
|
-
splitSplittableBlock
|
719
|
-
)
|
720
|
-
};
|
721
742
|
function defineKeymap(keymap) {
|
722
743
|
return defineFacetPayload(keymapFacet, [keymap]);
|
723
744
|
}
|
724
|
-
function defineBaseKeymap(options) {
|
725
|
-
var _a;
|
726
|
-
let priority = (_a = options == null ? void 0 : options.priority) != null ? _a : 1 /* low */;
|
727
|
-
return withPriority(defineKeymap(customBaseKeymap), priority);
|
728
|
-
}
|
729
745
|
var keymapFacet = defineFacet({
|
730
746
|
reduce: () => {
|
731
747
|
let handler, handlerWrapper = (view, event) => handler ? handler(view, event) : !1, plugin = new Plugin2({
|
@@ -772,6 +788,38 @@ function defineHistory() {
|
|
772
788
|
]);
|
773
789
|
}
|
774
790
|
|
791
|
+
// src/extensions/keymap-base.ts
|
792
|
+
import {
|
793
|
+
baseKeymap,
|
794
|
+
chainCommands as chainCommands2,
|
795
|
+
createParagraphNear,
|
796
|
+
deleteSelection,
|
797
|
+
joinTextblockBackward,
|
798
|
+
liftEmptyBlock,
|
799
|
+
newlineInCode,
|
800
|
+
selectNodeBackward
|
801
|
+
} from "@prosekit/pm/commands";
|
802
|
+
import { splitSplittableBlock } from "prosemirror-splittable";
|
803
|
+
var customEnter = chainCommands2(
|
804
|
+
newlineInCode,
|
805
|
+
createParagraphNear,
|
806
|
+
liftEmptyBlock,
|
807
|
+
splitSplittableBlock
|
808
|
+
), customBackspace = chainCommands2(
|
809
|
+
deleteSelection,
|
810
|
+
joinTextblockBackward,
|
811
|
+
selectNodeBackward
|
812
|
+
), customBaseKeymap = {
|
813
|
+
...baseKeymap,
|
814
|
+
Enter: customEnter,
|
815
|
+
Backspace: customBackspace
|
816
|
+
};
|
817
|
+
function defineBaseKeymap(options) {
|
818
|
+
var _a;
|
819
|
+
let priority = (_a = options == null ? void 0 : options.priority) != null ? _a : 1 /* low */;
|
820
|
+
return withPriority(defineKeymap(customBaseKeymap), priority);
|
821
|
+
}
|
822
|
+
|
775
823
|
// src/extensions/mark-spec.ts
|
776
824
|
function defineMarkSpec(options) {
|
777
825
|
return defineFacetPayload(markSpecFacet, [[options, void 0]]);
|
@@ -955,6 +1003,12 @@ function getId() {
|
|
955
1003
|
return id = (id + 1) % Number.MAX_SAFE_INTEGER, `id:${id}`;
|
956
1004
|
}
|
957
1005
|
|
1006
|
+
// src/utils/is-at-block-start.ts
|
1007
|
+
function isAtBlockStart(state, view) {
|
1008
|
+
let { $cursor } = state.selection;
|
1009
|
+
return !$cursor || (view ? !view.endOfTextblock("backward", state) : $cursor.parentOffset > 0) ? null : $cursor;
|
1010
|
+
}
|
1011
|
+
|
958
1012
|
// src/utils/is-in-code-block.ts
|
959
1013
|
function isCodeBlockType(type) {
|
960
1014
|
return type.spec.code && type.isBlock;
|
@@ -1036,6 +1090,7 @@ export {
|
|
1036
1090
|
insertNode,
|
1037
1091
|
isAllSelection,
|
1038
1092
|
isApple,
|
1093
|
+
isAtBlockStart,
|
1039
1094
|
isInCodeBlock,
|
1040
1095
|
isMark,
|
1041
1096
|
isMarkAbsent,
|
@@ -1060,6 +1115,9 @@ export {
|
|
1060
1115
|
toggleMark,
|
1061
1116
|
toggleNode,
|
1062
1117
|
union,
|
1118
|
+
unsetBlockType,
|
1119
|
+
unsetMark,
|
1063
1120
|
withPriority,
|
1064
|
-
withSkipCodeBlock
|
1121
|
+
withSkipCodeBlock,
|
1122
|
+
wrap
|
1065
1123
|
};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.7.
|
4
|
+
"version": "0.7.2",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -49,7 +49,7 @@
|
|
49
49
|
"devDependencies": {
|
50
50
|
"tsup": "^8.1.0",
|
51
51
|
"typescript": "^5.5.3",
|
52
|
-
"vitest": "^2.0.
|
52
|
+
"vitest": "^2.0.2",
|
53
53
|
"@prosekit/dev": "0.0.0"
|
54
54
|
},
|
55
55
|
"scripts": {
|