This repository has been archived by the owner on May 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(*): code cleanup and indicate props required
Signed-off-by: irmerk <[email protected]>
- Loading branch information
1 parent
142cd5f
commit 2d9af85
Showing
5 changed files
with
49 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,6 @@ import { render } from 'react-dom'; | |
import 'semantic-ui-css/semantic.min.css'; | ||
import ContractEditor from '../../src/ContractEditor'; | ||
|
||
const templates = {}; | ||
|
||
const slateTransformer = new SlateTransformer(); | ||
|
||
const templateUri = 'https://templates.accordproject.org/archives/[email protected]'; | ||
|
@@ -61,29 +59,13 @@ const parseClause = (template, text, clauseId) => { | |
} | ||
}; | ||
|
||
const fetchTemplateObj = async (action) => { | ||
const fetchTemplateObj = async (uri) => { | ||
try { | ||
const templateObj = await Template.fromUrl(action.uri); | ||
const templateObj = await Template.fromUrl(uri); | ||
return templateObj; | ||
} catch (err) { return err; } | ||
}; | ||
|
||
/** | ||
* Called by the clause plugin into the contract editor | ||
* when we need to load a template | ||
* Note: This is used for example and is not actually used in the demo | ||
*/ | ||
const loadTemplate = async (templateUri) => { | ||
let template = templates[templateUri]; | ||
if (!template) { | ||
console.log(`Loading template: ${templateUri}`); | ||
template = await Template.fromUrl(templateUri); | ||
templates[templateUri] = template; | ||
} | ||
|
||
return template; | ||
}; | ||
|
||
/** | ||
* A demo component that uses ContractEditor | ||
*/ | ||
|
@@ -135,7 +117,7 @@ function Demo() { | |
onChange={onContractChange} | ||
editorProps={editorProps} | ||
parseClause={(uri, text, clauseId) => parseClause(templateObj, text, clauseId)} | ||
loadTemplateObject={loadTemplate} | ||
loadTemplateObject={fetchTemplateObj} | ||
/>; | ||
|
||
return ( | ||
|
Oops, something went wrong.