question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OutputData is wrongly manipulated and does not match expected output

See original GitHub issue

Current Setup

Documented and prepared in this codesandbox example.

Note: It doesn’t matter if this is tested with or without react (I’ve prepared both, see links below)

Current Setup

Let’s assume I’ve a the following data object:

export const data = {
  blocks: [
    {
      type: 'header',
      data: {
        text: 'Editor.js',
        level: 2,
      },
    },
    {
      type: 'react',
      data: {
        url: 'remote.adjust.rotate=0&remote.size.w=5575&remote.size.h=3717',
      },
    },
  ],
}

When passing this later on to EditorJS everything works fine (note: tested in a react setup, but it does not really matter if it’s plain js or not).

Current Problem

When I now get the data from the editor with await editor.save() the data is corrupt and looks like this:

	{
      type: 'react',
      data: {
        url: 'remote.adjust.rotate=0&remote.size.w=5575&remote.size.h=3717',
      },
    },

remote.adjust.rotate=0& vs. remote.adjust.rotate=0&remote... 😕

This only happens since @editorjs/editorjs@2.17.0 in the latest 2.16 release everything works still (see codesandbox with 2.16.1).

Example Apps

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
gohaberegcommented, Mar 23, 2020

Hi @natterstefan

Thanks for the reminder 😃

A method that sanitizes blocks after save called is here — https://github.com/codex-team/editor.js/blob/master/src/components/modules/sanitizer.ts#L59

As you can see, if there is no sanitize config of any kind, it returns data as it is. But the problem is there is always sanitize config for inline-tools as this method appends br and wbr tags (2.17 changes).

The solution is actually simple — if a tool doesn’t provide inlineToolbar option, return an empty object from getInlineToolsConfig.

The second step would be to decode HTML entities after sanitize, but as we include inline tags to Editor’s output, it would break the markup

1reaction
gohaberegcommented, Mar 20, 2020

Hi @natterstefan Thanks for the report! It seems we need to escape entities after saving as html-janitor inserts data to temp DOM nodes on sanitizing

Read more comments on GitHub >

github_iconTop Results From Across the Web

Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >
dplyr Tutorial : Data Manipulation (50 Examples) - ListenData
LEFT JOIN : It returns all rows from the left table, even if there are no matches in the right table. left_join(df1, df2,...
Read more >
API Testing Tips | How To Test APIs - Katalon
Here are the 10 basic tips that you need to know for API testing. ... that the API returns an appropriate response when...
Read more >
SUGI 27: Tips for Manipulating Data - SAS Support
To place the OBS= option on the input data set can result in an output data set containing 0 to 5 observations, depending...
Read more >
What is Data Flow Diagram? - Visual Paradigm
Also known as DFD, Data flow diagrams are used to graphically represent the ... of DFD mistakes arise when the outputs from one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found