@lvce-editor/editor-worker 19.20.1 → 19.21.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/editorWorkerMain.js +21 -7
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -5239,20 +5239,28 @@ const handleBlur$1 = async editor => {
|
|
|
5239
5239
|
|
|
5240
5240
|
const replaceRange = (editor, ranges, replacement, origin) => {
|
|
5241
5241
|
const changes = [];
|
|
5242
|
+
const columnDeltas = new Map();
|
|
5242
5243
|
const rangesLength = ranges.length;
|
|
5243
5244
|
for (let i = 0; i < rangesLength; i += 4) {
|
|
5244
5245
|
const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(ranges, i);
|
|
5246
|
+
const columnDelta = selectionStartRow === selectionEndRow ? columnDeltas.get(selectionStartRow) ?? 0 : 0;
|
|
5245
5247
|
const start = {
|
|
5246
|
-
columnIndex: selectionStartColumn,
|
|
5248
|
+
columnIndex: selectionStartColumn + columnDelta,
|
|
5247
5249
|
rowIndex: selectionStartRow
|
|
5248
5250
|
};
|
|
5249
5251
|
const end = {
|
|
5250
|
-
columnIndex: selectionEndColumn,
|
|
5252
|
+
columnIndex: selectionEndColumn + columnDelta,
|
|
5251
5253
|
rowIndex: selectionEndRow
|
|
5252
5254
|
};
|
|
5253
5255
|
const selection = {
|
|
5254
|
-
end
|
|
5255
|
-
|
|
5256
|
+
end: {
|
|
5257
|
+
columnIndex: selectionEndColumn,
|
|
5258
|
+
rowIndex: selectionEndRow
|
|
5259
|
+
},
|
|
5260
|
+
start: {
|
|
5261
|
+
columnIndex: selectionStartColumn,
|
|
5262
|
+
rowIndex: selectionStartRow
|
|
5263
|
+
}
|
|
5256
5264
|
};
|
|
5257
5265
|
changes.push({
|
|
5258
5266
|
deleted: getSelectionText(editor, selection),
|
|
@@ -5261,6 +5269,14 @@ const replaceRange = (editor, ranges, replacement, origin) => {
|
|
|
5261
5269
|
origin,
|
|
5262
5270
|
start: start
|
|
5263
5271
|
});
|
|
5272
|
+
if (selectionStartRow === selectionEndRow) {
|
|
5273
|
+
if (replacement.length <= 1) {
|
|
5274
|
+
const insertedLength = replacement[0]?.length ?? 0;
|
|
5275
|
+
columnDeltas.set(selectionStartRow, columnDelta + insertedLength - (selectionEndColumn - selectionStartColumn));
|
|
5276
|
+
} else {
|
|
5277
|
+
columnDeltas.set(selectionStartRow, replacement.at(-1).length - selectionEndColumn);
|
|
5278
|
+
}
|
|
5279
|
+
}
|
|
5264
5280
|
}
|
|
5265
5281
|
return changes;
|
|
5266
5282
|
};
|
|
@@ -8400,9 +8416,7 @@ const selectionGrow = async editor => {
|
|
|
8400
8416
|
|
|
8401
8417
|
const getSelectionEditsSingleLineWord = (lines, selections) => {
|
|
8402
8418
|
const lastSelectionIndex = selections.length - 4;
|
|
8403
|
-
const rowIndex = selections
|
|
8404
|
-
const lastSelectionStartColumnIndex = selections[lastSelectionIndex + 1];
|
|
8405
|
-
const lastSelectionEndColumnIndex = selections[lastSelectionIndex + 3];
|
|
8419
|
+
const [rowIndex, lastSelectionStartColumnIndex,, lastSelectionEndColumnIndex] = getSelectionPairs(selections, lastSelectionIndex);
|
|
8406
8420
|
const line = lines[rowIndex];
|
|
8407
8421
|
const word = line.slice(lastSelectionStartColumnIndex, lastSelectionEndColumnIndex);
|
|
8408
8422
|
const columnIndexAfter = line.indexOf(word, lastSelectionEndColumnIndex);
|