@lobehub/chat 0.119.9 → 0.119.10

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 0.119.10](https://github.com/lobehub/lobe-chat/compare/v0.119.9...v0.119.10)
6
+
7
+ <sup>Released on **2024-01-08**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Debug information cannot be selected.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Debug information cannot be selected, closes [#980](https://github.com/lobehub/lobe-chat/issues/980) ([f02612d](https://github.com/lobehub/lobe-chat/commit/f02612d))
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 0.119.9](https://github.com/lobehub/lobe-chat/compare/v0.119.8...v0.119.9)
6
31
 
7
32
  <sup>Released on **2024-01-08**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.119.9",
3
+ "version": "0.119.10",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot 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",
@@ -7,6 +7,7 @@ enum ElType {
7
7
  div,
8
8
  input,
9
9
  markdown,
10
+ debug,
10
11
  }
11
12
 
12
13
  // 模拟elementFromPoint方法
@@ -19,6 +20,10 @@ document.elementFromPoint = function (x) {
19
20
  return document.createElement('input');
20
21
  }
21
22
 
23
+ if (x === ElType.debug) {
24
+ return document.createElement('pre');
25
+ }
26
+
22
27
  if (x === ElType.markdown) {
23
28
  const markdownEl = document.createElement('article');
24
29
  const markdownChildEl = document.createElement('p');
@@ -68,7 +73,7 @@ describe('useAutoFocus', () => {
68
73
  const inputRef = { current: { focus: vi.fn() } } as RefObject<any>;
69
74
  renderHook(() => useAutoFocus(inputRef));
70
75
 
71
- // Simulate a mousedown event on an input element
76
+ // Simulate a mousedown event on a markdown element
72
77
  act(() => {
73
78
  document.dispatchEvent(
74
79
  new MouseEvent('mousedown', { bubbles: true, clientX: ElType.markdown }),
@@ -82,4 +87,21 @@ describe('useAutoFocus', () => {
82
87
 
83
88
  expect(inputRef.current?.focus).not.toHaveBeenCalled();
84
89
  });
90
+
91
+ it('should not focus inputRef when mouseup event happens inside of debug element', () => {
92
+ const inputRef = { current: { focus: vi.fn() } } as RefObject<any>;
93
+ renderHook(() => useAutoFocus(inputRef));
94
+
95
+ // Simulate a mousedown event on a debug element
96
+ act(() => {
97
+ document.dispatchEvent(new MouseEvent('mousedown', { bubbles: true, clientX: ElType.debug }));
98
+ });
99
+
100
+ // Simulate a mouseup event
101
+ act(() => {
102
+ document.dispatchEvent(new MouseEvent('mouseup', { bubbles: true }));
103
+ });
104
+
105
+ expect(inputRef.current?.focus).not.toHaveBeenCalled();
106
+ });
85
107
  });
@@ -11,9 +11,12 @@ export const useAutoFocus = (inputRef: RefObject<TextAreaRef>) => {
11
11
  if (!element) return;
12
12
  let currentElement: Element | null = element;
13
13
  // 因为点击 Markdown 元素时,element 会是 article 标签的子元素
14
- // 所以向上查找全局点击对象是否是 Markdown 或者 Input 元素
14
+ // Debug 信息时,element 会是 pre 标签
15
+ // 所以向上查找全局点击对象是否是 Markdown 或者 Input 或者 Debug 元素
15
16
  while (currentElement && !isInputOrMarkdown) {
16
- isInputOrMarkdown = ['TEXTAREA', 'INPUT', 'ARTICLE'].includes(currentElement.tagName);
17
+ isInputOrMarkdown = ['TEXTAREA', 'INPUT', 'ARTICLE', 'PRE'].includes(
18
+ currentElement.tagName,
19
+ );
17
20
  currentElement = currentElement.parentElement;
18
21
  }
19
22
  };