Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
feat: support tab and shift+tab on range (#6703)
Kilu.He939e28d2e159
diff --git a/frontend/appflowy_web_app/cypress.config.ts b/frontend/appflowy_web_app/cypress.config.tsindex d8921bb893..212d1edca7 100644--- a/frontend/appflowy_web_app/cypress.config.ts+++ b/frontend/appflowy_web_app/cypress.config.ts@@ -25,7 +25,7 @@ export default defineConfig({retries: {// Configure retry attempts for `cypress run`// Default is 0- runMode: 2,+ runMode: 10,// Configure retry attempts for `cypress open`// Default is 0openMode: 0,diff --git a/frontend/appflowy_web_app/src/application/slate-yjs/command/index.ts b/frontend/appflowy_web_app/src/application/slate-yjs/command/index.tsindex ea7e8c07d8..db6dc0fa8d 100644--- a/frontend/appflowy_web_app/src/application/slate-yjs/command/index.ts+++ b/frontend/appflowy_web_app/src/application/slate-yjs/command/index.ts@@ -1,21 +1,21 @@import { YjsEditor } from '@/application/slate-yjs/plugins/withYjs';import { EditorMarkFormat } from '@/application/slate-yjs/types';+import { findIndentPath, findLiftPath } from '@/application/slate-yjs/utils/slateUtils';+import {dataStringTOJson,- executeOperations,+ executeOperations, findSlateEntryByBlockId, getAffectedBlocks,getBlock,getBlockEntry,getSelectionOrThrow, getSelectionTexts,getSharedRoot,handleCollapsedBreakWithTxn,handleDeleteEntireDocumentWithTxn,- handleIndentBlockWithTxn,handleLiftBlockOnBackspaceAndEnterWithTxn,- handleLiftBlockOnTabWithTxn,handleMergeBlockBackwardWithTxn,handleMergeBlockForwardWithTxn,handleNonParagraphBlockBackspaceAndEnterWithTxn,- handleRangeBreak,+ handleRangeBreak, indentBlock, liftBlock, preventIndentNode, preventLiftNode,removeRangeWithTxn,turnToBlock,} from '@/application/slate-yjs/utils/yjsOperations';@@ -29,7 +29,7 @@ import {} from '@/application/types';import { renderDate } from '@/utils/time';import isEqual from 'lodash-es/isEqual';-import { BasePoint, BaseRange, Editor, Element, Node, NodeEntry, Path, Range, Text, Transforms } from 'slate';+import { BaseRange, Editor, Element, Node, NodeEntry, Path, Range, Text, Transforms } from 'slate';import { ReactEditor } from 'slate-react';export const CustomEditor = {@@ -193,22 +193,85 @@ export const CustomEditor = {removeRangeWithTxn(editor, getSharedRoot(editor), at);},- tabForward (editor: YjsEditor, point: BasePoint) {+ tabEvent (editor: YjsEditor, event: KeyboardEvent) {+ const type = event.shiftKey ? 'tabBackward' : 'tabForward';const sharedRoot = getSharedRoot(editor);- const [node] = getBlockEntry(editor, point);+ const { selection } = editor;- const block = getBlock(node.blockId as string, sharedRoot);+ if (!selection) return;+ const [point, endPoint] = editor.edges(selection);+ const { middleBlocks, startBlock: node, endBlock: endNode } = getAffectedBlocks(editor, selection);- handleIndentBlockWithTxn(editor, sharedRoot, block, point);- },+ if (type === 'tabBackward' && preventLiftNode(editor, node[0].blockId as string)) {+ return;+ }- tabBackward (editor: YjsEditor, point: BasePoint) {- const sharedRoot = getSharedRoot(editor);- const [node] = getBlockEntry(editor, point);+ if (type === 'tabForward' && preventIndentNode(editor, node[0].blockId as string)) {+ return;+ }++ const startBlockPath = node[1];+ const endBlockPath = endNode[1];+ const startAtPath = point.path.slice(startBlockPath.length);+ const startAtOffset = point.offset;+ const endAtPath = endPoint.path.slice(endBlockPath.length);+ const endAtOffset = endPoint.offset;+ let newStartBlockPath: Path = [];+ let newEndBlockPath: Path = [];++ const isSameBlock = node[0].blockId === endNode[0].blockId;- const block = getBlock(node.blockId as string, sharedRoot);+ if (isSameBlock) {+ const block = getBlock(node[0].blockId as string, sharedRoot);+ let newBlockId: string | undefined;- handleLiftBlockOnTabWithTxn(editor, sharedRoot, block, point);+ executeOperations(sharedRoot, [() => {+ newBlockId = type === 'tabForward' ? indentBlock(sharedRoot, block) : liftBlock(sharedRoot, block);+ }], type === 'tabForward' ? 'indentBlock' : 'liftBlock');++ if (!newBlockId) return;+ const newBlockEntry = findSlateEntryByBlockId(editor, newBlockId);++ newStartBlockPath = newBlockEntry[1];+ newEndBlockPath = newStartBlockPath;+ } else {+ const blocks = [node, ...middleBlocks, endNode] as NodeEntry<Element>[];+ const newBlockIds: string[] = [];++ blocks.forEach((entry, index) => {+ const blockId = entry[0].blockId as string;+ const block = getBlock(blockId, sharedRoot);++ if (!block) return;++ executeOperations(sharedRoot, [() => {+ const newBlockId = type === 'tabForward' ? indentBlock(sharedRoot, block) : liftBlock(sharedRoot, block, index);++ if (newBlockId) {+ newBlockIds.push(newBlockId);+ }+ }], type === 'tabForward' ? 'indentBlock' : 'liftBlock');+ });+ if (newBlockIds.length === 0) return;+ const newStartBlockEntry = findSlateEntryByBlockId(editor, newBlockIds[0]);++ newStartBlockPath = newStartBlockEntry[1];+ newEndBlockPath = type === 'tabForward' ? findIndentPath(startBlockPath, endBlockPath, newStartBlockPath) : findLiftPath(startBlockPath, endBlockPath, newStartBlockPath);+ }++ const newStartPath = [...newStartBlockPath, ...startAtPath];+ const newEndPath = [...newEndBlockPath, ...endAtPath];++ Transforms.select(editor, {+ anchor: {+ path: newStartPath,+ offset: startAtOffset,+ },+ focus: {+ path: newEndPath,+ offset: endAtOffset,+ },+ });},toggleToggleList (editor: YjsEditor, blockId: string) {diff --git a/frontend/appflowy_web_app/src/application/slate-yjs/utils/applyToSlate.ts b/frontend/appflowy_web_app/src/application/slate-yjs/utils/applyToSlate.tsindex 5b8ce897ae..2df8d066f6 100644--- a/frontend/appflowy_web_app/src/application/slate-yjs/utils/applyToSlate.ts+++ b/frontend/appflowy_web_app/src/application/slate-yjs/utils/applyToSlate.ts@@ -157,6 +157,7 @@ function handleNewBlock (editor: YjsEditor, key: string, keyPath: Record<string,const [parentEntry] = editor.nodes({match: (n) => !Editor.isEditor(n) && Element.isElement(n) && n.blockId === parentId,mode: 'all',+ at: [],});if (!parentEntry) {diff --git a/frontend/appflowy_web_app/src/application/slate-yjs/utils/slateUtils.tsx b/frontend/appflowy_web_app/src/application/slate-yjs/utils/slateUtils.tsxnew file mode 100644index 0000000000..3cb983591a--- /dev/null+++ b/frontend/appflowy_web_app/src/application/slate-yjs/utils/slateUtils.tsx@@ -0,0 +1,26 @@+import { Path } from 'slate';++export function findIndentPath (originalStart: Path, originalEnd: Path, newStart: Path): Path {+ // Find the common ancestor path+ const commonPath = Path.common(originalStart, originalEnd);++ // Calculate end's path relative to common ancestor+ const endRelativePath = originalEnd.slice(commonPath.length);++ // Calculate new common ancestor path by maintaining the same level difference+ const startToCommonLevels = originalStart.length - commonPath.length;+ const newCommonAncestor = newStart.slice(0, newStart.length - startToCommonLevels);++ // Append the relative path to new common ancestor+ return [...newCommonAncestor, ...endRelativePath];+}++export function findLiftPath (originalStart: Path, originalEnd: Path, newStart: Path): Path {+ // Same logic as findIndentPath+ const commonPath = Path.common(originalStart, originalEnd);+ const endRelativePath = originalEnd.slice(commonPath.length);+ const startToCommonLevels = originalStart.length - commonPath.length;+ const newCommonAncestor = newStart.slice(0, newStart.length - startToCommonLevels);++ return [...newCommonAncestor, ...endRelativePath];+}\ No newline at end of filediff --git a/frontend/appflowy_web_app/src/application/slate-yjs/utils/yjsOperations.ts b/frontend/appflowy_web_app/src/application/slate-yjs/utils/yjsOperations.tsindex ccc238a280..9631e62e1f 100644--- a/frontend/appflowy_web_app/src/application/slate-yjs/utils/yjsOperations.ts+++ b/frontend/appflowy_web_app/src/application/slate-yjs/utils/yjsOperations.ts@@ -158,6 +158,11 @@ export function updateBlockParent (sharedRoot: YSharedRoot, block: YBlock, parenblock.set(YjsEditorKey.block_parent, parent.get(YjsEditorKey.block_id));const parentChildren = getChildrenArray(parent.get(YjsEditorKey.block_children), sharedRoot);+ if (index >= parentChildren.length) {+ parentChildren.push([block.get(YjsEditorKey.block_id)]);+ return;+ }+parentChildren.insert(index, [block.get(YjsEditorKey.block_id)]);}@@ -359,6 +364,15 @@ function moveToNextLine (editor: Editor, block: YBlock, at: BaseRange, blockId:Transforms.move(editor, { distance: 1, unit: 'line' });}+export function findSlateEntryByBlockId (editor: Editor, blockId: string) {+ const [node] = Editor.nodes(editor, {+ match: (n) => !Editor.isEditor(n) && Element.isElement(n) && n.blockId === blockId,+ at: [],+ });++ return node;+}+export function getNextSiblingBlockPath (editor: Editor, blockId: string) {const [blockSlateNode] = editor.nodes({match: (n) => !Editor.isEditor(n) && Element.isElement(n) && n.blockId === blockId,@@ -513,6 +527,12 @@ export function deleteBlock (sharedRoot: YSharedRoot, blockId: string) {const blocks = document.get(YjsEditorKey.blocks) as YBlocks;const parentId = block.get(YjsEditorKey.block_parent);+ const blockChildren = getChildrenArray(block.get(YjsEditorKey.block_children), sharedRoot).toArray();++ blockChildren.forEach((id) => {+ deleteBlock(sharedRoot, id);+ });+blocks.delete(blockId);const meta = document.get(YjsEditorKey.meta) as YMeta;@@ -532,6 +552,7 @@ export function deleteBlock (sharedRoot: YSharedRoot, blockId: string) {if (index !== -1) {parentChildren.delete(index, 1);}+}export function getBreakInfo (editor: YjsEditor, sharedRoot: YSharedRoot, at: BaseRange) {@@ -810,28 +831,6 @@ export function handleNonParagraphBlockBackspaceAndEnterWithTxn (sharedRoot: YShexecuteOperations(sharedRoot, operations, 'turnToBlock');}-export function handleLiftBlockOnTabWithTxn (editor: YjsEditor, sharedRoot: YSharedRoot, block: YBlock, point: Point) {- const operations: (() => void)[] = [];- const [, path] = getBlockEntry(editor, point);-- let newPath: number[] | undefined;-- operations.push(() => {- newPath = liftEditorNode(editor, sharedRoot, block, point);- });-- executeOperations(sharedRoot, operations, 'liftBlock');- if (!newPath) return;-- const newPoint = {- path: [...newPath, ...point.path.slice(path.length)],- offset: point.offset,- };-- // After the lift operation is complete, move the cursor to the start of the newly lifted block- Transforms.select(editor, newPoint);-}-export function handleLiftBlockOnBackspaceAndEnterWithTxn (editor: YjsEditor, sharedRoot: YSharedRoot, block: YBlock, point: Point) {const operations: (() => void)[] = [];const parent = getBlock(block.get(YjsEditorKey.block_parent), sharedRoot);@@ -842,6 +841,10 @@ export function handleLiftBlockOnBackspaceAndEnterWithTxn (editor: YjsEditor, shconst hasNextSibling = index < parentChildren.length - 1;const hasChildren = getChildrenArray(block.get(YjsEditorKey.block_children), sharedRoot).length > 0;+ if (preventLiftNode(editor, block.get(YjsEditorKey.block_id))) {+ return false;+ }+if (!hasChildren && !hasNextSibling) {let newPath: number[] | undefined;@@ -849,7 +852,7 @@ export function handleLiftBlockOnBackspaceAndEnterWithTxn (editor: YjsEditor, shnewPath = liftEditorNode(editor, sharedRoot, block, point);});executeOperations(sharedRoot, operations, 'liftBlock');- if (!newPath) return;+ if (!newPath) return false;const newPoint = {path: [...newPath, ...point.path.slice(path.length)],@@ -864,53 +867,6 @@ export function handleLiftBlockOnBackspaceAndEnterWithTxn (editor: YjsEditor, shreturn false;}-export function handleIndentBlockWithTxn (editor: YjsEditor, sharedRoot: YSharedRoot, block: YBlock, point: Point) {- const operations: (() => void)[] = [];- const parent = getBlock(block.get(YjsEditorKey.block_parent), sharedRoot);- const parentChildren = getChildrenArray(parent.get(YjsEditorKey.block_children), sharedRoot);- const index = parentChildren.toArray().findIndex((id) => id === block.get(YjsEditorKey.block_id));- const [, path] = getBlockEntry(editor, point);-- // Check if the block can be indented (not the first child)- if (index === 0) {- return false;- }-- // Get the previous sibling- const previousSiblingId = parentChildren.get(index - 1);- const previousSibling = getBlock(previousSiblingId, sharedRoot);-- if (!previousSibling) {- return false;- }-- // Check if the parent block is a container block- if (!CONTAINER_BLOCK_TYPES.includes(previousSibling.get(YjsEditorKey.block_type))) {- return false;- }-- let newPath: number[] | undefined;-- operations.push(() => {- newPath = indentEditorNode(editor, sharedRoot, block, point);- });-- executeOperations(sharedRoot, operations, 'indentBlock');-- if (!newPath) return;-- const newPoint = {- path: [...newPath, ...point.path.slice(path.length)],- offset: point.offset,- };-- console.log('newPath:', newPath, 'newPoint:', newPoint);-- Transforms.select(editor, newPoint);-- return true;-}-export function handleMergeBlockBackwardWithTxn (editor: YjsEditor, node: Element, point: Point) {const operations: (() => void)[] = [];const sharedRoot = getSharedRoot(editor);@@ -978,61 +934,66 @@ export function handleMergeBlockForwardWithTxn (editor: YjsEditor, node: ElementexecuteOperations(sharedRoot, operations, 'deleteBlockForward');}-export function liftEditorNode (editor: YjsEditor, sharedRoot: YSharedRoot, block: YBlock, point: Point) {- // Find the path of the current block- const [, path] = getBlockEntry(editor, point);- const parentPath = path.slice(0, -1);- const level = path.length;+export function preventIndentNode (editor: YjsEditor, blockId: string) {+ const sharedRoot = getSharedRoot(editor);+ const block = getBlock(blockId, sharedRoot);+ const parent = getBlock(block.get(YjsEditorKey.block_parent), sharedRoot);+ const parentChildren = getChildrenArray(parent.get(YjsEditorKey.block_children), sharedRoot);+ const index = parentChildren.toArray().findIndex((id) => id === block.get(YjsEditorKey.block_id));- if (level < 2) {- return;+ if (index === 0) {+ return true;}- // This is to prevent errors caused by invalid paths when the original node is deleted during the lift process- Transforms.select(editor, Editor.start(editor, parentPath));-- liftBlock(sharedRoot, block);+ // Get the previous sibling+ const previousSiblingId = parentChildren.get(index - 1);+ const previousSibling = getBlock(previousSiblingId, sharedRoot);- // Calculate the position where the new block should be after the lift operation- const nextPath = Path.next(parentPath);+ if (!previousSibling) {+ return true;+ }- return nextPath;+ // Check if the parent block is a container block+ if (!CONTAINER_BLOCK_TYPES.includes(previousSibling.get(YjsEditorKey.block_type))) {+ return true;+ }+ return false;}-export function indentEditorNode (editor: YjsEditor, sharedRoot: YSharedRoot, block: YBlock, point: Point) {- // Find the path of the current block- const [, path] = getBlockEntry(editor, point);- const index = path[path.length - 1];+export function preventLiftNode (editor: YjsEditor, blockId: string) {+ const [, path] = findSlateEntryByBlockId(editor, blockId);+ const level = path.length;- console.log('indentEditorNode:', block.get(YjsEditorKey.block_id), 'at index', index, editor.children);- // Check if the block can be indented (not the first child)- if (index === 0) {- console.warn('Cannot indent: block is the first child');+ if (level < 2) {+ return true;+ }++ return false;+}++export function liftEditorNode (editor: YjsEditor, sharedRoot: YSharedRoot, block: YBlock, point: Point) {+ if (preventLiftNode(editor, block.get(YjsEditorKey.block_id))) {return;}- // Get the previous sibling's path- const previousSiblingPath = Path.previous(path);- const previousSibling = Editor.above(editor, {- at: [...previousSiblingPath, 0],- match: (n) => !Editor.isEditor(n) && Element.isElement(n) && n.blockId !== undefined,- });- const [previousNode] = previousSibling as NodeEntry<Element>;+ // Find the path of the current block+ const [, path] = getBlockEntry(editor, point);+ const parentPath = path.slice(0, -1);- // This is to prevent errors caused by invalid paths when the original node is deleted during the indent process- Transforms.select(editor, Editor.start(editor, previousSiblingPath));+ // This is to prevent errors caused by invalid paths when the original node is deleted during the lift process+ Transforms.select(editor, Editor.start(editor, parentPath));- // Perform the indent operation on the Yjs document- indentBlock(sharedRoot, block);+ liftBlock(sharedRoot, block);- const newPath = [...previousSiblingPath, previousNode.children.length];+ // Calculate the position where the new block should be after the lift operation+ const nextPath = Path.next(parentPath);- return newPath;+ return nextPath;}-export function liftBlock (sharedRoot: YSharedRoot, block: YBlock) {+export function liftBlock (sharedRoot: YSharedRoot, block: YBlock, offset?: number) {const parentId = block.get(YjsEditorKey.block_parent);const parent = getBlock(parentId, sharedRoot);@@ -1063,10 +1024,11 @@ export function liftBlock (sharedRoot: YSharedRoot, block: YBlock) {return;}- moveNode(sharedRoot, block, grandParent, parentIndex + 1);+ return moveNode(sharedRoot, block, grandParent, parentIndex + 1 + (offset || 0));}export function indentBlock (sharedRoot: YSharedRoot, block: YBlock) {+const parentId = block.get(YjsEditorKey.block_parent);const parent = getBlock(parentId, sharedRoot);@@ -1149,6 +1111,7 @@ export function deepCopyBlock (sharedRoot: YSharedRoot, sourceBlock: YBlock): stconst targetChildrenArray = getChildrenArray(newBlock.get(YjsEditorKey.block_children), sharedRoot);if (sourceChildrenArray && targetChildrenArray) {+deepCopyChildren(sharedRoot, sourceChildrenArray, targetChildrenArray, newBlock.get(YjsEditorKey.block_id));}diff --git a/frontend/appflowy_web_app/src/application/types.ts b/frontend/appflowy_web_app/src/application/types.tsindex 8784d3f445..76ef8a84f2 100644--- a/frontend/appflowy_web_app/src/application/types.ts+++ b/frontend/appflowy_web_app/src/application/types.ts@@ -69,6 +69,7 @@ export interface TodoListBlockData extends BlockData {export interface ToggleListBlockData extends BlockData {collapsed: boolean;+ level?: number;}export interface CodeBlockData extends BlockData {diff --git a/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/TabBehavior.cy.tsx b/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/TabBehavior.cy.tsxindex 11f8006cb0..93c590f2ac 100644--- a/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/TabBehavior.cy.tsx+++ b/frontend/appflowy_web_app/src/components/editor/__tests__/behavior/TabBehavior.cy.tsx@@ -192,4 +192,65 @@ describe('Shift+Tab key behavior', () => {// cy.matchImageSnapshot('behavior/ShiftTabKeyBehavior/should-not-outdent-at-top-level');});-});\ No newline at end of file+ describe('Tab key behavior with range selections', () => {++ it('should indent multiple blocks when tab at start', () => {+ cy.selectMultipleText(['Toggle list', 'Final outer paragraph']);+ cy.wait(100);+ cy.get('@editor').realPress('Tab');+ assertJSON([+ {+ ...initialData[0],+ children: [initialData[1], initialData[2]],+ },+ ]);+ cy.get('@editor').realPress(['Shift', 'Tab']);+ assertJSON(initialData);+ });++ it('should indent ancestor block when tab at start', () => {+ cy.selectMultipleText(['Toggle list', 'Nested paragraph 1']);+ cy.wait(100);+ cy.get('@editor').realPress('Tab');+ assertJSON([+ {+ ...initialData[0],+ children: [+ initialData[1],+ ],+ },+ initialData[2],+ ]);+ cy.get('@editor').realPress(['Shift', 'Tab']);+ assertJSON(initialData);+ });++ it('should indent different levels of nested blocks when tab at start', () => {+ cy.selectMultipleText(['Nested toggle list', 'Final outer paragraph']);+ cy.wait(100);+ cy.get('@editor').realPress('Tab');+ assertJSON([+ initialData[0],+ {+ ...initialData[1],+ children: [+ {+ ...initialData[1].children[0],+ children: [+ initialData[1].children[0].children[0],+ initialData[1].children[1],+ initialData[1].children[2],+ ],+ },++ initialData[2],+ ],+ },+ ]);+ cy.get('@editor').realPress(['Shift', 'Tab']);+ assertJSON(initialData);+ });+ });++});+diff --git a/frontend/appflowy_web_app/src/components/editor/components/blocks/toggle-list/ToggleList.tsx b/frontend/appflowy_web_app/src/components/editor/components/blocks/toggle-list/ToggleList.tsxindex 6ccc38f757..2f08ed8a15 100644--- a/frontend/appflowy_web_app/src/components/editor/components/blocks/toggle-list/ToggleList.tsx+++ b/frontend/appflowy_web_app/src/components/editor/components/blocks/toggle-list/ToggleList.tsx@@ -1,19 +1,23 @@+import { getHeadingCssProperty } from '@/components/editor/components/blocks/heading';import React, { forwardRef, memo, useMemo } from 'react';import { EditorElementProps, ToggleListNode } from '@/components/editor/editor.type';export const ToggleList = memo(forwardRef<HTMLDivElement, EditorElementProps<ToggleListNode>>(({ node, children, ...attributes }, ref) => {- const { collapsed } = useMemo(() => node.data || {}, [node.data]);- const className = `${attributes.className ?? ''} flex w-full flex-col ${collapsed ? 'collapsed' : ''}`;+ const { collapsed, level } = useMemo(() => node.data || {}, [node.data]);+ const fontSizeCssProperty = getHeadingCssProperty(level || 0);+ const className = `${attributes.className ?? ''} flex w-full flex-col ${collapsed ? 'collapsed' : ''} ${fontSizeCssProperty} level-${level}`;return (<>- <div {...attributes} ref={ref} className={className}>+ <div {...attributes} ref={ref}+ className={className}+ >{children}</div></>);- })+ }),);export default ToggleList;diff --git a/frontend/appflowy_web_app/src/components/editor/components/leaf/formula/FormulaLeaf.tsx b/frontend/appflowy_web_app/src/components/editor/components/leaf/formula/FormulaLeaf.tsxindex 2f59702751..c3c85fb2aa 100644--- a/frontend/appflowy_web_app/src/components/editor/components/leaf/formula/FormulaLeaf.tsx+++ b/frontend/appflowy_web_app/src/components/editor/components/leaf/formula/FormulaLeaf.tsx@@ -19,10 +19,14 @@ function FormulaLeaf ({ formula, text }: {const open = Boolean(anchorPosition);const readonly = useReadOnly();const className = useMemo(() => {- const classList = ['formula-inline', 'relative', 'rounded', 'p-0.5 select-none'];+ const classList = ['formula-inline', 'relative', 'rounded', 'p-0.5'];++ if (readonly) {+ classList.push('cursor-default');+ } else {+ classList.push('select-none', 'cursor-pointer');+ }- if (readonly) classList.push('cursor-default');- else classList.push('cursor-pointer');if (isSelected || open) classList.push('selected');if (isCursorAfter) classList.push('cursor-after');if (isCursorBefore) classList.push('cursor-before');diff --git a/frontend/appflowy_web_app/src/components/editor/components/leaf/mention/MentionPage.tsx b/frontend/appflowy_web_app/src/components/editor/components/leaf/mention/MentionPage.tsxindex 085ecaf52a..98c04410ef 100644--- a/frontend/appflowy_web_app/src/components/editor/components/leaf/mention/MentionPage.tsx+++ b/frontend/appflowy_web_app/src/components/editor/components/leaf/mention/MentionPage.tsx@@ -101,8 +101,8 @@ function MentionPage ({ pageId, blockId, type }: { pageId: string; blockId?: strclassName={'text-text-title ml-0.5'}/>}{type === MentionType.PageRef &&- <span className={`absolute -right-0.5 bottom-0`}>- <NorthEast className={'w-3 h-3 text-content-blue-900'} />+ <span className={`absolute ${icon?.value ? 'right-0 bottom-0' : '-right-[1px] -bottom-[1px]'}`}>+ <NorthEast className={'w-[0.7em] h-[0.7em] text-content-blue-900'} /></span>}</>;diff --git a/frontend/appflowy_web_app/src/components/editor/components/toolbar/selection-toolbar/actions/Align.tsx b/frontend/appflowy_web_app/src/components/editor/components/toolbar/selection-toolbar/actions/Align.tsxindex 496e8a303c..8da66f24dc 100644--- a/frontend/appflowy_web_app/src/components/editor/components/toolbar/selection-toolbar/actions/Align.tsx+++ b/frontend/appflowy_web_app/src/components/editor/components/toolbar/selection-toolbar/actions/Align.tsx@@ -6,6 +6,10 @@ import { ReactComponent as AlignCenterSvg } from '@/assets/toolbar_align_center.import { ReactComponent as AlignLeftSvg } from '@/assets/toolbar_align_left.svg';import { ReactComponent as AlignRightSvg } from '@/assets/toolbar_align_right.svg';import { Popover } from '@/components/_shared/popover';+import {+ useSelectionToolbarContext,+} from '@/components/editor/components/toolbar/selection-toolbar/SelectionToolbar.hooks';+import { PopoverProps } from '@mui/material/Popover';import React, { useCallback, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -30,6 +34,9 @@ const popoverProps: Partial<PopoverProps> = {export function Align () {const [open, setOpen] = useState(false);+ const {+ visible: toolbarVisible,+ } = useSelectionToolbarContext();const ref = useRef<HTMLButtonElement | null>(null);const { t } = useTranslation();const editor = useSlateStatic() as YjsEditor;@@ -91,40 +98,47 @@ export function Align () {return (<><ActionButton- ref={ref} onClick={(e) => {- e.preventDefault();- e.stopPropagation();- handleOpen();- }} tooltip={t('document.plugins.optionAction.align')}+ ref={ref}+ onClick={(e) => {+ e.preventDefault();+ e.stopPropagation();+ handleOpen();+ }}+ tooltip={t('document.plugins.optionAction.align')}>{activeIcon()}</ActionButton>+<Popover+ keepMounted={false}disableAutoFocus={true}disableEnforceFocus={true}disableRestoreFocus={true}onClose={() => {setOpen(false);}}- open={open}+ open={open && toolbarVisible}anchorEl={ref.current}{...popoverProps}><div className={'flex items-center px-2 h-[32px] justify-center'}><ActionButton- active={getAlign() === AlignType.Left} tooltip={t('document.plugins.optionAction.left')}+ active={getAlign() === AlignType.Left}+ tooltip={t('document.plugins.optionAction.left')}onClick={toggleAlign(AlignType.Left)}><AlignLeftSvg /></ActionButton><ActionButton- active={getAlign() === AlignType.Center} tooltip={t('document.plugins.optionAction.center')}+ active={getAlign() === AlignType.Center}+ tooltip={t('document.plugins.optionAction.center')}onClick={toggleAlign(AlignType.Center)}><AlignCenterSvg /></ActionButton><ActionButton- active={getAlign() === AlignType.Right} tooltip={t('document.plugins.optionAction.right')}+ active={getAlign() === AlignType.Right}+ tooltip={t('document.plugins.optionAction.right')}onClick={toggleAlign(AlignType.Right)}><AlignRightSvg />diff --git a/frontend/appflowy_web_app/src/components/editor/components/toolbar/selection-toolbar/actions/Heading.tsx b/frontend/appflowy_web_app/src/components/editor/components/toolbar/selection-toolbar/actions/Heading.tsxindex 76bcf97247..cf16d02282 100644--- a/frontend/appflowy_web_app/src/components/editor/components/toolbar/selection-toolbar/actions/Heading.tsx+++ b/frontend/appflowy_web_app/src/components/editor/components/toolbar/selection-toolbar/actions/Heading.tsx@@ -3,6 +3,9 @@ import { CustomEditor } from '@/application/slate-yjs/command';import { getBlockEntry } from '@/application/slate-yjs/utils/yjsOperations';import { BlockType, HeadingBlockData } from '@/application/types';import { Popover } from '@/components/_shared/popover';+import {+ useSelectionToolbarContext,+} from '@/components/editor/components/toolbar/selection-toolbar/SelectionToolbar.hooks';import { PopoverProps } from '@mui/material/Popover';import React, { useCallback, useRef, useState } from 'react';import ActionButton from './ActionButton';@@ -35,6 +38,9 @@ const popoverProps: Partial<PopoverProps> = {export function Heading () {const { t } = useTranslation();const editor = useSlateStatic() as YjsEditor;+ const {+ visible: toolbarVisible,+ } = useSelectionToolbarContext();const toHeading = useCallback((level: number) => {@@ -131,18 +137,30 @@ export function Heading () {onClose={() => {setOpen(false);}}- open={open}+ open={open && toolbarVisible}anchorEl={ref.current}{...popoverProps}><div className={'flex items-center px-2 h-[32px] justify-center'}>- <ActionButton active={isActivated(1)} tooltip={t('editor.heading1')} onClick={toHeading(1)}>+ <ActionButton+ active={isActivated(1)}+ tooltip={t('editor.heading1')}+ onClick={toHeading(1)}+ ><Heading1Svg /></ActionButton>- <ActionButton active={isActivated(2)} tooltip={t('editor.heading2')} onClick={toHeading(2)}>+ <ActionButton+ active={isActivated(2)}+ tooltip={t('editor.heading2')}+ onClick={toHeading(2)}+ ><Heading2Svg /></ActionButton>- <ActionButton active={isActivated(3)} tooltip={t('editor.heading3')} onClick={toHeading(3)}>+ <ActionButton+ active={isActivated(3)}+ tooltip={t('editor.heading3')}+ onClick={toHeading(3)}+ ><Heading3Svg /></ActionButton></div>diff --git a/frontend/appflowy_web_app/src/components/editor/shortcut.hooks.ts b/frontend/appflowy_web_app/src/components/editor/shortcut.hooks.tsindex 7a4577210b..5a9ce55bb1 100644--- a/frontend/appflowy_web_app/src/components/editor/shortcut.hooks.ts+++ b/frontend/appflowy_web_app/src/components/editor/shortcut.hooks.ts@@ -60,10 +60,8 @@ export function useShortcuts (editor: ReactEditor) {// Do not process shortcuts if editor is read-only or no selectionif (readOnly || !selection) return;- const [point, endPoint] = editor.edges(selection);+ const [point] = editor.edges(selection);const node = getBlockEntry(yjsEditor, point);- const endNode = getBlockEntry(yjsEditor, endPoint);- const isSameBlock = node[0].blockId === endNode[0].blockId;// Add more cases here for editing shortcutsswitch (!readOnly) {@@ -86,13 +84,12 @@ export function useShortcuts (editor: ReactEditor) {case createHotkey(HOT_KEY_NAME.INDENT_BLOCK)(e):event.preventDefault();- if (!isSameBlock) return;if (SOFT_BREAK_TYPES.includes(node[0]?.type as BlockType)) {editor.insertText('\t');break;}- CustomEditor.tabForward(yjsEditor, point);+ CustomEditor.tabEvent(yjsEditor, e);break;/*** Outdent block: Shift+Tab@@ -100,8 +97,13 @@ export function useShortcuts (editor: ReactEditor) {*/case createHotkey(HOT_KEY_NAME.OUTDENT_BLOCK)(e):event.preventDefault();- if (!isSameBlock) return;- CustomEditor.tabBackward(yjsEditor, point);++ if (SOFT_BREAK_TYPES.includes(node[0]?.type as BlockType)) {+ editor.deleteBackward('character');+ break;+ }++ CustomEditor.tabEvent(yjsEditor, e);break;/*** Split block: Enterdiff --git a/frontend/appflowy_web_app/src/components/error/NotFound.tsx b/frontend/appflowy_web_app/src/components/error/NotFound.tsxindex 0f536ebbe5..e670eda311 100644--- a/frontend/appflowy_web_app/src/components/error/NotFound.tsx+++ b/frontend/appflowy_web_app/src/components/error/NotFound.tsx@@ -1,17 +1,25 @@-import React from 'react';+import { AFConfigContext, useCurrentUser } from '@/components/main/app.hooks';+import React, { useContext } from 'react';import { Typography, Button } from '@mui/material';-import { useTranslation } from 'react-i18next';+import { Trans, useTranslation } from 'react-i18next';import { Link, useNavigate } from 'react-router-dom';import { ReactComponent as AppflowyLogo } from '@/assets/appflowy.svg';const NotFound = () => {const { t } = useTranslation();const navigate = useNavigate();+ const openLoginModal = useContext(AFConfigContext)?.openLoginModal;+ const currentUser = useCurrentUser();+ const email = currentUser?.email || '';return (<div className={'m-0 flex h-screen w-screen items-center justify-center bg-bg-body p-0'}><div className={'flex flex-col items-center gap-1 text-center'}>- <Typography variant="h3" className={'mb-[27px] flex items-center gap-4 text-text-title'} gutterBottom>+ <Typography+ variant="h3"+ className={'mb-[27px] flex items-center gap-4 text-text-title'}+ gutterBottom+ ><AppflowyLogo className={'w-32'} /></Typography><div className={'mb-[16px] text-[52px] font-semibold leading-[128%] text-text-title max-sm:text-[24px]'}>@@ -39,11 +47,43 @@ const NotFound = () => {navigate('/');}}className={'flex-1 py-3 px-4 max-sm:w-full rounded-[8px] max-md:text-base text-[20px] font-medium'}- variant={'outlined'} color={'inherit'}+ variant={'outlined'}+ color={'inherit'}>{t('requestAccess.backToHome')}</Button></div>+ {currentUser ? <div className={'max-w-[400px] mt-10 flex flex-col text-text-caption'}>+ <span>+ <Trans+ i18nKey="requestAccess.tip"+ components={{ link: <span className={'text-fill-default'}>{email}</span> }}+ />+ </span>+ <span>+ <Trans+ i18nKey="requestAccess.mightBe"+ components={{+ login: <span+ onClick={() => openLoginModal?.()}+ className={'underline text-fill-default cursor-pointer'}+ >{t('signIn.logIn')}</span>,+ }}+ />+ </span>+ </div> : <div className={'max-w-[400px] mt-10 gap-1 flex flex-col text-text-caption'}>+ You are currently not logged in.+ <div>+ Click+ <span+ className={'underline mx-1 text-fill-default cursor-pointer'}+ onClick={() => openLoginModal?.()}+ >+ here+ </span>+ to login.+ </div>+ </div>}</div></div>diff --git a/frontend/appflowy_web_app/src/components/view-meta/ViewMetaPreview.tsx b/frontend/appflowy_web_app/src/components/view-meta/ViewMetaPreview.tsxindex aedee548af..4ffcce02b9 100644--- a/frontend/appflowy_web_app/src/components/view-meta/ViewMetaPreview.tsx+++ b/frontend/appflowy_web_app/src/components/view-meta/ViewMetaPreview.tsx@@ -62,7 +62,7 @@ export function ViewMetaPreview ({ icon, cover, name }: ViewMetaProps) {<divclassName={`relative mb-6 mt-[52px] max-md:mt-[38px] px-6 w-[964px] min-w-0 max-w-full overflow-visible`}>- <div+ <h1className={'flex gap-4 overflow-hidden whitespace-pre-wrap break-words break-all text-[2.25rem] font-bold max-md:text-[26px]'}@@ -72,7 +72,7 @@ export function ViewMetaPreview ({ icon, cover, name }: ViewMetaProps) {<div className={'relative'}>{name || <span className={'text-text-placeholder'}>{t('menuAppHeader.defaultNewPageName')}</span>}</div>- </div>+ </h1></div></div>);