Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #228 from accordproject/dl-paste-clause-node
Browse files Browse the repository at this point in the history
fix(ClausePlugin): use withMutations to fix issue when pasting a clause node
  • Loading branch information
DianaLease authored Nov 19, 2019
2 parents ab285ca + 7cffff0 commit 4d7f027
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/plugins/ClausePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,18 @@ function ClausePlugin() {
const isHeadingClause = node => node.type === 'clause';
mutableNodes = mutableNodes.map((node) => {
if (isHeadingClause(node)) {
const mutableNode = node.asMutable();
const mutableDataMap = mutableNode.data.asMutable();
const clauseUriSrc = mutableDataMap.get('src');
const generatedUUID = uuidv4();

mutableDataMap.set('clauseid', generatedUUID);
editor.props.clausePluginProps.pasteToContract(generatedUUID, clauseUriSrc, node.text);

mutableNode.data = mutableDataMap.asImmutable();
clausesToParse.push(node);
const mutableNode = node.withMutations((n) => {
const clauseUriSrc = n.data.get('src');
const generatedUUID = uuidv4();
const newData = n.data.withMutations((d) => {
d.set('clauseid', generatedUUID);
});
n.set('data', newData);
editor.props.clausePluginProps.pasteToContract(
generatedUUID, clauseUriSrc, node.text
);
clausesToParse.push(n);
});
return mutableNode;
}
return node;
Expand Down

0 comments on commit 4d7f027

Please sign in to comment.