-
Notifications
You must be signed in to change notification settings - Fork 40
Internal: Changed the way of data serialization. #1493
Conversation
src/model/position.js
Outdated
@@ -915,7 +926,7 @@ export default class Position { | |||
*/ | |||
static fromJSON( json, doc ) { | |||
if ( json.root === '$graveyard' ) { | |||
const pos = new Position( doc.graveyard, json.path ); | |||
const pos = new Position( doc.graveyard, Array.from( json.path ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be removed.
result[ attr[ 0 ] ] = attr[ 1 ]; | ||
|
||
return result; | ||
}, {} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Other: Make `toJSON()` to serialize nested objects. Closes #1477.
/** | ||
* @inheritDoc | ||
*/ | ||
toJSON() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder here... Theoretically, values could be arrays or objects. Will those be cloned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW... maybe we should just give up that and allow only for string, numeral and boolean values for attributes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔I'm afraid in a case of objects we pass a reference to the value instead of cloning.
return new AttributeOperation( this.range, this.key, this.oldValue, this.newValue, this.baseVersion ); |
We can think about dropping other formats than primitives but we don't know if someone has already used it with objects or arrays.
|
||
json.position = this.position.toJSON(); | ||
|
||
if ( json.graveyardPosition ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap operation can have graveyard position or element. Shouldn't we do json.element = this.element.toJSON()
?
Suggested merge commit message (convention)
Internal: Changed the way of data serialization. Closes ckeditor/ckeditor5#4392.
Additional information
For example – encountered issues, assumptions you had to make, other affected tickets, etc.