@lvce-editor/editor-worker 3.1.0 → 3.3.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.
@@ -116,6 +116,8 @@ const ColorPickerLight = 'ColorPickerLight';
116
116
  const ColorPickerRectangle = 'ColorPickerRectangle';
117
117
  const ColorPickerSlider = 'ColorPickerSlider';
118
118
  const ColorPickerSliderThumb = 'ColorPickerSliderThumb';
119
+ const CompletionDetailCloseButton = 'CompletionDetailCloseButton';
120
+ const CompletionDetailContent = 'CompletionDetailContent';
119
121
  const Diagnostic = 'Diagnostic';
120
122
  const EditorCompletionItem = 'EditorCompletionItem';
121
123
  const EditorCompletionItemDeprecated = 'EditorCompletionItemDeprecated';
@@ -131,11 +133,14 @@ const HoverEditorRow = 'HoverEditorRow';
131
133
  const HoverProblem = 'HoverProblem';
132
134
  const HoverProblemDetail = 'HoverProblemDetail';
133
135
  const HoverProblemMessage = 'HoverProblemMessage';
136
+ const IconClose = 'IconClose';
134
137
  const Label = 'Label';
138
+ const MaskIcon = 'MaskIcon';
135
139
  const Viewlet = 'Viewlet';
136
140
 
137
141
  const HandlePointerDown = 'handlePointerDown';
138
142
  const HandleSashPointerDown = 'handleSashPointerDown';
143
+ const HandleClose = 'handleClose';
139
144
 
