Coder Social home page Coder Social logo

hakawai's Introduction

Build Status

Hakawai

A subclass of UITextView providing extended functionality and support for 'plugins'. Hakawai ships with the Mentions plug-in, which provides a powerful and flexible way to easily add social-media-esque @mentions-style annotation support to your iOS app.

For a higher-level overview, check out our blog post at the LinkedIn engineering blog.

✨ Features

  • A convenient drop-in replacement for UITextView instances
    • Includes Storyboards and XIBs
  • Easily modify add, remove, and transform the text view's plain and attributed text using a set of powerful block-based APIs
  • Work with attribute formatting and easily register or unregister custom attributes with enhanced attribute APIs
  • Easily add, remove, and manage accessory views
    • These UI elements can be added/removed from the text view for additional functionality
  • Lock the current line of text to the top or the bottom of the text view using single-line viewport mode
  • Programmatically dismiss autocorrect suggestions, and temporarily override the autocorrect, autocorrection, and spell checking modes
  • Solve several UITextView text layout bugs as Hakawai implements a custom layout manager and text container
  • Extend functionality by registering or unregistering plugins
  • EXPERIMENTAL - Easily monitor user changes to the text view's contents using the optional Abstraction Layer
    • Two-stage insertion for Chinese and Japanese keyboards is also properly handled
    • Abstraction Layer is built into the text view
    • Can also be pulled out and used independently if you desire

🔧 Getting Started

For more detailed documentation, check out the wiki.

Requirements

  • iOS 7.1: Hakawai supports iOS 7.1 or later, as it makes extensive use of TextKit. Severe TextKit bugs in iOS 7.0 break many of the features offered by the library. At your own risk, you may try using Hakawai with iOS 7.0 (this may be a viable option if you only want to use the text transformers).

  • Linker flags: Hakawai uses class extensions, and as a result you should add the -ObjC linker flag to your project settings if it's not there already. CocoaPods will automatically configure this for you if it's not already set.

Integrating Hakawai

  • Cocoapods: just add pod 'Hakawai' to your Podfile and install as normal
  • Manually: check out the project and copy the source files into your own project

Functionality

The primary Hakawai entity is the HKWTextView. It is a direct replacement of a vanilla UITextView, and may be used the same way as a UITextView with one important exception. Never set the HKWTextView's delegate property. If you need the functionality of the UITextViewDelegate, set the externalDelegate or simpleDelegate properties instead. Those delegates combined should cover all use cases for which you would otherwise use delegate.

Hakawai's functionality is divided up into three main categories:

  1. HKWTextView+TextTransformation: methods for working with and altering text and attributes within the text view
  2. HKWTextView+Extras: miscellaneous utilities
  3. HKWTextView+Plugins: an API intended for consumption by plugins
    • You may use these features directly as well, but doing so may or may not cause conflicts with any active plugins

Sample App

