Skip to content

Commit

Permalink
make diff editor right side readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
blurymind committed Aug 8, 2024
1 parent 68003fe commit cab582a
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/public/plugins/plugin-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const editorOptions = {
tabSize: 2,
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
}
};
export var PluginEditor = function({
app,
createButton,
Expand All @@ -33,7 +33,9 @@ export var PluginEditor = function({
this.editingFile = '';
this.volatilePlugins = {};
this.gistPluginFiles = {};
this.mode = 'edit';
this.onSetPluginEditMode = mode => {
this.mode = mode;
setPluginStore(self.name, 'pluginEditMode', mode);
document
.querySelectorAll('#edit-plugin-mode > button')
Expand All @@ -48,7 +50,7 @@ export var PluginEditor = function({
document.getElementById('plugin-output-previewer').style.display =
mode === 'test' ? 'block' : 'none';

this.onSetEditingFile()
this.onSetEditingFile();
};
this.onOpenPluginEditor = async () => {
// ace-editor
Expand All @@ -69,27 +71,23 @@ export var PluginEditor = function({
this.editor.setValue(fileContents);
this.editor.clearSelection();
beautify.beautify(this.editor.session);



getGistPluginFiles().then(gistPluginFiles => {
const gistPluginFile = gistPluginFiles.find(
item => item.filename == fileName
);
console.log({ gistPluginFile }, this.differ.getEditors());
fileContents = this.editor.getValue()
fileContents = this.editor.getValue();
this.differ
.getEditors().left
.getSession()
.getEditors()
.left.getSession()
.setValue(fileContents);

// beautify.beautify(this.differ
// .getEditors().left.session);

this.differ
.getEditors().right
.getSession()
.getEditors()
.right.getSession()
.setValue(gistPluginFile.content);
this.differ.getEditors().right.setReadOnly(this.mode === 'commit');
});
});
};
Expand Down Expand Up @@ -176,15 +174,15 @@ export var PluginEditor = function({

const onChangeFromDiffDebounced = app.utils.debounce(() => {
setVloatilePlugin(this.editingFile, {
content: this.differ
.getEditors().left.getValue(),
content: this.differ.getEditors().left.getValue(),
});
}, 600);
this.differ
.getEditors().left
.getSession().on('change', function() {
onChangeFromDiffDebounced();
});
.getEditors()
.left.getSession()
.on('change', function() {
onChangeFromDiffDebounced();
});

// initialize data on both editor and differ
this.onSetEditingFile();
Expand Down

0 comments on commit cab582a

Please sign in to comment.