Skip to content

Commit

Permalink
Auto resize text areas
Browse files Browse the repository at this point in the history
  • Loading branch information
Sominemo committed Jan 8, 2025
1 parent b0bfe12 commit d48aa75
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,11 @@ <h1>Telegram Limits Editor</h1>
this.markDirty();
});

setTimeout(() => {
itemName.style.height = "5px";
itemName.style.height = (itemName.scrollHeight) + "px";
}, 0);

const itemHint = document.createElement('textarea');
itemHint.value = sectionLocale.items[item.id].hint || '';
itemHint.placeholder = 'Hint';
Expand All @@ -1612,6 +1617,11 @@ <h1>Telegram Limits Editor</h1>
this.markDirty();
});

setTimeout(() => {
itemHint.style.height = "5px";
itemHint.style.height = (itemHint.scrollHeight) + "px";
}, 0);

const itemContentContainer = document.createElement('div');
itemContentContainer.classList.add('item-content-container');
itemFields.appendChild(itemContentContainer);
Expand All @@ -1633,6 +1643,11 @@ <h1>Telegram Limits Editor</h1>
this.markDirty();
});

setTimeout(() => {
itemContent.style.height = "5px";
itemContent.style.height = (itemContent.scrollHeight) + "px";
}, 0);

const itemContentPremiumContainer = document.createElement('div');
itemContentPremiumContainer.classList.add('item-content-premium-container');
itemFields.appendChild(itemContentPremiumContainer);
Expand All @@ -1658,6 +1673,11 @@ <h1>Telegram Limits Editor</h1>
this.markDirty();
});

setTimeout(() => {
itemContentPremium.style.height = "5px";
itemContentPremium.style.height = (itemContentPremium.scrollHeight) + "px";
}, 0);

const idContainer = document.createElement('div');
idContainer.classList.add('id-container');
idContainer.textContent = item.id;
Expand Down Expand Up @@ -1760,18 +1780,43 @@ <h1>Telegram Limits Editor</h1>
idContainer.textContent = itemId;
});

setTimeout(() => {
newItemName.style.height = "5px";
newItemName.style.height = (newItemName.scrollHeight) + "px";
}, 0);

const newItemHint = document.createElement('textarea');
newItemHint.placeholder = 'Hint';
newItemHint.title = 'Enter a hint for the limit';
newItemHint.rows = 1;
newItemTitleContainer.appendChild(newItemHint);

newItemHint.addEventListener('input', () => {
newItemHint.style.height = "5px";
newItemHint.style.height = (newItemHint.scrollHeight) + "px";
});

setTimeout(() => {
newItemHint.style.height = "5px";
newItemHint.style.height = (newItemHint.scrollHeight) + "px";
}, 0);

const newItemContent = document.createElement('textarea');
newItemContent.placeholder = 'Limit Description';
newItemContent.title = 'Describe the limit';
newItemContent.rows = 1;
addItemPanelRow.appendChild(newItemContent);

newItemContent.addEventListener('input', () => {
newItemContent.style.height = "5px";
newItemContent.style.height = (newItemContent.scrollHeight) + "px";
});

setTimeout(() => {
newItemContent.style.height = "5px";
newItemContent.style.height = (newItemContent.scrollHeight) + "px";
}, 0);

const newItemContentPremiumContainer = document.createElement('div');
newItemContentPremiumContainer.classList.add('item-content-premium-container');
addItemPanelRow.appendChild(newItemContentPremiumContainer);
Expand All @@ -1787,6 +1832,16 @@ <h1>Telegram Limits Editor</h1>
newItemContentPremium.rows = 1;
newItemContentPremiumContainer.appendChild(newItemContentPremium);

newItemContentPremium.addEventListener('input', () => {
newItemContentPremium.style.height = "5px";
newItemContentPremium.style.height = (newItemContentPremium.scrollHeight) + "px";
});

setTimeout(() => {
newItemContentPremium.style.height = "5px";
newItemContentPremium.style.height = (newItemContentPremium.scrollHeight) + "px";
}, 0);

addItemPanelRow.appendChild(idContainer);

const trailingContainer = document.createElement('span');
Expand Down

0 comments on commit d48aa75

Please sign in to comment.