Hypertopic / HyperGlosae

A Nelsonian hypertext infrastructure for digital humanities
11 stars 21 forks source link

Refactor the EditableText component to reduce code duplication. #194

Open raphaelweis opened 5 months ago

raphaelweis commented 5 months ago

In editable text, the functions handleImageUrl and handleBlur are almost identical, with the main difference being the source of the text to update. These can be combined into a single function allowing it's users to update the text for a passage margin, regardless of the input method.

benel commented 5 months ago

Thank you for this suggestion.

Please note that a similar refactoring has recently been done to reuse code between handleClick and useEffect: https://github.com/Hypertopic/HyperGlosae/blob/8db04da049527506224eb612a611fb1ae94ecce7/frontend/src/components/EditableText.js#L23-L30

benel commented 1 month ago

https://github.com/Hypertopic/HyperGlosae/blob/092ff8dc9fda1456b32f38b2e67054a291efa1a1/frontend/src/components/EditableText.jsx#L56-L61

https://github.com/Hypertopic/HyperGlosae/blob/092ff8dc9fda1456b32f38b2e67054a291efa1a1/frontend/src/components/EditableText.jsx#L71-L76