@lvce-editor/problems-view 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/problemsViewWorkerMain.js +59 -37
- package/package.json +1 -1
|
@@ -1086,6 +1086,18 @@ const focusIndex = (state, index) => {
|
|
|
1086
1086
|
};
|
|
1087
1087
|
};
|
|
1088
1088
|
|
|
1089
|
+
const commandMapRef = {};
|
|
1090
|
+
|
|
1091
|
+
const toCommandId = key => {
|
|
1092
|
+
const dotIndex = key.indexOf('.');
|
|
1093
|
+
return key.slice(dotIndex + 1);
|
|
1094
|
+
};
|
|
1095
|
+
const getCommandIds = () => {
|
|
1096
|
+
const keys = Object.keys(commandMapRef);
|
|
1097
|
+
const ids = keys.map(toCommandId);
|
|
1098
|
+
return ids;
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1089
1101
|
const None = 'none';
|
|
1090
1102
|
const ToolBar = 'toolbar';
|
|
1091
1103
|
const Tree$1 = 'tree';
|
|
@@ -1495,6 +1507,19 @@ const getActionButtonVirtualDom = action => {
|
|
|
1495
1507
|
}, getIconVirtualDom(icon)];
|
|
1496
1508
|
};
|
|
1497
1509
|
|
|
1510
|
+
const getInputBoxVirtualDom = (name, onInput, placeholder) => {
|
|
1511
|
+
return {
|
|
1512
|
+
type: VirtualDomElements.Input,
|
|
1513
|
+
className: InputBox,
|
|
1514
|
+
autocapitalize: 'off',
|
|
1515
|
+
autocorrect: 'off',
|
|
1516
|
+
name,
|
|
1517
|
+
onInput: onInput,
|
|
1518
|
+
placeholder: placeholder,
|
|
1519
|
+
spellcheck: false
|
|
1520
|
+
};
|
|
1521
|
+
};
|
|
1522
|
+
|
|
1498
1523
|
const Filter$1 = 'filter';
|
|
1499
1524
|
|
|
1500
1525
|
const CollapseAll = 'CollapseAll';
|
|
@@ -1502,41 +1527,36 @@ const Filter = 'Filter';
|
|
|
1502
1527
|
const ListFlat = 'ListFlat';
|
|
1503
1528
|
const ListTree = 'ListTree';
|
|
1504
1529
|
|
|
1530
|
+
const getChildCount = badgeText => {
|
|
1531
|
+
let childCount = 0;
|
|
1532
|
+
childCount++; // input
|
|
1533
|
+
if (badgeText) {
|
|
1534
|
+
childCount++; // badge
|
|
1535
|
+
}
|
|
1536
|
+
childCount++; // action button
|
|
1537
|
+
return childCount;
|
|
1538
|
+
};
|
|
1539
|
+
const getBadgeDom = badgeText => {
|
|
1540
|
+
if (!badgeText) {
|
|
1541
|
+
return [];
|
|
1542
|
+
}
|
|
1543
|
+
return [{
|
|
1544
|
+
type: VirtualDomElements.Div,
|
|
1545
|
+
className: FilterBadge,
|
|
1546
|
+
childCount: 1
|
|
1547
|
+
}, text(badgeText)];
|
|
1548
|
+
};
|
|
1505
1549
|
const getProblemsFilterVirtualDom = action => {
|
|
1506
|
-
|
|
1507
|
-
const dom = [];
|
|
1508
|
-
dom.push({
|
|
1550
|
+
return [{
|
|
1509
1551
|
type: VirtualDomElements.Div,
|
|
1510
1552
|
className: Filter$2,
|
|
1511
|
-
childCount:
|
|
1512
|
-
}, {
|
|
1513
|
-
type: VirtualDomElements.Input,
|
|
1514
|
-
className: InputBox,
|
|
1515
|
-
spellcheck: false,
|
|
1516
|
-
autocapitalize: 'off',
|
|
1517
|
-
autocorrect: 'off',
|
|
1518
|
-
placeholder: action.placeholder,
|
|
1519
|
-
onInput: action.command,
|
|
1520
|
-
name: Filter$1,
|
|
1521
|
-
value: action.value
|
|
1522
|
-
});
|
|
1523
|
-
if (action.badgeText) {
|
|
1524
|
-
// @ts-ignore
|
|
1525
|
-
dom[0].childCount++;
|
|
1526
|
-
dom.push({
|
|
1527
|
-
type: VirtualDomElements.Div,
|
|
1528
|
-
className: FilterBadge,
|
|
1529
|
-
childCount: 1
|
|
1530
|
-
}, text(action.badgeText));
|
|
1531
|
-
}
|
|
1532
|
-
// @ts-ignore
|
|
1533
|
-
dom[0].childCount++;
|
|
1534
|
-
dom.push(...getActionButtonVirtualDom({
|
|
1553
|
+
childCount: getChildCount(action.badgeText)
|
|
1554
|
+
}, getInputBoxVirtualDom(Filter$1, action.command, action.placeholder || ''), ...getBadgeDom(action.badgeText), ...getActionButtonVirtualDom({
|
|
1535
1555
|
id: 'more filters',
|
|
1556
|
+
// TODO use i18n string
|
|
1536
1557
|
icon: Filter,
|
|
1537
1558
|
command: 'more filters'
|
|
1538
|
-
})
|
|
1539
|
-
return dom;
|
|
1559
|
+
})];
|
|
1540
1560
|
};
|
|
1541
1561
|
|
|
1542
1562
|
const getBadgeVirtualDom = (className, count) => {
|
|
@@ -1837,8 +1857,7 @@ const getProblemsVirtualDom$1 = (viewMode, problems, filterValue) => {
|
|
|
1837
1857
|
if (viewMode === Table) {
|
|
1838
1858
|
return getProblemsTableVirtualDom(problems);
|
|
1839
1859
|
}
|
|
1840
|
-
|
|
1841
|
-
return dom;
|
|
1860
|
+
return getProblemsListVirtualDom(problems);
|
|
1842
1861
|
};
|
|
1843
1862
|
|
|
1844
1863
|
const getProblemsVirtualDom = (viewMode, problems, filterValue, isSmall) => {
|
|
@@ -1858,9 +1877,7 @@ const getProblemsVirtualDom = (viewMode, problems, filterValue, isSmall) => {
|
|
|
1858
1877
|
dom.push(...getProblemsFilterVirtualDom({
|
|
1859
1878
|
command: HandleFilterInput,
|
|
1860
1879
|
badgeText: '',
|
|
1861
|
-
placeholder: filter()
|
|
1862
|
-
value: ''
|
|
1863
|
-
}));
|
|
1880
|
+
placeholder: filter()}));
|
|
1864
1881
|
}
|
|
1865
1882
|
dom.push(...getProblemsVirtualDom$1(viewMode, problems, filterValue));
|
|
1866
1883
|
return dom;
|
|
@@ -2031,7 +2048,10 @@ const getActions = state => {
|
|
|
2031
2048
|
return actions;
|
|
2032
2049
|
};
|
|
2033
2050
|
|
|
2034
|
-
const renderActions =
|
|
2051
|
+
const renderActions = uid => {
|
|
2052
|
+
const {
|
|
2053
|
+
newState
|
|
2054
|
+
} = get(uid);
|
|
2035
2055
|
const actions = getActions(newState);
|
|
2036
2056
|
const dom = getActionsVirtualDom(actions);
|
|
2037
2057
|
return dom;
|
|
@@ -2108,12 +2128,14 @@ const commandMap = {
|
|
|
2108
2128
|
'Problems.handleContextMenu': handleContextMenu,
|
|
2109
2129
|
'Problems.viewAsTable': viewAsTable,
|
|
2110
2130
|
'Problems.viewAsList': viewAsList,
|
|
2111
|
-
'Problems.handleClickAt': wrapCommand(handleClickAt)
|
|
2131
|
+
'Problems.handleClickAt': wrapCommand(handleClickAt),
|
|
2132
|
+
'Problems.getCommandIds': getCommandIds
|
|
2112
2133
|
};
|
|
2113
2134
|
|
|
2114
2135
|
const listen = async () => {
|
|
2136
|
+
Object.assign(commandMapRef, commandMap);
|
|
2115
2137
|
const rpc = await WebWorkerRpcClient.create({
|
|
2116
|
-
commandMap:
|
|
2138
|
+
commandMap: commandMapRef
|
|
2117
2139
|
});
|
|
2118
2140
|
set$1(rpc);
|
|
2119
2141
|
};
|