Skip to content
This repository was archived by the owner on Jan 14, 2022. It is now read-only.

Commit 052a8fc

Browse files
committed
fixed blank page when transfer snippet
1 parent ed57f01 commit 052a8fc

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Every notable changes in each version will be listed in this file.
1313
- **Interface**: Fixed link not open in default browser when clicked in markdown preview (Fixed [#40](https://github.com/ZeroX-DG/SnippetStore/issues/40)) ([4864b8b](https://github.com/ZeroX-DG/SnippetStore/commit/4864b8b))
1414
- **Interface**: Fixed can't preview github flavored markdown (Fixed [#39](https://github.com/ZeroX-DG/SnippetStore/issues/39))([9dec808](https://github.com/ZeroX-DG/SnippetStore/commit/9dec808))
1515
- **Interface**: Fixed MarkdownPreview not update when changing snippet (Fixed [#38](https://github.com/ZeroX-DG/SnippetStore/issues/38))([0d3ab7d](https://github.com/ZeroX-DG/SnippetStore/commit/0d3ab7d))
16-
- **Interface**: Fixed snippet not exiting preview mode when in edit mode (Fixed [37](https://github.com/ZeroX-DG/SnippetStore/issues/37))([64b74cc](https://github.com/ZeroX-DG/SnippetStore/commit/64b74cc))
16+
- **Interface**: Fixed snippet not exiting preview mode when in edit mode (Fixed [#37](https://github.com/ZeroX-DG/SnippetStore/issues/37))([64b74cc](https://github.com/ZeroX-DG/SnippetStore/commit/64b74cc))
1717

1818
# 0.2.11
1919

browser/render/components/select-input/index.jsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,21 @@ class SelectInput extends React.PureComponent {
2121
})
2222
}
2323

24-
value () {
24+
value (newValue) {
25+
if (newValue) {
26+
const { onChange } = this.props
27+
const selected = this.filteredOptions().find(
28+
option => option.label === newValue
29+
)
30+
if (!selected) return
31+
this.setState({ selected, isFocus: false }, () => {
32+
this.refs.input.value = selected.label
33+
if (typeof onChange === 'function') {
34+
onChange(selected)
35+
}
36+
})
37+
return
38+
}
2539
return this.state.selected
2640
}
2741

browser/render/modals/create-snippet/index.jsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ export default class CreateSnippetModal extends React.Component {
3131

3232
this.editor.setSize('100%', '100%')
3333
if (data) {
34+
console.log(data)
3435
if (data.code) {
3536
this.editor.setValue(data.code)
3637
}
3738
if (data.ext) {
3839
const mode = CodeMirror.findModeByExtension(data.ext)
39-
this.refs.lang.value = mode.name
40+
console.log(mode)
41+
this.refs.snippetLang.value(mode.name)
4042
}
4143
this.refs.snippetName.focus()
4244
}
@@ -61,8 +63,11 @@ export default class CreateSnippetModal extends React.Component {
6163
} = config.editor
6264
// only update codemirror mode if new props is passed
6365
if (props) {
64-
const snippetMode = CodeMirror.findModeByName(this.refs.lang.value).mode
65-
require(`codemirror/mode/${snippetMode}/${snippetMode}`)
66+
const selectedLangValue = this.refs.snippetLang.value().value
67+
if (selectedLangValue) {
68+
const snippetMode = CodeMirror.findModeByName(selectedLangValue).mode
69+
require(`codemirror/mode/${snippetMode}/${snippetMode}`)
70+
}
6671
}
6772
const gutters = showLineNumber
6873
? ['CodeMirror-linenumbers', 'CodeMirror-foldgutter']
@@ -92,7 +97,7 @@ export default class CreateSnippetModal extends React.Component {
9297
const langConf = config.language
9398
const snippetLang = this.refs.snippetLang.value()
9499
const snippetMode = snippetLang.value
95-
if (snippetMode === 'null') {
100+
if (snippetMode === 'null' || snippetMode === undefined) {
96101
this.editor.setOption('mode', 'null')
97102
this.editor.setOption('htmlMode', false)
98103
} else if (snippetMode === 'htmlmixed') {

0 commit comments

Comments
 (0)