Add a rewrite callback to Editable.getContent()
See original GitHub issueFirst, I think the call to extractContent()
in the Editable.getContent()
function
should actually be
return content.extractContent(element, false)
to ensure that the argument keepUiElements
is a boolean as defined in the function’s documentation:
Technically, undefined
is a falsey value, but it’s just not clean 🤓
Request
I’d like to modify/clean up the content of the host element before it’s serialized to HTML by passing in a callback function. Without it, getContent()
returns a serialized HTML which I need to parse into a DOM element, clean it up, and serialize it again… which isn’t great.
So, for example:
const content = editable.getContent(elem, function(e) {
// Modify and clean up `e` where `e` is the cloned and scrubbed `elem`.
});
If you’re interested in adding a callback function parameter to getContent()
then I can open a PR. (It’s not a big change, but quite useful!)
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How can I change the EditText text without triggering the Text ...
Short answer. You can check which View currently has the focus to distinguish between user and program triggered events. EditText myEditText = (EditText) ......
Read more >Creating a dynamic editable column - Oracle Communities
I was trying to make my dynamic columns as editable. The problem is my dynamic columns are nested columns.
Read more >Stencil Utils Reference | BigCommerce Dev Center
The getContent method allows your code to display the cart contents in customized ways. It takes the form utils.api.cart.getContent(options, callback); .
Read more >EditText - Android Developers
When you define an edit text widget, you must specify the R.styleable. ... android:bufferType, Determines the minimum type that getText() will return.
Read more >API - Quill Rich Text Editor
Insert embedded content into the editor, returning a Delta representing the change. Source may be "user" , "api" , or "silent" . Calls...
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
I think working with a fragment is more in line with other code in this package (which works with fragments) and it avoids creating elements that have no other purpose than wrapping the fragment — in my use case I’d only unwrap the fragment again.
Either way, the boolean function parameter to
content.extractContent()
should be fixed.@peyerluk what do you think here? Return a div, which is easier to operate on or return a DocumentFragment, which supports easy insertion into the dom?
… Or just use the transform callback 😄