Skip to main content

Class: CommentView

Defined in: packages/blockly/core/comments/comment_view.ts:25

Implements​

Properties index​

PropertyDescription
disposingWhether this comment view is currently being disposed or not.
disposedWhether this comment view has been disposed or not.
defaultCommentSizeThe default size of newly created comments.
workspace-
commentId-

Methods index​

MethodDescription
getEditorFocusableNodeReturns the FocusableNode representing the editor portion of this comment.
getSvgRootReturns the root SVG group element of the comment view.
getSizeReturns the current size of the comment in workspace units. Respects collapsing.
setSizeWithoutFiringEventsSets the size of the comment in workspace units, and updates the view elements to reflect the new size.
setSizeSets the size of the comment in workspace units, updates the view elements to reflect the new size, and triggers size change listeners.
addSizeChangeListenerRegisters a callback that listens for size changes.
removeSizeChangeListenerRemoves the given listener from the list of size change listeners.
isCollapsedReturns true if the comment is currently collapsed.
setCollapsedSets whether the comment is currently collapsed or not.
addOnCollapseListenerRegisters a callback that listens for collapsed-ness changes.
removeOnCollapseListenerRemoves the given listener from the list of on collapse listeners.
isEditableReturns true if the comment is currently editable.
setEditableSets the editability of the comment.
getRelativeToSurfaceXYReturns the current location of the comment in workspace coordinates.
moveToMoves the comment view to the given location.
getTextReturns the current text of the comment.
setTextSets the current text of the comment.
setPlaceholderTextSets the placeholder text displayed for an empty comment.
addTextChangeListenerRegisters a callback that listens for text changes on the comment editor.
removeTextChangeListenerRemoves the given listener from the comment editor.
bringToFrontBrings the workspace comment to the front of its layer.
disposeDisposes of this comment view.
isDisposedReturns whether this comment view has been disposed or not.
isDeadOrDyingReturns true if this comment view is currently being disposed or has already been disposed.
addDisposeListenerRegisters a callback that listens for disposal of this view.
removeDisposeListenerRemoves the given listener from the list of disposal listeners.

Constructors​

Constructor​

new CommentView(workspace, commentId): CommentView;

Defined in: packages/blockly/core/comments/comment_view.ts:104

Parameters​

ParameterType
workspaceWorkspaceSvg
commentIdstring

Returns​

CommentView

Properties​

disposing​

protected disposing: boolean = false;

Defined in: packages/blockly/core/comments/comment_view.ts:93

Whether this comment view is currently being disposed or not.


disposed​

protected disposed: boolean = false;

Defined in: packages/blockly/core/comments/comment_view.ts:96

Whether this comment view has been disposed or not.


defaultCommentSize​

static defaultCommentSize: Size;

Defined in: packages/blockly/core/comments/comment_view.ts:102

The default size of newly created comments.


workspace​

readonly workspace: WorkspaceSvg;

Defined in: packages/blockly/core/comments/comment_view.ts:105


commentId​

readonly commentId: string;

Defined in: packages/blockly/core/comments/comment_view.ts:106

Methods​

getEditorFocusableNode()​

getEditorFocusableNode(): CommentEditor;

Defined in: packages/blockly/core/comments/comment_view.ts:250

Returns​

CommentEditor

The FocusableNode representing the editor portion of this comment.


getSvgRoot()​

getSvgRoot(): SVGGElement;

Defined in: packages/blockly/core/comments/comment_view.ts:279

Returns the root SVG group element of the comment view.

Returns​

SVGGElement

Implementation of​

IRenderedElement.getSvgRoot


getSize()​

getSize(): Size;

Defined in: packages/blockly/core/comments/comment_view.ts:287

Returns the current size of the comment in workspace units. Respects collapsing.

Returns​

Size


setSizeWithoutFiringEvents()​

setSizeWithoutFiringEvents(size): void;

Defined in: packages/blockly/core/comments/comment_view.ts:295

Sets the size of the comment in workspace units, and updates the view elements to reflect the new size.

Parameters​

ParameterType
sizeSize

Returns​

void


setSize()​

setSize(size): void;

Defined in: packages/blockly/core/comments/comment_view.ts:319

Sets the size of the comment in workspace units, updates the view elements to reflect the new size, and triggers size change listeners.

Parameters​

ParameterType
sizeSize

Returns​

void


addSizeChangeListener()​

addSizeChangeListener(listener): void;

Defined in: packages/blockly/core/comments/comment_view.ts:417

Registers a callback that listens for size changes.

Parameters​

