diff options
| author | usodhi <61431818+usodhi@users.noreply.github.com> | 2021-03-02 23:35:15 -0500 | 
|---|---|---|
| committer | usodhi <61431818+usodhi@users.noreply.github.com> | 2021-03-02 23:35:15 -0500 | 
| commit | 067377e138254c72ad4cf3609b05d5aab2b71a26 (patch) | |
| tree | 9ce9b22e585a0e1472eb3216630c2404e8517144 /src/client/util/DragManager.ts | |
| parent | 95451a2eb0871856b946fff8a14ca0c385af5f1b (diff) | |
| parent | 1b481cd441cc8bb200906b246b43e4bc5dc53b4e (diff) | |
agh stop merging
Diffstat (limited to 'src/client/util/DragManager.ts')
| -rw-r--r-- | src/client/util/DragManager.ts | 38 | 
1 files changed, 17 insertions, 21 deletions
| diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts index 19f1f8d15..437fea0ea 100644 --- a/src/client/util/DragManager.ts +++ b/src/client/util/DragManager.ts @@ -13,7 +13,7 @@ import * as globalCssVariables from "../views/globalCssVariables.scss";  import { UndoManager } from "./UndoManager";  import { SnappingManager } from "./SnappingManager"; -export type dropActionType = "alias" | "copy" | "move" | "same" | "none" | undefined; // undefined = move, "same" = move but don't call removeDropProperties +export type dropActionType = "alias" | "copy" | "move" | "same" | "proto" | "none" | undefined; // undefined = move, "same" = move but don't call removeDropProperties  export function SetupDrag(      _reference: React.RefObject<HTMLElement>,      docFunc: () => Doc | Promise<Doc> | undefined, @@ -138,13 +138,13 @@ export namespace DragManager {          isSelectionMove?: boolean; // indicates that an explicitly selected Document is being dragged.  this will suppress onDragStart scripts      }      export class LinkDragData { -        constructor(linkSourceDoc: Doc) { -            this.linkSourceDocument = linkSourceDoc; +        constructor(dragDoc: Doc, linkSourceGetAnchor: () => Doc) { +            this.dragDocument = dragDoc; +            this.linkSourceGetAnchor = linkSourceGetAnchor;          } -        droppedDocuments: Doc[] = []; -        linkSourceDocument: Doc; -        dontClearTextBox?: boolean; -        linkDropCallback?: (data: { linkDocument: Doc }) => void; +        dragDocument: Doc; +        linkSourceGetAnchor: () => Doc; +        linkSourceDoc?: Doc;      }      export class ColumnDragData {          constructor(colKey: SchemaHeaderField) { @@ -154,23 +154,18 @@ export namespace DragManager {      }      // used by PDFs,Text,Image,Video,Web to conditionally (if the drop completes) create a text annotation when dragging the annotate button from the AnchorMenu when a text/region selection has been made.      // this is pretty clunky and should be rethought out using linkDrag or DocumentDrag -    export class AnchorAnnoDragData { -        constructor(dragDoc: Doc, annotationDocCreator: () => Doc, dropDocCreator: () => Doc) { -            this.dragDocument = dragDoc; +    export class AnchorAnnoDragData extends LinkDragData { +        constructor(dragDoc: Doc, linkSourceGetAnchor: () => Doc, dropDocCreator: (annotationOn: Doc | undefined) => Doc) { +            super(dragDoc, linkSourceGetAnchor);              this.dropDocCreator = dropDocCreator; -            this.annotationDocCreator = annotationDocCreator;              this.offset = [0, 0];          } -        targetContext: Doc | undefined; -        dragDocument: Doc; -        annotationDocCreator: () => Doc; -        dropDocCreator: () => Doc; +        linkSourceDoc?: Doc; +        dropDocCreator: (annotationOn: Doc | undefined) => Doc;          dropDocument?: Doc; -        annotationDocument?: Doc;          offset: number[];          dropAction: dropActionType;          userDropAction: dropActionType; -        linkDropCallback?: (data: { linkDocument: Doc }) => void;      }      export function MakeDropTarget( @@ -221,8 +216,9 @@ export namespace DragManager {                  docDragData.droppedDocuments =                      dragData.draggedDocuments.map(d => !dragData.isSelectionMove && !dragData.userDropAction && ScriptCast(d.onDragStart) ? addAudioTag(ScriptCast(d.onDragStart).script.run({ this: d }).result) :                          docDragData.dropAction === "alias" ? Doc.MakeAlias(d) : -                            docDragData.dropAction === "copy" ? Doc.MakeClone(d) : d); -                docDragData.dropAction !== "same" && docDragData.droppedDocuments.forEach((drop: Doc, i: number) => { +                            docDragData.dropAction === "proto" ? Doc.GetProto(d) : +                                docDragData.dropAction === "copy" ? Doc.MakeClone(d) : d); +                !["same", "proto"].includes(docDragData.dropAction as any) && docDragData.droppedDocuments.forEach((drop: Doc, i: number) => {                      const dragProps = Cast(dragData.draggedDocuments[i].removeDropProperties, listSpec("string"), []);                      const remProps = (dragData?.removeDropProperties || []).concat(Array.from(dragProps));                      remProps.map(prop => drop[prop] = undefined); @@ -257,8 +253,8 @@ export namespace DragManager {      }      // drags a linker button and creates a link on drop -    export function StartLinkDrag(ele: HTMLElement, sourceDoc: Doc, downX: number, downY: number, options?: DragOptions) { -        StartDrag([ele], new DragManager.LinkDragData(sourceDoc), downX, downY, options); +    export function StartLinkDrag(ele: HTMLElement, sourceDoc: Doc, sourceDocGetAnchor: undefined | (() => Doc), downX: number, downY: number, options?: DragOptions) { +        StartDrag([ele], new DragManager.LinkDragData(sourceDoc, () => sourceDocGetAnchor?.() ?? sourceDoc), downX, downY, options);      }      // drags a column from a schema view | 
