aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionSubView.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/collections/CollectionSubView.tsx')
-rw-r--r--src/client/views/collections/CollectionSubView.tsx32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index e79d0a76d..01a8da313 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -9,7 +9,7 @@ import { Id } from '../../../fields/FieldSymbols';
import { List } from '../../../fields/List';
import { listSpec } from '../../../fields/Schema';
import { ScriptField } from '../../../fields/ScriptField';
-import { BoolCast, Cast, DateCast, NumCast, ScriptCast, StrCast, toList } from '../../../fields/Types';
+import { BoolCast, Cast, DateCast, DocCast, NumCast, ScriptCast, StrCast, toList } from '../../../fields/Types';
import { WebField } from '../../../fields/URLField';
import { GetEffectiveAcl, TraceMobx } from '../../../fields/util';
import { GestureUtils } from '../../../pen-gestures/GestureUtils';
@@ -356,12 +356,16 @@ export function CollectionSubView<X>() {
return !!added;
}
if (de.complete.annoDragData) {
- const dropCreator = de.complete.annoDragData.dropDocCreator;
- de.complete.annoDragData.dropDocCreator = () => {
- const dropped = dropCreator(this._props.isAnnotationOverlay ? this.Document : undefined);
- this.addDocument(dropped);
- return dropped;
- };
+ if (![de.complete.annoDragData.dragDocument.embedContainer, de.complete.annoDragData.dragDocument].includes(this.Document)) {
+ de.complete.annoDragData.dropDocCreator = () => this.getAnchor?.(true) || this.Document;
+ } else {
+ const dropCreator = de.complete.annoDragData.dropDocCreator;
+ de.complete.annoDragData.dropDocCreator = () => {
+ const dropped = dropCreator(this._props.isAnnotationOverlay ? this.Document : undefined);
+ this.addDocument(dropped);
+ return dropped;
+ };
+ }
return true;
}
return false;
@@ -415,7 +419,7 @@ export function CollectionSubView<X>() {
const tags = html.split('<');
if (tags[0] === '') tags.splice(0, 1);
let img = tags[0].startsWith('img') ? tags[0] : tags.length > 1 && tags[1].startsWith('img') ? tags[1] : '';
- const cors = img.includes('corsProxy') ? img.match(/http.*corsProxy\//)![0] : '';
+ const cors = img.includes('corsproxy') ? img.match(/http.*corsproxy\//)![0] : '';
img = cors ? img.replace(cors, '') : img;
if (img) {
const imgSrc = img.split('src="')[1].split('"')[0];
@@ -561,7 +565,17 @@ export function CollectionSubView<X>() {
}
const loading = Docs.Create.LoadingDocument(file, options);
Doc.addCurrentlyLoading(loading);
- DocUtils.uploadFileToDoc(file, {}, loading);
+ DocUtils.uploadFileToDoc(file, {}, loading).then(d => {
+ if (d && d?.type === DocumentType.IMG) {
+ const imgTemplate = DocCast(Doc.UserDoc().defaultImageLayout);
+ if (imgTemplate) {
+ const templateFieldKey = StrCast(imgTemplate.title);
+ d.layout_fieldKey = templateFieldKey;
+ d[templateFieldKey] = imgTemplate;
+ }
+ }
+ });
+
return loading;
})
))