Persist comment state.

This commit is contained in:
Karishma Chadha 2018-06-01 18:10:25 -04:00
parent ac91d8af65
commit 522706ccf8
2 changed files with 96 additions and 2 deletions

View file

@ -2,6 +2,7 @@ const EventEmitter = require('events');
const Blocks = require('./blocks');
const Variable = require('../engine/variable');
const Comment = require('../engine/comment');
const uid = require('../util/uid');
const {Map} = require('immutable');
const log = require('../util/log');
@ -190,6 +191,30 @@ class Target extends EventEmitter {
}
}
/**
* Creates a comment with the given properties.
* @param {string} id Id of the comment.
* @param {string} blockId Optional id of the block the comment is attached
* to if it is a block comment.
* @param {string} text The text the comment contains.
* @param {number} x The x coordinate of the comment on the workspace.
* @param {number} y The y coordinate of the comment on the workspace.
* @param {number} width The width of the comment when it is full size
* @param {number} height The height of the comment when it is full size
* @param {boolean} minimized Whether the comment is minimized.
*/
createComment (id, blockId, text, x, y, width, height, minimized) {
if (!this.comments.hasOwnProperty(id)) {
const newComment = new Comment(id, text, x, y,
width, height, minimized);
if (blockId) {
newComment.blockId = blockId;
this.blocks.getBlock(blockId).comment = id;
}
this.comments[id] = newComment;
}
}
/**
* Renames the variable with the given id to newName.
* @param {string} id Id of renamed variable.