diff options
author | bobzel <zzzman@gmail.com> | 2023-05-21 22:25:28 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2023-05-21 22:25:28 -0400 |
commit | ad32fce170ffeef8e03c108569113dca9de15d5d (patch) | |
tree | b7c9dda79e8f56d6f2cd106ec2db7197fbac3323 /src/fields/Doc.ts | |
parent | 6d38405169b6475ed84baf7de81d01482c3d5fce (diff) |
fixed comparisonBox to create embeddings of documents by fixing targetDropAction to work for non-collections. fixed carouse3D view to have correct screentolocal XFs,
Diffstat (limited to 'src/fields/Doc.ts')
-rw-r--r-- | src/fields/Doc.ts | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts index 128cfffb2..8dd322e05 100644 --- a/src/fields/Doc.ts +++ b/src/fields/Doc.ts @@ -9,7 +9,7 @@ import { LinkManager } from '../client/util/LinkManager'; import { scriptingGlobal, ScriptingGlobals } from '../client/util/ScriptingGlobals'; import { SelectionManager } from '../client/util/SelectionManager'; import { afterDocDeserialize, autoObject, Deserializable, SerializationHelper } from '../client/util/SerializationHelper'; -import { UndoManager } from '../client/util/UndoManager'; +import { undoable, UndoManager } from '../client/util/UndoManager'; import { decycle } from '../decycler/decycler'; import { DashColor, incrementTitleCopy, intersectRect, Utils } from '../Utils'; import { DateField } from './DateField'; @@ -211,14 +211,14 @@ export class Doc extends RefField { public static get MyTrails() { return DocCast(Doc.ActiveDashboard?.myTrails); } - public static IsInMyOverlay(doc:Doc) { + public static IsInMyOverlay(doc: Doc) { return DocListCast(Doc.MyOverlayDocs?.data).includes(doc); } - public static AddToMyOverlay(doc:Doc) { + public static AddToMyOverlay(doc: Doc) { Doc.AddDocToList(Doc.MyOverlayDocs, undefined, doc); } - public static RemFromMyOverlay(doc:Doc) { - Doc.RemoveDocFromList(Doc.MyOverlayDocs, undefined, doc) + public static RemFromMyOverlay(doc: Doc) { + Doc.RemoveDocFromList(Doc.MyOverlayDocs, undefined, doc); } public static get MyOverlayDocs() { return DocCast(Doc.UserDoc().myOverlayDocs); @@ -1520,6 +1520,24 @@ export namespace Doc { return style; } + export function Paste(docids: string[], clone: boolean, addDocument: (doc: Doc | Doc[]) => boolean, ptx?: number, pty?: number, newPoint?: number[]) { + DocServer.GetRefFields(docids).then(async fieldlist => { + const list = Array.from(Object.values(fieldlist)) + .map(d => DocCast(d)) + .filter(d => d); + const docs = clone ? (await Promise.all(Doc.MakeClones(list, false))).map(res => res.clone) : list; + if (ptx !== undefined && pty !== undefined && newPoint !== undefined) { + const firstx = list.length ? NumCast(list[0].x) + ptx - newPoint[0] : 0; + const firsty = list.length ? NumCast(list[0].y) + pty - newPoint[1] : 0; + docs.map(doc => { + doc.x = NumCast(doc.x) - firstx; + doc.y = NumCast(doc.y) - firsty; + }); + } + undoable(addDocument, 'Paste Doc')(docs); // embedContainer gets set in addDocument + }); + } + // prettier-ignore export function toIcon(doc?: Doc, isOpen?: boolean) { switch (StrCast(doc?.type)) { |