aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/GlobalKeyHandler.ts
diff options
context:
space:
mode:
authorMelissa Zhang <mzhang19096@gmail.com>2020-08-07 09:40:06 -0700
committerMelissa Zhang <mzhang19096@gmail.com>2020-08-07 09:40:06 -0700
commit9886ed681ff18a33f7acab8f83b475ca9ea60bf7 (patch)
tree0b69d4b0fbfc52eac07c2e38fdbb34f161a2dc98 /src/client/views/GlobalKeyHandler.ts
parentc94a61aa594f77db4c9b08a5f91c1a7e57d5ff9d (diff)
parentb02cfed890d9d95a8f45bbc93d688bd3311dd387 (diff)
merge with master
Diffstat (limited to 'src/client/views/GlobalKeyHandler.ts')
-rw-r--r--src/client/views/GlobalKeyHandler.ts17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts
index b4a518326..0ea02e3cb 100644
--- a/src/client/views/GlobalKeyHandler.ts
+++ b/src/client/views/GlobalKeyHandler.ts
@@ -1,6 +1,6 @@
import { action } from "mobx";
import { DateField } from "../../fields/DateField";
-import { Doc, DocListCast } from "../../fields/Doc";
+import { Doc, DocListCast, AclEdit, AclAdmin } from "../../fields/Doc";
import { Id } from "../../fields/FieldSymbols";
import { InkTool } from "../../fields/InkField";
import { List } from "../../fields/List";
@@ -23,6 +23,7 @@ import PDFMenu from "./pdf/PDFMenu";
import { ContextMenu } from "./ContextMenu";
import GroupManager from "../util/GroupManager";
import { CollectionFreeFormViewChrome } from "./collections/CollectionMenu";
+import { GetEffectiveAcl } from "../../fields/util";
const modifiers = ["control", "meta", "shift", "alt"];
type KeyHandler = (keycode: string, e: KeyboardEvent) => KeyControlInfo | Promise<KeyControlInfo>;
@@ -116,8 +117,18 @@ export default class KeyManager {
return { stopPropagation: false, preventDefault: false };
}
}
- UndoManager.RunInBatch(() =>
- SelectionManager.SelectedDocuments().map(dv => dv.props.removeDocument?.(dv.props.Document)), "delete");
+
+ const recent = Cast(Doc.UserDoc().myRecentlyClosed, Doc) as Doc;
+ const selected = SelectionManager.SelectedDocuments().slice();
+ UndoManager.RunInBatch(() => {
+ selected.map(dv => {
+ const effectiveAcl = GetEffectiveAcl(dv.props.Document);
+ if (effectiveAcl === AclEdit || effectiveAcl === AclAdmin) { // deletes whatever you have the right to delete
+ recent && Doc.AddDocToList(recent, "data", dv.props.Document, undefined, true, true);
+ dv.props.removeDocument?.(dv.props.Document);
+ }
+ });
+ }, "delete");
SelectionManager.DeselectAll();
break;
case "arrowleft":