-
Notifications
You must be signed in to change notification settings - Fork 57
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
EZP-30732: As an Editor I want be able to add embed/images inside table cells #1034
base: 1.5
Are you sure you want to change the base?
EZP-30732: As an Editor I want be able to add embed/images inside table cells #1034
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.
Thanks for your contribution.
As we agreed to merge it into 2.5.x please:
- Change the base to 1.5
- Rebase branch with 1.5
- Change the commit message to "EZP-30732: As an Editor, I want to be able to add embed/images inside table cells"
const path = editor.elementPath(); | ||
|
||
return !path || path.contains('table', true) === null; | ||
return true; |
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.
This method is not needed anymore so we can remove it in 3.0 for BC we need to keep it in 2.5.x.
Please add the deprecation information:
console.warn('[DEPRECATED] canBeAdded method is deprecated');
console.warn('[DEPRECATED] it will be removed from ezplatform-admin-ui 2.0');
The usage of this method can be safely removed from our buttons:
https://github.com/ezsystems/ezplatform-admin-ui/blob/master/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-image.js#L60 and https://github.com/ezsystems/ezplatform-admin-ui/blob/master/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-embed.js#L58
Please remove the disable state and the method isDisabled
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.
All requested changes are done. Also a deprecation warning for EzBtnImage.isDisabled
and EzBtnEmbed.isDisabled
was added: 8b3687b
08059f5
to
7a97f04
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.
-
Should I be allowed to put in one cell embed and image? Because embed/image buttons appear only when cell is empty or filled with text. I can't put right now embed item and image at one cell - different menu bar: http://g.recordit.co/b6GjiklyR4.gif What is more I can't do any operations (add row/remove column etc.) because of that.
-
Validation of XML
a. Click Create and select Article
b. Put a table 3x3 into Intro field
c. Embed an item in every field, use this button
d. Add an image to every cell with added button:
e. Click Publish or Save or Preview
Actual result: embedded items disappear, message is displayed: Validation of XML content failed: Error in 0:0: Element section has extra content: informaltable
sorry, is it something I should have look at? |
@SerheyDolgushev yes, I've mentioned two issues in comment above. |
This comment has been minimized.
This comment has been minimized.
…ases it makes XML invalid
Please note, there are different toolbars, depending on the context of the current element in the editor. For example, if you are editing a table cell - you will see table cell toolbar. But if you are editing some text - you will see paragraph toolbar, even if the text is inside the table cell.
It will add embed and image buttons to listed toolbars. Also please note, there two different types of embeds: inline embed and regular embed. And inline embed is available in most toolbars, by default. So now you should be able to put embeds and images into the paragraph. But please note, there seems to be a separate bug: when you insert an embed or image in the paragraph in the table cell, it is added at the end of the edited field. I guess it might be fixed later?
Initially, I thought there is an issue in the schema: ezsystems/ezplatform-richtext#56. But later it was discovered that this issue is caused by "empty width space", which was used in inline embeds. 9e8739d fixes it. @barbaragr can you please make sure that |
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.
But please note, there seems to be a separate bug: when you insert an embed or image in the paragraph in the table cell, it is added at the end of the edited field. I guess it might be fixed later?
It should be fix in this PR. I'm not able to embed two images or image and embed item in one cell, because, as you've mentioned, the second item is added at the end of the editing field (video for future retests: http://g.recordit.co/vg8OcHOAf3.gif). AFAIR it was working with this PR wich was closed ezsystems/ezplatform-richtext#56
@dew326 is it something you can have a look? Maybe there is an easy fix? |
@@ -64,7 +64,6 @@ const ZERO_WIDTH_SPACE = '​'; | |||
}, | |||
|
|||
insertWrapper: function(wrapper) { | |||
this.editor.insertHtml(ZERO_WIDTH_SPACE); |
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.
This was the fix for https://jira.ez.no/browse/EZP-29882
I think we cannot merge this.
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.
@dew326 sorry, but this line causes errors: in some cases, the generated XML is invalid because of zero-width space. I tried to reproduce the mentioned issue and wasn't able to do so. Seems like inline embed functionality changed: user don't provide any text. @barbaragr can you please check this one also?
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.
@dew326 is right, regression could occur if we merged it: https://recordit.co/gtMfFuBtyl
https://jira.ez.no/browse/EZP-29882 doesn't work here.
@SerheyDolgushev Sorry, in 10 minutes I have days off to the end of the week. I would start looking from here: https://github.com/ezsystems/ezplatform-admin-ui/blob/master/src/bundle/Resources/public/js/alloyeditor/src/plugins/ez-add-content.js#L57 |
@dew326 thanks for pointing me towards the correct direction. |
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.
Some new issues discovered:
-
Adding image to the list -> http://g.recordit.co/jzciHmG1qX.gif
When I add an image, it's added below the list, not in a proper position. -
In a table it's not possible to add next element to the list, while there is an image/embedded item -> http://g.recordit.co/jLsIMTXn6e.gif
When I add an image to the list in table, I can't add next element. It is possible to add something only above the image/embedded item. -
Image added to the list in table, after publishing goes above the list -> http://g.recordit.co/j40GxtHbaT.gif
a. Add a table
b. Add a list with 3 strings
c. In the middle of the list add another element - an image
d. Publish the content
e. Noticed that image in preview went up, above the list
f. Go to edit mode - image is still on the top of the cell -
If you add two images into table cell there is an empty gap between them and that's the only way to add next images - user can't add them ad the end, only between those two. The same occurs for images on the list. Is it the only way to have a possibility to add more than one image? https://recordit.co/UPvsAVas45
@barbaragr nested elements for the list is out of scope for this PR. So when you try to add a new element (embed/image/custom tag/etc) in the list item, it will be added after the list. Which is pretty close to the default behavior. It fixes issues 1-3 you mentioned earlier. Let's have a separate PR for nested list item elements. @SylvainGuittard Regarding issue 4, there is an empty paragraph between two images. And you can remove it using trash button: If everything looks correct, the only remaining issue is to fix https://jira.ez.no/browse/EZP-29882. Please note, the original fix was not the best way to deal with it, as in some cases it leads to invalid XML in the Richt Text field (because of zero-width spaces). @dew326 do you think there should be another fix, which doesn't modify the content of the XML? |
Yes, we should have a fix for this ticket. We cannot merge bugfix which will make a regression on another issue. Currently, I don't have an idea of how to fix this without adding a space. |
src/bundle/Resources/public/js/alloyeditor/src/plugins/ez-add-content.js
Outdated
Show resolved
Hide resolved
src/bundle/Resources/public/js/alloyeditor/src/plugins/ez-add-content.js
Outdated
Show resolved
Hide resolved
src/bundle/Resources/public/js/alloyeditor/src/plugins/ez-add-content.js
Show resolved
Hide resolved
src/bundle/Resources/public/js/alloyeditor/src/plugins/ez-add-content.js
Outdated
Show resolved
Hide resolved
const isCurrentElementList = element.getName() == 'ul' || element.getName() == 'ol'; | ||
|
||
let insertIndex = insideTableCell || insideCustomTag ? 0 : elements.length - 2; | ||
if (elementPath.lastElement.getName() == 'li') { |
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.
And here I have a question why you have to check if this is a list item and increase the index
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.
@dew326 Answering your question:
If you are trying to insert any content (embed/image/etc) into the list item, it will be added after the list element, but not the list item element. And it fixes list item related issues previously submitted by @barbaragr
I guess this behavior will be changed in the future when it will be allowed to insert embed/images/etc inside list items.
Apart from https://jira.ez.no/browse/EZP-29882 again occurs an issue from my very first comment point 2.
@SerheyDolgushev according to:
Of course I can report it separately as follow up, but on this branch, right now, when you want to add an image in the middle of the list, it is added under the field: http://g.recordit.co/wcTT0Pz0kU.gif which is different than default behaviour - adding the image under the list.
I didn't ask about removing the paragraph, I'm familiar with trash button. The point is, when you add two images, there is an empty paragraph between them and it is the only way to add more images. If you remove the paragraph you can't add more images to the cell. |
In the latest commit |
I tested this briefly.
I didn't test the rest of the issues. |
Sorry, but images inside the lists are out of scope for this PR. Can you please test how the images/embeds are functionating inside the table cells? And probably we should have a separate ticket/PR for lists? |
@SerheyDolgushev sorry but it was already explained why we cannot merge it like this.
Without your changes, the image is added below the list, but with your changes it's added below the whole richtext field. We cannot merge it like this. |
@dew326 List item issue is fixed. So now when the image is added into the list item, it will be added after the list. We can change the UI to insert the image inside the list item. But it would require some changes in the schema. As right now schema does not let to store images inside list items. |
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 minor issues. We will send it to the QA.
const insertIndex = !elementPath.contains(isCustomTag, true) ? elements.length - 2 : 0; | ||
const insideTableCell = elementPath.blockLimit && elementPath.blockLimit.getName() === 'td'; | ||
const insideCustomTag = elementPath.contains(isCustomTag, true); | ||
const insideListItem = elementPath.lastElement.getName() == 'li'; |
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.
const insideListItem = elementPath.lastElement.getName() == 'li'; | |
const insideListItem = elementPath.lastElement.getName() === 'li'; |
const insideListItem = elementPath.lastElement.getName() == 'li'; | ||
let insertIndex = insideTableCell || insideCustomTag || insideListItem ? 0 : elements.length - 2; | ||
|
||
if (elementPath.lastElement.getName() == 'li') { |
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.
if (elementPath.lastElement.getName() == 'li') { | |
if (elementPath.lastElement.getName() === 'li') { |
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.
@SerheyDolgushev , issue mentioned by @barbaragr still occurs
Validation of XML
a. Click Create and select Article
b. Put a table 3x3 into Intro field
c. Embed an item in every field, use this button
d. Add an image to every cell with added button:e. Click Publish or Save or Preview
Actual result: embedded items disappear, message is displayed: Validation of XML content failed: Error in 0:0: Element section has extra content: informaltable
I guess this one should be closed in favor of ezsystems/ezplatform-richtext#171. @dew326 can you please confirm it? |
I think the goal here was to enable this in 2.5. As far as I know, a customer wanted this? @SylvainGuittard, @konradoboza |
I can confirm that. |
Yes, we should have this feature on 2.5 |
Right not you can add
ezembed
andezimage
buttons intotable
/td
toolbar:But they are disabled.
Checklist:
$ composer fix-cs
)