Comments (5)
The plugin has a very special approach because we can't put HTML in textarea, which is not the case with contenteditable elements.
Having the same functionnality in a contenteditable will require a totally different (and simplier) approach, which I won't implement in this plugin.
But it would be perfect in another one.
from jquery-highlighttextarea.
"Simplier" is really an understatement, it would only constist on getting the content, stripping HTML tags, wrapping matches in a span.highlight
and inject the new content, this on each "change" event.
No overly complicated (and buggy) wrappers, positioning, scrollbar calculators, etc.
from jquery-highlighttextarea.
Perhaps. I actually made some good headway towards implementing a highlightable contenteditable functionality separately from your library. I could perhaps have forked and submitted a pull request with this mostly separate functionality if it worked so that one library worked in both cases. However, my solution is unable to keep the caret in the right position; inserting the span.highlight into the contenteditable causes the caret to revert to the begining of the inserted span, which prevents what you suggest from being a viable option. After several days of unsuccessful hacking I came back to your library to try and make it work.. So I honestly think that if I modified your library, trying to get it to work with contenteditables is the best solution for me.
If I may ask, how is it that your overlayed div.highlighter is able to give focus to the underlying original textarea? If I intercepted focus events to div.highlighter overlaying contenteditables, do you think it work to then send focus to the contenteditable instead?
from jquery-highlighttextarea.
it's this block which automatically transfer focus to the textarea (It's not mine, it comes from a fork)
https://github.com/mistic100/jQuery-highlightTextarea/blob/master/jquery.highlighttextarea.js#L182
I found tons on results on Google when searchching for get/set carret position in a contenteditable
from jquery-highlighttextarea.
Yes, I used the brilliant jquery.caret library for getting and setting caret position. Unfortunately it's unable to work when the contenteditable contains inner HTML of any kind.. I am lead to believe that is due to deficiencies in the browser's range API.. certainly I could not achieve the desired effect when I used a different caret library either. At the moment, as I say, it seems like modifying your library will be an easier solution for me than modifying a caret library to work with HTML inside a contenteditable. Thank you for your last reply. I will have a closer look at the focus stealer you reference on line 182 of your library and let you know if I have any success.
from jquery-highlighttextarea.
Related Issues (20)
- Replace mechanism is broken causing misplaced highlights. HOT 1
- speed up scroll position
- Regular expression problem in words array HOT 2
- KeyUp events HOT 2
- Words with -(minus) highlight to bugs
- RegEx dosn't work HOT 2
- Multiple Highlights - Different Colors? HOT 1
- text area is not wrapped by highlighttext HOT 1
- Invalid regular expression: Nothing to repeat
- Highlighting not working properly when setting value of textarea using jquery HOT 1
- jQuery is not defined HOT 1
- Will the plugin work with bootstrap? HOT 1
- How to implement this in Vue?
- Highlighting is not working when searching for string in html source code placed in textarea?
- How can I reset the textarea?
- regex
- Is it possible to assign IDs to parts of text?
- Right to Left (like in arabic or hebrew) Highlighting doesn't working properly (working reverse left to right...) HOT 1
- Does it need to be only text area?
- need to update jquery.highlighttextarea.min.js from jquery.highlighttextarea.js
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-highlighttextarea.