@atlaskit/editor-plugin-media 1.29.8 → 1.30.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.
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
+ * @jsxFrag
4
5
  */
5
6
  import type { MouseEvent } from 'react';
6
7
  import React, { Component } from 'react';
@@ -34,7 +35,6 @@ export default class MediaSingleNode extends Component<MediaSingleNodeProps, Med
34
35
  state: MediaSingleNodeState;
35
36
  mediaSingleWrapperRef: React.RefObject<HTMLDivElement>;
36
37
  captionPlaceHolderRef: React.RefObject<HTMLSpanElement>;
37
- commentBadgeRef: React.RefObject<HTMLDivElement>;
38
38
  createOrUpdateMediaNodeUpdater: (props: MediaSingleNodeProps) => void;
39
39
  UNSAFE_componentWillReceiveProps(nextProps: MediaSingleNodeProps): void;
40
40
  setViewMediaClientConfig: (props: MediaSingleNodeProps) => Promise<void>;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { IntlShape } from 'react-intl-next';
3
+ import type { AnnotationMarkDefinition } from '@atlaskit/adf-schema';
3
4
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
5
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
@@ -18,5 +19,20 @@ type CommentBadgeProps = {
18
19
  export declare const CommentBadge: React.FC<import("react-intl-next").WithIntlProps<CommentBadgeProps>> & {
19
20
  WrappedComponent: React.ComponentType<CommentBadgeProps>;
20
21
  };
21
- export declare const CommentBadgeWithRef: React.ForwardRefExoticComponent<Omit<CommentBadgeProps, "intl"> & React.RefAttributes<HTMLDivElement>>;
22
+ /**
23
+ * Remove CommentBadgeWrapper component above
24
+ * and rename CommentBadgeNextWrapper to CommentBadgeWrapper
25
+ * when clean up platform_editor_insert_media_plugin_phase_one feature flag
26
+ */
27
+ type CommentBadgeNextWrapperProps = {
28
+ mediaSingleElement?: HTMLElement | null;
29
+ marks?: AnnotationMarkDefinition[];
30
+ isDrafting?: boolean;
31
+ api: ExtractInjectionAPI<MediaNextEditorPluginType>;
32
+ mediaNode: PMNode | null;
33
+ view: EditorView;
34
+ getPos: getPosHandler;
35
+ badgeSize: 'small' | 'medium';
36
+ };
37
+ export declare const CommentBadgeNextWrapper: ({ api, mediaNode, view, getPos, isDrafting, badgeSize, }: CommentBadgeNextWrapperProps) => JSX.Element | null;
22
38
  export {};
@@ -0,0 +1,54 @@
1
+ import { type MediaAttributes } from '@atlaskit/adf-schema';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ type MediaId = string;
4
+ type Props = {
5
+ id: MediaId;
6
+ nextAttributes: Partial<MediaAttributes>;
7
+ };
8
+ export type MediaAttributesMap = Record<MediaId, Partial<MediaAttributes>>;
9
+ type MediaAttributesCachePerView = MediaAttributesMap;
10
+ export type MediaAttributesCache = WeakMap<EditorView, MediaAttributesCachePerView>;
11
+ export declare const containsSameAttributes: (a: MediaAttributes, b: Partial<MediaAttributes>) => boolean;
12
+ /**
13
+ * Updates media node attributes in the editor view based on the provided cache.
14
+ *
15
+ * @param {EditorView} editorView - The editor view instance where the updates will be applied.
16
+ * @param {MediaAttributesCache} cache - The cache containing media attributes to be updated.
17
+ *
18
+ * This function performs the following steps:
19
+ * 1. Retrieves the media attributes to update from the cache for the given editor view.
20
+ * 2. Clears the media attributes cache for the editor view.
21
+ * 3. Searches for media nodes in the document and collects their positions and new attributes.
22
+ * 4. If there are any media nodes to update, it applies the updates in a batch.
23
+ */
24
+ export declare const runUpdate: (editorView: EditorView, cache: MediaAttributesCache) => void;
25
+ /**
26
+ * Creates a debounced version of the `runUpdate` function to update media node attributes in the editor view.
27
+ *
28
+ * @constant
29
+ * @type {Function}
30
+ * @param {Function} runUpdate - The function to be debounced.
31
+ * @param {number} debouncedTime - The debounce delay in milliseconds.
32
+ * @param {Object} [options] - The debounce options. Defaults to {leading: false, trailing: true}.
33
+ * @param {Function} keyResolver - A function that returns the key to be used for memoization. In this case, it returns the editor view instance.
34
+ *
35
+ * This function performs the following steps:
36
+ * 1. Debounces the `runUpdate` function with the specified delay and options.
37
+ * 2. Uses the editor view instance as the key for memoization to ensure that updates are applied correctly.
38
+ */
39
+ export declare const runUpdateDebounced: (editorView: EditorView, cache: MediaAttributesCache) => void | undefined;
40
+ /**
41
+ * Updates the media node attributes cache for the given editor view and triggers a debounced update.
42
+ *
43
+ * @param {EditorView} editorView - The editor view instance where the updates will be applied.
44
+ * @param {Props} props - The properties containing the media node ID and the next attributes to be updated.
45
+ *
46
+ * This function performs the following steps:
47
+ * 1. Retrieves the media attributes cache for the given editor view.
48
+ * 2. If no cache exists, initializes a new cache.
49
+ * 3. Updates the cache with the new attributes for the specified media node ID.
50
+ * 4. Sets the updated cache back to the media attributes cache.
51
+ * 5. Triggers a debounced update to apply the changes in the editor view.
52
+ */
53
+ export declare const batchMediaNodeAttrsUpdate: (editorView: EditorView, props: Props) => void;
54
+ export {};
@@ -0,0 +1,19 @@
1
+ import { type BatchAttrsStepData } from '@atlaskit/adf-schema/steps';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ /**
4
+ * Applies a batch of attribute update steps to media nodes in the editor view.
5
+ *
6
+ * @param {EditorView} editorView - The editor view instance where the updates will be applied.
7
+ * @param {BatchAttrsStepData[]} steps - An array of steps containing the positions and new attributes for media nodes.
8
+ * @returns {boolean} - Returns false if no steps were applied or if the document remains unchanged after applying the steps.
9
+ *
10
+ * This function performs the following steps:
11
+ * 1. Creates a new transaction from the current editor state.
12
+ * 2. If there are no steps to apply, it returns false.
13
+ * 3. Adds a new `BatchAttrsStep` to the transaction with the provided steps.
14
+ * 4. If the transaction has no steps or the document remains unchanged, it returns false.
15
+ * 5. Dispatches the transaction to apply the updates to the editor view.
16
+ *
17
+ * TODO: use pluginInjectionAPI to batch updates from a command in a separate PR later
18
+ */
19
+ export declare const batchStepsUpdate: (editorView: EditorView, steps: BatchAttrsStepData[]) => false | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "1.29.8",
3
+ "version": "1.30.0",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -9,9 +9,8 @@
9
9
  },
