Skip to content

Commit

Permalink
Add popup to hashed comments/pull requests/issues in file editing/add…
Browse files Browse the repository at this point in the history
…ing preview tab (#24040)

#23734 didn't add popups(tippy) to ref issues for the preview tab when
adding/editing a file

The location of the preview tab:
<img width="1214" alt="截屏2023-04-10 13 55 38"
src="https://user-images.githubusercontent.com/17645053/230836213-a73f0cee-378c-4a21-93db-583ba2c72f77.png">

This PR resues the logic in `ComboMarkdownEditor.js` to also add popup
to hashed comments/pull requests/issues in file editing/adding preview
tab.

After - On hover:
<img width="1222" alt="截屏2023-04-10 13 55 42"
src="https://user-images.githubusercontent.com/17645053/230836250-527ca7d0-6ec4-4c68-89ab-4f1b57b09239.png">

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
  • Loading branch information
3 people authored Apr 12, 2023
1 parent 6892e2b commit b43ad51
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
9 changes: 2 additions & 7 deletions web_src/js/features/comp/ComboMarkdownEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import $ from 'jquery';
import {attachTribute} from '../tribute.js';
import {hideElem, showElem, autosize} from '../../utils/dom.js';
import {initEasyMDEImagePaste, initTextareaImagePaste} from './ImagePaste.js';
import {initMarkupContent} from '../../markup/content.js';
import {handleGlobalEnterQuickSubmit} from './QuickSubmit.js';
import {attachRefIssueContextPopup} from '../contextpopup.js';
import {emojiKeys, emojiString} from '../emoji.js';
import {renderPreviewPanelContent} from '../repo-editor.js';

let elementIdCounter = 0;
const maxExpanderMatches = 6;
Expand Down Expand Up @@ -194,11 +193,7 @@ class ComboMarkdownEditor {
text: this.value(),
wiki: this.previewWiki,
}, (data) => {
$panelPreviewer.html(data);
initMarkupContent();

const refIssues = $panelPreviewer.find('p .ref-issue');
attachRefIssueContextPopup(refIssues);
renderPreviewPanelContent($panelPreviewer, data);
});
});
}
Expand Down
14 changes: 11 additions & 3 deletions web_src/js/features/repo-editor.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import $ from 'jquery';
import {htmlEscape} from 'escape-goat';
import {initMarkupContent} from '../markup/content.js';
import {createCodeEditor} from './codeeditor.js';
import {hideElem, showElem} from '../utils/dom.js';
import {initMarkupContent} from '../markup/content.js';
import {attachRefIssueContextPopup} from './contextpopup.js';

const {csrfToken} = window.config;

Expand All @@ -28,8 +29,7 @@ function initEditPreviewTab($form) {
file_path: treePathEl.val(),
}, (data) => {
const $previewPanel = $form.find(`.tab[data-tab="${$tabMenu.data('preview')}"]`);
$previewPanel.html(data);
initMarkupContent();
renderPreviewPanelContent($previewPanel, data);
});
});
}
Expand Down Expand Up @@ -191,3 +191,11 @@ export function initRepoEditor() {
});
})();
}

export function renderPreviewPanelContent($panelPreviewer, data) {
$panelPreviewer.html(data);
initMarkupContent();

const refIssues = $panelPreviewer.find('p .ref-issue');
attachRefIssueContextPopup(refIssues);
}

0 comments on commit b43ad51

Please sign in to comment.