Skip to content

Commit d0c00ac

Browse files
authored
[FEATURE] File Directive and File Textrole popover with help (#898)
for files that are defined as directive Does not yet work for code-block captions ![image](https://github.com/user-attachments/assets/37a54e7e-8aa0-4cfb-8d65-d32e39e2cefe) ![image](https://github.com/user-attachments/assets/0f399ec5-a1b4-4722-9f7f-c74dec65ff0a)
1 parent 94713f2 commit d0c00ac

31 files changed

+1437
-2020
lines changed

Documentation-rendertest/Localization.ru_RU/guides.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<inventory id="t3start11" url="https://docs.typo3.org/m/typo3/tutorial-getting-started/12.4/ru-ru/"/>
1717
<inventory id="t3start12" url="https://docs.typo3.org/m/typo3/tutorial-getting-started/12.4/ru-ru/"/>
1818
<inventory id="t3coreapi" url="https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/"/>
19-
<inventory id="t3editors" url="https://docs.typo3.org/m/typo3/tutorial-editors/main/ru-ru/"/>
19+
<inventory id="t3editors" url="https://docs.typo3.org/m/typo3/tutorial-editors/13.4/ru-ru/"/>
2020
<inventory id="t3sitepackage" url="https://docs.typo3.org/m/typo3/tutorial-sitepackage/main/en-us/"/>
2121
<inventory id="ext_workspaces" url="https://docs.typo3.org/c/typo3/cms-workspaces/main/en-us/"/>
2222
<inventory id="ext_surf" url="https://docs.typo3.org/other/typo3/surf/main/en-us/"/>

composer.lock

Lines changed: 41 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
(() => {
2+
const SELECTOR_MODAL = '#generalModal';
3+
const SELECTOR_COPY_BUTTON = '.copy-button';
4+
const SELECTOR_ALERT_SUCCESS = '#general-alert-success';
5+
6+
function handleCopyButtons(generalModal) {
7+
const alertSuccessDiv = generalModal.querySelector(SELECTOR_ALERT_SUCCESS);
8+
const copyButtons = generalModal.querySelectorAll(SELECTOR_COPY_BUTTON);
9+
if (!navigator.clipboard || !navigator.clipboard.writeText) {
10+
console.info('"navigator.clipboard.writeText" is not available. Update to a modern browser to copy code to the system\'s clipboard');
11+
copyButtons.forEach(button => button.disabled = true);
12+
} else {
13+
copyButtons.forEach(button => {
14+
button.addEventListener('click', function () {
15+
const targetId = this.getAttribute('data-target');
16+
const targetElement = generalModal.querySelector(`#${targetId}`);
17+
if (!targetElement) {
18+
console.warn('Cannot copy link as no input is available!');
19+
return;
20+
}
21+
alertSuccessDiv.classList.remove('d-none');
22+
alertSuccessDiv.innerHTML = `Path <code>${htmlEscape(targetElement.value)}</code> was copied to your clipboard.`;
23+
navigator.clipboard.writeText(targetElement.value);
24+
});
25+
});
26+
}
27+
}
28+
29+
function htmlEscape(text) {
30+
const div = document.createElement('div');
31+
div.textContent = text;
32+
return div.innerHTML;
33+
}
34+
35+
const generalModal = document.querySelector(SELECTOR_MODAL);
36+
if (generalModal) {
37+
generalModal.addEventListener('show.bs.modal', function (event) {
38+
const item = event.relatedTarget;
39+
if (!item.dataset.filename) {
40+
return;
41+
}
42+
const generalModalLabel = generalModal.querySelector('#generalModalLabel');
43+
const content = generalModal.querySelector('#generalModalContent');
44+
generalModalLabel.innerText = item.dataset.filename;
45+
if (item.dataset.scope) {
46+
generalModalLabel.innerText += ' (' + item.dataset.scope + ')';
47+
}
48+
handleCopyButtons(generalModal);
49+
content.innerHTML = '';
50+
if (item.dataset.shortdescription) {
51+
content.innerHTML += `<p>${item.dataset.shortdescription}</p>`;
52+
}
53+
content.innerHTML += `
54+
<div class="mb-3">
55+
<label class="form-label" for="composer-path">Path in Composer-based TYPO3 Installations: </label>
56+
<div class="input-group">
57+
<textarea class="form-control code" id="composer-path" readonly>${item.dataset.composerpath}${item.dataset.filename}</textarea>
58+
<button type="button" class="btn btn-outline-secondary copy-button" data-target="composer-path"><i class="far fa-clone"></i></button>
59+
</div>
60+
<p>Example: <code>${item.dataset.composerpathprefix}${item.dataset.composerpath}${item.dataset.filename}</code></p>
61+
</div>
62+
<div class="mb-3">
63+
<label class="form-label" for="classic-path">Path in Classic TYPO3 Installations: </label>
64+
<div class="input-group">
65+
<textarea class="form-control code" id="classic-path" readonly>${item.dataset.classicpath}${item.dataset.filename}</textarea>
66+
<button type="button" class="btn btn-outline-secondary copy-button" data-target="classic-path"><i class="far fa-clone"></i></button>
67+
</div>
68+
<p>Example: <code>${item.dataset.classicpathprefix}${item.dataset.classicpath}${item.dataset.filename}</code></p>
69+
</div>
70+
`;
71+
var links = '';
72+
if (item.dataset.source) {
73+
const url = new URL(item.dataset.source);
74+
var srcString = 'Source';
75+
if (url.hostname === 'github.com') {
76+
srcString = 'GitHub';
77+
}
78+
if (url.hostname === 'gitlab.com') {
79+
srcString = 'GitLab';
80+
}
81+
links += `<a class="btn btn-light" href="${item.dataset.source}">${srcString}</a>`;
82+
}
83+
if (item.dataset.issues) {
84+
links += `<a class="btn btn-light" href="${item.dataset.issues}">Report issue</a>`;
85+
}
86+
if (links) {
87+
content.innerHTML += `<div class="btn-group mt-2" role="group" aria-label="Links to GitHub / GitLab">${links}</div>`;
88+
}
89+
const generalModalCustomButtons = generalModal.querySelector('#generalModalCustomButtons');
90+
91+
// Add more buttons to the modal footer
92+
generalModalCustomButtons.innerHTML = `
93+
<a href="${item.href}" class="btn btn-default"><i class="fa-solid fa-arrow-right"></i>&nbsp;Documentation</a>
94+
`;
95+
if (item.dataset.documentation) {
96+
const url = new URL(item.dataset.documentation);
97+
const isExternal = url.hostname !== 'docs.typo3.org';
98+
generalModalCustomButtons.innerHTML += `
99+
<a href="${item.dataset.documentation}" class="btn btn-default">
100+
<i class="fa-solid fa-book"></i>&nbsp;Documentation ${isExternal ? '(external)' : ''}
101+
</a>
102+
`;
103+
}
104+
if (item.dataset.homepage) {
105+
const url = new URL(item.dataset.homepage);
106+
const isTER = url.hostname === 'extensions.typo3.org';
107+
if (isTER) {
108+
generalModalCustomButtons.innerHTML += `
109+
<a href="${item.dataset.homepage}" class="btn btn-default">
110+
<i class="fa-brands fa-typo3"></i>&nbsp;TER
111+
</a>
112+
`;
113+
}
114+
}
115+
handleCopyButtons(generalModal);
116+
});
117+
}
118+
})();

0 commit comments

Comments
 (0)