cybersemics / em

A beautiful, minimalistic note-taking app for personal sensemaking.
Other
288 stars 121 forks source link

Reducer: toggleSubtree #711

Open raineorshine opened 4 years ago

raineorshine commented 4 years ago

Define a new reducer toggleSubtree and write unit tests.

toggleSubtree(state: State, context: Context, subtree: string, { matchChild: boolean } = {}): State

Give the following subtree:

- a
  - b
    - c

Use importText to convert the subtree to thought updates.

shresthabijay commented 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.

shresthabijay commented 4 years ago

@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 commented 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.

Yes, those are all desirable changes.

@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 ?

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.

shresthabijay commented 4 years ago

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.