The HakawaiDemo sample app demonstrates some of Hakawai's features. Get it by using CocoaPods' try feature: pod try Hakawai, or by manually checking out the repository and running the HakawaiDemo scheme. Here's what's included:

  1. First tab: a simple text entry field with buttons to reverse or perform a ROT13 transformation on the selected text

  2. Second tab: demonstrates control flow plugins and the Abstraction Layer, and contains a 'console' which will display the user's actions as they type in or delete text.

  3. Third tab: demonstrates the mentions plug-in

    • Type in @ or + to see a list of entities that you can select (for demonstration's sake, the 25 earliest Turing Award winners)
    • You can also type in three characters of the name to bring up the built-in chooser

🔌 Plugins

Plugins are defined in the podspec file as subspecs, so you can pick and choose which plugins you want to use (as long as you include the Core subspec). If you are not using CocoaPods, each plug-in is located in a separate group in Xcode, and each plug-in's group can be deleted wholesale without compromising the functionality of the core library.

Hakawai supports two types of plugins, with both types receiving references to the parent HKWTextView:

  1. simple: has access to all the APIs of & can reference the core HKWTextView

  2. control flow: everything that simple plugins can do, plus the ability to implement additional delegate methods to respond to changes in the text view's state. Has two main subtypes, but please note that only one of the two subtypes can be registered to the text view at once:

    1. direct control flow plugins: receive UITextViewDelegate methods to monitor state of the text view and respond to user actions

    2. abstraction layer control flow plugins: receive HKWAbstractionLayerDelegate methods instead

Multiple simple plugins may be registered at once, but only one control flow plug-in can be registered at a time. Plugins can be unregistered at any time.

💬 The Mentions Plugin

For more detailed documentation, check out the Mentions page on the wiki.

Hakawai/Mentions is a plugin that allows annotations to be created within a HKWTextView. Annotations are portions of text which refer to specific entities, treated as a monolithic unit, and can be styled differently from the rest of the text. Examples of annotations are the mentions feature supported by many popular social media applications.

To see Mentions in action, check out the included demo app. Or, download the LinkedIn iOS app from the App Store, log in with your LinkedIn account, and try mentioning a connection or company.

Mentions Features

  • Easy to use - just implement a method to return results for a query string, and a method to return a cell for displaying a result
  • Support for implicit annotations (which are triggered after a customizable number of characters are typed)
  • Support for explicit annotations (which are triggered once one of any number of special characters are typed)
  • State machine-based logic makes changing or extending behavior less cumbersome
  • Query results can be returned synchronously or asynchronously
  • Multiple sets of results can be returned for a single query
  • Automatic rate limiting of queries
  • Annotations 'light up' if the user moves the selection cursor into them, or taps the backspace key with the cursor immediately following an annotation.
  • The plug-in offers the option to intelligently trim annotations; for example, truncating a full name into just a first name
  • Almost every aspect can be customized: styling of annotation in the highlighted and un-highlighted states, chooser view, results cells, etc
  • Annotations state is kept properly consistent even if user cuts and pastes text
  • Annotations work properly with autocapitalization and autocorrection

Integrating Mentions

  1. Create a helper class that implements the three required methods in HKWMentionsDelegate
  2. Create an instance of HKWTextView
  3. Create an instance of HKWMentionsPlugin using one of the factory methods
  4. Set the mention plug-in's delegate property to an instance of your helper class
  5. Call registerControlFlowPlugin: on the text view instance to register the plug-in

See the documentation comments for more information on the relevant classes and methods.

🚧 Testing

Hakawai includes an almost-comprehensive unit test suite for the main text view powered by the Specta and Expecta libraries. We hope to have test coverage for the abstraction layer and mentions plug-in in the future, although unit tests are probably not sufficient for testing these components.

📝 Contributing

Bug reports, feature requests, pull requests, comments, criticism, and honest feedback are all welcome. Please open an issue if you can't find an existing one that matches.

We currently use version 1.5.0 of Cocoapods to manage dependencies.

Plans/known issues for this library include:

  1. Verifying proper functionality and integration of Abstraction Layer

  2. Proper handling of non-period punctuation inserted after a predictive suggestion is selected (right now, implicit deletion of space when it's replaced by the punctuation is not registered).

  3. Abstraction Layer support for Korean text input

  4. Automated testing

🐉 Etymology

According to Wikipedia, "In Māori mythology, [...] Hakawai is a monstrous bird that ate people". There you go.

©️ Copyright & License

Hakawai © 2019 LinkedIn Corp. Licensed under the terms of the Apache License, Version 2.0.

hakawai's People

Contributors

aniyati avatar austinzheng avatar bkoatz avatar csv8674xn avatar cyuan1124 avatar dannyighsu avatar dotjim avatar dustinburge avatar erikackermann avatar jmkk avatar krayc425 avatar li-bakhade avatar li-jychen avatar li-pmehta avatar li-svartak avatar mrsmiley009 avatar narlei avatar nikhilbedi avatar qusic avatar rcancro avatar sergstav avatar terrychen1122 avatar tristanpollard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hakawai's Issues

Custom Mentions

Anyone can help me with adding custom mentioning outside the text view ?

Mentions plugin "disappears"

Hello,
my view hierarchy is like this

  • controller view
  • * tableview
  • * * tableviewcell (contentView)
  • * * * container view
  • * * * * hakawai text view, configured with mention plugin, with a small frame (ie 200x64)

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)

  • controller view
  • tableview
  • * tableviewcell (contentView)
  • container view (with proper fullscreen frame)
  • * hakawai text view
  • * chooser view

unfortunately at this point after I type some text I experience very strange problems when I trigger the mention plugin:

  1. for an instant before the plugin table view appears I can see the background (like if there were no textview at all)

  2. 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

  3. 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 ?

How to apply UITableViewAutomaticDimension in HKWTextView insice Cell

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)
UIViewController

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

