Blockly. WorkspaceCommentSvg
Constructor
WorkspaceCommentSvg
new WorkspaceCommentSvg(workspace, content, height, width, opt_id)
Class for a workspace comment's SVG representation.
Parameter |
|
---|---|
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
- Implements
- Blockly.IBoundedElement
- Blockly.IBubble
- Blockly.ICopyable
Properties
DEFAULT_SIZE
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_
unknown
- Inherited from
- Blockly.WorkspaceComment#content_
id
unknown
- Inherited from
- Blockly.WorkspaceComment#id
- Implements
- Blockly.ICopyable#id
isComment
unknown
- Inherited from
- Blockly.WorkspaceComment#isComment
RTL
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_
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
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 |
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.
- Implements
- Blockly.IBubble#dispose
getBoundingRectangle
getBoundingRectangle() returns Blockly.utils.Rect
Returns the coordinates of a bounding box describing the dimensions of this comment. Coordinate system: workspace coordinates.
- Implements
- Blockly.IBoundedElement#getBoundingRectangle
- Returns
-
non-null Blockly.utils.Rect
Object with 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 Blockly.utils.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.
- Implements
- Blockly.IBubble#getRelativeToSurfaceXY
- Returns
-
non-null Blockly.utils.Coordinate
Object with .x and .y properties in workspace coordinates.
getSvgRoot
getSvgRoot() returns SVGElement
Return the root node of the SVG or null if none exists.
- Implements
- Blockly.IBubble#getSvgRoot
- Returns
-
non-null SVGElement
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 Blockly.utils.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(opt_noSelect)
Create and initialize the SVG representation of a workspace comment. May be called more than once.
Parameter |
|
---|---|
opt_noSelect |
Optional boolean Text inside text area will be selected if false |
isDeletable
isDeletable() returns boolean
Get whether this comment is deletable or not.
- Inherited from
- Blockly.WorkspaceComment#isDeletable
- Implements
- Blockly.IBubble#isDeletable
- Blockly.ICopyable#isDeletable
- Returns
-
True if deletable.
isEditable
isEditable() returns boolean
Get whether this comment is editable or not.
- Inherited from
- Blockly.WorkspaceComment#isEditable
- Returns
-
True if editable.
isMovable
isMovable() returns boolean
Get whether this comment is movable or not.
- Inherited from
- Blockly.WorkspaceComment#isMovable
- Implements
- Blockly.ICopyable#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 |
The surface that carries rendered items during a drag, or null if no drag surface is in use. |
newLoc |
The location to translate to, in workspace coordinates. Value must not be null. |
- Implements
- Blockly.IBubble#moveDuringDrag
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. |
- Implements
- Blockly.IBubble#moveTo
moveToDragSurface
moveToDragSurface()
Move this comment to its workspace's drag surface, accounting for positioning. Generally should be called at the same time as setDragging(true). Does nothing if useDragSurface_ is false.
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.
- Implements
- Blockly.ICopyable#select
setAutoLayout
setAutoLayout(_enable)
Set whether auto-layout of this bubble is enabled. The first time a bubble is shown it positions itself to not cover any blocks. Once a user has dragged it to reposition, it renders where the user put it.
Parameter |
|
---|---|
_enable |
boolean True if auto-layout should be enabled, false otherwise. |
- Implements
- Blockly.IBubble#setAutoLayout
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. |
- Implements
- Blockly.IBubble#setDeleteStyle
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. |
- Implements
- Blockly.IBubble#setDragging
setEditable
setEditable(editable)
Set whether this comment is editable or not.
Parameter |
|
---|---|
editable |
boolean True if editable. |
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
showContextMenu
showContextMenu(e)
Show the context menu for this workspace comment.
Parameter |
|
---|---|
e |
Event Mouse event. Value must not be null. |
- Implements
- Blockly.IBubble#showContextMenu
toCopyData
toCopyData() returns Blockly.ICopyable.CopyData
Encode a comment for copying.
- Implements
- Blockly.ICopyable#toCopyData
- Returns
-
non-null Blockly.ICopyable.CopyData
Copy metadata.
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.
- Implements
- Blockly.ICopyable#unselect
updateMovable
updateMovable()
Add or remove the UI indicating if this comment is movable or not.