DRAWING OBJECT EDIT

Commands for manipulating drawing objects — images, videos, shapes, and layers — via editor.execCommand.

Commands


command - changeDrawingObjectProperties

Sets properties on the currently selected drawing object.

NameTypeDescription
actionNamestringAction name
propertiesobject{ style: object }
// Border
editor.execCommand('changeDrawingObjectProperties', {
  style: { border: { style: 'solid', width: 3, color: { r: 255, g: 0, b: 0 } } }
});

// Float
editor.execCommand('changeDrawingObjectProperties', {
  style: { float: 'left' }    // 'none' | 'left' | 'right'
});

// Margin
editor.execCommand('changeDrawingObjectProperties', {
  style: { margin: { left: 10, right: 10, top: 10, bottom: 10 } }
});

// Vertical align
editor.execCommand('changeDrawingObjectProperties', {
  style: { verticalAlign: 'top' }   // 'top' | 'middle' | 'bottom' | 'baseline'
});

// Width / height
editor.execCommand('changeDrawingObjectProperties', {
  style: { width: { value: 100, unit: 'px' }, height: { value: 100, unit: 'px' } }
});

command - insertDrawingObject

Inserts an image or video at the caret position. If a selection exists, the selection is removed first. The inserted file is uploaded to the server.

See: Import & Upload API.

NameTypeDescription
actionNamestringAction name
filesFile[]Files to upload
typestring'Image' or 'Video'
editor.execCommand('insertDrawingObject', [file], 'Image');
editor.execCommand('insertDrawingObject', [file], 'Video');

command - insertDrawingObjectAlt

Sets the alt text on the selected image.

NameTypeDescription
actionNamestringAction name
altstringAlt text
editor.execCommand('insertDrawingObjectAlt', 'Alternative text for the image');

command - insertDrawingObjectByURL

Inserts an image or video from a URL at the caret position. If a selection exists, it is removed first.

NameTypeDescription
actionNamestringAction name
urlstringURL of the image/video to insert
typestring'Image' or 'Video'
editor.execCommand('insertDrawingObjectByURL', 'https://image.url/image', 'Image');

command - insertDrawingObjectCaption

Inserts a caption on the selected image.

NameTypeDescription
actionNamestringAction name
captionstringCaption text
editor.execCommand('insertDrawingObjectCaption', 'Image caption');

command - moveAbsolutePositionDrawingObject

Moves the currently selected absolute-position image, video, layer, or shape.

NameTypeDescription
actionNamestringAction name
movePositionobject{ x: Number, y: Number } — destination
editor.execCommand('moveAbsolutePositionDrawingObject', { x: 100, y: 100 });

command - moveDrawingObject

Moves the currently selected image, video, or table.

NameTypeDescription
actionNamestringAction name
xnumberDestination x
ynumberDestination y
isFinishbooleanWhether the move is finished (recommended: true)
editor.execCommand('moveDrawingObject', 100, 100, true);

command - removeDrawingObject

Deletes the currently selected image or shape.

NameTypeDescription
actionNamestringAction name
editor.execCommand('removeDrawingObject');

command - resizeDrawingObject

Resizes the currently selected image, video, or shape.

NameTypeDescription
actionNamestringAction name
[parentWidth]number
[width]numberTarget width (px)
[height]numberTarget height (px)
[left]numberLeft coordinate (for absolute-position objects)
[top]numberTop coordinate (for absolute-position objects)
editor.execCommand('resizeDrawingObject', null, 200, 100, null, null);   // set width=200, height=100
editor.execCommand('resizeDrawingObject', null, null, null, 200, 100);   // set left=200, top=100

command - rotateDrawingObjectLeft

Rotates the currently selected image or shape 90° counter-clockwise.

NameTypeDescription
actionNamestringAction name
editor.execCommand('rotateDrawingObjectLeft');

command - rotateDrawingObjectRight

Rotates the currently selected image or shape 90° clockwise.

NameTypeDescription
actionNamestringAction name
editor.execCommand('rotateDrawingObjectRight');

command - setDrawingObjectBackground

Sets the background color of the selected layer.

NameTypeDescription
actionNamestringAction name
colorCodestringHex color (e.g. '#ff0000')
editor.execCommand('setDrawingObjectBackground', '#ff0000');

command - setDrawingObjectBorderColor

Sets the border color of the selected image, video, or layer.

NameTypeDescription
actionNamestringAction name
colorCodestringHex color (e.g. '#ff0000')
editor.execCommand('setDrawingObjectBorderColor', '#ff0000');

command - setDrawingObjectBorderStyle

Sets the border style of the selected image, video, or layer.

NameTypeDescription
actionNamestringAction name
stylestring'none', 'solid', 'dashed', 'dotted', 'double'
editor.execCommand('setDrawingObjectBorderStyle', 'none');
editor.execCommand('setDrawingObjectBorderStyle', 'solid');

command - setDrawingObjectBorderWidth

Sets the border width of the selected image, video, or layer.

NameTypeDescription
actionNamestringAction name
widthnumberBorder width in pixels
editor.execCommand('setDrawingObjectBorderWidth', 3);

command - zoomDrawingObject

Increases or decreases the width and/or height of the selected image or video.

NameTypeDescription
actionNamestringAction name
isWidthbooleanWhether to change width
isHeightbooleanWhether to change height
zoomnumberDelta in pixels (negative to shrink)
editor.execCommand('zoomDrawingObject', true,  false, 10);   // width +10px
editor.execCommand('zoomDrawingObject', false, true,  10);   // height +10px
editor.execCommand('zoomDrawingObject', true,  true,  -10);  // both -10px