-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright (c) 2016, Hendrik Leppelsack | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. | ||
* See the COPYING file. | ||
*/ | ||
|
||
// finds the url which should be opened when a link is clicked | ||
// example: '[hello](http://example.com)' | ||
app.factory('urlFinder', [function() { | ||
'use strict'; | ||
|
||
return function urlFinder(element) { | ||
element = $(element); | ||
|
||
// special case: click on ')' | ||
if(element.is('.cm-url.cm-formatting')) { | ||
if(element.prev().length !== 0) { | ||
element = element.prev(); | ||
} | ||
} | ||
|
||
// skip '[hello]' | ||
while(element.is('.cm-link')) { | ||
element = element.next(); | ||
} | ||
|
||
// skip '(' | ||
while(element.is('.cm-url.cm-formatting')) { | ||
element = element.next(); | ||
} | ||
|
||
// check if we actually have a cm-url | ||
if(element.is('.cm-url:not(.cm-formatting)')) { | ||
return element.text(); | ||
} | ||
|
||
return undefined; | ||
}; | ||
}]); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.