aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionTreeView.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/collections/CollectionTreeView.tsx')
-rw-r--r--src/client/views/collections/CollectionTreeView.tsx16
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[]) => {