tldraw 4.3.0-next.82cfddd7ee89 → 4.3.0-next.943ca6e3346e
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/dist-cjs/index.d.ts +14 -5
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/elbowArrowSnapLines.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/shared.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +2 -2
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +1 -1
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/crop.js +1 -0
- package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditableRichText.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +1 -4
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/ui/components/EditLinkDialog.js +11 -1
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +1 -2
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useFlatten.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +8 -0
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
- package/dist-cjs/lib/utils/frames/frames.js.map +2 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +14 -5
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/elbowArrowSnapLines.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/shared.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +2 -2
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +1 -1
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/crop.mjs +1 -0
- package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditableRichText.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +1 -4
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +1 -4
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +1 -4
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs +11 -1
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
- package/dist-esm/lib/ui/components/menu-items.mjs +1 -4
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +1 -2
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs +1 -4
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useFlatten.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +8 -0
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/export/exportAs.mjs +1 -3
- package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
- package/dist-esm/lib/utils/frames/frames.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +10 -10
- package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +4 -9
- package/src/lib/defaultExternalContentHandlers.ts +3 -4
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +2 -2
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +1 -1
- package/src/lib/shapes/arrow/arrowLabel.ts +1 -1
- package/src/lib/shapes/arrow/arrowTargetState.ts +1 -1
- package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +3 -3
- package/src/lib/shapes/arrow/shared.ts +4 -4
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +1 -1
- package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
- package/src/lib/shapes/draw/toolStates/Drawing.ts +4 -4
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
- package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
- package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +10 -2
- package/src/lib/shapes/geo/toolStates/Pointing.ts +3 -3
- package/src/lib/shapes/line/LineShapeTool.test.ts +6 -6
- package/src/lib/shapes/line/LineShapeUtil.test.tsx +5 -5
- package/src/lib/shapes/line/toolStates/Pointing.ts +1 -1
- package/src/lib/shapes/note/NoteShapeTool.test.ts +2 -1
- package/src/lib/shapes/note/noteHelpers.ts +2 -2
- package/src/lib/shapes/shared/PlainTextLabel.tsx +2 -1
- package/src/lib/shapes/shared/RichTextLabel.tsx +2 -1
- package/src/lib/shapes/shared/crop.ts +1 -0
- package/src/lib/shapes/shared/useEditablePlainText.ts +7 -3
- package/src/lib/shapes/shared/useEditableRichText.ts +7 -3
- package/src/lib/shapes/text/TextShapeTool.test.ts +4 -4
- package/src/lib/shapes/text/toolStates/Pointing.ts +1 -1
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +3 -5
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +3 -16
- package/src/lib/tools/SelectTool/DragAndDropManager.ts +2 -4
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +2 -6
- package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +2 -3
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +4 -7
- package/src/lib/tools/SelectTool/childStates/EditingShape.ts +2 -4
- package/src/lib/tools/SelectTool/childStates/Idle.ts +6 -10
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +4 -12
- package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +2 -2
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +2 -4
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +2 -4
- package/src/lib/tools/SelectTool/childStates/Translating.ts +1 -3
- package/src/lib/ui/components/EditLinkDialog.tsx +16 -6
- package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
- package/src/lib/ui/components/menu-items.tsx +6 -14
- package/src/lib/ui/context/actions.tsx +9 -13
- package/src/lib/ui/hooks/menu-hooks.ts +9 -19
- package/src/lib/ui/hooks/useFlatten.ts +1 -2
- package/src/lib/ui/hooks/useTools.tsx +1 -2
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +8 -0
- package/src/lib/utils/export/exportAs.ts +2 -9
- package/src/lib/utils/frames/frames.ts +1 -1
- package/src/lib/utils/tldr/buildFromV1Document.ts +12 -17
- package/src/test/Editor.test.tsx +38 -12
- package/src/test/SelectTool.test.ts +11 -19
- package/src/test/TestEditor.ts +1 -4
- package/src/test/TldrawEditor.test.tsx +21 -18
- package/src/test/bindings.test.tsx +29 -25
- package/src/test/bindingsIndex.test.tsx +4 -4
- package/src/test/commands/createShape.test.ts +64 -0
- package/src/test/commands/createShapes.test.ts +15 -1
- package/src/test/commands/getSvgString.test.ts +2 -2
- package/src/test/commands/isShapeOfType.test.ts +44 -0
- package/src/test/commands/putContent.test.ts +1 -0
- package/src/test/commands/updateShape.test.ts +67 -0
- package/src/test/commands/updateShapes.test.ts +21 -5
- package/src/test/custom-clipping.test.ts +36 -35
- package/src/test/customSnapping.test.tsx +77 -62
- package/src/test/duplicate.test.ts +1 -1
- package/src/test/frames.test.ts +2 -2
- package/src/test/getCulledShapes.test.tsx +11 -3
- package/src/test/getShapeAtPoint.test.ts +2 -2
- package/src/test/groups.test.tsx +6 -3
- package/src/test/resizing.test.ts +9 -13
- package/src/test/selection-omnibus.test.ts +11 -11
- package/src/test/shapeutils.test.ts +1 -1
- package/src/test/styles2.test.tsx +1 -1
- package/src/test/styles3.test.ts +5 -5
- package/src/test/test-jsx.tsx +69 -57
- package/src/test/text.test.ts +15 -17
- package/src/test/translating.test.ts +6 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/shapes/arrow/ArrowShapeUtil.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n\tArc2d,\n\tBox,\n\tEMPTY_ARRAY,\n\tEdge2d,\n\tEditor,\n\tGeometry2d,\n\tGroup2d,\n\tIndexKey,\n\tPI2,\n\tPolyline2d,\n\tRectangle2d,\n\tSVGContainer,\n\tShapeUtil,\n\tSvgExportContext,\n\tTLArrowBinding,\n\tTLArrowBindingProps,\n\tTLArrowShape,\n\tTLArrowShapeProps,\n\tTLHandle,\n\tTLHandleDragInfo,\n\tTLResizeInfo,\n\tTLShapePartial,\n\tTLShapeUtilCanBeLaidOutOpts,\n\tTLShapeUtilCanBindOpts,\n\tTLShapeUtilCanvasSvgDef,\n\tVec,\n\tWeakCache,\n\tarrowShapeMigrations,\n\tarrowShapeProps,\n\tclamp,\n\tdebugFlags,\n\texhaustiveSwitchError,\n\tgetColorValue,\n\tgetDefaultColorTheme,\n\tgetFontsFromRichText,\n\tinvLerp,\n\tlerp,\n\tmapObjectMapValues,\n\tmaybeSnapToGrid,\n\tstructuredClone,\n\ttoDomPrecision,\n\ttoRichText,\n\ttrack,\n\tuseEditor,\n\tuseIsEditing,\n\tuseSharedSafeId,\n\tuseValue,\n} from '@tldraw/editor'\nimport React, { useMemo } from 'react'\nimport { updateArrowTerminal } from '../../bindings/arrow/ArrowBindingUtil'\nimport { isEmptyRichText, renderPlaintextFromRichText } from '../../utils/text/richText'\nimport { PathBuilder } from '../shared/PathBuilder'\nimport { RichTextLabel, RichTextSVG } from '../shared/RichTextLabel'\nimport { ShapeFill } from '../shared/ShapeFill'\nimport { ARROW_LABEL_PADDING, STROKE_SIZES, TEXT_PROPS } from '../shared/default-shape-constants'\nimport { getFillDefForCanvas, getFillDefForExport } from '../shared/defaultStyleDefs'\nimport { useDefaultColorTheme } from '../shared/useDefaultColorTheme'\nimport { getArrowBodyPath, getArrowHandlePath } from './ArrowPath'\nimport { ArrowShapeOptions } from './arrow-types'\nimport {\n\tgetArrowLabelDefaultPosition,\n\tgetArrowLabelFontSize,\n\tgetArrowLabelPosition,\n} from './arrowLabel'\nimport { updateArrowTargetState } from './arrowTargetState'\nimport { getArrowheadPathForType } from './arrowheads'\nimport { ElbowArrowDebug } from './elbow/ElbowArrowDebug'\nimport { ElbowArrowAxes } from './elbow/definitions'\nimport { getElbowArrowSnapLines, perpDistanceToLineAngle } from './elbow/elbowArrowSnapLines'\nimport {\n\tTLArrowBindings,\n\tcreateOrUpdateArrowBinding,\n\tgetArrowBindings,\n\tgetArrowInfo,\n\tgetArrowTerminalsInArrowSpace,\n\tremoveArrowBinding,\n} from './shared'\n\nenum ArrowHandles {\n\tStart = 'start',\n\tMiddle = 'middle',\n\tEnd = 'end',\n}\n\n/** @public */\nexport class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {\n\tstatic override type = 'arrow' as const\n\tstatic override props = arrowShapeProps\n\tstatic override migrations = arrowShapeMigrations\n\n\toverride options: ArrowShapeOptions = {\n\t\texpandElbowLegLength: {\n\t\t\ts: 28,\n\t\t\tm: 36,\n\t\t\tl: 44,\n\t\t\txl: 66,\n\t\t},\n\t\tminElbowLegLength: {\n\t\t\ts: STROKE_SIZES.s * 3,\n\t\t\tm: STROKE_SIZES.m * 3,\n\t\t\tl: STROKE_SIZES.l * 3,\n\t\t\txl: STROKE_SIZES.xl * 3,\n\t\t},\n\t\tminElbowHandleDistance: 16,\n\n\t\tarcArrowCenterSnapDistance: 16,\n\t\telbowArrowCenterSnapDistance: 24,\n\t\telbowArrowEdgeSnapDistance: 20,\n\t\telbowArrowPointSnapDistance: 24,\n\t\telbowArrowAxisSnapDistance: 16,\n\n\t\tlabelCenterSnapDistance: 10,\n\n\t\telbowMidpointSnapDistance: 10,\n\t\telbowMinSegmentLengthToShowMidpointHandle: 20,\n\n\t\thoverPreciseTimeout: 600,\n\t\tpointingPreciseTimeout: 320,\n\n\t\tshouldBeExact: (editor: Editor) => editor.inputs.altKey,\n\t\tshouldIgnoreTargets: (editor: Editor) => editor.inputs.ctrlKey,\n\t}\n\n\toverride canEdit() {\n\t\treturn true\n\t}\n\toverride canBind({ toShapeType }: TLShapeUtilCanBindOpts<TLArrowShape>): boolean {\n\t\t// bindings can go from arrows to shapes, but not from shapes to arrows\n\t\treturn toShapeType !== 'arrow'\n\t}\n\toverride canSnap() {\n\t\treturn false\n\t}\n\toverride hideResizeHandles() {\n\t\treturn true\n\t}\n\toverride hideRotateHandle() {\n\t\treturn true\n\t}\n\toverride hideSelectionBoundsBg() {\n\t\treturn true\n\t}\n\toverride hideSelectionBoundsFg() {\n\t\treturn true\n\t}\n\toverride hideInMinimap() {\n\t\treturn true\n\t}\n\n\toverride canBeLaidOut(shape: TLArrowShape, info: TLShapeUtilCanBeLaidOutOpts) {\n\t\tif (info.type === 'flip') {\n\t\t\t// If we don't have this then the flip will be non-idempotent; that is, the flip will be multipotent, varipotent, or perhaps even omni-potent... and we can't have that\n\t\t\tconst bindings = getArrowBindings(this.editor, shape)\n\t\t\tconst { start, end } = bindings\n\t\t\tconst { shapes = [] } = info\n\t\t\tif (start && !shapes.find((s) => s.id === start.toId)) return false\n\t\t\tif (end && !shapes.find((s) => s.id === end.toId)) return false\n\t\t}\n\t\treturn true\n\t}\n\n\toverride getFontFaces(shape: TLArrowShape) {\n\t\tif (isEmptyRichText(shape.props.richText)) return EMPTY_ARRAY\n\n\t\treturn getFontsFromRichText(this.editor, shape.props.richText, {\n\t\t\tfamily: `tldraw_${shape.props.font}`,\n\t\t\tweight: 'normal',\n\t\t\tstyle: 'normal',\n\t\t})\n\t}\n\n\toverride getDefaultProps(): TLArrowShape['props'] {\n\t\treturn {\n\t\t\tkind: 'arc',\n\t\t\telbowMidPoint: 0.5,\n\t\t\tdash: 'draw',\n\t\t\tsize: 'm',\n\t\t\tfill: 'none',\n\t\t\tcolor: 'black',\n\t\t\tlabelColor: 'black',\n\t\t\tbend: 0,\n\t\t\tstart: { x: 0, y: 0 },\n\t\t\tend: { x: 2, y: 0 },\n\t\t\tarrowheadStart: 'none',\n\t\t\tarrowheadEnd: 'arrow',\n\t\t\trichText: toRichText(''),\n\t\t\tlabelPosition: 0.5,\n\t\t\tfont: 'draw',\n\t\t\tscale: 1,\n\t\t}\n\t}\n\n\tgetGeometry(shape: TLArrowShape) {\n\t\tconst isEditing = this.editor.getEditingShapeId() === shape.id\n\t\tconst info = getArrowInfo(this.editor, shape)!\n\n\t\tconst debugGeom: Geometry2d[] = []\n\n\t\tconst bodyGeom =\n\t\t\tinfo.type === 'straight'\n\t\t\t\t? new Edge2d({\n\t\t\t\t\t\tstart: Vec.From(info.start.point),\n\t\t\t\t\t\tend: Vec.From(info.end.point),\n\t\t\t\t\t})\n\t\t\t\t: info.type === 'arc'\n\t\t\t\t\t? new Arc2d({\n\t\t\t\t\t\t\tcenter: Vec.Cast(info.handleArc.center),\n\t\t\t\t\t\t\tstart: Vec.Cast(info.start.point),\n\t\t\t\t\t\t\tend: Vec.Cast(info.end.point),\n\t\t\t\t\t\t\tsweepFlag: info.bodyArc.sweepFlag,\n\t\t\t\t\t\t\tlargeArcFlag: info.bodyArc.largeArcFlag,\n\t\t\t\t\t\t})\n\t\t\t\t\t: new Polyline2d({ points: info.route.points })\n\n\t\tlet labelGeom\n\t\tif (isEditing || !isEmptyRichText(shape.props.richText)) {\n\t\t\tconst labelPosition = getArrowLabelPosition(this.editor, shape)\n\t\t\tif (debugFlags.debugGeometry.get()) {\n\t\t\t\tdebugGeom.push(...labelPosition.debugGeom)\n\t\t\t}\n\t\t\tlabelGeom = new Rectangle2d({\n\t\t\t\tx: labelPosition.box.x,\n\t\t\t\ty: labelPosition.box.y,\n\t\t\t\twidth: labelPosition.box.w,\n\t\t\t\theight: labelPosition.box.h,\n\t\t\t\tisFilled: true,\n\t\t\t\tisLabel: true,\n\t\t\t})\n\t\t}\n\n\t\treturn new Group2d({\n\t\t\tchildren: [...(labelGeom ? [bodyGeom, labelGeom] : [bodyGeom]), ...debugGeom],\n\t\t})\n\t}\n\n\toverride getHandles(shape: TLArrowShape): TLHandle[] {\n\t\tconst info = getArrowInfo(this.editor, shape)!\n\n\t\tconst handles: TLHandle[] = [\n\t\t\t{\n\t\t\t\tid: ArrowHandles.Start,\n\t\t\t\ttype: 'vertex',\n\t\t\t\tindex: 'a1' as IndexKey,\n\t\t\t\tx: info.start.handle.x,\n\t\t\t\ty: info.start.handle.y,\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ArrowHandles.End,\n\t\t\t\ttype: 'vertex',\n\t\t\t\tindex: 'a3' as IndexKey,\n\t\t\t\tx: info.end.handle.x,\n\t\t\t\ty: info.end.handle.y,\n\t\t\t},\n\t\t]\n\n\t\tif (shape.props.kind === 'arc' && (info.type === 'straight' || info.type === 'arc')) {\n\t\t\thandles.push({\n\t\t\t\tid: ArrowHandles.Middle,\n\t\t\t\ttype: 'virtual',\n\t\t\t\tindex: 'a2' as IndexKey,\n\t\t\t\tx: info.middle.x,\n\t\t\t\ty: info.middle.y,\n\t\t\t})\n\t\t}\n\n\t\tif (shape.props.kind === 'elbow' && info.type === 'elbow' && info.route.midpointHandle) {\n\t\t\tconst shapePageTransform = this.editor.getShapePageTransform(shape.id)!\n\n\t\t\tconst segmentStart = shapePageTransform.applyToPoint(info.route.midpointHandle.segmentStart)\n\t\t\tconst segmentEnd = shapePageTransform.applyToPoint(info.route.midpointHandle.segmentEnd)\n\t\t\tconst segmentLength = Vec.Dist(segmentStart, segmentEnd) * this.editor.getZoomLevel()\n\n\t\t\tif (segmentLength > this.options.elbowMinSegmentLengthToShowMidpointHandle) {\n\t\t\t\thandles.push({\n\t\t\t\t\tid: ArrowHandles.Middle,\n\t\t\t\t\ttype: 'vertex',\n\t\t\t\t\tindex: 'a2' as IndexKey,\n\t\t\t\t\tx: info.route.midpointHandle.point.x,\n\t\t\t\t\ty: info.route.midpointHandle.point.y,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn handles\n\t}\n\n\toverride getText(shape: TLArrowShape) {\n\t\treturn renderPlaintextFromRichText(this.editor, shape.props.richText)\n\t}\n\n\toverride onHandleDrag(shape: TLArrowShape, info: TLHandleDragInfo<TLArrowShape>) {\n\t\tconst handleId = info.handle.id as ArrowHandles\n\t\tswitch (handleId) {\n\t\t\tcase ArrowHandles.Middle:\n\t\t\t\tswitch (shape.props.kind) {\n\t\t\t\t\tcase 'arc':\n\t\t\t\t\t\treturn this.onArcMidpointHandleDrag(shape, info)\n\t\t\t\t\tcase 'elbow':\n\t\t\t\t\t\treturn this.onElbowMidpointHandleDrag(shape, info)\n\t\t\t\t\tdefault:\n\t\t\t\t\t\texhaustiveSwitchError(shape.props.kind)\n\t\t\t\t}\n\t\t\tcase ArrowHandles.Start:\n\t\t\tcase ArrowHandles.End:\n\t\t\t\treturn this.onTerminalHandleDrag(shape, info, handleId)\n\t\t\tdefault:\n\t\t\t\texhaustiveSwitchError(handleId)\n\t\t}\n\t}\n\n\tprivate onArcMidpointHandleDrag(shape: TLArrowShape, { handle }: TLHandleDragInfo<TLArrowShape>) {\n\t\tconst bindings = getArrowBindings(this.editor, shape)\n\n\t\t// Bending the arrow...\n\t\tconst { start, end } = getArrowTerminalsInArrowSpace(this.editor, shape, bindings)\n\n\t\tconst delta = Vec.Sub(end, start)\n\t\tconst v = Vec.Per(delta)\n\n\t\tconst med = Vec.Med(end, start)\n\t\tconst A = Vec.Sub(med, v)\n\t\tconst B = Vec.Add(med, v)\n\n\t\tconst point = Vec.NearestPointOnLineSegment(A, B, handle, false)\n\t\tlet bend = Vec.Dist(point, med)\n\t\tif (Vec.Clockwise(point, end, med)) bend *= -1\n\t\treturn { id: shape.id, type: shape.type, props: { bend } }\n\t}\n\n\tprivate onElbowMidpointHandleDrag(\n\t\tshape: TLArrowShape,\n\t\t{ handle }: TLHandleDragInfo<TLArrowShape>\n\t) {\n\t\tconst info = getArrowInfo(this.editor, shape)\n\t\tif (info?.type !== 'elbow') return\n\n\t\tconst shapeToPageTransform = this.editor.getShapePageTransform(shape.id)!\n\t\tconst handlePagePoint = shapeToPageTransform.applyToPoint(handle)\n\t\tconst axisName = info.route.midpointHandle?.axis\n\t\tif (!axisName) return\n\t\tconst axis = ElbowArrowAxes[axisName]\n\n\t\tconst midRange = info.elbow[axis.midRange]\n\t\tif (!midRange) return\n\n\t\t// We're snapping against a list of parallel lines. The way we do this is to calculate the\n\t\t// angle of the line we're snapping to...\n\t\tlet angle = Vec.Angle(\n\t\t\tshapeToPageTransform.applyToPoint(axis.v(0, 0)),\n\t\t\tshapeToPageTransform.applyToPoint(axis.v(0, 1))\n\t\t)\n\t\tif (angle < 0) angle += Math.PI\n\n\t\t// ...then calculate the perpendicular distance from the origin to the (infinite) line in\n\t\t// question. This returns a signed distance - lines \"behind\" the origin are negative.\n\t\tconst handlePoint = perpDistanceToLineAngle(handlePagePoint, angle)\n\n\t\t// As we're only ever moving along one dimension, we can use this perpendicular distance for\n\t\t// all of our snapping calculations.\n\t\tconst loPoint = perpDistanceToLineAngle(\n\t\t\tshapeToPageTransform.applyToPoint(axis.v(midRange.lo, 0)),\n\t\t\tangle\n\t\t)\n\t\tconst hiPoint = perpDistanceToLineAngle(\n\t\t\tshapeToPageTransform.applyToPoint(axis.v(midRange.hi, 0)),\n\t\t\tangle\n\t\t)\n\n\t\t// we want to snap to certain points. the maximum distance at which a snap will occur is\n\t\t// relative to the zoom level:\n\t\tconst maxSnapDistance = this.options.elbowMidpointSnapDistance / this.editor.getZoomLevel()\n\n\t\t// we snap to the midpoint of the range by default\n\t\tconst midPoint = perpDistanceToLineAngle(\n\t\t\tshapeToPageTransform.applyToPoint(axis.v(lerp(midRange.lo, midRange.hi, 0.5), 0)),\n\t\t\tangle\n\t\t)\n\n\t\tlet snapPoint = midPoint\n\t\tlet snapDistance = Math.abs(midPoint - handlePoint)\n\n\t\t// then we check all the other arrows that are on-screen.\n\t\tfor (const [snapAngle, snapLines] of getElbowArrowSnapLines(this.editor)) {\n\t\t\tconst { isParallel, isFlippedParallel } = anglesAreApproximatelyParallel(angle, snapAngle)\n\t\t\tif (isParallel || isFlippedParallel) {\n\t\t\t\tfor (const snapLine of snapLines) {\n\t\t\t\t\tconst doesShareStartIntersection =\n\t\t\t\t\t\tsnapLine.startBoundShapeId &&\n\t\t\t\t\t\t(snapLine.startBoundShapeId === info.bindings.start?.toId ||\n\t\t\t\t\t\t\tsnapLine.startBoundShapeId === info.bindings.end?.toId)\n\n\t\t\t\t\tconst doesShareEndIntersection =\n\t\t\t\t\t\tsnapLine.endBoundShapeId &&\n\t\t\t\t\t\t(snapLine.endBoundShapeId === info.bindings.start?.toId ||\n\t\t\t\t\t\t\tsnapLine.endBoundShapeId === info.bindings.end?.toId)\n\n\t\t\t\t\tif (!doesShareStartIntersection && !doesShareEndIntersection) continue\n\n\t\t\t\t\tconst point = isFlippedParallel ? -snapLine.perpDistance : snapLine.perpDistance\n\t\t\t\t\tconst distance = Math.abs(point - handlePoint)\n\t\t\t\t\tif (distance < snapDistance) {\n\t\t\t\t\t\tsnapPoint = point\n\t\t\t\t\t\tsnapDistance = distance\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (snapDistance > maxSnapDistance) {\n\t\t\tsnapPoint = handlePoint\n\t\t}\n\n\t\tconst newMid = clamp(invLerp(loPoint, hiPoint, snapPoint), 0, 1)\n\n\t\treturn {\n\t\t\tid: shape.id,\n\t\t\ttype: shape.type,\n\t\t\tprops: {\n\t\t\t\telbowMidPoint: newMid,\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate onTerminalHandleDrag(\n\t\tshape: TLArrowShape,\n\t\t{ handle, isPrecise }: TLHandleDragInfo<TLArrowShape>,\n\t\thandleId: ArrowHandles.Start | ArrowHandles.End\n\t) {\n\t\tconst bindings = getArrowBindings(this.editor, shape)\n\n\t\tconst update: TLShapePartial<TLArrowShape> = { id: shape.id, type: 'arrow', props: {} }\n\n\t\tconst currentBinding = bindings[handleId]\n\n\t\tconst oppositeHandleId = handleId === ArrowHandles.Start ? ArrowHandles.End : ArrowHandles.Start\n\t\tconst oppositeBinding = bindings[oppositeHandleId]\n\n\t\tconst targetInfo = updateArrowTargetState({\n\t\t\teditor: this.editor,\n\t\t\tpointInPageSpace: this.editor.getShapePageTransform(shape.id)!.applyToPoint(handle),\n\t\t\tarrow: shape,\n\t\t\tisPrecise: isPrecise,\n\t\t\tcurrentBinding,\n\t\t\toppositeBinding,\n\t\t})\n\n\t\tif (!targetInfo) {\n\t\t\t// todo: maybe double check that this isn't equal to the other handle too?\n\t\t\tremoveArrowBinding(this.editor, shape, handleId)\n\t\t\tconst newPoint = maybeSnapToGrid(new Vec(handle.x, handle.y), this.editor)\n\t\t\tupdate.props![handleId] = {\n\t\t\t\tx: newPoint.x,\n\t\t\t\ty: newPoint.y,\n\t\t\t}\n\t\t\treturn update\n\t\t}\n\n\t\t// we've got a target! the handle is being dragged over a shape, bind to it\n\t\tconst bindingProps: TLArrowBindingProps = {\n\t\t\tterminal: handleId,\n\t\t\tnormalizedAnchor: targetInfo.normalizedAnchor,\n\t\t\tisPrecise: targetInfo.isPrecise,\n\t\t\tisExact: targetInfo.isExact,\n\t\t\tsnap: targetInfo.snap,\n\t\t}\n\n\t\tcreateOrUpdateArrowBinding(this.editor, shape, targetInfo.target.id, bindingProps)\n\n\t\tconst newBindings = getArrowBindings(this.editor, shape)\n\t\tif (newBindings.start && newBindings.end && newBindings.start.toId === newBindings.end.toId) {\n\t\t\tif (\n\t\t\t\tVec.Equals(newBindings.start.props.normalizedAnchor, newBindings.end.props.normalizedAnchor)\n\t\t\t) {\n\t\t\t\tcreateOrUpdateArrowBinding(this.editor, shape, newBindings.end.toId, {\n\t\t\t\t\t...newBindings.end.props,\n\t\t\t\t\tnormalizedAnchor: {\n\t\t\t\t\t\tx: newBindings.end.props.normalizedAnchor.x + 0.05,\n\t\t\t\t\t\ty: newBindings.end.props.normalizedAnchor.y,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn update\n\t}\n\n\toverride onTranslateStart(shape: TLArrowShape) {\n\t\tconst bindings = getArrowBindings(this.editor, shape)\n\n\t\t// ...if the user is dragging ONLY this arrow, for elbow shapes, we can't maintain the bindings well just yet so we remove them entirely\n\t\tif (shape.props.kind === 'elbow' && this.editor.getOnlySelectedShapeId() === shape.id) {\n\t\t\tconst info = getArrowInfo(this.editor, shape)\n\t\t\tif (!info) return\n\t\t\tconst update: TLShapePartial<TLArrowShape> = { id: shape.id, type: 'arrow', props: {} }\n\t\t\tif (bindings.start) {\n\t\t\t\tupdate.props!.start = { x: info.start.point.x, y: info.start.point.y }\n\t\t\t\tremoveArrowBinding(this.editor, shape, 'start')\n\t\t\t}\n\t\t\tif (bindings.end) {\n\t\t\t\tupdate.props!.end = { x: info.end.point.x, y: info.end.point.y }\n\t\t\t\tremoveArrowBinding(this.editor, shape, 'end')\n\t\t\t}\n\t\t\treturn update\n\t\t}\n\n\t\tconst terminalsInArrowSpace = getArrowTerminalsInArrowSpace(this.editor, shape, bindings)\n\t\tconst shapePageTransform = this.editor.getShapePageTransform(shape.id)!\n\n\t\t// If at least one bound shape is in the selection, do nothing;\n\t\t// If no bound shapes are in the selection, unbind any bound shapes\n\n\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\n\t\tif (\n\t\t\t(bindings.start &&\n\t\t\t\t(selectedShapeIds.includes(bindings.start.toId) ||\n\t\t\t\t\tthis.editor.isAncestorSelected(bindings.start.toId))) ||\n\t\t\t(bindings.end &&\n\t\t\t\t(selectedShapeIds.includes(bindings.end.toId) ||\n\t\t\t\t\tthis.editor.isAncestorSelected(bindings.end.toId)))\n\t\t) {\n\t\t\treturn\n\t\t}\n\n\t\t// When we start translating shapes, record where their bindings were in page space so we\n\t\t// can maintain them as we translate the arrow\n\t\tshapeAtTranslationStart.set(shape, {\n\t\t\tpagePosition: shapePageTransform.applyToPoint(shape),\n\t\t\tterminalBindings: mapObjectMapValues(terminalsInArrowSpace, (terminalName, point) => {\n\t\t\t\tconst binding = bindings[terminalName]\n\t\t\t\tif (!binding) return null\n\t\t\t\treturn {\n\t\t\t\t\tbinding,\n\t\t\t\t\tshapePosition: point,\n\t\t\t\t\tpagePosition: shapePageTransform.applyToPoint(point),\n\t\t\t\t}\n\t\t\t}),\n\t\t})\n\n\t\t// update arrow terminal bindings eagerly to make sure the arrows unbind nicely when translating\n\t\tif (bindings.start) {\n\t\t\tupdateArrowTerminal({\n\t\t\t\teditor: this.editor,\n\t\t\t\tarrow: shape,\n\t\t\t\tterminal: 'start',\n\t\t\t\tuseHandle: true,\n\t\t\t})\n\t\t\tshape = this.editor.getShape(shape.id) as TLArrowShape\n\t\t}\n\t\tif (bindings.end) {\n\t\t\tupdateArrowTerminal({\n\t\t\t\teditor: this.editor,\n\t\t\t\tarrow: shape,\n\t\t\t\tterminal: 'end',\n\t\t\t\tuseHandle: true,\n\t\t\t})\n\t\t}\n\n\t\tfor (const handleName of [ArrowHandles.Start, ArrowHandles.End] as const) {\n\t\t\tconst binding = bindings[handleName]\n\t\t\tif (!binding) continue\n\n\t\t\tthis.editor.updateBinding({\n\t\t\t\t...binding,\n\t\t\t\tprops: { ...binding.props, isPrecise: true },\n\t\t\t})\n\t\t}\n\n\t\treturn\n\t}\n\n\toverride onTranslate(initialShape: TLArrowShape, shape: TLArrowShape) {\n\t\tconst atTranslationStart = shapeAtTranslationStart.get(initialShape)\n\t\tif (!atTranslationStart) return\n\n\t\tconst shapePageTransform = this.editor.getShapePageTransform(shape.id)!\n\t\tconst pageDelta = Vec.Sub(\n\t\t\tshapePageTransform.applyToPoint(shape),\n\t\t\tatTranslationStart.pagePosition\n\t\t)\n\n\t\tfor (const terminalBinding of Object.values(atTranslationStart.terminalBindings)) {\n\t\t\tif (!terminalBinding) continue\n\n\t\t\tconst newPagePoint = Vec.Add(terminalBinding.pagePosition, Vec.Mul(pageDelta, 0.5))\n\t\t\tconst newTarget = this.editor.getShapeAtPoint(newPagePoint, {\n\t\t\t\thitInside: true,\n\t\t\t\thitFrameInside: true,\n\t\t\t\tmargin: 0,\n\t\t\t\tfilter: (targetShape) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t!targetShape.isLocked &&\n\t\t\t\t\t\tthis.editor.canBindShapes({ fromShape: shape, toShape: targetShape, binding: 'arrow' })\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tif (newTarget?.id === terminalBinding.binding.toId) {\n\t\t\t\tconst targetBounds = Box.ZeroFix(this.editor.getShapeGeometry(newTarget).bounds)\n\t\t\t\tconst pointInTargetSpace = this.editor.getPointInShapeSpace(newTarget, newPagePoint)\n\t\t\t\tconst normalizedAnchor = {\n\t\t\t\t\tx: (pointInTargetSpace.x - targetBounds.minX) / targetBounds.width,\n\t\t\t\t\ty: (pointInTargetSpace.y - targetBounds.minY) / targetBounds.height,\n\t\t\t\t}\n\t\t\t\tcreateOrUpdateArrowBinding(this.editor, shape, newTarget.id, {\n\t\t\t\t\t...terminalBinding.binding.props,\n\t\t\t\t\tnormalizedAnchor,\n\t\t\t\t\tisPrecise: true,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tremoveArrowBinding(this.editor, shape, terminalBinding.binding.props.terminal)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate readonly _resizeInitialBindings = new WeakCache<TLArrowShape, TLArrowBindings>()\n\n\toverride onResize(shape: TLArrowShape, info: TLResizeInfo<TLArrowShape>) {\n\t\tconst { scaleX, scaleY } = info\n\n\t\tconst bindings = this._resizeInitialBindings.get(shape, () =>\n\t\t\tgetArrowBindings(this.editor, shape)\n\t\t)\n\t\tconst terminals = getArrowTerminalsInArrowSpace(this.editor, shape, bindings)\n\n\t\tconst { start, end } = structuredClone<TLArrowShape['props']>(shape.props)\n\t\tlet { bend } = shape.props\n\n\t\t// Rescale start handle if it's not bound to a shape\n\t\tif (!bindings.start) {\n\t\t\tstart.x = terminals.start.x * scaleX\n\t\t\tstart.y = terminals.start.y * scaleY\n\t\t}\n\n\t\t// Rescale end handle if it's not bound to a shape\n\t\tif (!bindings.end) {\n\t\t\tend.x = terminals.end.x * scaleX\n\t\t\tend.y = terminals.end.y * scaleY\n\t\t}\n\n\t\t// todo: we should only change the normalized anchor positions\n\t\t// of the shape's handles if the bound shape is also being resized\n\n\t\tconst mx = Math.abs(scaleX)\n\t\tconst my = Math.abs(scaleY)\n\n\t\tconst startNormalizedAnchor = bindings?.start\n\t\t\t? Vec.From(bindings.start.props.normalizedAnchor)\n\t\t\t: null\n\t\tconst endNormalizedAnchor = bindings?.end ? Vec.From(bindings.end.props.normalizedAnchor) : null\n\n\t\tif (scaleX < 0 && scaleY >= 0) {\n\t\t\tif (bend !== 0) {\n\t\t\t\tbend *= -1\n\t\t\t\tbend *= Math.max(mx, my)\n\t\t\t}\n\n\t\t\tif (startNormalizedAnchor) {\n\t\t\t\tstartNormalizedAnchor.x = 1 - startNormalizedAnchor.x\n\t\t\t}\n\n\t\t\tif (endNormalizedAnchor) {\n\t\t\t\tendNormalizedAnchor.x = 1 - endNormalizedAnchor.x\n\t\t\t}\n\t\t} else if (scaleX >= 0 && scaleY < 0) {\n\t\t\tif (bend !== 0) {\n\t\t\t\tbend *= -1\n\t\t\t\tbend *= Math.max(mx, my)\n\t\t\t}\n\n\t\t\tif (startNormalizedAnchor) {\n\t\t\t\tstartNormalizedAnchor.y = 1 - startNormalizedAnchor.y\n\t\t\t}\n\n\t\t\tif (endNormalizedAnchor) {\n\t\t\t\tendNormalizedAnchor.y = 1 - endNormalizedAnchor.y\n\t\t\t}\n\t\t} else if (scaleX >= 0 && scaleY >= 0) {\n\t\t\tif (bend !== 0) {\n\t\t\t\tbend *= Math.max(mx, my)\n\t\t\t}\n\t\t} else if (scaleX < 0 && scaleY < 0) {\n\t\t\tif (bend !== 0) {\n\t\t\t\tbend *= Math.max(mx, my)\n\t\t\t}\n\n\t\t\tif (startNormalizedAnchor) {\n\t\t\t\tstartNormalizedAnchor.x = 1 - startNormalizedAnchor.x\n\t\t\t\tstartNormalizedAnchor.y = 1 - startNormalizedAnchor.y\n\t\t\t}\n\n\t\t\tif (endNormalizedAnchor) {\n\t\t\t\tendNormalizedAnchor.x = 1 - endNormalizedAnchor.x\n\t\t\t\tendNormalizedAnchor.y = 1 - endNormalizedAnchor.y\n\t\t\t}\n\t\t}\n\n\t\tif (bindings.start && startNormalizedAnchor) {\n\t\t\tcreateOrUpdateArrowBinding(this.editor, shape, bindings.start.toId, {\n\t\t\t\t...bindings.start.props,\n\t\t\t\tnormalizedAnchor: startNormalizedAnchor.toJson(),\n\t\t\t})\n\t\t}\n\t\tif (bindings.end && endNormalizedAnchor) {\n\t\t\tcreateOrUpdateArrowBinding(this.editor, shape, bindings.end.toId, {\n\t\t\t\t...bindings.end.props,\n\t\t\t\tnormalizedAnchor: endNormalizedAnchor.toJson(),\n\t\t\t})\n\t\t}\n\n\t\tconst next = {\n\t\t\tprops: {\n\t\t\t\tstart,\n\t\t\t\tend,\n\t\t\t\tbend,\n\t\t\t},\n\t\t}\n\n\t\treturn next\n\t}\n\n\toverride onDoubleClickHandle(\n\t\tshape: TLArrowShape,\n\t\thandle: TLHandle\n\t): TLShapePartial<TLArrowShape> | void {\n\t\tswitch (handle.id) {\n\t\t\tcase ArrowHandles.Start: {\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...shape.props,\n\t\t\t\t\t\tarrowheadStart: shape.props.arrowheadStart === 'none' ? 'arrow' : 'none',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase ArrowHandles.End: {\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...shape.props,\n\t\t\t\t\t\tarrowheadEnd: shape.props.arrowheadEnd === 'none' ? 'arrow' : 'none',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponent(shape: TLArrowShape) {\n\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tconst theme = useDefaultColorTheme()\n\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\tconst shouldDisplayHandles =\n\t\t\tthis.editor.isInAny(\n\t\t\t\t'select.idle',\n\t\t\t\t'select.pointing_handle',\n\t\t\t\t'select.dragging_handle',\n\t\t\t\t'select.translating',\n\t\t\t\t'arrow.dragging'\n\t\t\t) && !this.editor.getIsReadonly()\n\n\t\tconst info = getArrowInfo(this.editor, shape)\n\t\tif (!info?.isValid) return null\n\n\t\tconst labelPosition = getArrowLabelPosition(this.editor, shape)\n\t\tconst isSelected = shape.id === this.editor.getOnlySelectedShapeId()\n\t\tconst isEditing = this.editor.getEditingShapeId() === shape.id\n\t\tconst showArrowLabel = isEditing || !isEmptyRichText(shape.props.richText)\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SVGContainer style={{ minWidth: 50, minHeight: 50 }}>\n\t\t\t\t\t<ArrowSvg\n\t\t\t\t\t\tshape={shape}\n\t\t\t\t\t\tshouldDisplayHandles={shouldDisplayHandles && onlySelectedShape?.id === shape.id}\n\t\t\t\t\t/>\n\t\t\t\t\t{shape.props.kind === 'elbow' && debugFlags.debugElbowArrows.get() && (\n\t\t\t\t\t\t<ElbowArrowDebug arrow={shape} />\n\t\t\t\t\t)}\n\t\t\t\t</SVGContainer>\n\t\t\t\t{showArrowLabel && (\n\t\t\t\t\t<RichTextLabel\n\t\t\t\t\t\tshapeId={shape.id}\n\t\t\t\t\t\ttype=\"arrow\"\n\t\t\t\t\t\tfont={shape.props.font}\n\t\t\t\t\t\tfontSize={getArrowLabelFontSize(shape)}\n\t\t\t\t\t\tlineHeight={TEXT_PROPS.lineHeight}\n\t\t\t\t\t\talign=\"middle\"\n\t\t\t\t\t\tverticalAlign=\"middle\"\n\t\t\t\t\t\tlabelColor={getColorValue(theme, shape.props.labelColor, 'solid')}\n\t\t\t\t\t\trichText={shape.props.richText}\n\t\t\t\t\t\ttextWidth={labelPosition.box.w - ARROW_LABEL_PADDING * 2 * shape.props.scale}\n\t\t\t\t\t\tisSelected={isSelected}\n\t\t\t\t\t\tpadding={0}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\ttransform: `translate(${labelPosition.box.center.x}px, ${labelPosition.box.center.y}px)`,\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t)\n\t}\n\n\tindicator(shape: TLArrowShape) {\n\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tconst isEditing = useIsEditing(shape.id)\n\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tconst clipPathId = useSharedSafeId(shape.id + '_clip')\n\n\t\tconst info = getArrowInfo(this.editor, shape)\n\t\tif (!info) return null\n\n\t\tconst { start, end } = getArrowTerminalsInArrowSpace(this.editor, shape, info?.bindings)\n\t\tconst geometry = this.editor.getShapeGeometry<Group2d>(shape)\n\t\tconst bounds = geometry.bounds\n\t\tconst isEmpty = isEmptyRichText(shape.props.richText)\n\n\t\tconst labelGeometry = isEditing || !isEmpty ? (geometry.children[1] as Rectangle2d) : null\n\n\t\tif (Vec.Equals(start, end)) return null\n\n\t\tconst strokeWidth = STROKE_SIZES[shape.props.size] * shape.props.scale\n\n\t\tconst as = info.start.arrowhead && getArrowheadPathForType(info, 'start', strokeWidth)\n\t\tconst ae = info.end.arrowhead && getArrowheadPathForType(info, 'end', strokeWidth)\n\n\t\tconst includeClipPath =\n\t\t\t(as && info.start.arrowhead !== 'arrow') ||\n\t\t\t(ae && info.end.arrowhead !== 'arrow') ||\n\t\t\t!!labelGeometry\n\n\t\tconst labelBounds = labelGeometry ? labelGeometry.getBounds() : new Box(0, 0, 0, 0)\n\n\t\tif (isEditing && labelGeometry) {\n\t\t\treturn (\n\t\t\t\t<rect\n\t\t\t\t\tx={toDomPrecision(labelBounds.x)}\n\t\t\t\t\ty={toDomPrecision(labelBounds.y)}\n\t\t\t\t\twidth={labelBounds.w}\n\t\t\t\t\theight={labelBounds.h}\n\t\t\t\t\trx={3.5 * shape.props.scale}\n\t\t\t\t\try={3.5 * shape.props.scale}\n\t\t\t\t/>\n\t\t\t)\n\t\t}\n\t\tconst clipStartArrowhead = !(\n\t\t\tinfo.start.arrowhead === 'none' || info.start.arrowhead === 'arrow'\n\t\t)\n\t\tconst clipEndArrowhead = !(info.end.arrowhead === 'none' || info.end.arrowhead === 'arrow')\n\n\t\treturn (\n\t\t\t<g>\n\t\t\t\t{includeClipPath && (\n\t\t\t\t\t<defs>\n\t\t\t\t\t\t<ArrowClipPath\n\t\t\t\t\t\t\tradius={3.5 * shape.props.scale}\n\t\t\t\t\t\t\thasText={!isEmpty}\n\t\t\t\t\t\t\tbounds={bounds}\n\t\t\t\t\t\t\tlabelBounds={labelBounds}\n\t\t\t\t\t\t\tas={clipStartArrowhead && as ? as : ''}\n\t\t\t\t\t\t\tae={clipEndArrowhead && ae ? ae : ''}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</defs>\n\t\t\t\t)}\n\t\t\t\t<g\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tclipPath: includeClipPath ? `url(#${clipPathId})` : undefined,\n\t\t\t\t\t\tWebkitClipPath: includeClipPath ? `url(#${clipPathId})` : undefined,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{/* This rect needs to be here if we're creating a mask due to an svg quirk on Chrome */}\n\t\t\t\t\t{includeClipPath && (\n\t\t\t\t\t\t<rect\n\t\t\t\t\t\t\tx={bounds.minX - 100}\n\t\t\t\t\t\t\ty={bounds.minY - 100}\n\t\t\t\t\t\t\twidth={bounds.width + 200}\n\t\t\t\t\t\t\theight={bounds.height + 200}\n\t\t\t\t\t\t\topacity={0}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{getArrowBodyPath(\n\t\t\t\t\t\tshape,\n\t\t\t\t\t\tinfo,\n\t\t\t\t\t\tshape.props.dash === 'draw'\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tstyle: 'draw',\n\t\t\t\t\t\t\t\t\trandomSeed: shape.id,\n\t\t\t\t\t\t\t\t\tstrokeWidth: 1,\n\t\t\t\t\t\t\t\t\tpasses: 1,\n\t\t\t\t\t\t\t\t\toffset: 0,\n\t\t\t\t\t\t\t\t\troundness: strokeWidth * 2,\n\t\t\t\t\t\t\t\t\tprops: { strokeWidth: undefined },\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: { style: 'solid', strokeWidth: 1, props: { strokeWidth: undefined } }\n\t\t\t\t\t)}\n\t\t\t\t</g>\n\t\t\t\t{as && <path d={as} />}\n\t\t\t\t{ae && <path d={ae} />}\n\t\t\t\t{labelGeometry && (\n\t\t\t\t\t<rect\n\t\t\t\t\t\tx={toDomPrecision(labelBounds.x)}\n\t\t\t\t\t\ty={toDomPrecision(labelBounds.y)}\n\t\t\t\t\t\twidth={labelBounds.w}\n\t\t\t\t\t\theight={labelBounds.h}\n\t\t\t\t\t\trx={3.5}\n\t\t\t\t\t\try={3.5}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</g>\n\t\t)\n\t}\n\n\toverride onEditStart(shape: TLArrowShape) {\n\t\tif (isEmptyRichText(shape.props.richText)) {\n\t\t\t// editing text for the first time, so set the position to the default:\n\t\t\tconst labelPosition = getArrowLabelDefaultPosition(this.editor, shape)\n\t\t\tthis.editor.updateShape<TLArrowShape>({\n\t\t\t\tid: shape.id,\n\t\t\t\ttype: shape.type,\n\t\t\t\tprops: { labelPosition },\n\t\t\t})\n\t\t}\n\t}\n\n\toverride toSvg(shape: TLArrowShape, ctx: SvgExportContext) {\n\t\tctx.addExportDef(getFillDefForExport(shape.props.fill))\n\t\tconst theme = getDefaultColorTheme(ctx)\n\t\tconst scaleFactor = 1 / shape.props.scale\n\n\t\treturn (\n\t\t\t<g transform={`scale(${scaleFactor})`}>\n\t\t\t\t<ArrowSvg shape={shape} shouldDisplayHandles={false} />\n\t\t\t\t<RichTextSVG\n\t\t\t\t\tfontSize={getArrowLabelFontSize(shape)}\n\t\t\t\t\tfont={shape.props.font}\n\t\t\t\t\talign=\"middle\"\n\t\t\t\t\tverticalAlign=\"middle\"\n\t\t\t\t\tlabelColor={getColorValue(theme, shape.props.labelColor, 'solid')}\n\t\t\t\t\trichText={shape.props.richText}\n\t\t\t\t\tbounds={getArrowLabelPosition(this.editor, shape)\n\t\t\t\t\t\t.box.clone()\n\t\t\t\t\t\t.expandBy(-ARROW_LABEL_PADDING * shape.props.scale)}\n\t\t\t\t\tpadding={0}\n\t\t\t\t\tshowTextOutline={true}\n\t\t\t\t/>\n\t\t\t</g>\n\t\t)\n\t}\n\n\toverride getCanvasSvgDefs(): TLShapeUtilCanvasSvgDef[] {\n\t\treturn [\n\t\t\tgetFillDefForCanvas(),\n\t\t\t{\n\t\t\t\tkey: `arrow:dot`,\n\t\t\t\tcomponent: ArrowheadDotDef,\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: `arrow:cross`,\n\t\t\t\tcomponent: ArrowheadCrossDef,\n\t\t\t},\n\t\t]\n\t}\n\toverride getInterpolatedProps(\n\t\tstartShape: TLArrowShape,\n\t\tendShape: TLArrowShape,\n\t\tprogress: number\n\t): TLArrowShapeProps {\n\t\treturn {\n\t\t\t...(progress > 0.5 ? endShape.props : startShape.props),\n\t\t\tscale: lerp(startShape.props.scale, endShape.props.scale, progress),\n\t\t\tstart: {\n\t\t\t\tx: lerp(startShape.props.start.x, endShape.props.start.x, progress),\n\t\t\t\ty: lerp(startShape.props.start.y, endShape.props.start.y, progress),\n\t\t\t},\n\t\t\tend: {\n\t\t\t\tx: lerp(startShape.props.end.x, endShape.props.end.x, progress),\n\t\t\t\ty: lerp(startShape.props.end.y, endShape.props.end.y, progress),\n\t\t\t},\n\t\t\tbend: lerp(startShape.props.bend, endShape.props.bend, progress),\n\t\t\tlabelPosition: lerp(startShape.props.labelPosition, endShape.props.labelPosition, progress),\n\t\t}\n\t}\n}\n\nexport function getArrowLength(editor: Editor, shape: TLArrowShape): number {\n\tconst info = getArrowInfo(editor, shape)!\n\n\treturn info.type === 'straight'\n\t\t? Vec.Dist(info.start.handle, info.end.handle)\n\t\t: info.type === 'arc'\n\t\t\t? Math.abs(info.handleArc.length)\n\t\t\t: info.route.distance\n}\n\nconst ArrowSvg = track(function ArrowSvg({\n\tshape,\n\tshouldDisplayHandles,\n}: {\n\tshape: TLArrowShape\n\tshouldDisplayHandles: boolean\n}) {\n\tconst editor = useEditor()\n\tconst theme = useDefaultColorTheme()\n\tconst info = getArrowInfo(editor, shape)\n\tconst isForceSolid = useValue(\n\t\t'force solid',\n\t\t() => {\n\t\t\treturn editor.getZoomLevel() < 0.2\n\t\t},\n\t\t[editor]\n\t)\n\tconst clipPathId = useSharedSafeId(shape.id + '_clip')\n\tconst arrowheadDotId = useSharedSafeId('arrowhead-dot')\n\tconst arrowheadCrossId = useSharedSafeId('arrowhead-cross')\n\tconst isEditing = useIsEditing(shape.id)\n\tconst geometry = editor.getShapeGeometry(shape)\n\tif (!geometry) return null\n\tconst bounds = Box.ZeroFix(geometry.bounds)\n\tconst bindings = getArrowBindings(editor, shape)\n\tconst isEmpty = isEmptyRichText(shape.props.richText)\n\n\tif (!info?.isValid) return null\n\n\tconst strokeWidth = STROKE_SIZES[shape.props.size] * shape.props.scale\n\n\tconst as = info.start.arrowhead && getArrowheadPathForType(info, 'start', strokeWidth)\n\tconst ae = info.end.arrowhead && getArrowheadPathForType(info, 'end', strokeWidth)\n\n\tlet handlePath: null | React.JSX.Element = null\n\n\tif (shouldDisplayHandles && (bindings.start || bindings.end)) {\n\t\thandlePath = getArrowHandlePath(info, {\n\t\t\tstyle: 'dashed',\n\t\t\tstart: 'skip',\n\t\t\tend: 'skip',\n\t\t\tlengthRatio: 2.5,\n\t\t\tstrokeWidth: 2 / editor.getZoomLevel(),\n\t\t\tprops: {\n\t\t\t\tclassName: 'tl-arrow-hint',\n\t\t\t\tmarkerStart: bindings.start\n\t\t\t\t\t? bindings.start.props.isExact\n\t\t\t\t\t\t? ''\n\t\t\t\t\t\t: bindings.start.props.isPrecise\n\t\t\t\t\t\t\t? `url(#${arrowheadCrossId})`\n\t\t\t\t\t\t\t: `url(#${arrowheadDotId})`\n\t\t\t\t\t: '',\n\t\t\t\tmarkerEnd: bindings.end\n\t\t\t\t\t? bindings.end.props.isExact\n\t\t\t\t\t\t? ''\n\t\t\t\t\t\t: bindings.end.props.isPrecise\n\t\t\t\t\t\t\t? `url(#${arrowheadCrossId})`\n\t\t\t\t\t\t\t: `url(#${arrowheadDotId})`\n\t\t\t\t\t: '',\n\t\t\t\topacity: 0.16,\n\t\t\t},\n\t\t})\n\t}\n\n\tconst labelPosition = getArrowLabelPosition(editor, shape)\n\n\tconst clipStartArrowhead = !(info.start.arrowhead === 'none' || info.start.arrowhead === 'arrow')\n\tconst clipEndArrowhead = !(info.end.arrowhead === 'none' || info.end.arrowhead === 'arrow')\n\n\treturn (\n\t\t<>\n\t\t\t{/* Yep */}\n\t\t\t<defs>\n\t\t\t\t<clipPath id={clipPathId}>\n\t\t\t\t\t<ArrowClipPath\n\t\t\t\t\t\tradius={3.5 * shape.props.scale}\n\t\t\t\t\t\thasText={isEditing || !isEmpty}\n\t\t\t\t\t\tbounds={bounds}\n\t\t\t\t\t\tlabelBounds={labelPosition.box}\n\t\t\t\t\t\tas={clipStartArrowhead && as ? as : ''}\n\t\t\t\t\t\tae={clipEndArrowhead && ae ? ae : ''}\n\t\t\t\t\t/>\n\t\t\t\t</clipPath>\n\t\t\t</defs>\n\t\t\t<g\n\t\t\t\tfill=\"none\"\n\t\t\t\tstroke={getColorValue(theme, shape.props.color, 'solid')}\n\t\t\t\tstrokeWidth={strokeWidth}\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tpointerEvents=\"none\"\n\t\t\t>\n\t\t\t\t{handlePath}\n\t\t\t\t<g\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tclipPath: `url(#${clipPathId})`,\n\t\t\t\t\t\tWebkitClipPath: `url(#${clipPathId})`,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<rect\n\t\t\t\t\t\tx={toDomPrecision(bounds.minX - 100)}\n\t\t\t\t\t\ty={toDomPrecision(bounds.minY - 100)}\n\t\t\t\t\t\twidth={toDomPrecision(bounds.width + 200)}\n\t\t\t\t\t\theight={toDomPrecision(bounds.height + 200)}\n\t\t\t\t\t\topacity={0}\n\t\t\t\t\t/>\n\t\t\t\t\t{getArrowBodyPath(shape, info, {\n\t\t\t\t\t\tstyle: shape.props.dash,\n\t\t\t\t\t\tstrokeWidth,\n\t\t\t\t\t\tforceSolid: isForceSolid,\n\t\t\t\t\t\trandomSeed: shape.id,\n\t\t\t\t\t})}\n\t\t\t\t</g>\n\t\t\t\t{as && clipStartArrowhead && shape.props.fill !== 'none' && (\n\t\t\t\t\t<ShapeFill\n\t\t\t\t\t\ttheme={theme}\n\t\t\t\t\t\td={as}\n\t\t\t\t\t\tcolor={shape.props.color}\n\t\t\t\t\t\tfill={shape.props.fill}\n\t\t\t\t\t\tscale={shape.props.scale}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t{ae && clipEndArrowhead && shape.props.fill !== 'none' && (\n\t\t\t\t\t<ShapeFill\n\t\t\t\t\t\ttheme={theme}\n\t\t\t\t\t\td={ae}\n\t\t\t\t\t\tcolor={shape.props.color}\n\t\t\t\t\t\tfill={shape.props.fill}\n\t\t\t\t\t\tscale={shape.props.scale}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t{as && <path d={as} />}\n\t\t\t\t{ae && <path d={ae} />}\n\t\t\t</g>\n\t\t</>\n\t)\n})\n\nfunction ArrowClipPath({\n\tradius,\n\thasText,\n\tbounds,\n\tlabelBounds,\n\tas,\n\tae,\n}: {\n\tradius: number\n\thasText: boolean\n\tbounds: Box\n\tlabelBounds: Box\n\tas: string\n\tae: string\n}) {\n\tconst path = useMemo(() => {\n\t\t// The direction in which we create the different path parts is important, as it determines what gets clipped.\n\t\t// See the description on the directions in the non-zero fill rule example:\n\t\t// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill-rule#nonzero\n\t\tconst path = new PathBuilder()\n\n\t\t// We create this one in the clockwise direction\n\t\tpath\n\t\t\t.moveTo(bounds.left - 100, bounds.top - 100)\n\t\t\t.lineTo(bounds.right + 100, bounds.top - 100)\n\t\t\t.lineTo(bounds.right + 100, bounds.bottom + 100)\n\t\t\t.lineTo(bounds.left - 100, bounds.bottom + 100)\n\t\t\t.close()\n\n\t\tif (hasText) {\n\t\t\t// We create this one in the counter-clockwise direction, which cuts out the label box\n\t\t\tpath\n\t\t\t\t.moveTo(labelBounds.left, labelBounds.top + radius)\n\t\t\t\t.lineTo(labelBounds.left, labelBounds.bottom - radius)\n\t\t\t\t.circularArcTo(radius, false, false, labelBounds.left + radius, labelBounds.bottom)\n\t\t\t\t.lineTo(labelBounds.right - radius, labelBounds.bottom)\n\t\t\t\t.circularArcTo(radius, false, false, labelBounds.right, labelBounds.bottom - radius)\n\t\t\t\t.lineTo(labelBounds.right, labelBounds.top + radius)\n\t\t\t\t.circularArcTo(radius, false, false, labelBounds.right - radius, labelBounds.top)\n\t\t\t\t.lineTo(labelBounds.left + radius, labelBounds.top)\n\t\t\t\t.circularArcTo(radius, false, false, labelBounds.left, labelBounds.top + radius)\n\t\t\t\t.close()\n\t\t}\n\n\t\treturn path.toD()\n\t}, [\n\t\tradius,\n\t\thasText,\n\t\tbounds.bottom,\n\t\tbounds.left,\n\t\tbounds.right,\n\t\tbounds.top,\n\t\tlabelBounds.bottom,\n\t\tlabelBounds.left,\n\t\tlabelBounds.right,\n\t\tlabelBounds.top,\n\t])\n\n\t// We also append the arrowhead paths to the clip path, so that we also clip the arrowheads\n\treturn <path d={`${path}${as}${ae}`} />\n}\n\nconst shapeAtTranslationStart = new WeakMap<\n\tTLArrowShape,\n\t{\n\t\tpagePosition: Vec\n\t\tterminalBindings: Record<\n\t\t\t'start' | 'end',\n\t\t\t{\n\t\t\t\tpagePosition: Vec\n\t\t\t\tshapePosition: Vec\n\t\t\t\tbinding: TLArrowBinding\n\t\t\t} | null\n\t\t>\n\t}\n>()\n\nfunction ArrowheadDotDef() {\n\tconst id = useSharedSafeId('arrowhead-dot')\n\treturn (\n\t\t<marker id={id} className=\"tl-arrow-hint\" refX=\"3.0\" refY=\"3.0\" orient=\"0\">\n\t\t\t<circle cx=\"3\" cy=\"3\" r=\"2\" strokeDasharray=\"100%\" />\n\t\t</marker>\n\t)\n}\n\nfunction ArrowheadCrossDef() {\n\tconst id = useSharedSafeId('arrowhead-cross')\n\treturn (\n\t\t<marker id={id} className=\"tl-arrow-hint\" refX=\"3.0\" refY=\"3.0\" orient=\"auto\">\n\t\t\t<line x1=\"1.5\" y1=\"1.5\" x2=\"4.5\" y2=\"4.5\" strokeDasharray=\"100%\" />\n\t\t\t<line x1=\"1.5\" y1=\"4.5\" x2=\"4.5\" y2=\"1.5\" strokeDasharray=\"100%\" />\n\t\t</marker>\n\t)\n}\n\n/**\n * Take 2 angles and return true if they are approximately parallel. Angle that point in the same\n * (or opposite) directions are considered parallel. This also handles wrap around - e.g. 0, \u03C0, and\n * 2\u03C0 are all considered parallel.\n */\nfunction anglesAreApproximatelyParallel(a: number, b: number, tolerance = 0.0001) {\n\tconst diff = Math.abs(a - b)\n\n\tconst isParallel = diff < tolerance\n\tconst isFlippedParallel = Math.abs(diff - Math.PI) < tolerance\n\tconst is360Parallel = Math.abs(diff - PI2) < tolerance\n\n\treturn { isParallel: isParallel || is360Parallel, isFlippedParallel }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAowBG;AApwBH,oBAgDO;AACP,mBAA+B;AAC/B,8BAAoC;AACpC,sBAA6D;AAC7D,yBAA4B;AAC5B,2BAA2C;AAC3C,uBAA0B;AAC1B,qCAA8D;AAC9D,8BAAyD;AACzD,kCAAqC;AACrC,uBAAqD;AAErD,wBAIO;AACP,8BAAuC;AACvC,wBAAwC;AACxC,6BAAgC;AAChC,yBAA+B;AAC/B,iCAAgE;AAChE,oBAOO;AAEP,IAAK,eAAL,kBAAKA,kBAAL;AACC,EAAAA,cAAA,WAA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IAAI,IAAI,CAAC;AAE3B,QAAM,aAAa,OAAO;AAC1B,QAAM,oBAAoB,KAAK,IAAI,OAAO,KAAK,EAAE,IAAI;AACrD,QAAM,gBAAgB,KAAK,IAAI,OAAO,iBAAG,IAAI;AAE7C,SAAO,EAAE,YAAY,cAAc,eAAe,kBAAkB;AACrE;",
|
|
4
|
+
"sourcesContent": ["import {\n\tArc2d,\n\tBox,\n\tEMPTY_ARRAY,\n\tEdge2d,\n\tEditor,\n\tGeometry2d,\n\tGroup2d,\n\tIndexKey,\n\tPI2,\n\tPolyline2d,\n\tRectangle2d,\n\tSVGContainer,\n\tShapeUtil,\n\tSvgExportContext,\n\tTLArrowBinding,\n\tTLArrowBindingProps,\n\tTLArrowShape,\n\tTLArrowShapeProps,\n\tTLHandle,\n\tTLHandleDragInfo,\n\tTLResizeInfo,\n\tTLShapePartial,\n\tTLShapeUtilCanBeLaidOutOpts,\n\tTLShapeUtilCanBindOpts,\n\tTLShapeUtilCanvasSvgDef,\n\tVec,\n\tWeakCache,\n\tarrowShapeMigrations,\n\tarrowShapeProps,\n\tclamp,\n\tdebugFlags,\n\texhaustiveSwitchError,\n\tgetColorValue,\n\tgetDefaultColorTheme,\n\tgetFontsFromRichText,\n\tinvLerp,\n\tlerp,\n\tmapObjectMapValues,\n\tmaybeSnapToGrid,\n\tstructuredClone,\n\ttoDomPrecision,\n\ttoRichText,\n\ttrack,\n\tuseEditor,\n\tuseIsEditing,\n\tuseSharedSafeId,\n\tuseValue,\n} from '@tldraw/editor'\nimport React, { useMemo } from 'react'\nimport { updateArrowTerminal } from '../../bindings/arrow/ArrowBindingUtil'\nimport { isEmptyRichText, renderPlaintextFromRichText } from '../../utils/text/richText'\nimport { PathBuilder } from '../shared/PathBuilder'\nimport { RichTextLabel, RichTextSVG } from '../shared/RichTextLabel'\nimport { ShapeFill } from '../shared/ShapeFill'\nimport { ARROW_LABEL_PADDING, STROKE_SIZES, TEXT_PROPS } from '../shared/default-shape-constants'\nimport { getFillDefForCanvas, getFillDefForExport } from '../shared/defaultStyleDefs'\nimport { useDefaultColorTheme } from '../shared/useDefaultColorTheme'\nimport { getArrowBodyPath, getArrowHandlePath } from './ArrowPath'\nimport { ArrowShapeOptions } from './arrow-types'\nimport {\n\tgetArrowLabelDefaultPosition,\n\tgetArrowLabelFontSize,\n\tgetArrowLabelPosition,\n} from './arrowLabel'\nimport { updateArrowTargetState } from './arrowTargetState'\nimport { getArrowheadPathForType } from './arrowheads'\nimport { ElbowArrowDebug } from './elbow/ElbowArrowDebug'\nimport { ElbowArrowAxes } from './elbow/definitions'\nimport { getElbowArrowSnapLines, perpDistanceToLineAngle } from './elbow/elbowArrowSnapLines'\nimport {\n\tTLArrowBindings,\n\tcreateOrUpdateArrowBinding,\n\tgetArrowBindings,\n\tgetArrowInfo,\n\tgetArrowTerminalsInArrowSpace,\n\tremoveArrowBinding,\n} from './shared'\n\nenum ArrowHandles {\n\tStart = 'start',\n\tMiddle = 'middle',\n\tEnd = 'end',\n}\n\n/** @public */\nexport class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {\n\tstatic override type = 'arrow' as const\n\tstatic override props = arrowShapeProps\n\tstatic override migrations = arrowShapeMigrations\n\n\toverride options: ArrowShapeOptions = {\n\t\texpandElbowLegLength: {\n\t\t\ts: 28,\n\t\t\tm: 36,\n\t\t\tl: 44,\n\t\t\txl: 66,\n\t\t},\n\t\tminElbowLegLength: {\n\t\t\ts: STROKE_SIZES.s * 3,\n\t\t\tm: STROKE_SIZES.m * 3,\n\t\t\tl: STROKE_SIZES.l * 3,\n\t\t\txl: STROKE_SIZES.xl * 3,\n\t\t},\n\t\tminElbowHandleDistance: 16,\n\n\t\tarcArrowCenterSnapDistance: 16,\n\t\telbowArrowCenterSnapDistance: 24,\n\t\telbowArrowEdgeSnapDistance: 20,\n\t\telbowArrowPointSnapDistance: 24,\n\t\telbowArrowAxisSnapDistance: 16,\n\n\t\tlabelCenterSnapDistance: 10,\n\n\t\telbowMidpointSnapDistance: 10,\n\t\telbowMinSegmentLengthToShowMidpointHandle: 20,\n\n\t\thoverPreciseTimeout: 600,\n\t\tpointingPreciseTimeout: 320,\n\n\t\tshouldBeExact: (editor: Editor) => editor.inputs.altKey,\n\t\tshouldIgnoreTargets: (editor: Editor) => editor.inputs.ctrlKey,\n\t}\n\n\toverride canEdit() {\n\t\treturn true\n\t}\n\toverride canBind({ toShapeType }: TLShapeUtilCanBindOpts<TLArrowShape>): boolean {\n\t\t// bindings can go from arrows to shapes, but not from shapes to arrows\n\t\treturn toShapeType !== 'arrow'\n\t}\n\toverride canSnap() {\n\t\treturn false\n\t}\n\toverride hideResizeHandles() {\n\t\treturn true\n\t}\n\toverride hideRotateHandle() {\n\t\treturn true\n\t}\n\toverride hideSelectionBoundsBg() {\n\t\treturn true\n\t}\n\toverride hideSelectionBoundsFg() {\n\t\treturn true\n\t}\n\toverride hideInMinimap() {\n\t\treturn true\n\t}\n\n\toverride canBeLaidOut(shape: TLArrowShape, info: TLShapeUtilCanBeLaidOutOpts) {\n\t\tif (info.type === 'flip') {\n\t\t\t// If we don't have this then the flip will be non-idempotent; that is, the flip will be multipotent, varipotent, or perhaps even omni-potent... and we can't have that\n\t\t\tconst bindings = getArrowBindings(this.editor, shape)\n\t\t\tconst { start, end } = bindings\n\t\t\tconst { shapes = [] } = info\n\t\t\tif (start && !shapes.find((s) => s.id === start.toId)) return false\n\t\t\tif (end && !shapes.find((s) => s.id === end.toId)) return false\n\t\t}\n\t\treturn true\n\t}\n\n\toverride getFontFaces(shape: TLArrowShape) {\n\t\tif (isEmptyRichText(shape.props.richText)) return EMPTY_ARRAY\n\n\t\treturn getFontsFromRichText(this.editor, shape.props.richText, {\n\t\t\tfamily: `tldraw_${shape.props.font}`,\n\t\t\tweight: 'normal',\n\t\t\tstyle: 'normal',\n\t\t})\n\t}\n\n\toverride getDefaultProps(): TLArrowShape['props'] {\n\t\treturn {\n\t\t\tkind: 'arc',\n\t\t\telbowMidPoint: 0.5,\n\t\t\tdash: 'draw',\n\t\t\tsize: 'm',\n\t\t\tfill: 'none',\n\t\t\tcolor: 'black',\n\t\t\tlabelColor: 'black',\n\t\t\tbend: 0,\n\t\t\tstart: { x: 0, y: 0 },\n\t\t\tend: { x: 2, y: 0 },\n\t\t\tarrowheadStart: 'none',\n\t\t\tarrowheadEnd: 'arrow',\n\t\t\trichText: toRichText(''),\n\t\t\tlabelPosition: 0.5,\n\t\t\tfont: 'draw',\n\t\t\tscale: 1,\n\t\t}\n\t}\n\n\tgetGeometry(shape: TLArrowShape) {\n\t\tconst isEditing = this.editor.getEditingShapeId() === shape.id\n\t\tconst info = getArrowInfo(this.editor, shape)!\n\n\t\tconst debugGeom: Geometry2d[] = []\n\n\t\tconst bodyGeom =\n\t\t\tinfo.type === 'straight'\n\t\t\t\t? new Edge2d({\n\t\t\t\t\t\tstart: Vec.From(info.start.point),\n\t\t\t\t\t\tend: Vec.From(info.end.point),\n\t\t\t\t\t})\n\t\t\t\t: info.type === 'arc'\n\t\t\t\t\t? new Arc2d({\n\t\t\t\t\t\t\tcenter: Vec.Cast(info.handleArc.center),\n\t\t\t\t\t\t\tstart: Vec.Cast(info.start.point),\n\t\t\t\t\t\t\tend: Vec.Cast(info.end.point),\n\t\t\t\t\t\t\tsweepFlag: info.bodyArc.sweepFlag,\n\t\t\t\t\t\t\tlargeArcFlag: info.bodyArc.largeArcFlag,\n\t\t\t\t\t\t})\n\t\t\t\t\t: new Polyline2d({ points: info.route.points })\n\n\t\tlet labelGeom\n\t\tif (isEditing || !isEmptyRichText(shape.props.richText)) {\n\t\t\tconst labelPosition = getArrowLabelPosition(this.editor, shape)\n\t\t\tif (debugFlags.debugGeometry.get()) {\n\t\t\t\tdebugGeom.push(...labelPosition.debugGeom)\n\t\t\t}\n\t\t\tlabelGeom = new Rectangle2d({\n\t\t\t\tx: labelPosition.box.x,\n\t\t\t\ty: labelPosition.box.y,\n\t\t\t\twidth: labelPosition.box.w,\n\t\t\t\theight: labelPosition.box.h,\n\t\t\t\tisFilled: true,\n\t\t\t\tisLabel: true,\n\t\t\t})\n\t\t}\n\n\t\treturn new Group2d({\n\t\t\tchildren: [...(labelGeom ? [bodyGeom, labelGeom] : [bodyGeom]), ...debugGeom],\n\t\t})\n\t}\n\n\toverride getHandles(shape: TLArrowShape): TLHandle[] {\n\t\tconst info = getArrowInfo(this.editor, shape)!\n\n\t\tconst handles: TLHandle[] = [\n\t\t\t{\n\t\t\t\tid: ArrowHandles.Start,\n\t\t\t\ttype: 'vertex',\n\t\t\t\tindex: 'a1' as IndexKey,\n\t\t\t\tx: info.start.handle.x,\n\t\t\t\ty: info.start.handle.y,\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: ArrowHandles.End,\n\t\t\t\ttype: 'vertex',\n\t\t\t\tindex: 'a3' as IndexKey,\n\t\t\t\tx: info.end.handle.x,\n\t\t\t\ty: info.end.handle.y,\n\t\t\t},\n\t\t]\n\n\t\tif (shape.props.kind === 'arc' && (info.type === 'straight' || info.type === 'arc')) {\n\t\t\thandles.push({\n\t\t\t\tid: ArrowHandles.Middle,\n\t\t\t\ttype: 'virtual',\n\t\t\t\tindex: 'a2' as IndexKey,\n\t\t\t\tx: info.middle.x,\n\t\t\t\ty: info.middle.y,\n\t\t\t})\n\t\t}\n\n\t\tif (shape.props.kind === 'elbow' && info.type === 'elbow' && info.route.midpointHandle) {\n\t\t\tconst shapePageTransform = this.editor.getShapePageTransform(shape.id)!\n\n\t\t\tconst segmentStart = shapePageTransform.applyToPoint(info.route.midpointHandle.segmentStart)\n\t\t\tconst segmentEnd = shapePageTransform.applyToPoint(info.route.midpointHandle.segmentEnd)\n\t\t\tconst segmentLength = Vec.Dist(segmentStart, segmentEnd) * this.editor.getZoomLevel()\n\n\t\t\tif (segmentLength > this.options.elbowMinSegmentLengthToShowMidpointHandle) {\n\t\t\t\thandles.push({\n\t\t\t\t\tid: ArrowHandles.Middle,\n\t\t\t\t\ttype: 'vertex',\n\t\t\t\t\tindex: 'a2' as IndexKey,\n\t\t\t\t\tx: info.route.midpointHandle.point.x,\n\t\t\t\t\ty: info.route.midpointHandle.point.y,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn handles\n\t}\n\n\toverride getText(shape: TLArrowShape) {\n\t\treturn renderPlaintextFromRichText(this.editor, shape.props.richText)\n\t}\n\n\toverride onHandleDrag(shape: TLArrowShape, info: TLHandleDragInfo<TLArrowShape>) {\n\t\tconst handleId = info.handle.id as ArrowHandles\n\t\tswitch (handleId) {\n\t\t\tcase ArrowHandles.Middle:\n\t\t\t\tswitch (shape.props.kind) {\n\t\t\t\t\tcase 'arc':\n\t\t\t\t\t\treturn this.onArcMidpointHandleDrag(shape, info)\n\t\t\t\t\tcase 'elbow':\n\t\t\t\t\t\treturn this.onElbowMidpointHandleDrag(shape, info)\n\t\t\t\t\tdefault:\n\t\t\t\t\t\texhaustiveSwitchError(shape.props.kind)\n\t\t\t\t}\n\t\t\tcase ArrowHandles.Start:\n\t\t\tcase ArrowHandles.End:\n\t\t\t\treturn this.onTerminalHandleDrag(shape, info, handleId)\n\t\t\tdefault:\n\t\t\t\texhaustiveSwitchError(handleId)\n\t\t}\n\t}\n\n\tprivate onArcMidpointHandleDrag(shape: TLArrowShape, { handle }: TLHandleDragInfo<TLArrowShape>) {\n\t\tconst bindings = getArrowBindings(this.editor, shape)\n\n\t\t// Bending the arrow...\n\t\tconst { start, end } = getArrowTerminalsInArrowSpace(this.editor, shape, bindings)\n\n\t\tconst delta = Vec.Sub(end, start)\n\t\tconst v = Vec.Per(delta)\n\n\t\tconst med = Vec.Med(end, start)\n\t\tconst A = Vec.Sub(med, v)\n\t\tconst B = Vec.Add(med, v)\n\n\t\tconst point = Vec.NearestPointOnLineSegment(A, B, handle, false)\n\t\tlet bend = Vec.Dist(point, med)\n\t\tif (Vec.Clockwise(point, end, med)) bend *= -1\n\t\treturn { id: shape.id, type: shape.type, props: { bend } }\n\t}\n\n\tprivate onElbowMidpointHandleDrag(\n\t\tshape: TLArrowShape,\n\t\t{ handle }: TLHandleDragInfo<TLArrowShape>\n\t) {\n\t\tconst info = getArrowInfo(this.editor, shape)\n\t\tif (info?.type !== 'elbow') return\n\n\t\tconst shapeToPageTransform = this.editor.getShapePageTransform(shape.id)!\n\t\tconst handlePagePoint = shapeToPageTransform.applyToPoint(handle)\n\t\tconst axisName = info.route.midpointHandle?.axis\n\t\tif (!axisName) return\n\t\tconst axis = ElbowArrowAxes[axisName]\n\n\t\tconst midRange = info.elbow[axis.midRange]\n\t\tif (!midRange) return\n\n\t\t// We're snapping against a list of parallel lines. The way we do this is to calculate the\n\t\t// angle of the line we're snapping to...\n\t\tlet angle = Vec.Angle(\n\t\t\tshapeToPageTransform.applyToPoint(axis.v(0, 0)),\n\t\t\tshapeToPageTransform.applyToPoint(axis.v(0, 1))\n\t\t)\n\t\tif (angle < 0) angle += Math.PI\n\n\t\t// ...then calculate the perpendicular distance from the origin to the (infinite) line in\n\t\t// question. This returns a signed distance - lines \"behind\" the origin are negative.\n\t\tconst handlePoint = perpDistanceToLineAngle(handlePagePoint, angle)\n\n\t\t// As we're only ever moving along one dimension, we can use this perpendicular distance for\n\t\t// all of our snapping calculations.\n\t\tconst loPoint = perpDistanceToLineAngle(\n\t\t\tshapeToPageTransform.applyToPoint(axis.v(midRange.lo, 0)),\n\t\t\tangle\n\t\t)\n\t\tconst hiPoint = perpDistanceToLineAngle(\n\t\t\tshapeToPageTransform.applyToPoint(axis.v(midRange.hi, 0)),\n\t\t\tangle\n\t\t)\n\n\t\t// we want to snap to certain points. the maximum distance at which a snap will occur is\n\t\t// relative to the zoom level:\n\t\tconst maxSnapDistance = this.options.elbowMidpointSnapDistance / this.editor.getZoomLevel()\n\n\t\t// we snap to the midpoint of the range by default\n\t\tconst midPoint = perpDistanceToLineAngle(\n\t\t\tshapeToPageTransform.applyToPoint(axis.v(lerp(midRange.lo, midRange.hi, 0.5), 0)),\n\t\t\tangle\n\t\t)\n\n\t\tlet snapPoint = midPoint\n\t\tlet snapDistance = Math.abs(midPoint - handlePoint)\n\n\t\t// then we check all the other arrows that are on-screen.\n\t\tfor (const [snapAngle, snapLines] of getElbowArrowSnapLines(this.editor)) {\n\t\t\tconst { isParallel, isFlippedParallel } = anglesAreApproximatelyParallel(angle, snapAngle)\n\t\t\tif (isParallel || isFlippedParallel) {\n\t\t\t\tfor (const snapLine of snapLines) {\n\t\t\t\t\tconst doesShareStartIntersection =\n\t\t\t\t\t\tsnapLine.startBoundShapeId &&\n\t\t\t\t\t\t(snapLine.startBoundShapeId === info.bindings.start?.toId ||\n\t\t\t\t\t\t\tsnapLine.startBoundShapeId === info.bindings.end?.toId)\n\n\t\t\t\t\tconst doesShareEndIntersection =\n\t\t\t\t\t\tsnapLine.endBoundShapeId &&\n\t\t\t\t\t\t(snapLine.endBoundShapeId === info.bindings.start?.toId ||\n\t\t\t\t\t\t\tsnapLine.endBoundShapeId === info.bindings.end?.toId)\n\n\t\t\t\t\tif (!doesShareStartIntersection && !doesShareEndIntersection) continue\n\n\t\t\t\t\tconst point = isFlippedParallel ? -snapLine.perpDistance : snapLine.perpDistance\n\t\t\t\t\tconst distance = Math.abs(point - handlePoint)\n\t\t\t\t\tif (distance < snapDistance) {\n\t\t\t\t\t\tsnapPoint = point\n\t\t\t\t\t\tsnapDistance = distance\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (snapDistance > maxSnapDistance) {\n\t\t\tsnapPoint = handlePoint\n\t\t}\n\n\t\tconst newMid = clamp(invLerp(loPoint, hiPoint, snapPoint), 0, 1)\n\n\t\treturn {\n\t\t\tid: shape.id,\n\t\t\ttype: shape.type,\n\t\t\tprops: {\n\t\t\t\telbowMidPoint: newMid,\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate onTerminalHandleDrag(\n\t\tshape: TLArrowShape,\n\t\t{ handle, isPrecise }: TLHandleDragInfo<TLArrowShape>,\n\t\thandleId: ArrowHandles.Start | ArrowHandles.End\n\t) {\n\t\tconst bindings = getArrowBindings(this.editor, shape)\n\n\t\tconst update: TLShapePartial<TLArrowShape> = { id: shape.id, type: 'arrow', props: {} }\n\n\t\tconst currentBinding = bindings[handleId]\n\n\t\tconst oppositeHandleId = handleId === ArrowHandles.Start ? ArrowHandles.End : ArrowHandles.Start\n\t\tconst oppositeBinding = bindings[oppositeHandleId]\n\n\t\tconst targetInfo = updateArrowTargetState({\n\t\t\teditor: this.editor,\n\t\t\tpointInPageSpace: this.editor.getShapePageTransform(shape.id)!.applyToPoint(handle),\n\t\t\tarrow: shape,\n\t\t\tisPrecise: isPrecise,\n\t\t\tcurrentBinding,\n\t\t\toppositeBinding,\n\t\t})\n\n\t\tif (!targetInfo) {\n\t\t\t// todo: maybe double check that this isn't equal to the other handle too?\n\t\t\tremoveArrowBinding(this.editor, shape, handleId)\n\t\t\tconst newPoint = maybeSnapToGrid(new Vec(handle.x, handle.y), this.editor)\n\t\t\tupdate.props![handleId] = {\n\t\t\t\tx: newPoint.x,\n\t\t\t\ty: newPoint.y,\n\t\t\t}\n\t\t\treturn update\n\t\t}\n\n\t\t// we've got a target! the handle is being dragged over a shape, bind to it\n\t\tconst bindingProps: TLArrowBindingProps = {\n\t\t\tterminal: handleId,\n\t\t\tnormalizedAnchor: targetInfo.normalizedAnchor,\n\t\t\tisPrecise: targetInfo.isPrecise,\n\t\t\tisExact: targetInfo.isExact,\n\t\t\tsnap: targetInfo.snap,\n\t\t}\n\n\t\tcreateOrUpdateArrowBinding(this.editor, shape, targetInfo.target.id, bindingProps)\n\n\t\tconst newBindings = getArrowBindings(this.editor, shape)\n\t\tif (newBindings.start && newBindings.end && newBindings.start.toId === newBindings.end.toId) {\n\t\t\tif (\n\t\t\t\tVec.Equals(newBindings.start.props.normalizedAnchor, newBindings.end.props.normalizedAnchor)\n\t\t\t) {\n\t\t\t\tcreateOrUpdateArrowBinding(this.editor, shape, newBindings.end.toId, {\n\t\t\t\t\t...newBindings.end.props,\n\t\t\t\t\tnormalizedAnchor: {\n\t\t\t\t\t\tx: newBindings.end.props.normalizedAnchor.x + 0.05,\n\t\t\t\t\t\ty: newBindings.end.props.normalizedAnchor.y,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn update\n\t}\n\n\toverride onTranslateStart(shape: TLArrowShape) {\n\t\tconst bindings = getArrowBindings(this.editor, shape)\n\n\t\t// ...if the user is dragging ONLY this arrow, for elbow shapes, we can't maintain the bindings well just yet so we remove them entirely\n\t\tif (shape.props.kind === 'elbow' && this.editor.getOnlySelectedShapeId() === shape.id) {\n\t\t\tconst info = getArrowInfo(this.editor, shape)\n\t\t\tif (!info) return\n\t\t\tconst update: TLShapePartial<TLArrowShape> = { id: shape.id, type: 'arrow', props: {} }\n\t\t\tif (bindings.start) {\n\t\t\t\tupdate.props!.start = { x: info.start.point.x, y: info.start.point.y }\n\t\t\t\tremoveArrowBinding(this.editor, shape, 'start')\n\t\t\t}\n\t\t\tif (bindings.end) {\n\t\t\t\tupdate.props!.end = { x: info.end.point.x, y: info.end.point.y }\n\t\t\t\tremoveArrowBinding(this.editor, shape, 'end')\n\t\t\t}\n\t\t\treturn update\n\t\t}\n\n\t\tconst terminalsInArrowSpace = getArrowTerminalsInArrowSpace(this.editor, shape, bindings)\n\t\tconst shapePageTransform = this.editor.getShapePageTransform(shape.id)!\n\n\t\t// If at least one bound shape is in the selection, do nothing;\n\t\t// If no bound shapes are in the selection, unbind any bound shapes\n\n\t\tconst selectedShapeIds = this.editor.getSelectedShapeIds()\n\n\t\tif (\n\t\t\t(bindings.start &&\n\t\t\t\t(selectedShapeIds.includes(bindings.start.toId) ||\n\t\t\t\t\tthis.editor.isAncestorSelected(bindings.start.toId))) ||\n\t\t\t(bindings.end &&\n\t\t\t\t(selectedShapeIds.includes(bindings.end.toId) ||\n\t\t\t\t\tthis.editor.isAncestorSelected(bindings.end.toId)))\n\t\t) {\n\t\t\treturn\n\t\t}\n\n\t\t// When we start translating shapes, record where their bindings were in page space so we\n\t\t// can maintain them as we translate the arrow\n\t\tshapeAtTranslationStart.set(shape, {\n\t\t\tpagePosition: shapePageTransform.applyToPoint(shape),\n\t\t\tterminalBindings: mapObjectMapValues(terminalsInArrowSpace, (terminalName, point) => {\n\t\t\t\tconst binding = bindings[terminalName]\n\t\t\t\tif (!binding) return null\n\t\t\t\treturn {\n\t\t\t\t\tbinding,\n\t\t\t\t\tshapePosition: point,\n\t\t\t\t\tpagePosition: shapePageTransform.applyToPoint(point),\n\t\t\t\t}\n\t\t\t}),\n\t\t})\n\n\t\t// update arrow terminal bindings eagerly to make sure the arrows unbind nicely when translating\n\t\tif (bindings.start) {\n\t\t\tupdateArrowTerminal({\n\t\t\t\teditor: this.editor,\n\t\t\t\tarrow: shape,\n\t\t\t\tterminal: 'start',\n\t\t\t\tuseHandle: true,\n\t\t\t})\n\t\t\tshape = this.editor.getShape(shape.id) as TLArrowShape\n\t\t}\n\t\tif (bindings.end) {\n\t\t\tupdateArrowTerminal({\n\t\t\t\teditor: this.editor,\n\t\t\t\tarrow: shape,\n\t\t\t\tterminal: 'end',\n\t\t\t\tuseHandle: true,\n\t\t\t})\n\t\t}\n\n\t\tfor (const handleName of [ArrowHandles.Start, ArrowHandles.End] as const) {\n\t\t\tconst binding = bindings[handleName]\n\t\t\tif (!binding) continue\n\n\t\t\tthis.editor.updateBinding({\n\t\t\t\t...binding,\n\t\t\t\tprops: { ...binding.props, isPrecise: true },\n\t\t\t})\n\t\t}\n\n\t\treturn\n\t}\n\n\toverride onTranslate(initialShape: TLArrowShape, shape: TLArrowShape) {\n\t\tconst atTranslationStart = shapeAtTranslationStart.get(initialShape)\n\t\tif (!atTranslationStart) return\n\n\t\tconst shapePageTransform = this.editor.getShapePageTransform(shape.id)!\n\t\tconst pageDelta = Vec.Sub(\n\t\t\tshapePageTransform.applyToPoint(shape),\n\t\t\tatTranslationStart.pagePosition\n\t\t)\n\n\t\tfor (const terminalBinding of Object.values(atTranslationStart.terminalBindings)) {\n\t\t\tif (!terminalBinding) continue\n\n\t\t\tconst newPagePoint = Vec.Add(terminalBinding.pagePosition, Vec.Mul(pageDelta, 0.5))\n\t\t\tconst newTarget = this.editor.getShapeAtPoint(newPagePoint, {\n\t\t\t\thitInside: true,\n\t\t\t\thitFrameInside: true,\n\t\t\t\tmargin: 0,\n\t\t\t\tfilter: (targetShape) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t!targetShape.isLocked &&\n\t\t\t\t\t\tthis.editor.canBindShapes({ fromShape: shape, toShape: targetShape, binding: 'arrow' })\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tif (newTarget?.id === terminalBinding.binding.toId) {\n\t\t\t\tconst targetBounds = Box.ZeroFix(this.editor.getShapeGeometry(newTarget).bounds)\n\t\t\t\tconst pointInTargetSpace = this.editor.getPointInShapeSpace(newTarget, newPagePoint)\n\t\t\t\tconst normalizedAnchor = {\n\t\t\t\t\tx: (pointInTargetSpace.x - targetBounds.minX) / targetBounds.width,\n\t\t\t\t\ty: (pointInTargetSpace.y - targetBounds.minY) / targetBounds.height,\n\t\t\t\t}\n\t\t\t\tcreateOrUpdateArrowBinding(this.editor, shape, newTarget.id, {\n\t\t\t\t\t...terminalBinding.binding.props,\n\t\t\t\t\tnormalizedAnchor,\n\t\t\t\t\tisPrecise: true,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tremoveArrowBinding(this.editor, shape, terminalBinding.binding.props.terminal)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate readonly _resizeInitialBindings = new WeakCache<TLArrowShape, TLArrowBindings>()\n\n\toverride onResize(shape: TLArrowShape, info: TLResizeInfo<TLArrowShape>) {\n\t\tconst { scaleX, scaleY } = info\n\n\t\tconst bindings = this._resizeInitialBindings.get(shape, () =>\n\t\t\tgetArrowBindings(this.editor, shape)\n\t\t)\n\t\tconst terminals = getArrowTerminalsInArrowSpace(this.editor, shape, bindings)\n\n\t\tconst { start, end } = structuredClone<TLArrowShape['props']>(shape.props)\n\t\tlet { bend } = shape.props\n\n\t\t// Rescale start handle if it's not bound to a shape\n\t\tif (!bindings.start) {\n\t\t\tstart.x = terminals.start.x * scaleX\n\t\t\tstart.y = terminals.start.y * scaleY\n\t\t}\n\n\t\t// Rescale end handle if it's not bound to a shape\n\t\tif (!bindings.end) {\n\t\t\tend.x = terminals.end.x * scaleX\n\t\t\tend.y = terminals.end.y * scaleY\n\t\t}\n\n\t\t// todo: we should only change the normalized anchor positions\n\t\t// of the shape's handles if the bound shape is also being resized\n\n\t\tconst mx = Math.abs(scaleX)\n\t\tconst my = Math.abs(scaleY)\n\n\t\tconst startNormalizedAnchor = bindings?.start\n\t\t\t? Vec.From(bindings.start.props.normalizedAnchor)\n\t\t\t: null\n\t\tconst endNormalizedAnchor = bindings?.end ? Vec.From(bindings.end.props.normalizedAnchor) : null\n\n\t\tif (scaleX < 0 && scaleY >= 0) {\n\t\t\tif (bend !== 0) {\n\t\t\t\tbend *= -1\n\t\t\t\tbend *= Math.max(mx, my)\n\t\t\t}\n\n\t\t\tif (startNormalizedAnchor) {\n\t\t\t\tstartNormalizedAnchor.x = 1 - startNormalizedAnchor.x\n\t\t\t}\n\n\t\t\tif (endNormalizedAnchor) {\n\t\t\t\tendNormalizedAnchor.x = 1 - endNormalizedAnchor.x\n\t\t\t}\n\t\t} else if (scaleX >= 0 && scaleY < 0) {\n\t\t\tif (bend !== 0) {\n\t\t\t\tbend *= -1\n\t\t\t\tbend *= Math.max(mx, my)\n\t\t\t}\n\n\t\t\tif (startNormalizedAnchor) {\n\t\t\t\tstartNormalizedAnchor.y = 1 - startNormalizedAnchor.y\n\t\t\t}\n\n\t\t\tif (endNormalizedAnchor) {\n\t\t\t\tendNormalizedAnchor.y = 1 - endNormalizedAnchor.y\n\t\t\t}\n\t\t} else if (scaleX >= 0 && scaleY >= 0) {\n\t\t\tif (bend !== 0) {\n\t\t\t\tbend *= Math.max(mx, my)\n\t\t\t}\n\t\t} else if (scaleX < 0 && scaleY < 0) {\n\t\t\tif (bend !== 0) {\n\t\t\t\tbend *= Math.max(mx, my)\n\t\t\t}\n\n\t\t\tif (startNormalizedAnchor) {\n\t\t\t\tstartNormalizedAnchor.x = 1 - startNormalizedAnchor.x\n\t\t\t\tstartNormalizedAnchor.y = 1 - startNormalizedAnchor.y\n\t\t\t}\n\n\t\t\tif (endNormalizedAnchor) {\n\t\t\t\tendNormalizedAnchor.x = 1 - endNormalizedAnchor.x\n\t\t\t\tendNormalizedAnchor.y = 1 - endNormalizedAnchor.y\n\t\t\t}\n\t\t}\n\n\t\tif (bindings.start && startNormalizedAnchor) {\n\t\t\tcreateOrUpdateArrowBinding(this.editor, shape, bindings.start.toId, {\n\t\t\t\t...bindings.start.props,\n\t\t\t\tnormalizedAnchor: startNormalizedAnchor.toJson(),\n\t\t\t})\n\t\t}\n\t\tif (bindings.end && endNormalizedAnchor) {\n\t\t\tcreateOrUpdateArrowBinding(this.editor, shape, bindings.end.toId, {\n\t\t\t\t...bindings.end.props,\n\t\t\t\tnormalizedAnchor: endNormalizedAnchor.toJson(),\n\t\t\t})\n\t\t}\n\n\t\tconst next = {\n\t\t\tprops: {\n\t\t\t\tstart,\n\t\t\t\tend,\n\t\t\t\tbend,\n\t\t\t},\n\t\t}\n\n\t\treturn next\n\t}\n\n\toverride onDoubleClickHandle(\n\t\tshape: TLArrowShape,\n\t\thandle: TLHandle\n\t): TLShapePartial<TLArrowShape> | void {\n\t\tswitch (handle.id) {\n\t\t\tcase ArrowHandles.Start: {\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...shape.props,\n\t\t\t\t\t\tarrowheadStart: shape.props.arrowheadStart === 'none' ? 'arrow' : 'none',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase ArrowHandles.End: {\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...shape.props,\n\t\t\t\t\t\tarrowheadEnd: shape.props.arrowheadEnd === 'none' ? 'arrow' : 'none',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponent(shape: TLArrowShape) {\n\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tconst theme = useDefaultColorTheme()\n\t\tconst onlySelectedShape = this.editor.getOnlySelectedShape()\n\t\tconst shouldDisplayHandles =\n\t\t\tthis.editor.isInAny(\n\t\t\t\t'select.idle',\n\t\t\t\t'select.pointing_handle',\n\t\t\t\t'select.dragging_handle',\n\t\t\t\t'select.translating',\n\t\t\t\t'arrow.dragging'\n\t\t\t) && !this.editor.getIsReadonly()\n\n\t\tconst info = getArrowInfo(this.editor, shape)\n\t\tif (!info?.isValid) return null\n\n\t\tconst labelPosition = getArrowLabelPosition(this.editor, shape)\n\t\tconst isSelected = shape.id === this.editor.getOnlySelectedShapeId()\n\t\tconst isEditing = this.editor.getEditingShapeId() === shape.id\n\t\tconst showArrowLabel = isEditing || !isEmptyRichText(shape.props.richText)\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SVGContainer style={{ minWidth: 50, minHeight: 50 }}>\n\t\t\t\t\t<ArrowSvg\n\t\t\t\t\t\tshape={shape}\n\t\t\t\t\t\tshouldDisplayHandles={shouldDisplayHandles && onlySelectedShape?.id === shape.id}\n\t\t\t\t\t/>\n\t\t\t\t\t{shape.props.kind === 'elbow' && debugFlags.debugElbowArrows.get() && (\n\t\t\t\t\t\t<ElbowArrowDebug arrow={shape} />\n\t\t\t\t\t)}\n\t\t\t\t</SVGContainer>\n\t\t\t\t{showArrowLabel && (\n\t\t\t\t\t<RichTextLabel\n\t\t\t\t\t\tshapeId={shape.id}\n\t\t\t\t\t\ttype=\"arrow\"\n\t\t\t\t\t\tfont={shape.props.font}\n\t\t\t\t\t\tfontSize={getArrowLabelFontSize(shape)}\n\t\t\t\t\t\tlineHeight={TEXT_PROPS.lineHeight}\n\t\t\t\t\t\talign=\"middle\"\n\t\t\t\t\t\tverticalAlign=\"middle\"\n\t\t\t\t\t\tlabelColor={getColorValue(theme, shape.props.labelColor, 'solid')}\n\t\t\t\t\t\trichText={shape.props.richText}\n\t\t\t\t\t\ttextWidth={labelPosition.box.w - ARROW_LABEL_PADDING * 2 * shape.props.scale}\n\t\t\t\t\t\tisSelected={isSelected}\n\t\t\t\t\t\tpadding={0}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\ttransform: `translate(${labelPosition.box.center.x}px, ${labelPosition.box.center.y}px)`,\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t)\n\t}\n\n\tindicator(shape: TLArrowShape) {\n\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tconst isEditing = useIsEditing(shape.id)\n\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tconst clipPathId = useSharedSafeId(shape.id + '_clip')\n\n\t\tconst info = getArrowInfo(this.editor, shape)\n\t\tif (!info) return null\n\n\t\tconst { start, end } = getArrowTerminalsInArrowSpace(this.editor, shape, info?.bindings)\n\t\tconst geometry = this.editor.getShapeGeometry<Group2d>(shape)\n\t\tconst bounds = geometry.bounds\n\t\tconst isEmpty = isEmptyRichText(shape.props.richText)\n\n\t\tconst labelGeometry = isEditing || !isEmpty ? (geometry.children[1] as Rectangle2d) : null\n\n\t\tif (Vec.Equals(start, end)) return null\n\n\t\tconst strokeWidth = STROKE_SIZES[shape.props.size] * shape.props.scale\n\n\t\tconst as = info.start.arrowhead && getArrowheadPathForType(info, 'start', strokeWidth)\n\t\tconst ae = info.end.arrowhead && getArrowheadPathForType(info, 'end', strokeWidth)\n\n\t\tconst includeClipPath =\n\t\t\t(as && info.start.arrowhead !== 'arrow') ||\n\t\t\t(ae && info.end.arrowhead !== 'arrow') ||\n\t\t\t!!labelGeometry\n\n\t\tconst labelBounds = labelGeometry ? labelGeometry.getBounds() : new Box(0, 0, 0, 0)\n\n\t\tif (isEditing && labelGeometry) {\n\t\t\treturn (\n\t\t\t\t<rect\n\t\t\t\t\tx={toDomPrecision(labelBounds.x)}\n\t\t\t\t\ty={toDomPrecision(labelBounds.y)}\n\t\t\t\t\twidth={labelBounds.w}\n\t\t\t\t\theight={labelBounds.h}\n\t\t\t\t\trx={3.5 * shape.props.scale}\n\t\t\t\t\try={3.5 * shape.props.scale}\n\t\t\t\t/>\n\t\t\t)\n\t\t}\n\t\tconst clipStartArrowhead = !(\n\t\t\tinfo.start.arrowhead === 'none' || info.start.arrowhead === 'arrow'\n\t\t)\n\t\tconst clipEndArrowhead = !(info.end.arrowhead === 'none' || info.end.arrowhead === 'arrow')\n\n\t\treturn (\n\t\t\t<g>\n\t\t\t\t{includeClipPath && (\n\t\t\t\t\t<defs>\n\t\t\t\t\t\t<ArrowClipPath\n\t\t\t\t\t\t\tradius={3.5 * shape.props.scale}\n\t\t\t\t\t\t\thasText={!isEmpty}\n\t\t\t\t\t\t\tbounds={bounds}\n\t\t\t\t\t\t\tlabelBounds={labelBounds}\n\t\t\t\t\t\t\tas={clipStartArrowhead && as ? as : ''}\n\t\t\t\t\t\t\tae={clipEndArrowhead && ae ? ae : ''}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</defs>\n\t\t\t\t)}\n\t\t\t\t<g\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tclipPath: includeClipPath ? `url(#${clipPathId})` : undefined,\n\t\t\t\t\t\tWebkitClipPath: includeClipPath ? `url(#${clipPathId})` : undefined,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{/* This rect needs to be here if we're creating a mask due to an svg quirk on Chrome */}\n\t\t\t\t\t{includeClipPath && (\n\t\t\t\t\t\t<rect\n\t\t\t\t\t\t\tx={bounds.minX - 100}\n\t\t\t\t\t\t\ty={bounds.minY - 100}\n\t\t\t\t\t\t\twidth={bounds.width + 200}\n\t\t\t\t\t\t\theight={bounds.height + 200}\n\t\t\t\t\t\t\topacity={0}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{getArrowBodyPath(\n\t\t\t\t\t\tshape,\n\t\t\t\t\t\tinfo,\n\t\t\t\t\t\tshape.props.dash === 'draw'\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tstyle: 'draw',\n\t\t\t\t\t\t\t\t\trandomSeed: shape.id,\n\t\t\t\t\t\t\t\t\tstrokeWidth: 1,\n\t\t\t\t\t\t\t\t\tpasses: 1,\n\t\t\t\t\t\t\t\t\toffset: 0,\n\t\t\t\t\t\t\t\t\troundness: strokeWidth * 2,\n\t\t\t\t\t\t\t\t\tprops: { strokeWidth: undefined },\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: { style: 'solid', strokeWidth: 1, props: { strokeWidth: undefined } }\n\t\t\t\t\t)}\n\t\t\t\t</g>\n\t\t\t\t{as && <path d={as} />}\n\t\t\t\t{ae && <path d={ae} />}\n\t\t\t\t{labelGeometry && (\n\t\t\t\t\t<rect\n\t\t\t\t\t\tx={toDomPrecision(labelBounds.x)}\n\t\t\t\t\t\ty={toDomPrecision(labelBounds.y)}\n\t\t\t\t\t\twidth={labelBounds.w}\n\t\t\t\t\t\theight={labelBounds.h}\n\t\t\t\t\t\trx={3.5}\n\t\t\t\t\t\try={3.5}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</g>\n\t\t)\n\t}\n\n\toverride onEditStart(shape: TLArrowShape) {\n\t\tif (isEmptyRichText(shape.props.richText)) {\n\t\t\t// editing text for the first time, so set the position to the default:\n\t\t\tconst labelPosition = getArrowLabelDefaultPosition(this.editor, shape)\n\t\t\tthis.editor.updateShape({\n\t\t\t\tid: shape.id,\n\t\t\t\ttype: shape.type,\n\t\t\t\tprops: { labelPosition },\n\t\t\t})\n\t\t}\n\t}\n\n\toverride toSvg(shape: TLArrowShape, ctx: SvgExportContext) {\n\t\tctx.addExportDef(getFillDefForExport(shape.props.fill))\n\t\tconst theme = getDefaultColorTheme(ctx)\n\t\tconst scaleFactor = 1 / shape.props.scale\n\n\t\treturn (\n\t\t\t<g transform={`scale(${scaleFactor})`}>\n\t\t\t\t<ArrowSvg shape={shape} shouldDisplayHandles={false} />\n\t\t\t\t<RichTextSVG\n\t\t\t\t\tfontSize={getArrowLabelFontSize(shape)}\n\t\t\t\t\tfont={shape.props.font}\n\t\t\t\t\talign=\"middle\"\n\t\t\t\t\tverticalAlign=\"middle\"\n\t\t\t\t\tlabelColor={getColorValue(theme, shape.props.labelColor, 'solid')}\n\t\t\t\t\trichText={shape.props.richText}\n\t\t\t\t\tbounds={getArrowLabelPosition(this.editor, shape)\n\t\t\t\t\t\t.box.clone()\n\t\t\t\t\t\t.expandBy(-ARROW_LABEL_PADDING * shape.props.scale)}\n\t\t\t\t\tpadding={0}\n\t\t\t\t\tshowTextOutline={true}\n\t\t\t\t/>\n\t\t\t</g>\n\t\t)\n\t}\n\n\toverride getCanvasSvgDefs(): TLShapeUtilCanvasSvgDef[] {\n\t\treturn [\n\t\t\tgetFillDefForCanvas(),\n\t\t\t{\n\t\t\t\tkey: `arrow:dot`,\n\t\t\t\tcomponent: ArrowheadDotDef,\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: `arrow:cross`,\n\t\t\t\tcomponent: ArrowheadCrossDef,\n\t\t\t},\n\t\t]\n\t}\n\toverride getInterpolatedProps(\n\t\tstartShape: TLArrowShape,\n\t\tendShape: TLArrowShape,\n\t\tprogress: number\n\t): TLArrowShapeProps {\n\t\treturn {\n\t\t\t...(progress > 0.5 ? endShape.props : startShape.props),\n\t\t\tscale: lerp(startShape.props.scale, endShape.props.scale, progress),\n\t\t\tstart: {\n\t\t\t\tx: lerp(startShape.props.start.x, endShape.props.start.x, progress),\n\t\t\t\ty: lerp(startShape.props.start.y, endShape.props.start.y, progress),\n\t\t\t},\n\t\t\tend: {\n\t\t\t\tx: lerp(startShape.props.end.x, endShape.props.end.x, progress),\n\t\t\t\ty: lerp(startShape.props.end.y, endShape.props.end.y, progress),\n\t\t\t},\n\t\t\tbend: lerp(startShape.props.bend, endShape.props.bend, progress),\n\t\t\tlabelPosition: lerp(startShape.props.labelPosition, endShape.props.labelPosition, progress),\n\t\t}\n\t}\n}\n\nexport function getArrowLength(editor: Editor, shape: TLArrowShape): number {\n\tconst info = getArrowInfo(editor, shape)!\n\n\treturn info.type === 'straight'\n\t\t? Vec.Dist(info.start.handle, info.end.handle)\n\t\t: info.type === 'arc'\n\t\t\t? Math.abs(info.handleArc.length)\n\t\t\t: info.route.distance\n}\n\nconst ArrowSvg = track(function ArrowSvg({\n\tshape,\n\tshouldDisplayHandles,\n}: {\n\tshape: TLArrowShape\n\tshouldDisplayHandles: boolean\n}) {\n\tconst editor = useEditor()\n\tconst theme = useDefaultColorTheme()\n\tconst info = getArrowInfo(editor, shape)\n\tconst isForceSolid = useValue(\n\t\t'force solid',\n\t\t() => {\n\t\t\treturn editor.getZoomLevel() < 0.2\n\t\t},\n\t\t[editor]\n\t)\n\tconst clipPathId = useSharedSafeId(shape.id + '_clip')\n\tconst arrowheadDotId = useSharedSafeId('arrowhead-dot')\n\tconst arrowheadCrossId = useSharedSafeId('arrowhead-cross')\n\tconst isEditing = useIsEditing(shape.id)\n\tconst geometry = editor.getShapeGeometry(shape)\n\tif (!geometry) return null\n\tconst bounds = Box.ZeroFix(geometry.bounds)\n\tconst bindings = getArrowBindings(editor, shape)\n\tconst isEmpty = isEmptyRichText(shape.props.richText)\n\n\tif (!info?.isValid) return null\n\n\tconst strokeWidth = STROKE_SIZES[shape.props.size] * shape.props.scale\n\n\tconst as = info.start.arrowhead && getArrowheadPathForType(info, 'start', strokeWidth)\n\tconst ae = info.end.arrowhead && getArrowheadPathForType(info, 'end', strokeWidth)\n\n\tlet handlePath: null | React.JSX.Element = null\n\n\tif (shouldDisplayHandles && (bindings.start || bindings.end)) {\n\t\thandlePath = getArrowHandlePath(info, {\n\t\t\tstyle: 'dashed',\n\t\t\tstart: 'skip',\n\t\t\tend: 'skip',\n\t\t\tlengthRatio: 2.5,\n\t\t\tstrokeWidth: 2 / editor.getZoomLevel(),\n\t\t\tprops: {\n\t\t\t\tclassName: 'tl-arrow-hint',\n\t\t\t\tmarkerStart: bindings.start\n\t\t\t\t\t? bindings.start.props.isExact\n\t\t\t\t\t\t? ''\n\t\t\t\t\t\t: bindings.start.props.isPrecise\n\t\t\t\t\t\t\t? `url(#${arrowheadCrossId})`\n\t\t\t\t\t\t\t: `url(#${arrowheadDotId})`\n\t\t\t\t\t: '',\n\t\t\t\tmarkerEnd: bindings.end\n\t\t\t\t\t? bindings.end.props.isExact\n\t\t\t\t\t\t? ''\n\t\t\t\t\t\t: bindings.end.props.isPrecise\n\t\t\t\t\t\t\t? `url(#${arrowheadCrossId})`\n\t\t\t\t\t\t\t: `url(#${arrowheadDotId})`\n\t\t\t\t\t: '',\n\t\t\t\topacity: 0.16,\n\t\t\t},\n\t\t})\n\t}\n\n\tconst labelPosition = getArrowLabelPosition(editor, shape)\n\n\tconst clipStartArrowhead = !(info.start.arrowhead === 'none' || info.start.arrowhead === 'arrow')\n\tconst clipEndArrowhead = !(info.end.arrowhead === 'none' || info.end.arrowhead === 'arrow')\n\n\treturn (\n\t\t<>\n\t\t\t{/* Yep */}\n\t\t\t<defs>\n\t\t\t\t<clipPath id={clipPathId}>\n\t\t\t\t\t<ArrowClipPath\n\t\t\t\t\t\tradius={3.5 * shape.props.scale}\n\t\t\t\t\t\thasText={isEditing || !isEmpty}\n\t\t\t\t\t\tbounds={bounds}\n\t\t\t\t\t\tlabelBounds={labelPosition.box}\n\t\t\t\t\t\tas={clipStartArrowhead && as ? as : ''}\n\t\t\t\t\t\tae={clipEndArrowhead && ae ? ae : ''}\n\t\t\t\t\t/>\n\t\t\t\t</clipPath>\n\t\t\t</defs>\n\t\t\t<g\n\t\t\t\tfill=\"none\"\n\t\t\t\tstroke={getColorValue(theme, shape.props.color, 'solid')}\n\t\t\t\tstrokeWidth={strokeWidth}\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tpointerEvents=\"none\"\n\t\t\t>\n\t\t\t\t{handlePath}\n\t\t\t\t<g\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tclipPath: `url(#${clipPathId})`,\n\t\t\t\t\t\tWebkitClipPath: `url(#${clipPathId})`,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<rect\n\t\t\t\t\t\tx={toDomPrecision(bounds.minX - 100)}\n\t\t\t\t\t\ty={toDomPrecision(bounds.minY - 100)}\n\t\t\t\t\t\twidth={toDomPrecision(bounds.width + 200)}\n\t\t\t\t\t\theight={toDomPrecision(bounds.height + 200)}\n\t\t\t\t\t\topacity={0}\n\t\t\t\t\t/>\n\t\t\t\t\t{getArrowBodyPath(shape, info, {\n\t\t\t\t\t\tstyle: shape.props.dash,\n\t\t\t\t\t\tstrokeWidth,\n\t\t\t\t\t\tforceSolid: isForceSolid,\n\t\t\t\t\t\trandomSeed: shape.id,\n\t\t\t\t\t})}\n\t\t\t\t</g>\n\t\t\t\t{as && clipStartArrowhead && shape.props.fill !== 'none' && (\n\t\t\t\t\t<ShapeFill\n\t\t\t\t\t\ttheme={theme}\n\t\t\t\t\t\td={as}\n\t\t\t\t\t\tcolor={shape.props.color}\n\t\t\t\t\t\tfill={shape.props.fill}\n\t\t\t\t\t\tscale={shape.props.scale}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t{ae && clipEndArrowhead && shape.props.fill !== 'none' && (\n\t\t\t\t\t<ShapeFill\n\t\t\t\t\t\ttheme={theme}\n\t\t\t\t\t\td={ae}\n\t\t\t\t\t\tcolor={shape.props.color}\n\t\t\t\t\t\tfill={shape.props.fill}\n\t\t\t\t\t\tscale={shape.props.scale}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t{as && <path d={as} />}\n\t\t\t\t{ae && <path d={ae} />}\n\t\t\t</g>\n\t\t</>\n\t)\n})\n\nfunction ArrowClipPath({\n\tradius,\n\thasText,\n\tbounds,\n\tlabelBounds,\n\tas,\n\tae,\n}: {\n\tradius: number\n\thasText: boolean\n\tbounds: Box\n\tlabelBounds: Box\n\tas: string\n\tae: string\n}) {\n\tconst path = useMemo(() => {\n\t\t// The direction in which we create the different path parts is important, as it determines what gets clipped.\n\t\t// See the description on the directions in the non-zero fill rule example:\n\t\t// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill-rule#nonzero\n\t\tconst path = new PathBuilder()\n\n\t\t// We create this one in the clockwise direction\n\t\tpath\n\t\t\t.moveTo(bounds.left - 100, bounds.top - 100)\n\t\t\t.lineTo(bounds.right + 100, bounds.top - 100)\n\t\t\t.lineTo(bounds.right + 100, bounds.bottom + 100)\n\t\t\t.lineTo(bounds.left - 100, bounds.bottom + 100)\n\t\t\t.close()\n\n\t\tif (hasText) {\n\t\t\t// We create this one in the counter-clockwise direction, which cuts out the label box\n\t\t\tpath\n\t\t\t\t.moveTo(labelBounds.left, labelBounds.top + radius)\n\t\t\t\t.lineTo(labelBounds.left, labelBounds.bottom - radius)\n\t\t\t\t.circularArcTo(radius, false, false, labelBounds.left + radius, labelBounds.bottom)\n\t\t\t\t.lineTo(labelBounds.right - radius, labelBounds.bottom)\n\t\t\t\t.circularArcTo(radius, false, false, labelBounds.right, labelBounds.bottom - radius)\n\t\t\t\t.lineTo(labelBounds.right, labelBounds.top + radius)\n\t\t\t\t.circularArcTo(radius, false, false, labelBounds.right - radius, labelBounds.top)\n\t\t\t\t.lineTo(labelBounds.left + radius, labelBounds.top)\n\t\t\t\t.circularArcTo(radius, false, false, labelBounds.left, labelBounds.top + radius)\n\t\t\t\t.close()\n\t\t}\n\n\t\treturn path.toD()\n\t}, [\n\t\tradius,\n\t\thasText,\n\t\tbounds.bottom,\n\t\tbounds.left,\n\t\tbounds.right,\n\t\tbounds.top,\n\t\tlabelBounds.bottom,\n\t\tlabelBounds.left,\n\t\tlabelBounds.right,\n\t\tlabelBounds.top,\n\t])\n\n\t// We also append the arrowhead paths to the clip path, so that we also clip the arrowheads\n\treturn <path d={`${path}${as}${ae}`} />\n}\n\nconst shapeAtTranslationStart = new WeakMap<\n\tTLArrowShape,\n\t{\n\t\tpagePosition: Vec\n\t\tterminalBindings: Record<\n\t\t\t'start' | 'end',\n\t\t\t{\n\t\t\t\tpagePosition: Vec\n\t\t\t\tshapePosition: Vec\n\t\t\t\tbinding: TLArrowBinding\n\t\t\t} | null\n\t\t>\n\t}\n>()\n\nfunction ArrowheadDotDef() {\n\tconst id = useSharedSafeId('arrowhead-dot')\n\treturn (\n\t\t<marker id={id} className=\"tl-arrow-hint\" refX=\"3.0\" refY=\"3.0\" orient=\"0\">\n\t\t\t<circle cx=\"3\" cy=\"3\" r=\"2\" strokeDasharray=\"100%\" />\n\t\t</marker>\n\t)\n}\n\nfunction ArrowheadCrossDef() {\n\tconst id = useSharedSafeId('arrowhead-cross')\n\treturn (\n\t\t<marker id={id} className=\"tl-arrow-hint\" refX=\"3.0\" refY=\"3.0\" orient=\"auto\">\n\t\t\t<line x1=\"1.5\" y1=\"1.5\" x2=\"4.5\" y2=\"4.5\" strokeDasharray=\"100%\" />\n\t\t\t<line x1=\"1.5\" y1=\"4.5\" x2=\"4.5\" y2=\"1.5\" strokeDasharray=\"100%\" />\n\t\t</marker>\n\t)\n}\n\n/**\n * Take 2 angles and return true if they are approximately parallel. Angle that point in the same\n * (or opposite) directions are considered parallel. This also handles wrap around - e.g. 0, \u03C0, and\n * 2\u03C0 are all considered parallel.\n */\nfunction anglesAreApproximatelyParallel(a: number, b: number, tolerance = 0.0001) {\n\tconst diff = Math.abs(a - b)\n\n\tconst isParallel = diff < tolerance\n\tconst isFlippedParallel = Math.abs(diff - Math.PI) < tolerance\n\tconst is360Parallel = Math.abs(diff - PI2) < tolerance\n\n\treturn { isParallel: isParallel || is360Parallel, isFlippedParallel }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAowBG;AApwBH,oBA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WAAU,iBAAgB,MAAK,OAAM,MAAK,OAAM,QAAO,QACtE;AAAA,gDAAC,UAAK,IAAG,OAAM,IAAG,OAAM,IAAG,OAAM,IAAG,OAAM,iBAAgB,QAAO;AAAA,IACjE,4CAAC,UAAK,IAAG,OAAM,IAAG,OAAM,IAAG,OAAM,IAAG,OAAM,iBAAgB,QAAO;AAAA,KAClE;AAEF;AAOA,SAAS,+BAA+B,GAAW,GAAW,YAAY,MAAQ;AACjF,QAAM,OAAO,KAAK,IAAI,IAAI,CAAC;AAE3B,QAAM,aAAa,OAAO;AAC1B,QAAM,oBAAoB,KAAK,IAAI,OAAO,KAAK,EAAE,IAAI;AACrD,QAAM,gBAAgB,KAAK,IAAI,OAAO,iBAAG,IAAI;AAE7C,SAAO,EAAE,YAAY,cAAc,eAAe,kBAAkB;AACrE;",
|
|
6
6
|
"names": ["ArrowHandles", "ArrowSvg", "path"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/shapes/arrow/arrowLabel.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tArc2d,\n\tBox,\n\tCircle2d,\n\tEdge2d,\n\tEditor,\n\tGeometry2d,\n\tGroup2d,\n\tPolygon2d,\n\tPolyline2d,\n\tTLArrowShape,\n\tTLShape,\n\tVec,\n\tVecLike,\n\tclamp,\n\tcreateComputedCache,\n\texhaustiveSwitchError,\n\tgetChangedKeys,\n\tpointInPolygon,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { isEmptyRichText, renderHtmlFromRichTextForMeasurement } from '../../utils/text/richText'\nimport {\n\tARROW_LABEL_FONT_SIZES,\n\tARROW_LABEL_PADDING,\n\tFONT_FAMILIES,\n\tLABEL_TO_ARROW_PADDING,\n\tSTROKE_SIZES,\n\tTEXT_PROPS,\n} from '../shared/default-shape-constants'\nimport { TLArrowInfo } from './arrow-types'\nimport { getArrowInfo } from './shared'\n\nexport function getArrowBodyGeometry(editor: Editor, shape: TLArrowShape) {\n\tconst info = getArrowInfo(editor, shape)!\n\tswitch (info.type) {\n\t\tcase 'straight':\n\t\t\treturn new Edge2d({\n\t\t\t\tstart: Vec.From(info.start.point),\n\t\t\t\tend: Vec.From(info.end.point),\n\t\t\t})\n\t\tcase 'arc':\n\t\t\treturn new Arc2d({\n\t\t\t\tcenter: Vec.Cast(info.handleArc.center),\n\t\t\t\tstart: Vec.Cast(info.start.point),\n\t\t\t\tend: Vec.Cast(info.end.point),\n\t\t\t\tsweepFlag: info.bodyArc.sweepFlag,\n\t\t\t\tlargeArcFlag: info.bodyArc.largeArcFlag,\n\t\t\t})\n\t\tcase 'elbow':\n\t\t\treturn new Polyline2d({ points: info.route.points })\n\t\tdefault:\n\t\t\texhaustiveSwitchError(info, 'type')\n\t}\n}\n\nconst labelSizeCache = createComputedCache(\n\t'arrow label size',\n\t(editor: Editor, shape: TLArrowShape) => {\n\t\teditor.fonts.trackFontsForShape(shape)\n\t\tlet width = 0\n\t\tlet height = 0\n\n\t\tconst bodyGeom = getArrowBodyGeometry(editor, shape)\n\t\t// We use 'i' as a default label to measure against as a minimum width.\n\t\tconst isEmpty = isEmptyRichText(shape.props.richText)\n\t\tconst html = renderHtmlFromRichTextForMeasurement(\n\t\t\teditor,\n\t\t\tisEmpty ? toRichText('i') : shape.props.richText\n\t\t)\n\n\t\tconst bodyBounds = bodyGeom.bounds\n\n\t\tconst fontSize = getArrowLabelFontSize(shape)\n\n\t\t// First we measure the text with no constraints\n\t\tconst { w, h } = editor.textMeasure.measureHtml(html, {\n\t\t\t...TEXT_PROPS,\n\t\t\tfontFamily: FONT_FAMILIES[shape.props.font],\n\t\t\tfontSize,\n\t\t\tmaxWidth: null,\n\t\t})\n\n\t\twidth = w\n\t\theight = h\n\n\t\tlet shouldSquish = false\n\n\t\t// If the text is wider than the body, we need to squish it\n\t\tconst info = getArrowInfo(editor, shape)!\n\t\tconst labelToArrowPadding = getLabelToArrowPadding(shape)\n\t\tconst margin =\n\t\t\tinfo.type === 'elbow'\n\t\t\t\t? Math.max(info.elbow.A.arrowheadOffset + labelToArrowPadding, 32) +\n\t\t\t\t\tMath.max(info.elbow.B.arrowheadOffset + labelToArrowPadding, 32)\n\t\t\t\t: 64\n\n\t\tif (bodyBounds.width > bodyBounds.height) {\n\t\t\twidth = Math.max(Math.min(w, margin), Math.min(bodyBounds.width - margin, w))\n\t\t\tshouldSquish = true\n\t\t} else if (width > 16 * fontSize) {\n\t\t\twidth = 16 * fontSize\n\t\t\tshouldSquish = true\n\t\t}\n\n\t\tif (shouldSquish) {\n\t\t\tconst { w: squishedWidth, h: squishedHeight } = editor.textMeasure.measureHtml(html, {\n\t\t\t\t...TEXT_PROPS,\n\t\t\t\tfontFamily: FONT_FAMILIES[shape.props.font],\n\t\t\t\tfontSize,\n\t\t\t\tmaxWidth: width,\n\t\t\t})\n\n\t\t\twidth = squishedWidth\n\t\t\theight = squishedHeight\n\t\t}\n\n\t\treturn new Vec(width, height).addScalar(ARROW_LABEL_PADDING * 2 * shape.props.scale)\n\t},\n\t{\n\t\tareRecordsEqual: (a, b) => {\n\t\t\tif (a.props === b.props) return true\n\n\t\t\t// If the only thing that has changed is the label position, we can skip recalculating the size\n\t\t\tconst changedKeys = getChangedKeys(a.props, b.props)\n\t\t\treturn changedKeys.length === 1 && changedKeys[0] === 'labelPosition'\n\t\t},\n\t}\n)\n\nfunction getArrowLabelSize(editor: Editor, shape: TLArrowShape) {\n\treturn labelSizeCache.get(editor, shape.id) ?? new Vec(0, 0)\n}\n\nfunction getLabelToArrowPadding(shape: TLArrowShape) {\n\tconst strokeWidth = STROKE_SIZES[shape.props.size]\n\tconst labelToArrowPadding =\n\t\t(LABEL_TO_ARROW_PADDING +\n\t\t\t(strokeWidth - STROKE_SIZES.s) * 2 +\n\t\t\t(strokeWidth === STROKE_SIZES.xl ? 20 : 0)) *\n\t\tshape.props.scale\n\n\treturn labelToArrowPadding\n}\n\n/**\n * Return the range of possible label positions for an arrow. The full possible range is 0 to 1, but\n * as the label itself takes up space the usable range is smaller.\n */\nfunction getArrowLabelRange(editor: Editor, shape: TLArrowShape, info: TLArrowInfo) {\n\tconst bodyGeom = getArrowBodyGeometry(editor, shape)\n\tconst dbgPoints: VecLike[] = []\n\tconst dbg: Geometry2d[] = [new Group2d({ children: [bodyGeom], debugColor: 'lime' })]\n\n\tconst labelSize = getArrowLabelSize(editor, shape)\n\tconst labelToArrowPadding = getLabelToArrowPadding(shape)\n\tconst paddingRelative = labelToArrowPadding / bodyGeom.length\n\n\t// we can calculate the range by sticking the center of the label at the very start/end of the\n\t// arrow, and seeing where the label intersects with the arrow. Then, if we move the label's\n\t// center to that point, that'll be the start/end of the range.\n\n\tlet startBox, endBox\n\tif (info.type === 'elbow') {\n\t\t// for elbow arrows, because they have multiple segments but are always axis-aligned, we can use\n\t\t// an expanded box. This helps keep the box from partially covering the first segment when it's\n\t\t// very small.\n\t\tdbgPoints.push(info.start.point, info.end.point)\n\t\tstartBox = Box.FromCenter(info.start.point, labelSize).expandBy(labelToArrowPadding)\n\t\tendBox = Box.FromCenter(info.end.point, labelSize).expandBy(labelToArrowPadding)\n\t} else {\n\t\t// for other arrows, we move along the arrow by the padding amount to find the start/end points\n\t\tconst startPoint = bodyGeom.interpolateAlongEdge(paddingRelative)\n\t\tconst endPoint = bodyGeom.interpolateAlongEdge(1 - paddingRelative)\n\t\tdbgPoints.push(startPoint, endPoint)\n\t\tstartBox = Box.FromCenter(startPoint, labelSize)\n\t\tendBox = Box.FromCenter(endPoint, labelSize)\n\t}\n\tconst startIntersections = bodyGeom.intersectPolygon(startBox.corners)\n\tconst endIntersections = bodyGeom.intersectPolygon(endBox.corners)\n\n\tconst startConstrained = furthest(info.start.point, startIntersections)\n\tconst endConstrained = furthest(info.end.point, endIntersections)\n\n\tlet startRelative = startConstrained ? bodyGeom.uninterpolateAlongEdge(startConstrained) : 0.5\n\tlet endRelative = endConstrained ? bodyGeom.uninterpolateAlongEdge(endConstrained) : 0.5\n\n\tif (startRelative > endRelative) {\n\t\tstartRelative = 0.5\n\t\tendRelative = 0.5\n\t}\n\n\tfor (const pt of [...startIntersections, ...endIntersections, ...dbgPoints]) {\n\t\tdbg.push(\n\t\t\tnew Circle2d({\n\t\t\t\tx: pt.x - 3,\n\t\t\t\ty: pt.y - 3,\n\t\t\t\tradius: 3,\n\t\t\t\tisFilled: false,\n\t\t\t\tdebugColor: 'magenta',\n\t\t\t\tignore: true,\n\t\t\t})\n\t\t)\n\t}\n\tdbg.push(\n\t\tnew Polygon2d({\n\t\t\tpoints: startBox.corners,\n\t\t\tdebugColor: 'lime',\n\t\t\tisFilled: false,\n\t\t\tignore: true,\n\t\t}),\n\t\tnew Polygon2d({\n\t\t\tpoints: endBox.corners,\n\t\t\tdebugColor: 'lime',\n\t\t\tisFilled: false,\n\t\t\tignore: true,\n\t\t})\n\t)\n\n\treturn { start: startRelative, end: endRelative, dbg }\n}\n\ninterface ArrowheadInfo {\n\thasStartBinding: boolean\n\thasEndBinding: boolean\n\thasStartArrowhead: boolean\n\thasEndArrowhead: boolean\n}\nexport function getArrowLabelPosition(editor: Editor, shape: TLArrowShape) {\n\tconst isEditing = editor.getEditingShapeId() === shape.id\n\tif (!isEditing && isEmptyRichText(shape.props.richText)) {\n\t\t// Short-circuit for empty labels.\n\t\tconst bodyGeom = getArrowBodyGeometry(editor, shape)\n\t\tconst labelCenter = bodyGeom.interpolateAlongEdge(0.5)\n\t\treturn { box: Box.FromCenter(labelCenter, new Vec(0, 0)), debugGeom: [] }\n\t}\n\n\tconst debugGeom: Geometry2d[] = []\n\tconst info = getArrowInfo(editor, shape)!\n\n\tconst arrowheadInfo: ArrowheadInfo = {\n\t\thasStartBinding: !!info.bindings.start,\n\t\thasEndBinding: !!info.bindings.end,\n\t\thasStartArrowhead: info.start.arrowhead !== 'none',\n\t\thasEndArrowhead: info.end.arrowhead !== 'none',\n\t}\n\n\tconst range = getArrowLabelRange(editor, shape, info)\n\tif (range.dbg) debugGeom.push(...range.dbg)\n\n\tconst clampedPosition = getClampedPosition(shape, range, arrowheadInfo)\n\tconst bodyGeom = getArrowBodyGeometry(editor, shape)\n\tconst labelCenter = bodyGeom.interpolateAlongEdge(clampedPosition)\n\tconst labelSize = getArrowLabelSize(editor, shape)\n\n\treturn { box: Box.FromCenter(labelCenter, labelSize), debugGeom }\n}\n\nfunction getClampedPosition(\n\tshape: TLArrowShape,\n\trange: { start: number; end: number },\n\tarrowheadInfo: ArrowheadInfo\n) {\n\tconst { hasEndArrowhead, hasEndBinding, hasStartBinding, hasStartArrowhead } = arrowheadInfo\n\tconst clampedPosition = clamp(\n\t\tshape.props.labelPosition,\n\t\thasStartArrowhead || hasStartBinding ? range.start : 0,\n\t\thasEndArrowhead || hasEndBinding ? range.end : 1\n\t)\n\n\treturn clampedPosition\n}\n\nfunction furthest(from: VecLike, candidates: VecLike[]): VecLike | null {\n\tlet furthest: VecLike | null = null\n\tlet furthestDist = -Infinity\n\n\tfor (const candidate of candidates) {\n\t\tconst dist = Vec.Dist2(from, candidate)\n\t\tif (dist > furthestDist) {\n\t\t\tfurthest = candidate\n\t\t\tfurthestDist = dist\n\t\t}\n\t}\n\n\treturn furthest\n}\n\nexport function getArrowLabelFontSize(shape: TLArrowShape) {\n\treturn ARROW_LABEL_FONT_SIZES[shape.props.size] * shape.props.scale\n}\n\nexport function getArrowLabelDefaultPosition(editor: Editor, shape: TLArrowShape) {\n\tconst info = getArrowInfo(editor, shape)!\n\tswitch (info.type) {\n\t\tcase 'straight':\n\t\tcase 'arc':\n\t\t\treturn 0.5\n\t\tcase 'elbow': {\n\t\t\tconst midpointHandle = info.route.midpointHandle\n\t\t\tconst bodyGeom = getArrowBodyGeometry(editor, shape)\n\t\t\tif (midpointHandle && bodyGeom) {\n\t\t\t\treturn bodyGeom.uninterpolateAlongEdge(midpointHandle.point)\n\t\t\t}\n\t\t\treturn 0.5\n\t\t}\n\t\tdefault:\n\t\t\texhaustiveSwitchError(info, 'type')\n\t}\n}\n\n/** @internal */\nexport function isOverArrowLabel(editor: Editor, shape: TLShape) {\n\tif (!editor.isShapeOfType<TLArrowShape>(shape, 'arrow')) return false\n\n\tconst pointInShapeSpace = editor.getPointInShapeSpace(shape, editor.inputs.currentPagePoint)\n\t// How should we handle multiple labels? Do shapes ever have multiple labels?\n\tconst labelGeometry = editor.getShapeGeometry<Group2d>(shape).children[1]\n\t// Knowing what we know about arrows... if the shape has no text in its label,\n\t// then the label geometry should not be there.\n\treturn labelGeometry && pointInPolygon(pointInShapeSpace, labelGeometry.vertices)\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAoBO;AACP,sBAAsE;AACtE,qCAOO;AAEP,oBAA6B;AAEtB,SAAS,qBAAqB,QAAgB,OAAqB;AACzE,QAAM,WAAO,4BAAa,QAAQ,KAAK;AACvC,UAAQ,KAAK,MAAM;AAAA,IAClB,KAAK;AACJ,aAAO,IAAI,qBAAO;AAAA,QACjB,OAAO,kBAAI,KAAK,KAAK,MAAM,KAAK;AAAA,QAChC,KAAK,kBAAI,KAAK,KAAK,IAAI,KAAK;AAAA,MAC7B,CAAC;AAAA,IACF,KAAK;AACJ,aAAO,IAAI,oBAAM;AAAA,QAChB,QAAQ,kBAAI,KAAK,KAAK,UAAU,MAAM;AAAA,QACtC,OAAO,kBAAI,KAAK,KAAK,MAAM,KAAK;AAAA,QAChC,KAAK,kBAAI,KAAK,KAAK,IAAI,KAAK;AAAA,QAC5B,WAAW,KAAK,QAAQ;AAAA,QACxB,cAAc,KAAK,QAAQ;AAAA,MAC5B,CAAC;AAAA,IACF,KAAK;AACJ,aAAO,IAAI,yBAAW,EAAE,QAAQ,KAAK,MAAM,OAAO,CAAC;AAAA,IACpD;AACC,+CAAsB,MAAM,MAAM;AAAA,EACpC;AACD;AAEA,MAAM,qBAAiB;AAAA,EACtB;AAAA,EACA,CAAC,QAAgB,UAA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W;AACX,qBAAe;AAAA,IAChB;AAAA,EACD;AAEA,SAAOA;AACR;AAEO,SAAS,sBAAsB,OAAqB;AAC1D,SAAO,sDAAuB,MAAM,MAAM,IAAI,IAAI,MAAM,MAAM;AAC/D;AAEO,SAAS,6BAA6B,QAAgB,OAAqB;AACjF,QAAM,WAAO,4BAAa,QAAQ,KAAK;AACvC,UAAQ,KAAK,MAAM;AAAA,IAClB,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR,KAAK,SAAS;AACb,YAAM,iBAAiB,KAAK,MAAM;AAClC,YAAM,WAAW,qBAAqB,QAAQ,KAAK;AACnD,UAAI,kBAAkB,UAAU;AAC/B,eAAO,SAAS,uBAAuB,eAAe,KAAK;AAAA,MAC5D;AACA,aAAO;AAAA,IACR;AAAA,IACA;AACC,+CAAsB,MAAM,MAAM;AAAA,EACpC;AACD;AAGO,SAAS,iBAAiB,QAAgB,OAAgB;AAChE,MAAI,CAAC,OAAO,
|
|
4
|
+
"sourcesContent": ["import {\n\tArc2d,\n\tBox,\n\tCircle2d,\n\tEdge2d,\n\tEditor,\n\tGeometry2d,\n\tGroup2d,\n\tPolygon2d,\n\tPolyline2d,\n\tTLArrowShape,\n\tTLShape,\n\tVec,\n\tVecLike,\n\tclamp,\n\tcreateComputedCache,\n\texhaustiveSwitchError,\n\tgetChangedKeys,\n\tpointInPolygon,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { isEmptyRichText, renderHtmlFromRichTextForMeasurement } from '../../utils/text/richText'\nimport {\n\tARROW_LABEL_FONT_SIZES,\n\tARROW_LABEL_PADDING,\n\tFONT_FAMILIES,\n\tLABEL_TO_ARROW_PADDING,\n\tSTROKE_SIZES,\n\tTEXT_PROPS,\n} from '../shared/default-shape-constants'\nimport { TLArrowInfo } from './arrow-types'\nimport { getArrowInfo } from './shared'\n\nexport function getArrowBodyGeometry(editor: Editor, shape: TLArrowShape) {\n\tconst info = getArrowInfo(editor, shape)!\n\tswitch (info.type) {\n\t\tcase 'straight':\n\t\t\treturn new Edge2d({\n\t\t\t\tstart: Vec.From(info.start.point),\n\t\t\t\tend: Vec.From(info.end.point),\n\t\t\t})\n\t\tcase 'arc':\n\t\t\treturn new Arc2d({\n\t\t\t\tcenter: Vec.Cast(info.handleArc.center),\n\t\t\t\tstart: Vec.Cast(info.start.point),\n\t\t\t\tend: Vec.Cast(info.end.point),\n\t\t\t\tsweepFlag: info.bodyArc.sweepFlag,\n\t\t\t\tlargeArcFlag: info.bodyArc.largeArcFlag,\n\t\t\t})\n\t\tcase 'elbow':\n\t\t\treturn new Polyline2d({ points: info.route.points })\n\t\tdefault:\n\t\t\texhaustiveSwitchError(info, 'type')\n\t}\n}\n\nconst labelSizeCache = createComputedCache(\n\t'arrow label size',\n\t(editor: Editor, shape: TLArrowShape) => {\n\t\teditor.fonts.trackFontsForShape(shape)\n\t\tlet width = 0\n\t\tlet height = 0\n\n\t\tconst bodyGeom = getArrowBodyGeometry(editor, shape)\n\t\t// We use 'i' as a default label to measure against as a minimum width.\n\t\tconst isEmpty = isEmptyRichText(shape.props.richText)\n\t\tconst html = renderHtmlFromRichTextForMeasurement(\n\t\t\teditor,\n\t\t\tisEmpty ? toRichText('i') : shape.props.richText\n\t\t)\n\n\t\tconst bodyBounds = bodyGeom.bounds\n\n\t\tconst fontSize = getArrowLabelFontSize(shape)\n\n\t\t// First we measure the text with no constraints\n\t\tconst { w, h } = editor.textMeasure.measureHtml(html, {\n\t\t\t...TEXT_PROPS,\n\t\t\tfontFamily: FONT_FAMILIES[shape.props.font],\n\t\t\tfontSize,\n\t\t\tmaxWidth: null,\n\t\t})\n\n\t\twidth = w\n\t\theight = h\n\n\t\tlet shouldSquish = false\n\n\t\t// If the text is wider than the body, we need to squish it\n\t\tconst info = getArrowInfo(editor, shape)!\n\t\tconst labelToArrowPadding = getLabelToArrowPadding(shape)\n\t\tconst margin =\n\t\t\tinfo.type === 'elbow'\n\t\t\t\t? Math.max(info.elbow.A.arrowheadOffset + labelToArrowPadding, 32) +\n\t\t\t\t\tMath.max(info.elbow.B.arrowheadOffset + labelToArrowPadding, 32)\n\t\t\t\t: 64\n\n\t\tif (bodyBounds.width > bodyBounds.height) {\n\t\t\twidth = Math.max(Math.min(w, margin), Math.min(bodyBounds.width - margin, w))\n\t\t\tshouldSquish = true\n\t\t} else if (width > 16 * fontSize) {\n\t\t\twidth = 16 * fontSize\n\t\t\tshouldSquish = true\n\t\t}\n\n\t\tif (shouldSquish) {\n\t\t\tconst { w: squishedWidth, h: squishedHeight } = editor.textMeasure.measureHtml(html, {\n\t\t\t\t...TEXT_PROPS,\n\t\t\t\tfontFamily: FONT_FAMILIES[shape.props.font],\n\t\t\t\tfontSize,\n\t\t\t\tmaxWidth: width,\n\t\t\t})\n\n\t\t\twidth = squishedWidth\n\t\t\theight = squishedHeight\n\t\t}\n\n\t\treturn new Vec(width, height).addScalar(ARROW_LABEL_PADDING * 2 * shape.props.scale)\n\t},\n\t{\n\t\tareRecordsEqual: (a, b) => {\n\t\t\tif (a.props === b.props) return true\n\n\t\t\t// If the only thing that has changed is the label position, we can skip recalculating the size\n\t\t\tconst changedKeys = getChangedKeys(a.props, b.props)\n\t\t\treturn changedKeys.length === 1 && changedKeys[0] === 'labelPosition'\n\t\t},\n\t}\n)\n\nfunction getArrowLabelSize(editor: Editor, shape: TLArrowShape) {\n\treturn labelSizeCache.get(editor, shape.id) ?? new Vec(0, 0)\n}\n\nfunction getLabelToArrowPadding(shape: TLArrowShape) {\n\tconst strokeWidth = STROKE_SIZES[shape.props.size]\n\tconst labelToArrowPadding =\n\t\t(LABEL_TO_ARROW_PADDING +\n\t\t\t(strokeWidth - STROKE_SIZES.s) * 2 +\n\t\t\t(strokeWidth === STROKE_SIZES.xl ? 20 : 0)) *\n\t\tshape.props.scale\n\n\treturn labelToArrowPadding\n}\n\n/**\n * Return the range of possible label positions for an arrow. The full possible range is 0 to 1, but\n * as the label itself takes up space the usable range is smaller.\n */\nfunction getArrowLabelRange(editor: Editor, shape: TLArrowShape, info: TLArrowInfo) {\n\tconst bodyGeom = getArrowBodyGeometry(editor, shape)\n\tconst dbgPoints: VecLike[] = []\n\tconst dbg: Geometry2d[] = [new Group2d({ children: [bodyGeom], debugColor: 'lime' })]\n\n\tconst labelSize = getArrowLabelSize(editor, shape)\n\tconst labelToArrowPadding = getLabelToArrowPadding(shape)\n\tconst paddingRelative = labelToArrowPadding / bodyGeom.length\n\n\t// we can calculate the range by sticking the center of the label at the very start/end of the\n\t// arrow, and seeing where the label intersects with the arrow. Then, if we move the label's\n\t// center to that point, that'll be the start/end of the range.\n\n\tlet startBox, endBox\n\tif (info.type === 'elbow') {\n\t\t// for elbow arrows, because they have multiple segments but are always axis-aligned, we can use\n\t\t// an expanded box. This helps keep the box from partially covering the first segment when it's\n\t\t// very small.\n\t\tdbgPoints.push(info.start.point, info.end.point)\n\t\tstartBox = Box.FromCenter(info.start.point, labelSize).expandBy(labelToArrowPadding)\n\t\tendBox = Box.FromCenter(info.end.point, labelSize).expandBy(labelToArrowPadding)\n\t} else {\n\t\t// for other arrows, we move along the arrow by the padding amount to find the start/end points\n\t\tconst startPoint = bodyGeom.interpolateAlongEdge(paddingRelative)\n\t\tconst endPoint = bodyGeom.interpolateAlongEdge(1 - paddingRelative)\n\t\tdbgPoints.push(startPoint, endPoint)\n\t\tstartBox = Box.FromCenter(startPoint, labelSize)\n\t\tendBox = Box.FromCenter(endPoint, labelSize)\n\t}\n\tconst startIntersections = bodyGeom.intersectPolygon(startBox.corners)\n\tconst endIntersections = bodyGeom.intersectPolygon(endBox.corners)\n\n\tconst startConstrained = furthest(info.start.point, startIntersections)\n\tconst endConstrained = furthest(info.end.point, endIntersections)\n\n\tlet startRelative = startConstrained ? bodyGeom.uninterpolateAlongEdge(startConstrained) : 0.5\n\tlet endRelative = endConstrained ? bodyGeom.uninterpolateAlongEdge(endConstrained) : 0.5\n\n\tif (startRelative > endRelative) {\n\t\tstartRelative = 0.5\n\t\tendRelative = 0.5\n\t}\n\n\tfor (const pt of [...startIntersections, ...endIntersections, ...dbgPoints]) {\n\t\tdbg.push(\n\t\t\tnew Circle2d({\n\t\t\t\tx: pt.x - 3,\n\t\t\t\ty: pt.y - 3,\n\t\t\t\tradius: 3,\n\t\t\t\tisFilled: false,\n\t\t\t\tdebugColor: 'magenta',\n\t\t\t\tignore: true,\n\t\t\t})\n\t\t)\n\t}\n\tdbg.push(\n\t\tnew Polygon2d({\n\t\t\tpoints: startBox.corners,\n\t\t\tdebugColor: 'lime',\n\t\t\tisFilled: false,\n\t\t\tignore: true,\n\t\t}),\n\t\tnew Polygon2d({\n\t\t\tpoints: endBox.corners,\n\t\t\tdebugColor: 'lime',\n\t\t\tisFilled: false,\n\t\t\tignore: true,\n\t\t})\n\t)\n\n\treturn { start: startRelative, end: endRelative, dbg }\n}\n\ninterface ArrowheadInfo {\n\thasStartBinding: boolean\n\thasEndBinding: boolean\n\thasStartArrowhead: boolean\n\thasEndArrowhead: boolean\n}\nexport function getArrowLabelPosition(editor: Editor, shape: TLArrowShape) {\n\tconst isEditing = editor.getEditingShapeId() === shape.id\n\tif (!isEditing && isEmptyRichText(shape.props.richText)) {\n\t\t// Short-circuit for empty labels.\n\t\tconst bodyGeom = getArrowBodyGeometry(editor, shape)\n\t\tconst labelCenter = bodyGeom.interpolateAlongEdge(0.5)\n\t\treturn { box: Box.FromCenter(labelCenter, new Vec(0, 0)), debugGeom: [] }\n\t}\n\n\tconst debugGeom: Geometry2d[] = []\n\tconst info = getArrowInfo(editor, shape)!\n\n\tconst arrowheadInfo: ArrowheadInfo = {\n\t\thasStartBinding: !!info.bindings.start,\n\t\thasEndBinding: !!info.bindings.end,\n\t\thasStartArrowhead: info.start.arrowhead !== 'none',\n\t\thasEndArrowhead: info.end.arrowhead !== 'none',\n\t}\n\n\tconst range = getArrowLabelRange(editor, shape, info)\n\tif (range.dbg) debugGeom.push(...range.dbg)\n\n\tconst clampedPosition = getClampedPosition(shape, range, arrowheadInfo)\n\tconst bodyGeom = getArrowBodyGeometry(editor, shape)\n\tconst labelCenter = bodyGeom.interpolateAlongEdge(clampedPosition)\n\tconst labelSize = getArrowLabelSize(editor, shape)\n\n\treturn { box: Box.FromCenter(labelCenter, labelSize), debugGeom }\n}\n\nfunction getClampedPosition(\n\tshape: TLArrowShape,\n\trange: { start: number; end: number },\n\tarrowheadInfo: ArrowheadInfo\n) {\n\tconst { hasEndArrowhead, hasEndBinding, hasStartBinding, hasStartArrowhead } = arrowheadInfo\n\tconst clampedPosition = clamp(\n\t\tshape.props.labelPosition,\n\t\thasStartArrowhead || hasStartBinding ? range.start : 0,\n\t\thasEndArrowhead || hasEndBinding ? range.end : 1\n\t)\n\n\treturn clampedPosition\n}\n\nfunction furthest(from: VecLike, candidates: VecLike[]): VecLike | null {\n\tlet furthest: VecLike | null = null\n\tlet furthestDist = -Infinity\n\n\tfor (const candidate of candidates) {\n\t\tconst dist = Vec.Dist2(from, candidate)\n\t\tif (dist > furthestDist) {\n\t\t\tfurthest = candidate\n\t\t\tfurthestDist = dist\n\t\t}\n\t}\n\n\treturn furthest\n}\n\nexport function getArrowLabelFontSize(shape: TLArrowShape) {\n\treturn ARROW_LABEL_FONT_SIZES[shape.props.size] * shape.props.scale\n}\n\nexport function getArrowLabelDefaultPosition(editor: Editor, shape: TLArrowShape) {\n\tconst info = getArrowInfo(editor, shape)!\n\tswitch (info.type) {\n\t\tcase 'straight':\n\t\tcase 'arc':\n\t\t\treturn 0.5\n\t\tcase 'elbow': {\n\t\t\tconst midpointHandle = info.route.midpointHandle\n\t\t\tconst bodyGeom = getArrowBodyGeometry(editor, shape)\n\t\t\tif (midpointHandle && bodyGeom) {\n\t\t\t\treturn bodyGeom.uninterpolateAlongEdge(midpointHandle.point)\n\t\t\t}\n\t\t\treturn 0.5\n\t\t}\n\t\tdefault:\n\t\t\texhaustiveSwitchError(info, 'type')\n\t}\n}\n\n/** @internal */\nexport function isOverArrowLabel(editor: Editor, shape: TLShape) {\n\tif (!editor.isShapeOfType(shape, 'arrow')) return false\n\n\tconst pointInShapeSpace = editor.getPointInShapeSpace(shape, editor.inputs.currentPagePoint)\n\t// How should we handle multiple labels? Do shapes ever have multiple labels?\n\tconst labelGeometry = editor.getShapeGeometry<Group2d>(shape).children[1]\n\t// Knowing what we know about arrows... if the shape has no text in its label,\n\t// then the label geometry should not be there.\n\treturn labelGeometry && pointInPolygon(pointInShapeSpace, labelGeometry.vertices)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAoBO;AACP,sBAAsE;AACtE,qCAOO;AAEP,oBAA6B;AAEtB,SAAS,qBAAqB,QAAgB,OAAqB;AACzE,QAAM,WAAO,4BAAa,QAAQ,KAAK;AACvC,UAAQ,KAAK,MAAM;AAAA,IAClB,KAAK;AACJ,aAAO,IAAI,qBAAO;AAAA,QACjB,OAAO,kBAAI,KAAK,KAAK,MAAM,KAAK;AAAA,QAChC,KAAK,kBAAI,KAAK,KAAK,IAAI,KAAK;AAAA,MAC7B,CAAC;AAAA,IACF,KAAK;AACJ,aAAO,IAAI,oBAAM;AAAA,QAChB,QAAQ,kBAAI,KAAK,KAAK,UAAU,MAAM;AAAA,QACtC,OAAO,kBAAI,KAAK,KAAK,MAAM,KAAK;AAAA,QAChC,KAAK,kBAAI,KAAK,KAAK,IAAI,KAAK;AAAA,QAC5B,WAAW,KAAK,QAAQ;AAAA,QACxB,cAAc,KAAK,QAAQ;AAAA,MAC5B,CAAC;AAAA,IACF,KAAK;AACJ,aAAO,IAAI,yBAAW,EAAE,QAAQ,KAAK,MAAM,OAAO,CAAC;AAAA,IACpD;AACC,+CAAsB,MAAM,MAAM;AAAA,EACpC;AACD;AAEA,MAAM,qBAAiB;AAAA,EACtB;AAAA,EACA,CAAC,QAAgB,UAAwB;AACxC,WAAO,MAAM,mBAAmB,KAAK;AACrC,QAAI,QAAQ;AACZ,QAAI,SAAS;AAEb,UAAM,WAAW,qBAAqB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AAuB,MAAM,MAAM,IAAI,IAAI,MAAM,MAAM;AAC/D;AAEO,SAAS,6BAA6B,QAAgB,OAAqB;AACjF,QAAM,WAAO,4BAAa,QAAQ,KAAK;AACvC,UAAQ,KAAK,MAAM;AAAA,IAClB,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR,KAAK,SAAS;AACb,YAAM,iBAAiB,KAAK,MAAM;AAClC,YAAM,WAAW,qBAAqB,QAAQ,KAAK;AACnD,UAAI,kBAAkB,UAAU;AAC/B,eAAO,SAAS,uBAAuB,eAAe,KAAK;AAAA,MAC5D;AACA,aAAO;AAAA,IACR;AAAA,IACA;AACC,+CAAsB,MAAM,MAAM;AAAA,EACpC;AACD;AAGO,SAAS,iBAAiB,QAAgB,OAAgB;AAChE,MAAI,CAAC,OAAO,cAAc,OAAO,OAAO,EAAG,QAAO;AAElD,QAAM,oBAAoB,OAAO,qBAAqB,OAAO,OAAO,OAAO,gBAAgB;AAE3F,QAAM,gBAAgB,OAAO,iBAA0B,KAAK,EAAE,SAAS,CAAC;AAGxE,SAAO,qBAAiB,8BAAe,mBAAmB,cAAc,QAAQ;AACjF;",
|
|
6
6
|
"names": ["bodyGeom", "labelCenter", "furthest"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/shapes/arrow/arrowTargetState.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tArrowShapeKindStyle,\n\tatom,\n\tAtom,\n\tBox,\n\tclamp,\n\tEditor,\n\tElbowArrowSnap,\n\tGeometry2dFilters,\n\tinvLerp,\n\tmapObjectMapValues,\n\tobjectMapEntries,\n\tobjectMapKeys,\n\tTLArrowBinding,\n\tTLArrowShape,\n\tTLArrowShapeKind,\n\tTLShape,\n\tVec,\n\tVecLike,\n\tWeakCache,\n} from '@tldraw/editor'\nimport { ArrowShapeUtil } from './ArrowShapeUtil'\nimport {\n\tElbowArrowAxes,\n\tElbowArrowSide,\n\tElbowArrowSideAxes,\n\tElbowArrowSideDeltas,\n} from './elbow/definitions'\n\n/**\n * Options passed to {@link updateArrowTargetState}.\n *\n * @public\n */\nexport interface UpdateArrowTargetStateOpts {\n\teditor: Editor\n\tpointInPageSpace: VecLike\n\tarrow: TLArrowShape | undefined\n\tisPrecise: boolean\n\tcurrentBinding: TLArrowBinding | undefined\n\t/** The binding from the opposite end of the arrow, if one exists. */\n\toppositeBinding: TLArrowBinding | undefined\n}\n\n/**\n * State representing what we're pointing to when drawing or updating an arrow. You can get this\n * state using {@link getArrowTargetState}, and update it as part of an arrow interaction with\n * {@link updateArrowTargetState} or {@link clearArrowTargetState}.\n *\n * @public\n */\nexport interface ArrowTargetState {\n\ttarget: TLShape\n\tarrowKind: TLArrowShapeKind\n\n\thandlesInPageSpace: {\n\t\ttop: { point: VecLike; isEnabled: boolean }\n\t\tbottom: { point: VecLike; isEnabled: boolean }\n\t\tleft: { point: VecLike; isEnabled: boolean }\n\t\tright: { point: VecLike; isEnabled: boolean }\n\t}\n\n\tisExact: boolean\n\tisPrecise: boolean\n\n\tcenterInPageSpace: VecLike\n\tanchorInPageSpace: VecLike\n\tsnap: ElbowArrowSnap\n\tnormalizedAnchor: VecLike\n}\n\nconst arrowTargetStore = new WeakCache<Editor, Atom<ArrowTargetState | null>>()\n\nfunction getArrowTargetAtom(editor: Editor) {\n\treturn arrowTargetStore.get(editor, () => atom('arrowTarget', null))\n}\n\n/**\n * Get the current arrow target state for an editor. See {@link ArrowTargetState} for more\n * information.\n *\n * @public\n */\nexport function getArrowTargetState(editor: Editor) {\n\treturn getArrowTargetAtom(editor).get()\n}\n\n/**\n * Clear the current arrow target state for an editor. See {@link ArrowTargetState} for more\n * information.\n *\n * @public\n */\nexport function clearArrowTargetState(editor: Editor) {\n\tgetArrowTargetAtom(editor).set(null)\n}\n\n/**\n * Update the current arrow target state for an editor. See {@link ArrowTargetState} for more\n * information.\n *\n * @public\n */\nexport function updateArrowTargetState({\n\teditor,\n\tpointInPageSpace,\n\tarrow,\n\tisPrecise,\n\tcurrentBinding,\n\toppositeBinding,\n}: UpdateArrowTargetStateOpts): ArrowTargetState | null {\n\tconst util = editor.getShapeUtil<ArrowShapeUtil>('arrow')\n\n\t// no target picking when ctrl is held:\n\tif (util.options.shouldIgnoreTargets(editor)) {\n\t\tgetArrowTargetAtom(editor).set(null)\n\t\treturn null\n\t}\n\n\tconst arrowKind = arrow ? arrow.props.kind : editor.getStyleForNextShape(ArrowShapeKindStyle)\n\n\tconst target = editor.getShapeAtPoint(pointInPageSpace, {\n\t\thitInside: true,\n\t\thitFrameInside: true,\n\t\tmargin: arrowKind === 'elbow' ? 8 : [8, 0],\n\t\tfilter: (targetShape) => {\n\t\t\treturn (\n\t\t\t\t!targetShape.isLocked &&\n\t\t\t\teditor.canBindShapes({\n\t\t\t\t\tfromShape: arrow ?? targetFilterFallback,\n\t\t\t\t\ttoShape: targetShape,\n\t\t\t\t\tbinding: 'arrow',\n\t\t\t\t})\n\t\t\t)\n\t\t},\n\t})\n\n\tif (!target) {\n\t\tgetArrowTargetAtom(editor).set(null)\n\t\treturn null\n\t}\n\n\tconst targetGeometryInTargetSpace = editor.getShapeGeometry(target)\n\tconst targetBoundsInTargetSpace = Box.ZeroFix(targetGeometryInTargetSpace.bounds)\n\tconst targetCenterInTargetSpace = targetGeometryInTargetSpace.center\n\tconst targetTransform = editor.getShapePageTransform(target)\n\tconst pointInTargetSpace = editor.getPointInShapeSpace(target, pointInPageSpace)\n\n\tconst castDistance = Math.max(\n\t\ttargetGeometryInTargetSpace.bounds.width,\n\t\ttargetGeometryInTargetSpace.bounds.height\n\t)\n\n\tconst handlesInPageSpace = mapObjectMapValues(ElbowArrowSideDeltas, (side, delta) => {\n\t\tconst axis = ElbowArrowAxes[ElbowArrowSideAxes[side]]\n\n\t\tconst farPoint = Vec.Mul(delta, castDistance).add(targetCenterInTargetSpace)\n\n\t\tlet isEnabled = false\n\t\tlet handlePointInTargetSpace: VecLike = axis.v(\n\t\t\ttargetBoundsInTargetSpace[side],\n\t\t\ttargetBoundsInTargetSpace[axis.crossMid]\n\t\t)\n\t\tlet furthestDistance = 0\n\n\t\tconst intersections = targetGeometryInTargetSpace.intersectLineSegment(\n\t\t\ttargetCenterInTargetSpace,\n\t\t\tfarPoint,\n\t\t\tGeometry2dFilters.EXCLUDE_NON_STANDARD\n\t\t)\n\t\tfor (const intersection of intersections) {\n\t\t\tconst distance = Vec.Dist2(intersection, targetCenterInTargetSpace)\n\t\t\tif (distance > furthestDistance) {\n\t\t\t\tfurthestDistance = distance\n\t\t\t\thandlePointInTargetSpace = intersection\n\t\t\t\tisEnabled = targetGeometryInTargetSpace.isClosed\n\t\t\t}\n\t\t}\n\n\t\tconst handlePointInPageSpace = targetTransform.applyToPoint(handlePointInTargetSpace)\n\n\t\treturn { point: handlePointInPageSpace, isEnabled, far: targetTransform.applyToPoint(farPoint) }\n\t})\n\n\tconst zoomLevel = editor.getZoomLevel()\n\tconst minDistScaled = util.options.minElbowHandleDistance / zoomLevel\n\n\tconst targetCenterInPageSpace = targetTransform.applyToPoint(targetCenterInTargetSpace)\n\tfor (const side of objectMapKeys(handlesInPageSpace)) {\n\t\tconst handle = handlesInPageSpace[side]\n\t\tif (Vec.DistMin(handle.point, targetCenterInPageSpace, minDistScaled)) {\n\t\t\thandle.isEnabled = false\n\t\t}\n\t}\n\n\tlet precise = isPrecise\n\n\tif (!precise) {\n\t\t// If we're switching to a new bound shape, then precise only if moving slowly\n\t\tif (!currentBinding || (currentBinding && target.id !== currentBinding.toId)) {\n\t\t\tprecise = editor.inputs.pointerVelocity.len() < 0.5\n\t\t}\n\t}\n\n\tif (!isPrecise) {\n\t\tif (!targetGeometryInTargetSpace.isClosed) {\n\t\t\tprecise = true\n\t\t}\n\n\t\t// Double check that we're not going to be doing an imprecise snap on\n\t\t// the same shape twice, as this would result in a zero length line\n\t\tif (oppositeBinding && target.id === oppositeBinding.toId && oppositeBinding.props.isPrecise) {\n\t\t\tprecise = true\n\t\t}\n\t}\n\n\tconst isExact = util.options.shouldBeExact(editor, precise)\n\tif (isExact) precise = true\n\n\tconst shouldSnapCenter = !isExact && precise && targetGeometryInTargetSpace.isClosed\n\t// const shouldSnapEdges = !isExact && (precise || !targetGeometryInTargetSpace.isClosed)\n\tconst shouldSnapEdges =\n\t\t!isExact && ((precise && arrowKind === 'elbow') || !targetGeometryInTargetSpace.isClosed)\n\tconst shouldSnapEdgePoints =\n\t\t!isExact && precise && arrowKind === 'elbow' && targetGeometryInTargetSpace.isClosed\n\tconst shouldSnapNone = precise && (targetGeometryInTargetSpace.isClosed || isExact)\n\tconst shouldSnapCenterAxis =\n\t\t!isExact && precise && arrowKind === 'elbow' && targetGeometryInTargetSpace.isClosed\n\n\t// we run through all the snapping options from least to most specific:\n\tlet snap: ElbowArrowSnap = 'none'\n\tlet anchorInPageSpace: VecLike = pointInPageSpace\n\n\tif (!shouldSnapNone) {\n\t\tsnap = 'center'\n\t\tanchorInPageSpace = targetCenterInPageSpace\n\t}\n\n\tif (shouldSnapEdges) {\n\t\tconst snapDistance = shouldSnapNone\n\t\t\t? calculateSnapDistance(\n\t\t\t\t\teditor,\n\t\t\t\t\ttargetBoundsInTargetSpace,\n\t\t\t\t\tutil.options.elbowArrowEdgeSnapDistance\n\t\t\t\t)\n\t\t\t: Infinity\n\n\t\tconst nearestPointOnEdgeInTargetSpace = targetGeometryInTargetSpace.nearestPoint(\n\t\t\tpointInTargetSpace,\n\t\t\t{\n\t\t\t\tincludeLabels: false,\n\t\t\t\tincludeInternal: false,\n\t\t\t}\n\t\t)\n\n\t\tconst nearestPointOnEdgeInPageSpace = targetTransform.applyToPoint(\n\t\t\tnearestPointOnEdgeInTargetSpace\n\t\t)\n\n\t\tconst distance = Vec.Dist(nearestPointOnEdgeInPageSpace, pointInPageSpace)\n\n\t\tif (distance < snapDistance) {\n\t\t\tsnap = 'edge'\n\t\t\tanchorInPageSpace = nearestPointOnEdgeInPageSpace\n\t\t}\n\t}\n\n\tif (shouldSnapCenterAxis) {\n\t\tconst snapDistance = calculateSnapDistance(\n\t\t\teditor,\n\t\t\ttargetBoundsInTargetSpace,\n\t\t\tutil.options.elbowArrowAxisSnapDistance\n\t\t)\n\n\t\tconst distanceFromXAxis = Vec.DistanceToLineSegment(\n\t\t\thandlesInPageSpace.left.far,\n\t\t\thandlesInPageSpace.right.far,\n\t\t\tpointInPageSpace\n\t\t)\n\t\tconst distanceFromYAxis = Vec.DistanceToLineSegment(\n\t\t\thandlesInPageSpace.top.far,\n\t\t\thandlesInPageSpace.bottom.far,\n\t\t\tpointInPageSpace\n\t\t)\n\n\t\tconst snapAxis =\n\t\t\tdistanceFromXAxis < distanceFromYAxis && distanceFromXAxis < snapDistance\n\t\t\t\t? 'x'\n\t\t\t\t: distanceFromYAxis < snapDistance\n\t\t\t\t\t? 'y'\n\t\t\t\t\t: null\n\n\t\tif (snapAxis) {\n\t\t\tconst axis = ElbowArrowAxes[snapAxis]\n\n\t\t\tconst loDist2 = Vec.Dist2(handlesInPageSpace[axis.loEdge].far, pointInPageSpace)\n\t\t\tconst hiDist2 = Vec.Dist2(handlesInPageSpace[axis.hiEdge].far, pointInPageSpace)\n\n\t\t\tconst side = loDist2 < hiDist2 ? axis.loEdge : axis.hiEdge\n\n\t\t\tif (handlesInPageSpace[side].isEnabled) {\n\t\t\t\tsnap = 'edge-point'\n\t\t\t\tanchorInPageSpace = handlesInPageSpace[side].point\n\t\t\t}\n\t\t}\n\t}\n\n\tif (shouldSnapEdgePoints) {\n\t\tconst snapDistance = calculateSnapDistance(\n\t\t\teditor,\n\t\t\ttargetBoundsInTargetSpace,\n\t\t\tutil.options.elbowArrowPointSnapDistance\n\t\t)\n\n\t\tlet closestSide: ElbowArrowSide | null = null\n\t\tlet closestDistance = Infinity\n\n\t\tfor (const [side, handle] of objectMapEntries(handlesInPageSpace)) {\n\t\t\tif (!handle.isEnabled) continue\n\t\t\tconst distance = Vec.Dist(handle.point, pointInPageSpace)\n\t\t\tif (distance < snapDistance && distance < closestDistance) {\n\t\t\t\tclosestDistance = distance\n\t\t\t\tclosestSide = side\n\t\t\t}\n\t\t}\n\n\t\tif (closestSide) {\n\t\t\tsnap = 'edge-point'\n\t\t\tanchorInPageSpace = handlesInPageSpace[closestSide].point\n\t\t}\n\t}\n\n\tif (shouldSnapCenter) {\n\t\tconst snapDistance = calculateSnapDistance(\n\t\t\teditor,\n\t\t\ttargetBoundsInTargetSpace,\n\t\t\tarrowKind === 'elbow'\n\t\t\t\t? util.options.elbowArrowCenterSnapDistance\n\t\t\t\t: util.options.arcArrowCenterSnapDistance\n\t\t)\n\n\t\tif (Vec.Dist(pointInTargetSpace, targetBoundsInTargetSpace.center) < snapDistance) {\n\t\t\tsnap = 'center'\n\t\t\tanchorInPageSpace = targetCenterInPageSpace\n\t\t}\n\t}\n\n\tconst snapPointInTargetSpace = editor.getPointInShapeSpace(target, anchorInPageSpace)\n\n\tconst normalizedAnchor = {\n\t\tx: invLerp(\n\t\t\ttargetBoundsInTargetSpace.minX,\n\t\t\ttargetBoundsInTargetSpace.maxX,\n\t\t\tsnapPointInTargetSpace.x\n\t\t),\n\t\ty: invLerp(\n\t\t\ttargetBoundsInTargetSpace.minY,\n\t\t\ttargetBoundsInTargetSpace.maxY,\n\t\t\tsnapPointInTargetSpace.y\n\t\t),\n\t}\n\n\tconst result: ArrowTargetState = {\n\t\ttarget,\n\t\tarrowKind,\n\t\thandlesInPageSpace,\n\t\tcenterInPageSpace: targetCenterInPageSpace,\n\t\tanchorInPageSpace,\n\t\tisExact,\n\t\tisPrecise: precise,\n\t\tsnap,\n\t\tnormalizedAnchor,\n\t}\n\n\tgetArrowTargetAtom(editor).set(result)\n\n\treturn result\n}\n\nconst targetFilterFallback = { type: 'arrow' }\n\n/**\n * Funky math but we want the snap distance to be 4 at the minimum and either 16 or 15% of the\n * smaller dimension of the target shape, whichever is smaller\n */\nfunction calculateSnapDistance(\n\teditor: Editor,\n\ttargetBoundsInTargetSpace: Box,\n\tidealSnapDistance: number\n) {\n\treturn (\n\t\tclamp(\n\t\t\tMath.min(targetBoundsInTargetSpace.width, targetBoundsInTargetSpace.height) * 0.15,\n\t\t\t4,\n\t\t\tidealSnapDistance\n\t\t) / editor.getZoomLevel()\n\t)\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAoBO;AAEP,yBAKO;AA4CP,MAAM,mBAAmB,IAAI,wBAAiD;AAE9E,SAAS,mBAAmB,QAAgB;AAC3C,SAAO,iBAAiB,IAAI,QAAQ,UAAM,oBAAK,eAAe,IAAI,CAAC;AACpE;AAQO,SAAS,oBAAoB,QAAgB;AACnD,SAAO,mBAAmB,MAAM,EAAE,IAAI;AACvC;AAQO,SAAS,sBAAsB,QAAgB;AACrD,qBAAmB,MAAM,EAAE,IAAI,IAAI;AACpC;AAQO,SAAS,uBAAuB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAwD;AACvD,QAAM,OAAO,OAAO,aAA6B,OAAO;AAGxD,MAAI,KAAK,QAAQ,oBAAoB,MAAM,GAAG;AAC7C,uBAAmB,MAAM,EAAE,IAAI,IAAI;AACnC,WAAO;AAAA,EACR;AAEA,QAAM,YAAY,QAAQ,MAAM,MAAM,OAAO,OAAO,qBAAqB,iCAAmB;AAE5F,QAAM,SAAS,OAAO,gBAAgB,kBAAkB;AAAA,IACvD,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,QAAQ,cAAc,UAAU,IAAI,CAAC,GAAG,CAAC;AAAA,IACzC,QAAQ,CAAC,gBAAgB;AACxB,aACC,CAAC,YAAY,YACb,OAAO,cAAc;AAAA,QACpB,WAAW,SAAS;AAAA,QACpB,SAAS;AAAA,QACT,SAAS;AAAA,MACV,CAAC;AAAA,IAEH;AAAA,EACD,CAAC;AAED,MAAI,CAAC,QAAQ;AACZ,uBAAmB,M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mB,WAAW,EAAE;AAAA,IACrD;AAAA,EACD;AAEA,MAAI,kBAAkB;AACrB,UAAM,eAAe;AAAA,MACpB;AAAA,MACA;AAAA,MACA,cAAc,UACX,KAAK,QAAQ,+BACb,KAAK,QAAQ;AAAA,IACjB;AAEA,QAAI,kBAAI,KAAK,oBAAoB,0BAA0B,MAAM,IAAI,cAAc;AAClF,aAAO;AACP,0BAAoB;AAAA,IACrB;AAAA,EACD;AAEA,QAAM,yBAAyB,OAAO,qBAAqB,QAAQ,iBAAiB;AAEpF,QAAM,mBAAmB;AAAA,IACxB,OAAG;AAAA,MACF,0BAA0B;AAAA,MAC1B,0BAA0B;AAAA,MAC1B,uBAAuB;AAAA,IACxB;AAAA,IACA,OAAG;AAAA,MACF,0BAA0B;AAAA,MAC1B,0BAA0B;AAAA,MAC1B,uBAAuB;AAAA,IACxB;AAAA,EACD;AAEA,QAAM,SAA2B;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,IACnB;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,EACD;AAEA,qBAAmB,MAAM,EAAE,IAAI,MAAM;AAErC,SAAO;AACR;AAEA,MAAM,uBAAuB,EAAE,MAAM,
|
|
4
|
+
"sourcesContent": ["import {\n\tArrowShapeKindStyle,\n\tatom,\n\tAtom,\n\tBox,\n\tclamp,\n\tEditor,\n\tElbowArrowSnap,\n\tGeometry2dFilters,\n\tinvLerp,\n\tmapObjectMapValues,\n\tobjectMapEntries,\n\tobjectMapKeys,\n\tTLArrowBinding,\n\tTLArrowShape,\n\tTLArrowShapeKind,\n\tTLShape,\n\tVec,\n\tVecLike,\n\tWeakCache,\n} from '@tldraw/editor'\nimport { ArrowShapeUtil } from './ArrowShapeUtil'\nimport {\n\tElbowArrowAxes,\n\tElbowArrowSide,\n\tElbowArrowSideAxes,\n\tElbowArrowSideDeltas,\n} from './elbow/definitions'\n\n/**\n * Options passed to {@link updateArrowTargetState}.\n *\n * @public\n */\nexport interface UpdateArrowTargetStateOpts {\n\teditor: Editor\n\tpointInPageSpace: VecLike\n\tarrow: TLArrowShape | undefined\n\tisPrecise: boolean\n\tcurrentBinding: TLArrowBinding | undefined\n\t/** The binding from the opposite end of the arrow, if one exists. */\n\toppositeBinding: TLArrowBinding | undefined\n}\n\n/**\n * State representing what we're pointing to when drawing or updating an arrow. You can get this\n * state using {@link getArrowTargetState}, and update it as part of an arrow interaction with\n * {@link updateArrowTargetState} or {@link clearArrowTargetState}.\n *\n * @public\n */\nexport interface ArrowTargetState {\n\ttarget: TLShape\n\tarrowKind: TLArrowShapeKind\n\n\thandlesInPageSpace: {\n\t\ttop: { point: VecLike; isEnabled: boolean }\n\t\tbottom: { point: VecLike; isEnabled: boolean }\n\t\tleft: { point: VecLike; isEnabled: boolean }\n\t\tright: { point: VecLike; isEnabled: boolean }\n\t}\n\n\tisExact: boolean\n\tisPrecise: boolean\n\n\tcenterInPageSpace: VecLike\n\tanchorInPageSpace: VecLike\n\tsnap: ElbowArrowSnap\n\tnormalizedAnchor: VecLike\n}\n\nconst arrowTargetStore = new WeakCache<Editor, Atom<ArrowTargetState | null>>()\n\nfunction getArrowTargetAtom(editor: Editor) {\n\treturn arrowTargetStore.get(editor, () => atom('arrowTarget', null))\n}\n\n/**\n * Get the current arrow target state for an editor. See {@link ArrowTargetState} for more\n * information.\n *\n * @public\n */\nexport function getArrowTargetState(editor: Editor) {\n\treturn getArrowTargetAtom(editor).get()\n}\n\n/**\n * Clear the current arrow target state for an editor. See {@link ArrowTargetState} for more\n * information.\n *\n * @public\n */\nexport function clearArrowTargetState(editor: Editor) {\n\tgetArrowTargetAtom(editor).set(null)\n}\n\n/**\n * Update the current arrow target state for an editor. See {@link ArrowTargetState} for more\n * information.\n *\n * @public\n */\nexport function updateArrowTargetState({\n\teditor,\n\tpointInPageSpace,\n\tarrow,\n\tisPrecise,\n\tcurrentBinding,\n\toppositeBinding,\n}: UpdateArrowTargetStateOpts): ArrowTargetState | null {\n\tconst util = editor.getShapeUtil<ArrowShapeUtil>('arrow')\n\n\t// no target picking when ctrl is held:\n\tif (util.options.shouldIgnoreTargets(editor)) {\n\t\tgetArrowTargetAtom(editor).set(null)\n\t\treturn null\n\t}\n\n\tconst arrowKind = arrow ? arrow.props.kind : editor.getStyleForNextShape(ArrowShapeKindStyle)\n\n\tconst target = editor.getShapeAtPoint(pointInPageSpace, {\n\t\thitInside: true,\n\t\thitFrameInside: true,\n\t\tmargin: arrowKind === 'elbow' ? 8 : [8, 0],\n\t\tfilter: (targetShape) => {\n\t\t\treturn (\n\t\t\t\t!targetShape.isLocked &&\n\t\t\t\teditor.canBindShapes({\n\t\t\t\t\tfromShape: arrow ?? targetFilterFallback,\n\t\t\t\t\ttoShape: targetShape,\n\t\t\t\t\tbinding: 'arrow',\n\t\t\t\t})\n\t\t\t)\n\t\t},\n\t})\n\n\tif (!target) {\n\t\tgetArrowTargetAtom(editor).set(null)\n\t\treturn null\n\t}\n\n\tconst targetGeometryInTargetSpace = editor.getShapeGeometry(target)\n\tconst targetBoundsInTargetSpace = Box.ZeroFix(targetGeometryInTargetSpace.bounds)\n\tconst targetCenterInTargetSpace = targetGeometryInTargetSpace.center\n\tconst targetTransform = editor.getShapePageTransform(target)\n\tconst pointInTargetSpace = editor.getPointInShapeSpace(target, pointInPageSpace)\n\n\tconst castDistance = Math.max(\n\t\ttargetGeometryInTargetSpace.bounds.width,\n\t\ttargetGeometryInTargetSpace.bounds.height\n\t)\n\n\tconst handlesInPageSpace = mapObjectMapValues(ElbowArrowSideDeltas, (side, delta) => {\n\t\tconst axis = ElbowArrowAxes[ElbowArrowSideAxes[side]]\n\n\t\tconst farPoint = Vec.Mul(delta, castDistance).add(targetCenterInTargetSpace)\n\n\t\tlet isEnabled = false\n\t\tlet handlePointInTargetSpace: VecLike = axis.v(\n\t\t\ttargetBoundsInTargetSpace[side],\n\t\t\ttargetBoundsInTargetSpace[axis.crossMid]\n\t\t)\n\t\tlet furthestDistance = 0\n\n\t\tconst intersections = targetGeometryInTargetSpace.intersectLineSegment(\n\t\t\ttargetCenterInTargetSpace,\n\t\t\tfarPoint,\n\t\t\tGeometry2dFilters.EXCLUDE_NON_STANDARD\n\t\t)\n\t\tfor (const intersection of intersections) {\n\t\t\tconst distance = Vec.Dist2(intersection, targetCenterInTargetSpace)\n\t\t\tif (distance > furthestDistance) {\n\t\t\t\tfurthestDistance = distance\n\t\t\t\thandlePointInTargetSpace = intersection\n\t\t\t\tisEnabled = targetGeometryInTargetSpace.isClosed\n\t\t\t}\n\t\t}\n\n\t\tconst handlePointInPageSpace = targetTransform.applyToPoint(handlePointInTargetSpace)\n\n\t\treturn { point: handlePointInPageSpace, isEnabled, far: targetTransform.applyToPoint(farPoint) }\n\t})\n\n\tconst zoomLevel = editor.getZoomLevel()\n\tconst minDistScaled = util.options.minElbowHandleDistance / zoomLevel\n\n\tconst targetCenterInPageSpace = targetTransform.applyToPoint(targetCenterInTargetSpace)\n\tfor (const side of objectMapKeys(handlesInPageSpace)) {\n\t\tconst handle = handlesInPageSpace[side]\n\t\tif (Vec.DistMin(handle.point, targetCenterInPageSpace, minDistScaled)) {\n\t\t\thandle.isEnabled = false\n\t\t}\n\t}\n\n\tlet precise = isPrecise\n\n\tif (!precise) {\n\t\t// If we're switching to a new bound shape, then precise only if moving slowly\n\t\tif (!currentBinding || (currentBinding && target.id !== currentBinding.toId)) {\n\t\t\tprecise = editor.inputs.pointerVelocity.len() < 0.5\n\t\t}\n\t}\n\n\tif (!isPrecise) {\n\t\tif (!targetGeometryInTargetSpace.isClosed) {\n\t\t\tprecise = true\n\t\t}\n\n\t\t// Double check that we're not going to be doing an imprecise snap on\n\t\t// the same shape twice, as this would result in a zero length line\n\t\tif (oppositeBinding && target.id === oppositeBinding.toId && oppositeBinding.props.isPrecise) {\n\t\t\tprecise = true\n\t\t}\n\t}\n\n\tconst isExact = util.options.shouldBeExact(editor, precise)\n\tif (isExact) precise = true\n\n\tconst shouldSnapCenter = !isExact && precise && targetGeometryInTargetSpace.isClosed\n\t// const shouldSnapEdges = !isExact && (precise || !targetGeometryInTargetSpace.isClosed)\n\tconst shouldSnapEdges =\n\t\t!isExact && ((precise && arrowKind === 'elbow') || !targetGeometryInTargetSpace.isClosed)\n\tconst shouldSnapEdgePoints =\n\t\t!isExact && precise && arrowKind === 'elbow' && targetGeometryInTargetSpace.isClosed\n\tconst shouldSnapNone = precise && (targetGeometryInTargetSpace.isClosed || isExact)\n\tconst shouldSnapCenterAxis =\n\t\t!isExact && precise && arrowKind === 'elbow' && targetGeometryInTargetSpace.isClosed\n\n\t// we run through all the snapping options from least to most specific:\n\tlet snap: ElbowArrowSnap = 'none'\n\tlet anchorInPageSpace: VecLike = pointInPageSpace\n\n\tif (!shouldSnapNone) {\n\t\tsnap = 'center'\n\t\tanchorInPageSpace = targetCenterInPageSpace\n\t}\n\n\tif (shouldSnapEdges) {\n\t\tconst snapDistance = shouldSnapNone\n\t\t\t? calculateSnapDistance(\n\t\t\t\t\teditor,\n\t\t\t\t\ttargetBoundsInTargetSpace,\n\t\t\t\t\tutil.options.elbowArrowEdgeSnapDistance\n\t\t\t\t)\n\t\t\t: Infinity\n\n\t\tconst nearestPointOnEdgeInTargetSpace = targetGeometryInTargetSpace.nearestPoint(\n\t\t\tpointInTargetSpace,\n\t\t\t{\n\t\t\t\tincludeLabels: false,\n\t\t\t\tincludeInternal: false,\n\t\t\t}\n\t\t)\n\n\t\tconst nearestPointOnEdgeInPageSpace = targetTransform.applyToPoint(\n\t\t\tnearestPointOnEdgeInTargetSpace\n\t\t)\n\n\t\tconst distance = Vec.Dist(nearestPointOnEdgeInPageSpace, pointInPageSpace)\n\n\t\tif (distance < snapDistance) {\n\t\t\tsnap = 'edge'\n\t\t\tanchorInPageSpace = nearestPointOnEdgeInPageSpace\n\t\t}\n\t}\n\n\tif (shouldSnapCenterAxis) {\n\t\tconst snapDistance = calculateSnapDistance(\n\t\t\teditor,\n\t\t\ttargetBoundsInTargetSpace,\n\t\t\tutil.options.elbowArrowAxisSnapDistance\n\t\t)\n\n\t\tconst distanceFromXAxis = Vec.DistanceToLineSegment(\n\t\t\thandlesInPageSpace.left.far,\n\t\t\thandlesInPageSpace.right.far,\n\t\t\tpointInPageSpace\n\t\t)\n\t\tconst distanceFromYAxis = Vec.DistanceToLineSegment(\n\t\t\thandlesInPageSpace.top.far,\n\t\t\thandlesInPageSpace.bottom.far,\n\t\t\tpointInPageSpace\n\t\t)\n\n\t\tconst snapAxis =\n\t\t\tdistanceFromXAxis < distanceFromYAxis && distanceFromXAxis < snapDistance\n\t\t\t\t? 'x'\n\t\t\t\t: distanceFromYAxis < snapDistance\n\t\t\t\t\t? 'y'\n\t\t\t\t\t: null\n\n\t\tif (snapAxis) {\n\t\t\tconst axis = ElbowArrowAxes[snapAxis]\n\n\t\t\tconst loDist2 = Vec.Dist2(handlesInPageSpace[axis.loEdge].far, pointInPageSpace)\n\t\t\tconst hiDist2 = Vec.Dist2(handlesInPageSpace[axis.hiEdge].far, pointInPageSpace)\n\n\t\t\tconst side = loDist2 < hiDist2 ? axis.loEdge : axis.hiEdge\n\n\t\t\tif (handlesInPageSpace[side].isEnabled) {\n\t\t\t\tsnap = 'edge-point'\n\t\t\t\tanchorInPageSpace = handlesInPageSpace[side].point\n\t\t\t}\n\t\t}\n\t}\n\n\tif (shouldSnapEdgePoints) {\n\t\tconst snapDistance = calculateSnapDistance(\n\t\t\teditor,\n\t\t\ttargetBoundsInTargetSpace,\n\t\t\tutil.options.elbowArrowPointSnapDistance\n\t\t)\n\n\t\tlet closestSide: ElbowArrowSide | null = null\n\t\tlet closestDistance = Infinity\n\n\t\tfor (const [side, handle] of objectMapEntries(handlesInPageSpace)) {\n\t\t\tif (!handle.isEnabled) continue\n\t\t\tconst distance = Vec.Dist(handle.point, pointInPageSpace)\n\t\t\tif (distance < snapDistance && distance < closestDistance) {\n\t\t\t\tclosestDistance = distance\n\t\t\t\tclosestSide = side\n\t\t\t}\n\t\t}\n\n\t\tif (closestSide) {\n\t\t\tsnap = 'edge-point'\n\t\t\tanchorInPageSpace = handlesInPageSpace[closestSide].point\n\t\t}\n\t}\n\n\tif (shouldSnapCenter) {\n\t\tconst snapDistance = calculateSnapDistance(\n\t\t\teditor,\n\t\t\ttargetBoundsInTargetSpace,\n\t\t\tarrowKind === 'elbow'\n\t\t\t\t? util.options.elbowArrowCenterSnapDistance\n\t\t\t\t: util.options.arcArrowCenterSnapDistance\n\t\t)\n\n\t\tif (Vec.Dist(pointInTargetSpace, targetBoundsInTargetSpace.center) < snapDistance) {\n\t\t\tsnap = 'center'\n\t\t\tanchorInPageSpace = targetCenterInPageSpace\n\t\t}\n\t}\n\n\tconst snapPointInTargetSpace = editor.getPointInShapeSpace(target, anchorInPageSpace)\n\n\tconst normalizedAnchor = {\n\t\tx: invLerp(\n\t\t\ttargetBoundsInTargetSpace.minX,\n\t\t\ttargetBoundsInTargetSpace.maxX,\n\t\t\tsnapPointInTargetSpace.x\n\t\t),\n\t\ty: invLerp(\n\t\t\ttargetBoundsInTargetSpace.minY,\n\t\t\ttargetBoundsInTargetSpace.maxY,\n\t\t\tsnapPointInTargetSpace.y\n\t\t),\n\t}\n\n\tconst result: ArrowTargetState = {\n\t\ttarget,\n\t\tarrowKind,\n\t\thandlesInPageSpace,\n\t\tcenterInPageSpace: targetCenterInPageSpace,\n\t\tanchorInPageSpace,\n\t\tisExact,\n\t\tisPrecise: precise,\n\t\tsnap,\n\t\tnormalizedAnchor,\n\t}\n\n\tgetArrowTargetAtom(editor).set(result)\n\n\treturn result\n}\n\nconst targetFilterFallback = { type: 'arrow' as const }\n\n/**\n * Funky math but we want the snap distance to be 4 at the minimum and either 16 or 15% of the\n * smaller dimension of the target shape, whichever is smaller\n */\nfunction calculateSnapDistance(\n\teditor: Editor,\n\ttargetBoundsInTargetSpace: Box,\n\tidealSnapDistance: number\n) {\n\treturn (\n\t\tclamp(\n\t\t\tMath.min(targetBoundsInTargetSpace.width, targetBoundsInTargetSpace.height) * 0.15,\n\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,cAAc,UACX,KAAK,QAAQ,+BACb,KAAK,QAAQ;AAAA,IACjB;AAEA,QAAI,kBAAI,KAAK,oBAAoB,0BAA0B,MAAM,IAAI,cAAc;AAClF,aAAO;AACP,0BAAoB;AAAA,IACrB;AAAA,EACD;AAEA,QAAM,yBAAyB,OAAO,qBAAqB,QAAQ,iBAAiB;AAEpF,QAAM,mBAAmB;AAAA,IACxB,OAAG;AAAA,MACF,0BAA0B;AAAA,MAC1B,0BAA0B;AAAA,MAC1B,uBAAuB;AAAA,IACxB;AAAA,IACA,OAAG;AAAA,MACF,0BAA0B;AAAA,MAC1B,0BAA0B;AAAA,MAC1B,uBAAuB;AAAA,IACxB;AAAA,EACD;AAEA,QAAM,SAA2B;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,IACnB;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,EACD;AAEA,qBAAmB,MAAM,EAAE,IAAI,MAAM;AAErC,SAAO;AACR;AAEA,MAAM,uBAAuB,EAAE,MAAM,QAAiB;AAMtD,SAAS,sBACR,QACA,2BACA,mBACC;AACD,aACC;AAAA,IACC,KAAK,IAAI,0BAA0B,OAAO,0BAA0B,MAAM,IAAI;AAAA,IAC9E;AAAA,IACA;AAAA,EACD,IAAI,OAAO,aAAa;AAE1B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n\tcomputed,\n\tComputed,\n\tEditor,\n\tTLArrowShape,\n\tTLShapeId,\n\tVec,\n\tVecLike,\n\tWeakCache,\n} from '@tldraw/editor'\nimport { getArrowBindings } from '../shared'\n\n/**\n * A snap line for an elbow arrow segment.\n *\n * This should already belong to ElbowArrowSnapLines establishing an angle of the line.\n */\ninterface ElbowArrowSnapLine {\n\t/** The id of the shape that the snap line starts from. */\n\tstartBoundShapeId: TLShapeId | undefined\n\t/** The id of the shape that the snap line ends at. */\n\tendBoundShapeId: TLShapeId | undefined\n\t/** The perpendicular distance from the snap line to the origin. */\n\tperpDistance: number\n}\n\n/**\n * A map from an angle (0-\u03C0) to a set of snap lines. Snap lines are stored in page space. They're\n * modelled as an angle (the angle of the line itself) and a perpendicular signed distance from the\n * page origin. Each line is effectively infinite in length, but modelling them in this way makes it\n * pretty efficient for us to query for relevant snap lines.\n */\ntype ElbowArrowSnapLines = Map<number, Set<ElbowArrowSnapLine>>\n\nconst snapLinesStore = new WeakCache<Editor, Computed<ElbowArrowSnapLines>>()\n\nexport function getElbowArrowSnapLines(editor: Editor) {\n\treturn snapLinesStore\n\t\t.get(editor, (editor) => {\n\t\t\tconst currentSelectedArrowShape = computed('current selected arrow shape', () => {\n\t\t\t\tconst shape = editor.getOnlySelectedShape()\n\t\t\t\tif (!shape || !editor.isShapeOfType
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBASO;AACP,oBAAiC;AAwBjC,MAAM,iBAAiB,IAAI,wBAAiD;AAErE,SAAS,uBAAuB,QAAgB;AACtD,SAAO,eACL,IAAI,QAAQ,CAACA,YAAW;AACxB,UAAM,gCAA4B,wBAAS,gCAAgC,MAAM;AAChF,YAAM,QAAQA,QAAO,qBAAqB;AAC1C,UAAI,CAAC,SAAS,CAACA,QAAO,
|
|
4
|
+
"sourcesContent": ["import {\n\tcomputed,\n\tComputed,\n\tEditor,\n\tTLArrowShape,\n\tTLShapeId,\n\tVec,\n\tVecLike,\n\tWeakCache,\n} from '@tldraw/editor'\nimport { getArrowBindings } from '../shared'\n\n/**\n * A snap line for an elbow arrow segment.\n *\n * This should already belong to ElbowArrowSnapLines establishing an angle of the line.\n */\ninterface ElbowArrowSnapLine {\n\t/** The id of the shape that the snap line starts from. */\n\tstartBoundShapeId: TLShapeId | undefined\n\t/** The id of the shape that the snap line ends at. */\n\tendBoundShapeId: TLShapeId | undefined\n\t/** The perpendicular distance from the snap line to the origin. */\n\tperpDistance: number\n}\n\n/**\n * A map from an angle (0-\u03C0) to a set of snap lines. Snap lines are stored in page space. They're\n * modelled as an angle (the angle of the line itself) and a perpendicular signed distance from the\n * page origin. Each line is effectively infinite in length, but modelling them in this way makes it\n * pretty efficient for us to query for relevant snap lines.\n */\ntype ElbowArrowSnapLines = Map<number, Set<ElbowArrowSnapLine>>\n\nconst snapLinesStore = new WeakCache<Editor, Computed<ElbowArrowSnapLines>>()\n\nexport function getElbowArrowSnapLines(editor: Editor) {\n\treturn snapLinesStore\n\t\t.get(editor, (editor) => {\n\t\t\tconst currentSelectedArrowShape = computed('current selected arrow shape', () => {\n\t\t\t\tconst shape = editor.getOnlySelectedShape()\n\t\t\t\tif (!shape || !editor.isShapeOfType(shape, 'arrow')) return null\n\t\t\t\treturn shape.id\n\t\t\t})\n\n\t\t\tconst unselectedArrowShapeIds = editor.store.query.ids('shape', () => {\n\t\t\t\tconst activeArrowShapeId = currentSelectedArrowShape.get()\n\t\t\t\tif (!activeArrowShapeId) return { type: { eq: 'arrow' } } as const\n\t\t\t\treturn {\n\t\t\t\t\ttype: { eq: 'arrow' },\n\t\t\t\t\tid: { neq: activeArrowShapeId },\n\t\t\t\t} as const\n\t\t\t})\n\n\t\t\treturn computed('elbow arrow snap lines', () => {\n\t\t\t\t// the result is a map from angle (0-\u03C0), to a set of single-axis co-ordinates. For\n\t\t\t\t// example, if a line from (0, 1) to (1, 1) is found (ie a horizontal line at y-coord 1),\n\t\t\t\t// we'll add an entry to the map with the key 0 (horizontal), and the set containing 1.\n\t\t\t\tconst result = new Map<number, Set<ElbowArrowSnapLine>>()\n\n\t\t\t\tconst currentPageShapeIds = editor.getCurrentPageShapeIds()\n\t\t\t\tconst viewportBounds = editor.getViewportPageBounds()\n\n\t\t\t\tfor (const id of unselectedArrowShapeIds.get()) {\n\t\t\t\t\tif (!currentPageShapeIds.has(id)) continue\n\n\t\t\t\t\tconst shape = editor.getShape<TLArrowShape>(id)\n\t\t\t\t\tif (shape?.type !== 'arrow') continue\n\n\t\t\t\t\tconst shapeBounds = editor.getShapePageBounds(id)\n\t\t\t\t\tif (!shapeBounds || !viewportBounds.includes(shapeBounds)) continue\n\n\t\t\t\t\tconst bindings = getArrowBindings(editor, shape)\n\t\t\t\t\tconst pageTransform = editor.getShapePageTransform(id)\n\t\t\t\t\tif (!pageTransform) continue\n\n\t\t\t\t\tconst geometry = editor.getShapeGeometry(id)\n\n\t\t\t\t\tconst pageVertices = pageTransform.applyToPoints(geometry.vertices)\n\n\t\t\t\t\tfor (let i = 1; i < pageVertices.length; i++) {\n\t\t\t\t\t\tconst prev = pageVertices[i - 1]\n\t\t\t\t\t\tconst curr = pageVertices[i]\n\n\t\t\t\t\t\tlet angle = Vec.Angle(prev, curr)\n\n\t\t\t\t\t\t// we don't care if the angle is going \"up\" or \"down\" - so we only care\n\t\t\t\t\t\t// about the 0-\u03C0 range\n\t\t\t\t\t\tif (angle < 0) angle += Math.PI\n\n\t\t\t\t\t\tlet set = result.get(angle)\n\t\t\t\t\t\tif (!set) {\n\t\t\t\t\t\t\tset = new Set()\n\t\t\t\t\t\t\tresult.set(angle, set)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst perpDistance = perpDistanceToLineAngle(prev, angle)\n\n\t\t\t\t\t\tset.add({\n\t\t\t\t\t\t\tperpDistance,\n\t\t\t\t\t\t\tstartBoundShapeId: bindings.start?.toId,\n\t\t\t\t\t\t\tendBoundShapeId: bindings.end?.toId,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn result\n\t\t\t})\n\t\t})\n\t\t.get()\n}\n\n/**\n * Return the signed distance from the origin to a point on a line of angle `lineAngle` that passes\n * through the point `pointOnLine`.\n */\nexport function perpDistanceToLineAngle(pointOnLine: VecLike, lineAngle: number): number {\n\t// The perpendicular unit vector to the line direction\n\tconst perpDir = Vec.FromAngle(lineAngle).per()\n\t// Project the point onto the perpendicular vector\n\treturn Vec.Dpr(pointOnLine, perpDir)\n}\n\n/**\n * Return the signed distance from the origin to the line segment defined by `A` and `B`.\n */\nexport function perpDistanceToLine(A: VecLike, B: VecLike): number {\n\treturn perpDistanceToLineAngle(A, Vec.Angle(A, B))\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBASO;AACP,oBAAiC;AAwBjC,MAAM,iBAAiB,IAAI,wBAAiD;AAErE,SAAS,uBAAuB,QAAgB;AACtD,SAAO,eACL,IAAI,QAAQ,CAACA,YAAW;AACxB,UAAM,gCAA4B,wBAAS,gCAAgC,MAAM;AAChF,YAAM,QAAQA,QAAO,qBAAqB;AAC1C,UAAI,CAAC,SAAS,CAACA,QAAO,cAAc,OAAO,OAAO,EAAG,QAAO;AAC5D,aAAO,MAAM;AAAA,IACd,CAAC;AAED,UAAM,0BAA0BA,QAAO,MAAM,MAAM,IAAI,SAAS,MAAM;AACrE,YAAM,qBAAqB,0BAA0B,IAAI;AACzD,UAAI,CAAC,mBAAoB,QAAO,EAAE,MAAM,EAAE,IAAI,QAAQ,EAAE;AACxD,aAAO;AAAA,QACN,MAAM,EAAE,IAAI,QAAQ;AAAA,QACpB,IAAI,EAAE,KAAK,mBAAmB;AAAA,MAC/B;AAAA,IACD,CAAC;AAED,eAAO,wBAAS,0BAA0B,MAAM;AAI/C,YAAM,SAAS,oBAAI,IAAqC;AAExD,YAAM,sBAAsBA,QAAO,uBAAuB;AAC1D,YAAM,iBAAiBA,QAAO,sBAAsB;AAEpD,iBAAW,MAAM,wBAAwB,IAAI,GAAG;AAC/C,YAAI,CAAC,oBAAoB,IAAI,EAAE,EAAG;AAElC,cAAM,QAAQA,QAAO,SAAuB,EAAE;AAC9C,YAAI,OAAO,SAAS,QAAS;AAE7B,cAAM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