|
@@ -4092,116 +4092,112 @@ class App extends React.Component<AppProps, AppState> {
|
4092
|
4092
|
actionToggleStats,
|
4093
|
4093
|
];
|
4094
|
4094
|
|
4095
|
|
- ContextMenu.push({
|
4096
|
|
- options: viewModeOptions,
|
4097
|
|
- top,
|
4098
|
|
- left,
|
4099
|
|
- actionManager: this.actionManager,
|
4100
|
|
- appState: this.state,
|
4101
|
|
- container: this.excalidrawContainerRef.current!,
|
4102
|
|
- });
|
4103
|
|
-
|
4104
|
4095
|
if (this.state.viewModeEnabled) {
|
4105
|
|
- return;
|
|
4096
|
+ ContextMenu.push({
|
|
4097
|
+ options: viewModeOptions,
|
|
4098
|
+ top,
|
|
4099
|
+ left,
|
|
4100
|
+ actionManager: this.actionManager,
|
|
4101
|
+ appState: this.state,
|
|
4102
|
+ container: this.excalidrawContainerRef.current!,
|
|
4103
|
+ });
|
|
4104
|
+ } else {
|
|
4105
|
+ ContextMenu.push({
|
|
4106
|
+ options: [
|
|
4107
|
+ this.isMobile &&
|
|
4108
|
+ navigator.clipboard && {
|
|
4109
|
+ name: "paste",
|
|
4110
|
+ perform: (elements, appStates) => {
|
|
4111
|
+ this.pasteFromClipboard(null);
|
|
4112
|
+ return {
|
|
4113
|
+ commitToHistory: false,
|
|
4114
|
+ };
|
|
4115
|
+ },
|
|
4116
|
+ contextItemLabel: "labels.paste",
|
|
4117
|
+ },
|
|
4118
|
+ this.isMobile && navigator.clipboard && separator,
|
|
4119
|
+ probablySupportsClipboardBlob &&
|
|
4120
|
+ elements.length > 0 &&
|
|
4121
|
+ actionCopyAsPng,
|
|
4122
|
+ probablySupportsClipboardWriteText &&
|
|
4123
|
+ elements.length > 0 &&
|
|
4124
|
+ actionCopyAsSvg,
|
|
4125
|
+ ((probablySupportsClipboardBlob && elements.length > 0) ||
|
|
4126
|
+ (probablySupportsClipboardWriteText && elements.length > 0)) &&
|
|
4127
|
+ separator,
|
|
4128
|
+ actionSelectAll,
|
|
4129
|
+ separator,
|
|
4130
|
+ typeof this.props.gridModeEnabled === "undefined" &&
|
|
4131
|
+ actionToggleGridMode,
|
|
4132
|
+ typeof this.props.zenModeEnabled === "undefined" &&
|
|
4133
|
+ actionToggleZenMode,
|
|
4134
|
+ typeof this.props.viewModeEnabled === "undefined" &&
|
|
4135
|
+ actionToggleViewMode,
|
|
4136
|
+ actionToggleStats,
|
|
4137
|
+ ],
|
|
4138
|
+ top,
|
|
4139
|
+ left,
|
|
4140
|
+ actionManager: this.actionManager,
|
|
4141
|
+ appState: this.state,
|
|
4142
|
+ container: this.excalidrawContainerRef.current!,
|
|
4143
|
+ });
|
4106
|
4144
|
}
|
4107
|
|
-
|
4108
|
|
- ContextMenu.push({
|
4109
|
|
- options: [
|
4110
|
|
- this.isMobile &&
|
4111
|
|
- navigator.clipboard && {
|
4112
|
|
- name: "paste",
|
4113
|
|
- perform: (elements, appStates) => {
|
4114
|
|
- this.pasteFromClipboard(null);
|
4115
|
|
- return {
|
4116
|
|
- commitToHistory: false,
|
4117
|
|
- };
|
|
4145
|
+ } else if (type === "element") {
|
|
4146
|
+ if (this.state.viewModeEnabled) {
|
|
4147
|
+ ContextMenu.push({
|
|
4148
|
+ options: [navigator.clipboard && actionCopy, ...options],
|
|
4149
|
+ top,
|
|
4150
|
+ left,
|
|
4151
|
+ actionManager: this.actionManager,
|
|
4152
|
+ appState: this.state,
|
|
4153
|
+ container: this.excalidrawContainerRef.current!,
|
|
4154
|
+ });
|
|
4155
|
+ } else {
|
|
4156
|
+ ContextMenu.push({
|
|
4157
|
+ options: [
|
|
4158
|
+ this.isMobile && actionCut,
|
|
4159
|
+ this.isMobile && navigator.clipboard && actionCopy,
|
|
4160
|
+ this.isMobile &&
|
|
4161
|
+ navigator.clipboard && {
|
|
4162
|
+ name: "paste",
|
|
4163
|
+ perform: (elements, appStates) => {
|
|
4164
|
+ this.pasteFromClipboard(null);
|
|
4165
|
+ return {
|
|
4166
|
+ commitToHistory: false,
|
|
4167
|
+ };
|
|
4168
|
+ },
|
|
4169
|
+ contextItemLabel: "labels.paste",
|
4118
|
4170
|
},
|
4119
|
|
- contextItemLabel: "labels.paste",
|
4120
|
|
- },
|
4121
|
|
- this.isMobile && navigator.clipboard && separator,
|
4122
|
|
- probablySupportsClipboardBlob &&
|
4123
|
|
- elements.length > 0 &&
|
4124
|
|
- actionCopyAsPng,
|
4125
|
|
- probablySupportsClipboardWriteText &&
|
4126
|
|
- elements.length > 0 &&
|
4127
|
|
- actionCopyAsSvg,
|
4128
|
|
- ((probablySupportsClipboardBlob && elements.length > 0) ||
|
4129
|
|
- (probablySupportsClipboardWriteText && elements.length > 0)) &&
|
|
4171
|
+ this.isMobile && separator,
|
|
4172
|
+ ...options,
|
4130
|
4173
|
separator,
|
4131
|
|
- actionSelectAll,
|
4132
|
|
- separator,
|
4133
|
|
- typeof this.props.gridModeEnabled === "undefined" &&
|
4134
|
|
- actionToggleGridMode,
|
4135
|
|
- typeof this.props.zenModeEnabled === "undefined" &&
|
4136
|
|
- actionToggleZenMode,
|
4137
|
|
- typeof this.props.viewModeEnabled === "undefined" &&
|
4138
|
|
- actionToggleViewMode,
|
4139
|
|
- actionToggleStats,
|
4140
|
|
- ],
|
4141
|
|
- top,
|
4142
|
|
- left,
|
4143
|
|
- actionManager: this.actionManager,
|
4144
|
|
- appState: this.state,
|
4145
|
|
- container: this.excalidrawContainerRef.current!,
|
4146
|
|
- });
|
4147
|
|
- return;
|
4148
|
|
- }
|
4149
|
|
-
|
4150
|
|
- if (this.state.viewModeEnabled) {
|
4151
|
|
- ContextMenu.push({
|
4152
|
|
- options: [navigator.clipboard && actionCopy, ...options],
|
4153
|
|
- top,
|
4154
|
|
- left,
|
4155
|
|
- actionManager: this.actionManager,
|
4156
|
|
- appState: this.state,
|
4157
|
|
- container: this.excalidrawContainerRef.current!,
|
4158
|
|
- });
|
4159
|
|
- return;
|
|
4174
|
+ actionCopyStyles,
|
|
4175
|
+ actionPasteStyles,
|
|
4176
|
+ separator,
|
|
4177
|
+ maybeGroupAction && actionGroup,
|
|
4178
|
+ maybeUngroupAction && actionUngroup,
|
|
4179
|
+ (maybeGroupAction || maybeUngroupAction) && separator,
|
|
4180
|
+ actionAddToLibrary,
|
|
4181
|
+ separator,
|
|
4182
|
+ actionSendBackward,
|
|
4183
|
+ actionBringForward,
|
|
4184
|
+ actionSendToBack,
|
|
4185
|
+ actionBringToFront,
|
|
4186
|
+ separator,
|
|
4187
|
+ maybeFlipHorizontal && actionFlipHorizontal,
|
|
4188
|
+ maybeFlipVertical && actionFlipVertical,
|
|
4189
|
+ (maybeFlipHorizontal || maybeFlipVertical) && separator,
|
|
4190
|
+ actionDuplicateSelection,
|
|
4191
|
+ actionDeleteSelected,
|
|
4192
|
+ ],
|
|
4193
|
+ top,
|
|
4194
|
+ left,
|
|
4195
|
+ actionManager: this.actionManager,
|
|
4196
|
+ appState: this.state,
|
|
4197
|
+ container: this.excalidrawContainerRef.current!,
|
|
4198
|
+ });
|
|
4199
|
+ }
|
4160
|
4200
|
}
|
4161
|
|
-
|
4162
|
|
- ContextMenu.push({
|
4163
|
|
- options: [
|
4164
|
|
- this.isMobile && actionCut,
|
4165
|
|
- this.isMobile && navigator.clipboard && actionCopy,
|
4166
|
|
- this.isMobile &&
|
4167
|
|
- navigator.clipboard && {
|
4168
|
|
- name: "paste",
|
4169
|
|
- perform: (elements, appStates) => {
|
4170
|
|
- this.pasteFromClipboard(null);
|
4171
|
|
- return {
|
4172
|
|
- commitToHistory: false,
|
4173
|
|
- };
|
4174
|
|
- },
|
4175
|
|
- contextItemLabel: "labels.paste",
|
4176
|
|
- },
|
4177
|
|
- this.isMobile && separator,
|
4178
|
|
- ...options,
|
4179
|
|
- separator,
|
4180
|
|
- actionCopyStyles,
|
4181
|
|
- actionPasteStyles,
|
4182
|
|
- separator,
|
4183
|
|
- maybeGroupAction && actionGroup,
|
4184
|
|
- maybeUngroupAction && actionUngroup,
|
4185
|
|
- (maybeGroupAction || maybeUngroupAction) && separator,
|
4186
|
|
- actionAddToLibrary,
|
4187
|
|
- separator,
|
4188
|
|
- actionSendBackward,
|
4189
|
|
- actionBringForward,
|
4190
|
|
- actionSendToBack,
|
4191
|
|
- actionBringToFront,
|
4192
|
|
- separator,
|
4193
|
|
- maybeFlipHorizontal && actionFlipHorizontal,
|
4194
|
|
- maybeFlipVertical && actionFlipVertical,
|
4195
|
|
- (maybeFlipHorizontal || maybeFlipVertical) && separator,
|
4196
|
|
- actionDuplicateSelection,
|
4197
|
|
- actionDeleteSelected,
|
4198
|
|
- ],
|
4199
|
|
- top,
|
4200
|
|
- left,
|
4201
|
|
- actionManager: this.actionManager,
|
4202
|
|
- appState: this.state,
|
4203
|
|
- container: this.excalidrawContainerRef.current!,
|
4204
|
|
- });
|
4205
|
4201
|
};
|
4206
|
4202
|
|
4207
|
4203
|
private handleWheel = withBatchedUpdates((event: WheelEvent) => {
|