Comments (12)
I'm looking to do the same. I want to remove the "@" in mentions. If you have any insight, please share.
from activelabel.swift.
I have planned to implement smth like this for URLs. I'll try to think in this use case when I implement it
from activelabel.swift.
@poolqf so that means it is basically impossible atm because you are just using the original text as read only property?
while playing around inside createMentionElements()
I could at least modify the range that gets highlighted
from activelabel.swift.
Hi @longbowww , I was trying to add this feature last weekend, but it was not as easy as I thought. Requires replacements in the text, and doing it in an specific order. If you have any better idea, feel free to share it 😄 !
from activelabel.swift.
Hi @longbowww, @poolqf I'm actually trying to implement the same thing as you. Have you come with a solution? How were you thinking about going at it? I'm just about to get started with it so any ideas would be great. Thanks!
from activelabel.swift.
Hi @juanjold , my approach was:
- ActiveType has 2 parameters, one for the trimmed word, and another one for the original
- While in the parsing, remove the extra characters from each word
- Replace the words in the label's text with the trimmed ones
All this things have to be done taking a lot of care of the ranges. Otherwise it is really easy to make it crash. The correct way to do it would be doing it backwards, that way the previous word's ranges are still the same even if you replace a word, due that it is in a higher range location.
That's all the ideas I came up, I'll try to work on in whenever I find time. Would be really happy to help you if you have time to start working on it.
from activelabel.swift.
@juanjold @poolqf The way you put it was also my approach to tinker with Active Type.
In my case it is quite easy to find mentions as it follows a specific regex pattern, unfortunately I am not that familiar with TextStorage
but could it be possible to set a 3rd parameter much like word
that keeps track of what should be removed?
So basically I was trying to also find my way around with my original string and then decide on base of the mention range what to cut off (in my case i know that it is either 29/30 characters)
All that worked, but as soon as i start cutting off stuff I get all messed up inside the UITableViewCell
rendering cycle and the library trying to detect mentions.
That was why I was asking when it would be best to step in.
Lets say we got:
String -> TableViewCell Label -> TextStorage? -> ActiveLabel parsing -> TextStorage?
I get caught up inside the last 2 parts when I try to modify word/range as it will then no longer detect the regex as valid and therefore drop the mention.
As a bottom line my idea also would be:
- get initial string
- detect mentions inside this string
- delete mention ranges from string and keep track ? in a dict? where we deleted what
- create ActiveType mentions, insert them again with either original string or modified string
- decide on what/where to update TextStorage depending on ActiveType returns and original mention dict from string
I hope this is remotely understandable :D
from activelabel.swift.
Anyone ever get this figured out? I made a kinda hacky version that removes the "@" symbol on mentions and bolds the name but leaves a space where the @ was. I found it extremely difficult to remove that space properly and have all the formatting move along with it. Looks like @longbowww outlined a possible solution but I wanted to see if anyone else has taken a crack at it before I try again.
from activelabel.swift.
This is done
from activelabel.swift.
@poolqf - How would removing the @ in mentions happen then? I don't see a config for something like that.
from activelabel.swift.
@michaelbina , my fault. I read it too quickly. This is not done.
BTW, it is not on our roadmap to be honest
from activelabel.swift.
In my case i just used invisible unicode character (u2063) with custom pattern, like this
static let purePattern = "(?:^|\s|$)\u{2063}[\p{L}0-9_]*"
from activelabel.swift.
Related Issues (20)
- How to active email ? HOT 1
- If there are the same mention, can I know which one is clicked HOT 2
- How to calculate the height of swiftui HOT 1
- Active table #tag not working for Tamil language properly HOT 1
- HTML tags not working properly HOT 1
- customeType does not work
- Email Support has not been included in the PODS
- string have mention username without space it is not working HOT 1
- configureLinkAttribute 点击后无效
- Add padding to LabelView in swiftui does not work. HOT 1
- Nn
- Tap Label outside of tags and mentions
- Label insets Issue
- How do I use a filterHashtag in swift5
- URL Link selected font
- In mention username with dot is not detecting HOT 2
- handleCustomTap not working
- In mentions(@) full user name not detected only first name is detecting HOT 2
- urls didn't get recognised by ActiveLabel
- Apple's update to their API policy - Required Reason in Privacy manifest
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 activelabel.swift.