mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-03-29 14:18:11 +00:00
simplify page count
This commit is contained in:
@@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -45,8 +45,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.cm-count {
|
.cm-pageLine[data-page-number]::after {
|
||||||
float : right;
|
content:attr(data-page-number);
|
||||||
|
float:right;
|
||||||
color : grey;
|
color : grey;
|
||||||
}
|
}
|
||||||
.cm-columnSplit {
|
.cm-columnSplit {
|
||||||
|
|||||||
Reference in New Issue
Block a user