Constructor

WorkspaceCommentSvg

new WorkspaceCommentSvg(workspace, content, height, width, opt_id)

Class for a workspace comment's SVG representation.

Parameter

workspace

Blockly.Workspace

The block's workspace.

Value must not be null.

content

string

The content of this workspace comment.

height

number

Height of the comment.

width

number

Width of the comment.

opt_id

Optional

string

Optional ID. Use this ID if provided, otherwise create a new ID.

Extends
Blockly.WorkspaceComment

Properties

DEFAULT_SIZE

static

number

The width and height to use to size a workspace comment when it is first added, before it has been edited by the user.

content_

protected

unknown

Inherited from
Blockly.WorkspaceComment#content_

id

unknown

Inherited from
Blockly.WorkspaceComment#id

isComment

unknown

Inherited from
Blockly.WorkspaceComment#isComment

RTL

protected

unknown

Inherited from
Blockly.WorkspaceComment#RTL

workspace

unknown

Inherited from
Blockly.WorkspaceComment#workspace

xy_

protected

unknown

The comment's position in workspace units. (0, 0) is at the workspace's origin; scale does not change this value.

Inherited from
Blockly.WorkspaceComment#xy_

Methods

fromXml

static

fromXml(xmlComment, workspace, opt_wsWidth) returns Blockly.WorkspaceCommentSvg

Decode an XML comment tag and create a rendered comment on the workspace.

Parameter

xmlComment

Element

XML comment element.

Value must not be null.

workspace

Blockly.Workspace

The workspace.

Value must not be null.

opt_wsWidth

Optional

number

The width of the workspace, which is used to position comments correctly in RTL.

Returns

non-null Blockly.WorkspaceCommentSvg The created workspace comment.

addFocus

addFocus()

Focus this comment. Highlight it visually.

addSelect

addSelect()

Select this comment. Highlight it visually.

blurFocus

blurFocus()

Remove focus from the text area.

dispose

dispose()

Dispose of this comment.

getBoundingRectangle

getBoundingRectangle() returns Object

Returns the coordinates of a bounding box describing the dimensions of this comment. Coordinate system: workspace coordinates.

Returns

non-null {topLeft: goog.math.Coordinate, bottomRight: goog.math.Coordinate} Object with top left and bottom right coordinates of the bounding box.

getContent

getContent() returns string

Returns this comment's text.

Returns

string Comment text.

getHeight

getHeight() returns number

Get comment height.

Inherited from
Blockly.WorkspaceComment#getHeight
Returns

comment height.

getHeightWidth

getHeightWidth() returns Object

Returns a bounding box describing the dimensions of this comment.

Returns

non-null {height: number, width: number} Object with height and width properties in workspace units.

getRelativeToSurfaceXY

getRelativeToSurfaceXY() returns goog.math.Coordinate

Return the coordinates of the top-left corner of this comment relative to the drawing surface's origin (0,0), in workspace units. If the comment is on the workspace, (0, 0) is the origin of the workspace coordinate system. This does not change with workspace scale.

Returns

non-null goog.math.Coordinate Object with .x and .y properties in workspace coordinates.

getSvgRoot

getSvgRoot() returns Element

Return the root node of the SVG or null if none exists.

Returns

Element The root SVG node (probably a group).

getWidth

getWidth() returns number

Get comment width.

Inherited from
Blockly.WorkspaceComment#getWidth
Returns

comment width.

getXY

getXY() returns goog.math.Coordinate

Get stored location.

Inherited from
Blockly.WorkspaceComment#getXY
Returns

The comment's stored location. This is not valid if the comment is currently being dragged.

initSvg

initSvg()

Create and initialize the SVG representation of a workspace comment. May be called more than once.

isDeletable

isDeletable() returns boolean

Get whether this comment is deletable or not.

Inherited from
Blockly.WorkspaceComment#isDeletable
Returns

True if deletable.

isMovable

isMovable() returns boolean

Get whether this comment is movable or not.

Inherited from
Blockly.WorkspaceComment#isMovable
Returns

True if movable.

moveBy

moveBy(dx, dy)

Move a comment by a relative offset.

Parameter

dx

number

Horizontal offset, in workspace units.

dy

number

Vertical offset, in workspace units.

moveDuringDrag

moveDuringDrag(dragSurface, newLoc)

Move this comment during a drag, taking into account whether we are using a drag surface to translate blocks.

Parameter

dragSurface

Blockly.BlockDragSurfaceSvg

The surface that carries rendered items during a drag, or null if no drag surface is in use.

Value may be null.

newLoc

goog.math.Coordinate

The location to translate to, in workspace coordinates.

Value must not be null.

moveTo

moveTo(x, y)

Move the bubble group to the specified location in workspace coordinates.

Parameter

x

number

The x position to move to.

y

number

The y position to move to.

removeFocus

removeFocus()

Unfocus this comment. Remove its highlighting.

removeSelect

removeSelect()

Unselect this comment. Remove its highlighting.

render

render()

Renders the workspace comment.

select

select()

Select this comment. Highlight it visually.

setContent

setContent(content)

Set this comment's content.

Parameter

content

string

Comment content.

setDeletable

setDeletable(deletable)

Set whether this comment is deletable or not.

Parameter

deletable

True if deletable.

Inherited from
Blockly.WorkspaceComment#setDeletable

setDeleteStyle

setDeleteStyle(enable)

Update the cursor over this comment by adding or removing a class.

Parameter

enable

boolean

True if the delete cursor should be shown, false otherwise.

setDragging

setDragging(adding)

Recursively adds or removes the dragging class to this node and its children.

Parameter

adding

boolean

True if adding, false if removing.

setFocus

setFocus()

Set the focus on the text area.

setHeight

setHeight(height)

Set comment height.

Parameter

height

comment height.

Inherited from
Blockly.WorkspaceComment#setHeight

setMovable

setMovable(movable)

Set whether this comment is movable or not.

Parameter

movable

boolean

True if movable.

setWidth

setWidth(width)

Set comment width.

Parameter

width

comment width.

Inherited from
Blockly.WorkspaceComment#setWidth

toXml

toXml(opt_noId) returns Element

Encode a comment subtree as XML, but don't serialize the XY coordinates. This method avoids some expensive metrics-related calls that are made in toXmlWithXY().

Parameter

opt_noId

Optional

True if the encoder should skip the comment id.

Inherited from
Blockly.WorkspaceComment#toXml
Returns

Tree of XML elements.

toXmlWithXY

toXmlWithXY(opt_noId) returns Element

Encode a comment subtree as XML with XY coordinates.

Parameter

opt_noId

Optional

boolean

True if the encoder should skip the comment id.

Returns

non-null Element Tree of XML elements.

translate

translate(x, y)

Transforms a comment by setting the translation on the transform attribute of the block's SVG.

Parameter

x

number

The x coordinate of the translation in workspace units.

y

number

The y coordinate of the translation in workspace units.

unselect

unselect()

Unselect this comment. Remove its highlighting.

updateMovable

updateMovable()

Add or remove the UI indicating if this comment is movable or not.