aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/DocumentContentsView.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-01-25 00:07:39 -0500
committerGitHub <noreply@github.com>2024-01-25 00:07:39 -0500
commitbdcada2f285a3cdbefe55f5dc46836b7cbe6423d (patch)
tree0058dae39c9c9ebfe16f4659bd1fa98715260873 /src/client/views/nodes/DocumentContentsView.tsx
parenteae271b661465c915ea3a27ff25406409c4b377f (diff)
parentf71d5693bb2c7e79e459a97d9a855cd0542dd7e9 (diff)
Merge pull request #291 from brown-dash/UpgradingRedux
Upgrading redux
Diffstat (limited to 'src/client/views/nodes/DocumentContentsView.tsx')
-rw-r--r--src/client/views/nodes/DocumentContentsView.tsx35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index 4cc7fe4c8..07e179246 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -24,7 +24,6 @@ import { YoutubeBox } from './../../apis/youtube/YoutubeBox';
import { AudioBox } from './AudioBox';
import { ComparisonBox } from './ComparisonBox';
import { DataVizBox } from './DataVizBox/DataVizBox';
-import { DocumentViewProps } from './DocumentView';
import './DocumentView.scss';
import { EquationBox } from './EquationBox';
import { FieldView, FieldViewProps } from './FieldView';
@@ -114,14 +113,11 @@ export class HTMLtag extends React.Component<HTMLtagProps> {
}
}
+export interface DocumentContentsViewProps extends FieldViewProps {
+ layoutFieldKey: string;
+}
@observer
-export class DocumentContentsView extends ObservableReactComponent<
- DocumentViewProps &
- FieldViewProps & {
- setHeight?: (height: number) => void;
- layout_fieldKey: string;
- }
-> {
+export class DocumentContentsView extends ObservableReactComponent<DocumentContentsViewProps> {
constructor(props: any) {
super(props);
makeObservable(this);
@@ -131,8 +127,8 @@ export class DocumentContentsView extends ObservableReactComponent<
TraceMobx();
if (this._props.LayoutTemplateString) return this._props.LayoutTemplateString;
if (!this.layoutDoc) return '<p>awaiting layout</p>';
- if (this._props.layout_fieldKey === 'layout_keyValue') return StrCast(this._props.Document.layout_keyValue, KeyValueBox.LayoutString());
- const layout = Cast(this.layoutDoc[this.layoutDoc === this._props.Document && this._props.layout_fieldKey ? this._props.layout_fieldKey : StrCast(this.layoutDoc.layout_fieldKey, 'layout')], 'string');
+ if (this._props.layoutFieldKey === 'layout_keyValue') return StrCast(this._props.Document.layout_keyValue, KeyValueBox.LayoutString());
+ const layout = Cast(this.layoutDoc[this.layoutDoc === this._props.Document && this._props.layoutFieldKey ? this._props.layoutFieldKey : StrCast(this.layoutDoc.layout_fieldKey, 'layout')], 'string');
if (layout === undefined) return this._props.Document.data ? "<FieldView {...props} fieldKey='data' />" : KeyValueBox.LayoutString();
if (typeof layout === 'string') return layout;
return '<p>Loading layout</p>';
@@ -140,30 +136,31 @@ export class DocumentContentsView extends ObservableReactComponent<
get layoutDoc() {
// bcz: replaced this with below : is it correct? change was made to accommodate passing fieldKey's from a layout script
- // const template: Doc = this._props.LayoutTemplate?.() || Doc.Layout(this._props.Document, this._props.layout_fieldKey ? Cast(this._props.Document[this._props.layout_fieldKey], Doc, null) : undefined);
+ // const template: Doc = this._props.LayoutTemplate?.() || Doc.Layout(this._props.Document, this._props.fieldKey ? Cast(this._props.Document[this._props.fieldKey], Doc, null) : undefined);
const template: Doc =
this._props.LayoutTemplate?.() ||
(this._props.LayoutTemplateString && this._props.Document) ||
- (this._props.layout_fieldKey && StrCast(this._props.Document[this._props.layout_fieldKey]) && this._props.Document) ||
- Doc.Layout(this._props.Document, this._props.layout_fieldKey ? Cast(this._props.Document[this._props.layout_fieldKey], Doc, null) : undefined);
+ (this._props.layoutFieldKey && StrCast(this._props.Document[this._props.layoutFieldKey]) && this._props.Document) ||
+ Doc.Layout(this._props.Document, this._props.layoutFieldKey ? Cast(this._props.Document[this._props.layoutFieldKey], Doc, null) : undefined);
return Doc.expandTemplateLayout(template, this._props.Document);
}
CreateBindings(onClick: Opt<ScriptField>, onInput: Opt<ScriptField>): JsxBindings {
const docOnlyProps = [
- // these are the properties in DocumentViewProps that need to be removed to pass on only DocumentSharedViewProps to the FieldViews
+ // these are the properties in DocumentViewProps that need to be removed to pass on only DocumentSharedViewProps to the FieldViews
'hideResizeHandles',
'hideTitle',
- 'contentPointerEvents',
- 'radialMenu',
+ 'bringToFront',
+ 'childContentPointerEvents',
'LayoutTemplateString',
'LayoutTemplate',
+ 'layoutFieldKey',
'dontCenter',
'contextMenuItems',
//'onClick', // don't need to omit this since it will be set
- 'onDoubleClick',
- 'onPointerDown',
- 'onPointerUp',
+ 'onDoubleClickScript',
+ 'onPointerDownScript',
+ 'onPointerUpScript',
];
const templateDataDoc = this._props.TemplateDataDocument ?? (this.layoutDoc !== this._props.Document ? this._props.Document[DocData] : undefined);
const list: BindingProps & React.DetailedHTMLProps<React.HtmlHTMLAttributes<HTMLDivElement>, HTMLDivElement> = {