Unverified Commit 01533082 authored by Dan MacFarlane's avatar Dan MacFarlane Committed by GitHub
Browse files

Merge pull request #118 from pgedzba/allow_space_while_mentioning

Add "allowSpace" while mentioning parameter for #106
parents ae122c5d 3eb39f50
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -64,6 +64,7 @@ The following optional configuration items can be used.
| dropUp        | false    | Show the menu above the cursor instead of below. |
| dropUp        | false    | Show the menu above the cursor instead of below. |
| maxItems      | ∞        | Limit the number of items shown in the text. The default is no limit. |
| maxItems      | ∞        | Limit the number of items shown in the text. The default is no limit. |
| mentionSelect |          | An optional function to format the selected item before inserting the text. |
| mentionSelect |          | An optional function to format the selected item before inserting the text. |
| allowSpace    | false    | An optional paremeter which decides whether to allow space while mentioning or not |


For Example: 
For Example: 


+1 −0
Original line number Original line Diff line number Diff line
@@ -64,6 +64,7 @@ The following optional configuration items can be used.
| dropUp        | false    | Show the menu above the cursor instead of below. |
| dropUp        | false    | Show the menu above the cursor instead of below. |
| maxItems      | ∞        | Limit the number of items shown in the text. The default is no limit. |
| maxItems      | ∞        | Limit the number of items shown in the text. The default is no limit. |
| mentionSelect |          | An optional function to format the selected item before inserting the text. |
| mentionSelect |          | An optional function to format the selected item before inserting the text. |
| allowSpace    | false    | An optional paremeter which decides whether to allow space while mentioning or not |


For Example: 
For Example: 


+3 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,9 @@ export interface Mentions {
  // display menu above text instead of below
  // display menu above text instead of below
  dropUp?:boolean;
  dropUp?:boolean;


  // whether to allow space while mentioning or not
  allowSpace?: boolean;

  // optional function to format the selected item before inserting the text
  // optional function to format the selected item before inserting the text
  mentionSelect?:(item: any) => (string);
  mentionSelect?:(item: any) => (string);
}
}
 No newline at end of file
+2 −1
Original line number Original line Diff line number Diff line
@@ -51,6 +51,7 @@ export class MentionDirective implements OnChanges {
    triggerChar: '@',
    triggerChar: '@',
    labelKey: 'label',
    labelKey: 'label',
    maxItems: -1,
    maxItems: -1,
    allowSpace: false,
    mentionSelect: (item: any) => this.activeConfig.triggerChar + item[this.activeConfig.labelKey]
    mentionSelect: (item: any) => this.activeConfig.triggerChar + item[this.activeConfig.labelKey]
  }
  }


@@ -209,7 +210,7 @@ export class MentionDirective implements OnChanges {
          !event.ctrlKey &&
          !event.ctrlKey &&
          pos > this.startPos
          pos > this.startPos
      ) {
      ) {
        if (event.keyCode === KEY_SPACE) {
        if (!this.activeConfig.allowSpace && event.keyCode === KEY_SPACE) {
          this.startPos = -1;
          this.startPos = -1;
        }
        }
        else if (event.keyCode === KEY_BACKSPACE && pos > 0) {
        else if (event.keyCode === KEY_BACKSPACE && pos > 0) {