Skip to content

Commit

Permalink
Add option to not open nodes in sidebar on create
Browse files Browse the repository at this point in the history
  • Loading branch information
mdroidian committed Nov 22, 2023
1 parent 2b54dea commit 1bc42ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/discourseGraphsMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,17 @@ const initializeDiscourseGraphsMode = async (args: OnloadArgs) => {
Panel: TextPanel,
},
// @ts-ignore
{
title: "open in sidebar",
description:
"Whether or not to open nodes in the sidebar when created",
Panel: FlagPanel,
options: {
onChange: onPageRefObserverChange(previewPageRefHandler),
},
defaultValue: true,
} as Field<FlagField>,
// @ts-ignore
{
title: "preview",
description:
Expand Down
2 changes: 2 additions & 0 deletions src/utils/createDiscourseNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import getFullTreeByParentUid from "roamjs-components/queries/getFullTreeByParen
import getSubTree from "roamjs-components/util/getSubTree";
import openBlockInSidebar from "roamjs-components/writes/openBlockInSidebar";
import { DiscourseNode } from "./getDiscourseNodes";
import isFlagEnabled from "./isFlagEnabled";

type Props = {
text: string;
Expand All @@ -22,6 +23,7 @@ const createDiscourseNode = async ({
discourseNodes,
}: Props) => {
const handleOpenInSidebar = (uid: string) => {
if (!isFlagEnabled("open in sidebar")) return;
openBlockInSidebar(uid);
setTimeout(() => {
const sidebarTitle = document.querySelector(
Expand Down

0 comments on commit 1bc42ff

Please sign in to comment.