blob: 1c64533c5b7f7a80f23a472a7fd8ad380e6d967d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import React from 'dom-chef';
import {replaceFieldText} from 'text-field-edit';
import * as pageDetect from 'github-url-detection';
import features from '../feature-manager.js';
import {isRefinedGitHubRepo} from '../github-helpers/index.js';
import observe from '../helpers/selector-observer.js';
function extract(textarea: HTMLTextAreaElement): void {
replaceFieldText(textarea, /<!--(.+)-->\n/s, (_, match) => {
textarea.closest('tab-container')!.before(
<div style={{whiteSpace: 'pre-wrap'}} className="flash mx-2 p-2">
{match.trim()}
</div>,
);
return '';
});
}
function init(signal: AbortSignal): void {
observe('#pull_request_body', extract, {signal});
}
void features.add(import.meta.url, {
asLongAs: [
isRefinedGitHubRepo,
pageDetect.isCompare,
],
init,
});
/*
Test URLs:
https://github.com/refined-github/refined-github/compare/main...sandbox/keep-branch?quick_pull=1
*/
|