-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Editor: Enable linking to existing content #3197
Conversation
ceb6d47
to
3fd70dc
Compare
posts: { | ||
items: { | ||
'3d097cb7c5473c169bba0eb8e3c6cb64': { ID: 841, site_ID: 2916284, global_ID: '3d097cb7c5473c169bba0eb8e3c6cb64', title: 'Hello World' }, | ||
'6c831c187ffef321eb43a67761a525a3': { ID: 413, site_ID: 2916284, global_ID: '6c831c187ffef321eb43a67761a525a3', title: 'Ribs & Chicken' } |
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.
🍗
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.
🍖 & 🐔
Very excited to see this becoming a reality - and the PostSelector has been used again :) A few items:
Some of the experience above can be seen in this .gif - where I also encountered a bug it seems: Steps to reproduce:
|
3fd70dc
to
ff4eb60
Compare
Thanks for the review, @timmyc ! Now that #3193 has been merged, the appearance is now much approved, and I've added a screenshot to the original comment. I've added the design label in case there's feedback about the current appearance.
I've set the height as fixed at
It's an option, but I quite like the idea of eliminating this extra step. The additional network request is pretty negligible on our end. To be clear, the request is not made until the dialog is opened.
I ran into a few bugs myself 😄 The one you noted was due to the fact that the dialog was quite "impure", and was not being properly re-rendered due to The behavior of assigning the link text was also pretty unpredictable. As of ff4eb60, the link text will only be assigned if existing text cannot be determined, either if editing an existing link, or if the user has set a custom link text. Tomorrow, I'll plan to add some improvements to the |
Thanks for the notes - I'll do some more testing and do so on mobile and the :transformer: too :) Since you brought up |
Looking good on the simulator, and with the fixed heigh it is much better. Moving the visibility out of the state and into a prop has fixed the other issue I was seeing too - nice job. I'll give it a spin on Edge/IE11 as well but this is looking great to me. One other minor change that might be nice is to add some GA Events / and tracks to these actions. Tracking how often links are added, and if they are linking to existing content would be great data to have. |
Ideally, the REST API simply returns any known posts, regardless of type, if passed Spoke too soon. The REST API already supports custom post types, but Jetpack sites must whitelist any custom post types using the https://developer.wordpress.com/2013/04/26/custom-post-type-and-metadata-support-in-the-rest-api/ |
Which will be replaced by |
I imagine we could provide some backwards-compatibility for plugin authors who have already whitelisted with the Jetpack filter. // See: WPCOM_JSON_API_Endpoint
function jetpack_allowed_post_types_compat( $args, $post_type ) {
if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) {
$args['show_in_rest'] = true;
}
return $args;
}
add_filter( 'register_post_type_args', 'jetpack_allowed_post_types_compat', 10, 2 ); |
@aduth just tested out on Edge and it looks good. I'm good with this getting merged in, wasn't sure if @hugobaeta wanted to give it a quick design review - but will mark ready to merge. |
Some last-minute testing revealed a few bugs with |
@aduth would it make sense to save the sorted state in redux? Even if it were just a sorted set of |
Relevant to this point: #3522 We tend to encourage using selectors in place of redundant data in the state tree. If we were to introduce something like |
67b3a9d
to
9c4e1b8
Compare
There's been some blockers parallel to this pull request which have since been merged, so this is once again ready for final review. Rebased changes account for:
Also included analytics tracking in 9c4e1b8, as requested by @timmyc. |
import { getSelectedSite } from 'state/ui/selectors'; | ||
import { getSitePosts } from 'state/posts/selectors'; | ||
import { decodeEntities } from 'lib/formatting'; | ||
import { recordEvent, recordStat } from 'lib/posts/stats'; |
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.
👏 Thanks for tidying.
👍 Code looks good and I tested the linking functionality. Should be good to 🚢 once you get the design +1 |
9c4e1b8
to
3e3ff60
Compare
3e3ff60
to
d864566
Compare
I'm going to go ahead and remove that label. Iterations on the design of the |
Editor: Enable linking to existing content
Closes #303
Blocked by
#3193,#3575Cherry-picks dcc54689123a09985fb9cf9f208ff3ac6fd95521 from #2472This pull request seeks to enable a user to add a link by selecting existing content from their site to which the link should target.
Testing instructions:
Note that there are design flaws that cause the post selector to occupy more space than desirable, likely preventing you from confirming the link selection. These will be remedied with the merge of #3193.