@atlaskit/editor-plugin-block-controls 20.1.2 → 20.1.4

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 (32) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/pm-plugins/selection-preservation/pm-plugin.js +17 -34
  3. package/dist/cjs/ui/block-controls-left-surface.compiled.css +7 -1
  4. package/dist/cjs/ui/block-controls-left-surface.js +41 -27
  5. package/dist/cjs/ui/block-controls-left-surfaces.js +32 -12
  6. package/dist/cjs/ui/block-controls-right-surface.js +32 -24
  7. package/dist/cjs/ui/block-controls-right-surfaces.js +6 -4
  8. package/dist/cjs/ui/block-controls-surface-components.js +142 -0
  9. package/dist/cjs/ui/utils/get-surface-placement.js +63 -16
  10. package/dist/cjs/ui/visibility-container.js +42 -7
  11. package/dist/es2019/pm-plugins/selection-preservation/pm-plugin.js +17 -34
  12. package/dist/es2019/ui/block-controls-left-surface.compiled.css +7 -1
  13. package/dist/es2019/ui/block-controls-left-surface.js +44 -29
  14. package/dist/es2019/ui/block-controls-left-surfaces.js +41 -16
  15. package/dist/es2019/ui/block-controls-right-surface.js +35 -26
  16. package/dist/es2019/ui/block-controls-right-surfaces.js +6 -4
  17. package/dist/es2019/ui/block-controls-surface-components.js +129 -0
  18. package/dist/es2019/ui/utils/get-surface-placement.js +59 -7
  19. package/dist/es2019/ui/visibility-container.js +44 -6
  20. package/dist/esm/pm-plugins/selection-preservation/pm-plugin.js +17 -34
  21. package/dist/esm/ui/block-controls-left-surface.compiled.css +7 -1
  22. package/dist/esm/ui/block-controls-left-surface.js +43 -29
  23. package/dist/esm/ui/block-controls-left-surfaces.js +33 -13
  24. package/dist/esm/ui/block-controls-right-surface.js +34 -26
  25. package/dist/esm/ui/block-controls-right-surfaces.js +6 -4
  26. package/dist/esm/ui/block-controls-surface-components.js +133 -0
  27. package/dist/esm/ui/utils/get-surface-placement.js +62 -15
  28. package/dist/esm/ui/visibility-container.js +41 -6
  29. package/dist/types/ui/block-controls-surface-components.d.ts +13 -0
  30. package/dist/types/ui/utils/get-surface-placement.d.ts +13 -0
  31. package/dist/types/ui/visibility-container.d.ts +14 -0
  32. package/package.json +3 -3
