-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Paste shortcodes #2874
Paste shortcodes #2874
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2874 +/- ##
==========================================
- Coverage 31.06% 31.02% -0.05%
==========================================
Files 231 232 +1
Lines 6470 6518 +48
Branches 1156 1163 +7
==========================================
+ Hits 2010 2022 +12
- Misses 3740 3770 +30
- Partials 720 726 +6
Continue to review full report at Codecov.
|
91bda60
to
4a8d920
Compare
Mmm... shortcake. Shortcake on the mind? 😄 |
🙈 Autocorrect, continuously have to undo it. Added it to the dictionary now. |
Maybe this is not an appropriate PR to add support for gallery as well, since he block would need to support initialisation with IDs only, and it seems |
Can you elaborate on what's not supported? |
@aduth Unless I'm missing something, the following won't work: withAPIData( ( props ) => {
const { images } = props.attributes;
return {
images: images.map( ( image ) => {
return image.id ? `/wp/v2/media/${ image.id }` : image;
} ),
};
} ), |
Correct. We could potentially make a separate component responsible only for displaying a single image, then |
@iseulde can't you do something like ? withAPIData( ( props ) => {
const { images } = props.attributes;
return images.reduce( ( memo, image, index ) => {
memo[ 'image-' + image.id ] = `/wp/v2/media/${ image.id }`;
return memo;
}, {} );
} ), |
Went with @aduth's suggestion. |
cbea3c5
to
1105e77
Compare
Going to request an initial review. I'm not quite sure how we can get the formatting form the caption with the current hpq matchers, so leaving that out for now. |
I tested this using Firefox on Linux and it did not quite work as expected.
|
@mkaz Thanks for testing. Do you see any errors in the console? What is it logging for paste? I tried to reproduce this in Firefox, but it works perfectly fine. |
For the test that includes the extra paragraph.
|
For the copy-paste test that only includes caption and photo. The raw HTML view of the post looks like this:
When I copy and paste, the console log results:
|
Coming back to this, I'm not sure what's going on. Everything works fine for me here in different browsers. Can anyone else reproduce? |
3aeeaba
to
7f53335
Compare
I've retested again and can not reproduce the same as above. Tried in a couple different browsers too, (Firefox, Safari, Chrome) though Firefox version upgraded to new 57 (beta). It is now all working as expected, pasting of caption shortcode comes in as image block, both with/without surrounding paragraph text. 👍 |
7f53335
to
6393063
Compare
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.
Comment already added - retested and looks good
6393063
to
2eeeec3
Compare
Description
This PR adds support for pasting shortcodes, starting with the caption and gallery shortcode.
How Has This Been Tested?
Create an "old" post and insert a single image (e.g. thumbnail, right aligned) with a caption. Verify that the text mode contains a shortcode. Go back to visual mode and select everything (maybe include a paragraph). Paste it in Gutenberg. There should be an image block, with the caption, correctly aligned.
To do: