aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionNoteTakingView.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/collections/CollectionNoteTakingView.tsx')
-rw-r--r--src/client/views/collections/CollectionNoteTakingView.tsx54
1 files changed, 25 insertions, 29 deletions
diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx
index 302ccd2db..b8133806f 100644
--- a/src/client/views/collections/CollectionNoteTakingView.tsx
+++ b/src/client/views/collections/CollectionNoteTakingView.tsx
@@ -1,6 +1,6 @@
-import * as React from 'react';
import { action, computed, IReactionDisposer, makeObservable, observable, reaction } from 'mobx';
import { observer } from 'mobx-react';
+import * as React from 'react';
import { Doc, Field, Opt } from '../../../fields/Doc';
import { DocData } from '../../../fields/DocSymbols';
import { Copy, Id } from '../../../fields/FieldSymbols';
@@ -18,14 +18,15 @@ import { undoBatch } from '../../util/UndoManager';
import { ContextMenu } from '../ContextMenu';
import { ContextMenuProps } from '../ContextMenuItem';
import { LightboxView } from '../LightboxView';
-import { DocFocusOptions, DocumentView, DocumentViewInternalProps, DocumentViewProps } from '../nodes/DocumentView';
-import { FieldViewProps } from '../nodes/FieldView';
+import { DocumentView } from '../nodes/DocumentView';
+import { FocusViewOptions, FieldViewProps } from '../nodes/FieldView';
import { FormattedTextBox } from '../nodes/formattedText/FormattedTextBox';
import { StyleProp } from '../StyleProvider';
import './CollectionNoteTakingView.scss';
import { CollectionNoteTakingViewColumn } from './CollectionNoteTakingViewColumn';
import { CollectionNoteTakingViewDivider } from './CollectionNoteTakingViewDivider';
import { CollectionSubView } from './CollectionSubView';
+import { JsxElement } from 'typescript';
const _global = (window /* browser */ || global) /* node */ as any;
/**
@@ -51,7 +52,7 @@ export class CollectionNoteTakingView extends CollectionSubView() {
}
@computed get chromeHidden() {
- return BoolCast(this.layoutDoc.chromeHidden) || this._props.onBrowseClick?.() ? true : false;
+ return BoolCast(this.layoutDoc.chromeHidden) || this._props.onBrowseClickScript?.() ? true : false;
}
// columnHeaders returns the list of SchemaHeaderFields currently being used by the layout doc to render the columns
@computed get colHeaderData() {
@@ -189,7 +190,7 @@ export class CollectionNoteTakingView extends CollectionSubView() {
};
// let's dive in and get the actual document we want to drag/move around
- focusDocument = (doc: Doc, options: DocFocusOptions) => {
+ focusDocument = (doc: Doc, options: FocusViewOptions) => {
Doc.BrushDoc(doc);
const found = this._mainCont && Array.from(this._mainCont.getElementsByClassName('documentView-node')).find((node: any) => node.id === doc[Id]);
if (found) {
@@ -203,7 +204,7 @@ export class CollectionNoteTakingView extends CollectionSubView() {
}
};
- styleProvider = (doc: Doc | undefined, props: Opt<DocumentViewInternalProps | FieldViewProps>, property: string) => {
+ styleProvider = (doc: Doc | undefined, props: Opt<FieldViewProps>, property: string) => {
switch (property) {
case StyleProp.BoxShadow:
if (doc && DragManager.docsBeingDragged.includes(doc)) {
@@ -238,7 +239,7 @@ export class CollectionNoteTakingView extends CollectionSubView() {
PanelWidth={width}
PanelHeight={height}
styleProvider={this.styleProvider}
- docViewPath={this._props.docViewPath}
+ containerViewPath={this.childContainerViewPath}
layout_fitWidth={this._props.childLayoutFitWidth}
isContentActive={emptyFunction}
onKey={this.onKeyDown}
@@ -254,9 +255,9 @@ export class CollectionNoteTakingView extends CollectionSubView() {
rootSelected={this.rootSelected}
layout_showTitle={this._props.childlayout_showTitle}
dragAction={StrCast(this.layoutDoc.childDragAction) as dropActionType}
- onClick={this.onChildClickHandler}
- onBrowseClick={this._props.onBrowseClick}
- onDoubleClick={this.onChildDoubleClickHandler}
+ onClickScript={this.onChildClickHandler}
+ onBrowseClickScript={this._props.onBrowseClickScript}
+ onDoubleClickScript={this.onChildDoubleClickHandler}
ScreenToLocalTransform={noteTakingDocTransform}
focus={this.focusDocument}
childFilters={this.childDocFilters}
@@ -267,10 +268,9 @@ export class CollectionNoteTakingView extends CollectionSubView() {
addDocument={this._props.addDocument}
moveDocument={this._props.moveDocument}
removeDocument={this._props.removeDocument}
- contentPointerEvents={StrCast(this.layoutDoc.contentPointerEvents) as any}
+ contentPointerEvents={StrCast(this.layoutDoc.childContentPointerEvents) as any}
whenChildContentsActiveChanged={this._props.whenChildContentsActiveChanged}
addDocTab={this._props.addDocTab}
- bringToFront={returnFalse}
pinToPres={this._props.pinToPres}
/>
);
@@ -407,11 +407,10 @@ export class CollectionNoteTakingView extends CollectionSubView() {
@undoBatch
onKeyDown = (e: React.KeyboardEvent, fieldProps: FieldViewProps) => {
- const docView = fieldProps.DocumentView?.();
- if (docView && (e.ctrlKey || docView.Document._createDocOnCR) && ['Enter'].includes(e.key)) {
+ if ((e.ctrlKey || fieldProps.Document._createDocOnCR) && ['Enter'].includes(e.key)) {
e.stopPropagation?.();
- const newDoc = Doc.MakeCopy(docView.Document, true);
- Doc.GetProto(newDoc).text = undefined;
+ const newDoc = Doc.MakeCopy(fieldProps.Document, true);
+ newDoc[DocData].text = undefined;
FormattedTextBox.SetSelectOnLoad(newDoc);
return this.addDocument?.(newDoc);
}
@@ -443,7 +442,7 @@ export class CollectionNoteTakingView extends CollectionSubView() {
}
return true;
}
- } else if (de.complete.linkDragData?.dragDocument.embedContainer === this._props.Document && de.complete.linkDragData?.linkDragView?.CollectionFreeFormDocumentView) {
+ } else if (de.complete.linkDragData?.dragDocument.embedContainer === this.Document && de.complete.linkDragData?.linkDragView?.CollectionFreeFormDocumentView) {
const source = Docs.Create.TextDocument('', { _width: 200, _height: 75, _layout_fitWidth: true, title: 'dropped annotation' });
if (!this._props.addDocument?.(source)) e.preventDefault();
de.complete.linkDocument = DocUtils.MakeLink(source, de.complete.linkDragData.linkSourceGetAnchor(), { link_relationship: 'doc annotation' }); // TODODO this is where in text links get passed
@@ -503,6 +502,7 @@ export class CollectionNoteTakingView extends CollectionSubView() {
const type = 'number';
return (
<CollectionNoteTakingViewColumn
+ key={heading?.heading ?? 'unset'}
unobserveHeight={ref => this.refList.splice(this.refList.indexOf(ref), 1)}
observeHeight={ref => {
if (ref) {
@@ -511,7 +511,7 @@ export class CollectionNoteTakingView extends CollectionSubView() {
action((entries: any) => {
if (this.layoutDoc._layout_autoHeight && ref && this.refList.length && !SnappingManager.IsDragging) {
const height = this.headerMargin + Math.min(NumCast(this.layoutDoc._maxHeight, Number.MAX_SAFE_INTEGER), Math.max(...this.refList.map(r => Number(getComputedStyle(r).height.replace('px', '')))));
- if (!LightboxView.IsLightboxDocView(this._props.docViewPath())) {
+ if (!LightboxView.Contains(this.DocumentView?.())) {
this._props.setHeight?.(height);
}
}
@@ -536,7 +536,6 @@ export class CollectionNoteTakingView extends CollectionSubView() {
dividerWidth={this.DividerWidth}
maxColWidth={this.maxColWidth}
availableWidth={this.availableWidth}
- key={heading?.heading ?? 'unset'}
headings={this.headings}
heading={heading?.heading ?? 'unset'}
headingObject={heading}
@@ -598,14 +597,11 @@ export class CollectionNoteTakingView extends CollectionSubView() {
@computed get renderedSections() {
TraceMobx();
const sections = Array.from(this.Sections.entries());
- return sections.map((sec, i) => (
- <>
- {this.sectionNoteTaking(sec[0], sec[1])}
- {i === sections.length - 1 ? null : ( //
- <CollectionNoteTakingViewDivider key={`divider${i}`} isContentActive={this.isContentActive} index={i} setColumnStartXCoords={this.setColumnStartXCoords} xMargin={this.xMargin} />
- )}
- </>
- ));
+ return sections.reduce((list, sec, i) => {
+ list.push(this.sectionNoteTaking(sec[0], sec[1]));
+ i !== sections.length - 1 && list.push(<CollectionNoteTakingViewDivider key={`divider${i}`} isContentActive={this.isContentActive} index={i} setColumnStartXCoords={this.setColumnStartXCoords} xMargin={this.xMargin} />);
+ return list;
+ }, [] as JSX.Element[]);
}
@computed get nativeWidth() {
@@ -643,8 +639,8 @@ export class CollectionNoteTakingView extends CollectionSubView() {
onDragOver={e => this.onPointerMove(true, e.clientX, e.clientY)}
onDrop={this.onExternalDrop.bind(this)}
onContextMenu={this.onContextMenu}
- onWheel={e => this._props.isContentActive(true) && e.stopPropagation()}>
- {this.renderedSections}
+ onWheel={e => this._props.isContentActive() && e.stopPropagation()}>
+ <>{this.renderedSections}</>
</div>
);
}