Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit56abcb8

Browse files
committed
create TextEditor component
1 parent7b7795a commit56abcb8

File tree

6 files changed

+68
-1
lines changed

6 files changed

+68
-1
lines changed

‎lib/components/TextEditor/index.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"use strict";
2+
var__extends=(this&&this.__extends)||function(d,b){
3+
for(varpinb)if(b.hasOwnProperty(p))d[p]=b[p];
4+
function__(){this.constructor=d;}
5+
d.prototype=b===null ?Object.create(b) :(__.prototype=b.prototype,new__());
6+
};
7+
varReact=require('react');
8+
varstyles={
9+
editor:{
10+
textAlign:'left',
11+
border:'2px solid red',
12+
margin:'5px',
13+
borderRadius:'3px',
14+
},
15+
};
16+
varTextEditor=(function(_super){
17+
__extends(TextEditor,_super);
18+
functionTextEditor(){
19+
_super.apply(this,arguments);
20+
}
21+
TextEditor.prototype.componentDidMount=function(){
22+
vared=atom.workspace.buildTextEditor();
23+
ed.setGrammar(atom.grammars.grammarForScopeName('source.js'));
24+
console.log(ed);
25+
ed.setText('var a = 42;');
26+
document.querySelector("#"+this.props.name).appendChild(ed.getElement());
27+
};
28+
TextEditor.prototype.render=function(){
29+
returnReact.createElement("div",{id:this.props.name,style:styles.editor});
30+
};
31+
returnTextEditor;
32+
}(React.Component));
33+
Object.defineProperty(exports,"__esModule",{value:true});
34+
exports.default=TextEditor;

‎lib/components/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ var Start_1 = require('./Start');
1616
exports.Start=Start_1.default;
1717
varTutorials_1=require('./Tutorials');
1818
exports.Tutorials=Tutorials_1.default;
19+
varTextEditor_1=require('./TextEditor');
20+
exports.TextEditor=TextEditor_1.default;
1921
varRouteButton_1=require('./common/RouteButton');
2022
exports.RouteButton=RouteButton_1.default;
2123
varContentCard_1=require('./common/ContentCard');

‎src/components/Start/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default class Start extends React.Component<{
1818
},{}>{
1919
render(){
2020
const{ready}=this.props;
21+
2122
return(
2223
<sectionclassName='cr-start'>
2324
<divstyle={headerStyles}>

‎src/components/TextEditor/index.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import*asReactfrom'react';
2+
3+
conststyles={
4+
editor:{
5+
textAlign:'left',
6+
border:'2px solid red',
7+
margin:'5px',
8+
borderRadius:'3px',
9+
},
10+
};
11+
12+
exportdefaultclassTextEditorextendsReact.Component<{
13+
name:string
14+
},{}>{
15+
componentDidMount(){
16+
consted=atom.workspace.buildTextEditor();
17+
ed.setGrammar(
18+
atom.grammars.grammarForScopeName('source.js')
19+
);
20+
console.log(ed);
21+
// ed.style.textAlign = 'left';
22+
ed.setText('var a = 42;');
23+
document.querySelector(`#${this.props.name}`).appendChild(ed.getElement());
24+
}
25+
render(){
26+
return<divid={this.props.name}style={styles.editor}/>;
27+
}
28+
}

‎src/components/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export{
2-
Alert,Markdown
2+
Alert,Markdown
33
}from'core-coderoad';
44

55
export{defaultasAppMenu}from'./AppMenu';
@@ -9,6 +9,7 @@ export {default as Progress} from './Progress';
99
export{defaultasRoutes}from'./Routes';
1010
export{defaultasStart}from'./Start';
1111
export{defaultasTutorials}from'./Tutorials';
12+
export{defaultasTextEditor}from'./TextEditor';
1213

1314
export{defaultasRouteButton}from'./common/RouteButton';
1415
export{defaultasContentCard}from'./common/ContentCard';

‎tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
"src/components/Start/Checks/VerifyButton.tsx",
121121
"src/components/Start/index.tsx",
122122
"src/components/Start/Welcome/index.tsx",
123+
"src/components/TextEditor/index.tsx",
123124
"src/components/Tutorials/index.tsx",
124125
"src/components/Tutorials/LoadTutorials/index.tsx",
125126
"src/components/Tutorials/SelectTutorial/index.tsx",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp