Skip to content

Commit

Permalink
fix: notebooks bullets (#17521)
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin authored Sep 19, 2023
1 parent 5ee838e commit ea13d0b
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 51 deletions.
Binary file modified frontend/__snapshots__/scenes-app-notebooks--bullet-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-app-notebooks--headings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-app-notebooks--numbered-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-app-notebooks--text-formats.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion frontend/src/lib/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,8 @@ export function sampleOne<T>(items: T[]): T {
if (!items.length) {
throw Error('Items array is empty!')
}
return items[Math.floor(Math.random() * items.length)]
const index = inStorybookTestRunner() ? 0 : Math.floor(Math.random() * items.length)
return items[index]
}

/** Convert camelCase, PascalCase or snake_case to Sentence case or Title Case. */
Expand Down
96 changes: 47 additions & 49 deletions frontend/src/scenes/notebooks/Notebook/Notebook.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,64 @@
width: 100%;
overflow: hidden;

> h1,
> h2,
> h3,
> h4,
> h5 {
margin-top: 0.5rem;
}

> p {
margin-bottom: 0.2rem;
}
.ProseMirror {
&-focused {
outline: none;
}

> .ProseMirror-focused {
outline: none;
}
> h1,
> h2,
> h3,
> h4,
> h5 {
margin-top: 0.5rem;
}

> .is-empty::before {
content: attr(data-placeholder);
float: left;
color: rgba(0, 0, 0, 0.2);
pointer-events: none;
height: 0;
}
> p {
margin-bottom: 0.2rem;
}

ul {
list-style-type: disc;
}
> .is-empty::before {
content: attr(data-placeholder);
float: left;
color: rgba(0, 0, 0, 0.2);
pointer-events: none;
height: 0;
}

ol {
list-style-type: decimal;
}
> ul {
list-style-type: disc;
}

ul,
ol {
padding-left: 1rem;
> ol {
list-style-type: decimal;
}

li {
p {
margin-bottom: 0.2rem;
}
> ul,
> ol {
padding-left: 1rem;

> p {
display: inline-block;
li {
p {
margin-bottom: 0.2rem;
}
}
}
}

> pre {
background-color: rgba(0, 0, 0, 0.05);
border-radius: var(--radius);
overflow-x: auto;
margin-bottom: 0.5rem;
padding: 0.5rem;
}
> pre {
background-color: rgba(0, 0, 0, 0.05);
border-radius: var(--radius);
overflow-x: auto;
margin-bottom: 0.5rem;
padding: 0.5rem;
}

> code,
> p code {
background-color: rgba(0, 0, 0, 0.05);
border-radius: var(--radius);
padding: 0.2rem;
> code,
> p code {
background-color: rgba(0, 0, 0, 0.05);
border-radius: var(--radius);
padding: 0.2rem;
}
}

.Backlink {
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/scenes/notebooks/Notebook/Notebook.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ const testCases: Record<string, NotebookType> = {
},
},
]),
'api/projects/:team_id/notebooks/empty': notebookTestTemplate('empty', []),
}

const meta: Meta = {
Expand Down Expand Up @@ -396,6 +397,13 @@ export function TextOnlyNotebook(): JSX.Element {
return <App />
}

export function EmptyNotebook(): JSX.Element {
useEffect(() => {
router.actions.push(urls.notebook('empty'))
}, [])
return <App />
}

export function NotebookNotFound(): JSX.Element {
useEffect(() => {
router.actions.push(urls.notebook('abcde'))
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/scenes/notebooks/Notebook/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ export const isCurrentNodeEmpty = (editor: TTEditor): boolean => {
const selection = editor.state.selection
const { $anchor, empty } = selection
const isEmptyTextBlock =
$anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !textContent($anchor.parent)
$anchor.parent.isTextblock &&
!$anchor.parent.type.spec.code &&
$anchor.depth <= 1 &&
!textContent($anchor.parent)

if (empty && isEmptyTextBlock) {
return true
Expand Down

0 comments on commit ea13d0b

Please sign in to comment.