From 2db1e43f21c936739fbb127cb7e8a0b2536d743d Mon Sep 17 00:00:00 2001 From: llj Date: Fri, 16 Aug 2024 20:27:18 +0800 Subject: [PATCH] ['dir view'] for 'sdoc' file: add menu option 'Convert & Export', and (#6574) make 'convert to markdown', 'convert to docx', 'export as docx' as its sub-menu options - menus: the 'more operation' menu for the current ``, the 'more operation' menu for the single selected file, the context menu --- .../components/context-menu/context-menu.js | 56 +++++++++++++++++ .../dropdown-menu/item-dropdown-menu.js | 60 ++++++++++++++++++- frontend/src/utils/text-translation.js | 1 + frontend/src/utils/utils.js | 18 ++++-- 4 files changed, 129 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/context-menu/context-menu.js b/frontend/src/components/context-menu/context-menu.js index 777b579c91..4a14a18e74 100644 --- a/frontend/src/components/context-menu/context-menu.js +++ b/frontend/src/components/context-menu/context-menu.js @@ -1,5 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; +import { Dropdown, DropdownMenu, DropdownToggle, DropdownItem } from 'reactstrap'; import listener from './globalEventListener'; import { hideMenu } from './actions'; import { callIfExists } from './helpers'; @@ -24,6 +25,8 @@ class ContextMenu extends React.Component { isVisible: false, currentObject: null, menuList: [], + isSubMenuShown: false, + currentItem: '' }; } @@ -183,6 +186,28 @@ class ContextMenu extends React.Component { event.stopPropagation(); }; + onDropDownMouseMove = (e) => { + if (this.state.isSubMenuShown && e.target && e.target.className === 'dropdown-item') { + this.setState({ + isSubMenuShown: false + }); + } + }; + + toggleSubMenu = (e) => { + e.stopPropagation(); + this.setState({ + isSubMenuShown: !this.state.isSubMenuShown + }); + }; + + toggleSubMenuShown = (item) => { + this.setState({ + isSubMenuShown: true, + currentItem: item.key + }); + }; + render() { const inlineStyle = { position: 'fixed', opacity: 0, pointerEvents: 'none', display: 'block' }; return ( @@ -190,6 +215,37 @@ class ContextMenu extends React.Component { {this.state.menuList.map((menuItem, index) => { if (menuItem === 'Divider') { return
; + } else if (menuItem.subOpList) { + return ( + {e.stopPropagation();}} + > + + {menuItem.value} + + + + {menuItem.subOpList.map((item, index) => { + if (item == 'Divider') { + return ; + } else { + return ( + {item.value} + ); + } + })} + + + ); } else { return (