@atlaskit/editor-plugin-block-controls 32.0.1 → 34.0.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 +18 -0
- package/dist/cjs/blockControlsPlugin.js +1 -2
- package/dist/cjs/editor-commands/move-node.js +1 -1
- package/dist/cjs/pm-plugins/decorations-drag-handle.js +5 -7
- package/dist/cjs/pm-plugins/handle-mouse-over.js +21 -33
- package/dist/cjs/pm-plugins/main.js +115 -170
- package/dist/cjs/pm-plugins/utils/getSelection.js +2 -3
- package/dist/cjs/pm-plugins/utils/transactions.js +2 -5
- package/dist/cjs/ui/global-styles.js +1 -19
- package/dist/es2019/blockControlsPlugin.js +1 -2
- package/dist/es2019/editor-commands/move-node.js +1 -1
- package/dist/es2019/pm-plugins/decorations-drag-handle.js +4 -7
- package/dist/es2019/pm-plugins/handle-mouse-over.js +21 -33
- package/dist/es2019/pm-plugins/main.js +85 -138
- package/dist/es2019/pm-plugins/utils/getSelection.js +2 -3
- package/dist/es2019/pm-plugins/utils/transactions.js +2 -5
- package/dist/es2019/ui/global-styles.js +1 -22
- package/dist/esm/blockControlsPlugin.js +1 -2
- package/dist/esm/editor-commands/move-node.js +1 -1
- package/dist/esm/pm-plugins/decorations-drag-handle.js +3 -7
- package/dist/esm/pm-plugins/handle-mouse-over.js +21 -33
- package/dist/esm/pm-plugins/main.js +115 -170
- package/dist/esm/pm-plugins/utils/getSelection.js +2 -3
- package/dist/esm/pm-plugins/utils/transactions.js +2 -5
- package/dist/esm/ui/global-styles.js +1 -19
- package/dist/types/pm-plugins/main.d.ts +1 -4
- package/dist/types/pm-plugins/utils/getSelection.d.ts +1 -1
- package/dist/types/pm-plugins/utils/transactions.d.ts +1 -2
- package/package.json +21 -21
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import { css, Global, jsx } from '@emotion/react';
|
|
7
7
|
import { DRAG_HANDLE_WIDTH } from '@atlaskit/editor-common/styles/drag-handle';
|
|
8
8
|
import { ANCHOR_VARIABLE_NAME, isCSSAnchorSupported } from '@atlaskit/editor-common/styles/native-anchor';
|
|
9
|
-
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
10
9
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/useSharedPluginStateWithSelector';
|
|
11
10
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace/whitespace';
|
|
12
11
|
import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorFullPageNarrowBreakout, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced } from '@atlaskit/editor-shared-styles/constants';
|
|
@@ -248,27 +247,10 @@ const extendedDragZoneNext = css({
|
|
|
248
247
|
}
|
|
249
248
|
}
|
|
250
249
|
});
|
|
251
|
-
const paragraphWithTrailingBreakAsOnlyChild = '+ :is(p, h1, h2, h3, h4, h5, h6) > .ProseMirror-trailingBreak:only-child';
|
|
252
|
-
const indentatedParagraphWithTrailingBreakAsOnlyChild = '+ div.fabric-editor-indentation-mark > :is(p, h1, h2, h3, h4, h5, h6) > .ProseMirror-trailingBreak:only-child';
|
|
253
|
-
const paragraphWithPlaceholder = '+ p > .placeholder-decoration';
|
|
254
250
|
const dragHandleContainer = '.ProseMirror-widget[data-blocks-drag-handle-container="true"]';
|
|
255
|
-
const dragHandleSelector = 'button[data-testid="block-ctrl-drag-handle"]';
|
|
256
251
|
const dropTargetContainer = '.ProseMirror-widget[data-blocks-drop-target-container="true"]';
|
|
257
252
|
const dividerBodiedInCustomPanelWithNoIconSelector = '[data-panel-type].ak-editor-panel__no-icon .ProseMirror-widget:first-child + .ProseMirror-widget:nth-child(2) + hr, [data-panel-type] hr:first-child';
|
|
258
|
-
const withInlineNodeStyleSelectors = [`${dragHandleContainer}:has(${paragraphWithTrailingBreakAsOnlyChild}) ${dragHandleSelector}`, `${dragHandleContainer}:has(${indentatedParagraphWithTrailingBreakAsOnlyChild}) ${dragHandleSelector}`, `${dragHandleContainer}:has(${paragraphWithPlaceholder}) ${dragHandleSelector}`].join(', ');
|
|
259
253
|
const withFormatInLayoutStyleFixSelectors = [`${dragHandleContainer}:first-child + .fabric-editor-indentation-mark > p:first-child`, `${dragHandleContainer}:first-child + .fabric-editor-alignment > p:first-child`, `${dragHandleContainer}:first-child + .fabric-editor-font-size > p:first-child`, `${dragHandleContainer}:first-child + ${dropTargetContainer} + .fabric-editor-indentation-mark > p:first-child`, `${dragHandleContainer}:first-child + ${dropTargetContainer} + .fabric-editor-alignment > p:first-child`, `${dragHandleContainer}:first-child + ${dropTargetContainer} + .fabric-editor-font-size > p:first-child`, `${dropTargetContainer}:first-child + .fabric-editor-alignment > p:first-child`, `${dropTargetContainer}:first-child + .fabric-editor-indentation-mark > p:first-child`, `${dropTargetContainer}:first-child + .fabric-editor-font-size > p:first-child`, `${dragHandleContainer}:first-child + .fabric-editor-indentation-mark > :is(h1, h2, h3, h4, h5, h6):first-child`, `${dragHandleContainer}:first-child + .fabric-editor-font-size > :is(h1, h2, h3, h4, h5, h6):first-child`].join(', ');
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Please do not change change transform to display:none, or visibility:hidden
|
|
263
|
-
* Otherwise it might break composition input for Chrome
|
|
264
|
-
* https://product-fabric.atlassian.net/browse/ED-24136
|
|
265
|
-
*/
|
|
266
|
-
const withInlineNodeStyle = css({
|
|
267
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
268
|
-
[withInlineNodeStyleSelectors]: {
|
|
269
|
-
transform: 'scale(0)'
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
254
|
const legacyBreakoutWideLayoutStyle = css({
|
|
273
255
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
274
256
|
'.ProseMirror-widget[data-blocks-drop-target-container="true"]': {
|
|
@@ -587,15 +569,12 @@ export const GlobalStylesWrapper = ({
|
|
|
587
569
|
const isDragging = isDraggingFromState;
|
|
588
570
|
const shouldRenderAnchors = isCSSAnchorSupported() && expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true);
|
|
589
571
|
const sparseSurfaceAnchorsEnabled = Boolean(isCSSAnchorSupported()) && sparseSurfacesEnabled;
|
|
590
|
-
const toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
591
572
|
return jsx(Global
|
|
592
573
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
593
574
|
, {
|
|
594
575
|
styles: [globalStyles(), globalDnDStyle, (!sparseSurfacesEnabled || isDragging) && (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? extendedHoverZoneNext() : extendedHoverZone()), isDragging && (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? extendedDragZoneNext : extendedDragZone), (!sparseSurfacesEnabled || isDragging) && editorExperiment('platform_editor_preview_panel_responsiveness', true, {
|
|
595
576
|
exposure: true
|
|
596
|
-
}) ? expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
|
|
597
|
-
// this allows drag handles to render on empty lines
|
|
598
|
-
toolbarFlagsEnabled ? undefined : withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, isExperimentEnabled('platform_editor_lovability_dividers') && withRuleOverflowStyleFix, withFormatInLayoutStyleFix, (!sparseSurfacesEnabled || isDragging) && (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? withRelativePosStyleNext : withRelativePosStyle), (!sparseSurfacesEnabled || isDragging) && (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle), (!sparseSurfacesEnabled || isDragging) && ((expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration')) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone), sparseSurfaceAnchorsEnabled ? isDragging ? dragAnchorStyles : false : expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true) ?
|
|
577
|
+
}) ? expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, isExperimentEnabled('platform_editor_lovability_dividers') && withRuleOverflowStyleFix, withFormatInLayoutStyleFix, (!sparseSurfacesEnabled || isDragging) && (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? withRelativePosStyleNext : withRelativePosStyle), (!sparseSurfacesEnabled || isDragging) && (expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration') ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle), (!sparseSurfacesEnabled || isDragging) && ((expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) || isExperimentEnabled('platform_editor_block_control_migration')) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone), sparseSurfaceAnchorsEnabled ? isDragging ? dragAnchorStyles : false : expValEquals('platform_editor_controls_reliable_anchor', 'isEnabled', true) ?
|
|
599
578
|
// dragAnchorStyles sets anchor-name on ALL nodes during drag (needed for drop target positioning).
|
|
600
579
|
// staticControlsAnchorStyles handles anchor-name via node decorations for non-drag state.
|
|
601
580
|
// shouldRenderAnchors guards both: only apply anchor styles on browsers that support CSS anchor positioning.
|
|
@@ -5,7 +5,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
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';
|
|
7
7
|
import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
|
|
8
|
-
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
9
8
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
9
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
11
10
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
@@ -170,7 +169,7 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
170
169
|
// Not registered under the registry migration: the decoration puts an inline
|
|
171
170
|
// `margin-top: 0` on the first document node, which fights features that render their own
|
|
172
171
|
// content above it — a leading show-diff widget is left flush against the node below.
|
|
173
|
-
if (
|
|
172
|
+
if (!registryBlockControlsEnabled) {
|
|
174
173
|
pmPlugins.push({
|
|
175
174
|
name: 'firstNodeDec',
|
|
176
175
|
plugin: firstNodeDecPlugin
|
|
@@ -460,7 +460,7 @@ export var moveNode = function moveNode(api) {
|
|
|
460
460
|
}
|
|
461
461
|
var sliceSize = sliceTo - sliceFrom;
|
|
462
462
|
if (inputMethod === INPUT_METHOD.DRAG_AND_DROP) {
|
|
463
|
-
tr = setCursorPositionAtMovedNode(tr, mappedTo
|
|
463
|
+
tr = setCursorPositionAtMovedNode(tr, mappedTo);
|
|
464
464
|
} else if (preservedSelection) {
|
|
465
465
|
var _currMeta = tr.getMeta(key);
|
|
466
466
|
var nodeMovedOffset = mappedTo - sliceFrom;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
2
|
import { createElement } from 'react';
|
|
5
3
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
6
4
|
import { v4 as uuid } from 'uuid';
|
|
7
5
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
-
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
9
6
|
import { ACTIVE_DRAG_HANDLE_ATTR } from '../ui/consts';
|
|
10
7
|
import { DragHandleWithVisibility } from '../ui/drag-handle';
|
|
11
8
|
import { TYPE_HANDLE_DEC, TYPE_NODE_DEC, unmountDecorations } from './decorations-common';
|
|
@@ -63,7 +60,7 @@ export var dragHandleDecoration = function dragHandleDecoration(_ref) {
|
|
|
63
60
|
unmountDecorations(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
|
|
64
61
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
65
62
|
var key = uuid();
|
|
66
|
-
var widgetSpec =
|
|
63
|
+
var widgetSpec = {
|
|
67
64
|
side: -1,
|
|
68
65
|
type: TYPE_HANDLE_DEC,
|
|
69
66
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
@@ -73,15 +70,14 @@ export var dragHandleDecoration = function dragHandleDecoration(_ref) {
|
|
|
73
70
|
* Exclude 'breakout' on purpose, so the widgets render at the top of the document to avoid z-index issues
|
|
74
71
|
* Other block marks must be added, otherwise PM will split the DOM elements causing mutations and re-draws
|
|
75
72
|
*/
|
|
76
|
-
marks: getMatchingBlockMarks(editorState, pos, [editorState.schema.marks.alignment, editorState.schema.marks.fontSize])
|
|
77
|
-
}, isExperimentEnabled('platform_editor_reduce_memory_leaks') && {
|
|
73
|
+
marks: getMatchingBlockMarks(editorState, pos, [editorState.schema.marks.alignment, editorState.schema.marks.fontSize]),
|
|
78
74
|
destroy: function destroy(node) {
|
|
79
75
|
// Deferred: unmounting a root during a React render warns
|
|
80
76
|
queueMicrotask(function () {
|
|
81
77
|
return unmountUnlessMenuOpen(api, node);
|
|
82
78
|
});
|
|
83
79
|
}
|
|
84
|
-
}
|
|
80
|
+
};
|
|
85
81
|
return Decoration.widget(pos, function (view, getPosUnsafe) {
|
|
86
82
|
var element = document.createElement('span');
|
|
87
83
|
// inline decoration causes focus issues when refocusing Editor into first line
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import memoizeOne from 'memoize-one';
|
|
3
3
|
import { isMultiBlockSelection } from '@atlaskit/editor-common/selection/utils';
|
|
4
|
-
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
5
4
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
6
5
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
7
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
@@ -102,7 +101,6 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
102
101
|
editorDisabled = _ref2.editorDisabled;
|
|
103
102
|
var editorViewMode = api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode;
|
|
104
103
|
var isViewMode = editorViewMode === 'view';
|
|
105
|
-
var toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
106
104
|
|
|
107
105
|
// EDITOR-7926: bail out while a diff is on screen (or a suggestion card is open) so hovering
|
|
108
106
|
// doesn't dispatch showDragHandleAt and cause the drag handle to jitter over the diff.
|
|
@@ -246,47 +244,37 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
246
244
|
var targetPos = view.state.doc.resolve(pos).pos;
|
|
247
245
|
var rootAnchorName;
|
|
248
246
|
var rootNodeType;
|
|
249
|
-
var rootPos;
|
|
250
|
-
|
|
251
247
|
// enables quick insert
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
(_rootDOM$getAttribute2 = rootDOM.getAttribute('data-drag-handler-node-type')) !== null && _rootDOM$getAttribute2 !== void 0 ? _rootDOM$getAttribute2 : getTypeNameFromDom(rootDOM);
|
|
262
|
-
}
|
|
248
|
+
var rootPos = view.state.doc.resolve(pos).before(1);
|
|
249
|
+
if (targetPos !== rootPos) {
|
|
250
|
+
var rootDOM = view.nodeDOM(rootPos);
|
|
251
|
+
if (rootDOM instanceof HTMLElement) {
|
|
252
|
+
var _ref4, _rootDOM$getAttribute, _rootDOM$getAttribute2;
|
|
253
|
+
rootAnchorName = (_ref4 = (_rootDOM$getAttribute = rootDOM.getAttribute(getAnchorAttrName())) !== null && _rootDOM$getAttribute !== void 0 ? _rootDOM$getAttribute : rootDOM.getAttribute(NODE_ANCHOR_ATTR_NAME)) !== null && _ref4 !== void 0 ? _ref4 : undefined;
|
|
254
|
+
rootNodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootDOM) : // Fallback: breakout mark wrappers have no data-drag-handler-node-type;
|
|
255
|
+
// use data-prosemirror-node-name instead.
|
|
256
|
+
(_rootDOM$getAttribute2 = rootDOM.getAttribute('data-drag-handler-node-type')) !== null && _rootDOM$getAttribute2 !== void 0 ? _rootDOM$getAttribute2 : getTypeNameFromDom(rootDOM);
|
|
263
257
|
}
|
|
264
258
|
}
|
|
265
259
|
var nodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootElement) : // Fallback for table nodes: tr has data-prosemirror-node-name but not data-drag-handler-node-type.
|
|
266
260
|
(_rootElement$getAttri2 = rootElement.getAttribute('data-drag-handler-node-type')) !== null && _rootElement$getAttri2 !== void 0 ? _rootElement$getAttri2 : getTypeNameFromDom(rootElement);
|
|
267
261
|
if (nodeType) {
|
|
268
|
-
var _api$userIntent2;
|
|
262
|
+
var _selectionPreservatio, _api$userIntent2;
|
|
269
263
|
// enables quick insert
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
var selection = preservedSelection || view.state.selection;
|
|
274
|
-
var isMultipleSelected = selection && isMultiBlockSelection(selection);
|
|
264
|
+
var preservedSelection = (_selectionPreservatio = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
|
|
265
|
+
var selection = preservedSelection || view.state.selection;
|
|
266
|
+
var isMultipleSelected = selection && isMultiBlockSelection(selection);
|
|
275
267
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
} else {
|
|
284
|
-
var _api$core2, _api$blockControls4;
|
|
285
|
-
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.showDragHandleAt(targetPos, anchorName, nodeType));
|
|
268
|
+
// Only execute when selection is not a multi-selection, block menu is open, and menu is opened via keyboard
|
|
269
|
+
// as when it is a multi-selection, the showDragHandleAt command interfere with selection
|
|
270
|
+
// sometimes makes the multi-selection not continous after block menu is opened with keyboard
|
|
271
|
+
if (!(isMultipleSelected && isMenuOpen && blockMenuOptions !== null && blockMenuOptions !== void 0 && blockMenuOptions.openedViaKeyboard)) {
|
|
272
|
+
var _api$core, _api$blockControls3;
|
|
273
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(targetPos, anchorName, nodeType, undefined, rootPos, rootAnchorName !== null && rootAnchorName !== void 0 ? rootAnchorName : anchorName, rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType));
|
|
286
274
|
}
|
|
287
275
|
if (isMenuOpen && originalAnchorName && (api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || (_api$userIntent2 = _api$userIntent2.sharedState.currentState()) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.currentUserIntent) === 'blockMenuOpen') {
|
|
288
|
-
var _api$
|
|
289
|
-
api === null || api === void 0 || (_api$
|
|
276
|
+
var _api$core2, _api$blockControls4;
|
|
277
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.toggleBlockMenu());
|
|
290
278
|
}
|
|
291
279
|
}
|
|
292
280
|
}
|
|
@@ -12,7 +12,6 @@ import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
|
12
12
|
import { getNodeIdProvider } from '@atlaskit/editor-common/node-anchor-provider';
|
|
13
13
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
14
14
|
import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles/drag-handle';
|
|
15
|
-
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
16
15
|
import { EDIT_AREA_ID } from '@atlaskit/editor-common/ui-toolbar';
|
|
17
16
|
import { isEmptyDocument } from '@atlaskit/editor-common/utils';
|
|
18
17
|
import { PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -173,14 +172,14 @@ var getDecorationAtPos = function getDecorationAtPos(state, decorations, pos, to
|
|
|
173
172
|
var nodeDecAtActivePos = nodeDecsAtActivePos.pop();
|
|
174
173
|
return nodeDecAtActivePos;
|
|
175
174
|
};
|
|
176
|
-
var _apply = function apply(api, formatMessage, tr, currentState, newState,
|
|
177
|
-
var _meta$multiSelectDnD, _api$editorViewMode, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$toggleMenu, _meta$isDragging3, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$lastDragCancell;
|
|
178
|
-
var rightSideControlsEnabled = arguments.length >
|
|
179
|
-
var quickInsertButtonEnabled = arguments.length >
|
|
180
|
-
var anchorRectCache = arguments.length >
|
|
181
|
-
var resizeObserverWidth = arguments.length >
|
|
182
|
-
var pragmaticCleanup = arguments.length >
|
|
183
|
-
var limitedModeTeardown = arguments.length >
|
|
175
|
+
var _apply = function apply(api, formatMessage, tr, currentState, newState, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
|
|
176
|
+
var _meta$multiSelectDnD, _api$editorViewMode, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _latestActiveNode11, _latestActiveNode12, _meta$toggleMenu, _meta$isDragging3, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$lastDragCancell;
|
|
177
|
+
var rightSideControlsEnabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
178
|
+
var quickInsertButtonEnabled = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : true;
|
|
179
|
+
var anchorRectCache = arguments.length > 9 ? arguments[9] : undefined;
|
|
180
|
+
var resizeObserverWidth = arguments.length > 10 ? arguments[10] : undefined;
|
|
181
|
+
var pragmaticCleanup = arguments.length > 11 ? arguments[11] : undefined;
|
|
182
|
+
var limitedModeTeardown = arguments.length > 12 ? arguments[12] : undefined;
|
|
184
183
|
var activeNode = currentState.activeNode,
|
|
185
184
|
decorations = currentState.decorations,
|
|
186
185
|
isResizerResizing = currentState.isResizerResizing,
|
|
@@ -198,7 +197,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
198
197
|
isPMDragging = currentState.isPMDragging,
|
|
199
198
|
lastDragCancelled = currentState.lastDragCancelled;
|
|
200
199
|
var isActiveNodeDeleted = false;
|
|
201
|
-
var _getTrMetadata = getTrMetadata(tr
|
|
200
|
+
var _getTrMetadata = getTrMetadata(tr),
|
|
202
201
|
from = _getTrMetadata.from,
|
|
203
202
|
to = _getTrMetadata.to,
|
|
204
203
|
numReplaceSteps = _getTrMetadata.numReplaceSteps,
|
|
@@ -297,62 +296,50 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
297
296
|
|
|
298
297
|
// enables quick insert
|
|
299
298
|
// don't remap activeNode if it's being dragged
|
|
300
|
-
if (
|
|
301
|
-
|
|
302
|
-
|
|
299
|
+
if (activeNode && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== true) {
|
|
300
|
+
var _mappedRootPos$pos, _mappedRootPos;
|
|
301
|
+
var mappedPos;
|
|
302
|
+
var browser = getBrowserInfo();
|
|
303
|
+
// In safari,
|
|
304
|
+
// sometimes the drag handle for the layout disppears after you click on the handle for a few times
|
|
305
|
+
// Which caused the drag handle onClick event not firing, then block menu wouldn't be opened
|
|
306
|
+
// This is caused by the mappedPos.deletedAfter sometimes returning true in webkit browsers even though the active node still exists
|
|
307
|
+
// 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
|
|
308
|
+
if (browser.webkit) {
|
|
309
|
+
mappedPos = tr.mapping.mapResult(activeNode.pos);
|
|
303
310
|
isActiveNodeDeleted = mappedPos.deleted;
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
nodeType: activeNode.nodeType
|
|
308
|
-
};
|
|
311
|
+
} else {
|
|
312
|
+
mappedPos = tr.mapping.mapResult(activeNode.pos, -1);
|
|
313
|
+
isActiveNodeDeleted = mappedPos.deletedAfter;
|
|
309
314
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
_mappedPos = tr.mapping.mapResult(activeNode.pos, -1);
|
|
325
|
-
isActiveNodeDeleted = _mappedPos.deletedAfter;
|
|
326
|
-
}
|
|
327
|
-
// for editor controls, remap the rootPos as well
|
|
328
|
-
var mappedRootPos;
|
|
329
|
-
if (activeNode.rootPos !== undefined) {
|
|
330
|
-
mappedRootPos = tr.mapping.mapResult(activeNode.rootPos, -1);
|
|
315
|
+
// for editor controls, remap the rootPos as well
|
|
316
|
+
var mappedRootPos;
|
|
317
|
+
if (activeNode.rootPos !== undefined) {
|
|
318
|
+
mappedRootPos = tr.mapping.mapResult(activeNode.rootPos, -1);
|
|
319
|
+
}
|
|
320
|
+
var mappedNodeType = activeNode.nodeType;
|
|
321
|
+
var mappedRootNodeType = activeNode.rootNodeType;
|
|
322
|
+
// Sparse mode does not redraw the old decorations. A block-type transaction may report
|
|
323
|
+
// a text range that excludes the active block position, so always refresh the already
|
|
324
|
+
// active node and root from the new document (for example, paragraph → heading-1).
|
|
325
|
+
if (isExperimentEnabled('platform_editor_block_control_migration')) {
|
|
326
|
+
var mappedNode = newState.doc.nodeAt(mappedPos.pos);
|
|
327
|
+
if (mappedNode !== null && mappedNode !== void 0 && mappedNode.isBlock) {
|
|
328
|
+
mappedNodeType = getNodeTypeWithLevel(mappedNode);
|
|
331
329
|
}
|
|
332
|
-
var
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
// a text range that excludes the active block position, so always refresh the already
|
|
336
|
-
// active node and root from the new document (for example, paragraph → heading-1).
|
|
337
|
-
if (isExperimentEnabled('platform_editor_block_control_migration')) {
|
|
338
|
-
var mappedNode = newState.doc.nodeAt(_mappedPos.pos);
|
|
339
|
-
if (mappedNode !== null && mappedNode !== void 0 && mappedNode.isBlock) {
|
|
340
|
-
mappedNodeType = getNodeTypeWithLevel(mappedNode);
|
|
341
|
-
}
|
|
342
|
-
var mappedRootNode = mappedRootPos ? mappedRootPos.pos === _mappedPos.pos && mappedNode ? mappedNode : newState.doc.nodeAt(mappedRootPos.pos) : undefined;
|
|
343
|
-
if (mappedRootNode !== null && mappedRootNode !== void 0 && mappedRootNode.isBlock) {
|
|
344
|
-
mappedRootNodeType = getNodeTypeWithLevel(mappedRootNode);
|
|
345
|
-
}
|
|
330
|
+
var mappedRootNode = mappedRootPos ? mappedRootPos.pos === mappedPos.pos && mappedNode ? mappedNode : newState.doc.nodeAt(mappedRootPos.pos) : undefined;
|
|
331
|
+
if (mappedRootNode !== null && mappedRootNode !== void 0 && mappedRootNode.isBlock) {
|
|
332
|
+
mappedRootNodeType = getNodeTypeWithLevel(mappedRootNode);
|
|
346
333
|
}
|
|
347
|
-
activeNode = {
|
|
348
|
-
pos: _mappedPos.pos,
|
|
349
|
-
anchorName: activeNode.anchorName,
|
|
350
|
-
nodeType: mappedNodeType,
|
|
351
|
-
rootPos: (_mappedRootPos$pos = (_mappedRootPos = mappedRootPos) === null || _mappedRootPos === void 0 ? void 0 : _mappedRootPos.pos) !== null && _mappedRootPos$pos !== void 0 ? _mappedRootPos$pos : activeNode.rootPos,
|
|
352
|
-
rootAnchorName: activeNode.rootAnchorName,
|
|
353
|
-
rootNodeType: mappedRootNodeType
|
|
354
|
-
};
|
|
355
334
|
}
|
|
335
|
+
activeNode = {
|
|
336
|
+
pos: mappedPos.pos,
|
|
337
|
+
anchorName: activeNode.anchorName,
|
|
338
|
+
nodeType: mappedNodeType,
|
|
339
|
+
rootPos: (_mappedRootPos$pos = (_mappedRootPos = mappedRootPos) === null || _mappedRootPos === void 0 ? void 0 : _mappedRootPos.pos) !== null && _mappedRootPos$pos !== void 0 ? _mappedRootPos$pos : activeNode.rootPos,
|
|
340
|
+
rootAnchorName: activeNode.rootAnchorName,
|
|
341
|
+
rootNodeType: mappedRootNodeType
|
|
342
|
+
};
|
|
356
343
|
}
|
|
357
344
|
if (multiSelectDnD) {
|
|
358
345
|
multiSelectDnD.anchor = tr.mapping.map(multiSelectDnD.anchor);
|
|
@@ -395,43 +382,21 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
395
382
|
decorations = decorations.add(newState.doc, newNodeDecs);
|
|
396
383
|
|
|
397
384
|
// enables quick insert
|
|
398
|
-
if (!
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
// Find the specific dec that the active node corresponds to
|
|
404
|
-
var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
|
|
405
|
-
return (dec === null || dec === void 0 ? void 0 : dec.from) === latestActiveNode.pos;
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
// If multiple decorations at the active node pos, we want the last one
|
|
409
|
-
var nodeDecAtActivePos = nodeDecsAtActivePos.pop();
|
|
410
|
-
|
|
411
|
-
// Update the active node anchor-name and type for accurate positioning
|
|
412
|
-
if (nodeDecAtActivePos) {
|
|
413
|
-
isActiveNodeModified = true;
|
|
414
|
-
latestActiveNode.anchorName = nodeDecAtActivePos.spec.anchorName;
|
|
415
|
-
latestActiveNode.nodeType = nodeDecAtActivePos.spec.nodeType;
|
|
416
|
-
}
|
|
385
|
+
if (latestActiveNode && (!isActiveNodeDeleted || isReplacedWithSameSize)) {
|
|
386
|
+
var nodeDecAtActivePos = getDecorationAtPos(newState, decorations, latestActiveNode.pos, to);
|
|
387
|
+
var rootNodeDecAtActivePos = latestActiveNode.rootPos !== undefined ? getDecorationAtPos(newState, decorations, latestActiveNode.rootPos, to) : undefined;
|
|
388
|
+
if (nodeDecAtActivePos || rootNodeDecAtActivePos) {
|
|
389
|
+
isActiveNodeModified = true;
|
|
417
390
|
}
|
|
418
|
-
} else {
|
|
419
|
-
if (latestActiveNode && (!isActiveNodeDeleted || isReplacedWithSameSize)) {
|
|
420
|
-
var _nodeDecAtActivePos = getDecorationAtPos(newState, decorations, latestActiveNode.pos, to);
|
|
421
|
-
var rootNodeDecAtActivePos = latestActiveNode.rootPos !== undefined ? getDecorationAtPos(newState, decorations, latestActiveNode.rootPos, to) : undefined;
|
|
422
|
-
if (_nodeDecAtActivePos || rootNodeDecAtActivePos) {
|
|
423
|
-
isActiveNodeModified = true;
|
|
424
|
-
}
|
|
425
391
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}
|
|
392
|
+
// Update the active node anchor-name and type for accurate positioning
|
|
393
|
+
if (nodeDecAtActivePos) {
|
|
394
|
+
latestActiveNode.anchorName = nodeDecAtActivePos.spec.anchorName;
|
|
395
|
+
latestActiveNode.nodeType = nodeDecAtActivePos.spec.nodeType;
|
|
396
|
+
}
|
|
397
|
+
if (rootNodeDecAtActivePos) {
|
|
398
|
+
latestActiveNode.rootAnchorName = rootNodeDecAtActivePos.spec.anchorName;
|
|
399
|
+
latestActiveNode.rootNodeType = rootNodeDecAtActivePos.spec.nodeType;
|
|
435
400
|
}
|
|
436
401
|
}
|
|
437
402
|
}
|
|
@@ -454,10 +419,8 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
454
419
|
var shouldRemoveHandle = latestActiveNode ? isResizerResizing || isActiveNodeDeleted && !isReplacedWithSameSize || (meta === null || meta === void 0 ? void 0 : meta.nodeMoved) : true;
|
|
455
420
|
|
|
456
421
|
// enables quick insert
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
shouldRemoveHandle = shouldRemoveHandle || (meta === null || meta === void 0 ? void 0 : meta.editorBlurred);
|
|
460
|
-
}
|
|
422
|
+
// Remove handle dec when editor is blurred
|
|
423
|
+
shouldRemoveHandle = shouldRemoveHandle || (meta === null || meta === void 0 ? void 0 : meta.editorBlurred);
|
|
461
424
|
|
|
462
425
|
// In view mode with right-side controls, remove any lingering drag handle decorations
|
|
463
426
|
// (they may carry over from edit mode). Only remove drag handles specifically, not
|
|
@@ -490,54 +453,52 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
490
453
|
// nodeDecorationRegistry cleanup (e.g. the legacy Remix button) is independent of the legacy
|
|
491
454
|
// quick-insert button, so this must not be gated by quickInsertButtonEnabled — otherwise a
|
|
492
455
|
// stale decoration is left behind whenever platform_editor_block_control_migration is on.
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
456
|
+
// enables quick insert
|
|
457
|
+
if (quickInsertButtonEnabled) {
|
|
458
|
+
var _activeNode7, _activeNode8;
|
|
459
|
+
var oldQuickInsertButton = findQuickInsertInsertButtonDecoration(decorations, (_activeNode7 = activeNode) === null || _activeNode7 === void 0 ? void 0 : _activeNode7.rootPos, (_activeNode8 = activeNode) === null || _activeNode8 === void 0 ? void 0 : _activeNode8.rootPos);
|
|
460
|
+
decorations = decorations.remove(oldQuickInsertButton);
|
|
461
|
+
}
|
|
462
|
+
var _iterator = _createForOfIteratorHelper(nodeDecorationRegistry),
|
|
463
|
+
_step;
|
|
464
|
+
try {
|
|
465
|
+
var _loop2 = function _loop2() {
|
|
466
|
+
var _activeNode1, _activeNode10;
|
|
467
|
+
var factory = _step.value;
|
|
468
|
+
var old = decorations.find((_activeNode1 = activeNode) === null || _activeNode1 === void 0 ? void 0 : _activeNode1.rootPos, (_activeNode10 = activeNode) === null || _activeNode10 === void 0 ? void 0 : _activeNode10.rootPos, function (spec) {
|
|
469
|
+
return spec.type === factory.type;
|
|
470
|
+
});
|
|
471
|
+
decorations = decorations.remove(old);
|
|
472
|
+
};
|
|
473
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
474
|
+
_loop2();
|
|
499
475
|
}
|
|
500
|
-
|
|
501
|
-
|
|
476
|
+
} catch (err) {
|
|
477
|
+
_iterator.e(err);
|
|
478
|
+
} finally {
|
|
479
|
+
_iterator.f();
|
|
480
|
+
}
|
|
481
|
+
if (rightSideControlsEnabled && isViewMode) {
|
|
482
|
+
var _iterator2 = _createForOfIteratorHelper(nodeDecorationRegistry),
|
|
483
|
+
_step2;
|
|
502
484
|
try {
|
|
503
|
-
var
|
|
504
|
-
var
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
485
|
+
var _loop = function _loop() {
|
|
486
|
+
var factory = _step2.value;
|
|
487
|
+
if (factory.showInViewMode) {
|
|
488
|
+
var _activeNode9, _activeNode0;
|
|
489
|
+
var old = decorations.find((_activeNode9 = activeNode) === null || _activeNode9 === void 0 ? void 0 : _activeNode9.rootPos, (_activeNode0 = activeNode) === null || _activeNode0 === void 0 ? void 0 : _activeNode0.rootPos, function (spec) {
|
|
490
|
+
return spec.type === factory.type;
|
|
491
|
+
});
|
|
492
|
+
decorations = decorations.remove(old);
|
|
493
|
+
}
|
|
510
494
|
};
|
|
511
|
-
for (
|
|
512
|
-
|
|
495
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
496
|
+
_loop();
|
|
513
497
|
}
|
|
514
498
|
} catch (err) {
|
|
515
|
-
|
|
499
|
+
_iterator2.e(err);
|
|
516
500
|
} finally {
|
|
517
|
-
|
|
518
|
-
}
|
|
519
|
-
if (rightSideControlsEnabled && isViewMode) {
|
|
520
|
-
var _iterator2 = _createForOfIteratorHelper(nodeDecorationRegistry),
|
|
521
|
-
_step2;
|
|
522
|
-
try {
|
|
523
|
-
var _loop = function _loop() {
|
|
524
|
-
var factory = _step2.value;
|
|
525
|
-
if (factory.showInViewMode) {
|
|
526
|
-
var _activeNode9, _activeNode0;
|
|
527
|
-
var old = decorations.find((_activeNode9 = activeNode) === null || _activeNode9 === void 0 ? void 0 : _activeNode9.rootPos, (_activeNode0 = activeNode) === null || _activeNode0 === void 0 ? void 0 : _activeNode0.rootPos, function (spec) {
|
|
528
|
-
return spec.type === factory.type;
|
|
529
|
-
});
|
|
530
|
-
decorations = decorations.remove(old);
|
|
531
|
-
}
|
|
532
|
-
};
|
|
533
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
534
|
-
_loop();
|
|
535
|
-
}
|
|
536
|
-
} catch (err) {
|
|
537
|
-
_iterator2.e(err);
|
|
538
|
-
} finally {
|
|
539
|
-
_iterator2.f();
|
|
540
|
-
}
|
|
501
|
+
_iterator2.f();
|
|
541
502
|
}
|
|
542
503
|
}
|
|
543
504
|
} else if (api) {
|
|
@@ -615,9 +576,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
615
576
|
}
|
|
616
577
|
}
|
|
617
578
|
}
|
|
618
|
-
if (shouldRecreateQuickInsertButton && ((_latestActiveNode5 = latestActiveNode) === null || _latestActiveNode5 === void 0 ? void 0 : _latestActiveNode5.rootPos) !== undefined && (quickInsertButtonEnabled || nodeDecorationRegistry.length > 0) &&
|
|
619
|
-
// enables quick insert
|
|
620
|
-
flags.toolbarFlagsEnabled && (!rightSideControlsEnabled || !isViewMode)) {
|
|
579
|
+
if (shouldRecreateQuickInsertButton && ((_latestActiveNode5 = latestActiveNode) === null || _latestActiveNode5 === void 0 ? void 0 : _latestActiveNode5.rootPos) !== undefined && (quickInsertButtonEnabled || nodeDecorationRegistry.length > 0) && (!rightSideControlsEnabled || !isViewMode)) {
|
|
621
580
|
var _latestActiveNode1;
|
|
622
581
|
if (quickInsertButtonEnabled) {
|
|
623
582
|
var _activeNode13, _activeNode14, _latestActiveNode6, _latestActiveNode7, _latestActiveNode8, _latestActiveNode9, _latestActiveNode0;
|
|
@@ -723,7 +682,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
723
682
|
var rootPos = (_latestActiveNode10 = latestActiveNode) === null || _latestActiveNode10 === void 0 ? void 0 : _latestActiveNode10.rootPos;
|
|
724
683
|
// rootPos is computed using the same logic as the floating insert menu, so it always points to a top-level (doc child) block when defined.
|
|
725
684
|
var isDocLevel = rootPos !== undefined && !isNaN(rootPos);
|
|
726
|
-
if (isViewMode && isDocLevel &&
|
|
685
|
+
if (isViewMode && isDocLevel && rightSideControlsEnabled) {
|
|
727
686
|
var _iterator5 = _createForOfIteratorHelper(nodeDecorationRegistry),
|
|
728
687
|
_step5;
|
|
729
688
|
try {
|
|
@@ -835,21 +794,15 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
835
794
|
decorations = decorations.add(newState.doc, [emptyParagraphNodeDecorations()]);
|
|
836
795
|
}
|
|
837
796
|
}
|
|
838
|
-
|
|
797
|
+
|
|
839
798
|
// enables quick insert
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
var keepActiveNodeForOpenBlockMenu = isExperimentEnabled('platform_editor_block_control_migration') && isMenuOpen;
|
|
848
|
-
newActiveNode = meta !== null && meta !== void 0 && meta.editorBlurred && !keepActiveNodeForOpenBlockMenu || !(meta !== null && meta !== void 0 && meta.activeNode) && !hasHandleOrViewModeControls ? null : latestActiveNode;
|
|
849
|
-
} else {
|
|
850
|
-
var _latestActiveNode13, _latestActiveNode14;
|
|
851
|
-
newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && !isExperimentEnabled('platform_editor_block_control_migration') && 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;
|
|
852
|
-
}
|
|
799
|
+
// remove isEmptyDoc check and let decorations render and determine their own visibility
|
|
800
|
+
// In view mode with right-side controls we render node decorations (right-edge button), not the
|
|
801
|
+
// handle - so findHandleDec is always empty. Don't clear activeNode in that case.
|
|
802
|
+
var hasHandleOrViewModeControls = isExperimentEnabled('platform_editor_block_control_migration') || isViewMode && rightSideControlsEnabled || findHandleDec(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length > 0;
|
|
803
|
+
// Keep the registry surface mounted while its Block Menu owns focus.
|
|
804
|
+
var keepActiveNodeForOpenBlockMenu = isExperimentEnabled('platform_editor_block_control_migration') && isMenuOpen;
|
|
805
|
+
var newActiveNode = meta !== null && meta !== void 0 && meta.editorBlurred && !keepActiveNodeForOpenBlockMenu || !(meta !== null && meta !== void 0 && meta.activeNode) && !hasHandleOrViewModeControls ? null : latestActiveNode;
|
|
853
806
|
var nextMenuTriggerByNode = (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.triggerByNode) || menuTriggerByNode;
|
|
854
807
|
if (isExperimentEnabled('platform_editor_block_control_migration') && tr.docChanged && menuTriggerByNode && !(meta !== null && meta !== void 0 && meta.toggleMenu)) {
|
|
855
808
|
var _menuTriggerByNode$ro, _newState$doc$nodeAt4;
|
|
@@ -871,11 +824,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
871
824
|
var isSameAnchor = (meta === null || meta === void 0 ? void 0 : meta.toggleMenu.anchorName) === menuTriggerBy;
|
|
872
825
|
isMenuOpen = menuTriggerBy === undefined || isSameAnchor || !isMenuOpen && !isSameAnchor ? !isMenuOpen : isMenuOpen;
|
|
873
826
|
}
|
|
874
|
-
|
|
875
|
-
isSelectedViaDragHandle = (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle) !== undefined ? meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle : isSelectedViaDragHandle;
|
|
876
|
-
} else {
|
|
877
|
-
isSelectedViaDragHandle = false;
|
|
878
|
-
}
|
|
827
|
+
isSelectedViaDragHandle = (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle) !== undefined ? meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle : isSelectedViaDragHandle;
|
|
879
828
|
return {
|
|
880
829
|
decorations: decorations,
|
|
881
830
|
surfaceNodePositions: surfaceNodePositions,
|
|
@@ -910,10 +859,6 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
910
859
|
var isAdvancedLayoutEnabled = editorExperiment('advanced_layouts', true, {
|
|
911
860
|
exposure: true
|
|
912
861
|
});
|
|
913
|
-
var toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
|
|
914
|
-
var flags = {
|
|
915
|
-
toolbarFlagsEnabled: toolbarFlagsEnabled
|
|
916
|
-
};
|
|
917
862
|
var anchorRectCache;
|
|
918
863
|
if (!isAnchorSupported()) {
|
|
919
864
|
anchorRectCache = new AnchorRectCache();
|
|
@@ -962,7 +907,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
962
907
|
return _objectSpread({}, initialState);
|
|
963
908
|
},
|
|
964
909
|
apply: function apply(tr, currentState, _, newState) {
|
|
965
|
-
return _apply(api, formatMessage, tr, currentState, newState,
|
|
910
|
+
return _apply(api, formatMessage, tr, currentState, newState, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, limitedModeTeardown);
|
|
966
911
|
}
|
|
967
912
|
},
|
|
968
913
|
props: {
|