mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	Show highlighted text in right panel
This commit is contained in:
		
							parent
							
								
									463d145cb7
								
							
						
					
					
						commit
						33fdad5159
					
				@ -28,6 +28,8 @@ const TPL = `<div class="highlighted-text-widget">
 | 
				
			|||||||
            margin-bottom: 3px;
 | 
					            margin-bottom: 3px;
 | 
				
			||||||
            text-align: justify;
 | 
					            text-align: justify;
 | 
				
			||||||
            text-justify: distribute;
 | 
					            text-justify: distribute;
 | 
				
			||||||
 | 
					            word-wrap: break-word;
 | 
				
			||||||
 | 
					            hyphens: auto;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        .highlighted-text li:hover {
 | 
					        .highlighted-text li:hover {
 | 
				
			||||||
@ -149,26 +151,27 @@ export default class HighlightTextWidget extends RightPanelWidget {
 | 
				
			|||||||
        findSubStr = findSubStr.substring(1)
 | 
					        findSubStr = findSubStr.substring(1)
 | 
				
			||||||
        combinedRegexStr = `(` + combinedRegexStr.substring(1) + `)`;
 | 
					        combinedRegexStr = `(` + combinedRegexStr.substring(1) + `)`;
 | 
				
			||||||
        const combinedRegex = new RegExp(combinedRegexStr, 'gi');
 | 
					        const combinedRegex = new RegExp(combinedRegexStr, 'gi');
 | 
				
			||||||
        var $hlt = $("<ol>");
 | 
					        let $hlt = $("<ol>");
 | 
				
			||||||
        var hltLiCount = 0;
 | 
					        let prevEndIndex = -1, hltLiCount = 0;
 | 
				
			||||||
        let prevEndIndex = -1;
 | 
					        for (let match = null, hltIndex=0; ((match = combinedRegex.exec(html)) !== null); hltIndex++) {
 | 
				
			||||||
        for (let match = null, hltIndex = 0; ((match = combinedRegex.exec(html)) !== null); hltIndex++) {
 | 
					 | 
				
			||||||
            var subHtml = match[0];
 | 
					            var subHtml = match[0];
 | 
				
			||||||
            const startIndex = match.index;
 | 
					            const startIndex = match.index;
 | 
				
			||||||
            const endIndex = combinedRegex.lastIndex;
 | 
					            const endIndex = combinedRegex.lastIndex;
 | 
				
			||||||
            hltLiCount++;
 | 
					 | 
				
			||||||
            if (prevEndIndex != -1 && startIndex === prevEndIndex) {
 | 
					            if (prevEndIndex != -1 && startIndex === prevEndIndex) {
 | 
				
			||||||
                $hlt.children().last().append(subHtml);
 | 
					                $hlt.children().last().append(subHtml);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                var $li = $('<li>');
 | 
					                if ([...subHtml.matchAll(/(?<=^|>)[^><]+?(?=<|$)/g)].map(matchTmp => matchTmp[0]).join('').trim() != ""){
 | 
				
			||||||
                $li.html(subHtml);
 | 
					                    var $li = $('<li>');
 | 
				
			||||||
                if ($li.text().trim() == "") { $li.css("display", "none"); }
 | 
					                    $li.html(subHtml);
 | 
				
			||||||
                $li.on("click", () => this.jumpToHlt(findSubStr,hltIndex));
 | 
					                    $li.on("click", () => this.jumpToHlt(findSubStr,hltIndex));
 | 
				
			||||||
                $hlt.append($li);
 | 
					                    $hlt.append($li);
 | 
				
			||||||
 | 
					                    hltLiCount++;
 | 
				
			||||||
 | 
					                }else{
 | 
				
			||||||
 | 
					                    continue
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            prevEndIndex = endIndex;
 | 
					            prevEndIndex = endIndex;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
            $hlt,
 | 
					            $hlt,
 | 
				
			||||||
            hltLiCount
 | 
					            hltLiCount
 | 
				
			||||||
 | 
				
			|||||||
@ -38,6 +38,10 @@ const TPL = `<div class="toc-widget">
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        .toc li {
 | 
					        .toc li {
 | 
				
			||||||
            cursor: pointer;
 | 
					            cursor: pointer;
 | 
				
			||||||
 | 
					            text-align: justify;
 | 
				
			||||||
 | 
					            text-justify: distribute;
 | 
				
			||||||
 | 
					            word-wrap: break-word;
 | 
				
			||||||
 | 
					            hyphens: auto;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        .toc li:hover {
 | 
					        .toc li:hover {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user