Skip to content

Commit

Permalink
feat: init & done
Browse files Browse the repository at this point in the history
  • Loading branch information
afeiship committed Feb 17, 2019
0 parents commit c2fa1a9
Show file tree
Hide file tree
Showing 11 changed files with 184 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"presets": [
"es2015",
"stage-0"
],
"plugins": [
"transform-decorators-legacy",
"transform-class-properties",
"transform-es2015-spread",
"transform-object-rest-spread",
"transform-react-jsx"
],
"ignore": [
]
}
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
bower_components
coverage
npm-debug.log
yarn.lock
Gemfile.lock
yarn-error.log
package-lock.json
.DS_Store
.idea
.vscode
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build
src
config
static
.babelrc
.gitignore
yarn.lock
test
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
40 changes: 40 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"trailingComma": "none",
"arrowParens": "always",
"printWidth": 100,
"bracketSpacing": true,
"jsxBracketSameLine": true,
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"overrides": [
{
"files": ["*.json", ".eslintrc", ".tslintrc", ".prettierrc", ".tern-project"],
"options": {
"parser": "json",
"tabWidth": 2
}
},
{
"files": "*.{css,sass,scss,less}",
"options": {
"parser": "postcss",
"tabWidth": 2
}
},
{
"files": "*.ts",
"options": {
"parser": "typescript"
}
},
{
"files": "*.md",
"options": {
"trailingComma": "none",
"tabWidth": 2,
"parser": "json"
}
}
]
}
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 afei <1290657123@qq.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# slate-plugin-color
> SlateJS color plugin.

## install:
```bash
npm install -S afeiship/slate-plugin-color --registry=https://registry.npm.taobao.org
```

## usage:
```js
//DOCS here!
```
22 changes: 22 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

exports.default = {
renderNode: function renderNode(inProps, inEditor, inNext) {
var children = inProps.children,
attributes = _objectWithoutProperties(inProps, ['children']);

var value = inProps.node.data.get('value');
switch (inProps.node.type) {
case 'color':
return React.createElement('p', { style: { color: value }, children: children });
default:
return inNext();
}
}
};
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "slate-plugin-color",
"version": "1.0.0",
"description": "SlateJS color plugin.",
"main": "dist/index.js",
"repository": "git@github.com:afeiship/slate-plugin-color.git",
"author": "feizheng <1290657123@qq.com>",
"license": "MIT",
"scripts": {
"build": "babel src -d dist",
"dev": "babel src -d dist -x .js -w"
},
"devDependencies": {
"@babel/plugin-transform-react-jsx": "^7.3.0",
"babel-cli": "^6.24.1",
"babel": "^6.5.2",
"babel-core": "^6.0.0",
"babel-eslint": "^7.0.0",
"babel-plugin-transform-class-properties": "^6.19.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-es2015-spread": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-plugin-transform-runtime": "^6.0.0",
"babel-preset-react": "^6.16.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.0.0"
}
}
12 changes: 12 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default {
renderNode(inProps, inEditor, inNext) {
const { children, ...attributes } = inProps;
const value = inProps.node.data.get('value');
switch (inProps.node.type) {
case 'color':
return <p style={{ color: value }} children={children} />;
default:
return inNext();
}
}
};

0 comments on commit c2fa1a9

Please sign in to comment.