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
handle focus on toggling outline list
ammarahm-ed1545c305e0b4
diff --git a/packages/editor/dist/es/extensions/outlinelist/component.js b/packages/editor/dist/es/extensions/outlinelist/component.jsindex 9d8d782cf..07a9da082 100644--- a/packages/editor/dist/es/extensions/outlinelist/component.js+++ b/packages/editor/dist/es/extensions/outlinelist/component.js@@ -14,12 +14,12 @@ export function OutlineListComponent(props) {ul: {display: collapsed ? "none" : "block",paddingInlineStart: 0,- paddingLeft: isNested ? 1 : 0,+ paddingLeft: 0,marginBlockStart: isNested ? 5 : 0,- marginBlockEnd: 0,+ marginBlockEnd: 0},li: {- listStyleType: "none",- },+ listStyleType: "none"+ }} }) }));}diff --git a/packages/editor/dist/es/extensions/outlinelistitem/component.js b/packages/editor/dist/es/extensions/outlinelistitem/component.jsindex 2020f5cf0..f9405065c 100644--- a/packages/editor/dist/es/extensions/outlinelistitem/component.js+++ b/packages/editor/dist/es/extensions/outlinelistitem/component.js@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";import { Box, Flex, Text } from "rebass";import { Icon } from "../../toolbar/components/icon";import { Icons } from "../../toolbar/icons";-import { findChildren, } from "@tiptap/core";+import { findChildren } from "@tiptap/core";import { OutlineList } from "../outline-list/outline-list";import { useIsMobile } from "../../toolbar/stores/toolbar-store";export function OutlineListItemComponent(props) {@@ -11,31 +11,35 @@ export function OutlineListItemComponent(props) {const isMobile = useIsMobile();const isNested = ((_a = node.lastChild) === null || _a === void 0 ? void 0 : _a.type.name) === OutlineList.name;const isCollapsed = isNested && ((_b = node.lastChild) === null || _b === void 0 ? void 0 : _b.attrs.collapsed);+ const onClick = () => {+ const [subList] = findChildren(node, (node) => node.type.name === OutlineList.name);+ if (!subList)+ return;+ const { pos } = subList;+ editor.commands.toggleOutlineCollapse(pos + getPos() + 1, !isCollapsed);+ };return (_jsxs(Flex, { children: [_jsxs(Flex, Object.assign({ className: "outline", sx: {flexDirection: "column",alignItems: "center",- mt: isMobile ? "0px" : "3px",+ mt: isMobile ? "0px" : "3px"} }, { children: [isNested ? (_jsx(Icon, { path: isCollapsed ? Icons.chevronRight : Icons.chevronDown, title: isCollapsed? "Click to uncollapse list": "Click to collapse list", sx: {cursor: "pointer",transition: `all .2s ease-in-out`,":hover": {- transform: ["unset", "scale(1.3)"],+ transform: ["unset", "scale(1.3)"]},":active": {- transform: ["scale(1.3)", "unset"],+ transform: ["scale(1.3)", "unset"]},".icon:hover path": {- fill: "var(--checked) !important",- },- }, size: isMobile ? 24 : 18, onMouseDown: (e) => e.preventDefault(), onClick: () => {- const [subList] = findChildren(node, (node) => node.type.name === OutlineList.name);- if (!subList)- return;- const { pos } = subList;- editor.commands.toggleOutlineCollapse(pos + getPos() + 1, !isCollapsed);- } })) : (_jsx(Icon, { path: Icons.circle, size: isMobile ? 24 : 18, sx: { transform: "scale(0.4)" } })), isNested && !isCollapsed && (_jsx(Box, { sx: {+ fill: "var(--checked) !important"+ }+ }, size: isMobile ? 24 : 18, onMouseDown: (e) => e.preventDefault(), onTouchEnd: (e) => {+ e.preventDefault();+ onClick();+ }, onClick: onClick })) : (_jsx(Icon, { path: Icons.circle, size: isMobile ? 24 : 18, sx: { transform: "scale(0.4)" } })), isNested && !isCollapsed && (_jsx(Box, { sx: {flex: 1,width: 1,mt: 2,@@ -46,11 +50,11 @@ export function OutlineListItemComponent(props) {transition: `all .2s ease-in-out`,":hover": {backgroundColor: "fontTertiary",- width: 4,- },+ width: 4+ }}, contentEditable: false }))] })), _jsx(Text, { ref: forwardRef, sx: {- pl: 2,+ pl: 1,listStyleType: "none",- flex: 1,+ flex: 1} })] }));}diff --git a/packages/editor/src/extensions/outline-list-item/component.tsx b/packages/editor/src/extensions/outline-list-item/component.tsxindex 59b752747..0135d2877 100644--- a/packages/editor/src/extensions/outline-list-item/component.tsx+++ b/packages/editor/src/extensions/outline-list-item/component.tsx@@ -8,7 +8,7 @@ import {findChildren,findParentNode,getNodeType,- NodeWithPos,+ NodeWithPos} from "@tiptap/core";import { useCallback, useEffect } from "react";import { OutlineList } from "../outline-list/outline-list";@@ -21,6 +21,17 @@ export function OutlineListItemComponent(props: ReactNodeViewProps) {const isNested = node.lastChild?.type.name === OutlineList.name;const isCollapsed = isNested && node.lastChild?.attrs.collapsed;+ const onClick = () => {+ const [subList] = findChildren(+ node,+ (node) => node.type.name === OutlineList.name+ );+ if (!subList) return;+ const { pos } = subList;++ editor.commands.toggleOutlineCollapse(pos + getPos() + 1, !isCollapsed);+ };+return (<Flex><Flex@@ -28,7 +39,7 @@ export function OutlineListItemComponent(props: ReactNodeViewProps) {sx={{flexDirection: "column",alignItems: "center",- mt: isMobile ? "0px" : "3px",+ mt: isMobile ? "0px" : "3px"}}>{isNested ? (@@ -43,30 +54,22 @@ export function OutlineListItemComponent(props: ReactNodeViewProps) {cursor: "pointer",transition: `all .2s ease-in-out`,":hover": {- transform: ["unset", "scale(1.3)"],+ transform: ["unset", "scale(1.3)"]},":active": {- transform: ["scale(1.3)", "unset"],+ transform: ["scale(1.3)", "unset"]},".icon:hover path": {- fill: "var(--checked) !important",- },+ fill: "var(--checked) !important"+ }}}size={isMobile ? 24 : 18}onMouseDown={(e) => e.preventDefault()}- onClick={() => {- const [subList] = findChildren(- node,- (node) => node.type.name === OutlineList.name- );- if (!subList) return;- const { pos } = subList;-- editor.commands.toggleOutlineCollapse(- pos + getPos() + 1,- !isCollapsed- );+ onTouchEnd={(e) => {+ e.preventDefault();+ onClick();}}+ onClick={onClick}/>) : (<Icon@@ -89,8 +92,8 @@ export function OutlineListItemComponent(props: ReactNodeViewProps) {transition: `all .2s ease-in-out`,":hover": {backgroundColor: "fontTertiary",- width: 4,- },+ width: 4+ }}}contentEditable={false}/>@@ -99,9 +102,9 @@ export function OutlineListItemComponent(props: ReactNodeViewProps) {<Textref={forwardRef}sx={{- pl: 2,+ pl: 1,listStyleType: "none",- flex: 1,+ flex: 1}}/></Flex>diff --git a/packages/editor/src/extensions/outline-list/component.tsx b/packages/editor/src/extensions/outline-list/component.tsxindex ef92c7287..e4775ff32 100644--- a/packages/editor/src/extensions/outline-list/component.tsx+++ b/packages/editor/src/extensions/outline-list/component.tsx@@ -25,13 +25,13 @@ export function OutlineListComponent(ul: {display: collapsed ? "none" : "block",paddingInlineStart: 0,- paddingLeft: isNested ? 1 : 0,+ paddingLeft: 0,marginBlockStart: isNested ? 5 : 0,- marginBlockEnd: 0,+ marginBlockEnd: 0},li: {- listStyleType: "none",- },+ listStyleType: "none"+ }}}/></>