0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-03-29 16:28:10 +00:00

simplify page count

This commit is contained in:
Víctor Losada Hernández
2026-03-29 01:12:21 +01:00
parent 2af063ac88
commit 1d02fb9565
2 changed files with 5 additions and 20 deletions

View File

@@ -53,22 +53,6 @@ const createHighlightPlugin = (renderer, tab)=>{
} else { } else {
tokenize = renderer === 'V3' ? tokenizeCustomMarkdown : legacyTokenizeCustomMarkdown; tokenize = renderer === 'V3' ? tokenizeCustomMarkdown : legacyTokenizeCustomMarkdown;
} }
/* eslint-disable no-restricted-syntax */
class countWidget extends WidgetType {
constructor(count) {
super();
this.count = count;
}
toDOM() {
const span = document.createElement('span');
span.className = 'cm-count';
span.textContent = this.count;
span.style.color = '#989898';
return span;
}
ignoreEvent() { return true; }
}
/* eslint-enable no-restricted-syntax */
return ViewPlugin.fromClass( return ViewPlugin.fromClass(
class { class {
@@ -96,11 +80,11 @@ const createHighlightPlugin = (renderer, tab)=>{
if(tok.type === 'pageLine' && tab === 'brewText') { if(tok.type === 'pageLine' && tab === 'brewText') {
pageCount++; pageCount++;
line.from === 0 && pageCount--; line.from === 0 && pageCount--;
decos.push(Decoration.widget({ widget: new countWidget(pageCount), side: 2 }).range(line.to)); decos.push( Decoration.line({ attributes: { "data-page-number": pageCount }}).range(line.from));
} }
if(tok.type === 'snippetLine' && tab === 'brewSnippets') { if(tok.type === 'snippetLine' && tab === 'brewSnippets') {
snippetCount++; snippetCount++;
decos.push(Decoration.widget({ widget: new countWidget(snippetCount), side: 2 }).range(line.to)); decos.push(Decoration.line({ attributes: { "data-page-number": pageCount }}).range(line.from));
} }
} }
}); });

View File

@@ -45,7 +45,8 @@
} }
} }
.cm-count { .cm-pageLine[data-page-number]::after {
content:attr(data-page-number);
float:right; float:right;
color : grey; color : grey;
} }