diff options
| author | bobzel <zzzman@gmail.com> | 2020-09-20 23:53:04 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2020-09-20 23:53:04 -0400 |
| commit | e4ae6fa6df6bb0118f113bbdf3a40f768405f7b3 (patch) | |
| tree | d6b59231fc2ad1e729abfb472d0fa5bf407e122c /src/client/views/collections/CollectionTreeView.tsx | |
| parent | f87037b13e0c97d1c9383ac023c8358963a58cff (diff) | |
fixed undo for bullet points to not take multiple steps and to work properly. no longer adds cursorfiels to the undo stack. fixed sharing manager to no create unnecesary documents..
Diffstat (limited to 'src/client/views/collections/CollectionTreeView.tsx')
| -rw-r--r-- | src/client/views/collections/CollectionTreeView.tsx | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx index e61b9624a..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[]) => |
