diff options
| author | bobzel <zzzman@gmail.com> | 2025-03-23 18:14:31 -0400 | 
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2025-03-23 18:14:31 -0400 | 
| commit | 705975eb43e7904c62e7e847478f6d0dac60d443 (patch) | |
| tree | c4831c2c12c400608889db39b4888a70e99f9d48 /src/client/views/DocComponent.tsx | |
| parent | 7db1a5d9bac676a1874c14cb8bba734fbdc7181e (diff) | |
more _props.Document  to .Document refactoring.  type updates to prosemirrortransfer
Diffstat (limited to 'src/client/views/DocComponent.tsx')
| -rw-r--r-- | src/client/views/DocComponent.tsx | 85 | 
1 files changed, 63 insertions, 22 deletions
| diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx index a311f6436..8f254ddcd 100644 --- a/src/client/views/DocComponent.tsx +++ b/src/client/views/DocComponent.tsx @@ -30,26 +30,40 @@ export function DocComponent<P extends DocComponentProps>() {          }          /** -         * This is the document being rendered.  In the case of a compound template, it -         * may not be the actual document rendered and it also may not be the 'real' root document. -         * Rather, it specifies the shared properties of all layouts of the document (eg, x,y,) +         * This is the doc that is being rendered. It will be either: +         *   1) the same as Document if the root of a regular or compound Doc is rendered +         *   2) the same as the layoutDoc if a component of a compound Doc is rendered. +         * NOTE: it is very unlikely that you really want to use this method. Instead +         *       consider: Document, layoutDoc, dataDoc           */ -        get Document() { -            return DocCast(this._props.Document.rootDocument, this._props.Document); +        get _renderDoc() { +            return this._props.Document;          }          /** -         * This is the document being rendered.  It may be a template so it may or may no inherit from the data doc. +         * This is the "root" Doc being rendered.  In the case of a compound template Doc, +         * this is the outermost Doc that represents the entire compound Doc.  It is not +         * necessarily the Doc being rendered in the current React component. +         * This Doc inherits from the dataDoc, and may or may not inherit (or be) the layoutDoc. +         */ +        get Document() { +            return DocCast(this._renderDoc.rootDocument, this._renderDoc); +        } +        /** +         * This is the document being rendered by the React component. In the +         * case of a compound template, this will be the  expanded template Doc +         * that represents the component of the compound Doc being rendered. +         * This may or may not inherit from the data doc.           */          @computed get layoutDoc() { -            return this._props.LayoutTemplateString ? this._props.Document : Doc.Layout(this._props.Document, this._props.LayoutTemplate?.()); +            return this._props.LayoutTemplateString ? this._renderDoc : Doc.Layout(this._renderDoc, this._props.LayoutTemplate?.());          }          /** -         * This is the unique data repository for a dcoument that stores the intrinsic document data +         * This is the unique data repository for a document that stores the intrinsic document data.           */          @computed get dataDoc() { -            return this._props.Document[DocData]; +            return this._renderDoc[DocData];          }      }      return Component; @@ -75,25 +89,40 @@ export function ViewBoxBaseComponent<P extends FieldViewProps>() {          }          /** -         * This is the document being rendered.  In the case of a compound template, it -         * may not be the actual document rendered and it also may not be the 'real' root document. -         * Rather, it specifies the shared properties of all layouts of the document (eg, x,y,) +         * This is the doc that is being rendered. It will be either: +         *   1) the same as Document if the root of a regular or compound Doc is rendered +         *   2) the same as the layoutDoc if a component of a compound Doc is rendered. +         * NOTE: it is very unlikely that you really want to use this method. Instead +         *       consider: Document, layoutDoc, dataDoc +         */ +        get _renderDoc() { +            return this._props.Document; +        } + +        /** +         * This is the "root" Doc being rendered.  In the case of a compound template Doc, +         * this is the outermost Doc that represents the entire compound Doc.  It is not +         * necessarily the Doc being rendered in the current React component. +         * This Doc inherits from the dataDoc, and may or may not inherit (or be) the layoutDoc.           */          get Document() { -            return DocCast(this._props.Document.rootDocument, this._props.Document); +            return DocCast(this._renderDoc.rootDocument, this._renderDoc);          }          /** -         * This is the document being rendered.  It may be a template so it may or may no inherit from the data doc. +         * This is the document being rendered by the React component. In the +         * case of a compound template, this will be the  expanded template Doc +         * that represents the component of the compound Doc being rendered. +         * This may or may not inherit from the data doc.           */          @computed get layoutDoc() { -            return Doc.Layout(this._props.Document); +            return Doc.Layout(this._renderDoc);          }          /**           * This is the unique data repository for a dcoument that stores the intrinsic document data           */          @computed get dataDoc() { -            return this._props.Document.isTemplateForField || this._props.Document.isTemplateDoc ? (this._props.TemplateDataDocument ?? this._props.Document[DocData]) : this._props.Document[DocData]; +            return this._renderDoc.isTemplateForField || this._renderDoc.isTemplateDoc ? (this._props.TemplateDataDocument ?? this._renderDoc[DocData]) : this._renderDoc[DocData];          }          /** @@ -133,25 +162,37 @@ export function ViewBoxAnnotatableComponent<P extends FieldViewProps>() {          }          /** -         * This is the document being rendered.  In the case of a compound template, it -         * may not be the actual document rendered and it also may not be the 'real' root document. -         * Rather, it specifies the shared properties of all layouts of the document (eg, x,y,) +         * This is the doc that is being rendered. It will be either: +         *   1) the same as Document if the root of a regular or compound Doc is rendered +         *   2) the same as the layoutDoc if a component of a compound Doc is rendered. +         * NOTE: it would unlikely that you really want to use this instead of the +         *       other Doc options (Document, layoutDoc, dataDoc) +         */ +        get _renderDoc() { +            return this._props.Document; +        } + +        /** +         * This is the "root" Doc being rendered.  In the case of a compound template Doc, +         * this is the outermost Doc that represents the entire compound Doc.  It is not +         * necessarily the Doc being rendered in the current React component. +         * This Doc inherits from the dataDoc, and may or may not inherit (or be) the layoutDoc.           */          @computed get Document() { -            return DocCast(this._props.Document.rootDocument, this._props.Document); +            return DocCast(this._renderDoc.rootDocument, this._renderDoc);          }          /**           * This is the document being rendered.  It may be a template so it may or may no inherit from the data doc.           */          @computed get layoutDoc() { -            return Doc.Layout(this._props.Document); +            return Doc.Layout(this._renderDoc);          }          /**           * This is the unique data repository for a dcoument that stores the intrinsic document data           */          @computed get dataDoc() { -            return this._props.Document.isTemplateForField || this._props.Document.isTemplateDoc ? (this._props.TemplateDataDocument ?? this._props.Document[DocData]) : this._props.Document[DocData]; +            return this._renderDoc.isTemplateForField || this._renderDoc.isTemplateDoc ? (this._props.TemplateDataDocument ?? this._renderDoc[DocData]) : this._props.Document[DocData];          }          /** | 
