mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 16:41:17 +01:00
Fixes for codemirror in sources modal
- Allows for max height - Override GeoJSON data when changing type
This commit is contained in:
parent
9ac908948d
commit
ee525631fa
5 changed files with 25 additions and 8 deletions
|
@ -69,12 +69,19 @@ class JSONEditor extends React.Component {
|
||||||
scrollbarStyle: "null",
|
scrollbarStyle: "null",
|
||||||
}
|
}
|
||||||
|
|
||||||
return <CodeMirror
|
const style = {};
|
||||||
value={this.state.code}
|
if (this.props.maxHeight) {
|
||||||
onBeforeChange={(editor, data, value) => this.onCodeUpdate(value)}
|
style.maxHeight = this.props.maxHeight;
|
||||||
onFocusChange={focused => focused ? true : this.resetValue()}
|
}
|
||||||
options={codeMirrorOptions}
|
|
||||||
/>
|
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) {
|
switch(mode) {
|
||||||
case 'geojson_url': return {
|
case 'geojson_url': return {
|
||||||
type: 'geojson',
|
type: 'geojson',
|
||||||
data: source.data || 'http://localhost:3000/geojson.json'
|
data: 'http://localhost:3000/geojson.json'
|
||||||
}
|
}
|
||||||
case 'geojson_json': return {
|
case 'geojson_json': return {
|
||||||
type: 'geojson',
|
type: 'geojson',
|
||||||
data: source.data || {}
|
data: {}
|
||||||
}
|
}
|
||||||
case 'tilejson_vector': return {
|
case 'tilejson_vector': return {
|
||||||
type: 'vector',
|
type: 'vector',
|
||||||
|
|
|
@ -116,6 +116,7 @@ class GeoJSONSourceJSONEditor extends React.Component {
|
||||||
return <InputBlock label={"GeoJSON"} doc={latest.source_geojson.data.doc}>
|
return <InputBlock label={"GeoJSON"} doc={latest.source_geojson.data.doc}>
|
||||||
<JSONEditor
|
<JSONEditor
|
||||||
layer={this.props.source.data}
|
layer={this.props.source.data}
|
||||||
|
maxHeight={200}
|
||||||
onChange={data => {
|
onChange={data => {
|
||||||
this.props.onChange({
|
this.props.onChange({
|
||||||
...this.props.source,
|
...this.props.source,
|
||||||
|
|
8
src/styles/_codemirror.scss
Normal file
8
src/styles/_codemirror.scss
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
.CodeMirror-lint-tooltip {
|
||||||
|
z-index: 2000 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-wrapper {
|
||||||
|
position: relative;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
|
@ -37,6 +37,7 @@ $toolbar-offset: 0;
|
||||||
@import 'zoomproperty';
|
@import 'zoomproperty';
|
||||||
@import 'popup';
|
@import 'popup';
|
||||||
@import 'map';
|
@import 'map';
|
||||||
|
@import 'codemirror';
|
||||||
@import 'react-collapse';
|
@import 'react-collapse';
|
||||||
@import 'react-codemirror';
|
@import 'react-codemirror';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue