diff --git a/README.md b/README.md index e69aa79..b392d20 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,6 @@ For example, to create a new React class, type `rcc` and press `Tab` or press `C ```js import React, { - Component, PropTypes, } from 'react'; @@ -59,7 +58,7 @@ export default $class$; 'use strict'; var React = require('react'); -var PropTypes = PropTypes; +var PropTypes = React.PropTypes; var $class$ = React.createClass({ render: function() { @@ -230,6 +229,18 @@ componentWillUnmount: function() { ``` +### `dn` + +```js +displayName: '$END$', +``` + +### `dnp` + +```js +$START$.displayName = '$END$'; +``` + ### `fdn` ```js @@ -315,7 +326,7 @@ dangerouslySetInnerHTML={__html: '$END$'} ```js propTypes: { $START$: PropTypes.$END$ -} +}, ``` @@ -391,7 +402,7 @@ this.state.$END$ ```js contextTypes: { $START$: PropTypes.$END$ -} +}, ``` @@ -400,7 +411,7 @@ contextTypes: { ```js childContextTypes: { $START$: PropTypes.$END$ -} +}, ``` @@ -432,6 +443,12 @@ getChildContext: function() { ``` +### `sdn` + +```js +static displayName = '$END$'; +``` + ### `spt` ```js @@ -468,7 +485,7 @@ static childContextTypes = { ``` -### `csttr` +### `cstt` ```js constructor(props, context$START$) { @@ -477,6 +494,48 @@ constructor(props, context$START$) { ``` +### `tsn` + +```js +transitionName="$END$" +``` + +### `tsa` + +```js +transitionAppear={$END$} +``` + +### `tse` + +```js +transitionEnter={$END$} +``` + +### `tsl` + +```js +transitionLeave={$END$} +``` + +### `tset` + +```js +transitionEnterTimeout={$END$} +``` + +### `tslt` + +```js +transitionLeaveTimeout={$END$} +``` + +### `tsat` + +```js +transitionAppearTimeout={$END$} +``` + ### `oncp` ```js diff --git a/gulpfile.js b/gulpfile.js index 40a1ad7..3c7fe87 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -9,30 +9,36 @@ var Handlebars = require('handlebars'); var template = Handlebars.compile(fs.readFileSync('src/ReactJS.hbs', 'utf8')); var docTpl = Handlebars.compile(fs.readFileSync('src/doc.hbs', 'utf8')); var readme = fs.readFileSync('README.md', 'utf8'); - var templates = yaml.safeLoad(fs.readFileSync('src/template.yaml', 'utf8')); var eventsTpl = yaml.safeLoad(fs.readFileSync('src/envents.yaml', 'utf8')); -var processTpl = function(tpl) { - tpl = JSON.stringify(tpl); - return tpl.replace(/\\n/g, ' ') +var escapeTpl = function(tpl) { + tpl = tpl.replace(/\n/g, ' ') .replace(//g, '>'); + .replace(/>/g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + // .replace(/&/g, '&') + + return JSON.stringify(tpl); }; var data = []; -var docData = []; for (var k in templates) { if (templates.hasOwnProperty(k)) { var t = templates[k]; + console.log(typeof t.tpl); + var isMethod = (typeof t.tpl === 'string' && t.tpl.indexOf(': function') > -1); var tpl = t.tpl.next || t.tpl; - tpl = tpl.replace(/: function/g, '').replace(/},/g, '}'); - + tpl = tpl.replace(/: function/g, ''); + + isMethod && (tpl = tpl.replace(/},/g, '}')); + var snippet = { name: k, description: t.description || t.tpl, - tpl: processTpl(tpl), + tpl: escapeTpl(tpl), variables: t.variables || [], tplRaw: tpl }; @@ -40,13 +46,13 @@ for (var k in templates) { data.push(snippet); if (t.tpl.next || - (typeof t.tpl === 'string' && t.tpl.indexOf(': function') > -1)) { + (typeof t.tpl === 'string' && isMethod)) { var tpl5 = t.tpl.es5 || t.tpl; var snippet5 = { name: k + '5', description: t.description || t.tpl, - tpl: processTpl(tpl5), + tpl: escapeTpl(tpl5), variables: t.variables || [], tplRaw: tpl5 }; @@ -56,7 +62,7 @@ for (var k in templates) { } } -function processEnventsTpl(eventsMap) { +function processEventsTpl(eventsMap) { for (var key in eventsMap) { if (eventsMap.hasOwnProperty(key)) { var tplName = eventsMap[key]; @@ -64,7 +70,7 @@ function processEnventsTpl(eventsMap) { data.push({ name: tplName, description: key, - tpl: JSON.stringify(tpl), + tpl: escapeTpl(tpl), tplRaw: tpl }); @@ -72,7 +78,7 @@ function processEnventsTpl(eventsMap) { } } -processEnventsTpl(eventsTpl); +processEventsTpl(eventsTpl); fs.writeFileSync('jetbrains/templates/ReactJS.xml', template(data)); fs.writeFileSync('README.md', readme.replace( diff --git a/jetbrains-react.jar b/jetbrains-react.jar index f95c619..d429cc0 100644 Binary files a/jetbrains-react.jar and b/jetbrains-react.jar differ diff --git a/jetbrains/templates/ReactJS.xml b/jetbrains/templates/ReactJS.xml index ceba734..6996642 100644 --- a/jetbrains/templates/ReactJS.xml +++ b/jetbrains/templates/ReactJS.xml @@ -1,7 +1,7 @@ + +