Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

feat(editor): add list indent controls

tianma-if7a78567ff689
diff --git a/apps/mobile/app.json b/apps/mobile/app.json
index 59400a03..e3548ab4 100644
--- a/apps/mobile/app.json
+++ b/apps/mobile/app.json
@@ -3,7 +3,7 @@
"name": "EdgeEver",
"slug": "edgeever",
"scheme": "edgeever",
- "version": "1.5.16",
+ "version": "1.5.17",
"runtimeVersion": {
"policy": "appVersion"
},
@@ -28,7 +28,7 @@
},
"android": {
"package": "org.edgeever.mobile",
- "versionCode": 36,
+ "versionCode": 37,
"adaptiveIcon": {
"backgroundColor": "#d1fae5",
"backgroundImage": "./assets/icon.png",
diff --git a/apps/mobile/src/components/LocalTiptapEditor.tsx b/apps/mobile/src/components/LocalTiptapEditor.tsx
index d2fde460..2bd62e74 100644
--- a/apps/mobile/src/components/LocalTiptapEditor.tsx
+++ b/apps/mobile/src/components/LocalTiptapEditor.tsx
@@ -519,6 +519,8 @@ function LocalTiptapEditorImpl(props: LocalTiptapEditorProps) {
mermaid: <DiagramIcon />,
bold: <BoldIcon />,
bulletList: <ListIcon />,
+ increaseListIndent: <ListIndentIncreaseIcon />,
+ decreaseListIndent: <ListIndentDecreaseIcon />,
blockquote: <QuoteIcon />,
horizontalRule: <MinusIcon />,
insertTable: <TableGridIcon />,
@@ -547,6 +549,8 @@ function LocalTiptapEditorImpl(props: LocalTiptapEditorProps) {
},
bold: () => editor?.chain().focus().toggleBold().run(),
bulletList: () => editor?.chain().focus().toggleBulletList().run(),
+ increaseListIndent: () => editor?.chain().focus().sinkListItem("listItem").run(),
+ decreaseListIndent: () => editor?.chain().focus().liftListItem("listItem").run(),
blockquote: () => editor?.chain().focus().toggleBlockquote().run(),
horizontalRule: () => editor?.chain().focus().setHorizontalRule().run(),
insertTable: () => runTableAction("insertTable"),
@@ -569,7 +573,11 @@ function LocalTiptapEditorImpl(props: LocalTiptapEditorProps) {
<ToolbarButton
key={action.id}
active={action.activeFlag > 0 && Boolean(toolbarState & action.activeFlag)}
- disabled={action.id === "insertTable" && Boolean(toolbarState & MOBILE_EDITOR_ACTIVE_FLAGS.table)}
+ disabled={(action.id === "insertTable" && Boolean(toolbarState & MOBILE_EDITOR_ACTIVE_FLAGS.table))
+ || (action.id === "increaseListIndent"
+ && !Boolean(editor?.can().chain().focus().sinkListItem("listItem").run()))
+ || (action.id === "decreaseListIndent"
+ && !Boolean(editor?.can().chain().focus().liftListItem("listItem").run()))}
icon={toolbarIcons[action.id]}
label={getMobileEditorToolbarActionLabel(action.id, props.locale)}
onRun={toolbarHandlers[action.id]}
@@ -718,6 +726,20 @@ const ListIcon = () => (
</EditorIcon>
);
+const ListIndentIncreaseIcon = () => (
+ <EditorIcon size={18} strokeWidth={2.1}>
+ <path d="M4 5h16M4 12h10M4 19h16" />
+ <path d="m14 9 3 3-3 3" />
+ </EditorIcon>
+);
+
+const ListIndentDecreaseIcon = () => (
+ <EditorIcon size={18} strokeWidth={2.1}>
+ <path d="M4 5h16M10 12h10M4 19h16" />
+ <path d="m10 9-3 3 3 3" />
+ </EditorIcon>
+);
+
const QuoteIcon = () => (
<EditorIcon size={17} strokeWidth={2.2}>
<path d="M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" />
diff --git a/apps/web/src/components/EditorToolbar.tsx b/apps/web/src/components/EditorToolbar.tsx
index fc9e2543..782e05e0 100644
--- a/apps/web/src/components/EditorToolbar.tsx
+++ b/apps/web/src/components/EditorToolbar.tsx
@@ -10,6 +10,8 @@ import {
Code2,
List,
ListOrdered,
+ ListIndentDecrease,
+ ListIndentIncrease,
Quote,
SquareCode,
Workflow,
@@ -347,6 +349,20 @@ export const EditorToolbar = ({
>
<ListOrdered className="h-4 w-4" />
</EditorToolbarButton>
+ <EditorToolbarButton
+ title={t("editorToolbar.increaseListIndent")}
+ disabled={!canRun((current) => current.can().chain().focus().sinkListItem("listItem").run())}
+ onClick={() => run((current) => current.chain().focus().sinkListItem("listItem").run())}
+ >
+ <ListIndentIncrease className="h-4 w-4" />
+ </EditorToolbarButton>
+ <EditorToolbarButton
+ title={t("editorToolbar.decreaseListIndent")}
+ disabled={!canRun((current) => current.can().chain().focus().liftListItem("listItem").run())}
+ onClick={() => run((current) => current.chain().focus().liftListItem("listItem").run())}
+ >
+ <ListIndentDecrease className="h-4 w-4" />
+ </EditorToolbarButton>
<EditorToolbarButton
title={t("editorToolbar.quote")}
active={isActive("blockquote")}
diff --git a/apps/web/src/components/MobileStandaloneEditorParts.tsx b/apps/web/src/components/MobileStandaloneEditorParts.tsx
index 9447009e..7c32b93a 100644
--- a/apps/web/src/components/MobileStandaloneEditorParts.tsx
+++ b/apps/web/src/components/MobileStandaloneEditorParts.tsx
@@ -1,4 +1,4 @@
-import { Bold, Check, ChevronDown, ImagePlus, List, Minus, Quote, Table2, Workflow } from "lucide-react";
+import { Bold, Check, ChevronDown, ImagePlus, List, ListIndentDecrease, ListIndentIncrease, Minus, Quote, Table2, Workflow } from "lucide-react";
import { useTranslation } from "react-i18next";
import {
MOBILE_EDITOR_TOOLBAR_ACTIONS,
@@ -59,6 +59,8 @@ export const MobileEditorToolbar = ({
disabled,
boldActive,
bulletListActive,
+ increaseListIndentAvailable,
+ decreaseListIndentAvailable,
blockquoteActive,
mermaidActive,
tableActive,
@@ -68,6 +70,8 @@ export const MobileEditorToolbar = ({
onInsertMermaid,
onToggleBold,
onToggleBulletList,
+ onIncreaseListIndent,
+ onDecreaseListIndent,
onToggleBlockquote,
onSetHorizontalRule,
onTableAction,
@@ -75,6 +79,8 @@ export const MobileEditorToolbar = ({
disabled: boolean;
boldActive: boolean;
bulletListActive: boolean;
+ increaseListIndentAvailable: boolean;
+ decreaseListIndentAvailable: boolean;
blockquoteActive: boolean;
mermaidActive: boolean;
tableActive: boolean;
@@ -84,6 +90,8 @@ export const MobileEditorToolbar = ({
onInsertMermaid: () => void;
onToggleBold: () => void;
onToggleBulletList: () => void;
+ onIncreaseListIndent: () => void;
+ onDecreaseListIndent: () => void;
onToggleBlockquote: () => void;
onSetHorizontalRule: () => void;
onTableAction: (action: MobileEditorTableActionId) => void;
@@ -95,6 +103,8 @@ export const MobileEditorToolbar = ({
mermaid: <Workflow aria-hidden="true" size={18} strokeWidth={2} />,
bold: <Bold aria-hidden="true" size={17} strokeWidth={2.4} />,
bulletList: <List aria-hidden="true" size={18} strokeWidth={2.2} />,
+ increaseListIndent: <ListIndentIncrease aria-hidden="true" size={18} strokeWidth={2.1} />,
+ decreaseListIndent: <ListIndentDecrease aria-hidden="true" size={18} strokeWidth={2.1} />,
blockquote: <Quote aria-hidden="true" size={17} strokeWidth={2.2} />,
horizontalRule: <Minus aria-hidden="true" size={18} strokeWidth={2.4} />,
insertTable: <Table2 aria-hidden="true" size={18} strokeWidth={2} />,
@@ -110,6 +120,8 @@ export const MobileEditorToolbar = ({
mermaid: onInsertMermaid,
bold: onToggleBold,
bulletList: onToggleBulletList,
+ increaseListIndent: onIncreaseListIndent,
+ decreaseListIndent: onDecreaseListIndent,
blockquote: onToggleBlockquote,
horizontalRule: onSetHorizontalRule,
insertTable: () => onTableAction("insertTable"),
@@ -149,7 +161,10 @@ export const MobileEditorToolbar = ({
aria-label={label}
title={label}
aria-pressed={activeStates[id]}
- disabled={disabled || (id === "insertTable" && tableActive)}
+ disabled={disabled
+ || (id === "insertTable" && tableActive)
+ || (id === "increaseListIndent" && !increaseListIndentAvailable)
+ || (id === "decreaseListIndent" && !decreaseListIndentAvailable)}
onPointerDown={(event) => event.preventDefault()}
onClick={handlers[id]}
>
diff --git a/apps/web/src/components/MobileStandaloneTiptapEditor.tsx b/apps/web/src/components/MobileStandaloneTiptapEditor.tsx
index ab295781..ba9d18e4 100644
--- a/apps/web/src/components/MobileStandaloneTiptapEditor.tsx
+++ b/apps/web/src/components/MobileStandaloneTiptapEditor.tsx
@@ -913,6 +913,8 @@ export const MobileStandaloneTiptapEditor = ({
disabled={editorActionDisabled}
boldActive={Boolean(editor?.isActive("bold"))}
bulletListActive={Boolean(editor?.isActive("bulletList"))}
+ increaseListIndentAvailable={Boolean(editor?.can().chain().focus().sinkListItem("listItem").run())}
+ decreaseListIndentAvailable={Boolean(editor?.can().chain().focus().liftListItem("listItem").run())}
blockquoteActive={Boolean(editor?.isActive("blockquote"))}
mermaidActive={Boolean(editor?.isActive("codeBlock", { language: "mermaid" }))}
tableActive={tableActive}
@@ -934,6 +936,8 @@ export const MobileStandaloneTiptapEditor = ({
})}
onToggleBold={() => runEditorCommand(() => editor?.chain().focus().toggleBold().run() ?? false)}
onToggleBulletList={() => runEditorCommand(() => editor?.chain().focus().toggleBulletList().run() ?? false)}
+ onIncreaseListIndent={() => runEditorCommand(() => editor?.chain().focus().sinkListItem("listItem").run() ?? false)}
+ onDecreaseListIndent={() => runEditorCommand(() => editor?.chain().focus().liftListItem("listItem").run() ?? false)}
onToggleBlockquote={() => runEditorCommand(() => editor?.chain().focus().toggleBlockquote().run() ?? false)}
onSetHorizontalRule={() => runEditorCommand(() => editor?.chain().focus().setHorizontalRule().run() ?? false)}
onTableAction={runTableAction}
diff --git a/package.json b/package.json
index b28fc92b..b21a8c58 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "edgeever",
- "version": "1.5.16",
+ "version": "1.5.17",
"private": true,
"type": "module",
"workspaces": [
diff --git a/packages/shared/src/content.test.mjs b/packages/shared/src/content.test.mjs
index d07d0fbd..21e8d3b1 100644
--- a/packages/shared/src/content.test.mjs
+++ b/packages/shared/src/content.test.mjs
@@ -59,6 +59,34 @@ describe("Markdown table conversion", () => {
});
});
+describe("Nested list Markdown conversion", () => {
+ const markdown = [
+ "- Level 1",
+ " - Level 2",
+ " - Level 3",
+ " - Another level 2",
+ "- Another level 1",
+ ].join("\n");
+
+ test("preserves nested list hierarchy through a Markdown round trip", () => {
+ const doc = markdownToDoc(markdown);
+
+ const topList = doc.content[0];
+ const firstItem = topList?.content?.[0];
+ const secondLevelList = firstItem?.content?.[1];
+ const secondLevelItem = secondLevelList?.content?.[0];
+
+ expect(topList?.type).toBe("bulletList");
+ expect(topList?.content).toHaveLength(2);
+ expect(firstItem?.type).toBe("listItem");
+ expect(secondLevelList?.type).toBe("bulletList");
+ expect(secondLevelList?.content).toHaveLength(2);
+ expect(secondLevelItem?.content?.[1]?.type).toBe("bulletList");
+ expect(secondLevelItem?.content?.[1]?.content).toHaveLength(1);
+ expect(docToMarkdown(doc)).toBe(markdown);
+ });
+});
+
describe("Mermaid Markdown conversion", () => {
const markdown = "```mermaid\nflowchart LR\n A --> B\n```";
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index 3591e116..6fdbd805 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -569,6 +569,8 @@ export const enUS = {
inlineCode: "Inline code",
bulletList: "Bulleted list",
orderedList: "Numbered list",
+ increaseListIndent: "Increase list level (Tab)",
+ decreaseListIndent: "Decrease list level (Shift + Tab)",
quote: "Quote",
codeBlock: "Code block",
copyCode: "Copy code",
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index bd1c2254..6fd7d331 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -569,6 +569,8 @@ export const zhCN = {
inlineCode: "行内代码",
bulletList: "无序列表",
orderedList: "有序列表",
+ increaseListIndent: "增加列表层级(Tab)",
+ decreaseListIndent: "减少列表层级(Shift + Tab)",
quote: "引用",
codeBlock: "代码块",
copyCode: "复制代码",
diff --git a/packages/shared/src/mobile-editor.test.mjs b/packages/shared/src/mobile-editor.test.mjs
index acf65b30..6719af0f 100644
--- a/packages/shared/src/mobile-editor.test.mjs
+++ b/packages/shared/src/mobile-editor.test.mjs
@@ -19,6 +19,8 @@ describe("mobile editor contract", () => {
"mermaid",
"bold",
"bulletList",
+ "increaseListIndent",
+ "decreaseListIndent",
"blockquote",
"horizontalRule",
"insertTable",
@@ -44,6 +46,8 @@ describe("mobile editor contract", () => {
expect(getMobileEditorTableMenuCopy("zh-CN")).toEqual({ title: "表格操作", close: "关闭" });
expect(getMobileEditorTableMenuCopy("en-US")).toEqual({ title: "Table actions", close: "Close" });
expect(getMobileEditorToolbarActionLabel("bulletList", "en-US")).toBe("Bullet list");
+ expect(getMobileEditorToolbarActionLabel("increaseListIndent", "zh-CN")).toBe("增加列表层级(Tab)");
+ expect(getMobileEditorToolbarActionLabel("decreaseListIndent", "en-US")).toBe("Decrease list level (Shift + Tab)");
expect(getMobileEditorToolbarActionLabel("mermaid", "zh-CN")).toBe("插入 Mermaid 图表");
expect(getMobileEditorToolbarActionLabel("insertTable", "zh-CN")).toBe("插入表格");
expect(getMobileEditorImageScaleLabel("zh-CN")).toBe("图片显示尺寸");
diff --git a/packages/shared/src/mobile-editor.ts b/packages/shared/src/mobile-editor.ts
index e6da659b..835701ee 100644
--- a/packages/shared/src/mobile-editor.ts
+++ b/packages/shared/src/mobile-editor.ts
@@ -7,6 +7,8 @@ export type MobileEditorToolbarActionId =
| "mermaid"
| "bold"
| "bulletList"
+ | "increaseListIndent"
+ | "decreaseListIndent"
| "blockquote"
| "horizontalRule"
| MobileEditorTableActionId;
@@ -34,6 +36,8 @@ export const MOBILE_EDITOR_TOOLBAR_ACTIONS = [
{ id: "mermaid", activeFlag: MOBILE_EDITOR_ACTIVE_FLAGS.mermaid, requiresTable: false },
{ id: "bold", activeFlag: MOBILE_EDITOR_ACTIVE_FLAGS.bold, requiresTable: false },
{ id: "bulletList", activeFlag: MOBILE_EDITOR_ACTIVE_FLAGS.bulletList, requiresTable: false },
+ { id: "increaseListIndent", activeFlag: 0, requiresTable: false },
+ { id: "decreaseListIndent", activeFlag: 0, requiresTable: false },
{ id: "blockquote", activeFlag: MOBILE_EDITOR_ACTIVE_FLAGS.blockquote, requiresTable: false },
{ id: "horizontalRule", activeFlag: 0, requiresTable: false },
{ id: "insertTable", activeFlag: 0, requiresTable: false },
@@ -66,6 +70,8 @@ const MOBILE_EDITOR_COPY = {
mermaid: "插入 Mermaid 图表",
bold: "加粗",
bulletList: "无序列表",
+ increaseListIndent: "增加列表层级(Tab)",
+ decreaseListIndent: "减少列表层级(Shift + Tab)",
blockquote: "引用",
horizontalRule: "分割线",
insertTable: "插入表格",
@@ -96,6 +102,8 @@ const MOBILE_EDITOR_COPY = {
mermaid: "Insert Mermaid diagram",
bold: "Bold",
bulletList: "Bullet list",
+ increaseListIndent: "Increase list level (Tab)",
+ decreaseListIndent: "Decrease list level (Shift + Tab)",
blockquote: "Quote",
horizontalRule: "Horizontal rule",
insertTable: "Insert table",