mirror of
https://github.com/maputnik/editor.git
synced 2025-12-26 16:10:01 +00:00
Fixes for codemirror in sources modal
- Allows for max height - Override GeoJSON data when changing type
This commit is contained in:
@@ -69,12 +69,19 @@ class JSONEditor extends React.Component {
|
||||
scrollbarStyle: "null",
|
||||
}
|
||||
|
||||
return <CodeMirror
|
||||
value={this.state.code}
|
||||
onBeforeChange={(editor, data, value) => this.onCodeUpdate(value)}
|
||||
onFocusChange={focused => focused ? true : this.resetValue()}
|
||||
options={codeMirrorOptions}
|
||||
/>
|
||||
const style = {};
|
||||
if (this.props.maxHeight) {
|
||||
style.maxHeight = this.props.maxHeight;
|
||||
}
|
||||
|
||||
return <div className="CodeMirror-wrapper" style={style}>
|
||||
<CodeMirror
|
||||
value={this.state.code}
|
||||
onBeforeChange={(editor, data, value) => this.onCodeUpdate(value)}
|
||||
onFocusChange={focused => focused ? true : this.resetValue()}
|
||||
options={codeMirrorOptions}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -115,11 +115,11 @@ class AddSource extends React.Component {
|
||||
switch(mode) {
|
||||
case 'geojson_url': return {
|
||||
type: 'geojson',
|
||||
data: source.data || 'http://localhost:3000/geojson.json'
|
||||
data: 'http://localhost:3000/geojson.json'
|
||||
}
|
||||
case 'geojson_json': return {
|
||||
type: 'geojson',
|
||||
data: source.data || {}
|
||||
data: {}
|
||||
}
|
||||
case 'tilejson_vector': return {
|
||||
type: 'vector',
|
||||
|
||||
@@ -116,6 +116,7 @@ class GeoJSONSourceJSONEditor extends React.Component {
|
||||
return <InputBlock label={"GeoJSON"} doc={latest.source_geojson.data.doc}>
|
||||
<JSONEditor
|
||||
layer={this.props.source.data}
|
||||
maxHeight={200}
|
||||
onChange={data => {
|
||||
this.props.onChange({
|
||||
...this.props.source,
|
||||
|
||||
Reference in New Issue
Block a user