mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-18 01:19:24 +00:00
allow even and odd to be clicked before any other terms
This commit is contained in:
parent
30072f4289
commit
6924ef2aa1
@ -21,10 +21,9 @@ export function appendExpression(currentInput: string, expr: string): string {
|
|||||||
// Produces a trailing space to allow the next token to be typed naturally.
|
// Produces a trailing space to allow the next token to be typed naturally.
|
||||||
export function insertOperatorSmart(currentInput: string, op: LogicalOperator): string {
|
export function insertOperatorSmart(currentInput: string, op: LogicalOperator): string {
|
||||||
const text = (currentInput || '').trim();
|
const text = (currentInput || '').trim();
|
||||||
if (text.length === 0) return `${op} `;
|
|
||||||
|
|
||||||
// Handle 'even' and 'odd' as page selection expressions, not logical operators
|
// Handle 'even' and 'odd' as page selection expressions, not logical operators
|
||||||
if (op === 'even' || op === 'odd') {
|
if (op === 'even' || op === 'odd') {
|
||||||
|
if (text.length === 0) return `${op} `;
|
||||||
// If current input ends with a logical operator, append the page selection with proper spacing
|
// If current input ends with a logical operator, append the page selection with proper spacing
|
||||||
const endsWithOperator = /(\b(and|not|or)\s*|[&|,!]\s*)$/i.test(text);
|
const endsWithOperator = /(\b(and|not|or)\s*|[&|,!]\s*)$/i.test(text);
|
||||||
if (endsWithOperator) {
|
if (endsWithOperator) {
|
||||||
@ -34,6 +33,8 @@ export function insertOperatorSmart(currentInput: string, op: LogicalOperator):
|
|||||||
}
|
}
|
||||||
return `${text} or ${op} `;
|
return `${text} or ${op} `;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (text.length === 0) return `${op} `;
|
||||||
|
|
||||||
// Extract up to the last two operator tokens (words or symbols) from the end
|
// Extract up to the last two operator tokens (words or symbols) from the end
|
||||||
const tokens: string[] = [];
|
const tokens: string[] = [];
|
||||||
|
@ -53,8 +53,7 @@ const OperatorsSection = ({ csvInput, onInsertOperator }: OperatorsSectionProps)
|
|||||||
variant="outline"
|
variant="outline"
|
||||||
className={classes.operatorChip}
|
className={classes.operatorChip}
|
||||||
onClick={() => onInsertOperator('even')}
|
onClick={() => onInsertOperator('even')}
|
||||||
disabled={!csvInput.trim()}
|
title="Select all even-numbered pages (2, 4, 6, 8...)"
|
||||||
title="Combine selections (both conditions must be true)"
|
|
||||||
>
|
>
|
||||||
<Text size="xs" fw={500}>even</Text>
|
<Text size="xs" fw={500}>even</Text>
|
||||||
</Button>
|
</Button>
|
||||||
@ -63,8 +62,7 @@ const OperatorsSection = ({ csvInput, onInsertOperator }: OperatorsSectionProps)
|
|||||||
variant="outline"
|
variant="outline"
|
||||||
className={classes.operatorChip}
|
className={classes.operatorChip}
|
||||||
onClick={() => onInsertOperator('odd')}
|
onClick={() => onInsertOperator('odd')}
|
||||||
disabled={!csvInput.trim()}
|
title="Select all odd-numbered pages (1, 3, 5, 7...)"
|
||||||
title="Add to selection (either condition can be true)"
|
|
||||||
>
|
>
|
||||||
<Text size="xs" fw={500}>odd</Text>
|
<Text size="xs" fw={500}>odd</Text>
|
||||||
</Button>
|
</Button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user