ParameterTypeDescription
listener(oldSize, newSize) => voidReceives callbacks when the size of the comment changes. The new and old size are in workspace units.

Returns​

void


removeSizeChangeListener()​

removeSizeChangeListener(listener): void;

Defined in: packages/blockly/core/comments/comment_view.ts:422

Removes the given listener from the list of size change listeners.

Parameters​

ParameterType
listener() => void

Returns​

void


isCollapsed()​

isCollapsed(): boolean;

Defined in: packages/blockly/core/comments/comment_view.ts:496

Returns true if the comment is currently collapsed.

Returns​

boolean


setCollapsed()​

setCollapsed(collapsed): void;

Defined in: packages/blockly/core/comments/comment_view.ts:501

Sets whether the comment is currently collapsed or not.

Parameters​

ParameterType
collapsedboolean

Returns​

void


addOnCollapseListener()​

addOnCollapseListener(listener): void;

Defined in: packages/blockly/core/comments/comment_view.ts:525

Registers a callback that listens for collapsed-ness changes.

Parameters​

ParameterType
listener(newCollapse) => void

Returns​

void


removeOnCollapseListener()​

removeOnCollapseListener(listener): void;

Defined in: packages/blockly/core/comments/comment_view.ts:530

Removes the given listener from the list of on collapse listeners.

Parameters​

ParameterType
listener() => void

Returns​

void


isEditable()​

isEditable(): boolean;

Defined in: packages/blockly/core/comments/comment_view.ts:538

Returns true if the comment is currently editable.

Returns​

boolean


setEditable()​

setEditable(editable): void;

Defined in: packages/blockly/core/comments/comment_view.ts:543

Sets the editability of the comment.

Parameters​

ParameterType
editableboolean

Returns​

void


getRelativeToSurfaceXY()​

getRelativeToSurfaceXY(): Coordinate;

Defined in: packages/blockly/core/comments/comment_view.ts:556

Returns the current location of the comment in workspace coordinates.

Returns​

Coordinate


moveTo()​

moveTo(location): void;

Defined in: packages/blockly/core/comments/comment_view.ts:565

Moves the comment view to the given location.

Parameters​

ParameterTypeDescription
locationCoordinateThe location to move to in workspace coordinates.

Returns​

void


getText()​

getText(): string;

Defined in: packages/blockly/core/comments/comment_view.ts:574

Returns the current text of the comment.

Returns​

string


setText()​

setText(text): void;

Defined in: packages/blockly/core/comments/comment_view.ts:579

Sets the current text of the comment.

Parameters​

ParameterType
textstring

Returns​

void


setPlaceholderText()​

setPlaceholderText(text): void;

Defined in: packages/blockly/core/comments/comment_view.ts:584

Sets the placeholder text displayed for an empty comment.

Parameters​

ParameterType
textstring

Returns​

void


addTextChangeListener()​

addTextChangeListener(listener): void;

Defined in: packages/blockly/core/comments/comment_view.ts:589

Registers a callback that listens for text changes on the comment editor.

Parameters​

ParameterType
listener(oldText, newText) => void

Returns​

void


removeTextChangeListener()​

removeTextChangeListener(listener): void;

Defined in: packages/blockly/core/comments/comment_view.ts:594

Removes the given listener from the comment editor.

Parameters​

ParameterType
listener() => void

Returns​

void


bringToFront()​

bringToFront(): void;

Defined in: packages/blockly/core/comments/comment_view.ts:609

Brings the workspace comment to the front of its layer.

Returns​

void


dispose()​

dispose(): void;

Defined in: packages/blockly/core/comments/comment_view.ts:634

Disposes of this comment view.

Returns​

void


isDisposed()​

isDisposed(): boolean;

Defined in: packages/blockly/core/comments/comment_view.ts:646

Returns whether this comment view has been disposed or not.

Returns​

boolean


isDeadOrDying()​

isDeadOrDying(): boolean;

Defined in: packages/blockly/core/comments/comment_view.ts:654

Returns true if this comment view is currently being disposed or has already been disposed.

Returns​

boolean


addDisposeListener()​

addDisposeListener(listener): void;

Defined in: packages/blockly/core/comments/comment_view.ts:659

Registers a callback that listens for disposal of this view.

Parameters​

ParameterType
listener() => void

Returns​

void


removeDisposeListener()​

removeDisposeListener(listener): void;

Defined in: packages/blockly/core/comments/comment_view.ts:664

Removes the given listener from the list of disposal listeners.

Parameters​

ParameterType
listener() => void

Returns​

void