From ad32fce170ffeef8e03c108569113dca9de15d5d Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Sun, 21 May 2023 22:25:28 -0400
Subject: fixed comparisonBox to create embeddings of documents by fixing
 targetDropAction to work for non-collections.  fixed carouse3D view to have
 correct screentolocal XFs,

---
 src/client/views/PreviewCursor.tsx | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

(limited to 'src/client/views/PreviewCursor.tsx')

diff --git a/src/client/views/PreviewCursor.tsx b/src/client/views/PreviewCursor.tsx
index f7fb443c0..8dd13ff08 100644
--- a/src/client/views/PreviewCursor.tsx
+++ b/src/client/views/PreviewCursor.tsx
@@ -1,14 +1,15 @@
 import { action, observable, runInAction } from 'mobx';
 import { observer } from 'mobx-react';
+import { listenerCount } from 'process';
 import * as React from 'react';
 import { Doc } from '../../fields/Doc';
-import { Cast, NumCast, StrCast } from '../../fields/Types';
+import { Cast, DocCast, NumCast, StrCast } from '../../fields/Types';
 import { returnFalse } from '../../Utils';
 import { DocServer } from '../DocServer';
 import { Docs, DocumentOptions, DocUtils } from '../documents/Documents';
 import { ImageUtils } from '../util/Import & Export/ImageUtils';
 import { Transform } from '../util/Transform';
-import { undoBatch, UndoManager } from '../util/UndoManager';
+import { undoable, undoBatch, UndoManager } from '../util/UndoManager';
 import { FormattedTextBox } from './nodes/formattedText/FormattedTextBox';
 import './PreviewCursor.scss';
 
@@ -66,23 +67,11 @@ export class PreviewCursor extends React.Component<{}> {
                 } else if (plain.startsWith('__DashDocId(') || plain.startsWith('__DashCloneId(')) {
                     const clone = plain.startsWith('__DashCloneId(');
                     const docids = plain.split(':');
-                    const strs = docids[0].split(',');
+                    const strs = docids[0].split(','); // hack!  docids[0] is the top left of the selection rectangle
                     const ptx = Number(strs[0].substring((clone ? '__DashCloneId(' : '__DashDocId(').length));
                     const pty = Number(strs[1].substring(0, strs[1].length - 1));
+                    Doc.Paste(docids.slice(1), clone, PreviewCursor._addDocument, ptx, pty, newPoint);
 
-                    const batch = UndoManager.StartBatch('cloning');
-                    {
-                        const toCopy = await Promise.all(docids.slice(1).map(async did => Cast(await DocServer.GetRefField(did), Doc, null)));
-                        const docs = clone ? (await Promise.all(Doc.MakeClones(toCopy, false))).map(res => res.clone) : toCopy;
-                        const firstx = docs.length ? NumCast(docs[0].x) + ptx - newPoint[0] : 0;
-                        const firsty = docs.length ? NumCast(docs[0].y) + pty - newPoint[1] : 0;
-                        docs.map(doc => {
-                            doc.x = NumCast(doc.x) - firstx;
-                            doc.y = NumCast(doc.y) - firsty;
-                        });
-                        PreviewCursor._addDocument(docs);
-                    }
-                    batch.end();
                     e.stopPropagation();
                 } else {
                     FormattedTextBox.PasteOnLoad = e;
-- 
cgit v1.2.3-70-g09d2

