@rytass/wms-map-react-components 0.1.1
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/LICENSE +21 -0
- package/README.md +77 -0
- package/components/breadcrumb/breadcrumb-edit-modal.d.ts +9 -0
- package/components/breadcrumb/breadcrumb-edit-modal.js +92 -0
- package/components/breadcrumb/breadcrumb-edit-modal.module.scss.js +3 -0
- package/components/breadcrumb/breadcrumb.d.ts +8 -0
- package/components/breadcrumb/breadcrumb.js +167 -0
- package/components/breadcrumb/breadcrumb.module.scss.js +3 -0
- package/components/canvas/react-flow-canvas.d.ts +37 -0
- package/components/canvas/react-flow-canvas.js +317 -0
- package/components/canvas/react-flow-canvas.module.scss.js +3 -0
- package/components/modal/wms-map-content.d.ts +4 -0
- package/components/modal/wms-map-content.js +753 -0
- package/components/modal/wms-map-header.d.ts +6 -0
- package/components/modal/wms-map-header.js +19 -0
- package/components/modal/wms-map-header.module.scss.js +3 -0
- package/components/modal/wms-map-modal-container.d.ts +4 -0
- package/components/modal/wms-map-modal-container.js +95 -0
- package/components/modal/wms-map-modal-container.module.scss.js +3 -0
- package/components/nodes/base-node.d.ts +12 -0
- package/components/nodes/image-node.d.ts +17 -0
- package/components/nodes/image-node.js +233 -0
- package/components/nodes/image-node.module.scss.js +3 -0
- package/components/nodes/path-node.d.ts +19 -0
- package/components/nodes/path-node.js +550 -0
- package/components/nodes/path-node.module.scss.js +3 -0
- package/components/nodes/rectangle-node.d.ts +11 -0
- package/components/nodes/rectangle-node.js +236 -0
- package/components/nodes/rectangle-node.module.scss.js +3 -0
- package/components/ui/context-menu.d.ts +25 -0
- package/components/ui/context-menu.js +168 -0
- package/components/ui/context-menu.module.scss.js +3 -0
- package/components/ui/toolbar.d.ts +23 -0
- package/components/ui/toolbar.js +278 -0
- package/components/ui/toolbar.module.scss.js +3 -0
- package/components/ui/view-mode-toolbar.d.ts +9 -0
- package/components/ui/view-mode-toolbar.js +41 -0
- package/components/ui/view-mode-toolbar.module.scss.js +3 -0
- package/constants/index.d.ts +45 -0
- package/constants/index.js +37 -0
- package/constants/text-mappings.d.ts +181 -0
- package/constants/text-mappings.js +44 -0
- package/hooks/use-context-menu.d.ts +37 -0
- package/hooks/use-context-menu.js +228 -0
- package/hooks/use-direct-state-history.d.ts +58 -0
- package/hooks/use-direct-state-history.js +214 -0
- package/hooks/use-pen-drawing.d.ts +30 -0
- package/hooks/use-pen-drawing.js +363 -0
- package/hooks/use-rectangle-drawing.d.ts +19 -0
- package/hooks/use-rectangle-drawing.js +136 -0
- package/hooks/use-text-editing.d.ts +19 -0
- package/hooks/use-text-editing.js +153 -0
- package/icons/index.d.ts +15 -0
- package/icons/index.js +209 -0
- package/index.cjs.css +1 -0
- package/index.cjs.js +5033 -0
- package/index.css +1 -0
- package/index.d.ts +5 -0
- package/index.js +4 -0
- package/package.json +40 -0
- package/types/callback.types.d.ts +7 -0
- package/types/canvas.types.d.ts +35 -0
- package/types/component-props.types.d.ts +41 -0
- package/types/history.types.d.ts +24 -0
- package/types/index.d.ts +5 -0
- package/types/react-flow.types.d.ts +30 -0
- package/typings.d.ts +140 -0
- package/typings.js +37 -0
- package/utils/api-data-transform.d.ts +33 -0
- package/utils/api-data-transform.js +218 -0
- package/utils/color-utils.d.ts +17 -0
- package/utils/color-utils.js +55 -0
- package/utils/debug-logger.d.ts +33 -0
- package/utils/debug-logger.js +41 -0
- package/utils/map-data-transform.d.ts +18 -0
- package/utils/map-data-transform.js +342 -0
- package/utils/node-operations.d.ts +26 -0
- package/utils/node-operations.js +83 -0
- package/utils/node-utils.d.ts +10 -0
- package/utils/node-utils.js +37 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
3
|
+
import { useReactFlow, useUpdateNodeInternals, NodeResizer } from '@xyflow/react';
|
|
4
|
+
import { ViewMode, EditMode } from '../../typings.js';
|
|
5
|
+
import { DEFAULT_RECTANGLE_LABEL, DEFAULT_RECTANGLE_WIDTH, DEFAULT_RECTANGLE_HEIGHT, DEFAULT_RECTANGLE_COLOR, ACTIVE_OPACITY, RECTANGLE_INACTIVE_OPACITY, MIN_RESIZE_HEIGHT, MIN_RESIZE_WIDTH } from '../../constants/index.js';
|
|
6
|
+
import { useContextMenu } from '../../hooks/use-context-menu.js';
|
|
7
|
+
import { useTextEditing } from '../../hooks/use-text-editing.js';
|
|
8
|
+
import { createRectangleCopy } from '../../utils/node-operations.js';
|
|
9
|
+
import { createHoverColor } from '../../utils/color-utils.js';
|
|
10
|
+
import ContextMenu from '../ui/context-menu.js';
|
|
11
|
+
import styles from './rectangle-node.module.scss.js';
|
|
12
|
+
|
|
13
|
+
const RectangleNode = ({ data, selected, id, editMode, viewMode, onTextEditComplete, isHovered = false })=>{
|
|
14
|
+
const { setNodes } = useReactFlow();
|
|
15
|
+
const updateNodeInternals = useUpdateNodeInternals();
|
|
16
|
+
const { width = DEFAULT_RECTANGLE_WIDTH, height = DEFAULT_RECTANGLE_HEIGHT, color = DEFAULT_RECTANGLE_COLOR, label = DEFAULT_RECTANGLE_LABEL } = data;
|
|
17
|
+
const [currentSize, setCurrentSize] = useState({
|
|
18
|
+
width,
|
|
19
|
+
height
|
|
20
|
+
});
|
|
21
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
22
|
+
// Sync state with node data changes
|
|
23
|
+
useEffect(()=>{
|
|
24
|
+
setCurrentSize({
|
|
25
|
+
width,
|
|
26
|
+
height
|
|
27
|
+
});
|
|
28
|
+
}, [
|
|
29
|
+
width,
|
|
30
|
+
height
|
|
31
|
+
]);
|
|
32
|
+
// Only editable in LAYER mode
|
|
33
|
+
const isEditable = viewMode === ViewMode.EDIT && editMode === EditMode.LAYER;
|
|
34
|
+
// Check if this node should be selectable (only in LAYER mode)
|
|
35
|
+
const isSelectable = editMode === EditMode.LAYER;
|
|
36
|
+
const opacity = editMode === EditMode.LAYER ? ACTIVE_OPACITY : RECTANGLE_INACTIVE_OPACITY;
|
|
37
|
+
// Context menu functionality
|
|
38
|
+
const { contextMenu, handleContextMenu, handleCloseContextMenu, handleDelete, arrangeActions, arrangeStates, getNodes, setNodes: setNodesFromHook } = useContextMenu({
|
|
39
|
+
id,
|
|
40
|
+
editMode,
|
|
41
|
+
isEditable,
|
|
42
|
+
nodeType: 'rectangleNode'
|
|
43
|
+
});
|
|
44
|
+
// Text editing functionality
|
|
45
|
+
const { isEditing, editingText, inputRef, setEditingText, handleDoubleClick, handleKeyDown, handleBlur } = useTextEditing({
|
|
46
|
+
id,
|
|
47
|
+
label,
|
|
48
|
+
isEditable,
|
|
49
|
+
onTextEditComplete
|
|
50
|
+
});
|
|
51
|
+
// Handle resize start
|
|
52
|
+
const handleResizeStart = useCallback(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
(_event, _params)=>{
|
|
54
|
+
// 開始調整大小時可以執行額外的邏輯,例如禁用拖拽
|
|
55
|
+
// 這裡保持空白,但提供了擴展點
|
|
56
|
+
}, []);
|
|
57
|
+
// Handle resize with size sync and position update (diagonal anchor)
|
|
58
|
+
const handleResize = useCallback(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
+
(_event, params)=>{
|
|
60
|
+
const newSize = {
|
|
61
|
+
width: params.width,
|
|
62
|
+
height: params.height
|
|
63
|
+
};
|
|
64
|
+
setCurrentSize(newSize);
|
|
65
|
+
// 標記正在調整大小,避免在 WmsMapModal 中記錄歷史
|
|
66
|
+
if (!isResizing) {
|
|
67
|
+
setIsResizing(true);
|
|
68
|
+
}
|
|
69
|
+
// 即時更新節點以提供視覺回饋,同時更新位置以保持對角錨點
|
|
70
|
+
setNodes((nodes)=>nodes.map((node)=>node.id === id ? {
|
|
71
|
+
...node,
|
|
72
|
+
data: {
|
|
73
|
+
...node.data,
|
|
74
|
+
width: params.width,
|
|
75
|
+
height: params.height,
|
|
76
|
+
isResizing: true
|
|
77
|
+
},
|
|
78
|
+
position: {
|
|
79
|
+
x: params.x ?? 0,
|
|
80
|
+
y: params.y ?? 0
|
|
81
|
+
}
|
|
82
|
+
} : node));
|
|
83
|
+
}, [
|
|
84
|
+
id,
|
|
85
|
+
setNodes,
|
|
86
|
+
isResizing
|
|
87
|
+
]);
|
|
88
|
+
// Handle resize end to ensure final state is saved
|
|
89
|
+
const handleResizeEnd = useCallback(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
+
(_event, params)=>{
|
|
91
|
+
const newSize = {
|
|
92
|
+
width: params.width,
|
|
93
|
+
height: params.height
|
|
94
|
+
};
|
|
95
|
+
setCurrentSize(newSize);
|
|
96
|
+
// 清除調整大小標記
|
|
97
|
+
setIsResizing(false);
|
|
98
|
+
// 最終更新節點資料,移除 isResizing 標記,同時更新位置
|
|
99
|
+
// 這次更新會觸發歷史記錄(因為沒有 isResizing 標記)
|
|
100
|
+
setNodes((nodes)=>nodes.map((node)=>node.id === id ? {
|
|
101
|
+
...node,
|
|
102
|
+
data: {
|
|
103
|
+
...node.data,
|
|
104
|
+
width: params.width,
|
|
105
|
+
height: params.height,
|
|
106
|
+
isResizing: undefined
|
|
107
|
+
},
|
|
108
|
+
position: {
|
|
109
|
+
x: params.x ?? 0,
|
|
110
|
+
y: params.y ?? 0
|
|
111
|
+
}
|
|
112
|
+
} : node));
|
|
113
|
+
// 確保內部狀態同步
|
|
114
|
+
updateNodeInternals(id);
|
|
115
|
+
}, [
|
|
116
|
+
id,
|
|
117
|
+
setNodes,
|
|
118
|
+
updateNodeInternals
|
|
119
|
+
]);
|
|
120
|
+
// Handle copy and paste
|
|
121
|
+
const handleCopyPaste = useCallback(()=>{
|
|
122
|
+
const currentNode = getNodes().find((node)=>node.id === id);
|
|
123
|
+
if (!currentNode) {
|
|
124
|
+
console.error('Current node not found');
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
setNodesFromHook((nds)=>{
|
|
128
|
+
// Calculate next zIndex
|
|
129
|
+
const maxZIndex = Math.max(...nds.map((n)=>n.zIndex || 0), 0);
|
|
130
|
+
const copiedNode = createRectangleCopy({
|
|
131
|
+
currentNode,
|
|
132
|
+
data: {
|
|
133
|
+
width: currentSize.width,
|
|
134
|
+
height: currentSize.height,
|
|
135
|
+
color,
|
|
136
|
+
label
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
const nodeWithZIndex = {
|
|
140
|
+
...copiedNode,
|
|
141
|
+
zIndex: maxZIndex + 1
|
|
142
|
+
};
|
|
143
|
+
return [
|
|
144
|
+
...nds,
|
|
145
|
+
nodeWithZIndex
|
|
146
|
+
];
|
|
147
|
+
});
|
|
148
|
+
handleCloseContextMenu();
|
|
149
|
+
}, [
|
|
150
|
+
id,
|
|
151
|
+
currentSize,
|
|
152
|
+
color,
|
|
153
|
+
label,
|
|
154
|
+
getNodes,
|
|
155
|
+
setNodesFromHook,
|
|
156
|
+
handleCloseContextMenu
|
|
157
|
+
]);
|
|
158
|
+
// 在檢視模式下計算 hover 顏色
|
|
159
|
+
const displayColor = viewMode === ViewMode.VIEW && isHovered ? createHoverColor(color) : color;
|
|
160
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
161
|
+
className: `${styles.rectangleNode} ${selected && isEditable ? styles.selected : ''} ${!isSelectable ? styles.nonSelectable : ''}`,
|
|
162
|
+
children: [
|
|
163
|
+
selected && isEditable && /*#__PURE__*/ jsx(NodeResizer, {
|
|
164
|
+
minWidth: MIN_RESIZE_WIDTH,
|
|
165
|
+
minHeight: MIN_RESIZE_HEIGHT,
|
|
166
|
+
keepAspectRatio: false,
|
|
167
|
+
onResizeStart: handleResizeStart,
|
|
168
|
+
onResize: handleResize,
|
|
169
|
+
onResizeEnd: handleResizeEnd,
|
|
170
|
+
isVisible: selected && isEditable,
|
|
171
|
+
color: "#5570d3",
|
|
172
|
+
handleClassName: styles.customResizeHandle
|
|
173
|
+
}),
|
|
174
|
+
/*#__PURE__*/ jsx("div", {
|
|
175
|
+
className: styles.rectangleContainer,
|
|
176
|
+
style: {
|
|
177
|
+
width: `${currentSize.width}px`,
|
|
178
|
+
height: `${currentSize.height}px`,
|
|
179
|
+
backgroundColor: `${displayColor}33`,
|
|
180
|
+
opacity: opacity,
|
|
181
|
+
border: selected && isEditable ? '2px solid #3b82f6' : `2px solid ${displayColor}`,
|
|
182
|
+
borderRadius: '4px',
|
|
183
|
+
display: 'flex',
|
|
184
|
+
alignItems: 'center',
|
|
185
|
+
justifyContent: 'center',
|
|
186
|
+
color: 'white',
|
|
187
|
+
fontSize: '12px',
|
|
188
|
+
fontWeight: 'bold',
|
|
189
|
+
textShadow: '1px 1px 2px rgba(0,0,0,0.5)',
|
|
190
|
+
position: 'relative',
|
|
191
|
+
cursor: viewMode === ViewMode.VIEW ? 'pointer' : 'default',
|
|
192
|
+
transition: viewMode === ViewMode.VIEW ? 'all 0.2s ease' : 'none'
|
|
193
|
+
},
|
|
194
|
+
onDoubleClick: viewMode === ViewMode.EDIT ? handleDoubleClick : undefined,
|
|
195
|
+
onContextMenu: viewMode === ViewMode.EDIT ? handleContextMenu : undefined,
|
|
196
|
+
children: isEditing ? /*#__PURE__*/ jsx("input", {
|
|
197
|
+
ref: inputRef,
|
|
198
|
+
type: "text",
|
|
199
|
+
value: editingText,
|
|
200
|
+
onChange: (e)=>setEditingText(e.target.value),
|
|
201
|
+
onKeyDown: handleKeyDown,
|
|
202
|
+
onBlur: handleBlur,
|
|
203
|
+
style: {
|
|
204
|
+
background: 'transparent',
|
|
205
|
+
border: 'none',
|
|
206
|
+
outline: 'none',
|
|
207
|
+
color: 'white',
|
|
208
|
+
fontSize: '12px',
|
|
209
|
+
fontWeight: 'bold',
|
|
210
|
+
textAlign: 'center',
|
|
211
|
+
width: '90%',
|
|
212
|
+
textShadow: '1px 1px 2px rgba(0,0,0,0.5)'
|
|
213
|
+
},
|
|
214
|
+
onClick: (e)=>e.stopPropagation()
|
|
215
|
+
}) : /*#__PURE__*/ jsx("span", {
|
|
216
|
+
style: {
|
|
217
|
+
cursor: 'default'
|
|
218
|
+
},
|
|
219
|
+
children: label
|
|
220
|
+
})
|
|
221
|
+
}),
|
|
222
|
+
viewMode === ViewMode.EDIT && /*#__PURE__*/ jsx(ContextMenu, {
|
|
223
|
+
visible: contextMenu.visible,
|
|
224
|
+
x: contextMenu.x,
|
|
225
|
+
y: contextMenu.y,
|
|
226
|
+
onClose: handleCloseContextMenu,
|
|
227
|
+
onCopyPaste: handleCopyPaste,
|
|
228
|
+
onDelete: handleDelete,
|
|
229
|
+
arrangeActions: arrangeActions,
|
|
230
|
+
arrangeStates: arrangeStates
|
|
231
|
+
})
|
|
232
|
+
]
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export { RectangleNode as default };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var styles = {"rectangleNode":"rectangle-node-module_rectangleNode__gQkvp","selected":"rectangle-node-module_selected__QiPsy","nonSelectable":"rectangle-node-module_nonSelectable__5Fz40","rectangleContainer":"rectangle-node-module_rectangleContainer__8dFeg","customResizeHandle":"rectangle-node-module_customResizeHandle__0ckhO"};
|
|
2
|
+
|
|
3
|
+
export { styles as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
interface ArrangeActions {
|
|
3
|
+
onBringToFront: () => void;
|
|
4
|
+
onBringForward: () => void;
|
|
5
|
+
onSendBackward: () => void;
|
|
6
|
+
onSendToBack: () => void;
|
|
7
|
+
}
|
|
8
|
+
interface ArrangeStates {
|
|
9
|
+
canBringToFront: boolean;
|
|
10
|
+
canBringForward: boolean;
|
|
11
|
+
canSendBackward: boolean;
|
|
12
|
+
canSendToBack: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface ContextMenuProps {
|
|
15
|
+
visible: boolean;
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
onCopyPaste: () => void;
|
|
20
|
+
onDelete: () => void;
|
|
21
|
+
arrangeActions: ArrangeActions;
|
|
22
|
+
arrangeStates: ArrangeStates;
|
|
23
|
+
}
|
|
24
|
+
declare const ContextMenu: FC<ContextMenuProps>;
|
|
25
|
+
export default ContextMenu;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useRef, useState, useEffect } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import styles from './context-menu.module.scss.js';
|
|
5
|
+
|
|
6
|
+
const ContextMenu = ({ visible, x, y, onClose, onCopyPaste, onDelete, arrangeActions, arrangeStates })=>{
|
|
7
|
+
const menuRef = useRef(null);
|
|
8
|
+
const [showArrangeSubmenu, setShowArrangeSubmenu] = useState(false);
|
|
9
|
+
// Handle clicking outside to close menu
|
|
10
|
+
useEffect(()=>{
|
|
11
|
+
if (!visible) return;
|
|
12
|
+
const handleClickOutside = (event)=>{
|
|
13
|
+
const target = event.target;
|
|
14
|
+
const menuElement = menuRef.current;
|
|
15
|
+
if (menuElement) {
|
|
16
|
+
const isInsideMenu = menuElement.contains(target);
|
|
17
|
+
if (!isInsideMenu) {
|
|
18
|
+
onClose();
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
onClose();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const handleKeyDown = (event)=>{
|
|
25
|
+
if (event.key === 'Escape') {
|
|
26
|
+
onClose();
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
// Add small delay to prevent immediate closing when the menu appears
|
|
30
|
+
const timeoutId = setTimeout(()=>{
|
|
31
|
+
document.addEventListener('mousedown', handleClickOutside, true);
|
|
32
|
+
document.addEventListener('click', handleClickOutside, true);
|
|
33
|
+
document.addEventListener('keydown', handleKeyDown, true);
|
|
34
|
+
}, 50);
|
|
35
|
+
return ()=>{
|
|
36
|
+
clearTimeout(timeoutId);
|
|
37
|
+
document.removeEventListener('mousedown', handleClickOutside, true);
|
|
38
|
+
document.removeEventListener('click', handleClickOutside, true);
|
|
39
|
+
document.removeEventListener('keydown', handleKeyDown, true);
|
|
40
|
+
};
|
|
41
|
+
}, [
|
|
42
|
+
visible,
|
|
43
|
+
onClose
|
|
44
|
+
]);
|
|
45
|
+
if (!visible) return null;
|
|
46
|
+
// Adjust position to ensure menu stays within viewport
|
|
47
|
+
const adjustedX = Math.min(x, window.innerWidth - 150); // 150 is approximate menu width
|
|
48
|
+
const adjustedY = Math.min(y, window.innerHeight - 120); // 120 is approximate menu height
|
|
49
|
+
const contextMenuElement = /*#__PURE__*/ jsxs("div", {
|
|
50
|
+
ref: menuRef,
|
|
51
|
+
className: styles.contextMenu,
|
|
52
|
+
style: {
|
|
53
|
+
position: 'fixed',
|
|
54
|
+
left: Math.max(0, adjustedX),
|
|
55
|
+
top: Math.max(0, adjustedY),
|
|
56
|
+
zIndex: 10000
|
|
57
|
+
},
|
|
58
|
+
children: [
|
|
59
|
+
/*#__PURE__*/ jsx("div", {
|
|
60
|
+
className: styles.menuItem,
|
|
61
|
+
onClick: onCopyPaste,
|
|
62
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
63
|
+
className: styles.menuItemContent,
|
|
64
|
+
children: [
|
|
65
|
+
/*#__PURE__*/ jsx("span", {
|
|
66
|
+
className: styles.menuItemText,
|
|
67
|
+
children: "複製並貼上"
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ jsx("span", {
|
|
70
|
+
className: styles.menuItemShortcut,
|
|
71
|
+
children: "⌘D"
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
})
|
|
75
|
+
}),
|
|
76
|
+
/*#__PURE__*/ jsx("div", {
|
|
77
|
+
className: styles.menuItem,
|
|
78
|
+
onClick: onDelete,
|
|
79
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
80
|
+
className: styles.menuItemContent,
|
|
81
|
+
children: [
|
|
82
|
+
/*#__PURE__*/ jsx("span", {
|
|
83
|
+
className: styles.menuItemText,
|
|
84
|
+
children: "刪除"
|
|
85
|
+
}),
|
|
86
|
+
/*#__PURE__*/ jsx("span", {
|
|
87
|
+
className: styles.menuItemShortcut,
|
|
88
|
+
children: "Del"
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
})
|
|
92
|
+
}),
|
|
93
|
+
/*#__PURE__*/ jsxs("div", {
|
|
94
|
+
className: `${styles.menuItem} ${styles.hasSubmenu}`,
|
|
95
|
+
onMouseEnter: ()=>setShowArrangeSubmenu(true),
|
|
96
|
+
onMouseLeave: ()=>setShowArrangeSubmenu(false),
|
|
97
|
+
children: [
|
|
98
|
+
"排列順序",
|
|
99
|
+
/*#__PURE__*/ jsx("span", {
|
|
100
|
+
className: styles.arrow,
|
|
101
|
+
children: "▶"
|
|
102
|
+
}),
|
|
103
|
+
showArrangeSubmenu && /*#__PURE__*/ jsxs("div", {
|
|
104
|
+
className: styles.submenu,
|
|
105
|
+
style: {
|
|
106
|
+
position: 'absolute',
|
|
107
|
+
left: '100%',
|
|
108
|
+
top: 0,
|
|
109
|
+
zIndex: 10001
|
|
110
|
+
},
|
|
111
|
+
onMouseEnter: ()=>setShowArrangeSubmenu(true),
|
|
112
|
+
onMouseLeave: ()=>setShowArrangeSubmenu(false),
|
|
113
|
+
children: [
|
|
114
|
+
/*#__PURE__*/ jsx("div", {
|
|
115
|
+
className: `${styles.menuItem} ${!arrangeStates.canBringToFront ? styles.disabled : ''}`,
|
|
116
|
+
onClick: (e)=>{
|
|
117
|
+
e.stopPropagation();
|
|
118
|
+
if (arrangeStates.canBringToFront) {
|
|
119
|
+
arrangeActions.onBringToFront();
|
|
120
|
+
onClose();
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
children: "移至最前"
|
|
124
|
+
}),
|
|
125
|
+
/*#__PURE__*/ jsx("div", {
|
|
126
|
+
className: `${styles.menuItem} ${!arrangeStates.canBringForward ? styles.disabled : ''}`,
|
|
127
|
+
onClick: (e)=>{
|
|
128
|
+
e.stopPropagation();
|
|
129
|
+
if (arrangeStates.canBringForward) {
|
|
130
|
+
arrangeActions.onBringForward();
|
|
131
|
+
onClose();
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
children: "置前"
|
|
135
|
+
}),
|
|
136
|
+
/*#__PURE__*/ jsx("div", {
|
|
137
|
+
className: `${styles.menuItem} ${!arrangeStates.canSendBackward ? styles.disabled : ''}`,
|
|
138
|
+
onClick: (e)=>{
|
|
139
|
+
e.stopPropagation();
|
|
140
|
+
if (arrangeStates.canSendBackward) {
|
|
141
|
+
arrangeActions.onSendBackward();
|
|
142
|
+
onClose();
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
children: "置後"
|
|
146
|
+
}),
|
|
147
|
+
/*#__PURE__*/ jsx("div", {
|
|
148
|
+
className: `${styles.menuItem} ${!arrangeStates.canSendToBack ? styles.disabled : ''}`,
|
|
149
|
+
onClick: (e)=>{
|
|
150
|
+
e.stopPropagation();
|
|
151
|
+
if (arrangeStates.canSendToBack) {
|
|
152
|
+
arrangeActions.onSendToBack();
|
|
153
|
+
onClose();
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
children: "移至最後"
|
|
157
|
+
})
|
|
158
|
+
]
|
|
159
|
+
})
|
|
160
|
+
]
|
|
161
|
+
})
|
|
162
|
+
]
|
|
163
|
+
});
|
|
164
|
+
// Render to document body to avoid z-index issues
|
|
165
|
+
return /*#__PURE__*/ createPortal(contextMenuElement, document.body);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export { ContextMenu as default };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var styles = {"contextMenu":"context-menu-module_contextMenu__sLD6R","menuItem":"context-menu-module_menuItem__f0SPx","disabled":"context-menu-module_disabled__08MXH","menuItemContent":"context-menu-module_menuItemContent__GXixI","menuItemText":"context-menu-module_menuItemText__GLxb4","menuItemShortcut":"context-menu-module_menuItemShortcut__z-DrG","hasSubmenu":"context-menu-module_hasSubmenu__JYdzl","arrow":"context-menu-module_arrow__nLoR1","submenu":"context-menu-module_submenu__pV8AQ"};
|
|
2
|
+
|
|
3
|
+
export { styles as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { DrawingMode, EditMode } from '../../typings';
|
|
3
|
+
interface ToolbarProps {
|
|
4
|
+
onUpload: (files: File[]) => Promise<void>;
|
|
5
|
+
onDeleteAll: () => void;
|
|
6
|
+
onSave: () => void;
|
|
7
|
+
editMode: EditMode;
|
|
8
|
+
drawingMode: DrawingMode;
|
|
9
|
+
onEditModeChange: (mode: EditMode) => void;
|
|
10
|
+
onToggleRectangleTool: () => void;
|
|
11
|
+
onTogglePenTool: () => void;
|
|
12
|
+
onUndo?: () => void;
|
|
13
|
+
onRedo?: () => void;
|
|
14
|
+
canUndo?: boolean;
|
|
15
|
+
canRedo?: boolean;
|
|
16
|
+
onColorChange?: (color: string) => void;
|
|
17
|
+
selectedColor?: string;
|
|
18
|
+
colorPalette?: string[];
|
|
19
|
+
isUploading?: boolean;
|
|
20
|
+
maxFileSizeKB?: number;
|
|
21
|
+
}
|
|
22
|
+
declare const Toolbar: FC<ToolbarProps>;
|
|
23
|
+
export default Toolbar;
|