diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-12 07:35:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-12 07:35:15 +0300 |
commit | d81721fdfb0913b197e5e53d577833cd5bde4a4f (patch) | |
tree | efb21e265bc1c13f66b7ea5c4cf470bc52a48b84 /app | |
parent | b5d655aea242b952abb8c020482fe8b810cb4d30 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
5 files changed, 61 insertions, 1 deletions
diff --git a/app/assets/javascripts/content_editor/services/highlight_js_language_loader.js b/app/assets/javascripts/content_editor/services/highlight_js_language_loader.js index a0ebbebed4e..5e7c981ace3 100644 --- a/app/assets/javascripts/content_editor/services/highlight_js_language_loader.js +++ b/app/assets/javascripts/content_editor/services/highlight_js_language_loader.js @@ -47,6 +47,10 @@ export default { 'clojure-repl': () => import(/* webpackChunkName: 'hl-clojure-repl' */ 'highlight.js/lib/languages/clojure-repl'), clojure: () => import(/* webpackChunkName: 'hl-clojure' */ 'highlight.js/lib/languages/clojure'), + codeowners: () => + import( + /* webpackChunkName: 'hl-codeowners' */ '~/vue_shared/components/source_viewer/languages/codeowners' + ), cmake: () => import(/* webpackChunkName: 'hl-cmake' */ 'highlight.js/lib/languages/cmake'), coffeescript: () => import(/* webpackChunkName: 'hl-coffeescript' */ 'highlight.js/lib/languages/coffeescript'), diff --git a/app/assets/javascripts/vue_shared/components/source_viewer/constants.js b/app/assets/javascripts/vue_shared/components/source_viewer/constants.js index 58db1ceda95..6c49a601401 100644 --- a/app/assets/javascripts/vue_shared/components/source_viewer/constants.js +++ b/app/assets/javascripts/vue_shared/components/source_viewer/constants.js @@ -147,3 +147,7 @@ export const BIDI_CHAR_TOOLTIP = 'Potentially unwanted character detected: Unico * HAML: https://github.com/highlightjs/highlight.js/issues/3783 * */ export const LEGACY_FALLBACKS = ['python', 'haml']; + +export const CODEOWNERS_FILE_NAME = 'CODEOWNERS'; + +export const CODEOWNERS_LANGUAGE = 'codeowners'; diff --git a/app/assets/javascripts/vue_shared/components/source_viewer/languages/codeowners.js b/app/assets/javascripts/vue_shared/components/source_viewer/languages/codeowners.js new file mode 100644 index 00000000000..33149b42222 --- /dev/null +++ b/app/assets/javascripts/vue_shared/components/source_viewer/languages/codeowners.js @@ -0,0 +1,42 @@ +/* +Language: Codeowners +Description: language definition for CODEOWNERS files +*/ + +export default (hljs) => { + return { + name: 'codeowners', + case_insensitive: true, + contains: [ + { + scope: 'number', + begin: '\\[\\d+\\]', + end: '(?=\\s|$)', + }, + { + scope: 'regexp', + begin: '^\\^|\\*', + }, + { + scope: 'attr', + begin: '^\\s*(?![#^*[])\\S|(?<=\\*)\\S*', + end: '(?=\\s|$)', + contains: [ + { + scope: 'regexp', + begin: '\\*', + }, + ], + }, + { + scope: 'keyword', + begin: '\\[(?!\\d+\\])[^\\]]+\\]', + }, + { + scope: 'variable', + begin: '\\S*@.*$', + }, + hljs.HASH_COMMENT_MODE, + ], + }; +}; diff --git a/app/assets/javascripts/vue_shared/components/source_viewer/source_viewer.vue b/app/assets/javascripts/vue_shared/components/source_viewer/source_viewer.vue index 11708b6f1f6..34ef85978b3 100644 --- a/app/assets/javascripts/vue_shared/components/source_viewer/source_viewer.vue +++ b/app/assets/javascripts/vue_shared/components/source_viewer/source_viewer.vue @@ -6,6 +6,7 @@ import { EVENT_ACTION, EVENT_LABEL_VIEWER } from './constants'; import Chunk from './components/chunk.vue'; export default { + name: 'SourceViewer', components: { Chunk, }, diff --git a/app/assets/javascripts/vue_shared/components/source_viewer/source_viewer_deprecated.vue b/app/assets/javascripts/vue_shared/components/source_viewer/source_viewer_deprecated.vue index 26cf45c7570..02b1113e3e9 100644 --- a/app/assets/javascripts/vue_shared/components/source_viewer/source_viewer_deprecated.vue +++ b/app/assets/javascripts/vue_shared/components/source_viewer/source_viewer_deprecated.vue @@ -12,6 +12,8 @@ import { ROUGE_TO_HLJS_LANGUAGE_MAP, LINES_PER_CHUNK, LEGACY_FALLBACKS, + CODEOWNERS_FILE_NAME, + CODEOWNERS_LANGUAGE, } from './constants'; import Chunk from './components/chunk_deprecated.vue'; import { registerPlugins } from './plugins/index'; @@ -25,6 +27,7 @@ import { registerPlugins } from './plugins/index'; * it does not trigger a repaint on a parent element that wraps all 1000 lines. */ export default { + name: 'SourceViewerDeprecated', components: { GlLoadingIcon, Chunk, @@ -40,7 +43,6 @@ export default { return { languageDefinition: null, content: this.blob.rawTextBlob, - language: ROUGE_TO_HLJS_LANGUAGE_MAP[this.blob.language?.toLowerCase()], hljs: null, firstChunk: null, chunks: {}, @@ -53,6 +55,11 @@ export default { splitContent() { return this.content.split(/\r?\n/); }, + language() { + return this.blob.name === this.$options.codeownersFileName + ? this.$options.codeownersLanguage + : ROUGE_TO_HLJS_LANGUAGE_MAP[this.blob.language?.toLowerCase()]; + }, lineNumbers() { return this.splitContent.length; }, @@ -185,6 +192,8 @@ export default { }, userColorScheme: window.gon.user_color_scheme, currentlySelectedLine: null, + codeownersFileName: CODEOWNERS_FILE_NAME, + codeownersLanguage: CODEOWNERS_LANGUAGE, }; </script> <template> |