mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-03-28 07:58:10 +00:00
snippetline count, and disable highlights in css tab
This commit is contained in:
@@ -39,7 +39,7 @@ const createHighlightPlugin = (renderer, tab)=>{
|
|||||||
}
|
}
|
||||||
toDOM() {
|
toDOM() {
|
||||||
const span = document.createElement('span');
|
const span = document.createElement('span');
|
||||||
span.className = 'cm-page-count';
|
span.className = 'cm-count';
|
||||||
span.textContent = this.count;
|
span.textContent = this.count;
|
||||||
span.style.color = '#989898';
|
span.style.color = '#989898';
|
||||||
return span;
|
return span;
|
||||||
@@ -62,6 +62,7 @@ const createHighlightPlugin = (renderer, tab)=>{
|
|||||||
const tokens = tokenize(view.state.doc.toString());
|
const tokens = tokenize(view.state.doc.toString());
|
||||||
|
|
||||||
let pageCount = 1;
|
let pageCount = 1;
|
||||||
|
let snippetCount = 0;
|
||||||
tokens.forEach((tok)=>{
|
tokens.forEach((tok)=>{
|
||||||
const line = view.state.doc.line(tok.line + 1);
|
const line = view.state.doc.line(tok.line + 1);
|
||||||
|
|
||||||
@@ -74,11 +75,15 @@ const createHighlightPlugin = (renderer, tab)=>{
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
decos.push(Decoration.line({ class: `cm-${tok.type}` }).range(line.from));
|
decos.push(Decoration.line({ class: `cm-${tok.type}` }).range(line.from));
|
||||||
if(tok.type === 'pageLine') {
|
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.widget({ widget: new countWidget(pageCount), side: 2 }).range(line.to));
|
||||||
}
|
}
|
||||||
|
if(tok.type === 'snippetLine' && tab === "brewSnippets") {
|
||||||
|
snippetCount++;
|
||||||
|
decos.push(Decoration.widget({ widget: new countWidget(snippetCount), side: 2 }).range(line.to));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -121,7 +126,7 @@ const CodeEditor = forwardRef(
|
|||||||
? syntaxHighlighting(customHighlightStyle)
|
? syntaxHighlighting(customHighlightStyle)
|
||||||
: syntaxHighlighting(legacyCustomHighlightStyle);
|
: syntaxHighlighting(legacyCustomHighlightStyle);
|
||||||
|
|
||||||
const customHighlightPlugin = createHighlightPlugin(renderer);
|
const customHighlightPlugin = createHighlightPlugin(renderer, tab);
|
||||||
|
|
||||||
const combinedHighlight = [
|
const combinedHighlight = [
|
||||||
customHighlightPlugin,
|
customHighlightPlugin,
|
||||||
@@ -231,7 +236,7 @@ const CodeEditor = forwardRef(
|
|||||||
? syntaxHighlighting(customHighlightStyle)
|
? syntaxHighlighting(customHighlightStyle)
|
||||||
: syntaxHighlighting(legacyCustomHighlightStyle);
|
: syntaxHighlighting(legacyCustomHighlightStyle);
|
||||||
|
|
||||||
const customHighlightPlugin = createHighlightPlugin(renderer);
|
const customHighlightPlugin = createHighlightPlugin(renderer, tab);
|
||||||
|
|
||||||
view.dispatch({
|
view.dispatch({
|
||||||
effects : highlightCompartment.reconfigure([customHighlightPlugin, highlightExtension]),
|
effects : highlightCompartment.reconfigure([customHighlightPlugin, highlightExtension]),
|
||||||
|
|||||||
@@ -10,7 +10,14 @@
|
|||||||
.codeEditor {
|
.codeEditor {
|
||||||
height : calc(100% - 25px);
|
height : calc(100% - 25px);
|
||||||
.cm-editor { height : 100%; }
|
.cm-editor { height : 100%; }
|
||||||
.cm-pageLine, &.brewSnippets .cm-snippetLine {
|
&.brewSnippets .cm-snippetLine {
|
||||||
|
background : #33333328;
|
||||||
|
border-top : #333399 solid 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.brewText, &.brewSnippets {
|
||||||
|
|
||||||
|
.cm-pageLine {
|
||||||
background : #33333328;
|
background : #33333328;
|
||||||
border-top : #333399 solid 1px;
|
border-top : #333399 solid 1px;
|
||||||
}
|
}
|
||||||
@@ -26,14 +33,9 @@
|
|||||||
.cm-completionIcon { display : none; }
|
.cm-completionIcon { display : none; }
|
||||||
.cm-tooltip-autocomplete .cm-completionLabel { translate : 0 -2px; }
|
.cm-tooltip-autocomplete .cm-completionLabel { translate : 0 -2px; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.cm-page-count {
|
.cm-count {
|
||||||
float : right;
|
|
||||||
color : grey;
|
|
||||||
}
|
|
||||||
.cm-snippet-count {
|
|
||||||
float : right;
|
float : right;
|
||||||
color : grey;
|
color : grey;
|
||||||
}
|
}
|
||||||
@@ -99,6 +101,9 @@
|
|||||||
}
|
}
|
||||||
.cm-definitionDesc { color : rgb(97, 57, 178); }
|
.cm-definitionDesc { color : rgb(97, 57, 178); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.brewJump {
|
.brewJump {
|
||||||
|
|||||||
Reference in New Issue
Block a user