hello,Lumpy Burgertushie wrote: Tue Sep 19, 2023 1:26 pm you don't need an extension. just right click in the text box and choose select all then right click and choose delete
Hi see if this BBcode is what you need :Myng wrote: Tue Sep 19, 2023 3:41 pmhello,Lumpy Burgertushie wrote: Tue Sep 19, 2023 1:26 pm you don't need an extension. just right click in the text box and choose select all then right click and choose delete
Thank you for your reply. Unfortunately, I don't quite understand what you mean.
Right-clicking in the box has the same effect as clicking outside the box - I can neither copy nor select anything with it.
By the way, selecting everything is not shown to me at all. In another browser I have the option but then not only the box is selected but the whole page.
What do you mean by delete?
best regards
Code: Select all
<style>/* CSS for the code container */
.code-container {
position: relative;
border: 1px solid #ccc;
background-color: #f8f8f8;
padding: 10px;
margin-bottom: 10px;
}
/* CSS for the copy button */
.copy-button {
position: absolute;
top: 5px;
right: 5px;
padding: 5px 10px;
background-color: #007bff;
color: #fff;
border: none;
cursor: pointer;
}
</style>
<div class="code-container">
<pre>
<code>{TEXT}</code>
</pre>
<button class="copy-button" onclick="copyToClipboard(this)">Copy this code</button>
</div>
<script>
function copyToClipboard(button) {
const codeElement = button.parentElement.querySelector('code');
const codeText = codeElement.innerText;
const textarea = document.createElement('textarea');
textarea.value = codeText;
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
button.innerText = 'Code Copied!';
setTimeout(() => {
button.innerText = 'Copy this code';
}, 1500);
}
</script>
Code: Select all
[php]{TEXT}[/php]
Code: Select all
<div class="code-container">
<div class="code-header">
<span class="code-title">Code:</span>
<button class="copy-button" onclick="copyToClipboard(this)">Copy this code</button>
</div>
<pre><code>{TEXT}</code></pre>
</div>
<script>
function copyToClipboard(button) {
const codeElement = button.parentElement.parentElement.querySelector('code');
const codeText = codeElement.innerText;
const textarea = document.createElement('textarea');
textarea.value = codeText;
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
button.innerText = 'Code Copied!';
setTimeout(() => {
button.innerText = 'Copy this code';
}, 1500);
}
</script>
Code: Select all
/* CSS for the code container */
.code-container {
position: relative;
border: 1px solid #ccc;
background-color: #f8f8f8;
border-radius: 5px;
padding: 10px;
margin-bottom: 10px;
}
/* CSS for the code container */
.code-container {
position: relative;
border: 1px solid #ccc;
background-color: #f8f8f8;
border-radius: 5px;
padding: 10px;
margin-bottom: 10px;
white-space: pre-wrap; /* Preserve line breaks */
}
/* CSS for the code container */
.code-container {
border: 1px solid #ccc;
background-color: #f8f8f8;
border-radius: 5px;
padding: 10px;
margin-bottom: 10px;
display: flex;
flex-direction: column;
}
/* CSS for the code header */
.code-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}
/* CSS for the "Code:" label */
.code-title {
font-weight: bold;
margin-right: 10px;
}
/* CSS for the copy button */
.copy-button {
padding: 5px 10px;
background-color: #007bff;
color: #fff;
border: none;
cursor: pointer;
border-radius: 3px;
}
/* Style for code within the code container */
.code-container pre {
margin: 0;
white-space: pre-wrap; /* Preserve line breaks */
}
/* Optional: Line numbers style (if you want line numbers) */
.linenums {
border-right: 1px solid #ccc;
padding-right: 10px;
text-align: right;
color: #777;
}
Thank you again. Yes, it works now.Mixlight - eStriKe wrote: Wed Sep 20, 2023 1:07 pm Ok , let's try this way then .
BBcode usage :Now to make it look nice go to /public_html/forum/styles/your-style/theme/stylesheet.css and add at the bottom of the document this :Code: Select all
[php]{TEXT}[/php]
This is how it should look like and now it should work properly as well :
phpv2.PNG
The current implementation of the BBcode corresponds to my ideas. A box with a copy button that copies the contents of the box is exactly what I was looking for. Your quick help is really great, I appreciate it a lot.Mixlight - eStriKe wrote: Wed Sep 20, 2023 1:35 pm So You want that bbcode such as[b][/b] [i]
to work on the bbcode i gave You ?
share the code with us that allows you such a thing and i will see if i can make it to copy it with the formatting.Myng wrote: Wed Sep 20, 2023 8:44 pm In the meantime, I was able to get the box to allow formatting. (see screenshot). The button also copies the text from the box. However, it copies the text without the formatting. If I copy the text manually, the formatting is also copied. is there a solution for this? If it is not possible, is it possible to turn the copy button into a select all button?
best regards
Code: Select all
[b]text[/b]
Hello, thank you very much for your answer.Mixlight - eStriKe wrote: Fri Sep 22, 2023 9:07 amshare the code with us that allows you such a thing and i will see if i can make it to copy it with the formatting.Myng wrote: Wed Sep 20, 2023 8:44 pm In the meantime, I was able to get the box to allow formatting. (see screenshot). The button also copies the text from the box. However, it copies the text without the formatting. If I copy the text manually, the formatting is also copied. is there a solution for this? If it is not possible, is it possible to turn the copy button into a select all button?
best regards
But be aware that ion order to copy it in the input box it will still displayonly after the post was made the bbcode such as bold will applyCode: Select all
[b]text[/b]
Code: Select all
<div style="padding: 10px; border: 1px solid #000000; background-color: #131a24; margin: 10px 0; margin-left: 30px; margin-right: 30px;">
<div class="box-container">
<div class="box-header">
<button class="select-button" onclick="selectBoxText(this)">Alles auswählen</button>
</div>
<box id="box">{TEXT}</box>
</div>
</div>
<script>
function selectBoxText(button) {
const boxElement = button.parentElement.parentElement.querySelector('box');
const range = document.createRange();
range.selectNodeContents(boxElement);
const selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
}
</script>
Code: Select all
/* CSS for the box header */
.box-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}
/* CSS for the select button */
.select-button {
padding: 5px 10px;
background-color: #2b5b84;
color: #fff;
border: none;
cursor: pointer;
border-radius: 3px;
}
.select-button:hover {
background-color: #4889c5;
color: white;
transition: background-color 0.3s ease;
}
/* Optional: Line numbers style (if you want line numbers) */
.linenums {
border-right: 1px solid #ccc;
padding-right: 10px;
text-align: right;
color: #777;
}
Code: Select all
<div style="padding: 10px; border: 1px solid #000000; background-color: #131a24; margin: 10px 0; margin-left: 30px; margin-right: 30px;">
<div class="box-container">
<div class="code-header">
<button class="select-button" onclick="selectBoxText(this)">Alles auswählen</button>
</div>
<box id="box">{TEXT}</box>
</div>
</div>
<script>
// Call the conversion function and selectBoxText when the page loads
window.onload = function() {
convertListTagsToUL();
selectBoxText(document.querySelector('.select-button'));
}
function selectBoxText(button) {
const boxElement = button.parentElement.parentElement.querySelector('box');
const range = document.createRange();
range.selectNodeContents(boxElement);
const selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
}
function convertListTagsToUL() {
const boxElement = document.querySelector('box');
if (boxElement) {
const text = boxElement.innerHTML;
const htmlWithLists = text.replace(/\[list\]([\s\S]*?)\[\/list\]/g, '<ul>$1</ul>');
boxElement.innerHTML = htmlWithLists;
}
}
</script>