diff options
| author | Geireann Lindfield Roberts <60007097+geireann@users.noreply.github.com> | 2020-09-21 21:47:46 +0800 | 
|---|---|---|
| committer | Geireann Lindfield Roberts <60007097+geireann@users.noreply.github.com> | 2020-09-21 21:47:46 +0800 | 
| commit | fd21e351a23b395847da11c3523dbac0038321f3 (patch) | |
| tree | 31dedbc9aae622a713bc1ab41c4b8fd6455fe132 /src/client/views/collections/CollectionTreeView.tsx | |
| parent | 17f0a7a33fdea46bac50b5cb0d45c9278e41b821 (diff) | |
| parent | 6ecfe48643917e5dc774ff39a84c5bef47f0d3b9 (diff) | |
Merge branch 'master' into presentation_v1
Diffstat (limited to 'src/client/views/collections/CollectionTreeView.tsx')
| -rw-r--r-- | src/client/views/collections/CollectionTreeView.tsx | 16 | 
1 files changed, 12 insertions, 4 deletions
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx index 46f18099a..efbe5581b 100644 --- a/src/client/views/collections/CollectionTreeView.tsx +++ b/src/client/views/collections/CollectionTreeView.tsx @@ -24,6 +24,8 @@ import { CollectionSubView } from "./CollectionSubView";  import "./CollectionTreeView.scss";  import { TreeView } from "./TreeView";  import React = require("react"); +import { DocumentManager } from '../../util/DocumentManager'; +import { FormattedTextBoxComment } from '../nodes/formattedText/FormattedTextBoxComment';  export type collectionTreeViewProps = {      treeViewHideTitle?: boolean; @@ -61,19 +63,26 @@ export class CollectionTreeView extends CollectionSubView<Document, Partial<coll          this.treedropDisposer?.();      } -    @action -    remove = (doc: Doc | Doc[]): boolean => { +    @undoBatch +    remove = action((doc: Doc | Doc[]): boolean => {          const docs = doc instanceof Doc ? [doc] : doc;          const targetDataDoc = this.doc[DataSym];          const value = DocListCast(targetDataDoc[this.props.fieldKey]);          const result = value.filter(v => !docs.includes(v));          SelectionManager.DeselectAll();          if (result.length !== value.length) { +            const ind = targetDataDoc[this.props.fieldKey].indexOf(doc);              targetDataDoc[this.props.fieldKey] = new List<Doc>(result); +            if (ind > 0) { +                const prev = targetDataDoc[this.props.fieldKey][ind - 1]; +                FormattedTextBox.SelectOnLoad = prev[Id]; +                const prevView = DocumentManager.Instance.getDocumentView(prev, this.props.CollectionView); +                prevView?.select(false); +            }              return true;          }          return false; -    } +    })      @action      addDoc = (doc: Doc | Doc[], relativeTo: Opt<Doc>, before?: boolean): boolean => {          const doAddDoc = (doc: Doc | Doc[]) => @@ -121,7 +130,6 @@ export class CollectionTreeView extends CollectionSubView<Document, Partial<coll          const bullet = TreeView.makeTextBullet();          bullet.context = this.doc;          this.addDoc(bullet, childDocs.length ? childDocs[0] : undefined, true); -        setTimeout(() => RichTextMenu.Instance.TextView?.EditorView?.focus(), 150);      });      editableTitle = (childDocs: Doc[]) => {  | 
