Preet 1 年之前
父节点
当前提交
0360e64219
共有 2 个文件被更改,包括 19 次插入7 次删除
  1. 18 5
      src/components/App.tsx
  2. 1 2
      src/element/linearElementEditor.ts

+ 18 - 5
src/components/App.tsx

@@ -3750,9 +3750,27 @@ class App extends React.Component<AppProps, AppState> {
       return;
     }
 
+    let { x: sceneX, y: sceneY } = viewportCoordsToSceneCoords(
+      event,
+      this.state,
+    );
+
     const selectedElements = this.scene.getSelectedElements(this.state);
 
     if (selectedElements.length === 1 && isLinearElement(selectedElements[0])) {
+      const pointUnderCursorIndex = LinearElementEditor.getPointIndexUnderCursor(
+        selectedElements[0],
+        this.state.zoom,
+        sceneX,
+        sceneY,
+      );
+      if (pointUnderCursorIndex >= 0) {
+        LinearElementEditor.toggleSegmentSplitAtIndex(
+          selectedElements[0],
+          pointUnderCursorIndex,
+        );
+        return;
+      }
       if (
         event[KEYS.CTRL_OR_CMD] &&
         (!this.state.editingLinearElement ||
@@ -3776,11 +3794,6 @@ class App extends React.Component<AppProps, AppState> {
 
     resetCursor(this.interactiveCanvas);
 
-    let { x: sceneX, y: sceneY } = viewportCoordsToSceneCoords(
-      event,
-      this.state,
-    );
-
     const selectedGroupIds = getSelectedGroupIds(this.state);
 
     if (selectedGroupIds.length > 0) {

+ 1 - 2
src/element/linearElementEditor.ts

@@ -1475,7 +1475,6 @@ export class LinearElementEditor {
 
   static toggleSegmentSplitAtIndex(
     element: NonDeleted<ExcalidrawLinearElement>,
-    appState: AppState,
     index: number,
   ) {
     let found = false;
@@ -1491,7 +1490,7 @@ export class LinearElementEditor {
     }
 
     mutateElement(element, {
-      segmentSplitIndices: splitIndices,
+      segmentSplitIndices: splitIndices.sort(),
     });
   }
 }