This repository was archived by the owner on May 12, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ export default class CodeEditor extends React.Component {
5757 }
5858 this . searchHandler = ( e , msg ) => this . handleSearch ( msg )
5959 this . searchState = null
60+ this . scrollToLineHandeler = this . scrollToLine . bind ( this )
6061
6162 this . formatTable = ( ) => this . handleFormatTable ( )
6263 this . editorActivityHandler = ( ) => this . handleEditorActivity ( )
@@ -125,6 +126,7 @@ export default class CodeEditor extends React.Component {
125126 componentDidMount ( ) {
126127 const { rulers, enableRulers } = this . props
127128 const expandSnippet = this . expandSnippet . bind ( this )
129+ eventEmitter . on ( 'line:jump' , this . scrollToLineHandeler )
128130
129131 const defaultSnippet = [
130132 {
@@ -475,7 +477,13 @@ export default class CodeEditor extends React.Component {
475477
476478 moveCursorTo ( row , col ) { }
477479
478- scrollToLine ( num ) { }
480+ scrollToLine ( event , num ) {
481+ const cursor = {
482+ line : num ,
483+ ch : 1
484+ }
485+ this . editor . setCursor ( cursor )
486+ }
479487
480488 focus ( ) {
481489 this . editor . focus ( )
Original file line number Diff line number Diff line change @@ -866,6 +866,15 @@ export default class MarkdownPreview extends React.Component {
866866 return
867867 }
868868
869+ const regexIsLine = / ^ : l i n e : [ 0 - 9 ] /
870+ if ( regexIsLine . test ( linkHash ) ) {
871+ const numberPattern = / \d + / g
872+
873+ const lineNumber = parseInt ( linkHash . match ( numberPattern ) [ 0 ] )
874+ eventEmitter . emit ( 'line:jump' , lineNumber )
875+ return
876+ }
877+
869878 // this will match the old link format storage.key-note.key
870879 // e.g.
871880 // 877f99c3268608328037-1c211eb7dcb463de6490
You can’t perform that action at this time.
0 commit comments