mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-28 22:30:40 -04:00
Persist comment state.
This commit is contained in:
parent
ac91d8af65
commit
522706ccf8
2 changed files with 96 additions and 2 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue