Skip to content
Snippets Groups Projects
Commit 757742e7 authored by Silvio Giebl's avatar Silvio Giebl
Browse files

Fixed search result word wrap

parent 538591dd
No related branches found
No related tags found
No related merge requests found
...@@ -166,6 +166,11 @@ ...@@ -166,6 +166,11 @@
height: $sp-4; height: $sp-4;
margin-right: $sp-2; margin-right: $sp-2;
fill: $link-color; fill: $link-color;
flex-shrink: 0;
}
.search-result-doc-title {
overflow: auto;
} }
} }
......
...@@ -187,16 +187,17 @@ function searchLoaded(index, docs) { ...@@ -187,16 +187,17 @@ function searchLoaded(index, docs) {
resultDoc.innerHTML = '<svg viewBox="0 0 24 24" class="search-result-icon"><use xlink:href="#svg-doc"></use></svg>'; resultDoc.innerHTML = '<svg viewBox="0 0 24 24" class="search-result-icon"><use xlink:href="#svg-doc"></use></svg>';
resultTitle.appendChild(resultDoc); resultTitle.appendChild(resultDoc);
var resultDocSpan = document.createElement('span'); var resultDocTitle = document.createElement('div');
resultDocSpan.innerHTML = doc.doc; resultDocTitle.classList.add('search-result-doc-title');
resultDoc.appendChild(resultDocSpan); resultDocTitle.innerText = doc.doc;
var resultDocOrSection = resultDocSpan; resultDoc.appendChild(resultDocTitle);
var resultDocOrSection = resultDocTitle;
if (doc.doc != doc.title) { if (doc.doc != doc.title) {
resultDoc.classList.add('search-result-doc-parent'); resultDoc.classList.add('search-result-doc-parent');
var resultSection = document.createElement('div'); var resultSection = document.createElement('div');
resultSection.classList.add('search-result-section'); resultSection.classList.add('search-result-section');
resultSection.innerHTML = doc.title; resultSection.innerText = doc.title;
resultTitle.appendChild(resultSection); resultTitle.appendChild(resultSection);
resultDocOrSection = resultSection; resultDocOrSection = resultSection;
} }
...@@ -325,18 +326,14 @@ function searchLoaded(index, docs) { ...@@ -325,18 +326,14 @@ function searchLoaded(index, docs) {
var index = start; var index = start;
for (var i in positions) { for (var i in positions) {
var position = positions[i]; var position = positions[i];
var span = document.createElement('span'); parent.appendChild(document.createTextNode(text.substring(index, position[0])));
span.innerHTML = text.substring(index, position[0]);
parent.appendChild(span);
index = position[0] + position[1]; index = position[0] + position[1];
var highlight = document.createElement('span'); var highlight = document.createElement('span');
highlight.classList.add('search-result-highlight'); highlight.classList.add('search-result-highlight');
highlight.innerHTML = text.substring(position[0], index); highlight.innerText = text.substring(position[0], index);
parent.appendChild(highlight); parent.appendChild(highlight);
} }
var span = document.createElement('span'); parent.appendChild(document.createTextNode(text.substring(index, end)));
span.innerHTML = text.substring(index, end);
parent.appendChild(span);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment