Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 21:25:58 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 21:25:58 +0300
commita5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch)
treefb69158581673816a8cd895f9d352dcb3c678b1e /app/assets/javascripts/content_editor/extensions/code_block_highlight.js
parentd16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff)
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'app/assets/javascripts/content_editor/extensions/code_block_highlight.js')
-rw-r--r--app/assets/javascripts/content_editor/extensions/code_block_highlight.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/app/assets/javascripts/content_editor/extensions/code_block_highlight.js b/app/assets/javascripts/content_editor/extensions/code_block_highlight.js
index ce8bd57c7e3..50d72f4089a 100644
--- a/app/assets/javascripts/content_editor/extensions/code_block_highlight.js
+++ b/app/assets/javascripts/content_editor/extensions/code_block_highlight.js
@@ -1,12 +1,20 @@
import { CodeBlockLowlight } from '@tiptap/extension-code-block-lowlight';
+import * as lowlight from 'lowlight';
import { defaultMarkdownSerializer } from 'prosemirror-markdown/src/to_markdown';
-const extractLanguage = (element) => element.firstElementChild?.getAttribute('lang');
+const extractLanguage = (element) => element.getAttribute('lang');
const ExtendedCodeBlockLowlight = CodeBlockLowlight.extend({
addAttributes() {
return {
- ...this.parent(),
+ language: {
+ default: null,
+ parseHTML: (element) => {
+ return {
+ language: extractLanguage(element),
+ };
+ },
+ },
/* `params` is the name of the attribute that
prosemirror-markdown uses to extract the language
of a codeblock.
@@ -19,8 +27,16 @@ const ExtendedCodeBlockLowlight = CodeBlockLowlight.extend({
};
},
},
+ class: {
+ default: 'code highlight js-syntax-highlight',
+ },
};
},
+ renderHTML({ HTMLAttributes }) {
+ return ['pre', HTMLAttributes, ['code', {}, 0]];
+ },
+}).configure({
+ lowlight,
});
export const tiptapExtension = ExtendedCodeBlockLowlight;