aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/collections/CollectionStackingViewFieldColumn.tsx')
-rw-r--r--src/client/views/collections/CollectionStackingViewFieldColumn.tsx26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/client/views/collections/CollectionStackingViewFieldColumn.tsx b/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
index ed0cabd0a..6f32dd2e0 100644
--- a/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
+++ b/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
@@ -2,7 +2,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { action, computed, IReactionDisposer, makeObservable, observable, reaction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
-import { DivHeight, DivWidth, returnEmptyString, setupMoveUpEvents } from '../../../ClientUtils';
+import { DivHeight, DivWidth, returnEmptyString, returnTrue, setupMoveUpEvents } from '../../../ClientUtils';
import { Doc, DocListCast, Opt } from '../../../fields/Doc';
import { RichTextField } from '../../../fields/RichTextField';
import { PastelSchemaPalette, SchemaHeaderField } from '../../../fields/SchemaHeaderField';
@@ -23,7 +23,7 @@ import { undoBatch } from '../../util/UndoManager';
import { ContextMenu } from '../ContextMenu';
import { ContextMenuProps } from '../ContextMenuItem';
import { EditableView } from '../EditableView';
-import { FormattedTextBox } from '../nodes/formattedText/FormattedTextBox';
+import { DocumentView } from '../nodes/DocumentView';
import { ObservableReactComponent } from '../ObservableReactComponent';
import './CollectionStackingView.scss';
@@ -149,19 +149,14 @@ export class CollectionStackingViewFieldColumn extends ObservableReactComponent<
@action pointerEntered = () => { SnappingManager.IsDragging && (this._background = '#b4b4b4'); } // prettier-ignore
@action pointerLeave = () => { this._background = 'inherit'}; // prettier-ignore
- @undoBatch typedNote = () => this.addNewTextDoc('-typed text-', false, true);
-
- @action
- addNewTextDoc = (value: string, shiftDown?: boolean, forceEmptyNote?: boolean) => {
- if (!value && !forceEmptyNote) return false;
+ @undoBatch typedNote = () => {
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 });
key && (newDoc[key] = this.getValue(this._props.heading));
const maxHeading = this._props.docList.reduce((prevHeading, doc) => (NumCast(doc.heading) > prevHeading ? NumCast(doc.heading) : prevHeading), 0);
const heading = maxHeading === 0 || this._props.docList.length === 0 ? 1 : maxHeading === 1 ? 2 : 3;
newDoc.heading = heading;
- Doc.SetSelectOnLoad(newDoc);
- FormattedTextBox.SelectOnLoadChar = forceEmptyNote ? '' : ' ';
+ DocumentView.SetSelectOnLoad(newDoc);
return this._props.addDocument?.(newDoc) || false;
};
@@ -240,7 +235,7 @@ export class CollectionStackingViewFieldColumn extends ObservableReactComponent<
const height = this._ele ? DivHeight(this._ele) : 0;
DocUtils.addDocumentCreatorMenuItems(
doc => {
- Doc.SetSelectOnLoad(doc);
+ DocumentView.SetSelectOnLoad(doc);
return this._props.addDocument?.(doc);
},
this._props.addDocument,
@@ -394,14 +389,7 @@ export class CollectionStackingViewFieldColumn extends ObservableReactComponent<
onKeyDown={e => e.stopPropagation()}
className="collectionStackingView-addDocumentButton"
style={{ width: 'calc(100% - 25px)', maxWidth: this._props.columnWidth / this._props.numGroupColumns - 25, marginBottom: 10 }}>
- <EditableView
- GetValue={returnEmptyString}
- SetValue={this.addNewTextDoc}
- textCallback={this.typedNote}
- placeholder={"Type ':' for commands"}
- contents={<FontAwesomeIcon icon="plus" />}
- menuCallback={this.menuCallback}
- />
+ <EditableView GetValue={returnEmptyString} SetValue={returnTrue} textCallback={this.typedNote} placeholder={"Type ':' for commands"} contents={<FontAwesomeIcon icon="plus" />} menuCallback={this.menuCallback} />
</div>
) : null}
</div>