@lvce-editor/panel-worker 1.4.0 → 1.6.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/panelWorkerMain.js +79 -30
- package/package.json +1 -1
package/dist/panelWorkerMain.js
CHANGED
|
@@ -886,6 +886,7 @@ const create$3 = async ({
|
|
|
886
886
|
};
|
|
887
887
|
|
|
888
888
|
const Tab = 'tab';
|
|
889
|
+
const ToolBar = 'toolbar';
|
|
889
890
|
|
|
890
891
|
const Button = 1;
|
|
891
892
|
const Div = 4;
|
|
@@ -1080,6 +1081,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1080
1081
|
initial: true,
|
|
1081
1082
|
platform,
|
|
1082
1083
|
selectedIndex: -1,
|
|
1084
|
+
tabs: [],
|
|
1083
1085
|
uid,
|
|
1084
1086
|
views: [],
|
|
1085
1087
|
warningCount: 0,
|
|
@@ -1091,7 +1093,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1091
1093
|
};
|
|
1092
1094
|
|
|
1093
1095
|
const isEqual = (oldState, newState) => {
|
|
1094
|
-
return oldState.assetDir === newState.assetDir && oldState.initial === newState.initial && oldState.currentViewletId === newState.currentViewletId;
|
|
1096
|
+
return oldState.assetDir === newState.assetDir && oldState.initial === newState.initial && oldState.currentViewletId === newState.currentViewletId && oldState.selectedIndex === newState.selectedIndex && oldState.views === newState.views;
|
|
1095
1097
|
};
|
|
1096
1098
|
|
|
1097
1099
|
const RenderItems = 4;
|
|
@@ -1126,6 +1128,11 @@ const handleClickClose = async state => {
|
|
|
1126
1128
|
};
|
|
1127
1129
|
|
|
1128
1130
|
const handleClickMaximize = async state => {
|
|
1131
|
+
await invoke('Layout.maximizePanel');
|
|
1132
|
+
return state;
|
|
1133
|
+
};
|
|
1134
|
+
|
|
1135
|
+
const handleBlur = async state => {
|
|
1129
1136
|
return state;
|
|
1130
1137
|
};
|
|
1131
1138
|
|
|
@@ -1528,13 +1535,26 @@ const diffTree = (oldNodes, newNodes) => {
|
|
|
1528
1535
|
return removeTrailingNavigationPatches(patches);
|
|
1529
1536
|
};
|
|
1530
1537
|
|
|
1538
|
+
const Badge = 'Badge';
|
|
1539
|
+
const PanelTab = 'PanelTab';
|
|
1540
|
+
const PanelTabSelected = 'PanelTabSelected';
|
|
1541
|
+
const Panel = 'Panel';
|
|
1542
|
+
const PanelHeader = 'PanelHeader';
|
|
1543
|
+
const PanelTabs = 'PanelTabs';
|
|
1544
|
+
const PanelToolBar = 'PanelToolBar';
|
|
1545
|
+
const IconButton = 'IconButton';
|
|
1546
|
+
const MaskIcon = 'MaskIcon';
|
|
1547
|
+
const MaskIconChevronUp = 'MaskIconChevronUp';
|
|
1548
|
+
const MaskIconClose = 'MaskIconClose';
|
|
1549
|
+
const Actions = 'Actions';
|
|
1550
|
+
|
|
1531
1551
|
const getActionsDom = newState => {
|
|
1532
1552
|
const actions = newState.actionsUid || -1;
|
|
1533
1553
|
if (actions === -1) {
|
|
1534
1554
|
return [{
|
|
1535
1555
|
childCount: 0,
|
|
1536
|
-
className:
|
|
1537
|
-
role:
|
|
1556
|
+
className: Actions,
|
|
1557
|
+
role: ToolBar,
|
|
1538
1558
|
type: Div
|
|
1539
1559
|
}];
|
|
1540
1560
|
}
|
|
@@ -1548,56 +1568,79 @@ const HandleClickClose = 'handleClickClose';
|
|
|
1548
1568
|
const HandleClickMaximize = 'handleClickMaximize';
|
|
1549
1569
|
const HandleClickSelectTab = 'HandleClickSelectTab';
|
|
1550
1570
|
|
|
1571
|
+
const emptyObject = {};
|
|
1572
|
+
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1573
|
+
const i18nString = (key, placeholders = emptyObject) => {
|
|
1574
|
+
if (placeholders === emptyObject) {
|
|
1575
|
+
return key;
|
|
1576
|
+
}
|
|
1577
|
+
const replacer = (match, rest) => {
|
|
1578
|
+
return placeholders[rest];
|
|
1579
|
+
};
|
|
1580
|
+
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1581
|
+
};
|
|
1582
|
+
|
|
1583
|
+
const Maximize = 'Maximize';
|
|
1584
|
+
const Close = 'Close';
|
|
1585
|
+
|
|
1586
|
+
const maximize = () => {
|
|
1587
|
+
return i18nString(Maximize);
|
|
1588
|
+
};
|
|
1589
|
+
const close = () => {
|
|
1590
|
+
return i18nString(Close);
|
|
1591
|
+
};
|
|
1592
|
+
|
|
1551
1593
|
const getGlobalActionsDom = () => {
|
|
1552
1594
|
return [{
|
|
1553
1595
|
childCount: 2,
|
|
1554
|
-
className:
|
|
1596
|
+
className: PanelToolBar,
|
|
1555
1597
|
role: 'toolbar',
|
|
1556
1598
|
type: Div
|
|
1557
1599
|
}, {
|
|
1558
|
-
ariaLabel:
|
|
1600
|
+
ariaLabel: maximize(),
|
|
1559
1601
|
childCount: 1,
|
|
1560
|
-
className:
|
|
1602
|
+
className: IconButton,
|
|
1561
1603
|
onClick: HandleClickMaximize,
|
|
1562
|
-
|
|
1604
|
+
title: maximize(),
|
|
1563
1605
|
type: Button
|
|
1564
1606
|
}, {
|
|
1565
1607
|
childCount: 0,
|
|
1566
|
-
className:
|
|
1608
|
+
className: `${MaskIcon} ${MaskIconChevronUp}`,
|
|
1567
1609
|
type: Div
|
|
1568
1610
|
}, {
|
|
1569
|
-
ariaLabel:
|
|
1611
|
+
ariaLabel: close(),
|
|
1570
1612
|
childCount: 1,
|
|
1571
|
-
className:
|
|
1613
|
+
className: IconButton,
|
|
1572
1614
|
onClick: HandleClickClose,
|
|
1573
|
-
|
|
1615
|
+
title: close(),
|
|
1574
1616
|
type: Button
|
|
1575
1617
|
}, {
|
|
1576
1618
|
childCount: 0,
|
|
1577
|
-
className:
|
|
1619
|
+
className: `${MaskIcon} ${MaskIconClose}`,
|
|
1578
1620
|
type: Div
|
|
1579
1621
|
}];
|
|
1580
1622
|
};
|
|
1581
1623
|
|
|
1582
|
-
const
|
|
1583
|
-
const PanelTab = 'PanelTab';
|
|
1584
|
-
const PanelTabSelected = 'PanelTabSelected';
|
|
1585
|
-
|
|
1586
|
-
const createPanelTab = (tab, badgeCount, isSelected, index) => {
|
|
1587
|
-
const label = tab;
|
|
1624
|
+
const getTabClassName = isSelected => {
|
|
1588
1625
|
let className = PanelTab;
|
|
1589
1626
|
if (isSelected) {
|
|
1590
1627
|
className += ' ' + PanelTabSelected;
|
|
1591
1628
|
}
|
|
1629
|
+
return className;
|
|
1630
|
+
};
|
|
1631
|
+
const createPanelTab = (tab, badgeCount, isSelected, index) => {
|
|
1632
|
+
const label = tab;
|
|
1633
|
+
const className = getTabClassName(isSelected);
|
|
1592
1634
|
const childCount = badgeCount ? 2 : 1;
|
|
1593
1635
|
const tabDom = {
|
|
1594
1636
|
ariaSelected: isSelected,
|
|
1595
1637
|
childCount,
|
|
1596
1638
|
className,
|
|
1597
1639
|
'data-index': index,
|
|
1640
|
+
name: tab,
|
|
1598
1641
|
onClick: HandleClickSelectTab,
|
|
1599
1642
|
role: Tab,
|
|
1600
|
-
type:
|
|
1643
|
+
type: Button
|
|
1601
1644
|
};
|
|
1602
1645
|
const dom = [tabDom, text(label)];
|
|
1603
1646
|
if (badgeCount) {
|
|
@@ -1609,6 +1652,7 @@ const createPanelTab = (tab, badgeCount, isSelected, index) => {
|
|
|
1609
1652
|
}
|
|
1610
1653
|
return dom;
|
|
1611
1654
|
};
|
|
1655
|
+
|
|
1612
1656
|
const getPanelTabsVirtualDom = (tabs, selectedIndex, badgeCounts) => {
|
|
1613
1657
|
const dom = [];
|
|
1614
1658
|
for (let i = 0; i < tabs.length; i++) {
|
|
@@ -1620,24 +1664,28 @@ const getPanelTabsVirtualDom = (tabs, selectedIndex, badgeCounts) => {
|
|
|
1620
1664
|
return dom;
|
|
1621
1665
|
};
|
|
1622
1666
|
|
|
1623
|
-
const
|
|
1624
|
-
const {
|
|
1625
|
-
childUid
|
|
1626
|
-
} = newState;
|
|
1667
|
+
const getPanelHeaderDom = newState => {
|
|
1627
1668
|
const tabsDom = getPanelTabsVirtualDom(newState.views, newState.selectedIndex, newState.badgeCounts);
|
|
1628
1669
|
return [{
|
|
1629
|
-
childCount: 2,
|
|
1630
|
-
className: 'Panel',
|
|
1631
|
-
type: Div
|
|
1632
|
-
}, {
|
|
1633
1670
|
childCount: 3,
|
|
1634
|
-
className:
|
|
1671
|
+
className: PanelHeader,
|
|
1635
1672
|
type: Div
|
|
1636
1673
|
}, {
|
|
1637
1674
|
childCount: newState.views.length,
|
|
1638
|
-
className:
|
|
1675
|
+
className: PanelTabs,
|
|
1676
|
+
type: Div
|
|
1677
|
+
}, ...tabsDom, ...getActionsDom(newState), ...getGlobalActionsDom()];
|
|
1678
|
+
};
|
|
1679
|
+
|
|
1680
|
+
const getPanelDom = newState => {
|
|
1681
|
+
const {
|
|
1682
|
+
childUid
|
|
1683
|
+
} = newState;
|
|
1684
|
+
return [{
|
|
1685
|
+
childCount: 2,
|
|
1686
|
+
className: Panel,
|
|
1639
1687
|
type: Div
|
|
1640
|
-
}, ...
|
|
1688
|
+
}, ...getPanelHeaderDom(newState), {
|
|
1641
1689
|
type: Reference,
|
|
1642
1690
|
uid: childUid
|
|
1643
1691
|
}];
|
|
@@ -1743,6 +1791,7 @@ const commandMap = {
|
|
|
1743
1791
|
'Panel.create': create,
|
|
1744
1792
|
'Panel.diff2': diff2,
|
|
1745
1793
|
'Panel.getCommandIds': getCommandIds,
|
|
1794
|
+
'Panel.handleBlur': wrapCommand(handleBlur),
|
|
1746
1795
|
'Panel.handleClickClose': wrapCommand(handleClickClose),
|
|
1747
1796
|
'Panel.handleClickMaximize': wrapCommand(handleClickMaximize),
|
|
1748
1797
|
'Panel.handleFilterInput': wrapCommand(handleFilterInput),
|