basecamp / basecamp/trix

toJSON/fromJSON doesn't work on document

Open
#942 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
20k
Forks
1.1k
Avg merge
3d 12h
Merged PRs (30d)
13

Description

The ```toJSON``` and ```fromJSON``` methods on ```Trix.Document``` seem to be broken.

As an example look at this screenshot:
image
*Note: Loading ```doc1``` results to garbage in the editor.*

This also breaks ```editor.toJSON()``` and ```editor.fromJSON()``` as these methods rely on the document methods.

It might be intentional, but it clearly should be.

##### Steps to Reproduce

1. Type something into Trix
2. Open the console
3. Type ```var editor = document.querySelector("trix-editor").editor```
4. Type ```Trix.Document.fromJSON(editor.getDocument().toJSON())```
5. Look at the produced object or try to load it into the editor (which should produce garbage)

##### Details

* Trix version: master
* Browser name and version: FireFox 94 using the local test setup
* Operating system: macOS Catalina 10.15.7

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with Trix.Document.toJSON and Trix.Document.fromJSON, then trace editor.toJSON() and editor.fromJSON(), which depend on them. Reproduce the issue using the console steps and verify that serializing and restoring editor.getDocument() preserves the document instead of producing garbage.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.