Synchronized editor for multiple files
This commit is contained in:

committed by
Sebastian Serth

parent
7df37078f4
commit
23a95d315d
@ -24,12 +24,12 @@ $(document).on('turbolinks:load', function () {
|
|||||||
received(data) {
|
received(data) {
|
||||||
// Called when there's incoming data on the websocket for this channel
|
// Called when there's incoming data on the websocket for this channel
|
||||||
if (current_user_id !== data['current_user_id']) {
|
if (current_user_id !== data['current_user_id']) {
|
||||||
CodeOceanEditor.applyChanges(data['delta']['data']);
|
CodeOceanEditor.applyChanges(data['delta']['data'], data['active_file']);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
send_changes(delta) {
|
send_changes(delta, active_file) {
|
||||||
const delta_with_user_id = {current_user_id: current_user_id, delta: delta}
|
const delta_with_user_id = {current_user_id: current_user_id, active_file: active_file, delta: delta}
|
||||||
this.perform('send_changes', {delta_with_user_id: delta_with_user_id});
|
this.perform('send_changes', {delta_with_user_id: delta_with_user_id});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -339,7 +339,7 @@ var CodeOceanEditor = {
|
|||||||
CodeOceanEditor.lastDeltaObject = null;
|
CodeOceanEditor.lastDeltaObject = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
App.synchronized_editor?.send_changes(deltaObject);
|
App.synchronized_editor?.send_changes(deltaObject, this.active_file);
|
||||||
|
|
||||||
// TODO: This is a workaround for a bug in Ace. Remove when upgrading Ace.
|
// TODO: This is a workaround for a bug in Ace. Remove when upgrading Ace.
|
||||||
this.handleUTF16Surrogates(deltaObject, session);
|
this.handleUTF16Surrogates(deltaObject, session);
|
||||||
@ -1022,9 +1022,10 @@ var CodeOceanEditor = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
applyChanges: function (delta) {
|
applyChanges: function (delta, active_file) {
|
||||||
this.lastDeltaObject = delta;
|
this.lastDeltaObject = delta;
|
||||||
this.editors[0].session.doc.applyDeltas([delta]);
|
const editor = this.editor_for_file.get(active_file.filename)
|
||||||
|
editor.session.doc.applyDeltas([delta]);
|
||||||
},
|
},
|
||||||
|
|
||||||
compareDeltaObjects: function (delta, last_delta) {
|
compareDeltaObjects: function (delta, last_delta) {
|
||||||
|
Reference in New Issue
Block a user