mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
62719f3201
* Fix OAuth token, new request content-type, and more * better error messaging around invalid Curl opts * Make XFERINFOFUNCTION an optional option * Fix content-type change prompt and double quotes in prettify * Don't send Expect header on file upload * Remove dead code * Base64 tag * Fix HTML entities in URL clicks * Fix curl paste
31 lines
858 B
JavaScript
31 lines
858 B
JavaScript
import CodeMirror from 'codemirror';
|
|
import 'codemirror/addon/mode/overlay';
|
|
import {AllHtmlEntities} from 'html-entities';
|
|
import {FLEXIBLE_URL_REGEX} from '../../../../common/constants';
|
|
|
|
const entities = new AllHtmlEntities();
|
|
|
|
CodeMirror.defineExtension('makeLinksClickable', function (handleClick) {
|
|
// Only add the click mode if we have links to click
|
|
this.addOverlay({
|
|
token: function (stream, state) {
|
|
if (stream.match(FLEXIBLE_URL_REGEX, true)) {
|
|
return 'clickable';
|
|
}
|
|
|
|
while (stream.next() != null) {
|
|
if (stream.match(FLEXIBLE_URL_REGEX, false)) break;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
});
|
|
|
|
this.getWrapperElement().addEventListener('click', e => {
|
|
const cls = e.target.className;
|
|
if (cls.indexOf('cm-clickable') >= 0) {
|
|
handleClick(entities.decode(e.target.innerHTML));
|
|
}
|
|
});
|
|
});
|