그리기 객체 편집
editor.execCommand를 통해 그리기 객체(이미지, 비디오, shape, 레이어)를 조작하는 명령어.
명령어
command - changeDrawingObjectPropertiescommand - insertDrawingObjectcommand - insertDrawingObjectAltcommand - insertDrawingObjectByURLcommand - insertDrawingObjectCaptioncommand - moveAbsolutePositionDrawingObjectcommand - moveDrawingObjectcommand - removeDrawingObjectcommand - resizeDrawingObjectcommand - rotateDrawingObjectLeftcommand - rotateDrawingObjectRightcommand - setDrawingObjectBackgroundcommand - setDrawingObjectBorderColorcommand - setDrawingObjectBorderStylecommand - setDrawingObjectBorderWidthcommand - zoomDrawingObject
command - changeDrawingObjectProperties
현재 선택된 그리기 객체에 속성을 설정합니다.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
properties | object | { 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
캐럿 위치에 이미지 또는 비디오를 삽입합니다. 선택 영역이 있으면 먼저 선택 영역이 제거됩니다. 삽입된 파일은 서버에 업로드됩니다.
참고: 임포트 & 업로드 API.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
files | File[] | 업로드할 파일 |
type | string | 'Image' 또는 'Video' |
editor.execCommand('insertDrawingObject', [file], 'Image');
editor.execCommand('insertDrawingObject', [file], 'Video');
command - insertDrawingObjectAlt
선택한 이미지에 대체 텍스트를 설정합니다.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
alt | string | 대체 텍스트 |
editor.execCommand('insertDrawingObjectAlt', 'Alternative text for the image');
command - insertDrawingObjectByURL
URL에서 이미지 또는 비디오를 캐럿 위치에 삽입합니다. 선택 영역이 있으면 먼저 제거됩니다.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
url | string | 삽입할 이미지/비디오의 URL |
type | string | 'image' 또는 'video' |
editor.execCommand('insertDrawingObjectByURL', 'https://image.url/image', 'Image');
command - insertDrawingObjectCaption
선택한 이미지에 캡션을 삽입합니다.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
caption | string | 캡션 텍스트 |
editor.execCommand('insertDrawingObjectCaption', 'Image caption');
command - moveAbsolutePositionDrawingObject
현재 선택된 절대 위치 이미지, 비디오, 레이어 또는 shape를 이동합니다.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
movePosition | object | { x: Number, y: Number } — 이동할 위치 |
editor.execCommand('moveAbsolutePositionDrawingObject', { x: 100, y: 100 });
command - moveDrawingObject
현재 선택된 이미지, 비디오 또는 표를 이동합니다.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
x | number | 이동할 x 좌표 |
y | number | 이동할 y 좌표 |
isFinish | boolean | 이동이 완료되었는지 여부 (권장: true) |
editor.execCommand('moveDrawingObject', 100, 100, true);
command - removeDrawingObject
현재 선택된 이미지 또는 shape를 삭제합니다.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
editor.execCommand('removeDrawingObject');
command - resizeDrawingObject
현재 선택된 이미지, 비디오 또는 shape의 크기를 조절합니다.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
[parentWidth] | number | 객체를 담은 영역(본문, 표 셀)의 너비(px). 객체 너비가 퍼센트일 때만 width 를 퍼센트로 바꾸는 기준 |
[width] | number | 변경할 너비 (px) |
[height] | number | 변경할 높이 (px) |
[left] | number | 왼쪽 좌표 (절대 위치 객체용) |
[top] | number | 위쪽 좌표 (절대 위치 객체용) |
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
현재 선택된 이미지 또는 shape를 반시계 방향으로 90° 회전합니다.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
editor.execCommand('rotateDrawingObjectLeft');
command - rotateDrawingObjectRight
현재 선택된 이미지 또는 shape를 시계 방향으로 90° 회전합니다.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
editor.execCommand('rotateDrawingObjectRight');
command - setDrawingObjectBackground
선택한 레이어의 배경색을 설정합니다.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
colorCode | string | 16진수 색상 (예: '#ff0000') |
editor.execCommand('setDrawingObjectBackground', '#ff0000');
command - setDrawingObjectBorderColor
선택한 이미지, 비디오 또는 레이어의 테두리 색상을 설정합니다.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
colorCode | string | 16진수 색상 (예: '#ff0000') |
editor.execCommand('setDrawingObjectBorderColor', '#ff0000');
command - setDrawingObjectBorderStyle
선택한 이미지, 비디오 또는 레이어의 테두리 스타일을 설정합니다.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
style | string | 'none', 'solid', 'dashed', 'dotted', 'double' |
editor.execCommand('setDrawingObjectBorderStyle', 'none');
editor.execCommand('setDrawingObjectBorderStyle', 'solid');
command - setDrawingObjectBorderWidth
선택한 이미지, 비디오 또는 레이어의 테두리 두께를 설정합니다.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
width | number | 테두리 두께(픽셀 단위) |
editor.execCommand('setDrawingObjectBorderWidth', 3);
command - zoomDrawingObject
선택한 이미지 또는 비디오의 너비나 높이를 늘리거나 줄입니다.
| 이름 | 타입 | 설명 |
|---|---|---|
actionName | string | 명령 이름 |
isWidth | boolean | 너비를 변경할지 여부 |
isHeight | boolean | 높이를 변경할지 여부 |
zoom | number | 픽셀 단위의 변화량(음수는 축소) |
editor.execCommand('zoomDrawingObject', true, false, 10); // width +10px
editor.execCommand('zoomDrawingObject', false, true, 10); // height +10px
editor.execCommand('zoomDrawingObject', true, true, -10); // both -10px