@lvce-editor/editor-worker 18.7.0 → 18.8.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.
@@ -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 = /(?:(?:https?|ftp|ftps|file):\/\/)?(?:www\.)?(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\/[^\s"']*)?/g;
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):\/\//;
@@ -3081,7 +3081,7 @@ const getTabCount = string => {
3081
3081
  return count;
3082
3082
  };
3083
3083
 
3084
- const RE_ASCII = /^[\p{ASCII}]*$/u;
3084
+ const RE_ASCII = /^\p{ASCII}*$/u;
3085
3085
  const isAscii = line => {
3086
3086
  return RE_ASCII.test(line);
3087
3087
  };
@@ -6206,11 +6206,7 @@ const handleMouseMoveWithAltKey = async (editor, x, y) => {
6206
6206
  // TODO make sure that editor is not disposed
6207
6207
 
6208
6208
  const definitionStartPosition = positionAt(editor, definition.startOffset);
6209
- const definitionEndPosition = positionAt(editor, definition.endOffset);
6210
- // @ts-ignore
6211
- const definitionRelativeStartX = definitionStartPosition.columnIndex;
6212
- // @ts-ignore
6213
- const definitionRelativeEndX = definitionEndPosition.columnIndex;
6209
+ positionAt(editor, definition.endOffset);
6214
6210
  // const definitionRelativeY = definitionStartPosition.rowIndex - editor.minLineY
6215
6211
 
6216
6212
  const lineTokenMap = editor.lineCache[definitionStartPosition.rowIndex + 1];
@@ -6531,7 +6527,8 @@ const setDelta = (editor, deltaMode, eventDeltaX, eventDeltaY) => {
6531
6527
  number(eventDeltaY);
6532
6528
  // @ts-ignore
6533
6529
  const {
6534
- deltaX} = editor;
6530
+ deltaX
6531
+ } = editor;
6535
6532
  if (eventDeltaX === 0) {
6536
6533
  return setDeltaY(editor, eventDeltaY);
6537
6534
  }
@@ -7328,7 +7325,7 @@ const logError = async error => {
7328
7325
  };
7329
7326
  const handleError = async error => {
7330
7327
  try {
7331
- const prettyError = await logError(error);
7328
+ await logError(error);
7332
7329
  } catch (otherError) {
7333
7330
  console.warn('ErrorHandling error');
7334
7331
  console.warn(otherError);
@@ -7435,13 +7432,8 @@ const getNewSelections$4 = (selections, lines, getDelta) => {
7435
7432
  for (let i = 0; i < selections.length; i += 4) {
7436
7433
  // @ts-ignore
7437
7434
  const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
7438
- if (selectionStartRow === selectionEndRow && selectionStartColumn === selectionEndColumn) {
7439
- moveToPositionLeft(newSelections, i + 2, selectionStartRow, selectionStartColumn, lines, getDelta);
7440
- moveToPositionEqual(newSelections, i, selectionEndRow, selectionEndColumn);
7441
- } else {
7442
- moveToPositionLeft(newSelections, i + 2, selectionStartRow, selectionStartColumn, lines, getDelta);
7443
- moveToPositionEqual(newSelections, i, selectionEndRow, selectionEndColumn);
7444
- }
7435
+ moveToPositionLeft(newSelections, i + 2, selectionStartRow, selectionStartColumn, lines, getDelta);
7436
+ moveToPositionEqual(newSelections, i, selectionEndRow, selectionEndColumn);
7445
7437
  }
7446
7438
  return newSelections;
7447
7439
  };
@@ -8450,6 +8442,27 @@ const getBlockComment = async (editor, offset) => {
8450
8442
 
8451
8443
  const RE_WHITESPACE_AT_START$1 = /^\s+/;
8452
8444
  const RE_WHITESPACE_AT_END = /\s+$/;
8445
+ const createDeleteEdit = (rowIndex, columnIndex, text) => {
8446
+ return {
8447
+ deleted: [text],
8448
+ end: {
8449
+ columnIndex: columnIndex + text.length,
8450
+ rowIndex
8451
+ },
8452
+ inserted: [],
8453
+ origin: ToggleBlockComment$1,
8454
+ start: {
8455
+ columnIndex,
8456
+ rowIndex
8457
+ }
8458
+ };
8459
+ };
8460
+ const getRemoveBlockCommentEdits = (rowIndex, startRowIndex, startColumnIndex, endRowIndex, endColumnIndex, blockCommentStart, blockCommentEnd) => {
8461
+ if (startRowIndex === endRowIndex) {
8462
+ return [createDeleteEdit(rowIndex, startColumnIndex, blockCommentStart), createDeleteEdit(rowIndex, endColumnIndex - blockCommentStart.length, blockCommentEnd)];
8463
+ }
8464
+ return [createDeleteEdit(startRowIndex, startColumnIndex, blockCommentStart), createDeleteEdit(endRowIndex, endColumnIndex, blockCommentEnd)];
8465
+ };
8453
8466
  const getBlockCommentEdits = (editor, blockComment) => {
8454
8467
  const {
8455
8468
  selections
@@ -8481,75 +8494,19 @@ const getBlockCommentEdits = (editor, blockComment) => {
8481
8494
  }
8482
8495
  const changes = [];
8483
8496
  if (startColumnIndex !== -1 && endColumnIndex !== -1) {
8484
- if (startRowIndex === endRowIndex) {
8485
- const change1 = {
8486
- deleted: [blockCommentStart],
8487
- end: {
8488
- columnIndex: startColumnIndex + blockCommentStart.length,
8489
- rowIndex
8490
- },
8491
- inserted: [],
8492
- origin: ToggleBlockComment$1,
8493
- start: {
8494
- columnIndex: startColumnIndex,
8495
- rowIndex
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
- }
8497
+ changes.push(...getRemoveBlockCommentEdits(rowIndex, startRowIndex, startColumnIndex, endRowIndex, endColumnIndex, blockCommentStart, blockCommentEnd));
8498
+
8499
+ // const oldRow1 = TextDocument.getLine(editor, startRowIndex)
8500
+ // const newRow1 =
8501
+ // oldRow1.slice(0, startColumnIndex) +
8502
+ // oldRow1.slice(startColumnIndex + blockCommentStart.length)
8503
+ // const oldRow2 = TextDocument.getLine(editor, endRowIndex)
8504
+ // const newRow2 =
8505
+ // oldRow2.slice(0, endColumnIndex) +
8506
+ // oldRow2.slice(endColumnIndex + blockCommentEnd.length)
8507
+ // // TODO use applyEdit to have undo functionality
8508
+ // TextDocument.setLine(editor, startRowIndex, newRow1)
8509
+ // TextDocument.setLine(editor, endRowIndex, newRow2)
8553
8510
  // TODO move cursors
8554
8511
  } else {
8555
8512
  const whitespaceAtStart = line.match(RE_WHITESPACE_AT_START$1);
@@ -9508,7 +9465,8 @@ const handleSashPointerDown = (state, eventX, eventY) => {
9508
9465
  const handleSashPointerMove = (state, eventX, eventY) => {
9509
9466
  // @ts-ignore
9510
9467
  const {
9511
- x} = state;
9468
+ x
9469
+ } = state;
9512
9470
  const minWidth = 100;
9513
9471
  const newWidth = Math.max(eventX - x, minWidth);
9514
9472
  return {
@@ -9602,7 +9560,9 @@ const hoverProblemDetail = {
9602
9560
  type: Span
9603
9561
  };
9604
9562
  const getChildCount = (lineInfos, documentation, diagnostics) => {
9605
- return lineInfos.length + documentation ? 1 : 0 + (diagnostics && diagnostics.length > 0) ? 1 : 0;
9563
+ const documentationCount = documentation ? 1 : 0;
9564
+ const diagnosticsCount = diagnostics && diagnostics.length > 0 ? 1 : 0;
9565
+ return lineInfos.length + documentationCount + diagnosticsCount;
9606
9566
  };
9607
9567
  const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
9608
9568
  const dom = [];
@@ -11272,7 +11232,6 @@ const diffChildren = (oldChildren, newChildren, patches) => {
11272
11232
  patches.push({
11273
11233
  type: NavigateParent
11274
11234
  });
11275
- currentChildIndex = -1;
11276
11235
  }
11277
11236
  // Add remove patches in reverse order (highest index first)
11278
11237
  // This ensures indices remain valid as we remove
@@ -12386,7 +12345,7 @@ const add$1 = widget => {
12386
12345
  return addWidget$1(widget, 'EditorCompletionDetails', render$1);
12387
12346
  };
12388
12347
  const remove$1 = removeWidget$1;
12389
- const handleEditorType = (editor, state) => {
12348
+ const handleEditorChange = (editor, state) => {
12390
12349
  const completionState = getCompletionState(editor);
12391
12350
  if (!completionState) {
12392
12351
  return editor;
@@ -12400,19 +12359,11 @@ const handleEditorType = (editor, state) => {
12400
12359
  x: detailX
12401
12360
  };
12402
12361
  };
12362
+ const handleEditorType = (editor, state) => {
12363
+ return handleEditorChange(editor, state);
12364
+ };
12403
12365
  const handleEditorDeleteLeft = (editor, state) => {
12404
- const completionState = getCompletionState(editor);
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
- };
12366
+ return handleEditorChange(editor, state);
12416
12367
  };
12417
12368
 
12418
12369
  const EditorCompletionDetailWidget = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "18.7.0",
3
+ "version": "18.8.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"