Merge branch 'fix-code-block-linefeed' into development

This commit is contained in:
Dan Brown 2022-02-06 15:19:52 +00:00
commit 2732d8961f
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9

View file

@ -136,18 +136,14 @@ function codePlugin() {
const selectedNode = editor.selection.getNode();
if (!elemIsCodeBlock(selectedNode)) {
const providedCode = editor.selection.getNode().textContent;
const providedCode = editor.selection.getContent({format: 'text'});
window.components.first('code-editor').open(providedCode, '', (code, lang) => {
const wrap = document.createElement('div');
wrap.innerHTML = `<pre><code class="language-${lang}"></code></pre>`;
wrap.querySelector('code').innerText = code;
editor.formatter.toggle('pre');
const node = editor.selection.getNode();
editor.dom.setHTML(node, wrap.querySelector('pre').innerHTML);
editor.fire('SetContent');
editor.focus()
editor.insertContent(wrap.innerHTML);
editor.focus();
});
return;
}