diff --git a/.babelrc b/.babelrc index 454f09d6a..a89509275 100644 --- a/.babelrc +++ b/.babelrc @@ -1,6 +1,6 @@ { - "presets": ["es2015"], + "presets": ["env"], "plugins": [ ["transform-react-jsx", {"pragma": "element"}] ] -} \ No newline at end of file +} diff --git a/css/base/font.css b/css/base/font.css index 2ad38c180..cba7efa99 100644 --- a/css/base/font.css +++ b/css/base/font.css @@ -9,4 +9,4 @@ code { color: #c7254e; background-color: #f9f2f4; border-radius: 4px; -} \ No newline at end of file +} diff --git a/css/base/margin-padding.css b/css/base/margin-padding.css index 7fdab501b..8f3215df2 100644 --- a/css/base/margin-padding.css +++ b/css/base/margin-padding.css @@ -16,4 +16,4 @@ p { ul { margin: 0; padding: auto 0; -} \ No newline at end of file +} diff --git a/css/color.css b/css/color.css index a8241f952..d4016baec 100644 --- a/css/color.css +++ b/css/color.css @@ -2,7 +2,7 @@ --MainBackgroundColor: white; --BackgroundColor: #f4f4f4; --AccentColor: #5acbe3; - --MenuLinkColor: #0F0F0F; - --LeadingTextColor: #3D454E; - --TextColor: #30363D; -} \ No newline at end of file + --MenuLinkColor: #0f0f0f; + --LeadingTextColor: #3d454e; + --TextColor: #30363d; +} diff --git a/css/components/AddTextlintRule.css b/css/components/AddTextlintRule.css index db59be9a2..9acf5d356 100644 --- a/css/components/AddTextlintRule.css +++ b/css/components/AddTextlintRule.css @@ -4,4 +4,4 @@ .AddTextlintRule input { margin: 0 0.2rem; -} \ No newline at end of file +} diff --git a/css/components/App.css b/css/components/App.css index 95df63a8d..7940529f4 100644 --- a/css/components/App.css +++ b/css/components/App.css @@ -1,5 +1,6 @@ @import "../color.css"; -html, body { +html, +body { background-color: var(--BackgroundColor); -} \ No newline at end of file +} diff --git a/css/components/DisabledTextlintRuleList.css b/css/components/DisabledTextlintRuleList.css index 7f91fe64a..e98d8502f 100644 --- a/css/components/DisabledTextlintRuleList.css +++ b/css/components/DisabledTextlintRuleList.css @@ -1,7 +1,8 @@ -.DisabledTextlintRuleListBox, .DisabledTextlintRuleList { +.DisabledTextlintRuleListBox, +.DisabledTextlintRuleList { margin: 0; } .DisabledTextlintRuleList { padding-left: 32px; -} \ No newline at end of file +} diff --git a/css/components/EnabledTextlintRuleList.css b/css/components/EnabledTextlintRuleList.css index 69d68de7e..1337f0d36 100644 --- a/css/components/EnabledTextlintRuleList.css +++ b/css/components/EnabledTextlintRuleList.css @@ -1,7 +1,8 @@ -.EnabledTextlintRuleListBox, .EnabledTextlintRuleList { +.EnabledTextlintRuleListBox, +.EnabledTextlintRuleList { margin: 0; } .EnabledTextlintRuleList { padding-left: 32px; -} \ No newline at end of file +} diff --git a/css/components/Footer.css b/css/components/Footer.css index 5e187a778..827cbe1dd 100644 --- a/css/components/Footer.css +++ b/css/components/Footer.css @@ -12,4 +12,4 @@ .Footer-list-item a { color: var(--MenuLinkColor); -} \ No newline at end of file +} diff --git a/css/components/Header.css b/css/components/Header.css index 02157d48c..c9ce99506 100644 --- a/css/components/Header.css +++ b/css/components/Header.css @@ -1,7 +1,7 @@ @import "../color.css"; @import "./_var-layout.css"; .Header { - background-color: #FBFBFB; + background-color: #fbfbfb; padding: 5px 0; display: flex; } @@ -23,7 +23,8 @@ padding-right: var(--right-end-padding); } -.HeaderMenus, .HeaderMenuItem { +.HeaderMenus, +.HeaderMenuItem { display: inline-block; } @@ -54,4 +55,4 @@ .Logo-img { height: 40px; -} \ No newline at end of file +} diff --git a/css/components/Leading.css b/css/components/Leading.css index aa6dda02d..a0c322173 100644 --- a/css/components/Leading.css +++ b/css/components/Leading.css @@ -1,7 +1,7 @@ @import "../color.css"; -:root{ - --leadingColor : white; +:root { + --leadingColor: white; } .Leading { background-color: var(--AccentColor); @@ -34,6 +34,6 @@ .Leading-downloadButton:hover { color: var(--AccentColor); text-shadow: none; - background-color: #FFF; - border-color: #FFF; + background-color: #fff; + border-color: #fff; } diff --git a/css/components/TextlintDemo.css b/css/components/TextlintDemo.css index 80ff8f14c..2b2ca751f 100644 --- a/css/components/TextlintDemo.css +++ b/css/components/TextlintDemo.css @@ -1,16 +1,23 @@ @import "./_var-layout.css"; @import "../color.css"; +:root { + --TextlintDemo-height: 100%; +} + .TextlintDemo { background-color: var(--MainBackgroundColor); + height: 100%; } -.TextlintDemo-title, .TextlintDemo-lead { +.TextlintDemo-title, +.TextlintDemo-lead { padding-left: var(--left-start-padding); padding-right: var(--right-end-padding); } -.TextlintDemo-ruleBox, .TextlintDemo-errorBox { +.TextlintDemo-ruleBox, +.TextlintDemo-errorBox { padding-bottom: 1rem; } @@ -22,37 +29,41 @@ } .TextlintDemo-Editor { - border-right: 1px solid #ddd + border-right: 1px solid #ddd; } .TextlintDemo-Setting { - border-left: 1px solid #ddd + border-left: 1px solid #ddd; } -.TextlintDemo-Editor, .TextlintEditor .TextlintDemo-Setting, .TextlintErrorList { +.TextlintDemo-Editor, +.TextlintEditor .TextlintDemo-Setting, +.TextlintErrorList { width: 100%; } +.TextlintDemo-errorBox, +.TextlintDemo-ruleBox { + overflow: scroll; +} + /*TextlintDemo-Editor | TextlintDemo-Setting*/ -.TextlintDemo-Editor, .TextlintEditor, .TextlintDemo-Setting { - height: 100%; +.TextlintEditor, +.TextlintDemo-Setting { + height: var(--TextlintDemo-height); } -.TextlintDemo-Editor h3, .TextlintDemo-Setting h3 { - /* 縦位置をめにゅーと揃える */ - padding: 0; +.TextlintDemo-Editor h3, +.TextlintDemo-Setting h3 { margin: 0; - padding-right: var(--right-end-padding); + padding: 0 var(--right-end-padding) 0 0; text-align: right; background-color: #f4f4f4; color: var(--TextColor); } -.CodeMirrorEditor { - height: 100%; -} - -.CodeMirror { - height: auto; +.CodeMirrorEditor, +.CodeMirrorEditor .CodeMirror { + height: var(--TextlintDemo-height); font-size: 14px; -} \ No newline at end of file +} diff --git a/css/components/TextlintRuleListItem.css b/css/components/TextlintRuleListItem.css index c6723e468..bfee97f83 100644 --- a/css/components/TextlintRuleListItem.css +++ b/css/components/TextlintRuleListItem.css @@ -5,4 +5,4 @@ .TextLintRuleListItem p { padding: 0; margin: 0; -} \ No newline at end of file +} diff --git a/css/components/TextlintRuleListSet.css b/css/components/TextlintRuleListSet.css index 9398210a4..de7cc0db3 100644 --- a/css/components/TextlintRuleListSet.css +++ b/css/components/TextlintRuleListSet.css @@ -1,3 +1,3 @@ .TextlintRuleListSet { margin: 0.5rem 0; -} \ No newline at end of file +} diff --git a/css/components/WhatIsTextLint.css b/css/components/WhatIsTextLint.css index ee37653aa..74a1af71d 100644 --- a/css/components/WhatIsTextLint.css +++ b/css/components/WhatIsTextLint.css @@ -14,5 +14,5 @@ } .WhatIsTextLint-philosophy-list { - padding-left: calc(var(--left-start-padding) + 1em) -} \ No newline at end of file + padding-left: calc(var(--left-start-padding) + 1em); +} diff --git a/css/components/_shared_header.css b/css/components/_shared_header.css index c37806745..41da47792 100644 --- a/css/components/_shared_header.css +++ b/css/components/_shared_header.css @@ -1,6 +1,6 @@ .header-has-icon:before { - content:""; + content: ""; background: url("../img/textlint-icon_black-white-128x128.png") no-repeat left center; background-size: 0.8em; padding-right: 1em; -} \ No newline at end of file +} diff --git a/css/components/_var-layout.css b/css/components/_var-layout.css index a725debf8..178393207 100644 --- a/css/components/_var-layout.css +++ b/css/components/_var-layout.css @@ -7,4 +7,4 @@ :root { --right-end-padding: 1.5rem; --left-start-padding: 1.5rem; -} \ No newline at end of file +} diff --git a/css/index.css b/css/index.css index ed96dc845..24dfc9024 100644 --- a/css/index.css +++ b/css/index.css @@ -22,4 +22,4 @@ @import "./components/_shared_header.css"; /* Utils */ @import "./utils/padding.css"; -@import "./utils/image.css"; \ No newline at end of file +@import "./utils/image.css"; diff --git a/css/layout/Body.css b/css/layout/Body.css index fd612bcb2..d6a07c1f5 100644 --- a/css/layout/Body.css +++ b/css/layout/Body.css @@ -1,4 +1,5 @@ -html, body { +html, +body { padding: 0; margin: 0; } @@ -9,4 +10,4 @@ html, body { .MainContent { padding: 0 5px; -} \ No newline at end of file +} diff --git a/css/utils/image.css b/css/utils/image.css index 0d39d5610..ccb3269c6 100644 --- a/css/utils/image.css +++ b/css/utils/image.css @@ -1,4 +1,4 @@ .u-inline-icon { display: inline !important; height: 1em !important; -} \ No newline at end of file +} diff --git a/package.json b/package.json index 2d420acbe..d12ac997c 100644 --- a/package.json +++ b/package.json @@ -19,43 +19,66 @@ "test": "test" }, "scripts": { + "start": "npm-run-all clean --parallel watch:css server", "build:css": "suitcss --import-root css/ css/index.css bundle/build.css", "build:js": "webpack -p", "build": "npm-run-all --parallel build:*", - "watch:css": "suitcss --watch --import-root css/ css/index.css bundle/build.css", + "watch:css": "suitcss --watch --import-root css/ css/index.css public/build/build.css", "watch:js": "webpack -d --watch", "watch": "npm-run-all --parallel watch:*", - "deploy": "gh-pages -b master -d ./ --repo git@github.com:textlint/textlint.github.io.git" + "deploy": "gh-pages -b master -d ./public --repo git@github.com:textlint/textlint.github.io.git", + "server": "cross-env NODE_ENV=development webpack-dev-server --hot --content-base ./public --open", + "prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"", + "precommit": "lint-staged", + "postcommit": "git reset", + "clean": "rimraf public/build/" }, "dependencies": { - "camelcase": "^2.0.1", - "codemirror": "^5.10.0", - "codemirror-textlint": "^1.0.1", - "decca": "^2.0.1", + "@textlint/kernel": "^2.0.3", + "camelcase": "^4.1.0", + "codemirror": "^5.33.0", + "decca": "^2.3.0", "isomorphic-fetch": "^2.2.1", "lodash.debounce": "^4.0.0", - "redux": "^3.0.5", - "redux-logger": "^2.3.1", - "textlint": "^7.2.2", + "redux": "^3.7.2", + "redux-logger": "^3.0.6", "textlint-message-to-codemirror": "^1.0.0", + "textlint-plugin-markdown": "^4.0.4", "textlint-rule-alex": "^1.0.1", - "textlint-rule-no-todo": "^1.0.3", + "textlint-rule-no-todo": "^2.0.0", "textlint-rule-rousseau": "^1.3.2", "textlint-rule-sjsj": "^1.0.5", "textlint-rule-unexpanded-acronym": "^1.2.1" }, "devDependencies": { - "babel-loader": "^6.2.1", - "babel-plugin-transform-react-jsx": "^6.3.13", - "babel-preset-es2015": "^6.3.13", - "css-loader": "0.26.1", - "gh-pages": "0.12.0", - "json-loader": "^0.5.4", - "npm-run-all": "4.0.1", + "babel-core": "^6.26.0", + "babel-loader": "^7.1.2", + "babel-plugin-transform-react-jsx": "^6.24.1", + "babel-preset-env": "^1.6.1", + "cross-env": "^5.1.3", + "css-loader": "0.28.8", + "gh-pages": "1.1.0", + "husky": "^0.14.3", + "lint-staged": "^6.0.0", + "npm-run-all": "4.1.2", + "prettier": "^1.10.2", + "rimraf": "^2.6.2", "shebang-loader": "^0.0.1", - "style-loader": "^0.13.0", - "suitcss-preprocessor": "3.0.1", - "suitcss-utils": "2.0.0", - "webpack": "^2.2.0" + "style-loader": "^0.19.1", + "suitcss-preprocessor": "4.0.0", + "suitcss-utils": "3.0.0", + "webpack": "^3.10.0", + "webpack-dev-server": "^2.10.1" + }, + "prettier": { + "singleQuote": false, + "printWidth": 120, + "tabWidth": 4 + }, + "lint-staged": { + "*.{js,jsx,ts,tsx,css}": [ + "prettier --write", + "git add" + ] } } diff --git a/img/banner_1420x512.png b/public/img/banner_1420x512.png similarity index 100% rename from img/banner_1420x512.png rename to public/img/banner_1420x512.png diff --git a/img/textlint-icon-no-circle_128x128.png b/public/img/textlint-icon-no-circle_128x128.png similarity index 100% rename from img/textlint-icon-no-circle_128x128.png rename to public/img/textlint-icon-no-circle_128x128.png diff --git a/img/textlint-icon_256x256.png b/public/img/textlint-icon_256x256.png similarity index 100% rename from img/textlint-icon_256x256.png rename to public/img/textlint-icon_256x256.png diff --git a/img/textlint-icon_black-white-128x128.png b/public/img/textlint-icon_black-white-128x128.png similarity index 100% rename from img/textlint-icon_black-white-128x128.png rename to public/img/textlint-icon_black-white-128x128.png diff --git a/img/textlint-logo.png b/public/img/textlint-logo.png similarity index 100% rename from img/textlint-logo.png rename to public/img/textlint-logo.png diff --git a/index.html b/public/index.html similarity index 70% rename from index.html rename to public/index.html index 2f8754d3f..8c4266f27 100644 --- a/index.html +++ b/public/index.html @@ -7,17 +7,17 @@ textlint - pluggable linting tool for text and markdown - - + + - + - + - \ No newline at end of file + diff --git a/src/actions/textlintActions.js b/src/actions/textlintActions.js index f08ab73ab..df2e24b08 100644 --- a/src/actions/textlintActions.js +++ b/src/actions/textlintActions.js @@ -12,46 +12,46 @@ export function updateText(text) { return { type: UPDATE_TEXT, text - } + }; } export function updateRuleErrors(errors) { return { type: UPDATE_RULE_ERRORS, errors - } + }; } export function updateRuleList(rules) { return { type: UPDATE_RULE_LIST, rules - } + }; } export function toggleRule(id) { return { type: TOGGLE_RULE, id - } + }; } export function addRule(ruleName, rule) { return { type: ADD_RULE, ruleName, rule - } + }; } export function startRequest(url) { return { type: START_REQUEST, url - } + }; } export function successResponse(url) { return { type: SUCCESS_RESPONSE, url - } + }; } export function failureResponse(url, error) { @@ -59,5 +59,5 @@ export function failureResponse(url, error) { type: FAILURE_RESPONSE, url, error - } -} \ No newline at end of file + }; +} diff --git a/src/components/App.js b/src/components/App.js index 039b58beb..28b7b0347 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -1,34 +1,39 @@ // LICENSE : MIT "use strict"; -import {element} from 'decca' -import {TextlintDemo} from "./TextlintDemo"; -import {Header} from "./Header"; -import {WhatIsTextLint} from "./WhatIsTextLint"; -import {Leading} from "./Leading"; -import {Fixable} from "./Fixable" -import {Footer} from "./Footer"; -import {scrollToLocationHash} from "../side-effect/scroll-to-location"; +import { element } from "decca"; +import { TextlintDemo } from "./TextlintDemo"; +import { Header } from "./Header"; +import { WhatIsTextLint } from "./WhatIsTextLint"; +import { Leading } from "./Leading"; +import { Fixable } from "./Fixable"; +import { Footer } from "./Footer"; +import { scrollToLocationHash } from "../side-effect/scroll-to-location"; const App = { - onCreate(){ - requestAnimationFrame(function () { + onCreate() { + requestAnimationFrame(function() { const hash = location.hash; scrollToLocationHash(hash.slice(1)); }); }, - render({context}){ + render({ context }) { const enabledRules = context.rules.filter(rule => rule.enable); const disabledRules = context.rules.filter(rule => !rule.enable); - const {text, ruleErrors} = context; - return
-
- - - - -
+ const { text, ruleErrors } = context; + return ( +
+
+ + + + +
+ ); } }; export default App; diff --git a/src/components/Fixable.js b/src/components/Fixable.js index 49a4d52bd..7c5776c2e 100644 --- a/src/components/Fixable.js +++ b/src/components/Fixable.js @@ -1,18 +1,22 @@ // LICENSE : MIT "use strict"; -import {element} from 'decca' +import { element } from "decca"; export const Fixable = { - render({props}){ - return
-

