diff --git a/modules/svg/SvgIcon.jsx b/modules/svg/SvgIcon.jsx
index 7ed550be..7131a4f1 100644
--- a/modules/svg/SvgIcon.jsx
+++ b/modules/svg/SvgIcon.jsx
@@ -1,17 +1,9 @@
-import React, {useEffect, useMemo, useRef} from 'react';
+import React, {useMemo} from 'react';
export function SvgIcon({content, size, ...props}) {
- const divEl = useRef(null);
-
const className = size&&'icon-'+size;
- useEffect(() => {
- if (divEl.current) {
- divEl.current.innerHTML = content;
- }
- }, [divEl]);
-
const style = useMemo(() => {
return {
display: 'flex',
@@ -19,7 +11,7 @@ export function SvgIcon({content, size, ...props}) {
};
}, [props.style]);
- return
+ return
}
diff --git a/modules/ui/components/Stack.jsx b/modules/ui/components/Stack.jsx
index 960abc1e..40766825 100644
--- a/modules/ui/components/Stack.jsx
+++ b/modules/ui/components/Stack.jsx
@@ -2,8 +2,8 @@ import React from 'react';
import ls from './Stack.less'
-export default function Stack({children}) {
- return
{children}
+export default function Stack(props) {
+ return
}
diff --git a/modules/ui/components/controls/Button.jsx b/modules/ui/components/controls/Button.jsx
index 813ee749..49ab419c 100644
--- a/modules/ui/components/controls/Button.jsx
+++ b/modules/ui/components/controls/Button.jsx
@@ -2,9 +2,9 @@ import React from 'react';
import cx from 'classnames';
-export default function Button({type, onClick, className, children}) {
+export default function Button({type, onClick, className, ...props}) {
- return
+ return
}
diff --git a/web/app/sketcher.js b/web/app/sketcher.js
index 50627f59..e58d1198 100644
--- a/web/app/sketcher.js
+++ b/web/app/sketcher.js
@@ -1,11 +1,12 @@
+import '../css/app.less'
+import 'ui/styles/init/index.less';
+
import App2D from './sketcher/sketcher-app';
import {Layer} from './sketcher/viewer2d';
import * as ui from './ui/ui.js';
import * as toolkit from './ui/toolkit';
import {Constraints} from './sketcher/parametric'
import './utils/jqueryfy'
-import '../css/app.less'
-import 'ui/styles/init/index.less';
import ReactDOM from "react-dom";
import {SketcherApp} from "./sketcher/components/SketcherApp";
@@ -25,16 +26,6 @@ function initializeSketcherApplication() {
app.loadFromLocalStorage();
app.fit();
- var actionsWin = new ui.Window($('#actions'), app.winManager);
-
- ui.bindOpening( $('#showActions'), actionsWin );
- var addAction = ui.createActionsWinBuilder(actionsWin);
-
- for (var p = 0; p < app._actionsOrder.length; ++p) {
- var act = app.actions[app._actionsOrder[p]];
- addAction(act.desc, act.action);
- $('.act-' + act.id).click(act.action).attr('title', act.desc);
- }
const constraintsView = app.dock.views['Constraints'];
diff --git a/web/app/sketcher/actions/commonActions.js b/web/app/sketcher/actions/commonActions.js
index a1f49062..7883ab41 100644
--- a/web/app/sketcher/actions/commonActions.js
+++ b/web/app/sketcher/actions/commonActions.js
@@ -65,9 +65,11 @@ export default [
icon: AiOutlineExport,
invoke: (ctx, e) => {
- ui.openWin(ctx.app._exportWin, e);
+ ctx.ui.$exportDialogRequest.next({
+ x: e.pageX,
+ y: e.pageY
+ });
}
-
},
{
diff --git a/web/app/sketcher/actions/exportActions.js b/web/app/sketcher/actions/exportActions.js
new file mode 100644
index 00000000..01e6bf49
--- /dev/null
+++ b/web/app/sketcher/actions/exportActions.js
@@ -0,0 +1,31 @@
+import {IO} from "../io";
+import React from "react";
+import {AiOutlineExport} from "react-icons/ai";
+
+
+export default [
+ {
+ id: 'ExportSVG',
+ shortName: 'Export to SVG',
+ kind: 'Export',
+ description: 'Export sketch to SVG',
+ icon: AiOutlineExport,
+
+ invoke: (ctx) => {
+ IO.exportTextData(ctx.viewer.io.svgExport(), ctx.app.getSketchId() + ".svg");
+ }
+ },
+
+ {
+ id: 'ExportDXF',
+ shortName: 'Export to DXF',
+ kind: 'Export',
+ description: 'Export sketch to DXF',
+ icon: AiOutlineExport,
+
+ invoke: (ctx) => {
+ IO.exportTextData(ctx.viewer.io.dxfExport(), ctx.app.getSketchId() + ".dxf");
+ }
+
+ },
+];
\ No newline at end of file
diff --git a/web/app/sketcher/actions/index.js b/web/app/sketcher/actions/index.js
index 0775d677..66f33780 100644
--- a/web/app/sketcher/actions/index.js
+++ b/web/app/sketcher/actions/index.js
@@ -6,6 +6,7 @@ import constraintGlobalActions from "./constraintGlobalActions";
import measureActions from "./measureActions";
import toolActions from "./toolActions";
import commonActions from "./commonActions";
+import exportActions from "./exportActions";
const ALL_CONTEXTUAL_ACTIONS = [
...constraintActions,
@@ -16,7 +17,8 @@ const ACTIONS = [
...constraintGlobalActions,
...measureActions,
...toolActions,
- ...commonActions
+ ...commonActions,
+ ...exportActions
//keep going here
];
diff --git a/web/app/sketcher/components/ExportDialog.jsx b/web/app/sketcher/components/ExportDialog.jsx
new file mode 100644
index 00000000..24d7b29a
--- /dev/null
+++ b/web/app/sketcher/components/ExportDialog.jsx
@@ -0,0 +1,29 @@
+import React from 'react';
+import {useStreamWithUpdater} from "ui/effects";
+import Window from "../../../../modules/ui/components/Window";
+import Stack from "../../../../modules/ui/components/Stack";
+import {SketcherActionButton} from "./SketcherActionButton";
+
+export function ExportDialog() {
+
+ const [request, setRequest] = useStreamWithUpdater(ctx => ctx.ui.$exportDialogRequest);
+
+ if (!request) {
+ return null;
+ }
+ const x = request.x || 200;
+ const y = request.y || 200;
+ return
setRequest(null)}>
+
+
+
+
+
+
+}
+
+const style = {
+ fontSize: 12,
+};
\ No newline at end of file
diff --git a/web/app/sketcher/components/SketchManager.jsx b/web/app/sketcher/components/SketchManager.jsx
index 9d30cc9d..84dacc55 100644
--- a/web/app/sketcher/components/SketchManager.jsx
+++ b/web/app/sketcher/components/SketchManager.jsx
@@ -52,12 +52,12 @@ function SketchList() {
{items.map(item =>
app.openSketch(item)}>
{item}
- {' '}
-
)}
diff --git a/web/app/sketcher/components/SketcherActionButton.jsx b/web/app/sketcher/components/SketcherActionButton.jsx
new file mode 100644
index 00000000..0fb70fe9
--- /dev/null
+++ b/web/app/sketcher/components/SketcherActionButton.jsx
@@ -0,0 +1,21 @@
+import {getSketcherAction} from "../actions";
+import React, {useContext} from "react";
+import {SketcherAppContext} from "./SketcherApp";
+
+export function SketcherActionButton({actionId, text=false}) {
+
+ const action = getSketcherAction(actionId);
+
+ if (!action) {
+ return
?{actionId}?;
+ }
+
+ const ctx = useContext(SketcherAppContext);
+
+ const Icon = action.icon;
+
+ return
action.invoke(ctx, e)} title={action.description} className={`action-kind-${action.kind} ${text ? 'icon-button' : ''}`}>
+ {Icon && } {(text || !Icon) && action.shortName}
+ ;
+
+}
diff --git a/web/app/sketcher/components/SketcherApp.jsx b/web/app/sketcher/components/SketcherApp.jsx
index 7cab0aec..ec3d9577 100644
--- a/web/app/sketcher/components/SketcherApp.jsx
+++ b/web/app/sketcher/components/SketcherApp.jsx
@@ -12,6 +12,7 @@ import {Scope} from "./Scope";
import {SketcherToolbar} from "./SketcherToolbar";
import {sketcherRightToolbarConfig, sketcherTopToolbarConfig} from "../uiConfig";
import {SketchManager} from "./SketchManager";
+import {ExportDialog} from "./ExportDialog";
export const SketcherAppContext = React.createContext({});
@@ -33,7 +34,10 @@ export function SketcherApp({applicationContext}) {
document.getElementById('top-toolbar')
)}
{ReactDOM.createPortal(
-
,
+
+
+
+ ,
document.getElementById('global-windows')
)}
diff --git a/web/app/sketcher/components/SketcherToolbar.jsx b/web/app/sketcher/components/SketcherToolbar.jsx
index 110cda82..e2e526f3 100644
--- a/web/app/sketcher/components/SketcherToolbar.jsx
+++ b/web/app/sketcher/components/SketcherToolbar.jsx
@@ -1,8 +1,7 @@
-import React, {useContext} from 'react';
-import {getSketcherAction} from "../actions";
-import {SketcherAppContext} from "./SketcherApp";
+import React from 'react';
import ls from './SketcherToolbar.less';
import cx from 'classnames';
+import {SketcherActionButton} from "./SketcherActionButton";
export function SketcherToolbar({actions, horizontal=false, compact}) {
@@ -15,21 +14,3 @@ export function SketcherToolbar({actions, horizontal=false, compact}) {
})}
;
}
-
-export function SketcherActionButton({actionId}) {
-
- const action = getSketcherAction(actionId);
-
- if (!action) {
- return