140
145
  const mergeClassNames = (...classNames) => {
141
146
  return classNames.filter(Boolean).join(' ');
@@ -6676,6 +6681,24 @@ const editorUnindent = editor => {
6676
6681
 
6677
6682
  // editor.lines //?
6678
6683
 
6684
+ const isCompletionDetailWidget = widget => {
6685
+ return widget.id === CompletionDetail;
6686
+ };
6687
+ const closeDetails = editor => {
6688
+ const {
6689
+ widgets
6690
+ } = editor;
6691
+ const index = widgets.findIndex(isCompletionDetailWidget);
6692
+ if (index === -1) {
6693
+ return editor;
6694
+ }
6695
+ const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
6696
+ return {
6697
+ ...editor,
6698
+ widgets: newWidgets
6699
+ };
6700
+ };
6701
+
6679
6702
  const getWidgetState = (editor, id) => {
6680
6703
  const {
6681
6704
  widgets
@@ -6692,18 +6715,6 @@ const getCompletionState = editor => {
6692
6715
  return getWidgetState(editor, Completion);
6693
6716
  };
6694
6717
 
6695
- const closeDetails = editor => {
6696
- const child = getCompletionState(editor);
6697
- if (!child) {
6698
- return editor;
6699
- }
6700
- console.log('open details');
6701
- // TODO when completion details are open, close them
6702
- // TODO when completion details are opening, close them
6703
- // TODO when completion details are closed, open them
6704
- return editor;
6705
- };
6706
-
6707
6718
  const isCompletion$1 = widget => {
6708
6719
  return widget.id === Completion;
6709
6720
  };
@@ -6781,6 +6792,15 @@ const getCompletionDetailState = editor => {
6781
6792
  return getWidgetState(editor, CompletionDetail);
6782
6793
  };
6783
6794
 
6795
+ const getCompletionDetailBounds = (completionBounds, borderSize) => {
6796
+ return {
6797
+ x: completionBounds.x + completionBounds.width - borderSize,
6798
+ y: completionBounds.y,
6799
+ width: 100,
6800
+ height: 100
6801
+ };
6802
+ };
6803
+
6784
6804
  const openDetails = editor => {
6785
6805
  const child = getCompletionState(editor);
6786
6806
  if (!child) {
@@ -6791,16 +6811,11 @@ const openDetails = editor => {
6791
6811
  return editor;
6792
6812
  }
6793
6813
  const widget = create();
6794
- console.log({
6795
- child
6796
- });
6814
+ const borderSize = 1;
6797
6815
  const newestState = {
6798
6816
  ...widget.newState,
6799
6817
  content: 'abc',
6800
- x: child.x + child.width,
6801
- y: child.y,
6802
- width: 100,
6803
- height: 100
6818
+ ...getCompletionDetailBounds(child, borderSize)
6804
6819
  };
6805
6820
  const latestWidgets = [...editor.widgets, {
6806
6821
  ...widget,
@@ -6890,14 +6905,11 @@ const selectCurrent = editor => {
6890
6905
  };
6891
6906
 
6892
6907
  const toggleDetails = editor => {
6893
- const child = getCompletionState(editor);
6908
+ const child = getCompletionDetailState(editor);
6894
6909
  if (!child) {
6895
- return editor;
6910
+ return openDetails(editor);
6896
6911
  }
6897
- // TODO when completion details are open, close them
6898
- // TODO when completion details are opening, close them
6899
- // TODO when completion details are closed, open them
6900
- return editor;
6912
+ return closeDetails(editor);
6901
6913
  };
6902
6914
 
6903
6915
  const executeHoverProvider = (editor, offset) => {
@@ -8539,14 +8551,20 @@ const EditorCompletionWidget = {
8539
8551
  const getCompletionDetailVirtualDom = content => {
8540
8552
  const dom = [{
8541
8553
  type: Div,
8554
+ className: 'Viewlet EditorCompletionDetails',
8542
8555
  childCount: 2
8543
8556
  }, {
8544
8557
  type: Div,
8545
- className: 'CompletionDetailContent',
8558
+ className: CompletionDetailContent,
8546
8559
  childCount: 1
8547
8560
  }, text(content), {
8548
8561
  type: Div,
8549
- className: 'CompletionDetailCloseButton',
8562
+ className: CompletionDetailCloseButton,
8563
+ onClick: HandleClose,
8564
+ childCount: 1
8565
+ }, {
8566
+ type: Div,
8567
+ className: `${MaskIcon} ${IconClose}`,
8550
8568
  childCount: 0
8551
8569
  }];
8552
8570
  return dom;
@@ -8558,7 +8576,7 @@ const renderContent = {
8558
8576
  },
8559
8577
  apply(oldState, newState) {
8560
8578
  const dom = getCompletionDetailVirtualDom(newState.content);
8561
- return ['setDom', dom];
8579
+ return ['Viewlet.setDom2', newState.uid, dom];
8562
8580
  }
8563
8581
  };
8564
8582
  const renderBounds = {
@@ -8591,7 +8609,11 @@ const render$1 = (oldState, newState) => {
8591
8609
  const wrappedCommands = [];
8592
8610
  const uid = newState.uid;
8593
8611
  for (const command of commands) {
8594
- wrappedCommands.push(['Viewlet.send', uid, ...command]);
8612
+ if (command[0] === 'Viewlet.setDom2') {
8613
+ wrappedCommands.push(command);
8614
+ } else {
8615
+ wrappedCommands.push(['Viewlet.send', uid, ...command]);
8616
+ }
8595
8617
  }
8596
8618
  return wrappedCommands;
8597
8619
  };
@@ -8602,8 +8624,9 @@ const add = widget => {
8602
8624
  // that doesn't collide with ids created in renderer worker?
8603
8625
  const uid = widget.newState.uid;
8604
8626
  const allCommands = [];
8605
- allCommands.push(['Viewlet.create', id, uid]);
8627
+ allCommands.push(['Viewlet.createFunctionalRoot', id, uid]);
8606
8628
  allCommands.push(...commands);
8629
+ allCommands.push(['Viewlet.send', uid, 'appendWidget']);
8607
8630
  return allCommands;
8608
8631
  };
8609
8632
  const remove = widget => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "",
5
5
  "main": "dist/testWorkerMain.js",
6
6
  "type": "module",