更新换行算法和APP-PUSH
This commit is contained in:
21
client/src/features/textWrap/searchWidget/constraints.ts
Normal file
21
client/src/features/textWrap/searchWidget/constraints.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { Token } from '../core/types';
|
||||
|
||||
export const DEFAULT_TOO_LONG_THRESHOLDS = Object.freeze({ EN: 30, TC: 60 });
|
||||
|
||||
export function isTooLong(tokens: Token[], lang: 'TC' | 'EN', thresholds: { EN: number; TC: number }): boolean {
|
||||
const n = Math.max(0, tokens.length | 0);
|
||||
const limit = lang === 'EN' ? thresholds.EN : thresholds.TC;
|
||||
return n > limit;
|
||||
}
|
||||
|
||||
export function isLineStartPunctTC(tokens: Token[], nextPos: number, tcPunctuations: string[]): boolean {
|
||||
const p = nextPos | 0;
|
||||
if (p <= 0) return false;
|
||||
const t = tokens[p]?.text ?? '';
|
||||
return tcPunctuations.includes(t);
|
||||
}
|
||||
|
||||
export function approxWidth(tokenCount: number, charCount: number, lang: 'TC' | 'EN'): number {
|
||||
return lang === 'EN' ? tokenCount : charCount;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user