@lvce-editor/renderer-process 21.12.0 → 21.14.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.
@@ -180,6 +180,13 @@ const downloadFile = (fileName, url) => {
180
180
  a.click();
181
181
  };
182
182
 
183
+ const instances = Object.create(null);
184
+ const get$1$1 = viewletId => {
185
+ return instances[viewletId];
186
+ };
187
+ const set$1$1 = (viewletId, instance) => {
188
+ instances[viewletId] = instance;
189
+ };
183
190
  const Audio$2 = 'audio';
184
191
  const Button$2 = 'button';
185
192
  const Col$2 = 'col';
@@ -419,13 +426,6 @@ const ElementTagMap = {
419
426
  const {
420
427
  getElementTag
421
428
  } = ElementTagMap;
422
- const instances = Object.create(null);
423
- const get$1$1 = viewletId => {
424
- return instances[viewletId];
425
- };
426
- const set$1$1 = (viewletId, instance) => {
427
- instances[viewletId] = instance;
428
- };
429
429
  const getEventListenerOptions$1 = (eventName, value) => {
430
430
  if (value.passive) {
431
431
  return {
@@ -750,6 +750,7 @@ const NavigateChild = 7;
750
750
  const NavigateParent = 8;
751
751
  const RemoveChild = 9;
752
752
  const NavigateSibling = 10;
753
+ const SetReferenceNodeUid = 11;
753
754
  const dragInfos = Object.create(null);
754
755
  const setDragInfo = (id, data) => {
755
756
  dragInfos[id] = data;
@@ -1088,6 +1089,23 @@ const applyPatch = ($Element, patches, eventMap = {}, id = 0) => {
1088
1089
  case SetAttribute:
1089
1090
  setProp($Current, patch.key, patch.value, events);
1090
1091
  break;
1092
+ case SetReferenceNodeUid:
1093
+ {
1094
+ // Get the new reference node instance
1095
+ const instance = get$1$1(patch.uid);
1096
+ if (!instance || !instance.state) {
1097
+ console.error('Cannot set reference node uid: instance not found', {
1098
+ uid: patch.uid
1099
+ });
1100
+ return;
1101
+ }
1102
+ const $NewNode = instance.state.$Viewlet;
1103
+ // Replace the current reference node with the new viewlet
1104
+ // @ts-ignore
1105
+ $Current.replaceWith($NewNode);
1106
+ $Current = $NewNode;
1107
+ break;
1108
+ }
1091
1109
  case SetText:
1092
1110
  setText$3($Current, patch.value);
1093
1111
  break;
@@ -2908,12 +2926,15 @@ const measureTextBlockHeight = (text, fontSize, fontFamily, lineHeight, width) =
2908
2926
  const $Measure = document.createElement('textarea');
2909
2927
  $Measure.style.width = `${width}px`;
2910
2928
  $Measure.style.contain = 'content';
2929
+ // @ts-ignore
2930
+ $Measure.style.fieldSizing = 'content';
2911
2931
  $Measure.style.position = 'absolute';
2912
2932
  $Measure.style.top = '-9999px';
2913
2933
  $Measure.style.left = '-9999px';
2914
2934
  $Measure.style.fontSize = `${fontSize}px`;
2915
2935
  $Measure.style.lineHeight = lineHeight;
2916
2936
  $Measure.value = text;
2937
+ $Measure.name = 'measureTextBlockHeight';
2917
2938
  const height = getElementHeight($Measure);
2918
2939
  return height;
2919
2940
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "21.12.0",
3
+ "version": "21.14.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"