Skip to content

Commit

Permalink
Merge branch 'master' into documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
anijanyan committed Oct 30, 2022
2 parents 88af815 + bf2913a commit b496a08
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [1.12.3](https://github.com/ajaxorg/ace/compare/v1.12.2...v1.12.3) (2022-10-18)


### Bug Fixes

* Fix syntax error in the custom scroll CSS ([#4968](https://github.com/ajaxorg/ace/issues/4968)) ([f2a424a](https://github.com/ajaxorg/ace/commit/f2a424a649f655b9511b1bb6047097634edb0e3f))

### [1.12.2](https://github.com/ajaxorg/ace/compare/v1.12.1...v1.12.2) (2022-10-18)


Expand Down
2 changes: 1 addition & 1 deletion build
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ace-code",
"description": "Ajax.org Code Editor is a full featured source code highlighting editor that powers the Cloud9 IDE",
"version": "1.12.2",
"version": "1.12.3",
"homepage": "http://github.com/ajaxorg/ace",
"engines": {
"node": ">= 0.6.0"
Expand Down
4 changes: 4 additions & 0 deletions src/commands/default_commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,10 @@ exports.commands = [{
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "openlink",
bindKey: bindKey("Ctrl+F3", "F3"),
exec: function(editor) { editor.openLink(); }
}, {
name: "joinlines",
description: "Join lines",
Expand Down
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,6 @@ var reportErrorIfPathIsNotConfigured = function() {
}
};

exports.version = "1.12.2";
exports.version = "1.12.3";


35 changes: 35 additions & 0 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1729,6 +1729,41 @@ Editor.$uid = 0;
}
};

/**
* Finds link at defined {row} and {column}
* @returns {String}
**/
this.findLinkAt = function (row, column) {
var line = this.session.getLine(row);
var wordParts = line.split(/((?:https?|ftp):\/\/[\S]+)/);
var columnPosition = column;
if (columnPosition < 0) columnPosition = 0;
var previousPosition = 0, currentPosition = 0, match;
for (let item of wordParts) {
currentPosition = previousPosition + item.length;
if (columnPosition >= previousPosition && columnPosition <= currentPosition) {
if (item.match(/((?:https?|ftp):\/\/[\S]+)/)) {
match = item.replace(/[\s:.,'";}\]]+$/, "");
break;
}
}
previousPosition = currentPosition;
}
return match;
};

/**
* Open valid url under cursor in another tab
* @returns {Boolean}
**/
this.openLink = function () {
var cursor = this.selection.getCursor();
var url = this.findLinkAt(cursor.row, cursor.column);
if (url)
window.open(url, '_blank');
return url != null;
};

/**
* Removes all the lines in the current selection
* @related EditSession.remove
Expand Down
12 changes: 10 additions & 2 deletions src/editor_commands_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ if (typeof process !== "undefined") {

"use strict";

var ace = require("./ace");
var EditSession = require("./edit_session").EditSession;
var Editor = require("./editor").Editor;
var UndoManager = require("./undomanager").UndoManager;
var MockRenderer = require("./test/mockrenderer").MockRenderer;
Expand Down Expand Up @@ -533,6 +531,16 @@ module.exports = {
exec("selectlineend", 1);
editor.execCommand(editor.commands.byName.joinlines);
assert.equal(editor.getValue(), "foo for foo foo foo for foo foo\nfoo for foo foo");
},
"test findlink": function() {
editor = new Editor(new MockRenderer());

editor.setValue("foo for foo foo\nhttps://www.google.com/", 1);
var url = editor.findLinkAt(0, 1);
assert.equal(url, null);

url = editor.findLinkAt(1, 5);
assert.equal(url, "https://www.google.com/");
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/scrollbar_custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ dom.importCssString(`.ace_editor>.ace_sb-v div, .ace_editor>.ace_sb-h div{
.ace_editor>.ace_sb-v, .ace_editor>.ace_sb-h {
position: absolute;
z-index: 6;
background: none;' + ' overflow: hidden!important;
background: none;
overflow: hidden!important;
}
.ace_editor>.ace_sb-v {
z-index: 6;
Expand Down

0 comments on commit b496a08

Please sign in to comment.