chore(ui): finish large text paste merge into main
Adds the Turkish dictionary entries main introduced after this branch was opened, keeps the composer's four-space style in the new paste modules, and drops the unused offer-action type plus the widening return annotation flagged by the anti-slop lint.
This commit is contained in:
@@ -10,13 +10,13 @@ export const LARGE_TEXT_PASTE_CHAR_THRESHOLD = 2000;
|
||||
export const LARGE_TEXT_PASTE_LINE_THRESHOLD = 25;
|
||||
|
||||
const countLines = (text: string): number => {
|
||||
let lines = 1;
|
||||
for (let index = 0; index < text.length; index += 1) {
|
||||
if (text.charCodeAt(index) === 10) {
|
||||
lines += 1;
|
||||
let lines = 1;
|
||||
for (let index = 0; index < text.length; index += 1) {
|
||||
if (text.charCodeAt(index) === 10) {
|
||||
lines += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
return lines;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -27,29 +27,29 @@ const countLines = (text: string): number => {
|
||||
* character count or line count is enough.
|
||||
*/
|
||||
export const isLargePlainTextPaste = (
|
||||
text: string,
|
||||
options?: {
|
||||
charThreshold?: number;
|
||||
lineThreshold?: number;
|
||||
},
|
||||
text: string,
|
||||
options?: {
|
||||
charThreshold?: number;
|
||||
lineThreshold?: number;
|
||||
},
|
||||
): boolean => {
|
||||
if (!text || !text.trim()) {
|
||||
return false;
|
||||
}
|
||||
if (!text || !text.trim()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const charThreshold = options?.charThreshold ?? LARGE_TEXT_PASTE_CHAR_THRESHOLD;
|
||||
const lineThreshold = options?.lineThreshold ?? LARGE_TEXT_PASTE_LINE_THRESHOLD;
|
||||
const charThreshold = options?.charThreshold ?? LARGE_TEXT_PASTE_CHAR_THRESHOLD;
|
||||
const lineThreshold = options?.lineThreshold ?? LARGE_TEXT_PASTE_LINE_THRESHOLD;
|
||||
|
||||
if (text.length >= charThreshold) {
|
||||
return true;
|
||||
}
|
||||
if (text.length >= charThreshold) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return countLines(text) >= lineThreshold;
|
||||
return countLines(text) >= lineThreshold;
|
||||
};
|
||||
|
||||
export const createPastedContextFile = (text: string, filename: string): File => (
|
||||
new File([text], filename, {
|
||||
type: 'text/plain',
|
||||
lastModified: Date.now(),
|
||||
})
|
||||
new File([text], filename, {
|
||||
type: 'text/plain',
|
||||
lastModified: Date.now(),
|
||||
})
|
||||
);
|
||||
|
||||
@@ -6,11 +6,9 @@
|
||||
* invalidation pure so ChatInput only wires toast UI to attach/inline actions.
|
||||
*/
|
||||
|
||||
export type LargeTextPasteOfferAction = 'attach' | 'inline';
|
||||
|
||||
/** Allocate a new offer id, superseding any unanswered previous offer. */
|
||||
export const beginLargeTextPasteOffer = (activeOfferId: number): number => (
|
||||
activeOfferId + 1
|
||||
activeOfferId + 1
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -19,15 +17,15 @@ export const beginLargeTextPasteOffer = (activeOfferId: number): number => (
|
||||
* dismiss/action cannot double-apply.
|
||||
*/
|
||||
export const resolveLargeTextPasteOffer = (
|
||||
activeOfferId: number,
|
||||
offerId: number,
|
||||
): { accepted: boolean; nextOfferId: number } => {
|
||||
if (offerId !== activeOfferId) {
|
||||
return { accepted: false, nextOfferId: activeOfferId };
|
||||
}
|
||||
return { accepted: true, nextOfferId: activeOfferId + 1 };
|
||||
activeOfferId: number,
|
||||
offerId: number,
|
||||
) => {
|
||||
if (offerId !== activeOfferId) {
|
||||
return { accepted: false, nextOfferId: activeOfferId };
|
||||
}
|
||||
return { accepted: true, nextOfferId: activeOfferId + 1 };
|
||||
};
|
||||
|
||||
/** Toast chrome: widen on desktop only; leave mobile full-width to Sonner. */
|
||||
export const LARGE_TEXT_PASTE_TOAST_CLASSNAME =
|
||||
'[&_[data-icon]]:!hidden sm:!min-w-[22rem] sm:!w-auto';
|
||||
'[&_[data-icon]]:!hidden sm:!min-w-[22rem] sm:!w-auto';
|
||||
|
||||
Reference in New Issue
Block a user