Quickest way to wrap just selected text in a block?
See original GitHub issueI know there is probably a way to do this easily, however I am getting tripped up with transforms and selections.
I know about wrapBlock()
however it wraps the entire block and not just the selection. I desire functionality like wrapInline()
where only the portion of the block that is in the selection is wrapped. How might I accomplish this in a single transform?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Wrapping and breaking text - CSS: Cascading Style Sheets
Wrapping and breaking text. This guide explains the various ways in which overflowing text can be managed in CSS.
Read more >Wrap text in a cell in Excel for Mac - Microsoft Support
Select the cells that you want to format. · On the Home tab, click Wrap Text. On the Home tab, select Wrap Text...
Read more >Deep Dive into Text Wrapping and Word Breaking
Putting overflow-wrap: break-word on an element will allow text to break mid-word if needed. It'll first try to keep a word unbroken by...
Read more >How to Wrap Text in Excel - YouTube
In today's tutorial, we'll see how to wrap text in Excel. This function can help you keep even longer texts within the boundaries...
Read more >How do I wrap text in a pre tag? - html - Stack Overflow
I just inspected the stackoverflow code blocks and they wrap in a <code> tag wrapped in <pre> tag with css ... code {...
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 Free
Top 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
Ah yes the
.splitBlockAtRange(selection.collapseToEnd())
is what I believe I was missing. I will make another attempt at this tomorrow. I am still a novice at this immutability stuff and it didn’t occur to me that I could transform the content without moving the selection around. Thanks.As for the use case, I am looking for alternative ways to solve #178. I was thinking that perhaps the popup could be embedded in the document next to the inline text it is linked to. Since the popup content will require block nodes, I assumed that all the parent nodes would need to be block nodes as well. Truthfully an Inline node would fit better. So I guess this leads to another question: Can Inline nodes contain Block nodes as children?
Personally I think the functionality of
wrapBlock
andwrapInline
are to be expected as the documentation describes them as “Wrap the {Inline/Block} nodes in the current selection”. To me that says that no splitting of blocks or inlines will take place at the selection boundaries and new nodes will simply wrap the existing ones. Additionally, it makes sense thatwrapInline
would split Text nodes when there are no inline nodes to wrap. I would expect the same functionality fromwrapBlock
if the document just had text nodes but it seems like documents always contain blocks.Perhaps you could add two new methods with names like
wrapRangeWithBlock
andwrapRangeWithInline
? Interestingly these could have the added benefit of wrapping inside the current block or inline instead of wrapping on the outside (assuming that’s howwrapBlock
andwrapInline
work currently).Okay no problem thanks for clarifying this!