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: improve text direction support in lists
alihamuhf134184a438c
diff --git a/packages/editor/src/extensions/outline-list/component.tsx b/packages/editor/src/extensions/outline-list/component.tsxindex 6bbbf2ec4..49b4bfe72 100644--- a/packages/editor/src/extensions/outline-list/component.tsx+++ b/packages/editor/src/extensions/outline-list/component.tsx@@ -27,7 +27,7 @@ export function OutlineListComponent(props: ReactNodeViewProps<OutlineListAttributes>) {const { editor, getPos, node, forwardRef } = props;- const { collapsed } = node.attrs;+ const { collapsed, textDirection } = node.attrs;const isNested = useMemo(() => {const pos = editor.state.doc.resolve(getPos());@@ -40,6 +40,7 @@ export function OutlineListComponent(className="outline-list"as={"div"}ref={forwardRef}+ dir={textDirection}sx={{ul: {display: collapsed ? "none" : "block",diff --git a/packages/editor/src/extensions/outline-list/outline-list.ts b/packages/editor/src/extensions/outline-list/outline-list.tsindex 459519d4c..a650705a0 100644--- a/packages/editor/src/extensions/outline-list/outline-list.ts+++ b/packages/editor/src/extensions/outline-list/outline-list.ts@@ -23,6 +23,7 @@ import { OutlineListComponent } from "./component";export type OutlineListAttributes = {collapsed: boolean;+ textDirection: string;};export interface OutlineListOptions {@@ -60,6 +61,17 @@ export const OutlineList = Node.create<OutlineListOptions>({renderHTML: (attributes) => ({"data-collapsed": attributes.collapsed === true})+ },+ textDirection: {+ default: "ltr",+ parseHTML: (element) => element.dir,+ renderHTML(attributes) {+ if (!attributes.textDirection) {+ return {};+ }++ return { dir: attributes.textDirection };+ }}};},diff --git a/packages/editor/src/extensions/task-item/component.tsx b/packages/editor/src/extensions/task-item/component.tsxindex 5cb2b01e7..fe2a113cb 100644--- a/packages/editor/src/extensions/task-item/component.tsx+++ b/packages/editor/src/extensions/task-item/component.tsx@@ -172,9 +172,9 @@ export function TaskItemComponent(className="taskItemTools"sx={{bg: "background",- position: "absolute",- right: 0,- top: "4px",+ ml: 0,+ mt: "4px",+ alignSelf: "end",opacity: 0,alignItems: "center"}}diff --git a/packages/editor/src/extensions/task-list/component.tsx b/packages/editor/src/extensions/task-list/component.tsxindex 83e6b30aa..0c53a0c2a 100644--- a/packages/editor/src/extensions/task-list/component.tsx+++ b/packages/editor/src/extensions/task-list/component.tsx@@ -34,7 +34,7 @@ export function TaskListComponent(// const isMobile = useIsMobile();const { editor, getPos, node, updateAttributes, forwardRef } = props;const taskItemType = getNodeType(TaskItemNode.name, editor.schema);- const { title } = node.attrs;+ const { title, textDirection } = node.attrs;const [stats, setStats] = useState({ checked: 0, total: 0, percentage: 0 });const getParent = useCallback(() => {@@ -83,6 +83,7 @@ export function TaskListComponent(flexDirection: "column"}}className="task-list-tools"+ dir={textDirection}>{!isNested && (<Flex@@ -175,6 +176,7 @@ export function TaskListComponent(<Textas={"div"}ref={forwardRef}+ dir={textDirection}sx={{ul: {display: "block",diff --git a/packages/editor/src/extensions/task-list/task-list.ts b/packages/editor/src/extensions/task-list/task-list.tsindex 34f3d0c57..8028178cd 100644--- a/packages/editor/src/extensions/task-list/task-list.ts+++ b/packages/editor/src/extensions/task-list/task-list.ts@@ -28,6 +28,7 @@ import { findChildrenByType } from "../../utils/prosemirror";export type TaskListAttributes = {title: string;+ textDirection: string;};const stateKey = new PluginKey("task-item-drop-override");@@ -47,6 +48,17 @@ export const TaskListNode = TaskList.extend({"data-title": attributes.title};}+ },+ textDirection: {+ default: "ltr",+ parseHTML: (element) => element.dir,+ renderHTML(attributes) {+ if (!attributes.textDirection) {+ return {};+ }++ return { dir: attributes.textDirection };+ }}};},diff --git a/packages/editor/src/extensions/text-direction/text-direction.ts b/packages/editor/src/extensions/text-direction/text-direction.tsindex 8dafdf023..383ef486b 100644--- a/packages/editor/src/extensions/text-direction/text-direction.ts+++ b/packages/editor/src/extensions/text-direction/text-direction.ts@@ -41,7 +41,14 @@ export const TextDirection = Extension.create<TextDirectionOptions>({name: "textDirection",defaultOptions: {- types: ["paragraph", "heading"],+ types: [+ "paragraph",+ "heading",+ "orderedList",+ "bulletList",+ "outlineList",+ "taskList"+ ],defaultDirection: "ltr"},