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

package   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

package

unknown

Inherited from
Blockly.WorkspaceComment#isComment

RTL

protected

unknown

Inherited from
Blockly.WorkspaceComment#RTL

svgGroup_

non-null Element

svgGroup_

non-null Element

svgGroup_

non-null Element

svgGroup_

non-null Element

svgGroup_

non-null Element

svgGroup_

non-null Element

svgGroup_

non-null Element

svgGroup_

non-null Element

svgGroup_

non-null Element

svgGroup_

non-null Element

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

package   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

package

addFocus()

Focus this comment. Highlight it visually.

addSelect

package

addSelect()

Select this comment. Highlight it visually.

blurFocus

package

blurFocus()

Remove focus from the text area.

dispose

package

dispose()

Dispose of this comment.

getBoundingRectangle

package

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

package

getContent() returns string

Returns this comment's text.

Returns

string Comment text.

getHeight

package

getHeight() returns number

Get comment height.

Inherited from
Blockly.WorkspaceComment#getHeight
Returns

Comment height.

getHeightWidth

package

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

package

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

package

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

package

getWidth() returns number

Get comment width.

Inherited from
Blockly.WorkspaceComment#getWidth
Returns

Comment width.

getXY

package

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

package

initSvg()

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

isDeletable

package

isDeletable() returns boolean

Get whether this comment is deletable or not.

Inherited from
Blockly.WorkspaceComment#isDeletable
Returns

True if deletable.

isMovable

package

isMovable() returns boolean

Get whether this comment is movable or not.

Inherited from
Blockly.WorkspaceComment#isMovable
Returns

True if movable.

moveBy

package

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

package

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.

newLoc

goog.math.Coordinate

The location to translate to, in workspace coordinates.

Value must not be null.

moveTo

package

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

package

removeFocus()

Unfocus this comment. Remove its highlighting.

removeSelect

package

removeSelect()

Unselect this comment. Remove its highlighting.

render

package

render()

Renders the workspace comment.

select

package

select()

Select this comment. Highlight it visually.

setContent

package

setContent(content)

Set this comment's content.

Parameter

content

string

Comment content.

setDeletable

package

setDeletable(deletable)

Set whether this comment is deletable or not.

Parameter

deletable

True if deletable.

Inherited from
Blockly.WorkspaceComment#setDeletable

setDeleteStyle

package

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

package

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

package

setFocus()

Set the focus on the text area.

setHeight

package

setHeight(height)

Set comment height.

Parameter

height

Comment height.

Inherited from
Blockly.WorkspaceComment#setHeight

setMovable

package

setMovable(movable)

Set whether this comment is movable or not.

Parameter

movable

boolean

True if movable.

setWidth

package

setWidth(width)

Set comment width.

Parameter

width

comment width.

Inherited from
Blockly.WorkspaceComment#setWidth

toXml

package

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

package

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

package

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

package

unselect()

Unselect this comment. Remove its highlighting.

updateMovable

package

updateMovable()

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