mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 20:36:07 +01:00 
			
		
		
		
	Fix file editor & preview (#32706)
Fix a regression caused by jQuery removal (`renderPreviewPanelContent`) And simplify the file editor, it doesn't need to be that complex. And remove jQuery code.
This commit is contained in:
		@@ -134,19 +134,17 @@ function getFileBasedOptions(filename: string, lineWrapExts: string[]) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function togglePreviewDisplay(previewable: boolean) {
 | 
			
		||||
  const previewTab = document.querySelector('a[data-tab="preview"]');
 | 
			
		||||
  const previewTab = document.querySelector<HTMLElement>('a[data-tab="preview"]');
 | 
			
		||||
  if (!previewTab) return;
 | 
			
		||||
 | 
			
		||||
  if (previewable) {
 | 
			
		||||
    const newUrl = (previewTab.getAttribute('data-url') || '').replace(/(.*)\/.*/, `$1/markup`);
 | 
			
		||||
    previewTab.setAttribute('data-url', newUrl);
 | 
			
		||||
    previewTab.style.display = '';
 | 
			
		||||
  } else {
 | 
			
		||||
    previewTab.style.display = 'none';
 | 
			
		||||
    // If the "preview" tab was active, user changes the filename to a non-previewable one,
 | 
			
		||||
    // then the "preview" tab becomes inactive (hidden), so the "write" tab should become active
 | 
			
		||||
    if (previewTab.classList.contains('active')) {
 | 
			
		||||
      const writeTab = document.querySelector('a[data-tab="write"]');
 | 
			
		||||
      const writeTab = document.querySelector<HTMLElement>('a[data-tab="write"]');
 | 
			
		||||
      writeTab.click();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user