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
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commitc7bfc1f

Browse files
committed
export editor, pass editor into Main
1 parentea0f64c commitc7bfc1f

16 files changed

+214
-90
lines changed

‎lib/editor/compareVersions.js

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎lib/editor/compareVersions.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎lib/editor/index.js

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎lib/editor/index.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎lib/editor/setup.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎lib/editor/setup.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎lib/index.js

Lines changed: 3 additions & 38 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎lib/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎lib/main.js

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎lib/main.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎src/editor/compareVersions.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* extracts versions intro array from a string
3+
* "0.1.0" -> ['0', '1', '0']
4+
* or returns null
5+
*@param {string} v
6+
*/
7+
functionmatchVersions(v:string):string[]|null{
8+
returnv.match(/([0-9]+)\.([0-9]+)/);
9+
}
10+
11+
/**
12+
* checks that a version is >= b version
13+
*@param {string} a
14+
*@param {string} b
15+
*@returns boolean
16+
*/
17+
exportfunctionisAboveVersion(a:string,b:string):boolean{
18+
if(a===b){returntrue;}
19+
consta_components=a.split('.');
20+
constb_components=b.split('.');
21+
constlen=Math.min(a_components.length,b_components.length);
22+
for(leti=0;i<len;i++){
23+
constfirst=parseInt(a_components[i],10);
24+
constsecond=parseInt(b_components[i],10);
25+
if(first>second){returntrue;}
26+
if(first<second){returnfalse;}
27+
}
28+
if(a_components.length>b_components.length){returntrue;}
29+
if(a_components.length<b_components.length){returnfalse;}
30+
returntrue;
31+
}

‎src/editor/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import{directory}from'./directory';
2+
import{getGrammar,tokenizeLines}from'./grammar';
3+
import{
4+
editorIssuesPath,editorMinVersion,editorName,
5+
editorVersionFailMessage,editorVersionLabel,minVersion
6+
}from'./setup';
7+
importSubscriptionsfrom'./subscriptions';
8+
import{addRightPanel}from'./ui';
9+
10+
consteditor={
11+
directory,
12+
getGrammar,
13+
tokenizeLines,
14+
editorName,
15+
editorMinVersion,
16+
editorVersionLabel,
17+
editorVersionFailMessage,
18+
editorIssuesPath,
19+
minVersion,
20+
Subscriptions,
21+
addRightPanel
22+
}
23+
24+
exportdefaulteditor;

‎src/editor/setup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import*asReactfrom'react';
22

3-
import{isAboveVersion}from'../utils/compareVersions';
3+
import{isAboveVersion}from'./compareVersions';
44
importcommandLinefrom'atom-plugin-command-line';
55

66
exportconsteditorName='Atom';

‎src/index.ts

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,7 @@
1-
import*asReactfrom'react';
2-
import*asReactDOMfrom'react-dom';
3-
4-
import*asactionsfrom'./actions';
5-
import{SideRoot,sideElement}from'./components/SidePanel';
6-
importaddToStatusBarfrom'./components/StatusBar';
7-
importSubscriptionsfrom'./editor/subscriptions';
8-
import{addRightPanel}from'./editor/ui';
9-
import{setupVerify}from'./modules/setup';
10-
importstorefrom'./store';
11-
importloadPolyfillsfrom'./utils/polyfills';
12-
import*asinjectTapEventPluginfrom'react-tap-event-plugin';
1+
importeditorfrom'./editor';
2+
importMainfrom'./main';
133

144
// React optimization
155
process.env.NODE_ENV='production';
166

17-
classMain{
18-
privateside:HTMLElement;
19-
privatestatusBarTile:StatusBar.IStatusBarView|null;
20-
privatesubscriptions:any;
21-
constructor(){
22-
injectTapEventPlugin();// remove later
23-
loadPolyfills();
24-
// run startup checks
25-
store.dispatch(setupVerify());
26-
this.side=sideElement.init();
27-
this.subscriptions=newSubscriptions();
28-
}
29-
publicactivate():void{
30-
// create editor panel
31-
addRightPanel(this.side);
32-
// activate subscriptions
33-
this.subscriptions.onActivate(store,actions);
34-
// render React component
35-
ReactDOM.render(SideRoot(store),this.side);
36-
}
37-
publicdeactivate():void{
38-
// remove bottom status bar icon
39-
if(this.statusBarTile){
40-
this.statusBarTile.destroy();
41-
this.statusBarTile=null;
42-
}
43-
// remove subscriptions & unmount react app
44-
this.subscriptions.onDeactivate(store);
45-
// unmount React
46-
sideElement.unmount();
47-
}
48-
privateconsumeStatusBar(statusBar){
49-
this.statusBarTile=addToStatusBar(store,statusBar);
50-
}
51-
};
52-
export=newMain();
7+
export=newMain(editor);

‎src/main.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import*asReactfrom'react';
2+
import*asReactDOMfrom'react-dom';
3+
4+
import*asactionsfrom'./actions';
5+
import{SideRoot,sideElement}from'./components/SidePanel';
6+
importaddToStatusBarfrom'./components/StatusBar';
7+
import{setupVerify}from'./modules/setup';
8+
importstorefrom'./store';
9+
importloadPolyfillsfrom'./utils/polyfills';
10+
import*asinjectTapEventPluginfrom'react-tap-event-plugin';
11+
12+
classMain{
13+
publiceditor:any;
14+
privateside:HTMLElement;
15+
privatestatusBarTile:StatusBar.IStatusBarView|null;
16+
privatesubscriptions:any;
17+
constructor(editor){
18+
injectTapEventPlugin();// remove later
19+
loadPolyfills();
20+
21+
this.editor=editor;
22+
// run startup checks
23+
store.dispatch(setupVerify());
24+
this.side=sideElement.init();
25+
this.subscriptions=neweditor.Subscriptions();
26+
}
27+
publicactivate():void{
28+
// create editor panel
29+
this.editor.addRightPanel(this.side);
30+
// activate subscriptions
31+
this.subscriptions.onActivate(store,actions);
32+
// render React component
33+
ReactDOM.render(SideRoot(store),this.side);
34+
}
35+
publicdeactivate():void{
36+
// remove bottom status bar icon
37+
if(this.statusBarTile){
38+
this.statusBarTile.destroy();
39+
this.statusBarTile=null;
40+
}
41+
// remove subscriptions & unmount react app
42+
this.subscriptions.onDeactivate(store);
43+
// unmount React
44+
sideElement.unmount();
45+
}
46+
privateconsumeStatusBar(statusBar){
47+
this.statusBarTile=addToStatusBar(store,statusBar);
48+
}
49+
};
50+
exportdefaultMain;

‎tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,14 @@
9393
"src/editor/actions/terminal.ts",
9494
"src/editor/actions/write.ts",
9595
"src/editor/actions/writeFile.ts",
96+
"src/editor/compareVersions.ts",
9697
"src/editor/directory.ts",
9798
"src/editor/grammar.ts",
99+
"src/editor/index.ts",
98100
"src/editor/subscriptions.ts",
99101
"src/editor/ui.ts",
100102
"src/index.ts",
103+
"src/main.ts",
101104
"src/modules/alert/actions.ts",
102105
"src/modules/alert/index.ts",
103106
"src/modules/alert/types.ts",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp