@prosekit/extensions 0.0.0-next-20240505104851 → 0.0.0-next-20240519080336
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 +51 -5
- package/dist/{chunk-HLBUHIMJ.js → chunk-DZAKXWWF.js} +15 -17
- package/dist/{chunk-CJ3SOSL6.js → chunk-LVMTQOWG.js} +8 -7
- package/dist/{chunk-7G7COECS.js → chunk-ZOBSD7ZH.js} +17 -16
- package/dist/prosekit-extensions-autocomplete.js +13 -17
- package/dist/prosekit-extensions-blockquote.js +1 -1
- package/dist/prosekit-extensions-bold.js +1 -1
- package/dist/prosekit-extensions-code-block.js +2 -2
- package/dist/prosekit-extensions-code.js +1 -1
- package/dist/prosekit-extensions-enter-rule.js +1 -1
- package/dist/prosekit-extensions-heading.js +1 -1
- package/dist/prosekit-extensions-input-rule.js +1 -1
- package/dist/prosekit-extensions-italic.js +1 -1
- package/dist/prosekit-extensions-link.js +3 -3
- package/dist/prosekit-extensions-list.js +1 -1
- package/dist/prosekit-extensions-mark-rule.js +1 -1
- package/dist/prosekit-extensions-mod-click-prevention.js +1 -6
- package/dist/prosekit-extensions-readonly.js +1 -2
- package/dist/prosekit-extensions-strike.js +1 -1
- package/dist/prosekit-extensions-text-align.d.ts +5 -0
- package/dist/prosekit-extensions-text-align.js +55 -0
- package/package.json +14 -6
@@ -638,6 +638,32 @@ NODES: "table";
|
|
638
638
|
export { defineTableSpec }
|
639
639
|
export { defineTableSpec as defineTableSpec_alias_1 }
|
640
640
|
|
641
|
+
/**
|
642
|
+
* Adds a `textAlign` attribute to the specified nodes. This will be rendered as
|
643
|
+
* a CSS `text-align` style.
|
644
|
+
*
|
645
|
+
* @public
|
646
|
+
*/
|
647
|
+
export declare function defineTextAlign(options: TextAlignOptions): Extension<{
|
648
|
+
COMMAND_ARGS: {
|
649
|
+
setTextAlign: [value: string | null];
|
650
|
+
};
|
651
|
+
}>;
|
652
|
+
|
653
|
+
/**
|
654
|
+
* @internal
|
655
|
+
*/
|
656
|
+
export declare function defineTextAlignCommands(types: string[]): Extension<{
|
657
|
+
COMMAND_ARGS: {
|
658
|
+
setTextAlign: [value: string | null];
|
659
|
+
};
|
660
|
+
}>;
|
661
|
+
|
662
|
+
/**
|
663
|
+
* @internal
|
664
|
+
*/
|
665
|
+
export declare function defineTextAlignKeymap(types: string[]): Extension<ExtensionTyping<string, string, CommandArgs>>;
|
666
|
+
|
641
667
|
/**
|
642
668
|
* Defines an enter rule that replaces the matched text with a block node.
|
643
669
|
*
|
@@ -854,11 +880,6 @@ export declare function insertTable({ row, col, header, }: {
|
|
854
880
|
header: boolean;
|
855
881
|
}): Command;
|
856
882
|
|
857
|
-
/**
|
858
|
-
* @deprecated Use `isApple` from `@prosekit/core`
|
859
|
-
*/
|
860
|
-
export declare const isApple: boolean;
|
861
|
-
|
862
883
|
export declare const LINK_ENTER_RE: RegExp;
|
863
884
|
|
864
885
|
export declare const LINK_INPUT_RE: RegExp;
|
@@ -967,8 +988,33 @@ export declare interface PredictionPluginState {
|
|
967
988
|
} | null;
|
968
989
|
}
|
969
990
|
|
991
|
+
/**
|
992
|
+
* @internal
|
993
|
+
*/
|
994
|
+
export declare function setTextAlign({ types, value, }: {
|
995
|
+
types: string[];
|
996
|
+
value: string | null;
|
997
|
+
}): Command;
|
998
|
+
|
970
999
|
export declare function setTrMeta(tr: Transaction, meta: PredictionPluginState): Transaction;
|
971
1000
|
|
1001
|
+
export declare interface TextAlignOptions {
|
1002
|
+
/**
|
1003
|
+
* The names of node to add the attribute to.
|
1004
|
+
*
|
1005
|
+
* @example
|
1006
|
+
*
|
1007
|
+
* ["paragraph", "heading"]
|
1008
|
+
*/
|
1009
|
+
types: string[];
|
1010
|
+
/**
|
1011
|
+
* The default value for the attribute.
|
1012
|
+
*
|
1013
|
+
* @default "left"
|
1014
|
+
*/
|
1015
|
+
default?: string;
|
1016
|
+
}
|
1017
|
+
|
972
1018
|
/**
|
973
1019
|
* Options for {@link defineTextBlockEnterRule}.
|
974
1020
|
*
|
@@ -1,7 +1,8 @@
|
|
1
1
|
// src/enter-rule/index.ts
|
2
2
|
import {
|
3
|
-
Facet,
|
4
3
|
OBJECT_REPLACEMENT_CHARACTER,
|
4
|
+
defineFacet,
|
5
|
+
defineFacetPayload,
|
5
6
|
getNodeType,
|
6
7
|
isTextSelection,
|
7
8
|
maybeRun,
|
@@ -9,7 +10,8 @@ import {
|
|
9
10
|
} from "@prosekit/core";
|
10
11
|
import { keydownHandler } from "@prosekit/pm/keymap";
|
11
12
|
import {
|
12
|
-
ProseMirrorPlugin
|
13
|
+
ProseMirrorPlugin,
|
14
|
+
PluginKey
|
13
15
|
} from "@prosekit/pm/state";
|
14
16
|
function defineEnterRule({
|
15
17
|
regex,
|
@@ -17,7 +19,7 @@ function defineEnterRule({
|
|
17
19
|
stop = false
|
18
20
|
}) {
|
19
21
|
const rule = new EnterRule(regex, handler, stop);
|
20
|
-
return enterRule
|
22
|
+
return defineFacetPayload(enterRule, [rule]);
|
21
23
|
}
|
22
24
|
function defineTextBlockEnterRule({
|
23
25
|
regex,
|
@@ -46,8 +48,8 @@ var EnterRule = class {
|
|
46
48
|
this.stop = stop;
|
47
49
|
}
|
48
50
|
};
|
49
|
-
var enterRule =
|
50
|
-
|
51
|
+
var enterRule = defineFacet({
|
52
|
+
reduce: () => {
|
51
53
|
let rules = [];
|
52
54
|
const command = (state, dispatch, view) => {
|
53
55
|
if (!view)
|
@@ -55,20 +57,16 @@ var enterRule = Facet.define({
|
|
55
57
|
return execRules(view, rules, dispatch);
|
56
58
|
};
|
57
59
|
const handler = keydownHandler({ Enter: command });
|
58
|
-
const plugin = new ProseMirrorPlugin({
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
update: (inputs) => {
|
66
|
-
rules = inputs;
|
67
|
-
return null;
|
68
|
-
}
|
60
|
+
const plugin = new ProseMirrorPlugin({
|
61
|
+
key: new PluginKey("prosekit-enter-rule"),
|
62
|
+
props: { handleKeyDown: handler }
|
63
|
+
});
|
64
|
+
return function reducer(inputs) {
|
65
|
+
rules = inputs;
|
66
|
+
return plugin;
|
69
67
|
};
|
70
68
|
},
|
71
|
-
|
69
|
+
parent: pluginFacet
|
72
70
|
});
|
73
71
|
function execRules(view, rules, dispatch) {
|
74
72
|
if (view.composing)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
// src/input-rule/index.ts
|
2
2
|
import {
|
3
|
-
|
3
|
+
defineFacet,
|
4
|
+
defineFacetPayload,
|
4
5
|
getMarkType,
|
5
6
|
getNodeType,
|
6
7
|
isMarkAbsent,
|
@@ -16,7 +17,7 @@ import {
|
|
16
17
|
import "@prosekit/pm/model";
|
17
18
|
import "@prosekit/pm/state";
|
18
19
|
function defineInputRule(rule) {
|
19
|
-
return inputRuleFacet
|
20
|
+
return defineFacetPayload(inputRuleFacet, [() => rule]);
|
20
21
|
}
|
21
22
|
function createMarkInputRule({
|
22
23
|
regex,
|
@@ -61,7 +62,7 @@ function defineTextBlockInputRule({
|
|
61
62
|
type,
|
62
63
|
attrs
|
63
64
|
}) {
|
64
|
-
return inputRuleFacet
|
65
|
+
return defineFacetPayload(inputRuleFacet, [
|
65
66
|
({ schema }) => {
|
66
67
|
const nodeType = getNodeType(schema, type);
|
67
68
|
return textblockTypeInputRule(regex, nodeType, attrs);
|
@@ -74,21 +75,21 @@ function defineWrappingInputRule({
|
|
74
75
|
attrs,
|
75
76
|
join
|
76
77
|
}) {
|
77
|
-
return inputRuleFacet
|
78
|
+
return defineFacetPayload(inputRuleFacet, [
|
78
79
|
({ schema }) => {
|
79
80
|
const nodeType = getNodeType(schema, type);
|
80
81
|
return wrappingInputRule(regex, nodeType, attrs, join);
|
81
82
|
}
|
82
83
|
]);
|
83
84
|
}
|
84
|
-
var inputRuleFacet =
|
85
|
-
|
85
|
+
var inputRuleFacet = defineFacet({
|
86
|
+
reducer: (inputs) => {
|
86
87
|
return (context) => {
|
87
88
|
const rules = inputs.flatMap((callback) => callback(context));
|
88
89
|
return [inputRules({ rules })];
|
89
90
|
};
|
90
91
|
},
|
91
|
-
|
92
|
+
parent: pluginFacet
|
92
93
|
});
|
93
94
|
|
94
95
|
export {
|
@@ -1,6 +1,13 @@
|
|
1
1
|
// src/mark-rule/extension.ts
|
2
|
-
import {
|
3
|
-
|
2
|
+
import {
|
3
|
+
defineFacet,
|
4
|
+
defineFacetPayload,
|
5
|
+
pluginFacet
|
6
|
+
} from "@prosekit/core";
|
7
|
+
import {
|
8
|
+
PluginKey,
|
9
|
+
ProseMirrorPlugin
|
10
|
+
} from "@prosekit/pm/state";
|
4
11
|
|
5
12
|
// src/mark-rule/apply.ts
|
6
13
|
import {
|
@@ -158,29 +165,23 @@ function applyMarkRules(rules, transactions, oldState, newState) {
|
|
158
165
|
|
159
166
|
// src/mark-rule/extension.ts
|
160
167
|
function defineMarkRule(options) {
|
161
|
-
return markRuleFacet
|
168
|
+
return defineFacetPayload(markRuleFacet, [options]);
|
162
169
|
}
|
163
|
-
var markRuleFacet =
|
164
|
-
|
170
|
+
var markRuleFacet = defineFacet({
|
171
|
+
reduce: () => {
|
165
172
|
let rules = [];
|
166
173
|
const plugin = new ProseMirrorPlugin({
|
174
|
+
key: new PluginKey("prosekit-mark-rule"),
|
167
175
|
appendTransaction: (transactions, oldState, newState) => {
|
168
176
|
return applyMarkRules(rules, transactions, oldState, newState);
|
169
177
|
}
|
170
178
|
});
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
rules = inputs;
|
175
|
-
return pluginFunc;
|
176
|
-
},
|
177
|
-
update: (inputs) => {
|
178
|
-
rules = inputs;
|
179
|
-
return null;
|
180
|
-
}
|
179
|
+
return function reducer(input) {
|
180
|
+
rules = input;
|
181
|
+
return plugin;
|
181
182
|
};
|
182
183
|
},
|
183
|
-
|
184
|
+
parent: pluginFacet
|
184
185
|
});
|
185
186
|
|
186
187
|
export {
|
@@ -1,6 +1,7 @@
|
|
1
1
|
// src/autocomplete/index.ts
|
2
2
|
import {
|
3
|
-
|
3
|
+
defineFacet,
|
4
|
+
defineFacetPayload,
|
4
5
|
pluginFacet
|
5
6
|
} from "@prosekit/core";
|
6
7
|
|
@@ -170,25 +171,20 @@ var AutocompleteRule = class {
|
|
170
171
|
|
171
172
|
// src/autocomplete/index.ts
|
172
173
|
function defineAutocomplete(rule) {
|
173
|
-
return autocompleteFacet
|
174
|
+
return defineFacetPayload(autocompleteFacet, [rule]);
|
174
175
|
}
|
175
|
-
var autocompleteFacet =
|
176
|
-
|
177
|
-
let
|
178
|
-
const getRules = () =>
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
return () => [plugin];
|
184
|
-
},
|
185
|
-
update: (rules) => {
|
186
|
-
localRules = rules;
|
187
|
-
return null;
|
188
|
-
}
|
176
|
+
var autocompleteFacet = defineFacet({
|
177
|
+
reduce: () => {
|
178
|
+
let rules = [];
|
179
|
+
const getRules = () => rules;
|
180
|
+
const plugin = createAutocompletePlugin({ getRules });
|
181
|
+
return function reducer(inputs) {
|
182
|
+
rules = inputs;
|
183
|
+
return plugin;
|
189
184
|
};
|
190
185
|
},
|
191
|
-
|
186
|
+
parent: pluginFacet,
|
187
|
+
singleton: true
|
192
188
|
});
|
193
189
|
export {
|
194
190
|
AutocompleteRule,
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import {
|
2
2
|
defineTextBlockInputRule
|
3
|
-
} from "./chunk-
|
3
|
+
} from "./chunk-LVMTQOWG.js";
|
4
4
|
import {
|
5
5
|
defineTextBlockEnterRule
|
6
|
-
} from "./chunk-
|
6
|
+
} from "./chunk-DZAKXWWF.js";
|
7
7
|
|
8
8
|
// src/code-block/code-block.ts
|
9
9
|
import { union } from "@prosekit/core";
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import {
|
2
2
|
defineMarkRule
|
3
|
-
} from "./chunk-
|
3
|
+
} from "./chunk-ZOBSD7ZH.js";
|
4
4
|
import {
|
5
5
|
defineInputRule
|
6
|
-
} from "./chunk-
|
6
|
+
} from "./chunk-LVMTQOWG.js";
|
7
7
|
import {
|
8
8
|
defineEnterRule
|
9
|
-
} from "./chunk-
|
9
|
+
} from "./chunk-DZAKXWWF.js";
|
10
10
|
|
11
11
|
// src/link/index.ts
|
12
12
|
import {
|
@@ -1,11 +1,6 @@
|
|
1
1
|
// src/mod-click-prevention/index.ts
|
2
|
-
import { definePlugin } from "@prosekit/core";
|
2
|
+
import { definePlugin, isApple } from "@prosekit/core";
|
3
3
|
import { Plugin, PluginKey } from "@prosekit/pm/state";
|
4
|
-
|
5
|
-
// src/mod-click-prevention/env.ts
|
6
|
-
var isApple = typeof navigator !== "undefined" ? /Mac|iP(hone|[ao]d)/.test(navigator.platform) : false;
|
7
|
-
|
8
|
-
// src/mod-click-prevention/index.ts
|
9
4
|
function defineModClickPrevention() {
|
10
5
|
return definePlugin(new Plugin({ key, props: { handleClick } }));
|
11
6
|
}
|
@@ -4,9 +4,8 @@ import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state";
|
|
4
4
|
function defineReadonly() {
|
5
5
|
return definePlugin(plugin);
|
6
6
|
}
|
7
|
-
var key = new PluginKey("readonly");
|
8
7
|
var plugin = new ProseMirrorPlugin({
|
9
|
-
key,
|
8
|
+
key: new PluginKey("prosekey-readonly"),
|
10
9
|
props: {
|
11
10
|
editable: () => false
|
12
11
|
}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export { setTextAlign } from './_tsup-dts-rollup';
|
2
|
+
export { defineTextAlignCommands } from './_tsup-dts-rollup';
|
3
|
+
export { defineTextAlignKeymap } from './_tsup-dts-rollup';
|
4
|
+
export { defineTextAlign } from './_tsup-dts-rollup';
|
5
|
+
export { TextAlignOptions } from './_tsup-dts-rollup';
|
@@ -0,0 +1,55 @@
|
|
1
|
+
// src/text-align/index.ts
|
2
|
+
import {
|
3
|
+
defineCommands,
|
4
|
+
defineKeymap,
|
5
|
+
defineNodeAttr,
|
6
|
+
setNodeAttrs,
|
7
|
+
union
|
8
|
+
} from "@prosekit/core";
|
9
|
+
function defineTextAlignAttr(type, defaultValue) {
|
10
|
+
return defineNodeAttr({
|
11
|
+
type,
|
12
|
+
attr: "textAlign",
|
13
|
+
default: defaultValue,
|
14
|
+
splittable: true,
|
15
|
+
toDOM: (value) => value ? ["style", `text-align:${value};`] : null,
|
16
|
+
parseDOM: (node) => {
|
17
|
+
return node.style.getPropertyValue("text-align") || null;
|
18
|
+
}
|
19
|
+
});
|
20
|
+
}
|
21
|
+
function defineTextAlignAttrs(types, defaultValue) {
|
22
|
+
return union(types.map((type) => defineTextAlignAttr(type, defaultValue)));
|
23
|
+
}
|
24
|
+
function setTextAlign({
|
25
|
+
types,
|
26
|
+
value
|
27
|
+
}) {
|
28
|
+
return setNodeAttrs({ type: types, attrs: { textAlign: value } });
|
29
|
+
}
|
30
|
+
function defineTextAlignCommands(types) {
|
31
|
+
return defineCommands({
|
32
|
+
setTextAlign: (value) => setTextAlign({ types, value })
|
33
|
+
});
|
34
|
+
}
|
35
|
+
function defineTextAlignKeymap(types) {
|
36
|
+
return defineKeymap({
|
37
|
+
"mod-shift-l": setTextAlign({ types, value: "left" }),
|
38
|
+
"mod-shift-e": setTextAlign({ types, value: "center" }),
|
39
|
+
"mod-shift-r": setTextAlign({ types, value: "right" }),
|
40
|
+
"mod-shift-j": setTextAlign({ types, value: "justify" })
|
41
|
+
});
|
42
|
+
}
|
43
|
+
function defineTextAlign(options) {
|
44
|
+
return union([
|
45
|
+
defineTextAlignAttrs(options.types, options.default || "left"),
|
46
|
+
defineTextAlignKeymap(options.types),
|
47
|
+
defineTextAlignCommands(options.types)
|
48
|
+
]);
|
49
|
+
}
|
50
|
+
export {
|
51
|
+
defineTextAlign,
|
52
|
+
defineTextAlignCommands,
|
53
|
+
defineTextAlignKeymap,
|
54
|
+
setTextAlign
|
55
|
+
};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/extensions",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next-
|
4
|
+
"version": "0.0.0-next-20240519080336",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -139,6 +139,11 @@
|
|
139
139
|
"./table/style.css": {
|
140
140
|
"default": "./dist/table/style.css"
|
141
141
|
},
|
142
|
+
"./text-align": {
|
143
|
+
"types": "./dist/prosekit-extensions-text-align.d.ts",
|
144
|
+
"import": "./dist/prosekit-extensions-text-align.js",
|
145
|
+
"default": "./dist/prosekit-extensions-text-align.js"
|
146
|
+
},
|
142
147
|
"./underline": {
|
143
148
|
"types": "./dist/prosekit-extensions-underline.d.ts",
|
144
149
|
"import": "./dist/prosekit-extensions-underline.js",
|
@@ -157,19 +162,19 @@
|
|
157
162
|
"dist"
|
158
163
|
],
|
159
164
|
"dependencies": {
|
160
|
-
"@prosekit/core": "0.0.0-next-
|
161
|
-
"@prosekit/pm": "0.0.0-next-
|
165
|
+
"@prosekit/core": "0.0.0-next-20240519080336",
|
166
|
+
"@prosekit/pm": "0.0.0-next-20240519080336",
|
162
167
|
"prosemirror-dropcursor": "^1.8.1",
|
163
168
|
"prosemirror-flat-list": "^0.5.0",
|
164
169
|
"prosemirror-highlight": "^0.5.0",
|
165
170
|
"prosemirror-tables": "^1.3.7",
|
166
|
-
"shiki": "^1.
|
171
|
+
"shiki": "^1.5.2"
|
167
172
|
},
|
168
173
|
"devDependencies": {
|
169
|
-
"@prosekit/dev": "*",
|
170
174
|
"tsup": "^8.0.2",
|
171
175
|
"typescript": "^5.4.5",
|
172
|
-
"vitest": "^1.6.0"
|
176
|
+
"vitest": "^1.6.0",
|
177
|
+
"@prosekit/dev": "0.0.0"
|
173
178
|
},
|
174
179
|
"scripts": {
|
175
180
|
"build:tsup": "tsup",
|
@@ -241,6 +246,9 @@
|
|
241
246
|
"table": [
|
242
247
|
"./dist/prosekit-extensions-table.d.ts"
|
243
248
|
],
|
249
|
+
"text-align": [
|
250
|
+
"./dist/prosekit-extensions-text-align.d.ts"
|
251
|
+
],
|
244
252
|
"underline": [
|
245
253
|
"./dist/prosekit-extensions-underline.d.ts"
|
246
254
|
],
|