-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat: custom byline interface #3746
base: trunk
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.
Overall I think this is coming together! The UX of it feels good. I noticed a few quirks in my testing:
- In general it's kind of hard to read once there are a few authors in there:

Not sure if we should reduce the size of the author boxes or how best to handle that. What do you think, @thomasguillot?
- Using the arrow keys, you can go into one of the boxes and then type to modify the content. I think it should not be editable.

- If you select a portion of the text that includes a box and delete, the box doesn't go back into the available authors section:


- Authors are always inserted at the end of the text box. I think the best experience would be for them to be inserted at the cursor position, otherwise it's tricky to edit existing bylines to add/change authors around.
This is starting to look pretty good! Here are two things I noticed:
The idea of storing the ID and the name is to have a fallback in case the user is deleted. When we render the byline, we'll always read the ID and get the Display name from the database, but if the ID is gone, we'll use the name that is stored there. |
Ah, and before you get crazy and go deep in a rabbit role, we DON'T NEED TO SUPPORT Guest Authors |
You're right, this doesn't look good. Let me think about a different approach here. |
Note: The panel should simply be named "Byline", not "Newspack Custom Byline" |
Can we please make sure the style matches Core's FormTokenField Also we can use |
I've just tested on a fresh post and I still have issues with the backspace interaction: custom-byline.movAnother problem I faced while drafting the new post was that the additional authors only became available after I saved and refreshed the post. Ideally, the component would be aware of the edited changes and update the component's available tokens. |
The latest commit fixes the backspace interaction, @miguelpeixe. About authors, it was expected that for the first version that would be acceptable (to have to refresh the page to make them available to use on byline), can you confirm that, @claudiulodro? |
Thanks for the revisions @allysonsouza! Backspace interaction is working well for deleting the token when the cursor is at the end of it. I'm facing a couple of issues still:
bylines.mov |
After struggling to handle the state of the content, which was not being managed by React state, @goldenapples started working on a simplification to use He's proposing it on this PR on our fork, I've been testing it and it seems like we need to deal with the removal of the tokens itself when there's a change to the token content (like adding characters or removing them with backspace or delete). That seems possible to be handled by onInput too, by adding an onInput on each token to remove itself when changes happen and to keep the onInput on the wrapper contenteditable div. |
b49dbc5
to
0867dfa
Compare
Replaced the MutationObserver with an event listener, replaced some of the DOM interaction with a useRef element, and tried to refactor some of the data getters and setters.
Prevents editing the content in these spans, and makes it so that deleting (with backspace) will remove the whole span at once rather than editing within the span.
Updates the "cursorPos" variable logic to use the end of the line if there's no cursor position set yet, and to add a non-breaking space at the end of the text if necessary. Also updates the white-space styling of the editable area, to ensure that users can select any point in the text they may need to.
ef23903
to
d403417
Compare
Heads up that I've implemented the data structure changes that this PR does in trunk to allow us to move on with some tests. This might create conflicts that should be easily resolved - just ignore the changes on trunk |
All Submissions:
Changes proposed in this Pull Request:
This Pull Request implements the feature to allow the selection of author tokens from authors selected on Co-Authors Plus to compound a custom byline with them.
How to test the changes in this Pull Request:
div
withcontenteditable
. Below it you should see the authors assigned to the post as buttons that will insert the tokens on the content when clicked.Things to check:
Other information: