@kids-reporter/draft-editor 1.0.16 → 1.0.18
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/lib/block-renderer-fn.js +1 -1
- package/lib/block-renderers/blockquote.js +21 -18
- package/lib/block-renderers/embedded-code.js +31 -25
- package/lib/block-renderers/image-link.js +78 -73
- package/lib/block-renderers/image.js +23 -21
- package/lib/block-renderers/info-box.js +22 -19
- package/lib/block-renderers/slideshow.js +22 -19
- package/lib/block-renderers/styled.js +12 -8
- package/lib/buttons/anchor.js +18 -14
- package/lib/buttons/annotation.js +19 -15
- package/lib/buttons/bg-color.js +31 -23
- package/lib/buttons/blockquote.js +68 -62
- package/lib/buttons/control-buttons.js +31 -25
- package/lib/buttons/divider.js +29 -21
- package/lib/buttons/embedded-code.js +84 -76
- package/lib/buttons/enlarge.js +7 -5
- package/lib/buttons/font-color.js +21 -16
- package/lib/buttons/form/select.js +14 -10
- package/lib/buttons/image-link.js +26 -22
- package/lib/buttons/image.js +18 -12
- package/lib/buttons/index.js +6 -6
- package/lib/buttons/info-box.js +79 -73
- package/lib/buttons/link.js +17 -15
- package/lib/buttons/news-reading.js +65 -56
- package/lib/buttons/selector/align-selector.js +20 -16
- package/lib/buttons/selector/image-selector.js +119 -88
- package/lib/buttons/selector/pagination.js +45 -33
- package/lib/buttons/selector/search-box.js +19 -18
- package/lib/buttons/slideshow.js +18 -12
- package/lib/buttons/toc-anchor.js +9 -5
- package/lib/entity-decorators/anchor.js +46 -33
- package/lib/entity-decorators/annotation.js +53 -52
- package/lib/entity-decorators/link.js +38 -36
- package/lib/entity-decorators/toc-anchor.js +41 -35
- package/lib/entity-decorators/wrapper.js +9 -6
- package/lib/index.js +7 -6
- package/lib/local-types/kids-reporter__draft-renderer.d.js +1 -0
- package/lib/rich-text-editor.js +110 -84
- package/lib/styled.js +14 -3
- package/package.json +12 -10
- package/lib/buttons/form/array-field.js +0 -30
|
@@ -5,19 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.NewsReadingButton = NewsReadingButton;
|
|
7
7
|
exports.NewsReadingInput = NewsReadingInput;
|
|
8
|
-
var
|
|
9
|
-
var
|
|
8
|
+
var _fields = require("@keystone-ui/fields");
|
|
9
|
+
var _modals = require("@keystone-ui/modals");
|
|
10
10
|
var _errors = _interopRequireDefault(require("@twreporter/errors"));
|
|
11
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
11
12
|
var _draftJs = require("draft-js");
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
18
|
// @ts-ignore pkg does not have definition
|
|
18
19
|
|
|
19
20
|
async function fetchNewsReadingGroup(itemId) {
|
|
20
|
-
var _res$data, _res$data2;
|
|
21
21
|
const query = `
|
|
22
22
|
query GetNewsReadingGroup($itemId: ID!){
|
|
23
23
|
newsReadingGroup(where: {id: $itemId}) {
|
|
@@ -40,13 +40,13 @@ query GetNewsReadingGroup($itemId: ID!){
|
|
|
40
40
|
const annotatedErr = _errors.default.helpers.annotateAxiosError(err);
|
|
41
41
|
throw annotatedErr;
|
|
42
42
|
}
|
|
43
|
-
if (
|
|
43
|
+
if (res.data?.errors) {
|
|
44
44
|
const annotatingError = _errors.default.helpers.wrap(new Error('Errors occured while executing `GetNewsReadingGroup` query'), 'GraphQLError', '`errors` returned in the GQL query response', {
|
|
45
45
|
errors: res.data.errors
|
|
46
46
|
});
|
|
47
47
|
throw annotatingError;
|
|
48
48
|
}
|
|
49
|
-
return
|
|
49
|
+
return res.data?.data?.newsReadingGroup;
|
|
50
50
|
}
|
|
51
51
|
function NewsReadingInput({
|
|
52
52
|
isOpen,
|
|
@@ -58,9 +58,8 @@ function NewsReadingInput({
|
|
|
58
58
|
const [warning, setWarning] = (0, _react.useState)('');
|
|
59
59
|
const confirmInput = async () => {
|
|
60
60
|
try {
|
|
61
|
-
var _newsReadingGroup$ite;
|
|
62
61
|
const newsReadingGroup = await fetchNewsReadingGroup(inputValueState);
|
|
63
|
-
if (newsReadingGroup === null ||
|
|
62
|
+
if (newsReadingGroup === null || newsReadingGroup?.items?.length === 0) {
|
|
64
63
|
throw new Error(`input ${inputValueState} has no data.`);
|
|
65
64
|
}
|
|
66
65
|
onConfirm({
|
|
@@ -77,7 +76,7 @@ function NewsReadingInput({
|
|
|
77
76
|
};
|
|
78
77
|
let warningJsx = null;
|
|
79
78
|
if (warning) {
|
|
80
|
-
warningJsx = /*#__PURE__*/
|
|
79
|
+
warningJsx = /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.AlertDialog, {
|
|
81
80
|
isOpen: warning !== '',
|
|
82
81
|
title: `Something went wrong`,
|
|
83
82
|
actions: {
|
|
@@ -87,37 +86,43 @@ function NewsReadingInput({
|
|
|
87
86
|
},
|
|
88
87
|
label: 'Done'
|
|
89
88
|
}
|
|
90
|
-
}
|
|
91
|
-
}, /*#__PURE__*/_react.default.createElement(_fields.TextArea, {
|
|
92
|
-
readOnly: true
|
|
93
|
-
}, warning));
|
|
94
|
-
}
|
|
95
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, warningJsx, /*#__PURE__*/_react.default.createElement(_modals.DrawerController, {
|
|
96
|
-
isOpen: isOpen
|
|
97
|
-
}, /*#__PURE__*/_react.default.createElement(_modals.Drawer, {
|
|
98
|
-
title: "\u8B80\u5831\u4E3B\u984C",
|
|
99
|
-
actions: {
|
|
100
|
-
cancel: {
|
|
101
|
-
label: 'Cancel',
|
|
102
|
-
action: onCancel
|
|
103
89
|
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
90
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fields.TextArea, {
|
|
91
|
+
readOnly: true,
|
|
92
|
+
children: warning
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
97
|
+
children: [warningJsx, /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.DrawerController, {
|
|
98
|
+
isOpen: isOpen,
|
|
99
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.Drawer, {
|
|
100
|
+
title: "\u8B80\u5831\u4E3B\u984C",
|
|
101
|
+
actions: {
|
|
102
|
+
cancel: {
|
|
103
|
+
label: 'Cancel',
|
|
104
|
+
action: onCancel
|
|
105
|
+
},
|
|
106
|
+
confirm: {
|
|
107
|
+
label: 'Confirm',
|
|
108
|
+
action: confirmInput
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fields.TextInput, {
|
|
112
|
+
onChange: e => {
|
|
113
|
+
setInputValueState(e.target.value);
|
|
114
|
+
},
|
|
115
|
+
placeholder: "News-readings-groups Item ID",
|
|
116
|
+
type: "text",
|
|
117
|
+
value: inputValueState,
|
|
118
|
+
style: {
|
|
119
|
+
marginBottom: '10px',
|
|
120
|
+
marginTop: '30px'
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
})]
|
|
125
|
+
});
|
|
121
126
|
}
|
|
122
127
|
function NewsReadingButton(props) {
|
|
123
128
|
const {
|
|
@@ -130,11 +135,10 @@ function NewsReadingButton(props) {
|
|
|
130
135
|
setIsInputOpen(true);
|
|
131
136
|
};
|
|
132
137
|
const onInputChange = inputValue => {
|
|
133
|
-
var _inputValue$newsReadi;
|
|
134
138
|
const contentState = editorState.getCurrentContent();
|
|
135
139
|
const contentStateWithEntity = contentState.createEntity('NEWS_READING', 'IMMUTABLE', {
|
|
136
140
|
newsReadingGroupId: inputValue.newsReadingGroupId,
|
|
137
|
-
readings:
|
|
141
|
+
readings: inputValue?.newsReadingGroup?.items || []
|
|
138
142
|
});
|
|
139
143
|
const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
|
|
140
144
|
const newEditorState = _draftJs.EditorState.set(editorState, {
|
|
@@ -149,17 +153,22 @@ function NewsReadingButton(props) {
|
|
|
149
153
|
const onInputCancel = () => {
|
|
150
154
|
setIsInputOpen(false);
|
|
151
155
|
};
|
|
152
|
-
return /*#__PURE__*/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
156
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
|
|
157
|
+
children: [isInputOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(NewsReadingInput, {
|
|
158
|
+
isOpen: isInputOpen,
|
|
159
|
+
onConfirm: onInputChange,
|
|
160
|
+
onCancel: onInputCancel,
|
|
161
|
+
inputValue: ""
|
|
162
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
163
|
+
onClick: () => {
|
|
164
|
+
promptForInput();
|
|
165
|
+
},
|
|
166
|
+
className: className,
|
|
167
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
168
|
+
className: "far"
|
|
169
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
170
|
+
children: "\u8B80\u5831"
|
|
171
|
+
})]
|
|
172
|
+
})]
|
|
173
|
+
});
|
|
165
174
|
}
|
|
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.AlignSelector = AlignSelector;
|
|
7
|
+
var _fields = require("@keystone-ui/fields");
|
|
7
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
9
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
var
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -44,19 +45,22 @@ function AlignSelector(props) {
|
|
|
44
45
|
onOpen();
|
|
45
46
|
}
|
|
46
47
|
}, [isOpen]);
|
|
47
|
-
return /*#__PURE__*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
|
|
49
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Label, {
|
|
50
|
+
htmlFor: "alignment",
|
|
51
|
+
children: "\u5C0D\u9F4A"
|
|
52
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(AlignSelect, {
|
|
53
|
+
id: "alignment"
|
|
54
|
+
// default align === undefined
|
|
55
|
+
,
|
|
56
|
+
value: options.find(option => option.value === align) || null,
|
|
57
|
+
options: options,
|
|
58
|
+
onChange: option => {
|
|
59
|
+
onChange(option.value);
|
|
60
|
+
},
|
|
61
|
+
onMenuOpen: () => setIsOpen(true),
|
|
62
|
+
onMenuClose: () => setIsOpen(false),
|
|
63
|
+
menuHeight: menuHeight
|
|
64
|
+
})]
|
|
65
|
+
});
|
|
62
66
|
}
|
|
@@ -5,17 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.ImageAlignment = exports.ImageAlignOptions = void 0;
|
|
7
7
|
exports.ImageSelector = ImageSelector;
|
|
8
|
-
var
|
|
8
|
+
var _apollo = require("@keystone-6/core/admin-ui/apollo");
|
|
9
|
+
var _modals = require("@keystone-ui/modals");
|
|
9
10
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
12
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
-
var _modals = require("@keystone-ui/modals");
|
|
12
|
-
var _apollo = require("@keystone-6/core/admin-ui/apollo");
|
|
13
13
|
var _alignSelector = require("./align-selector");
|
|
14
|
-
var _searchBox = require("./search-box");
|
|
15
14
|
var _pagination = require("./pagination");
|
|
16
|
-
|
|
15
|
+
var _searchBox = require("./search-box");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
20
|
let ImageAlignment = exports.ImageAlignment = /*#__PURE__*/function (ImageAlignment) {
|
|
20
21
|
ImageAlignment["DEFAULT"] = "default";
|
|
21
22
|
ImageAlignment["PARAGRAPH"] = "paragraph-width";
|
|
@@ -87,15 +88,16 @@ function ImageGrids(props) {
|
|
|
87
88
|
images,
|
|
88
89
|
onSelect
|
|
89
90
|
} = props;
|
|
90
|
-
return /*#__PURE__*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridsBlock, {
|
|
92
|
+
children: images.map(image => {
|
|
93
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridBlock, {
|
|
94
|
+
onClick: () => onSelect(image),
|
|
95
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Img, {
|
|
96
|
+
src: image?.imageFile?.url
|
|
97
|
+
})
|
|
98
|
+
}, image.id);
|
|
99
|
+
})
|
|
100
|
+
});
|
|
99
101
|
}
|
|
100
102
|
function ImageMetaGrids(props) {
|
|
101
103
|
const {
|
|
@@ -104,35 +106,39 @@ function ImageMetaGrids(props) {
|
|
|
104
106
|
enableCaption,
|
|
105
107
|
enableDelete
|
|
106
108
|
} = props;
|
|
107
|
-
return /*#__PURE__*/
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
109
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridsBlock, {
|
|
110
|
+
children: imageMetas.map((imageMeta, idx) => {
|
|
111
|
+
const {
|
|
112
|
+
desc,
|
|
113
|
+
url
|
|
114
|
+
} = imageMeta;
|
|
115
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(GridBlock, {
|
|
116
|
+
children: [enableDelete && /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
117
|
+
onClick: () => {
|
|
118
|
+
onChange(imageMeta, 'delete');
|
|
119
|
+
},
|
|
120
|
+
className: "fas fa-check-circle"
|
|
121
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Img, {
|
|
122
|
+
src: imageMeta?.imageFile?.url
|
|
123
|
+
}), enableCaption && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
|
|
124
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Label, {
|
|
125
|
+
htmlFor: "caption",
|
|
126
|
+
children: "Image Caption:"
|
|
127
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("textarea", {
|
|
128
|
+
id: "caption",
|
|
129
|
+
placeholder: imageMeta?.name,
|
|
130
|
+
defaultValue: desc,
|
|
131
|
+
onChange: _.debounce(e => {
|
|
132
|
+
onChange(Object.assign({}, imageMeta, {
|
|
133
|
+
desc: e.target.value,
|
|
134
|
+
url
|
|
135
|
+
}), 'modify');
|
|
136
|
+
})
|
|
137
|
+
})]
|
|
138
|
+
})]
|
|
139
|
+
}, idx);
|
|
140
|
+
})
|
|
141
|
+
});
|
|
136
142
|
}
|
|
137
143
|
const imagesQuery = (0, _apollo.gql)`
|
|
138
144
|
query Photos($searchText: String!, $take: Int, $skip: Int) {
|
|
@@ -197,10 +203,9 @@ function ImageSelector(props) {
|
|
|
197
203
|
setAlign(align);
|
|
198
204
|
};
|
|
199
205
|
const onAlignSelectOpen = () => {
|
|
200
|
-
|
|
201
|
-
const scrollWrapper = (_contentWrapperRef$cu = contentWrapperRef.current) === null || _contentWrapperRef$cu === void 0 ? void 0 : _contentWrapperRef$cu.parentElement;
|
|
206
|
+
const scrollWrapper = contentWrapperRef.current?.parentElement;
|
|
202
207
|
if (scrollWrapper) {
|
|
203
|
-
scrollWrapper.scrollTop = scrollWrapper
|
|
208
|
+
scrollWrapper.scrollTop = scrollWrapper?.scrollHeight;
|
|
204
209
|
}
|
|
205
210
|
};
|
|
206
211
|
const changeSelectedImage = (imageEntityWithMeta, actionType) => {
|
|
@@ -245,51 +250,77 @@ function ImageSelector(props) {
|
|
|
245
250
|
});
|
|
246
251
|
}
|
|
247
252
|
}, [currentPage, searchText]);
|
|
248
|
-
let searchResult = /*#__PURE__*/
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
253
|
+
let searchResult = /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
254
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ImageGrids, {
|
|
255
|
+
images: images,
|
|
256
|
+
onSelect: selectImage
|
|
257
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_pagination.Pagination, {
|
|
258
|
+
currentPage: currentPage,
|
|
259
|
+
total: imagesCount,
|
|
260
|
+
pageSize: pageSize,
|
|
261
|
+
onChange: pageIndex => {
|
|
262
|
+
setCurrentPage(pageIndex);
|
|
263
|
+
}
|
|
264
|
+
})]
|
|
265
|
+
});
|
|
259
266
|
if (loading) {
|
|
260
|
-
searchResult = /*#__PURE__*/
|
|
267
|
+
searchResult = /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
268
|
+
children: "searching..."
|
|
269
|
+
});
|
|
261
270
|
}
|
|
262
271
|
if (error) {
|
|
263
|
-
|
|
264
|
-
|
|
272
|
+
searchResult = /*#__PURE__*/(0, _jsxRuntime.jsxs)(ErrorWrapper, {
|
|
273
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h3", {
|
|
274
|
+
children: "Errors occurs in the `images` query"
|
|
275
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
276
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), /*#__PURE__*/(0, _jsxRuntime.jsx)("b", {
|
|
277
|
+
children: "Message:"
|
|
278
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
279
|
+
children: error.message
|
|
280
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), /*#__PURE__*/(0, _jsxRuntime.jsx)("b", {
|
|
281
|
+
children: "Stack:"
|
|
282
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
283
|
+
children: error.stack
|
|
284
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), /*#__PURE__*/(0, _jsxRuntime.jsx)("b", {
|
|
285
|
+
children: "Query:"
|
|
286
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("pre", {
|
|
287
|
+
children: imagesQuery.loc?.source.body
|
|
288
|
+
})]
|
|
289
|
+
})]
|
|
290
|
+
});
|
|
265
291
|
}
|
|
266
|
-
return /*#__PURE__*/
|
|
267
|
-
isOpen: true
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
292
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.DrawerController, {
|
|
293
|
+
isOpen: true,
|
|
294
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_modals.Drawer, {
|
|
295
|
+
title: "Select image",
|
|
296
|
+
actions: {
|
|
297
|
+
cancel: {
|
|
298
|
+
label: 'Cancel',
|
|
299
|
+
action: onCancel
|
|
300
|
+
},
|
|
301
|
+
confirm: {
|
|
302
|
+
label: 'Confirm',
|
|
303
|
+
action: onSave
|
|
304
|
+
}
|
|
274
305
|
},
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
})
|
|
306
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
307
|
+
ref: contentWrapperRef,
|
|
308
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(SearchBox, {
|
|
309
|
+
onChange: onSearchBoxChange
|
|
310
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(MainBlock, {
|
|
311
|
+
children: [searchResult, selected.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(SeparationLine, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(ImageMetaGrids, {
|
|
312
|
+
imageMetas: selected,
|
|
313
|
+
onChange: changeSelectedImage,
|
|
314
|
+
enableCaption: enableCaption,
|
|
315
|
+
enableDelete: enableMultiSelect
|
|
316
|
+
})]
|
|
317
|
+
}), enableAlignment && /*#__PURE__*/(0, _jsxRuntime.jsx)(_alignSelector.AlignSelector, {
|
|
318
|
+
align: align,
|
|
319
|
+
options: ImageAlignOptions,
|
|
320
|
+
onChange: onAlignSelectChange,
|
|
321
|
+
onOpen: onAlignSelectOpen
|
|
322
|
+
})]
|
|
323
|
+
})
|
|
324
|
+
})
|
|
325
|
+
});
|
|
295
326
|
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Pagination = Pagination;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
11
|
const PaginationWrapper = _styledComponents.default.div`
|
|
11
12
|
display: flex;
|
|
@@ -27,6 +28,7 @@ const ArrowButtonWrapper = _styledComponents.default.a`
|
|
|
27
28
|
cursor: unset;
|
|
28
29
|
`;
|
|
29
30
|
}
|
|
31
|
+
return '';
|
|
30
32
|
}}
|
|
31
33
|
`;
|
|
32
34
|
function Pagination({
|
|
@@ -42,37 +44,47 @@ function Pagination({
|
|
|
42
44
|
|
|
43
45
|
// Don't render the pagiantion component if the pageSize is greater than the total number of items in the list.
|
|
44
46
|
if (total <= pageSize) return null;
|
|
45
|
-
return /*#__PURE__*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
47
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(PaginationWrapper, {
|
|
48
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
49
|
+
children: [currentPage, " of ", limit, " pages"]
|
|
50
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Arrows, {
|
|
51
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ArrowButtonWrapper, {
|
|
52
|
+
onClick: () => {
|
|
53
|
+
onChange(prevPage);
|
|
54
|
+
},
|
|
55
|
+
disable: prevPage < minPage,
|
|
56
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
|
|
57
|
+
"aria-hidden": "true",
|
|
58
|
+
focusable: "false",
|
|
59
|
+
height: "24px",
|
|
60
|
+
width: "24px",
|
|
61
|
+
role: "img",
|
|
62
|
+
viewBox: "0 0 24 24",
|
|
63
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
64
|
+
className: "css-bztyua",
|
|
65
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("polyline", {
|
|
66
|
+
points: "15 18 9 12 15 6"
|
|
67
|
+
}), ' ']
|
|
68
|
+
})
|
|
69
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(ArrowButtonWrapper, {
|
|
70
|
+
onClick: () => {
|
|
71
|
+
onChange(nextPage);
|
|
72
|
+
},
|
|
73
|
+
disable: nextPage > limit,
|
|
74
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
75
|
+
"aria-hidden": "true",
|
|
76
|
+
focusable: "false",
|
|
77
|
+
height: "24px",
|
|
78
|
+
width: "24px",
|
|
79
|
+
role: "img",
|
|
80
|
+
viewBox: "0 0 24 24",
|
|
81
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
82
|
+
className: "css-bztyua",
|
|
83
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("polyline", {
|
|
84
|
+
points: "9 18 15 12 9 6"
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
})]
|
|
88
|
+
})]
|
|
89
|
+
});
|
|
78
90
|
}
|
|
@@ -4,13 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SearchBox = SearchBox;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
7
|
var _button = require("@keystone-ui/button");
|
|
10
8
|
var _fields = require("@keystone-ui/fields");
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
13
|
const SearchBoxWrapper = _styledComponents.default.div`
|
|
15
14
|
display: flex;
|
|
16
15
|
`;
|
|
@@ -20,18 +19,20 @@ function SearchBox(props) {
|
|
|
20
19
|
className
|
|
21
20
|
} = props;
|
|
22
21
|
const [searchInput, setSearchInput] = (0, _react.useState)('');
|
|
23
|
-
return /*#__PURE__*/
|
|
24
|
-
className: className
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(SearchBoxWrapper, {
|
|
23
|
+
className: className,
|
|
24
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_fields.TextInput, {
|
|
25
|
+
type: "text",
|
|
26
|
+
placeholder: "\u8ACB\u8F38\u5165\u95DC\u9375\u5B57\u641C\u5C0B",
|
|
27
|
+
value: searchInput,
|
|
28
|
+
onChange: e => {
|
|
29
|
+
setSearchInput(e.target.value);
|
|
30
|
+
}
|
|
31
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
|
|
32
|
+
onClick: () => {
|
|
33
|
+
onChange(searchInput);
|
|
34
|
+
},
|
|
35
|
+
children: "Search"
|
|
36
|
+
})]
|
|
37
|
+
});
|
|
37
38
|
}
|