labellife-design-tool 2.2.8 → 2.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.
@@ -975,8 +975,10 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
975
975
  var scaleY = absScale.y;
976
976
  var cssFontStyle = element.fontStyle === 'italic' ? 'italic' : 'normal';
977
977
  var cssFontWeight = String(element.fontWeight || 'normal');
978
+ var originalText = element.text;
978
979
  var textarea = document.createElement('textarea');
979
- textarea.value = element.text;
980
+ textarea.value = '';
981
+ textarea.placeholder = originalText;
980
982
  textarea.style.position = 'absolute';
981
983
  textarea.style.top = "".concat(textPosition.y, "px");
982
984
  textarea.style.left = "".concat(textPosition.x, "px");
@@ -1009,15 +1011,21 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
1009
1011
  textarea.style.wordBreak = 'break-word';
1010
1012
  textarea.style.minHeight = '0';
1011
1013
  textarea.style.minWidth = '0';
1014
+
1015
+ // Placeholder inherits the element's text color at 40% opacity
1016
+ var placeholderStyle = document.createElement('style');
1017
+ placeholderStyle.textContent = "\n textarea:placeholder-shown { opacity: 1; }\n textarea::placeholder { color: ".concat(element.fill, "; opacity: 0.4; }\n ");
1018
+ stageContainer.appendChild(placeholderStyle);
1012
1019
  stageContainer.appendChild(textarea);
1013
1020
  textarea.focus();
1014
- textarea.select();
1015
1021
  var removed = false;
1016
1022
  var removeTextarea = function removeTextarea() {
1023
+ var cancel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1017
1024
  if (removed) return;
1018
1025
  removed = true;
1026
+ var newText = !cancel && textarea.value.length > 0 ? textarea.value : originalText;
1019
1027
  element.set({
1020
- text: textarea.value
1028
+ text: newText
1021
1029
  });
1022
1030
  element.toggleEditMode(false);
1023
1031
  if (grp) grp.show();
@@ -1025,12 +1033,15 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
1025
1033
  if (textarea.parentNode) {
1026
1034
  textarea.parentNode.removeChild(textarea);
1027
1035
  }
1036
+ if (placeholderStyle.parentNode) {
1037
+ placeholderStyle.parentNode.removeChild(placeholderStyle);
1038
+ }
1028
1039
  };
1029
- textarea.addEventListener('blur', removeTextarea);
1040
+ textarea.addEventListener('blur', function () {
1041
+ return removeTextarea(false);
1042
+ });
1030
1043
  textarea.addEventListener('keydown', function (e) {
1031
- if (e.key === 'Escape') {
1032
- removeTextarea();
1033
- }
1044
+ if (e.key === 'Escape') removeTextarea(true);
1034
1045
  });
1035
1046
  };
1036
1047
 
@@ -2190,6 +2201,7 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2190
2201
  setDisplayIndex = _useState8[1];
2191
2202
  var initialTotalRef = react.useRef(0);
2192
2203
  var completedHistoryRef = react.useRef([]);
2204
+ var removedDueToSkipRef = react.useRef([]);
2193
2205
  var isGoingBackRef = react.useRef(false);
2194
2206
  var prevBackTriggerRef = react.useRef(backTrigger);
2195
2207
  var config = getInputFieldsConfig();
@@ -2232,14 +2244,24 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2232
2244
  var last = completedHistoryRef.current.pop();
2233
2245
  if (!last) return;
2234
2246
  var el = last.el,
2235
- previousValue = last.previousValue;
2247
+ previousValue = last.previousValue,
2248
+ removed = last.removed;
2236
2249
  if (el) {
2237
2250
  var isImage = el.custom && el.custom.inputType === 'image';
2238
- el.set(isImage ? {
2239
- src: previousValue || ''
2240
- } : {
2241
- text: previousValue || ''
2242
- });
2251
+ if (removed) {
2252
+ el.set({
2253
+ visible: true
2254
+ });
2255
+ removedDueToSkipRef.current = removedDueToSkipRef.current.filter(function (e) {
2256
+ return e.id !== el.id;
2257
+ });
2258
+ } else {
2259
+ el.set(isImage ? {
2260
+ src: previousValue || ''
2261
+ } : {
2262
+ text: previousValue || ''
2263
+ });
2264
+ }
2243
2265
  isGoingBackRef.current = true;
2244
2266
  store._unresolveInputField(el);
2245
2267
  }
