diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-24 06:07:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-24 06:07:07 +0000 |
commit | 12287a65b735d784cda3555d1b261e50b461b29e (patch) | |
tree | e7539b1b3672986a4f41b544f913ee120d623d44 /app/assets/javascripts/blob_edit | |
parent | 24ed154fa81265f47bcfbecfcb331f82a5faad0d (diff) | |
download | gitlab-ce-12287a65b735d784cda3555d1b261e50b461b29e.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/blob_edit')
-rw-r--r-- | app/assets/javascripts/blob_edit/edit_blob.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/app/assets/javascripts/blob_edit/edit_blob.js b/app/assets/javascripts/blob_edit/edit_blob.js index 011898a5e7a..8561f650e8f 100644 --- a/app/assets/javascripts/blob_edit/edit_blob.js +++ b/app/assets/javascripts/blob_edit/edit_blob.js @@ -4,7 +4,8 @@ import $ from 'jquery'; import axios from '~/lib/utils/axios_utils'; import createFlash from '~/flash'; import { __ } from '~/locale'; -import TemplateSelectorMediator from '../blob/file_template_mediator'; +import { blobLinkRegex } from '~/blob/blob_utils'; +import TemplateSelectorMediator from '~/blob/file_template_mediator'; import getModeByFileExtension from '~/lib/utils/ace_utils'; import { addEditorMarkdownListeners } from '~/lib/utils/text_markdown'; @@ -17,6 +18,7 @@ export default class EditBlob { this.initModePanesAndLinks(); this.initSoftWrap(); this.initFileSelectors(); + this.initBlobContentLinkClickability(); } configureAceEditor() { @@ -89,6 +91,22 @@ export default class EditBlob { return this.editor.focus(); } + initBlobContentLinkClickability() { + this.editor.renderer.on('afterRender', () => { + document.querySelectorAll('.ace_text-layer .ace_line > *').forEach(token => { + if (token.dataset.linkified || !token.textContent.includes('http')) return; + + // eslint-disable-next-line no-param-reassign + token.innerHTML = token.innerHTML.replace( + blobLinkRegex, + '<a target="_blank" href="$&">$&</a>', + ); + // eslint-disable-next-line no-param-reassign + token.dataset.linkified = true; + }); + }); + } + initSoftWrap() { this.isSoftWrapped = false; this.$toggleButton = $('.soft-wrap-toggle'); |