10
10
  "atlassian": {
11
11
  "team": "Editor: Media Experience Porygon",
12
- "releaseModel": "continuous",
13
12
  "singleton": true,
14
- "runReact18": false
13
+ "runReact18": true
15
14
  },
16
15
  "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
17
16
  "main": "dist/cjs/index.js",
@@ -34,17 +33,17 @@
34
33
  },
35
34
  "dependencies": {
36
35
  "@atlaskit/adf-schema": "^40.9.0",
37
- "@atlaskit/analytics-namespaced-context": "^6.11.0",
36
+ "@atlaskit/analytics-namespaced-context": "^6.12.0",
38
37
  "@atlaskit/analytics-next": "^10.1.0",
39
38
  "@atlaskit/button": "^20.1.0",
40
- "@atlaskit/editor-common": "^88.3.0",
39
+ "@atlaskit/editor-common": "^88.12.0",
41
40
  "@atlaskit/editor-palette": "1.6.0",
42
41
  "@atlaskit/editor-plugin-analytics": "^1.8.0",
43
- "@atlaskit/editor-plugin-annotation": "1.19.3",
42
+ "@atlaskit/editor-plugin-annotation": "1.19.4",
44
43
  "@atlaskit/editor-plugin-decorations": "^1.3.0",
45
44
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
46
45
  "@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
47
- "@atlaskit/editor-plugin-floating-toolbar": "^1.11.0",
46
+ "@atlaskit/editor-plugin-floating-toolbar": "^1.12.0",
48
47
  "@atlaskit/editor-plugin-focus": "^1.3.0",
49
48
  "@atlaskit/editor-plugin-grid": "^1.2.0",
50
49
  "@atlaskit/editor-plugin-guideline": "^1.2.0",
@@ -54,17 +53,17 @@
54
53
  "@atlaskit/editor-shared-styles": "^2.13.0",
55
54
  "@atlaskit/editor-tables": "^2.8.0",
56
55
  "@atlaskit/form": "^10.5.0",
57
- "@atlaskit/icon": "^22.15.0",
58
- "@atlaskit/media-card": "^78.1.0",
59
- "@atlaskit/media-client": "^27.5.0",
60
- "@atlaskit/media-client-react": "^2.1.0",
56
+ "@atlaskit/icon": "^22.16.0",
57
+ "@atlaskit/media-card": "^78.2.0",
58
+ "@atlaskit/media-client": "^27.6.0",
59
+ "@atlaskit/media-client-react": "^2.2.0",
61
60
  "@atlaskit/media-common": "^11.4.0",
62
61
  "@atlaskit/media-filmstrip": "^47.2.0",
63
62
  "@atlaskit/media-picker": "^66.5.0",
64
63
  "@atlaskit/media-ui": "^25.11.0",
65
64
  "@atlaskit/media-viewer": "^48.7.0",
66
65
  "@atlaskit/platform-feature-flags": "^0.3.0",
67
- "@atlaskit/primitives": "^12.0.0",
66
+ "@atlaskit/primitives": "^12.1.0",
68
67
  "@atlaskit/textfield": "^6.5.0",
69
68
  "@atlaskit/theme": "^13.0.0",
70
69
  "@atlaskit/tokens": "^1.59.0",
@@ -83,8 +82,8 @@
83
82
  },
84
83
  "peerDependencies": {
85
84
  "@atlaskit/media-core": "^34.3.0",
86
- "react": "^16.8.0",
87
- "react-dom": "^16.8.0",
85
+ "react": "^16.8.0 || ^17.0.0 || ~18.2.0",
86
+ "react-dom": "^16.8.0 || ^17.0.0 || ~18.2.0",
88
87
  "react-intl-next": "npm:react-intl@^5.18.1"
89
88
  },
90
89
  "techstack": {
@@ -149,6 +148,9 @@
149
148
  },
150
149
  "platform_editor_insert_media_plugin_phase_one": {
151
150
  "type": "boolean"
151
+ },
152
+ "platform_editor_media_batch_updates": {
153
+ "type": "boolean"
152
154
  }
153
155
  },
154
156
  "stricter": {