mirror of
https://github.com/toeverything/AFFiNE.git
synced 2025-01-03 19:23:37 +03:00
Merge pull request #383 from toeverything/feat/editing-experience
Feat/editing experience
This commit is contained in:
commit
b90ce50c0f
@ -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 = () => {
|
||||
|
Loading…
Reference in New Issue
Block a user