Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to not open nodes in sidebar on create (Closes #176) #177

Merged
merged 6 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
mdroidian marked this conversation as resolved.
Show resolved Hide resolved
} 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