From 192fa8fc2483f2d8dc083a1969e97c6cf1e8d902 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Mon, 6 Feb 2023 10:03:13 +0500 Subject: [PATCH] editor: add rtl support in outline list --- .../outline-list-item/component.tsx | 102 ++++++++++++------ .../extensions/outline-list/outline-list.ts | 12 --- 2 files changed, 71 insertions(+), 43 deletions(-) diff --git a/packages/editor/src/extensions/outline-list-item/component.tsx b/packages/editor/src/extensions/outline-list-item/component.tsx index 8b571372b..4f291930e 100644 --- a/packages/editor/src/extensions/outline-list-item/component.tsx +++ b/packages/editor/src/extensions/outline-list-item/component.tsx @@ -18,7 +18,7 @@ along with this program. If not, see . */ import { Box, Flex, Text } from "@theme-ui/components"; -import { ReactNodeViewProps } from "../react"; +import { GetPosNode, ReactNodeViewProps } from "../react"; import { Icon } from "../../toolbar/components/icon"; import { Icons } from "../../toolbar/icons"; import { Node as ProsemirrorNode } from "prosemirror-model"; @@ -26,6 +26,7 @@ import { findChildren } from "@tiptap/core"; import { OutlineList } from "../outline-list/outline-list"; import { useIsMobile } from "../../toolbar/stores/toolbar-store"; import { Editor } from "../../types"; +import { TextDirections } from "../text-direction"; export function OutlineListItemComponent(props: ReactNodeViewProps) { const { editor, node, getPos, forwardRef } = props; @@ -45,36 +46,24 @@ export function OutlineListItemComponent(props: ReactNodeViewProps) { }} > {isNested ? ( - e.preventDefault()} - onTouchEnd={(e) => { - e.preventDefault(); - toggleOutlineList(editor, node, isCollapsed, getPos()); - }} - onClick={() => { - toggleOutlineList(editor, node, isCollapsed, getPos()); - }} - /> + <> + + + ) : ( e.preventDefault()} + onTouchEnd={(e) => { + e.preventDefault(); + toggleOutlineList(editor, node, isCollapsed, getPos()); + }} + onClick={() => { + toggleOutlineList(editor, node, isCollapsed, getPos()); + }} + /> + ); +} diff --git a/packages/editor/src/extensions/outline-list/outline-list.ts b/packages/editor/src/extensions/outline-list/outline-list.ts index a650705a0..459519d4c 100644 --- a/packages/editor/src/extensions/outline-list/outline-list.ts +++ b/packages/editor/src/extensions/outline-list/outline-list.ts @@ -23,7 +23,6 @@ import { OutlineListComponent } from "./component"; export type OutlineListAttributes = { collapsed: boolean; - textDirection: string; }; export interface OutlineListOptions { @@ -61,17 +60,6 @@ export const OutlineList = Node.create({ renderHTML: (attributes) => ({ "data-collapsed": attributes.collapsed === true }) - }, - textDirection: { - default: "ltr", - parseHTML: (element) => element.dir, - renderHTML(attributes) { - if (!attributes.textDirection) { - return {}; - } - - return { dir: attributes.textDirection }; - } } }; },