Highlight Issue

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

Cursor stops when deleting text while using Mentions plugin

This bug can be verified in the LinkedIn app's new post view:

  1. type a somewhat long message into the textview
  2. hold down the delete button

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.

Spell checking is disabled

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.

Error on 3DTouch Select

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

Editing Mention after setting text to textview programmatically

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

How to set the placeholder for HKWTextView?

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.

  • (void)textViewDidBeginEditing:(HKWTextView *)textView
    {
    //want to call this
    }
  • (void)textViewDidEndEditing:(HKWTextView *)textView
    {
    //want to call this
    }

How to do this?

Hide the Top Arrow from Plugin

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.

Using custom class HKWTextView on StoryBoard doesn't show keyboard

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.

Simulating a placeholder break the mention plugin

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

Adding Mentions view triggers keyboardHide and then keyboardShow

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

Buffer Bug 'resumeMentionsPriorString / buffer'

Bug: invalid prefix / buffer was sent to the delegate (plugin's mentionDelegate)

Steps to replicate:

  • Make sure the plugin's resumeMentionsCreationEnabled property is set to YES
  1. Insert a random sentence.
  2. Initiate to create a mention somewhere between the sentence.
  3. Resign the HKWTextView
  4. Make the HKWTextView as first responder
  5. Invalid prefix / buffer was sent to the delegate BUG

@Mention does not appear when placed at the end of text

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.

Mention issue

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?

Typing emoji does not fire textViewDidChange delegate method

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.

#45

Swift Compatibility

Can I use LinkedIn/Hakawai framework in Xcode Version 8.3.3 and with swift 3 and above !!

UIControl bounds

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 :)

Setting a different font for `unselectedMentionAttributes` causes text view to overwrite textView's text styling

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).

Adjacent Mentions Classified as One

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

Trigger mentions programmatically?

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.

HKWTextView can't resume mention creation

Bug:

Invoking resignFirstResponder on HKWTextView while on the state of HKWMentionsStartDetectionStateCreatingMention doesn't resign the HKWTextView completely. This also makes the functionality to resume mention creation to halt.

Steps to replicate:

  • Make sure the plugin's resumeMentionsCreationEnabled property is set to YES
  1. Initiate to create a mention
  2. While on mention creation state, resign the HKWTextView
  3. Made the HKWTextView as first responder
  4. BUG

Unable to change height constraint of custom chooser view

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.

Reference to HKWMentionsChooserPositionModeCustomNoLockArrowPointingDown is ambiguous

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"

screen shot 2018-06-05 at 2 39 04 pm

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

screen shot 2018-06-05 at 2 42 14 pm

why is it so?

textViewShouldBeginEditing not called

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

How do you change the position of the selection list?

你的代码十分强大.但是现在我的疑问是如何改变选择列表的位置.让它不呈现在输入框内部.因为我需要做类似 Facebook 的评论功能. 选择列表是浮现在输入框的上面.我应该如何修改?

TextView text disappears when chooser view appears

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.

Insert Control Character programmatically and start mention picker automatically

I 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.

Mentions plugin breaks after manipulating text programmatically

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.

Custom Chooser view example.

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!

Mentions plugin : HKWRoundedRectBackgroundAttributeName broken in swift

  1. HKWRoundedRectBackgroundAttributeName not work in swift when i manual set this attribute
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"))])
  1. mention backgroundColor height not correct when i select mention (cause of set selected metion attributes font size less than textview size)

and i hope can support mention attribute inset control

HakawaiDemo causes Assertion failure when using text selection on 'abstractions' demo on iOS 8.1.2

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

Not working with input methods that insert unconfirmed text during user entering

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.

Example 1

  1. Use Chinese input method
  2. Press test
  3. Select the first candidate test
  4. The marked text test disappears and nothing inserted

hakawai-issue-1

Example 2

  1. Use Chinese input method
  2. Press @tes
  3. s is not inserted and also the marked text te disappears

hakawai-issue-2

Unable to select values from the Default chooser view

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.