linkedin / hakawai Goto Github PK
View Code? Open in Web Editor NEWA powerful, extensible UITextView.
License: Apache License 2.0
A powerful, extensible UITextView.
License: Apache License 2.0
I added a data on -setupFakeData
method with a long ass string.
[MentionEntity entityWithName:@"ytingasdasdasdlakdlaksdjlkasjdlkajsldkjalksdjlaksjdlkajsldkjalksdjalsdjlaksdjlakjsdljalskjalskdjalskdjlaksjdlkajsdlkajdlkajsdlkajsdlkajsdlkajsdlkajsdlkasjdlkasjd" entityId:@"27"]];
Creation of mentions with long name were still working fine, but when you're highlighting the created mention with long name the bug will occur.
Screenshot of behaviour.
http://imgur.com/a/8uNj4
It would be nice to have some easy interface to know when an @mention is added.
(Additionally, it would be nice if the standard UITextView delegate was called with -textViewDidChange:
when these @mentions are added).
Error when using 3DTouch keyboard text selection:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString setCursorPosition:]: unrecognized selector sent to instance
OR
[_NSActivityAssertion setCursorPosition:]: unrecognized selector sent to instance
Hello,
I am currently trying to append a space after a mention programmatically. I'm using the code below to accomplish this, for simplicity sake I'm assuming the mention is being added to the end of the text.
func mentionsPlugin(_ plugin: HKWMentionsPlugin!, createdMention entity: HKWMentionsEntityProtocol!, atLocation location: UInt) {
// capture existing mentions
let mentions = plugin.mentions()
// append a space, this will cause the mentions plug in to lose it's mentions
textView.text.append(" ")
// add the captured mentions back to the plugin
plugin.addMentions(mentions)
//inform the plugin that we have updated the textview programatically
plugin.textViewDidProgrammaticallyUpdate(textView)
}
If the next character that is typed is a control character mentionsPlugin(_ plugin: HKWMentionsPlugin!, stateChangedTo newState: HKWMentionsPluginState, from oldState: HKWMentionsPluginState)
is called twice in rapid succession once with a newState
of .creatingMention
and then with a newState
of .quiescent
. The chooser view is never presented, and the mentionsPluginWillActivateChooserView
and mentionsPluginActivatedChooserView
delegate methods are never called.
if the control character is deleted, a space typed, or any other characters are typed before the initial control character the chooser view is presented as expected.
It doesn't fire any of the related UITextViewDelegate unless a regular character or backspace is used.
However it is noticeable that shouldChangeTextInRange is called with internal delegate. But external delegate version is not called...
This issue has already been mentioned and closed on the same day without a solution.
The Hakawai framework is being used in an app to display @mentions in posts. The framework produces a bug where when this is put at the end of entered text the @mention no longer appears. Erasing the text and then trying again will show the @mention.
I have added the mentions plugin to my app and have noticed that when the keyboard is showing, loading the mention view will cause the keyboard to re-call the observer notifications.
Load view:
keyboardWillShow
keyboardDidShow
These occur as expected when we load the keyboard.
Type the mention character (# or @)
keyboardWillHide
keyboardDidHide
keyboardWillShow
keyboardDidShow
The keyboard doesn't change at all but these functions are still called.
This is causing issues for me as I am refreshing the tableView under the mentions view when the keyboard appears. Each time I open or close the mentions view this is happening.
Do you have any idea why this could be happening with the mentions view and plugin?
Simon
For example the result will be displayed as +MentionUser instead of MentionUser for now.
When my objective-c project didn't have the bridging-header file, my project was working fine. But when I created the bridging-header file, as I am using swift in my project , it started giving me the error in files where I imported HKWTextView.h.
The error is "Definition of 'HKWTextView' must be imported from module 'Hakawai.HKWTextView' before it is required"
And then when I used #import <Hakawai/Hakawai-umbrella.h> , it got resolved.
But I still don't understand the concept and use of this file.
And If I am importing this file in .h file of this screenshot's base class , it still gives error
why is it so?
How can I set the placeholder for HKWTextView ? I have UITextView instance of HKWTextView. I have set the delegate to implement the features.Now I am trying to call textViewDidBeginEditing and textViewDidEndEditing,but none of these delegate getting called.
_postTextView.simpleDelegate = self;
_postTextView.externalDelegate = self;
But textViewDidBeginEditing and textViewDidEndEditing not getting called.
How to do this?
I am using Hakawai textview. I have a submit button which gets enabled when textview has some text (text.length > 0). When I enter emoji, I do not get callback textViewDidChange.
Hello!, Im trying to implement this feature in my project and I have to say that it is really awesome!, I've managed to implemented the sibling project for Android but I cannot managed to do the same on iOS. The problem comes when subclassing the TextView on my storyboard to HKWTextView.
I am implementing this feature in a old project with Swift 3.0.
I have a TextView inside a Cell within a TableView and when I change the textview class to HKWTextView and create an outlet of type
@IBOutlet weak var textView: UITextView!
the keyboard doesnt show anymore and I'm not able to select the input text to write. It just doesn't let me introduce anything.
Do you have any idea why could it be?
Thank you so much.
I'm having to do something like this:
...
_commentTextView.controlFlowPlugin = _mentionsPlugin;
[_commentTextView resignFirstResponder];
...
Not sure where the text view gets passed the message becomeFirstResponder
.
Hello,
my view hierarchy is like this
when the textview becomes first responder on "keyboard will appear" I change the hierarchy like this (by calling [self.view addSubview:containerView] and then applying fullscreen constraints)
unfortunately at this point after I type some text I experience very strange problems when I trigger the mention plugin:
for an instant before the plugin table view appears I can see the background (like if there were no textview at all)
as soon as I try to "select" a mention the plugins disappear, the textview becomes empty, and no mention is appended, the cursor blink but when I try to trigger the plugin again it does not work
if I press backspace several times, it gets like reseted and then the control characted triggers the plugin again; sometimes at this point I can properly add a mention but as soon as I try to type more the textview becomes empy again
I understand this is bizarre, I'm using latest version from cocoapods. Any advice ?
Hello, I noticed the bounds of the child UIControl do not resize properly (also confirmed on the demo app using "Debug view hierarchy" with iPhone5S emulator). For me this is a problem, because I move my textview around using constraints to set it to fullscreen and uicontrol do not get the proper bounds this way; from an end user point of view some portions of the "single line" textview are not sensible to touch gestures when the mention plugin is visible.
At the moment I've been able to do a workaround for ios8 (not working on ios7) using constraints and removing the explicit code to sync its frame with the textview one (ie setFrame and layoutSubview) but there is probably an easier fix. Any help is appreciated, thanks :)
I have integrated Hakawai
and it's working perfectly.
One issue is I need to remove the top Line with the Arrow on top of the textview.
Note: I'm using the default chooser view with custom table view cell.
With such input methods, Hakawai can't detect user interaction with the text view correctly because some assumptions are not true any more, such as that the user can only insert one character by tapping one key on the keyboard.
test
test
disappears and nothing inserteds
is not inserted and also the marked text te
disappearsI want to do exactly what the LinkedIn iPhone app is doing. Tap an @ button in the inputAccessoryView which them inserts the @ symbol into the UITextView and starts the mention picker dropdown.
I have the beginning part working. When I tap the button it inserts my control character (@) but it does not start the mention picker. This only happens when I actually type an @ symbol.
Any help with this would be great appreciated. I have a feeling it's a simple fix and I am just missing something.
I thought the method textViewDidProgrammaticallyUpdate
was the key but it doesn't seem to be working for me.
Is there a way to enter mention-pick state by code? I.e. simulate action key of explicit mention.
This is requirement I have to place '#' button in convenient place. I tried
[textView insertText...]
or
[textView replaceRange:withText:]
with no success. I.e. control character is being inserted to text, but no mention autocomplete list shows up.
This bug can be verified in the LinkedIn app's new post view:
Observe behavior that after deleting some text the cursor will get stuck and stop deleting characters until you let off the button and re-press. I suspect this has something to do with the code that deals with partially deleting names of Mentions, e.g. turning "Ryan Downing" into "Ryan", but I haven't investigated further. Happy to provide more info if needed / take a look with you.
whenever the control character @ is appended in textview text on click of uibutton , chooser view doesn't open
Hello Dear,
Mentions works nice in the Create mode.
Now on Edit screen. I am preloading textView with text that contains mentions.
But Hakawai textView does not highlight those mentions which are set programatically as textView.text = "Hi XYZMention".
If I add new mention it highlights the new mention, when I call plugin.mentions() method it only returns the mentions that are newly created (typed by user) not the one that were already present in the text when textview is initialized.
I have also tried creating HKWMentionsAttribute for mentions that previously there in text and added it to plugin but still not working.
Here is my code
if let mentions = objPost?.mentions
{
for mention in mentions
{
let mentionAttrib = HKWMentionsAttribute()
mentionAttrib.entityIdentifier = String(mention.id!)
let str = messageString
let range = (mention.start! - 1)..<(mention.start! + mention.length! - 1)
let mySubstring = str[range]
mentionAttrib.mentionText = mySubstring
mentionAttrib.entityIdentifier = String(mention.id!)
mentionAttrib.metadata = ["id": mention.id!, "type": 1, "length": mention.length!]
mentionAttrib.range = NSMakeRange(mention.start! - 1, mention.length!)
plugin!.addMention(mentionAttrib)
}
}
plugin?.textViewDidProgrammaticallyUpdate(txtPost)
Please provide solution
If I inserted a mention fck_trmp
and inserted again the same mention immediately after the first mention fck_trmpfck_trmp
, it will be classified as a single mention
unselectedMentionAttributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 14),
NSAttributedStringKey.foregroundColor: UIColor.black,
HKWRoundedRectBackgroundAttributeName: HKWRoundedRectBackgroundAttributeValue.init(backgroundColor: UIColor("#f2faff"))],
selectedMentionAttributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 14),
NSAttributedStringKey.foregroundColor: UIColor.white,
HKWRoundedRectBackgroundAttributeName: HKWRoundedRectBackgroundAttributeValue.init(backgroundColor: UIColor("#718dff"))])
and i hope can support mention attribute inset control
When scrolling property for UITextView is disabled textView resizes as content grows. Is that possible with HKWTextView?
Currently the HKWMentionsPlugin can take a custom chooser view by subclassing HKWAbstractChooserView
but this implementation has two major limitations:
inputAccessoryView
)Hi
It's an awesome library. Thanks for this.
Can you please tell me how can I change the mention color text?
Thanks
With the 3.1.0 release, custom fonts for selected/unselected mentions are working (not sure if this is related).
But, as soon as the mention chooser view appears, all text in the TextView disappears. I can continue typing (although I can't see what I'm entering); as soon as the chooser view disappears, all of the text comes back, still with the correct formatting.
Is there way to create mention programatically?
你的代码十分强大.但是现在我的疑问是如何改变选择列表的位置.让它不呈现在输入框内部.因为我需要做类似 Facebook 的评论功能. 选择列表是浮现在输入框的上面.我应该如何修改?
Bug: invalid prefix / buffer was sent to the delegate (plugin's mentionDelegate)
Steps to replicate:
resumeMentionsCreationEnabled
property is set to YES
I am setting up my custom chooser view with the following constraints like so:
UIView *keyboardToolbar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 50)];
keyboardToolbar.translatesAutoresizingMaskIntoConstraints = NO;
[_mentionsPlugin setChooserTopLevelView:keyboardToolbar attachmentBlock:^(UIView *view) {
[keyboardToolbar addConstraint:[NSLayoutConstraint constraintWithItem:view
attribute:NSLayoutAttributeHeight
relatedBy:NSLayoutRelationEqual
toItem:keyboardToolbar
attribute:NSLayoutAttributeHeight
multiplier:1.0
constant:0.0]];
}];
textView.inputAccessoryView = keyboardToolbar;
When the keyboardToolbar
is initialized, it has the frame {0, 0, 375, 50} on an iPhone 6. After the setup block is called, I get this error:
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x7fae93f30b10 V:[UIView:0x7fae93cab380(50)]>",
"<NSLayoutConstraint:0x7fae93f140d0 HTUserMentionChooserView:0x7fae93abef40.height == UIView:0x7fae93cab380.height>",
"<NSAutoresizingMaskLayoutConstraint:0x7fae93f09bd0 h=--& v=--& V:[HTUserMentionChooserView:0x7fae93abef40(100)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fae93f140d0 HTUserMentionChooserView:0x7fae93abef40.height == UIView:0x7fae93cab380.height>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
Anyone can help me with adding custom mentioning outside the text view ?
How to reproduce:
Maybe you will have any idea @narlei?
Hello everyone!, does anybody managed to use UITableViewAutomaticDimension within a HKWTextView inside a Cell?.
I have a ViewController that has a TableView inside with two cells. The first one has an TextView and the second one is UIView (like the image below)
The followed was working for a time now but with no problem, using the UITableViewAutomaticDimension the cell resize within its own content, the second cell the linkCell was listening to an input and when it recognises an url it show a preview of the url.
Now I was able to add the mentions feature..but I want to have the first cell with a UITableViewAutomaticDimension
attribute but if I set the tableView.rowHeight = UITableViewAutomaticDimension
(as it was before) the text view (now the HKWTextView) isn't showing...
Do you know what I am missing?
Thank you so much
I have done the initial setup of Hakawai Textview, but when I select the value from Table View, it just dismisses, the selected value is not appearing in my textview also the Cursor disappears!
Someone please help me on this!
Hello,
when I use the mention/any plugin my textViewShouldBeginEditing external delegate method is not called. Would it be possible to have it processed anyway ?
My textview has a "fake" placeholder that needs to be removed on that delegate, apparently doing that on didBeginEditing will set the mention in a wrong internal state preventing me from creating a mention at location 0 (I open another bug for this).
thanks
hi,
Inside the mention delegate method i need to send a network request after typing 3 letters after @ sign and get the data, rather already having data. Then process the local search function on that data.
Is there any possible suggestions?
Would be great if thats possible.
Also can you insert videos?
Do you have swift examples?
Bests!
Can I use LinkedIn/Hakawai framework in Xcode Version 8.3.3 and with swift 3 and above !!
I can't find a way of showing the loadingCell while fetching the results the first time. I'm making a network call and I want to show the "loading" while the app is fetching the info to show.
Thanks 👍
Hi.
I'm trying to replicate "the marking someone in a post comment" situation. When you have a keyboard up and there's a tableview that rises with the possible entities to mark. (Image reference: http://imgur.com/a/w58jK)
Any insights are welcomed. The documentation is quite scarce.
Thanks!
Hey,
I've noticed spellCheckingType
is always overridden to .no
.
I can fix it but I wanted to understand the logic first.
Part of the initial setup of HKWTextView
is
[self.parentTextView overrideSpellCheckingWith:UITextSpellCheckingTypeNo];
I didn't understand when it returns to the original setting, please shed some light on this one :)
The only way I succeed solving it is commenting out the line above, nothing on my side solved it, even using the overrideSpellCheckingType:
method.
Thanks.
If I initialize the mention plugin as follows:
_mentionsPlugin = [HKWMentionsPlugin mentionsPluginWithChooserMode:HKWMentionsChooserPositionModeCustomLockBottomNoArrow
controlCharacters:[NSCharacterSet characterSetWithCharactersInString:@"@"]
searchLength:3
unselectedMentionAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:16],
NSForegroundColorAttributeName : [UIColor blackColor],
NSBackgroundColorAttributeName : [UIColor lightGrayColor]}
selectedMentionAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:16],
NSForegroundColorAttributeName : [UIColor whiteColor],
NSBackgroundColorAttributeName : [UIColor blackColor]}];
/* any other setup */
textView.controlFlowPlugin = _mentionsPlugin;
the font for the non-mention text in the textView
is reset to the UITextView
default value (I think system font of size 12).
Hello,
on my text view I set a fake placeholder text that I need to remove before editing starts. To accomplish this I've some logic to eventually set the textView text to @"" on my delegate textViewDidBeginEditing. Unfortunately in this case I can't create a mention anymore at location 0 by pressing control characters; mention creating can be resumed by writing/deleting some text and then it works at location 0 too.
Looking at the code when my user tap the text view I still have my fake "placeholder text" and the internal state is set at "Stalled" because it believes I'm tapping in a middle of a world.
It would be great if you could add support for a placeholder :) meanwhile could you have a look at this problem ?
thanks in advance
I got the following error once, but could not reproduce it again:
2015-03-11 17:33:11.734 HakawaiDemo[6681:3380888] *** Assertion failure in -[HKWAbstractionLayer textViewShouldChangeTextInRange:replacementText:], ~/Hakawai/Core/AbstractionLayer/HKWAbstractionLayer.m:302
2015-03-11 17:33:11.741 HakawaiDemo[6681:3380888] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Internal error'
*** First throw call stack:
(0x187e5659c 0x1989d00e4 0x187e5645c 0x188cdd554 0x1000d8bb0 0x1000e05e0 0x18cd3e790 0x18c8547b4 0x18c853efc 0x18c853a98 0x18cd72d50 0x18c807400 0x18c7c426c 0x18c7c3d08 0x18c7c1c78 0x18cd72d50 0x18ca8e1c0 0x18c7c0070 0x18c630950 0x18c7bfde0 0x18c7bfb64 0x18c63c228 0x18c6358b0 0x18c608fa8 0x18c8a7f58 0x18c607510 0x187e0e9ec 0x187e0dc90 0x187e0bd40 0x187d390a4 0x190eaf5a4 0x18c66e3c0 0x1000d3acc 0x19903ea08)
libc++abi.dylib: terminating with uncaught exception of type NSException
Bug:
Invoking
resignFirstResponder
on HKWTextView while on the state ofHKWMentionsStartDetectionStateCreatingMention
doesn't resign the HKWTextView completely. This also makes the functionality to resume mention creation to halt.
Steps to replicate:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.