Skip to content
This repository was archived by the owner on Oct 4, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/monaco-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ var MonacoAdapter = function () {
*/
MonacoAdapter.prototype.registerUndo = function registerUndo(callback) {
if (typeof callback === 'function') {
this.callbacks.undo = callback;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

registerUndo is called once during initialisation, but internally monaco can change model. This is required to handle such scenario. Rest looks fine. Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think my approach is right as it can go out of sync and generate errors. Can you think of a way to solve this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am yet to test this out. I can look again then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Progyan1997 @adamjimenez just let me know when you two are satisfied with the solution here, this is beyond my knowledge of how Monaco works so I will defer to you.

this.monaco.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_Z, callback);
} else {
throw new Error('MonacoAdapter: registerUndo method expects a '
+ 'callback function in parameter');
Expand All @@ -285,7 +285,7 @@ var MonacoAdapter = function () {
*/
MonacoAdapter.prototype.registerRedo = function registerRedo(callback) {
if (typeof callback === 'function') {
this.callbacks.redo = callback;
this.monaco.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_Y, callback);
} else {
throw new Error('MonacoAdapter: registerRedo method expects a '
+ 'callback function in parameter');
Expand Down Expand Up @@ -498,7 +498,7 @@ var MonacoAdapter = function () {
* @param {Operation} operation - OT.js Operation Object
*/
MonacoAdapter.prototype.invertOperation = function invertOperation(operation) {
operation.invert(this.getValue());
operation.invert(this.monaco.getValue());
};

return MonacoAdapter;
Expand Down