@lobehub/lobehub 2.0.0-next.229 → 2.0.0-next.230

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 2.0.0-next.230](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.229...v2.0.0-next.230)
6
+
7
+ <sup>Released on **2026-01-07**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix edit rich render codeblock.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix edit rich render codeblock, closes [#11303](https://github.com/lobehub/lobe-chat/issues/11303) ([5338170](https://github.com/lobehub/lobe-chat/commit/5338170))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ## [Version 2.0.0-next.229](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.228...v2.0.0-next.229)
6
31
 
7
32
  <sup>Released on **2026-01-07**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,13 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "fixes": [
5
+ "Fix edit rich render codeblock."
6
+ ]
7
+ },
8
+ "date": "2026-01-07",
9
+ "version": "2.0.0-next.230"
10
+ },
2
11
  {
3
12
  "children": {
4
13
  "fixes": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/lobehub",
3
- "version": "2.0.0-next.229",
3
+ "version": "2.0.0-next.230",
4
4
  "description": "LobeHub - an open-source,comprehensive AI Agent framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -202,7 +202,7 @@
202
202
  "@lobehub/chat-plugin-sdk": "^1.32.4",
203
203
  "@lobehub/chat-plugins-gateway": "^1.9.0",
204
204
  "@lobehub/desktop-ipc-typings": "workspace:*",
205
- "@lobehub/editor": "^3.4.1",
205
+ "@lobehub/editor": "^3.6.0",
206
206
  "@lobehub/icons": "^4.0.2",
207
207
  "@lobehub/market-sdk": "^0.27.1",
208
208
  "@lobehub/tts": "^4.0.2",
@@ -89,17 +89,7 @@ const InputEditor = memo<{ defaultRows?: number }>(({ defaultRows = 2 }) => {
89
89
  !enableRichRender
90
90
  ? {
91
91
  enablePasteMarkdown: false,
92
- markdownOption: {
93
- bold: false,
94
- code: false,
95
- header: false,
96
- italic: false,
97
- quote: false,
98
- strikethrough: false,
99
- underline: false,
100
- underlineStrikethrough: false,
101
- },
102
- plugins: [ReactCodemirrorPlugin],
92
+ markdownOption: false,
103
93
  }
104
94
  : {
105
95
  plugins: [
@@ -10,7 +10,10 @@ import {
10
10
  } from '@lobehub/editor';
11
11
  import { Editor } from '@lobehub/editor/react';
12
12
  import { Flexbox } from '@lobehub/ui';
13
- import { FC } from 'react';
13
+ import { FC, useMemo } from 'react';
14
+
15
+ import { useUserStore } from '@/store/user';
16
+ import { labPreferSelectors } from '@/store/user/selectors';
14
17
 
15
18
  import TypoBar from './Typobar';
16
19
 
@@ -20,9 +23,32 @@ interface EditorCanvasProps {
20
23
  }
21
24
 
22
25
  const EditorCanvas: FC<EditorCanvasProps> = ({ defaultValue, editor }) => {
26
+ const enableRichRender = useUserStore(labPreferSelectors.enableInputMarkdown);
27
+
28
+ const richRenderProps = useMemo(
29
+ () =>
30
+ !enableRichRender
31
+ ? {
32
+ enablePasteMarkdown: false,
33
+ markdownOption: false,
34
+ }
35
+ : {
36
+ plugins: [
37
+ ReactListPlugin,
38
+ ReactCodePlugin,
39
+ ReactCodemirrorPlugin,
40
+ ReactHRPlugin,
41
+ ReactLinkPlugin,
42
+ ReactTablePlugin,
43
+ ReactMathPlugin,
44
+ ],
45
+ },
46
+ [enableRichRender],
47
+ );
48
+
23
49
  return (
24
50
  <>
25
- <TypoBar editor={editor} />
51
+ {enableRichRender && <TypoBar editor={editor} />}
26
52
  <Flexbox
27
53
  padding={16}
28
54
  style={{ cursor: 'text', maxHeight: '80vh', minHeight: '50vh', overflowY: 'auto' }}
@@ -34,25 +60,21 @@ const EditorCanvas: FC<EditorCanvasProps> = ({ defaultValue, editor }) => {
34
60
  onInit={(editor) => {
35
61
  if (!editor || !defaultValue) return;
36
62
  try {
37
- editor?.setDocument('markdown', defaultValue);
63
+ if (enableRichRender) {
64
+ editor?.setDocument('markdown', defaultValue);
65
+ } else {
66
+ editor?.setDocument('text', defaultValue);
67
+ }
38
68
  } catch (e) {
39
69
  console.error('setDocument error:', e);
40
70
  }
41
71
  }}
42
- plugins={[
43
- ReactListPlugin,
44
- ReactCodePlugin,
45
- ReactCodemirrorPlugin,
46
- ReactHRPlugin,
47
- ReactLinkPlugin,
48
- ReactTablePlugin,
49
- ReactMathPlugin,
50
- ]}
51
72
  style={{
52
73
  paddingBottom: 120,
53
74
  }}
54
75
  type={'text'}
55
76
  variant={'chat'}
77
+ {...richRenderProps}
56
78
  />
57
79
  </Flexbox>
58
80
  </>
@@ -3,11 +3,7 @@ import { Modal, ModalProps, createRawModal } from '@lobehub/ui';
3
3
  import { memo, useState } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
 
6
- import { useUserStore } from '@/store/user';
7
- import { labPreferSelectors } from '@/store/user/slices/preference/selectors';
8
-
9
6
  import EditorCanvas from './EditorCanvas';
10
- import TextareCanvas from './TextareCanvas';
11
7
 
12
8
  interface EditorModalProps extends ModalProps {
13
9
  onConfirm?: (value: string) => Promise<void>;
@@ -17,8 +13,7 @@ interface EditorModalProps extends ModalProps {
17
13
  export const EditorModal = memo<EditorModalProps>(({ value, onConfirm, ...rest }) => {
18
14
  const [confirmLoading, setConfirmLoading] = useState(false);
19
15
  const { t } = useTranslation('common');
20
- const [v, setV] = useState(value);
21
- const enableRichRender = useUserStore(labPreferSelectors.enableInputMarkdown);
16
+
22
17
  const editor = useEditor();
23
18
 
24
19
  return (
@@ -30,13 +25,12 @@ export const EditorModal = memo<EditorModalProps>(({ value, onConfirm, ...rest }
30
25
  okText={t('ok')}
31
26
  onOk={async () => {
32
27
  setConfirmLoading(true);
33
- let finalValue;
34
- if (enableRichRender) {
35
- finalValue = editor?.getDocument('markdown') as unknown as string;
36
- } else {
37
- finalValue = v;
28
+ try {
29
+ await onConfirm?.((editor?.getDocument('markdown') as unknown as string) || '');
30
+ } catch (e) {
31
+ console.error('EditorModal onOk error:', e);
32
+ onConfirm?.(value || '');
38
33
  }
39
- await onConfirm?.(finalValue || '');
40
34
  setConfirmLoading(false);
41
35
  }}
42
36
  styles={{
@@ -49,11 +43,7 @@ export const EditorModal = memo<EditorModalProps>(({ value, onConfirm, ...rest }
49
43
  width={'min(90vw, 920px)'}
50
44
  {...rest}
51
45
  >
52
- {enableRichRender ? (
53
- <EditorCanvas defaultValue={value} editor={editor} />
54
- ) : (
55
- <TextareCanvas defaultValue={value} onChange={(v) => setV(v)} value={v} />
56
- )}
46
+ <EditorCanvas defaultValue={value} editor={editor} />
57
47
  </Modal>
58
48
  );
59
49
  });
@@ -1,30 +0,0 @@
1
- import { TextArea } from '@lobehub/ui';
2
- import { FC } from 'react';
3
-
4
- interface EditorCanvasProps {
5
- defaultValue?: string;
6
- onChange?: (value: string) => void;
7
- value?: string;
8
- }
9
-
10
- const EditorCanvas: FC<EditorCanvasProps> = ({ defaultValue, value, onChange }) => {
11
- return (
12
- <TextArea
13
- defaultValue={defaultValue}
14
- onChange={(e) => {
15
- onChange?.(e.target.value);
16
- }}
17
- style={{
18
- cursor: 'text',
19
- maxHeight: '80vh',
20
- minHeight: '50vh',
21
- overflowY: 'auto',
22
- padding: 16,
23
- }}
24
- value={value}
25
- variant={'borderless'}
26
- />
27
- );
28
- };
29
-
30
- export default EditorCanvas;