1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 14:10:04 +02:00

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

View File

@ -2,8 +2,33 @@ import React, { Component } from 'react';
import ReactCodeMirror from 'react-codemirror'; import ReactCodeMirror from 'react-codemirror';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
const options = {
theme: 'eclipse',
indentUnit: 2,
smartIndent: true,
tabSize: 2,
indentWithTabs: false,
electricChars: true,
lineNumbers: true,
inputStyle: 'contenteditable',
readOnly: false,
lint: true,
autoCloseBrackets: true,
styleActiveLine: true,
matchBrackets: true,
lineWrapping: true,
foldGutter: true,
autoCloseTags: true,
viewportMargin: Infinity,
gutters: [
'CodeMirror-lint-markers',
'CodeMirror-foldgutter',
'CodeMirror-linenumbers'
]
};
class ManifestEditor extends Component { class ManifestEditor extends Component {
constructor({ value, defaultValue }) { constructor() {
super(); super();
this._refs = {}; this._refs = {};
@ -13,7 +38,7 @@ class ManifestEditor extends Component {
this._refs[name] = ref; this._refs[name] = ref;
}; };
} }
options({ mode, theme, keyMap }) { options({ mode }) {
const modes = { const modes = {
json: { json: {
name: 'javascript', name: 'javascript',
@ -22,32 +47,9 @@ class ManifestEditor extends Component {
yaml: 'yaml' yaml: 'yaml'
}; };
return { return Object.assign({}, options, {
mode: modes[mode.toLowerCase()], mode: modes[mode.toLowerCase()]
theme, });
indentUnit: 2,
smartIndent: true,
tabSize: 2,
indentWithTabs: false,
electricChars: true,
keyMap,
lineNumbers: true,
inputStyle: 'contenteditable',
readOnly: false,
lint: true,
autoCloseBrackets: true,
styleActiveLine: true,
matchBrackets: true,
lineWrapping: true,
foldGutter: true,
autoCloseTags: true,
viewportMargin: Infinity,
gutters: [
'CodeMirror-lint-markers',
'CodeMirror-linenumbers',
'CodeMirror-foldgutter'
]
};
} }
render() { render() {
return ( return (
@ -66,73 +68,20 @@ class ManifestEditor extends Component {
ManifestEditor.defaultProps = { ManifestEditor.defaultProps = {
mode: 'json', mode: 'json',
theme: 'eclipse',
defaultValue: '', defaultValue: '',
onChange: () => null, onChange: () => null,
onFocusChange: () => null, onFocusChange: () => null,
autoSave: true, autoSave: true,
preserveScrollPosition: true, preserveScrollPosition: true
keyMap: 'sublime'
}; };
ManifestEditor.propTypes = { ManifestEditor.propTypes = {
mode: PropTypes.oneOf(['json', 'yaml']), 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, value: PropTypes.string,
onChange: PropTypes.func, onChange: PropTypes.func,
onFocusChange: PropTypes.func, onFocusChange: PropTypes.func,
autoSave: PropTypes.bool, autoSave: PropTypes.bool,
preserveScrollPosition: PropTypes.bool, preserveScrollPosition: PropTypes.bool
keyMap: PropTypes.oneOf(['sublime', 'vim', 'emacs'])
}; };
export default ManifestEditor; export default ManifestEditor;

File diff suppressed because it is too large Load Diff