@difizen/libro-rendermime 0.3.32 → 0.3.34

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.
@@ -1 +1 @@
1
- {"version":3,"file":"text-render.d.ts","sourceRoot":"","sources":["../../src/components/text-render.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,cAAc,CAAC;AAWtB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,cAAc,CAAA;CAAE,CAiH7D,CAAC;AAEF,eAAO,MAAM,UAAU;WAnHuB,cAAc;EAmHT,CAAC"}
1
+ {"version":3,"file":"text-render.d.ts","sourceRoot":"","sources":["../../src/components/text-render.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,cAAc,CAAC;AAWtB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,cAAc,CAAA;CAAE,CAqJ7D,CAAC;AAEF,eAAO,MAAM,UAAU;WAvJuB,cAAc;EAuJT,CAAC"}
@@ -17,6 +17,7 @@ import { renderText } from "../renderers.js";
17
17
  import { RenderMimeRegistry } from "../rendermime-registry.js";
18
18
  import { jsx as _jsx } from "react/jsx-runtime";
19
19
  import { jsxs as _jsxs } from "react/jsx-runtime";
20
+ import { Fragment as _Fragment } from "react/jsx-runtime";
20
21
  function getLastThreeAfterFirstTwo(arr) {
21
22
  var startIndex = Math.max(2, arr.length - 3);
22
23
  return arr.slice(startIndex);
@@ -58,47 +59,76 @@ export var RawTextRender = function RawTextRender(props) {
58
59
  }
59
60
  // eslint-disable-next-line react-hooks/exhaustive-deps
60
61
  }, [mimeType, dataContent]);
61
- return /*#__PURE__*/_jsxs("div", {
62
- className: "libro-text-render-container",
63
- ref: renderTextContainerRef,
64
- children: [/*#__PURE__*/_jsx("div", {
65
- className: "libro-text-render",
66
- ref: renderTextRef,
67
- style: {
68
- overflowY: 'auto',
69
- maxHeight: "".concat(isLargeOutputDisplay ? '420px' : 'unset')
70
- }
71
- }), model.raw['display_text'] && /*#__PURE__*/_jsxs("div", {
72
- className: "libro-text-display-action-container",
73
- children: [/*#__PURE__*/_jsx("span", {
74
- children: "\u8BE5\u6BB5\u8F93\u51FA\u592A\u957F\uFF0C\u70B9\u51FB\u53EF\u8FDB\u884C"
75
- }), /*#__PURE__*/_jsx("a", {
76
- onClick: function onClick() {
77
- model.cell.isLargeOutputDisplay = !model.cell.isLargeOutputDisplay;
78
- setIsLargeOutputDisplay(!isLargeOutputDisplay);
79
- },
80
- className: "libro-text-display-action",
81
- children: isLargeOutputDisplay ? ' 展开查看' : ' 截断查看'
82
- }), isLargeOutputDisplay && /*#__PURE__*/_jsxs("span", {
83
- children: ["\uFF0C\u6216\u5728", /*#__PURE__*/_jsx("a", {
84
- className: "libro-text-display-action",
62
+ var content = null;
63
+ if (isLargeOutputDisplay) {
64
+ content = /*#__PURE__*/_jsxs(_Fragment, {
65
+ children: [/*#__PURE__*/_jsx("div", {
66
+ className: "libro-text-render",
67
+ ref: renderTextRef,
68
+ style: {
69
+ overflowY: 'auto',
70
+ maxHeight: 'unset'
71
+ }
72
+ }), model.raw['display_text'] && /*#__PURE__*/_jsxs("div", {
73
+ className: "libro-text-display-action-container",
74
+ children: [/*#__PURE__*/_jsx("span", {
75
+ children: "\u8F93\u51FA\u5DF2\u88AB\u622A\u65AD\uFF0C\u70B9\u51FB\u53EF\u5728\u6EDA\u52A8\u5BB9\u5668\u5185"
76
+ }), /*#__PURE__*/_jsx("a", {
85
77
  onClick: function onClick() {
86
- var mimeType = defaultRenderMime.defaultPreferredMimeType(model, undefined);
87
- var dataContent = null;
88
- if (mimeType) {
89
- dataContent = model.data[mimeType];
90
- if (dataContent !== null) {
91
- model.cell.parent.outputRenderTabEmitter.fire({
92
- mimeType: mimeType,
93
- data: dataContent || ''
94
- });
78
+ model.cell.isLargeOutputDisplay = !model.cell.isLargeOutputDisplay;
79
+ setIsLargeOutputDisplay(!isLargeOutputDisplay);
80
+ },
81
+ className: "libro-text-display-action",
82
+ children: "\u6EDA\u52A8\u67E5\u770B"
83
+ }), /*#__PURE__*/_jsxs("span", {
84
+ children: ["\uFF0C\u6216\u5728", /*#__PURE__*/_jsx("a", {
85
+ className: "libro-text-display-action",
86
+ onClick: function onClick() {
87
+ var mimeType = defaultRenderMime.defaultPreferredMimeType(model, undefined);
88
+ var dataContent = null;
89
+ if (mimeType) {
90
+ dataContent = model.data[mimeType];
91
+ if (dataContent !== null) {
92
+ model.cell.parent.outputRenderTabEmitter.fire({
93
+ mimeType: mimeType,
94
+ data: dataContent || ''
95
+ });
96
+ }
95
97
  }
96
- }
98
+ },
99
+ children: "\u6587\u672C\u7F16\u8F91\u5668"
100
+ }), "\u4E2D\u6253\u5F00"]
101
+ })]
102
+ })]
103
+ });
104
+ } else {
105
+ content = /*#__PURE__*/_jsxs(_Fragment, {
106
+ children: [/*#__PURE__*/_jsx("div", {
107
+ className: "libro-text-render",
108
+ ref: renderTextRef,
109
+ style: {
110
+ overflowY: 'auto',
111
+ maxHeight: '420px'
112
+ }
113
+ }), model.raw['display_text'] && /*#__PURE__*/_jsxs("div", {
114
+ className: "libro-text-display-action-container",
115
+ children: [/*#__PURE__*/_jsx("span", {
116
+ children: "\u5F53\u524D\u5904\u4E8E\u6EDA\u52A8\u67E5\u770B\uFF0C\u70B9\u51FB\u53EF"
117
+ }), /*#__PURE__*/_jsx("a", {
118
+ onClick: function onClick() {
119
+ model.cell.isLargeOutputDisplay = !model.cell.isLargeOutputDisplay;
120
+ setIsLargeOutputDisplay(!isLargeOutputDisplay);
97
121
  },
98
- children: "\u6587\u672C\u7F16\u8F91\u5668"
99
- }), "\u4E2D\u6253\u5F00"]
122
+ className: "libro-text-display-action",
123
+ children: "\u622A\u65AD\u67E5\u770B"
124
+ })]
100
125
  })]
101
- })]
126
+ });
127
+ }
128
+ return /*#__PURE__*/_jsx("div", {
129
+ className: "libro-text-render-container",
130
+ ref: renderTextContainerRef,
131
+ children: content
102
132
  });
103
133
  };
104
134
  export var TextRender = /*#__PURE__*/React.memo(RawTextRender);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-rendermime",
3
- "version": "0.3.32",
3
+ "version": "0.3.34",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
@@ -32,9 +32,9 @@
32
32
  "src"
33
33
  ],
34
34
  "dependencies": {
35
- "@difizen/libro-common": "^0.3.32",
36
- "@difizen/libro-core": "^0.3.32",
37
- "@difizen/libro-markdown": "^0.3.32",
35
+ "@difizen/libro-common": "^0.3.34",
36
+ "@difizen/libro-core": "^0.3.34",
37
+ "@difizen/libro-markdown": "^0.3.34",
38
38
  "@difizen/mana-app": "latest",
39
39
  "lodash.escape": "^4.0.1"
40
40
  },
@@ -75,29 +75,32 @@ export const RawTextRender: React.FC<{ model: BaseOutputView }> = (props: {
75
75
  }
76
76
  // eslint-disable-next-line react-hooks/exhaustive-deps
77
77
  }, [mimeType, dataContent]);
78
- return (
79
- <div className="libro-text-render-container" ref={renderTextContainerRef}>
80
- <div
81
- className="libro-text-render"
82
- ref={renderTextRef}
83
- style={{
84
- overflowY: 'auto',
85
- maxHeight: `${isLargeOutputDisplay ? '420px' : 'unset'}`,
86
- }}
87
- />
88
- {model.raw['display_text'] && (
89
- <div className="libro-text-display-action-container">
90
- <span>该段输出太长,点击可进行</span>
91
- <a
92
- onClick={() => {
93
- model.cell.isLargeOutputDisplay = !model.cell.isLargeOutputDisplay;
94
- setIsLargeOutputDisplay(!isLargeOutputDisplay);
95
- }}
96
- className="libro-text-display-action"
97
- >
98
- {isLargeOutputDisplay ? ' 展开查看' : ' 截断查看'}
99
- </a>
100
- {isLargeOutputDisplay && (
78
+
79
+ let content = null;
80
+
81
+ if (isLargeOutputDisplay) {
82
+ content = (
83
+ <>
84
+ <div
85
+ className="libro-text-render"
86
+ ref={renderTextRef}
87
+ style={{
88
+ overflowY: 'auto',
89
+ maxHeight: 'unset',
90
+ }}
91
+ />
92
+ {model.raw['display_text'] && (
93
+ <div className="libro-text-display-action-container">
94
+ <span>输出已被截断,点击可在滚动容器内</span>
95
+ <a
96
+ onClick={() => {
97
+ model.cell.isLargeOutputDisplay = !model.cell.isLargeOutputDisplay;
98
+ setIsLargeOutputDisplay(!isLargeOutputDisplay);
99
+ }}
100
+ className="libro-text-display-action"
101
+ >
102
+ 滚动查看
103
+ </a>
101
104
  <span>
102
105
  ,或在
103
106
  <a
@@ -123,9 +126,42 @@ export const RawTextRender: React.FC<{ model: BaseOutputView }> = (props: {
123
126
  </a>
124
127
  中打开
125
128
  </span>
126
- )}
127
- </div>
128
- )}
129
+ </div>
130
+ )}
131
+ </>
132
+ );
133
+ } else {
134
+ content = (
135
+ <>
136
+ <div
137
+ className="libro-text-render"
138
+ ref={renderTextRef}
139
+ style={{
140
+ overflowY: 'auto',
141
+ maxHeight: '420px',
142
+ }}
143
+ />
144
+ {model.raw['display_text'] && (
145
+ <div className="libro-text-display-action-container">
146
+ <span>当前处于滚动查看,点击可</span>
147
+ <a
148
+ onClick={() => {
149
+ model.cell.isLargeOutputDisplay = !model.cell.isLargeOutputDisplay;
150
+ setIsLargeOutputDisplay(!isLargeOutputDisplay);
151
+ }}
152
+ className="libro-text-display-action"
153
+ >
154
+ 截断查看
155
+ </a>
156
+ </div>
157
+ )}
158
+ </>
159
+ );
160
+ }
161
+
162
+ return (
163
+ <div className="libro-text-render-container" ref={renderTextContainerRef}>
164
+ {content}
129
165
  </div>
130
166
  );
131
167
  };