@lvce-editor/main-area-worker 8.14.0 → 8.15.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.
@@ -2382,7 +2382,7 @@ const getLabel = uri => {
2382
2382
  return getBasename$1(uri);
2383
2383
  };
2384
2384
 
2385
- const createEmptyGroup = (state, uri, requestId) => {
2385
+ const createEmptyGroup = (state, uri, requestId, preview = false) => {
2386
2386
  const {
2387
2387
  layout
2388
2388
  } = state;
@@ -2400,7 +2400,7 @@ const createEmptyGroup = (state, uri, requestId) => {
2400
2400
  icon: '',
2401
2401
  id: tabId,
2402
2402
  isDirty: false,
2403
- isPreview: false,
2403
+ isPreview: preview,
2404
2404
  language: '',
2405
2405
  loadingState: 'loading',
2406
2406
  title,
@@ -2460,7 +2460,7 @@ const openTab = (state, groupId, tab) => {
2460
2460
  };
2461
2461
  };
2462
2462
 
2463
- const ensureActiveGroup = (state, uri) => {
2463
+ const ensureActiveGroup = (state, uri, preview = false) => {
2464
2464
  // Find the active group (by activeGroupId or focused flag)
2465
2465
  const {
2466
2466
  layout
@@ -2472,11 +2472,49 @@ const ensureActiveGroup = (state, uri) => {
2472
2472
  const activeGroup = activeGroupId === undefined ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
2473
2473
 
2474
2474
  // Generate a request ID for content loading
2475
- getNextRequestId();
2475
+ const requestId = getNextRequestId();
2476
2476
 
2477
2477
  // If no active group exists, create one
2478
2478
  let newState;
2479
2479
  if (activeGroup) {
2480
+ const activeTab = activeGroup.tabs.find(tab => tab.id === activeGroup.activeTabId);
2481
+ if (activeTab?.isPreview) {
2482
+ const title = getLabel(uri);
2483
+ const updatedGroups = groups.map(group => {
2484
+ if (group.id !== activeGroup.id) {
2485
+ return group;
2486
+ }
2487
+ const updatedTabs = group.tabs.map(tab => {
2488
+ if (tab.id !== activeTab.id) {
2489
+ return tab;
2490
+ }
2491
+ return {
2492
+ ...tab,
2493
+ errorMessage: '',
2494
+ icon: '',
2495
+ isDirty: false,
2496
+ isPreview: preview,
2497
+ language: '',
2498
+ loadingState: 'loading',
2499
+ title,
2500
+ uri
2501
+ };
2502
+ });
2503
+ return {
2504
+ ...group,
2505
+ tabs: updatedTabs
2506
+ };
2507
+ });
2508
+ return {
2509
+ ...state,
2510
+ layout: {
2511
+ ...layout,
2512
+ activeGroupId: activeGroup.id,
2513
+ groups: updatedGroups
2514
+ }
2515
+ };
2516
+ }
2517
+
2480
2518
  // Create a new tab with the URI in the active group
2481
2519
  const title = getLabel(uri);
2482
2520
  const tabId = create$1();
@@ -2488,7 +2526,7 @@ const ensureActiveGroup = (state, uri) => {
2488
2526
  icon: '',
2489
2527
  id: tabId,
2490
2528
  isDirty: false,
2491
- isPreview: false,
2529
+ isPreview: preview,
2492
2530
  language: '',
2493
2531
  loadingState: 'loading',
2494
2532
  title,
@@ -2496,7 +2534,7 @@ const ensureActiveGroup = (state, uri) => {
2496
2534
  };
2497
2535
  newState = openTab(state, activeGroup.id, newTab);
2498
2536
  } else {
2499
- newState = createEmptyGroup(state, uri);
2537
+ newState = createEmptyGroup(state, uri, requestId, preview);
2500
2538
  }
2501
2539
  return newState;
2502
2540
  };
@@ -2698,6 +2736,7 @@ const openUri = async (state, options) => {
2698
2736
  uid
2699
2737
  } = state;
2700
2738
  const uri = getOptionUriOptions(options);
2739
+ const preview = typeof options === 'string' ? false : options.preview ?? false;
2701
2740
 
2702
2741
  // Check if a tab with this URI already exists in the passed-in state
2703
2742
  const existingTab = findTabByUri(state, uri);
@@ -2745,7 +2784,7 @@ const openUri = async (state, options) => {
2745
2784
  tabId = existingTab.tab.id;
2746
2785
  } else {
2747
2786
  // Add tab to state BEFORE any async calls to prevent race conditions
2748
- stateWithTab = ensureActiveGroup(currentState, uri);
2787
+ stateWithTab = ensureActiveGroup(currentState, uri, preview);
2749
2788
  tabId = getActiveTabId(stateWithTab);
2750
2789
  }
2751
2790
 
@@ -3047,6 +3086,7 @@ const IconButton = 'IconButton';
3047
3086
  const MainTab = 'MainTab';
3048
3087
  const MainTabs = 'MainTabs';
3049
3088
  const MainTabModified = 'MainTabModified';
3089
+ const MainTabPreview = 'MainTabPreview';
3050
3090
  const MainTabSelected = 'MainTabSelected';
3051
3091
 
3052
3092
  const newFile = async state => {
@@ -4320,6 +4360,9 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
4320
4360
  if (tab.isDirty) {
4321
4361
  className += ' ' + MainTabModified;
4322
4362
  }
4363
+ if (tab.isPreview) {
4364
+ className += ' ' + MainTabPreview;
4365
+ }
4323
4366
  return [{
4324
4367
  'aria-selected': isActive,
4325
4368
  childCount: 3,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "8.14.0",
3
+ "version": "8.15.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",