Skip to content

Commit bcc5086

Browse files
author
minwe
committed
add Transition add-on prop templates
1 parent 3788e5d commit bcc5086

File tree

6 files changed

+271
-32
lines changed

6 files changed

+271
-32
lines changed

README.md

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ For example, to create a new React class, type `rcc` and press `Tab` or press `C
3737

3838
```js
3939
import React, {
40-
Component,
4140
PropTypes,
4241
} from 'react';
4342

@@ -59,7 +58,7 @@ export default $class$;
5958
'use strict';
6059

6160
var React = require('react');
62-
var PropTypes = PropTypes;
61+
var PropTypes = React.PropTypes;
6362

6463
var $class$ = React.createClass({
6564
render: function() {
@@ -230,6 +229,18 @@ componentWillUnmount: function() {
230229

231230
```
232231

232+
### `dn`
233+
234+
```js
235+
displayName: '$END$',
236+
```
237+
238+
### `dnp`
239+
240+
```js
241+
$START$.displayName = '$END$';
242+
```
243+
233244
### `fdn`
234245

235246
```js
@@ -315,7 +326,7 @@ dangerouslySetInnerHTML={__html: '$END$'}
315326
```js
316327
propTypes: {
317328
$START$: PropTypes.$END$
318-
}
329+
},
319330

320331
```
321332

@@ -391,7 +402,7 @@ this.state.$END$
391402
```js
392403
contextTypes: {
393404
$START$: PropTypes.$END$
394-
}
405+
},
395406

396407
```
397408

@@ -400,7 +411,7 @@ contextTypes: {
400411
```js
401412
childContextTypes: {
402413
$START$: PropTypes.$END$
403-
}
414+
},
404415

405416
```
406417

@@ -432,6 +443,12 @@ getChildContext: function() {
432443

433444
```
434445

446+
### `sdn`
447+
448+
```js
449+
static displayName = '$END$';
450+
```
451+
435452
### `spt`
436453

437454
```js
@@ -468,7 +485,7 @@ static childContextTypes = {
468485

469486
```
470487

471-
### `csttr`
488+
### `cstt`
472489

473490
```js
474491
constructor(props, context$START$) {
@@ -477,6 +494,48 @@ constructor(props, context$START$) {
477494

478495
```
479496

497+
### `tsn`
498+
499+
```js
500+
transitionName="$END$"
501+
```
502+
503+
### `tsa`
504+
505+
```js
506+
transitionAppear={$END$}
507+
```
508+
509+
### `tse`
510+
511+
```js
512+
transitionEnter={$END$}
513+
```
514+
515+
### `tsl`
516+
517+
```js
518+
transitionLeave={$END$}
519+
```
520+
521+
### `tset`
522+
523+
```js
524+
transitionEnterTimeout={$END$}
525+
```
526+
527+
### `tslt`
528+
529+
```js
530+
transitionLeaveTimeout={$END$}
531+
```
532+
533+
### `tsat`
534+
535+
```js
536+
transitionAppearTimeout={$END$}
537+
```
538+
480539
### `oncp`
481540

482541
```js

gulpfile.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,50 @@ var Handlebars = require('handlebars');
99
var template = Handlebars.compile(fs.readFileSync('src/ReactJS.hbs', 'utf8'));
1010
var docTpl = Handlebars.compile(fs.readFileSync('src/doc.hbs', 'utf8'));
1111
var readme = fs.readFileSync('README.md', 'utf8');
12-
1312
var templates = yaml.safeLoad(fs.readFileSync('src/template.yaml', 'utf8'));
1413
var eventsTpl = yaml.safeLoad(fs.readFileSync('src/envents.yaml', 'utf8'));
1514

16-
var processTpl = function(tpl) {
17-
tpl = JSON.stringify(tpl);
18-
return tpl.replace(/\\n/g, '
')
15+
var escapeTpl = function(tpl) {
16+
tpl = tpl.replace(/\n/g, '
')
1917
.replace(/</g, '&lt;')
20-
.replace(/>/g, '&gt;');
18+
.replace(/>/g, '&gt;')
19+
.replace(/"/g, '&quot;')
20+
.replace(/'/g, '&apos;');
21+
// .replace(/&/g, '&amp;')
22+
23+
return JSON.stringify(tpl);
2124
};
2225

2326
var data = [];
24-
var docData = [];
2527

2628
for (var k in templates) {
2729
if (templates.hasOwnProperty(k)) {
2830
var t = templates[k];
31+
console.log(typeof t.tpl);
32+
var isMethod = (typeof t.tpl === 'string' && t.tpl.indexOf(': function') > -1);
2933
var tpl = t.tpl.next || t.tpl;
30-
tpl = tpl.replace(/: function/g, '').replace(/},/g, '}');
31-
34+
tpl = tpl.replace(/: function/g, '');
35+
36+
isMethod && (tpl = tpl.replace(/},/g, '}'));
37+
3238
var snippet = {
3339
name: k,
3440
description: t.description || t.tpl,
35-
tpl: processTpl(tpl),
41+
tpl: escapeTpl(tpl),
3642
variables: t.variables || [],
3743
tplRaw: tpl
3844
};
3945

4046
data.push(snippet);
4147

4248
if (t.tpl.next ||
43-
(typeof t.tpl === 'string' && t.tpl.indexOf(': function') > -1)) {
49+
(typeof t.tpl === 'string' && isMethod)) {
4450

4551
var tpl5 = t.tpl.es5 || t.tpl;
4652
var snippet5 = {
4753
name: k + '5',
4854
description: t.description || t.tpl,
49-
tpl: processTpl(tpl5),
55+
tpl: escapeTpl(tpl5),
5056
variables: t.variables || [],
5157
tplRaw: tpl5
5258
};
@@ -56,23 +62,23 @@ for (var k in templates) {
5662
}
5763
}
5864

59-
function processEnventsTpl(eventsMap) {
65+
function processEventsTpl(eventsMap) {
6066
for (var key in eventsMap) {
6167
if (eventsMap.hasOwnProperty(key)) {
6268
var tplName = eventsMap[key];
6369
var tpl = `${key}={$END$}`;
6470
data.push({
6571
name: tplName,
6672
description: key,
67-
tpl: JSON.stringify(tpl),
73+
tpl: escapeTpl(tpl),
6874
tplRaw: tpl
6975
});
7076

7177
}
7278
}
7379
}
7480

75-
processEnventsTpl(eventsTpl);
81+
processEventsTpl(eventsTpl);
7682

7783
fs.writeFileSync('jetbrains/templates/ReactJS.xml', template(data));
7884
fs.writeFileSync('README.md', readme.replace(

jetbrains-react.jar

189 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)