From 42e78dab52dcac803036397d15f3bdd696b9097d Mon Sep 17 00:00:00 2001 From: ochafik Date: Sun, 26 Mar 2023 15:29:18 +0100 Subject: [PATCH] new actions menu --- src/App.tsx | 129 ++++++++++++++++++++++++++++++++++++++++++++++--- src/actions.ts | 4 +- 2 files changed, 124 insertions(+), 9 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 18eaddd..2f0ffd8 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -78,6 +78,8 @@ function EditorPanel({className, style}: {className?: string, style?: CSSPropert const model = useContext(ModelContext); if (!model) throw new Error('No model'); + const menu = useRef(null); + const state = model.state; const fs = useContext(FSContext); @@ -141,12 +143,120 @@ function EditorPanel({className, style}: {className?: string, style?: CSSPropert ...(style ?? {}) }}> {/* */} - model.openFile(String(e.value))} - filter - options={fsItems} /> +
+ + window.open(buildUrlForStateParams(blankProjectState), '_blank'), + }, + { + // TODO: share text, title and rendering image + // https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share + label: 'Share project', + icon: 'pi pi-share-alt', + disabled: true, + command: () => window.open('http://openscad.org/cheatsheet/', '_blank'), + }, + { + separator: true + }, + { + // TODO: popup to ask for file name + label: "New file", + icon: 'pi pi-plus', + disabled: true, + command: () => window.open('https://github.com/openscad/openscad-playground/tree/rewrite1', '_blank'), + }, + { + label: "Copy to new file", + icon: 'pi pi-clone', + disabled: true, + command: () => window.open('https://github.com/openscad/openscad-playground/tree/rewrite1', '_blank'), + }, + { + label: "Upload file(s)", + icon: 'pi pi-upload', + disabled: true, + command: () => window.open('https://github.com/openscad/openscad-playground/tree/rewrite1', '_blank'), + }, + { + label: 'Download sources', + icon: 'pi pi-download', + disabled: true, + command: () => window.open('https://github.com/revarbat/BOSL2/wiki/CheatSheet', '_blank'), + }, + { + separator: true + }, + // https://vscode-docs.readthedocs.io/en/stable/customization/keybindings/ + // { + // label: 'Undo', + // icon: 'pi pi-undo', + // // disabled: true, + // command: () => editor?.trigger(state.params.sourcePath, 'editor.action.undoAction', null), + // }, + // { + // label: 'Redo', + // icon: 'pi pi-reply', + // // disabled: true, + // command: () => editor?.trigger(state.params.sourcePath, 'editor.action.redoAction', null), + // }, + { + separator: true + }, + // { + // label: 'Copy', + // icon: 'pi pi-copy', + // // disabled: true, + // command: () => editor?.trigger(state.params.sourcePath, 'editor.action.clipboardCopyAction', null), + // }, + // { + // label: 'Cut', + // icon: 'pi pi-eraser', + // // disabled: true, + // command: () => editor?.trigger(state.params.sourcePath, 'editor.action.clipboardCutAction', null), + // }, + // { + // label: 'Paste', + // icon: 'pi pi-images', + // // disabled: true, + // command: () => editor?.trigger(state.params.sourcePath, 'editor.action.clipboardPasteAction', null), + // }, + { + label: 'Select All', + icon: 'pi pi-info-circle', + // disabled: true, + command: () => editor?.trigger(state.params.sourcePath, 'editor.action.selectAll', null), + }, + { + separator: true + }, + { + label: 'Find', + icon: 'pi pi-search', + // disabled: true, + command: () => editor?.trigger(state.params.sourcePath, 'actions.find', null), + }, + ] as MenuItem[]} popup ref={menu} /> +
{/* */} {/*
*/} @@ -279,6 +389,7 @@ function Footer({style}: {style?: CSSProperties}) { if (!model) throw new Error('No model'); const menu = useRef(null); + const toast = useRef(null); const state = model.state; @@ -321,6 +432,7 @@ function Footer({style}: {style?: CSSProperties}) {