//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}
            />
        );
    }
}