@@ -46,13 +46,16 @@ var hiddenStylesCSS = css({
46
46
  var displayContentsStylesCSS = css({
47
47
  display: 'contents'
48
48
  });
49
- export var VisibilityContainer = function VisibilityContainer(_ref) {
49
+
50
+ /**
51
+ * Resolves visibility once so a surface can apply the same state to each rendered control without
52
+ * creating a plugin-state subscription and hide-delay timer for every control wrapper.
53
+ */
54
+ export var useBlockControlsVisibility = function useBlockControlsVisibility(_ref) {
50
55
  var api = _ref.api,
51
- children = _ref.children,
52
56
  controlSide = _ref.controlSide,
53
57
  forceVisibleOnMouseOut = _ref.forceVisibleOnMouseOut,
54
- isPersistent = _ref.isPersistent,
55
- shouldUseDisplayContents = _ref.shouldUseDisplayContents;
58
+ isPersistent = _ref.isPersistent;
56
59
  var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['typeAhead', 'blockControls', 'editorViewMode', 'userIntent', 'showDiff'], function (states) {
57
60
  var _states$typeAheadStat, _states$blockControls, _states$blockControls2, _states$blockControls3, _states$editorViewMod, _states$userIntentSta, _states$showDiffState, _states$blockControls4;
58
61
  return {
@@ -128,9 +131,20 @@ export var VisibilityContainer = function VisibilityContainer(_ref) {
128
131
  };
129
132
  }, [shouldHideImmediate, isRightControlViewMode]);
130
133
  var shouldHide = isRightControlViewMode ? delayedShouldHide : shouldHideImmediate;
131
- if (editorExperiment('platform_editor_preview_panel_responsiveness', true, {
134
+ var useCssStyles = editorExperiment('platform_editor_preview_panel_responsiveness', true, {
132
135
  exposure: true
133
- })) {
136
+ });
137
+ return {
138
+ shouldHide: shouldHide,
139
+ useCssStyles: useCssStyles
140
+ };
141
+ };
142
+ export var VisibilityWrapper = function VisibilityWrapper(_ref2) {
143
+ var children = _ref2.children,
144
+ shouldHide = _ref2.shouldHide,
145
+ shouldUseDisplayContents = _ref2.shouldUseDisplayContents,
146
+ useCssStyles = _ref2.useCssStyles;
147
+ if (useCssStyles) {
134
148
  return jsx("div", {
135
149
  css: [baseStylesCSS, shouldHide ? hiddenStylesCSS : visibleStylesCSS, shouldUseDisplayContents && displayContentsStylesCSS]
136
150
  }, children);
@@ -140,4 +154,25 @@ export var VisibilityContainer = function VisibilityContainer(_ref) {
140
154
  , {
141
155
  xcss: [baseStyles, shouldHide ? hiddenStyles : visibleStyles, shouldUseDisplayContents && displayContentsStyles]
142
156
  }, children);
157
+ };
158
+ export var VisibilityContainer = function VisibilityContainer(_ref3) {
159
+ var api = _ref3.api,
160
+ children = _ref3.children,
161
+ controlSide = _ref3.controlSide,
162
+ forceVisibleOnMouseOut = _ref3.forceVisibleOnMouseOut,
163
+ isPersistent = _ref3.isPersistent,
164
+ shouldUseDisplayContents = _ref3.shouldUseDisplayContents;
165
+ var _useBlockControlsVisi = useBlockControlsVisibility({
166
+ api: api,
167
+ controlSide: controlSide,
168
+ forceVisibleOnMouseOut: forceVisibleOnMouseOut,
169
+ isPersistent: isPersistent
170
+ }),
171
+ shouldHide = _useBlockControlsVisi.shouldHide,
172
+ useCssStyles = _useBlockControlsVisi.useCssStyles;
173
+ return jsx(VisibilityWrapper, {
174
+ shouldHide: shouldHide,
175
+ shouldUseDisplayContents: shouldUseDisplayContents,
176
+ useCssStyles: useCssStyles
177
+ }, children);
143
178
  };
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { RegisterComponent, SurfaceContext } from '@atlaskit/editor-ui-control-model/types';
3
+ type BlockControlsVisibility = {
4
+ shouldHideHoverControls: boolean;
5
+ useCssStyles: boolean;
6
+ };
7
+ type BlockControlsVisibilityProviderProps = BlockControlsVisibility & {
8
+ children: React.ReactNode;
9
+ };
10
+ export declare const BlockControlsVisibilityProvider: ({ children, shouldHideHoverControls, useCssStyles, }: BlockControlsVisibilityProviderProps) => React.JSX.Element;
11
+ export declare const getBlockControlsLeftSurfaceComponents: (components: RegisterComponent[], surfaceContext: SurfaceContext) => RegisterComponent[] | undefined;
12
+ export declare const getBlockControlsRightSurfaceComponents: (components: RegisterComponent[], surfaceContext: SurfaceContext) => RegisterComponent[] | undefined;
13
+ export {};
@@ -10,6 +10,7 @@ export type SurfacePlacement = {
10
10
  left: number;
11
11
  top: number;
12
12
  transform: string;
13
+ width?: number;
13
14
  };
14
15
  export type SurfaceSide = 'left' | 'right';
15
16
  export type SurfacePlacementOptions = {
@@ -37,6 +38,13 @@ export declare const getAbsoluteSurfacePlacement: ({ offsetParentRect, offsetPar
37
38
  * can be folded straight into `left` with no transform needed.
38
39
  */
39
40
  export declare const getSurfacePlacement: ({ layout, nodeRect, nodeType, nodeTypeWithLevel, parentNodeType, side, }: SurfacePlacementOptions) => SurfacePlacement;
41
+ export type LeftGutterSurfacePlacementOptions = Omit<SurfacePlacementOptions, 'side'> & {
42
+ leftGutterBoundary: number;
43
+ };
44
+ /**
45
+ * Expands a measured left surface from the available gutter boundary to the target node.
46
+ */
47
+ export declare const getLeftGutterSurfacePlacement: ({ leftGutterBoundary, ...options }: LeftGutterSurfacePlacementOptions) => SurfacePlacement;
40
48
  /**
41
49
  * The insets to apply to a surface wrapper, plus whether that wrapper spans its target node.
42
50
  *
@@ -67,3 +75,8 @@ export type AnchoredSurfacePlacementOptions = {
67
75
  side: SurfaceSide;
68
76
  };
69
77
  export declare const getAnchoredSurfacePlacement: ({ anchorName, layout, nodeType, nodeTypeWithLevel, parentNodeType, side, }: AnchoredSurfacePlacementOptions) => SurfaceWrapperPlacement;
78
+ export type AnchoredLeftGutterSurfacePlacementOptions = Omit<AnchoredSurfacePlacementOptions, 'side'>;
79
+ /**
80
+ * Expands an anchored left surface across the available gutter without runtime measurement.
81
+ */
82
+ export declare const getAnchoredLeftGutterSurfacePlacement: (options: AnchoredLeftGutterSurfacePlacementOptions) => SurfaceWrapperPlacement;
@@ -17,5 +17,19 @@ interface VisibilityContainerProps {
17
17
  */
18
18
  shouldUseDisplayContents?: boolean;
19
19
  }
20
+ type VisibilityWrapperProps = Pick<VisibilityContainerProps, 'children' | 'shouldUseDisplayContents'> & {
21
+ shouldHide: boolean;
22
+ useCssStyles: boolean;
23
+ };
24
+ type BlockControlsVisibilityOptions = Omit<VisibilityContainerProps, 'children' | 'shouldUseDisplayContents'>;
25
+ /**
26
+ * Resolves visibility once so a surface can apply the same state to each rendered control without
27
+ * creating a plugin-state subscription and hide-delay timer for every control wrapper.
28
+ */
29
+ export declare const useBlockControlsVisibility: ({ api, controlSide, forceVisibleOnMouseOut, isPersistent, }: BlockControlsVisibilityOptions) => {
30
+ shouldHide: boolean;
31
+ useCssStyles: boolean;
32
+ };
33
+ export declare const VisibilityWrapper: ({ children, shouldHide, shouldUseDisplayContents, useCssStyles, }: VisibilityWrapperProps) => jsx.JSX.Element;
20
34
  export declare const VisibilityContainer: ({ api, children, controlSide, forceVisibleOnMouseOut, isPersistent, shouldUseDisplayContents, }: VisibilityContainerProps) => jsx.JSX.Element;
21
35
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "20.1.2",
3
+ "version": "20.1.4",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -61,7 +61,7 @@
61
61
  "@atlaskit/primitives": "^22.5.0",
62
62
  "@atlaskit/section-message": "^10.2.0",
63
63
  "@atlaskit/theme": "^28.2.0",
64
- "@atlaskit/tmp-editor-statsig": "^202.0.0",
64
+ "@atlaskit/tmp-editor-statsig": "^204.0.0",
65
65
  "@atlaskit/tokens": "^19.0.0",
66
66
  "@atlaskit/tooltip": "^24.3.0",
67
67
  "@babel/runtime": "^7.0.0",
@@ -73,7 +73,7 @@
73
73
  "uuid": "^11.1.1"
74
74
  },
75
75
  "peerDependencies": {
76
- "@atlaskit/editor-common": "^123.7.0",
76
+ "@atlaskit/editor-common": "^123.8.0",
77
77
  "react": "^18.2.0 || ^19.2.0",
78
78
  "react-dom": "^18.2.0 || ^19.2.0",
79
79
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"