Skip to content

Commit 7ede5ed

Browse files
committed
update 1.4.0
1 parent b004291 commit 7ede5ed

6 files changed

Lines changed: 56 additions & 41 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
## Changelog
2-
- Fixed: when open a huge directory, it will make colon slow
2+
- Add: Real Time Code Sharing
3+
- Fixed: XSS Vulnerability

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ Colon is a flexible text editor, built on [Electron](https://github.com/electron
66

77
### macOS
88

9-
Download the latest [Colon release](https://github.com/Chhekur/colon-ide/releases/download/v1.3.1/Colon-1.3.1.dmg) for mac.
9+
Download the latest [Colon release](https://github.com/Chhekur/colon-ide/releases/download/v1.4.0/Colon-1.4.0.dmg) for mac.
1010

1111
Colon will automatically update when a new release is available.
1212

1313
### Windows
1414

15-
Download the latest [Colon installer](https://github.com/Chhekur/colon-ide/releases/download/v1.3.1/Colon-Setup-1.3.1.exe) for windows.
15+
Download the latest [Colon installer](https://github.com/Chhekur/colon-ide/releases/download/v1.4.0/Colon-Setup-1.4.0.exe) for windows.
1616

1717
Colon will automatically update when a new release is available.
1818

1919
### Linux
2020

21-
Download the latest [Colon installer](https://github.com/Chhekur/colon-ide/releases/download/v1.3.1/Colon-1.3.1-x86_64.AppImage) for linux.
21+
Download the latest [Colon installer](https://github.com/Chhekur/colon-ide/releases/download/v1.4.0/Colon-1.4.0-x86_64.AppImage) for linux.
2222

2323
## License
2424

assets/js/editor.js

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -877,48 +877,59 @@ function openCodeSharingPanel(){
877877

878878
// end here
879879

880+
function isCurrentFileSaved(){
881+
// if(file.path != undefined) return true
882+
var data = editor.getValue();
883+
// console.log(file.path);
884+
ipc.send('save-data', data, file.path);
885+
if(file.path != undefined) return true;
886+
else return false;
887+
}
888+
880889
// code sharing function
881890

882891
function shareCode(){
883-
$('#code-sharing-box').html('<h5>Waiting...</h5>');
884-
app.listen(4000, function(){
885-
// console.log('listening at 4000');
886-
var tunnel = localtunnel(4000, function(err, tunnel) {
887-
if (err) {
888-
// console.log(err);
892+
if(isCurrentFileSaved()){
893+
$('#code-sharing-box').html('<h5>Waiting...</h5>');
894+
app.listen(4000, function(){
895+
// console.log('listening at 4000');
896+
var tunnel = localtunnel(4000, function(err, tunnel) {
897+
if (err) {
898+
// console.log(err);
899+
$('#code-sharing-box').html(err);
900+
}
901+
902+
// the assigned public url for your tunnel
903+
// i.e. https://abcdefgjhij.localtunnel.me
904+
$('#code-sharing-box').html('<h5>Share this url with whome you want to share</h5><br>');
905+
$('#code-sharing-box').append('<h5>' + tunnel.url + '</h5><br>');
906+
$('#code-sharing-box').append('<button class = "btn" id = "commit-changes-sender" onclick="commitChangesSender()">Commit Changes</button><br><br>');
907+
$('#code-sharing-box').append('<button class = "btn" id = "disconnect" onclick="disconnect()">Disconnect</button>');
908+
// console.log(tunnel.url);
909+
});
910+
tunnel.on('error', function(err) {
889911
$('#code-sharing-box').html(err);
890-
}
891-
892-
// the assigned public url for your tunnel
893-
// i.e. https://abcdefgjhij.localtunnel.me
894-
$('#code-sharing-box').html('<h5>Share this url with whome you want to share</h5><br>');
895-
$('#code-sharing-box').append('<h5>' + tunnel.url + '</h5><br>');
896-
$('#code-sharing-box').append('<button class = "btn" id = "commit-changes-sender" onclick="commitChangesSender()">Commit Changes</button>');
897-
$('#code-sharing-box').append('<button class = "btn" id = "disconnect" onclick="disconnect()">Disconnect</button><br><br>');
898-
// console.log(tunnel.url);
912+
});
899913
});
900-
tunnel.on('error', function(err) {
901-
$('#code-sharing-box').html(err);
914+
// console.log(file);
915+
io.on('connection', function (socket) {
916+
clients.push(socket);
917+
socket.emit('file', { id: file.id, name:file.name, remote_path:file.path, data:file.editor.getValue() });
918+
socket.on('commit-changes', function (data) {
919+
// console.log('hello');
920+
if(file.id == data.id && file.path == data.path){
921+
file.editor.setValue(data.data);
922+
editor.setValue(data.data);
923+
}
924+
files['#' + data.id].editor.setValue(data.data);
925+
});
902926
});
903-
});
904-
// console.log(file);
905-
io.on('connection', function (socket) {
906-
clients.push(socket);
907-
socket.emit('file', { id: file.id, name:file.name, remote_path:file.path, data:file.editor.getValue() });
908-
socket.on('commit-changes', function (data) {
909-
// console.log('hello');
910-
if(file.id == data.id && file.path == data.path){
911-
file.editor.setValue(data.data);
912-
editor.setValue(data.data);
913-
}
914-
files['#' + data.id].editor.setValue(data.data);
915-
});
916-
});
927+
}
917928
}
918929

919930
function connect(flag){
920931
if(!flag){
921-
$('#code-sharing-box').html('<input class = "input-field" id = "url"><br> <br><button class ="btn" onclick = "connect(true)">Connect</button>');
932+
$('#code-sharing-box').html('<input placeholder = "URL" class = "input-field" id = "url"><br> <br><button class ="btn" onclick = "connect(true)">Connect</button>');
922933
}else{
923934
let url = $('#url').val();
924935
$('#code-sharing-box').html('<h5>Waiting...</h5>');
@@ -927,7 +938,7 @@ function connect(flag){
927938
remoteFile = data;
928939
// newFileCount++;
929940
// newTab(undefined, newFileCount, path.basename(data.remote_path), data.data);
930-
openFile(data.data, undefined, path.basename(data.remote_path), data.remote_path);
941+
openFile(data.data, undefined, data.name, data.remote_path);
931942
// console.log(data);
932943
// socket.emit('my other event', { my: 'data' });
933944
$('#code-sharing-box').html('<button class = "btn" id = "commit_changes" onclick="commitChanges()">Commit Changes</button><br><br>');
@@ -949,6 +960,9 @@ function connect(flag){
949960
}
950961
}
951962
});
963+
socket.on('error', function(error){
964+
$('#code-sharing-box').html(error);
965+
});
952966
}
953967
}
954968

main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function createWindow () {
3131
slashes: true
3232
}))
3333
// Open the DevTools.
34-
mainWindow.webContents.openDevTools()
34+
// mainWindow.webContents.openDevTools()
3535
// Emitted when the window is closed.
3636
mainWindow.on('closed', function () {
3737
// Dereference the window object, usually you would store windows

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Colon",
3-
"version": "1.3.1",
3+
"version": "1.4.0",
44
"description": "A flexible text editor",
55
"author": "Harendra Chhekur <820121223505e@gmail.com>",
66
"main": "main.js",

views/editor.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@
131131
</div>
132132

133133
<div class = "html-preview">
134-
<iframe id=html-preview class="html-preview"></iframe>
134+
<iframe id=html-preview class="html-preview" sandbox="allow-same-origin"></iframe>
135135
<img style = "position: relative;float: left;bottom:70;right:30;float:right;" onclick = "updateHtmlPreview()" src = "../assets/icons/refresh-button.svg" width="40px"></img>
136136
</div>
137137
<div class = "markdown-preview">
138138
<!-- <button onclick = "updateMarkdownPreview()">refresh</button> -->
139-
<iframe id=markdown-preview class="markdown-preview"></iframe>
139+
<iframe id=markdown-preview class="markdown-preview" sandbox="allow-same-origin"></iframe>
140140
<img style = "position: relative;float: left;bottom:70;right:30;float:right;" onclick = "updateMarkdownPreview()" src = "../assets/icons/refresh-button.svg" width="40px"></img>
141141
</div>
142142

0 commit comments

Comments
 (0)