refactor(joyent-manifest-editor): react-codemirror as peer-dep

BREAKING CHANGE
This commit is contained in:
Sérgio Ramos 2017-06-09 05:22:49 +01:00 committed by Judit Greskovits
parent 75eded4b06
commit 14ffdb9636
3 changed files with 100 additions and 881 deletions

View File

@ -6,9 +6,9 @@
"description": "",
"keywords": [],
"repository": "github:yldio/joyent-portal",
"main": "dist/manifest-editor.umd.js",
"jsnext:main": "dist/manifest-editor.es.js",
"module": "dist/manifest-editor.es.js",
"main": "dist/joyent-manifest-editor.umd.js",
"jsnext:main": "dist/joyent-manifest-editor.es.js",
"module": "dist/joyent-manifest-editor.es.js",
"entry": "src/index.js",
"scripts": {
"lint:css": "echo 0",
@ -23,13 +23,11 @@
"prepublish": "redrun build"
},
"dependencies": {
"prop-types": "^15.5.10",
"react-codemirror": "^1.0.0"
"prop-types": "^15.5.10"
},
"devDependencies": {
"babel-preset-react-app": "^3.0.0",
"bup": "^1.0.9",
"codemirror": "^5.26.0",
"eslint": "^3.19.0",
"eslint-config-joyent-portal": "1.0.3",
"jest": "^20.0.4",
@ -39,8 +37,7 @@
},
"peerDependencies": {
"react": "*",
"codemirror": "*",
"react-dom": "*"
"react-codemirror": "*"
},
"jest": {
"testEnvironment": "jsdom",

View File

@ -2,35 +2,13 @@ import React, { Component } from 'react';
import ReactCodeMirror from 'react-codemirror';
import PropTypes from 'prop-types';
class ManifestEditor extends Component {
constructor({ value, defaultValue }) {
super();
this._refs = {};
}
ref(name) {
return ref => {
this._refs[name] = ref;
};
}
options({ mode, theme, keyMap }) {
const modes = {
json: {
name: 'javascript',
json: true
},
yaml: 'yaml'
};
return {
mode: modes[mode.toLowerCase()],
theme,
const options = {
theme: 'eclipse',
indentUnit: 2,
smartIndent: true,
tabSize: 2,
indentWithTabs: false,
electricChars: true,
keyMap,
lineNumbers: true,
inputStyle: 'contenteditable',
readOnly: false,
@ -44,10 +22,34 @@ class ManifestEditor extends Component {
viewportMargin: Infinity,
gutters: [
'CodeMirror-lint-markers',
'CodeMirror-linenumbers',
'CodeMirror-foldgutter'
'CodeMirror-foldgutter',
'CodeMirror-linenumbers'
]
};
class ManifestEditor extends Component {
constructor() {
super();
this._refs = {};
}
ref(name) {
return ref => {
this._refs[name] = ref;
};
}
options({ mode }) {
const modes = {
json: {
name: 'javascript',
json: true
},
yaml: 'yaml'
};
return Object.assign({}, options, {
mode: modes[mode.toLowerCase()]
});
}
render() {
return (
@ -66,73 +68,20 @@ class ManifestEditor extends Component {
ManifestEditor.defaultProps = {
mode: 'json',
theme: 'eclipse',
defaultValue: '',
onChange: () => null,
onFocusChange: () => null,
autoSave: true,
preserveScrollPosition: true,
keyMap: 'sublime'
preserveScrollPosition: true
};
ManifestEditor.propTypes = {
mode: PropTypes.oneOf(['json', 'yaml']),
theme: PropTypes.oneOf([
'3024-day',
'3024-night',
'abcdef',
'ambiance-mobile',
'ambiance',
'base16-dark',
'base16-light',
'bespin',
'blackboard',
'cobalt',
'colorforth',
'dracula',
'duotone-dark',
'duotone-light',
'eclipse',
'elegant',
'erlang-dark',
'hopscotch',
'icecoder',
'isotope',
'lesser-dark',
'liquibyte',
'material',
'mbo',
'mdn-like',
'midnight',
'monokai',
'neat',
'neo',
'night',
'panda-syntax',
'paraiso-dark',
'paraiso-light',
'pastel-on-dark',
'railscasts',
'rubyblue',
'seti',
'solarized',
'the-matrix',
'tomorrow-night-bright',
'tomorrow-night-eighties',
'ttcn',
'twilight',
'vibrant-ink',
'xq-dark',
'xq-light',
'yeti',
'zenburn'
]),
value: PropTypes.string,
onChange: PropTypes.func,
onFocusChange: PropTypes.func,
autoSave: PropTypes.bool,
preserveScrollPosition: PropTypes.bool,
keyMap: PropTypes.oneOf(['sublime', 'vim', 'emacs'])
preserveScrollPosition: PropTypes.bool
};
export default ManifestEditor;

File diff suppressed because it is too large Load Diff