josdejong / jsoneditor

A web-based tool to view, edit, format, and validate JSON
http://jsoneditoronline.org
Apache License 2.0
11.63k stars 2.04k forks source link

Tree mode paste problem #1259

Open zhangjin747 opened 3 years ago

zhangjin747 commented 3 years ago

In the tree mode, after paste plain text in fields, the pasted text was wrapped by a 'span' element and it cause the text cannot be selected or insert cursor. Atfer tesing several versions, I found the problem happens since version 8.6.7, previous version works fine.

<div contenteditable="true" spellcheck="false" class="jsoneditor-value jsoneditor-string jsoneditor-color-value" title>
    <span>gold</span>
</div>
josdejong commented 3 years ago

Thanks for reporting @zhangjin747. How can I reproduce this issue exactly? And what browser are you using?

zhangjin747 commented 3 years ago

@josdejong You just need to copy some text from key or value field and paste it to another field in tree mode. And then, the cursor can not be inserted between letters. I'm using the latest Microsoft Edge browser based on Chromium.

josdejong commented 3 years ago

Hm I've tried on Edge but am not able to reproduce this. Can it be related to specific locales or keyboard inputs?

zhangjin747 commented 3 years ago

@josdejong I have figured out the problem. What I have copied seems to be formatted text(although it looks just like plain text) and if I use paste as plain text, everything works fine. In the older version, the formatted text will be converted to plain text on blur, but in the latest version, it won't happen. I don't know if this is a bug.

josdejong commented 3 years ago

Ahh, that helps a lot. Looking at the history, it may be related to the fix made in v8.6.8 in the following commit: https://github.com/josdejong/jsoneditor/commit/ad021ec7afa65da05f347b40b783947eab82abbd.

Without being able to reproduce this myself I'm not sure though how to create a fix for the issue you encounter. Any ideas?