File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 3131- Исправлена инструкция для запуска в firefox, [ issue #19 ] ( https://github.com/devmanorg/github-copy-plugin/issues/19 )
3232- Добавляет определения языка при копировании кода в gitlab, [ issue #16 ] ( https://github.com/devmanorg/github-copy-plugin/issues/16 )
3333- Исправляет получение типа файла в ссылках с get параметрами, [ issue #28 ] ( https://github.com/devmanorg/github-copy-plugin/issues/28 )
34+ - Исправляет копирование строк в GitHub, [ issue #30 ] ( https://github.com/devmanorg/github-copy-plugin/issues/30 )
Original file line number Diff line number Diff line change @@ -19,18 +19,20 @@ var copyMarkdownSnippetFromGithub = (function(){ // ES6 modules are not supporte
1919 }
2020
2121 function convertLineElToText ( lineEl ) {
22- let spans = lineEl . querySelectorAll ( 'span' ) ;
23- let textFragments = Array . prototype . map . call ( spans , span => span . getAttribute ( 'data-code-text' ) )
22+ let lines = Array . from ( lineEl . querySelector ( '.react-file-line' ) . childNodes ) ;
23+ let textFragments = Array . prototype . map . call ( lines , line => line . textContent )
2424 return textFragments . join ( '' )
2525 }
2626
2727 function readHighlightedLines ( ) {
2828 // Read code lines highlighted on GitHub page, return multiline string
29- let lines = document . querySelectorAll ( '.js-file-line-container .js-file-line.highlighted' ) ;
30- if ( lines . length === 0 ) {
31- lines = document . querySelectorAll ( 'div[aria-current]' ) ;
29+ let lines = Array . from ( document . querySelectorAll ( '.highlighted-line' ) ) ;
30+ const numbers = lines . map ( line => line . getAttribute ( 'data-line-number' ) ) ;
31+ let texts = numbers . map ( number => document . querySelector ( `[data-key="${ number - 1 } "]` ) )
32+ if ( texts . length === 0 ) {
33+ texts = document . querySelectorAll ( 'div[aria-current]' ) ;
3234 }
33- const codeLines = Array . prototype . map . call ( lines , convertLineElToText ) ;
35+ const codeLines = Array . prototype . map . call ( texts , convertLineElToText ) ;
3436 return codeLines . join ( '\n' ) ;
3537 }
3638
You can’t perform that action at this time.
0 commit comments