-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add serialization of basic block attributes to JSOs #5053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add serialization of basic block attributes to JSOs #5053
Conversation
51442e1 to
dfce263
Compare
| * @param {!Blockly.serialization.blocks.State} state The state object to append | ||
| * to. | ||
| */ | ||
| const addAttributes = function(block, state) { |
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.
Update private functions w/ whatever the preferred syntax is before merging.
| if (!block.isEnabled()) { | ||
| state['disabled'] = true; | ||
| } |
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.
Do we want to change this to be state['enabled'] to match the new API?
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.
In general I think 'enabled' flags are easier to understand than 'disabled' ones (and therefore preferable), but given that undefined is falsey there might be an argument to using disabled if 'enabled' is the default state allowing the flat to be omitted in most cases.
dfce263 to
38bb6d8
Compare
…ation#5053) * Add basic attribute tests * Add basic block serialization * Add more attribute tests * Change save to use options dictionary * Add obeying save options * Add test for data attribute * Add saving data tag * Move to ES6 syntax * Fixup move to es6 syntax * Declare module * Format and lint * Add docs * Add returning null on insertion markers * Fixup for move to module * Switch to other function declarations * Cleanup for finalized style * Fix lint and types * Export State def * Switch disabled=true to enabled=false
* Add basic attribute tests * Add basic block serialization * Add more attribute tests * Change save to use options dictionary * Add obeying save options * Add test for data attribute * Add saving data tag * Move to ES6 syntax * Fixup move to es6 syntax * Declare module * Format and lint * Add docs * Add returning null on insertion markers * Fixup for move to module * Switch to other function declarations * Cleanup for finalized style * Fix lint and types * Export State def * Switch disabled=true to enabled=false
…ation#5053) * Add basic attribute tests * Add basic block serialization * Add more attribute tests * Change save to use options dictionary * Add obeying save options * Add test for data attribute * Add saving data tag * Move to ES6 syntax * Fixup move to es6 syntax * Declare module * Format and lint * Add docs * Add returning null on insertion markers * Fixup for move to module * Switch to other function declarations * Cleanup for finalized style * Fix lint and types * Export State def * Switch disabled=true to enabled=false
* Add basic attribute tests * Add basic block serialization * Add more attribute tests * Change save to use options dictionary * Add obeying save options * Add test for data attribute * Add saving data tag * Move to ES6 syntax * Fixup move to es6 syntax * Declare module * Format and lint * Add docs * Add returning null on insertion markers * Fixup for move to module * Switch to other function declarations * Cleanup for finalized style * Fix lint and types * Export State def * Switch disabled=true to enabled=false
The basics
Link for Diff: BeksOmega/blockly@cereal/basic-hooks...BeksOmega:cereal/block-serialization
The details
Resolves
Work on project cereal
Dependent on #5052
Proposed Changes
Adds serialization of basic block attributes: type, id, x, y, collapsed, deletable, etc.
Does not serialize children, fields, mutators, or icons. Does not handle deserialization.
Reason for Changes
Serializing state is good.
Test Coverage
Added unit tests to make sure the serializer is returning an object with the structure we expect.