A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
editor: added image-tools for readonly-mode
Muhammad Ali1cb34d0783f3
diff --git a/packages/editor/src/components/resizer/index.tsx b/packages/editor/src/components/resizer/index.tsxindex af7ad99f0..f8e2c3597 100644--- a/packages/editor/src/components/resizer/index.tsx+++ b/packages/editor/src/components/resizer/index.tsx@@ -22,6 +22,7 @@ import { Resizable } from "re-resizable";import { PropsWithChildren } from "react";import { Icon, Icons } from "../../toolbar";import { Editor } from "../../types";+import { Flex } from "@theme-ui/components";type ResizerProps = {editor: Editor;@@ -44,7 +45,7 @@ export function Resizer(props: PropsWithChildren<ResizerProps>) {style} = props;- if (!editor.isEditable) return <>{children}</>;+ if (!editor.isEditable) return <Flex sx={{position:"absolute"}}>{children}</Flex>;return (<Resizablediff --git a/packages/editor/src/extensions/image/component.tsx b/packages/editor/src/extensions/image/component.tsxindex 5457828ce..83594f93e 100644--- a/packages/editor/src/extensions/image/component.tsx+++ b/packages/editor/src/extensions/image/component.tsx@@ -67,6 +67,7 @@ export function ImageComponent(const [error, setError] = useState<string>();const [source, setSource] = useState<string>();const downloadOptions = useToolbarStore((store) => store.downloadOptions);+ const isReadonly = !editor.current?.isEditable;useEffect(() => {@@ -194,36 +195,42 @@ export function ImageComponent(><DesktopOnly>{selected && (- <Flex sx={{ position: "relative", justifyContent: "end" }}>- <Flex+ <Flex+ sx={{+ position: "absolute",+ top: -40,+ right: 0,+ mb: 2,+ alignItems: "end"+ }}+ >+ <ToolbarGroup+ editor={editor}+ tools={+ isReadonly+ ? [+ hash ? "previewAttachment" : "none",+ hash ? "downloadAttachment" : "none"+ ]+ : [+ hash ? "previewAttachment" : "none",+ hash ? "downloadAttachment" : "none",+ "imageAlignLeft",+ float ? "none" : "imageAlignCenter",+ "imageAlignRight",+ "imageProperties"+ ]+ }sx={{- position: "absolute",- top: -40,- mb: 2,- alignItems: "end"+ boxShadow: "menu",+ borderRadius: "default",+ bg: "background"}}- >- <ToolbarGroup- editor={editor}- tools={[- hash ? "previewAttachment" : "none",- hash ? "downloadAttachment" : "none",- "imageAlignLeft",- float ? "none" : "imageAlignCenter",- "imageAlignRight",- "imageProperties"- ]}- sx={{- boxShadow: "menu",- borderRadius: "default",- bg: "background"- }}- />- </Flex>+ /></Flex>)}</DesktopOnly>- {selected && (+ {selected && !isReadonly && (<IconclassName="drag-handle"data-drag-handlediff --git a/packages/editor/src/extensions/react/selection-based-react-node-view.tsx b/packages/editor/src/extensions/react/selection-based-react-node-view.tsxindex 89877198c..ba8029f83 100644--- a/packages/editor/src/extensions/react/selection-based-react-node-view.tsx+++ b/packages/editor/src/extensions/react/selection-based-react-node-view.tsx@@ -90,7 +90,9 @@ export class SelectionBasedNodeView<forwardRef?: ForwardRef): React.ReactElement<unknown> | null {if (!this.options.component) return null;- const isSelected =(this.options.forceEnableSelection || this.editor.isEditable) && this.isSelectedNode(this.editor.view.state.selection);+ const isSelected =+ (this.options.forceEnableSelection || this.editor.isEditable) &&+ this.isSelectedNode(this.editor.view.state.selection);return (<ThemeProvider>