mirror of
https://github.com/go-gitea/gitea.git
synced 2025-11-10 10:18:11 -05:00
Fix "ref-issue" handling in markup (#35739)
This is a follow up for #35662, and also fix #31181, help #30275, fix #31161
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
import {createApp} from 'vue';
|
||||
import ContextPopup from '../components/ContextPopup.vue';
|
||||
import {parseIssueHref} from '../utils.ts';
|
||||
import {createTippy} from '../modules/tippy.ts';
|
||||
|
||||
export function initContextPopups() {
|
||||
const refIssues = document.querySelectorAll<HTMLElement>('.ref-issue');
|
||||
attachRefIssueContextPopup(refIssues);
|
||||
}
|
||||
|
||||
export function attachRefIssueContextPopup(refIssues: NodeListOf<HTMLElement>) {
|
||||
for (const refIssue of refIssues) {
|
||||
if (refIssue.classList.contains('ref-external-issue')) continue;
|
||||
|
||||
const issuePathInfo = parseIssueHref(refIssue.getAttribute('href'));
|
||||
if (!issuePathInfo.ownerName) continue;
|
||||
|
||||
const el = document.createElement('div');
|
||||
el.classList.add('tw-p-3');
|
||||
refIssue.parentNode.insertBefore(el, refIssue.nextSibling);
|
||||
|
||||
const view = createApp(ContextPopup);
|
||||
|
||||
try {
|
||||
view.mount(el);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
el.textContent = 'ContextPopup failed to load';
|
||||
}
|
||||
|
||||
createTippy(refIssue, {
|
||||
theme: 'default',
|
||||
content: el,
|
||||
placement: 'top-start',
|
||||
interactive: true,
|
||||
role: 'dialog',
|
||||
interactiveBorder: 5,
|
||||
onShow: () => {
|
||||
el.firstChild.dispatchEvent(new CustomEvent('ce-load-context-popup', {detail: issuePathInfo}));
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,6 @@ import {invertFileFolding} from './file-fold.ts';
|
||||
import {parseDom, sleep} from '../utils.ts';
|
||||
import {registerGlobalSelectorFunc} from '../modules/observer.ts';
|
||||
|
||||
const {i18n} = window.config;
|
||||
|
||||
function initRepoDiffFileBox(el: HTMLElement) {
|
||||
// switch between "rendered" and "source", for image and CSV files
|
||||
queryElems(el, '.file-view-toggle', (btn) => btn.addEventListener('click', () => {
|
||||
@@ -86,7 +84,7 @@ function initRepoDiffConversationForm() {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
showErrorToast(i18n.network_error);
|
||||
showErrorToast(`Submit form failed: ${error}`);
|
||||
} finally {
|
||||
form?.classList.remove('is-loading');
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {html, htmlRaw} from '../utils/html.ts';
|
||||
import {createCodeEditor} from './codeeditor.ts';
|
||||
import {hideElem, queryElems, showElem, createElementFromHTML} from '../utils/dom.ts';
|
||||
import {attachRefIssueContextPopup} from './contextpopup.ts';
|
||||
import {POST} from '../modules/fetch.ts';
|
||||
import {initDropzone} from './dropzone.ts';
|
||||
import {confirmModal} from './comp/ConfirmModal.ts';
|
||||
@@ -199,5 +198,4 @@ export function initRepoEditor() {
|
||||
export function renderPreviewPanelContent(previewPanel: Element, htmlContent: string) {
|
||||
// the content is from the server, so it is safe to use innerHTML
|
||||
previewPanel.innerHTML = html`<div class="render-content markup">${htmlRaw(htmlContent)}</div>`;
|
||||
attachRefIssueContextPopup(previewPanel.querySelectorAll('p .ref-issue'));
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import {getComboMarkdownEditor, initComboMarkdownEditor, ComboMarkdownEditor} fr
|
||||
import {POST} from '../modules/fetch.ts';
|
||||
import {showErrorToast} from '../modules/toast.ts';
|
||||
import {hideElem, querySingleVisibleElem, showElem, type DOMEvent} from '../utils/dom.ts';
|
||||
import {attachRefIssueContextPopup} from './contextpopup.ts';
|
||||
import {triggerUploadStateChanged} from './comp/EditorUpload.ts';
|
||||
import {convertHtmlToMarkdown} from '../markup/html2markdown.ts';
|
||||
import {applyAreYouSure, reinitializeAreYouSure} from '../vendor/jquery.are-you-sure.ts';
|
||||
@@ -62,8 +61,6 @@ async function tryOnEditContent(e: DOMEvent<MouseEvent>) {
|
||||
renderContent = newRenderContent;
|
||||
|
||||
rawContent.textContent = comboMarkdownEditor.value();
|
||||
const refIssues = renderContent.querySelectorAll<HTMLElement>('p .ref-issue');
|
||||
attachRefIssueContextPopup(refIssues);
|
||||
|
||||
if (!commentContent.querySelector('.dropzone-attachments')) {
|
||||
if (data.attachments !== '') {
|
||||
|
||||
Reference in New Issue
Block a user