@atlaskit/editor-plugin-block-controls 17.0.1 → 17.1.1
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 +21 -0
- package/dist/cjs/blockControlsPlugin.js +23 -4
- package/dist/cjs/pm-plugins/decorations-drag-handle.js +5 -22
- package/dist/cjs/pm-plugins/decorations-quick-insert-button.js +2 -6
- package/dist/cjs/ui/block-controls-surface-context.js +60 -0
- package/dist/cjs/ui/block-controls-surface.compiled.css +3 -0
- package/dist/cjs/ui/block-controls-surface.js +160 -0
- package/dist/cjs/ui/quick-insert-button.js +9 -0
- package/dist/cjs/ui/utils/get-node-content-element.js +24 -0
- package/dist/cjs/ui/utils/get-surface-placement.js +39 -0
- package/dist/es2019/blockControlsPlugin.js +28 -4
- package/dist/es2019/pm-plugins/decorations-drag-handle.js +5 -22
- package/dist/es2019/pm-plugins/decorations-quick-insert-button.js +2 -6
- package/dist/es2019/ui/block-controls-surface-context.js +51 -0
- package/dist/es2019/ui/block-controls-surface.compiled.css +3 -0
- package/dist/es2019/ui/block-controls-surface.js +144 -0
- package/dist/es2019/ui/quick-insert-button.js +9 -0
- package/dist/es2019/ui/utils/get-node-content-element.js +18 -0
- package/dist/es2019/ui/utils/get-surface-placement.js +30 -0
- package/dist/esm/blockControlsPlugin.js +23 -4
- package/dist/esm/pm-plugins/decorations-drag-handle.js +5 -22
- package/dist/esm/pm-plugins/decorations-quick-insert-button.js +2 -6
- package/dist/esm/ui/block-controls-surface-context.js +53 -0
- package/dist/esm/ui/block-controls-surface.compiled.css +3 -0
- package/dist/esm/ui/block-controls-surface.js +151 -0
- package/dist/esm/ui/quick-insert-button.js +9 -0
- package/dist/esm/ui/utils/get-node-content-element.js +18 -0
- package/dist/esm/ui/utils/get-surface-placement.js +32 -0
- package/dist/types/blockControlsPluginType.d.ts +3 -1
- package/dist/types/ui/block-controls-surface-context.d.ts +4 -0
- package/dist/types/ui/block-controls-surface.d.ts +14 -0
- package/dist/types/ui/quick-insert-button.d.ts +8 -0
- package/dist/types/ui/utils/get-node-content-element.d.ts +1 -0
- package/dist/types/ui/utils/get-surface-placement.d.ts +23 -0
- package/package.json +7 -7
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import { QUICK_INSERT_LEFT_OFFSET, dragHandleGap, topPositionAdjustment } from '../consts';
|
|
5
|
+
export var getAbsoluteSurfacePlacement = function getAbsoluteSurfacePlacement(_ref) {
|
|
6
|
+
var _offsetParentRect$lef, _offsetParentRect$top;
|
|
7
|
+
var offsetParentRect = _ref.offsetParentRect,
|
|
8
|
+
offsetParentScrollLeft = _ref.offsetParentScrollLeft,
|
|
9
|
+
offsetParentScrollTop = _ref.offsetParentScrollTop,
|
|
10
|
+
placement = _ref.placement;
|
|
11
|
+
return _objectSpread(_objectSpread({}, placement), {}, {
|
|
12
|
+
left: placement.left - ((_offsetParentRect$lef = offsetParentRect === null || offsetParentRect === void 0 ? void 0 : offsetParentRect.left) !== null && _offsetParentRect$lef !== void 0 ? _offsetParentRect$lef : 0) + offsetParentScrollLeft,
|
|
13
|
+
top: placement.top - ((_offsetParentRect$top = offsetParentRect === null || offsetParentRect === void 0 ? void 0 : offsetParentRect.top) !== null && _offsetParentRect$top !== void 0 ? _offsetParentRect$top : 0) + offsetParentScrollTop
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Positions the Task 1 left surface beside the legacy drag-handle slot.
|
|
19
|
+
* The surface's own width is handled by the transform, so later controls do not require measuring it.
|
|
20
|
+
*/
|
|
21
|
+
export var getSurfacePlacement = function getSurfacePlacement(_ref2) {
|
|
22
|
+
var layout = _ref2.layout,
|
|
23
|
+
nodeRect = _ref2.nodeRect,
|
|
24
|
+
nodeType = _ref2.nodeType,
|
|
25
|
+
nodeTypeWithLevel = _ref2.nodeTypeWithLevel,
|
|
26
|
+
parentNodeType = _ref2.parentNodeType;
|
|
27
|
+
return {
|
|
28
|
+
left: nodeRect.left,
|
|
29
|
+
top: nodeRect.top + topPositionAdjustment(nodeTypeWithLevel, layout),
|
|
30
|
+
transform: "translateX(calc(-100% - ".concat(dragHandleGap(nodeType, parentNodeType) + QUICK_INSERT_LEFT_OFFSET, "px))")
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -16,6 +16,7 @@ import type { ShowDiffPlugin } from '@atlaskit/editor-plugin-show-diff';
|
|
|
16
16
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
17
17
|
import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
18
18
|
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
19
|
+
import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry/ui-control-registry-plugin-type';
|
|
19
20
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
20
21
|
import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
21
22
|
import type { Mapping } from '@atlaskit/editor-prosemirror/transform';
|
|
@@ -159,7 +160,8 @@ export type BlockControlsPluginDependencies = [
|
|
|
159
160
|
OptionalPlugin<InteractionPlugin>,
|
|
160
161
|
OptionalPlugin<UserIntentPlugin>,
|
|
161
162
|
OptionalPlugin<ToolbarPlugin>,
|
|
162
|
-
OptionalPlugin<ShowDiffPlugin
|
|
163
|
+
OptionalPlugin<ShowDiffPlugin>,
|
|
164
|
+
OptionalPlugin<UiControlRegistryPlugin>
|
|
163
165
|
];
|
|
164
166
|
export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
165
167
|
actions: {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BlockControlUIContext } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import type { ActiveNode } from '../blockControlsPluginType';
|
|
4
|
+
export declare const createBlockControlsSurfaceContext: (view: EditorView, activeNode: ActiveNode | undefined) => BlockControlUIContext | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
7
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
+
import type { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
9
|
+
type Props = {
|
|
10
|
+
api: ExtractInjectionAPI<BlockControlsPlugin>;
|
|
11
|
+
editorView: EditorView;
|
|
12
|
+
};
|
|
13
|
+
export declare const BlockControlsSurface: ({ api, editorView }: Props) => React.JSX.Element | null;
|
|
14
|
+
export {};
|
|
@@ -19,6 +19,14 @@ type Props = {
|
|
|
19
19
|
rootNodeType: string;
|
|
20
20
|
view: EditorView;
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Legacy widget-decoration Quick Insert implementation.
|
|
24
|
+
*
|
|
25
|
+
* Its behavior is intentionally duplicated by the registry-backed control in
|
|
26
|
+
* `editor-plugin-quick-insert`. Remove this implementation when
|
|
27
|
+
* `platform_editor_block_control_migration` is cleaned up; until then this path remains unchanged
|
|
28
|
+
* for users outside the experiment.
|
|
29
|
+
*/
|
|
22
30
|
export declare const TypeAheadControl: ({ view, api, formatMessage, getPos, anchorName, rootAnchorName, rootNodeType, anchorRectCache, }: Props) => jsx.JSX.Element;
|
|
23
31
|
export declare const QuickInsertWithVisibility: ({ view, api, formatMessage, getPos, nodeType, anchorName, rootAnchorName, rootNodeType, anchorRectCache, }: Props) => jsx.JSX.Element;
|
|
24
32
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getNodeContentElement: (nodeElement: HTMLElement, nodeType: string) => HTMLElement;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type SurfacePlacement = {
|
|
2
|
+
left: number;
|
|
3
|
+
top: number;
|
|
4
|
+
transform: string;
|
|
5
|
+
};
|
|
6
|
+
export type SurfacePlacementOptions = {
|
|
7
|
+
layout: string;
|
|
8
|
+
nodeRect: Pick<DOMRect, 'left' | 'top'>;
|
|
9
|
+
nodeType: string;
|
|
10
|
+
nodeTypeWithLevel: string;
|
|
11
|
+
parentNodeType?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const getAbsoluteSurfacePlacement: ({ offsetParentRect, offsetParentScrollLeft, offsetParentScrollTop, placement, }: {
|
|
14
|
+
offsetParentRect?: Pick<DOMRect, 'left' | 'top'>;
|
|
15
|
+
offsetParentScrollLeft: number;
|
|
16
|
+
offsetParentScrollTop: number;
|
|
17
|
+
placement: SurfacePlacement;
|
|
18
|
+
}) => SurfacePlacement;
|
|
19
|
+
/**
|
|
20
|
+
* Positions the Task 1 left surface beside the legacy drag-handle slot.
|
|
21
|
+
* The surface's own width is handled by the transform, so later controls do not require measuring it.
|
|
22
|
+
*/
|
|
23
|
+
export declare const getSurfacePlacement: ({ layout, nodeRect, nodeType, nodeTypeWithLevel, parentNodeType, }: SurfacePlacementOptions) => SurfacePlacement;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.1.1",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@atlaskit/browser-apis": "^1.2.0",
|
|
24
24
|
"@atlaskit/button": "^25.2.0",
|
|
25
|
+
"@atlaskit/css": "^1.0.0",
|
|
25
26
|
"@atlaskit/docs": "^12.2.0",
|
|
26
27
|
"@atlaskit/editor-plugin-accessibility-utils": "^16.0.0",
|
|
27
28
|
"@atlaskit/editor-plugin-analytics": "^16.0.0",
|
|
@@ -31,16 +32,18 @@
|
|
|
31
32
|
"@atlaskit/editor-plugin-interaction": "^27.0.0",
|
|
32
33
|
"@atlaskit/editor-plugin-limited-mode": "^13.0.0",
|
|
33
34
|
"@atlaskit/editor-plugin-metrics": "^17.0.0",
|
|
34
|
-
"@atlaskit/editor-plugin-quick-insert": "^16.
|
|
35
|
+
"@atlaskit/editor-plugin-quick-insert": "^16.1.0",
|
|
35
36
|
"@atlaskit/editor-plugin-selection": "^16.0.0",
|
|
36
37
|
"@atlaskit/editor-plugin-show-diff": "^14.0.0",
|
|
37
38
|
"@atlaskit/editor-plugin-toolbar": "^13.0.0",
|
|
38
39
|
"@atlaskit/editor-plugin-type-ahead": "^17.0.0",
|
|
40
|
+
"@atlaskit/editor-plugin-ui-control-registry": "^10.0.0",
|
|
39
41
|
"@atlaskit/editor-plugin-user-intent": "^14.0.0",
|
|
40
42
|
"@atlaskit/editor-plugin-width": "^17.0.0",
|
|
41
43
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
42
44
|
"@atlaskit/editor-shared-styles": "^4.0.0",
|
|
43
45
|
"@atlaskit/editor-tables": "^3.0.0",
|
|
46
|
+
"@atlaskit/editor-ui-control-model": "^2.8.0",
|
|
44
47
|
"@atlaskit/icon": "^37.5.0",
|
|
45
48
|
"@atlaskit/icon-lab": "^7.7.0",
|
|
46
49
|
"@atlaskit/link": "^5.1.0",
|
|
@@ -52,7 +55,7 @@
|
|
|
52
55
|
"@atlaskit/primitives": "^22.4.0",
|
|
53
56
|
"@atlaskit/section-message": "^10.1.0",
|
|
54
57
|
"@atlaskit/theme": "^28.1.0",
|
|
55
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
58
|
+
"@atlaskit/tmp-editor-statsig": "^162.0.0",
|
|
56
59
|
"@atlaskit/tokens": "^16.8.0",
|
|
57
60
|
"@atlaskit/tooltip": "^24.2.0",
|
|
58
61
|
"@babel/runtime": "^7.0.0",
|
|
@@ -63,7 +66,7 @@
|
|
|
63
66
|
"uuid": "^3.1.0"
|
|
64
67
|
},
|
|
65
68
|
"peerDependencies": {
|
|
66
|
-
"@atlaskit/editor-common": "^120.
|
|
69
|
+
"@atlaskit/editor-common": "^120.2.0",
|
|
67
70
|
"react": "^18.2.0 || ^19.2.0",
|
|
68
71
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
69
72
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
@@ -119,9 +122,6 @@
|
|
|
119
122
|
"platform_editor_column_count_analytics": {
|
|
120
123
|
"type": "boolean"
|
|
121
124
|
},
|
|
122
|
-
"platform_editor_fix_widget_destroy": {
|
|
123
|
-
"type": "boolean"
|
|
124
|
-
},
|
|
125
125
|
"platform_editor_content_mode_button_mvp": {
|
|
126
126
|
"type": "boolean"
|
|
127
127
|
},
|