Skip to content

Commit

Permalink
v0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lingjieee committed May 30, 2020
0 parents commit ed9ae07
Show file tree
Hide file tree
Showing 272 changed files with 20,243 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/dist
/lib
/es

/examples/dist
/node_modules
20 changes: 20 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
env: {
browser: true,
},
parser: '@typescript-eslint/parser',
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:prettier/recommended',
'prettier/@typescript-eslint',
],
plugins: ['@typescript-eslint', 'react', 'prettier'],
rules: {
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/no-empty-interface': 0,
'@typescript-eslint/no-explicit-any': 0,
'react/prop-types': 0,
},
};
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.DS_Store

/node_modules

/dist
/lib
/es

.umi
.umi-production
.env.local

.eslintcache
/examples/dist

npm-debug.log*
yarn-debug.log*
yarn-error.log*

/.idea
15 changes: 15 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.DS_Store
/.idea
/docs
/examples
/scripts
/src
.eslintignore
.eslintrc.js
.prettierignore
.prettierrc.js
.umirc.ts
babel.config.js
tsconfig.cjs.json
tsconfig.json
yarn.lock
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/examples/**/dist
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
printWidth: 120,
singleQuote: true,
trailingComma: 'all',
};
23 changes: 23 additions & 0 deletions .umirc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { defineConfig } from 'dumi';

export default defineConfig({
mode: 'site',
logo: 'https://cdn-blog.jieee.xyz/img/fe-128.png',
title: 'Fantasy Editor',
favicon: 'https://cdn-blog.jieee.xyz/img/fe-24.ico',
navs: [
null,
{
title: 'GitHub',
path: 'https://github.com/lingjieee/fantasy-editor',
},
{
title: 'Changelog',
path: 'https://github.com/lingjieee/fantasy-editor/blob/master/CHANGELOG.md',
},
],
exportStatic: {},
styles: [],
scripts: [],
externals: {},
});
21 changes: 21 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = function(api) {
api.cache(true);

const presets = [
[
'@babel/preset-env',
{
loose: true,
modules: false,
},
],
'@babel/preset-react',
];

const plugins = ['lodash'];

return {
presets,
plugins,
};
};
8 changes: 8 additions & 0 deletions docs/examples/demo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Demo
group:
title: DD
order: 1
---

<code src="../../examples/demo" compact/>
8 changes: 8 additions & 0 deletions docs/examples/full.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: FullUsage
group:
title: Core
order: 1
---

<code src="../../examples/full" compact/>
38 changes: 38 additions & 0 deletions docs/guide/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: 快速上手
group:
title: 指南
order: 0
nav:
title: 指南
---

## 安装

### npm

```bash | pure
npm install fantasy-editor --save
```

### umd

```html | pure
<script src="https://unpkg.com/fantasy-editor@${version}/dist/index.js"></script>
```

## 示例

```bash | pure
# 克隆仓库
$ git clone https://github.com/lingjieee/fantasy-editor.git

# 切换目录
$ cd fantasy-editor

# 安装依赖
$ yarn install

# 运行示例
$ yarn start
```
10 changes: 10 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Fantasy Editor - A React Rich Text Editor Based On Slate
hero:
title: Fantasy Editor
desc: A React Rich Text Editor Based On Slate
actions:
- text: Getting Started
link: /guide/getting-started
footer: Open-source MIT Licensed | Copyright © 2020<br />Powered by [dumi](https://d.umijs.org)
---
17 changes: 17 additions & 0 deletions examples/demo/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

import React, { FunctionComponent } from 'react';

interface OwnProps {}

type Props = OwnProps;

const Demo: FunctionComponent<Props> = (props) => {

return (
<div>
demo
</div>
);
};

export default Demo;
56 changes: 56 additions & 0 deletions examples/full/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React, {FunctionComponent, useState} from 'react';
import initValue from './value.json';
import {Node} from 'slate';
import FantasyEditor from "fantasy-editor";
import {Config} from "../../src";

interface OwnProps {
}

type Props = OwnProps;

const FullUsage: FunctionComponent<Props> = (props) => {

const [value, setValue] = useState<Node[]>(initValue as any);
const config: Config = {
plugin: {
undo: true,
redo: true,
heading: true,
fontSize: true,
bold: true,
italic: true,
underline: true,
strikeThrough: true,
blockquote: true,
subscript: true,
superscript: true,
fontColor: true,
backgroundColor: true,
align: true,
code: true,
codeBlock: true,
list: true,
ident: true,
link: true,
image: true,
file: true,
hr: true,
table: true,
lineHeight: true,
full: true,
},
};

const onChange = (value: Node[]) => {
setValue(value);
};

return (
<div style={{padding: 50}}>
<FantasyEditor value={value} config={config} onChange={onChange}/>
</div>
);
};

export default FullUsage;
26 changes: 26 additions & 0 deletions examples/full/value.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"type": "paragraph",
"children": [{ "text": "hello" }]
},
{
"type": "paragraph",
"children": [
{
"type": "file",
"filename": "测试.pdf",
"url": "https://www.baidu.com/test.pdf",
"children": [{ "text": "" }]
},
{
"type": "file",
"filename": "测试.pdf",
"url": "https://www.baidu.com/test.txt",
"children": [{ "text": "" }]
},
{
"text": "xxxx"
}
]
}
]
13 changes: 13 additions & 0 deletions examples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"module": "esnext",
"moduleResolution": "node",
"target": "esnext",
"jsx": "react",
"noImplicitThis": true,
"strictBindCallApply": true,
"baseUrl": ".",
"sourceMap": true,
}
}
Loading

0 comments on commit ed9ae07

Please sign in to comment.