@atlaskit/editor-plugin-media 20.0.3 → 20.1.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/CHANGELOG.md +20 -0
- package/dist/cjs/nodeviews/mediaNodeView/media.js +145 -32
- package/dist/cjs/ui/GeneratedMediaReveal.compiled.css +12 -0
- package/dist/cjs/ui/GeneratedMediaReveal.js +124 -0
- package/dist/es2019/nodeviews/mediaNodeView/media.js +107 -7
- package/dist/es2019/ui/GeneratedMediaReveal.compiled.css +12 -0
- package/dist/es2019/ui/GeneratedMediaReveal.js +101 -0
- package/dist/esm/nodeviews/mediaNodeView/media.js +144 -31
- package/dist/esm/ui/GeneratedMediaReveal.compiled.css +12 -0
- package/dist/esm/ui/GeneratedMediaReveal.js +116 -0
- package/dist/types/nodeviews/mediaNodeView/media.d.ts +21 -0
- package/dist/types/types/index.d.ts +9 -0
- package/dist/types/ui/GeneratedMediaReveal.d.ts +25 -0
- package/package.json +9 -3
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/* GeneratedMediaReveal.tsx generated by @compiled/babel-plugin v3.0.1 */
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import "./GeneratedMediaReveal.compiled.css";
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Only `collapsed` and `revealing` size and clip the content. `open` drops back to plain
|
|
9
|
+
* block layout, so the reveal leaves nothing behind for selection outlines, resize handles
|
|
10
|
+
* or badges to collide with.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Which path opened the node. Surfaced as a data attribute for debugging. */
|
|
14
|
+
|
|
15
|
+
// A `0fr -> 1fr` grid row opens out to the content's natural height without anyone having to
|
|
16
|
+
// measure it, which matters because the card's height comes from an aspect-ratio padding
|
|
17
|
+
// further down the tree.
|
|
18
|
+
var openRow = null;
|
|
19
|
+
var collapsedStyles = null;
|
|
20
|
+
var revealStyles = null;
|
|
21
|
+
var clippedStyles = null;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Fail-safe, not a normal path: opens the node even if the preview never reports itself
|
|
25
|
+
* rendered, so a failed or hanging image still ends up visible rather than staying collapsed.
|
|
26
|
+
* Also covers lazy loading, where a card collapsed to zero height may never satisfy the
|
|
27
|
+
* IntersectionObserver that triggers its fetch.
|
|
28
|
+
*
|
|
29
|
+
* Deliberately generous, because opening early is worse than opening late — the space then
|
|
30
|
+
* reveals the card's own loading treatment instead of the image, and an AI-generated image has
|
|
31
|
+
* to be generated, uploaded, processed and fetched first. `data-media-reveal-trigger` shows
|
|
32
|
+
* which path fired; `timeout` in normal use means the readiness signal is broken.
|
|
33
|
+
*/
|
|
34
|
+
var READY_TIMEOUT_MS = 30000;
|
|
35
|
+
|
|
36
|
+
// Backstop for reduced motion and browsers that don't interpolate grid-template-rows, where no
|
|
37
|
+
// animationend fires. Must stay comfortably longer than the reveal, or it cuts it off part way.
|
|
38
|
+
var REVEAL_TIMEOUT_MS = 1000;
|
|
39
|
+
/**
|
|
40
|
+
* Opens the document out to make room for a media node once its preview is ready, rather than
|
|
41
|
+
* having the node snap into place at full height. For AI-generated media in the Create with
|
|
42
|
+
* Rovo preview, where images are inserted after the surrounding content has streamed in:
|
|
43
|
+
* holding the node closed until the preview has rendered means the space opens exactly once,
|
|
44
|
+
* with the image already fading in, so there is no placeholder to look at in between.
|
|
45
|
+
*/
|
|
46
|
+
export var GeneratedMediaReveal = function GeneratedMediaReveal(_ref) {
|
|
47
|
+
var children = _ref.children,
|
|
48
|
+
isEnabled = _ref.isEnabled,
|
|
49
|
+
isReady = _ref.isReady,
|
|
50
|
+
mediaKey = _ref.mediaKey;
|
|
51
|
+
var _useState = useState('collapsed'),
|
|
52
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
53
|
+
state = _useState2[0],
|
|
54
|
+
setState = _useState2[1];
|
|
55
|
+
var _useState3 = useState(),
|
|
56
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
57
|
+
trigger = _useState4[0],
|
|
58
|
+
setTrigger = _useState4[1];
|
|
59
|
+
|
|
60
|
+
// Reset during render rather than remounting on a `key`, which would also remount the card
|
|
61
|
+
// below and restart its fetch. The reveal's effect only runs while `collapsed`, so without
|
|
62
|
+
// this a replacement would appear at once, having inherited the previous file's `open`.
|
|
63
|
+
var _useState5 = useState(mediaKey),
|
|
64
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
65
|
+
renderedMediaKey = _useState6[0],
|
|
66
|
+
setRenderedMediaKey = _useState6[1];
|
|
67
|
+
if (mediaKey !== renderedMediaKey) {
|
|
68
|
+
setRenderedMediaKey(mediaKey);
|
|
69
|
+
setState('collapsed');
|
|
70
|
+
setTrigger(undefined);
|
|
71
|
+
}
|
|
72
|
+
useEffect(function () {
|
|
73
|
+
if (!isEnabled || state !== 'collapsed') {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (isReady) {
|
|
77
|
+
setTrigger('ready');
|
|
78
|
+
setState('revealing');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
var timer = setTimeout(function () {
|
|
82
|
+
setTrigger('timeout');
|
|
83
|
+
setState('revealing');
|
|
84
|
+
}, READY_TIMEOUT_MS);
|
|
85
|
+
return function () {
|
|
86
|
+
return clearTimeout(timer);
|
|
87
|
+
};
|
|
88
|
+
}, [isEnabled, isReady, state]);
|
|
89
|
+
useEffect(function () {
|
|
90
|
+
if (state !== 'revealing') {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
var timer = setTimeout(function () {
|
|
94
|
+
return setState('open');
|
|
95
|
+
}, REVEAL_TIMEOUT_MS);
|
|
96
|
+
return function () {
|
|
97
|
+
return clearTimeout(timer);
|
|
98
|
+
};
|
|
99
|
+
}, [state]);
|
|
100
|
+
if (!isEnabled) {
|
|
101
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
102
|
+
}
|
|
103
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
104
|
+
"data-media-reveal": state,
|
|
105
|
+
"data-media-reveal-trigger": trigger,
|
|
106
|
+
onAnimationEnd: function onAnimationEnd(event) {
|
|
107
|
+
// The media card runs animations of its own, which bubble through here.
|
|
108
|
+
if (event.target === event.currentTarget) {
|
|
109
|
+
setState('open');
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
className: ax([state === 'collapsed' && "_1e0c11p5 _2z0563bf", state === 'revealing' && "", state === 'revealing' && "_1e0c11p5 _2z05hkll _j7hq8gkt _5sag15uc _1pglindk _1o51eoah _1bumglyw"])
|
|
113
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
114
|
+
className: ax([state !== 'open' && "_1reo15vq _18m915vq _1tkeidpf"])
|
|
115
|
+
}, children));
|
|
116
|
+
};
|
|
@@ -32,6 +32,13 @@ export interface MediaNodeProps extends ReactNodeProps, ImageLoaderProps {
|
|
|
32
32
|
}
|
|
33
33
|
interface MediaNodeState {
|
|
34
34
|
contextIdentifierProvider?: ContextIdentifierProvider;
|
|
35
|
+
/** File the card reported a terminal error for. Keyed by id, as `previewRenderedFileId`. */
|
|
36
|
+
failedFileId?: string;
|
|
37
|
+
/**
|
|
38
|
+
* File the card last reported a rendered preview for. Keyed by id rather than a boolean,
|
|
39
|
+
* because the node's media can be replaced without remounting this component.
|
|
40
|
+
*/
|
|
41
|
+
previewRenderedFileId?: string;
|
|
35
42
|
viewAndUploadMediaClientConfig?: MediaClientConfig;
|
|
36
43
|
viewMediaClientConfig?: MediaClientConfig;
|
|
37
44
|
}
|
|
@@ -54,6 +61,20 @@ export declare class MediaNode extends Component<MediaNodeProps, MediaNodeState>
|
|
|
54
61
|
private selectMediaSingleFromCard;
|
|
55
62
|
private selectMediaSingle;
|
|
56
63
|
private getMediaSettings;
|
|
64
|
+
/**
|
|
65
|
+
* Surface opt-in first, so surfaces that never ask for the motion are not exposed to the
|
|
66
|
+
* gate. The node type is checked after it, so every node on an opted-in surface counts
|
|
67
|
+
* towards the same exposure population.
|
|
68
|
+
*/
|
|
69
|
+
private get hasGeneratedMediaMotion();
|
|
70
|
+
/**
|
|
71
|
+
* Media written straight into the document arrives without intrinsic dimensions, and the
|
|
72
|
+
* fetch that would supply them resolves `false` while the file is still processing. Only
|
|
73
|
+
* editor-driven uploads get a second attempt, from the plugin's media-state listener, so
|
|
74
|
+
* otherwise the card would keep its placeholder ratio forever. The preview rendering is the
|
|
75
|
+
* one moment the file is guaranteed ready, so the fetch is retried there.
|
|
76
|
+
*/
|
|
77
|
+
private fetchMissingDimensions;
|
|
57
78
|
private onPreviewRender;
|
|
58
79
|
private onError;
|
|
59
80
|
private onRemixRenderError;
|
|
@@ -34,6 +34,15 @@ export type MediaRenderEvent = {
|
|
|
34
34
|
export interface MediaPluginOptions {
|
|
35
35
|
alignLeftOnInsert?: boolean;
|
|
36
36
|
allowAdvancedToolBarOptions?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Animates media nodes into the document: the content opens out to make room for the node
|
|
39
|
+
* once its preview is ready, then the preview fades in. For surfaces where media arrives
|
|
40
|
+
* mid-flight, e.g. AI-generated images inserted into the Create with Rovo preview after the
|
|
41
|
+
* surrounding content has streamed in.
|
|
42
|
+
*
|
|
43
|
+
* Also behind `aifc_page_create_defer_generated_visuals`.
|
|
44
|
+
*/
|
|
45
|
+
allowAIGeneratedMediaMotion?: boolean;
|
|
37
46
|
allowAltTextOnImages?: boolean;
|
|
38
47
|
allowBreakoutSnapPoints?: boolean;
|
|
39
48
|
allowCaptions?: boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
type GeneratedMediaRevealProps = {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
isEnabled: boolean;
|
|
9
|
+
/** The node is held closed until this is true, so the wait happens before the document moves. */
|
|
10
|
+
isReady: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Identity of the media being revealed. Changing it restarts the reveal, so media replaced
|
|
13
|
+
* in place waits for its own preview instead of inheriting the previous file's open state.
|
|
14
|
+
*/
|
|
15
|
+
mediaKey?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Opens the document out to make room for a media node once its preview is ready, rather than
|
|
19
|
+
* having the node snap into place at full height. For AI-generated media in the Create with
|
|
20
|
+
* Rovo preview, where images are inserted after the surrounding content has streamed in:
|
|
21
|
+
* holding the node closed until the preview has rendered means the space opens exactly once,
|
|
22
|
+
* with the image already fading in, so there is no placeholder to look at in between.
|
|
23
|
+
*/
|
|
24
|
+
export declare const GeneratedMediaReveal: ({ children, isEnabled, isReady, mediaKey, }: GeneratedMediaRevealProps) => React.JSX.Element;
|
|
25
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "20.0
|
|
3
|
+
"version": "20.1.0",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"@atlaskit/analytics-namespaced-context": "^8.2.0",
|
|
26
26
|
"@atlaskit/analytics-next": "^12.5.0",
|
|
27
27
|
"@atlaskit/button": "^25.3.0",
|
|
28
|
+
"@atlaskit/css": "^1.1.0",
|
|
28
29
|
"@atlaskit/editor-palette": "^3.5.0",
|
|
29
30
|
"@atlaskit/editor-plugin-analytics": "^18.0.0",
|
|
30
31
|
"@atlaskit/editor-plugin-annotation": "^18.0.0",
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
"@atlaskit/form": "^17.2.0",
|
|
49
50
|
"@atlaskit/icon": "^37.6.0",
|
|
50
51
|
"@atlaskit/icon-lab": "^7.8.0",
|
|
51
|
-
"@atlaskit/media-card": "^81.
|
|
52
|
+
"@atlaskit/media-card": "^81.11.0",
|
|
52
53
|
"@atlaskit/media-client": "^38.1.0",
|
|
53
54
|
"@atlaskit/media-client-react": "^6.4.0",
|
|
54
55
|
"@atlaskit/media-common": "^14.6.0",
|
|
@@ -60,10 +61,11 @@
|
|
|
60
61
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
61
62
|
"@atlaskit/primitives": "^22.5.0",
|
|
62
63
|
"@atlaskit/textfield": "^10.2.0",
|
|
63
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
64
|
+
"@atlaskit/tmp-editor-statsig": "^192.0.0",
|
|
64
65
|
"@atlaskit/tokens": "^16.12.0",
|
|
65
66
|
"@atlaskit/tooltip": "^24.3.0",
|
|
66
67
|
"@babel/runtime": "^7.0.0",
|
|
68
|
+
"@compiled/react": "^1.0.2",
|
|
67
69
|
"@emotion/react": "^11.7.1",
|
|
68
70
|
"bind-event-listener": "^3.0.0",
|
|
69
71
|
"classnames": "^2.2.5",
|
|
@@ -112,6 +114,10 @@
|
|
|
112
114
|
"platform_editor_media_border_radius_fix": {
|
|
113
115
|
"type": "boolean"
|
|
114
116
|
},
|
|
117
|
+
"aifc_page_create_defer_generated_visuals": {
|
|
118
|
+
"type": "boolean",
|
|
119
|
+
"referenceOnly": true
|
|
120
|
+
},
|
|
115
121
|
"cc-maui-phase-2": {
|
|
116
122
|
"type": "boolean"
|
|
117
123
|
},
|