@mirrormedia/lilith-draft-editor 3.0.12 → 3.0.13

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.
Files changed (26) hide show
  1. package/lib/index.js +8 -0
  2. package/lib/website/mirrortv/block-renderer/background-image-block.js +93 -0
  3. package/lib/website/mirrortv/block-renderer/background-video-block.js +93 -0
  4. package/lib/website/mirrortv/block-renderer/color-box-block.js +86 -0
  5. package/lib/website/mirrortv/block-renderer/embedded-code-block.js +88 -0
  6. package/lib/website/mirrortv/block-renderer/image-block.js +108 -0
  7. package/lib/website/mirrortv/block-renderer/info-box-block.js +86 -0
  8. package/lib/website/mirrortv/block-renderer/side-index-block.js +90 -0
  9. package/lib/website/mirrortv/block-renderer/slideshow-block.js +150 -0
  10. package/lib/website/mirrortv/block-renderer/table-block.js +408 -0
  11. package/lib/website/mirrortv/block-renderer-fn.js +151 -0
  12. package/lib/website/mirrortv/draft-editor.js +1027 -0
  13. package/lib/website/mirrortv/entity-decorator.js +27 -0
  14. package/lib/website/mirrortv/index.js +16 -0
  15. package/lib/website/mirrortv/selector/align-selector.js +71 -0
  16. package/lib/website/mirrortv/selector/audio-selector.js +279 -0
  17. package/lib/website/mirrortv/selector/image-selector.js +463 -0
  18. package/lib/website/mirrortv/selector/image-uploader.js +260 -0
  19. package/lib/website/mirrortv/selector/pagination.js +82 -0
  20. package/lib/website/mirrortv/selector/post-selector.js +321 -0
  21. package/lib/website/mirrortv/selector/search-box.js +46 -0
  22. package/lib/website/mirrortv/selector/video-selector.js +432 -0
  23. package/lib/website/mirrortv/shared-style/index.js +17 -0
  24. package/lib/website/mirrortv/theme/index.js +28 -0
  25. package/lib/website/mirrortv/utils/file-convert.js +67 -0
  26. package/package.json +2 -2
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SearchBox = SearchBox;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
11
+
12
+ var _button = require("@keystone-ui/button");
13
+
14
+ var _fields = require("@keystone-ui/fields");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ const SearchBoxWrapper = _styledComponents.default.div`
23
+ display: flex;
24
+ `;
25
+
26
+ function SearchBox(props) {
27
+ const {
28
+ onChange,
29
+ className = ''
30
+ } = props;
31
+ const [searchInput, setSearchInput] = (0, _react.useState)('');
32
+ return /*#__PURE__*/_react.default.createElement(SearchBoxWrapper, {
33
+ className: className
34
+ }, /*#__PURE__*/_react.default.createElement(_fields.TextInput, {
35
+ type: "text",
36
+ placeholder: "\u8ACB\u8F38\u5165\u95DC\u9375\u5B57\u641C\u5C0B",
37
+ value: searchInput,
38
+ onChange: e => {
39
+ setSearchInput(e.target.value);
40
+ }
41
+ }), /*#__PURE__*/_react.default.createElement(_button.Button, {
42
+ onClick: () => {
43
+ onChange(searchInput);
44
+ }
45
+ }, "Search"));
46
+ }
@@ -0,0 +1,432 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VideoSelector = VideoSelector;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _debounce = _interopRequireDefault(require("lodash/debounce"));
11
+
12
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
13
+
14
+ var _modals = require("@keystone-ui/modals");
15
+
16
+ var _apollo = require("@keystone-6/core/admin-ui/apollo");
17
+
18
+ var _searchBox = require("./search-box");
19
+
20
+ var _pagination = require("./pagination");
21
+
22
+ var _fields = require("@keystone-ui/fields");
23
+
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+
26
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
+
28
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
+
30
+ const videosQuery = (0, _apollo.gql)`
31
+ query Videos($searchText: String!, $take: Int, $skip: Int) {
32
+ videosCount(where: { name: { contains: $searchText } })
33
+ videos(
34
+ where: { name: { contains: $searchText } }
35
+ orderBy: { id: desc }
36
+ take: $take
37
+ skip: $skip
38
+ ) {
39
+ id
40
+ name
41
+ videoSrc
42
+ file {
43
+ filename
44
+ filesize
45
+ url
46
+ }
47
+ coverPhoto {
48
+ id
49
+ name
50
+ resized {
51
+ original
52
+ }
53
+ }
54
+ }
55
+ }
56
+ `;
57
+ const _ = {
58
+ debounce: _debounce.default
59
+ };
60
+ const VideoSearchBox = (0, _styledComponents.default)(_searchBox.SearchBox)`
61
+ margin-top: 10px;
62
+ `;
63
+ const VideoSelectionWrapper = _styledComponents.default.div`
64
+ overflow: auto;
65
+ margin-top: 10px;
66
+ `;
67
+ const VideoGridsWrapper = _styledComponents.default.div`
68
+ display: flex;
69
+ flex-wrap: wrap;
70
+ overflow: auto;
71
+ `;
72
+ const VideoGridWrapper = _styledComponents.default.div`
73
+ flex: 0 0 33.3333%;
74
+ cursor: pointer;
75
+ padding: 0 10px 10px;
76
+ `;
77
+ const VideoMetaGridsWrapper = _styledComponents.default.div`
78
+ display: flex;
79
+ flex-wrap: wrap;
80
+ overflow: auto;
81
+ `;
82
+ const VideoMetaGridWrapper = _styledComponents.default.div`
83
+ flex: 0 0 33.3333%;
84
+ cursor: pointer;
85
+ padding: 0 10px 10px;
86
+ `;
87
+ const Video = _styledComponents.default.video`
88
+ display: block;
89
+ width: 100%;
90
+ aspect-ratio: 16 / 9;
91
+ object-fit: cover;
92
+ `;
93
+ const SeparationLine = _styledComponents.default.div`
94
+ border: #e1e5e9 1px solid;
95
+ margin-top: 10px;
96
+ margin-bottom: 10px;
97
+ `;
98
+ const VideoSelected = _styledComponents.default.div`
99
+ height: 1.4rem;
100
+ `;
101
+ const ErrorWrapper = _styledComponents.default.div`
102
+ & * {
103
+ margin: 0;
104
+ }
105
+ `;
106
+ const VideoName = _styledComponents.default.p`
107
+ text-align: center;
108
+ `;
109
+ const Label = _styledComponents.default.label`
110
+ display: block;
111
+ margin: 10px 0;
112
+ font-weight: 600;
113
+ `;
114
+
115
+ const getYoutubeId = url => {
116
+ if (!url) return null;
117
+ const match = url.match(/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/);
118
+ return match ? match[1] : null;
119
+ };
120
+
121
+ function VideosGrids(props) {
122
+ const {
123
+ videos,
124
+ selected,
125
+ onSelect
126
+ } = props;
127
+ return /*#__PURE__*/_react.default.createElement(VideoGridsWrapper, null, videos.map(video => {
128
+ return /*#__PURE__*/_react.default.createElement(VideoGrid, {
129
+ key: video.id,
130
+ isSelected: selected === null || selected === void 0 ? void 0 : selected.some(s => s.id === video.id),
131
+ onSelect: () => onSelect(video),
132
+ video: video
133
+ });
134
+ }));
135
+ }
136
+
137
+ function VideoGrid(props) {
138
+ var _video$file, _video$coverPhoto, _video$coverPhoto$res;
139
+
140
+ const {
141
+ video,
142
+ onSelect,
143
+ isSelected
144
+ } = props;
145
+ const [isPlaying, setIsPlaying] = (0, _react.useState)(false);
146
+ (0, _react.useEffect)(() => {
147
+ setIsPlaying(false);
148
+ }, [video.id]);
149
+ const youtubeId = getYoutubeId(video === null || video === void 0 ? void 0 : video.videoSrc);
150
+ const fileUrl = video === null || video === void 0 ? void 0 : (_video$file = video.file) === null || _video$file === void 0 ? void 0 : _video$file.url;
151
+ const posterUrl = (video === null || video === void 0 ? void 0 : (_video$coverPhoto = video.coverPhoto) === null || _video$coverPhoto === void 0 ? void 0 : (_video$coverPhoto$res = _video$coverPhoto.resized) === null || _video$coverPhoto$res === void 0 ? void 0 : _video$coverPhoto$res.original) || (youtubeId ? `https://img.youtube.com/vi/${encodeURIComponent(youtubeId)}/hqdefault.jpg` : "");
152
+
153
+ const handlePlayAndSelect = e => {
154
+ e.stopPropagation();
155
+
156
+ if (isPlaying) {
157
+ setIsPlaying(false);
158
+ } else {
159
+ setIsPlaying(true);
160
+ onSelect(video);
161
+ }
162
+ };
163
+
164
+ return /*#__PURE__*/_react.default.createElement(VideoGridWrapper, {
165
+ key: video === null || video === void 0 ? void 0 : video.id,
166
+ onClick: () => onSelect(video)
167
+ }, /*#__PURE__*/_react.default.createElement(VideoSelected, {
168
+ style: {
169
+ height: '24px',
170
+ marginBottom: '4px'
171
+ }
172
+ }, isSelected ? /*#__PURE__*/_react.default.createElement("i", {
173
+ className: "fas fa-check-circle",
174
+ style: {
175
+ color: '#007bff'
176
+ }
177
+ }) : null), /*#__PURE__*/_react.default.createElement("div", {
178
+ onClick: handlePlayAndSelect,
179
+ style: {
180
+ width: '100%',
181
+ aspectRatio: '16/9',
182
+ position: 'relative',
183
+ backgroundColor: '#000',
184
+ borderRadius: '4px',
185
+ overflow: 'hidden'
186
+ }
187
+ }, isPlaying ? youtubeId ? /*#__PURE__*/_react.default.createElement("iframe", {
188
+ style: {
189
+ width: '100%',
190
+ height: '100%',
191
+ border: 'none',
192
+ display: 'block'
193
+ },
194
+ src: `https://www.youtube.com/embed/${youtubeId}?autoplay=1&mute=1&rel=0`,
195
+ allow: "autoplay; encrypted-media",
196
+ allowFullScreen: true
197
+ }) : /*#__PURE__*/_react.default.createElement(Video, {
198
+ autoPlay: true,
199
+ controls: true,
200
+ muted: true,
201
+ style: {
202
+ width: '100%',
203
+ height: '100%',
204
+ objectFit: 'cover'
205
+ }
206
+ }, (fileUrl || (video === null || video === void 0 ? void 0 : video.videoSrc)) && /*#__PURE__*/_react.default.createElement("source", {
207
+ src: fileUrl || (video === null || video === void 0 ? void 0 : video.videoSrc)
208
+ })) : /*#__PURE__*/_react.default.createElement("div", {
209
+ style: {
210
+ width: '100%',
211
+ height: '100%',
212
+ backgroundImage: `url(${posterUrl})`,
213
+ backgroundSize: 'cover',
214
+ backgroundPosition: 'center',
215
+ display: 'flex',
216
+ alignItems: 'center',
217
+ justifyContent: 'center'
218
+ }
219
+ }, /*#__PURE__*/_react.default.createElement("i", {
220
+ className: youtubeId ? "fab fa-youtube" : "fas fa-play-circle",
221
+ style: {
222
+ color: 'white',
223
+ fontSize: '2.5rem',
224
+ opacity: 0.8
225
+ }
226
+ }))), /*#__PURE__*/_react.default.createElement(VideoName, {
227
+ style: {
228
+ marginTop: '8px',
229
+ fontSize: '14px',
230
+ height: '1.2em',
231
+ lineHeight: '1.2',
232
+ whiteSpace: 'nowrap',
233
+ overflow: 'hidden',
234
+ textOverflow: 'ellipsis',
235
+ color: isSelected ? '#007bff' : 'inherit'
236
+ }
237
+ }, (video === null || video === void 0 ? void 0 : video.name) || "Untitled"));
238
+ }
239
+
240
+ function VideoMetaGrids(props) {
241
+ const {
242
+ videoMetas,
243
+ onChange
244
+ } = props;
245
+ return /*#__PURE__*/_react.default.createElement(VideoMetaGridsWrapper, null, videoMetas.map(videoMeta => {
246
+ var _videoMeta$video;
247
+
248
+ return /*#__PURE__*/_react.default.createElement(VideoMetaGrid, {
249
+ key: videoMeta === null || videoMeta === void 0 ? void 0 : (_videoMeta$video = videoMeta.video) === null || _videoMeta$video === void 0 ? void 0 : _videoMeta$video.id,
250
+ videoMeta: videoMeta,
251
+ onChange: onChange
252
+ });
253
+ }));
254
+ }
255
+
256
+ function VideoMetaGrid(props) {
257
+ var _video$coverPhoto2, _video$coverPhoto2$re, _video$file2, _video$file3;
258
+
259
+ const {
260
+ videoMeta,
261
+ onChange
262
+ } = props;
263
+ const {
264
+ video,
265
+ desc
266
+ } = videoMeta;
267
+ const youtubeId = getYoutubeId(video === null || video === void 0 ? void 0 : video.videoSrc);
268
+ const posterUrl = (video === null || video === void 0 ? void 0 : (_video$coverPhoto2 = video.coverPhoto) === null || _video$coverPhoto2 === void 0 ? void 0 : (_video$coverPhoto2$re = _video$coverPhoto2.resized) === null || _video$coverPhoto2$re === void 0 ? void 0 : _video$coverPhoto2$re.original) || (youtubeId ? `https://img.youtube.com/vi/${youtubeId}/hqdefault.jpg` : "");
269
+
270
+ const onVideoDescriptionChange = e => {
271
+ onChange({
272
+ video,
273
+ desc: e.target.value
274
+ });
275
+ };
276
+
277
+ return /*#__PURE__*/_react.default.createElement(VideoMetaGridWrapper, null, youtubeId ? /*#__PURE__*/_react.default.createElement("iframe", {
278
+ width: "100%",
279
+ style: {
280
+ aspectRatio: '16/9',
281
+ border: 'none',
282
+ backgroundColor: '#000'
283
+ },
284
+ src: `https://www.youtube.com/embed/${youtubeId}?rel=0&autoplay=0`,
285
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
286
+ allowFullScreen: true,
287
+ loading: "lazy"
288
+ }) : /*#__PURE__*/_react.default.createElement(Video, {
289
+ muted: true,
290
+ autoPlay: true,
291
+ loop: true,
292
+ controls: true,
293
+ poster: posterUrl,
294
+ style: {
295
+ width: '100%',
296
+ aspectRatio: '16/9'
297
+ }
298
+ }, ((video === null || video === void 0 ? void 0 : video.videoSrc) || (video === null || video === void 0 ? void 0 : (_video$file2 = video.file) === null || _video$file2 === void 0 ? void 0 : _video$file2.url)) && /*#__PURE__*/_react.default.createElement("source", {
299
+ src: (video === null || video === void 0 ? void 0 : video.videoSrc) || (video === null || video === void 0 ? void 0 : (_video$file3 = video.file) === null || _video$file3 === void 0 ? void 0 : _video$file3.url)
300
+ })), /*#__PURE__*/_react.default.createElement(Label, null, "Video Name"), /*#__PURE__*/_react.default.createElement(VideoName, {
301
+ style: {
302
+ textAlign: 'left',
303
+ fontSize: '14px',
304
+ fontWeight: '500'
305
+ }
306
+ }, (video === null || video === void 0 ? void 0 : video.name) || 'Untitled'), /*#__PURE__*/_react.default.createElement(Label, {
307
+ htmlFor: "description"
308
+ }, "Video Description"), /*#__PURE__*/_react.default.createElement(_fields.TextInput, {
309
+ id: "description",
310
+ type: "text",
311
+ placeholder: "(Optional)",
312
+ defaultValue: desc,
313
+ onChange: _.debounce(onVideoDescriptionChange, 300)
314
+ }));
315
+ }
316
+
317
+ function VideoSelector(props) {
318
+ const [queryVideos, {
319
+ loading,
320
+ error,
321
+ data: {
322
+ videos = [],
323
+ videosCount = 0
324
+ } = {}
325
+ }] = (0, _apollo.useLazyQuery)(videosQuery, {
326
+ fetchPolicy: 'no-cache'
327
+ });
328
+ const [currentPage, setCurrentPage] = (0, _react.useState)(0); // page starts with 1, 0 is used to detect initialization
329
+
330
+ const [searchText, setSearchText] = (0, _react.useState)('');
331
+ const [selected, setSelected] = (0, _react.useState)([]);
332
+ const pageSize = 6;
333
+ const {
334
+ onChange
335
+ } = props;
336
+
337
+ const onSave = () => {
338
+ onChange(selected);
339
+ };
340
+
341
+ const onCancel = () => {
342
+ onChange([]);
343
+ };
344
+
345
+ const onSearchBoxChange = async searchInput => {
346
+ setSearchText(searchInput);
347
+ setCurrentPage(1);
348
+ };
349
+
350
+ const onVideoMetaChange = videoEntityWithMeta => {
351
+ setSelected([videoEntityWithMeta]);
352
+ };
353
+
354
+ const onVideosGridSelect = videoEntity => {
355
+ setSelected(selected => {
356
+ const filterdSelected = selected.filter(ele => {
357
+ var _ele$video;
358
+
359
+ return ((_ele$video = ele.video) === null || _ele$video === void 0 ? void 0 : _ele$video.id) !== videoEntity.id;
360
+ }); // deselect the video
361
+
362
+ if (filterdSelected.length !== selected.length) {
363
+ return filterdSelected;
364
+ } // single select
365
+
366
+
367
+ return [{
368
+ video: videoEntity,
369
+ desc: ''
370
+ }];
371
+ });
372
+ };
373
+
374
+ const selectedVideos = selected.map(ele => {
375
+ return ele.video;
376
+ });
377
+ (0, _react.useEffect)(() => {
378
+ if (currentPage !== 0) {
379
+ queryVideos({
380
+ variables: {
381
+ searchText: searchText,
382
+ skip: (currentPage - 1) * pageSize,
383
+ take: pageSize
384
+ }
385
+ });
386
+ }
387
+ }, [currentPage, searchText]);
388
+
389
+ let searchResult = /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(VideosGrids, {
390
+ videos: videos,
391
+ selected: selectedVideos,
392
+ onSelect: onVideosGridSelect
393
+ }), /*#__PURE__*/_react.default.createElement(_pagination.Pagination, {
394
+ currentPage: currentPage,
395
+ total: videosCount,
396
+ pageSize: pageSize,
397
+ onChange: pageIndex => {
398
+ setCurrentPage(pageIndex);
399
+ }
400
+ }));
401
+
402
+ if (loading) {
403
+ searchResult = /*#__PURE__*/_react.default.createElement("p", null, "searching...");
404
+ }
405
+
406
+ if (error) {
407
+ var _videosQuery$loc;
408
+
409
+ searchResult = /*#__PURE__*/_react.default.createElement(ErrorWrapper, null, /*#__PURE__*/_react.default.createElement("h3", null, "Errors occurs in the `videos` query"), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement("b", null, "Message:"), /*#__PURE__*/_react.default.createElement("div", null, error.message), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement("b", null, "Stack:"), /*#__PURE__*/_react.default.createElement("div", null, error.stack), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement("b", null, "Query:"), /*#__PURE__*/_react.default.createElement("pre", null, (_videosQuery$loc = videosQuery.loc) === null || _videosQuery$loc === void 0 ? void 0 : _videosQuery$loc.source.body)));
410
+ }
411
+
412
+ return /*#__PURE__*/_react.default.createElement(_modals.DrawerController, {
413
+ isOpen: true
414
+ }, /*#__PURE__*/_react.default.createElement(_modals.Drawer, {
415
+ title: "Select video",
416
+ actions: {
417
+ cancel: {
418
+ label: 'Cancel',
419
+ action: onCancel
420
+ },
421
+ confirm: {
422
+ label: 'Confirm',
423
+ action: onSave
424
+ }
425
+ }
426
+ }, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(VideoSearchBox, {
427
+ onChange: onSearchBoxChange
428
+ }), /*#__PURE__*/_react.default.createElement(VideoSelectionWrapper, null, /*#__PURE__*/_react.default.createElement("div", null, searchResult), !!selected.length && /*#__PURE__*/_react.default.createElement(SeparationLine, null), /*#__PURE__*/_react.default.createElement(VideoMetaGrids, {
429
+ videoMetas: selected,
430
+ onChange: onVideoMetaChange
431
+ })))));
432
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.defaultMarginTop = exports.defaultMarginBottom = void 0;
7
+
8
+ var _styledComponents = require("styled-components");
9
+
10
+ const defaultMarginTop = (0, _styledComponents.css)`
11
+ margin-top: 32px;
12
+ `;
13
+ exports.defaultMarginTop = defaultMarginTop;
14
+ const defaultMarginBottom = (0, _styledComponents.css)`
15
+ margin-bottom: 32px;
16
+ `;
17
+ exports.defaultMarginBottom = defaultMarginBottom;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.theme = exports.mediaSize = exports.default = void 0;
7
+ const mediaSize = {
8
+ xs: 0,
9
+ sm: 576,
10
+ md: 768,
11
+ lg: 960,
12
+ xl: 1200,
13
+ xxl: 1400
14
+ };
15
+ exports.mediaSize = mediaSize;
16
+ const theme = {
17
+ breakpoint: {
18
+ xs: `@media (min-width: ${mediaSize.xs}px)`,
19
+ sm: `@media (min-width: ${mediaSize.sm}px)`,
20
+ md: `@media (min-width: ${mediaSize.md}px)`,
21
+ lg: `@media (min-width: ${mediaSize.lg}px)`,
22
+ xl: `@media (min-width: ${mediaSize.xl}px)`,
23
+ xxl: `@media (min-width: ${mediaSize.xxl}px)`
24
+ }
25
+ };
26
+ exports.theme = theme;
27
+ var _default = theme;
28
+ exports.default = _default;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.convertBlobToString = convertBlobToString;
7
+ exports.convertFilesToImageData = convertFilesToImageData;
8
+ exports.convertStringToFile = convertStringToFile;
9
+
10
+ var _jsSha = require("js-sha256");
11
+
12
+ async function convertFilesToMediaData(fileList, isValidFile, wrapResult) {
13
+ const files = Array.from(fileList);
14
+ const fileNamePostfix = new Intl.DateTimeFormat('fr-CA', {
15
+ year: 'numeric',
16
+ month: '2-digit',
17
+ day: '2-digit'
18
+ }).format(Date.now());
19
+ const tasks = files.map(async file => {
20
+ if (!isValidFile(file)) return;
21
+ const uInt8Data = await file.arrayBuffer();
22
+ const name = file.name;
23
+ const positionOfLastDot = name.lastIndexOf('.');
24
+ const filename = positionOfLastDot > -1 ? `${name.slice(0, positionOfLastDot)}_${fileNamePostfix}${name.slice(positionOfLastDot)}` : `${name}_${fileNamePostfix}`;
25
+ return wrapResult({
26
+ uid: (0, _jsSha.sha256)(uInt8Data),
27
+ name: filename,
28
+ type: file.type,
29
+ blobURL: convertBlobToString(file)
30
+ });
31
+ });
32
+ const results = await Promise.allSettled(tasks);
33
+ return results.filter(r => r.status === 'fulfilled').map(r => r.value).filter(r => Boolean(r));
34
+ }
35
+
36
+ function isImageFile(file) {
37
+ return file.type.startsWith('image/');
38
+ }
39
+
40
+ async function convertFilesToImageData(fileList) {
41
+ return convertFilesToMediaData(fileList, isImageFile, ({
42
+ uid,
43
+ name,
44
+ type,
45
+ blobURL
46
+ }) => ({
47
+ uid,
48
+ name,
49
+ type,
50
+ blobURL
51
+ }));
52
+ }
53
+
54
+ function blobToFile(blob, fileName, extension) {
55
+ return new File([blob], fileName, {
56
+ type: extension
57
+ });
58
+ }
59
+
60
+ function convertBlobToString(blob) {
61
+ return URL.createObjectURL(blob);
62
+ }
63
+
64
+ async function convertStringToFile(str, fileName, extension) {
65
+ const request = new Request(str);
66
+ return await fetch(request).then(response => response.blob()).then(blob => blobToFile(blob, fileName, extension ?? blob.type));
67
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mirrormedia/lilith-draft-editor",
3
- "version": "3.0.12",
3
+ "version": "3.0.13",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -37,4 +37,4 @@
37
37
  "files": [
38
38
  "lib"
39
39
  ]
40
- }
40
+ }