Use CSS.supports to determine auto-fit validity

ac0c33eb7669cfbbb7b8cd8460a94e9c6dca5135

Cohee <18619528+Cohee1207@users.noreply.github.com>

6 files changed, +18 -25Ignore whitespace
public/script.js+2 -6
@@ -10577,9 +10577,6 @@ jQuery(async function () {
10577 stopScriptExecution();10577 stopScriptExecution();
10578 });10578 });
1057910579
10580 const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/');
10581 const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx));
10582
10583 $('.drawer-toggle').on('click', function () {10580 $('.drawer-toggle').on('click', function () {
10584 var icon = $(this).find('.drawer-icon');10581 var icon = $(this).find('.drawer-icon');
10585 var drawer = $(this).parent().find('.drawer-content');10582 var drawer = $(this).parent().find('.drawer-content');
@@ -10619,8 +10616,7 @@ jQuery(async function () {
10619 }10616 }
1062010617
10621 // Set the height of "autoSetHeight" textareas within the drawer to their scroll height10618 // Set the height of "autoSetHeight" textareas within the drawer to their scroll height
1062210619 if (!CSS.supports('field-sizing', 'content')) {
10623 if (chromeUaIdx == -1 || Number(chromeVersion) < 123) {
10624 $(this).closest('.drawer').find('.drawer-content textarea.autoSetHeight').each(async function () {10620 $(this).closest('.drawer').find('.drawer-content textarea.autoSetHeight').each(async function () {
10625 await resetScrollHeight($(this));10621 await resetScrollHeight($(this));
10626 return;10622 return;
@@ -10697,7 +10693,7 @@ jQuery(async function () {
10697 $(this).closest('.inline-drawer').find('.inline-drawer-content').stop().slideToggle();10693 $(this).closest('.inline-drawer').find('.inline-drawer-content').stop().slideToggle();
1069810694
10699 // Set the height of "autoSetHeight" textareas within the inline-drawer to their scroll height10695 // Set the height of "autoSetHeight" textareas within the inline-drawer to their scroll height
10700 if (chromeUaIdx == -1 || Number(chromeVersion) < 123) {10696 if (!CSS.supports('field-sizing', 'content')) {
10701 $(this).closest('.inline-drawer').find('.inline-drawer-content textarea.autoSetHeight').each(async function () {10697 $(this).closest('.inline-drawer').find('.inline-drawer-content textarea.autoSetHeight').each(async function () {
10702 await resetScrollHeight($(this));10698 await resetScrollHeight($(this));
10703 return;10699 return;
public/scripts/group-chats.js+8 -4
@@ -1491,9 +1491,11 @@ function select_group_chats(groupId, skipAnimation) {
1491 }1491 }
14921492
1493 // Toggle textbox sizes, as input events have not fired here1493 // Toggle textbox sizes, as input events have not fired here
1494 $('#rm_group_chats_block .autoSetHeight').each(element => {1494 if (!CSS.supports('field-sizing', 'content')) {
1495 resetScrollHeight(element);1495 $('#rm_group_chats_block .autoSetHeight').each(element => {
1496 });1496 resetScrollHeight(element);
1497 });
1498 }
14971499
1498 eventSource.emit('groupSelected', { detail: { id: openGroupId, group: group } });1500 eventSource.emit('groupSelected', { detail: { id: openGroupId, group: group } });
1499}1501}
@@ -1965,7 +1967,9 @@ function doCurMemberListPopout() {
19651967
1966jQuery(() => {1968jQuery(() => {
1967 $(document).on('input', '#rm_group_chats_block .autoSetHeight', function () {1969 $(document).on('input', '#rm_group_chats_block .autoSetHeight', function () {
1968 resetScrollHeight($(this));1970 if (!CSS.supports('field-sizing', 'content')) {
1971 resetScrollHeight($(this));
1972 }
1969 });1973 });
19701974
1971 $(document).on('click', '.group_select', function () {1975 $(document).on('click', '.group_select', function () {
public/scripts/instruct-mode.js+1 -4
@@ -42,9 +42,6 @@ const controls = [
42 { id: 'instruct_system_same_as_user', property: 'system_same_as_user', isCheckbox: true, trigger: true },42 { id: 'instruct_system_same_as_user', property: 'system_same_as_user', isCheckbox: true, trigger: true },
43];43];
4444
45const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/');
46const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx));
47
48/**45/**
49 * Migrates instruct mode settings into the evergreen format.46 * Migrates instruct mode settings into the evergreen format.
50 * @param {object} settings Instruct mode settings.47 * @param {object} settings Instruct mode settings.
@@ -103,7 +100,7 @@ export async function loadInstructMode(data) {
103100
104 $element.on('input', async function () {101 $element.on('input', async function () {
105 power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this).val;102 power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this).val;
106 if (chromeUaIdx == -1 || Number(chromeVersion) < 123) {103 if (!CSS.supports('field-sizing', 'content')) {
107 await resetScrollHeight($(this));104 await resetScrollHeight($(this));
108 }105 }
109 saveSettingsDebounced();106 saveSettingsDebounced();
public/scripts/openai.js+5 -3
@@ -5281,9 +5281,11 @@ $(document).ready(async function () {
5281 saveSettingsDebounced();5281 saveSettingsDebounced();
5282 });5282 });
52835283
5284 $(document).on('input', '#openai_settings .autoSetHeight', function () {5284 if (!CSS.supports('field-sizing', 'content')) {
5285 resetScrollHeight($(this));5285 $(document).on('input', '#openai_settings .autoSetHeight', function () {
5286 });5286 resetScrollHeight($(this));
5287 });
5288 }
52875289
5288 if (!isMobile()) {5290 if (!isMobile()) {
5289 $('#model_openrouter_select').select2({5291 $('#model_openrouter_select').select2({
public/scripts/power-user.js+1 -4
@@ -105,9 +105,6 @@ export const persona_description_positions = {
105 NONE: 9,105 NONE: 9,
106};106};
107107
108const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/');
109const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx));
110
111let power_user = {108let power_user = {
112 tokenizer: tokenizers.BEST_MATCH,109 tokenizer: tokenizers.BEST_MATCH,
113 token_padding: 64,110 token_padding: 64,
@@ -1757,7 +1754,7 @@ async function loadContextSettings() {
1757 power_user.context[control.property] = value;1754 power_user.context[control.property] = value;
1758 }1755 }
1759 console.log(`Setting ${$element.prop('id')} to ${value}`);1756 console.log(`Setting ${$element.prop('id')} to ${value}`);
1760 if (chromeUaIdx == -1 || Number(chromeVersion) < 123) {1757 if (!CSS.supports('field-sizing', 'content')) {
1761 await resetScrollHeight($(this));1758 await resetScrollHeight($(this));
1762 }1759 }
1763 saveSettingsDebounced();1760 saveSettingsDebounced();
public/scripts/utils.js+1 -4
@@ -2027,11 +2027,8 @@ export function toggleDrawer(drawer, expand = true) {
2027 content.style.display = 'none';2027 content.style.display = 'none';
2028 }2028 }
20292029
2030 const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/');
2031 const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx));
2032
2033 // Set the height of "autoSetHeight" textareas within the inline-drawer to their scroll height2030 // Set the height of "autoSetHeight" textareas within the inline-drawer to their scroll height
2034 if (chromeUaIdx == -1 || Number(chromeVersion) < 123) {2031 if (!CSS.supports('field-sizing', 'content')) {
2035 content.querySelectorAll('textarea.autoSetHeight').forEach(resetScrollHeight);2032 content.querySelectorAll('textarea.autoSetHeight').forEach(resetScrollHeight);
2036 }2033 }
2037}2034}