@lvce-editor/editor-worker 3.6.0 → 3.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.
@@ -513,7 +513,6 @@ const offsetAt = (textDocument, positionRowIndex, positionColumnIndex) => {
513
513
  return offset;
514
514
  };
515
515
  const positionAt = (textDocument, offset) => {
516
- // console.log({ textDocument, offset })
517
516
  let rowIndex = 0;
518
517
  let columnIndex = 0;
519
518
  let currentOffset = 0;
@@ -2012,7 +2011,6 @@ const createEditor = async ({
2012
2011
  ...newEditor3,
2013
2012
  focused: true
2014
2013
  };
2015
- // console.log({ newEditor })
2016
2014
  set$7(id, emptyEditor, newEditor4);
2017
2015
  await invoke$2(TextDocumentSyncFull, uri, id, languageId, content);
2018
2016
  };
@@ -2080,7 +2078,7 @@ const applyEdit = async (editor, changes) => {
2080
2078
  return scheduleDocumentAndCursorsSelections(editor, changes);
2081
2079
  };
2082
2080
 
2083
- const handleBlur = editor => {
2081
+ const handleBlur$1 = editor => {
2084
2082
  // for (const listener of state.blurListeners) {
2085
2083
  // listener(editor)
2086
2084
  // }
@@ -2503,7 +2501,7 @@ const create$3 = () => {
2503
2501
  };
2504
2502
 
2505
2503
  const ColorPicker = 41;
2506
- const FindWidget$1 = 16;
2504
+ const FindWidget = 16;
2507
2505
  const EditorCompletion = 9;
2508
2506
  const CompletionDetail = 999;
2509
2507
 
@@ -3629,7 +3627,7 @@ const handleDoubleClick = (editor, modifier, x, y) => {
3629
3627
  };
3630
3628
 
3631
3629
  const WhenExpressionEditorText = 12;
3632
- const handleFocus = editor => {
3630
+ const handleFocus$1 = editor => {
3633
3631
  // TODO make change events functional,
3634
3632
  // when rendering, send focus changes to renderer worker
3635
3633
  invoke$3('Focus.setFocus', WhenExpressionEditorText);
@@ -3646,7 +3644,7 @@ const state$5 = {
3646
3644
  columnIndex: 0
3647
3645
  }
3648
3646
  };
3649
- const getPosition$1 = () => {
3647
+ const getPosition$2 = () => {
3650
3648
  return state$5.position;
3651
3649
  };
3652
3650
 
@@ -3871,13 +3869,6 @@ const handleMouseMoveWithAltKey = async (editor, x, y) => {
3871
3869
  // const definitionRelativeY = definitionStartPosition.rowIndex - editor.minLineY
3872
3870
 
3873
3871
  const lineTokenMap = editor.lineCache[definitionStartPosition.rowIndex + 1];
3874
- console.log({
3875
- tokenMap: lineTokenMap
3876
- });
3877
- console.log({
3878
- lineCache: editor.lineCache,
3879
- rowIndex: definitionStartPosition.rowIndex
3880
- });
3881
3872
  if (!lineTokenMap) {
3882
3873
  return editor;
3883
3874
  }
@@ -3885,9 +3876,6 @@ const handleMouseMoveWithAltKey = async (editor, x, y) => {
3885
3876
  if (tokenIndex === -1) {
3886
3877
  return editor;
3887
3878
  }
3888
- console.log({
3889
- token: tokenIndex
3890
- });
3891
3879
  // .tokens
3892
3880
  // await RendererProcess.invoke(
3893
3881
  // /* Viewlet.invoke */ 'Viewlet.send',
@@ -3896,9 +3884,6 @@ const handleMouseMoveWithAltKey = async (editor, x, y) => {
3896
3884
  // /* relativeY */ definitionRelativeY,
3897
3885
  // /* tokenIndex */ tokenIndex,
3898
3886
  // )
3899
- console.log({
3900
- definition
3901
- });
3902
3887
  return editor;
3903
3888
  } catch (error) {
3904
3889
  // @ts-ignore
@@ -3979,7 +3964,7 @@ const setPosition = position => {
3979
3964
  const getEditor$1 = () => {
3980
3965
  return state$3.currentEditor;
3981
3966
  };
3982
- const getPosition = () => {
3967
+ const getPosition$1 = () => {
3983
3968
  return state$3.position;
3984
3969
  };
3985
3970
  const hasListener = () => {
@@ -4224,7 +4209,7 @@ const getNewSelections$5 = (anchor, position) => {
4224
4209
 
4225
4210
  // @ts-ignore
4226
4211
  const editorMoveSelection = (editor, position) => {
4227
- const anchor = getPosition$1();
4212
+ const anchor = getPosition$2();
4228
4213
  const newSelections = getNewSelections$5(anchor, position);
4229
4214
  // TODO if selection equals previous selection -> do nothing
4230
4215
  return scheduleSelections(editor, newSelections);
@@ -4511,7 +4496,7 @@ const getNewEditor$1 = (editor, position) => {
4511
4496
  const newMinLineY = position.rowIndex;
4512
4497
  const newMaxLineY = position.rowIndex + diff;
4513
4498
  const newDeltaY = position.rowIndex * rowHeight;
4514
- const anchor = getPosition$1();
4499
+ const anchor = getPosition$2();
4515
4500
  const newSelections = new Uint32Array([position.rowIndex - 1, position.columnIndex, anchor.rowIndex, anchor.columnIndex]);
4516
4501
  return {
4517
4502
  ...editor,
@@ -4526,7 +4511,7 @@ const getNewEditor$1 = (editor, position) => {
4526
4511
  const newMinLineY = position.rowIndex - diff;
4527
4512
  const newMaxLineY = position.rowIndex;
4528
4513
  const newDeltaY = newMinLineY * rowHeight;
4529
- const anchor = getPosition$1();
4514
+ const anchor = getPosition$2();
4530
4515
  const newSelections = new Uint32Array([anchor.rowIndex, anchor.columnIndex, position.rowIndex + 1, position.columnIndex]);
4531
4516
  return {
4532
4517
  ...editor,
@@ -4543,7 +4528,7 @@ const continueScrollingAndMovingSelection = async () => {
4543
4528
  if (!editor) {
4544
4529
  return;
4545
4530
  }
4546
- const position = getPosition();
4531
+ const position = getPosition$1();
4547
4532
  if (position.rowIndex === 0) {
4548
4533
  return;
4549
4534
  }
@@ -5087,12 +5072,6 @@ const openCompletion = async editor => {
5087
5072
  };
5088
5073
  };
5089
5074
 
5090
- const FindWidget = 'FindWidget';
5091
- const openFind = async state => {
5092
- await invoke$3('Viewlet.openWidget', FindWidget);
5093
- return state;
5094
- };
5095
-
5096
5075
  const create$1 = () => {
5097
5076
  const uid = create$4();
5098
5077
  const widget = {
@@ -5109,7 +5088,12 @@ const create$1 = () => {
5109
5088
  matchCase: false,
5110
5089
  matchWholeWord: false,
5111
5090
  replacement: '',
5112
- editorUid: 0
5091
+ editorUid: 0,
5092
+ x: 0,
5093
+ y: 0,
5094
+ width: 0,
5095
+ height: 0,
5096
+ focused: false
5113
5097
  },
5114
5098
  newState: {
5115
5099
  value: '',
@@ -5123,7 +5107,12 @@ const create$1 = () => {
5123
5107
  matchCase: false,
5124
5108
  matchWholeWord: false,
5125
5109
  replacement: '',
5126
- editorUid: 0
5110
+ editorUid: 0,
5111
+ x: 0,
5112
+ y: 0,
5113
+ width: 0,
5114
+ height: 0,
5115
+ focused: true
5127
5116
  }
5128
5117
  };
5129
5118
  return widget;
@@ -5173,6 +5162,20 @@ const getMatchCount = matches => {
5173
5162
  return matches.length / 2;
5174
5163
  };
5175
5164
 
5165
+ const getPosition = editor => {
5166
+ const width = 300;
5167
+ const height = 30;
5168
+ const paddingTop = 10;
5169
+ const paddingRight = 20;
5170
+ const x = editor.x + editor.width - width - paddingRight;
5171
+ const y = editor.y + paddingTop;
5172
+ return {
5173
+ y,
5174
+ x,
5175
+ width,
5176
+ height
5177
+ };
5178
+ };
5176
5179
  const loadContent$1 = editorId => {
5177
5180
  const editor = getEditor(editorId);
5178
5181
  const {
@@ -5216,6 +5219,22 @@ const refresh = (state, value = state.value) => {
5216
5219
  const handleInput = (state, value) => {
5217
5220
  return refresh(state, value);
5218
5221
  };
5222
+ const handleFocus = async state => {
5223
+ const FindWidget = 16;
5224
+ await invoke$3('Focus.setFocus', FindWidget);
5225
+ return state;
5226
+ };
5227
+ const handleBlur = async state => {
5228
+ const Empty = 0;
5229
+ await invoke$3('Focus.setFocus', Empty);
5230
+ return state;
5231
+ };
5232
+ const toggleReplace = state => {
5233
+ return {
5234
+ ...state,
5235
+ replaceExpanded: !state.replaceExpanded
5236
+ };
5237
+ };
5219
5238
 
5220
5239
  // TODO this function should be synchronous
5221
5240
  const focusIndex$1 = async (state, index) => {
@@ -5269,6 +5288,14 @@ const focusPrevious$1 = state => {
5269
5288
  }
5270
5289
  return focusIndex$1(state, matchIndex - 1);
5271
5290
  };
5291
+ const close$1 = async state => {
5292
+ // TODO
5293
+ // await Viewlet.closeWidget(uid)
5294
+ return {
5295
+ ...state,
5296
+ disposed: true
5297
+ };
5298
+ };
5272
5299
 
5273
5300
  const openFind2 = async editor => {
5274
5301
  const newStateGenerator = async state => {
@@ -5278,24 +5305,35 @@ const openFind2 = async editor => {
5278
5305
  matchCount,
5279
5306
  matchIndex
5280
5307
  } = await loadContent$1(editor.uid);
5308
+ const {
5309
+ x,
5310
+ y,
5311
+ width,
5312
+ height
5313
+ } = getPosition(editor);
5281
5314
  const latestState = {
5282
5315
  ...state,
5283
5316
  value,
5284
5317
  matches,
5285
5318
  matchCount,
5286
- matchIndex
5319
+ matchIndex,
5320
+ x,
5321
+ y,
5322
+ width,
5323
+ height
5287
5324
  };
5288
5325
  return latestState;
5289
5326
  };
5290
- return addWidgetToEditor(Find, FindWidget$1, editor, create$1, newStateGenerator);
5327
+ return addWidgetToEditor(Find, FindWidget, editor, create$1, newStateGenerator);
5328
+ };
5329
+
5330
+ const openFind = async state => {
5331
+ return openFind2(state);
5291
5332
  };
5292
5333
 
5293
5334
  const organizeImports = async editor => {
5294
5335
  // TODO ask extension host worker directly
5295
5336
  const edits = await invoke$3('ExtensionHostOrganizeImports.organizeImports', editor);
5296
- console.log({
5297
- edits
5298
- });
5299
5337
  return applyDocumentEdits(editor, edits);
5300
5338
  };
5301
5339
 
@@ -6786,9 +6824,6 @@ const typeWithAutoClosing = async (editor, text) => {
6786
6824
  case DoubleQuote:
6787
6825
  case SingleQuote:
6788
6826
  case BackTick:
6789
- console.log({
6790
- auto: editor
6791
- });
6792
6827
  if (isAutoClosingQuotesEnabled) {
6793
6828
  return typeWithAutoClosingQuote(editor, text);
6794
6829
  }
@@ -7539,7 +7574,7 @@ const renderHoverDom = {
7539
7574
  return [/* method */'Viewlet.setDom2', dom];
7540
7575
  }
7541
7576
  };
7542
- const renderBounds$3 = {
7577
+ const renderBounds$4 = {
7543
7578
  isEqual(oldState, newState) {
7544
7579
  return oldState.x === newState.x && oldState.y === newState.y && oldState.resizedWidth === newState.resizedWidth;
7545
7580
  },
@@ -7557,7 +7592,7 @@ const renderBounds$3 = {
7557
7592
  return [SetBounds, x, y, resizedWidth, height];
7558
7593
  }
7559
7594
  };
7560
- const render$9 = [renderHoverDom, renderBounds$3];
7595
+ const render$9 = [renderHoverDom, renderBounds$4];
7561
7596
  const renderHover = async (oldState, newState) => {
7562
7597
  const commands = [];
7563
7598
  for (const item of render$9) {
@@ -8171,7 +8206,6 @@ const getLineInfosViewport = (editor, tokens, embeddedResults, minLineY, maxLine
8171
8206
  };
8172
8207
  };
8173
8208
  const getVisible = async (editor, syncIncremental) => {
8174
- // console.log({ editor })
8175
8209
  // TODO should separate rendering from business logic somehow
8176
8210
  // currently hard to test because need to mock editor height, top, left,
8177
8211
  // invalidStartIndex, lineCache, etc. just for testing editorType
@@ -8421,7 +8455,7 @@ const renderScrollBarX = {
8421
8455
  return [/* method */'setScrollBarHorizontal', /* scrollBarX */scrollBarX, /* scrollBarWidth */scrollBarWidth, /* deltaX */newState.deltaX];
8422
8456
  }
8423
8457
  };
8424
- const renderFocus = {
8458
+ const renderFocus$1 = {
8425
8459
  isEqual(oldState, newState) {
8426
8460
  return oldState.focused === newState.focused;
8427
8461
  },
@@ -8519,7 +8553,7 @@ const renderWidgets = {
8519
8553
  },
8520
8554
  multiple: true
8521
8555
  };
8522
- const render$8 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus, renderDecorations, renderGutterInfo, renderWidgets];
8556
+ const render$8 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
8523
8557
  const renderEditor = async id => {
8524
8558
  const instance = get$7(id);
8525
8559
  if (!instance) {
@@ -8551,16 +8585,7 @@ const keep = [
8551
8585
  // 'ColorPicker.loadContent',
8552
8586
  'Editor.create', 'Editor.getWordAt', 'Editor.getWordBefore', 'Editor.offsetAt', 'Editor.render',
8553
8587
  // 'ColorPicker.render',
8554
- 'Editor.getText', 'Editor.getSelections',
8555
- // 'EditorCompletion.advance',
8556
- // 'EditorCompletion.handleEditorBlur',
8557
- // 'EditorCompletion.handleEditorClick',
8558
- // 'EditorCompletion.handleEditorDeleteLeft',
8559
- // 'EditorCompletion.handleEditorType',
8560
- // 'EditorCompletion.loadContent',
8561
- // 'EditorCompletion.selectCurrent',
8562
- // 'EditorCompletion.selectIndex',
8563
- 'FindWidget.focusFirst', 'FindWidget.focusIndex', 'FindWidget.focusLast', 'FindWidget.focusNext', 'FindWidget.focusPrevious', 'FindWidget.handleInput', 'FindWidget.loadContent', 'Font.ensure', 'Hover.getHoverInfo', 'Hover.handleSashPointerDown', 'Hover.handleSashPointerMove', 'Hover.handleSashPointerUp', 'Hover.loadContent', 'Hover.render', 'Initialize.initialize'];
8588
+ 'Editor.getText', 'Editor.getSelections', 'Font.ensure', 'Hover.getHoverInfo', 'Hover.handleSashPointerDown', 'Hover.handleSashPointerMove', 'Hover.handleSashPointerUp', 'Hover.loadContent', 'Hover.render', 'Initialize.initialize'];
8564
8589
 
8565
8590
  const wrapWidgetCommand = (widgetId, fn) => {
8566
8591
  const isWidget = widget => {
@@ -8587,7 +8612,16 @@ const wrapWidgetCommand = (widgetId, fn) => {
8587
8612
 
8588
8613
  const widgetCommands = {
8589
8614
  'ColorPicker.handleSliderPointerDown': ColorPicker$1,
8590
- 'ColorPicker.handleSliderPointerMove': ColorPicker$1
8615
+ 'ColorPicker.handleSliderPointerMove': ColorPicker$1,
8616
+ 'FindWidget.focusNext': Find,
8617
+ 'FindWidget.focusPrevious': Find,
8618
+ 'FindWidget.close': Find,
8619
+ 'FindWidget.focusIndex': Find,
8620
+ 'FindWidget.focusFirst': Find,
8621
+ 'FindWidget.focusLast': Find,
8622
+ 'FindWidget.toggleReplace': Find,
8623
+ 'FindWidget.handleFocus': Find,
8624
+ 'FindWidget.handleBlur': Find
8591
8625
  };
8592
8626
 
8593
8627
  // TODO wrap commands globally, not per editor
@@ -8667,10 +8701,10 @@ const commandMap = {
8667
8701
  'Editor.goToTypeDefinition': goToTypeDefinition,
8668
8702
  'Editor.handleBeforeInput': handleBeforeInput,
8669
8703
  'Editor.handleBeforeInputFromContentEditable': handleBeforeInputFromContentEditable,
8670
- 'Editor.handleBlur': handleBlur,
8704
+ 'Editor.handleBlur': handleBlur$1,
8671
8705
  'Editor.handleContextMenu': handleContextMenu,
8672
8706
  'Editor.handleDoubleClick': handleDoubleClick,
8673
- 'Editor.handleFocus': handleFocus,
8707
+ 'Editor.handleFocus': handleFocus$1,
8674
8708
  'Editor.handleMouseDown': handleMouseDown,
8675
8709
  'Editor.handleMouseMove': handleMouseMove,
8676
8710
  'Editor.handleMouseMoveWithAltKey': handleMouseMoveWithAltKey,
@@ -8762,6 +8796,10 @@ const commandMap = {
8762
8796
  'FindWidget.focusNext': focusNext$1,
8763
8797
  'FindWidget.focusPrevious': focusPrevious$1,
8764
8798
  'FindWidget.handleInput': handleInput,
8799
+ 'FindWidget.handleFocus': handleFocus,
8800
+ 'FindWidget.handleBlur': handleBlur,
8801
+ 'FindWidget.toggleReplace': toggleReplace,
8802
+ 'FindWidget.close': close$1,
8765
8803
  'FindWidget.loadContent': loadContent$1,
8766
8804
  'Font.ensure': ensure,
8767
8805
  'Hover.getHoverInfo': getEditorHoverInfo,
@@ -8775,6 +8813,7 @@ const commandMap = {
8775
8813
  wrapCommands(commandMap);
8776
8814
 
8777
8815
  const CheckBox = 'checkbox';
8816
+ const Group = 'group';
8778
8817
  const None = 'none';
8779
8818
  const Option = 'option';
8780
8819
 
@@ -8975,7 +9014,7 @@ const renderItems = {
8975
9014
  return ['setDom', dom];
8976
9015
  }
8977
9016
  };
8978
- const renderBounds$2 = {
9017
+ const renderBounds$3 = {
8979
9018
  isEqual(oldState, newState) {
8980
9019
  return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.x === newState.x && oldState.y === newState.y;
8981
9020
  },
@@ -9021,7 +9060,7 @@ const renderScrollBar = {
9021
9060
  return [/* method */SetScrollBar, /* scrollBarY */scrollBarY, /* scrollBarHeight */scrollBarHeight];
9022
9061
  }
9023
9062
  };
9024
- const render$7 = [renderItems, renderBounds$2, renderHeight, renderNegativeMargin, renderScrollBar];
9063
+ const render$7 = [renderItems, renderBounds$3, renderHeight, renderNegativeMargin, renderScrollBar];
9025
9064
  const renderCompletion = (oldState, newState) => {
9026
9065
  const commands = [];
9027
9066
  for (const item of render$7) {
@@ -9624,6 +9663,17 @@ const addWidget = (widget, id, render) => {
9624
9663
  allCommands.push(['Viewlet.createFunctionalRoot', id, uid]);
9625
9664
  allCommands.push(...commands);
9626
9665
  allCommands.push(['Viewlet.send', uid, 'appendWidget']);
9666
+ const focusCommandIndex = allCommands.findIndex(command => command[2] === 'focus');
9667
+ // TODO have separate rendering functions, e.g.
9668
+ // 1. renderDom
9669
+ // 2. renderAriaAnnouncement
9670
+ // 3. renderFocus
9671
+ // to ensure that focus is always after the element is added to the dom
9672
+ if (focusCommandIndex !== -1) {
9673
+ const command = allCommands[focusCommandIndex];
9674
+ allCommands.splice(focusCommandIndex, 1);
9675
+ allCommands.push(command);
9676
+ }
9627
9677
  return allCommands;
9628
9678
  };
9629
9679
 
@@ -9652,7 +9702,7 @@ const renderContent$1 = {
9652
9702
  return ['Viewlet.setDom2', newState.uid, dom];
9653
9703
  }
9654
9704
  };
9655
- const renderBounds$1 = {
9705
+ const renderBounds$2 = {
9656
9706
  isEqual(oldState, newState) {
9657
9707
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
9658
9708
  },
@@ -9666,7 +9716,7 @@ const renderBounds$1 = {
9666
9716
  return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
9667
9717
  }
9668
9718
  };
9669
- const render$5 = [renderContent$1, renderBounds$1, renderColor, renderOffsetX];
9719
+ const render$5 = [renderContent$1, renderBounds$2, renderColor, renderOffsetX];
9670
9720
  const renderFull$1 = (oldState, newState) => {
9671
9721
  const commands = [];
9672
9722
  for (const item of render$5) {
@@ -9694,9 +9744,14 @@ const add$2 = widget => {
9694
9744
  return addWidget(widget, 'ColorPicker', render$4);
9695
9745
  };
9696
9746
  const remove$2 = removeWidget;
9747
+ const Commands$1 = {
9748
+ 'ColorPicker.handleSliderPointerDown': handleSliderPointerDown,
9749
+ 'ColorPicker.handleSliderPointerMove': handleSliderPointerMove
9750
+ };
9697
9751
 
9698
9752
  const EditorColorPickerWidget = {
9699
9753
  __proto__: null,
9754
+ Commands: Commands$1,
9700
9755
  add: add$2,
9701
9756
  remove: remove$2,
9702
9757
  render: render$4
@@ -9733,7 +9788,7 @@ const renderContent = {
9733
9788
  return ['Viewlet.setDom2', newState.uid, dom];
9734
9789
  }
9735
9790
  };
9736
- const renderBounds = {
9791
+ const renderBounds$1 = {
9737
9792
  isEqual(oldState, newState) {
9738
9793
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
9739
9794
  },
@@ -9747,7 +9802,7 @@ const renderBounds = {
9747
9802
  return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
9748
9803
  }
9749
9804
  };
9750
- const render$3 = [renderContent, renderBounds];
9805
+ const render$3 = [renderContent, renderBounds$1];
9751
9806
  const renderFull = (oldState, newState) => {
9752
9807
  return renderParts(render$3, oldState, newState);
9753
9808
  };
@@ -9872,23 +9927,6 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
9872
9927
  return dom;
9873
9928
  };
9874
9929
 
9875
- const getSearchToggleButtonVirtualDom = (replaceExpanded, onClick = '') => {
9876
- return [{
9877
- type: Button,
9878
- className: `IconButton SearchToggleButton ${replaceExpanded ? 'SearchToggleButtonExpanded' : ''}`,
9879
- title: 'Toggle Replace',
9880
- ariaLabel: 'Toggle Replace',
9881
- ariaExpanded: replaceExpanded,
9882
- childCount: 1,
9883
- 'data-command': 'toggleReplace',
9884
- onClick
9885
- }, {
9886
- type: Div,
9887
- className: `MaskIcon ${replaceExpanded ? 'MaskIconChevronDown' : 'MaskIconChevronRight'}`,
9888
- childCount: 0
9889
- }];
9890
- };
9891
-
9892
9930
  const getIconButtonVirtualDom = iconButton => {
9893
9931
  const {
9894
9932
  label,
@@ -9903,24 +9941,13 @@ const getIconButtonVirtualDom = iconButton => {
9903
9941
  type: Button,
9904
9942
  className,
9905
9943
  title: label,
9906
- ariaLaBel: label,
9944
+ ariaLabel: label,
9907
9945
  childCount: 1,
9908
9946
  disabled: disabled ? true : undefined
9909
9947
  }, getIconVirtualDom(icon)];
9910
9948
  };
9911
- const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, buttons, matchCase, matchWholeWord, useRegularExpression) => {
9949
+ const getFindWidgetFindVirtualDom = (matchCountText, buttons) => {
9912
9950
  const dom = [];
9913
- dom.push({
9914
- type: Div,
9915
- className: 'Viewlet ViewletFind',
9916
- childCount: 2
9917
- });
9918
- dom.push(...getSearchToggleButtonVirtualDom(replaceExpanded, 'handleClick'));
9919
- dom.push({
9920
- type: Div,
9921
- className: FindWidgetRight,
9922
- childCount: replaceExpanded ? 2 : 1
9923
- });
9924
9951
  dom.push({
9925
9952
  type: Div,
9926
9953
  className: FindWidgetFind,
@@ -9932,6 +9959,11 @@ const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, buttons, match
9932
9959
  className: FindWidgetMatchCount,
9933
9960
  childCount: 1
9934
9961
  }, text(matchCountText), ...buttons.flatMap(getIconButtonVirtualDom));
9962
+ return dom;
9963
+ };
9964
+
9965
+ const getFindWidgetReplaceVirtualDom = replaceExpanded => {
9966
+ const dom = [];
9935
9967
  if (replaceExpanded) {
9936
9968
  dom.push({
9937
9969
  type: Div,
@@ -9942,6 +9974,44 @@ const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, buttons, match
9942
9974
  return dom;
9943
9975
  };
9944
9976
 
9977
+ const getSearchToggleButtonVirtualDom = (replaceExpanded, onClick = '') => {
9978
+ return [{
9979
+ type: Button,
9980
+ className: `IconButton SearchToggleButton ${replaceExpanded ? 'SearchToggleButtonExpanded' : ''}`,
9981
+ title: 'Toggle Replace',
9982
+ ariaLabel: 'Toggle Replace',
9983
+ ariaExpanded: replaceExpanded,
9984
+ childCount: 1,
9985
+ 'data-command': 'toggleReplace',
9986
+ onClick
9987
+ }, {
9988
+ type: Div,
9989
+ className: `MaskIcon ${replaceExpanded ? 'MaskIconChevronDown' : 'MaskIconChevronRight'}`,
9990
+ childCount: 0
9991
+ }];
9992
+ };
9993
+
9994
+ const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, buttons, matchCase, matchWholeWord, useRegularExpression) => {
9995
+ const dom = [];
9996
+ dom.push({
9997
+ type: Div,
9998
+ className: 'Viewlet ViewletFind ViewletFindWidget FindWidget',
9999
+ childCount: 2,
10000
+ role: Group
10001
+ });
10002
+ dom.push(...getSearchToggleButtonVirtualDom(replaceExpanded, 'handleClick'));
10003
+ dom.push({
10004
+ type: Div,
10005
+ className: FindWidgetRight,
10006
+ childCount: replaceExpanded ? 2 : 1
10007
+ });
10008
+ dom.push(...getFindWidgetFindVirtualDom(matchCountText, buttons));
10009
+ if (replaceExpanded) {
10010
+ dom.push(...getFindWidgetReplaceVirtualDom(replaceExpanded));
10011
+ }
10012
+ return dom;
10013
+ };
10014
+
9945
10015
  const getMatchCountText = (matchIndex, matchCount) => {
9946
10016
  if (matchCount === 0) {
9947
10017
  return noResults();
@@ -9985,7 +10055,28 @@ const renderDetails = {
9985
10055
  return ['Viewlet.setDom2', dom];
9986
10056
  }
9987
10057
  };
9988
-
10058
+ const renderBounds = {
10059
+ isEqual(oldState, newState) {
10060
+ return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10061
+ },
10062
+ apply(oldState, newState) {
10063
+ const {
10064
+ x,
10065
+ y,
10066
+ width,
10067
+ height
10068
+ } = newState;
10069
+ return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
10070
+ }
10071
+ };
10072
+ const renderFocus = {
10073
+ isEqual(oldState, newState) {
10074
+ return oldState.focused === newState.focused;
10075
+ },
10076
+ apply(oldState, newState) {
10077
+ return ['focus', newState.focused];
10078
+ }
10079
+ };
9989
10080
  // const getAriaLabel = (state: FindWidgetState) => {
9990
10081
  // const { matchIndex, matchCount, value } = state
9991
10082
  // return FindStrings.matchesFoundFor(matchIndex, matchCount, value)
@@ -10006,9 +10097,7 @@ const renderDetails = {
10006
10097
  // },
10007
10098
  // }
10008
10099
 
10009
- const render$1 = [
10010
- // renderAriaAnnouncement,
10011
- renderDetails, renderValue];
10100
+ const render$1 = [renderDetails, renderBounds, renderValue, renderFocus];
10012
10101
  const apply = (oldState, newState) => {
10013
10102
  return renderParts(render$1, oldState, newState);
10014
10103
  };
@@ -10019,7 +10108,7 @@ const render = widget => {
10019
10108
  const uid = widget.newState.uid;
10020
10109
  for (const command of commands) {
10021
10110
  if (command[0] === 'Viewlet.setDom2') {
10022
- wrappedCommands.push(command);
10111
+ wrappedCommands.push([command[0], uid, ...command.slice(1)]);
10023
10112
  } else {
10024
10113
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
10025
10114
  }
@@ -10030,9 +10119,20 @@ const add = widget => {
10030
10119
  return addWidget(widget, 'FindWidget', render);
10031
10120
  };
10032
10121
  const remove = removeWidget;
10122
+ const Commands = {
10123
+ 'FindWidget.close': close$1,
10124
+ 'FindWidget.focusNext': focusNext$1,
10125
+ 'FindWidget.focusPrevious': focusPrevious$1,
10126
+ 'FindWidget.focusIndex': focusIndex$1,
10127
+ 'FindWidget.focusLast': focusLast,
10128
+ 'FindWidget.toggleReplace': toggleReplace,
10129
+ 'FindWidget.handleFocus': handleFocus,
10130
+ 'FindWidget.handleBlur': handleBlur
10131
+ };
10033
10132
 
10034
10133
  const EditorFindWidget = {
10035
10134
  __proto__: null,
10135
+ Commands,
10036
10136
  add,
10037
10137
  remove,
10038
10138
  render
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
4
4
  "description": "",
5
5
  "main": "dist/testWorkerMain.js",
6
6
  "type": "module",