@atlaskit/editor-plugin-block-controls 31.0.2 → 31.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/blockControlsPlugin.js +0 -1
  3. package/dist/cjs/pm-plugins/decorations-drag-handle.js +1 -4
  4. package/dist/cjs/pm-plugins/decorations-quick-insert-button.js +1 -4
  5. package/dist/cjs/pm-plugins/handle-mouse-over.js +2 -2
  6. package/dist/cjs/pm-plugins/interaction-tracking/handle-mouse-move.js +2 -2
  7. package/dist/cjs/pm-plugins/interaction-tracking/pm-plugin.js +0 -2
  8. package/dist/cjs/pm-plugins/main.js +4 -5
  9. package/dist/cjs/pm-plugins/utils/getSelection.js +1 -11
  10. package/dist/cjs/ui/block-controls-surface-drag-handle.js +1 -2
  11. package/dist/cjs/ui/consts.js +1 -22
  12. package/dist/cjs/ui/drag-handle.js +1 -1
  13. package/dist/cjs/ui/visibility-container.js +0 -1
  14. package/dist/es2019/blockControlsPlugin.js +0 -1
  15. package/dist/es2019/pm-plugins/decorations-drag-handle.js +1 -4
  16. package/dist/es2019/pm-plugins/decorations-quick-insert-button.js +1 -4
  17. package/dist/es2019/pm-plugins/handle-mouse-over.js +2 -2
  18. package/dist/es2019/pm-plugins/interaction-tracking/handle-mouse-move.js +2 -2
  19. package/dist/es2019/pm-plugins/interaction-tracking/pm-plugin.js +0 -2
  20. package/dist/es2019/pm-plugins/main.js +4 -5
  21. package/dist/es2019/pm-plugins/utils/getSelection.js +0 -10
  22. package/dist/es2019/ui/block-controls-surface-drag-handle.js +1 -2
  23. package/dist/es2019/ui/consts.js +0 -37
  24. package/dist/es2019/ui/drag-handle.js +1 -1
  25. package/dist/es2019/ui/visibility-container.js +0 -1
  26. package/dist/esm/blockControlsPlugin.js +0 -1
  27. package/dist/esm/pm-plugins/decorations-drag-handle.js +1 -4
  28. package/dist/esm/pm-plugins/decorations-quick-insert-button.js +1 -4
  29. package/dist/esm/pm-plugins/handle-mouse-over.js +2 -2
  30. package/dist/esm/pm-plugins/interaction-tracking/handle-mouse-move.js +2 -2
  31. package/dist/esm/pm-plugins/interaction-tracking/pm-plugin.js +0 -2
  32. package/dist/esm/pm-plugins/main.js +4 -5
  33. package/dist/esm/pm-plugins/utils/getSelection.js +0 -10
  34. package/dist/esm/ui/block-controls-surface-drag-handle.js +1 -2
  35. package/dist/esm/ui/consts.js +0 -21
  36. package/dist/esm/ui/drag-handle.js +1 -1
  37. package/dist/esm/ui/visibility-container.js +0 -1
  38. package/dist/types/pm-plugins/decorations-surface-anchor.d.ts +0 -5
  39. package/dist/types/pm-plugins/main.d.ts +3 -49
  40. package/dist/types/pm-plugins/utils/getSelection.d.ts +0 -1
  41. package/dist/types/ui/consts.d.ts +0 -11
  42. package/package.json +3 -6
  43. package/dist/cjs/pm-plugins/vanilla-quick-insert.js +0 -215
  44. package/dist/es2019/pm-plugins/vanilla-quick-insert.js +0 -215
  45. package/dist/esm/pm-plugins/vanilla-quick-insert.js +0 -208
  46. package/dist/types/pm-plugins/vanilla-quick-insert.d.ts +0 -21
@@ -516,7 +516,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
516
516
  } finally {
517
517
  _iterator.f();
518
518
  }
