@prosekit/extensions 0.7.23 → 0.7.24
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 +38 -15
- package/dist/{chunk-LAQZC3ZM.js → chunk-BV3SHIMW.js} +1 -2
- package/dist/{chunk-TWEOBBYZ.js → chunk-D54VSLLS.js} +1 -1
- package/dist/{chunk-KNFGQ3MV.js → chunk-HFAZX2J3.js} +8 -10
- package/dist/prosekit-extensions-autocomplete.js +6 -9
- package/dist/prosekit-extensions-blockquote.js +2 -2
- 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-file.js +2 -4
- package/dist/prosekit-extensions-heading.js +3 -4
- package/dist/prosekit-extensions-horizontal-rule.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 +2 -2
- package/dist/prosekit-extensions-list.d.ts +1 -0
- package/dist/prosekit-extensions-list.js +62 -4
- package/dist/prosekit-extensions-placeholder.js +2 -3
- package/dist/prosekit-extensions-search.js +1 -1
- package/dist/prosekit-extensions-strike.js +1 -1
- package/dist/prosekit-extensions-table.js +1 -1
- package/dist/prosekit-extensions-virtual-selection.js +1 -2
- package/dist/prosekit-extensions-yjs.js +2 -3
- package/package.json +14 -13
@@ -2,6 +2,8 @@ import { Attrs } from '@prosekit/pm/model';
|
|
2
2
|
import { Attrs as Attrs_2 } from 'prosemirror-model';
|
3
3
|
import type { Awareness } from 'y-protocols/awareness';
|
4
4
|
import { BaseCommandsExtension } from '@prosekit/core';
|
5
|
+
import { BlockquoteExtension as BlockquoteExtension_2 } from '../blockquote';
|
6
|
+
import { BoldExtension as BoldExtension_2 } from '../bold';
|
5
7
|
import type { BundledHighlighterOptions } from 'shiki';
|
6
8
|
import { BundledLanguage } from 'shiki';
|
7
9
|
import { BundledLanguageInfo } from 'shiki';
|
@@ -10,11 +12,11 @@ import { BundledTheme } from 'shiki';
|
|
10
12
|
import { BundledThemeInfo } from 'shiki';
|
11
13
|
import { bundledThemesInfo } from 'shiki';
|
12
14
|
import { CellSelection } from 'prosemirror-tables';
|
15
|
+
import { CodeExtension as CodeExtension_2 } from '../code';
|
13
16
|
import { Command } from '@prosekit/pm/state';
|
14
17
|
import { CursorAwareness } from 'loro-prosemirror';
|
15
18
|
import type { DecorationAttrs } from '@prosekit/pm/view';
|
16
19
|
import { DedentListOptions } from 'prosemirror-flat-list';
|
17
|
-
import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
|
18
20
|
import { DocExtension } from '@prosekit/core';
|
19
21
|
import { EditorState } from '@prosekit/pm/state';
|
20
22
|
import type { EditorView } from '@prosekit/pm/view';
|
@@ -24,13 +26,19 @@ import { ExtractMarkActions } from '@prosekit/core';
|
|
24
26
|
import { ExtractNodeActions } from '@prosekit/core';
|
25
27
|
import { FindParentNodeResult } from '@prosekit/core';
|
26
28
|
import { GapCursor } from 'prosemirror-gapcursor';
|
29
|
+
import { HeadingExtension as HeadingExtension_2 } from '../heading';
|
27
30
|
import type { Highlighter } from 'shiki';
|
28
31
|
import { HistoryExtension } from '@prosekit/core';
|
32
|
+
import { HorizontalRuleExtension as HorizontalRuleExtension_2 } from '../horizontal-rule';
|
33
|
+
import { ImageExtension as ImageExtension_2 } from '../image';
|
29
34
|
import { IndentListOptions } from 'prosemirror-flat-list';
|
30
35
|
import { InputRule } from '@prosekit/pm/inputrules';
|
31
36
|
import type { IsEqual } from 'type-fest';
|
37
|
+
import { ItalicExtension as ItalicExtension_2 } from '../italic';
|
38
|
+
import { LinkExtension as LinkExtension_2 } from '../link';
|
32
39
|
import { ListAttributes } from 'prosemirror-flat-list';
|
33
40
|
import { ListDOMSerializer } from 'prosemirror-flat-list';
|
41
|
+
import { ListExtension as ListExtension_2 } from '../list';
|
34
42
|
import type { LoroDocType } from 'loro-prosemirror';
|
35
43
|
import { LoroSyncPluginProps } from 'loro-prosemirror';
|
36
44
|
import { LoroUndoPluginProps } from 'loro-prosemirror';
|
@@ -40,7 +48,6 @@ import { NodeAction } from '@prosekit/core';
|
|
40
48
|
import { NodeChild } from '@prosekit/core';
|
41
49
|
import { NodeJSON } from '@prosekit/core';
|
42
50
|
import type { NodeType } from '@prosekit/pm/model';
|
43
|
-
import { Options } from 'tsup';
|
44
51
|
import { Parser } from 'prosemirror-highlight';
|
45
52
|
import type { PeerID } from 'loro-crdt';
|
46
53
|
import { PlainExtension } from '@prosekit/core';
|
@@ -52,11 +59,14 @@ import type { Selection as Selection_2 } from '@prosekit/pm/state';
|
|
52
59
|
import { SimplifyDeeper } from '@prosekit/core';
|
53
60
|
import type { SpecialLanguage } from 'shiki';
|
54
61
|
import { StepJSON } from '@prosekit/core';
|
62
|
+
import { StrikeExtension as StrikeExtension_2 } from '../strike';
|
63
|
+
import { TableExtension as TableExtension_2 } from '../table';
|
55
64
|
import { TestEditor } from '@prosekit/core/test';
|
56
65
|
import { TextExtension } from '@prosekit/core';
|
57
66
|
import { ToggleCollapsedOptions } from 'prosemirror-flat-list';
|
58
67
|
import { ToMarkAction } from '@prosekit/core';
|
59
68
|
import { Transaction } from '@prosekit/pm/state';
|
69
|
+
import { UnderlineExtension as UnderlineExtension_2 } from '../underline';
|
60
70
|
import { Union } from '@prosekit/core';
|
61
71
|
import { UnwrapListOptions } from 'prosemirror-flat-list';
|
62
72
|
import { WrapInListGetAttrs } from 'prosemirror-flat-list';
|
@@ -343,10 +353,6 @@ export declare function createOrGetHighlighter_alias_1(options: HighlighterOptio
|
|
343
353
|
export { DedentListOptions }
|
344
354
|
export { DedentListOptions as DedentListOptions_alias_1 }
|
345
355
|
|
346
|
-
export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
|
347
|
-
|
348
|
-
export { default_alias_1 }
|
349
|
-
|
350
356
|
export declare function defaultCanMatch({ state }: {
|
351
357
|
state: EditorState;
|
352
358
|
}): boolean;
|
@@ -800,6 +806,13 @@ export { defineListPlugins }
|
|
800
806
|
export { defineListPlugins as defineListPlugins_alias_1 }
|
801
807
|
export { defineListPlugins as defineListPlugins_alias_2 }
|
802
808
|
|
809
|
+
/**
|
810
|
+
* @internal
|
811
|
+
*/
|
812
|
+
declare function defineListSerializer(): Extension<ExtensionTyping<any, any, any>>;
|
813
|
+
export { defineListSerializer }
|
814
|
+
export { defineListSerializer as defineListSerializer_alias_1 }
|
815
|
+
|
803
816
|
/**
|
804
817
|
* @internal
|
805
818
|
*/
|
@@ -1004,11 +1017,11 @@ export { defineTableSpec as defineTableSpec_alias_1 }
|
|
1004
1017
|
/**
|
1005
1018
|
* @internal
|
1006
1019
|
*/
|
1007
|
-
export declare function defineTestExtension(): Union<readonly [DocExtension, TextExtension,
|
1020
|
+
export declare function defineTestExtension(): Union<readonly [DocExtension, TextExtension, HeadingExtension_2, HistoryExtension, ListExtension_2, BlockquoteExtension_2, PlainExtension, BaseCommandsExtension, ItalicExtension_2, BoldExtension_2, UnderlineExtension_2, StrikeExtension_2, CodeExtension_2, LinkExtension_2, ImageExtension_2, Extension<{
|
1008
1021
|
Nodes: {
|
1009
1022
|
paragraph: Attrs_2;
|
1010
1023
|
};
|
1011
|
-
}>,
|
1024
|
+
}>, TableExtension_2, HorizontalRuleExtension_2]>;
|
1012
1025
|
|
1013
1026
|
/**
|
1014
1027
|
* Adds a `textAlign` attribute to the specified nodes. This will be rendered as
|
@@ -1328,6 +1341,8 @@ declare function findTable($pos: ResolvedPos): FindParentNodeResult | undefined;
|
|
1328
1341
|
export { findTable }
|
1329
1342
|
export { findTable as findTable_alias_1 }
|
1330
1343
|
|
1344
|
+
export declare function formatHTML(html: string): Promise<string>;
|
1345
|
+
|
1331
1346
|
export { GapCursor }
|
1332
1347
|
|
1333
1348
|
/**
|
@@ -1832,6 +1847,10 @@ export declare interface PredictionPluginState {
|
|
1832
1847
|
*/
|
1833
1848
|
export declare function pressKey(input: string): Promise<void>;
|
1834
1849
|
|
1850
|
+
export declare function readHtmlTextFromClipboard(format?: boolean): Promise<string>;
|
1851
|
+
|
1852
|
+
export declare function readPlainTextFromClipboard(): Promise<string>;
|
1853
|
+
|
1835
1854
|
/**
|
1836
1855
|
* @internal
|
1837
1856
|
*/
|
@@ -1983,11 +2002,11 @@ export declare function setTrMeta(tr: Transaction, meta: PredictionPluginState):
|
|
1983
2002
|
* @internal
|
1984
2003
|
*/
|
1985
2004
|
export declare function setupTest(): {
|
1986
|
-
editor: TestEditor<Union<readonly [DocExtension, TextExtension,
|
2005
|
+
editor: TestEditor<Union<readonly [DocExtension, TextExtension, HeadingExtension_2, HistoryExtension, ListExtension_2, BlockquoteExtension_2, PlainExtension, BaseCommandsExtension, ItalicExtension_2, BoldExtension_2, UnderlineExtension_2, StrikeExtension_2, CodeExtension_2, LinkExtension_2, ImageExtension_2, Extension<{
|
1987
2006
|
Nodes: {
|
1988
2007
|
paragraph: Attrs_2;
|
1989
2008
|
};
|
1990
|
-
}>,
|
2009
|
+
}>, TableExtension_2, HorizontalRuleExtension_2]>>;
|
1991
2010
|
m: ToMarkAction<SimplifyDeeper< {
|
1992
2011
|
bold: {
|
1993
2012
|
readonly [x: string]: any;
|
@@ -2043,13 +2062,13 @@ export declare function setupTest(): {
|
|
2043
2062
|
readonly [x: string]: any;
|
2044
2063
|
}>;
|
2045
2064
|
image: NodeAction< {
|
2046
|
-
src?:
|
2047
|
-
width?:
|
2048
|
-
height?:
|
2065
|
+
src?: string | null | undefined;
|
2066
|
+
width?: number | null | undefined;
|
2067
|
+
height?: number | null | undefined;
|
2049
2068
|
}>;
|
2050
2069
|
list: NodeAction< {
|
2051
|
-
kind?:
|
2052
|
-
order?:
|
2070
|
+
kind?: "bullet" | "ordered" | "task" | "toggle" | undefined;
|
2071
|
+
order?: number | null | undefined;
|
2053
2072
|
checked?: boolean | undefined;
|
2054
2073
|
collapsed?: boolean | undefined;
|
2055
2074
|
}>;
|
@@ -2070,6 +2089,10 @@ export declare function setupTest(): {
|
|
2070
2089
|
colwidth: number[] | null;
|
2071
2090
|
}>;
|
2072
2091
|
};
|
2092
|
+
copy: () => Promise<{
|
2093
|
+
html: string;
|
2094
|
+
plain: string;
|
2095
|
+
}>;
|
2073
2096
|
};
|
2074
2097
|
|
2075
2098
|
/**
|
@@ -24,7 +24,6 @@ function createMarkInputRule({
|
|
24
24
|
attrs = null
|
25
25
|
}) {
|
26
26
|
const rule = new InputRule(regex, (state, match, start, end) => {
|
27
|
-
var _a;
|
28
27
|
const { tr, schema } = state;
|
29
28
|
const [fullText, markText] = match;
|
30
29
|
if (!markText) {
|
@@ -40,7 +39,7 @@ function createMarkInputRule({
|
|
40
39
|
if (!isMarkAbsent(tr.doc, markStart, markEnd, markType, attrs)) {
|
41
40
|
return null;
|
42
41
|
}
|
43
|
-
const initialStoredMarks =
|
42
|
+
const initialStoredMarks = tr.storedMarks ?? [];
|
44
43
|
tr.addMark(markStart, markEnd, mark);
|
45
44
|
if (markEnd < end) {
|
46
45
|
tr.delete(markEnd, end);
|
@@ -45,12 +45,11 @@ function findTable($pos) {
|
|
45
45
|
return findParentNode((node) => node.type.spec.tableRole === "table", $pos);
|
46
46
|
}
|
47
47
|
function findCellRange(selection, anchorHit, headHit) {
|
48
|
-
var _a, _b;
|
49
48
|
if (anchorHit == null && headHit == null && isCellSelection(selection)) {
|
50
49
|
return [selection.$anchorCell, selection.$headCell];
|
51
50
|
}
|
52
|
-
const anchor =
|
53
|
-
const head =
|
51
|
+
const anchor = anchorHit ?? headHit ?? selection.anchor;
|
52
|
+
const head = headHit ?? anchorHit ?? selection.head;
|
54
53
|
const doc = selection.$head.doc;
|
55
54
|
const $anchorCell = findCellPos(doc, anchor);
|
56
55
|
const $headCell = findCellPos(doc, head);
|
@@ -116,7 +115,7 @@ var exitTable = (state, dispatch) => {
|
|
116
115
|
const above = $head.node(tableDepth - 1);
|
117
116
|
const after = $head.indexAfter(tableDepth - 1);
|
118
117
|
const type = defaultBlockAt(above.contentMatchAt(after));
|
119
|
-
const node = type
|
118
|
+
const node = type?.createAndFill();
|
120
119
|
if (!type || !node || !above.canReplaceWith(after, after, type)) {
|
121
120
|
return false;
|
122
121
|
}
|
@@ -130,7 +129,7 @@ var exitTable = (state, dispatch) => {
|
|
130
129
|
};
|
131
130
|
function selectTableColumn(options) {
|
132
131
|
return (state, dispatch) => {
|
133
|
-
const range = findCellRange(state.selection, options
|
132
|
+
const range = findCellRange(state.selection, options?.anchor, options?.head);
|
134
133
|
if (!range) {
|
135
134
|
return false;
|
136
135
|
}
|
@@ -144,7 +143,7 @@ function selectTableColumn(options) {
|
|
144
143
|
}
|
145
144
|
function selectTableRow(options) {
|
146
145
|
return (state, dispatch) => {
|
147
|
-
const range = findCellRange(state.selection, options
|
146
|
+
const range = findCellRange(state.selection, options?.anchor, options?.head);
|
148
147
|
if (!range) {
|
149
148
|
return false;
|
150
149
|
}
|
@@ -158,10 +157,9 @@ function selectTableRow(options) {
|
|
158
157
|
}
|
159
158
|
function selectTableCell(options) {
|
160
159
|
return (state, dispatch) => {
|
161
|
-
var _a;
|
162
160
|
const $cellPos = findCellPos(
|
163
161
|
state.doc,
|
164
|
-
|
162
|
+
options?.pos ?? state.selection.anchor
|
165
163
|
);
|
166
164
|
if (!$cellPos) {
|
167
165
|
return false;
|
@@ -175,7 +173,7 @@ function selectTableCell(options) {
|
|
175
173
|
}
|
176
174
|
function selectTable(options) {
|
177
175
|
return (state, dispatch) => {
|
178
|
-
const $pos =
|
176
|
+
const $pos = options?.pos ? state.doc.resolve(options.pos) : state.selection.$anchor;
|
179
177
|
const table = findTable($pos);
|
180
178
|
if (!table) {
|
181
179
|
return false;
|
@@ -194,7 +192,7 @@ function selectTable(options) {
|
|
194
192
|
const $lastCellPos = tr.doc.resolve(lastCellPos);
|
195
193
|
const selection = new CellSelection2($firstCellPos, $lastCellPos);
|
196
194
|
tr = tr.setSelection(selection);
|
197
|
-
dispatch
|
195
|
+
dispatch?.(tr);
|
198
196
|
}
|
199
197
|
return true;
|
200
198
|
};
|
@@ -54,7 +54,6 @@ function createAutocompletePlugin({
|
|
54
54
|
return { active: false, ignore: null, matching: null };
|
55
55
|
},
|
56
56
|
apply: (tr, prevValue, oldState, newState) => {
|
57
|
-
var _a;
|
58
57
|
const meta = getTrMeta(tr);
|
59
58
|
if (!tr.docChanged && oldState.selection.eq(newState.selection) && !meta) {
|
60
59
|
return prevValue;
|
@@ -63,7 +62,7 @@ function createAutocompletePlugin({
|
|
63
62
|
return meta;
|
64
63
|
}
|
65
64
|
const nextValue = calcPluginState(newState, getRules());
|
66
|
-
if (nextValue.active && prevValue.ignore != null &&
|
65
|
+
if (nextValue.active && prevValue.ignore != null && nextValue.matching?.from === prevValue.ignore) {
|
67
66
|
return prevValue;
|
68
67
|
}
|
69
68
|
return nextValue;
|
@@ -71,13 +70,12 @@ function createAutocompletePlugin({
|
|
71
70
|
},
|
72
71
|
view: () => ({
|
73
72
|
update: (view, prevState) => {
|
74
|
-
var _a, _b, _c;
|
75
73
|
const prevValue = getPluginState(prevState);
|
76
74
|
const currValue = getPluginState(view.state);
|
77
|
-
if (
|
78
|
-
|
75
|
+
if (prevValue?.active && prevValue.matching && prevValue.matching.rule !== currValue?.matching?.rule) {
|
76
|
+
prevValue.matching.rule.onLeave?.();
|
79
77
|
}
|
80
|
-
if (
|
78
|
+
if (currValue?.active && currValue.matching && currValue.matching.from !== currValue.ignore) {
|
81
79
|
const { from, to, match, rule } = currValue.matching;
|
82
80
|
const textContent = view.state.doc.textBetween(
|
83
81
|
from,
|
@@ -118,7 +116,7 @@ function createAutocompletePlugin({
|
|
118
116
|
props: {
|
119
117
|
decorations: (state) => {
|
120
118
|
const pluginState = getPluginState(state);
|
121
|
-
if (
|
119
|
+
if (pluginState?.active && pluginState.matching) {
|
122
120
|
const { from, to } = pluginState.matching;
|
123
121
|
const deco = Decoration.inline(from, to, {
|
124
122
|
class: "prosemirror-prediction-match"
|
@@ -185,11 +183,10 @@ var autocompleteFacet = defineFacet({
|
|
185
183
|
// src/autocomplete/autocomplete-rule.ts
|
186
184
|
var AutocompleteRule = class {
|
187
185
|
constructor(options) {
|
188
|
-
var _a;
|
189
186
|
this.regex = options.regex;
|
190
187
|
this.onMatch = options.onEnter;
|
191
188
|
this.onLeave = options.onLeave;
|
192
|
-
this.canMatch =
|
189
|
+
this.canMatch = options.canMatch ?? defaultCanMatch;
|
193
190
|
}
|
194
191
|
};
|
195
192
|
export {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
2
|
defineWrappingInputRule
|
3
|
-
} from "./chunk-
|
3
|
+
} from "./chunk-BV3SHIMW.js";
|
4
4
|
|
5
5
|
// src/blockquote/blockquote.ts
|
6
6
|
import {
|
@@ -49,7 +49,7 @@ function toggleBlockquoteKeybinding() {
|
|
49
49
|
function backspaceUnsetBlockquote() {
|
50
50
|
return (state, dispatch, view) => {
|
51
51
|
const $pos = isAtBlockStart(state, view);
|
52
|
-
if (
|
52
|
+
if ($pos?.node(-1).type.name === "blockquote") {
|
53
53
|
return joinBackward(state, dispatch, view);
|
54
54
|
}
|
55
55
|
return false;
|
@@ -31,8 +31,7 @@ function defineFileDropHandler(handler) {
|
|
31
31
|
return defineFacetPayload(facet, [handler]);
|
32
32
|
}
|
33
33
|
function getFiles(event) {
|
34
|
-
|
35
|
-
return Array.from((_b = (_a = event.dataTransfer) == null ? void 0 : _a.files) != null ? _b : []);
|
34
|
+
return Array.from(event.dataTransfer?.files ?? []);
|
36
35
|
}
|
37
36
|
var facet = defineFacet({
|
38
37
|
parent: editorEventFacet,
|
@@ -65,8 +64,7 @@ function defineFilePasteHandler(handler) {
|
|
65
64
|
return defineFacetPayload2(facet2, [handler]);
|
66
65
|
}
|
67
66
|
function getFiles2(event) {
|
68
|
-
|
69
|
-
return Array.from((_b = (_a = event.clipboardData) == null ? void 0 : _a.files) != null ? _b : []);
|
67
|
+
return Array.from(event.clipboardData?.files ?? []);
|
70
68
|
}
|
71
69
|
var facet2 = defineFacet2({
|
72
70
|
parent: editorEventFacet2,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
2
|
defineTextBlockInputRule
|
3
|
-
} from "./chunk-
|
3
|
+
} from "./chunk-BV3SHIMW.js";
|
4
4
|
|
5
5
|
// src/heading/heading.ts
|
6
6
|
import {
|
@@ -34,8 +34,7 @@ function defineHeadingInputRule() {
|
|
34
34
|
regex: /^(#{1,6})\s$/,
|
35
35
|
type: "heading",
|
36
36
|
attrs: (match) => {
|
37
|
-
|
38
|
-
const level = (_b = (_a = match[1]) == null ? void 0 : _a.length) != null ? _b : 1;
|
37
|
+
const level = match[1]?.length ?? 1;
|
39
38
|
return { level };
|
40
39
|
}
|
41
40
|
});
|
@@ -54,7 +53,7 @@ function toggleHeadingKeybinding(level) {
|
|
54
53
|
}
|
55
54
|
var backspaceUnsetHeading = (state, dispatch, view) => {
|
56
55
|
const $pos = isAtBlockStart(state, view);
|
57
|
-
if (
|
56
|
+
if ($pos?.parent.type.name === "heading") {
|
58
57
|
return unsetBlockType()(state, dispatch, view);
|
59
58
|
}
|
60
59
|
return false;
|
@@ -3,10 +3,10 @@ import {
|
|
3
3
|
} from "./chunk-6UYLCVBX.js";
|
4
4
|
import {
|
5
5
|
defineEnterRule
|
6
|
-
} from "./chunk-
|
6
|
+
} from "./chunk-D54VSLLS.js";
|
7
7
|
import {
|
8
8
|
defineInputRule
|
9
|
-
} from "./chunk-
|
9
|
+
} from "./chunk-BV3SHIMW.js";
|
10
10
|
|
11
11
|
// src/link/index.ts
|
12
12
|
import {
|
@@ -11,6 +11,7 @@ export { ListCommandsExtension } from './_tsup-dts-rollup.js';
|
|
11
11
|
export { defineListInputRules } from './_tsup-dts-rollup.js';
|
12
12
|
export { defineListKeymap } from './_tsup-dts-rollup.js';
|
13
13
|
export { defineListPlugins } from './_tsup-dts-rollup.js';
|
14
|
+
export { defineListSerializer } from './_tsup-dts-rollup.js';
|
14
15
|
export { defineListSpec } from './_tsup-dts-rollup.js';
|
15
16
|
export { ListSpecExtension } from './_tsup-dts-rollup.js';
|
16
17
|
export { ListAttrs } from './_tsup-dts-rollup.js';
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
2
|
defineInputRule
|
3
|
-
} from "./chunk-
|
3
|
+
} from "./chunk-BV3SHIMW.js";
|
4
4
|
|
5
5
|
// src/list/index.ts
|
6
6
|
import { ListDOMSerializer as ListDOMSerializer2 } from "prosemirror-flat-list";
|
@@ -89,9 +89,65 @@ function defineListKeymap() {
|
|
89
89
|
|
90
90
|
// src/list/list-plugins.ts
|
91
91
|
import { definePlugin } from "@prosekit/core";
|
92
|
-
import {
|
92
|
+
import { Plugin } from "@prosekit/pm/state";
|
93
|
+
import {
|
94
|
+
createListEventPlugin,
|
95
|
+
createListRenderingPlugin,
|
96
|
+
createSafariInputMethodWorkaroundPlugin,
|
97
|
+
unwrapListSlice
|
98
|
+
} from "prosemirror-flat-list";
|
99
|
+
function createListClipboardPlugin() {
|
100
|
+
return new Plugin({
|
101
|
+
props: {
|
102
|
+
transformCopied: unwrapListSlice
|
103
|
+
}
|
104
|
+
});
|
105
|
+
}
|
106
|
+
function createListPlugins() {
|
107
|
+
return [
|
108
|
+
createListEventPlugin(),
|
109
|
+
createListRenderingPlugin(),
|
110
|
+
createListClipboardPlugin(),
|
111
|
+
createSafariInputMethodWorkaroundPlugin()
|
112
|
+
];
|
113
|
+
}
|
93
114
|
function defineListPlugins() {
|
94
|
-
return definePlugin(
|
115
|
+
return definePlugin(createListPlugins);
|
116
|
+
}
|
117
|
+
|
118
|
+
// src/list/list-serializer.ts
|
119
|
+
import {
|
120
|
+
defineClipboardSerializer,
|
121
|
+
isElement
|
122
|
+
} from "@prosekit/core";
|
123
|
+
import {
|
124
|
+
joinListElements,
|
125
|
+
listToDOM
|
126
|
+
} from "prosemirror-flat-list";
|
127
|
+
function defineListSerializer() {
|
128
|
+
return defineClipboardSerializer({
|
129
|
+
serializeFragmentWrapper: (fn) => {
|
130
|
+
return (...args) => {
|
131
|
+
const dom = fn(...args);
|
132
|
+
return joinListElements(dom);
|
133
|
+
};
|
134
|
+
},
|
135
|
+
serializeNodeWrapper: (fn) => {
|
136
|
+
return (...args) => {
|
137
|
+
const dom = fn(...args);
|
138
|
+
return isElement(dom) ? joinListElements(dom) : dom;
|
139
|
+
};
|
140
|
+
},
|
141
|
+
nodesFromSchemaWrapper: (fn) => {
|
142
|
+
return (...args) => {
|
143
|
+
const nodes = fn(...args);
|
144
|
+
return {
|
145
|
+
...nodes,
|
146
|
+
list: (node) => listToDOM({ node, nativeList: true, getMarkers: () => null })
|
147
|
+
};
|
148
|
+
};
|
149
|
+
}
|
150
|
+
});
|
95
151
|
}
|
96
152
|
|
97
153
|
// src/list/list-spec.ts
|
@@ -114,7 +170,8 @@ function defineList() {
|
|
114
170
|
defineListPlugins(),
|
115
171
|
defineListKeymap(),
|
116
172
|
defineListInputRules(),
|
117
|
-
defineListCommands()
|
173
|
+
defineListCommands(),
|
174
|
+
defineListSerializer()
|
118
175
|
);
|
119
176
|
}
|
120
177
|
export {
|
@@ -124,5 +181,6 @@ export {
|
|
124
181
|
defineListInputRules,
|
125
182
|
defineListKeymap,
|
126
183
|
defineListPlugins,
|
184
|
+
defineListSerializer,
|
127
185
|
defineListSpec
|
128
186
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
2
|
findTable
|
3
|
-
} from "./chunk-
|
3
|
+
} from "./chunk-HFAZX2J3.js";
|
4
4
|
|
5
5
|
// src/placeholder/index.ts
|
6
6
|
import {
|
@@ -48,8 +48,7 @@ function docStrategy(state) {
|
|
48
48
|
return isDocEmpty(state.doc) && defaultStrategy(state);
|
49
49
|
}
|
50
50
|
function isDocEmpty(doc) {
|
51
|
-
|
52
|
-
return doc.childCount <= 1 && !((_a = doc.firstChild) == null ? void 0 : _a.content.size);
|
51
|
+
return doc.childCount <= 1 && !doc.firstChild?.content.size;
|
53
52
|
}
|
54
53
|
function createPlaceholderDecoration(state, placeholderText) {
|
55
54
|
if (!placeholderText) return null;
|
@@ -22,7 +22,7 @@ function defineSearchQuery(options) {
|
|
22
22
|
function scrollActiveIntoView(view) {
|
23
23
|
if (view.isDestroyed) return;
|
24
24
|
const active = view.dom.querySelector(".ProseMirror-active-search-match");
|
25
|
-
active
|
25
|
+
active?.scrollIntoView({
|
26
26
|
block: "nearest",
|
27
27
|
inline: "nearest",
|
28
28
|
behavior: "smooth"
|
@@ -42,7 +42,7 @@ function fixYUndoPlugin(yUndoPluginInstance) {
|
|
42
42
|
);
|
43
43
|
undoManager._observers = observers;
|
44
44
|
};
|
45
|
-
if (viewRet
|
45
|
+
if (viewRet?.destroy) {
|
46
46
|
viewRet.destroy();
|
47
47
|
}
|
48
48
|
}
|
@@ -125,9 +125,8 @@ function defineYjsSyncPlugin(options) {
|
|
125
125
|
|
126
126
|
// src/yjs/yjs.ts
|
127
127
|
function defineYjs(options) {
|
128
|
-
var _a;
|
129
128
|
const { doc, awareness, sync, undo: undo2, cursor } = options;
|
130
|
-
const fragment =
|
129
|
+
const fragment = options.fragment ?? doc.getXmlFragment("prosemirror");
|
131
130
|
return withPriority(
|
132
131
|
union([
|
133
132
|
defineYjsKeymap(),
|
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.24",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -218,9 +218,9 @@
|
|
218
218
|
"prosemirror-gapcursor": "^1.3.2",
|
219
219
|
"prosemirror-highlight": "^0.11.0",
|
220
220
|
"prosemirror-search": "^1.0.0",
|
221
|
-
"prosemirror-tables": "^1.6.
|
222
|
-
"shiki": "^1.
|
223
|
-
"@prosekit/core": "^0.7.
|
221
|
+
"prosemirror-tables": "^1.6.2",
|
222
|
+
"shiki": "^1.26.2",
|
223
|
+
"@prosekit/core": "^0.7.15",
|
224
224
|
"@prosekit/pm": "^0.1.9"
|
225
225
|
},
|
226
226
|
"peerDependencies": {
|
@@ -244,22 +244,23 @@
|
|
244
244
|
}
|
245
245
|
},
|
246
246
|
"devDependencies": {
|
247
|
-
"@vitest/browser": "^
|
247
|
+
"@vitest/browser": "^3.0.4",
|
248
248
|
"just-pick": "^4.2.0",
|
249
|
-
"loro-crdt": "^1.
|
250
|
-
"loro-prosemirror": "^0.2.
|
249
|
+
"loro-crdt": "^1.3.0",
|
250
|
+
"loro-prosemirror": "^0.2.1",
|
251
|
+
"prettier": "^3.4.2",
|
251
252
|
"tsup": "^8.3.5",
|
252
|
-
"type-fest": "^4.
|
253
|
-
"typescript": "~5.
|
254
|
-
"vitest": "^
|
253
|
+
"type-fest": "^4.32.0",
|
254
|
+
"typescript": "~5.7.2",
|
255
|
+
"vitest": "^3.0.4",
|
255
256
|
"y-prosemirror": "^1.2.15",
|
256
257
|
"y-protocols": "^1.0.6",
|
257
|
-
"yjs": "^13.6.
|
258
|
+
"yjs": "^13.6.22",
|
258
259
|
"@prosekit/dev": "0.0.0"
|
259
260
|
},
|
260
261
|
"scripts": {
|
261
|
-
"build:
|
262
|
-
"build:
|
262
|
+
"build:tsc": "tsc -b tsconfig.json",
|
263
|
+
"build:tsup": "tsup"
|
263
264
|
},
|
264
265
|
"types": "./dist/prosekit-extensions.d.ts",
|
265
266
|
"typesVersions": {
|