Comments (11)
I don't know what you mean with "caret position"? Do you want to insert a caret into HTML or what?
from android-rteditor.
Hi,
I what to get the position of the cursor in HTML.
For example, if i have this text:
This is a text
If my cursor is before the word 'is' (This |is a text) the position of the cursor is 5 in plain text. But if i had the same sentence but with some HTML tags like this:
<b><u>This</u></b> is my text
And i put the cursor in the same position i will get position 5 in plain text, but i want to get the position in HTML which is 19 in this example.
So i want to get this position.
Thanks =D
from android-rteditor.
Why would you want the position in the html text? The html is simply used as an format to persist the text and it could be any format that supports the formatting (rtf, markdown, xml...). Spanned text as used by Android is not a good format to persist and thus the conversion from/to html.
I'm asking this question because I think you're trying to do something and I'm fairly certain that something might not be necessary or might have a much easier solution.
If you elaborate on what you're ultimately trying to achieve I might be able to point out a different approach.
from android-rteditor.
Oh Thanks! I'm trying to insert a image inside the text. I have the image path and i'm doing like this:
mRTMessageField.setRichTextEditing(true, rtHtmlBefore.getText() + "<img src=\"" + url +"\">" + rtHtmlAfter.getText());
from android-rteditor.
I tried but did not work =(
from android-rteditor.
You can't insert an image from a url into the rich text editor. Android's ImageSpan doesn't support images that aren't stored locally so even if you could insert the image like that, it wouldn't render. You need to download the image first or else rewrite the ImageSpan class.
from android-rteditor.
Oh sorry, the image is stored locally.
I was doing this:
Editable str = mRTMessageField.getText(); str.insert(mRTMessageField.getSelectionStart(), "\uFFFC"); ImageSpan imageSpan = new ImageSpan(new RTImageImpl(imagePath), false); str.setSpan(imageSpan, mRTMessageField.getSelectionStart(), mRTMessageField.getSelectionStart(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
from android-rteditor.
That's how the editor itself inserts an image:
EventBus.getDefault().post( new MediaEvent(RTMedia) );
RTMedia can be an RTImageImpl:
new RTImageImpl(url)
If you want more information about storage scenarios, please read this: https://github.com/1gravity/Android-RTEditor/blob/master/STORAGE.md
from android-rteditor.
It's not working =( Which method is called with this post? It's onEventMainThread(MediaEvent event) from the RTManager?
from android-rteditor.
Don't even think of calling the onEventMainThread directly ;-).
You're right though, the method I mention above wouldn't work since it's using mActiveEditor to determine in what editor to insert the image. mActiveEditor is usually null though and is only set when the user does the insert manually.
The way to go is to use the insertImage(RTEditText, RTImage) method. It's currently private but can be made public. I tested it but it didn't work and I don't have the time to look into this atm but this is the way to go.
from android-rteditor.
No problem ;) Thank you very much!
from android-rteditor.
Related Issues (20)
- Trouble Applying the 1.6.7 version HOT 3
- How to add a blockquote an horizontal line?
- Photo Capture is not working in the latest version of this library (1.6.7 of RTEditor)
- Android 8.0 insert text crash
- Fatal Exception: java.lang.IllegalStateException: The RTMediaFactory is null. Please make sure to register the editor at the RTManager before using it. HOT 2
- Can we have support for Fonts? HOT 1
- android.view.InflateException while using RTEditor HOT 1
- No subscribers registered for event class com.onegravity.rteditor.media.choose.MediaEvent when picking an image
- 为啥如此设置字体恢复不了 HOT 2
- Installation Error HOT 5
- link error
- Heading1 and heading2 formatting required HOT 2
- is this support kotlin? HOT 1
- [BUG] numbering append with <ol> when the last item deleted HOT 2
- It is possible to add emoji and file uploading
- Insta bug 11.3.0 is not working after integrated rteditor:1.7.6" HOT 2
- [BUG] Indentation left does not work any more in latest version
- [BUG] Caused by: android.view.InflateException: Binary XML file line #36 HOT 1
- 向右一直缩进到最后不会变成竖直一列
- problem when using proguard
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 android-rteditor.