markuapad 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module Markuapad
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
data/src/jsx/editor.jsx CHANGED
@@ -6,6 +6,8 @@ import emacsKeys from "brace/keybinding/emacs"
6
6
  import FileAccessor from "../file_accessor";
7
7
  import _ from "underscore";
8
8
 
9
+ let EDITOR_KEY = 1;
10
+
9
11
  class Editor extends React.Component {
10
12
  constructor(props) {
11
13
  super(props);
@@ -21,10 +23,20 @@ class Editor extends React.Component {
21
23
  this.setupEditor();
22
24
  }
23
25
 
26
+ componentWillUpdate(nextProps, nextState) {
27
+ if (nextProps.currentFile !== this.props.currentFile) {
28
+ if (this.editor) {
29
+ this.editor.destroy();
30
+ EDITOR_KEY = EDITOR_KEY + 1;
31
+ }
32
+ }
33
+ }
34
+
24
35
  // If we get a file change from outside our domain, switch to it.
25
36
  // TODO: maybe show a merge warning or something?
26
37
  componentDidUpdate(lastProps, lastState) {
27
38
  if (lastProps.currentFile !== this.props.currentFile) {
39
+ this.setState({ currentFileValue: null })
28
40
  this.setupEditor();
29
41
  }
30
42
  }
@@ -56,6 +68,8 @@ class Editor extends React.Component {
56
68
 
57
69
  // When someone changes the cursor, we need to tell the file that we have a changed cursor
58
70
  onCursorChanged() {
71
+ if (!this.props.currentFile) return;
72
+
59
73
  let count = 0,
60
74
  position = this.editor.getCursorPosition(),
61
75
  i = 0,
@@ -68,6 +82,8 @@ class Editor extends React.Component {
68
82
  // When the editor value changes, then we have to set our current state,
69
83
  // then update the file through the data store.
70
84
  onEditorChanged() {
85
+ if (!this.props.currentFile) return;
86
+
71
87
  let value = this.editor.getValue();
72
88
 
73
89
  if (value === this.state.currentFileValue)
@@ -93,7 +109,7 @@ class Editor extends React.Component {
93
109
 
94
110
  renderEditor() {
95
111
  return (
96
- <section ref="editor" className="editor"></section>
112
+ <section key={EDITOR_KEY} ref="editor" className="editor"></section>
97
113
  );
98
114
  }
99
115
 
@@ -51,7 +51,7 @@ class FileBrowser extends React.Component {
51
51
 
52
52
  // We need to rechoose an appropriate file
53
53
  onFileDeleted() {
54
- this.props.onChangeFile(this.state.files[0])
54
+ this.props.onChangeFile(null)
55
55
  }
56
56
 
57
57
  // List what text files we have
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markuapad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braden Simpson