@handlewithcare/react-prosemirror 2.8.0-tiptap.10 → 2.8.0-tiptap.11
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/cjs/tiptap/tiptapNodeView.js +26 -13
- package/dist/esm/tiptap/tiptapNodeView.js +27 -14
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/props.d.ts +26 -26
- package/package.json +1 -1
- package/dist/esm/@jest/pattern/src/__tests__/TestPathPatterns.test.js +0 -241
- package/dist/esm/@swc/cli/lib/swc/__tests__/compile.test.js +0 -19
- package/dist/esm/@swc/cli/lib/swc/__tests__/options.test.js +0 -315
- package/dist/esm/@swc/cli/lib/swc/__tests__/sources.test.js +0 -161
- package/dist/esm/@uiw/react-codemirror/src/__tests__/index.test.js +0 -111
- package/dist/esm/cheerio/src/__tests__/deprecated.spec.js +0 -249
- package/dist/esm/cheerio/src/__tests__/xml.spec.js +0 -55
- package/dist/esm/components/__tests__/ProseMirror.composition.test.js +0 -395
- package/dist/esm/components/__tests__/ProseMirror.domchange.test.js +0 -266
- package/dist/esm/components/__tests__/ProseMirror.draw-decoration.test.js +0 -968
- package/dist/esm/components/__tests__/ProseMirror.draw.test.js +0 -335
- package/dist/esm/components/__tests__/ProseMirror.mobile.test.js +0 -54
- package/dist/esm/components/__tests__/ProseMirror.node-view.test.js +0 -553
- package/dist/esm/components/__tests__/ProseMirror.selection.test.js +0 -440
- package/dist/esm/components/__tests__/ProseMirror.test.js +0 -324
- package/dist/esm/contexts/__tests__/DeferredLayoutEffects.test.js +0 -98
- package/dist/esm/hooks/__tests__/useEditorEffect.test.js +0 -134
- package/dist/esm/jsx-ast-utils/__tests__/helper.js +0 -83
- package/dist/esm/jsx-ast-utils/__tests__/src/elementType-test.js +0 -76
- package/dist/esm/jsx-ast-utils/__tests__/src/eventHandlers-test.js +0 -98
- package/dist/esm/jsx-ast-utils/__tests__/src/getProp-parser-test.js +0 -188
- package/dist/esm/jsx-ast-utils/__tests__/src/getProp-test.js +0 -119
- package/dist/esm/jsx-ast-utils/__tests__/src/getPropLiteralValue-babelparser-test.js +0 -393
- package/dist/esm/jsx-ast-utils/__tests__/src/getPropLiteralValue-flowparser-test.js +0 -379
- package/dist/esm/jsx-ast-utils/__tests__/src/getPropValue-babelparser-test.js +0 -925
- package/dist/esm/jsx-ast-utils/__tests__/src/getPropValue-flowparser-test.js +0 -700
- package/dist/esm/jsx-ast-utils/__tests__/src/hasProp-test.js +0 -350
- package/dist/esm/jsx-ast-utils/__tests__/src/index-test.js +0 -24
- package/dist/esm/jsx-ast-utils/__tests__/src/propName-test.js +0 -37
- package/dist/esm/plugins/__tests__/reactKeys.test.js +0 -77
- package/dist/esm/tsconfig-paths/lib/__tests__/config-loader.test.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/config-loader.test.js +0 -97
- package/dist/esm/tsconfig-paths/lib/__tests__/data/match-path-data.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/data/match-path-data.js +0 -319
- package/dist/esm/tsconfig-paths/lib/__tests__/filesystem.test.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/filesystem.test.js +0 -62
- package/dist/esm/tsconfig-paths/lib/__tests__/mapping-entry.test.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/mapping-entry.test.js +0 -80
- package/dist/esm/tsconfig-paths/lib/__tests__/match-path-async.test.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/match-path-async.test.js +0 -22
- package/dist/esm/tsconfig-paths/lib/__tests__/match-path-sync.test.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/match-path-sync.test.js +0 -20
- package/dist/esm/tsconfig-paths/lib/__tests__/try-path.test.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/try-path.test.js +0 -219
- package/dist/esm/tsconfig-paths/lib/__tests__/tsconfig-loader.test.d.js +0 -1
- package/dist/esm/tsconfig-paths/lib/__tests__/tsconfig-loader.test.js +0 -323
- package/dist/esm/tsconfig-paths/src/__tests__/config-loader.test.js +0 -89
- package/dist/esm/tsconfig-paths/src/__tests__/data/match-path-data.js +0 -314
- package/dist/esm/tsconfig-paths/src/__tests__/filesystem.test.js +0 -58
- package/dist/esm/tsconfig-paths/src/__tests__/mapping-entry.test.js +0 -76
- package/dist/esm/tsconfig-paths/src/__tests__/match-path-async.test.js +0 -12
- package/dist/esm/tsconfig-paths/src/__tests__/match-path-sync.test.js +0 -10
- package/dist/esm/tsconfig-paths/src/__tests__/try-path.test.js +0 -214
- package/dist/esm/tsconfig-paths/src/__tests__/tsconfig-loader.test.js +0 -296
|
@@ -1,335 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */ import { Schema } from "prosemirror-model";
|
|
2
|
-
import { Plugin } from "prosemirror-state";
|
|
3
|
-
import { builders, doc, h1, hr, img, p, pre, schema, strong } from "prosemirror-test-builder";
|
|
4
|
-
import React, { forwardRef } from "react";
|
|
5
|
-
import { tempEditor } from "../../testing/editorViewTestHelpers.js";
|
|
6
|
-
describe("EditorView draw", ()=>{
|
|
7
|
-
it("updates the DOM", async ()=>{
|
|
8
|
-
const { view } = tempEditor({
|
|
9
|
-
doc: doc(p("foo"))
|
|
10
|
-
});
|
|
11
|
-
view.dispatch(view.state.tr.insertText("bar"));
|
|
12
|
-
expect(view.dom.textContent).toBe("barfoo");
|
|
13
|
-
});
|
|
14
|
-
it("doesn't redraw nodes after changes", async ()=>{
|
|
15
|
-
const { view } = tempEditor({
|
|
16
|
-
doc: doc(h1("foo<a>"), p("bar"))
|
|
17
|
-
});
|
|
18
|
-
const oldP = view.dom.querySelector("p");
|
|
19
|
-
view.dispatch(view.state.tr.insertText("!"));
|
|
20
|
-
expect(view.dom.querySelector("p")).toBe(oldP);
|
|
21
|
-
});
|
|
22
|
-
it("doesn't redraw nodes before changes", async ()=>{
|
|
23
|
-
const { view } = tempEditor({
|
|
24
|
-
doc: doc(p("foo"), h1("bar"))
|
|
25
|
-
});
|
|
26
|
-
const oldP = view.dom.querySelector("p");
|
|
27
|
-
view.dispatch(view.state.tr.insertText("!", 2));
|
|
28
|
-
expect(view.dom.querySelector("p")).toBe(oldP);
|
|
29
|
-
});
|
|
30
|
-
it("doesn't redraw nodes between changes", async ()=>{
|
|
31
|
-
const { view } = tempEditor({
|
|
32
|
-
doc: doc(p("foo"), h1("bar"), pre("baz"))
|
|
33
|
-
});
|
|
34
|
-
const oldP = view.dom.querySelector("p");
|
|
35
|
-
const oldPre = view.dom.querySelector("pre");
|
|
36
|
-
view.dispatch(view.state.tr.insertText("!", 2));
|
|
37
|
-
expect(view.dom.querySelector("p")).toBe(oldP);
|
|
38
|
-
expect(view.dom.querySelector("pre")).toBe(oldPre);
|
|
39
|
-
});
|
|
40
|
-
it("doesn't redraw siblings of a split node", async ()=>{
|
|
41
|
-
const { view } = tempEditor({
|
|
42
|
-
doc: doc(p("foo"), h1("bar"), pre("baz"))
|
|
43
|
-
});
|
|
44
|
-
const oldP = view.dom.querySelector("p");
|
|
45
|
-
const oldPre = view.dom.querySelector("pre");
|
|
46
|
-
view.dispatch(view.state.tr.split(8));
|
|
47
|
-
expect(view.dom.querySelector("p")).toBe(oldP);
|
|
48
|
-
expect(view.dom.querySelector("pre")).toBe(oldPre);
|
|
49
|
-
});
|
|
50
|
-
it("doesn't redraw siblings of a joined node", async ()=>{
|
|
51
|
-
const { view } = tempEditor({
|
|
52
|
-
doc: doc(p("foo"), h1("bar"), h1("x"), pre("baz"))
|
|
53
|
-
});
|
|
54
|
-
const oldP = view.dom.querySelector("p");
|
|
55
|
-
const oldPre = view.dom.querySelector("pre");
|
|
56
|
-
view.dispatch(view.state.tr.join(10));
|
|
57
|
-
expect(view.dom.querySelector("p")).toBe(oldP);
|
|
58
|
-
expect(view.dom.querySelector("pre")).toBe(oldPre);
|
|
59
|
-
});
|
|
60
|
-
it("doesn't redraw after a big deletion", async ()=>{
|
|
61
|
-
const { view } = tempEditor({
|
|
62
|
-
doc: doc(p(), p(), p(), p(), p(), p(), p(), p(), h1("!"), p(), p())
|
|
63
|
-
});
|
|
64
|
-
const oldH = view.dom.querySelector("h1");
|
|
65
|
-
view.dispatch(view.state.tr.delete(2, 14));
|
|
66
|
-
expect(view.dom.querySelector("h1")).toBe(oldH);
|
|
67
|
-
});
|
|
68
|
-
it("adds classes from the attributes prop", async ()=>{
|
|
69
|
-
const { view, rerender } = tempEditor({
|
|
70
|
-
doc: doc(p()),
|
|
71
|
-
attributes: {
|
|
72
|
-
class: "foo bar"
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
expect(view.dom.classList.contains("foo")).toBeTruthy();
|
|
76
|
-
expect(view.dom.classList.contains("bar")).toBeTruthy();
|
|
77
|
-
expect(view.dom.classList.contains("ProseMirror")).toBeTruthy();
|
|
78
|
-
rerender({
|
|
79
|
-
attributes: {
|
|
80
|
-
class: "baz"
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
expect(!view.dom.classList.contains("foo")).toBeTruthy();
|
|
84
|
-
expect(view.dom.classList.contains("baz")).toBeTruthy();
|
|
85
|
-
});
|
|
86
|
-
it("adds style from the attributes prop", async ()=>{
|
|
87
|
-
const { view } = tempEditor({
|
|
88
|
-
doc: doc(p()),
|
|
89
|
-
attributes: {
|
|
90
|
-
style: "border: 1px solid red;"
|
|
91
|
-
},
|
|
92
|
-
plugins: [
|
|
93
|
-
new Plugin({
|
|
94
|
-
props: {
|
|
95
|
-
attributes: {
|
|
96
|
-
style: "background: red;"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}),
|
|
100
|
-
new Plugin({
|
|
101
|
-
props: {
|
|
102
|
-
attributes: {
|
|
103
|
-
style: "color: red;"
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
]
|
|
108
|
-
});
|
|
109
|
-
expect(view.dom.style.border).toBe("1px solid red");
|
|
110
|
-
expect(view.dom.style.backgroundColor).toBe("red");
|
|
111
|
-
expect(view.dom.style.color).toBe("red");
|
|
112
|
-
});
|
|
113
|
-
it("can set other attributes", async ()=>{
|
|
114
|
-
const { view, rerender } = tempEditor({
|
|
115
|
-
doc: doc(p()),
|
|
116
|
-
attributes: {
|
|
117
|
-
spellcheck: "false",
|
|
118
|
-
"aria-label": "hello"
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
expect(view.dom.spellcheck).toBe(false);
|
|
122
|
-
expect(view.dom.getAttribute("aria-label")).toBe("hello");
|
|
123
|
-
rerender({
|
|
124
|
-
attributes: {
|
|
125
|
-
style: "background-color: yellow"
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
expect(view.dom.hasAttribute("aria-label")).toBe(false);
|
|
129
|
-
expect(view.dom.style.backgroundColor).toBe("yellow");
|
|
130
|
-
});
|
|
131
|
-
it("can't set the contenteditable attribute", async ()=>{
|
|
132
|
-
const { view } = tempEditor({
|
|
133
|
-
doc: doc(p()),
|
|
134
|
-
attributes: {
|
|
135
|
-
contenteditable: "false"
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
expect(view.dom.contentEditable).toBe("true");
|
|
139
|
-
});
|
|
140
|
-
it("understands the editable prop", async ()=>{
|
|
141
|
-
const { view, rerender } = tempEditor({
|
|
142
|
-
doc: doc(p()),
|
|
143
|
-
editable: ()=>false
|
|
144
|
-
});
|
|
145
|
-
expect(view.dom.contentEditable).toBe("false");
|
|
146
|
-
rerender({
|
|
147
|
-
editable: ()=>true
|
|
148
|
-
});
|
|
149
|
-
expect(view.dom.contentEditable).toBe("true");
|
|
150
|
-
});
|
|
151
|
-
it("doesn't redraw following paragraphs when a paragraph is split", async ()=>{
|
|
152
|
-
const { view } = tempEditor({
|
|
153
|
-
doc: doc(p("abcde"), p("fg"))
|
|
154
|
-
});
|
|
155
|
-
const lastPara = view.dom.lastChild;
|
|
156
|
-
view.dispatch(view.state.tr.split(3));
|
|
157
|
-
expect(view.dom.lastChild).toBe(lastPara);
|
|
158
|
-
});
|
|
159
|
-
it("doesn't greedily match nodes that have another match", async ()=>{
|
|
160
|
-
const { view } = tempEditor({
|
|
161
|
-
doc: doc(p("a"), p("b"), p())
|
|
162
|
-
});
|
|
163
|
-
const secondPara = view.dom.querySelectorAll("p")[1];
|
|
164
|
-
view.dispatch(view.state.tr.split(2));
|
|
165
|
-
expect(view.dom.querySelectorAll("p")[2]).toBe(secondPara);
|
|
166
|
-
});
|
|
167
|
-
it("creates, updates, and destroys plugin views", async ()=>{
|
|
168
|
-
const events = [];
|
|
169
|
-
let PluginView = class PluginView {
|
|
170
|
-
update() {
|
|
171
|
-
events.push("update");
|
|
172
|
-
}
|
|
173
|
-
destroy() {
|
|
174
|
-
events.push("destroy");
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
const plugin = new Plugin({
|
|
178
|
-
view () {
|
|
179
|
-
events.push("create");
|
|
180
|
-
return new PluginView();
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
const { view, unmount } = tempEditor({
|
|
184
|
-
plugins: [
|
|
185
|
-
plugin
|
|
186
|
-
]
|
|
187
|
-
});
|
|
188
|
-
view.dispatch(view.state.tr.insertText("u"));
|
|
189
|
-
unmount();
|
|
190
|
-
expect(events.join(" ")).toBe("create update destroy");
|
|
191
|
-
});
|
|
192
|
-
it("redraws changed node views", async ()=>{
|
|
193
|
-
const { view, rerender } = tempEditor({
|
|
194
|
-
doc: doc(p("foo"), hr())
|
|
195
|
-
});
|
|
196
|
-
expect(view.dom.querySelector("hr")).toBeTruthy();
|
|
197
|
-
rerender({
|
|
198
|
-
nodeViews: {
|
|
199
|
-
horizontal_rule: /*#__PURE__*/ forwardRef(function HorizontalRule(param, ref) {
|
|
200
|
-
let { nodeProps, ...props } = param;
|
|
201
|
-
return /*#__PURE__*/ React.createElement("var", {
|
|
202
|
-
...props,
|
|
203
|
-
ref: ref
|
|
204
|
-
});
|
|
205
|
-
})
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
expect(!view.dom.querySelector("hr")).toBeTruthy();
|
|
209
|
-
expect(view.dom.querySelector("var")).toBeTruthy();
|
|
210
|
-
});
|
|
211
|
-
it("doesn't get confused by merged nodes", async ()=>{
|
|
212
|
-
const { view } = tempEditor({
|
|
213
|
-
doc: doc(p(strong("one"), " two ", strong("three")))
|
|
214
|
-
});
|
|
215
|
-
view.dispatch(view.state.tr.removeMark(1, 4, schema.marks.strong));
|
|
216
|
-
expect(view.dom.querySelectorAll("strong")).toHaveLength(1);
|
|
217
|
-
});
|
|
218
|
-
it("doesn't redraw too much when marks are present", async ()=>{
|
|
219
|
-
const s = new Schema({
|
|
220
|
-
nodes: {
|
|
221
|
-
doc: {
|
|
222
|
-
content: "paragraph+",
|
|
223
|
-
marks: "m"
|
|
224
|
-
},
|
|
225
|
-
text: {
|
|
226
|
-
group: "inline"
|
|
227
|
-
},
|
|
228
|
-
paragraph: schema.spec.nodes.get("paragraph")
|
|
229
|
-
},
|
|
230
|
-
marks: {
|
|
231
|
-
m: {
|
|
232
|
-
toDOM: ()=>[
|
|
233
|
-
"div",
|
|
234
|
-
{
|
|
235
|
-
class: "m"
|
|
236
|
-
},
|
|
237
|
-
0
|
|
238
|
-
],
|
|
239
|
-
parseDOM: [
|
|
240
|
-
{
|
|
241
|
-
tag: "div.m"
|
|
242
|
-
}
|
|
243
|
-
]
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
const paragraphs = [];
|
|
248
|
-
for(let i = 1; i <= 10; i++)paragraphs.push(s.node("paragraph", null, [
|
|
249
|
-
s.text("para " + i)
|
|
250
|
-
], [
|
|
251
|
-
s.mark("m")
|
|
252
|
-
]));
|
|
253
|
-
const { view } = tempEditor({
|
|
254
|
-
// @ts-expect-error this is fine
|
|
255
|
-
doc: s.node("doc", null, paragraphs)
|
|
256
|
-
});
|
|
257
|
-
const initialChildren = Array.from(view.dom.querySelectorAll("p"));
|
|
258
|
-
const newParagraphs = [];
|
|
259
|
-
for(let i = -6; i < 0; i++)newParagraphs.push(s.node("paragraph", null, [
|
|
260
|
-
s.text("para " + i)
|
|
261
|
-
], [
|
|
262
|
-
s.mark("m")
|
|
263
|
-
]));
|
|
264
|
-
view.dispatch(view.state.tr.replaceWith(0, 8, newParagraphs));
|
|
265
|
-
const currentChildren = Array.from(view.dom.querySelectorAll("p"));
|
|
266
|
-
let sameAtEnd = 0;
|
|
267
|
-
while(sameAtEnd < currentChildren.length && sameAtEnd < initialChildren.length && currentChildren[currentChildren.length - sameAtEnd - 1] == initialChildren[initialChildren.length - sameAtEnd - 1])sameAtEnd++;
|
|
268
|
-
expect(sameAtEnd).toBe(9);
|
|
269
|
-
});
|
|
270
|
-
it("correctly wraps inline nodes with marks", async ()=>{
|
|
271
|
-
const { view } = tempEditor({
|
|
272
|
-
doc: doc(p(strong(img(), " two")))
|
|
273
|
-
});
|
|
274
|
-
const docDom = view.dom;
|
|
275
|
-
const paragraphDom = docDom.firstElementChild;
|
|
276
|
-
const strongDom = paragraphDom.firstElementChild;
|
|
277
|
-
expect(strongDom?.tagName).toBe("STRONG");
|
|
278
|
-
expect(strongDom?.firstElementChild?.tagName).toBe("IMG");
|
|
279
|
-
expect(strongDom?.childNodes.item(1).textContent).toBe(" two");
|
|
280
|
-
});
|
|
281
|
-
it("correctly wraps block nodes with marks", async ()=>{
|
|
282
|
-
const testSchema = new Schema({
|
|
283
|
-
nodes: schema.spec.nodes.update("image", {
|
|
284
|
-
...schema.spec.nodes.get("image"),
|
|
285
|
-
inline: false,
|
|
286
|
-
group: "block"
|
|
287
|
-
}),
|
|
288
|
-
marks: schema.spec.marks.addToEnd("difficulty", {
|
|
289
|
-
attrs: {
|
|
290
|
-
level: {
|
|
291
|
-
default: "beginner"
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
toDOM (mark) {
|
|
295
|
-
return [
|
|
296
|
-
"div",
|
|
297
|
-
{
|
|
298
|
-
"data-difficulty": mark.attrs["level"]
|
|
299
|
-
},
|
|
300
|
-
0
|
|
301
|
-
];
|
|
302
|
-
}
|
|
303
|
-
})
|
|
304
|
-
});
|
|
305
|
-
const { doc, image, difficulty } = builders(testSchema);
|
|
306
|
-
const { view } = tempEditor({
|
|
307
|
-
doc: doc(difficulty(image({
|
|
308
|
-
src: ""
|
|
309
|
-
})))
|
|
310
|
-
});
|
|
311
|
-
const docDom = view.dom;
|
|
312
|
-
const difficultyDom = docDom.firstElementChild;
|
|
313
|
-
const imageDom = difficultyDom.firstElementChild;
|
|
314
|
-
expect(difficultyDom.tagName).toBe("DIV");
|
|
315
|
-
expect(difficultyDom.dataset["difficulty"]).toBe("beginner");
|
|
316
|
-
expect(imageDom.tagName).toBe("IMG");
|
|
317
|
-
});
|
|
318
|
-
it("supports omitting the hole in mark specs", async ()=>{
|
|
319
|
-
const testSchema = new Schema({
|
|
320
|
-
nodes: schema.spec.nodes,
|
|
321
|
-
marks: schema.spec.marks.addToEnd("bold", {
|
|
322
|
-
toDOM () {
|
|
323
|
-
return [
|
|
324
|
-
"strong"
|
|
325
|
-
];
|
|
326
|
-
}
|
|
327
|
-
})
|
|
328
|
-
});
|
|
329
|
-
const { doc, paragraph, bold } = builders(testSchema);
|
|
330
|
-
const { view } = tempEditor({
|
|
331
|
-
doc: doc(paragraph(bold("Some bold text")))
|
|
332
|
-
});
|
|
333
|
-
expect(view.dom.textContent).toBe("Some bold text");
|
|
334
|
-
});
|
|
335
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { baseKeymap } from "prosemirror-commands";
|
|
2
|
-
import { keymap } from "prosemirror-keymap";
|
|
3
|
-
import { TextSelection } from "prosemirror-state";
|
|
4
|
-
import { br, doc, p, schema } from "prosemirror-test-builder";
|
|
5
|
-
import { beforeInputPlugin } from "../../plugins/beforeInputPlugin.js";
|
|
6
|
-
import { tempEditor } from "../../testing/editorViewTestHelpers.js";
|
|
7
|
-
describe("ProseMirror Mobile", ()=>{
|
|
8
|
-
it("handles insertParagraph with mobile Enter key", async ()=>{
|
|
9
|
-
const { view } = tempEditor({
|
|
10
|
-
doc: doc(p("Hello")),
|
|
11
|
-
plugins: createPlugins()
|
|
12
|
-
});
|
|
13
|
-
setCursorAtEnd(view);
|
|
14
|
-
view.focus();
|
|
15
|
-
await browser.keys("Enter");
|
|
16
|
-
expect(view.state.doc).toEqual(doc(p("Hello"), p()));
|
|
17
|
-
});
|
|
18
|
-
it("handles insertLineBreak with mobile Shift+Enter", async ()=>{
|
|
19
|
-
const { view } = tempEditor({
|
|
20
|
-
doc: doc(p("Hello")),
|
|
21
|
-
plugins: createPlugins()
|
|
22
|
-
});
|
|
23
|
-
setCursorAtEnd(view);
|
|
24
|
-
view.focus();
|
|
25
|
-
await browser.keys([
|
|
26
|
-
"Shift",
|
|
27
|
-
"Enter"
|
|
28
|
-
]);
|
|
29
|
-
expect(view.state.doc).toEqual(doc(p("Hello", br())));
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
function createPlugins() {
|
|
33
|
-
return [
|
|
34
|
-
keymap({
|
|
35
|
-
"Shift-Enter": (state, dispatch)=>{
|
|
36
|
-
const { tr } = state;
|
|
37
|
-
if (schema.nodes.hard_break) {
|
|
38
|
-
tr.insert(tr.selection.from, schema.nodes.hard_break.create());
|
|
39
|
-
dispatch?.(tr);
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
}),
|
|
45
|
-
keymap(baseKeymap),
|
|
46
|
-
beforeInputPlugin(()=>{
|
|
47
|
-
// no-op as this doesn't matter for this test
|
|
48
|
-
})
|
|
49
|
-
];
|
|
50
|
-
}
|
|
51
|
-
function setCursorAtEnd(view) {
|
|
52
|
-
const endPos = view.state.doc.content.size - 1;
|
|
53
|
-
view.dispatch(view.state.tr.setSelection(TextSelection.near(view.state.doc.resolve(endPos))));
|
|
54
|
-
}
|