@prosekit/extensions 0.11.2 → 0.11.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/{drop-indicator-B8P652g2.js → drop-indicator-dB9rZn8e.js} +2 -1
- package/dist/paste-rule-Cca3n5TA.js +173 -0
- package/dist/prosekit-extensions-code-block.d.ts +1 -1
- package/dist/prosekit-extensions-drop-indicator.js +1 -1
- package/dist/prosekit-extensions-link.d.ts +10 -2
- package/dist/prosekit-extensions-link.js +19 -2
- package/dist/prosekit-extensions-list.js +1 -1
- package/dist/prosekit-extensions-paste-rule.d.ts +93 -0
- package/dist/prosekit-extensions-paste-rule.js +3 -0
- package/dist/prosekit-extensions-placeholder.js +2 -1
- package/dist/prosekit-extensions-table.d.ts +10 -1
- package/dist/prosekit-extensions-table.js +3 -2
- package/dist/shiki-highlighter-chunk.d.ts +1 -1
- package/dist/{table-3rDWFyBH.js → table-CPI9ZxbK.js} +28 -2
- package/package.json +13 -5
- /package/dist/{shiki-highlighter-chunk-D7gKY7Kr.d.ts → shiki-highlighter-chunk-DSPM0T27.d.ts} +0 -0
|
@@ -61,8 +61,9 @@ function buildGetTarget(view, onDrag) {
|
|
|
61
61
|
const p2Distance = pointLineDistance(point, line2);
|
|
62
62
|
return p1Distance - p2Distance || pos1 - pos2;
|
|
63
63
|
};
|
|
64
|
-
|
|
64
|
+
let targets = getTargets();
|
|
65
65
|
targets.sort(compare);
|
|
66
|
+
targets = targets.slice(0, 8);
|
|
66
67
|
const target = targets.find((target$1) => onDrag({
|
|
67
68
|
view,
|
|
68
69
|
pos: target$1[0],
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { defineFacet, defineFacetPayload, getMarkType, pluginFacet } from "@prosekit/core";
|
|
2
|
+
import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state";
|
|
3
|
+
import { Fragment, Slice } from "@prosekit/pm/model";
|
|
4
|
+
|
|
5
|
+
//#region src/paste-rule/paste-rule-plugin.ts
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
const pasteRuleFacet = defineFacet({
|
|
10
|
+
reduce: () => {
|
|
11
|
+
let handlers = [];
|
|
12
|
+
let isPlainText = false;
|
|
13
|
+
const transformPasted = (slice, view) => {
|
|
14
|
+
for (const handler of handlers) slice = handler({
|
|
15
|
+
slice,
|
|
16
|
+
view,
|
|
17
|
+
plain: isPlainText
|
|
18
|
+
});
|
|
19
|
+
return slice;
|
|
20
|
+
};
|
|
21
|
+
const plugin = new ProseMirrorPlugin({
|
|
22
|
+
key: new PluginKey("prosekit-paste-rule"),
|
|
23
|
+
props: {
|
|
24
|
+
transformPasted,
|
|
25
|
+
transformPastedText: (text, plain) => {
|
|
26
|
+
isPlainText = plain;
|
|
27
|
+
return text;
|
|
28
|
+
},
|
|
29
|
+
transformPastedHTML(html) {
|
|
30
|
+
isPlainText = false;
|
|
31
|
+
return html;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return (inputs) => {
|
|
36
|
+
handlers = [...inputs].reverse();
|
|
37
|
+
return plugin;
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
singleton: true,
|
|
41
|
+
parent: pluginFacet
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
function definePasteRulePlugin(payload) {
|
|
47
|
+
return defineFacetPayload(pasteRuleFacet, [payload]);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/paste-rule/paste-rule.ts
|
|
52
|
+
/**
|
|
53
|
+
* Defines a paste rule. This rule allows you to modify pasted or dragged
|
|
54
|
+
* content before it is inserted into the document.
|
|
55
|
+
*
|
|
56
|
+
* @param options
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
function definePasteRule({ handler }) {
|
|
61
|
+
return definePasteRulePlugin(handler);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/paste-rule/split-text-by-regex.ts
|
|
66
|
+
/**
|
|
67
|
+
* Splits text into chunks based on regex matches, preserving both matched and unmatched segments.
|
|
68
|
+
* Returns an array of tuples where each tuple contains a text segment and either the match data
|
|
69
|
+
* (for matched segments) or undefined (for unmatched segments).
|
|
70
|
+
*/
|
|
71
|
+
function splitTextByRegex(text, regex) {
|
|
72
|
+
regex.lastIndex = 0;
|
|
73
|
+
const chunks = [];
|
|
74
|
+
let lastIndex = 0;
|
|
75
|
+
let match;
|
|
76
|
+
let matched = false;
|
|
77
|
+
while (match = regex.exec(text)) {
|
|
78
|
+
const start = match.index;
|
|
79
|
+
const end = regex.lastIndex;
|
|
80
|
+
if (start > lastIndex) chunks.push([text.slice(lastIndex, start), void 0]);
|
|
81
|
+
chunks.push([text.slice(start, end), match]);
|
|
82
|
+
matched = true;
|
|
83
|
+
if (lastIndex === end) return;
|
|
84
|
+
lastIndex = end;
|
|
85
|
+
}
|
|
86
|
+
if (matched && lastIndex < text.length) chunks.push([text.slice(lastIndex), void 0]);
|
|
87
|
+
regex.lastIndex = 0;
|
|
88
|
+
return matched ? chunks : void 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/paste-rule/mark-paste-rule.ts
|
|
93
|
+
/**
|
|
94
|
+
* Defines a paste rule that applies marks based on regex patterns.
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
function defineMarkPasteRule(options) {
|
|
99
|
+
return definePasteRule({ handler: ({ slice, view, plain }) => {
|
|
100
|
+
if (plain) return slice;
|
|
101
|
+
const markType = getMarkType(view.state.schema, options.type);
|
|
102
|
+
return replaceMarkInSlice({
|
|
103
|
+
markType,
|
|
104
|
+
regex: options.regex,
|
|
105
|
+
getAttrs: options.getAttrs,
|
|
106
|
+
shouldSkip: options.shouldSkip
|
|
107
|
+
}, slice);
|
|
108
|
+
} });
|
|
109
|
+
}
|
|
110
|
+
function replaceMarkInSlice(options, slice) {
|
|
111
|
+
const newFragment = replaceMarkInFragment(options, slice.content);
|
|
112
|
+
if (!newFragment) return slice;
|
|
113
|
+
return new Slice(newFragment, slice.openStart, slice.openEnd);
|
|
114
|
+
}
|
|
115
|
+
function replaceMarkInFragment(options, fragment) {
|
|
116
|
+
let changed = false;
|
|
117
|
+
let children = [];
|
|
118
|
+
for (const child of fragment.content) {
|
|
119
|
+
const newChild = replaceMarkInNode(options, child);
|
|
120
|
+
if (newChild) changed = true;
|
|
121
|
+
children.push(newChild || child);
|
|
122
|
+
}
|
|
123
|
+
if (changed) return Fragment.from(children);
|
|
124
|
+
}
|
|
125
|
+
function replaceMarkInNode(options, node) {
|
|
126
|
+
if (node.type.spec.code) return;
|
|
127
|
+
if (node.type.isInline) return;
|
|
128
|
+
if (node.type.isTextblock) return replaceMarkInTextblockNode(options, node);
|
|
129
|
+
const newChildren = replaceMarkInFragment(options, node.content);
|
|
130
|
+
if (!newChildren) return;
|
|
131
|
+
return node.copy(newChildren);
|
|
132
|
+
}
|
|
133
|
+
function replaceMarkInTextblockNode(options, node) {
|
|
134
|
+
const newChildren = [];
|
|
135
|
+
let changed = false;
|
|
136
|
+
for (const inlineNode of node.content.content) {
|
|
137
|
+
const newInlineNodes = replaceMarkInInlineNode(options, inlineNode);
|
|
138
|
+
if (newInlineNodes) {
|
|
139
|
+
changed = true;
|
|
140
|
+
newChildren.push(...newInlineNodes);
|
|
141
|
+
} else newChildren.push(inlineNode);
|
|
142
|
+
}
|
|
143
|
+
if (changed) return node.copy(Fragment.from(newChildren));
|
|
144
|
+
}
|
|
145
|
+
function replaceMarkInInlineNode(options, node) {
|
|
146
|
+
const text = node.text;
|
|
147
|
+
if (!text) return;
|
|
148
|
+
const { markType, shouldSkip } = options;
|
|
149
|
+
if (shouldSkip) {
|
|
150
|
+
if (shouldSkip(node)) return;
|
|
151
|
+
} else {
|
|
152
|
+
if (node.marks.some((mark) => mark.type === markType)) return;
|
|
153
|
+
if (node.marks.some((mark) => mark.type.spec.code)) return;
|
|
154
|
+
}
|
|
155
|
+
const chunks = splitTextByRegex(text, options.regex);
|
|
156
|
+
if (!chunks) return;
|
|
157
|
+
const schema = node.type.schema;
|
|
158
|
+
const nodes = [];
|
|
159
|
+
for (const [text$1, match] of chunks) {
|
|
160
|
+
if (!text$1) continue;
|
|
161
|
+
if (match) {
|
|
162
|
+
const attrs = options.getAttrs?.(match) ?? null;
|
|
163
|
+
if (attrs !== false) {
|
|
164
|
+
const mark = markType.create(attrs);
|
|
165
|
+
nodes.push(schema.text(text$1, [...node.marks, mark]));
|
|
166
|
+
} else nodes.push(schema.text(text$1, node.marks));
|
|
167
|
+
} else nodes.push(schema.text(text$1, node.marks));
|
|
168
|
+
}
|
|
169
|
+
return nodes;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
export { defineMarkPasteRule, definePasteRule };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ShikiHighlighterOptions } from "./shiki-highlighter-chunk-
|
|
1
|
+
import { ShikiHighlighterOptions } from "./shiki-highlighter-chunk-DSPM0T27.js";
|
|
2
2
|
import { Extension, PlainExtension, Union } from "@prosekit/core";
|
|
3
3
|
import { Parser } from "prosemirror-highlight";
|
|
4
4
|
import { BundledLanguage as ShikiBundledLanguage, BundledLanguageInfo as ShikiBundledLanguageInfo, BundledTheme as ShikiBundledTheme, BundledThemeInfo as ShikiBundledThemeInfo, SpecialLanguage, bundledLanguagesInfo as shikiBundledLanguagesInfo, bundledThemesInfo as shikiBundledThemesInfo } from "shiki";
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { Extension, PlainExtension, Union } from "@prosekit/core";
|
|
2
2
|
|
|
3
|
-
//#region src/link/
|
|
3
|
+
//#region src/link/link-paste-rule.d.ts
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
declare function defineLinkPasteRule(): PlainExtension;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/link/link-types.d.ts
|
|
5
11
|
/**
|
|
6
12
|
* @public
|
|
7
13
|
*/
|
|
@@ -10,6 +16,8 @@ interface LinkAttrs {
|
|
|
10
16
|
target?: string | null;
|
|
11
17
|
rel?: string | null;
|
|
12
18
|
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/link/index.d.ts
|
|
13
21
|
/**
|
|
14
22
|
* @internal
|
|
15
23
|
*/
|
|
@@ -61,4 +69,4 @@ type LinkExtension = Union<[LinkSpecExtension, LinkCommandsExtension]>;
|
|
|
61
69
|
*/
|
|
62
70
|
declare function defineLink(): LinkExtension;
|
|
63
71
|
//#endregion
|
|
64
|
-
export { LinkAttrs, LinkCommandsExtension, LinkExtension, LinkSpecExtension, defineLink, defineLinkCommands, defineLinkEnterRule, defineLinkInputRule, defineLinkMarkRule, defineLinkSpec };
|
|
72
|
+
export { type LinkAttrs, LinkCommandsExtension, LinkExtension, LinkSpecExtension, defineLink, defineLinkCommands, defineLinkEnterRule, defineLinkInputRule, defineLinkMarkRule, defineLinkPasteRule, defineLinkSpec };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineInputRule } from "./input-rule-Gji4N7Oe.js";
|
|
2
2
|
import { defineEnterRule } from "./enter-rule-RdhEA900.js";
|
|
3
3
|
import { defineMarkRule } from "./mark-rule-D7zaa32n.js";
|
|
4
|
+
import { defineMarkPasteRule } from "./paste-rule-Cca3n5TA.js";
|
|
4
5
|
import { addMark, defineCommands, defineMarkSpec, expandMark, removeMark, toggleMark, union } from "@prosekit/core";
|
|
5
6
|
import { InputRule } from "@prosekit/pm/inputrules";
|
|
6
7
|
|
|
@@ -17,6 +18,22 @@ const LINK_ENTER_RE = new RegExp(LINK_ENTER_PATTERN, "gi");
|
|
|
17
18
|
const LINK_INPUT_RE = new RegExp(LINK_INPUT_PATTERN, "gi");
|
|
18
19
|
const LINK_MARK_RE = new RegExp(LINK_MARK_PATTERN, "gi");
|
|
19
20
|
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/link/link-paste-rule.ts
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
function defineLinkPasteRule() {
|
|
27
|
+
return defineMarkPasteRule({
|
|
28
|
+
type: "link",
|
|
29
|
+
regex: LINK_MARK_RE,
|
|
30
|
+
getAttrs: (match) => {
|
|
31
|
+
if (match[1]) return { href: match[1] };
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
20
37
|
//#endregion
|
|
21
38
|
//#region src/link/index.ts
|
|
22
39
|
/**
|
|
@@ -121,8 +138,8 @@ function defineLinkMarkRule() {
|
|
|
121
138
|
* @public
|
|
122
139
|
*/
|
|
123
140
|
function defineLink() {
|
|
124
|
-
return union(defineLinkSpec(), defineLinkCommands(), defineLinkInputRule(), defineLinkEnterRule());
|
|
141
|
+
return union(defineLinkSpec(), defineLinkCommands(), defineLinkInputRule(), defineLinkEnterRule(), defineLinkPasteRule());
|
|
125
142
|
}
|
|
126
143
|
|
|
127
144
|
//#endregion
|
|
128
|
-
export { defineLink, defineLinkCommands, defineLinkEnterRule, defineLinkInputRule, defineLinkMarkRule, defineLinkSpec };
|
|
145
|
+
export { defineLink, defineLinkCommands, defineLinkEnterRule, defineLinkInputRule, defineLinkMarkRule, defineLinkPasteRule, defineLinkSpec };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineInputRule } from "./input-rule-Gji4N7Oe.js";
|
|
2
|
-
import { defineDropIndicator } from "./drop-indicator-
|
|
2
|
+
import { defineDropIndicator } from "./drop-indicator-dB9rZn8e.js";
|
|
3
3
|
import { defineClipboardSerializer, defineCommands, defineKeymap, defineNodeSpec, definePlugin, insertNode, union } from "@prosekit/core";
|
|
4
4
|
import { Plugin } from "@prosekit/pm/state";
|
|
5
5
|
import { chainCommands, deleteSelection } from "@prosekit/pm/commands";
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { PlainExtension } from "@prosekit/core";
|
|
2
|
+
import { EditorView } from "@prosekit/pm/view";
|
|
3
|
+
import { Attrs, MarkType, ProseMirrorNode, Slice } from "@prosekit/pm/model";
|
|
4
|
+
|
|
5
|
+
//#region src/paste-rule/mark-paste-rule.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The options for {@link defineMarkPasteRule}.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
interface MarkPasteRuleOptions {
|
|
13
|
+
/**
|
|
14
|
+
* The regular expression to match against. It must have a `g` flag to match
|
|
15
|
+
* all instances of the mark.
|
|
16
|
+
*/
|
|
17
|
+
regex: RegExp;
|
|
18
|
+
/**
|
|
19
|
+
* The mark type to apply to the matched text.
|
|
20
|
+
*/
|
|
21
|
+
type: string | MarkType;
|
|
22
|
+
/**
|
|
23
|
+
* A function used to compute attributes to set on the mark created by this
|
|
24
|
+
* rule. When it returns `false`, the rule won't match. When it returns `null`
|
|
25
|
+
* or `undefined`, that is interpreted as an empty/default set of attributes.
|
|
26
|
+
* @default null
|
|
27
|
+
*/
|
|
28
|
+
getAttrs?: (match: RegExpExecArray) => Attrs | null | undefined | false;
|
|
29
|
+
/**
|
|
30
|
+
* Optional function to determine if a text node should be skipped.
|
|
31
|
+
* Default behavior: skip code nodes and nodes that already have the target mark.
|
|
32
|
+
*/
|
|
33
|
+
shouldSkip?: (node: ProseMirrorNode) => boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Defines a paste rule that applies marks based on regex patterns.
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
declare function defineMarkPasteRule(options: MarkPasteRuleOptions): PlainExtension;
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/paste-rule/paste-rule.d.ts
|
|
43
|
+
/**
|
|
44
|
+
* @public
|
|
45
|
+
*
|
|
46
|
+
* Options for {@link PasteRuleHandler}.
|
|
47
|
+
*/
|
|
48
|
+
interface PasteRuleHandlerOptions {
|
|
49
|
+
/**
|
|
50
|
+
* The slice to be pasted.
|
|
51
|
+
*/
|
|
52
|
+
slice: Slice;
|
|
53
|
+
/**
|
|
54
|
+
* The editor view.
|
|
55
|
+
*/
|
|
56
|
+
view: EditorView;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the pasted content is treated as plain text. This is true when the
|
|
59
|
+
* `Shift` key is held when pasting.
|
|
60
|
+
*/
|
|
61
|
+
plain: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @public
|
|
65
|
+
*
|
|
66
|
+
* Can be used to transform pasted or dragged-and-dropped content before it is
|
|
67
|
+
* applied to the document.
|
|
68
|
+
*/
|
|
69
|
+
type PasteRuleHandler = (options: PasteRuleHandlerOptions) => Slice;
|
|
70
|
+
/**
|
|
71
|
+
* Options for {@link definePasteRule}.
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
interface PasteRuleOptions {
|
|
76
|
+
/**
|
|
77
|
+
* A function to be called when a paste rule is triggered.
|
|
78
|
+
*/
|
|
79
|
+
handler: PasteRuleHandler;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Defines a paste rule. This rule allows you to modify pasted or dragged
|
|
83
|
+
* content before it is inserted into the document.
|
|
84
|
+
*
|
|
85
|
+
* @param options
|
|
86
|
+
*
|
|
87
|
+
* @public
|
|
88
|
+
*/
|
|
89
|
+
declare function definePasteRule({
|
|
90
|
+
handler
|
|
91
|
+
}: PasteRuleOptions): PlainExtension;
|
|
92
|
+
//#endregion
|
|
93
|
+
export { type MarkPasteRuleOptions, type PasteRuleHandler, type PasteRuleHandlerOptions, type PasteRuleOptions, defineMarkPasteRule, definePasteRule };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./drop-indicator-dB9rZn8e.js";
|
|
2
|
+
import { findTable } from "./table-CPI9ZxbK.js";
|
|
2
3
|
import { definePlugin, isInCodeBlock, maybeRun } from "@prosekit/core";
|
|
3
4
|
import { Plugin, PluginKey } from "@prosekit/pm/state";
|
|
4
5
|
import { Decoration, DecorationSet } from "@prosekit/pm/view";
|
|
@@ -268,6 +268,15 @@ type TableExtension = Union<[TableSpecExtension, TableRowSpecExtension, TableCel
|
|
|
268
268
|
*/
|
|
269
269
|
declare function defineTable(): TableExtension;
|
|
270
270
|
//#endregion
|
|
271
|
+
//#region src/table/table-drop-indicator.d.ts
|
|
272
|
+
/**
|
|
273
|
+
* Hides the drop indicator when dragging a table column or row by using the
|
|
274
|
+
* table handle.
|
|
275
|
+
*
|
|
276
|
+
* @internal
|
|
277
|
+
*/
|
|
278
|
+
declare function defineTableDropIndicator(): PlainExtension;
|
|
279
|
+
//#endregion
|
|
271
280
|
//#region src/table/table-plugins.d.ts
|
|
272
281
|
/**
|
|
273
282
|
* @public
|
|
@@ -296,4 +305,4 @@ declare function findTable($pos: ResolvedPos): FindParentNodeResult | undefined;
|
|
|
296
305
|
*/
|
|
297
306
|
|
|
298
307
|
//#endregion
|
|
299
|
-
export { type InsertTableOptions, type MoveTableColumnOptions, type MoveTableRowOptions, type SelectTableCellOptions, type SelectTableColumnOptions, type SelectTableOptions, type SelectTableRowOptions, type TableCellSpecExtension, type TableCommandsExtension, type TableExtension, type TableHeaderCellSpecExtension, type TableRowSpecExtension, type TableSpecExtension, defineTable, defineTableCellSpec, defineTableCommands, defineTableHeaderCellSpec, defineTablePlugins, defineTableRowSpec, defineTableSpec, exitTable, findTable, insertTable, isCellSelection, moveTableColumn, moveTableRow, selectTable, selectTableCell, selectTableColumn, selectTableRow };
|
|
308
|
+
export { type InsertTableOptions, type MoveTableColumnOptions, type MoveTableRowOptions, type SelectTableCellOptions, type SelectTableColumnOptions, type SelectTableOptions, type SelectTableRowOptions, type TableCellSpecExtension, type TableCommandsExtension, type TableExtension, type TableHeaderCellSpecExtension, type TableRowSpecExtension, type TableSpecExtension, defineTable, defineTableCellSpec, defineTableCommands, defineTableDropIndicator, defineTableHeaderCellSpec, defineTablePlugins, defineTableRowSpec, defineTableSpec, exitTable, findTable, insertTable, isCellSelection, moveTableColumn, moveTableRow, selectTable, selectTableCell, selectTableColumn, selectTableRow };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./drop-indicator-dB9rZn8e.js";
|
|
2
|
+
import { defineTable, defineTableCellSpec, defineTableCommands, defineTableDropIndicator, defineTableHeaderCellSpec, defineTablePlugins, defineTableRowSpec, defineTableSpec, exitTable, findTable, insertTable, isCellSelection, moveTableColumn, moveTableRow, selectTable, selectTableCell, selectTableColumn, selectTableRow } from "./table-CPI9ZxbK.js";
|
|
2
3
|
|
|
3
|
-
export { defineTable, defineTableCellSpec, defineTableCommands, defineTableHeaderCellSpec, defineTablePlugins, defineTableRowSpec, defineTableSpec, exitTable, findTable, insertTable, isCellSelection, moveTableColumn, moveTableRow, selectTable, selectTableCell, selectTableColumn, selectTableRow };
|
|
4
|
+
export { defineTable, defineTableCellSpec, defineTableCommands, defineTableDropIndicator, defineTableHeaderCellSpec, defineTablePlugins, defineTableRowSpec, defineTableSpec, exitTable, findTable, insertTable, isCellSelection, moveTableColumn, moveTableRow, selectTable, selectTableCell, selectTableColumn, selectTableRow };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { HighlighterOptions, HighlighterResult, ShikiHighlighterOptions, createOrGetHighlighter } from "./shiki-highlighter-chunk-
|
|
1
|
+
import { HighlighterOptions, HighlighterResult, ShikiHighlighterOptions, createOrGetHighlighter } from "./shiki-highlighter-chunk-DSPM0T27.js";
|
|
2
2
|
export { HighlighterOptions, HighlighterResult, ShikiHighlighterOptions, createOrGetHighlighter };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defineDropIndicator } from "./drop-indicator-dB9rZn8e.js";
|
|
1
2
|
import { defaultBlockAt, defineCommands, defineNodeSpec, definePlugin, findParentNode, getNodeType, insertNode, union } from "@prosekit/core";
|
|
2
3
|
import { TextSelection } from "@prosekit/pm/state";
|
|
3
4
|
import { CellSelection, TableMap, addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, cellAround, cellNear, columnResizing, deleteCellSelection, deleteColumn, deleteRow, deleteTable, inSameTable, mergeCells, splitCell, tableEditing, tableNodes } from "prosemirror-tables";
|
|
@@ -661,6 +662,31 @@ function defineTableCommands() {
|
|
|
661
662
|
});
|
|
662
663
|
}
|
|
663
664
|
|
|
665
|
+
//#endregion
|
|
666
|
+
//#region src/table/table-drop-indicator.ts
|
|
667
|
+
/**
|
|
668
|
+
* Hides the drop indicator when dragging a table column or row by using the
|
|
669
|
+
* table handle.
|
|
670
|
+
*
|
|
671
|
+
* @internal
|
|
672
|
+
*/
|
|
673
|
+
function defineTableDropIndicator() {
|
|
674
|
+
return defineDropIndicator({ onDrag });
|
|
675
|
+
}
|
|
676
|
+
const matchMap = /* @__PURE__ */ new WeakMap();
|
|
677
|
+
const onDrag = ({ event }) => {
|
|
678
|
+
const dataTransfer = event.dataTransfer;
|
|
679
|
+
if (!dataTransfer) return true;
|
|
680
|
+
let match;
|
|
681
|
+
if (matchMap.has(dataTransfer)) match = matchMap.get(dataTransfer);
|
|
682
|
+
else {
|
|
683
|
+
const types = dataTransfer.types;
|
|
684
|
+
match = types.includes("application/x-prosekit-table-handle-drag");
|
|
685
|
+
matchMap.set(dataTransfer, match);
|
|
686
|
+
}
|
|
687
|
+
return !match;
|
|
688
|
+
};
|
|
689
|
+
|
|
664
690
|
//#endregion
|
|
665
691
|
//#region src/table/table-plugins.ts
|
|
666
692
|
/**
|
|
@@ -727,8 +753,8 @@ function defineTableHeaderCellSpec() {
|
|
|
727
753
|
* @public
|
|
728
754
|
*/
|
|
729
755
|
function defineTable() {
|
|
730
|
-
return union(defineTableSpec(), defineTableRowSpec(), defineTableCellSpec(), defineTableHeaderCellSpec(), defineTablePlugins(), defineTableCommands());
|
|
756
|
+
return union(defineTableSpec(), defineTableRowSpec(), defineTableCellSpec(), defineTableHeaderCellSpec(), defineTablePlugins(), defineTableCommands(), defineTableDropIndicator());
|
|
731
757
|
}
|
|
732
758
|
|
|
733
759
|
//#endregion
|
|
734
|
-
export { defineTable, defineTableCellSpec, defineTableCommands, defineTableHeaderCellSpec, defineTablePlugins, defineTableRowSpec, defineTableSpec, exitTable, findTable, insertTable, isCellSelection, moveTableColumn, moveTableRow, selectTable, selectTableCell, selectTableColumn, selectTableRow };
|
|
760
|
+
export { defineTable, defineTableCellSpec, defineTableCommands, defineTableDropIndicator, defineTableHeaderCellSpec, defineTablePlugins, defineTableRowSpec, defineTableSpec, exitTable, findTable, insertTable, isCellSelection, moveTableColumn, moveTableRow, selectTable, selectTableCell, selectTableColumn, selectTableRow };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosekit/extensions",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.4",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "A collection of common extensions for ProseKit",
|
|
7
7
|
"author": {
|
|
@@ -142,6 +142,10 @@
|
|
|
142
142
|
"types": "./dist/prosekit-extensions-paragraph.d.ts",
|
|
143
143
|
"default": "./dist/prosekit-extensions-paragraph.js"
|
|
144
144
|
},
|
|
145
|
+
"./paste-rule": {
|
|
146
|
+
"types": "./dist/prosekit-extensions-paste-rule.d.ts",
|
|
147
|
+
"default": "./dist/prosekit-extensions-paste-rule.js"
|
|
148
|
+
},
|
|
145
149
|
"./placeholder": {
|
|
146
150
|
"types": "./dist/prosekit-extensions-placeholder.d.ts",
|
|
147
151
|
"default": "./dist/prosekit-extensions-placeholder.js"
|
|
@@ -210,7 +214,7 @@
|
|
|
210
214
|
"prosemirror-highlight": "^0.13.0",
|
|
211
215
|
"prosemirror-search": "^1.1.0",
|
|
212
216
|
"prosemirror-tables": "^1.7.1",
|
|
213
|
-
"shiki": "^3.9.
|
|
217
|
+
"shiki": "^3.9.2",
|
|
214
218
|
"@prosekit/core": "^0.8.3",
|
|
215
219
|
"@prosekit/pm": "^0.1.11"
|
|
216
220
|
},
|
|
@@ -239,16 +243,16 @@
|
|
|
239
243
|
"@vitest/browser": "^3.2.4",
|
|
240
244
|
"diffable-html": "^6.0.1",
|
|
241
245
|
"just-pick": "^4.2.0",
|
|
242
|
-
"loro-crdt": "^1.5.
|
|
246
|
+
"loro-crdt": "^1.5.10",
|
|
243
247
|
"loro-prosemirror": "^0.2.3",
|
|
244
248
|
"rehype-parse": "^9.0.1",
|
|
245
249
|
"rehype-remark": "^10.0.1",
|
|
246
250
|
"remark-html": "^16.0.1",
|
|
247
251
|
"remark-parse": "^11.0.0",
|
|
248
252
|
"remark-stringify": "^11.0.0",
|
|
249
|
-
"tsdown": "^0.13.
|
|
253
|
+
"tsdown": "^0.13.4",
|
|
250
254
|
"type-fest": "^4.41.0",
|
|
251
|
-
"typescript": "~5.
|
|
255
|
+
"typescript": "~5.9.2",
|
|
252
256
|
"unified": "^11.0.5",
|
|
253
257
|
"vitest": "^3.2.4",
|
|
254
258
|
"y-prosemirror": "^1.3.7",
|
|
@@ -292,6 +296,7 @@
|
|
|
292
296
|
"prosekit-extensions-mention": "./src/mention/index.ts",
|
|
293
297
|
"prosekit-extensions-mod-click-prevention": "./src/mod-click-prevention/index.ts",
|
|
294
298
|
"prosekit-extensions-paragraph": "./src/paragraph/index.ts",
|
|
299
|
+
"prosekit-extensions-paste-rule": "./src/paste-rule/index.ts",
|
|
295
300
|
"prosekit-extensions-placeholder": "./src/placeholder/index.ts",
|
|
296
301
|
"placeholder/style": "./src/placeholder/style.css",
|
|
297
302
|
"prosekit-extensions-readonly": "./src/readonly/index.ts",
|
|
@@ -394,6 +399,9 @@
|
|
|
394
399
|
"paragraph": [
|
|
395
400
|
"./dist/prosekit-extensions-paragraph.d.ts"
|
|
396
401
|
],
|
|
402
|
+
"paste-rule": [
|
|
403
|
+
"./dist/prosekit-extensions-paste-rule.d.ts"
|
|
404
|
+
],
|
|
397
405
|
"placeholder": [
|
|
398
406
|
"./dist/prosekit-extensions-placeholder.d.ts"
|
|
399
407
|
],
|
/package/dist/{shiki-highlighter-chunk-D7gKY7Kr.d.ts → shiki-highlighter-chunk-DSPM0T27.d.ts}
RENAMED
|
File without changes
|