@atlaskit/editor-plugin-block-controls 17.2.4 → 17.3.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/blockControlsPlugin.js +28 -8
- package/dist/cjs/editor-commands/move-node-with-block-menu.js +2 -2
- package/dist/cjs/editor-commands/move-node.js +6 -6
- package/dist/cjs/editor-commands/utils/move-node-utils.js +4 -4
- package/dist/cjs/pm-plugins/decorations-anchor.js +4 -4
- package/dist/cjs/pm-plugins/decorations-drag-handle.js +3 -3
- package/dist/cjs/pm-plugins/decorations-drop-target-active.js +2 -2
- package/dist/cjs/pm-plugins/decorations-drop-target.js +2 -2
- package/dist/cjs/pm-plugins/decorations-quick-insert-button.js +2 -2
- package/dist/cjs/pm-plugins/handle-mouse-down.js +3 -3
- package/dist/cjs/pm-plugins/handle-mouse-over.js +7 -7
- package/dist/cjs/pm-plugins/interaction-tracking/pm-plugin.js +3 -3
- package/dist/cjs/pm-plugins/main.js +23 -21
- package/dist/cjs/pm-plugins/react-root-registry.js +7 -7
- package/dist/cjs/pm-plugins/utils/active-anchor-tracker.js +2 -2
- package/dist/cjs/pm-plugins/utils/consts.js +2 -2
- package/dist/cjs/pm-plugins/utils/drag-handle-positions.js +6 -6
- package/dist/cjs/pm-plugins/utils/expand-and-update-selection.js +2 -2
- package/dist/cjs/pm-plugins/utils/getSelection.js +5 -5
- package/dist/cjs/pm-plugins/utils/inline-drop-target.js +2 -2
- package/dist/cjs/pm-plugins/utils/remove-from-source.js +2 -2
- package/dist/cjs/pm-plugins/utils/surface-node-positions.js +45 -19
- package/dist/cjs/pm-plugins/utils/validation.js +2 -2
- package/dist/cjs/ui/block-controls-left-surfaces.js +5 -4
- package/dist/cjs/ui/block-controls-right-surface.compiled.css +4 -0
- package/dist/cjs/ui/block-controls-right-surface.js +45 -0
- package/dist/cjs/ui/block-controls-right-surfaces.js +222 -0
- package/dist/{esm/ui/block-controls-left-surface-targets.js → cjs/ui/block-controls-surface-targets.js} +14 -2
- package/dist/cjs/ui/consts.js +4 -4
- package/dist/cjs/ui/drag-handle.js +20 -19
- package/dist/cjs/ui/drop-target.js +2 -2
- package/dist/cjs/ui/global-styles.js +5 -5
- package/dist/cjs/ui/utils/get-surface-placement.js +20 -6
- package/dist/cjs/ui/visibility-container.js +2 -2
- package/dist/es2019/blockControlsPlugin.js +28 -4
- package/dist/es2019/editor-commands/move-node-with-block-menu.js +1 -1
- package/dist/es2019/editor-commands/move-node.js +1 -1
- package/dist/es2019/editor-commands/utils/move-node-utils.js +1 -1
- package/dist/es2019/pm-plugins/decorations-anchor.js +1 -1
- package/dist/es2019/pm-plugins/decorations-drag-handle.js +1 -1
- package/dist/es2019/pm-plugins/decorations-drop-target-active.js +1 -1
- package/dist/es2019/pm-plugins/decorations-drop-target.js +1 -1
- package/dist/es2019/pm-plugins/decorations-quick-insert-button.js +1 -1
- package/dist/es2019/pm-plugins/handle-mouse-down.js +1 -1
- package/dist/es2019/pm-plugins/handle-mouse-over.js +1 -1
- package/dist/es2019/pm-plugins/interaction-tracking/pm-plugin.js +1 -1
- package/dist/es2019/pm-plugins/main.js +10 -10
- package/dist/es2019/pm-plugins/react-root-registry.js +7 -7
- package/dist/es2019/pm-plugins/utils/active-anchor-tracker.js +1 -1
- package/dist/es2019/pm-plugins/utils/consts.js +1 -1
- package/dist/es2019/pm-plugins/utils/drag-handle-positions.js +1 -1
- package/dist/es2019/pm-plugins/utils/expand-and-update-selection.js +1 -1
- package/dist/es2019/pm-plugins/utils/getSelection.js +1 -1
- package/dist/es2019/pm-plugins/utils/inline-drop-target.js +1 -1
- package/dist/es2019/pm-plugins/utils/remove-from-source.js +1 -1
- package/dist/es2019/pm-plugins/utils/surface-node-positions.js +34 -15
- package/dist/es2019/pm-plugins/utils/validation.js +1 -1
- package/dist/es2019/ui/block-controls-left-surfaces.js +5 -4
- package/dist/es2019/ui/block-controls-right-surface.compiled.css +4 -0
- package/dist/es2019/ui/block-controls-right-surface.js +39 -0
- package/dist/es2019/ui/block-controls-right-surfaces.js +187 -0
- package/dist/es2019/ui/{block-controls-left-surface-targets.js → block-controls-surface-targets.js} +8 -2
- package/dist/es2019/ui/consts.js +1 -1
- package/dist/es2019/ui/drag-handle.js +4 -3
- package/dist/es2019/ui/drop-target.js +1 -1
- package/dist/es2019/ui/global-styles.js +1 -1
- package/dist/es2019/ui/utils/get-surface-placement.js +20 -6
- package/dist/es2019/ui/visibility-container.js +1 -1
- package/dist/esm/blockControlsPlugin.js +24 -4
- package/dist/esm/editor-commands/move-node-with-block-menu.js +1 -1
- package/dist/esm/editor-commands/move-node.js +1 -1
- package/dist/esm/editor-commands/utils/move-node-utils.js +1 -1
- package/dist/esm/pm-plugins/decorations-anchor.js +1 -1
- package/dist/esm/pm-plugins/decorations-drag-handle.js +1 -1
- package/dist/esm/pm-plugins/decorations-drop-target-active.js +1 -1
- package/dist/esm/pm-plugins/decorations-drop-target.js +1 -1
- package/dist/esm/pm-plugins/decorations-quick-insert-button.js +1 -1
- package/dist/esm/pm-plugins/handle-mouse-down.js +1 -1
- package/dist/esm/pm-plugins/handle-mouse-over.js +1 -1
- package/dist/esm/pm-plugins/interaction-tracking/pm-plugin.js +1 -1
- package/dist/esm/pm-plugins/main.js +11 -9
- package/dist/esm/pm-plugins/react-root-registry.js +7 -7
- package/dist/esm/pm-plugins/utils/active-anchor-tracker.js +1 -1
- package/dist/esm/pm-plugins/utils/consts.js +1 -1
- package/dist/esm/pm-plugins/utils/drag-handle-positions.js +1 -1
- package/dist/esm/pm-plugins/utils/expand-and-update-selection.js +1 -1
- package/dist/esm/pm-plugins/utils/getSelection.js +1 -1
- package/dist/esm/pm-plugins/utils/inline-drop-target.js +1 -1
- package/dist/esm/pm-plugins/utils/remove-from-source.js +1 -1
- package/dist/esm/pm-plugins/utils/surface-node-positions.js +45 -19
- package/dist/esm/pm-plugins/utils/validation.js +1 -1
- package/dist/esm/ui/block-controls-left-surfaces.js +5 -4
- package/dist/esm/ui/block-controls-right-surface.compiled.css +4 -0
- package/dist/esm/ui/block-controls-right-surface.js +38 -0
- package/dist/esm/ui/block-controls-right-surfaces.js +213 -0
- package/dist/{cjs/ui/block-controls-left-surface-targets.js → esm/ui/block-controls-surface-targets.js} +8 -8
- package/dist/esm/ui/consts.js +1 -1
- package/dist/esm/ui/drag-handle.js +4 -3
- package/dist/esm/ui/drop-target.js +1 -1
- package/dist/esm/ui/global-styles.js +1 -1
- package/dist/esm/ui/utils/get-surface-placement.js +20 -6
- package/dist/esm/ui/visibility-container.js +1 -1
- package/dist/types/pm-plugins/main.d.ts +2 -2
- package/dist/types/pm-plugins/react-root-registry.d.ts +4 -4
- package/dist/types/pm-plugins/utils/surface-node-positions.d.ts +3 -3
- package/dist/types/ui/block-controls-left-surface.d.ts +2 -2
- package/dist/types/ui/block-controls-right-surface.d.ts +23 -0
- package/dist/types/ui/block-controls-right-surfaces.d.ts +20 -0
- package/dist/types/ui/block-controls-surface-targets.d.ts +13 -0
- package/dist/types/ui/utils/get-surface-placement.d.ts +12 -4
- package/package.json +23 -26
- package/dist/types/ui/block-controls-left-surface-targets.d.ts +0 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { BLOCK_CONTROLS_LEFT_GROUP, BLOCK_CONTROLS_LEFT_SECTION, BLOCK_CONTROLS_LEFT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
2
|
+
import { BLOCK_CONTROLS_LEFT_GROUP, BLOCK_CONTROLS_LEFT_SECTION, BLOCK_CONTROLS_LEFT_SURFACE, BLOCK_CONTROLS_RIGHT_GROUP, BLOCK_CONTROLS_RIGHT_SECTION, BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
3
3
|
import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
4
4
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
5
5
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -7,7 +7,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
7
7
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
9
9
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
10
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
10
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
11
11
|
import { handleKeyDownWithPreservedSelection } from './editor-commands/handle-key-down-with-preserved-selection';
|
|
12
12
|
import { mapPreservedSelection } from './editor-commands/map-preserved-selection';
|
|
13
13
|
import { moveNode } from './editor-commands/move-node';
|
|
@@ -23,6 +23,7 @@ import { createSelectionPreservationPlugin } from './pm-plugins/selection-preser
|
|
|
23
23
|
import { expandAndUpdateSelection } from './pm-plugins/utils/expand-and-update-selection';
|
|
24
24
|
import { selectNode } from './pm-plugins/utils/getSelection';
|
|
25
25
|
import { BlockControlsLeftSurfaces } from './ui/block-controls-left-surfaces';
|
|
26
|
+
import { BlockControlsRightSurfaces } from './ui/block-controls-right-surfaces';
|
|
26
27
|
import { getBlockControlsSurfaceDragHandleComponents } from './ui/block-controls-surface-drag-handle-registration';
|
|
27
28
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
28
29
|
import { SurfaceEditorViewContext } from './ui/surface-editor-view-context';
|
|
@@ -37,6 +38,7 @@ export const blockControlsPlugin = ({
|
|
|
37
38
|
const registryBlockControlsEnabled = isExperimentEnabled('platform_editor_block_control_migration');
|
|
38
39
|
const surfaceNodePositionsEnabled = registryBlockControlsEnabled && isExperimentEnabled('platform_editor_collapsible_headings');
|
|
39
40
|
const legacyBlockControlsEnabled = !registryBlockControlsEnabled;
|
|
41
|
+
const rightSurfaceEnabled = registryBlockControlsEnabled && isExperimentEnabled('platform_editor_block_control_right_surface');
|
|
40
42
|
if (registryBlockControlsEnabled) {
|
|
41
43
|
var _api$uiControlRegistr;
|
|
42
44
|
api === null || api === void 0 ? void 0 : (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 ? void 0 : _api$uiControlRegistr.actions.register([BLOCK_CONTROLS_LEFT_SURFACE, {
|
|
@@ -54,6 +56,25 @@ export const blockControlsPlugin = ({
|
|
|
54
56
|
}, ...getBlockControlsSurfaceDragHandleComponents({
|
|
55
57
|
api
|
|
56
58
|
})]);
|
|
59
|
+
if (rightSurfaceEnabled) {
|
|
60
|
+
var _api$uiControlRegistr2;
|
|
61
|
+
// The right surface host stays generic: it only registers the toolbar/section/group
|
|
62
|
+
// hierarchy. Individual features contribute their own buttons into
|
|
63
|
+
// BLOCK_CONTROLS_RIGHT_GROUP from their own plugins, same as the left surface.
|
|
64
|
+
api === null || api === void 0 ? void 0 : (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.register([BLOCK_CONTROLS_RIGHT_SURFACE, {
|
|
65
|
+
...BLOCK_CONTROLS_RIGHT_SECTION,
|
|
66
|
+
parents: [{
|
|
67
|
+
...BLOCK_CONTROLS_RIGHT_SURFACE,
|
|
68
|
+
rank: 100
|
|
69
|
+
}]
|
|
70
|
+
}, {
|
|
71
|
+
...BLOCK_CONTROLS_RIGHT_GROUP,
|
|
72
|
+
parents: [{
|
|
73
|
+
...BLOCK_CONTROLS_RIGHT_SECTION,
|
|
74
|
+
rank: 100
|
|
75
|
+
}]
|
|
76
|
+
}]);
|
|
77
|
+
}
|
|
57
78
|
}
|
|
58
79
|
return {
|
|
59
80
|
name: 'blockControls',
|
|
@@ -123,7 +144,7 @@ export const blockControlsPlugin = ({
|
|
|
123
144
|
plugin: ({
|
|
124
145
|
getIntl,
|
|
125
146
|
nodeViewPortalProviderAPI
|
|
126
|
-
}) => createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled && legacyBlockControlsEnabled, legacyBlockControlsEnabled, surfaceNodePositionsEnabled)
|
|
147
|
+
}) => createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled && legacyBlockControlsEnabled, legacyBlockControlsEnabled, surfaceNodePositionsEnabled, rightSurfaceEnabled)
|
|
127
148
|
}];
|
|
128
149
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
129
150
|
pmPlugins.push({
|
|
@@ -446,7 +467,10 @@ export const blockControlsPlugin = ({
|
|
|
446
467
|
}, /*#__PURE__*/React.createElement(BlockControlsLeftSurfaces, {
|
|
447
468
|
api: api,
|
|
448
469
|
editorView: editorView
|
|
449
|
-
})
|
|
470
|
+
}), rightSurfaceEnabled ? /*#__PURE__*/React.createElement(BlockControlsRightSurfaces, {
|
|
471
|
+
api: api,
|
|
472
|
+
editorView: editorView
|
|
473
|
+
}) : null) : null);
|
|
450
474
|
}
|
|
451
475
|
};
|
|
452
476
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { DIRECTION } from '@atlaskit/editor-common/types';
|
|
3
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
4
4
|
import { key } from '../pm-plugins/main';
|
|
5
5
|
import { mapPreservedSelection } from '../pm-plugins/utils/selection';
|
|
6
6
|
import { moveNode } from './move-node';
|
|
@@ -14,7 +14,7 @@ import { findTable, isInTable, isTableSelected } from '@atlaskit/editor-tables/u
|
|
|
14
14
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
15
15
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
16
16
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
17
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
17
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
18
18
|
import { key } from '../pm-plugins/main';
|
|
19
19
|
import { attachMoveNodeAnalytics, getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
|
|
20
20
|
import { getNestedNodePosition } from '../pm-plugins/utils/getNestedNodePosition';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
3
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
4
4
|
import { createPreservedSelection } from '../../pm-plugins/utils/selection';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
4
4
|
import { getNodeAnchor, getNodeTypeWithLevel, NESTED_DEPTH, TYPE_NODE_DEC } from './decorations-common';
|
|
5
5
|
const IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption', 'layoutColumn'];
|
|
6
6
|
export const IGNORE_NODES_NEXT = ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption'];
|
|
@@ -4,7 +4,7 @@ import uuid from 'uuid';
|
|
|
4
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
6
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
8
8
|
import { ACTIVE_DRAG_HANDLE_ATTR } from '../ui/consts';
|
|
9
9
|
import { DragHandle, DragHandleWithVisibility } from '../ui/drag-handle';
|
|
10
10
|
import { TYPE_HANDLE_DEC, TYPE_NODE_DEC, unmountDecorations } from './decorations-common';
|
|
@@ -4,7 +4,7 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
|
4
4
|
import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-utils';
|
|
5
5
|
import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
8
8
|
import { getNodeAnchor } from './decorations-common';
|
|
9
9
|
import { createDropTargetDecoration, createLayoutDropTargetDecoration } from './decorations-drop-target';
|
|
10
10
|
import { findSurroundingNodes } from './decorations-find-surrounding-nodes';
|
|
@@ -7,7 +7,7 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
|
7
7
|
import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-utils';
|
|
8
8
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
9
9
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
10
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
10
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
11
11
|
import { nodeMargins } from '../ui/consts';
|
|
12
12
|
import { DropTarget, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET } from '../ui/drop-target';
|
|
13
13
|
import { DropTargetLayout, DropTargetLayoutNativeAnchorSupport } from '../ui/drop-target-layout';
|
|
@@ -4,7 +4,7 @@ import uuid from 'uuid';
|
|
|
4
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
6
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
8
8
|
import { ACTIVE_QUICK_INSERT_ATTR } from '../ui/consts';
|
|
9
9
|
import { QuickInsertWithVisibility } from '../ui/quick-insert-button';
|
|
10
10
|
import { getMatchingBlockMarks } from './utils/marks';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
|
|
2
2
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
4
4
|
export const handleMouseDown = api => (view, event) => {
|
|
5
5
|
if (!(event.target instanceof HTMLElement)) {
|
|
6
6
|
return false;
|
|
@@ -4,7 +4,7 @@ import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-che
|
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
5
5
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
6
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
7
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
8
8
|
import { getAnchorAttrName, getTypeNameAttrName, getTypeNameFromDom, NODE_ANCHOR_ATTR_NAME } from '../ui/utils/dom-attr-name';
|
|
9
9
|
import { IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT, IGNORE_NODES_NEXT } from './decorations-anchor';
|
|
10
10
|
import { selectionPreservationPluginKey } from './selection-preservation/plugin-key';
|
|
@@ -4,7 +4,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
4
4
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
5
5
|
import { UNSAFE_expValNoExposure } from '@atlaskit/platform-feature-experiments/unsafe-exp-val-no-exposure';
|
|
6
6
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
8
8
|
import { RIGHT_MARGIN_ROVO_GAP_PX } from './constants';
|
|
9
9
|
import { handleKeyDown } from './handle-key-down';
|
|
10
10
|
import { handleMouseEnter, handleMouseLeave, handleMouseMove } from './handle-mouse-move';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import rafSchedule from 'raf-schd';
|
|
2
2
|
import { getDocument } from '@atlaskit/browser-apis';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { BLOCK_CONTROLS_LEFT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
4
|
+
import { BLOCK_CONTROLS_LEFT_SURFACE, BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
5
5
|
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
6
6
|
import { getNodeIdProvider } from '@atlaskit/editor-common/node-anchor';
|
|
7
7
|
import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
@@ -18,7 +18,7 @@ import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-sc
|
|
|
18
18
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/utils/combine';
|
|
19
19
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter';
|
|
20
20
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
21
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
21
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
22
22
|
import { BLOCK_CONTROLS_SURFACE_SELECTOR } from '../ui/consts';
|
|
23
23
|
import { getAnchorAttrName } from '../ui/utils/dom-attr-name';
|
|
24
24
|
import { findNodeDecs, nodeDecorations } from './decorations-anchor';
|
|
@@ -231,7 +231,7 @@ const getDecorationAtPos = (state, decorations, pos, to) => {
|
|
|
231
231
|
const nodeDecAtActivePos = nodeDecsAtActivePos.pop();
|
|
232
232
|
return nodeDecAtActivePos;
|
|
233
233
|
};
|
|
234
|
-
export const apply = (api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled = false, quickInsertButtonEnabled = true, anchorRectCache, resizeObserverWidth, pragmaticCleanup,
|
|
234
|
+
export const apply = (api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled = false, quickInsertButtonEnabled = true, anchorRectCache, resizeObserverWidth, pragmaticCleanup, resolvedSurfaces = []) => {
|
|
235
235
|
var _api$limitedMode, _api$limitedMode$shar, _api$limitedMode$shar2, _meta$multiSelectDnD, _api$editorViewMode, _api$editorViewMode$s, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$isDragging3, _meta$toggleMenu, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
|
|
236
236
|
let {
|
|
237
237
|
activeNode,
|
|
@@ -717,14 +717,14 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
717
717
|
var _latestActiveNode13, _latestActiveNode14;
|
|
718
718
|
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && flags.legacyDragHandleEnabled && findHandleDec(decorations, (_latestActiveNode13 = latestActiveNode) === null || _latestActiveNode13 === void 0 ? void 0 : _latestActiveNode13.pos, (_latestActiveNode14 = latestActiveNode) === null || _latestActiveNode14 === void 0 ? void 0 : _latestActiveNode14.pos).length === 0 ? null : latestActiveNode;
|
|
719
719
|
}
|
|
720
|
-
if (flags.surfaceNodePositionsEnabled &&
|
|
720
|
+
if (flags.surfaceNodePositionsEnabled && resolvedSurfaces.length > 0) {
|
|
721
721
|
surfaceNodePositions = updateSurfaceNodePositions({
|
|
722
722
|
activeNode: newActiveNode,
|
|
723
723
|
currentPositions: surfaceNodePositions,
|
|
724
724
|
from,
|
|
725
725
|
newState,
|
|
726
726
|
previousActiveNode,
|
|
727
|
-
|
|
727
|
+
resolvedSurfaces,
|
|
728
728
|
to,
|
|
729
729
|
tr
|
|
730
730
|
});
|
|
@@ -772,8 +772,8 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
772
772
|
isSelectedViaDragHandle: isSelectedViaDragHandleNew
|
|
773
773
|
};
|
|
774
774
|
};
|
|
775
|
-
export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled = false, quickInsertButtonEnabled = true, legacyDragHandleEnabled = true, surfaceNodePositionsEnabled = false) => {
|
|
776
|
-
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
775
|
+
export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled = false, quickInsertButtonEnabled = true, legacyDragHandleEnabled = true, surfaceNodePositionsEnabled = false, rightSurfaceEnabled = false) => {
|
|
776
|
+
var _api$uiControlRegistr, _api$uiControlRegistr2, _api$uiControlRegistr3, _api$uiControlRegistr4;
|
|
777
777
|
const {
|
|
778
778
|
formatMessage
|
|
779
779
|
} = getIntl();
|
|
@@ -786,7 +786,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
786
786
|
surfaceNodePositionsEnabled,
|
|
787
787
|
toolbarFlagsEnabled
|
|
788
788
|
};
|
|
789
|
-
const
|
|
789
|
+
const resolvedSurfaces = surfaceNodePositionsEnabled ? [resolveSurface((_api$uiControlRegistr = api === null || api === void 0 ? void 0 : (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(BLOCK_CONTROLS_LEFT_SURFACE)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [], BLOCK_CONTROLS_LEFT_SURFACE), ...(rightSurfaceEnabled ? [resolveSurface((_api$uiControlRegistr3 = api === null || api === void 0 ? void 0 : (_api$uiControlRegistr4 = api.uiControlRegistry) === null || _api$uiControlRegistr4 === void 0 ? void 0 : _api$uiControlRegistr4.actions.getComponents(BLOCK_CONTROLS_RIGHT_SURFACE)) !== null && _api$uiControlRegistr3 !== void 0 ? _api$uiControlRegistr3 : [], BLOCK_CONTROLS_RIGHT_SURFACE)] : [])] : [];
|
|
790
790
|
let anchorRectCache;
|
|
791
791
|
if (!isAnchorSupported()) {
|
|
792
792
|
anchorRectCache = new AnchorRectCache();
|
|
@@ -799,10 +799,10 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
799
799
|
init(_config, editorState) {
|
|
800
800
|
return {
|
|
801
801
|
...initialState,
|
|
802
|
-
surfaceNodePositions:
|
|
802
|
+
surfaceNodePositions: resolvedSurfaces.length > 0 ? getSurfaceNodePositions(editorState, resolvedSurfaces) : []
|
|
803
803
|
};
|
|
804
804
|
},
|
|
805
|
-
apply: (tr, currentState, _, newState) => apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup,
|
|
805
|
+
apply: (tr, currentState, _, newState) => apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, resolvedSurfaces)
|
|
806
806
|
},
|
|
807
807
|
props: {
|
|
808
808
|
decorations: state => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ReactDOM, { flushSync } from 'react-dom';
|
|
2
2
|
import { createRoot } from 'react-dom/client';
|
|
3
|
-
import {
|
|
3
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Shared registry of React roots created via `createRoot`.
|
|
@@ -14,16 +14,16 @@ const reactRoots = new WeakMap();
|
|
|
14
14
|
/**
|
|
15
15
|
* Mounts `element` into `mountPoint`.
|
|
16
16
|
*
|
|
17
|
-
* When `
|
|
17
|
+
* When `platform_editor_react19_migration` is **on**, uses the React 18/19 `createRoot`
|
|
18
18
|
* API wrapped in `flushSync` so the render is synchronous – matching the
|
|
19
19
|
* legacy `ReactDOM.render` timing that ProseMirror decoration widgets depend
|
|
20
20
|
* on (focus management, anchor positioning, block-menu visibility all read
|
|
21
21
|
* the rendered DOM immediately after the callback returns).
|
|
22
22
|
*
|
|
23
|
-
*
|
|
23
|
+
* Otherwise, falls back to the legacy `ReactDOM.render` path.
|
|
24
24
|
*/
|
|
25
25
|
export const renderToMountPoint = (element, mountPoint) => {
|
|
26
|
-
if (
|
|
26
|
+
if (isExperimentEnabled('platform_editor_react19_migration')) {
|
|
27
27
|
let root = reactRoots.get(mountPoint);
|
|
28
28
|
if (!root) {
|
|
29
29
|
root = createRoot(mountPoint);
|
|
@@ -42,13 +42,13 @@ export const renderToMountPoint = (element, mountPoint) => {
|
|
|
42
42
|
/**
|
|
43
43
|
* Unmounts the React tree at `mountPoint`.
|
|
44
44
|
*
|
|
45
|
-
* When `
|
|
45
|
+
* When `platform_editor_react19_migration` is **on**, looks up the root in the shared
|
|
46
46
|
* registry, calls `root.unmount()`, and removes the entry.
|
|
47
47
|
*
|
|
48
|
-
*
|
|
48
|
+
* Otherwise, falls back to `ReactDOM.unmountComponentAtNode`.
|
|
49
49
|
*/
|
|
50
50
|
export const unmountFromMountPoint = mountPoint => {
|
|
51
|
-
if (
|
|
51
|
+
if (isExperimentEnabled('platform_editor_react19_migration')) {
|
|
52
52
|
const root = reactRoots.get(mountPoint);
|
|
53
53
|
if (root) {
|
|
54
54
|
root.unmount();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
4
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
5
5
|
export class ActiveAnchorTracker {
|
|
6
6
|
constructor() {
|
|
7
7
|
_defineProperty(this, "lastActiveAnchor", '');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
1
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
2
2
|
export const maxLayoutColumnSupported = () => {
|
|
3
3
|
return editorExperiment('advanced_layouts', true) ? 5 : 3;
|
|
4
4
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import memoizeOne from 'memoize-one';
|
|
2
2
|
import { DRAG_HANDLE_WIDTH } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
4
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
5
5
|
import { DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, DRAG_HANDLE_H1_TOP_ADJUSTMENT, DRAG_HANDLE_H2_TOP_ADJUSTMENT, DRAG_HANDLE_H4_TOP_ADJUSTMENT, DRAG_HANDLE_H5_TOP_ADJUSTMENT, DRAG_HANDLE_H6_TOP_ADJUSTMENT, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_PARAGRAPH_SMALL_TOP_ADJUSTMENT, DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT, dragHandleGap } from '../../ui/consts';
|
|
6
6
|
const STICKY_NODES = ['panel', 'table', 'expand', 'layoutSection', 'bodiedExtension'];
|
|
7
7
|
export const getTopPosition = (dom, type) => {
|
|
@@ -4,7 +4,7 @@ import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-che
|
|
|
4
4
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
7
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
8
8
|
import { selectNode } from './getSelection';
|
|
9
9
|
import { adjustSelectionBoundsForEdgePositions } from './selection';
|
|
10
10
|
const isPosWithinRange = (pos, range) => {
|
|
@@ -5,7 +5,7 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
|
|
|
5
5
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
8
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
8
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
9
9
|
export const getInlineNodePos = (doc, start, nodeSize) => {
|
|
10
10
|
const $startPos = doc.resolve(start);
|
|
11
11
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
2
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
2
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
3
3
|
import { isWrappedMedia } from './check-media-layout';
|
|
4
4
|
import { maxLayoutColumnSupported } from './consts';
|
|
5
5
|
const syncedBlockTypes = ['syncBlock', 'bodiedSyncBlock'];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
3
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
4
4
|
import { isFragmentOfType } from './check-fragment';
|
|
5
5
|
import { MIN_LAYOUT_COLUMN } from './consts';
|
|
6
6
|
import { updateColumnWidths } from './update-column-widths';
|
|
@@ -6,19 +6,35 @@ const createSurfaceContextAtPosition = (state, position, activeNode) => {
|
|
|
6
6
|
const blockControlsContext = createBlockControlsSurfaceContextForPosition(state, position, activeNode);
|
|
7
7
|
return blockControlsContext ? createSurfaceContext(BLOCK_CONTROL_UI_CONTEXT, blockControlsContext) : undefined;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A position qualifies as soon as ANY of the given surfaces would render something for it.
|
|
12
|
+
* The surface context depends only on state/position/activeNode, not on which surface is being
|
|
13
|
+
* checked, so it's built once here rather than once per surface inside the `.some()`.
|
|
14
|
+
*/
|
|
15
|
+
const willAnySurfaceRenderAt = (surfaces, state, position, activeNode) => {
|
|
16
|
+
const surfaceContext = createSurfaceContextAtPosition(state, position, activeNode);
|
|
17
|
+
return surfaces.some(({
|
|
18
|
+
childrenMap,
|
|
19
|
+
root
|
|
20
|
+
}) => willComponentRender(root, childrenMap, surfaceContext));
|
|
21
|
+
};
|
|
22
|
+
export const getSurfaceNodePositions = (state, resolvedSurfaces, activeNode, from = 0, to = state.doc.content.size) => {
|
|
23
|
+
const surfaces = resolvedSurfaces.flatMap(({
|
|
24
|
+
childrenMap,
|
|
25
|
+
root
|
|
26
|
+
}) => root ? [{
|
|
27
|
+
childrenMap,
|
|
28
|
+
root
|
|
29
|
+
}] : []);
|
|
30
|
+
if (surfaces.length === 0) {
|
|
15
31
|
return [];
|
|
16
32
|
}
|
|
17
33
|
const positions = [];
|
|
18
34
|
const start = Math.max(0, from);
|
|
19
35
|
const end = Math.min(state.doc.content.size, Math.max(start, to));
|
|
20
36
|
state.doc.nodesBetween(start, end, (node, position) => {
|
|
21
|
-
if (node.isBlock &&
|
|
37
|
+
if (node.isBlock && willAnySurfaceRenderAt(surfaces, state, position, activeNode)) {
|
|
22
38
|
positions.push(position);
|
|
23
39
|
}
|
|
24
40
|
});
|
|
@@ -31,7 +47,7 @@ export const updateSurfaceNodePositions = ({
|
|
|
31
47
|
from,
|
|
32
48
|
newState,
|
|
33
49
|
previousActiveNode,
|
|
34
|
-
|
|
50
|
+
resolvedSurfaces,
|
|
35
51
|
to,
|
|
36
52
|
tr
|
|
37
53
|
}) => {
|
|
@@ -41,16 +57,19 @@ export const updateSurfaceNodePositions = ({
|
|
|
41
57
|
}
|
|
42
58
|
const nextActiveNode = activeNode !== null && activeNode !== void 0 ? activeNode : undefined;
|
|
43
59
|
if (activeNodeChanged) {
|
|
44
|
-
return getSurfaceNodePositions(newState,
|
|
60
|
+
return getSurfaceNodePositions(newState, resolvedSurfaces, nextActiveNode);
|
|
45
61
|
}
|
|
46
|
-
const {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
62
|
+
const surfaces = resolvedSurfaces.flatMap(({
|
|
63
|
+
childrenMap,
|
|
64
|
+
root
|
|
65
|
+
}) => root ? [{
|
|
66
|
+
childrenMap,
|
|
67
|
+
root
|
|
68
|
+
}] : []);
|
|
50
69
|
const mappedPositions = currentPositions.map(position => tr.mapping.mapResult(position, -1)).filter(result => !result.deleted).map(result => result.pos).filter(position => {
|
|
51
70
|
const node = newState.doc.nodeAt(position);
|
|
52
|
-
return Boolean((node === null || node === void 0 ? void 0 : node.isBlock) &&
|
|
71
|
+
return Boolean((node === null || node === void 0 ? void 0 : node.isBlock) && willAnySurfaceRenderAt(surfaces, newState, position, nextActiveNode));
|
|
53
72
|
});
|
|
54
|
-
const changedPositions = getSurfaceNodePositions(newState,
|
|
73
|
+
const changedPositions = getSurfaceNodePositions(newState, resolvedSurfaces, nextActiveNode, from - 1, to + 1);
|
|
55
74
|
return Array.from(new Set([...mappedPositions, ...changedPositions])).sort((first, second) => first - second);
|
|
56
75
|
};
|
|
@@ -4,7 +4,7 @@ import { getBaseNodeTypeName } from '@atlaskit/editor-common/utils/node-type-uti
|
|
|
4
4
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
8
8
|
export const isInsideTable = nodeType => {
|
|
9
9
|
const {
|
|
10
10
|
tableCell,
|
|
@@ -8,9 +8,9 @@ import { BLOCK_CONTROLS_LEFT_SURFACE } from '@atlaskit/editor-common/block-contr
|
|
|
8
8
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
9
9
|
import { createSurfaceContext } from '@atlaskit/editor-ui-control-model/create-surface-context';
|
|
10
10
|
import { getNodeTypeWithLevel } from '../pm-plugins/decorations-common';
|
|
11
|
-
import { createBlockControlsSurfaceContext, createBlockControlsSurfaceContextForPosition } from './block-controls-surface-context';
|
|
12
11
|
import { BlockControlsLeftSurface } from './block-controls-left-surface';
|
|
13
|
-
import {
|
|
12
|
+
import { createBlockControlsSurfaceContext, createBlockControlsSurfaceContextForPosition } from './block-controls-surface-context';
|
|
13
|
+
import { getBlockControlsSurfaceTargets } from './block-controls-surface-targets';
|
|
14
14
|
import { getNodeContentElement } from './utils/get-node-content-element';
|
|
15
15
|
import { getAbsoluteSurfacePlacement, getSurfacePlacement } from './utils/get-surface-placement';
|
|
16
16
|
const EMPTY_SURFACE_POSITIONS = [];
|
|
@@ -31,7 +31,7 @@ export const BlockControlsLeftSurfaces = ({
|
|
|
31
31
|
};
|
|
32
32
|
});
|
|
33
33
|
const components = (_api$uiControlRegistr = (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(BLOCK_CONTROLS_LEFT_SURFACE)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : EMPTY_SURFACE_COMPONENTS;
|
|
34
|
-
const targets = useMemo(() =>
|
|
34
|
+
const targets = useMemo(() => getBlockControlsSurfaceTargets(activeNode, surfaceNodePositions), [activeNode, surfaceNodePositions]);
|
|
35
35
|
const surfaces = useMemo(() => targets.flatMap(target => {
|
|
36
36
|
const context = target.source === 'stored' ? createBlockControlsSurfaceContextForPosition(editorView.state, target.position, activeNode) : createBlockControlsSurfaceContext(editorView, activeNode, target.source);
|
|
37
37
|
if (!context) {
|
|
@@ -93,7 +93,8 @@ export const BlockControlsLeftSurfaces = ({
|
|
|
93
93
|
nodeRect: targetElement.getBoundingClientRect(),
|
|
94
94
|
nodeType: blockControlsContext.targetNode.type.name,
|
|
95
95
|
nodeTypeWithLevel: getNodeTypeWithLevel(blockControlsContext.targetNode.node),
|
|
96
|
-
parentNodeType: blockControlsContext.targetNode.parentType === 'doc' ? undefined : blockControlsContext.targetNode.parentType
|
|
96
|
+
parentNodeType: blockControlsContext.targetNode.parentType === 'doc' ? undefined : blockControlsContext.targetNode.parentType,
|
|
97
|
+
side: 'left'
|
|
97
98
|
});
|
|
98
99
|
nextPlacements.set(position, getAbsoluteSurfacePlacement({
|
|
99
100
|
offsetParentRect,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* block-controls-right-surface.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
2
|
+
import "./block-controls-right-surface.compiled.css";
|
|
3
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
6
|
+
import { SurfaceRenderer, willSurfaceRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
7
|
+
import { VisibilityContainer } from './visibility-container';
|
|
8
|
+
const rightSurfaceStyles = null;
|
|
9
|
+
/** Renders one right block-controls surface at a document position. */
|
|
10
|
+
export const BlockControlsRightSurface = ({
|
|
11
|
+
api,
|
|
12
|
+
components,
|
|
13
|
+
forceVisibleOnMouseOut,
|
|
14
|
+
placement,
|
|
15
|
+
source,
|
|
16
|
+
surfaceContext
|
|
17
|
+
}) => {
|
|
18
|
+
if (!placement || !willSurfaceRender(components, BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const surface = /*#__PURE__*/React.createElement(SurfaceRenderer, {
|
|
22
|
+
components: components,
|
|
23
|
+
surface: BLOCK_CONTROLS_RIGHT_SURFACE,
|
|
24
|
+
surfaceContext: surfaceContext
|
|
25
|
+
});
|
|
26
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
27
|
+
"data-editor-block-controls-surface": true,
|
|
28
|
+
"data-testid": source === 'stored' ? 'block-controls-right-surface-stored' : source === 'active' ? 'block-controls-right-surface-active' : 'block-controls-right-surface'
|
|
29
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Placement is resolved from the target node's runtime DOM geometry.
|
|
30
|
+
,
|
|
31
|
+
style: placement,
|
|
32
|
+
className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw _kqswstnw _1pbyb4wl"])
|
|
33
|
+
}, /*#__PURE__*/React.createElement(VisibilityContainer, {
|
|
34
|
+
api: api,
|
|
35
|
+
controlSide: "right",
|
|
36
|
+
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
37
|
+
shouldUseDisplayContents: true
|
|
38
|
+
}, surface));
|
|
39
|
+
};
|