aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/formattedText/DashDocView.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/formattedText/DashDocView.tsx')
-rw-r--r--src/client/views/nodes/formattedText/DashDocView.tsx45
1 files changed, 26 insertions, 19 deletions
diff --git a/src/client/views/nodes/formattedText/DashDocView.tsx b/src/client/views/nodes/formattedText/DashDocView.tsx
index c05a30d1a..c929b7ff3 100644
--- a/src/client/views/nodes/formattedText/DashDocView.tsx
+++ b/src/client/views/nodes/formattedText/DashDocView.tsx
@@ -41,18 +41,33 @@ export class DashDocView {
this.root = ReactDOM.createRoot(this.dom);
this.root.render(
- <DashDocViewInternal docId={node.attrs.docId} alias={node.attrs.alias} width={node.attrs.width} height={node.attrs.height} hidden={node.attrs.hidden} fieldKey={node.attrs.fieldKey} tbox={tbox} view={view} node={node} getPos={getPos} />
+ <DashDocViewInternal
+ docId={node.attrs.docId}
+ embedding={node.attrs.embedding}
+ width={node.attrs.width}
+ height={node.attrs.height}
+ hidden={node.attrs.hidden}
+ fieldKey={node.attrs.fieldKey}
+ tbox={tbox}
+ view={view}
+ node={node}
+ getPos={getPos}
+ />
);
}
destroy() {
- setTimeout(this.root.unmount);
+ setTimeout(() => {
+ try {
+ this.root.unmount();
+ } catch {}
+ });
}
selectNode() {}
}
interface IDashDocViewInternal {
docId: string;
- alias: string;
+ embedding: string;
tbox: FormattedTextBox;
width: string;
height: string;
@@ -69,25 +84,18 @@ export class DashDocViewInternal extends React.Component<IDashDocViewInternal> {
_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._finalLayout = dashDoc;
- 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
+ // bcz: an exception will be thrown if two embeddings 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,
@@ -105,15 +113,15 @@ export class DashDocViewInternal extends React.Component<IDashDocViewInternal> {
super(props);
this._textBox = this.props.tbox;
- DocServer.GetRefField(this.props.docId + this.props.alias).then(async dashDoc => {
+ DocServer.GetRefField(this.props.docId + this.props.embedding).then(async dashDoc => {
if (!(dashDoc instanceof Doc)) {
- this.props.alias &&
+ this.props.embedding &&
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);
+ const embedding = Doc.MakeEmbedding(dashDocBase, this.props.docId + this.props.embedding);
+ embedding.layout_fieldKey = 'layout';
+ this.props.fieldKey && DocUtils.makeCustomViewClicked(embedding, Docs.Create.StackingDocument, this.props.fieldKey, undefined);
+ this.updateDoc(embedding);
}
});
} else {
@@ -191,7 +199,6 @@ export class DashDocViewInternal extends React.Component<IDashDocViewInternal> {
onWheel={e => e.preventDefault()}>
<DocumentView
Document={this._finalLayout}
- DataDoc={this._resolvedDataDoc}
addDocument={returnFalse}
rootSelected={returnFalse} //{this._textBox.props.isSelected}
removeDocument={this.removeDoc}