bug: unable to remove header formatting in a specific scenario
See original GitHub issueIs your feature request related to a problem? Please describe.
In the markdown editor toolbar, there is no easy way to remove heading level stylings once applied. From what I can tell, the only way to remove a heading level styling from text is to switch to the raw markdown mode and remove the #
formatting there.
Describe the solution you’d like Add a toolbar option to remove a heading styling if applied to selected text. I can thing of 3 ways this could be implemented.
- When a heading level option in the dropdown is applied/active, clicking the dropdown item again toggles the formatting off.
- Add a new heading dropdown option “Remove”
- Add a new toolbar button that more generally removes any applied markdown formatting from a selection.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:14 (7 by maintainers)
Top Results From Across the Web
How to remove header and footer from a single ... - YouTube
Let's learn a clean and simple way to delete header and footer from a particular page in a Word document. The trick is...
Read more >Correct way to remove header and/or footer in Word - YouTube
Want to remove header and footer in Ms Word? There are many ways to ... try restarting your device. Your browser can't play...
Read more >Word VBA>New to Macros: Cannot remove Header/Footer
Double-click on the module and paste in your code in the VBA code area. If all looks good, no red text, press F5...
Read more >Can't Delete Header and Footer - Microsoft Community
You cannot actually remove headers and footers; they are a part of Word's document structure. You can remove any content from them other...
Read more >Excel header and footer: how to add, change and remove
Header and footer in Excel: how to insert, edit and remove ... a built-in header or footer, you cannot control the location of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Good question. Interestingly, the List and Quote blocks are not affected because they are handled by different methods that use a different logic. For example:
If you triple click Heading 1, the selection will be
<h1>
to</p>
.editor.value.blocks
will contain two blocks,heading-one
andparagraph
.Then click either List or Quote button. The
toggleQuoteblock
andtoggleList
only look foreditor.value.startBlock
, which will always be the first block of the selection and then do the transformation.In contrast, when clicking a Heading button, we look for
editor.value.blocks
and check if every single block inside it is of the same heading type with a helper methodeveryBlock
. Of course they aren’t, so this method returns false.If
everyBlock
returns true, we passdefaultType = 'paragraph'
toeditor.setBlocks
. But it returns false, so we pass the value of headingeditor.setBlocks
. Soeditor.setBlocks('heading 1')
to aheading-one
block doesn’t change the same.You may wonder: How about the paragraph block after
<h1>
? Does it get turned intoheading-one
? As I’ve said,editor.value.blocks
contains both blocks, but when callingeditor.setBlocks
, Slate still correctly identifies “Heading 1” as the only block that gets selected. Hence the paragraph block is untouched.I don’t know why it behaves that way, but this is probably a reason why this triple-click issue has flown under the radar for so long.
But thanks to your inquiry, I think I’ve discovered an economical way to resolve this issue.
Here’s a video showing the issue. When I’m selecting the entire line I’m triple clicking the text.
https://user-images.githubusercontent.com/6277206/126909999-642ca4d8-9ec7-4d11-8a6f-dfd6dff50ebd.mov