@lvce-editor/editor-worker 19.69.4 → 19.69.6

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.
@@ -1234,7 +1234,7 @@ const create$c = rpcId => {
1234
1234
  };
1235
1235
  };
1236
1236
 
1237
- const Text = 12;
1237
+ const Text$1 = 12;
1238
1238
  const Reference = 100;
1239
1239
 
1240
1240
  const AltKey = 'event.altKey';
@@ -3986,7 +3986,7 @@ const moveRangeToPosition$1 = (selections, i, rowIndex, columnIndex) => {
3986
3986
  selections[i] = selections[i + 2] = rowIndex;
3987
3987
  selections[i + 1] = selections[i + 3] = columnIndex;
3988
3988
  };
3989
- const isEmpty = (selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn) => {
3989
+ const isEmpty$1 = (selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn) => {
3990
3990
  return selectionStartRow === selectionEndRow && selectionStartColumn === selectionEndColumn;
3991
3991
  };
3992
3992
  const isSelectionSingleLine = (selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn) => {
@@ -4005,7 +4005,7 @@ const isEverySelection = (selections, fn) => {
4005
4005
  return true;
4006
4006
  };
4007
4007
  const isEverySelectionEmpty = selections => {
4008
- return isEverySelection(selections, isEmpty);
4008
+ return isEverySelection(selections, isEmpty$1);
4009
4009
  };
4010
4010
  const isEverySelectionSingleLine = selections => {
4011
4011
  return isEverySelection(selections, isSelectionSingleLine);
@@ -4103,7 +4103,7 @@ const getVisible = async editor => {
4103
4103
  const endLine = lines[selectionEndRow];
4104
4104
  const endLineEndX = await getX(endLine, selectionEndColumn, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, endLineDifference);
4105
4105
  const endLineY = relativeEndLineRow * rowHeight;
4106
- if (isEmpty(selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn) && endLineEndX > 0) {
4106
+ if (isEmpty$1(selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn) && endLineEndX > 0) {
4107
4107
  visibleCursors.push(endLineEndX, endLineY);
4108
4108
  continue;
4109
4109
  }
@@ -6142,14 +6142,27 @@ const dispose$3 = async () => {
6142
6142
  };
6143
6143
 
6144
6144
  const renderedDoms = new Map();
6145
+ const textAppendPaths = new Map();
6145
6146
  const get$1 = uid => {
6146
6147
  return renderedDoms.get(uid);
6147
6148
  };
6148
- const set$1 = (uid, dom) => {
6149
+ const set$1 = (uid, dom, paths) => {
6149
6150
  renderedDoms.set(uid, dom);
6151
+ setTextAppendPaths(uid, paths);
6152
+ };
6153
+ const getTextAppendPaths$1 = uid => {
6154
+ return textAppendPaths.get(uid);
6155
+ };
6156
+ const setTextAppendPaths = (uid, paths) => {
6157
+ if (paths) {
6158
+ textAppendPaths.set(uid, paths);
6159
+ } else {
6160
+ textAppendPaths.delete(uid);
6161
+ }
6150
6162
  };
6151
6163
  const dispose$2 = uid => {
6152
6164
  renderedDoms.delete(uid);
6165
+ textAppendPaths.delete(uid);
6153
6166
  };
6154
6167
 
6155
6168
  const addWidget$1 = widget => {
@@ -8947,7 +8960,7 @@ const getChanges$5 = (lines, selections, getDelta) => {
8947
8960
  };
8948
8961
 
8949
8962
  const isAutoClosingPairDelete = (autoClosingRanges, startRowIndex, startColumnIndex, endRowIndex, endColumnIndex) => {
8950
- if (!isEmpty(startRowIndex, startColumnIndex, endRowIndex, endColumnIndex)) {
8963
+ if (!isEmpty$1(startRowIndex, startColumnIndex, endRowIndex, endColumnIndex)) {
8951
8964
  return false;
8952
8965
  }
8953
8966
  if (startColumnIndex < 1) {
@@ -11245,7 +11258,7 @@ const getChanges = (lines, selections, languageConfiguration, indentUnit) => {
11245
11258
  end,
11246
11259
  start
11247
11260
  };
11248
- if (isEmpty(selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn)) {
11261
+ if (isEmpty$1(selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn)) {
11249
11262
  const line = lines[selectionStartRow];
11250
11263
  const before = line.slice(0, selectionStartColumn);
11251
11264
  const after = line.slice(selectionStartColumn);
@@ -14118,6 +14131,7 @@ const Button$1 = 1;
14118
14131
  const Div = 4;
14119
14132
  const Input = 6;
14120
14133
  const Span = 8;
14134
+ const Text = 12;
14121
14135
  const Img = 17;
14122
14136
  const Nav = 40;
14123
14137
  const TextArea = 62;
@@ -14126,7 +14140,7 @@ const text = data => {
14126
14140
  return {
14127
14141
  childCount: 0,
14128
14142
  text: data,
14129
- type: Text
14143
+ type: Text$1
14130
14144
  };
14131
14145
  };
14132
14146
 
@@ -14215,7 +14229,7 @@ const compareNodes = (oldNode, newNode) => {
14215
14229
  });
14216
14230
  }
14217
14231
  // Handle text nodes
14218
- if (oldNode.type === Text && newNode.type === Text) {
14232
+ if (oldNode.type === Text$1 && newNode.type === Text$1) {
14219
14233
  if (oldNode.text !== newNode.text) {
14220
14234
  patches.push({
14221
14235
  type: SetText,
@@ -14437,7 +14451,7 @@ const hoverSashNode = {
14437
14451
  onPointerDown: HandleSashPointerDown,
14438
14452
  type: Div
14439
14453
  };
14440
- const getChildCount = (lineInfos, documentationVirtualDom, diagnostics) => {
14454
+ const getChildCount$1 = (lineInfos, documentationVirtualDom, diagnostics) => {
14441
14455
  const documentationCount = documentationVirtualDom.length > 0 ? 1 : 0;
14442
14456
  const diagnosticsCount = diagnostics && diagnostics.length > 0 ? 1 : 0;
14443
14457
  return (lineInfos.length > 0 ? 1 : 0) + documentationCount + diagnosticsCount;
@@ -14449,7 +14463,7 @@ const getEditorHoverClassName = (lineInfos, documentationVirtualDom, diagnostics
14449
14463
  const getHoverVirtualDom = (lineInfos, documentationVirtualDom, diagnostics, editorUid = 0) => {
14450
14464
  const dom = [];
14451
14465
  dom.push({
14452
- childCount: getChildCount(lineInfos, documentationVirtualDom, diagnostics) + 1,
14466
+ childCount: getChildCount$1(lineInfos, documentationVirtualDom, diagnostics) + 1,
14453
14467
  className: getEditorHoverClassName(lineInfos, documentationVirtualDom, diagnostics),
14454
14468
  'data-uid': editorUid,
14455
14469
  onMouseOut: HandleMouseOut,
@@ -17199,6 +17213,147 @@ const getScrollBarDiagnostics = (editor, diagnostics) => {
17199
17213
  return scrollBarDecorations;
17200
17214
  };
17201
17215
 
17216
+ const getChildCount = node => node.childCount || 0;
17217
+ const getTextAppendPaths = dom => {
17218
+ if (dom.length === 0) {
17219
+ return undefined;
17220
+ }
17221
+ let textIndex = -1;
17222
+ let cursorIndex = -1;
17223
+ let textPath = [];
17224
+ let cursorPath = [];
17225
+ let numberOfRows = 0;
17226
+ let numberOfCursors = 0;
17227
+ const visit = (index, path) => {
17228
+ const node = dom[index];
17229
+ if (!node) {
17230
+ return index;
17231
+ }
17232
+ if (node.className === 'EditorRow' || node.className?.startsWith('EditorRow ')) {
17233
+ numberOfRows++;
17234
+ const span = dom[index + 1];
17235
+ const text = dom[index + 2];
17236
+ if (node.childCount !== 1 || span?.type !== Span || span.childCount !== 1 || text?.type !== Text) {
17237
+ numberOfRows = -100;
17238
+ } else {
17239
+ textIndex = index + 2;
17240
+ textPath = [...path, 0, 0];
17241
+ }
17242
+ }
17243
+ if (node.className === 'EditorCursor') {
17244
+ numberOfCursors++;
17245
+ if (node.childCount === 0) {
17246
+ cursorIndex = index;
17247
+ cursorPath = path;
17248
+ } else {
17249
+ numberOfCursors = -100;
17250
+ }
17251
+ }
17252
+ let nextIndex = index + 1;
17253
+ const childCount = getChildCount(node);
17254
+ for (let childIndex = 0; childIndex < childCount; childIndex++) {
17255
+ nextIndex = visit(nextIndex, [...path, childIndex]);
17256
+ }
17257
+ return nextIndex;
17258
+ };
17259
+ const endIndex = visit(0, []);
17260
+ if (endIndex !== dom.length || numberOfRows !== 1 || numberOfCursors !== 1 || textIndex < 0 || cursorIndex < 0) {
17261
+ return undefined;
17262
+ }
17263
+ return {
17264
+ cursorIndex,
17265
+ cursorPath,
17266
+ textIndex,
17267
+ textPath
17268
+ };
17269
+ };
17270
+ const isEmpty = value => !value || value.length === 0;
17271
+ const sameValues = (left = [], right = []) => {
17272
+ return left.length === right.length && left.every((value, index) => value === right[index]);
17273
+ };
17274
+ const isPlainTextLine = ({
17275
+ languageId,
17276
+ lines,
17277
+ textInfos
17278
+ }) => {
17279
+ return languageId === 'plaintext' && lines.length === 1 && textInfos.length === 1 && textInfos[0]?.length === 2 && textInfos[0][0] === lines[0];
17280
+ };
17281
+ const canRenderPlainTextAppend = (oldState, newState) => {
17282
+ const {
17283
+ lines: oldLines,
17284
+ textInfos: oldTextInfos
17285
+ } = oldState;
17286
+ const {
17287
+ lines: newLines,
17288
+ textInfos: newTextInfos
17289
+ } = newState;
17290
+ if (!isPlainTextLine(oldState) || !isPlainTextLine(newState)) {
17291
+ return false;
17292
+ }
17293
+ const oldLine = oldLines[0];
17294
+ const newLine = newLines[0];
17295
+ if (newLine.length <= oldLine.length || !newLine.startsWith(oldLine) || /[\r\n]/.test(newLine.slice(oldLine.length))) {
17296
+ return false;
17297
+ }
17298
+ if (oldState.initial || newState.initial || !oldState.focused || !newState.focused || oldState.uid !== newState.uid || oldTextInfos[0][1] !== newTextInfos[0][1] || oldState.cursorInfos.length !== 1 || newState.cursorInfos.length !== 1 || oldState.selectionInfos.length > 0 || newState.selectionInfos.length > 0 || oldState.selections.length !== 4 || newState.selections.length !== 4 || oldState.selections[0] !== 0 || oldState.selections[1] !== oldLine.length || oldState.selections[2] !== 0 || oldState.selections[3] !== oldLine.length || newState.selections[0] !== 0 || newState.selections[1] !== newLine.length || newState.selections[2] !== 0 || newState.selections[3] !== newLine.length) {
17299
+ return false;
17300
+ }
17301
+ if (oldState.breadcrumbsEnabled || newState.breadcrumbsEnabled || oldState.minimapEnabled || newState.minimapEnabled || oldState.lineNumbers !== newState.lineNumbers || oldState.highlightActiveLineNumber !== newState.highlightActiveLineNumber || oldState.highlightedLine !== newState.highlightedLine || oldState.problemsHighlightedRow !== newState.problemsHighlightedRow || oldState.focused !== newState.focused || oldState.roundedSelection !== newState.roundedSelection || oldState.width !== newState.width || oldState.height !== newState.height || oldState.minimumSliderSize !== newState.minimumSliderSize || getScrollBarSize(oldState.width, oldState.longestLineWidth, oldState.minimumSliderSize) !== getScrollBarSize(newState.width, newState.longestLineWidth, newState.minimumSliderSize) || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || !sameValues(oldState.visibleLineIndices, newState.visibleLineIndices) || !sameValues(oldState.visibleViewLineIndices, newState.visibleViewLineIndices) || oldState.differences !== newState.differences && !sameValues(oldState.differences, newState.differences) || oldState.scrollBarHeight !== newState.scrollBarHeight || oldState.uri !== newState.uri || oldState.workspaceUri !== newState.workspaceUri || oldState.assetDir !== newState.assetDir || oldState.loadError !== newState.loadError || oldState.combineWhitespaceTokens !== newState.combineWhitespaceTokens || oldState.widgets?.length > 0 || newState.widgets?.length > 0 || oldState.mergeConflicts.length > 0 || newState.mergeConflicts.length > 0 || !isEmpty(oldState.diagnostics) || !isEmpty(newState.diagnostics) || !isEmpty(oldState.visualDecorations) || !isEmpty(newState.visualDecorations) || !isEmpty(oldState.bracketMatchInfos) || !isEmpty(newState.bracketMatchInfos) || !isEmpty(oldState.endOfLineDecorations) || !isEmpty(newState.endOfLineDecorations) || !isEmpty(oldState.gutterDecorations) || !isEmpty(newState.gutterDecorations) || !isEmpty(oldState.breakPoints) || !isEmpty(newState.breakPoints)) {
17302
+ return false;
17303
+ }
17304
+ return true;
17305
+ };
17306
+ const getTextAppendPatches = (state, paths) => {
17307
+ const {
17308
+ cursorInfos,
17309
+ lines
17310
+ } = state;
17311
+ const patches = [];
17312
+ for (const index of paths.textPath) {
17313
+ patches.push({
17314
+ index,
17315
+ type: 7
17316
+ }); // NavigateChild
17317
+ }
17318
+ patches.push({
17319
+ type: 1,
17320
+ value: lines[0]
17321
+ }); // SetText
17322
+ for (let index = 0; index < paths.textPath.length; index++) {
17323
+ patches.push({
17324
+ type: 8
17325
+ }); // NavigateParent
17326
+ }
17327
+ for (const index of paths.cursorPath) {
17328
+ patches.push({
17329
+ index,
17330
+ type: 7
17331
+ }); // NavigateChild
17332
+ }
17333
+ patches.push({
17334
+ key: 'translate',
17335
+ type: 3,
17336
+ value: cursorInfos[0]
17337
+ }); // SetAttribute
17338
+ return patches;
17339
+ };
17340
+ const updateTextAppendDom = (oldDom, state, paths) => {
17341
+ const {
17342
+ cursorInfos,
17343
+ lines
17344
+ } = state;
17345
+ const newDom = [...oldDom];
17346
+ newDom[paths.textIndex] = {
17347
+ ...oldDom[paths.textIndex],
17348
+ text: lines[0]
17349
+ };
17350
+ newDom[paths.cursorIndex] = {
17351
+ ...oldDom[paths.cursorIndex],
17352
+ translate: cursorInfos[0]
17353
+ };
17354
+ return newDom;
17355
+ };
17356
+
17202
17357
  const getDom = state => {
17203
17358
  const {
17204
17359
  diagnostics = [],
@@ -17228,13 +17383,22 @@ const mergeConflictsEqual = (oldState, newState) => {
17228
17383
  });
17229
17384
  };
17230
17385
  const renderIncremental = (oldState, newState) => {
17386
+ const renderedDom = get$1(newState.uid);
17387
+ const textAppendPaths = getTextAppendPaths$1(newState.uid);
17388
+ if (renderedDom && textAppendPaths && canRenderPlainTextAppend(oldState, newState)) {
17389
+ const newDom = updateTextAppendDom(renderedDom, newState, textAppendPaths);
17390
+ set$1(newState.uid, newDom, textAppendPaths);
17391
+ const patches = getTextAppendPatches(newState, textAppendPaths);
17392
+ return [SetPatches, newState.uid, patches];
17393
+ }
17231
17394
  const oldDom = oldState.initial || !mergeConflictsEqual(oldState, newState) ? getDom(oldState) : get$1(newState.uid) || getDom(oldState);
17232
17395
  const newDom = getDom(newState);
17233
17396
  const patches = diffTree(oldDom, newDom);
17397
+ const newTextAppendPaths = newState.languageId === 'plaintext' && newState.lines.length === 1 ? getTextAppendPaths(newDom) : undefined;
17398
+ set$1(newState.uid, newDom, newTextAppendPaths);
17234
17399
  if (patches.length === 0) {
17235
17400
  return [];
17236
17401
  }
17237
- set$1(newState.uid, newDom);
17238
17402
  return [SetPatches, newState.uid, patches];
17239
17403
  };
17240
17404
 
@@ -456,7 +456,17 @@
456
456
  "description": "The modifier to be used to add multiple cursors with the mouse",
457
457
  "heading": "Multi Cursor Modifier",
458
458
  "id": "editor.multiCursorModifier",
459
- "type": "string",
459
+ "options": [
460
+ {
461
+ "id": "alt",
462
+ "label": "Alt"
463
+ },
464
+ {
465
+ "id": "ctrlCmd",
466
+ "label": "Ctrl/Cmd"
467
+ }
468
+ ],
469
+ "type": "enum",
460
470
  "value": "alt"
461
471
  },
462
472
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.69.4",
3
+ "version": "19.69.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"