mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
bb57f360e0
* Sort of working nunjucks editor * Some more tweaks * Lots of stuff * Gettingn pretty good * Minor tweaks and test fixes * Minor bug fixes and stuff * Some fixes and perf * Refactoring * Good for now * Codemirror URL * More and more fixes and improvements * Code single-line CSS perfect!!! * Better nj editing * Show preview in nj edit * Some editor updates * All inputs now covered * A bunch of fixes and stuff * Don't cache node modules because it's not needed * More stuff * Tweak * Style tweaks * Pull nunjucks mode into own file * Move codemirror click overlay to own file * Pull nunjucks tag stuff out * Fixed key value editor * raw/endraw and marks improvements * Some tweaks
29 lines
752 B
JavaScript
29 lines
752 B
JavaScript
import CodeMirror from 'codemirror';
|
|
import 'codemirror/addon/mode/overlay';
|
|
|
|
CodeMirror.defineExtension('makeLinksClickable', function (handleClick) {
|
|
// Only add the click mode if we have links to click
|
|
const regexUrl = /^https?:\/\/([\da-z.\-]+)\.([a-z.]{2,6})([\/\w .\-+=;]*)*\/?/;
|
|
|
|
this.addOverlay({
|
|
token: function (stream, state) {
|
|
if (stream.match(regexUrl, true)) {
|
|
return 'clickable';
|
|
}
|
|
|
|
while (stream.next() != null) {
|
|
if (stream.match(regexUrl, false)) break;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
});
|
|
|
|
this.getWrapperElement().addEventListener('click', e => {
|
|
const cls = e.target.className;
|
|
if (cls.indexOf('cm-clickable') >= 0) {
|
|
handleClick(e.target.innerHTML);
|
|
}
|
|
});
|
|
});
|