0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-02 19:22:47 +00:00

Highlight target line during moveSource

This commit is contained in:
G.Ambatte
2022-06-02 13:50:37 +12:00
parent 0c0d817cc2
commit e9adc4de82
2 changed files with 11 additions and 1 deletions

View File

@@ -19,6 +19,8 @@ const DEFAULT_STYLE_TEXT = dedent`
color: black;
}`;
const sourceMoveHighlightClass = 'sourceMoveFlash';
const splice = function(str, index, inject){
return str.slice(0, index) + inject + str.slice(index);
};
@@ -131,6 +133,7 @@ const Editor = createClass({
//reset custom line styles
codeMirror.removeLineClass(lineNumber, 'background', 'pageLine');
codeMirror.removeLineClass(lineNumber, 'text');
codeMirror.removeLineClass(lineNumber, 'wrap', sourceMoveHighlightClass);
// Styling for \page breaks
if((this.props.renderer == 'legacy' && line.includes('\\page')) ||
@@ -217,7 +220,9 @@ const Editor = createClass({
targetLine = lineCount;
}
this.refs.codeEditor.setCursorPosition(targetLine, 0);
// this.refs.codeEditor.codeMirror.scrollIntoView({ line: targetLine, ch: 0 }, 30);
this.refs.codeEditor.setCursorPosition({ line: targetLine, ch: 0 });
this.refs.codeEditor.codeMirror.addLineClass(targetLine, 'wrap', sourceMoveHighlightClass);
}
},