@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
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.key = exports.getDecorations = exports.getBlockControlsMeta = exports.createPlugin = exports.apply = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
10
11
|
var _browserApis = require("@atlaskit/browser-apis");
|
|
@@ -26,7 +27,7 @@ var _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
|
|
|
26
27
|
var _combine = require("@atlaskit/pragmatic-drag-and-drop/utils/combine");
|
|
27
28
|
var _elementAdapter = require("@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter");
|
|
28
29
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
29
|
-
var
|
|
30
|
+
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
30
31
|
var _consts = require("../ui/consts");
|
|
31
32
|
var _domAttrName = require("../ui/utils/dom-attr-name");
|
|
32
33
|
var _decorationsAnchor = require("./decorations-anchor");
|
|
@@ -246,7 +247,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
246
247
|
var anchorRectCache = arguments.length > 10 ? arguments[10] : undefined;
|
|
247
248
|
var resizeObserverWidth = arguments.length > 11 ? arguments[11] : undefined;
|
|
248
249
|
var pragmaticCleanup = arguments.length > 12 ? arguments[12] : undefined;
|
|
249
|
-
var
|
|
250
|
+
var resolvedSurfaces = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : [];
|
|
250
251
|
var activeNode = currentState.activeNode,
|
|
251
252
|
decorations = currentState.decorations,
|
|
252
253
|
isResizerResizing = currentState.isResizerResizing,
|
|
@@ -313,7 +314,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
313
314
|
// Which caused the drag handle onClick event not firing, then block menu wouldn't be opened
|
|
314
315
|
// This is caused by the mappedPos.deletedAfter sometimes returning true in webkit browsers even though the active node still exists
|
|
315
316
|
// This is likely a prosemirror and safari integration bug, but to unblock the issue, we are going to use mappedPos.deleted in safari for now
|
|
316
|
-
if (browser.webkit && (0,
|
|
317
|
+
if (browser.webkit && (0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true)) {
|
|
317
318
|
_mappedPos = tr.mapping.mapResult(activeNode.pos);
|
|
318
319
|
isActiveNodeDeleted = _mappedPos.deleted;
|
|
319
320
|
} else {
|
|
@@ -364,7 +365,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
364
365
|
|
|
365
366
|
// Re-create node decorations
|
|
366
367
|
var isDecSetEmpty = decorations === _view.DecorationSet.empty;
|
|
367
|
-
var isNodeDecsMissing = isDecSetEmpty || maybeNodeCountChanged || (0,
|
|
368
|
+
var isNodeDecsMissing = isDecSetEmpty || maybeNodeCountChanged || (0, _editorExperiment.editorExperiment)('platform_editor_breakout_resizing', true) && hasJustFinishedResizing;
|
|
368
369
|
var shouldRedrawNodeDecs = !isResizerResizing && (isNodeDecsMissing || (meta === null || meta === void 0 ? void 0 : meta.isDragging)) &&
|
|
369
370
|
// Skip expensive anchor node decoration recalculations when native anchor support is enabled
|
|
370
371
|
!(0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
|
|
@@ -811,26 +812,26 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
811
812
|
// handle - so findHandleDec is always empty. Don't clear activeNode in that case.
|
|
812
813
|
var hasHandleOrViewModeControls = (0, _decorationsDragHandle.findHandleDec)(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length > 0 || isViewMode && rightSideControlsEnabled || !flags.legacyDragHandleEnabled;
|
|
813
814
|
// Keep the registry surface mounted while its Block Menu owns focus.
|
|
814
|
-
var keepActiveNodeForOpenBlockMenu = !flags.legacyDragHandleEnabled && isMenuOpen && (0,
|
|
815
|
+
var keepActiveNodeForOpenBlockMenu = !flags.legacyDragHandleEnabled && isMenuOpen && (0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true);
|
|
815
816
|
newActiveNode = meta !== null && meta !== void 0 && meta.editorBlurred && !keepActiveNodeForOpenBlockMenu || !(meta !== null && meta !== void 0 && meta.activeNode) && !hasHandleOrViewModeControls ? null : latestActiveNode;
|
|
816
817
|
} else {
|
|
817
818
|
var _latestActiveNode13, _latestActiveNode14;
|
|
818
819
|
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && flags.legacyDragHandleEnabled && (0, _decorationsDragHandle.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;
|
|
819
820
|
}
|
|
820
|
-
if (flags.surfaceNodePositionsEnabled &&
|
|
821
|
+
if (flags.surfaceNodePositionsEnabled && resolvedSurfaces.length > 0) {
|
|
821
822
|
surfaceNodePositions = (0, _surfaceNodePositions.updateSurfaceNodePositions)({
|
|
822
823
|
activeNode: newActiveNode,
|
|
823
824
|
currentPositions: surfaceNodePositions,
|
|
824
825
|
from: from,
|
|
825
826
|
newState: newState,
|
|
826
827
|
previousActiveNode: previousActiveNode,
|
|
827
|
-
|
|
828
|
+
resolvedSurfaces: resolvedSurfaces,
|
|
828
829
|
to: to,
|
|
829
830
|
tr: tr
|
|
830
831
|
});
|
|
831
832
|
}
|
|
832
833
|
var isMenuOpenNew = isMenuOpen;
|
|
833
|
-
if ((0,
|
|
834
|
+
if ((0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true)) {
|
|
834
835
|
if (meta !== null && meta !== void 0 && meta.closeMenu) {
|
|
835
836
|
isMenuOpenNew = false;
|
|
836
837
|
} else if (meta !== null && meta !== void 0 && meta.toggleMenu) {
|
|
@@ -853,9 +854,9 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
853
854
|
activeDropTargetNode: currentActiveDropTargetNode,
|
|
854
855
|
isDragging: (_meta$isDragging3 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging3 !== void 0 ? _meta$isDragging3 : isDragging,
|
|
855
856
|
isMenuOpen: isMenuOpenNew,
|
|
856
|
-
menuTriggerBy: flags.toolbarFlagsEnabled || (0,
|
|
857
|
+
menuTriggerBy: flags.toolbarFlagsEnabled || (0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true) ? (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy : undefined,
|
|
857
858
|
menuTriggerByNode: (meta === null || meta === void 0 || (_meta$toggleMenu2 = meta.toggleMenu) === null || _meta$toggleMenu2 === void 0 ? void 0 : _meta$toggleMenu2.triggerByNode) || menuTriggerByNode,
|
|
858
|
-
blockMenuOptions: (0,
|
|
859
|
+
blockMenuOptions: (0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true) ? {
|
|
859
860
|
canMoveUp: (meta === null || meta === void 0 || (_meta$toggleMenu3 = meta.toggleMenu) === null || _meta$toggleMenu3 === void 0 ? void 0 : _meta$toggleMenu3.moveUp) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu4 = meta.toggleMenu) === null || _meta$toggleMenu4 === void 0 ? void 0 : _meta$toggleMenu4.moveUp : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.canMoveUp,
|
|
860
861
|
canMoveDown: (meta === null || meta === void 0 || (_meta$toggleMenu5 = meta.toggleMenu) === null || _meta$toggleMenu5 === void 0 ? void 0 : _meta$toggleMenu5.moveDown) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu6 = meta.toggleMenu) === null || _meta$toggleMenu6 === void 0 ? void 0 : _meta$toggleMenu6.moveDown : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.canMoveDown,
|
|
861
862
|
openedViaKeyboard: (meta === null || meta === void 0 || (_meta$toggleMenu7 = meta.toggleMenu) === null || _meta$toggleMenu7 === void 0 ? void 0 : _meta$toggleMenu7.openedViaKeyboard) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu8 = meta.toggleMenu) === null || _meta$toggleMenu8 === void 0 ? void 0 : _meta$toggleMenu8.openedViaKeyboard : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.openedViaKeyboard
|
|
@@ -873,14 +874,15 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
873
874
|
};
|
|
874
875
|
};
|
|
875
876
|
var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
|
|
876
|
-
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
877
|
+
var _api$uiControlRegistr, _api$uiControlRegistr2, _api$uiControlRegistr3, _api$uiControlRegistr4;
|
|
877
878
|
var rightSideControlsEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
878
879
|
var quickInsertButtonEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
879
880
|
var legacyDragHandleEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : true;
|
|
880
881
|
var surfaceNodePositionsEnabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
882
|
+
var rightSurfaceEnabled = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
881
883
|
var _getIntl = getIntl(),
|
|
882
884
|
formatMessage = _getIntl.formatMessage;
|
|
883
|
-
var isAdvancedLayoutEnabled = (0,
|
|
885
|
+
var isAdvancedLayoutEnabled = (0, _editorExperiment.editorExperiment)('advanced_layouts', true, {
|
|
884
886
|
exposure: true
|
|
885
887
|
});
|
|
886
888
|
var toolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
@@ -889,7 +891,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
889
891
|
surfaceNodePositionsEnabled: surfaceNodePositionsEnabled,
|
|
890
892
|
toolbarFlagsEnabled: toolbarFlagsEnabled
|
|
891
893
|
};
|
|
892
|
-
var
|
|
894
|
+
var resolvedSurfaces = surfaceNodePositionsEnabled ? [(0, _surfaceRenderer.resolveSurface)((_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(_surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [], _surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE)].concat((0, _toConsumableArray2.default)(rightSurfaceEnabled ? [(0, _surfaceRenderer.resolveSurface)((_api$uiControlRegistr3 = api === null || api === void 0 || (_api$uiControlRegistr4 = api.uiControlRegistry) === null || _api$uiControlRegistr4 === void 0 ? void 0 : _api$uiControlRegistr4.actions.getComponents(_surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE)) !== null && _api$uiControlRegistr3 !== void 0 ? _api$uiControlRegistr3 : [], _surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE)] : [])) : [];
|
|
893
895
|
var anchorRectCache;
|
|
894
896
|
if (!(0, _anchorUtils.isAnchorSupported)()) {
|
|
895
897
|
anchorRectCache = new _anchorUtils.AnchorRectCache();
|
|
@@ -901,11 +903,11 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
901
903
|
state: {
|
|
902
904
|
init: function init(_config, editorState) {
|
|
903
905
|
return _objectSpread(_objectSpread({}, initialState), {}, {
|
|
904
|
-
surfaceNodePositions:
|
|
906
|
+
surfaceNodePositions: resolvedSurfaces.length > 0 ? (0, _surfaceNodePositions.getSurfaceNodePositions)(editorState, resolvedSurfaces) : []
|
|
905
907
|
});
|
|
906
908
|
},
|
|
907
909
|
apply: function apply(tr, currentState, _, newState) {
|
|
908
|
-
return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup,
|
|
910
|
+
return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, resolvedSurfaces);
|
|
909
911
|
}
|
|
910
912
|
},
|
|
911
913
|
props: {
|
|
@@ -1083,7 +1085,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
1083
1085
|
if (api !== null && api !== void 0 && (_api$limitedMode7 = api.limitedMode) !== null && _api$limitedMode7 !== void 0 && (_api$limitedMode7 = _api$limitedMode7.sharedState.currentState()) !== null && _api$limitedMode7 !== void 0 && _api$limitedMode7.enabled) {
|
|
1084
1086
|
return;
|
|
1085
1087
|
}
|
|
1086
|
-
return (0,
|
|
1088
|
+
return (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _handleMouseDown.handleMouseDown)(api)(view, event) : undefined;
|
|
1087
1089
|
},
|
|
1088
1090
|
keydown: function keydown(view, event) {
|
|
1089
1091
|
var _api$limitedMode8;
|
|
@@ -1097,13 +1099,13 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
1097
1099
|
return true;
|
|
1098
1100
|
}
|
|
1099
1101
|
}
|
|
1100
|
-
if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && (0,
|
|
1101
|
-
var isDragHandle = event.target.closest((0,
|
|
1102
|
+
if ((event.key === 'Enter' || event.key === ' ') && event.target instanceof HTMLElement && (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
1103
|
+
var isDragHandle = event.target.closest((0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true) ? _styles.DRAG_HANDLE_SELECTOR : '[data-editor-block-ctrl-drag-handle="true"]') !== null;
|
|
1102
1104
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.blockControls.commands.setSelectedViaDragHandle(isDragHandle));
|
|
1103
1105
|
}
|
|
1104
|
-
if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && (0,
|
|
1106
|
+
if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'ArrowDown' || event.key === 'ArrowUp') && (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
1105
1107
|
var _api$blockControls$sh2, _api$blockControls$sh3;
|
|
1106
|
-
var isBlockMenuOpen = (api === null || api === void 0 || (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh2 === void 0 ? void 0 : _api$blockControls$sh2.isMenuOpen) && (0,
|
|
1108
|
+
var isBlockMenuOpen = (api === null || api === void 0 || (_api$blockControls$sh2 = api.blockControls.sharedState.currentState()) === null || _api$blockControls$sh2 === void 0 ? void 0 : _api$blockControls$sh2.isMenuOpen) && (0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true);
|
|
1107
1109
|
// when block menu is just open, and we press arrow keys, we want to use the arrow keys to navigate the block menu
|
|
1108
1110
|
// in this scenario, isSelectedViaDragHandle should not be set to false
|
|
1109
1111
|
if (api !== null && api !== void 0 && (_api$blockControls$sh3 = api.blockControls.sharedState.currentState()) !== null && _api$blockControls$sh3 !== void 0 && _api$blockControls$sh3.isSelectedViaDragHandle && !isBlockMenuOpen) {
|
|
@@ -1133,7 +1135,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
1133
1135
|
if (api !== null && api !== void 0 && (_api$limitedMode0 = api.limitedMode) !== null && _api$limitedMode0 !== void 0 && (_api$limitedMode0 = _api$limitedMode0.sharedState.currentState()) !== null && _api$limitedMode0 !== void 0 && _api$limitedMode0.enabled) {
|
|
1134
1136
|
return;
|
|
1135
1137
|
}
|
|
1136
|
-
if ((0,
|
|
1138
|
+
if ((0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
1137
1139
|
var _api$core2;
|
|
1138
1140
|
// Focus moving into the registry surface remains inside the editor experience.
|
|
1139
1141
|
var isChildOfSurface = !flags.legacyDragHandleEnabled && event.relatedTarget instanceof HTMLElement && event.relatedTarget.closest(_consts.BLOCK_CONTROLS_SURFACE_SELECTOR) !== null;
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.unmountFromMountPoint = exports.renderToMountPoint = void 0;
|
|
8
8
|
var _reactDom = _interopRequireWildcard(require("react-dom"));
|
|
9
9
|
var _client = require("react-dom/client");
|
|
10
|
-
var
|
|
10
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
11
11
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
12
|
/**
|
|
13
13
|
* Shared registry of React roots created via `createRoot`.
|
|
@@ -21,16 +21,16 @@ var reactRoots = new WeakMap();
|
|
|
21
21
|
/**
|
|
22
22
|
* Mounts `element` into `mountPoint`.
|
|
23
23
|
*
|
|
24
|
-
* When `
|
|
24
|
+
* When `platform_editor_react19_migration` is **on**, uses the React 18/19 `createRoot`
|
|
25
25
|
* API wrapped in `flushSync` so the render is synchronous – matching the
|
|
26
26
|
* legacy `ReactDOM.render` timing that ProseMirror decoration widgets depend
|
|
27
27
|
* on (focus management, anchor positioning, block-menu visibility all read
|
|
28
28
|
* the rendered DOM immediately after the callback returns).
|
|
29
29
|
*
|
|
30
|
-
*
|
|
30
|
+
* Otherwise, falls back to the legacy `ReactDOM.render` path.
|
|
31
31
|
*/
|
|
32
32
|
var renderToMountPoint = exports.renderToMountPoint = function renderToMountPoint(element, mountPoint) {
|
|
33
|
-
if ((0,
|
|
33
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_react19_migration')) {
|
|
34
34
|
var root = reactRoots.get(mountPoint);
|
|
35
35
|
if (!root) {
|
|
36
36
|
root = (0, _client.createRoot)(mountPoint);
|
|
@@ -51,13 +51,13 @@ var renderToMountPoint = exports.renderToMountPoint = function renderToMountPoin
|
|
|
51
51
|
/**
|
|
52
52
|
* Unmounts the React tree at `mountPoint`.
|
|
53
53
|
*
|
|
54
|
-
* When `
|
|
54
|
+
* When `platform_editor_react19_migration` is **on**, looks up the root in the shared
|
|
55
55
|
* registry, calls `root.unmount()`, and removes the entry.
|
|
56
56
|
*
|
|
57
|
-
*
|
|
57
|
+
* Otherwise, falls back to `ReactDOM.unmountComponentAtNode`.
|
|
58
58
|
*/
|
|
59
59
|
var unmountFromMountPoint = exports.unmountFromMountPoint = function unmountFromMountPoint(mountPoint) {
|
|
60
|
-
if ((0,
|
|
60
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_react19_migration')) {
|
|
61
61
|
var root = reactRoots.get(mountPoint);
|
|
62
62
|
if (root) {
|
|
63
63
|
root.unmount();
|
|
@@ -11,7 +11,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
11
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
12
|
var _events = require("events");
|
|
13
13
|
var _react = require("react");
|
|
14
|
-
var
|
|
14
|
+
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
15
15
|
var ActiveAnchorTracker = exports.ActiveAnchorTracker = /*#__PURE__*/function () {
|
|
16
16
|
function ActiveAnchorTracker() {
|
|
17
17
|
(0, _classCallCheck2.default)(this, ActiveAnchorTracker);
|
|
@@ -71,7 +71,7 @@ var useActiveAnchorTracker = exports.useActiveAnchorTracker = function useActive
|
|
|
71
71
|
setIsActive(eventIsActive);
|
|
72
72
|
};
|
|
73
73
|
(0, _react.useEffect)(function () {
|
|
74
|
-
if (activeAnchorTracker && anchorName && (0,
|
|
74
|
+
if (activeAnchorTracker && anchorName && (0, _editorExperiment.editorExperiment)('advanced_layouts', true)) {
|
|
75
75
|
activeAnchorTracker.subscribe(anchorName, onActive);
|
|
76
76
|
if (activeAnchorTracker.getActiveAnchor() === anchorName) {
|
|
77
77
|
setIsActive(true);
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.maxLayoutColumnSupported = exports.MIN_LAYOUT_COLUMN = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
8
8
|
var maxLayoutColumnSupported = exports.maxLayoutColumnSupported = function maxLayoutColumnSupported() {
|
|
9
|
-
return (0,
|
|
9
|
+
return (0, _editorExperiment.editorExperiment)('advanced_layouts', true) ? 5 : 3;
|
|
10
10
|
};
|
|
11
11
|
var MIN_LAYOUT_COLUMN = exports.MIN_LAYOUT_COLUMN = 2;
|
|
@@ -9,7 +9,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
9
9
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
10
10
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
11
11
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
12
|
-
var
|
|
12
|
+
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
13
13
|
var _consts = require("../../ui/consts");
|
|
14
14
|
var STICKY_NODES = ['panel', 'table', 'expand', 'layoutSection', 'bodiedExtension'];
|
|
15
15
|
var getTopPosition = exports.getTopPosition = function getTopPosition(dom, type) {
|
|
@@ -67,24 +67,24 @@ var getStickyNodes = (0, _memoizeOne.default)(function () {
|
|
|
67
67
|
return [].concat(STICKY_NODES, (0, _toConsumableArray2.default)((0, _expValEquals.expValEquals)('confluence_native_tabs_experiment', 'isEnabled', true) ? ['multiBodiedExtension'] : []));
|
|
68
68
|
});
|
|
69
69
|
var shouldBeSticky = exports.shouldBeSticky = function shouldBeSticky(nodeType) {
|
|
70
|
-
return (0,
|
|
70
|
+
return (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') && getStickyNodes().includes(nodeType);
|
|
71
71
|
};
|
|
72
72
|
var getControlBottomCSSValue = exports.getControlBottomCSSValue = function getControlBottomCSSValue(anchor, isSticky, isTopLevelNode, isLayoutColumn, fallbackAnchor) {
|
|
73
73
|
if ((0, _expValEquals.expValEquals)('platform_editor_controls_reliable_anchor', 'isEnabled', true)) {
|
|
74
|
-
return (0,
|
|
74
|
+
return (0, _editorExperiment.editorExperiment)('advanced_layouts', true) && isLayoutColumn || !isSticky || !isTopLevelNode ? {
|
|
75
75
|
bottom: 'unset'
|
|
76
76
|
} : {
|
|
77
77
|
bottom: fallbackAnchor ? "anchor(".concat(anchor, " end, anchor(").concat(fallbackAnchor, " end))") : "anchor(".concat(anchor, " end)")
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
return (0,
|
|
80
|
+
return (0, _editorExperiment.editorExperiment)('advanced_layouts', true) && isLayoutColumn || !isSticky || !isTopLevelNode ? {
|
|
81
81
|
bottom: 'unset'
|
|
82
82
|
} : {
|
|
83
83
|
bottom: "anchor(".concat(anchor, " end)")
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
86
|
var getControlHeightCSSValue = exports.getControlHeightCSSValue = function getControlHeightCSSValue(nodeHeight, isSticky, isTopLevelNode, fallbackPxHeight, isLayoutColumn) {
|
|
87
|
-
return (0,
|
|
87
|
+
return (0, _editorExperiment.editorExperiment)('advanced_layouts', true) && isLayoutColumn || !isSticky || !isTopLevelNode ? {
|
|
88
88
|
height: 'unset'
|
|
89
89
|
} : {
|
|
90
90
|
height: "".concat(nodeHeight || fallbackPxHeight, "px")
|
|
@@ -93,6 +93,6 @@ var getControlHeightCSSValue = exports.getControlHeightCSSValue = function getCo
|
|
|
93
93
|
var shouldMaskNodeControls = exports.shouldMaskNodeControls = function shouldMaskNodeControls(nodeType, isTopLevelNode) {
|
|
94
94
|
return (
|
|
95
95
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
96
|
-
isTopLevelNode && ['table'].includes(nodeType) && (0,
|
|
96
|
+
isTopLevelNode && ['table'].includes(nodeType) && (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1')
|
|
97
97
|
);
|
|
98
98
|
};
|
|
@@ -10,7 +10,7 @@ var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
11
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
12
12
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
13
|
-
var
|
|
13
|
+
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
14
14
|
var _getSelection = require("./getSelection");
|
|
15
15
|
var _selection2 = require("./selection");
|
|
16
16
|
var isPosWithinRange = function isPosWithinRange(pos, range) {
|
|
@@ -66,7 +66,7 @@ var expandAndUpdateSelection = exports.expandAndUpdateSelection = function expan
|
|
|
66
66
|
tr.setSelection(_state.TextSelection.create(tr.doc, Math.min(selection.from, expandedRange.$from.pos), Math.max(selection.to, expandedRange.$to.pos)));
|
|
67
67
|
} else if (
|
|
68
68
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
69
|
-
(0, _fg.fg)('platform_editor_maui_jira_updates') && ((0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) || (0,
|
|
69
|
+
(0, _fg.fg)('platform_editor_maui_jira_updates') && ((0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) || (0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true))) {
|
|
70
70
|
// Under the gate (and when on the simplified newGetSelection path), use
|
|
71
71
|
// the platform-level composer — same path as open-remix-modal, no drift.
|
|
72
72
|
(0, _nodeSelection.selectNodeAtPos)(tr, startPos, nodeType);
|
|
@@ -11,7 +11,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
11
11
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
12
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
13
13
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
14
|
-
var
|
|
14
|
+
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
15
15
|
var getInlineNodePos = exports.getInlineNodePos = function getInlineNodePos(doc, start, nodeSize) {
|
|
16
16
|
var $startPos = doc.resolve(start);
|
|
17
17
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
@@ -100,14 +100,14 @@ var newGetSelection = exports.newGetSelection = function newGetSelection(doc, se
|
|
|
100
100
|
// inline nodes correctly with TextSelection.
|
|
101
101
|
if (
|
|
102
102
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
103
|
-
(0, _fg.fg)('platform_editor_maui_jira_updates') && (0,
|
|
103
|
+
(0, _fg.fg)('platform_editor_maui_jira_updates') && (0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true)) {
|
|
104
104
|
return (0, _nodeSelection.getNodeSelectionForPos)(doc, start) || false;
|
|
105
105
|
}
|
|
106
106
|
var node = doc.nodeAt(start);
|
|
107
107
|
var isNodeSelection = node && _state.NodeSelection.isSelectable(node);
|
|
108
108
|
var nodeSize = node ? node.nodeSize : 1;
|
|
109
109
|
var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
|
|
110
|
-
if ((0,
|
|
110
|
+
if ((0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true)) {
|
|
111
111
|
// if mediaGroup only has a single child, we want to select the child
|
|
112
112
|
if (nodeName === 'mediaGroup' && (node === null || node === void 0 ? void 0 : node.childCount) === 1) {
|
|
113
113
|
var $mediaStartPos = doc.resolve(start + 1);
|
|
@@ -142,7 +142,7 @@ var newGetSelection = exports.newGetSelection = function newGetSelection(doc, se
|
|
|
142
142
|
return new _state.TextSelection(doc.resolve(inlineNodePos), doc.resolve(inlineNodeEndPos));
|
|
143
143
|
};
|
|
144
144
|
var getSelection = exports.getSelection = function getSelection(tr, start, api) {
|
|
145
|
-
if ((0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) || (0,
|
|
145
|
+
if ((0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) || (0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true)) {
|
|
146
146
|
return newGetSelection(tr.doc, tr.selection.empty, start);
|
|
147
147
|
}
|
|
148
148
|
return oldGetSelection(tr, start);
|
|
@@ -154,7 +154,7 @@ var selectNode = exports.selectNode = function selectNode(tr, start, nodeType, a
|
|
|
154
154
|
// TextSelection) in legacy contexts where those flags are off.
|
|
155
155
|
if (
|
|
156
156
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
157
|
-
(0, _fg.fg)('platform_editor_maui_jira_updates') && (0,
|
|
157
|
+
(0, _fg.fg)('platform_editor_maui_jira_updates') && (0, _editorExperiment.editorExperiment)('platform_editor_block_menu', true)) {
|
|
158
158
|
return (0, _nodeSelection.selectNodeAtPos)(tr, start, nodeType);
|
|
159
159
|
}
|
|
160
160
|
if (nodeType === 'table') {
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.shouldAllowInlineDropTarget = void 0;
|
|
7
7
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
-
var
|
|
8
|
+
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
9
9
|
var _checkMediaLayout = require("./check-media-layout");
|
|
10
10
|
var _consts = require("./consts");
|
|
11
11
|
var syncedBlockTypes = ['syncBlock', 'bodiedSyncBlock'];
|
|
@@ -14,7 +14,7 @@ var shouldAllowInlineDropTarget = exports.shouldAllowInlineDropTarget = function
|
|
|
14
14
|
var activeNode = arguments.length > 3 ? arguments[3] : undefined;
|
|
15
15
|
var parentNode = arguments.length > 4 ? arguments[4] : undefined;
|
|
16
16
|
var isInsideBodiedSyncBlock = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) === 'bodiedSyncBlock';
|
|
17
|
-
if ((0,
|
|
17
|
+
if ((0, _editorExperiment.editorExperiment)('advanced_layouts', false) || isNested) {
|
|
18
18
|
// If nested inside bodiedSyncBlock, enable inline drop target so user can drop to create a layout inside it
|
|
19
19
|
if (isInsideBodiedSyncBlock) {
|
|
20
20
|
return true;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.removeFromSource = void 0;
|
|
7
7
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
8
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
-
var
|
|
9
|
+
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
10
10
|
var _checkFragment = require("./check-fragment");
|
|
11
11
|
var _consts = require("./consts");
|
|
12
12
|
var _updateColumnWidths = require("./update-column-widths");
|
|
@@ -19,7 +19,7 @@ var removeFromSource = exports.removeFromSource = function removeFromSource(tr,
|
|
|
19
19
|
* that contains only 2 child node, and single column layouts are not enabled.
|
|
20
20
|
* In this case, we delete the layout column and replace it with its content.
|
|
21
21
|
*/
|
|
22
|
-
if (isLayoutColumn && !(0,
|
|
22
|
+
if (isLayoutColumn && !(0, _editorExperiment.editorExperiment)('single_column_layouts', true)) {
|
|
23
23
|
var sourceParent = $from.parent;
|
|
24
24
|
if (sourceParent.childCount === _consts.MIN_LAYOUT_COLUMN) {
|
|
25
25
|
// Only delete the layout content, but keep the layout column itself
|
|
@@ -14,19 +14,39 @@ var createSurfaceContextAtPosition = function createSurfaceContextAtPosition(sta
|
|
|
14
14
|
var blockControlsContext = (0, _blockControlsSurfaceContext.createBlockControlsSurfaceContextForPosition)(state, position, activeNode);
|
|
15
15
|
return blockControlsContext ? (0, _types.createSurfaceContext)(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT, blockControlsContext) : undefined;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A position qualifies as soon as ANY of the given surfaces would render something for it.
|
|
20
|
+
* The surface context depends only on state/position/activeNode, not on which surface is being
|
|
21
|
+
* checked, so it's built once here rather than once per surface inside the `.some()`.
|
|
22
|
+
*/
|
|
23
|
+
var willAnySurfaceRenderAt = function willAnySurfaceRenderAt(surfaces, state, position, activeNode) {
|
|
24
|
+
var surfaceContext = createSurfaceContextAtPosition(state, position, activeNode);
|
|
25
|
+
return surfaces.some(function (_ref) {
|
|
26
|
+
var childrenMap = _ref.childrenMap,
|
|
27
|
+
root = _ref.root;
|
|
28
|
+
return (0, _surfaceRenderer.willComponentRender)(root, childrenMap, surfaceContext);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
var getSurfaceNodePositions = exports.getSurfaceNodePositions = function getSurfaceNodePositions(state, resolvedSurfaces, activeNode) {
|
|
18
32
|
var from = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
19
33
|
var to = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : state.doc.content.size;
|
|
20
|
-
var
|
|
21
|
-
childrenMap =
|
|
22
|
-
|
|
34
|
+
var surfaces = resolvedSurfaces.flatMap(function (_ref2) {
|
|
35
|
+
var childrenMap = _ref2.childrenMap,
|
|
36
|
+
root = _ref2.root;
|
|
37
|
+
return root ? [{
|
|
38
|
+
childrenMap: childrenMap,
|
|
39
|
+
root: root
|
|
40
|
+
}] : [];
|
|
41
|
+
});
|
|
42
|
+
if (surfaces.length === 0) {
|
|
23
43
|
return [];
|
|
24
44
|
}
|
|
25
45
|
var positions = [];
|
|
26
46
|
var start = Math.max(0, from);
|
|
27
47
|
var end = Math.min(state.doc.content.size, Math.max(start, to));
|
|
28
48
|
state.doc.nodesBetween(start, end, function (node, position) {
|
|
29
|
-
if (node.isBlock && (
|
|
49
|
+
if (node.isBlock && willAnySurfaceRenderAt(surfaces, state, position, activeNode)) {
|
|
30
50
|
positions.push(position);
|
|
31
51
|
}
|
|
32
52
|
});
|
|
@@ -35,25 +55,31 @@ var getSurfaceNodePositions = exports.getSurfaceNodePositions = function getSurf
|
|
|
35
55
|
var hasActiveNodeChanged = function hasActiveNodeChanged(previousActiveNode, activeNode) {
|
|
36
56
|
return (previousActiveNode === null || previousActiveNode === void 0 ? void 0 : previousActiveNode.pos) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos) || (previousActiveNode === null || previousActiveNode === void 0 ? void 0 : previousActiveNode.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || (previousActiveNode === null || previousActiveNode === void 0 ? void 0 : previousActiveNode.rootPos) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.rootPos);
|
|
37
57
|
};
|
|
38
|
-
var updateSurfaceNodePositions = exports.updateSurfaceNodePositions = function updateSurfaceNodePositions(
|
|
39
|
-
var activeNode =
|
|
40
|
-
currentPositions =
|
|
41
|
-
from =
|
|
42
|
-
newState =
|
|
43
|
-
previousActiveNode =
|
|
44
|
-
|
|
45
|
-
to =
|
|
46
|
-
tr =
|
|
58
|
+
var updateSurfaceNodePositions = exports.updateSurfaceNodePositions = function updateSurfaceNodePositions(_ref3) {
|
|
59
|
+
var activeNode = _ref3.activeNode,
|
|
60
|
+
currentPositions = _ref3.currentPositions,
|
|
61
|
+
from = _ref3.from,
|
|
62
|
+
newState = _ref3.newState,
|
|
63
|
+
previousActiveNode = _ref3.previousActiveNode,
|
|
64
|
+
resolvedSurfaces = _ref3.resolvedSurfaces,
|
|
65
|
+
to = _ref3.to,
|
|
66
|
+
tr = _ref3.tr;
|
|
47
67
|
var activeNodeChanged = hasActiveNodeChanged(previousActiveNode, activeNode);
|
|
48
68
|
if (!tr.docChanged && !activeNodeChanged) {
|
|
49
69
|
return currentPositions;
|
|
50
70
|
}
|
|
51
71
|
var nextActiveNode = activeNode !== null && activeNode !== void 0 ? activeNode : undefined;
|
|
52
72
|
if (activeNodeChanged) {
|
|
53
|
-
return getSurfaceNodePositions(newState,
|
|
73
|
+
return getSurfaceNodePositions(newState, resolvedSurfaces, nextActiveNode);
|
|
54
74
|
}
|
|
55
|
-
var
|
|
56
|
-
childrenMap =
|
|
75
|
+
var surfaces = resolvedSurfaces.flatMap(function (_ref4) {
|
|
76
|
+
var childrenMap = _ref4.childrenMap,
|
|
77
|
+
root = _ref4.root;
|
|
78
|
+
return root ? [{
|
|
79
|
+
childrenMap: childrenMap,
|
|
80
|
+
root: root
|
|
81
|
+
}] : [];
|
|
82
|
+
});
|
|
57
83
|
var mappedPositions = currentPositions.map(function (position) {
|
|
58
84
|
return tr.mapping.mapResult(position, -1);
|
|
59
85
|
}).filter(function (result) {
|
|
@@ -62,9 +88,9 @@ var updateSurfaceNodePositions = exports.updateSurfaceNodePositions = function u
|
|
|
62
88
|
return result.pos;
|
|
63
89
|
}).filter(function (position) {
|
|
64
90
|
var node = newState.doc.nodeAt(position);
|
|
65
|
-
return Boolean((node === null || node === void 0 ? void 0 : node.isBlock) &&
|
|
91
|
+
return Boolean((node === null || node === void 0 ? void 0 : node.isBlock) && willAnySurfaceRenderAt(surfaces, newState, position, nextActiveNode));
|
|
66
92
|
});
|
|
67
|
-
var changedPositions = getSurfaceNodePositions(newState,
|
|
93
|
+
var changedPositions = getSurfaceNodePositions(newState, resolvedSurfaces, nextActiveNode, from - 1, to + 1);
|
|
68
94
|
return Array.from(new Set([].concat((0, _toConsumableArray2.default)(mappedPositions), (0, _toConsumableArray2.default)(changedPositions)))).sort(function (first, second) {
|
|
69
95
|
return first - second;
|
|
70
96
|
});
|
|
@@ -14,7 +14,7 @@ var _nodeTypeUtils = require("@atlaskit/editor-common/utils/node-type-utils");
|
|
|
14
14
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
15
15
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
16
16
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
17
|
-
var
|
|
17
|
+
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
18
18
|
var isInsideTable = exports.isInsideTable = function isInsideTable(nodeType) {
|
|
19
19
|
var _nodeType$schema$node = nodeType.schema.nodes,
|
|
20
20
|
tableCell = _nodeType$schema$node.tableCell,
|
|
@@ -156,7 +156,7 @@ function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNodePos,
|
|
|
156
156
|
var activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type;
|
|
157
157
|
var layoutColumnContent = srcNode.content;
|
|
158
158
|
var isNestingTablesSupported = (0, _nesting.isNestedTablesSupported)(schema);
|
|
159
|
-
if (activeNodeType === layoutColumn && (0,
|
|
159
|
+
if (activeNodeType === layoutColumn && (0, _editorExperiment.editorExperiment)('advanced_layouts', true)) {
|
|
160
160
|
// Allow drag layout column and drop into layout section
|
|
161
161
|
if ((destNode === null || destNode === void 0 ? void 0 : destNode.type) === layoutSection || destParentNodeType === doc) {
|
|
162
162
|
return true;
|
|
@@ -18,9 +18,9 @@ var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys"
|
|
|
18
18
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
19
19
|
var _createSurfaceContext = require("@atlaskit/editor-ui-control-model/create-surface-context");
|
|
20
20
|
var _decorationsCommon = require("../pm-plugins/decorations-common");
|
|
21
|
-
var _blockControlsSurfaceContext = require("./block-controls-surface-context");
|
|
22
21
|
var _blockControlsLeftSurface = require("./block-controls-left-surface");
|
|
23
|
-
var
|
|
22
|
+
var _blockControlsSurfaceContext = require("./block-controls-surface-context");
|
|
23
|
+
var _blockControlsSurfaceTargets = require("./block-controls-surface-targets");
|
|
24
24
|
var _getNodeContentElement = require("./utils/get-node-content-element");
|
|
25
25
|
var _getSurfacePlacement = require("./utils/get-surface-placement");
|
|
26
26
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -46,7 +46,7 @@ var BlockControlsLeftSurfaces = exports.BlockControlsLeftSurfaces = function Blo
|
|
|
46
46
|
surfaceNodePositions = _useSharedPluginState.surfaceNodePositions;
|
|
47
47
|
var components = (_api$uiControlRegistr = (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(_surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : EMPTY_SURFACE_COMPONENTS;
|
|
48
48
|
var targets = (0, _react.useMemo)(function () {
|
|
49
|
-
return (0,
|
|
49
|
+
return (0, _blockControlsSurfaceTargets.getBlockControlsSurfaceTargets)(activeNode, surfaceNodePositions);
|
|
50
50
|
}, [activeNode, surfaceNodePositions]);
|
|
51
51
|
var surfaces = (0, _react.useMemo)(function () {
|
|
52
52
|
return targets.flatMap(function (target) {
|
|
@@ -115,7 +115,8 @@ var BlockControlsLeftSurfaces = exports.BlockControlsLeftSurfaces = function Blo
|
|
|
115
115
|
nodeRect: targetElement.getBoundingClientRect(),
|
|
116
116
|
nodeType: blockControlsContext.targetNode.type.name,
|
|
117
117
|
nodeTypeWithLevel: (0, _decorationsCommon.getNodeTypeWithLevel)(blockControlsContext.targetNode.node),
|
|
118
|
-
parentNodeType: blockControlsContext.targetNode.parentType === 'doc' ? undefined : blockControlsContext.targetNode.parentType
|
|
118
|
+
parentNodeType: blockControlsContext.targetNode.parentType === 'doc' ? undefined : blockControlsContext.targetNode.parentType,
|
|
119
|
+
side: 'left'
|
|
119
120
|
});
|
|
120
121
|
nextPlacements.set(position, (0, _getSurfacePlacement.getAbsoluteSurfacePlacement)({
|
|
121
122
|
offsetParentRect: offsetParentRect,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* block-controls-right-surface.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.BlockControlsRightSurface = void 0;
|
|
9
|
+
require("./block-controls-right-surface.compiled.css");
|
|
10
|
+
var _runtime = require("@compiled/react/runtime");
|
|
11
|
+
var _react = _interopRequireDefault(require("react"));
|
|
12
|
+
var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys");
|
|
13
|
+
var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
|
|
14
|
+
var _visibilityContainer = require("./visibility-container");
|
|
15
|
+
var rightSurfaceStyles = null;
|
|
16
|
+
/** Renders one right block-controls surface at a document position. */
|
|
17
|
+
var BlockControlsRightSurface = exports.BlockControlsRightSurface = function BlockControlsRightSurface(_ref) {
|
|
18
|
+
var api = _ref.api,
|
|
19
|
+
components = _ref.components,
|
|
20
|
+
forceVisibleOnMouseOut = _ref.forceVisibleOnMouseOut,
|
|
21
|
+
placement = _ref.placement,
|
|
22
|
+
source = _ref.source,
|
|
23
|
+
surfaceContext = _ref.surfaceContext;
|
|
24
|
+
if (!placement || !(0, _surfaceRenderer.willSurfaceRender)(components, _surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE, surfaceContext)) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
var surface = /*#__PURE__*/_react.default.createElement(_surfaceRenderer.SurfaceRenderer, {
|
|
28
|
+
components: components,
|
|
29
|
+
surface: _surfaceKeys.BLOCK_CONTROLS_RIGHT_SURFACE,
|
|
30
|
+
surfaceContext: surfaceContext
|
|
31
|
+
});
|
|
32
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
33
|
+
"data-editor-block-controls-surface": true,
|
|
34
|
+
"data-testid": source === 'stored' ? 'block-controls-right-surface-stored' : source === 'active' ? 'block-controls-right-surface-active' : 'block-controls-right-surface'
|
|
35
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Placement is resolved from the target node's runtime DOM geometry.
|
|
36
|
+
,
|
|
37
|
+
style: placement,
|
|
38
|
+
className: (0, _runtime.ax)(["_zulpv77o _4cvr1h6o _1e0c1txw _kqswstnw _1pbyb4wl"])
|
|
39
|
+
}, /*#__PURE__*/_react.default.createElement(_visibilityContainer.VisibilityContainer, {
|
|
40
|
+
api: api,
|
|
41
|
+
controlSide: "right",
|
|
42
|
+
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
43
|
+
shouldUseDisplayContents: true
|
|
44
|
+
}, surface));
|
|
45
|
+
};
|