Skip to content

Latest commit

 

History

History
81 lines (59 loc) · 2.39 KB

File metadata and controls

81 lines (59 loc) · 2.39 KB

Code ⇐ Shape

Implements Code shape which renders the highlighted code at specified point.

Kind: global class
Extends: Shape
Since: 1.0.0

new Code(cursor, [options])

Create Code shape.

Param Type Description
cursor Cursor Cursor instance
[options] Object Options object
[options.code] String Code fragment that you want to show

Example

Code.create(cursor, {
  code: 'console.log('Your code here');'
});

code.getCode() ⇒ String

Get current code from shape.

Kind: instance method of Code

code.setCode([code]) ⇒ Shape

Set new code to this shape.

Kind: instance method of Code

Param Type Default
[code] String ''

code.getWidth() ⇒ Number

Returns actual width of the shape. Since code shape hasn't specified width, we need to override default. It looks for the longest line in your shape and returns its length.

Kind: instance method of Code

code.getHeight() ⇒ Number

Returns actual height of the shape. Since code shape hasn't specified height, we need to override default. It returns count of lines in our shape.

Kind: instance method of Code

code.render() ⇒ Text

Render the shape based on options.

Kind: instance method of Code

code.toObject() ⇒ Object

Overrides default toObject() method because we have new fields here.

Kind: instance method of Code