Fixable in textlint

-

- textlint is a linter and also is fixer. - -

-

- Please see document about fixer for details. -

-
; + render({ props }) { + return ( +
+

Fixable in textlint

+

+ textlint is a linter and also is fixer. +

+

+ Please see{" "} + + document about fixer + {" "} + for details. +

+
+ ); } -}; \ No newline at end of file +}; diff --git a/src/components/Footer.js b/src/components/Footer.js index 75daf063c..974281c54 100644 --- a/src/components/Footer.js +++ b/src/components/Footer.js @@ -1,17 +1,20 @@ // LICENSE : MIT "use strict"; -import {element} from 'decca' +import { element } from "decca"; export const Footer = { - render({props}){ - return
- -
; + render({ props }) { + return ( +
+ +
+ ); } -}; \ No newline at end of file +}; diff --git a/src/components/Header.js b/src/components/Header.js index 8b268414c..d55d4a4ea 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -1,51 +1,58 @@ // LICENSE : MIT "use strict"; -import {element} from 'decca' +import { element } from "decca"; const menuItems = [ { - "title": "Rules", - "url": "https://github.com/azu/textlint/wiki/Collection-of-textlint-rule" + title: "Rules", + url: "https://github.com/azu/textlint/wiki/Collection-of-textlint-rule" }, { - "title": "Documentation", - "url": "https://github.com/textlint/textlint/tree/master/docs" + title: "Documentation", + url: "https://github.com/textlint/textlint/tree/master/docs" }, { - "title": "GitHub", - "url": "https://github.com/textlint/textlint" + title: "GitHub", + url: "https://github.com/textlint/textlint" } ]; export const Logo = { - render(){ - return - textlint - + render() { + return ( + + textlint + + ); } }; export const HeaderMenuItem = { - render({props}){ - return
  • {props.title}
  • + render({ props }) { + return ( +
  • + {props.title} +
  • + ); } }; export const HeaderMenu = { - render({props}){ + render({ props }) { const items = props.menuItems.map(item => { - return + return ; }); - return + return ( + + ); } }; export const Header = { - render({props}){ - return
    - - -
    ; + render({ props }) { + return ( +
    + + +
    + ); } }; diff --git a/src/components/Leading.js b/src/components/Leading.js index 46c5e7806..7bad04fb7 100644 --- a/src/components/Leading.js +++ b/src/components/Leading.js @@ -1,17 +1,30 @@ // LICENSE : MIT "use strict"; -import {element} from 'decca' +import { element } from "decca"; export const Leading = { - render({props}){ - return
    -

    - textlint -

    -

    The pluggable linting tool for text and markdown.

    -

    Install

    -
    ; + render({ props }) { + return ( +
    +

    + textlint +

    +

    The pluggable linting tool for text and markdown.

    +

    + + Install + +

    +
    + ); } -}; \ No newline at end of file +}; diff --git a/src/components/TextlintDemo.js b/src/components/TextlintDemo.js index 8f51834fe..90e59da36 100644 --- a/src/components/TextlintDemo.js +++ b/src/components/TextlintDemo.js @@ -1,40 +1,45 @@ // LICENSE : MIT "use strict"; -import {element} from 'decca' +import { element } from "decca"; import EnabledTextlintRuleList from "./TextlintDemo/EnabledTextlintRuleList"; import DisabledTextlintRuleList from "./TextlintDemo/DisabledTextlintRuleList"; -import AddTextlintRule from "./TextlintDemo/AddTextlintRule"; -import TextlintEditor from "./TextlintDemo/TextlintEditor" -import TextlintErrorList from "./TextlintDemo/TextlintErrorList" +// import AddTextlintRule from "./TextlintDemo/AddTextlintRule"; +import TextlintEditor from "./TextlintDemo/TextlintEditor"; +import TextlintErrorList from "./TextlintDemo/TextlintErrorList"; export const TextlintDemo = { - render({props}){ - const {enabledRules, disabledRules, ruleErrors, text} = props; - return
    -

    Online DEMO

    -

    - Take textlint for a spin, start typing below. Want to use more? Go to GitHub -

    -
    -
    - -
    -
    -
    -

    Rule Errors

    - + render({ props }) { + const { enabledRules, disabledRules, ruleErrors, text } = props; + return ( +
    +

    + Online DEMO +

    +

    + Take textlint for a spin, start typing below. Want to use more? Go to{" "} + + GitHub + +

    +
    +
    +
    -
    -

    Rule Lists

    -
    - - +
    +
    +

    Rule Errors

    + +
    +
    +

    Rule Lists

    +
    + + +
    + {/**/}
    - -
    -
    + ); } -}; \ No newline at end of file +}; diff --git a/src/components/TextlintDemo/AddTextlintRule.js b/src/components/TextlintDemo/AddTextlintRule.js index 5088914d3..6ae702062 100644 --- a/src/components/TextlintDemo/AddTextlintRule.js +++ b/src/components/TextlintDemo/AddTextlintRule.js @@ -1,8 +1,8 @@ // LICENSE : MIT "use strict"; -import {element} from 'decca' -import {addRule, startRequest, failureResponse, successResponse} from "../../actions/textlintActions"; -import camelCase from 'camelcase'; +import { element } from "decca"; +import { addRule, startRequest, failureResponse, successResponse } from "../../actions/textlintActions"; +import camelCase from "camelcase"; // Dispatch an action when the button is clicked const fetchModule = (dispatch, moduleName) => { return new Promise((resolve, reject) => { @@ -24,7 +24,7 @@ const fetchModule = (dispatch, moduleName) => { reject(error); } }; - script.onerror = (error) => { + script.onerror = error => { dispatch(failureResponse(API_URL, error)); reject(error); }; @@ -37,24 +37,31 @@ const onSubmit = (dispatch, path) => { if (!/^textlint-rule/.test(moduleName)) { return; } - fetchModule(dispatch, moduleName).then(()=> { - input.value = ""; - }).catch((error) => { - alert(error.message); - }); + fetchModule(dispatch, moduleName) + .then(() => { + input.value = ""; + }) + .catch(error => { + alert(error.message); + }); }; export default { - render({props, path, dispatch}){ - return
    -
    { - event.preventDefault(); - onSubmit(dispatch, path); - }}> - - - -
    - -
    + render({ props, path, dispatch }) { + return ( +
    +
    { + event.preventDefault(); + onSubmit(dispatch, path); + }} + > + + + +
    +
    + ); } -} \ No newline at end of file +}; diff --git a/src/components/TextlintDemo/CodeMirrorEditor.js b/src/components/TextlintDemo/CodeMirrorEditor.js index cdcb284a8..fa72c229f 100644 --- a/src/components/TextlintDemo/CodeMirrorEditor.js +++ b/src/components/TextlintDemo/CodeMirrorEditor.js @@ -1,7 +1,7 @@ // LICENSE : MIT "use strict"; -import {dom, element} from 'decca' -import CodeMirror from "codemirror" +import { dom, element } from "decca"; +import CodeMirror from "codemirror"; const mirrorMap = {}; function mutateAfterMount(path, props) { return () => { @@ -10,7 +10,7 @@ function mutateAfterMount(path, props) { updateCmState(cm, props); mirrorMap[path] = cm; if (typeof props["onChange"] === "function") { - cm.on('change', props["onChange"]); + cm.on("change", props["onChange"]); } if (typeof props.defaultValue === "string") { cm.setValue(props.defaultValue); @@ -25,7 +25,7 @@ function updateCmState(cm, nextProps) { } } // options - if (typeof nextProps.options === 'object') { + if (typeof nextProps.options === "object") { Object.keys(nextProps.options).forEach(optionName => { if (nextProps.options.hasOwnProperty(optionName)) { cm.setOption(optionName, nextProps.options[optionName]); @@ -34,27 +34,29 @@ function updateCmState(cm, nextProps) { } } const CodeMirrorEditor = { - onCreate({path, props}){ + onCreate({ path, props }) { requestAnimationFrame(mutateAfterMount(path, props)); }, - onUpdate({props, path}){ + onUpdate({ props, path }) { const cm = mirrorMap[path]; if (cm) { updateCmState(cm, props); } }, - onRemove({path}){ + onRemove({ path }) { const cm = mirrorMap[path]; if (cm) { cm.toTextArea(); mirrorMap[path] = null; } }, - render({path}){ - return
    - -
    + render({ path }) { + return ( +
    +