...
| 이벤트 타입 | 설명 |
|---|
| ON_SYNC | - 실시간 협업이 연결되었을 때 발생합니다.
- 리스너의 parameter로 전달되는 값:
| Name | Type | Description |
|---|
| event | Object |
| Code Block |
|---|
| {
setForceUpdate: (update: boolean) => void
} |
- setForceUpdate(update): 실시간 협업 모델을 현재 에디터에 작성된 모델로 강제로 업데이트할지 여부를 설정합니다.
|
| Code Block |
|---|
| language | js |
|---|
| theme | Emacs |
|---|
| title | example |
|---|
| var editor = new SynapEditor(id, synapEditorConfig);
var collaboration = editor.plugins.collaboration;
var EVENT_TYPE = collaboration.EVENT_TYPE;
collaboration.on(EVENT_TYPE.ON_SYNC, function (event) {
event.setForceUpdate(true);
}); |
|
| USER_CHANGED | - 접속 중인 사용자 수가 변경되었을 때 발생합니다.
- 리스너의 parameter로 전달되는 값:
| Name | Type | Description |
|---|
| users | Object[] | 접속 중인 사용자 목록 배열입니다. | Code Block |
|---|
| [
{ id: {number}, name: {string}, color: {string}, data: {Object}, position: {Position}, modified: {number}, self: {boolean} },
....
] |
- id: 사용자의 Client Id
- name: 사용자의 이름
- color: 사용자 색
- data: 사용자 데이터
- position: 사용자의 커서 위치 정보
- modified: 마지막으로 업데이트된 시간 timestamp
- self: 사용자가 나 인지 여부
| | added | number[] | 추가된 사용자의 Client Id 배열입니다. | | removed | number[] | 제거된 사용자의 Client Id 배열입니다. |
| Code Block |
|---|
| language | js |
|---|
| theme | Emacs |
|---|
| title | example |
|---|
| var editor = new SynapEditor(id, synapEditorConfig);
var collaboration = editor.plugins.collaboration;
var EVENT_TYPE = collaboration.EVENT_TYPE;
collaboration.on(EVENT_TYPE.USER_CHANGED, function (users, added, removed) {}); |
|
| USER_INFO_CHANGED | - 접속 중인 사용자의 이름, 색, 커서 위치 정보가 변경되거나 사용자 수가 변경되었을 때 발생합니다.
- 리스너의 parameter로 전달되는 값:
| Name | Type | Description |
|---|
| users | Object[] | 접속 중인 사용자 목록 배열입니다. | Code Block |
|---|
| [
{ id: {number}, name: {string}, color: {string}, data{Object}, position: {Position}, modified: {number}, self: {boolean} },
....
] |
- id: 사용자의 Client Id
- name: 사용자의 이름
- color: 사용자 색
- data: 사용자 데이터
- position: 사용자의 커서 위치 정보
- modified: 마지막으로 업데이트된 시간 timestamp
- self: 사용자가 나 인지 여부
|
| Code Block |
|---|
| language | js |
|---|
| theme | Emacs |
|---|
| title | example |
|---|
| var editor = new SynapEditor(id, synapEditorConfig);
var collaboration = editor.plugins.collaboration;
var EVENT_TYPE = collaboration.EVENT_TYPE;
collaboration.on(EVENT_TYPE.USER_INFO_CHANGED, function (users) {}); |
|
| DOCUMENT_UPDATED | | Status |
|---|
| colour | Yellow |
|---|
| title | 릴리즈 3.0.2404 이상 |
|---|
|
- 문서에 변경사항이 생겼을 때 발생합니다.
- 리스너의 parameter로 전달되는 값:
| Name | Type | Description |
|---|
| user | Object[] | 문서를 변경한 사용자 정보입니다. | Code Block |
|---|
| {
id: {number}, name: {string}, color: {string}, self: {boolean}
} |
- id: 사용자의 Client Id
- name: 사용자의 이름
- color: 사용자 색
- self: 사용자가 나 인지 여부
|
| Code Block |
|---|
| language | js |
|---|
| theme | Emacs |
|---|
| title | example |
|---|
| var editor = new SynapEditor(id, synapEditorConfig);
var collaboration = editor.plugins.collaboration;
var EVENT_TYPE = collaboration.EVENT_TYPE;
collaboration.on(EVENT_TYPE.DOCUMENT_UPDATED, function (user) {}); |
|
on(eventType, listener)
Collaboration 플러그인에서 발생하는 이벤트에 대한 리스너를 설정합니다.
...
parameters:
| Name | Type | Description |
|---|
| namecolor | string | 설정할 사용자의 색입니다. |
| Code Block |
|---|
| language | js |
|---|
| theme | Emacs |
|---|
| title | example |
|---|
|
var editor = new SynapEditor(id, synapEditorConfig);
var collaboration = editor.plugins.collaboration;
collaboration.setUserNamesetUserColor('#39b6b8'); |
setUserData(data)
...
parameters:
| Name | Type | Description |
|---|
| namedata | Object | 필요한 사용자 정보를 저장합니다. |
| Code Block |
|---|
| language | js |
|---|
| theme | Emacs |
|---|
| title | example |
|---|
|
var editor = new SynapEditor(id, synapEditorConfig);
var collaboration = editor.plugins.collaboration;
collaboration.setUserData({ userId: 'userId', connected: Date.now() }); |
...
| Code Block |
|---|
| language | js |
|---|
| theme | Emacs |
|---|
| title | example |
|---|
|
var editor = new SynapEditor(id, synapEditorConfig);
var collaboration = editor.plugins.collaboration;
collaboration.changeDocument('newDocumentId'); |
destroy()
현재 사용자의 실시간 협업을 종료합니다.
| Code Block |
|---|
| language | js |
|---|
| theme | Emacs |
|---|
| title | example |
|---|
|
var editor = new SynapEditor(id, synapEditorConfig);
var collaboration = editor.plugins.collaboration;
collaboration.destroy(); |
...
| Type | Description |
|---|
| Object |
| Code Block |
|---|
| language | js |
|---|
| theme | Emacs |
|---|
| title | example |
|---|
| {
original: {string},
versions: [
{
data: {string},
modified: {number},
user: {
id: {number},
name: {string}
}
},
...
]
} |
- original: 업데이트 기록이 시작된 에디터 모델의 JSON String 입니다.
- versions: 업데이트 기록입니다. 최대 100개 까지 유지됩니다.
- data: 변경이 된 이후의 에디터 모델 JSON String 입니다.
- modified: 변경이 일어난 클라이언트 시간 timestamp 입니다.
- user: 변경을 한 사용자의 id, name 정보 입니다.
| Status |
|---|
| |
|---|
| colour | Yellow |
|---|
| title | 릴리즈 3.1.0 이상 |
|---|
|
| Code Block |
|---|
| language | js |
|---|
| theme | Emacs |
|---|
| title | example |
|---|
| [
{
modified: {number},
rootModified: {boolean},
snapshot: {Unit8Array},
user: {
id: {number},
name: {string},
color: {string}
}
},
...
] |
- modified: 변경이 일어난 클라이언트 시간 timestamp 입니다.
- rootModified: 문서의 root(body)영역이 수정되었는지 여부입니다.
- snapshot: 변경이 된 이후의 에디터 모델 snapshot 입니다.
- user: 변경을 한 사용자의 id, name 정보 입니다.
|
| Code Block |
|---|
| language | js |
|---|
| theme | Emacs |
|---|
| title | example |
|---|
|
var editor = new SynapEditor(id, synapEditorConfig);
var collaboration = editor.plugins.collaboration;
var history = collaboration.getHistory(); |
updateHistoryOriginal(modelJSON) (deprecated)
| Warning |
|---|
|
3.1.0 버전부터 updateHistoryOriginal함수를 지원하지 않습니다. |
업데이트 기록의 원본 모델을 업데이트합니다.
parameter로 modelJSON을 넘기지 않은 경우 에디터의 현재 모델로 업데이트 합니다. 업데이트 기록 데이터의 versions 가 초기화 됩니다.
...