-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WEB-8] [EDITOR] Basic Delete Block Functionality #341
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a small change needed but besides that it looks good! [EDIT: don't merge quite yet there appears to be an error when accessing the published blog]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can move this entire component into frontend/src/cse-ui-kit/DeleteBlock_button/index.ts
That way there isn't a need for an empty file with a singular import :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently this doesn't work since index.ts
is a ts
file instead of a tsx
file :/
All of the existing Button components in cse-ui-kit
(eg CreateContentBlock, CreateHeadingBlock) have an similar index.ts
file with a single import.
Should I change the file to index.tsx
? Or keep it consistent with the other button components?
Why are the changes needed?
Currently there is no way for a user to delete a content or heading block from the editor. Adding this functionality enables users to rollback on mistakes and format more easily.
Changes
frontend/src/packages/editor/index.tsx
BlockWrapper
andBlockContainer
in order to properly format the delete button with its corresponding block.deleteButtonClickHandler
, which deletes the block that its caller is associated with.deletionOperation
for future OT integration.frontend/src/packages/editor/types.ts
key
attribute toCustomElement
,CustomText
, andCMSBlockProps
. Thiskey
is only used to allow a block to know when to re-render its value when a block above it is deleted.In
frontend/src/cse-ui-kit/
DeleteBlock
, the button used to delete a corresponding block.Screenshots
When 'X' button is hovered over
When
X
button is not hovered overComments
While this implementation is currently working, there are still things to be done to refine and improve:
DeleteBlock
component -DeleteBlock.stories.tsx
is currently just a stub file. Need to research what a story is used for and how to implement one -> DONE (16/03/23 6:42pm)key
generation - Currently the key for each block is just generated withMath.random()
. While this produces unique enough keys for our needs, it would be good to use a more robust method such asuuid
(currentlyuuid
is failing to import, still investigating why).