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: get text direction from selected or parent node
Abdullah Atta6ecf2c8ac3c7
diff --git a/packages/editor/src/toolbar/tools/text-direction.tsx b/packages/editor/src/toolbar/tools/text-direction.tsxindex 42b7d39b7..43412efa3 100644--- a/packages/editor/src/toolbar/tools/text-direction.tsx+++ b/packages/editor/src/toolbar/tools/text-direction.tsx@@ -21,10 +21,13 @@ import { ToolProps } from "../types";import { ToolButton } from "../components/tool-button";import { IconNames } from "../icons";import { useRefValue } from "../../hooks/use-ref-value";+import {+ getTextDirection,+ TextDirections+} from "../../extensions/text-direction";-type TextDirection = "ltr" | "rtl";type TextDirectionToolProps = ToolProps & {- direction: TextDirection;+ direction: TextDirections;};function TextDirectionTool(props: TextDirectionToolProps) {const { editor, direction, ...toolProps } = props;@@ -47,15 +50,11 @@ function TextDirectionTool(props: TextDirectionToolProps) {export function TextDirection(props: ToolProps) {const { editor } = props;- const { textDirection } = {- ...editor.getAttributes("paragraph"),- ...editor.getAttributes("heading")- } as { textDirection: TextDirection };+ const textDirection = getTextDirection(editor);- const newTextDirection: TextDirection =- textDirection === "ltr" ? "rtl" : "ltr";+ const newTextDirection: TextDirections = textDirection ? undefined : "rtl";- const icon: IconNames = textDirection === "ltr" ? "ltr" : "rtl";+ const icon: IconNames = textDirection ? "rtl" : "ltr";return (<TextDirectionTool direction={newTextDirection} {...props} icon={icon} />