Skip to content

Commit

Permalink
fix(quicknote): Fixing the rendered note, global replace of &
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-wilson-bh authored and jgodi committed Jun 28, 2017
1 parent 68d16fc commit d711a1d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 39 deletions.
35 changes: 0 additions & 35 deletions src/elements/quick-note/QuickNote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,41 +364,6 @@ describe('Elements: QuickNoteElement', () => {
});
}));

it('should leave references in the model when keepReferences is true.', fakeAsync(() => {
component.config.keepReferences = true;
ckEditorInstance.valueSetByUser('Note about: ');
ckEditorInstance.keyEnteredByUser('@');
ckEditorInstance.keyEnteredByUser('j');
ckEditorInstance.keyEnteredByUser('o');
ckEditorInstance.keyEnteredByUser('h');
ckEditorInstance.keyEnteredByUser('n');
ckEditorInstance.userPausedAfterEntry();
ckEditorInstance.keyEnteredByUser('DownArrow', KeyCodes.DOWN);
ckEditorInstance.keyEnteredByUser('Enter', KeyCodes.ENTER);

expect(parentForm.getValue()).toEqual({
note: 'Note about: <a href=\"http://www.bullhorn.com\">@John Bullhorn</a> ',
references: {
person: [{
value: 'j.bullhorn',
label: 'John Bullhorn'
}]
}
});

ckEditorInstance.valueSetByUser('Note about: ');

expect(parentForm.getValue()).toEqual({
note: 'Note about: ',
references: {
person: [{
value: 'j.bullhorn',
label: 'John Bullhorn'
}]
}
});
}));

it('should not add duplicate references to the model.', fakeAsync(() => {
ckEditorInstance.valueSetByUser('Note about: ');
ckEditorInstance.keyEnteredByUser('@');
Expand Down
7 changes: 3 additions & 4 deletions src/elements/quick-note/QuickNote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,7 @@ export class QuickNoteElement extends OutsideClick implements OnInit, OnDestroy,
value = value.replace(regex, '');

// Make sure that any references in the model are still valid
if (!this.config.keepReferences) {
this.validateReferences();
}
this.validateReferences();

// Possibly show results if the user has entered a search term
this.showResults();
Expand Down Expand Up @@ -464,7 +462,8 @@ export class QuickNoteElement extends OutsideClick implements OnInit, OnDestroy,

// CKEditor stopped supporting the config.forceSimpleAmpersand setting, so we have to convert '&amp;' to '&'
// when we pull html from the editor - see: https://dev.ckeditor.com/ticket/13723
html = html.replace('&amp;', '&');
let ampRegex = new RegExp('&amp;', 'g');
html = html.replace(ampRegex, '&');

Object.keys(this.model.references).forEach(taggingMode => {
let array = this.model.references[taggingMode] || [];
Expand Down

0 comments on commit d711a1d

Please sign in to comment.