@prosekit/core 0.6.0 → 0.6.1
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 +19 -6
- package/dist/prosekit-core.d.ts +1 -1
- package/dist/prosekit-core.js +12 -12
- package/package.json +1 -1
@@ -462,10 +462,11 @@ export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
|
|
462
462
|
* Add undo/redo history to the editor.
|
463
463
|
*/
|
464
464
|
declare function defineHistory(): Extension< {
|
465
|
-
Nodes:
|
466
|
-
Marks:
|
465
|
+
Nodes: never;
|
466
|
+
Marks: never;
|
467
467
|
Commands: {
|
468
|
-
|
468
|
+
undo: [];
|
469
|
+
redo: [];
|
469
470
|
};
|
470
471
|
}>;
|
471
472
|
export { defineHistory }
|
@@ -936,7 +937,7 @@ export { ExtractNodes as ExtractNodes_alias_1 }
|
|
936
937
|
/**
|
937
938
|
* @internal
|
938
939
|
*/
|
939
|
-
export declare type ExtractTyping<E extends Extension> = E extends Extension<infer
|
940
|
+
export declare type ExtractTyping<E extends Extension> = E extends Extension<ExtensionTyping<infer N, infer M, infer C>> ? ExtensionTyping<PickStringLiteral<N>, PickStringLiteral<M>, PickKnownCommandTyping<C>> : never;
|
940
941
|
|
941
942
|
/**
|
942
943
|
* @internal
|
@@ -1501,6 +1502,18 @@ export { PasteHandler as PasteHandler_alias_1 }
|
|
1501
1502
|
*/
|
1502
1503
|
export declare type Payloads<T> = Tuple5<T[]>;
|
1503
1504
|
|
1505
|
+
/**
|
1506
|
+
* @internal
|
1507
|
+
*/
|
1508
|
+
export declare type PickKnownCommandTyping<T extends CommandTyping> = [
|
1509
|
+
CommandTyping
|
1510
|
+
] extends [T] ? never : T;
|
1511
|
+
|
1512
|
+
/**
|
1513
|
+
* @internal
|
1514
|
+
*/
|
1515
|
+
export declare type PickStringLiteral<T extends string> = [string] extends [T] ? never : T;
|
1516
|
+
|
1504
1517
|
/**
|
1505
1518
|
* @internal
|
1506
1519
|
*/
|
@@ -1788,14 +1801,14 @@ export declare type Tuple5<T> = [T, T, T, T, T];
|
|
1788
1801
|
*
|
1789
1802
|
* @public
|
1790
1803
|
*/
|
1791
|
-
declare function union<E extends Extension | Extension[]>(extension: E): UnionExtension<E>;
|
1804
|
+
declare function union<const E extends Extension | readonly Extension[]>(extension: E): UnionExtension<E>;
|
1792
1805
|
export { union }
|
1793
1806
|
export { union as union_alias_1 }
|
1794
1807
|
|
1795
1808
|
/**
|
1796
1809
|
* @internal
|
1797
1810
|
*/
|
1798
|
-
declare type UnionExtension<E extends Extension | Extension[]> = E extends Extension[] ? Extension<{
|
1811
|
+
declare type UnionExtension<E extends Extension | readonly Extension[]> = E extends readonly Extension[] ? Extension<{
|
1799
1812
|
Nodes: ExtractNodes<E[number]>;
|
1800
1813
|
Marks: ExtractMarks<E[number]>;
|
1801
1814
|
Commands: ExtractCommands<E[number]>;
|
package/dist/prosekit-core.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
export { addMark } from './_tsup-dts-rollup';
|
2
2
|
export { expandMark } from './_tsup-dts-rollup';
|
3
3
|
export { insertNode } from './_tsup-dts-rollup';
|
4
|
-
export { removeNode } from './_tsup-dts-rollup';
|
5
4
|
export { removeMark } from './_tsup-dts-rollup';
|
5
|
+
export { removeNode } from './_tsup-dts-rollup';
|
6
6
|
export { setBlockType } from './_tsup-dts-rollup';
|
7
7
|
export { setNodeAttrs } from './_tsup-dts-rollup';
|
8
8
|
export { toggleMark } from './_tsup-dts-rollup';
|
package/dist/prosekit-core.js
CHANGED
@@ -117,6 +117,17 @@ function insertNode(options) {
|
|
117
117
|
};
|
118
118
|
}
|
119
119
|
|
120
|
+
// src/commands/remove-mark.ts
|
121
|
+
import "@prosekit/pm/model";
|
122
|
+
import "@prosekit/pm/state";
|
123
|
+
function removeMark(options) {
|
124
|
+
return (state, dispatch) => {
|
125
|
+
var _a, _b;
|
126
|
+
let markType = getMarkType(state.schema, options.type), mark = options.attrs ? markType.create(options.attrs) : markType, from = (_a = options.from) != null ? _a : state.selection.from, to = (_b = options.to) != null ? _b : state.selection.to;
|
127
|
+
return from > to ? !1 : (dispatch == null || dispatch(state.tr.removeMark(from, to, mark)), !0);
|
128
|
+
};
|
129
|
+
}
|
130
|
+
|
120
131
|
// src/utils/find-parent-node.ts
|
121
132
|
function findParentNode(nodeType, $pos) {
|
122
133
|
for (let depth = $pos.depth; depth > 0; depth -= 1)
|
@@ -141,17 +152,6 @@ function removeNode(options) {
|
|
141
152
|
};
|
142
153
|
}
|
143
154
|
|
144
|
-
// src/commands/remove-mark.ts
|
145
|
-
import "@prosekit/pm/model";
|
146
|
-
import "@prosekit/pm/state";
|
147
|
-
function removeMark(options) {
|
148
|
-
return (state, dispatch) => {
|
149
|
-
var _a, _b;
|
150
|
-
let markType = getMarkType(state.schema, options.type), mark = options.attrs ? markType.create(options.attrs) : markType, from = (_a = options.from) != null ? _a : state.selection.from, to = (_b = options.to) != null ? _b : state.selection.to;
|
151
|
-
return from > to ? !1 : (dispatch == null || dispatch(state.tr.removeMark(from, to, mark)), !0);
|
152
|
-
};
|
153
|
-
}
|
154
|
-
|
155
155
|
// src/commands/set-block-type.ts
|
156
156
|
import "@prosekit/pm/state";
|
157
157
|
|
@@ -951,7 +951,7 @@ var EditorInstance = class {
|
|
951
951
|
defineCommand(name, commandCreator) {
|
952
952
|
let applier = (...args) => {
|
953
953
|
let view = this.view;
|
954
|
-
return view
|
954
|
+
return assert(view, `Cannot call command "${name}" before the editor is mounted`), commandCreator(...args)(view.state, view.dispatch.bind(view), view);
|
955
955
|
};
|
956
956
|
applier.canApply = (...args) => {
|
957
957
|
let view = this.view;
|