diff --git a/app/components/search/autocomplete-item/index.hbs b/app/components/search/autocomplete-item/index.hbs index 894dfd0..250cc99 100644 --- a/app/components/search/autocomplete-item/index.hbs +++ b/app/components/search/autocomplete-item/index.hbs @@ -1,5 +1,10 @@ -
  • -
    -
    {{@item.title}}
    -
    {{@item.path}}
    -
  • \ No newline at end of file +
  • +
    +
    +
    {{@item.title}}
    +
    {{@item.path}}
    +
    +
  • +
    +
    diff --git a/app/components/search_results/document/index.hbs b/app/components/search_results/document/index.hbs index 55a8872..2a1bea0 100644 --- a/app/components/search_results/document/index.hbs +++ b/app/components/search_results/document/index.hbs @@ -6,9 +6,7 @@ {{@result_node.title}} - - - \ No newline at end of file + diff --git a/app/modifiers/text_to_dom.js b/app/modifiers/text_to_dom.js new file mode 100644 index 0000000..6641329 --- /dev/null +++ b/app/modifiers/text_to_dom.js @@ -0,0 +1,49 @@ +import Modifier from 'ember-modifier'; + + +export default class TextToDom extends Modifier { + /* + Converts plain text to HTML DOM elements and inserts them + as children to `this.element` + + Autocomplete receives text matching highlights as plain text e.g. + + "This is great match". + + Besides the fact that you cannot style plain text, it is also + rendered with tag. + To fix this problem hightlight text is converted to DOM nodes. + */ + didReceiveArguments() { + + let text = this.args.positional[0], + template, + nodes, + that = this, + em_element, + text_element; + + // inspired from https://stackoverflow.com/a/35385518 + // HTML5's