code icon indicating copy to clipboard operation
code copied to clipboard

Characters are replaced by HTML entities

Open polyrainbow opened this issue 6 years ago • 3 comments

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:

  1. Create code block
  2. Type reserved HTML characters like "<>&"
  3. Click on "Save and load"

The code block's content changes and displays the HTML entities of the characters.

polyrainbow avatar Apr 10 '20 15:04 polyrainbow

Fixed in #20

alcarazzam avatar Apr 18 '20 14:04 alcarazzam

Is there any workaround till next release??

gopumon avatar May 17 '20 18:05 gopumon

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;
}

erBhushanPawar avatar May 28 '20 05:05 erBhushanPawar