Skip to content

Commit c60764c

Browse files
committed
chore: upgrade prosemirror-inputrules
1 parent 2bbc465 commit c60764c

File tree

3 files changed

+69
-5
lines changed

3 files changed

+69
-5
lines changed

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@
204204
"prosemirror-commands": "^1.6.2",
205205
"prosemirror-dropcursor": "^1.8.1",
206206
"prosemirror-history": "^1.4.1",
207-
"prosemirror-inputrules": "^1.4.0",
207+
"prosemirror-inputrules": "^1.5.0",
208208
"prosemirror-keymap": "^1.2.2",
209209
"prosemirror-model": "^1.24.1",
210210
"prosemirror-schema-list": "^1.5.0",
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import {EditorState, TextSelection} from 'prosemirror-state';
2+
import {builders} from 'prosemirror-test-builder';
3+
import {EditorView} from 'prosemirror-view';
4+
5+
import {ExtensionsManager} from '../../../core';
6+
import {CodeSpecs, codeMarkName} from '../../markdown/Code/CodeSpecs';
7+
import {BaseNode, BaseSchemaSpecs} from '../specs';
8+
9+
import {BaseInputRules} from './index';
10+
11+
const {schema, plugins} = new ExtensionsManager({
12+
extensions: (builder) => builder.use(BaseSchemaSpecs, {}).use(CodeSpecs).use(BaseInputRules),
13+
}).build();
14+
15+
const {doc, p, c} = builders<'doc' | 'p', 'c'>(schema, {
16+
doc: {nodeType: BaseNode.Doc},
17+
p: {nodeType: BaseNode.Paragraph},
18+
c: {nodeType: codeMarkName},
19+
});
20+
21+
describe('BaseInputRules', () => {
22+
it('replaces triple dots with ellipsis outside code marks', () => {
23+
const startDoc = doc(p(''));
24+
const state = EditorState.create({
25+
schema,
26+
doc: startDoc,
27+
selection: TextSelection.create(startDoc, 1),
28+
plugins,
29+
});
30+
const view = new EditorView(document.createElement('div'), {state});
31+
const from = view.state.selection.from;
32+
let handled = false;
33+
view.someProp('handleTextInput', (f) => {
34+
handled = f(view, from, from, '...');
35+
});
36+
if (!handled) {
37+
view.dispatch(view.state.tr.insertText('...', from, from));
38+
}
39+
expect(view.state.doc).toMatchNode(doc(p('…')));
40+
view.destroy();
41+
});
42+
43+
it('does not replace triple dots inside inline code', () => {
44+
const startDoc = doc(p(c('foo')));
45+
const state = EditorState.create({
46+
schema,
47+
doc: startDoc,
48+
selection: TextSelection.create(startDoc, 4),
49+
plugins,
50+
});
51+
const view = new EditorView(document.createElement('div'), {state});
52+
const from = view.state.selection.from;
53+
let handled = false;
54+
view.someProp('handleTextInput', (f) => {
55+
handled = f(view, from, from, '...');
56+
});
57+
if (!handled) {
58+
view.dispatch(view.state.tr.insertText('...', from, from));
59+
}
60+
expect(view.state.doc).toMatchNode(doc(p(c('foo...'))));
61+
view.destroy();
62+
});
63+
});

0 commit comments

Comments
 (0)