Commit 550f64c1 authored by Enrique Alcantara's avatar Enrique Alcantara Committed by Mark Florian

Fix code block input rules

When inserting a code block using input rules,
the code block language is not saved

Changelog: fixed
parent 36495806
......@@ -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: {
default: 'code highlight js-syntax-highlight',
},
......
......@@ -51,7 +51,13 @@ const defaultSerializerConfig = {
nodes: {
[Blockquote.name]: defaultMarkdownSerializer.nodes.blockquote,
[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) => {
const { name } = node.attrs;
......
......@@ -25,7 +25,6 @@ describe('content_editor/extensions/code_block_highlight', () => {
expect(tiptapEditor.getJSON().content[0].attrs).toMatchObject({
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