@prosekit/core 0.0.0-next-20240724172520 → 0.0.0-next-20240901092634
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 +413 -120
- package/dist/{chunk-MOSGJZHV.js → chunk-RNBMCB5M.js} +363 -258
- package/dist/prosekit-core-test.js +16 -19
- package/dist/prosekit-core.d.ts +10 -1
- package/dist/prosekit-core.js +321 -305
- package/package.json +9 -6
@@ -4,11 +4,15 @@ import {
|
|
4
4
|
assert,
|
5
5
|
createMarkActions,
|
6
6
|
createNodeActions,
|
7
|
+
isProseMirrorNode,
|
7
8
|
setupEditorExtension
|
8
|
-
} from "./chunk-
|
9
|
+
} from "./chunk-RNBMCB5M.js";
|
9
10
|
|
10
11
|
// src/test/test-editor.ts
|
11
|
-
import {
|
12
|
+
import {
|
13
|
+
NodeSelection,
|
14
|
+
TextSelection
|
15
|
+
} from "@prosekit/pm/state";
|
12
16
|
|
13
17
|
// src/test/test-builder.ts
|
14
18
|
var createNodeForTest = (type, attrs, children) => {
|
@@ -53,7 +57,7 @@ var createNodeForTest = (type, attrs, children) => {
|
|
53
57
|
};
|
54
58
|
var applyMarkForTest = (mark, children) => {
|
55
59
|
return children.map((node) => {
|
56
|
-
const newNode = node.mark(
|
60
|
+
const newNode = node.mark(mark.addToSet(node.marks));
|
57
61
|
newNode.tags = node.tags;
|
58
62
|
return newNode;
|
59
63
|
});
|
@@ -85,6 +89,12 @@ var TestEditorInstance = class extends EditorInstance {
|
|
85
89
|
this.nodes = createNodeActions(this.schema, this.getState, createNodeForTest);
|
86
90
|
this.marks = createMarkActions(this.schema, this.getState, applyMarkForTest);
|
87
91
|
}
|
92
|
+
setContent(content, selection) {
|
93
|
+
return super.setContent(
|
94
|
+
content,
|
95
|
+
isProseMirrorNode(content) && !selection ? getSelection(content) : selection
|
96
|
+
);
|
97
|
+
}
|
88
98
|
};
|
89
99
|
var TestEditor = class extends Editor {
|
90
100
|
constructor(instance) {
|
@@ -104,21 +114,7 @@ var TestEditor = class extends Editor {
|
|
104
114
|
* ```
|
105
115
|
*/
|
106
116
|
set(doc) {
|
107
|
-
|
108
|
-
doc.type.schema === this.schema,
|
109
|
-
"Document schema does not match editor schema"
|
110
|
-
);
|
111
|
-
assert(
|
112
|
-
doc.type === this.schema.topNodeType,
|
113
|
-
"Document type does not match editor top node type"
|
114
|
-
);
|
115
|
-
const selection = getSelection(doc);
|
116
|
-
const state = EditorState.create({
|
117
|
-
doc,
|
118
|
-
selection,
|
119
|
-
plugins: this.state.plugins
|
120
|
-
});
|
121
|
-
this.updateState(state);
|
117
|
+
return this.setContent(doc);
|
122
118
|
}
|
123
119
|
dispatchEvent(event) {
|
124
120
|
this.view.dispatchEvent(event);
|
@@ -126,7 +122,8 @@ var TestEditor = class extends Editor {
|
|
126
122
|
};
|
127
123
|
function createTestEditor(options) {
|
128
124
|
const extension = setupEditorExtension(options);
|
129
|
-
|
125
|
+
const instance = new TestEditorInstance(extension);
|
126
|
+
return new TestEditor(instance);
|
130
127
|
}
|
131
128
|
export {
|
132
129
|
createTestEditor
|
package/dist/prosekit-core.d.ts
CHANGED
@@ -4,6 +4,8 @@ export { expandMark } from './_tsup-dts-rollup';
|
|
4
4
|
export { ExpandMarkOptions } from './_tsup-dts-rollup';
|
5
5
|
export { insertNode } from './_tsup-dts-rollup';
|
6
6
|
export { InsertNodeOptions } from './_tsup-dts-rollup';
|
7
|
+
export { insertDefaultBlock } from './_tsup-dts-rollup';
|
8
|
+
export { InsertDefaultBlockOptions } from './_tsup-dts-rollup';
|
7
9
|
export { removeMark } from './_tsup-dts-rollup';
|
8
10
|
export { RemoveMarkOptions } from './_tsup-dts-rollup';
|
9
11
|
export { removeNode } from './_tsup-dts-rollup';
|
@@ -104,7 +106,6 @@ export { defineParagraph } from './_tsup-dts-rollup';
|
|
104
106
|
export { ParagraphExtension } from './_tsup-dts-rollup';
|
105
107
|
export { definePlugin } from './_tsup-dts-rollup';
|
106
108
|
export { pluginFacet } from './_tsup-dts-rollup';
|
107
|
-
export { PluginExtension } from './_tsup-dts-rollup';
|
108
109
|
export { PluginPayload } from './_tsup-dts-rollup';
|
109
110
|
export { defineText } from './_tsup-dts-rollup';
|
110
111
|
export { TextExtension } from './_tsup-dts-rollup';
|
@@ -123,6 +124,7 @@ export { ExtractMarkActions } from './_tsup-dts-rollup';
|
|
123
124
|
export { ExtractMarks } from './_tsup-dts-rollup';
|
124
125
|
export { ExtractNodeActions } from './_tsup-dts-rollup';
|
125
126
|
export { ExtractNodes } from './_tsup-dts-rollup';
|
127
|
+
export { PlainExtension } from './_tsup-dts-rollup';
|
126
128
|
export { Union } from './_tsup-dts-rollup';
|
127
129
|
export { UnionExtension } from './_tsup-dts-rollup';
|
128
130
|
export { CommandAction } from './_tsup-dts-rollup';
|
@@ -142,11 +144,15 @@ export { SimplifyUnion } from './_tsup-dts-rollup';
|
|
142
144
|
export { assert } from './_tsup-dts-rollup';
|
143
145
|
export { canUseRegexLookbehind } from './_tsup-dts-rollup';
|
144
146
|
export { clsx } from './_tsup-dts-rollup';
|
147
|
+
export { collectChildren } from './_tsup-dts-rollup';
|
145
148
|
export { collectNodes } from './_tsup-dts-rollup';
|
146
149
|
export { NodeContent } from './_tsup-dts-rollup';
|
147
150
|
export { containsInlineNode } from './_tsup-dts-rollup';
|
148
151
|
export { defaultBlockAt } from './_tsup-dts-rollup';
|
149
152
|
export { isApple } from './_tsup-dts-rollup';
|
153
|
+
export { findParentNode } from './_tsup-dts-rollup';
|
154
|
+
export { FindParentNodeResult } from './_tsup-dts-rollup';
|
155
|
+
export { findParentNodeOfType } from './_tsup-dts-rollup';
|
150
156
|
export { _getId } from './_tsup-dts-rollup';
|
151
157
|
export { getMarkType } from './_tsup-dts-rollup';
|
152
158
|
export { getNodeType } from './_tsup-dts-rollup';
|
@@ -171,9 +177,12 @@ export { DOMParserOptions } from './_tsup-dts-rollup';
|
|
171
177
|
export { DOMSerializerOptions } from './_tsup-dts-rollup';
|
172
178
|
export { JSONParserOptions } from './_tsup-dts-rollup';
|
173
179
|
export { isAllSelection } from './_tsup-dts-rollup';
|
180
|
+
export { isFragment } from './_tsup-dts-rollup';
|
174
181
|
export { isMark } from './_tsup-dts-rollup';
|
175
182
|
export { isNodeSelection } from './_tsup-dts-rollup';
|
176
183
|
export { isProseMirrorNode } from './_tsup-dts-rollup';
|
184
|
+
export { isSelection } from './_tsup-dts-rollup';
|
185
|
+
export { isSlice } from './_tsup-dts-rollup';
|
177
186
|
export { isTextSelection } from './_tsup-dts-rollup';
|
178
187
|
export { withSkipCodeBlock } from './_tsup-dts-rollup';
|
179
188
|
export { OBJECT_REPLACEMENT_CHARACTER } from './_tsup-dts-rollup';
|