You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
import React from 'react' ;
import ReactDOM from 'react-dom/client' ;
import Reactions from './components/Reactions' ;
console . log ( 'Redmine Reactions Extension Loaded!' ) ;
// Функция для извлечения ID задачи из URL
function getIssueId ( ) : number | null {
const match = window . location . pathname . match ( /\/issues\/(\d+)/ ) ;
return match && match [ 1 ] ? parseInt ( match [ 1 ] , 10 ) : null ;
}
// Находим все блоки с комментариями на странице
const commentContainers = document . querySelectorAll ( 'div.journal.has-notes' ) ;
const issueId = getIssueId ( ) ;
if ( issueId ) {
commentContainers . forEach ( container = > {
// Находим вложенный div с ID комментария
const noteElement = container . querySelector < HTMLDivElement > ( 'div[id^="note-"]' ) ;
if ( ! noteElement ) return ;
const commentId = noteElement . id ;
// Создаем div, в который будем рендерить наш React-компонент
const reactionRootEl = document . createElement ( 'div' ) ;
reactionRootEl . className = 'reactions-app-root' ;
// Вставляем наш div в конец контейнера, как вы и определили
container . appendChild ( reactionRootEl ) ;
// Создаем React-root и рендерим компонент
const root = ReactDOM . createRoot ( reactionRootEl ) ;
root . render (
< React.StrictMode >
< Reactions issueId = { issueId } commentId = { commentId } / >
< / React.StrictMode >
) ;
} ) ;
}