@difizen/libro-prompt-cell 0.2.2 → 0.2.4

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.
@@ -155,9 +155,7 @@ export var PromptOutputRender = function PromptOutputRender(props) {
155
155
  var updateSelection = function updateSelection() {
156
156
  var _document$getSelectio;
157
157
  var tmpSelection = (_document$getSelectio = document.getSelection()) === null || _document$getSelectio === void 0 ? void 0 : _document$getSelectio.toString();
158
- if (tmpSelection) {
159
- setSelection(tmpSelection);
160
- }
158
+ setSelection(tmpSelection || '');
161
159
  };
162
160
  return /*#__PURE__*/_jsxs("div", {
163
161
  className: "libro-prompt-output-render-container",
@@ -180,12 +178,12 @@ export var PromptOutputRender = function PromptOutputRender(props) {
180
178
  onClick: insert,
181
179
  className: "libro-prompt-output-btn",
182
180
  children: "\u63D2\u5165\u4EE3\u7801"
181
+ }), /*#__PURE__*/_jsx("span", {
182
+ onClick: copy,
183
+ className: "libro-prompt-output-btn",
184
+ children: "\u590D\u5236\u4EE3\u7801"
183
185
  })]
184
- }), /*#__PURE__*/_jsx("span", {
185
- onClick: copy,
186
- className: "libro-prompt-output-btn",
187
- children: "\u590D\u5236\u4EE3\u7801"
188
- }), /*#__PURE__*/_jsx("span", {
186
+ }), selection && /*#__PURE__*/_jsx("span", {
189
187
  onClick: copySelection,
190
188
  className: "libro-prompt-output-btn",
191
189
  children: "\u590D\u5236\u9009\u4E2D\u5185\u5BB9"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-prompt-cell",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
@@ -32,12 +32,12 @@
32
32
  "src"
33
33
  ],
34
34
  "dependencies": {
35
- "@difizen/libro-code-editor": "^0.2.2",
36
- "@difizen/libro-jupyter": "^0.2.2",
37
- "@difizen/libro-rendermime": "^0.2.2",
38
- "@difizen/libro-codemirror": "^0.2.2",
39
- "@difizen/libro-common": "^0.2.2",
40
- "@difizen/libro-core": "^0.2.2",
35
+ "@difizen/libro-code-editor": "^0.2.4",
36
+ "@difizen/libro-jupyter": "^0.2.4",
37
+ "@difizen/libro-rendermime": "^0.2.4",
38
+ "@difizen/libro-codemirror": "^0.2.4",
39
+ "@difizen/libro-common": "^0.2.4",
40
+ "@difizen/libro-core": "^0.2.4",
41
41
  "@ant-design/icons": "^5.1.0",
42
42
  "@difizen/mana-l10n": "latest",
43
43
  "@difizen/mana-app": "latest",
@@ -88,9 +88,7 @@ export const PromptOutputRender: React.FC<{
88
88
 
89
89
  const updateSelection = () => {
90
90
  const tmpSelection = document.getSelection()?.toString();
91
- if (tmpSelection) {
92
- setSelection(tmpSelection);
93
- }
91
+ setSelection(tmpSelection || '');
94
92
  };
95
93
 
96
94
  return (
@@ -108,14 +106,16 @@ export const PromptOutputRender: React.FC<{
108
106
  <span onClick={insert} className="libro-prompt-output-btn">
109
107
  插入代码
110
108
  </span>
109
+ <span onClick={copy} className="libro-prompt-output-btn">
110
+ 复制代码
111
+ </span>
111
112
  </>
112
113
  )}
113
- <span onClick={copy} className="libro-prompt-output-btn">
114
- 复制代码
115
- </span>
116
- <span onClick={copySelection} className="libro-prompt-output-btn">
117
- 复制选中内容
118
- </span>
114
+ {selection && (
115
+ <span onClick={copySelection} className="libro-prompt-output-btn">
116
+ 复制选中内容
117
+ </span>
118
+ )}
119
119
  </div>
120
120
  );
121
121
  };