File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -1125,9 +1125,11 @@ async function renderLiveViewMarkdown(file) {
11251125 if ( isMobile ) frameDoc . body . classList . add ( 'mobile' ) ;
11261126 setAttr ( frameDoc . body , 'dir' , 'auto' ) ;
11271127
1128- frameDoc . body . querySelectorAll ( 'a[href]' ) . forEach ( link => {
1128+ frameDoc . body . querySelectorAll ( 'a[href]:not([target="_blank"]) ' ) . forEach ( link => {
11291129
1130- if ( ! getAttr ( link , 'href' ) . startsWith ( '#' ) ) {
1130+ const href = getAttr ( link , 'href' ) ;
1131+
1132+ if ( ! href . startsWith ( '#' ) ) {
11311133
11321134 link . title = isMac ? '⌘ + click to open link' : 'Ctrl + click to open link' ;
11331135
@@ -1137,16 +1139,27 @@ async function renderLiveViewMarkdown(file) {
11371139
11381140 if ( event . ctrlKey || event . metaKey ) {
11391141
1140- window . open ( getAttr ( link , ' href' ) , '_blank' ) ;
1142+ window . open ( href , '_blank' ) ;
11411143
11421144 } else {
11431145
1144- showMessage ( getAttr ( link , ' href' ) ) ;
1146+ showMessage ( href ) ;
11451147
11461148 }
11471149
11481150 } ;
11491151
1152+ } else {
1153+
1154+ link . onclick = ( e ) => {
1155+
1156+ e . preventDefault ( ) ;
1157+
1158+ const target = document . querySelector ( href ) ;
1159+ target . scrollIntoView ( ) ;
1160+
1161+ } ;
1162+
11501163 }
11511164
11521165 } ) ;
You can’t perform that action at this time.
0 commit comments