@lvce-editor/find-widget-worker 3.5.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/findWidgetWorkerMain.js +35 -35
- package/package.json +1 -1
|
@@ -1127,7 +1127,7 @@ const isEqual$8 = (oldState, newState) => {
|
|
|
1127
1127
|
};
|
|
1128
1128
|
|
|
1129
1129
|
const isEqual$7 = (oldState, newState) => {
|
|
1130
|
-
return
|
|
1130
|
+
return oldState.width === newState.width && oldState.height === newState.height && oldState.x === newState.x && oldState.searchInputHeight === newState.searchInputHeight;
|
|
1131
1131
|
};
|
|
1132
1132
|
|
|
1133
1133
|
const isEqual$6 = (oldState, newState) => {
|
|
@@ -1309,8 +1309,8 @@ const buildRegex = (searchString, options) => {
|
|
|
1309
1309
|
};
|
|
1310
1310
|
} catch (error) {
|
|
1311
1311
|
return {
|
|
1312
|
-
error:
|
|
1313
|
-
regex:
|
|
1312
|
+
error: String(error),
|
|
1313
|
+
regex: /.^/
|
|
1314
1314
|
};
|
|
1315
1315
|
}
|
|
1316
1316
|
};
|
|
@@ -1323,16 +1323,15 @@ const findRegexMatches = (lines, regex) => {
|
|
|
1323
1323
|
length
|
|
1324
1324
|
} = lines;
|
|
1325
1325
|
const matches = [];
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1326
|
+
const collectMatchesForLine = (line, lineIndex) => {
|
|
1327
|
+
let lastMatch = regex.exec(line);
|
|
1328
|
+
while (lastMatch) {
|
|
1329
|
+
matches.push(lineIndex, lastMatch.index, lastMatch[0].length);
|
|
1330
1330
|
lastMatch = regex.exec(line);
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
} while (true);
|
|
1331
|
+
}
|
|
1332
|
+
};
|
|
1333
|
+
for (let i = 0; i < length; i++) {
|
|
1334
|
+
collectMatchesForLine(lines[i], i);
|
|
1336
1335
|
}
|
|
1337
1336
|
return new Uint32Array(matches);
|
|
1338
1337
|
};
|
|
@@ -1520,20 +1519,22 @@ const applyRegexReplacement = (originalText, regex, replacement) => {
|
|
|
1520
1519
|
let result = replacement;
|
|
1521
1520
|
|
|
1522
1521
|
// Handle $& (entire match)
|
|
1523
|
-
result = result.replaceAll('$&',
|
|
1522
|
+
result = result.replaceAll('$&', () => {
|
|
1523
|
+
return match[0];
|
|
1524
|
+
});
|
|
1524
1525
|
|
|
1525
1526
|
// Handle $` (text before match) - in this context it's empty since we're matching the whole text
|
|
1526
|
-
result = result.replaceAll('$`', '');
|
|
1527
|
+
result = result.replaceAll('$`', () => '');
|
|
1527
1528
|
|
|
1528
1529
|
// Handle $' (text after match) - in this context it's empty since we're matching the whole text
|
|
1529
|
-
result = result.replaceAll("$'", '');
|
|
1530
|
+
result = result.replaceAll("$'", () => '');
|
|
1530
1531
|
|
|
1531
1532
|
// Handle $$ (literal $)
|
|
1532
|
-
result = result.replaceAll('$$', '\
|
|
1533
|
+
result = result.replaceAll('$$', '\u{0}DOLLAR\u{0}');
|
|
1533
1534
|
|
|
1534
1535
|
// Handle $n and $nn (numbered capture groups)
|
|
1535
1536
|
result = result.replaceAll(/\$(\d{1,2})/g, (_match, groupNumber) => {
|
|
1536
|
-
const index = Number
|
|
1537
|
+
const index = Number(groupNumber);
|
|
1537
1538
|
if (index < match.length) {
|
|
1538
1539
|
return match[index] ?? '';
|
|
1539
1540
|
}
|
|
@@ -1541,7 +1542,7 @@ const applyRegexReplacement = (originalText, regex, replacement) => {
|
|
|
1541
1542
|
});
|
|
1542
1543
|
|
|
1543
1544
|
// Restore literal $
|
|
1544
|
-
result = result.replaceAll('\
|
|
1545
|
+
result = result.replaceAll('\u{0}DOLLAR\u{0}', '$');
|
|
1545
1546
|
return result;
|
|
1546
1547
|
};
|
|
1547
1548
|
|
|
@@ -1604,6 +1605,15 @@ const getEdits = (matches, value, replacement, startIndex, replaceAll, lines, pr
|
|
|
1604
1605
|
regex = builtRegex;
|
|
1605
1606
|
}
|
|
1606
1607
|
}
|
|
1608
|
+
const lineOffsets = [];
|
|
1609
|
+
let lineOffset = 0;
|
|
1610
|
+
for (let row = 0; row < lines.length; row++) {
|
|
1611
|
+
lineOffsets[row] = lineOffset;
|
|
1612
|
+
lineOffset += lines[row].length + 1;
|
|
1613
|
+
}
|
|
1614
|
+
const getOffset = (rowIndex, columnIndex) => {
|
|
1615
|
+
return lineOffsets[rowIndex] + columnIndex;
|
|
1616
|
+
};
|
|
1607
1617
|
for (let i = fromIndex; i < toIndex; i++) {
|
|
1608
1618
|
const rowIndex = matches[i * 3];
|
|
1609
1619
|
const startColumnIndex = matches[i * 3 + 1];
|
|
@@ -1625,18 +1635,8 @@ const getEdits = (matches, value, replacement, startIndex, replaceAll, lines, pr
|
|
|
1625
1635
|
if (preserveCaseOption) {
|
|
1626
1636
|
finalReplacement = preserveCase$1(originalText, finalReplacement);
|
|
1627
1637
|
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
let startOffset = 0;
|
|
1631
|
-
for (let row = 0; row < rowIndex; row++) {
|
|
1632
|
-
startOffset += lines[row].length + 1; // +1 for newline character
|
|
1633
|
-
}
|
|
1634
|
-
startOffset += startColumnIndex;
|
|
1635
|
-
let endOffset = 0;
|
|
1636
|
-
for (let row = 0; row < rowIndex; row++) {
|
|
1637
|
-
endOffset += lines[row].length + 1; // +1 for newline character
|
|
1638
|
-
}
|
|
1639
|
-
endOffset += endColumnIndex;
|
|
1638
|
+
const startOffset = getOffset(rowIndex, startColumnIndex);
|
|
1639
|
+
const endOffset = getOffset(rowIndex, endColumnIndex);
|
|
1640
1640
|
edits.push({
|
|
1641
1641
|
endOffset,
|
|
1642
1642
|
inserted: finalReplacement,
|
|
@@ -2472,6 +2472,9 @@ const getSearchFieldButtonVirtualDom = button => {
|
|
|
2472
2472
|
};
|
|
2473
2473
|
|
|
2474
2474
|
const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, outsideButtons, onFocus, extraClassName, autofocus = false) => {
|
|
2475
|
+
if (outsideButtons.length > 0) {
|
|
2476
|
+
throw new Error('outsideButtons are deprecated');
|
|
2477
|
+
}
|
|
2475
2478
|
const dom = [{
|
|
2476
2479
|
childCount: 2,
|
|
2477
2480
|
className: mergeClassNames(SearchField, extraClassName),
|
|
@@ -2488,17 +2491,14 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
|
|
|
2488
2491
|
placeholder,
|
|
2489
2492
|
spellcheck: false,
|
|
2490
2493
|
type: TextArea,
|
|
2491
|
-
...(autofocus
|
|
2494
|
+
...(autofocus && {
|
|
2492
2495
|
autofocus: true
|
|
2493
|
-
}
|
|
2496
|
+
})
|
|
2494
2497
|
}, {
|
|
2495
2498
|
childCount: insideButtons.length,
|
|
2496
2499
|
className: SearchFieldButtons,
|
|
2497
2500
|
type: Div
|
|
2498
2501
|
}, ...insideButtons.flatMap(getSearchFieldButtonVirtualDom)];
|
|
2499
|
-
if (outsideButtons.length > 0) {
|
|
2500
|
-
throw new Error('outsideButtons are deprecated');
|
|
2501
|
-
}
|
|
2502
2502
|
return dom;
|
|
2503
2503
|
};
|
|
2504
2504
|
|