jdorn / json-editor

JSON Schema Based Editor
MIT License
5.81k stars 1.08k forks source link

Using SCEditor in an array is broken #751

Open roypardi opened 7 years ago

roypardi commented 7 years ago

I trying to use SCEditor in an array. It is functional when first loaded but when I try to load a data set using setValue()the SCEditor instance freezes. I've tried targeting the specific SCEditor instance and calling setValue() on that and it fails with that as well. No error to the console.

Searching the open issues there are a few related (e.g. #217 "WYSIWYG area is rendered unusable after saving inside the "Edit JSON" pop-up"). I don't know where the problem is – in SCEditor or in json-editor.

Has anyone got any suggestions on how to resolve this?

My test schema and data set is below. The schema defines one SCEditor in an array and one not in an array. The one not in an array behaves as expected when loading data.

Schema

       let editor = new JSONEditor(document.getElementById('editor_holder'),
            {
                "schema": {
                    "type": "object",
                    "properties": {
                        "test": {
                            "type": "string",
                            "format": "html",
                            "options": {
                                "wysiwyg": true
                            },
                            "default": ""
                        },
                        "events": {
                            "type": "array",
                            "minItems": 1,
                            "id": "event",
                            "format": "tabs",
                            "items": {
                                "type": "object",
                                "id": "event",
                                "description": "Event",
                                "properties": {
                                    "caption": {
                                        "id": "caption",
                                        "type": "string",
                                        "format": "html",
                                        "options": {
                                            "wysiwyg": true
                                        },
                                        "default": "something"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        );

Test data

{
    "test": "<p>\n\t<strong><span style=\"color: rgb(1, 255, 112); font-size: 24px;\">this is the test field</span></strong>\n</p>",
    "events": [
        {
            "caption": "<p>\n\t<strong><span style=\"color: rgb(240, 18, 190); font-size: 18px;\">This is the caption field</span></strong>\n</p>"
        }
    ]
}
roypardi commented 7 years ago

Wasn't able to solve this issue with SCEditor. I ended up using the Summernote changes as described here: #440 and that works fine.

vietsrc commented 7 years ago

someone need to resolve that branch