@lvce-editor/editor-worker 18.7.0 → 18.9.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 +85 -117
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -2878,7 +2878,7 @@ const getRegexMatches = (text, regex) => {
|
|
|
2878
2878
|
// Supports: http://, https://, ftp://, ftps://, file://
|
|
2879
2879
|
// Also matches URLs without explicit scheme (www.example.com)
|
|
2880
2880
|
// Excludes trailing quotes which are commonly used in JSON strings
|
|
2881
|
-
const URL_PATTERN = /(?:
|
|
2881
|
+
const URL_PATTERN = /(?:https?|ftps?|file):\/\/[^\s"']+|www\.[^\s"']+/g;
|
|
2882
2882
|
|
|
2883
2883
|
// Regex to check if URL has a scheme (http://, https://, ftp://, etc.)
|
|
2884
2884
|
const HAS_SCHEME_PATTERN = /^(?:https?|ftp|ftps|file):\/\//;
|
|
@@ -3042,6 +3042,37 @@ const notifyListeners = async (listenerType, method, ...params) => {
|
|
|
3042
3042
|
await Promise.all(notifications);
|
|
3043
3043
|
};
|
|
3044
3044
|
|
|
3045
|
+
const resize = (state, dimensions, columnWidth = state.columnWidth) => {
|
|
3046
|
+
const x = dimensions.x ?? state.x;
|
|
3047
|
+
const y = dimensions.y ?? state.y;
|
|
3048
|
+
const width = dimensions.width ?? state.width;
|
|
3049
|
+
const height = dimensions.height ?? state.height;
|
|
3050
|
+
const numberOfVisibleLines = Math.floor(height / state.itemHeight);
|
|
3051
|
+
const total = state.lines.length;
|
|
3052
|
+
const finalY = Math.max(total - numberOfVisibleLines, 0);
|
|
3053
|
+
const finalDeltaY = finalY * state.itemHeight;
|
|
3054
|
+
const deltaY = Math.min(state.deltaY, finalDeltaY);
|
|
3055
|
+
const minLineY = Math.floor(deltaY / state.itemHeight);
|
|
3056
|
+
const maxLineY = Math.min(minLineY + numberOfVisibleLines, total);
|
|
3057
|
+
const contentHeight = total * state.rowHeight;
|
|
3058
|
+
const scrollBarHeight = getScrollBarSize(height, contentHeight, state.minimumSliderSize);
|
|
3059
|
+
return {
|
|
3060
|
+
...state,
|
|
3061
|
+
columnWidth,
|
|
3062
|
+
deltaY,
|
|
3063
|
+
finalDeltaY,
|
|
3064
|
+
finalY,
|
|
3065
|
+
height,
|
|
3066
|
+
maxLineY,
|
|
3067
|
+
minLineY,
|
|
3068
|
+
numberOfVisibleLines,
|
|
3069
|
+
scrollBarHeight,
|
|
3070
|
+
width,
|
|
3071
|
+
x,
|
|
3072
|
+
y
|
|
3073
|
+
};
|
|
3074
|
+
};
|
|
3075
|
+
|
|
3045
3076
|
const splitLines = lines => {
|
|
3046
3077
|
if (!lines) {
|
|
3047
3078
|
return [''];
|
|
@@ -3081,7 +3112,7 @@ const getTabCount = string => {
|
|
|
3081
3112
|
return count;
|
|
3082
3113
|
};
|
|
3083
3114
|
|
|
3084
|
-
const RE_ASCII =
|
|
3115
|
+
const RE_ASCII = /^\p{ASCII}*$/u;
|
|
3085
3116
|
const isAscii = line => {
|
|
3086
3117
|
return RE_ASCII.test(line);
|
|
3087
3118
|
};
|
|
@@ -3604,26 +3635,12 @@ const hasSelection = editor => {
|
|
|
3604
3635
|
return editor.selections && editor.selections.length > 0;
|
|
3605
3636
|
};
|
|
3606
3637
|
const setBounds = (editor, x, y, width, height, columnWidth) => {
|
|
3607
|
-
|
|
3608
|
-
itemHeight
|
|
3609
|
-
} = editor;
|
|
3610
|
-
const numberOfVisibleLines = Math.floor(height / itemHeight);
|
|
3611
|
-
const total = editor.lines.length;
|
|
3612
|
-
const maxLineY = Math.min(numberOfVisibleLines, total);
|
|
3613
|
-
const finalY = Math.max(total - numberOfVisibleLines, 0);
|
|
3614
|
-
const finalDeltaY = finalY * itemHeight;
|
|
3615
|
-
return {
|
|
3616
|
-
...editor,
|
|
3617
|
-
columnWidth,
|
|
3618
|
-
finalDeltaY,
|
|
3619
|
-
finalY,
|
|
3638
|
+
return resize(editor, {
|
|
3620
3639
|
height,
|
|
3621
|
-
maxLineY,
|
|
3622
|
-
numberOfVisibleLines,
|
|
3623
3640
|
width,
|
|
3624
3641
|
x,
|
|
3625
3642
|
y
|
|
3626
|
-
};
|
|
3643
|
+
}, columnWidth);
|
|
3627
3644
|
};
|
|
3628
3645
|
const setText$1 = (editor, text) => {
|
|
3629
3646
|
const lines = splitLines(text);
|
|
@@ -6206,11 +6223,7 @@ const handleMouseMoveWithAltKey = async (editor, x, y) => {
|
|
|
6206
6223
|
// TODO make sure that editor is not disposed
|
|
6207
6224
|
|
|
6208
6225
|
const definitionStartPosition = positionAt(editor, definition.startOffset);
|
|
6209
|
-
|
|
6210
|
-
// @ts-ignore
|
|
6211
|
-
const definitionRelativeStartX = definitionStartPosition.columnIndex;
|
|
6212
|
-
// @ts-ignore
|
|
6213
|
-
const definitionRelativeEndX = definitionEndPosition.columnIndex;
|
|
6226
|
+
positionAt(editor, definition.endOffset);
|
|
6214
6227
|
// const definitionRelativeY = definitionStartPosition.rowIndex - editor.minLineY
|
|
6215
6228
|
|
|
6216
6229
|
const lineTokenMap = editor.lineCache[definitionStartPosition.rowIndex + 1];
|
|
@@ -6531,7 +6544,8 @@ const setDelta = (editor, deltaMode, eventDeltaX, eventDeltaY) => {
|
|
|
6531
6544
|
number(eventDeltaY);
|
|
6532
6545
|
// @ts-ignore
|
|
6533
6546
|
const {
|
|
6534
|
-
deltaX
|
|
6547
|
+
deltaX
|
|
6548
|
+
} = editor;
|
|
6535
6549
|
if (eventDeltaX === 0) {
|
|
6536
6550
|
return setDeltaY(editor, eventDeltaY);
|
|
6537
6551
|
}
|
|
@@ -7328,7 +7342,7 @@ const logError = async error => {
|
|
|
7328
7342
|
};
|
|
7329
7343
|
const handleError = async error => {
|
|
7330
7344
|
try {
|
|
7331
|
-
|
|
7345
|
+
await logError(error);
|
|
7332
7346
|
} catch (otherError) {
|
|
7333
7347
|
console.warn('ErrorHandling error');
|
|
7334
7348
|
console.warn(otherError);
|
|
@@ -7435,13 +7449,8 @@ const getNewSelections$4 = (selections, lines, getDelta) => {
|
|
|
7435
7449
|
for (let i = 0; i < selections.length; i += 4) {
|
|
7436
7450
|
// @ts-ignore
|
|
7437
7451
|
const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
moveToPositionEqual(newSelections, i, selectionEndRow, selectionEndColumn);
|
|
7441
|
-
} else {
|
|
7442
|
-
moveToPositionLeft(newSelections, i + 2, selectionStartRow, selectionStartColumn, lines, getDelta);
|
|
7443
|
-
moveToPositionEqual(newSelections, i, selectionEndRow, selectionEndColumn);
|
|
7444
|
-
}
|
|
7452
|
+
moveToPositionLeft(newSelections, i + 2, selectionStartRow, selectionStartColumn, lines, getDelta);
|
|
7453
|
+
moveToPositionEqual(newSelections, i, selectionEndRow, selectionEndColumn);
|
|
7445
7454
|
}
|
|
7446
7455
|
return newSelections;
|
|
7447
7456
|
};
|
|
@@ -8450,6 +8459,27 @@ const getBlockComment = async (editor, offset) => {
|
|
|
8450
8459
|
|
|
8451
8460
|
const RE_WHITESPACE_AT_START$1 = /^\s+/;
|
|
8452
8461
|
const RE_WHITESPACE_AT_END = /\s+$/;
|
|
8462
|
+
const createDeleteEdit = (rowIndex, columnIndex, text) => {
|
|
8463
|
+
return {
|
|
8464
|
+
deleted: [text],
|
|
8465
|
+
end: {
|
|
8466
|
+
columnIndex: columnIndex + text.length,
|
|
8467
|
+
rowIndex
|
|
8468
|
+
},
|
|
8469
|
+
inserted: [],
|
|
8470
|
+
origin: ToggleBlockComment$1,
|
|
8471
|
+
start: {
|
|
8472
|
+
columnIndex,
|
|
8473
|
+
rowIndex
|
|
8474
|
+
}
|
|
8475
|
+
};
|
|
8476
|
+
};
|
|
8477
|
+
const getRemoveBlockCommentEdits = (rowIndex, startRowIndex, startColumnIndex, endRowIndex, endColumnIndex, blockCommentStart, blockCommentEnd) => {
|
|
8478
|
+
if (startRowIndex === endRowIndex) {
|
|
8479
|
+
return [createDeleteEdit(rowIndex, startColumnIndex, blockCommentStart), createDeleteEdit(rowIndex, endColumnIndex - blockCommentStart.length, blockCommentEnd)];
|
|
8480
|
+
}
|
|
8481
|
+
return [createDeleteEdit(startRowIndex, startColumnIndex, blockCommentStart), createDeleteEdit(endRowIndex, endColumnIndex, blockCommentEnd)];
|
|
8482
|
+
};
|
|
8453
8483
|
const getBlockCommentEdits = (editor, blockComment) => {
|
|
8454
8484
|
const {
|
|
8455
8485
|
selections
|
|
@@ -8481,75 +8511,19 @@ const getBlockCommentEdits = (editor, blockComment) => {
|
|
|
8481
8511
|
}
|
|
8482
8512
|
const changes = [];
|
|
8483
8513
|
if (startColumnIndex !== -1 && endColumnIndex !== -1) {
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
};
|
|
8498
|
-
const change2 = {
|
|
8499
|
-
deleted: [blockCommentEnd],
|
|
8500
|
-
end: {
|
|
8501
|
-
columnIndex: endColumnIndex - blockCommentStart.length + blockCommentEnd.length,
|
|
8502
|
-
rowIndex
|
|
8503
|
-
},
|
|
8504
|
-
inserted: [],
|
|
8505
|
-
origin: ToggleBlockComment$1,
|
|
8506
|
-
start: {
|
|
8507
|
-
columnIndex: endColumnIndex - blockCommentStart.length,
|
|
8508
|
-
rowIndex
|
|
8509
|
-
}
|
|
8510
|
-
};
|
|
8511
|
-
changes.push(change1, change2);
|
|
8512
|
-
} else {
|
|
8513
|
-
const change1 = {
|
|
8514
|
-
deleted: [blockCommentStart],
|
|
8515
|
-
end: {
|
|
8516
|
-
columnIndex: startColumnIndex + blockCommentStart.length,
|
|
8517
|
-
rowIndex: startRowIndex
|
|
8518
|
-
},
|
|
8519
|
-
inserted: [],
|
|
8520
|
-
origin: ToggleBlockComment$1,
|
|
8521
|
-
start: {
|
|
8522
|
-
columnIndex: startColumnIndex,
|
|
8523
|
-
rowIndex: startRowIndex
|
|
8524
|
-
}
|
|
8525
|
-
};
|
|
8526
|
-
const change2 = {
|
|
8527
|
-
deleted: [blockCommentEnd],
|
|
8528
|
-
end: {
|
|
8529
|
-
columnIndex: endColumnIndex + blockCommentEnd.length,
|
|
8530
|
-
rowIndex: endRowIndex
|
|
8531
|
-
},
|
|
8532
|
-
inserted: [],
|
|
8533
|
-
origin: ToggleBlockComment$1,
|
|
8534
|
-
start: {
|
|
8535
|
-
columnIndex: endColumnIndex,
|
|
8536
|
-
rowIndex: endRowIndex
|
|
8537
|
-
}
|
|
8538
|
-
};
|
|
8539
|
-
changes.push(change1, change2);
|
|
8540
|
-
|
|
8541
|
-
// const oldRow1 = TextDocument.getLine(editor, startRowIndex)
|
|
8542
|
-
// const newRow1 =
|
|
8543
|
-
// oldRow1.slice(0, startColumnIndex) +
|
|
8544
|
-
// oldRow1.slice(startColumnIndex + blockCommentStart.length)
|
|
8545
|
-
// const oldRow2 = TextDocument.getLine(editor, endRowIndex)
|
|
8546
|
-
// const newRow2 =
|
|
8547
|
-
// oldRow2.slice(0, endColumnIndex) +
|
|
8548
|
-
// oldRow2.slice(endColumnIndex + blockCommentEnd.length)
|
|
8549
|
-
// // TODO use applyEdit to have undo functionality
|
|
8550
|
-
// TextDocument.setLine(editor, startRowIndex, newRow1)
|
|
8551
|
-
// TextDocument.setLine(editor, endRowIndex, newRow2)
|
|
8552
|
-
}
|
|
8514
|
+
changes.push(...getRemoveBlockCommentEdits(rowIndex, startRowIndex, startColumnIndex, endRowIndex, endColumnIndex, blockCommentStart, blockCommentEnd));
|
|
8515
|
+
|
|
8516
|
+
// const oldRow1 = TextDocument.getLine(editor, startRowIndex)
|
|
8517
|
+
// const newRow1 =
|
|
8518
|
+
// oldRow1.slice(0, startColumnIndex) +
|
|
8519
|
+
// oldRow1.slice(startColumnIndex + blockCommentStart.length)
|
|
8520
|
+
// const oldRow2 = TextDocument.getLine(editor, endRowIndex)
|
|
8521
|
+
// const newRow2 =
|
|
8522
|
+
// oldRow2.slice(0, endColumnIndex) +
|
|
8523
|
+
// oldRow2.slice(endColumnIndex + blockCommentEnd.length)
|
|
8524
|
+
// // TODO use applyEdit to have undo functionality
|
|
8525
|
+
// TextDocument.setLine(editor, startRowIndex, newRow1)
|
|
8526
|
+
// TextDocument.setLine(editor, endRowIndex, newRow2)
|
|
8553
8527
|
// TODO move cursors
|
|
8554
8528
|
} else {
|
|
8555
8529
|
const whitespaceAtStart = line.match(RE_WHITESPACE_AT_START$1);
|
|
@@ -9508,7 +9482,8 @@ const handleSashPointerDown = (state, eventX, eventY) => {
|
|
|
9508
9482
|
const handleSashPointerMove = (state, eventX, eventY) => {
|
|
9509
9483
|
// @ts-ignore
|
|
9510
9484
|
const {
|
|
9511
|
-
x
|
|
9485
|
+
x
|
|
9486
|
+
} = state;
|
|
9512
9487
|
const minWidth = 100;
|
|
9513
9488
|
const newWidth = Math.max(eventX - x, minWidth);
|
|
9514
9489
|
return {
|
|
@@ -9602,7 +9577,9 @@ const hoverProblemDetail = {
|
|
|
9602
9577
|
type: Span
|
|
9603
9578
|
};
|
|
9604
9579
|
const getChildCount = (lineInfos, documentation, diagnostics) => {
|
|
9605
|
-
|
|
9580
|
+
const documentationCount = documentation ? 1 : 0;
|
|
9581
|
+
const diagnosticsCount = diagnostics && diagnostics.length > 0 ? 1 : 0;
|
|
9582
|
+
return lineInfos.length + documentationCount + diagnosticsCount;
|
|
9606
9583
|
};
|
|
9607
9584
|
const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
|
|
9608
9585
|
const dom = [];
|
|
@@ -11272,7 +11249,6 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
11272
11249
|
patches.push({
|
|
11273
11250
|
type: NavigateParent
|
|
11274
11251
|
});
|
|
11275
|
-
currentChildIndex = -1;
|
|
11276
11252
|
}
|
|
11277
11253
|
// Add remove patches in reverse order (highest index first)
|
|
11278
11254
|
// This ensures indices remain valid as we remove
|
|
@@ -12386,7 +12362,7 @@ const add$1 = widget => {
|
|
|
12386
12362
|
return addWidget$1(widget, 'EditorCompletionDetails', render$1);
|
|
12387
12363
|
};
|
|
12388
12364
|
const remove$1 = removeWidget$1;
|
|
12389
|
-
const
|
|
12365
|
+
const handleEditorChange = (editor, state) => {
|
|
12390
12366
|
const completionState = getCompletionState(editor);
|
|
12391
12367
|
if (!completionState) {
|
|
12392
12368
|
return editor;
|
|
@@ -12400,19 +12376,11 @@ const handleEditorType = (editor, state) => {
|
|
|
12400
12376
|
x: detailX
|
|
12401
12377
|
};
|
|
12402
12378
|
};
|
|
12379
|
+
const handleEditorType = (editor, state) => {
|
|
12380
|
+
return handleEditorChange(editor, state);
|
|
12381
|
+
};
|
|
12403
12382
|
const handleEditorDeleteLeft = (editor, state) => {
|
|
12404
|
-
|
|
12405
|
-
if (!completionState) {
|
|
12406
|
-
return editor;
|
|
12407
|
-
}
|
|
12408
|
-
const {
|
|
12409
|
-
x
|
|
12410
|
-
} = getPositionAtCursor$1(editor);
|
|
12411
|
-
const detailX = x + completionState.width - state.borderSize;
|
|
12412
|
-
return {
|
|
12413
|
-
...state,
|
|
12414
|
-
x: detailX
|
|
12415
|
-
};
|
|
12383
|
+
return handleEditorChange(editor, state);
|
|
12416
12384
|
};
|
|
12417
12385
|
|
|
12418
12386
|
const EditorCompletionDetailWidget = {
|