Skip to content
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

Merged
merged 2 commits into from
Feb 26, 2019

Conversation

dew326
Copy link
Member

@dew326 dew326 commented Feb 5, 2019

Question Answer
Tickets https://jira.ez.no/browse/EZP-29280
Depends on ezsystems/ezplatform-richtext#28
Bug fix? no
New feature? yes
BC breaks? no
Tests pass? yes
Doc needed? no
License GPL-2.0

This PR introduces new svg icon link-anchor:
screen shot 2019-02-12 at 13 48 07

Checklist:

  • Coding standards ($ composer fix-cs)
  • Ready for Code Review

@dew326 dew326 self-assigned this Feb 5, 2019
@dew326 dew326 added the Feature label Feb 5, 2019
@dew326 dew326 changed the title [WIP] EZP-29280: As an editor, I want to add anchors to RichText content EZP-29280: As an editor, I want to add anchors to RichText content Feb 11, 2019
const label = Translator.trans(/*@Desc("Anchor")*/ 'anchor_btn.label', {}, 'alloy_editor');

return (
<button
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing type="button"

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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}
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Contributor

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'));
Copy link
Contributor

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?

Copy link
Contributor

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 {
Copy link
Contributor

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.

Copy link
Contributor

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] {
Copy link
Contributor

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();
Copy link
Contributor

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.

Copy link
Member Author

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'));
Copy link
Contributor

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();
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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) {
Copy link
Contributor

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.

@katarzynazawada katarzynazawada self-assigned this Feb 18, 2019
Copy link

@katarzynazawada katarzynazawada left a 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:

  1. Add two paragraphs in RTE.
  2. In second paragraph link to anchor, e.g #test.
  3. In first paragraph add anchor (test).
  4. Publish.

Link in second paragraph dose not point to anchor (anchor is not saved)

2) Second unused anchor is not saved.

Steps:

  1. Add anchor to first paragraph in RTE.
  2. Add anchor to second paragraph in RTE.
  3. Publish content.
  4. 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:

  1. Click in RTE
  2. Type some text.
  3. Click on anchor icon.
  4. Type name.
  5. Click on Remove button.

Error in console
image

4) Missing colon :

image

5) Half border of Remove and Save buttons (Safari, Firefox, Edge)

image

6) One extra line when adding anchor in Firefox

Steps:

  1. Type some text in RTE.
  2. Click on anchor icon, fill name and save.
  3. Click in RTE area.

image

7) No anchor icon when formatted style is selected

Steps:

  1. Click in RTE
  2. Change style from Paragraph to Formatted.
  3. Type some text.
  4. Click anchor icon
  5. Type name and save

Anchor icon is not displayed. Moreover, one additional line is added.
image

8) When pressing Enter button in paragraph with anchor, icon skips to next line

Steps:

  1. Type some text in RTE.
  2. Click on anchor icon, fill name and save.
  3. Press Enter button.

image

In console:

image

9) Anchor to image does not work.

Steps:

  1. Add image in RTE.
  2. Click on anchor icon, fill name and save.
  3. In other paragraph link to anchor.
  4. Publish.

When clicking on created link user is not pointed to anchor.

10) Error when editing anchor in image.

Steps:

  1. Add image to RTE.
  2. Click on anchor icon, fill name and save.
  3. Click on anchor icon again.

Error occurs:
image

11) Anchor icon changes position in table.

Steps:

  1. Add table in RTE.
  2. Click on anchor icon, fill name and save. (A)
  3. In other paragraph link to anchor.
  4. Publish.
  5. Edit. (B)

A
image

B
image

12) Embed inline in anchor (Chrome and Safari)

Steps:

  1. Type some text in RTE.
  2. Click on anchor icon, fill name and save.
  3. Add embed inline.

Cursor is moved to the beginning of the paragraph, it is not possible to write text after the embed block
image

13) Validation of XML content failed when adding two anchors with the same name

Steps:

  1. Add anchor to first paragraph.
  2. Add anchor to second paragraph with the same name.
  3. In third paragraph add link to anchor.
  4. 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.

@dew326 dew326 force-pushed the anchor-in-richtext branch 2 times, most recently from 06ddefc to d5f4776 Compare February 25, 2019 14:07
@dew326 dew326 force-pushed the anchor-in-richtext branch from d5f4776 to 3a3c395 Compare February 25, 2019 14:10
@micszo micszo self-assigned this Feb 26, 2019
Copy link
Member

@micszo micszo left a 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.

@lserwatka lserwatka merged commit bf0bfcd into ezsystems:master Feb 26, 2019
@micszo micszo removed their assignment Feb 26, 2019
konradoboza pushed a commit to konradoboza/ezplatform-admin-ui that referenced this pull request May 29, 2019
…zsystems#831)

* EZP-29280: As an editor, I want to add anchors to RichText content

* compiled AE
mateuszdebinski pushed a commit that referenced this pull request Feb 13, 2024
#831)

[Behat] Added small wait before interacting with Single relation button (#830)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

6 participants