# Accord Project Web Components Contract Editor
[![npm version](https://badge.fury.io/js/%40accordproject%2Fui-contract-editor.svg)](https://badge.fury.io/js/%40accordproject%2Fui-contract-editor)
[![join slack](https://img.shields.io/badge/Accord%20Project-Join%20Slack-blue)](https://accord-project-slack-signup.herokuapp.com/)
This repository contains a WYSIWYG editor for markdown that conforms to the [CommonMark](https://spec.commonmark.org) specification which can handle Accord Project's smart contract technology.
The editor is based on React, [Slate](https://www.slatejs.org), and the Accord Project [`markdown-transform` project](https://github.com/accordproject/markdown-transform).
### Installation
```shell
npm install @accordproject/ui-contract-editor @accordproject/markdown-slate slate slate-history slate-react semantic-ui-react semantic-ui-css
```
### Implementation
```js
import { render } from 'react-dom';
import React, { useCallback, useState } from 'react';
import ContractEditor from '@accordproject/ui-contract-editor';
import { SlateTransformer } from '@accordproject/markdown-slate';
import 'semantic-ui-css/semantic.min.css';
const slateTransformer = new SlateTransformer();
const getContractSlateVal = () => {
const defaultContractMarkdown = `# Heading One
This is text. This is *italic* text. This is **bold** text. This is \`inline code\`. Fin.`;
return slateTransformer.fromMarkdown(defaultContractMarkdown);
};
const clausePropsObject = {
CLAUSE_DELETE_FUNCTION (function),
CLAUSE_EDIT_FUNCTION (function),
CLAUSE_TEST_FUNCTION (function),
}
const parseClauseFunction = () => { /* ... */ }
const loadTemplateObjectFunction = () => { /* ... */ }
const pasteToContractFunction = () => { /* ... */ }
const ContractEditorRenderer = () => {
const [slateValue, setSlateValue] = useState(() => {
const slate = getContractSlateVal();
return slate.document.children;
});
const onContractChange = useCallback((value) => { setSlateValue(value); }, []);
return (
<ContractEditor
value={slateValue}
lockText={false}
readOnly={false}
onChange={onContractChange}
clauseProps={clausePropsObject}
loadTemplateObject={loadTemplateObjectFunction}
pasteToContract={pasteToContractFunction}
onClauseUpdated={parseClauseFunction}
/>
);
}
render(<ContractEditorRenderer />, document.getElementById('root'));
```
### Develop inside Storybook
While Storybook is running, if you make a change in a package that you want to see reflected in the demo, in a new terminal:
```sh
cd packages/ui-contract-editor
npm run build
```
Storybook will reload with the applied changes.
## Props
### Expected Properties
#### Values
- `value` [OPTIONAL]: An `array` which is the initial contents of the editor.
- `lockText` [OPTIONAL]: A `boolean` to lock all non variable text.
- `readOnly` [OPTIONAL]: A `boolean` to lock all text and remove the formatting toolbar.
- `activeButton` [OPTIONAL]: Optional `object` to change formatting button active state color
- `{ background: '#FFF', symbol: '#000' }`
#### Functionality
- `onChange` [OPTIONAL]: A callback `function` called when the contents of the editor change. Argument:
- `value`: The Slate nodes `array` representing all the rich text
- `loadTemplateObject` [OPTIONAL]: A callback `function` to load a template. Argument:
- `uri`: URI `string` source for loading the template
- `onClauseUpdated` [OPTIONAL]: A callback `function` called when text inside of a clause is changed. Arguments:
- `clause`: The Slate node `object` representation of the clause
- `justAdded`: A `boolean` indicating if this was just added (likely via a paste action)
- `pasteToContract` [OPTIONAL]: A callback `function` to load a clause template via copy/paste. Arguments:
- `clauseid`: Data `string` from the clause in Slate to indicate a `uuid`
- `src`: URI `string` source for loading the template
### Available Functionality
- `clauseProps`: An `object` for the clauses in the editor which contains a deletion, edit, and test function, as well as a header title string and color for clause icons on hover see below.
`clauseProps`:
You can support deletion, editing, and testing of the Clause Components within the `ContractEditor`. An object may be passed down this component with the following possible functions:
```js
clauseProps = {
CLAUSE_DELETE_FUNCTION, // (Function)
CLAUSE_EDIT_FUNCTION, // (Function)
CLAUSE_TEST_FUNCTION, // (Function)
HEADER_TITLE, // (String)
ICON_HOVER_COLOR, // (String)
}
```
---
<p align="center">
<a href="https://www.accordproject.org/">
<img src="../../assets/APLogo.png" alt="Accord Project Logo" width="400" />
</a>
</p>
<p align="center">
<a href="./LICENSE">
<img src="https://img.shields.io/github/license/accordproject/cicero?color=bright-green" alt="GitHub license">
</a>
<a href="https://accord-project-slack-signup.herokuapp.com/">
<img src="https://img.shields.io/badge/Accord%20Project-Join%20Slack-blue" alt="Join the Accord Project Slack"/>
</a>
</p>
Accord Project is an open source, non-profit, initiative working to transform contract management and contract automation by digitizing contracts. Accord Project operates under the umbrella of the [Linux Foundation][linuxfound]. The technical charter for the Accord Project can be found [here][charter].
## Learn More About Accord Project
### [Overview][apmain]
### [Documentation][apdoc]
## Contributing
The Accord Project technology is being developed as open source. All the software packages are being actively maintained on GitHub and we encourage organizations and individuals to contribute requirements, documentation, issues, new templates, and code.
Find out what’s coming on our [blog][apblog].
Join the Accord Project Technology Working Group [Slack channel][apslack] to get involved!
For code contributions, read our [CONTRIBUTING guide][contributing] and information for [DEVELOPERS][developers].
### README Badge
Using Accord Project? Add a README badge to let everyone know: [![accord project](https://img.shields.io/badge/powered%20by-accord%20project-19C6C8.svg)](https://www.accordproject.org/)
```
[![accord project](https://img.shields.io/badge/powered%20by-accord%20project-19C6C8.svg)](https://www.accordproject.org/)
```
## License <a name="license"></a>
Accord Project source code files are made available under the [Apache License, Version 2.0][apache].
Accord Project documentation files are made available under the [Creative Commons Attribution 4.0 International License][creativecommons] (CC-BY-4.0).
Copyright 2018-2019 Clause, Inc. All trademarks are the property of their respective owners. See [LF Projects Trademark Policy](https://lfprojects.org/policies/trademark-policy/).
[linuxfound]: https://www.linuxfoundation.org
[charter]: https://github.com/accordproject/governance/blob/master/accord-project-technical-charter.md
[apmain]: https://accordproject.org/
[apblog]: https://medium.com/@accordhq
[apdoc]: https://docs.accordproject.org/
[apslack]: https://accord-project-slack-signup.herokuapp.com
[contributing]: https://github.com/accordproject/web-components/blob/master/CONTRIBUTING.md
[developers]: https://github.com/accordproject/web-components/blob/master/DEVELOPERS.md
[apache]: https://github.com/accordproject/web-components/blob/master/LICENSE
[creativecommons]: http://creativecommons.org/licenses/by/4.0/
没有合适的资源?快使用搜索试试~ 我知道了~
Accord项目的React组件_JavaScript_CSS_下载.zip
共268个文件
js:168个
json:24个
md:17个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 197 浏览量
2023-04-21
11:02:09
上传
评论
收藏 2.65MB ZIP 举报
温馨提示
Accord项目的React组件_JavaScript_CSS_下载.zip
资源推荐
资源详情
资源评论
收起资源包目录
Accord项目的React组件_JavaScript_CSS_下载.zip (268个子文件)
concertoForm.css 2KB
styles.css 1KB
index.css 311B
styles.css 100B
styles.css 73B
specialTypes.cto 452B
relationship.cto 316B
booleans.cto 125B
datetime.cto 122B
.eslintrc 276B
.eslintrc 276B
.eslintrc 276B
.eslintrc 276B
.eslintrc 36B
.eslintrc 36B
.gitignore 2KB
.gitignore 379B
.gitignore 343B
.gitignore 343B
.gitignore 343B
.gitignore 343B
HEADER 520B
index.html 2KB
preview-body.html 59B
favicon.ico 4KB
reactformvisitor.js 12KB
1-MarkdownEditor.stories.js 12KB
index.js 11KB
index.js 11KB
HyperlinkModal.js 9KB
TableModal.js 9KB
index.js 8KB
withClauses.js 8KB
withTables.js 8KB
utilities.js 7KB
index.js 7KB
fields.js 7KB
4-ContractEditor.stories.js 7KB
modelBuilderVisitor.js 7KB
toolbarHelpers.js 6KB
formgenerator.js 6KB
concertoForm.js 6KB
delete.js 5KB
7-Library.stories.js 5KB
styles.js 5KB
index.js 4KB
index.js 4KB
styles.js 4KB
withImages.js 4KB
3-ConcertoForm.stories.js 4KB
link.js 3KB
withLinks.js 3KB
concertoFormWrapper.test.js 3KB
withVariables.js 3KB
index.js 3KB
constants.js 3KB
index.js 3KB
quote.js 3KB
DownloadDropdown.js 3KB
index.js 3KB
formgenerator.test.js 3KB
index.js 2KB
code.js 2KB
index.js 2KB
image.js 2KB
open.js 2KB
rollup.config.js 2KB
redo.js 2KB
rollup.config.js 2KB
index.js 2KB
LibraryItemCard.js 2KB
ulist.js 2KB
olist.js 2KB
undo.js 2KB
rollup.config.js 2KB
testProps.js 2KB
testProps.js 2KB
ConditionalBoolean.js 2KB
index.js 2KB
OptionalBoolean.js 2KB
rollup.config.js 2KB
index.js 2KB
styles.js 2KB
Error.js 2KB
testIcon.js 2KB
tooltipHelpers.js 2KB
rollup.config.js 2KB
schema.js 2KB
ClauseVariableList.js 2KB
deleteRow.js 2KB
deleteCol.js 2KB
withLists.js 2KB
CardActions.js 2KB
generators.js 2KB
copy.js 2KB
HyperlinkButton.js 2KB
FormatButton.js 2KB
concertoModelBuilder.js 2KB
index.js 1KB
withHtml.js 1KB
共 268 条
- 1
- 2
- 3
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功