code
code copied to clipboard
Characters are replaced by HTML entities
In v2.4.1, reserved HTML characters like <>& are replaced by HTML entities on saving data.
Here's a code sandbox to quickly reproduce the issue: https://codesandbox.io/s/peaceful-dhawan-wz02y?file=/index.js
Steps to reproduce:
- Create code block
- Type reserved HTML characters like "<>&"
- Click on "Save and load"
The code block's content changes and displays the HTML entities of the characters.
Fixed in #20
Is there any workaround till next release??
You can use this code for getting it fixed, call it after save block returns the data
fixCodeBlocks(blocks) {
let codeBlockIndex = 0;
const els = document.getElementsByClassName('ce-code__textarea') as any || [];
blocks.map(x => {
if (x.type === 'code') {
x.data.code = els[codeBlockIndex++].value
}
return x;
})
return blocks;
}