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): improve code editing experience
tzhangchie9fcbe24b40c
diff --git a/libs/components/editor-blocks/src/blocks/code/CodeView.tsx b/libs/components/editor-blocks/src/blocks/code/CodeView.tsxindex f5b91d7fcf..86845789c5 100644--- a/libs/components/editor-blocks/src/blocks/code/CodeView.tsx+++ b/libs/components/editor-blocks/src/blocks/code/CodeView.tsx@@ -99,7 +99,7 @@ const langs: Record<string, any> = {dockerfile: () => StreamLanguage.define(dockerFile),r: () => StreamLanguage.define(r),};-const DEFAULT_LANG = 'javascript';+const DEFAULT_LANG = 'markdown';const CodeBlock = styled('div')(({ theme }) => ({backgroundColor: '#F2F5F9',padding: '8px 24px',@@ -142,10 +142,13 @@ export const CodeView = ({ block, editor }: CreateCodeView) => {const langType: string = block.getProperty('lang');const [extensions, setExtensions] = useState<Extension[]>();const codeMirror = useRef<ReactCodeMirrorRef>();- useOnSelect(block.id, (_is_select: boolean) => {+ const focusCode = () => {if (codeMirror.current) {codeMirror?.current?.view?.focus();}+ };+ useOnSelect(block.id, (_is_select: boolean) => {+ focusCode();});const onChange = (value: string) => {block.setProperty('text', {@@ -158,6 +161,9 @@ export const CodeView = ({ block, editor }: CreateCodeView) => {};useEffect(() => {handleLangChange(langType ? langType : DEFAULT_LANG);+ setTimeout(() => {+ focusCode();+ }, 100);}, []);const copyCode = () => {