Skip to content

Commit fb37316

Browse files
authored
Merge pull request #188 from scniro/elsigh
Adds options to constructor, fixes #100
2 parents cc3a47d + ec9b05f commit fb37316

File tree

5 files changed

+33
-10
lines changed

5 files changed

+33
-10
lines changed

.ts/index.js

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

index.js

Lines changed: 3 additions & 3 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
@@ -1,6 +1,6 @@
11
{
22
"name": "react-codemirror2",
3-
"version": "7.1.0",
3+
"version": "7.2.0",
44
"description": "a tiny react codemirror component wrapper",
55
"main": "index.js",
66
"typings": "index.d.ts",

src/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,12 @@ export class Controlled extends React.Component<IControlledCodeMirror, any> {
510510
}
511511
}
512512

513-
this.editor = cm(this.ref) as codemirror.Editor;
513+
this.editor = cm(this.ref, this.props.options) as codemirror.Editor;
514514

515515
this.shared = new Shared(this.editor, this.props);
516516

517517
this.mirror = (cm as any)(() => {
518-
});
518+
}, this.props.options);
519519

520520
this.editor.on('electricInput', () => {
521521
this.mirror.setHistory(this.editor.getDoc().getHistory());
@@ -713,7 +713,7 @@ export class UnControlled extends React.Component<IUnControlledCodeMirror, any>
713713
}
714714
}
715715

716-
this.editor = cm(this.ref) as codemirror.Editor;
716+
this.editor = cm(this.ref, this.props.options) as codemirror.Editor;
717717

718718
this.shared = new Shared(this.editor, this.props);
719719

test/index.spec.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,29 @@ describe('[Controlled, UnControlled]: init', () => {
5959
expect(cUnmounted).toBeTruthy();
6060
});
6161

62+
// refs https://github.com/scniro/react-codemirror2/issues/100
63+
// prior to 7115754851dde1e1ae90be9f1c1a5e46faecc016 would throw
64+
it('should allow inputStyle to be set (uses the constructor)', () => {
65+
let inputStyle = 'contenteditable' as const;
66+
const options = {inputStyle};
67+
Enzyme.shallow(
68+
<UnControlled
69+
options={options}
70+
editorDidMount={(editor, value, next) => {
71+
expect(editor.getInputField().tagName).toBe('DIV');
72+
}}
73+
/>);
74+
Enzyme.shallow(
75+
<Controlled
76+
value=""
77+
options={options}
78+
onBeforeChange={sinon.spy}
79+
editorDidMount={(editor, value, next) => {
80+
expect(editor.getInputField().tagName).toBe('DIV');
81+
}}
82+
/>);
83+
});
84+
6285
it('should append a class name', () => {
6386

6487
const uWrapper = Enzyme.mount(

0 commit comments

Comments
 (0)