@ablogcms/media 3.2.28-beta.0
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/README.md +28 -0
- package/dist/acms.d.ts +10 -0
- package/dist/acms.mjs +1 -0
- package/dist/acms.mjs.map +1 -0
- package/dist/chunk-32U7ADG2.mjs +456 -0
- package/dist/chunk-32U7ADG2.mjs.map +1 -0
- package/dist/chunk-3SYVRD3N.mjs +37 -0
- package/dist/chunk-3SYVRD3N.mjs.map +1 -0
- package/dist/chunk-5P6HFS6L.mjs +90 -0
- package/dist/chunk-5P6HFS6L.mjs.map +1 -0
- package/dist/chunk-J5LGTIGS.mjs +10 -0
- package/dist/chunk-J5LGTIGS.mjs.map +1 -0
- package/dist/chunk-JJTHI4QP.mjs +1783 -0
- package/dist/chunk-JJTHI4QP.mjs.map +1 -0
- package/dist/chunk-KQNVYJOK.mjs +1814 -0
- package/dist/chunk-KQNVYJOK.mjs.map +1 -0
- package/dist/chunk-LAZAMWG6.mjs +231 -0
- package/dist/chunk-LAZAMWG6.mjs.map +1 -0
- package/dist/components/media-admin/media-admin-view.d.ts +22 -0
- package/dist/components/media-admin/media-admin.d.ts +6 -0
- package/dist/components/media-admin/media-admin.mjs +148 -0
- package/dist/components/media-admin/media-admin.mjs.map +1 -0
- package/dist/components/media-droparea/media-droparea.d.ts +63 -0
- package/dist/components/media-droparea/media-droparea.mjs +152 -0
- package/dist/components/media-droparea/media-droparea.mjs.map +1 -0
- package/dist/components/media-edit-modal/media-edit-modal.d.ts +58 -0
- package/dist/components/media-insert/media-insert-modal.d.ts +30 -0
- package/dist/components/media-insert/media-insert.d.ts +5 -0
- package/dist/components/media-insert/media-insert.mjs +11 -0
- package/dist/components/media-insert/media-insert.mjs.map +1 -0
- package/dist/components/media-list/media-list.d.ts +125 -0
- package/dist/components/media-modal/media-modal.d.ts +94 -0
- package/dist/components/media-modal/pdf-previewer.d.ts +8 -0
- package/dist/components/media-unit/media-unit.d.ts +65 -0
- package/dist/components/media-unit/media-unit.mjs +13 -0
- package/dist/components/media-unit/media-unit.mjs.map +1 -0
- package/dist/components/media-update/media-update-modal.d.ts +12 -0
- package/dist/components/media-update/media-update.d.ts +5 -0
- package/dist/components/media-update/media-update.mjs +10 -0
- package/dist/components/media-update/media-update.mjs.map +1 -0
- package/dist/components/media-uploader/media-uploader.d.ts +69 -0
- package/dist/constants/index.d.ts +19 -0
- package/dist/containers/media-admin.d.ts +10 -0
- package/dist/containers/media-insert.d.ts +17 -0
- package/dist/containers/media-update.d.ts +13 -0
- package/dist/dataview/column-type.d.ts +10 -0
- package/dist/dataview/column-type.mjs +75 -0
- package/dist/dataview/column-type.mjs.map +1 -0
- package/dist/events.d.ts +70 -0
- package/dist/media-crop-focal-OQHAYXEP.svg +1 -0
- package/dist/media-crop-icon-LD2QEJHL.svg +12 -0
- package/dist/media-focal-point-OQQ3MQM2.svg +3 -0
- package/dist/media-rotate-icon-HBMXAPD4.svg +7 -0
- package/dist/runtime.d.ts +20 -0
- package/dist/runtime.mjs +16 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/setup-media-unit.d.ts +2 -0
- package/dist/setup-media-unit.mjs +118 -0
- package/dist/setup-media-unit.mjs.map +1 -0
- package/dist/stores/actions.d.ts +64 -0
- package/dist/stores/reducer.d.ts +5 -0
- package/dist/stores/saga.d.ts +35 -0
- package/dist/types/config.d.ts +29 -0
- package/dist/types/index.d.ts +83 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types/transport.d.ts +76 -0
- package/dist/utils/index.d.ts +5 -0
- package/package.json +112 -0
|
@@ -0,0 +1,1814 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getMediaTransport
|
|
3
|
+
} from "./chunk-3SYVRD3N.mjs";
|
|
4
|
+
|
|
5
|
+
// src/components/media-list/media-list.tsx
|
|
6
|
+
import classnames from "classnames";
|
|
7
|
+
import RangeSlider from "rc-slider";
|
|
8
|
+
import dayjs from "dayjs";
|
|
9
|
+
import "rc-slider/assets/index.css";
|
|
10
|
+
import { Component, createRef } from "react";
|
|
11
|
+
import { emit } from "@ablogcms/events";
|
|
12
|
+
import { Grid, GridItem } from "@ablogcms/components/grid";
|
|
13
|
+
import { formatBytes, parseQuery } from "@ablogcms/utils";
|
|
14
|
+
import { notify } from "@ablogcms/notify";
|
|
15
|
+
import { pending } from "@ablogcms/pending";
|
|
16
|
+
import {
|
|
17
|
+
Menu,
|
|
18
|
+
MenuList,
|
|
19
|
+
MenuTrigger,
|
|
20
|
+
MenuDivider,
|
|
21
|
+
MenuItemCheckbox,
|
|
22
|
+
MenuItemRadioGroup,
|
|
23
|
+
MenuItemRadio,
|
|
24
|
+
MenuPopover
|
|
25
|
+
} from "@ablogcms/components/dropdown-menu";
|
|
26
|
+
import { Pagination, PaginationRoot, PaginationSummary } from "@ablogcms/components/pagination";
|
|
27
|
+
import {
|
|
28
|
+
Filter,
|
|
29
|
+
FilterBody,
|
|
30
|
+
FilterContent,
|
|
31
|
+
FilterDetailButton,
|
|
32
|
+
FilterFooter,
|
|
33
|
+
FilterGroup,
|
|
34
|
+
FilterGroupTitle,
|
|
35
|
+
FilterInner,
|
|
36
|
+
FilterItem,
|
|
37
|
+
FilterItemLabel
|
|
38
|
+
} from "@ablogcms/components/filter";
|
|
39
|
+
import ConditionalWrap from "@ablogcms/components/conditional-wrap";
|
|
40
|
+
import { RichSelect, CreatableSelect } from "@ablogcms/components/rich-select";
|
|
41
|
+
import VisuallyHidden from "@ablogcms/components/visually-hidden";
|
|
42
|
+
import { Slot } from "@ablogcms/components/slot-fill";
|
|
43
|
+
import {
|
|
44
|
+
Table,
|
|
45
|
+
TableScrollable,
|
|
46
|
+
TableHeader,
|
|
47
|
+
TableBody,
|
|
48
|
+
TableRow,
|
|
49
|
+
TableHead,
|
|
50
|
+
TableCell
|
|
51
|
+
} from "@ablogcms/components/table";
|
|
52
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
53
|
+
var delimiter = ",";
|
|
54
|
+
var MediaList = class extends Component {
|
|
55
|
+
listRef;
|
|
56
|
+
static defaultProps = {
|
|
57
|
+
radioMode: false,
|
|
58
|
+
filetype: "all",
|
|
59
|
+
extensions: []
|
|
60
|
+
};
|
|
61
|
+
constructor(props) {
|
|
62
|
+
super(props);
|
|
63
|
+
this.state = {
|
|
64
|
+
order: {
|
|
65
|
+
media_title: "asc",
|
|
66
|
+
media_last_modified: "desc",
|
|
67
|
+
media_path: "asc",
|
|
68
|
+
media_size: "asc",
|
|
69
|
+
media_filesize: "asc"
|
|
70
|
+
},
|
|
71
|
+
menu: {
|
|
72
|
+
image: true,
|
|
73
|
+
id: true,
|
|
74
|
+
filename: true,
|
|
75
|
+
tag: true,
|
|
76
|
+
last_modified: true,
|
|
77
|
+
upload_datetime: false,
|
|
78
|
+
imagesize: true,
|
|
79
|
+
filesize: true,
|
|
80
|
+
blogname: false
|
|
81
|
+
},
|
|
82
|
+
limit: 20,
|
|
83
|
+
displayPage: 6,
|
|
84
|
+
scale: 1,
|
|
85
|
+
selectedLabels: [],
|
|
86
|
+
year: "",
|
|
87
|
+
month: "",
|
|
88
|
+
filterMenuOpened: false,
|
|
89
|
+
toggleAll: false,
|
|
90
|
+
orderActive: "media_last_modified",
|
|
91
|
+
search: "",
|
|
92
|
+
labels: [],
|
|
93
|
+
items: props.items,
|
|
94
|
+
filteredOptions: [],
|
|
95
|
+
style: "table",
|
|
96
|
+
editMode: "",
|
|
97
|
+
filetype: props.filetype ? props.filetype : "all",
|
|
98
|
+
fileext: "all",
|
|
99
|
+
owner: false,
|
|
100
|
+
blogAxis: false,
|
|
101
|
+
oldItemId: null
|
|
102
|
+
};
|
|
103
|
+
this.listRef = createRef();
|
|
104
|
+
}
|
|
105
|
+
getOrderSelectBtnLabel() {
|
|
106
|
+
const { orderActive, order } = this.state;
|
|
107
|
+
const active = order[orderActive] === "asc" ? ACMS.i18n("media.asc") : ACMS.i18n("media.desc");
|
|
108
|
+
if (orderActive === "media_title") {
|
|
109
|
+
return `${ACMS.i18n("media.title")}\uFF08${active}\uFF09`;
|
|
110
|
+
}
|
|
111
|
+
if (orderActive === "media_last_modified") {
|
|
112
|
+
return `${ACMS.i18n("media.update_date")}\uFF08${active}\uFF09`;
|
|
113
|
+
}
|
|
114
|
+
if (orderActive === "media_datetime") {
|
|
115
|
+
return `${ACMS.i18n("media.created_date")}\uFF08${active}\uFF09`;
|
|
116
|
+
}
|
|
117
|
+
if (orderActive === "media_path") {
|
|
118
|
+
return `${ACMS.i18n("media.file_name")}\uFF08${active}\uFF09`;
|
|
119
|
+
}
|
|
120
|
+
if (orderActive === "media_filesize") {
|
|
121
|
+
return `${ACMS.i18n("media.file_size")}\uFF08${active}\uFF09`;
|
|
122
|
+
}
|
|
123
|
+
return ACMS.i18n("media.select");
|
|
124
|
+
}
|
|
125
|
+
setItem(item) {
|
|
126
|
+
const { media_id } = item;
|
|
127
|
+
if ("history" in window) {
|
|
128
|
+
history.replaceState(null, "", `#mid=${media_id}`);
|
|
129
|
+
}
|
|
130
|
+
getMediaTransport().fetchMediaDetail(media_id).then((res) => {
|
|
131
|
+
if (res.status === "failure") {
|
|
132
|
+
notify.danger(ACMS.i18n("media.get_media_error"));
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (res.item && res.item.media_id) {
|
|
136
|
+
this.props.actions.setItem(res.item);
|
|
137
|
+
}
|
|
138
|
+
}).catch(() => {
|
|
139
|
+
notify.danger(ACMS.i18n("media.get_media_error"));
|
|
140
|
+
});
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
toggleCheck(item) {
|
|
144
|
+
const { items, radioMode } = this.props;
|
|
145
|
+
if (radioMode) {
|
|
146
|
+
const findItem = items.find((item2) => item2.checked);
|
|
147
|
+
if (findItem) {
|
|
148
|
+
this.props.actions.updateMediaList({ ...findItem, checked: !findItem.checked });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
this.props.actions.updateMediaList({ ...item, checked: !item.checked });
|
|
152
|
+
}
|
|
153
|
+
toggleCheckFrom(fromItemId, toItem) {
|
|
154
|
+
const { items, radioMode } = this.props;
|
|
155
|
+
const { updateMediaList } = this.props.actions;
|
|
156
|
+
if (radioMode) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const fromIndex = items.findIndex((item) => {
|
|
160
|
+
if (item.media_id === fromItemId) {
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
});
|
|
165
|
+
const toIndex = items.findIndex((item) => {
|
|
166
|
+
if (item.media_id === toItem.media_id) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
return false;
|
|
170
|
+
});
|
|
171
|
+
const { checked } = toItem;
|
|
172
|
+
const nextChecked = !checked;
|
|
173
|
+
const minIndex = fromIndex > toIndex ? toIndex : fromIndex;
|
|
174
|
+
const maxIndex = fromIndex > toIndex ? fromIndex : toIndex;
|
|
175
|
+
items.forEach((item, index) => {
|
|
176
|
+
if (index >= minIndex && index <= maxIndex) {
|
|
177
|
+
updateMediaList({ ...item, checked: nextChecked });
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
toggleAllCheck() {
|
|
182
|
+
const { items, actions, radioMode } = this.props;
|
|
183
|
+
const { toggleAll } = this.state;
|
|
184
|
+
const all = !toggleAll;
|
|
185
|
+
this.setState({
|
|
186
|
+
toggleAll: all
|
|
187
|
+
});
|
|
188
|
+
if (radioMode) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (all) {
|
|
192
|
+
actions.setMediaList(items.map((item) => ({ ...item, checked: true })));
|
|
193
|
+
} else {
|
|
194
|
+
actions.setMediaList(items.map((item) => ({ ...item, checked: false })));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
async removeImgs() {
|
|
198
|
+
if (!confirm(ACMS.i18n("media.remove_media_confirm"))) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (this.listRef.current === null) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const mediaIds = this.getSelectedItems().map((item) => String(item.media_id));
|
|
205
|
+
const gateResult = await emit("media.delete.before", { mediaIds });
|
|
206
|
+
if (gateResult.canceled) {
|
|
207
|
+
if (gateResult.reason) {
|
|
208
|
+
notify.danger(gateResult.reason);
|
|
209
|
+
}
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const fd = new FormData(this.listRef.current);
|
|
213
|
+
fd.append("ACMS_POST_Media_Index_Delete", "true");
|
|
214
|
+
fd.append("formToken", window.csrfToken);
|
|
215
|
+
const end = pending.splash(ACMS.i18n("media.deleting_media"));
|
|
216
|
+
try {
|
|
217
|
+
await getMediaTransport().deleteMedia(fd);
|
|
218
|
+
notify.info(ACMS.i18n("media.remove_media_success"));
|
|
219
|
+
void emit("media.delete.success", gateResult.event);
|
|
220
|
+
this.fetchMediaList();
|
|
221
|
+
} catch {
|
|
222
|
+
notify.danger(ACMS.i18n("media.remove_media_error"));
|
|
223
|
+
} finally {
|
|
224
|
+
end();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
setOrder(target) {
|
|
228
|
+
const { state } = this;
|
|
229
|
+
const { order } = state;
|
|
230
|
+
const sortDirection = this.getNextSortDirection(target);
|
|
231
|
+
this.setState(
|
|
232
|
+
{
|
|
233
|
+
...state,
|
|
234
|
+
orderActive: target,
|
|
235
|
+
order: {
|
|
236
|
+
...order,
|
|
237
|
+
[target]: sortDirection
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
() => {
|
|
241
|
+
this.fetchMediaList();
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
checkOrder(orderActive) {
|
|
246
|
+
this.setState(
|
|
247
|
+
{
|
|
248
|
+
orderActive
|
|
249
|
+
},
|
|
250
|
+
() => {
|
|
251
|
+
this.fetchMediaList();
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
checkAscDesc(ascdesc) {
|
|
256
|
+
const { order, orderActive } = this.state;
|
|
257
|
+
order[orderActive] = ascdesc;
|
|
258
|
+
this.setState(
|
|
259
|
+
{
|
|
260
|
+
order
|
|
261
|
+
},
|
|
262
|
+
() => {
|
|
263
|
+
this.fetchMediaList();
|
|
264
|
+
}
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
getOrder() {
|
|
268
|
+
const { orderActive, order } = this.state;
|
|
269
|
+
if (orderActive === "media_title") {
|
|
270
|
+
return `file_name-${order[orderActive]}`;
|
|
271
|
+
}
|
|
272
|
+
if (orderActive === "media_last_modified") {
|
|
273
|
+
return `last_modified-${order[orderActive]}`;
|
|
274
|
+
}
|
|
275
|
+
if (orderActive === "media_datetime") {
|
|
276
|
+
return `upload_date-${order[orderActive]}`;
|
|
277
|
+
}
|
|
278
|
+
if (orderActive === "media_filesize") {
|
|
279
|
+
return `file_size-${order[orderActive]}`;
|
|
280
|
+
}
|
|
281
|
+
return "";
|
|
282
|
+
}
|
|
283
|
+
fetchMediaList(config = {}) {
|
|
284
|
+
const { year, month, limit, filetype, fileext, owner, blogAxis } = this.state;
|
|
285
|
+
const { actions, selectedTags: labels } = this.props;
|
|
286
|
+
const order = this.getOrder();
|
|
287
|
+
const tag = labels.reduce((accumulator, current) => {
|
|
288
|
+
if (!accumulator) {
|
|
289
|
+
return current;
|
|
290
|
+
}
|
|
291
|
+
return `${accumulator}/${current}`;
|
|
292
|
+
}, "");
|
|
293
|
+
const override = {
|
|
294
|
+
order,
|
|
295
|
+
tag,
|
|
296
|
+
limit,
|
|
297
|
+
filetype,
|
|
298
|
+
fileext,
|
|
299
|
+
owner,
|
|
300
|
+
blogAxis
|
|
301
|
+
};
|
|
302
|
+
if (year && month) {
|
|
303
|
+
override.date = `${year}/${month}`;
|
|
304
|
+
} else {
|
|
305
|
+
override.date = "";
|
|
306
|
+
override.year = year;
|
|
307
|
+
override.month = month;
|
|
308
|
+
}
|
|
309
|
+
if (!config.page) {
|
|
310
|
+
config.page = 1;
|
|
311
|
+
}
|
|
312
|
+
const settings = { ...config, ...override };
|
|
313
|
+
if (actions && actions.fetchMediaList) {
|
|
314
|
+
actions.fetchMediaList(settings);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
getIsSorted(th) {
|
|
318
|
+
const { order, orderActive } = this.state;
|
|
319
|
+
if (orderActive === th) {
|
|
320
|
+
if (order[orderActive] === "asc") {
|
|
321
|
+
return "asc";
|
|
322
|
+
}
|
|
323
|
+
return "desc";
|
|
324
|
+
}
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
getNextSortDirection(th) {
|
|
328
|
+
const { order } = this.state;
|
|
329
|
+
return order[th] === "asc" ? "desc" : "asc";
|
|
330
|
+
}
|
|
331
|
+
changeStyle(style) {
|
|
332
|
+
this.setState({
|
|
333
|
+
style
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
getCheckedItemsLength() {
|
|
337
|
+
const { items } = this.props;
|
|
338
|
+
const checks = items.filter((item) => item.checked);
|
|
339
|
+
if (checks && checks.length) {
|
|
340
|
+
return checks.length;
|
|
341
|
+
}
|
|
342
|
+
return 0;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* チェック済みかつ「実際にチェックボックスが描画される」アイテムのみを返す。
|
|
346
|
+
* `mode === 'edit'` のとき `!media_editable` の行はチェックボックス自体が描画されない
|
|
347
|
+
* (テーブル行の描画条件 `mode !== 'edit' || item.media_editable` と同じ判定)が、
|
|
348
|
+
* `toggleAllCheck()`(全選択)は編集可否を見ずに `checked` を立てるため、`props.items` の
|
|
349
|
+
* `checked` だけを見ると実際にフォーム送信される対象より多く数えてしまう。
|
|
350
|
+
* `media.delete.before`/`.success` の `mediaIds` と Slot `media.list.bulk-actions` の
|
|
351
|
+
* `selectedItems` は、実削除対象(フォームのチェックボックス)と一致させるためこちらを使う。
|
|
352
|
+
*/
|
|
353
|
+
getSelectedItems() {
|
|
354
|
+
const { items, mode } = this.props;
|
|
355
|
+
return items.filter((item) => item.checked && (mode !== "edit" || item.media_editable));
|
|
356
|
+
}
|
|
357
|
+
onLabelChange(labels) {
|
|
358
|
+
const tags = labels.map((label) => label.value);
|
|
359
|
+
this.props.actions.setSelectedTags(tags);
|
|
360
|
+
this.getFilteredOptions(tags);
|
|
361
|
+
}
|
|
362
|
+
getFilteredOptions(tags) {
|
|
363
|
+
getMediaTransport().fetchMediaTags(tags).then((data) => {
|
|
364
|
+
const filteredOptions = data.map((item) => ({
|
|
365
|
+
value: item,
|
|
366
|
+
label: item
|
|
367
|
+
}));
|
|
368
|
+
this.setState({
|
|
369
|
+
filteredOptions
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
onChangeDisplayNumber(e) {
|
|
374
|
+
const { actions } = this.props;
|
|
375
|
+
const limit = parseInt(e.target.value, 10);
|
|
376
|
+
actions.setMediaConfig({
|
|
377
|
+
limit,
|
|
378
|
+
page: 1
|
|
379
|
+
});
|
|
380
|
+
this.setState({ limit });
|
|
381
|
+
}
|
|
382
|
+
onKeywordInput(e) {
|
|
383
|
+
if (!(e.target instanceof HTMLInputElement)) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
const { actions } = this.props;
|
|
387
|
+
actions.setMediaConfig({
|
|
388
|
+
keyword: e.target.value
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
getArchives(archives) {
|
|
392
|
+
let years = [];
|
|
393
|
+
let months = [];
|
|
394
|
+
archives.forEach((archive) => {
|
|
395
|
+
const [year, month] = archive.split("-");
|
|
396
|
+
years.push(year);
|
|
397
|
+
months.push(month);
|
|
398
|
+
});
|
|
399
|
+
years = [...new Set(years)].sort();
|
|
400
|
+
months = [...new Set(months)].sort();
|
|
401
|
+
return { years, months };
|
|
402
|
+
}
|
|
403
|
+
onDateChange(value, type) {
|
|
404
|
+
if (type === "month") {
|
|
405
|
+
this.setState({
|
|
406
|
+
month: value
|
|
407
|
+
});
|
|
408
|
+
} else {
|
|
409
|
+
this.setState({
|
|
410
|
+
year: value
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
onAddedLabelsChange(labels) {
|
|
415
|
+
this.setState({
|
|
416
|
+
selectedLabels: labels.map((label) => label)
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
async addLabelToItems() {
|
|
420
|
+
if (this.listRef.current === null) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
const { selectedLabels } = this.state;
|
|
424
|
+
const tags = selectedLabels.map((selectedLabel) => selectedLabel.value).join(",");
|
|
425
|
+
const fd = new FormData(this.listRef.current);
|
|
426
|
+
fd.append("tags", tags);
|
|
427
|
+
fd.append("ACMS_POST_Media_Index_Tags", "true");
|
|
428
|
+
fd.append("formToken", window.csrfToken);
|
|
429
|
+
try {
|
|
430
|
+
await getMediaTransport().addTagsToMedia(fd);
|
|
431
|
+
notify.info(ACMS.i18n("media.add_tags_to_media_success"));
|
|
432
|
+
this.fetchMediaList();
|
|
433
|
+
} catch {
|
|
434
|
+
notify.danger(ACMS.i18n("media.add_tags_to_media_error"));
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
getFileStyle = (item) => {
|
|
438
|
+
if (!item) {
|
|
439
|
+
return {};
|
|
440
|
+
}
|
|
441
|
+
if (item.media_ext.toLowerCase() === "pdf") {
|
|
442
|
+
return {
|
|
443
|
+
height: "70%",
|
|
444
|
+
width: "auto",
|
|
445
|
+
opacity: 1
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
return {
|
|
449
|
+
verticalAlign: "middle",
|
|
450
|
+
width: "70px",
|
|
451
|
+
opacity: 1
|
|
452
|
+
};
|
|
453
|
+
};
|
|
454
|
+
getImageStyle = (item) => {
|
|
455
|
+
if (!item || !item.width || !item.height) {
|
|
456
|
+
return {};
|
|
457
|
+
}
|
|
458
|
+
if (item.width > item.height) {
|
|
459
|
+
return {
|
|
460
|
+
width: "100%",
|
|
461
|
+
height: "auto",
|
|
462
|
+
opacity: 1,
|
|
463
|
+
transform: `translate(-50%,-50%) scale(${item.width / item.height})`
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
return {
|
|
467
|
+
width: "auto",
|
|
468
|
+
height: "100%",
|
|
469
|
+
opacity: 1,
|
|
470
|
+
transform: `translate(-50%,-50%) scale(${item.height / item.width})`
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
rowClick(e, item) {
|
|
474
|
+
const { oldItemId } = this.state;
|
|
475
|
+
const element = e.target;
|
|
476
|
+
if (element.tagName === "INPUT" || element.tagName === "I" || element.tagName === "LABEL") {
|
|
477
|
+
e.preventDefault();
|
|
478
|
+
}
|
|
479
|
+
if (element.tagName !== "BUTTON") {
|
|
480
|
+
if (e.shiftKey && oldItemId !== null) {
|
|
481
|
+
this.toggleCheckFrom(oldItemId, item);
|
|
482
|
+
} else {
|
|
483
|
+
this.toggleCheck(item);
|
|
484
|
+
this.setState({
|
|
485
|
+
oldItemId: item.media_id
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
componentDidUpdate(prevProps) {
|
|
491
|
+
const { style, scale, order, orderActive, limit, filterMenuOpened, owner, blogAxis } = this.state;
|
|
492
|
+
localStorage.setItem(
|
|
493
|
+
"acms-media-list",
|
|
494
|
+
JSON.stringify({
|
|
495
|
+
style,
|
|
496
|
+
scale,
|
|
497
|
+
order,
|
|
498
|
+
orderActive,
|
|
499
|
+
limit,
|
|
500
|
+
filterMenuOpened,
|
|
501
|
+
owner,
|
|
502
|
+
blogAxis
|
|
503
|
+
})
|
|
504
|
+
);
|
|
505
|
+
if (prevProps.items !== this.props.items) {
|
|
506
|
+
this.setItems(this.props.items);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
componentDidMount() {
|
|
510
|
+
const storage = localStorage.getItem("acms-media-list");
|
|
511
|
+
const { selectedTags } = this.props;
|
|
512
|
+
if (!storage) {
|
|
513
|
+
this.fetchMediaList();
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
if (location.hash) {
|
|
517
|
+
const { mid } = parseQuery(location.hash.slice(1));
|
|
518
|
+
if (mid) {
|
|
519
|
+
this.setItem({ media_id: mid });
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
const { style, scale, order, orderActive, limit, filterMenuOpened, owner, blogAxis } = JSON.parse(storage);
|
|
523
|
+
this.setState(
|
|
524
|
+
{
|
|
525
|
+
style,
|
|
526
|
+
scale,
|
|
527
|
+
order,
|
|
528
|
+
orderActive,
|
|
529
|
+
limit,
|
|
530
|
+
filterMenuOpened,
|
|
531
|
+
owner,
|
|
532
|
+
blogAxis
|
|
533
|
+
},
|
|
534
|
+
() => {
|
|
535
|
+
this.fetchMediaList();
|
|
536
|
+
}
|
|
537
|
+
);
|
|
538
|
+
if (selectedTags) {
|
|
539
|
+
this.getFilteredOptions(selectedTags);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
loadImg(url) {
|
|
543
|
+
return new Promise((resolve) => {
|
|
544
|
+
const img = new Image();
|
|
545
|
+
img.onload = () => {
|
|
546
|
+
resolve(img);
|
|
547
|
+
};
|
|
548
|
+
setTimeout(() => {
|
|
549
|
+
resolve(img);
|
|
550
|
+
}, 500);
|
|
551
|
+
img.src = url;
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
setItems(items) {
|
|
555
|
+
const newItems = items.map(async (item) => {
|
|
556
|
+
if ((item.media_type === "image" || item.media_type === "svg") && !item.width) {
|
|
557
|
+
const img = await this.loadImg(item.media_thumbnail);
|
|
558
|
+
if (img.naturalWidth && img.naturalHeight) {
|
|
559
|
+
return { ...item, width: img.naturalWidth, height: img.naturalHeight };
|
|
560
|
+
}
|
|
561
|
+
return { ...item, width: img.width, height: img.height };
|
|
562
|
+
}
|
|
563
|
+
return item;
|
|
564
|
+
});
|
|
565
|
+
Promise.all(newItems).then((items2) => {
|
|
566
|
+
this.setState({ items: items2 });
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
scaleChanged = (scale) => {
|
|
570
|
+
const newScale = Array.isArray(scale) ? scale[0] : scale;
|
|
571
|
+
this.setState({ scale: newScale });
|
|
572
|
+
};
|
|
573
|
+
getOptions = () => {
|
|
574
|
+
const { filteredOptions } = this.state;
|
|
575
|
+
const { tags, selectedTags } = this.props;
|
|
576
|
+
if (selectedTags.length) {
|
|
577
|
+
return filteredOptions;
|
|
578
|
+
}
|
|
579
|
+
return tags.map((tag) => ({
|
|
580
|
+
value: tag,
|
|
581
|
+
label: tag
|
|
582
|
+
}));
|
|
583
|
+
};
|
|
584
|
+
toggleMenu(menuItem) {
|
|
585
|
+
const { menu } = this.state;
|
|
586
|
+
const newMenu = { ...menu, [menuItem]: !menu[menuItem] };
|
|
587
|
+
this.setState({
|
|
588
|
+
menu: newMenu
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
render() {
|
|
592
|
+
const { mode, config, archives, tags, total, items, selectedTags, extensions } = this.props;
|
|
593
|
+
const { years, months } = this.getArchives(archives);
|
|
594
|
+
const { page, keyword } = config;
|
|
595
|
+
const {
|
|
596
|
+
style,
|
|
597
|
+
editMode,
|
|
598
|
+
scale,
|
|
599
|
+
selectedLabels,
|
|
600
|
+
items: stateItems,
|
|
601
|
+
limit,
|
|
602
|
+
menu,
|
|
603
|
+
owner,
|
|
604
|
+
blogAxis,
|
|
605
|
+
order,
|
|
606
|
+
orderActive,
|
|
607
|
+
oldItemId,
|
|
608
|
+
toggleAll,
|
|
609
|
+
filterMenuOpened,
|
|
610
|
+
filetype
|
|
611
|
+
} = this.state;
|
|
612
|
+
const checkedLength = this.getCheckedItemsLength();
|
|
613
|
+
const selectedItems = this.getSelectedItems();
|
|
614
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
615
|
+
/* @__PURE__ */ jsx("div", { id: "media-filter-form", role: "search", className: "acms-admin-form", children: /* @__PURE__ */ jsxs(Filter, { children: [
|
|
616
|
+
/* @__PURE__ */ jsxs(FilterBody, { children: [
|
|
617
|
+
/* @__PURE__ */ jsxs(FilterGroup, { children: [
|
|
618
|
+
/* @__PURE__ */ jsx(FilterGroupTitle, { children: ACMS.i18n("media.filter_search") }),
|
|
619
|
+
/* @__PURE__ */ jsxs(FilterContent, { fit: true, children: [
|
|
620
|
+
/* @__PURE__ */ jsxs(FilterItem, { children: [
|
|
621
|
+
/* @__PURE__ */ jsx(FilterItemLabel, { htmlFor: "filter-date", children: ACMS.i18n("media.created_date") }),
|
|
622
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex" }, children: [
|
|
623
|
+
/* @__PURE__ */ jsx("div", { className: "acms-admin-inline-block acms-admin-margin-right-mini", children: /* @__PURE__ */ jsxs(
|
|
624
|
+
"select",
|
|
625
|
+
{
|
|
626
|
+
id: "filter-date",
|
|
627
|
+
className: "acms-admin-margin-right-mini",
|
|
628
|
+
onChange: (e) => {
|
|
629
|
+
this.onDateChange(e.target.value, "year");
|
|
630
|
+
},
|
|
631
|
+
children: [
|
|
632
|
+
/* @__PURE__ */ jsx("option", { value: "", children: ACMS.i18n("media.year") }),
|
|
633
|
+
years.map((year) => /* @__PURE__ */ jsx("option", { value: year, children: year }, year))
|
|
634
|
+
]
|
|
635
|
+
}
|
|
636
|
+
) }),
|
|
637
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { asChild: true, children: /* @__PURE__ */ jsx("label", { htmlFor: "filter-date-month", children: ACMS.i18n("media.month") }) }),
|
|
638
|
+
/* @__PURE__ */ jsx("div", { className: "acms-admin-inline-block", children: /* @__PURE__ */ jsxs(
|
|
639
|
+
"select",
|
|
640
|
+
{
|
|
641
|
+
id: "filter-date-month",
|
|
642
|
+
onChange: (e) => {
|
|
643
|
+
this.onDateChange(e.target.value, "month");
|
|
644
|
+
},
|
|
645
|
+
children: [
|
|
646
|
+
/* @__PURE__ */ jsx("option", { value: "", children: ACMS.i18n("media.month") }),
|
|
647
|
+
months.map((month) => /* @__PURE__ */ jsx("option", { value: month, children: month }, month))
|
|
648
|
+
]
|
|
649
|
+
}
|
|
650
|
+
) })
|
|
651
|
+
] })
|
|
652
|
+
] }),
|
|
653
|
+
/* @__PURE__ */ jsxs(FilterItem, { full: true, children: [
|
|
654
|
+
/* @__PURE__ */ jsx(FilterItemLabel, { htmlFor: "filter-tag", children: ACMS.i18n("media.tag") }),
|
|
655
|
+
/* @__PURE__ */ jsx("div", { className: "acms-admin-form-width-medium", children: /* @__PURE__ */ jsx(
|
|
656
|
+
RichSelect,
|
|
657
|
+
{
|
|
658
|
+
isMulti: true,
|
|
659
|
+
value: selectedTags.map((selectedTag) => ({
|
|
660
|
+
label: selectedTag,
|
|
661
|
+
value: selectedTag
|
|
662
|
+
})),
|
|
663
|
+
options: this.getOptions(),
|
|
664
|
+
onChange: this.onLabelChange.bind(this),
|
|
665
|
+
closeMenuOnSelect: false,
|
|
666
|
+
placeholder: ACMS.i18n("media.tag_search_select_placeholder"),
|
|
667
|
+
noOptionsMessage: () => ACMS.i18n("media.tag_select_no_options_message"),
|
|
668
|
+
inputId: "filter-tag"
|
|
669
|
+
}
|
|
670
|
+
) })
|
|
671
|
+
] })
|
|
672
|
+
] })
|
|
673
|
+
] }),
|
|
674
|
+
filterMenuOpened && /* @__PURE__ */ jsx("div", { id: "search-detail", children: /* @__PURE__ */ jsxs(FilterInner, { children: [
|
|
675
|
+
/* @__PURE__ */ jsxs(FilterGroup, { children: [
|
|
676
|
+
/* @__PURE__ */ jsx(FilterGroupTitle, { children: ACMS.i18n("media.detailed_condition") }),
|
|
677
|
+
/* @__PURE__ */ jsx(FilterContent, { children: /* @__PURE__ */ jsxs(FilterItem, { full: true, children: [
|
|
678
|
+
/* @__PURE__ */ jsx(FilterItemLabel, { htmlFor: "filter-keyword", children: ACMS.i18n("media.keyword") }),
|
|
679
|
+
/* @__PURE__ */ jsx(
|
|
680
|
+
"input",
|
|
681
|
+
{
|
|
682
|
+
type: "text",
|
|
683
|
+
placeholder: ACMS.i18n("media.search_by_keyword"),
|
|
684
|
+
id: "filter-keyword",
|
|
685
|
+
className: "acms-admin-form-width-full",
|
|
686
|
+
value: keyword,
|
|
687
|
+
onInput: this.onKeywordInput.bind(this)
|
|
688
|
+
}
|
|
689
|
+
)
|
|
690
|
+
] }) })
|
|
691
|
+
] }),
|
|
692
|
+
/* @__PURE__ */ jsxs(FilterGroup, { children: [
|
|
693
|
+
/* @__PURE__ */ jsx(FilterGroupTitle, { children: ACMS.i18n("media.narrow_down") }),
|
|
694
|
+
/* @__PURE__ */ jsxs(FilterContent, { children: [
|
|
695
|
+
/* @__PURE__ */ jsxs(FilterItem, { children: [
|
|
696
|
+
/* @__PURE__ */ jsx(FilterItemLabel, { htmlFor: "filter-sort", children: ACMS.i18n("media.number_of_items") }),
|
|
697
|
+
/* @__PURE__ */ jsxs("select", { id: "filter-sort", value: limit, onChange: this.onChangeDisplayNumber.bind(this), children: [
|
|
698
|
+
/* @__PURE__ */ jsx("option", { value: "5", children: "5" }),
|
|
699
|
+
/* @__PURE__ */ jsx("option", { value: "10", children: "10" }),
|
|
700
|
+
/* @__PURE__ */ jsx("option", { value: "20", children: "20" }),
|
|
701
|
+
/* @__PURE__ */ jsx("option", { value: "50", children: "50" }),
|
|
702
|
+
/* @__PURE__ */ jsx("option", { value: "75", children: "75" }),
|
|
703
|
+
/* @__PURE__ */ jsx("option", { value: "100", children: "100" }),
|
|
704
|
+
/* @__PURE__ */ jsx("option", { value: "200", children: "200" }),
|
|
705
|
+
/* @__PURE__ */ jsx("option", { value: "300", children: "300" })
|
|
706
|
+
] })
|
|
707
|
+
] }),
|
|
708
|
+
/* @__PURE__ */ jsxs(FilterItem, { children: [
|
|
709
|
+
/* @__PURE__ */ jsx(FilterItemLabel, { htmlFor: "filter-type", children: ACMS.i18n("media.type") }),
|
|
710
|
+
/* @__PURE__ */ jsxs(
|
|
711
|
+
"select",
|
|
712
|
+
{
|
|
713
|
+
id: "filter-type",
|
|
714
|
+
disabled: this.props.filetype !== "all",
|
|
715
|
+
defaultValue: filetype,
|
|
716
|
+
onChange: (e) => {
|
|
717
|
+
this.setState({
|
|
718
|
+
filetype: e.target.value
|
|
719
|
+
});
|
|
720
|
+
},
|
|
721
|
+
children: [
|
|
722
|
+
/* @__PURE__ */ jsx("option", { value: "all", children: ACMS.i18n("media.all") }),
|
|
723
|
+
/* @__PURE__ */ jsx("option", { value: "image", children: ACMS.i18n("media.image") }),
|
|
724
|
+
/* @__PURE__ */ jsx("option", { value: "file", children: ACMS.i18n("media.file") })
|
|
725
|
+
]
|
|
726
|
+
}
|
|
727
|
+
)
|
|
728
|
+
] }),
|
|
729
|
+
/* @__PURE__ */ jsxs(FilterItem, { children: [
|
|
730
|
+
/* @__PURE__ */ jsx(FilterItemLabel, { htmlFor: "filter-ext", children: ACMS.i18n("media.extension") }),
|
|
731
|
+
/* @__PURE__ */ jsxs(
|
|
732
|
+
"select",
|
|
733
|
+
{
|
|
734
|
+
id: "filter-ext",
|
|
735
|
+
onChange: (e) => {
|
|
736
|
+
this.setState({
|
|
737
|
+
fileext: e.target.value
|
|
738
|
+
});
|
|
739
|
+
},
|
|
740
|
+
children: [
|
|
741
|
+
/* @__PURE__ */ jsx("option", { value: "all", children: ACMS.i18n("media.all") }),
|
|
742
|
+
extensions && extensions.map((extension) => /* @__PURE__ */ jsx("option", { value: extension, children: extension.toLowerCase() }, extension.toLowerCase()))
|
|
743
|
+
]
|
|
744
|
+
}
|
|
745
|
+
)
|
|
746
|
+
] }),
|
|
747
|
+
/* @__PURE__ */ jsx(FilterItem, { children: /* @__PURE__ */ jsxs("label", { htmlFor: "filter-owner", className: "acms-admin-form-checkbox acms-admin-m-0", children: [
|
|
748
|
+
/* @__PURE__ */ jsx(
|
|
749
|
+
"input",
|
|
750
|
+
{
|
|
751
|
+
id: "filter-owner",
|
|
752
|
+
type: "checkbox",
|
|
753
|
+
checked: owner,
|
|
754
|
+
onChange: (e) => {
|
|
755
|
+
this.setState({
|
|
756
|
+
owner: e.target.checked
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
),
|
|
761
|
+
/* @__PURE__ */ jsx("i", { className: "acms-admin-ico-checkbox" }),
|
|
762
|
+
ACMS.i18n("media.owner")
|
|
763
|
+
] }) }),
|
|
764
|
+
ACMS.Config.sbid !== ACMS.Config.bid && /* @__PURE__ */ jsx(FilterItem, { children: /* @__PURE__ */ jsxs("label", { htmlFor: "filter-blog-axis", className: "acms-admin-form-checkbox acms-admin-m-0", children: [
|
|
765
|
+
/* @__PURE__ */ jsx(
|
|
766
|
+
"input",
|
|
767
|
+
{
|
|
768
|
+
id: "filter-blog-axis",
|
|
769
|
+
type: "checkbox",
|
|
770
|
+
checked: blogAxis,
|
|
771
|
+
onChange: (e) => {
|
|
772
|
+
this.setState({
|
|
773
|
+
blogAxis: e.target.checked
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
),
|
|
778
|
+
/* @__PURE__ */ jsx("i", { className: "acms-admin-ico-checkbox" }),
|
|
779
|
+
ACMS.i18n("media.blog_axis")
|
|
780
|
+
] }) })
|
|
781
|
+
] })
|
|
782
|
+
] })
|
|
783
|
+
] }) })
|
|
784
|
+
] }),
|
|
785
|
+
/* @__PURE__ */ jsxs(FilterFooter, { children: [
|
|
786
|
+
/* @__PURE__ */ jsx(
|
|
787
|
+
"button",
|
|
788
|
+
{
|
|
789
|
+
type: "button",
|
|
790
|
+
className: "acms-admin-btn acms-admin-btn-info acms-admin-btn-search",
|
|
791
|
+
onClick: () => {
|
|
792
|
+
this.fetchMediaList();
|
|
793
|
+
},
|
|
794
|
+
children: ACMS.i18n("media.search")
|
|
795
|
+
}
|
|
796
|
+
),
|
|
797
|
+
/* @__PURE__ */ jsx(
|
|
798
|
+
FilterDetailButton,
|
|
799
|
+
{
|
|
800
|
+
type: "button",
|
|
801
|
+
onClick: (e) => {
|
|
802
|
+
e.preventDefault();
|
|
803
|
+
this.setState({
|
|
804
|
+
filterMenuOpened: !filterMenuOpened
|
|
805
|
+
});
|
|
806
|
+
},
|
|
807
|
+
"aria-expanded": filterMenuOpened,
|
|
808
|
+
"aria-controls": "search-detail",
|
|
809
|
+
children: ACMS.i18n("media.detailed_search")
|
|
810
|
+
}
|
|
811
|
+
)
|
|
812
|
+
] })
|
|
813
|
+
] }) }),
|
|
814
|
+
/* @__PURE__ */ jsxs("div", { className: "acms-admin-media-action-group", children: [
|
|
815
|
+
/* @__PURE__ */ jsxs("div", { className: "acms-admin-media-action-item acms-admin-media-action-item-fix", children: [
|
|
816
|
+
/* @__PURE__ */ jsxs("div", { className: "acms-admin-btn-group acms-admin-media-action-display-switch", role: "group", children: [
|
|
817
|
+
/* @__PURE__ */ jsx(
|
|
818
|
+
"button",
|
|
819
|
+
{
|
|
820
|
+
type: "button",
|
|
821
|
+
className: classnames("acms-admin-btn", {
|
|
822
|
+
"acms-admin-btn-active": style === "table"
|
|
823
|
+
}),
|
|
824
|
+
onClick: this.changeStyle.bind(this, "table"),
|
|
825
|
+
"aria-pressed": style === "table",
|
|
826
|
+
"aria-label": ACMS.i18n("media.display_switch_list"),
|
|
827
|
+
children: /* @__PURE__ */ jsx("i", { className: "acms-admin-icon-list" })
|
|
828
|
+
}
|
|
829
|
+
),
|
|
830
|
+
/* @__PURE__ */ jsx(
|
|
831
|
+
"button",
|
|
832
|
+
{
|
|
833
|
+
type: "button",
|
|
834
|
+
className: classnames("acms-admin-btn", {
|
|
835
|
+
"acms-admin-btn-active": style === "list"
|
|
836
|
+
}),
|
|
837
|
+
onClick: this.changeStyle.bind(this, "list"),
|
|
838
|
+
"aria-pressed": style === "list",
|
|
839
|
+
"aria-label": ACMS.i18n("media.display_switch_grid"),
|
|
840
|
+
children: /* @__PURE__ */ jsx("i", { className: "acms-admin-icon-grid" })
|
|
841
|
+
}
|
|
842
|
+
)
|
|
843
|
+
] }),
|
|
844
|
+
/* @__PURE__ */ jsxs("div", { className: "acms-admin-media-action-sort-select-wrap", children: [
|
|
845
|
+
/* @__PURE__ */ jsx("div", { className: "acms-admin-media-action-sort-select", children: style === "table" && /* @__PURE__ */ jsxs(Menu, { closeOnSelect: false, children: [
|
|
846
|
+
/* @__PURE__ */ jsx(MenuTrigger, { className: "acms-admin-btn", "aria-label": ACMS.i18n("media.open_config_menu"), children: /* @__PURE__ */ jsx("i", { className: "acms-admin-icon-config", "aria-hidden": "true" }) }),
|
|
847
|
+
/* @__PURE__ */ jsx(MenuPopover, { children: /* @__PURE__ */ jsxs(MenuList, { children: [
|
|
848
|
+
/* @__PURE__ */ jsx(
|
|
849
|
+
MenuItemCheckbox,
|
|
850
|
+
{
|
|
851
|
+
value: "image",
|
|
852
|
+
checked: menu.image,
|
|
853
|
+
onCheckedChange: (_checked, value) => {
|
|
854
|
+
this.toggleMenu(value);
|
|
855
|
+
},
|
|
856
|
+
children: ACMS.i18n("media.image2")
|
|
857
|
+
}
|
|
858
|
+
),
|
|
859
|
+
/* @__PURE__ */ jsx(
|
|
860
|
+
MenuItemCheckbox,
|
|
861
|
+
{
|
|
862
|
+
value: "id",
|
|
863
|
+
checked: menu.id,
|
|
864
|
+
onCheckedChange: (_checked, value) => {
|
|
865
|
+
this.toggleMenu(value);
|
|
866
|
+
},
|
|
867
|
+
children: "ID"
|
|
868
|
+
}
|
|
869
|
+
),
|
|
870
|
+
/* @__PURE__ */ jsx(
|
|
871
|
+
MenuItemCheckbox,
|
|
872
|
+
{
|
|
873
|
+
value: "filename",
|
|
874
|
+
checked: menu.filename,
|
|
875
|
+
onCheckedChange: (_checked, value) => {
|
|
876
|
+
this.toggleMenu(value);
|
|
877
|
+
},
|
|
878
|
+
children: ACMS.i18n("media.file_name")
|
|
879
|
+
}
|
|
880
|
+
),
|
|
881
|
+
/* @__PURE__ */ jsx(
|
|
882
|
+
MenuItemCheckbox,
|
|
883
|
+
{
|
|
884
|
+
value: "tag",
|
|
885
|
+
checked: menu.tag,
|
|
886
|
+
onCheckedChange: (_checked, value) => {
|
|
887
|
+
this.toggleMenu(value);
|
|
888
|
+
},
|
|
889
|
+
children: ACMS.i18n("media.tag")
|
|
890
|
+
}
|
|
891
|
+
),
|
|
892
|
+
/* @__PURE__ */ jsx(
|
|
893
|
+
MenuItemCheckbox,
|
|
894
|
+
{
|
|
895
|
+
value: "last_modified",
|
|
896
|
+
checked: menu.last_modified,
|
|
897
|
+
onCheckedChange: (_checked, value) => {
|
|
898
|
+
this.toggleMenu(value);
|
|
899
|
+
},
|
|
900
|
+
children: ACMS.i18n("media.updated_date")
|
|
901
|
+
}
|
|
902
|
+
),
|
|
903
|
+
/* @__PURE__ */ jsx(
|
|
904
|
+
MenuItemCheckbox,
|
|
905
|
+
{
|
|
906
|
+
value: "upload_datetime",
|
|
907
|
+
checked: menu.upload_datetime,
|
|
908
|
+
onCheckedChange: (_checked, value) => {
|
|
909
|
+
this.toggleMenu(value);
|
|
910
|
+
},
|
|
911
|
+
children: ACMS.i18n("media.created_date")
|
|
912
|
+
}
|
|
913
|
+
),
|
|
914
|
+
/* @__PURE__ */ jsx(
|
|
915
|
+
MenuItemCheckbox,
|
|
916
|
+
{
|
|
917
|
+
value: "filesize",
|
|
918
|
+
checked: menu.filesize,
|
|
919
|
+
onCheckedChange: (_checked, value) => {
|
|
920
|
+
this.toggleMenu(value);
|
|
921
|
+
},
|
|
922
|
+
children: ACMS.i18n("media.file_size")
|
|
923
|
+
}
|
|
924
|
+
),
|
|
925
|
+
/* @__PURE__ */ jsx(
|
|
926
|
+
MenuItemCheckbox,
|
|
927
|
+
{
|
|
928
|
+
value: "blogname",
|
|
929
|
+
checked: menu.blogname,
|
|
930
|
+
onCheckedChange: (_checked, value) => {
|
|
931
|
+
this.toggleMenu(value);
|
|
932
|
+
},
|
|
933
|
+
children: ACMS.i18n("media.blog_name")
|
|
934
|
+
}
|
|
935
|
+
)
|
|
936
|
+
] }) })
|
|
937
|
+
] }) }),
|
|
938
|
+
/* @__PURE__ */ jsx("div", { className: "acms-admin-media-action-sort-select", style: { position: "relative" }, children: /* @__PURE__ */ jsxs(Menu, { closeOnSelect: false, children: [
|
|
939
|
+
/* @__PURE__ */ jsx(MenuTrigger, { type: "button", className: "acms-admin-select-btn", children: this.getOrderSelectBtnLabel() }),
|
|
940
|
+
/* @__PURE__ */ jsx(MenuPopover, { children: /* @__PURE__ */ jsxs(MenuList, { children: [
|
|
941
|
+
/* @__PURE__ */ jsxs(
|
|
942
|
+
MenuItemRadioGroup,
|
|
943
|
+
{
|
|
944
|
+
value: orderActive,
|
|
945
|
+
onValueChange: (value) => {
|
|
946
|
+
this.checkOrder(value);
|
|
947
|
+
},
|
|
948
|
+
children: [
|
|
949
|
+
/* @__PURE__ */ jsx(MenuItemRadio, { value: "media_title", children: ACMS.i18n("media.title") }),
|
|
950
|
+
/* @__PURE__ */ jsx(MenuItemRadio, { value: "media_last_modified", children: ACMS.i18n("media.updated_date") }),
|
|
951
|
+
/* @__PURE__ */ jsx(MenuItemRadio, { value: "media_datetime", children: ACMS.i18n("media.created_date") }),
|
|
952
|
+
/* @__PURE__ */ jsx(MenuItemRadio, { value: "media_filesize", children: ACMS.i18n("media.file_size") })
|
|
953
|
+
]
|
|
954
|
+
}
|
|
955
|
+
),
|
|
956
|
+
/* @__PURE__ */ jsx(MenuDivider, {}),
|
|
957
|
+
/* @__PURE__ */ jsxs(
|
|
958
|
+
MenuItemRadioGroup,
|
|
959
|
+
{
|
|
960
|
+
value: order[orderActive],
|
|
961
|
+
onValueChange: (value) => {
|
|
962
|
+
this.checkAscDesc(value);
|
|
963
|
+
},
|
|
964
|
+
children: [
|
|
965
|
+
/* @__PURE__ */ jsx(MenuItemRadio, { value: "asc", children: ACMS.i18n("media.asc") }),
|
|
966
|
+
/* @__PURE__ */ jsx(MenuItemRadio, { value: "desc", children: ACMS.i18n("media.desc") })
|
|
967
|
+
]
|
|
968
|
+
}
|
|
969
|
+
)
|
|
970
|
+
] }) })
|
|
971
|
+
] }) })
|
|
972
|
+
] })
|
|
973
|
+
] }),
|
|
974
|
+
/* @__PURE__ */ jsxs("div", { className: "acms-admin-media-action-item acms-admin-media-action-item-middle", children: [
|
|
975
|
+
style === "list" && /* @__PURE__ */ jsx("div", { className: "acms-admin-media-action-range", children: /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", width: "100%", alignItems: "center" }, children: [
|
|
976
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: ACMS.i18n("media.display_size") }),
|
|
977
|
+
/* @__PURE__ */ jsx(
|
|
978
|
+
"i",
|
|
979
|
+
{
|
|
980
|
+
className: "acms-admin-icon-unit-image",
|
|
981
|
+
style: { fontSize: "12px", color: "#777777", marginRight: "10px" }
|
|
982
|
+
}
|
|
983
|
+
),
|
|
984
|
+
/* @__PURE__ */ jsx(
|
|
985
|
+
RangeSlider,
|
|
986
|
+
{
|
|
987
|
+
className: "acms-admin-range-slider",
|
|
988
|
+
min: 1,
|
|
989
|
+
max: 2,
|
|
990
|
+
step: 0.1,
|
|
991
|
+
value: scale,
|
|
992
|
+
onChange: this.scaleChanged
|
|
993
|
+
}
|
|
994
|
+
),
|
|
995
|
+
/* @__PURE__ */ jsx(
|
|
996
|
+
"i",
|
|
997
|
+
{
|
|
998
|
+
className: "acms-admin-icon-unit-image",
|
|
999
|
+
style: { fontSize: "18px", color: "#777777", marginLeft: "10px" }
|
|
1000
|
+
}
|
|
1001
|
+
)
|
|
1002
|
+
] }) }),
|
|
1003
|
+
style === "list" && /* @__PURE__ */ jsx("div", { className: "acms-admin-media-action-select-all", children: /* @__PURE__ */ jsxs(
|
|
1004
|
+
"button",
|
|
1005
|
+
{
|
|
1006
|
+
type: "button",
|
|
1007
|
+
onClick: this.toggleAllCheck.bind(this),
|
|
1008
|
+
className: "acms-admin-media-grid-checkbox-wrap",
|
|
1009
|
+
children: [
|
|
1010
|
+
/* @__PURE__ */ jsx(
|
|
1011
|
+
"span",
|
|
1012
|
+
{
|
|
1013
|
+
className: classnames("acms-admin-media-grid-checkbox", {
|
|
1014
|
+
selected: toggleAll
|
|
1015
|
+
}),
|
|
1016
|
+
"aria-hidden": "true"
|
|
1017
|
+
}
|
|
1018
|
+
),
|
|
1019
|
+
ACMS.i18n("media.select_all")
|
|
1020
|
+
]
|
|
1021
|
+
}
|
|
1022
|
+
) })
|
|
1023
|
+
] }),
|
|
1024
|
+
/* @__PURE__ */ jsx("div", { className: "acms-admin-form-group acms-admin-media-action-item acms-admin-media-action-item-left", children: /* @__PURE__ */ jsxs("div", { className: "acms-admin-form", children: [
|
|
1025
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { asChild: true, children: /* @__PURE__ */ jsx("label", { htmlFor: "media-action-select", children: ACMS.i18n("media.select") }) }),
|
|
1026
|
+
/* @__PURE__ */ jsxs(
|
|
1027
|
+
"select",
|
|
1028
|
+
{
|
|
1029
|
+
id: "media-action-select",
|
|
1030
|
+
className: "acms-admin-margin-right-mini",
|
|
1031
|
+
value: editMode,
|
|
1032
|
+
onChange: (e) => {
|
|
1033
|
+
const { value } = e.target;
|
|
1034
|
+
this.setState({
|
|
1035
|
+
editMode: value
|
|
1036
|
+
});
|
|
1037
|
+
},
|
|
1038
|
+
children: [
|
|
1039
|
+
/* @__PURE__ */ jsx("option", { children: ACMS.i18n("media.select") }),
|
|
1040
|
+
/* @__PURE__ */ jsx("option", { value: "remove", children: ACMS.i18n("media.remove") }),
|
|
1041
|
+
/* @__PURE__ */ jsx("option", { value: "tag", children: ACMS.i18n("media.add_tags") })
|
|
1042
|
+
]
|
|
1043
|
+
}
|
|
1044
|
+
),
|
|
1045
|
+
editMode === "remove" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1046
|
+
ACMS.i18n("media.checked_items").replace("$1", checkedLength.toString()),
|
|
1047
|
+
"\xA0",
|
|
1048
|
+
/* @__PURE__ */ jsx(
|
|
1049
|
+
"button",
|
|
1050
|
+
{
|
|
1051
|
+
type: "button",
|
|
1052
|
+
className: "acms-admin-btn acms-admin-btn-danger",
|
|
1053
|
+
onClick: this.removeImgs.bind(this),
|
|
1054
|
+
children: ACMS.i18n("media.remove")
|
|
1055
|
+
}
|
|
1056
|
+
)
|
|
1057
|
+
] }),
|
|
1058
|
+
editMode === "tag" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1059
|
+
/* @__PURE__ */ jsx(
|
|
1060
|
+
"div",
|
|
1061
|
+
{
|
|
1062
|
+
style: { display: "inline-block", verticalAlign: "middle" },
|
|
1063
|
+
className: "acms-admin-margin-right-mini",
|
|
1064
|
+
children: ACMS.i18n("media.add_tags_to_checked_items").replace("$1", checkedLength.toString())
|
|
1065
|
+
}
|
|
1066
|
+
),
|
|
1067
|
+
/* @__PURE__ */ jsx(
|
|
1068
|
+
"div",
|
|
1069
|
+
{
|
|
1070
|
+
style: {
|
|
1071
|
+
display: "inline-block",
|
|
1072
|
+
width: "200px",
|
|
1073
|
+
verticalAlign: "middle",
|
|
1074
|
+
marginRight: "5px"
|
|
1075
|
+
},
|
|
1076
|
+
children: /* @__PURE__ */ jsx(
|
|
1077
|
+
CreatableSelect,
|
|
1078
|
+
{
|
|
1079
|
+
isMulti: true,
|
|
1080
|
+
onChange: this.onAddedLabelsChange.bind(this),
|
|
1081
|
+
value: selectedLabels,
|
|
1082
|
+
options: tags.map((tag) => ({
|
|
1083
|
+
label: tag,
|
|
1084
|
+
value: tag
|
|
1085
|
+
})),
|
|
1086
|
+
placeholder: ACMS.i18n("media.tag_select_placeholder"),
|
|
1087
|
+
noOptionsMessage: () => ACMS.i18n("media.tag_select_no_options_message"),
|
|
1088
|
+
formatCreateLabel: (inputValue) => ACMS.i18n("media.add_tag", { name: inputValue }),
|
|
1089
|
+
isValidNewOption: (inputValue) => inputValue.trim().length > 0,
|
|
1090
|
+
closeMenuOnSelect: false,
|
|
1091
|
+
hideSelectedOptions: true
|
|
1092
|
+
}
|
|
1093
|
+
)
|
|
1094
|
+
}
|
|
1095
|
+
),
|
|
1096
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "acms-admin-btn", onClick: this.addLabelToItems.bind(this), children: "\u8FFD\u52A0" })
|
|
1097
|
+
] }),
|
|
1098
|
+
/* @__PURE__ */ jsx(Slot, { name: "media.list.bulk-actions", fillProps: { selectedItems } })
|
|
1099
|
+
] }) }),
|
|
1100
|
+
/* @__PURE__ */ jsx(
|
|
1101
|
+
"form",
|
|
1102
|
+
{
|
|
1103
|
+
ref: this.listRef,
|
|
1104
|
+
className: "acms-admin-media-list",
|
|
1105
|
+
style: { display: style === "table" ? "block" : "none" },
|
|
1106
|
+
children: /* @__PURE__ */ jsx(TableScrollable, { breakpoints: ["xs", "sm", "md"], children: /* @__PURE__ */ jsxs(Table, { variant: "list", hover: true, className: "adminTable acms-admin-media-table", children: [
|
|
1107
|
+
/* @__PURE__ */ jsx(TableHeader, { heading: true, children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1108
|
+
/* @__PURE__ */ jsx(TableHead, { nowrap: true, className: "acms-admin-media-row-check", children: mode === "edit" && /* @__PURE__ */ jsxs(
|
|
1109
|
+
"label",
|
|
1110
|
+
{
|
|
1111
|
+
htmlFor: "checkAll",
|
|
1112
|
+
"aria-label": "\u3059\u3079\u3066\u9078\u629E",
|
|
1113
|
+
className: "acms-admin-form-checkbox acms-admin-m-0",
|
|
1114
|
+
onChange: this.toggleAllCheck.bind(this),
|
|
1115
|
+
children: [
|
|
1116
|
+
/* @__PURE__ */ jsx("input", { id: "checkAll", type: "checkbox" }),
|
|
1117
|
+
/* @__PURE__ */ jsx("i", { className: "acms-admin-ico-checkbox" })
|
|
1118
|
+
]
|
|
1119
|
+
}
|
|
1120
|
+
) }),
|
|
1121
|
+
menu.image && /* @__PURE__ */ jsx(TableHead, { nowrap: true, className: "acms-admin-media-row-image", children: ACMS.i18n("media.image2") }),
|
|
1122
|
+
menu.id && /* @__PURE__ */ jsx(TableHead, { nowrap: true, className: "acms-admin-media-row-id", children: "ID" }),
|
|
1123
|
+
menu.filename && /* @__PURE__ */ jsx(
|
|
1124
|
+
TableHead,
|
|
1125
|
+
{
|
|
1126
|
+
className: "acms-admin-media-row-title",
|
|
1127
|
+
"aria-sort": this.getIsSorted("media_title") ? `${this.getIsSorted("media_title")}ending` : void 0,
|
|
1128
|
+
children: /* @__PURE__ */ jsxs(
|
|
1129
|
+
"button",
|
|
1130
|
+
{
|
|
1131
|
+
type: "button",
|
|
1132
|
+
className: "acms-admin-th-sort-btn",
|
|
1133
|
+
onClick: this.setOrder.bind(this, "media_title"),
|
|
1134
|
+
"data-next-sort": `${this.getNextSortDirection("media_title")}ending`,
|
|
1135
|
+
children: [
|
|
1136
|
+
ACMS.i18n("media.file_name"),
|
|
1137
|
+
/* @__PURE__ */ jsx("span", { className: "acms-admin-th-sort-btn-icon" }),
|
|
1138
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: ACMS.i18n(`table.label.sort.${this.getIsSorted("media_title") || "none"}`) })
|
|
1139
|
+
]
|
|
1140
|
+
}
|
|
1141
|
+
)
|
|
1142
|
+
}
|
|
1143
|
+
),
|
|
1144
|
+
menu.tag && /* @__PURE__ */ jsx(TableHead, { className: "acms-admin-media-row-tag", children: ACMS.i18n("media.tag") }),
|
|
1145
|
+
menu.last_modified && /* @__PURE__ */ jsx(
|
|
1146
|
+
TableHead,
|
|
1147
|
+
{
|
|
1148
|
+
nowrap: true,
|
|
1149
|
+
className: "acms-admin-media-row-date",
|
|
1150
|
+
"aria-sort": this.getIsSorted("media_last_modified") ? `${this.getIsSorted("media_last_modified")}ending` : void 0,
|
|
1151
|
+
children: /* @__PURE__ */ jsxs(
|
|
1152
|
+
"button",
|
|
1153
|
+
{
|
|
1154
|
+
type: "button",
|
|
1155
|
+
className: "acms-admin-th-sort-btn",
|
|
1156
|
+
onClick: this.setOrder.bind(this, "media_last_modified"),
|
|
1157
|
+
"data-next-sort": `${this.getNextSortDirection("media_last_modified")}ending`,
|
|
1158
|
+
children: [
|
|
1159
|
+
ACMS.i18n("media.updated_date"),
|
|
1160
|
+
/* @__PURE__ */ jsx("span", { className: "acms-admin-th-sort-btn-icon" }),
|
|
1161
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: ACMS.i18n(`table.label.sort.${this.getIsSorted("media_last_modified") || "none"}`) })
|
|
1162
|
+
]
|
|
1163
|
+
}
|
|
1164
|
+
)
|
|
1165
|
+
}
|
|
1166
|
+
),
|
|
1167
|
+
menu.upload_datetime && /* @__PURE__ */ jsx(
|
|
1168
|
+
TableHead,
|
|
1169
|
+
{
|
|
1170
|
+
nowrap: true,
|
|
1171
|
+
className: "acms-admin-media-row-date",
|
|
1172
|
+
"aria-sort": this.getIsSorted("media_datetime") ? `${this.getIsSorted("media_datetime")}ending` : void 0,
|
|
1173
|
+
children: /* @__PURE__ */ jsxs(
|
|
1174
|
+
"button",
|
|
1175
|
+
{
|
|
1176
|
+
type: "button",
|
|
1177
|
+
className: "acms-admin-th-sort-btn",
|
|
1178
|
+
onClick: this.setOrder.bind(this, "media_datetime"),
|
|
1179
|
+
"data-next-sort": `${this.getNextSortDirection("media_datetime")}ending`,
|
|
1180
|
+
children: [
|
|
1181
|
+
ACMS.i18n("media.created_date"),
|
|
1182
|
+
/* @__PURE__ */ jsx("span", { className: "acms-admin-th-sort-btn-icon" }),
|
|
1183
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: ACMS.i18n(`table.label.sort.${this.getIsSorted("media_datetime") || "none"}`) })
|
|
1184
|
+
]
|
|
1185
|
+
}
|
|
1186
|
+
)
|
|
1187
|
+
}
|
|
1188
|
+
),
|
|
1189
|
+
menu.filesize && /* @__PURE__ */ jsx(
|
|
1190
|
+
TableHead,
|
|
1191
|
+
{
|
|
1192
|
+
nowrap: true,
|
|
1193
|
+
className: "acms-admin-media-row-size",
|
|
1194
|
+
"aria-sort": this.getIsSorted("media_filesize") ? `${this.getIsSorted("media_filesize")}ending` : void 0,
|
|
1195
|
+
children: /* @__PURE__ */ jsxs(
|
|
1196
|
+
"button",
|
|
1197
|
+
{
|
|
1198
|
+
type: "button",
|
|
1199
|
+
className: "acms-admin-th-sort-btn",
|
|
1200
|
+
onClick: this.setOrder.bind(this, "media_filesize"),
|
|
1201
|
+
"data-next-sort": `${this.getNextSortDirection("media_filesize")}ending`,
|
|
1202
|
+
children: [
|
|
1203
|
+
ACMS.i18n("media.file_size"),
|
|
1204
|
+
/* @__PURE__ */ jsx("span", { className: "acms-admin-th-sort-btn-icon" }),
|
|
1205
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: ACMS.i18n(`table.label.sort.${this.getIsSorted("media_filesize") || "none"}`) })
|
|
1206
|
+
]
|
|
1207
|
+
}
|
|
1208
|
+
)
|
|
1209
|
+
}
|
|
1210
|
+
),
|
|
1211
|
+
menu.blogname && /* @__PURE__ */ jsx(TableHead, { className: "acms-admin-media-row-blogname", children: ACMS.i18n("media.blog_name") }),
|
|
1212
|
+
mode === "edit" && /* @__PURE__ */ jsx(TableHead, { nowrap: true, className: "acms-admin-media-row-action", style: { whiteSpace: "nowrap" }, children: ACMS.i18n("media.action") })
|
|
1213
|
+
] }) }),
|
|
1214
|
+
/* @__PURE__ */ jsx(TableBody, { children: items.map((item) => /* @__PURE__ */ jsxs(
|
|
1215
|
+
TableRow,
|
|
1216
|
+
{
|
|
1217
|
+
onClick: (e) => {
|
|
1218
|
+
this.rowClick(e, item);
|
|
1219
|
+
},
|
|
1220
|
+
children: [
|
|
1221
|
+
/* @__PURE__ */ jsxs(TableCell, { nowrap: true, className: "acms-admin-media-row-check", children: [
|
|
1222
|
+
item.media_editable,
|
|
1223
|
+
(mode !== "edit" || item.media_editable) && /* @__PURE__ */ jsxs("label", { "aria-label": "\u9078\u629E", className: "acms-admin-form-checkbox acms-admin-m-0", children: [
|
|
1224
|
+
/* @__PURE__ */ jsx(
|
|
1225
|
+
"input",
|
|
1226
|
+
{
|
|
1227
|
+
type: "checkbox",
|
|
1228
|
+
name: "checks[]",
|
|
1229
|
+
value: `${item.media_bid}:${item.media_id}`,
|
|
1230
|
+
checked: item.checked,
|
|
1231
|
+
onChange: this.toggleCheck.bind(this, item),
|
|
1232
|
+
"aria-label": item.media_title || `${item.media_id}`
|
|
1233
|
+
}
|
|
1234
|
+
),
|
|
1235
|
+
/* @__PURE__ */ jsx("i", { className: "acms-admin-ico-checkbox" })
|
|
1236
|
+
] })
|
|
1237
|
+
] }),
|
|
1238
|
+
menu.image && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(TableCell, { nowrap: true, className: "acms-admin-media-row-image", children: /* @__PURE__ */ jsx(
|
|
1239
|
+
ConditionalWrap,
|
|
1240
|
+
{
|
|
1241
|
+
wrap: (chidren) => /* @__PURE__ */ jsx("a", { href: item.media_permalink, target: "_blank", rel: "noopener noreferrer", children: chidren }),
|
|
1242
|
+
condition: item.media_type === "file",
|
|
1243
|
+
children: /* @__PURE__ */ jsx("div", { className: "acms-admin-media-list-thumbnail-wrap", children: /* @__PURE__ */ jsx(
|
|
1244
|
+
"img",
|
|
1245
|
+
{
|
|
1246
|
+
src: `${item.media_thumbnail}?date=${item.media_last_modified}`,
|
|
1247
|
+
className: "acms-admin-media-list-thumbnail",
|
|
1248
|
+
alt: ""
|
|
1249
|
+
}
|
|
1250
|
+
) })
|
|
1251
|
+
}
|
|
1252
|
+
) }) }),
|
|
1253
|
+
menu.id && /* @__PURE__ */ jsx(TableCell, { nowrap: true, className: "acms-admin-media-row-id", children: /* @__PURE__ */ jsx("span", { className: "acms-admin-label", children: item.media_id }) }),
|
|
1254
|
+
menu.filename && /* @__PURE__ */ jsx(TableCell, { className: "acms-admin-media-row-title", children: item.media_title }),
|
|
1255
|
+
menu.tag && /* @__PURE__ */ jsx(TableCell, { className: "acms-admin-media-row-tag", children: item.media_label && item.media_label.split(delimiter).map((label) => /* @__PURE__ */ jsx(
|
|
1256
|
+
"span",
|
|
1257
|
+
{
|
|
1258
|
+
className: "acms-admin-label acms-admin-label-info",
|
|
1259
|
+
style: {
|
|
1260
|
+
display: "inline-block",
|
|
1261
|
+
marginRight: "5px",
|
|
1262
|
+
marginTop: "5px"
|
|
1263
|
+
},
|
|
1264
|
+
children: label
|
|
1265
|
+
},
|
|
1266
|
+
label
|
|
1267
|
+
)) }),
|
|
1268
|
+
menu.last_modified && /* @__PURE__ */ jsxs(TableCell, { nowrap: true, className: "acms-admin-media-row-date", children: [
|
|
1269
|
+
dayjs(item.media_last_modified).format("YYYY/MM/DD"),
|
|
1270
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
1271
|
+
dayjs(item.media_last_modified).format("HH:mm")
|
|
1272
|
+
] }),
|
|
1273
|
+
menu.upload_datetime && /* @__PURE__ */ jsxs(TableCell, { nowrap: true, className: "acms-admin-media-row-date", children: [
|
|
1274
|
+
dayjs(item.media_datetime).format("YYYY/MM/DD"),
|
|
1275
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
1276
|
+
dayjs(item.media_datetime).format("HH:mm")
|
|
1277
|
+
] }),
|
|
1278
|
+
menu.filesize && /* @__PURE__ */ jsxs(TableCell, { nowrap: true, className: "acms-admin-media-row-action", children: [
|
|
1279
|
+
item.media_filesize && /* @__PURE__ */ jsx(Fragment, { children: formatBytes(item.media_filesize) }),
|
|
1280
|
+
item.media_size && item.media_type === "image" && /* @__PURE__ */ jsxs("span", { style: { display: "block", marginTop: "5px" }, children: [
|
|
1281
|
+
item.media_size,
|
|
1282
|
+
"px"
|
|
1283
|
+
] })
|
|
1284
|
+
] }),
|
|
1285
|
+
menu.blogname && /* @__PURE__ */ jsx(TableCell, { className: "acms-admin-media-row-blogname", children: item.media_blog_name }),
|
|
1286
|
+
mode === "edit" && /* @__PURE__ */ jsx(TableCell, { nowrap: true, children: item.media_editable && /* @__PURE__ */ jsx("button", { type: "button", onClick: this.setItem.bind(this, item), className: "acms-admin-btn", children: ACMS.i18n("media.edit") }) })
|
|
1287
|
+
]
|
|
1288
|
+
},
|
|
1289
|
+
item.media_id
|
|
1290
|
+
)) })
|
|
1291
|
+
] }) })
|
|
1292
|
+
}
|
|
1293
|
+
),
|
|
1294
|
+
/* @__PURE__ */ jsx("div", { className: "acms-admin-media-grid", style: { display: style === "table" ? "none" : "flex" }, children: items.map((item, index) => /* @__PURE__ */ jsxs(
|
|
1295
|
+
"div",
|
|
1296
|
+
{
|
|
1297
|
+
className: "acms-admin-media-grid-item",
|
|
1298
|
+
style: { width: `${150 * scale}px`, height: `${150 * scale}px` },
|
|
1299
|
+
children: [
|
|
1300
|
+
/* @__PURE__ */ jsxs(
|
|
1301
|
+
"div",
|
|
1302
|
+
{
|
|
1303
|
+
className: classnames("acms-admin-media-grid-figure", { selected: item.checked }),
|
|
1304
|
+
title: item.media_title,
|
|
1305
|
+
role: "button",
|
|
1306
|
+
tabIndex: 0,
|
|
1307
|
+
onClick: (e) => {
|
|
1308
|
+
if (e.shiftKey && oldItemId !== null) {
|
|
1309
|
+
this.toggleCheckFrom(oldItemId, item);
|
|
1310
|
+
} else {
|
|
1311
|
+
this.toggleCheck(item);
|
|
1312
|
+
this.setState({
|
|
1313
|
+
oldItemId: item.media_id
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
},
|
|
1317
|
+
onKeyDown: (e) => {
|
|
1318
|
+
if (e.currentTarget !== document.activeElement) {
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1322
|
+
if (e.shiftKey && oldItemId !== null) {
|
|
1323
|
+
this.toggleCheckFrom(oldItemId, item);
|
|
1324
|
+
} else {
|
|
1325
|
+
this.toggleCheck(item);
|
|
1326
|
+
this.setState({
|
|
1327
|
+
oldItemId: item.media_id
|
|
1328
|
+
});
|
|
1329
|
+
}
|
|
1330
|
+
e.preventDefault();
|
|
1331
|
+
}
|
|
1332
|
+
},
|
|
1333
|
+
children: [
|
|
1334
|
+
/* @__PURE__ */ jsx("div", { className: "acms-admin-media-grid-shadow" }),
|
|
1335
|
+
item.media_type === "file" && /* @__PURE__ */ jsxs("div", { className: "acms-admin-media-grid-img-wrap", children: [
|
|
1336
|
+
/* @__PURE__ */ jsx(
|
|
1337
|
+
"img",
|
|
1338
|
+
{
|
|
1339
|
+
className: "acms-admin-media-grid-file-img",
|
|
1340
|
+
src: item.media_thumbnail,
|
|
1341
|
+
style: this.getFileStyle(stateItems[index]),
|
|
1342
|
+
alt: ""
|
|
1343
|
+
}
|
|
1344
|
+
),
|
|
1345
|
+
/* @__PURE__ */ jsx("span", { className: "acms-admin-media-grid-filename", children: item.media_title })
|
|
1346
|
+
] }),
|
|
1347
|
+
(item.media_type === "image" || item.media_type === "svg") && /* @__PURE__ */ jsx(
|
|
1348
|
+
"img",
|
|
1349
|
+
{
|
|
1350
|
+
src: `${item.media_thumbnail}?date=${item.media_last_modified}`,
|
|
1351
|
+
style: this.getImageStyle(stateItems[index]),
|
|
1352
|
+
id: `media-image-${index}`,
|
|
1353
|
+
alt: ""
|
|
1354
|
+
}
|
|
1355
|
+
),
|
|
1356
|
+
/* @__PURE__ */ jsxs("div", { className: classnames("acms-admin-media-grid-flame", { selected: item.checked }), children: [
|
|
1357
|
+
/* @__PURE__ */ jsx("div", { className: "acms-admin-media-grid-checkbox" }),
|
|
1358
|
+
mode === "edit" && item.media_editable && /* @__PURE__ */ jsx("div", { className: "acms-admin-media-edit-list-btn-wrap", children: /* @__PURE__ */ jsx(
|
|
1359
|
+
"button",
|
|
1360
|
+
{
|
|
1361
|
+
type: "button",
|
|
1362
|
+
className: "acms-admin-media-edit-btn acms-admin-media-edit-list-btn",
|
|
1363
|
+
onClick: (e) => {
|
|
1364
|
+
e.preventDefault();
|
|
1365
|
+
e.stopPropagation();
|
|
1366
|
+
this.setItem(item);
|
|
1367
|
+
},
|
|
1368
|
+
children: ACMS.i18n("media.edit")
|
|
1369
|
+
}
|
|
1370
|
+
) })
|
|
1371
|
+
] })
|
|
1372
|
+
]
|
|
1373
|
+
}
|
|
1374
|
+
),
|
|
1375
|
+
/* @__PURE__ */ jsx("input", { type: "hidden", name: "checks[]", value: `${item.media_bid}:${item.media_id}` })
|
|
1376
|
+
]
|
|
1377
|
+
},
|
|
1378
|
+
item.media_id
|
|
1379
|
+
)) }),
|
|
1380
|
+
/* @__PURE__ */ jsx(Grid, { className: "acms-admin-margin-top-medium", children: /* @__PURE__ */ jsxs(
|
|
1381
|
+
PaginationRoot,
|
|
1382
|
+
{
|
|
1383
|
+
page,
|
|
1384
|
+
pageSize: limit,
|
|
1385
|
+
total: Math.ceil(total / limit),
|
|
1386
|
+
totalItems: total,
|
|
1387
|
+
onChange: (page2) => this.fetchMediaList({
|
|
1388
|
+
page: page2
|
|
1389
|
+
}),
|
|
1390
|
+
children: [
|
|
1391
|
+
/* @__PURE__ */ jsx(GridItem, { col: { md: 6, xs: 12 }, children: /* @__PURE__ */ jsx(Pagination, {}) }),
|
|
1392
|
+
/* @__PURE__ */ jsx(GridItem, { col: { md: 6, xs: 12 }, children: /* @__PURE__ */ jsx(PaginationSummary, {}) })
|
|
1393
|
+
]
|
|
1394
|
+
}
|
|
1395
|
+
) })
|
|
1396
|
+
] })
|
|
1397
|
+
] });
|
|
1398
|
+
}
|
|
1399
|
+
};
|
|
1400
|
+
|
|
1401
|
+
// src/components/media-uploader/media-uploader.tsx
|
|
1402
|
+
import { Component as Component2 } from "react";
|
|
1403
|
+
import classNames from "classnames";
|
|
1404
|
+
import DOMPurify from "dompurify";
|
|
1405
|
+
import { emit as emit2 } from "@ablogcms/events";
|
|
1406
|
+
import { random, getExt, dataURItoBlob } from "@ablogcms/utils";
|
|
1407
|
+
import createPdf from "@ablogcms/lib/create-pdf";
|
|
1408
|
+
import runWithConcurrency from "@ablogcms/utils/run-with-concurrency";
|
|
1409
|
+
import ResizeImage from "@ablogcms/lib/resize-image-util";
|
|
1410
|
+
import readFiles from "@ablogcms/lib/read-files";
|
|
1411
|
+
import { CreatableSelect as CreatableSelect2 } from "@ablogcms/components/rich-select";
|
|
1412
|
+
import { DropZone } from "@ablogcms/components/drop-zone";
|
|
1413
|
+
import ProgressBar from "@ablogcms/components/progress-bar";
|
|
1414
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1415
|
+
var delimiter2 = ",";
|
|
1416
|
+
var DEFAULT_UPLOAD_LIMIT = 100;
|
|
1417
|
+
var DEFAULT_UPLOAD_CONCURRENCY = 4;
|
|
1418
|
+
var MediaUploader = class extends Component2 {
|
|
1419
|
+
static defaultProps = {
|
|
1420
|
+
showUploadButton: true,
|
|
1421
|
+
tags: [],
|
|
1422
|
+
files: []
|
|
1423
|
+
};
|
|
1424
|
+
constructor(props) {
|
|
1425
|
+
super(props);
|
|
1426
|
+
this.state = {
|
|
1427
|
+
items: [],
|
|
1428
|
+
label: props.label || "",
|
|
1429
|
+
loading: false,
|
|
1430
|
+
imgsOnStage: false,
|
|
1431
|
+
hasUploadedItems: false
|
|
1432
|
+
// has already uploaded images
|
|
1433
|
+
};
|
|
1434
|
+
}
|
|
1435
|
+
// 一度にアップロードできる件数の上限(config 由来。未設定・不正値はデフォルトにフォールバック)
|
|
1436
|
+
get uploadLimit() {
|
|
1437
|
+
const value = parseInt(String(ACMS.Config.mediaUploadLimit ?? ""), 10);
|
|
1438
|
+
return Number.isFinite(value) && value > 0 ? value : DEFAULT_UPLOAD_LIMIT;
|
|
1439
|
+
}
|
|
1440
|
+
// 同時にアップロードする本数(並列度。config 由来。未設定・不正値はデフォルトにフォールバック)
|
|
1441
|
+
get uploadConcurrency() {
|
|
1442
|
+
const value = parseInt(String(ACMS.Config.mediaUploadConcurrency ?? ""), 10);
|
|
1443
|
+
return Number.isFinite(value) && value > 0 ? value : DEFAULT_UPLOAD_CONCURRENCY;
|
|
1444
|
+
}
|
|
1445
|
+
// 全体のアップロード進捗(完了件数・失敗件数・総件数・全体パーセント)
|
|
1446
|
+
get uploadProgress() {
|
|
1447
|
+
const { items } = this.state;
|
|
1448
|
+
const total = items.length;
|
|
1449
|
+
if (total === 0) {
|
|
1450
|
+
return { done: 0, total: 0, percent: 0, errorCount: 0 };
|
|
1451
|
+
}
|
|
1452
|
+
const isDone = (item) => Boolean(item.uploadedItem) || item.progress < 0;
|
|
1453
|
+
const done = items.filter(isDone).length;
|
|
1454
|
+
const errorCount = items.filter((item) => item.progressError).length;
|
|
1455
|
+
const sum = items.reduce((acc, item) => acc + (isDone(item) ? 100 : Math.max(0, Math.min(100, item.progress))), 0);
|
|
1456
|
+
return { done, total, percent: Math.round(sum / total), errorCount };
|
|
1457
|
+
}
|
|
1458
|
+
// アップロード中のページ離脱・リロードに確認ダイアログを出す(途中中断の防止)
|
|
1459
|
+
handleBeforeUnload = (event) => {
|
|
1460
|
+
if (this.state.loading) {
|
|
1461
|
+
event.preventDefault();
|
|
1462
|
+
event.returnValue = "";
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
componentDidMount() {
|
|
1466
|
+
window.addEventListener("beforeunload", this.handleBeforeUnload);
|
|
1467
|
+
if (this.props.files) {
|
|
1468
|
+
readFiles(this.props.files).then((extededFiles) => {
|
|
1469
|
+
this.onComplete(extededFiles);
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
componentWillUnmount() {
|
|
1474
|
+
window.removeEventListener("beforeunload", this.handleBeforeUnload);
|
|
1475
|
+
}
|
|
1476
|
+
async createPdfThumbnail(file) {
|
|
1477
|
+
const pdf = await createPdf(file, 1);
|
|
1478
|
+
return pdf;
|
|
1479
|
+
}
|
|
1480
|
+
upload(blob, label, name, item) {
|
|
1481
|
+
const { largeSize } = this.props;
|
|
1482
|
+
return new Promise(async (resolve, reject) => {
|
|
1483
|
+
const fd = new FormData();
|
|
1484
|
+
fd.append("ACMS_POST_Media_Upload", "true");
|
|
1485
|
+
if (label) {
|
|
1486
|
+
fd.append("tags", label);
|
|
1487
|
+
}
|
|
1488
|
+
const ext = getExt(name);
|
|
1489
|
+
if (ext.toLowerCase() === "pdf") {
|
|
1490
|
+
const image = await this.createPdfThumbnail(blob);
|
|
1491
|
+
if (image) {
|
|
1492
|
+
fd.append("media_pdf_thumbnail", dataURItoBlob(image));
|
|
1493
|
+
fd.append("pdf_page", "1");
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
fd.append("size", `${largeSize}`);
|
|
1497
|
+
fd.append("file", blob, name);
|
|
1498
|
+
fd.append("formToken", window.csrfToken);
|
|
1499
|
+
this.setProgressBar(item, 0);
|
|
1500
|
+
getMediaTransport().uploadMedia(fd, {
|
|
1501
|
+
onUploadProgress: (e) => {
|
|
1502
|
+
if (typeof e.total === "number") {
|
|
1503
|
+
this.setProgressBar(item, 70 * (e.loaded / e.total));
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
}).then((res) => {
|
|
1507
|
+
if (res && res.data) {
|
|
1508
|
+
if ("status" in res.data && res.data.status === "failure") {
|
|
1509
|
+
throw new Error(res.data.message);
|
|
1510
|
+
}
|
|
1511
|
+
const mediaItem = res.data;
|
|
1512
|
+
this.setProgressBar(item, 100);
|
|
1513
|
+
setTimeout(() => {
|
|
1514
|
+
resolve(mediaItem);
|
|
1515
|
+
}, 300);
|
|
1516
|
+
return;
|
|
1517
|
+
}
|
|
1518
|
+
throw new Error(ACMS.i18n("media.error.unknown"));
|
|
1519
|
+
}).catch((err) => {
|
|
1520
|
+
console.error(err);
|
|
1521
|
+
this.setProgressBar(item, 100, true);
|
|
1522
|
+
if (err instanceof Error) {
|
|
1523
|
+
alert(err.message);
|
|
1524
|
+
}
|
|
1525
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
1526
|
+
});
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
setProgressBar(item, progress, progressError = false) {
|
|
1530
|
+
this.setState((prev) => {
|
|
1531
|
+
const index = prev.items.findIndex((file) => file.id === item.id);
|
|
1532
|
+
if (index === -1) {
|
|
1533
|
+
return null;
|
|
1534
|
+
}
|
|
1535
|
+
const copyItems = prev.items.slice();
|
|
1536
|
+
copyItems[index] = { ...copyItems[index], progress, progressError };
|
|
1537
|
+
return { items: copyItems };
|
|
1538
|
+
});
|
|
1539
|
+
}
|
|
1540
|
+
removeFile(file) {
|
|
1541
|
+
this.setState((prev) => ({
|
|
1542
|
+
items: prev.items.filter((item) => item.idx !== file.idx)
|
|
1543
|
+
}));
|
|
1544
|
+
}
|
|
1545
|
+
setUploadedItem(file, uploadedItem) {
|
|
1546
|
+
this.setState((prev) => {
|
|
1547
|
+
const index = prev.items.findIndex((item) => item.idx === file.idx);
|
|
1548
|
+
if (index === -1) {
|
|
1549
|
+
return null;
|
|
1550
|
+
}
|
|
1551
|
+
const copyItems = prev.items.slice();
|
|
1552
|
+
copyItems[index] = { ...copyItems[index], uploadedItem, progress: -1 };
|
|
1553
|
+
return { items: copyItems };
|
|
1554
|
+
});
|
|
1555
|
+
}
|
|
1556
|
+
editItem(item) {
|
|
1557
|
+
if (item.uploadedItem) {
|
|
1558
|
+
this.props.actions.setItem(item.uploadedItem);
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
async uploadItems() {
|
|
1562
|
+
const { items, label } = this.state;
|
|
1563
|
+
const { actions } = this.props;
|
|
1564
|
+
const gateResult = await emit2("media.upload.before", { files: items.map((item) => item.file) });
|
|
1565
|
+
if (gateResult.canceled) {
|
|
1566
|
+
if (gateResult.reason) {
|
|
1567
|
+
alert(gateResult.reason);
|
|
1568
|
+
}
|
|
1569
|
+
return [];
|
|
1570
|
+
}
|
|
1571
|
+
const allowedFiles = new Set(gateResult.event.files);
|
|
1572
|
+
const targetItems = items.filter((item) => allowedFiles.has(item.file));
|
|
1573
|
+
const resizeImage = new ResizeImage();
|
|
1574
|
+
this.setState({
|
|
1575
|
+
loading: true,
|
|
1576
|
+
hasUploadedItems: true
|
|
1577
|
+
});
|
|
1578
|
+
const [resizeType, largeSize] = ACMS.Config.lgImg.split(":");
|
|
1579
|
+
const tasks = targetItems.map((item) => async () => {
|
|
1580
|
+
const { name, filetype, file } = item;
|
|
1581
|
+
const isHeic = filetype === "image" && /(heic|heif)/i.test(file.type);
|
|
1582
|
+
const isSvg = filetype === "image" && file.type.includes("svg");
|
|
1583
|
+
const isGif = filetype === "image" && file.type.includes("gif");
|
|
1584
|
+
try {
|
|
1585
|
+
let uploadData;
|
|
1586
|
+
if (filetype === "image") {
|
|
1587
|
+
if (isHeic) {
|
|
1588
|
+
if (!(item.blob instanceof Blob)) {
|
|
1589
|
+
return null;
|
|
1590
|
+
}
|
|
1591
|
+
uploadData = item.blob;
|
|
1592
|
+
} else if (isSvg) {
|
|
1593
|
+
const text = await file.text();
|
|
1594
|
+
const clean = DOMPurify.sanitize(text, { USE_PROFILES: { svg: true, svgFilters: true } });
|
|
1595
|
+
uploadData = new Blob([clean], { type: "image/svg+xml" });
|
|
1596
|
+
} else if (isGif) {
|
|
1597
|
+
uploadData = file;
|
|
1598
|
+
} else {
|
|
1599
|
+
const { blob, resize } = await resizeImage.getBlobFromFile(file, resizeType, parseInt(largeSize, 10));
|
|
1600
|
+
uploadData = resize && ACMS.Config.mediaClientResize !== "off" ? blob : file;
|
|
1601
|
+
}
|
|
1602
|
+
} else {
|
|
1603
|
+
uploadData = file;
|
|
1604
|
+
}
|
|
1605
|
+
const uploadedItem = await this.upload(uploadData, label, name, item);
|
|
1606
|
+
this.setUploadedItem(item, uploadedItem);
|
|
1607
|
+
return uploadedItem;
|
|
1608
|
+
} catch {
|
|
1609
|
+
return null;
|
|
1610
|
+
}
|
|
1611
|
+
});
|
|
1612
|
+
const results = await runWithConcurrency(tasks, this.uploadConcurrency);
|
|
1613
|
+
this.setState({
|
|
1614
|
+
loading: false
|
|
1615
|
+
});
|
|
1616
|
+
actions.fetchMediaList();
|
|
1617
|
+
const uploadedItems = results.filter((result) => result !== null);
|
|
1618
|
+
await emit2("media.upload.success", { items: uploadedItems });
|
|
1619
|
+
return uploadedItems;
|
|
1620
|
+
}
|
|
1621
|
+
onComplete(files) {
|
|
1622
|
+
let items = [
|
|
1623
|
+
...this.state.items,
|
|
1624
|
+
...files.map(
|
|
1625
|
+
(file) => ({
|
|
1626
|
+
file: file.file,
|
|
1627
|
+
filetype: file.filetype,
|
|
1628
|
+
preview: file.filetype === "image" ? file.preview : "",
|
|
1629
|
+
blob: file.filetype === "image" ? file.blob : null,
|
|
1630
|
+
// for heic
|
|
1631
|
+
name: file.file.name,
|
|
1632
|
+
size: file.file.size,
|
|
1633
|
+
idx: -1,
|
|
1634
|
+
id: "",
|
|
1635
|
+
progress: 0,
|
|
1636
|
+
progressError: false
|
|
1637
|
+
})
|
|
1638
|
+
)
|
|
1639
|
+
].filter((item) => {
|
|
1640
|
+
if (item.uploadedItem) {
|
|
1641
|
+
return false;
|
|
1642
|
+
}
|
|
1643
|
+
return true;
|
|
1644
|
+
}).map((item, index) => ({
|
|
1645
|
+
...item,
|
|
1646
|
+
idx: index,
|
|
1647
|
+
id: random(10)
|
|
1648
|
+
}));
|
|
1649
|
+
items = Array.from(
|
|
1650
|
+
new Map(items.map((item) => [`${item.file.name}:${item.file.size}:${item.file.lastModified}`, item])).values()
|
|
1651
|
+
);
|
|
1652
|
+
const limit = this.uploadLimit;
|
|
1653
|
+
if (items.length > limit) {
|
|
1654
|
+
alert(ACMS.i18n("media.more_than_limit_not_allowed", { limit }));
|
|
1655
|
+
items = items.slice(0, limit);
|
|
1656
|
+
}
|
|
1657
|
+
if (items.length > 0) {
|
|
1658
|
+
this.setState({ items, hasUploadedItems: false, imgsOnStage: true });
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
makeTags(label) {
|
|
1662
|
+
if (!label) {
|
|
1663
|
+
return null;
|
|
1664
|
+
}
|
|
1665
|
+
const labels = label.split(delimiter2);
|
|
1666
|
+
return labels.map((label2) => ({
|
|
1667
|
+
value: label2,
|
|
1668
|
+
label: label2
|
|
1669
|
+
}));
|
|
1670
|
+
}
|
|
1671
|
+
addTags(tags) {
|
|
1672
|
+
const label = tags.reduce((val, tag, idx) => {
|
|
1673
|
+
if (idx === 0) {
|
|
1674
|
+
return tag.value;
|
|
1675
|
+
}
|
|
1676
|
+
return `${val}${delimiter2}${tag.value}`;
|
|
1677
|
+
}, "");
|
|
1678
|
+
this.setState({
|
|
1679
|
+
label
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
removeUploadedItems() {
|
|
1683
|
+
this.setState((prev) => ({
|
|
1684
|
+
items: prev.items.filter((item) => !item.uploadedItem)
|
|
1685
|
+
}));
|
|
1686
|
+
}
|
|
1687
|
+
// 全体進捗テキストの出し分け(進行中 / 完了 / 一部失敗)
|
|
1688
|
+
renderOverallText() {
|
|
1689
|
+
const overall = this.uploadProgress;
|
|
1690
|
+
const processed = overall.total > 0 && overall.done + overall.errorCount === overall.total;
|
|
1691
|
+
if (!processed) {
|
|
1692
|
+
return ACMS.i18n("media.upload_overall_progress", { done: overall.done, total: overall.total });
|
|
1693
|
+
}
|
|
1694
|
+
if (overall.errorCount > 0) {
|
|
1695
|
+
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
1696
|
+
ACMS.i18n("media.upload_done_count", { done: overall.done }),
|
|
1697
|
+
/* @__PURE__ */ jsx2("span", { className: "acms-admin-text-danger", children: ACMS.i18n("media.upload_failed_count", { failed: overall.errorCount }) })
|
|
1698
|
+
] });
|
|
1699
|
+
}
|
|
1700
|
+
return ACMS.i18n("media.upload_all_complete", { total: overall.total });
|
|
1701
|
+
}
|
|
1702
|
+
render() {
|
|
1703
|
+
const { items, label, hasUploadedItems, imgsOnStage } = this.state;
|
|
1704
|
+
const { showUploadButton, tags } = this.props;
|
|
1705
|
+
const overall = this.uploadProgress;
|
|
1706
|
+
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
1707
|
+
/* @__PURE__ */ jsx2("div", { className: "clearfix", style: { marginBottom: "10px" }, children: /* @__PURE__ */ jsx2("div", { style: { padding: "0 10px" }, children: /* @__PURE__ */ jsx2(
|
|
1708
|
+
CreatableSelect2,
|
|
1709
|
+
{
|
|
1710
|
+
isMulti: true,
|
|
1711
|
+
options: (tags || []).map((tag) => ({
|
|
1712
|
+
label: tag,
|
|
1713
|
+
value: tag
|
|
1714
|
+
})),
|
|
1715
|
+
value: this.makeTags(label),
|
|
1716
|
+
onChange: this.addTags.bind(this),
|
|
1717
|
+
placeholder: ACMS.i18n("media.tag_select_placeholder"),
|
|
1718
|
+
formatCreateLabel: (inputValue) => ACMS.i18n("media.add_tag", { name: inputValue }),
|
|
1719
|
+
isValidNewOption: (inputValue) => inputValue.trim().length > 0,
|
|
1720
|
+
noOptionsMessage: () => ACMS.i18n("media.tag_select_no_options_message"),
|
|
1721
|
+
closeMenuOnSelect: false,
|
|
1722
|
+
hideSelectedOptions: true,
|
|
1723
|
+
menuPortalTarget: document.body
|
|
1724
|
+
}
|
|
1725
|
+
) }) }),
|
|
1726
|
+
hasUploadedItems && items.length > 0 && /* @__PURE__ */ jsxs2("div", { className: "acms-admin-media-upload-overall", style: { padding: "0 10px", marginBottom: "10px" }, children: [
|
|
1727
|
+
/* @__PURE__ */ jsx2(ProgressBar, { value: overall.percent, variant: "info", striped: true, animated: true }),
|
|
1728
|
+
/* @__PURE__ */ jsx2("p", { className: "acms-admin-media-upload-overall-text", children: this.renderOverallText() })
|
|
1729
|
+
] }),
|
|
1730
|
+
/* @__PURE__ */ jsx2("div", { className: "acms-admin-media-upload-container-wrap", children: /* @__PURE__ */ jsxs2("div", { className: "acms-admin-media-upload-container", children: [
|
|
1731
|
+
/* @__PURE__ */ jsx2("div", { className: "acms-admin-media-upload-item", children: /* @__PURE__ */ jsx2("div", { className: "acms-admin-media-upload-item-inner", children: /* @__PURE__ */ jsx2(DropZone, { onComplete: this.onComplete.bind(this) }) }) }),
|
|
1732
|
+
items.map((item) => /* @__PURE__ */ jsx2("div", { className: "acms-admin-media-upload-item", children: /* @__PURE__ */ jsxs2(
|
|
1733
|
+
"div",
|
|
1734
|
+
{
|
|
1735
|
+
className: classNames("acms-admin-media-upload-item-inner", {
|
|
1736
|
+
"-progress": item.progress > 0
|
|
1737
|
+
}),
|
|
1738
|
+
style: { position: "relative" },
|
|
1739
|
+
children: [
|
|
1740
|
+
item.progress > 0 && /* @__PURE__ */ jsx2(
|
|
1741
|
+
"div",
|
|
1742
|
+
{
|
|
1743
|
+
style: {
|
|
1744
|
+
position: "absolute",
|
|
1745
|
+
top: "0",
|
|
1746
|
+
left: "0",
|
|
1747
|
+
width: "100%",
|
|
1748
|
+
boxSizing: "border-box",
|
|
1749
|
+
zIndex: 2
|
|
1750
|
+
},
|
|
1751
|
+
children: /* @__PURE__ */ jsx2("div", { className: "acms-admin-loading-bar acms-admin-active", children: /* @__PURE__ */ jsx2(
|
|
1752
|
+
"div",
|
|
1753
|
+
{
|
|
1754
|
+
className: classNames("acms-admin-loading-bar-inner", {
|
|
1755
|
+
"-alert": item.progressError
|
|
1756
|
+
}),
|
|
1757
|
+
style: { width: `${item.progress}%` }
|
|
1758
|
+
}
|
|
1759
|
+
) })
|
|
1760
|
+
}
|
|
1761
|
+
),
|
|
1762
|
+
!item.uploadedItem && /* @__PURE__ */ jsx2(
|
|
1763
|
+
"button",
|
|
1764
|
+
{
|
|
1765
|
+
type: "button",
|
|
1766
|
+
className: "acms-admin-media-upload-cancel",
|
|
1767
|
+
onClick: this.removeFile.bind(this, item),
|
|
1768
|
+
"aria-label": ACMS.i18n("media.remove_file")
|
|
1769
|
+
}
|
|
1770
|
+
),
|
|
1771
|
+
item.uploadedItem && /* @__PURE__ */ jsx2(
|
|
1772
|
+
"button",
|
|
1773
|
+
{
|
|
1774
|
+
type: "button",
|
|
1775
|
+
className: "acms-admin-media-edit-btn acms-admin-media-edit-upload-btn",
|
|
1776
|
+
onClick: this.editItem.bind(this, item),
|
|
1777
|
+
children: ACMS.i18n("media.edit")
|
|
1778
|
+
}
|
|
1779
|
+
),
|
|
1780
|
+
item.filetype === "image" && /* @__PURE__ */ jsx2("div", { className: "acms-admin-media-upload-bg", style: { backgroundImage: `url(${item.preview})` } }),
|
|
1781
|
+
item.filetype !== "image" && /* @__PURE__ */ jsx2("div", { className: "acms-admin-media-upload-bg", children: /* @__PURE__ */ jsx2(
|
|
1782
|
+
"img",
|
|
1783
|
+
{
|
|
1784
|
+
src: `${ACMS.Config.root}themes/system/images/fileicon/file.png`,
|
|
1785
|
+
className: "acms-admin-media-upload-file",
|
|
1786
|
+
alt: ""
|
|
1787
|
+
}
|
|
1788
|
+
) }),
|
|
1789
|
+
/* @__PURE__ */ jsx2("div", { className: "acms-admin-media-overlay" }),
|
|
1790
|
+
/* @__PURE__ */ jsx2("div", { className: "acms-admin-media-upload-caption", children: /* @__PURE__ */ jsx2("p", { className: "acms-admin-media-upload-caption-text", children: item.name }) })
|
|
1791
|
+
]
|
|
1792
|
+
}
|
|
1793
|
+
) }, item.id))
|
|
1794
|
+
] }) }),
|
|
1795
|
+
items.length === 0 && /* @__PURE__ */ jsx2("p", { style: { textAlign: "center" }, children: ACMS.i18n("media.no_staged_media") }),
|
|
1796
|
+
showUploadButton && imgsOnStage && /* @__PURE__ */ jsx2("div", { className: "acms-admin-media-upload-footer clearfix", children: /* @__PURE__ */ jsx2(
|
|
1797
|
+
"button",
|
|
1798
|
+
{
|
|
1799
|
+
type: "button",
|
|
1800
|
+
className: "acms-admin-btn-admin acms-admin-btn-admin-primary acms-admin-float-right",
|
|
1801
|
+
onClick: this.uploadItems.bind(this),
|
|
1802
|
+
disabled: hasUploadedItems,
|
|
1803
|
+
children: ACMS.i18n("media.upload")
|
|
1804
|
+
}
|
|
1805
|
+
) })
|
|
1806
|
+
] });
|
|
1807
|
+
}
|
|
1808
|
+
};
|
|
1809
|
+
|
|
1810
|
+
export {
|
|
1811
|
+
MediaList,
|
|
1812
|
+
MediaUploader
|
|
1813
|
+
};
|
|
1814
|
+
//# sourceMappingURL=chunk-KQNVYJOK.mjs.map
|