blob: e99bf67c7bc442a56a47ab4311c9b678fbecea07 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
//IGNORE FOR NOW, CURRENTLY NOT USED IN SCRAPBOOK IMPLEMENTATION
import * as React from "react";
import { observer } from "mobx-react";
import { Doc } from "../../../../fields/Doc";
import { DocumentView } from "../DocumentView";
import { Transform } from "../../../util/Transform";
interface EmbeddedDocViewProps {
doc: Doc;
width?: number;
height?: number;
slotId?: string;
}
@observer
export class EmbeddedDocView extends React.Component<EmbeddedDocViewProps> {
render() {
const { doc, width = 300, height = 200, slotId } = this.props;
// Use either an existing embedding or create one
let docToDisplay = doc;
// If we need an embedding, create or use one
if (!docToDisplay.isEmbedding) {
docToDisplay = Doc.BestEmbedding(doc) || Doc.MakeEmbedding(doc);
// Set the container to the slot's ID so we can track it
if (slotId) {
docToDisplay.embedContainer = `scrapbook-slot-${slotId}`;
}
}
return (
<DocumentView
Document={docToDisplay}
renderDepth={0}
// Required sizing functions
NativeWidth={() => width}
NativeHeight={() => height}
PanelWidth={() => width}
PanelHeight={() => height}
// Required state functions
isContentActive={() => true}
childFilters={() => []}
ScreenToLocalTransform={() => new Transform()}
// Display options
hideDeleteButton={true}
hideDecorations={true}
hideResizeHandles={true}
/>
);
}
}
|