-
Notifications
You must be signed in to change notification settings - Fork 56
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-29280: As an editor, I want to add anchors to RichText content #831
Conversation
const label = Translator.trans(/*@Desc("Anchor")*/ 'anchor_btn.label', {}, 'alloy_editor'); | ||
|
||
return ( | ||
<button |
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.
Missing type="button"
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.
Why do we need the type
in alloyeditor? None of the buttons from AE has this and I follow their convention.
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.
Unless I'm mistaken the alloy editor app is rendered inside a form. Having type="button"
added to a button element secures the app and us from a random form submission attempt.
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.
AE is not rendered in the form. It has own container at the end of the page.
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.
I see. Anyway, it's a good practice to add this attribute, but I'm fine if you want to follow the convention from AE.
aria-pressed={cssClass.indexOf('pressed') !== -1} | ||
className={cssClass} | ||
onClick={this.props.requestExclusive} | ||
tabIndex={this.props.tabIndex} |
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.
Do you need to set tabIndex
on a button? Can you control the tab
switch flow?
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.
I follow the convention from AE
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.
Ok, then it's fine.
findIcon() { | ||
const block = this.findBlock(); | ||
|
||
return [...block.getChildren().$].find((child) => child.classList && child.classList.contains('ez-icon--anchor')); |
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.
Can you store it: ez-icon--anchor
as a variable?
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.
I would extract arrow function to method to improve readability.
display: flex; | ||
padding: calculateRem(8px) 0 calculateRem(8px) calculateRem(8px); | ||
|
||
&__input-wrapper { |
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.
What about moving it inside the &__input {
selector? In fact, it looks like it should be a separate component, but it's acceptable use case here.
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.
Are you suggesting using this structure:
&__input {
/*...*/
&-wrapper {/*...*/}
&-label {/*...*/}
}
? I have bad experience with splitting selectors in this way. I have once searched for a selector and it took me a while, because element name was split in halve.
For me the most natural and easy to comprehend approach is to split class name in 3: block, element, modifier, like it was done here. 🙂
background-color: $ez-color-positive; | ||
} | ||
|
||
&[disabled] { |
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.
I'm still thinking about unifying this. Because I found we're adding the similar rule here and there in our codebase. We have to check whether we could unify it and make it more generic.
return <AlloyEditor.EzBtnAnchorEdit {...this.props} />; | ||
} | ||
|
||
const cssClass = 'ae-button ez-btn-ae--anchor ez-btn-ae ' + this.getStateClasses(); |
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.
Nitpick: we usually use `${}`
to concatenate strings. Do we have any in-house rule on this? There is eslint rule for this: https://eslint.org/docs/rules/prefer-template.
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.
Yes, most of the button in AE has the convention that I proposed. We should unify this in 3.0.
findIcon() { | ||
const block = this.findBlock(); | ||
|
||
return [...block.getChildren().$].find((child) => child.classList && child.classList.contains('ez-icon--anchor')); |
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.
I would extract arrow function to method to improve readability.
|
||
removeAnchor() { | ||
const block = this.findBlock(); | ||
const icon = this.findIcon(); |
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.
Nitpick: we can pass block
to findIcon
instead of finding it twice.
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 I wanted to have a more atomic method. And if you look atfindBlock()
you will find out that the method is calculating things only one time, the second one is returning block immediately.
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're right, I didn't notice this.block = block;
. I like your approach! :)
@@ -130,6 +130,10 @@ | |||
headers.forEach((header) => header.remove()); | |||
} | |||
|
|||
clearAnchorIcons(icon) { |
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.
Nitpick: clearAnchorIcon
, without s
as we clear only one icon.
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.
I have a few comments, tested together with ezsystems/ezplatform-richtext#28
1) Link does not point to anchor when user adds link first and then creates anchor.
Steps:
- Add two paragraphs in RTE.
- In second paragraph link to anchor, e.g #test.
- In first paragraph add anchor (test).
- Publish.
Link in second paragraph dose not point to anchor (anchor is not saved)
2) Second unused anchor is not saved.
Steps:
- Add anchor to first paragraph in RTE.
- Add anchor to second paragraph in RTE.
- Publish content.
- Edit content
Second anchor is not added.
3) Remove button should be grayed out when editing anchor for the first time or it should remove anchor.
Steps:
- Click in RTE
- Type some text.
- Click on anchor icon.
- Type name.
- Click on Remove button.
4) Missing colon :
5) Half border of Remove and Save buttons (Safari, Firefox, Edge)
6) One extra line when adding anchor in Firefox
Steps:
- Type some text in RTE.
- Click on anchor icon, fill name and save.
- Click in RTE area.
7) No anchor icon when formatted style is selected
Steps:
- Click in RTE
- Change style from Paragraph to Formatted.
- Type some text.
- Click anchor icon
- Type name and save
Anchor icon is not displayed. Moreover, one additional line is added.
8) When pressing Enter button in paragraph with anchor, icon skips to next line
Steps:
- Type some text in RTE.
- Click on anchor icon, fill name and save.
- Press Enter button.
9) Anchor to image does not work.
Steps:
- Add image in RTE.
- Click on anchor icon, fill name and save.
- In other paragraph link to anchor.
- Publish.
When clicking on created link user is not pointed to anchor.
10) Error when editing anchor in image.
Steps:
- Add image to RTE.
- Click on anchor icon, fill name and save.
- Click on anchor icon again.
11) Anchor icon changes position in table.
Steps:
- Add table in RTE.
- Click on anchor icon, fill name and save. (A)
- In other paragraph link to anchor.
- Publish.
- Edit. (B)
12) Embed inline in anchor (Chrome and Safari)
Steps:
- Type some text in RTE.
- Click on anchor icon, fill name and save.
- Add embed inline.
Cursor is moved to the beginning of the paragraph, it is not possible to write text after the embed block
13) Validation of XML content failed when adding two anchors with the same name
Steps:
- Add anchor to first paragraph.
- Add anchor to second paragraph with the same name.
- In third paragraph add link to anchor.
- Publish.
Error Validation of XML content failed: Error in 40:0: Element section has extra content: para. occurs.
Mabye error message should be more user-friendly ? Or it could be validated earlier – when adding name.
06ddefc
to
d5f4776
Compare
d5f4776
to
3a3c395
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.
Issues 1-9 and 12 do not occur anymore.
It was agreed that 10, 11 and 13 will be handled separately (will add tickets linked to story).
Also 7 and 9 require little follow-ups.
…zsystems#831) * EZP-29280: As an editor, I want to add anchors to RichText content * compiled AE
This PR introduces new svg icon
![screen shot 2019-02-12 at 13 48 07](https://user-images.githubusercontent.com/10233057/52636448-e7486c00-2ecc-11e9-9776-4bc56cfe663e.png)
link-anchor
:Checklist:
$ composer fix-cs
)