Use placeholders instead of a default value for comments

This commit is contained in:
Paul Kaplan 2019-07-29 14:40:57 -04:00
parent ef1de26862
commit c72e6934b4
4 changed files with 9 additions and 3 deletions

View file

@ -292,7 +292,7 @@ Blockly.ContextMenu.blockCommentOption = function(block) {
// If there's no comment, add an option to create a comment.
commentOption.text = Blockly.Msg.ADD_COMMENT;
commentOption.callback = function() {
block.setCommentText(Blockly.Msg.WORKSPACE_COMMENT_DEFAULT_TEXT);
block.setCommentText('');
};
}
return commentOption;
@ -468,8 +468,7 @@ Blockly.ContextMenu.workspaceCommentOption = function(ws, e) {
disabled = true;
}
var comment = new Blockly.WorkspaceCommentSvg(
ws, Blockly.Msg.WORKSPACE_COMMENT_DEFAULT_TEXT,
Blockly.WorkspaceCommentSvg.DEFAULT_SIZE,
ws, '', Blockly.WorkspaceCommentSvg.DEFAULT_SIZE,
Blockly.WorkspaceCommentSvg.DEFAULT_SIZE, false);
var injectionDiv = ws.getInjectionDiv();

View file

@ -695,6 +695,11 @@ Blockly.Css.CONTENT = [
'overflow: hidden;',
'}',
'.scratchCommentTextarea::placeholder {',
'color: rgba(0,0,0,0.5);',
'font-style: italic;',
'}',
'.scratchCommentResizeSE {',
'cursor: se-resize;',
'fill: transparent;',

View file

@ -227,6 +227,7 @@ Blockly.ScratchBlockComment.prototype.createEditor_ = function() {
textarea.className = 'scratchCommentTextarea scratchCommentText';
textarea.setAttribute('dir', this.block_.RTL ? 'RTL' : 'LTR');
textarea.setAttribute('maxlength', Blockly.ScratchBlockComment.COMMENT_TEXT_LIMIT);
textarea.setAttribute('placeholder', Blockly.Msg.WORKSPACE_COMMENT_DEFAULT_TEXT);
body.appendChild(textarea);
this.textarea_ = textarea;
this.textarea_.style.margin = (Blockly.ScratchBlockComment.TEXTAREA_OFFSET) + 'px';

View file

@ -183,6 +183,7 @@ Blockly.WorkspaceCommentSvg.prototype.createEditor_ = function() {
textarea.className = 'scratchCommentTextarea scratchCommentText';
textarea.setAttribute('dir', this.RTL ? 'RTL' : 'LTR');
textarea.setAttribute('maxlength', Blockly.WorkspaceComment.COMMENT_TEXT_LIMIT);
textarea.setAttribute('placeholder', Blockly.Msg.WORKSPACE_COMMENT_DEFAULT_TEXT);
body.appendChild(textarea);
this.textarea_ = textarea;
this.textarea_.style.margin = (Blockly.WorkspaceCommentSvg.TEXTAREA_OFFSET) + 'px';