Open raineorshine opened 4 years ago
@raineorshine We cannot use importText
action creator inside a reducer. Either we have to make toggleSubtree
an action-creator or use importHTML
inside toggleSubtree
. The later one will need moving rawTextToHTML
function from importText
to a separate util function, so that we can use it inside toggleSubtree
.
@raineorshine We need to specifically parse a
and b
from the string. We need to update importHTML
function to do return these or we can just pass those data to the toggleSubtree
directly. What is your view on this ?
@raineorshine We cannot use
importText
action creator inside a reducer. Either we have to maketoggleSubtree
an action-creator or useimportHTML
insidetoggleSubtree
. The later one will need movingrawTextToHTML
function fromimportText
to a separate util function, so that we can use it insidetoggleSubtree
.
Yes, those are all desirable changes.
@raineorshine We need to specifically parse
a
andb
from the string. We need to updateimportHTML
function to do return these or we can just pass those data to thetoggleSubtree
directly. What is your view on this ?
Perhaps we should change the signature to accept JSON rather than a string. We can always convert the string to JSON beforehand. Then the imported root and its children will be easily accessible.
I'm going to put this on hold until #714 is complete. There is some overlap.
Perhaps we should change the signature to accept JSON rather than a string. We can always convert the string to JSON beforehand. Then the imported root and its children will be easily accessible.
I'm going to put this on hold until #714 is complete. There is some overlap.
Sure.
Define a new reducer
toggleSubtree
and write unit tests.Give the following subtree:
toggleSubtree(state, context, subtree)
should insert the subtree if{context}/a
does not exist.toggleSubtree(state, context, subtree)
should remove{context}/a
and all descendants if{context}/a
exists.toggleSubtree(state, context, subtree, { matchChild: true })
should insert the subtree if{context}/a
does not exist or if{context}/a/b
does not exist.toggleSubtree(state, context, subtree, { matchChild: true })
should remove{context}/a
and all descendants if{context}/a/b
exists.Use
importText
to convert the subtree to thought updates.