cozy-viewer 26.0.3 → 26.1.1
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 +10 -0
- package/dist/Panel/AI/AIAssistantPanel.d.ts +3 -1
- package/dist/Panel/AI/AIAssistantPanel.js +8 -6
- package/dist/components/SummarizeByAIButton.d.ts +11 -0
- package/dist/components/SummarizeByAIButton.js +88 -0
- package/dist/components/Toolbar.js +5 -34
- package/package.json +4 -4
- package/src/Panel/AI/AIAssistantPanel.jsx +5 -2
- package/src/components/SummarizeByAIButton.jsx +55 -0
- package/src/components/Toolbar.jsx +3 -34
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [26.1.1](https://github.com/cozy/cozy-libs/compare/cozy-viewer@26.1.0...cozy-viewer@26.1.1) (2025-12-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package cozy-viewer
|
|
9
|
+
|
|
10
|
+
# [26.1.0](https://github.com/cozy/cozy-libs/compare/cozy-viewer@26.0.3...cozy-viewer@26.1.0) (2025-12-11)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- Update components use in summarization to use in app :sparkles: ([bcc5447](https://github.com/cozy/cozy-libs/commit/bcc54474b11ed9753fff7c67fa91483588e10e2c))
|
|
15
|
+
|
|
6
16
|
## [26.0.3](https://github.com/cozy/cozy-libs/compare/cozy-viewer@26.0.2...cozy-viewer@26.0.3) (2025-12-10)
|
|
7
17
|
|
|
8
18
|
### Bug Fixes
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export default AIAssistantPanel;
|
|
2
|
-
declare function AIAssistantPanel(
|
|
2
|
+
declare function AIAssistantPanel({ className }: {
|
|
3
|
+
className: any;
|
|
4
|
+
}): JSX.Element;
|
|
3
5
|
declare namespace AIAssistantPanel {
|
|
4
6
|
namespace propTypes {
|
|
5
7
|
let isLoading: PropTypes.Requireable<boolean>;
|
|
@@ -69,7 +69,9 @@ var styles = {
|
|
|
69
69
|
"aiLoaderSlide": "styles__aiLoaderSlide___9K8aD"
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
var AIAssistantPanel = function AIAssistantPanel() {
|
|
72
|
+
var AIAssistantPanel = function AIAssistantPanel(_ref) {
|
|
73
|
+
var className = _ref.className;
|
|
74
|
+
|
|
73
75
|
var _useI18n = (0, _twakeI18n.useI18n)(),
|
|
74
76
|
t = _useI18n.t;
|
|
75
77
|
|
|
@@ -111,14 +113,14 @@ var AIAssistantPanel = function AIAssistantPanel() {
|
|
|
111
113
|
};
|
|
112
114
|
|
|
113
115
|
var summarizeFile = /*#__PURE__*/function () {
|
|
114
|
-
var
|
|
115
|
-
var client, file,
|
|
116
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref2) {
|
|
117
|
+
var client, file, _ref2$stream, stream, model, fileBlob, textContent, summaryConfig, _error, messages, summaryResponse;
|
|
116
118
|
|
|
117
119
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
118
120
|
while (1) {
|
|
119
121
|
switch (_context.prev = _context.next) {
|
|
120
122
|
case 0:
|
|
121
|
-
client =
|
|
123
|
+
client = _ref2.client, file = _ref2.file, _ref2$stream = _ref2.stream, stream = _ref2$stream === void 0 ? false : _ref2$stream, model = _ref2.model;
|
|
122
124
|
_context.prev = 1;
|
|
123
125
|
_context.next = 4;
|
|
124
126
|
return (0, _file.fetchBlobFileById)(client, file === null || file === void 0 ? void 0 : file._id);
|
|
@@ -179,7 +181,7 @@ var AIAssistantPanel = function AIAssistantPanel() {
|
|
|
179
181
|
}));
|
|
180
182
|
|
|
181
183
|
return function summarizeFile(_x) {
|
|
182
|
-
return
|
|
184
|
+
return _ref3.apply(this, arguments);
|
|
183
185
|
};
|
|
184
186
|
}();
|
|
185
187
|
|
|
@@ -257,7 +259,7 @@ var AIAssistantPanel = function AIAssistantPanel() {
|
|
|
257
259
|
}, [fetchSummary]);
|
|
258
260
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Stack.default, {
|
|
259
261
|
spacing: "s",
|
|
260
|
-
className: (0, _classnames.default)('u-flex u-flex-column u-h-100')
|
|
262
|
+
className: (0, _classnames.default)('u-flex u-flex-column u-h-100', className)
|
|
261
263
|
}, /*#__PURE__*/_react.default.createElement(_Paper.default, {
|
|
262
264
|
className: (0, _classnames.default)({
|
|
263
265
|
'u-flex-grow-1': !isLoading
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default SummarizeByAIButton;
|
|
2
|
+
declare function SummarizeByAIButton({ onPaywallRedirect, className }: {
|
|
3
|
+
onPaywallRedirect: any;
|
|
4
|
+
className: any;
|
|
5
|
+
}): JSX.Element;
|
|
6
|
+
declare namespace SummarizeByAIButton {
|
|
7
|
+
namespace propTypes {
|
|
8
|
+
let onPaywallRedirect: PropTypes.Requireable<(...args: any[]) => any>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
import PropTypes from 'prop-types';
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
|
|
16
|
+
var _twakeI18n = require("twake-i18n");
|
|
17
|
+
|
|
18
|
+
var _cozyFlags = _interopRequireDefault(require("cozy-flags"));
|
|
19
|
+
|
|
20
|
+
var _Buttons = _interopRequireDefault(require("cozy-ui/transpiled/react/Buttons"));
|
|
21
|
+
|
|
22
|
+
var _Icon = _interopRequireDefault(require("cozy-ui/transpiled/react/Icon"));
|
|
23
|
+
|
|
24
|
+
var _Text = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Text"));
|
|
25
|
+
|
|
26
|
+
var _helpers = require("../helpers");
|
|
27
|
+
|
|
28
|
+
var _ViewerProvider = require("../providers/ViewerProvider");
|
|
29
|
+
|
|
30
|
+
var styles = {
|
|
31
|
+
"viewer-nav": "styles__viewer-nav___3V03k",
|
|
32
|
+
"viewer-nav--visible": "styles__viewer-nav--visible___4GLTe",
|
|
33
|
+
"viewer-nav--previous": "styles__viewer-nav--previous___2LsMS",
|
|
34
|
+
"viewer-nav-arrow": "styles__viewer-nav-arrow___Z0ykc",
|
|
35
|
+
"viewer-nav--next": "styles__viewer-nav--next___3mBHi",
|
|
36
|
+
"viewer-controls": "styles__viewer-controls___2lf-z",
|
|
37
|
+
"--expanded": "styles__--expanded___1sp4Q",
|
|
38
|
+
"viewer-toolbar": "styles__viewer-toolbar___1GLOA",
|
|
39
|
+
"viewer-toolbar--hidden": "styles__viewer-toolbar--hidden___Zq97m",
|
|
40
|
+
"viewer-footer": "styles__viewer-footer___iGv8J",
|
|
41
|
+
"viewer-ai-summarise-btn": "styles__viewer-ai-summarise-btn___2YOrl"
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var SummarizeByAIButton = function SummarizeByAIButton(_ref) {
|
|
45
|
+
var onPaywallRedirect = _ref.onPaywallRedirect,
|
|
46
|
+
className = _ref.className;
|
|
47
|
+
|
|
48
|
+
var _useI18n = (0, _twakeI18n.useI18n)(),
|
|
49
|
+
t = _useI18n.t;
|
|
50
|
+
|
|
51
|
+
var _useViewer = (0, _ViewerProvider.useViewer)(),
|
|
52
|
+
setIsOpenAiAssistant = _useViewer.setIsOpenAiAssistant,
|
|
53
|
+
file = _useViewer.file,
|
|
54
|
+
pdfPageCount = _useViewer.pdfPageCount;
|
|
55
|
+
|
|
56
|
+
var isAiEnabled = (0, _cozyFlags.default)('ai.enabled');
|
|
57
|
+
var isAiAvailable = (0, _cozyFlags.default)('ai.available');
|
|
58
|
+
var isSummaryCompatible = (0, _helpers.isFileSummaryCompatible)(file, {
|
|
59
|
+
pageCount: pdfPageCount
|
|
60
|
+
});
|
|
61
|
+
var showSummariseButton = isAiAvailable && isSummaryCompatible;
|
|
62
|
+
|
|
63
|
+
var handleSummariseClick = function handleSummariseClick() {
|
|
64
|
+
if (!isAiEnabled && onPaywallRedirect) {
|
|
65
|
+
onPaywallRedirect();
|
|
66
|
+
} else {
|
|
67
|
+
setIsOpenAiAssistant(true);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return showSummariseButton ? /*#__PURE__*/_react.default.createElement(_Buttons.default, {
|
|
72
|
+
variant: "text",
|
|
73
|
+
startIcon: /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
74
|
+
icon: _Text.default,
|
|
75
|
+
className: (0, _classnames.default)(styles['viewer-ai-summarise-btn'])
|
|
76
|
+
}),
|
|
77
|
+
"aria-label": t('Viewer.summariseWithAi'),
|
|
78
|
+
label: t('Viewer.summariseWithAi'),
|
|
79
|
+
onClick: handleSummariseClick,
|
|
80
|
+
className: (0, _classnames.default)(styles['viewer-ai-summarise-btn'], className)
|
|
81
|
+
}) : null;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
SummarizeByAIButton.propTypes = {
|
|
85
|
+
onPaywallRedirect: _propTypes.default.func
|
|
86
|
+
};
|
|
87
|
+
var _default = SummarizeByAIButton;
|
|
88
|
+
exports.default = _default;
|
|
@@ -21,8 +21,6 @@ var _cozyClient = require("cozy-client");
|
|
|
21
21
|
|
|
22
22
|
var _file = require("cozy-client/dist/models/file");
|
|
23
23
|
|
|
24
|
-
var _cozyFlags = _interopRequireDefault(require("cozy-flags"));
|
|
25
|
-
|
|
26
24
|
var _cozyIntent = require("cozy-intent");
|
|
27
25
|
|
|
28
26
|
var _cozySharing = require("cozy-sharing");
|
|
@@ -39,8 +37,6 @@ var _Download = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/D
|
|
|
39
37
|
|
|
40
38
|
var _Previous = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Previous"));
|
|
41
39
|
|
|
42
|
-
var _Text = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Text"));
|
|
43
|
-
|
|
44
40
|
var _MidEllipsis = _interopRequireDefault(require("cozy-ui/transpiled/react/MidEllipsis"));
|
|
45
41
|
|
|
46
42
|
var _Typography = _interopRequireDefault(require("cozy-ui/transpiled/react/Typography"));
|
|
@@ -49,12 +45,12 @@ var _withBreakpoints = _interopRequireDefault(require("cozy-ui/transpiled/react/
|
|
|
49
45
|
|
|
50
46
|
var _Encrypted = require("cozy-ui/transpiled/react/providers/Encrypted");
|
|
51
47
|
|
|
48
|
+
var _SummarizeByAIButton = _interopRequireDefault(require("./SummarizeByAIButton"));
|
|
49
|
+
|
|
52
50
|
var _ToolbarFilePath = require("./ToolbarFilePath");
|
|
53
51
|
|
|
54
52
|
var _helpers = require("../Footer/helpers");
|
|
55
53
|
|
|
56
|
-
var _helpers2 = require("../helpers");
|
|
57
|
-
|
|
58
54
|
var _ShareModalProvider = require("../providers/ShareModalProvider");
|
|
59
55
|
|
|
60
56
|
var _ViewerProvider = require("../providers/ViewerProvider");
|
|
@@ -91,9 +87,7 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
91
87
|
var webviewIntent = (0, _cozyIntent.useWebviewIntent)();
|
|
92
88
|
|
|
93
89
|
var _useViewer = (0, _ViewerProvider.useViewer)(),
|
|
94
|
-
file = _useViewer.file
|
|
95
|
-
setIsOpenAiAssistant = _useViewer.setIsOpenAiAssistant,
|
|
96
|
-
pdfPageCount = _useViewer.pdfPageCount;
|
|
90
|
+
file = _useViewer.file;
|
|
97
91
|
|
|
98
92
|
var _useSharingInfos = (0, _cozySharing.useSharingInfos)(),
|
|
99
93
|
isSharingShortcutCreated = _useSharingInfos.isSharingShortcutCreated,
|
|
@@ -116,21 +110,6 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
116
110
|
file: file,
|
|
117
111
|
name: 'ToolbarButtons'
|
|
118
112
|
});
|
|
119
|
-
var isAiAvailable = (0, _cozyFlags.default)('ai.available');
|
|
120
|
-
var isAiEnabled = (0, _cozyFlags.default)('ai.enabled');
|
|
121
|
-
var isSummaryCompatible = (0, _helpers2.isFileSummaryCompatible)(file, {
|
|
122
|
-
pageCount: pdfPageCount
|
|
123
|
-
});
|
|
124
|
-
var showSummariseButton = isAiAvailable && isSummaryCompatible;
|
|
125
|
-
|
|
126
|
-
var handleSummariseClick = function handleSummariseClick() {
|
|
127
|
-
if (!isAiEnabled && onPaywallRedirect) {
|
|
128
|
-
onPaywallRedirect();
|
|
129
|
-
} else {
|
|
130
|
-
setIsOpenAiAssistant(true);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
|
|
134
113
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
135
114
|
ref: toolbarRef,
|
|
136
115
|
"data-testid": "viewer-toolbar",
|
|
@@ -169,16 +148,8 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
169
148
|
className: "u-white",
|
|
170
149
|
color: "default",
|
|
171
150
|
isShortLabel: true
|
|
172
|
-
}),
|
|
173
|
-
|
|
174
|
-
startIcon: /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
175
|
-
icon: _Text.default,
|
|
176
|
-
className: (0, _classnames.default)(styles['viewer-ai-summarise-btn'])
|
|
177
|
-
}),
|
|
178
|
-
"aria-label": t('Viewer.summariseWithAi'),
|
|
179
|
-
label: t('Viewer.summariseWithAi'),
|
|
180
|
-
onClick: handleSummariseClick,
|
|
181
|
-
className: (0, _classnames.default)(styles['viewer-ai-summarise-btn'])
|
|
151
|
+
}), /*#__PURE__*/_react.default.createElement(_SummarizeByAIButton.default, {
|
|
152
|
+
onPaywallRedirect: onPaywallRedirect
|
|
182
153
|
}), /*#__PURE__*/_react.default.createElement(_Buttons.default, {
|
|
183
154
|
className: "u-white",
|
|
184
155
|
variant: "text",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-viewer",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.1.1",
|
|
4
4
|
"description": "Cozy-Viewer provides a component to show files in a viewer.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"babel-preset-cozy-app": "^2.8.2",
|
|
32
32
|
"cozy-client": "^60.20.0",
|
|
33
33
|
"cozy-device-helper": "2.0.0",
|
|
34
|
-
"cozy-harvest-lib": "^36.0.
|
|
34
|
+
"cozy-harvest-lib": "^36.0.7",
|
|
35
35
|
"cozy-intent": "^2.30.1",
|
|
36
36
|
"cozy-logger": "^1.17.0",
|
|
37
|
-
"cozy-sharing": "^28.0
|
|
37
|
+
"cozy-sharing": "^28.1.0",
|
|
38
38
|
"cozy-ui": "^135.0.0",
|
|
39
39
|
"cozy-ui-plus": "^4.1.0",
|
|
40
40
|
"identity-obj-proxy": "3.0.0",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react-router-dom": ">=6.14.2",
|
|
71
71
|
"twake-i18n": ">=0.3.0"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "5a6cae822a71ed09c62b53de7329df0aa4e5a01e"
|
|
74
74
|
}
|
|
@@ -25,7 +25,7 @@ import styles from './styles.styl'
|
|
|
25
25
|
import { getSummaryConfig, roughTokensEstimation } from '../../helpers'
|
|
26
26
|
import { useViewer } from '../../providers/ViewerProvider'
|
|
27
27
|
|
|
28
|
-
const AIAssistantPanel = () => {
|
|
28
|
+
const AIAssistantPanel = ({ className }) => {
|
|
29
29
|
const { t } = useI18n()
|
|
30
30
|
const client = useClient()
|
|
31
31
|
const { file, setIsOpenAiAssistant } = useViewer()
|
|
@@ -124,7 +124,10 @@ const AIAssistantPanel = () => {
|
|
|
124
124
|
|
|
125
125
|
return (
|
|
126
126
|
<>
|
|
127
|
-
<Stack
|
|
127
|
+
<Stack
|
|
128
|
+
spacing="s"
|
|
129
|
+
className={cx('u-flex u-flex-column u-h-100', className)}
|
|
130
|
+
>
|
|
128
131
|
<Paper
|
|
129
132
|
className={cx({
|
|
130
133
|
'u-flex-grow-1': !isLoading
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import cx from 'classnames'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { useI18n } from 'twake-i18n'
|
|
5
|
+
|
|
6
|
+
import flag from 'cozy-flags'
|
|
7
|
+
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
8
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
9
|
+
import TextIcon from 'cozy-ui/transpiled/react/Icons/Text'
|
|
10
|
+
|
|
11
|
+
import styles from './styles.styl'
|
|
12
|
+
import { isFileSummaryCompatible } from '../helpers'
|
|
13
|
+
import { useViewer } from '../providers/ViewerProvider'
|
|
14
|
+
|
|
15
|
+
const SummarizeByAIButton = ({ onPaywallRedirect, className }) => {
|
|
16
|
+
const { t } = useI18n()
|
|
17
|
+
const { setIsOpenAiAssistant, file, pdfPageCount } = useViewer()
|
|
18
|
+
|
|
19
|
+
const isAiEnabled = flag('ai.enabled')
|
|
20
|
+
const isAiAvailable = flag('ai.available')
|
|
21
|
+
const isSummaryCompatible = isFileSummaryCompatible(file, {
|
|
22
|
+
pageCount: pdfPageCount
|
|
23
|
+
})
|
|
24
|
+
const showSummariseButton = isAiAvailable && isSummaryCompatible
|
|
25
|
+
|
|
26
|
+
const handleSummariseClick = () => {
|
|
27
|
+
if (!isAiEnabled && onPaywallRedirect) {
|
|
28
|
+
onPaywallRedirect()
|
|
29
|
+
} else {
|
|
30
|
+
setIsOpenAiAssistant(true)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return showSummariseButton ? (
|
|
35
|
+
<Button
|
|
36
|
+
variant="text"
|
|
37
|
+
startIcon={
|
|
38
|
+
<Icon
|
|
39
|
+
icon={TextIcon}
|
|
40
|
+
className={cx(styles['viewer-ai-summarise-btn'])}
|
|
41
|
+
/>
|
|
42
|
+
}
|
|
43
|
+
aria-label={t('Viewer.summariseWithAi')}
|
|
44
|
+
label={t('Viewer.summariseWithAi')}
|
|
45
|
+
onClick={handleSummariseClick}
|
|
46
|
+
className={cx(styles['viewer-ai-summarise-btn'], className)}
|
|
47
|
+
/>
|
|
48
|
+
) : null
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
SummarizeByAIButton.propTypes = {
|
|
52
|
+
onPaywallRedirect: PropTypes.func
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default SummarizeByAIButton
|
|
@@ -5,7 +5,6 @@ import { useI18n } from 'twake-i18n'
|
|
|
5
5
|
|
|
6
6
|
import { useClient } from 'cozy-client'
|
|
7
7
|
import { downloadFile } from 'cozy-client/dist/models/file'
|
|
8
|
-
import flag from 'cozy-flags'
|
|
9
8
|
import { useWebviewIntent } from 'cozy-intent'
|
|
10
9
|
import {
|
|
11
10
|
OpenSharingLinkButton,
|
|
@@ -19,16 +18,15 @@ import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
|
19
18
|
import IconButton from 'cozy-ui/transpiled/react/IconButton'
|
|
20
19
|
import DownloadIcon from 'cozy-ui/transpiled/react/Icons/Download'
|
|
21
20
|
import PreviousIcon from 'cozy-ui/transpiled/react/Icons/Previous'
|
|
22
|
-
import TextIcon from 'cozy-ui/transpiled/react/Icons/Text'
|
|
23
21
|
import MidEllipsis from 'cozy-ui/transpiled/react/MidEllipsis'
|
|
24
22
|
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
25
23
|
import withBreakpoints from 'cozy-ui/transpiled/react/helpers/withBreakpoints'
|
|
26
24
|
import { useEncrypted } from 'cozy-ui/transpiled/react/providers/Encrypted'
|
|
27
25
|
|
|
26
|
+
import SummarizeByAIButton from './SummarizeByAIButton'
|
|
28
27
|
import { ToolbarFilePath } from './ToolbarFilePath'
|
|
29
28
|
import styles from './styles.styl'
|
|
30
29
|
import { extractChildrenCompByName } from '../Footer/helpers'
|
|
31
|
-
import { isFileSummaryCompatible } from '../helpers'
|
|
32
30
|
import { useShareModal } from '../providers/ShareModalProvider'
|
|
33
31
|
import { useViewer } from '../providers/ViewerProvider'
|
|
34
32
|
|
|
@@ -46,7 +44,7 @@ const Toolbar = ({
|
|
|
46
44
|
const client = useClient()
|
|
47
45
|
const { t } = useI18n()
|
|
48
46
|
const webviewIntent = useWebviewIntent()
|
|
49
|
-
const { file
|
|
47
|
+
const { file } = useViewer()
|
|
50
48
|
const { isSharingShortcutCreated, addSharingLink, loading } =
|
|
51
49
|
useSharingInfos()
|
|
52
50
|
const { isOwner } = useSharingContext()
|
|
@@ -61,21 +59,6 @@ const Toolbar = ({
|
|
|
61
59
|
name: 'ToolbarButtons'
|
|
62
60
|
})
|
|
63
61
|
|
|
64
|
-
const isAiAvailable = flag('ai.available')
|
|
65
|
-
const isAiEnabled = flag('ai.enabled')
|
|
66
|
-
const isSummaryCompatible = isFileSummaryCompatible(file, {
|
|
67
|
-
pageCount: pdfPageCount
|
|
68
|
-
})
|
|
69
|
-
const showSummariseButton = isAiAvailable && isSummaryCompatible
|
|
70
|
-
|
|
71
|
-
const handleSummariseClick = () => {
|
|
72
|
-
if (!isAiEnabled && onPaywallRedirect) {
|
|
73
|
-
onPaywallRedirect()
|
|
74
|
-
} else {
|
|
75
|
-
setIsOpenAiAssistant(true)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
62
|
return (
|
|
80
63
|
<div
|
|
81
64
|
ref={toolbarRef}
|
|
@@ -123,21 +106,7 @@ const Toolbar = ({
|
|
|
123
106
|
isShortLabel
|
|
124
107
|
/>
|
|
125
108
|
)}
|
|
126
|
-
{
|
|
127
|
-
<Button
|
|
128
|
-
variant="text"
|
|
129
|
-
startIcon={
|
|
130
|
-
<Icon
|
|
131
|
-
icon={TextIcon}
|
|
132
|
-
className={cx(styles['viewer-ai-summarise-btn'])}
|
|
133
|
-
/>
|
|
134
|
-
}
|
|
135
|
-
aria-label={t('Viewer.summariseWithAi')}
|
|
136
|
-
label={t('Viewer.summariseWithAi')}
|
|
137
|
-
onClick={handleSummariseClick}
|
|
138
|
-
className={cx(styles['viewer-ai-summarise-btn'])}
|
|
139
|
-
/>
|
|
140
|
-
)}
|
|
109
|
+
<SummarizeByAIButton onPaywallRedirect={onPaywallRedirect} />
|
|
141
110
|
<Button
|
|
142
111
|
className="u-white"
|
|
143
112
|
variant="text"
|