diff --git a/src/public/app/widgets/highlighted_text.js b/src/public/app/widgets/highlighted_text.js index f13bdc6b8..f39e7c696 100644 --- a/src/public/app/widgets/highlighted_text.js +++ b/src/public/app/widgets/highlighted_text.js @@ -28,6 +28,8 @@ const TPL = `
margin-bottom: 3px; text-align: justify; text-justify: distribute; + word-wrap: break-word; + hyphens: auto; } .highlighted-text li:hover { @@ -149,26 +151,27 @@ export default class HighlightTextWidget extends RightPanelWidget { findSubStr = findSubStr.substring(1) combinedRegexStr = `(` + combinedRegexStr.substring(1) + `)`; const combinedRegex = new RegExp(combinedRegexStr, 'gi'); - var $hlt = $("
    "); - var hltLiCount = 0; - let prevEndIndex = -1; - for (let match = null, hltIndex = 0; ((match = combinedRegex.exec(html)) !== null); hltIndex++) { + let $hlt = $("
      "); + let prevEndIndex = -1, hltLiCount = 0; + for (let match = null, hltIndex=0; ((match = combinedRegex.exec(html)) !== null); hltIndex++) { var subHtml = match[0]; const startIndex = match.index; const endIndex = combinedRegex.lastIndex; - hltLiCount++; if (prevEndIndex != -1 && startIndex === prevEndIndex) { $hlt.children().last().append(subHtml); } else { - var $li = $('
    1. '); - $li.html(subHtml); - if ($li.text().trim() == "") { $li.css("display", "none"); } - $li.on("click", () => this.jumpToHlt(findSubStr,hltIndex)); - $hlt.append($li); + if ([...subHtml.matchAll(/(?<=^|>)[^><]+?(?=<|$)/g)].map(matchTmp => matchTmp[0]).join('').trim() != ""){ + var $li = $('
    2. '); + $li.html(subHtml); + $li.on("click", () => this.jumpToHlt(findSubStr,hltIndex)); + $hlt.append($li); + hltLiCount++; + }else{ + continue + } } prevEndIndex = endIndex; } - return { $hlt, hltLiCount diff --git a/src/public/app/widgets/toc.js b/src/public/app/widgets/toc.js index f17c3e65b..43ecb8f2d 100644 --- a/src/public/app/widgets/toc.js +++ b/src/public/app/widgets/toc.js @@ -38,6 +38,10 @@ const TPL = `
      .toc li { cursor: pointer; + text-align: justify; + text-justify: distribute; + word-wrap: break-word; + hyphens: auto; } .toc li:hover {