@@ -2257,6 +2279,15 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2257
2279
  var currentField = fields[0];
2258
2280
  if (!currentField) return null;
2259
2281
 
2282
+ // ── Helper: clear the removed-elements tracking ref ──────────────────
2283
+ // Elements are kept in the canvas with visible:false — they don't render
2284
+ // on screen or in exports, and can be restored via back navigation at any
2285
+ // point (including back-from-summary via backTrigger) without touching
2286
+ // deleted MST nodes.
2287
+ var _flushRemovedElements = function _flushRemovedElements() {
2288
+ removedDueToSkipRef.current = [];
2289
+ };
2290
+
2260
2291
  // ── Shared submit / skip / back helpers ─────────────────────────────
2261
2292
  var handleSubmit = function handleSubmit(elementId, value) {
2262
2293
  var el = store.getElementById(elementId);
@@ -2280,6 +2311,7 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2280
2311
  }
2281
2312
  store._resolveInputField(elementId);
2282
2313
  if (fields.length <= 1) {
2314
+ _flushRemovedElements();
2283
2315
  store.history.addUndoState();
2284
2316
  if (_onComplete) _onComplete();
2285
2317
  } else {
@@ -2292,13 +2324,24 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2292
2324
  var el = store.getElementById(elementId);
2293
2325
  var isImage = el && el.custom && el.custom.inputType === 'image';
2294
2326
  var previousValue = el ? isImage ? el.src : el.text : '';
2327
+ var shouldRemove = !!(el && el.custom && el.custom.removeIfSkipped);
2328
+ if (shouldRemove) {
2329
+ el.set({
2330
+ visible: false
2331
+ });
2332
+ removedDueToSkipRef.current.push(el);
2333
+ }
2295
2334
  completedHistoryRef.current.push({
2296
2335
  el: el,
2297
2336
  previousValue: previousValue,
2298
- skipped: true
2337
+ skipped: true,
2338
+ removed: shouldRemove
2299
2339
  });
2300
2340
  store._resolveInputField(elementId);
2301
2341
  if (fields.length <= 1) {
2342
+ var hadRemovals = removedDueToSkipRef.current.length > 0;
2343
+ _flushRemovedElements();
2344
+ if (hadRemovals) store.history.addUndoState();
2302
2345
  if (_onComplete) _onComplete();
2303
2346
  } else {
2304
2347
  setDisplayIndex(function (prev) {
@@ -2310,14 +2353,24 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2310
2353
  var last = completedHistoryRef.current.pop();
2311
2354
  if (!last) return;
2312
2355
  var el = last.el,
2313
- previousValue = last.previousValue;
2356
+ previousValue = last.previousValue,
2357
+ removed = last.removed;
2314
2358
  if (el) {
2315
2359
  var isImage = el.custom && el.custom.inputType === 'image';
2316
- el.set(isImage ? {
2317
- src: previousValue || ''
2318
- } : {
2319
- text: previousValue || ''
2320
- });
2360
+ if (removed) {
2361
+ el.set({
2362
+ visible: true
2363
+ });
2364
+ removedDueToSkipRef.current = removedDueToSkipRef.current.filter(function (e) {
2365
+ return e.id !== el.id;
2366
+ });
2367
+ } else {
2368
+ el.set(isImage ? {
2369
+ src: previousValue || ''
2370
+ } : {
2371
+ text: previousValue || ''
2372
+ });
2373
+ }
2321
2374
  store._unresolveInputField(el);
2322
2375
  }
2323
2376
  setDisplayIndex(function (prev) {
@@ -2351,6 +2404,7 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2351
2404
  onBack: handleBack,
2352
2405
  canGoBack: canGoBack,
2353
2406
  onComplete: function onComplete() {
2407
+ _flushRemovedElements();
2354
2408
  store.history.addUndoState();
2355
2409
  if (_onComplete) _onComplete();
2356
2410
  }