Commit 57917640 authored by Mark Florian's avatar Mark Florian

Merge branch 'fix-code-block-input-rule' into 'master'

Fix: Code block input rule doesn’t save the code block language

See merge request gitlab-org/gitlab!67980
parents f588c195 550f64c1
...@@ -14,18 +14,6 @@ export default CodeBlockLowlight.extend({ ...@@ -14,18 +14,6 @@ export default CodeBlockLowlight.extend({
}; };
}, },
}, },
/* `params` is the name of the attribute that
prosemirror-markdown uses to extract the language
of a codeblock.
https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.js#L62
*/
params: {
parseHTML: (element) => {
return {
params: extractLanguage(element),
};
},
},
class: { class: {
default: 'code highlight js-syntax-highlight', default: 'code highlight js-syntax-highlight',
}, },
......
...@@ -51,7 +51,13 @@ const defaultSerializerConfig = { ...@@ -51,7 +51,13 @@ const defaultSerializerConfig = {
nodes: { nodes: {
[Blockquote.name]: defaultMarkdownSerializer.nodes.blockquote, [Blockquote.name]: defaultMarkdownSerializer.nodes.blockquote,
[BulletList.name]: defaultMarkdownSerializer.nodes.bullet_list, [BulletList.name]: defaultMarkdownSerializer.nodes.bullet_list,
[CodeBlockHighlight.name]: defaultMarkdownSerializer.nodes.code_block, [CodeBlockHighlight.name]: (state, node) => {
state.write(`\`\`\`${node.attrs.language || ''}\n`);
state.text(node.textContent, false);
state.ensureNewLine();
state.write('```');
state.closeBlock(node);
},
[Emoji.name]: (state, node) => { [Emoji.name]: (state, node) => {
const { name } = node.attrs; const { name } = node.attrs;
......
...@@ -25,7 +25,6 @@ describe('content_editor/extensions/code_block_highlight', () => { ...@@ -25,7 +25,6 @@ describe('content_editor/extensions/code_block_highlight', () => {
expect(tiptapEditor.getJSON().content[0].attrs).toMatchObject({ expect(tiptapEditor.getJSON().content[0].attrs).toMatchObject({
language, language,
params: language,
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment