@lvce-editor/main-area-worker 9.19.0 → 9.21.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.
- package/dist/mainAreaWorkerMain.js +498 -31
- package/package.json +1 -1
|
@@ -272,7 +272,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
|
|
|
272
272
|
for (const property of Object.values(value)) {
|
|
273
273
|
walkValue(property, transferrables, isTransferrable);
|
|
274
274
|
}
|
|
275
|
-
return;
|
|
276
275
|
}
|
|
277
276
|
};
|
|
278
277
|
const getTransferrables = value => {
|
|
@@ -1416,15 +1415,175 @@ const create$3 = rpcId => {
|
|
|
1416
1415
|
|
|
1417
1416
|
const None$1 = 'none';
|
|
1418
1417
|
|
|
1418
|
+
const Audio = 0;
|
|
1419
1419
|
const Button$2 = 1;
|
|
1420
|
+
const Col = 2;
|
|
1421
|
+
const ColGroup = 3;
|
|
1420
1422
|
const Div = 4;
|
|
1423
|
+
const H1 = 5;
|
|
1424
|
+
const Input = 6;
|
|
1425
|
+
const Kbd = 7;
|
|
1421
1426
|
const Span = 8;
|
|
1427
|
+
const Table = 9;
|
|
1428
|
+
const TBody = 10;
|
|
1429
|
+
const Td = 11;
|
|
1422
1430
|
const Text = 12;
|
|
1431
|
+
const Th = 13;
|
|
1432
|
+
const THead = 14;
|
|
1433
|
+
const Tr = 15;
|
|
1434
|
+
const I = 16;
|
|
1423
1435
|
const Img = 17;
|
|
1436
|
+
const Root = 0;
|
|
1437
|
+
const Ins = 20;
|
|
1438
|
+
const Del = 21;
|
|
1439
|
+
const H2 = 22;
|
|
1440
|
+
const H3 = 23;
|
|
1441
|
+
const H4 = 24;
|
|
1442
|
+
const H5 = 25;
|
|
1443
|
+
const H6 = 26;
|
|
1444
|
+
const Article = 27;
|
|
1445
|
+
const Aside = 28;
|
|
1446
|
+
const Footer = 29;
|
|
1447
|
+
const Header = 30;
|
|
1448
|
+
const Nav = 40;
|
|
1449
|
+
const Section = 41;
|
|
1450
|
+
const Search = 42;
|
|
1451
|
+
const Dd = 43;
|
|
1452
|
+
const Dl = 44;
|
|
1453
|
+
const Figcaption = 45;
|
|
1454
|
+
const Figure = 46;
|
|
1455
|
+
const Hr = 47;
|
|
1456
|
+
const Li = 48;
|
|
1457
|
+
const Ol = 49;
|
|
1424
1458
|
const P = 50;
|
|
1425
1459
|
const Pre = 51;
|
|
1460
|
+
const A = 53;
|
|
1461
|
+
const Abbr = 54;
|
|
1462
|
+
const Br = 55;
|
|
1463
|
+
const Cite = 56;
|
|
1464
|
+
const Data = 57;
|
|
1465
|
+
const Time = 58;
|
|
1466
|
+
const Tfoot = 59;
|
|
1467
|
+
const Ul = 60;
|
|
1468
|
+
const Video = 61;
|
|
1469
|
+
const TextArea = 62;
|
|
1470
|
+
const Select = 63;
|
|
1471
|
+
const Option = 64;
|
|
1472
|
+
const Code = 65;
|
|
1473
|
+
const Label = 66;
|
|
1474
|
+
const Dt = 67;
|
|
1475
|
+
const Iframe = 68;
|
|
1476
|
+
const Main$2 = 69;
|
|
1477
|
+
const Strong = 70;
|
|
1478
|
+
const Em = 71;
|
|
1479
|
+
const Style = 72;
|
|
1480
|
+
const Html = 73;
|
|
1481
|
+
const Head = 74;
|
|
1482
|
+
const Title = 75;
|
|
1483
|
+
const Meta = 76;
|
|
1484
|
+
const Canvas = 77;
|
|
1485
|
+
const Form = 78;
|
|
1486
|
+
const BlockQuote = 79;
|
|
1487
|
+
const Quote = 80;
|
|
1488
|
+
const Circle = 81;
|
|
1489
|
+
const Defs = 82;
|
|
1490
|
+
const Ellipse = 83;
|
|
1491
|
+
const G = 84;
|
|
1492
|
+
const Line = 85;
|
|
1493
|
+
const Path = 86;
|
|
1494
|
+
const Polygon = 87;
|
|
1495
|
+
const Polyline = 88;
|
|
1496
|
+
const Rect = 89;
|
|
1497
|
+
const Svg = 90;
|
|
1498
|
+
const Use = 91;
|
|
1426
1499
|
const Reference = 100;
|
|
1427
1500
|
|
|
1501
|
+
const VirtualDomElements = {
|
|
1502
|
+
__proto__: null,
|
|
1503
|
+
A,
|
|
1504
|
+
Abbr,
|
|
1505
|
+
Article,
|
|
1506
|
+
Aside,
|
|
1507
|
+
Audio,
|
|
1508
|
+
BlockQuote,
|
|
1509
|
+
Br,
|
|
1510
|
+
Button: Button$2,
|
|
1511
|
+
Canvas,
|
|
1512
|
+
Circle,
|
|
1513
|
+
Cite,
|
|
1514
|
+
Code,
|
|
1515
|
+
Col,
|
|
1516
|
+
ColGroup,
|
|
1517
|
+
Data,
|
|
1518
|
+
Dd,
|
|
1519
|
+
Defs,
|
|
1520
|
+
Del,
|
|
1521
|
+
Div,
|
|
1522
|
+
Dl,
|
|
1523
|
+
Dt,
|
|
1524
|
+
Ellipse,
|
|
1525
|
+
Em,
|
|
1526
|
+
Figcaption,
|
|
1527
|
+
Figure,
|
|
1528
|
+
Footer,
|
|
1529
|
+
Form,
|
|
1530
|
+
G,
|
|
1531
|
+
H1,
|
|
1532
|
+
H2,
|
|
1533
|
+
H3,
|
|
1534
|
+
H4,
|
|
1535
|
+
H5,
|
|
1536
|
+
H6,
|
|
1537
|
+
Head,
|
|
1538
|
+
Header,
|
|
1539
|
+
Hr,
|
|
1540
|
+
Html,
|
|
1541
|
+
I,
|
|
1542
|
+
Iframe,
|
|
1543
|
+
Img,
|
|
1544
|
+
Input,
|
|
1545
|
+
Ins,
|
|
1546
|
+
Kbd,
|
|
1547
|
+
Label,
|
|
1548
|
+
Li,
|
|
1549
|
+
Line,
|
|
1550
|
+
Main: Main$2,
|
|
1551
|
+
Meta,
|
|
1552
|
+
Nav,
|
|
1553
|
+
Ol,
|
|
1554
|
+
Option,
|
|
1555
|
+
P,
|
|
1556
|
+
Path,
|
|
1557
|
+
Polygon,
|
|
1558
|
+
Polyline,
|
|
1559
|
+
Pre,
|
|
1560
|
+
Quote,
|
|
1561
|
+
Rect,
|
|
1562
|
+
Reference,
|
|
1563
|
+
Root,
|
|
1564
|
+
Search,
|
|
1565
|
+
Section,
|
|
1566
|
+
Select,
|
|
1567
|
+
Span,
|
|
1568
|
+
Strong,
|
|
1569
|
+
Style,
|
|
1570
|
+
Svg,
|
|
1571
|
+
TBody,
|
|
1572
|
+
THead,
|
|
1573
|
+
Table,
|
|
1574
|
+
Td,
|
|
1575
|
+
Text,
|
|
1576
|
+
TextArea,
|
|
1577
|
+
Tfoot,
|
|
1578
|
+
Th,
|
|
1579
|
+
Time,
|
|
1580
|
+
Title,
|
|
1581
|
+
Tr,
|
|
1582
|
+
Ul,
|
|
1583
|
+
Use,
|
|
1584
|
+
Video
|
|
1585
|
+
};
|
|
1586
|
+
|
|
1428
1587
|
const Button$1 = 'event.button';
|
|
1429
1588
|
const ClientX = 'event.clientX';
|
|
1430
1589
|
const ClientY = 'event.clientY';
|
|
@@ -1896,6 +2055,38 @@ const closeTabsRight = (state, groupId) => {
|
|
|
1896
2055
|
return withGroups(addClosedTabs(state, closedTabs), newGroups);
|
|
1897
2056
|
};
|
|
1898
2057
|
|
|
2058
|
+
const findGroupById = (state, groupId) => {
|
|
2059
|
+
const {
|
|
2060
|
+
layout
|
|
2061
|
+
} = state;
|
|
2062
|
+
const {
|
|
2063
|
+
groups
|
|
2064
|
+
} = layout;
|
|
2065
|
+
return groups.find(group => group.id === groupId);
|
|
2066
|
+
};
|
|
2067
|
+
|
|
2068
|
+
const copyIntoNewWindow$1 = async state => {
|
|
2069
|
+
const {
|
|
2070
|
+
activeGroupId
|
|
2071
|
+
} = state.layout;
|
|
2072
|
+
const group = findGroupById(state, activeGroupId ?? 0);
|
|
2073
|
+
if (!group) {
|
|
2074
|
+
return state;
|
|
2075
|
+
}
|
|
2076
|
+
const {
|
|
2077
|
+
activeTabId
|
|
2078
|
+
} = group;
|
|
2079
|
+
if (activeTabId === undefined) {
|
|
2080
|
+
return state;
|
|
2081
|
+
}
|
|
2082
|
+
const tab = group.tabs.find(tab => tab.id === activeTabId);
|
|
2083
|
+
if (!tab?.uri) {
|
|
2084
|
+
return state;
|
|
2085
|
+
}
|
|
2086
|
+
await invoke('ElectronWindow.openNewWithUri', tab.uri);
|
|
2087
|
+
return state;
|
|
2088
|
+
};
|
|
2089
|
+
|
|
1899
2090
|
const copyPath$1 = async (state, path) => {
|
|
1900
2091
|
string(path);
|
|
1901
2092
|
await writeClipBoardText(path);
|
|
@@ -1944,6 +2135,7 @@ const create$2 = (uid, uri, x, y, width, height, platform, assetDir, tabHeight =
|
|
|
1944
2135
|
closedTabs: [],
|
|
1945
2136
|
fileIconCache: {},
|
|
1946
2137
|
height,
|
|
2138
|
+
homeDirUri: '',
|
|
1947
2139
|
iframes: [],
|
|
1948
2140
|
initial: true,
|
|
1949
2141
|
layout: {
|
|
@@ -3018,6 +3210,16 @@ const getCurrentState = state => {
|
|
|
3018
3210
|
return state;
|
|
3019
3211
|
};
|
|
3020
3212
|
|
|
3213
|
+
const getTitle = (uri, homeDir) => {
|
|
3214
|
+
if (!uri) {
|
|
3215
|
+
return '';
|
|
3216
|
+
}
|
|
3217
|
+
const normalizedHomeDir = homeDir.endsWith('/') ? homeDir.slice(0, -1) : homeDir;
|
|
3218
|
+
if (uri.startsWith('file://') && normalizedHomeDir.startsWith('file://') && (uri === normalizedHomeDir || uri.startsWith(`${normalizedHomeDir}/`))) {
|
|
3219
|
+
return `~${uri.slice(normalizedHomeDir.length)}`;
|
|
3220
|
+
}
|
|
3221
|
+
return uri;
|
|
3222
|
+
};
|
|
3021
3223
|
const getBasename$1 = uri => {
|
|
3022
3224
|
const lastSlashIndex = uri.lastIndexOf('/');
|
|
3023
3225
|
if (lastSlashIndex === -1) {
|
|
@@ -3034,6 +3236,9 @@ const getInlineDiffLabel = uri => {
|
|
|
3034
3236
|
return `${getBasename$1(workingTreeUri)} (Working Tree)`;
|
|
3035
3237
|
};
|
|
3036
3238
|
const getLabel = uri => {
|
|
3239
|
+
if (uri === 'app://keybindings') {
|
|
3240
|
+
return 'Keyboard Shortcuts';
|
|
3241
|
+
}
|
|
3037
3242
|
if (uri.startsWith('settings://')) {
|
|
3038
3243
|
return 'Settings';
|
|
3039
3244
|
}
|
|
@@ -3072,7 +3277,41 @@ const getEditorInputTitle = editorInput => {
|
|
|
3072
3277
|
}
|
|
3073
3278
|
};
|
|
3074
3279
|
|
|
3075
|
-
const
|
|
3280
|
+
const getUriTitle = (uri, homeDirUri) => {
|
|
3281
|
+
if (!uri) {
|
|
3282
|
+
return undefined;
|
|
3283
|
+
}
|
|
3284
|
+
const title = getTitle(uri, homeDirUri);
|
|
3285
|
+
return title === uri ? undefined : title;
|
|
3286
|
+
};
|
|
3287
|
+
const updateTabUriTitle = (tab, homeDirUri) => {
|
|
3288
|
+
const uriTitle = getUriTitle(tab.uri, homeDirUri);
|
|
3289
|
+
if (tab.uriTitle === uriTitle) {
|
|
3290
|
+
return tab;
|
|
3291
|
+
}
|
|
3292
|
+
return {
|
|
3293
|
+
...tab,
|
|
3294
|
+
uriTitle
|
|
3295
|
+
};
|
|
3296
|
+
};
|
|
3297
|
+
const updateTabUriTitles = state => {
|
|
3298
|
+
const {
|
|
3299
|
+
layout
|
|
3300
|
+
} = state;
|
|
3301
|
+
const homeDirUri = state.homeDirUri || '';
|
|
3302
|
+
return {
|
|
3303
|
+
...state,
|
|
3304
|
+
layout: {
|
|
3305
|
+
...layout,
|
|
3306
|
+
groups: layout.groups.map(group => ({
|
|
3307
|
+
...group,
|
|
3308
|
+
tabs: group.tabs.map(tab => updateTabUriTitle(tab, homeDirUri))
|
|
3309
|
+
}))
|
|
3310
|
+
}
|
|
3311
|
+
};
|
|
3312
|
+
};
|
|
3313
|
+
|
|
3314
|
+
const createEmptyGroup$1 = (state, uri, requestId, preview = false, title = getLabel(uri), editorType = 'text', editorInput) => {
|
|
3076
3315
|
const {
|
|
3077
3316
|
layout
|
|
3078
3317
|
} = state;
|
|
@@ -3094,7 +3333,8 @@ const createEmptyGroup = (state, uri, requestId, preview = false, title = getLab
|
|
|
3094
3333
|
language: '',
|
|
3095
3334
|
loadingState: 'loading',
|
|
3096
3335
|
title,
|
|
3097
|
-
uri
|
|
3336
|
+
uri,
|
|
3337
|
+
uriTitle: getUriTitle(uri, state.homeDirUri || '')
|
|
3098
3338
|
};
|
|
3099
3339
|
const newGroup = {
|
|
3100
3340
|
activeTabId: newTab.id,
|
|
@@ -3188,7 +3428,8 @@ const ensureActiveGroup = (state, uri, preview = false, title = getLabel(uri), e
|
|
|
3188
3428
|
language: '',
|
|
3189
3429
|
loadingState: 'loading',
|
|
3190
3430
|
title,
|
|
3191
|
-
uri
|
|
3431
|
+
uri,
|
|
3432
|
+
uriTitle: getUriTitle(uri, state.homeDirUri || '')
|
|
3192
3433
|
};
|
|
3193
3434
|
});
|
|
3194
3435
|
return {
|
|
@@ -3221,11 +3462,12 @@ const ensureActiveGroup = (state, uri, preview = false, title = getLabel(uri), e
|
|
|
3221
3462
|
language: '',
|
|
3222
3463
|
loadingState: 'loading',
|
|
3223
3464
|
title,
|
|
3224
|
-
uri: uri
|
|
3465
|
+
uri: uri,
|
|
3466
|
+
uriTitle: getUriTitle(uri, state.homeDirUri || '')
|
|
3225
3467
|
};
|
|
3226
3468
|
newState = openTab(state, activeGroup.id, newTab);
|
|
3227
3469
|
} else {
|
|
3228
|
-
newState = createEmptyGroup(state, uri, requestId, preview, title, editorType, editorInput);
|
|
3470
|
+
newState = createEmptyGroup$1(state, uri, requestId, preview, title, editorType, editorInput);
|
|
3229
3471
|
}
|
|
3230
3472
|
return newState;
|
|
3231
3473
|
};
|
|
@@ -3239,7 +3481,8 @@ const getStateWithTab = (currentState, editorInput, existingTab, shouldRetryExis
|
|
|
3239
3481
|
errorMessage: '',
|
|
3240
3482
|
loadingState: 'loading',
|
|
3241
3483
|
title,
|
|
3242
|
-
uri
|
|
3484
|
+
uri,
|
|
3485
|
+
uriTitle: getUriTitle(uri, currentState.homeDirUri || '')
|
|
3243
3486
|
}),
|
|
3244
3487
|
tabId: existingTab.tab.id
|
|
3245
3488
|
};
|
|
@@ -3548,7 +3791,7 @@ const openUri = async (state, options) => {
|
|
|
3548
3791
|
const preview = typeof options === 'string' ? false : options.preview ?? false;
|
|
3549
3792
|
return openInput(state, {
|
|
3550
3793
|
editorInput: getNormalizedOpenEditorInput(uri),
|
|
3551
|
-
|
|
3794
|
+
focus: typeof options === 'string' ? false : options.focus,
|
|
3552
3795
|
preview
|
|
3553
3796
|
});
|
|
3554
3797
|
};
|
|
@@ -3564,7 +3807,7 @@ const retryOpen = async state => {
|
|
|
3564
3807
|
if (tab.editorInput) {
|
|
3565
3808
|
return openInput(state, {
|
|
3566
3809
|
editorInput: tab.editorInput,
|
|
3567
|
-
|
|
3810
|
+
focus: false,
|
|
3568
3811
|
preview: tab.isPreview
|
|
3569
3812
|
});
|
|
3570
3813
|
}
|
|
@@ -3921,7 +4164,7 @@ const newFile = async state => {
|
|
|
3921
4164
|
targetGroupId = activeGroup.id;
|
|
3922
4165
|
} else {
|
|
3923
4166
|
// No active group, create an empty one
|
|
3924
|
-
newState = createEmptyGroup(state, '');
|
|
4167
|
+
newState = createEmptyGroup$1(state, '');
|
|
3925
4168
|
const updatedActiveGroupId = newState.layout.activeGroupId;
|
|
3926
4169
|
if (!updatedActiveGroupId) {
|
|
3927
4170
|
return state;
|
|
@@ -4306,7 +4549,8 @@ const handleUriChange = async (state, oldUri, newUri) => {
|
|
|
4306
4549
|
return {
|
|
4307
4550
|
...tab,
|
|
4308
4551
|
title: newTitle,
|
|
4309
|
-
uri: newUri
|
|
4552
|
+
uri: newUri,
|
|
4553
|
+
uriTitle: getUriTitle(newUri, state.homeDirUri || '')
|
|
4310
4554
|
};
|
|
4311
4555
|
}
|
|
4312
4556
|
return tab;
|
|
@@ -4371,6 +4615,27 @@ const initialize = async () => {
|
|
|
4371
4615
|
set$3(rpc);
|
|
4372
4616
|
};
|
|
4373
4617
|
|
|
4618
|
+
const toFileUri = path => {
|
|
4619
|
+
if (!path) {
|
|
4620
|
+
return '';
|
|
4621
|
+
}
|
|
4622
|
+
if (path.startsWith('file://')) {
|
|
4623
|
+
return path;
|
|
4624
|
+
}
|
|
4625
|
+
if (path.startsWith('/')) {
|
|
4626
|
+
return `file://${path}`;
|
|
4627
|
+
}
|
|
4628
|
+
return path;
|
|
4629
|
+
};
|
|
4630
|
+
const loadHomeDirUri = async () => {
|
|
4631
|
+
try {
|
|
4632
|
+
const homeDir = await invoke('Workspace.getHomeDir');
|
|
4633
|
+
return typeof homeDir === 'string' ? toFileUri(homeDir) : '';
|
|
4634
|
+
} catch {
|
|
4635
|
+
return '';
|
|
4636
|
+
}
|
|
4637
|
+
};
|
|
4638
|
+
|
|
4374
4639
|
const isValidTab = tab => {
|
|
4375
4640
|
return tab && typeof tab.id === 'number' && typeof tab.title === 'string' && typeof tab.isDirty === 'boolean' && typeof tab.isPreview === 'boolean' && typeof tab.editorUid === 'number' && typeof tab.icon === 'string' && (tab.editorType === 'text' || tab.editorType === 'custom');
|
|
4376
4641
|
};
|
|
@@ -4562,10 +4827,15 @@ const restoreAndCreateEditors = async (state, restoredLayout) => {
|
|
|
4562
4827
|
};
|
|
4563
4828
|
|
|
4564
4829
|
const loadContent = async (state, savedState) => {
|
|
4830
|
+
const homeDirUri = await loadHomeDirUri();
|
|
4831
|
+
const stateWithHomeDir = {
|
|
4832
|
+
...state,
|
|
4833
|
+
homeDirUri
|
|
4834
|
+
};
|
|
4565
4835
|
const restoredLayout = tryRestoreLayout(savedState);
|
|
4566
4836
|
if (restoredLayout) {
|
|
4567
4837
|
// Restore and create editors
|
|
4568
|
-
const editorState = await restoreAndCreateEditors(
|
|
4838
|
+
const editorState = await restoreAndCreateEditors(stateWithHomeDir, restoredLayout);
|
|
4569
4839
|
|
|
4570
4840
|
// Load file icons with the updated editor state
|
|
4571
4841
|
const {
|
|
@@ -4574,16 +4844,16 @@ const loadContent = async (state, savedState) => {
|
|
|
4574
4844
|
} = await loadFileIcons(editorState);
|
|
4575
4845
|
|
|
4576
4846
|
// Merge the results
|
|
4577
|
-
const finalState = {
|
|
4847
|
+
const finalState = updateTabUriTitles({
|
|
4578
4848
|
...editorState,
|
|
4579
4849
|
fileIconCache,
|
|
4580
4850
|
initial: false,
|
|
4581
4851
|
layout: updatedLayout
|
|
4582
|
-
};
|
|
4852
|
+
});
|
|
4583
4853
|
return finalState;
|
|
4584
4854
|
}
|
|
4585
4855
|
return {
|
|
4586
|
-
...
|
|
4856
|
+
...stateWithHomeDir,
|
|
4587
4857
|
initial: false,
|
|
4588
4858
|
layout: {
|
|
4589
4859
|
activeGroupId: undefined,
|
|
@@ -4721,7 +4991,7 @@ const pin = () => {
|
|
|
4721
4991
|
const splitAndMove = () => {
|
|
4722
4992
|
return i18nString(SplitAndMove);
|
|
4723
4993
|
};
|
|
4724
|
-
const moveIntoNewWindow = () => {
|
|
4994
|
+
const moveIntoNewWindow$1 = () => {
|
|
4725
4995
|
return i18nString(MoveIntoNewWindow);
|
|
4726
4996
|
};
|
|
4727
4997
|
const copyIntoNewWindow = () => {
|
|
@@ -4803,16 +5073,6 @@ const getMenuEntries$2 = (state, groupId) => {
|
|
|
4803
5073
|
}];
|
|
4804
5074
|
};
|
|
4805
5075
|
|
|
4806
|
-
const findGroupById = (state, groupId) => {
|
|
4807
|
-
const {
|
|
4808
|
-
layout
|
|
4809
|
-
} = state;
|
|
4810
|
-
const {
|
|
4811
|
-
groups
|
|
4812
|
-
} = layout;
|
|
4813
|
-
return groups.find(group => group.id === groupId);
|
|
4814
|
-
};
|
|
4815
|
-
|
|
4816
5076
|
// TODO should pass tab uri as argument or tab index
|
|
4817
5077
|
const getMenuEntries$1 = state => {
|
|
4818
5078
|
const {
|
|
@@ -4920,12 +5180,12 @@ const getMenuEntries$1 = state => {
|
|
|
4920
5180
|
id: 'splitAndMove',
|
|
4921
5181
|
label: splitAndMove()
|
|
4922
5182
|
}, {
|
|
4923
|
-
command: '',
|
|
5183
|
+
command: 'MainArea.moveIntoNewWindow',
|
|
4924
5184
|
flags: None,
|
|
4925
5185
|
id: 'moveIntoNewWindow',
|
|
4926
|
-
label: moveIntoNewWindow()
|
|
5186
|
+
label: moveIntoNewWindow$1()
|
|
4927
5187
|
}, {
|
|
4928
|
-
command: '',
|
|
5188
|
+
command: 'MainArea.copyIntoNewWindow',
|
|
4929
5189
|
flags: None,
|
|
4930
5190
|
id: 'copyIntoNewWindow',
|
|
4931
5191
|
label: copyIntoNewWindow()
|
|
@@ -4949,8 +5209,30 @@ const getMenuEntries = async (state, props) => {
|
|
|
4949
5209
|
}
|
|
4950
5210
|
};
|
|
4951
5211
|
|
|
5212
|
+
const moveIntoNewWindow = async state => {
|
|
5213
|
+
const {
|
|
5214
|
+
activeGroupId
|
|
5215
|
+
} = state.layout;
|
|
5216
|
+
const group = findGroupById(state, activeGroupId ?? 0);
|
|
5217
|
+
if (!group) {
|
|
5218
|
+
return state;
|
|
5219
|
+
}
|
|
5220
|
+
const {
|
|
5221
|
+
activeTabId
|
|
5222
|
+
} = group;
|
|
5223
|
+
if (activeTabId === undefined) {
|
|
5224
|
+
return state;
|
|
5225
|
+
}
|
|
5226
|
+
const tab = group.tabs.find(tab => tab.id === activeTabId);
|
|
5227
|
+
if (!tab?.uri) {
|
|
5228
|
+
return state;
|
|
5229
|
+
}
|
|
5230
|
+
await invoke('ElectronWindow.openNewWithUri', tab.uri);
|
|
5231
|
+
return closeTabAndSave(state, group.id, activeTabId);
|
|
5232
|
+
};
|
|
5233
|
+
|
|
4952
5234
|
const newWindow = async state => {
|
|
4953
|
-
await invoke('
|
|
5235
|
+
await invoke('ElectronWindow.openNew');
|
|
4954
5236
|
return state;
|
|
4955
5237
|
};
|
|
4956
5238
|
|
|
@@ -5112,6 +5394,8 @@ const text = data => {
|
|
|
5112
5394
|
};
|
|
5113
5395
|
};
|
|
5114
5396
|
|
|
5397
|
+
new Set(Object.values(VirtualDomElements));
|
|
5398
|
+
|
|
5115
5399
|
const SetText = 1;
|
|
5116
5400
|
const Replace = 2;
|
|
5117
5401
|
const SetAttribute = 3;
|
|
@@ -5518,7 +5802,7 @@ const renderTab = (tab, isActive, tabIndex, groupIndex) => {
|
|
|
5518
5802
|
onContextMenu: HandleTabContextMenu,
|
|
5519
5803
|
onMouseDown: HandleClickTab,
|
|
5520
5804
|
role: 'tab',
|
|
5521
|
-
title: tab.uri || tab.title,
|
|
5805
|
+
title: tab.uriTitle || tab.uri || tab.title,
|
|
5522
5806
|
type: Div
|
|
5523
5807
|
}, {
|
|
5524
5808
|
childCount: 0,
|
|
@@ -5995,6 +6279,178 @@ const saveState = state => {
|
|
|
5995
6279
|
};
|
|
5996
6280
|
};
|
|
5997
6281
|
|
|
6282
|
+
const flipDirection = direction => {
|
|
6283
|
+
return direction === Horizontal ? Vertical : Horizontal;
|
|
6284
|
+
};
|
|
6285
|
+
const createEmptyGroup = () => {
|
|
6286
|
+
return {
|
|
6287
|
+
activeTabId: undefined,
|
|
6288
|
+
focused: false,
|
|
6289
|
+
id: create$1(),
|
|
6290
|
+
isEmpty: true,
|
|
6291
|
+
size: 100,
|
|
6292
|
+
tabs: []
|
|
6293
|
+
};
|
|
6294
|
+
};
|
|
6295
|
+
const getActiveGroupIndex = (groups, activeGroupId) => {
|
|
6296
|
+
const activeIndex = groups.findIndex(group => group.id === activeGroupId);
|
|
6297
|
+
if (activeIndex !== -1) {
|
|
6298
|
+
return activeIndex;
|
|
6299
|
+
}
|
|
6300
|
+
const focusedIndex = groups.findIndex(group => group.focused);
|
|
6301
|
+
if (focusedIndex !== -1) {
|
|
6302
|
+
return focusedIndex;
|
|
6303
|
+
}
|
|
6304
|
+
return 0;
|
|
6305
|
+
};
|
|
6306
|
+
const mergeGroups = (target, groups, activeGroupId) => {
|
|
6307
|
+
const allGroups = [target, ...groups];
|
|
6308
|
+
const tabs = allGroups.flatMap(group => group.tabs);
|
|
6309
|
+
const activeGroup = allGroups.find(group => group.id === activeGroupId) ?? groups.findLast(group => group.activeTabId !== undefined) ?? target;
|
|
6310
|
+
const activeTabId = activeGroup.activeTabId ?? tabs[0]?.id;
|
|
6311
|
+
return {
|
|
6312
|
+
...target,
|
|
6313
|
+
activeTabId,
|
|
6314
|
+
isEmpty: tabs.length === 0,
|
|
6315
|
+
tabs
|
|
6316
|
+
};
|
|
6317
|
+
};
|
|
6318
|
+
const getGroupsForSlotCount = (groups, slotCount, activeGroupId) => {
|
|
6319
|
+
if (slotCount === 1) {
|
|
6320
|
+
const firstGroup = groups[0] ?? createEmptyGroup();
|
|
6321
|
+
return [mergeGroups(firstGroup, groups.slice(1), activeGroupId)];
|
|
6322
|
+
}
|
|
6323
|
+
if (groups.length === slotCount) {
|
|
6324
|
+
return groups;
|
|
6325
|
+
}
|
|
6326
|
+
if (groups.length < slotCount) {
|
|
6327
|
+
const missingGroups = Array.from({
|
|
6328
|
+
length: slotCount - groups.length
|
|
6329
|
+
}, createEmptyGroup);
|
|
6330
|
+
return [...groups, ...missingGroups];
|
|
6331
|
+
}
|
|
6332
|
+
const retainedGroups = groups.slice(0, slotCount);
|
|
6333
|
+
const extraGroups = groups.slice(slotCount);
|
|
6334
|
+
const lastGroup = retainedGroups.at(-1);
|
|
6335
|
+
if (!lastGroup) {
|
|
6336
|
+
return retainedGroups;
|
|
6337
|
+
}
|
|
6338
|
+
return [...retainedGroups.slice(0, -1), mergeGroups(lastGroup, extraGroups, activeGroupId)];
|
|
6339
|
+
};
|
|
6340
|
+
const setEditorLayout = (state, direction, slots) => {
|
|
6341
|
+
const {
|
|
6342
|
+
layout
|
|
6343
|
+
} = state;
|
|
6344
|
+
const groups = getGroupsForSlotCount(layout.groups, slots.length, layout.activeGroupId);
|
|
6345
|
+
const originalActiveIndex = layout.groups.findIndex(group => group.id === layout.activeGroupId);
|
|
6346
|
+
const activeIndex = originalActiveIndex >= slots.length ? slots.length - 1 : getActiveGroupIndex(groups, layout.activeGroupId);
|
|
6347
|
+
const nextGroups = groups.map((group, index) => {
|
|
6348
|
+
const slot = slots[index];
|
|
6349
|
+
const focused = index === activeIndex;
|
|
6350
|
+
return {
|
|
6351
|
+
...group,
|
|
6352
|
+
direction: slot.direction,
|
|
6353
|
+
focused,
|
|
6354
|
+
size: slot.size
|
|
6355
|
+
};
|
|
6356
|
+
});
|
|
6357
|
+
return {
|
|
6358
|
+
...state,
|
|
6359
|
+
layout: {
|
|
6360
|
+
activeGroupId: nextGroups[activeIndex]?.id,
|
|
6361
|
+
direction,
|
|
6362
|
+
groups: nextGroups
|
|
6363
|
+
}
|
|
6364
|
+
};
|
|
6365
|
+
};
|
|
6366
|
+
const flipLayout = state => {
|
|
6367
|
+
return {
|
|
6368
|
+
...state,
|
|
6369
|
+
layout: {
|
|
6370
|
+
...state.layout,
|
|
6371
|
+
direction: flipDirection(state.layout.direction),
|
|
6372
|
+
groups: state.layout.groups.map(group => ({
|
|
6373
|
+
...group,
|
|
6374
|
+
direction: group.direction === undefined ? undefined : flipDirection(group.direction)
|
|
6375
|
+
}))
|
|
6376
|
+
}
|
|
6377
|
+
};
|
|
6378
|
+
};
|
|
6379
|
+
const setEditorLayoutSingle = state => {
|
|
6380
|
+
return setEditorLayout(state, Horizontal, [{
|
|
6381
|
+
size: 100
|
|
6382
|
+
}]);
|
|
6383
|
+
};
|
|
6384
|
+
const setEditorLayoutTwoColumns = state => {
|
|
6385
|
+
return setEditorLayout(state, Horizontal, [{
|
|
6386
|
+
size: 50
|
|
6387
|
+
}, {
|
|
6388
|
+
size: 50
|
|
6389
|
+
}]);
|
|
6390
|
+
};
|
|
6391
|
+
const setEditorLayoutThreeColumns = state => {
|
|
6392
|
+
return setEditorLayout(state, Horizontal, [{
|
|
6393
|
+
size: 33.333333
|
|
6394
|
+
}, {
|
|
6395
|
+
size: 33.333333
|
|
6396
|
+
}, {
|
|
6397
|
+
size: 33.333334
|
|
6398
|
+
}]);
|
|
6399
|
+
};
|
|
6400
|
+
const setEditorLayoutTwoRows = state => {
|
|
6401
|
+
return setEditorLayout(state, Vertical, [{
|
|
6402
|
+
size: 50
|
|
6403
|
+
}, {
|
|
6404
|
+
size: 50
|
|
6405
|
+
}]);
|
|
6406
|
+
};
|
|
6407
|
+
const setEditorLayoutThreeRows = state => {
|
|
6408
|
+
return setEditorLayout(state, Vertical, [{
|
|
6409
|
+
size: 33.333333
|
|
6410
|
+
}, {
|
|
6411
|
+
size: 33.333333
|
|
6412
|
+
}, {
|
|
6413
|
+
size: 33.333334
|
|
6414
|
+
}]);
|
|
6415
|
+
};
|
|
6416
|
+
const setEditorLayoutGrid = state => {
|
|
6417
|
+
return setEditorLayout(state, Horizontal, [{
|
|
6418
|
+
direction: Vertical,
|
|
6419
|
+
size: 25
|
|
6420
|
+
}, {
|
|
6421
|
+
direction: Vertical,
|
|
6422
|
+
size: 25
|
|
6423
|
+
}, {
|
|
6424
|
+
direction: Vertical,
|
|
6425
|
+
size: 25
|
|
6426
|
+
}, {
|
|
6427
|
+
direction: Vertical,
|
|
6428
|
+
size: 25
|
|
6429
|
+
}]);
|
|
6430
|
+
};
|
|
6431
|
+
const setEditorLayoutTwoRowsRight = state => {
|
|
6432
|
+
return setEditorLayout(state, Horizontal, [{
|
|
6433
|
+
size: 50
|
|
6434
|
+
}, {
|
|
6435
|
+
direction: Vertical,
|
|
6436
|
+
size: 25
|
|
6437
|
+
}, {
|
|
6438
|
+
direction: Vertical,
|
|
6439
|
+
size: 25
|
|
6440
|
+
}]);
|
|
6441
|
+
};
|
|
6442
|
+
const setEditorLayoutTwoColumnsBottom = state => {
|
|
6443
|
+
return setEditorLayout(state, Vertical, [{
|
|
6444
|
+
size: 50
|
|
6445
|
+
}, {
|
|
6446
|
+
direction: Horizontal,
|
|
6447
|
+
size: 25
|
|
6448
|
+
}, {
|
|
6449
|
+
direction: Horizontal,
|
|
6450
|
+
size: 25
|
|
6451
|
+
}]);
|
|
6452
|
+
};
|
|
6453
|
+
|
|
5998
6454
|
const splitDown = (state, groupId) => {
|
|
5999
6455
|
const {
|
|
6000
6456
|
layout
|
|
@@ -6165,10 +6621,12 @@ const commandMap = {
|
|
|
6165
6621
|
'MainArea.closeSaved': wrapCommand(closeSaved$1),
|
|
6166
6622
|
'MainArea.closeTabsByUris': wrapCommand(closeTabsByUris),
|
|
6167
6623
|
'MainArea.closeTabsRight': wrapCommand(closeTabsRight),
|
|
6624
|
+
'MainArea.copyIntoNewWindow': wrapCommand(copyIntoNewWindow$1),
|
|
6168
6625
|
'MainArea.copyPath': wrapCommand(copyPath$1),
|
|
6169
6626
|
'MainArea.copyRelativePath': wrapCommand(copyRelativePath$1),
|
|
6170
6627
|
'MainArea.create': create$2,
|
|
6171
6628
|
'MainArea.diff2': diff2,
|
|
6629
|
+
'MainArea.flipEditorLayout': wrapCommand(flipLayout),
|
|
6172
6630
|
'MainArea.focusNext': wrapCommand(focusNextTab),
|
|
6173
6631
|
'MainArea.focusNextTab': wrapCommand(focusNextTab),
|
|
6174
6632
|
'MainArea.focusPrevious': wrapCommand(focusPreviousTab),
|
|
@@ -6196,6 +6654,7 @@ const commandMap = {
|
|
|
6196
6654
|
'MainArea.handleWorkspaceChange': wrapCommand(handleWorkspaceChange),
|
|
6197
6655
|
'MainArea.initialize': initialize,
|
|
6198
6656
|
'MainArea.loadContent': wrapCommand(loadContent),
|
|
6657
|
+
'MainArea.moveIntoNewWindow': wrapCommand(moveIntoNewWindow),
|
|
6199
6658
|
'MainArea.newFile': wrapCommand(newFile),
|
|
6200
6659
|
'MainArea.newWindow': wrapCommand(newWindow),
|
|
6201
6660
|
'MainArea.openInput': wrapCommand(openInput),
|
|
@@ -6209,6 +6668,14 @@ const commandMap = {
|
|
|
6209
6668
|
'MainArea.save': wrapCommand(save),
|
|
6210
6669
|
'MainArea.saveState': wrapGetter(saveState),
|
|
6211
6670
|
'MainArea.selectTab': wrapCommand(selectTab),
|
|
6671
|
+
'MainArea.setEditorLayoutGrid': wrapCommand(setEditorLayoutGrid),
|
|
6672
|
+
'MainArea.setEditorLayoutSingle': wrapCommand(setEditorLayoutSingle),
|
|
6673
|
+
'MainArea.setEditorLayoutThreeColumns': wrapCommand(setEditorLayoutThreeColumns),
|
|
6674
|
+
'MainArea.setEditorLayoutThreeRows': wrapCommand(setEditorLayoutThreeRows),
|
|
6675
|
+
'MainArea.setEditorLayoutTwoColumns': wrapCommand(setEditorLayoutTwoColumns),
|
|
6676
|
+
'MainArea.setEditorLayoutTwoColumnsBottom': wrapCommand(setEditorLayoutTwoColumnsBottom),
|
|
6677
|
+
'MainArea.setEditorLayoutTwoRows': wrapCommand(setEditorLayoutTwoRows),
|
|
6678
|
+
'MainArea.setEditorLayoutTwoRowsRight': wrapCommand(setEditorLayoutTwoRowsRight),
|
|
6212
6679
|
'MainArea.splitDown': wrapCommand(splitDown),
|
|
6213
6680
|
'MainArea.splitLeft': wrapCommand(splitLeft),
|
|
6214
6681
|
'MainArea.splitRight': wrapCommand(splitRight),
|