Skip to content

Commit

Permalink
notebooks: properly handle code blocks
Browse files Browse the repository at this point in the history
Fixes LAND-1404 by making sure we send code blocks as `blocks` in notebook posts.

Only handled as blocks in notebook posts, nothing changes for chat posts.

Inline and block code still render correctly in chat messages, and now both render correctly in notebook posts.
  • Loading branch information
patosullivan committed Feb 7, 2024
1 parent 631becb commit 2922694
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ui/src/diary/diary-add-note.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default function DiaryAddNote() {
const data = JSONToInlines(editor?.getJSON(), false, true);
const values = getValues();

const noteContent = constructStory(data);
const noteContent = constructStory(data, true);
const now = Date.now();
const cacheId = {
author: window.our,
Expand Down
6 changes: 5 additions & 1 deletion ui/src/types/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,10 @@ export const emptyReply: Reply = {
},
};

export function constructStory(data: (Inline | Block)[]): Story {
export function constructStory(
data: (Inline | Block)[],
codeAsBlock?: boolean
): Story {
const isBlock = (c: Inline | Block) =>
[
'image',
Expand All @@ -564,6 +567,7 @@ export function constructStory(data: (Inline | Block)[]): Story {
'header',
'rule',
'cite',
codeAsBlock ? 'code' : '',
].some((k) => typeof c !== 'string' && k in c);
const postContent: Story = [];
let index = 0;
Expand Down

0 comments on commit 2922694

Please sign in to comment.