There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat(code): focus
tzhangchi04065bd6bd6f
diff --git a/libs/components/editor-blocks/src/blocks/code/CodeView.tsx b/libs/components/editor-blocks/src/blocks/code/CodeView.tsxindex 86845789c5..ff6638deb3 100644--- a/libs/components/editor-blocks/src/blocks/code/CodeView.tsx+++ b/libs/components/editor-blocks/src/blocks/code/CodeView.tsx@@ -39,7 +39,7 @@ import { yaml } from '@codemirror/legacy-modes/mode/yaml';import { Extension } from '@codemirror/state';import {BlockPendantProvider,- useOnSelect,+ useOnSelectActive,} from '@toeverything/components/editor-core';import { DuplicateIcon } from '@toeverything/components/icons';import { Option, Select, styled } from '@toeverything/components/ui';@@ -147,7 +147,8 @@ export const CodeView = ({ block, editor }: CreateCodeView) => {codeMirror?.current?.view?.focus();}};- useOnSelect(block.id, (_is_select: boolean) => {+ //TODO listen codeMirror.up down event , active+ useOnSelectActive(block.id, () => {focusCode();});const onChange = (value: string) => {@@ -161,9 +162,9 @@ export const CodeView = ({ block, editor }: CreateCodeView) => {};useEffect(() => {handleLangChange(langType ? langType : DEFAULT_LANG);- setTimeout(() => {- focusCode();- }, 100);+ // setTimeout(() => {+ // focusCode();+ // }, 100);}, []);const copyCode = () => {diff --git a/libs/components/editor-plugins/src/menu/command-menu/Menu.tsx b/libs/components/editor-plugins/src/menu/command-menu/Menu.tsxindex 2772ec0d41..1bdda4e739 100644--- a/libs/components/editor-plugins/src/menu/command-menu/Menu.tsx+++ b/libs/components/editor-plugins/src/menu/command-menu/Menu.tsx@@ -118,7 +118,7 @@ export const CommandMenu = ({ editor, hooks, style }: CommandMenuProps) => {?.getRangeAt(0)?.getBoundingClientRect();if (rect) {- let rectTop = rect.top;+ const rectTop = rect.top;const clientHeight =document.documentElement.clientHeight;@@ -224,8 +224,10 @@ export const CommandMenu = ({ editor, hooks, style }: CommandMenuProps) => {await commonCommandMenuHandler(blockId, type, editor);}const block = await editor.getBlockById(blockId);- let nextBlock = await block.nextSibling();- editor.selectionManager.activeNodeByNodeId(nextBlock.id);+ const nextBlock = await block.nextSibling();+ setTimeout(() => {+ editor.selectionManager.activeNodeByNodeId(nextBlock.id);+ });if (block.blockProvider.isEmpty()) {block.remove();}