@lvce-editor/editor-worker 5.4.0 → 5.6.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.
@@ -147,9 +147,10 @@ const Format = 'format';
147
147
  const IndentLess = 'indentLess';
148
148
  const IndentMore = 'indentMore';
149
149
  const InsertLineBreak = 'insertLineBreak';
150
+ const LineComment = 'lineComment';
151
+ const Rename$1 = 'rename';
150
152
  const ReplaceAll$2 = 'replaceAll';
151
153
  const ToggleBlockComment = 'toggleBlockComment';
152
- const Rename$1 = 'rename';
153
154
 
154
155
  const map$1 = Object.create(null);
155
156
  const set$7 = (id, widget) => {
@@ -1852,6 +1853,9 @@ const updateDiagnostics = async newState => {
1852
1853
  // TODO sync and ask for diagnostics at the same time?
1853
1854
  // TODO throttle diagnostics
1854
1855
  const content = getText$1(newState);
1856
+
1857
+ // TODO don't really need text document sync response
1858
+ // could perhaps save a lot of messages by using send instead of invoke
1855
1859
  await invoke$2(TextDocumentSyncFull, newState.uri, newState.id, newState.languageId, content);
1856
1860
  const diagnostics = await executeDiagnosticProvider(newState);
1857
1861
  const latest = get$6(newState.id);
@@ -6827,7 +6831,7 @@ const getEditorHoverInfo = async (editorUid, position) => {
6827
6831
  } = hover;
6828
6832
  const tokenizerPath = '';
6829
6833
  const lineInfos = await tokenizeCodeBlock(displayString, displayStringLanguageId || fallbackDisplayStringLanguageId, tokenizerPath);
6830
- const wordPart = await getWordBefore(editor, rowIndex, columnIndex);
6834
+ const wordPart = getWordBefore(editor, rowIndex, columnIndex);
6831
6835
  const wordStart = columnIndex - wordPart.length;
6832
6836
  await measureTextBlockHeight(documentation, hoverDocumentationFontFamily, hoverDocumentationFontSize, hoverDocumentationLineHeight, hoverDocumentationWidth);
6833
6837
  const {
@@ -6865,6 +6869,7 @@ const loadHoverContent = async state => {
6865
6869
  documentation,
6866
6870
  x,
6867
6871
  y,
6872
+ width: 600,
6868
6873
  diagnostics: matchingDiagnostics
6869
6874
  };
6870
6875
  };
@@ -7168,14 +7173,11 @@ const getBlockComment = async editor => {
7168
7173
 
7169
7174
  const RE_WHITESPACE_AT_START$1 = /^\s+/;
7170
7175
  const RE_WHITESPACE_AT_END = /\s+$/;
7171
-
7172
- // @ts-ignore
7173
- const toggleBlockComment = async editor => {
7174
- const blockComment = await getBlockComment(editor);
7175
- if (!blockComment) {
7176
- return editor;
7177
- }
7178
- const rowIndex = editor.selections[0];
7176
+ const getBlockCommentEdits = (editor, blockComment) => {
7177
+ const {
7178
+ selections
7179
+ } = editor;
7180
+ const [rowIndex] = selections;
7179
7181
  const line = getLine(editor, rowIndex);
7180
7182
  const numberOfLines = editor.lines.length;
7181
7183
  let endRowIndex = rowIndex;
@@ -7229,18 +7231,7 @@ const toggleBlockComment = async editor => {
7229
7231
  deleted: [blockCommentEnd],
7230
7232
  origin: ToggleBlockComment
7231
7233
  };
7232
- // @ts-ignore
7233
7234
  changes.push(change1, change2);
7234
- // Editor.moveCursors(editor, (editor, cursor) => {
7235
- // let newColumnIndex = cursor.columnIndex - blockComment[0].length
7236
- // if (cursor.columnIndex === endColumnIndex + blockComment[1].length) {
7237
- // newColumnIndex -= blockComment[1].length
7238
- // }
7239
- // return {
7240
- // rowIndex: cursor.rowIndex,
7241
- // columnIndex: newColumnIndex,
7242
- // }
7243
- // })
7244
7235
  } else {
7245
7236
  const change1 = {
7246
7237
  start: {
@@ -7363,7 +7354,16 @@ const toggleBlockComment = async editor => {
7363
7354
  // }
7364
7355
  // RendererProcess.invoke(/* setLines */ 2135, /* lines */ lines)
7365
7356
 
7366
- return scheduleDocument(editor, changes);
7357
+ return changes;
7358
+ };
7359
+
7360
+ const toggleBlockComment = async editor => {
7361
+ const blockComment = await getBlockComment(editor);
7362
+ if (!blockComment) {
7363
+ return editor;
7364
+ }
7365
+ const edits = getBlockCommentEdits(editor, blockComment);
7366
+ return scheduleDocument(editor, edits);
7367
7367
  };
7368
7368
 
7369
7369
  const getLineComment = async editor => {
@@ -7383,7 +7383,7 @@ const getLineCommentEdit = (rowIndex, line, lineComment) => {
7383
7383
  if (line[index + lineComment.length] === ' ') {
7384
7384
  return {
7385
7385
  inserted: [''],
7386
- deleted: [lineComment.length + 1],
7386
+ deleted: [lineComment + ' '],
7387
7387
  start: {
7388
7388
  rowIndex,
7389
7389
  columnIndex: index
@@ -7392,7 +7392,7 @@ const getLineCommentEdit = (rowIndex, line, lineComment) => {
7392
7392
  rowIndex,
7393
7393
  columnIndex: index + lineComment.length + 1
7394
7394
  },
7395
- type: /* singleLineEdit */1
7395
+ origin: LineComment
7396
7396
  };
7397
7397
  }
7398
7398
  return {
@@ -7406,7 +7406,7 @@ const getLineCommentEdit = (rowIndex, line, lineComment) => {
7406
7406
  rowIndex,
7407
7407
  columnIndex: index + lineComment.length
7408
7408
  },
7409
- type: /* singleLineEdit */1
7409
+ origin: LineComment
7410
7410
  };
7411
7411
  }
7412
7412
  return {
@@ -7420,11 +7420,10 @@ const getLineCommentEdit = (rowIndex, line, lineComment) => {
7420
7420
  rowIndex,
7421
7421
  columnIndex: index
7422
7422
  },
7423
- type: /* singleLineEdit */1
7423
+ origin: LineComment
7424
7424
  };
7425
7425
  };
7426
7426
 
7427
- // @ts-ignore
7428
7427
  const editorToggleLineComment = async editor => {
7429
7428
  const lineComment = await getLineComment(editor);
7430
7429
  if (!lineComment) {
@@ -8020,7 +8019,7 @@ const handleSashPointerUp = (state, eventX, eventY) => {
8020
8019
  return state;
8021
8020
  };
8022
8021
 
8023
- const CodeGeneratorInput = 'CodeGeneratorInput';
8022
+ const CodeGeneratorInput$1 = 'CodeGeneratorInput';
8024
8023
  const CodeGeneratorMessage = 'CodeGeneratorMessage';
8025
8024
  const CodeGeneratorWidget = 'CodeGeneratorWidget';
8026
8025
  const ColoredMaskIcon = 'ColoredMaskIcon';
@@ -8211,10 +8210,10 @@ const renderBounds$7 = {
8211
8210
  const {
8212
8211
  x,
8213
8212
  y,
8213
+ width,
8214
8214
  height
8215
8215
  } = newState;
8216
- const renderWidth = 200;
8217
- return [SetBounds, x, y, renderWidth, height];
8216
+ return [SetBounds, x, y, width, height];
8218
8217
  }
8219
8218
  };
8220
8219
  const render$g = [renderHoverDom, renderBounds$7];
@@ -10166,6 +10165,9 @@ const removeWidget = widget => {
10166
10165
  return [['Viewlet.send', widget.newState.uid, 'dispose']];
10167
10166
  };
10168
10167
 
10168
+ const CodeGeneratorInput = 'CodeGeneratorInput';
10169
+ const ToggleReplace$1 = 'ToggleReplace';
10170
+
10169
10171
  const getCodeGeneratorVirtualDom = state => {
10170
10172
  const escapeToClose$1 = escapeToClose();
10171
10173
  const enterCode$1 = enterCode();
@@ -10175,10 +10177,10 @@ const getCodeGeneratorVirtualDom = state => {
10175
10177
  childCount: 2
10176
10178
  }, {
10177
10179
  type: Input,
10178
- className: mergeClassNames(CodeGeneratorInput, InputBox),
10180
+ className: mergeClassNames(CodeGeneratorInput$1, InputBox),
10179
10181
  childCount: 0,
10180
10182
  placeholder: enterCode$1,
10181
- name: 'CodeGeneratorInput'
10183
+ name: CodeGeneratorInput
10182
10184
  }, {
10183
10185
  type: Div,
10184
10186
  className: CodeGeneratorMessage,
@@ -11103,7 +11105,7 @@ const getSearchToggleButtonVirtualDom = (replaceExpanded, onClick = '') => {
11103
11105
  title: 'Toggle Replace',
11104
11106
  ariaLabel: 'Toggle Replace',
11105
11107
  ariaExpanded: replaceExpanded,
11106
- name: 'ToggleReplace',
11108
+ name: ToggleReplace$1,
11107
11109
  childCount: 1,
11108
11110
  'data-command': 'toggleReplace',
11109
11111
  onClick,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "5.4.0",
3
+ "version": "5.6.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",