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

Editor: Add Semantic Headings to the right click menu of Text Elements #11402

Closed
bmattb opened this issue Apr 29, 2022 · 9 comments · Fixed by #12062
Closed

Editor: Add Semantic Headings to the right click menu of Text Elements #11402

bmattb opened this issue Apr 29, 2022 · 9 comments · Fixed by #12062
Assignees
Labels
Elements: Text P2 Should do soon Package: Story Editor /packages/story-editor Type: Enhancement New feature or improvement of an existing feature

Comments

@bmattb
Copy link

bmattb commented Apr 29, 2022

Feature Description

Now that automatic semantic headings are applied to text elements within stories (see #5326), users are requesting a way to be able to view what that value is or will be on publish so adjustments can be made beforehand.

This feature will allow a user to select the text within a page and see and change the text element within the sidebar.

Many thanks to @swissspidy for the implementation idea, and to @aaskedall for the UX guidance.

Acceptance Criteria

  • This should be under a new experimental feature flag.
  • Within the right click menu of a text element on the page, there should be a new item called Heading Level
  • This Heading Level item should have a submenu that show the following properties (along with the one currently selected):
    • Automatic (xyz) (stored as auto)
    • Heading 1 (stored as h1)
    • Heading 2 (stored as h2)
    • Heading 3 (stored as h3)
    • Paragraph (stored as p)
  • When the menu item is changed to another option in the menu, it should update the text element's tagName property

Developer Notes

Notes from @swissspidy on implementation:
xyz is replaced with whatever getTextElementTagNames() returns for the element.

When changing this option, the text element's tagName property is updated.

getTextElementTagNames() is updated to take this tagName property into account.

Alternatives Considered

In addition to this space, this functionality will also be accomplished within the sidebar of the Editor.

Additional Context

@bmattb bmattb added Type: Enhancement New feature or improvement of an existing feature Elements: Text Pod: Prometheus labels Apr 29, 2022
@swissspidy swissspidy changed the title Consider adding an indicator of the H value that will be applied to text Semantic Headings: Consider adding UI / indicator for heading level Apr 29, 2022
@merapi merapi added the P2 Should do soon label May 11, 2022
@swissspidy
Copy link
Collaborator

swissspidy commented May 30, 2022

Implementation note: this would mean exporting getTextElementTagNames from the output package and then using that in the editor for this indicator.

While this needs UX, we can already implement something behind a feature flag.

Suggestion:

  1. Create a new TextAccessibility panel
  2. In this panel, add a new dropdown (with dropDownLabel={__('Heading Level', 'web-stories')} to modify the text element's heading level with the following options:
    • Automatic (xyz) (stored as auto)
    • Heading 1 (stored as h1)
    • Heading 2 (stored as h2)
    • Heading 3 (stored as h3)
    • Paragraph (stored as p)

xyz is replaced with whatever getTextElementTagNames() returns for the element.

When changing this option, the text element's tagName property is updated.

getTextElementTagNames() is updated to take this tagName property into account.

Below the dropdown we can add a helper text <a>Learn more</a> about using headings in Web Stories., where we can link to the docs

Mock:

Screenshot 2022-05-30 at 16 19 17

Context:

@bmattb
Copy link
Author

bmattb commented Jun 9, 2022

Andrew to provide UX guidance on this one

@sblinde
Copy link
Contributor

sblinde commented Jun 13, 2022

Our plan is to include this in the upcoming release, so this story will be pulled in to the sprint once we have UX (which I hope to talk about on Tuesday!)

@sblinde
Copy link
Contributor

sblinde commented Jun 22, 2022

As talked about in our design sync meeting, we can approach this as suggested by @swissspidy and also consider adding this to the right click menu dropdown as a submenu item to be changed. Will follow back up with this ticket to get those requests written out appropriately with context.

@sblinde sblinde removed the UX Needed label Jun 23, 2022
@sblinde sblinde changed the title Semantic Headings: Consider adding UI / indicator for heading level Editor: Add Semantic Headings to the right click menu of Text Elements Jun 23, 2022
@sblinde sblinde added the Package: Story Editor /packages/story-editor label Jun 23, 2022
@sblinde
Copy link
Contributor

sblinde commented Jul 8, 2022

For additional context on how this was accomplished for the Editor sidebar, see: #11788

@felipebochehin87
Copy link

Issue found. Tested against https://stories-qa-wordpress-amp.pantheonsite.io/wp-admin/, using PR #12062.

  1. Create a new story
  2. Add two "Title 1" to the canvas
  3. Switch their position - the top one is set to H1, the other is set to H2 - OK
  4. Right click on the lower "Title 1" and change the heading to anything but H1 or H2
  5. Click out of the element
  6. Right click again on the same element and set to "Automatic" - see that in the right-click menu, the element is set to Automatic (Heading 1), but on the Style tab it's set to Automatic (Heading 2)

https://images.zenhubusercontent.com/235435637/4bdbcd00-d4fc-4b2a-9723-61925fa5b3a6/2022_08_04_12_28_58.mp4

12062.png

@timarney
Copy link
Contributor

timarney commented Aug 5, 2022

@felipebochehin87 the code is updated to fix #11402 (comment)

@felipebochehin87
Copy link

Looks good. Thanks!

1 similar comment
@felipebochehin87
Copy link

Looks good. Thanks!

@felipebochehin87 felipebochehin87 self-assigned this Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Elements: Text P2 Should do soon Package: Story Editor /packages/story-editor Type: Enhancement New feature or improvement of an existing feature
Projects
None yet
8 participants