519
- if (rightSideControlsEnabled && isViewMode && fg('confluence_remix_button_right_side_block_fg')) {
519
+ if (rightSideControlsEnabled && isViewMode) {
520
520
  var _iterator2 = _createForOfIteratorHelper(nodeDecorationRegistry),
521
521
  _step2;
522
522
  try {
@@ -772,7 +772,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
772
772
  } finally {
773
773
  _iterator5.f();
774
774
  }
775
- } else if (isViewMode && rightSideControlsEnabled && fg('confluence_remix_button_right_side_block_fg')) {
775
+ } else if (isViewMode && rightSideControlsEnabled) {
776
776
  // Remove view-mode right-side decorations when no active node
777
777
  var _iterator6 = _createForOfIteratorHelper(nodeDecorationRegistry),
778
778
  _step6;
@@ -880,7 +880,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
880
880
  if (flags.toolbarFlagsEnabled) {
881
881
  isSelectedViaDragHandle = (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle) !== undefined ? meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle : isSelectedViaDragHandle;
882
882
  } else {
883
- isSelectedViaDragHandle = (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle) !== undefined && flags.toolbarFlagsEnabled && (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle);
883
+ isSelectedViaDragHandle = false;
884
884
  }
885
885
  return {
886
886
  decorations: decorations,
@@ -980,9 +980,8 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
980
980
  var isDisabled = api === null || api === void 0 || (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 || (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled === void 0 ? void 0 : _api$editorDisabled.editorDisabled;
981
981
  if (isDisabled) {
982
982
  var _api$editorViewMode2;
983
- var remixRightSideEnabled = rightSideControlsEnabled && fg('confluence_remix_button_right_side_block_fg');
984
983
  // Hide decorations when disabled, except in view mode when right-side controls are enabled
985
- if (!remixRightSideEnabled || (api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 || (_api$editorViewMode2 = _api$editorViewMode2.sharedState.currentState()) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.mode) !== 'view') {
984
+ if (!rightSideControlsEnabled || (api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 || (_api$editorViewMode2 = _api$editorViewMode2.sharedState.currentState()) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.mode) !== 'view') {
986
985
  return;
987
986
  }
988
987
  }
@@ -28,16 +28,6 @@ export var getInlineNodePos = function getInlineNodePos(doc, start, nodeSize) {
28
28
  inlineNodeEndPos: inlineNodeEndPos
29
29
  };
30
30
  };
31
- export var isNodeWithCodeBlock = function isNodeWithCodeBlock(tr, start, nodeSize) {
32
- var $startPos = tr.doc.resolve(start);
33
- var hasCodeBlock = false;
34
- tr.doc.nodesBetween($startPos.pos, $startPos.pos + nodeSize, function (n) {
35
- if (['codeBlock'].includes(n.type.name)) {
36
- hasCodeBlock = true;
37
- }
38
- });
39
- return hasCodeBlock;
40
- };
41
31
 
42
32
  /**
43
33
  * Gets the appropriate selection for the node at the given start position.
@@ -17,7 +17,6 @@ import { messages as blockControlsMessages } from '@atlaskit/editor-common/messa
17
17
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/useSharedPluginStateWithSelector';
18
18
  import DragHandleVerticalIcon from '@atlaskit/icon/core/drag-handle-vertical';
19
19
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
20
- import { fg } from '@atlaskit/platform-feature-flags/fg';
21
20
  import Tooltip from '@atlaskit/tooltip/Tooltip';
22
21
  import { selectionPreservationPluginKey } from '../pm-plugins/selection-preservation/plugin-key';
23
22
  import { prepareCollapsedHeadingSelection } from '../pm-plugins/utils/collapsed-heading';
@@ -273,7 +272,7 @@ export var BlockControlsSurfaceDragHandle = function BlockControlsSurfaceDragHan
273
272
  return event.stopPropagation();
274
273
  },
275
274
  "data-editor-block-ctrl-drag-handle": true,
276
- "data-blocks-drag-handle": fg('confluence_remix_button_right_side_block_fg') || undefined,
275
+ "data-blocks-drag-handle": true,
277
276
  "data-testid": "block-controls-surface-drag-handle",
278
277
  className: ax([dragHandleStyles.root, browser.gecko && dragHandleStyles.firefoxSelection, isLayoutColumn && dragHandleStyles.layoutColumn, dragHandleSelected && interactionState !== 'hasNotHadInteraction' && dragHandleStyles.selected, (handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused) && dragHandleStyles.keyboardFocused, dragHandleStyles.scaled])
279
278
  }, /*#__PURE__*/React.createElement("span", {
@@ -1,6 +1,4 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
- var _dropTargetMarginMap;
4
2
  import { DRAG_HANDLE_WIDTH } from '@atlaskit/editor-common/styles/drag-handle';
5
3
  import { breakoutResizableNodes, getBreakoutResizableNodes } from '@atlaskit/editor-common/utils';
6
4
  import { akEditorUnitZIndex, akRichMediaResizeZIndex } from '@atlaskit/editor-shared-styles/constants';
@@ -158,25 +156,6 @@ export var topPositionAdjustment = function topPositionAdjustment(nodeType, layo
158
156
  return 0;
159
157
  }
160
158
  };
161
- export var dropTargetMarginMap = (_dropTargetMarginMap = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_dropTargetMarginMap, -24, "var(--ds-space-negative-300, -24px)"), -20, "var(--ds-space-negative-250, -20px)"), -16, "var(--ds-space-negative-200, -16px)"), -12, "var(--ds-space-negative-150, -12px)"), -8, "var(--ds-space-negative-100, -8px)"), -6, "var(--ds-space-negative-075, -6px)"), -4, "var(--ds-space-negative-050, -4px)"), -2, "var(--ds-space-negative-025, -2px)"), 0, "var(--ds-space-0, 0px)"), 2, "var(--ds-space-025, 2px)"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_dropTargetMarginMap, 4, "var(--ds-space-050, 4px)"), 6, "var(--ds-space-075, 6px)"), 8, "var(--ds-space-100, 8px)"), 12, "var(--ds-space-150, 12px)"), 16, "var(--ds-space-200, 16px)"), 20, "var(--ds-space-250, 20px)"), 24, "var(--ds-space-300, 24px)"));
162
-
163
- /**
164
- * This document serves as a quick reference map for correlating various space matches
165
- * to the table provided above.
166
- * For instance, the number 1 will correspond to \{0: token('space.0', '0')\}.
167
- */
168
- export var spaceLookupMap = Object.fromEntries(
169
- // 49 = -24 -> 0 -> 24 totaling 49 entries.
170
- Array.from({
171
- length: 49
172
- }, function (_, index) {
173
- var currKeyValue = index - 24;
174
- var keyValues = Object.keys(dropTargetMarginMap).map(Number);
175
- var value = keyValues.reduce(function (acc, curr) {
176
- return Math.abs(currKeyValue - curr) < Math.abs(currKeyValue - acc) ? curr : acc;
177
- }, 1000);
178
- return [currKeyValue, dropTargetMarginMap[value]];
179
- }));
180
159
  export var spacingBetweenNodesForPreview = {
181
160
  paragraph: {
182
161
  top: '0.75rem',
@@ -1037,7 +1037,7 @@ export var DragHandle = function DragHandle(_ref2) {
1037
1037
  ,
1038
1038
  onDrop: handleOnDrop,
1039
1039
  "data-editor-block-ctrl-drag-handle": true,
1040
- "data-blocks-drag-handle": fg('confluence_remix_button_right_side_block_fg') || undefined,
1040
+ "data-blocks-drag-handle": true,
1041
1041
  "data-testid": "block-ctrl-drag-handle",
1042
1042
  "aria-label": dragHandleAriaLabel,
1043
1043
  onBlur: function onBlur() {
@@ -79,7 +79,6 @@ export var useBlockControlsVisibility = function useBlockControlsVisibility(_ref
79
79
  isDisplayingDiff = _useSharedPluginState.isDisplayingDiff,
80
80
  rightSideControlsEnabled = _useSharedPluginState.rightSideControlsEnabled;
81
81
  var isViewMode = editorViewMode === 'view';
82
- // rightSideControlsEnabled is the single source of truth (confluence_remix_button_right_side_block_fg from preset)
83
82
  // Both controls are restricted by side: the drag handle shows on the left half, the Remix button on
84
83
  // the right half (and the right margin), matching the midpoint split in handle-mouse-move.
85
84
  var shouldRestrictBySide = rightSideControlsEnabled && controlSide !== undefined && !isViewMode;
@@ -5,11 +5,6 @@ export declare const TYPE_SURFACE_ANCHOR_DEC = "block-controls-surface-anchor";
5
5
  export declare const SURFACE_ANCHOR_ATTR = "data-block-controls-surface-anchor";
6
6
  export declare const SURFACE_NODE_TYPE_ATTR = "data-block-controls-surface-node-type";
7
7
  export declare const SURFACE_ANCHOR_VARIABLE = "--block-controls-surface-anchor-name";
8
- export type SurfaceAnchorDecorationSpec = {
9
- anchorName: string;
10
- nodeType: string;
11
- type: typeof TYPE_SURFACE_ANCHOR_DEC;
12
- };
13
8
  export type SurfaceAnchorDecorationResult = {
14
9
  anchors: ReadonlyMap<number, string>;
15
10
  decorations: DecorationSet;
@@ -5,7 +5,7 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-edi
5
5
  import type { EditorState, ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
6
6
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
7
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
- import type { ActiveDropTargetNode, BlockControlsMeta, BlockControlsPlugin, MultiSelectDnD, NodeDecorationFactory, PluginState } from '../blockControlsPluginType';
8
+ import type { BlockControlsMeta, BlockControlsPlugin, NodeDecorationFactory, PluginState } from '../blockControlsPluginType';
9
9
  import { AnchorRectCache } from './utils/anchor-utils';
10
10
  export declare const key: PluginKey<PluginState>;
11
11
  export interface FlagType {
@@ -14,52 +14,6 @@ export interface FlagType {
14
14
  export declare const getDecorations: (state: EditorState) => DecorationSet | undefined;
15
15
  export declare const apply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, nodeDecorationRegistry: NodeDecorationFactory[], rightSideControlsEnabled?: boolean, quickInsertButtonEnabled?: boolean, anchorRectCache?: AnchorRectCache, resizeObserverWidth?: ResizeObserver, pragmaticCleanup?: (() => void) | null, limitedModeTeardown?: {
16
16
  done: boolean;
17
- }) => PluginState | {
18
- activeDropTargetNode: ActiveDropTargetNode | undefined;
19
- activeNode: any;
20
- blockMenuOptions: {
21
- canMoveDown: any;
22
- canMoveUp: any;
23
- openedViaKeyboard: any;
24
- } | undefined;
25
- decorations: DecorationSet;
26
- editorHeight: any;
27
- editorWidthLeft: any;
28
- editorWidthRight: any;
29
- isDocSizeLimitEnabled: boolean | null;
30
- isDragging: any;
31
- isMenuOpen: boolean | undefined;
32
- isPMDragging: any;
33
- isResizerResizing: boolean;
34
- isSelectedViaDragHandle: any;
35
- lastDragCancelled: any;
36
- menuTriggerBy: any;
37
- menuTriggerByNode: any;
38
- multiSelectDnD: MultiSelectDnD | undefined;
39
- surfaceNodePositions: number[];
40
- };
41
- export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI, nodeDecorationRegistry: NodeDecorationFactory[], rightSideControlsEnabled?: boolean, quickInsertButtonEnabled?: boolean) => SafePlugin<PluginState | {
42
- activeDropTargetNode: ActiveDropTargetNode | undefined;
43
- activeNode: any;
44
- blockMenuOptions: {
45
- canMoveDown: any;
46
- canMoveUp: any;
47
- openedViaKeyboard: any;
48
- } | undefined;
49
- decorations: DecorationSet;
50
- editorHeight: any;
51
- editorWidthLeft: any;
52
- editorWidthRight: any;
53
- isDocSizeLimitEnabled: boolean | null;
54
- isDragging: any;
55
- isMenuOpen: boolean | undefined;
56
- isPMDragging: any;
57
- isResizerResizing: boolean;
58
- isSelectedViaDragHandle: any;
59
- lastDragCancelled: any;
60
- menuTriggerBy: any;
61
- menuTriggerByNode: any;
62
- multiSelectDnD: MultiSelectDnD | undefined;
63
- surfaceNodePositions: number[];
64
- }>;
17
+ }) => PluginState;
18
+ export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI, nodeDecorationRegistry: NodeDecorationFactory[], rightSideControlsEnabled?: boolean, quickInsertButtonEnabled?: boolean) => SafePlugin<PluginState>;
65
19
  export declare const getBlockControlsMeta: (tr: Transaction | ReadonlyTransaction) => BlockControlsMeta | undefined;
@@ -7,7 +7,6 @@ export declare const getInlineNodePos: (doc: PMNode, start: number, nodeSize: nu
7
7
  inlineNodeEndPos: number;
8
8
  inlineNodePos: number;
9
9
  };
10
- export declare const isNodeWithCodeBlock: (tr: Transaction, start: number, nodeSize: number) => boolean;
11
10
  /**
12
11
  * Gets the appropriate selection for the node at the given start position.
13
12
  *
@@ -34,17 +34,6 @@ export declare const dragHandleGap: (nodeType: string, parentNodeType?: string)
34
34
  export declare const rootElementGap: (nodeType: string) => number;
35
35
  export declare const getNestedNodeLeftPaddingMargin: (nodeType?: string) => '24px' | '8px' | '16px' | '20px' | '28px' | '40px';
36
36
  export declare const topPositionAdjustment: (nodeType: string, layout?: string) => number;
37
- export declare const dropTargetMarginMap: {
38
- [key: number]: string;
39
- };
40
- /**
41
- * This document serves as a quick reference map for correlating various space matches
42
- * to the table provided above.
43
- * For instance, the number 1 will correspond to \{0: token('space.0', '0')\}.
44
- */
45
- export declare const spaceLookupMap: {
46
- [k: string]: string;
47
- };
48
37
  export declare const spacingBetweenNodesForPreview: {
49
38
  [key: string]: {
50
39
  bottom: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "31.0.2",
3
+ "version": "31.0.4",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -61,7 +61,7 @@
61
61
  "@atlaskit/primitives": "^22.6.0",
62
62
  "@atlaskit/section-message": "^10.2.0",
63
63
  "@atlaskit/theme": "^28.2.0",
64
- "@atlaskit/tmp-editor-statsig": "^247.0.0",
64
+ "@atlaskit/tmp-editor-statsig": "^248.0.0",
65
65
  "@atlaskit/tokens": "^20.8.0",
66
66
  "@atlaskit/tooltip": "^24.4.0",
67
67
  "@babel/runtime": "^7.0.0",
@@ -73,7 +73,7 @@
73
73
  "uuid": "^11.1.1"
74
74
  },
75
75
  "peerDependencies": {
76
- "@atlaskit/editor-common": "^134.0.0",
76
+ "@atlaskit/editor-common": "^134.1.0",
77
77
  "react": "^18.2.0 || ^19.2.0",
78
78
  "react-dom": "^18.2.0 || ^19.2.0",
79
79
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -85,9 +85,6 @@
85
85
  "platform_editor_maui_jira_updates": {
86
86
  "type": "boolean"
87
87
  },
88
- "confluence_remix_button_right_side_block_fg": {
89
- "type": "boolean"
90
- },
91
88
  "platform_editor_controls_reliable_anchor_patch_1": {
92
89
  "type": "boolean"
93
90
  },
@@ -1,215 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createVanillaButton = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _cssHelper = require("@atlaskit/editor-common/css-helper");
10
- var _blockControls = require("@atlaskit/editor-common/messages/block-controls");
11
- var _vanillaTooltip = require("@atlaskit/editor-common/vanilla-tooltip");
12
- var _model = require("@atlaskit/editor-prosemirror/model");
13
- var _state = require("@atlaskit/editor-prosemirror/state");
14
- var _utils = require("@atlaskit/editor-prosemirror/utils");
15
- var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
16
- var _documentChecks = require("../ui/utils/document-checks");
17
- var _editorCommands = require("../ui/utils/editor-commands");
18
- var _quickInsertCalculatePosition = require("./quick-insert-calculate-position");
19
- 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; }
20
- 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) { (0, _defineProperty2.default)(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; }
21
- // Based on platform/packages/design-system/icon/svgs/utility/add.svg
22
- var plusButtonDOM = ['http://www.w3.org/2000/svg svg', {
23
- width: '12',
24
- height: '12',
25
- fill: 'none',
26
- viewBox: '0 0 12 12',
27
- style: 'pointer-events: none;'
28
- }, ['http://www.w3.org/2000/svg path', {
29
- fill: 'currentcolor',
30
- 'fill-rule': 'evenodd',
31
- d: 'M5.25 6.75V11h1.5V6.75H11v-1.5H6.75V1h-1.5v4.25H1v1.5z',
32
- 'clip-rule': 'evenodd',
33
- style: 'pointer-events: none;'
34
- }]];
35
- var vanillaQuickInsert = function vanillaQuickInsert(_ref) {
36
- var _api$featureFlags$sha, _api$featureFlags;
37
- var view = _ref.view,
38
- getPos = _ref.getPos,
39
- rootNodeType = _ref.rootNodeType,
40
- anchorRectCache = _ref.anchorRectCache,
41
- anchorName = _ref.anchorName,
42
- rootAnchorName = _ref.rootAnchorName,
43
- api = _ref.api;
44
- return ['div', {
45
- style: (0, _cssHelper.convertToInlineCss)(_objectSpread({
46
- position: 'absolute'
47
- }, (0, _quickInsertCalculatePosition.calculatePosition)({
48
- rootAnchorName: rootAnchorName,
49
- anchorName: anchorName,
50
- view: view,
51
- getPos: getPos,
52
- rootNodeType: rootNodeType,
53
- macroInteractionUpdates: (_api$featureFlags$sha = api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 || (_api$featureFlags = _api$featureFlags.sharedState.currentState()) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.macroInteractionUpdates) !== null && _api$featureFlags$sha !== void 0 ? _api$featureFlags$sha : false,
54
- anchorRectCache: anchorRectCache
55
- })))
56
- }, ['button', {
57
- class: 'blocks-quick-insert-button',
58
- 'data-testid': 'editor-quick-insert-button'
59
- }, plusButtonDOM]];
60
- };
61
-
62
- /**
63
- * Create a Node which contains the quick insert button
64
- */
65
- var createVanillaButton = exports.createVanillaButton = function createVanillaButton(props) {
66
- var _props$api$typeAhead, _props$api$blockContr, _props$api$blockContr2, _props$api$blockContr3, _props$api$blockContr4, _props$api$editorView, _props$api$typeAhead2, _props$api$blockContr5;
67
- var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, vanillaQuickInsert(props)),
68
- dom = _DOMSerializer$render.dom;
69
- if (dom instanceof HTMLElement) {
70
- var button = dom.querySelector('button[data-testid="editor-quick-insert-button"]');
71
- if (button instanceof HTMLButtonElement) {
72
- button.onclick = function () {
73
- return handleQuickInsert(props);
74
- };
75
-
76
- // Flag-on (platform-dst-top-layer), positioning is async via a React root;
77
- // safe here as VanillaTooltip stays hidden until positioned.
78
- var tooltip = new _vanillaTooltip.VanillaTooltip(button, props.formatMessage(_blockControls.messages.insert), 'quick-insert-button-tooltip', 'blocks-quick-insert-tooltip');
79
- props.cleanupCallbacks.push(function () {
80
- tooltip.destroy();
81
- });
82
- }
83
- }
84
-
85
- // Dynamically control the visibility of the node
86
- var isTypeAheadOpen = (_props$api$typeAhead = props.api.typeAhead) === null || _props$api$typeAhead === void 0 || (_props$api$typeAhead = _props$api$typeAhead.sharedState.currentState()) === null || _props$api$typeAhead === void 0 ? void 0 : _props$api$typeAhead.isOpen;
87
- var isEditing = (_props$api$blockContr = props.api.blockControls) === null || _props$api$blockContr === void 0 || (_props$api$blockContr = _props$api$blockContr.sharedState.currentState()) === null || _props$api$blockContr === void 0 ? void 0 : _props$api$blockContr.isEditing;
88
- var hoverSide = (_props$api$blockContr2 = props.api.blockControls) === null || _props$api$blockContr2 === void 0 || (_props$api$blockContr2 = _props$api$blockContr2.sharedState.currentState()) === null || _props$api$blockContr2 === void 0 ? void 0 : _props$api$blockContr2.hoverSide;
89
- var rightSideControlsEnabled = (_props$api$blockContr3 = (_props$api$blockContr4 = props.api.blockControls) === null || _props$api$blockContr4 === void 0 || (_props$api$blockContr4 = _props$api$blockContr4.sharedState.currentState()) === null || _props$api$blockContr4 === void 0 ? void 0 : _props$api$blockContr4.rightSideControlsEnabled) !== null && _props$api$blockContr3 !== void 0 ? _props$api$blockContr3 : false;
90
- var editorViewMode = (_props$api$editorView = props.api.editorViewMode) === null || _props$api$editorView === void 0 || (_props$api$editorView = _props$api$editorView.sharedState.currentState()) === null || _props$api$editorView === void 0 ? void 0 : _props$api$editorView.mode;
91
- var changeDOMVisibility = function changeDOMVisibility() {
92
- if (!(dom instanceof HTMLElement)) {
93
- return;
94
- }
95
- var isViewMode = editorViewMode === 'view';
96
- var shouldRestrictBySide = rightSideControlsEnabled && !isViewMode;
97
- // Only restrict by side when hoverSide is known. When undefined, show quick insert.
98
- var sideHidden = shouldRestrictBySide && hoverSide !== undefined ? hoverSide !== 'left' : false;
99
- if (isTypeAheadOpen || isEditing || sideHidden) {
100
- dom.classList.add('blocks-quick-insert-invisible-container');
101
- dom.classList.remove('blocks-quick-insert-visible-container');
102
- } else {
103
- dom.classList.add('blocks-quick-insert-visible-container');
104
- dom.classList.remove('blocks-quick-insert-invisible-container');
105
- }
106
- };
107
- changeDOMVisibility();
108
- props.cleanupCallbacks.push((_props$api$typeAhead2 = props.api.typeAhead) === null || _props$api$typeAhead2 === void 0 ? void 0 : _props$api$typeAhead2.sharedState.onChange(function (_ref2) {
109
- var nextSharedState = _ref2.nextSharedState;
110
- isTypeAheadOpen = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isOpen;
111
- changeDOMVisibility();
112
- }));
113
- props.cleanupCallbacks.push((_props$api$blockContr5 = props.api.blockControls) === null || _props$api$blockContr5 === void 0 ? void 0 : _props$api$blockContr5.sharedState.onChange(function (_ref3) {
114
- var _nextSharedState$righ;
115
- var nextSharedState = _ref3.nextSharedState;
116
- isEditing = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isEditing;
117
- hoverSide = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.hoverSide;
118
- rightSideControlsEnabled = (_nextSharedState$righ = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.rightSideControlsEnabled) !== null && _nextSharedState$righ !== void 0 ? _nextSharedState$righ : false;
119
- changeDOMVisibility();
120
- }));
121
- // Only subscribe to view mode when right-side controls are enabled (editorViewMode affects side restriction)
122
- if (rightSideControlsEnabled) {
123
- var _props$api$editorView2, _props$api$editorView3, _props$api$editorView4;
124
- var unsubscribeViewMode = (_props$api$editorView2 = props.api.editorViewMode) === null || _props$api$editorView2 === void 0 || (_props$api$editorView3 = (_props$api$editorView4 = _props$api$editorView2.sharedState).onChange) === null || _props$api$editorView3 === void 0 ? void 0 : _props$api$editorView3.call(_props$api$editorView4, function (_ref4) {
125
- var nextSharedState = _ref4.nextSharedState;
126
- editorViewMode = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mode;
127
- changeDOMVisibility();
128
- });
129
- if (unsubscribeViewMode) {
130
- props.cleanupCallbacks.push(unsubscribeViewMode);
131
- }
132
- }
133
- return dom;
134
- };
135
- var TEXT_PARENT_TYPES = ['paragraph', 'heading', 'blockquote', 'taskItem', 'decisionItem'];
136
- var handleQuickInsert = function handleQuickInsert(_ref5) {
137
- var _api$quickInsert;
138
- var api = _ref5.api,
139
- view = _ref5.view,
140
- getPos = _ref5.getPos;
141
- // if the selection is not within the node this decoration is rendered at
142
- // then insert a newline and trigger quick insert
143
- var start = getPos();
144
- if (start !== undefined) {
145
- // if the selection is not within the node this decoration is rendered at
146
- // or the node is non-editable, then insert a newline and trigger quick insert
147
- var isSelectionInsideNode = (0, _documentChecks.isSelectionInNode)(start, view);
148
- if (!isSelectionInsideNode || (0, _documentChecks.isNonEditableBlock)(start, view)) {
149
- api.core.actions.execute((0, _editorCommands.createNewLine)(start));
150
- }
151
- var codeBlock = view.state.schema.nodes.codeBlock;
152
- var selection = view.state.selection;
153
- var codeBlockParentNode = (0, _utils.findParentNodeOfType)(codeBlock)(selection);
154
- if (codeBlockParentNode) {
155
- // Slash command is not meant to be triggered inside code block, hence always insert slash in a new line following
156
- api.core.actions.execute((0, _editorCommands.createNewLine)(codeBlockParentNode.pos));
157
- } else if (isSelectionInsideNode) {
158
- // text or element with be deselected and the / added immediately after the paragraph
159
- // unless the selection is empty
160
- var currentSelection = view.state.selection;
161
- if ((0, _documentChecks.isInTextSelection)(view) && currentSelection.from !== currentSelection.to) {
162
- var currentParagraphNode = (0, _utils.findParentNode)(function (node) {
163
- return TEXT_PARENT_TYPES.includes(node.type.name);
164
- })(currentSelection);
165
- if (currentParagraphNode) {
166
- var newPos =
167
- //if the current selection is selected from right to left, then set the selection to the start of the paragraph
168
- currentSelection.anchor === currentSelection.to ? currentParagraphNode.pos : currentParagraphNode.pos + currentParagraphNode.node.nodeSize - 1;
169
- api.core.actions.execute(function (_ref6) {
170
- var tr = _ref6.tr;
171
- tr.setSelection(_state.TextSelection.create(view.state.selection.$from.doc, newPos));
172
- return tr;
173
- });
174
- }
175
- }
176
- if ((0, _documentChecks.isNestedNodeSelected)(view)) {
177
- // if the nested selected node is non-editable, then insert a newline below the selected node
178
- if ((0, _documentChecks.isNonEditableBlock)(view.state.selection.from, view)) {
179
- api.core.actions.execute((0, _editorCommands.createNewLine)(view.state.selection.from));
180
- } else {
181
- // otherwise need to force the selection to be at the start of the node, because
182
- // prosemirror is keeping it as NodeSelection for nested nodes. Do this to keep it
183
- // consistent NodeSelection for root level nodes.
184
- api.core.actions.execute(function (_ref7) {
185
- var tr = _ref7.tr;
186
- (0, _editorCommands.createNewLine)(view.state.selection.from)({
187
- tr: tr
188
- });
189
- tr.setSelection(_state.TextSelection.create(tr.doc, view.state.selection.from));
190
- return tr;
191
- });
192
- }
193
- }
194
- if (currentSelection instanceof _cellSelection.CellSelection) {
195
- // find the last inline position in the selection
196
- var lastInlinePosition = _state.TextSelection.near(view.state.selection.$to, -1);
197
- lastInlinePosition && api.core.actions.execute(function (_ref8) {
198
- var tr = _ref8.tr;
199
- if (!(lastInlinePosition instanceof _state.TextSelection)) {
200
- // this will create a new line after the node
201
- (0, _editorCommands.createNewLine)(lastInlinePosition.from)({
202
- tr: tr
203
- });
204
- // this will find the next valid text position after the node
205
- tr.setSelection(_state.TextSelection.create(tr.doc, lastInlinePosition.to));
206
- } else {
207
- tr.setSelection(lastInlinePosition);
208
- }
209
- return tr;
210
- });
211
- }
212
- }
213
- }
214
- (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl', true);
215
- };