();
    _disposers: { [name: string]: IReactionDisposer } = {};
    _textBox: FormattedTextBox;
    @observable _dashDoc: Doc | undefined;
    @observable _finalLayout: any;
    @observable _resolvedDataDoc: any;
    @observable _width: number = 0;
    @observable _height: number = 0;
    updateDoc = action((dashDoc: Doc) => {
        this._dashDoc = dashDoc;
        this._finalLayout = this.props.docid ? dashDoc : Doc.expandTemplateLayout(Doc.Layout(dashDoc), dashDoc, this.props.fieldKey);
        if (this._finalLayout) {
            if (!Doc.AreProtosEqual(this._finalLayout, dashDoc)) {
                this._finalLayout.rootDocument = dashDoc.aliasOf;
            }
            this._resolvedDataDoc = Cast(this._finalLayout.resolvedDataDoc, Doc, null);
        }
        if (this.props.width !== (this._dashDoc?._width ?? '') + 'px' || this.props.height !== (this._dashDoc?._height ?? '') + 'px') {
            try {
                this._width = NumCast(this._dashDoc?._width);
                this._height = NumCast(this._dashDoc?._height);
                // bcz: an exception will be thrown if two aliases are open at the same time when a doc view comment is made
                this.props.view.dispatch(
                    this.props.view.state.tr.setNodeMarkup(this.props.getPos(), null, {
                        ...this.props.node.attrs,
                        width: this._width + 'px',
                        height: this._height + 'px',
                    })
                );
            } catch (e) {
                console.log('DashDocView:' + e);
            }
        }
    });
    constructor(props: IDashDocViewInternal) {
        super(props);
        this._textBox = this.props.tbox;
        DocServer.GetRefField(this.props.docid + this.props.alias).then(async dashDoc => {
            if (!(dashDoc instanceof Doc)) {
                this.props.alias &&
                    DocServer.GetRefField(this.props.docid).then(async dashDocBase => {
                        if (dashDocBase instanceof Doc) {
                            const aliasedDoc = Doc.MakeAlias(dashDocBase, this.props.docid + this.props.alias);
                            aliasedDoc.layoutKey = 'layout';
                            this.props.fieldKey && DocUtils.makeCustomViewClicked(aliasedDoc, Docs.Create.StackingDocument, this.props.fieldKey, undefined);
                            this.updateDoc(aliasedDoc);
                        }
                    });
            } else {
                this.updateDoc(dashDoc);
            }
        });
    }
    componentDidMount() {
        this._disposers.upater = reaction(
            () => this._dashDoc && NumCast(this._dashDoc._height) + NumCast(this._dashDoc._width),
            action(() => {
                if (this._dashDoc) {
                    this._width = NumCast(this._dashDoc._width);
                    this._height = NumCast(this._dashDoc._height);
                    const parent = this._spanRef.current?.parentNode as HTMLElement;
                    if (parent) {
                        parent.style.width = this._width + 'px';
                        parent.style.height = this._height + 'px';
                    }
                }
            })
        );
    }
    removeDoc = () => {
        this.props.view.dispatch(this.props.view.state.tr.setSelection(new NodeSelection(this.props.view.state.doc.resolve(this.props.getPos()))).deleteSelection());
        return true;
    };
    getDocTransform = () => {
        if (!this._spanRef.current) return Transform.Identity();
        const { scale, translateX, translateY } = Utils.GetScreenTransform(this._spanRef.current);
        return new Transform(-translateX, -translateY, 1).scale(1 / scale);
    };
    outerFocus = (target: Doc) => this._textBox.props.focus(this._textBox.props.Document, {}); // ideally, this would scroll to show the focus target
    onKeyDown = (e: any) => {
        e.stopPropagation();
        if (e.key === 'Tab' || e.key === 'Enter') {
            e.preventDefault();
        }
    };
    onPointerLeave = () => {
        const ele = document.getElementById('DashDocCommentView-' + this.props.docid) as HTMLDivElement;
        ele && (ele.style.backgroundColor = '');
    };
    onPointerEnter = () => {
        const ele = document.getElementById('DashDocCommentView-' + this.props.docid) as HTMLDivElement;
        ele && (ele.style.backgroundColor = 'orange');
    };
    componentWillUnmount = () => Object.values(this._disposers).forEach(disposer => disposer?.());
    render() {
        return !this._dashDoc || !this._finalLayout || this.props.hidden ? null : (
             e.stopPropagation()}
                onKeyUp={e => e.stopPropagation()}
                onWheel={e => e.preventDefault()}>
                
            
        );
    }
}