Skip to content

Commit

Permalink
fix problems with inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronsutter committed Oct 29, 2019
1 parent 88ed4de commit 3eb9a23
Show file tree
Hide file tree
Showing 19 changed files with 131 additions and 96 deletions.
13 changes: 12 additions & 1 deletion bin/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var { stringify } = require('dotenv-stringify')
var i18n = require('format-message')
const { autoUpdater } = require('electron-updater')
if (process.env.NODE_ENV === 'dev') {
require('electron-reload')(path.join('..'))
// require('electron-reload')(path.join('..'))
}

const ENV_FILE_PATH = path.resolve(__dirname, '..', '.env')
Expand Down Expand Up @@ -515,6 +515,11 @@ function openWindow (fileName, newFile = false) {
}
})

newWindow.webContents.on('will-navigate', (event, string) => {
console.log("WILL NAVIGATE", string)
log.warn("WILL NAVIGATE")
})

if (process.env.NODE_ENV === 'dev') {
newWindow.openDevTools()
}
Expand Down Expand Up @@ -1069,6 +1074,12 @@ function buildViewMenu () {
accelerator: 'CmdOrCtrl+P',
click: takeScreenshot
}]
if (process.env.NODE_ENV === 'dev') {
submenu.push({
label: 'View Verify Window',
click: openVerifyWindow
})
}
return {
label: i18n('View'),
submenu: submenu
Expand Down
20 changes: 16 additions & 4 deletions example.pltr
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"cards": [
{
"characters": [],
"description": "stuff",
"id": 163,
"lineId": 27,
"places": [],
"sceneId": 107,
"tags": [],
"title": "new card"
},
{
"characters": [],
"description": "",
Expand Down Expand Up @@ -634,9 +644,9 @@
},
"file": {
"dirty": true,
"fileName": "/Users/cameron/github/plottr_electron/example.pltr",
"fileName": "/Users/sparrowhawk/github/plottr_electron/example.pltr",
"loaded": true,
"version": "1.4.20"
"version": "1.4.24"
},
"lines": [
{
Expand Down Expand Up @@ -1084,9 +1094,11 @@
}
],
"ui": {
"characterFilter": null,
"characterFilter": {
"age": []
},
"characterSort": "name~asc",
"currentView": "timeline",
"currentView": "characters",
"darkMode": false,
"noteFilter": null,
"noteSort": "title~asc",
Expand Down
120 changes: 61 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"repository": "https://github.com/cameronsutter/plottr_electron.git",
"private": true,
"readme": "Copyright 2016 C. Louis S. (Cameron Sutter)",
"version": "1.4.24",
"version": "1.4.25",
"author": {
"name": "C. Louis S.",
"email": "[email protected]",
Expand Down
8 changes: 4 additions & 4 deletions src/app/components/characters/characterListView.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _ from 'lodash'
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'react-proptypes'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
Expand Down Expand Up @@ -51,8 +52,7 @@ class CharacterListView extends Component {

componentDidUpdate () {
if (this.refs.attrInput) {
var input = this.refs.attrInput.getInputDOMNode()
input.focus()
ReactDOM.findDOMNode(this.refs.attrInput).focus()
}
}

Expand Down Expand Up @@ -119,7 +119,7 @@ class CharacterListView extends Component {
}

handleType = () => {
const attr = this.refs.attrInput.getValue()
const attr = ReactDOM.findDOMNode(this.refs.attrInput).value
this.setState({addAttrText: attr})
}

Expand All @@ -130,7 +130,7 @@ class CharacterListView extends Component {
}

saveAttr = () => {
const attr = this.refs.attrInput.getValue()
const attr = ReactDOM.findDOMNode(this.refs.attrInput).value
this.props.customAttributeActions.addCharacterAttr(attr)

this.setState({addAttrText: ''})
Expand Down
11 changes: 6 additions & 5 deletions src/app/components/characters/characterView.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _ from 'lodash'
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'react-proptypes'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
Expand Down Expand Up @@ -49,16 +50,16 @@ class CharacterView extends Component {
}

saveEdit = () => {
var name = this.refs.nameInput.getValue() || this.props.character.name
var description = this.refs.descriptionInput.getValue()
var name = ReactDOM.findDOMNode(this.refs.nameInput).value || this.props.character.name
var description = ReactDOM.findDOMNode(this.refs.descriptionInput).value
var notes = this.state.notes
var attrs = {}
this.props.customAttributes.forEach(attr => {
const [attrName, attrType] = attr.split(':#:')
if (attrType == 'paragraph') {
attrs[attrName] = this.state.description[attrName]
} else {
const val = this.refs[`${attr}Input`].getValue()
const val = ReactDOM.findDOMNode(this.refs[`${attr}Input`]).value
attrs[attr] = val
}
})
Expand Down Expand Up @@ -108,13 +109,13 @@ class CharacterView extends Component {
<div className='character-list__inputs__normal'>
<FormGroup>
<ControlLabel>{i18n('Name')}</ControlLabel>
<Input
<FormControl
type='text' ref='nameInput' autoFocus
onKeyDown={this.handleEsc}
onKeyPress={this.handleEnter}
defaultValue={character.name} />
<ControlLabel>{i18n('Short Description')}</ControlLabel>
<Input type='text' ref='descriptionInput'
<FormControl type='text' ref='descriptionInput'
onKeyDown={this.handleEsc}
onKeyPress={this.handleEnter}
defaultValue={character.description} />
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/colorpicker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'react-proptypes'
import Modal from 'react-modal'
import { reds, oranges, greens, blues, purples, grays, whites, browns } from '../constants/CSScolors'
Expand All @@ -18,7 +19,7 @@ class ColorPicker extends Component {
}

showColor = () => {
var newColor = this.refs.hex.getValue()
var newColor = ReactDOM.findDOMNode(this.refs.hex).value
var regex = /#?([0123456789abcdef]{6})/
var matches = regex.exec(newColor)
if (matches) {
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/notes/noteView.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _ from 'lodash'
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'react-proptypes'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
Expand Down Expand Up @@ -32,7 +33,7 @@ class NoteView extends Component {
}

saveEdit = () => {
var title = this.refs.titleInput.getValue() || this.props.note.title
var title = ReactDOM.findDOMNode(this.refs.titleInput).value || this.props.note.title
var content = this.state.content
this.props.actions.editNote(this.props.note.id, {title, content})
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/outline/cardView.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'react-proptypes'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
Expand All @@ -25,7 +26,7 @@ class CardView extends Component {
}

saveEdit = () => {
var newTitle = this.refs.titleInput.getValue() || this.props.card.title
var newTitle = ReactDOM.findDOMNode(this.refs.titleInput).value || this.props.card.title
var newDescription = this.state.description
this.saveCreatedLabels(newDescription)
this.props.actions.editCard(this.props.card.id, newTitle, newDescription)
Expand Down
12 changes: 6 additions & 6 deletions src/app/components/places/placeListView.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _ from 'lodash'
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'react-proptypes'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
Expand Down Expand Up @@ -49,8 +50,7 @@ class PlaceListView extends Component {

componentDidUpdate () {
if (this.refs.attrInput) {
var input = this.refs.attrInput.getInputDOMNode()
input.focus()
ReactDOM.findDOMNode(this.refs.attrInput).focus()
}
}

Expand Down Expand Up @@ -116,7 +116,7 @@ class PlaceListView extends Component {
}

handleType = () => {
const attr = this.refs.attrInput.getValue()
const attr = ReactDOM.findDOMNode(this.refs.attrInput).value
this.setState({addAttrText: attr})
}

Expand All @@ -127,11 +127,11 @@ class PlaceListView extends Component {
}

saveAttr = () => {
const attr = this.refs.attrInput.getValue()
const inputNode = ReactDOM.findDOMNode(this.refs.attrInput)
const attr = inputNode.value
this.props.customAttributeActions.addPlaceAttr(attr)
this.setState({addAttrText: ''})
var input = this.refs.attrInput.getInputDOMNode()
input.focus()
inputNode.focus()
}

removeAttr (attr) {
Expand Down
Loading

0 comments on commit 3eb9a23

Please sign in to comment.