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

Revert "Revert "Improve block performance"" #2271

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/cljs/athens/components.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
renderer-k (block-type-dispatcher/block-type->protocol-k block-type ff)
renderer (block-type-dispatcher/block-type->protocol renderer-k {})]
^{:key renderer-k}
[types/transclusion-view renderer blocks/block-el block-uid {} :embed])
[:f> types/transclusion-view renderer blocks/block-el block-uid {} :embed])
;; roam actually hides the brackets around [[embed]]
[:span "{{" content "}}"])))

Expand Down
2 changes: 1 addition & 1 deletion src/cljs/athens/types/default/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
:pr "1.3rem"
"textarea" {:background "transparent"}}}}
[:<>
[block-el
[:f> block-el
(util/recursively-modify-block-for-embed block embed-id)
{:linked-ref false}
{:block-embed? true}]
Expand Down
471 changes: 240 additions & 231 deletions src/cljs/athens/views/blocks/core.cljs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/cljs/athens/views/pages/block_page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@
[:> PageBody
(for [prop (common-db/sort-block-properties properties)]
^{:key (:db/id prop)}
[blocks/block-el prop])])
[:f> blocks/block-el prop])])

;; Children
[:> PageBody
(for [child children]
(let [{:keys [db/id]} child]
^{:key id} [blocks/block-el child]))]
^{:key id} [:f> blocks/block-el child]))]

;; Refs
[:> PageFooter
Expand Down
6 changes: 3 additions & 3 deletions src/cljs/athens/views/pages/node_page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
(swap! state assoc :block new-B :parents new-P))}
[parse-and-render (common-db/breadcrumb-string @db/dsdb uid) uid]]]))]
[:> Box {:class "block-embed"}
[blocks/block-el
[:f> blocks/block-el
(recursively-modify-block-for-embed block embed-id)
linked-ref-data
{:block-embed? true}]]]))))
Expand Down Expand Up @@ -517,14 +517,14 @@
(seq properties))
(for [prop (common-db/sort-block-properties properties)]
^{:key (:db/id prop)}
[blocks/block-el prop]))]
[:f> blocks/block-el prop]))]

;; Children
[:div
(for [{:block/keys [uid] :as child} children]
^{:key uid}
[perf-mon/hoc-perfmon {:span-name "block-el"}
[blocks/block-el child]])]]
[:f> blocks/block-el child]])]]

;; References
[:> PageFooter
Expand Down
4 changes: 0 additions & 4 deletions src/js/components/Block/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ export const Autocomplete = ({ isOpen, onClose, event, children }) => {
}
}, [isOpen]);

if (!isOpen) {
return false;
}

return (
<Popover
isOpen={isOpen}
Expand Down
7 changes: 5 additions & 2 deletions src/js/components/Block/Container.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { Box, useMergeRefs } from "@chakra-ui/react";
import { Box, AlertIcon, Alert, AlertTitle, useMergeRefs } from "@chakra-ui/react";
import { withErrorBoundary } from "react-error-boundary";
import { ContextMenuContext } from "@/App/ContextMenuContext";

const ERROR_MESSAGE = "An error occurred while rendering this block.";
const ERROR_MESSAGE = <Alert ml={4} status='error'><AlertIcon /><AlertTitle>An error occurred while rendering this block.</AlertTitle></Alert>;

// Don't open the context menu on these elements
const CONTAINER_CONTEXT_MENU_FILTERED_TAGS = ["A", "BUTTON", "INPUT", "TEXTAREA", "LABEL", "VIDEO", "EMBED", "IFRAME", "IMG"];
Expand Down Expand Up @@ -102,6 +102,9 @@ const _Container = React.forwardRef(({ children, isDragging, isHidden, isSelecte
minHeight: '2em',
position: "relative",
},
"> .block-body > .block-content": {
gridArea: "content",
},
"&:hover > .block-toggle, &:focus-within > .block-toggle": { opacity: "1" },
"button.block-edit-toggle": {
position: "absolute",
Expand Down
8 changes: 8 additions & 0 deletions src/js/theme/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,14 @@ const components = {
color: "var(--toast-color)",
}
})
},
subtle: {
container: {
borderRadius: "md"
},
title: {
fontWeight: "normal"
},
}
}
},
Expand Down