Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp committed Mar 7, 2018
2 parents 00bf0b0 + d9df127 commit 911ec9a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ In order to make CodeMirror work correctly, do not forget to start your HTML pag

##### Initialize

`codemirrorOptions` can be `null` or contain original CodeMirror settings
`codemirrorOptions` can be `null` (ignored) or contain original CodeMirror settings

`jqueryCodemirroOptions` can be `null` (ignored)
`jqueryCodemirrorOptions` can be `null` (ignored)

```
$(...).codemirrorInit(codemirrorOptions, jqueryCodemirrorOptions);
Expand All @@ -30,7 +30,7 @@ lineNumbers: true,
lineWrapping: true
```

`NB!` Do not forget to add required mode `mode/xml/xml.js`
`NB!` Do not forget to add required CodeMirror mode `mode/xml/xml.js`

`jqueryCodemirrorDefaults` are:

Expand All @@ -40,35 +40,39 @@ height: "auto"; (Set in CSS)

Height options are `auto` and `inherit`

When `auto`, CodeMirror container is auto resized. (Container's CSS parameter `height` value should be `auto`! May have `min-height`, should not ave `max-height`)
When `auto`, CodeMirror container is auto resized. (Container's CSS parameter `height` value should be `auto`! May have `min-height`, should not have `max-height`)

When `inherit`, CodeMirror container is not resized, scroll-bar appears. (Container's CSS `height` value should not be `auto`! )


You can set CodeMirror configs in DOM element attribute `codemirror-config` or `codemirror`. Latest is preferred.
You can set CodeMirror configs in DOM element attribute `codemirror-config` or `codemirror` in JSON format. Last one is preferred when both used.

```
<div codemirror='{"autofocus": true, "value": "Hello world"}'></div>
```

You can set plugin configs in DOM element attribute `jquery-codemirror-config` or `jquery-codemirror`. Latest is preferred.
You can set plugin configs in DOM element attribute `jquery-codemirror-config` or `jquery-codemirror` in JSON format. Last one is preferred when both used.

```
<div jquery-codemirror='{"height": "inherit"}'></div>
```

##### CodeMirror methods

CodeMirror object is initialized and saved for each element via `$.data(element, 'codemirror)`
CodeMirror object is initialized and saved for each element via `$.data(element, 'codemirror')`

You can access it and use as specified in CodeMirror manual
You can access it and use as specified in CodeMirror manual (after initialization is done)

```
$(...).codemirrorInit();
$.data($(...)][0], 'codemirror').getValue()
```

Plugin itself adds `setValue(string), getValue(), setOption(option, value), setOptions(optionsObject)`
Plugin itself adds `setValue(string), getValue(), setOption(option, value), setOptions(optionsObject)`. You can access them after initialization is done.

```
$(...).codemirror().getValue()
$(...).codemirrorInit();
$(...).codemirror().getValue();
```

`NB!` Plugin's options (height) cannot be set outside initialization (yet).

0 comments on commit 911ec9a

Please sign in to comment.