Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion apps/roam/src/components/PublishNodeTitleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,5 @@ export const renderPublishNodeTitleButton = ({
handleTitleAdditions(
h1,
<PublishNodeTitleButton uid={uid} title={title} nodeType={nodeType} />,
{ layout: "inline" },
);
};
10 changes: 1 addition & 9 deletions apps/roam/src/utils/handleTitleAdditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@ import ReactDOM from "react-dom";

const ROAM_TITLE_CONTAINER_CLASS = "rm-title-display-container";
const ADDITIONS_CONTAINER_CLASS = "discourse-graph-title-additions";
const ADDITIONS_CONTAINER_CLASSES = `${ADDITIONS_CONTAINER_CLASS} flex flex-wrap items-start gap-x-2 gap-y-2`;
const INLINE_ADDITION_CLASSES = "min-w-0 flex-none";
const BLOCK_ADDITION_CLASSES = "min-w-0 basis-full grow shrink-0";

type TitleAdditionLayout = "inline" | "block";

export const handleTitleAdditions = (
h1: HTMLHeadingElement,
element: React.ReactNode,
{ layout = "block" }: { layout?: TitleAdditionLayout } = {},
): void => {
const titleDisplayContainer =
h1.closest(`.${ROAM_TITLE_CONTAINER_CLASS}`) ||
Expand All @@ -31,7 +25,7 @@ export const handleTitleAdditions = (
if (!parent) return;

container = document.createElement("div");
container.className = ADDITIONS_CONTAINER_CLASSES;
container.className = `${ADDITIONS_CONTAINER_CLASS} flex flex-col`;

const oldMarginBottom = getComputedStyle(h1).marginBottom;
const oldMarginBottomNum = Number.isFinite(parseFloat(oldMarginBottom))
Expand All @@ -51,8 +45,6 @@ export const handleTitleAdditions = (

if (React.isValidElement(element)) {
const renderContainer = document.createElement("div");
renderContainer.className =
layout === "inline" ? INLINE_ADDITION_CLASSES : BLOCK_ADDITION_CLASSES;
container.appendChild(renderContainer);
// eslint-disable-next-line react/no-deprecated
ReactDOM.render(element, renderContainer);
Expand Down
1 change: 0 additions & 1 deletion apps/roam/src/utils/renderLinkedReferenceAdditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const renderDiscourseContext = ({
uid,
id: nanoid(),
}),
{ layout: "inline" },
);
h1.setAttribute("data-roamjs-top-discourse-context", "true");
};
Expand Down