aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/collections/CollectionNoteTakingViewColumn.tsx')
-rw-r--r--src/client/views/collections/CollectionNoteTakingViewColumn.tsx38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
index 8c6a6b551..40b3f9ef2 100644
--- a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
+++ b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
@@ -1,8 +1,8 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { action, computed, makeObservable, observable } from 'mobx';
+import { action, computed, makeObservable, observable, runInAction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
-import { lightOrDark, returnEmptyString } from '../../../ClientUtils';
+import { lightOrDark, returnEmptyString, returnTrue } from '../../../ClientUtils';
import { Doc, Opt } from '../../../fields/Doc';
import { listSpec } from '../../../fields/Schema';
import { SchemaHeaderField } from '../../../fields/SchemaHeaderField';
@@ -17,8 +17,8 @@ import { undoBatch, undoable } from '../../util/UndoManager';
import { ContextMenu } from '../ContextMenu';
import { EditableProps, EditableView } from '../EditableView';
import { ObservableReactComponent } from '../ObservableReactComponent';
-import { FormattedTextBox } from '../nodes/formattedText/FormattedTextBox';
import './CollectionNoteTakingView.scss';
+import { DocumentView } from '../nodes/DocumentView';
interface CSVFieldColumnProps {
Document: Doc;
@@ -87,12 +87,16 @@ export class CollectionNoteTakingViewColumn extends ObservableReactComponent<CSV
};
componentDidMount(): void {
- this._ele && this.props.refList.push(this._ele);
+ runInAction(() => {
+ this._ele && this.props.refList.push(this._ele);
+ });
}
componentWillUnmount() {
- this._ele && this.props.refList.splice(this._props.refList.indexOf(this._ele), 1);
- this._ele = null;
+ runInAction(() => {
+ this._ele && this.props.refList.splice(this._props.refList.indexOf(this._ele), 1);
+ this._ele = null;
+ });
}
@undoBatch
@@ -136,20 +140,15 @@ export class CollectionNoteTakingViewColumn extends ObservableReactComponent<CSV
this._hover = false;
};
- addTextNote = undoable(() => this.addNewTextDoc('-typed text-', false, true), 'add text note');
-
// addNewTextDoc is called when a user starts typing in a column to create a new node
- @action
- addNewTextDoc = (value: string, shiftDown?: boolean, forceEmptyNote?: boolean) => {
- if (!value && !forceEmptyNote) return false;
+ addTextNote = undoable(() => {
const key = this._props.pivotField;
- const newDoc = Docs.Create.TextDocument(value, { _height: 18, _width: 200, _layout_fitWidth: true, title: value, _layout_autoHeight: true });
+ const newDoc = Docs.Create.TextDocument('', { _height: 18, _width: 200, _layout_fitWidth: true, _layout_autoHeight: true });
const colValue = this.getValue(this._props.heading);
newDoc[key] = colValue;
- Doc.SetSelectOnLoad(newDoc);
- FormattedTextBox.SelectOnLoadChar = forceEmptyNote ? '' : ' ';
+ DocumentView.SetSelectOnLoad(newDoc);
return this._props.addDocument?.(newDoc) || false;
- };
+ }, 'add text note');
// deleteColumn is called when a user deletes a column using the 'trash' icon in the button area.
// If the user deletes the first column, the documents get moved to the second column. Otherwise,
@@ -173,7 +172,7 @@ export class CollectionNoteTakingViewColumn extends ObservableReactComponent<CSV
doc => {
const key = this._props.pivotField;
doc[key] = this.getValue(this._props.heading);
- Doc.SetSelectOnLoad(doc);
+ DocumentView.SetSelectOnLoad(doc);
return this._props.addDocument?.(doc);
},
this._props.addDocument,
@@ -245,13 +244,10 @@ export class CollectionNoteTakingViewColumn extends ObservableReactComponent<CSV
{!this._props.chromeHidden ? (
<div className="collectionNoteTakingView-DocumentButtons" style={{ display: this._props.isContentActive() ? 'flex' : 'none', marginBottom: 10 }}>
<div className="collectionNoteTakingView-addDocumentButton" style={{ color: lightOrDark(this._props.backgroundColor?.()) }}>
- <EditableView GetValue={returnEmptyString} SetValue={this.addNewTextDoc} textCallback={this.addTextNote} placeholder={"Type ':' for commands"} contents="+ Node" menuCallback={this.menuCallback} />
+ <EditableView GetValue={returnEmptyString} SetValue={returnTrue} textCallback={this.addTextNote} placeholder={"Type ':' for commands"} contents="+ Node" menuCallback={this.menuCallback} />
</div>
<div className="collectionNoteTakingView-addDocumentButton" style={{ color: lightOrDark(this._props.backgroundColor?.()) }}>
- {
- // eslint-disable-next-line react/jsx-props-no-spreading
- <EditableView {...this._props.editableViewProps()} />
- }
+ <EditableView {...this._props.editableViewProps()} />
</div>
</div>
) : null}