@atlaskit/editor-plugin-block-controls 3.15.11 → 3.15.12

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.
@@ -0,0 +1,64 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { rootElementGap, topPositionAdjustment, QUICK_INSERT_DIMENSIONS, QUICK_INSERT_LEFT_OFFSET } from '../ui/consts';
5
+ import { refreshAnchorName } from '../ui/utils/anchor-name';
6
+ import { getControlBottomCSSValue, getControlHeightCSSValue, getNodeHeight, getTopPosition, shouldBeSticky } from './utils/drag-handle-positions';
7
+ import { getLeftPositionForRootElement } from './utils/widget-positions';
8
+
9
+ // Adapted from `src/ui/drag-handle.tsx` as positioning logic is similar
10
+ // CHANGES - added an offset so quick insert button can be positioned beside drag handle
11
+ // CHANGES - removed `editorExperiment('nested-dnd', true)` check and rootNodeType calculation
12
+ // CHANGES - replace anchorName with rootAnchorName
13
+ // CHANGES - `removed editorExperiment('advanced_layouts', true) && isLayoutColumn` checks as quick insert button will not be positioned for layout column
14
+ export var calculatePosition = function calculatePosition(_ref) {
15
+ var rootAnchorName = _ref.rootAnchorName,
16
+ anchorName = _ref.anchorName,
17
+ view = _ref.view,
18
+ getPos = _ref.getPos,
19
+ rootNodeType = _ref.rootNodeType,
20
+ macroInteractionUpdates = _ref.macroInteractionUpdates,
21
+ anchorRectCache = _ref.anchorRectCache;
22
+ var supportsAnchor = CSS.supports('top', "anchor(".concat(rootAnchorName, " start)")) && CSS.supports('left', "anchor(".concat(rootAnchorName, " start)"));
23
+ var safeAnchorName = refreshAnchorName({
24
+ getPos: getPos,
25
+ view: view,
26
+ anchorName: rootAnchorName
27
+ });
28
+ var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(safeAnchorName, "\"]"));
29
+ var hasResizer = rootNodeType === 'table' || rootNodeType === 'mediaSingle';
30
+ var isExtension = rootNodeType === 'extension' || rootNodeType === 'bodiedExtension';
31
+ var isBlockCard = rootNodeType === 'blockCard';
32
+ var isEmbedCard = rootNodeType === 'embedCard';
33
+ var isMacroInteractionUpdates = macroInteractionUpdates && isExtension;
34
+ var innerContainer = null;
35
+ if (dom) {
36
+ if (isEmbedCard) {
37
+ innerContainer = dom.querySelector('.rich-media-item');
38
+ } else if (hasResizer) {
39
+ innerContainer = dom.querySelector('.resizer-item');
40
+ } else if (isExtension) {
41
+ innerContainer = dom.querySelector('.extension-container[data-layout]');
42
+ } else if (isBlockCard) {
43
+ //specific to datasource blockCard
44
+ innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
45
+ }
46
+ }
47
+ var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
48
+ var isSticky = shouldBeSticky(rootNodeType);
49
+ var bottom = getControlBottomCSSValue(safeAnchorName || anchorName, isSticky, true);
50
+ if (supportsAnchor) {
51
+ return _objectSpread({
52
+ left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat(getLeftPositionForRootElement(dom, rootNodeType, QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(QUICK_INSERT_LEFT_OFFSET, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(QUICK_INSERT_DIMENSIONS.width, "px - ").concat(rootElementGap(rootNodeType), "px + -").concat(QUICK_INSERT_LEFT_OFFSET, "px)"),
53
+ top: "calc(anchor(".concat(safeAnchorName, " start) + ").concat(topPositionAdjustment(rootNodeType), "px)")
54
+ }, bottom);
55
+ }
56
+
57
+ // expensive, calls offsetHeight
58
+ var nodeHeight = getNodeHeight(dom, safeAnchorName || anchorName, anchorRectCache) || 0;
59
+ var height = getControlHeightCSSValue(nodeHeight, isSticky, true, "var(--ds-space-300, 24px)");
60
+ return _objectSpread({
61
+ left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat(getLeftPositionForRootElement(dom, rootNodeType, QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(QUICK_INSERT_LEFT_OFFSET, "px)") : "calc(".concat(getLeftPositionForRootElement(dom, rootNodeType, QUICK_INSERT_DIMENSIONS, innerContainer, isMacroInteractionUpdates), " + -").concat(QUICK_INSERT_LEFT_OFFSET, "px)"),
62
+ top: getTopPosition(dom, rootNodeType)
63
+ }, height);
64
+ };
@@ -0,0 +1,183 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
5
+ import { blockControlsMessages as messages } from '@atlaskit/editor-common/messages';
6
+ import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
7
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
8
+ import { findParentNode, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
9
+ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
10
+ import { isInTextSelection, isNestedNodeSelected, isNonEditableBlock, isSelectionInNode } from '../ui/utils/document-checks';
11
+ import { createNewLine } from '../ui/utils/editor-commands';
12
+ import { calculatePosition } from './quick-insert-calculate-position';
13
+ import { VanillaTooltip } from './vanilla-tooltip';
14
+ // Based on platform/packages/design-system/icon/svgs/utility/add.svg
15
+ var plusButtonDOM = ['http://www.w3.org/2000/svg svg', {
16
+ width: '12',
17
+ height: '12',
18
+ fill: 'none',
19
+ viewBox: '0 0 12 12',
20
+ style: 'pointer-events: none;'
21
+ }, ['http://www.w3.org/2000/svg path', {
22
+ fill: 'currentcolor',
23
+ 'fill-rule': 'evenodd',
24
+ d: 'M5.25 6.75V11h1.5V6.75H11v-1.5H6.75V1h-1.5v4.25H1v1.5z',
25
+ 'clip-rule': 'evenodd',
26
+ style: 'pointer-events: none;'
27
+ }]];
28
+ var vanillaQuickInsert = function vanillaQuickInsert(_ref) {
29
+ var _api$featureFlags$sha, _api$featureFlags;
30
+ var view = _ref.view,
31
+ getPos = _ref.getPos,
32
+ rootNodeType = _ref.rootNodeType,
33
+ anchorRectCache = _ref.anchorRectCache,
34
+ anchorName = _ref.anchorName,
35
+ rootAnchorName = _ref.rootAnchorName,
36
+ api = _ref.api;
37
+ return ['div', {
38
+ style: convertToInlineCss(_objectSpread({
39
+ position: 'absolute'
40
+ }, calculatePosition({
41
+ rootAnchorName: rootAnchorName,
42
+ anchorName: anchorName,
43
+ view: view,
44
+ getPos: getPos,
45
+ rootNodeType: rootNodeType,
46
+ 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,
47
+ anchorRectCache: anchorRectCache
48
+ })))
49
+ }, ['button', {
50
+ class: 'blocks-quick-insert-button',
51
+ 'data-testid': 'editor-quick-insert-button'
52
+ }, plusButtonDOM]];
53
+ };
54
+
55
+ /**
56
+ * Create a Node which contains the quick insert button
57
+ */
58
+ export var createVanillaButton = function createVanillaButton(props) {
59
+ var _props$api$typeAhead, _props$api$blockContr, _props$api$typeAhead2, _props$api$blockContr2;
60
+ var _DOMSerializer$render = DOMSerializer.renderSpec(document, vanillaQuickInsert(props)),
61
+ dom = _DOMSerializer$render.dom;
62
+ if (dom instanceof HTMLElement) {
63
+ var button = dom.querySelector('button[data-testid="editor-quick-insert-button"]');
64
+ if (button instanceof HTMLButtonElement) {
65
+ button.onclick = function () {
66
+ return handleQuickInsert(props);
67
+ };
68
+ var tooltip = new VanillaTooltip(button, props.formatMessage(messages.insert), 'quick-insert-button-tooltip');
69
+ props.cleanupCallbacks.push(function () {
70
+ tooltip.destroy();
71
+ });
72
+ }
73
+ }
74
+
75
+ // Dynamically control the visibility of the node
76
+ 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;
77
+ 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;
78
+ var changeDOMVisibility = function changeDOMVisibility() {
79
+ if (!(dom instanceof HTMLElement)) {
80
+ return;
81
+ }
82
+ if (isTypeAheadOpen || isEditing) {
83
+ dom.classList.add('blocks-quick-insert-invisible-container');
84
+ dom.classList.remove('blocks-quick-insert-visible-container');
85
+ } else {
86
+ dom.classList.add('blocks-quick-insert-visible-container');
87
+ dom.classList.remove('blocks-quick-insert-invisible-container');
88
+ }
89
+ };
90
+ changeDOMVisibility();
91
+ props.cleanupCallbacks.push((_props$api$typeAhead2 = props.api.typeAhead) === null || _props$api$typeAhead2 === void 0 ? void 0 : _props$api$typeAhead2.sharedState.onChange(function (_ref2) {
92
+ var nextSharedState = _ref2.nextSharedState;
93
+ isTypeAheadOpen = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isOpen;
94
+ changeDOMVisibility();
95
+ }));
96
+ props.cleanupCallbacks.push((_props$api$blockContr2 = props.api.blockControls) === null || _props$api$blockContr2 === void 0 ? void 0 : _props$api$blockContr2.sharedState.onChange(function (_ref3) {
97
+ var nextSharedState = _ref3.nextSharedState;
98
+ isEditing = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isEditing;
99
+ changeDOMVisibility();
100
+ }));
101
+ return dom;
102
+ };
103
+ var TEXT_PARENT_TYPES = ['paragraph', 'heading', 'blockquote', 'taskItem', 'decisionItem'];
104
+ var handleQuickInsert = function handleQuickInsert(_ref4) {
105
+ var _api$quickInsert;
106
+ var api = _ref4.api,
107
+ view = _ref4.view,
108
+ getPos = _ref4.getPos;
109
+ // if the selection is not within the node this decoration is rendered at
110
+ // then insert a newline and trigger quick insert
111
+ var start = getPos();
112
+ if (start !== undefined) {
113
+ // if the selection is not within the node this decoration is rendered at
114
+ // or the node is non-editable, then insert a newline and trigger quick insert
115
+ var isSelectionInsideNode = isSelectionInNode(start, view);
116
+ if (!isSelectionInsideNode || isNonEditableBlock(start, view)) {
117
+ api.core.actions.execute(createNewLine(start));
118
+ }
119
+ var codeBlock = view.state.schema.nodes.codeBlock;
120
+ var selection = view.state.selection;
121
+ var codeBlockParentNode = findParentNodeOfType(codeBlock)(selection);
122
+ if (codeBlockParentNode) {
123
+ // Slash command is not meant to be triggered inside code block, hence always insert slash in a new line following
124
+ api.core.actions.execute(createNewLine(codeBlockParentNode.pos));
125
+ } else if (isSelectionInsideNode) {
126
+ // text or element with be deselected and the / added immediately after the paragraph
127
+ // unless the selection is empty
128
+ var currentSelection = view.state.selection;
129
+ if (isInTextSelection(view) && currentSelection.from !== currentSelection.to) {
130
+ var currentParagraphNode = findParentNode(function (node) {
131
+ return TEXT_PARENT_TYPES.includes(node.type.name);
132
+ })(currentSelection);
133
+ if (currentParagraphNode) {
134
+ var newPos =
135
+ //if the current selection is selected from right to left, then set the selection to the start of the paragraph
136
+ currentSelection.anchor === currentSelection.to ? currentParagraphNode.pos : currentParagraphNode.pos + currentParagraphNode.node.nodeSize - 1;
137
+ api.core.actions.execute(function (_ref5) {
138
+ var tr = _ref5.tr;
139
+ tr.setSelection(TextSelection.create(view.state.selection.$from.doc, newPos));
140
+ return tr;
141
+ });
142
+ }
143
+ }
144
+ if (isNestedNodeSelected(view)) {
145
+ // if the nested selected node is non-editable, then insert a newline below the selected node
146
+ if (isNonEditableBlock(view.state.selection.from, view)) {
147
+ api.core.actions.execute(createNewLine(view.state.selection.from));
148
+ } else {
149
+ // otherwise need to force the selection to be at the start of the node, because
150
+ // prosemirror is keeping it as NodeSelection for nested nodes. Do this to keep it
151
+ // consistent NodeSelection for root level nodes.
152
+ api.core.actions.execute(function (_ref6) {
153
+ var tr = _ref6.tr;
154
+ createNewLine(view.state.selection.from)({
155
+ tr: tr
156
+ });
157
+ tr.setSelection(TextSelection.create(tr.doc, view.state.selection.from));
158
+ return tr;
159
+ });
160
+ }
161
+ }
162
+ if (currentSelection instanceof CellSelection) {
163
+ // find the last inline position in the selection
164
+ var lastInlinePosition = TextSelection.near(view.state.selection.$to, -1);
165
+ lastInlinePosition && api.core.actions.execute(function (_ref7) {
166
+ var tr = _ref7.tr;
167
+ if (!(lastInlinePosition instanceof TextSelection)) {
168
+ // this will create a new line after the node
169
+ createNewLine(lastInlinePosition.from)({
170
+ tr: tr
171
+ });
172
+ // this will find the next valid text position after the node
173
+ tr.setSelection(TextSelection.create(tr.doc, lastInlinePosition.to));
174
+ } else {
175
+ tr.setSelection(lastInlinePosition);
176
+ }
177
+ return tr;
178
+ });
179
+ }
180
+ }
181
+ }
182
+ (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl', true);
183
+ };
@@ -0,0 +1,172 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ 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; }
5
+ 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; }
6
+ import { createPopper } from '@popperjs/core';
7
+ import { bind } from 'bind-event-listener';
8
+ var startingOffset = {
9
+ name: 'offset',
10
+ options: {
11
+ offset: [0, 4]
12
+ }
13
+ };
14
+ var endingOffset = {
15
+ name: 'offset',
16
+ options: {
17
+ offset: [0, 8]
18
+ }
19
+ };
20
+
21
+ /**
22
+ * A tooltip component similar to "@atlaskit/tooltip" but built for vanilla scenarios
23
+ *
24
+ * Uses Popover API for accessibility + stacking context: https://developer.mozilla.org/en-US/docs/Web/API/Popover_API
25
+ * Uses popperJS for positioning
26
+ *
27
+ * @warning Still experimental. One day we can likely want to move this to a common package.
28
+ */
29
+ export var VanillaTooltip = /*#__PURE__*/function () {
30
+ function VanillaTooltip(button, content,
31
+ /**
32
+ * Id associated to the tooltip - must be unique.
33
+ */
34
+ id) {
35
+ var _this = this;
36
+ var timeout = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 300;
37
+ _classCallCheck(this, VanillaTooltip);
38
+ _defineProperty(this, "listeners", []);
39
+ _defineProperty(this, "shouldHidePopover", false);
40
+ _defineProperty(this, "isDisplayed", false);
41
+ this.button = button;
42
+ this.timeout = timeout;
43
+ var tooltip = document.createElement('span');
44
+ tooltip.role = 'tooltip';
45
+ tooltip.popover = 'hint';
46
+ // Warning: Currently this is used for styling - only works in the block controls package
47
+ tooltip.className = 'blocks-quick-insert-tooltip';
48
+ tooltip.id = id;
49
+ tooltip.textContent = content;
50
+ this.tooltip = tooltip;
51
+
52
+ // Button preparation
53
+ button.appendChild(tooltip);
54
+ // Prepare the button to have the popover target and accessibility properties
55
+ button.setAttribute('popovertarget', tooltip.id);
56
+ button.setAttribute('aria-describedby', tooltip.id);
57
+ var showEvents = ['mouseenter', 'focus'];
58
+ var hideEvents = ['mouseleave', 'blur'];
59
+ showEvents.forEach(function (event) {
60
+ _this.listeners.push(bind(button, {
61
+ type: event,
62
+ listener: function listener() {
63
+ return _this.show();
64
+ }
65
+ }));
66
+ });
67
+ hideEvents.forEach(function (event) {
68
+ _this.listeners.push(bind(button, {
69
+ type: event,
70
+ listener: function listener() {
71
+ return _this.hide();
72
+ }
73
+ }));
74
+ });
75
+ this.listeners.push(bind(window, {
76
+ type: 'keydown',
77
+ listener: function listener(e) {
78
+ if (e.key === 'Escape') {
79
+ _this.hide(true);
80
+ }
81
+ }
82
+ }));
83
+
84
+ // Hide the tooltip if the hide transition has completed
85
+ this.tooltip.ontransitionend = function () {
86
+ if (_this.shouldHidePopover) {
87
+ _this.tooltip.hidePopover();
88
+ }
89
+ };
90
+ }
91
+ return _createClass(VanillaTooltip, [{
92
+ key: "createPopperInstance",
93
+ value: function createPopperInstance() {
94
+ this.popperInstance = createPopper(this.button, this.tooltip, {
95
+ placement: 'top',
96
+ modifiers: [startingOffset]
97
+ });
98
+ }
99
+ }, {
100
+ key: "destroy",
101
+ value: function destroy() {
102
+ var _this$popperInstance;
103
+ (_this$popperInstance = this.popperInstance) === null || _this$popperInstance === void 0 || _this$popperInstance.destroy();
104
+ this.listeners.forEach(function (listener) {
105
+ listener();
106
+ });
107
+ }
108
+ }, {
109
+ key: "hide",
110
+ value: function hide() {
111
+ var _this2 = this;
112
+ var immediate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
113
+ clearTimeout(this.currentTimeoutId);
114
+ this.shouldHidePopover = true;
115
+ // Disable the event listeners
116
+ this.currentTimeoutId = setTimeout(function () {
117
+ var _this2$popperInstance;
118
+ (_this2$popperInstance = _this2.popperInstance) === null || _this2$popperInstance === void 0 || _this2$popperInstance.setOptions(function (options) {
119
+ return _objectSpread(_objectSpread({}, options), {}, {
120
+ modifiers: [startingOffset, {
121
+ name: 'eventListeners',
122
+ enabled: false
123
+ }]
124
+ });
125
+ });
126
+ _this2.tooltip.style.opacity = '0';
127
+ _this2.isDisplayed = false;
128
+ // If transition animations are disabled immediately hide the popover
129
+ if (_this2.tooltip.style.transition === 'none') {
130
+ _this2.tooltip.hidePopover();
131
+ }
132
+ }, immediate ? 0 : this.timeout);
133
+ }
134
+ }, {
135
+ key: "show",
136
+ value: function show() {
137
+ var _this3 = this;
138
+ if (this.isDisplayed) {
139
+ return;
140
+ }
141
+ clearTimeout(this.currentTimeoutId);
142
+ this.shouldHidePopover = false;
143
+
144
+ // Make the tooltip visible - but hide until
145
+ this.tooltip.style.visibility = 'hidden';
146
+ this.tooltip.showPopover();
147
+
148
+ // Update its position
149
+ if (!this.popperInstance) {
150
+ this.createPopperInstance();
151
+ } else {
152
+ this.popperInstance.update();
153
+ }
154
+
155
+ // Enable the event listeners
156
+ this.currentTimeoutId = setTimeout(function () {
157
+ var _this3$popperInstance;
158
+ _this3.tooltip.style.opacity = '1';
159
+ _this3.tooltip.style.visibility = 'visible';
160
+ (_this3$popperInstance = _this3.popperInstance) === null || _this3$popperInstance === void 0 || _this3$popperInstance.setOptions(function (options) {
161
+ return _objectSpread(_objectSpread({}, options), {}, {
162
+ modifiers: [endingOffset, {
163
+ name: 'eventListeners',
164
+ enabled: true
165
+ }]
166
+ });
167
+ });
168
+ _this3.isDisplayed = true;
169
+ }, this.timeout);
170
+ }
171
+ }]);
172
+ }();
@@ -5,9 +5,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
5
  */
6
6
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
7
  import { css, Global, jsx } from '@emotion/react';
8
+ import { tableControlsSpacing } from '@atlaskit/editor-common/styles';
8
9
  import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
9
10
  import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport } from '@atlaskit/editor-shared-styles';
10
11
  import { fg } from '@atlaskit/platform-feature-flags';
12
+ import { layers } from '@atlaskit/theme/constants';
11
13
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
14
  import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, DRAG_HANDLE_WIDTH } from './consts';
13
15
 
@@ -118,6 +120,89 @@ var globalStyles = function globalStyles() {
118
120
  }
119
121
  });
120
122
  };
123
+ var quickInsertStyles = function quickInsertStyles() {
124
+ return css({
125
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
126
+ '.blocks-quick-insert-button': {
127
+ backgroundColor: 'transparent',
128
+ top: "var(--top-override,8px)",
129
+ position: 'sticky',
130
+ boxSizing: 'border-box',
131
+ display: 'flex',
132
+ flexDirection: 'column',
133
+ justifyContent: 'center',
134
+ alignItems: 'center',
135
+ height: "var(--ds-space-300, 24px)",
136
+ width: "var(--ds-space-300, 24px)",
137
+ border: 'none',
138
+ borderRadius: '50%',
139
+ zIndex: layers.card(),
140
+ outline: 'none',
141
+ cursor: 'pointer',
142
+ color: "var(--ds-icon-subtle, #626F86)"
143
+ },
144
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
145
+ '[data-blocks-quick-insert-container]:has(~ [data-prosemirror-node-name="table"] .pm-table-with-controls tr.sticky) &': {
146
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
147
+ '--top-override': "".concat(tableControlsSpacing, "px")
148
+ },
149
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
150
+ '[data-prosemirror-mark-name="breakout"]:has([data-blocks-quick-insert-container]):has(~ [data-prosemirror-node-name="table"] .pm-table-with-controls tr.sticky) &': {
151
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
152
+ '--top-override': "".concat(tableControlsSpacing, "px")
153
+ },
154
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
155
+ '.blocks-quick-insert-button:hover': {
156
+ backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
157
+ },
158
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
159
+ '.blocks-quick-insert-button:active': {
160
+ backgroundColor: "var(--ds-background-neutral-subtle-pressed, #091E4224)"
161
+ },
162
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
163
+ '.blocks-quick-insert-button:focus': {
164
+ outline: "2px solid ".concat("var(--ds-border-focused, #388BFF)")
165
+ },
166
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
167
+ '.blocks-quick-insert-visible-container': {
168
+ transition: 'opacity 0.1s ease-in-out, visibility 0.1s ease-in-out',
169
+ opacity: 1,
170
+ visibility: 'visible'
171
+ },
172
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
173
+ '.blocks-quick-insert-invisible-container': {
174
+ transition: 'opacity 0.1s ease-in-out, visibility 0.1s ease-in-out',
175
+ opacity: 0,
176
+ visibility: 'hidden'
177
+ },
178
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
179
+ '.blocks-quick-insert-tooltip': {
180
+ zIndex: layers.tooltip(),
181
+ borderRadius: "var(--ds-border-radius, 4px)",
182
+ padding: "var(--ds-space-050, 4px)".concat(" 0"),
183
+ boxSizing: 'border-box',
184
+ maxWidth: '240px',
185
+ backgroundColor: "var(--ds-background-neutral-bold, #44546F)",
186
+ color: "var(--ds-text-inverse, #FFFFFF)",
187
+ font: "var(--ds-font-body-UNSAFE_small, normal 400 12px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
188
+ insetBlockStart: "var(--ds-space-0, 0px)",
189
+ insetInlineStart: "var(--ds-space-0, 0px)",
190
+ overflowWrap: 'break-word',
191
+ paddingBlockEnd: "var(--ds-space-025, 2px)",
192
+ paddingBlockStart: "var(--ds-space-025, 2px)",
193
+ paddingInlineEnd: "var(--ds-space-075, 6px)",
194
+ paddingInlineStart: "var(--ds-space-075, 6px)",
195
+ wordWrap: 'break-word',
196
+ pointerEvents: 'none',
197
+ userSelect: 'none',
198
+ // Based on: platform/packages/design-system/motion/src/entering/keyframes-motion.tsx
199
+ transition: 'opacity .1s ease-in-out, transform .1s ease-in-out, visibility .1s ease-in-out',
200
+ '@media (prefers-reduced-motion: reduce)': {
201
+ transition: 'none'
202
+ }
203
+ }
204
+ });
205
+ };
121
206
  var topLevelNodeMarginStyles = css({
122
207
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
123
208
  '.ProseMirror': {
@@ -194,6 +279,6 @@ var blockCardWithoutLayout = css({
194
279
  });
195
280
  export var GlobalStylesWrapper = function GlobalStylesWrapper() {
196
281
  return jsx(Global, {
197
- styles: [globalStyles(), globalDnDStyle, extendedHoverZone(), editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_widget_visibility') ? undefined : withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, fg('platform_editor_fix_safari_cursor_hidden_empty') ? withRelativePosStyle : withRelativePosStyleLegacy, topLevelNodeMarginStyles, withAnchorNameZindexStyle]
282
+ styles: [globalStyles(), globalDnDStyle, extendedHoverZone(), editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_widget_visibility') ? undefined : withInlineNodeStyle, editorExperiment('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, fg('platform_editor_fix_safari_cursor_hidden_empty') ? withRelativePosStyle : withRelativePosStyleLegacy, topLevelNodeMarginStyles, withAnchorNameZindexStyle]
198
283
  });
199
284
  };
@@ -0,0 +1,12 @@
1
+ import { type CSSProperties } from 'react';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import { AnchorRectCache } from './utils/anchor-utils';
4
+ export declare const calculatePosition: ({ rootAnchorName, anchorName, view, getPos, rootNodeType, macroInteractionUpdates, anchorRectCache, }: {
5
+ rootAnchorName: string | undefined;
6
+ getPos: () => number | undefined;
7
+ view: EditorView;
8
+ rootNodeType: string;
9
+ anchorName: string;
10
+ macroInteractionUpdates: boolean | undefined;
11
+ anchorRectCache: AnchorRectCache | undefined;
12
+ }) => CSSProperties;
@@ -0,0 +1,21 @@
1
+ import { type IntlShape } from 'react-intl-next';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { BlockControlsPlugin } from '../blockControlsPluginType';
5
+ import { AnchorRectCache } from './utils/anchor-utils';
6
+ type VanillaQuickInsertProps = {
7
+ formatMessage: IntlShape['formatMessage'];
8
+ api: ExtractInjectionAPI<BlockControlsPlugin>;
9
+ view: EditorView;
10
+ getPos: () => number | undefined;
11
+ cleanupCallbacks: ((() => void) | undefined)[];
12
+ rootNodeType: string;
13
+ anchorRectCache?: AnchorRectCache;
14
+ anchorName: string;
15
+ rootAnchorName: string;
16
+ };
17
+ /**
18
+ * Create a Node which contains the quick insert button
19
+ */
20
+ export declare const createVanillaButton: (props: VanillaQuickInsertProps) => Node;
21
+ export {};
@@ -0,0 +1,27 @@
1
+ /**
2
+ * A tooltip component similar to "@atlaskit/tooltip" but built for vanilla scenarios
3
+ *
4
+ * Uses Popover API for accessibility + stacking context: https://developer.mozilla.org/en-US/docs/Web/API/Popover_API
5
+ * Uses popperJS for positioning
6
+ *
7
+ * @warning Still experimental. One day we can likely want to move this to a common package.
8
+ */
9
+ export declare class VanillaTooltip {
10
+ private button;
11
+ private timeout;
12
+ private popperInstance;
13
+ private listeners;
14
+ private currentTimeoutId;
15
+ private shouldHidePopover;
16
+ private tooltip;
17
+ private isDisplayed;
18
+ constructor(button: HTMLButtonElement, content: string,
19
+ /**
20
+ * Id associated to the tooltip - must be unique.
21
+ */
22
+ id: string, timeout?: number);
23
+ private createPopperInstance;
24
+ destroy(): void;
25
+ private hide;
26
+ private show;
27
+ }
@@ -0,0 +1,12 @@
1
+ import { type CSSProperties } from 'react';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import { AnchorRectCache } from './utils/anchor-utils';
4
+ export declare const calculatePosition: ({ rootAnchorName, anchorName, view, getPos, rootNodeType, macroInteractionUpdates, anchorRectCache, }: {
5
+ rootAnchorName: string | undefined;
6
+ getPos: () => number | undefined;
7
+ view: EditorView;
8
+ rootNodeType: string;
9
+ anchorName: string;
10
+ macroInteractionUpdates: boolean | undefined;
11
+ anchorRectCache: AnchorRectCache | undefined;
12
+ }) => CSSProperties;
@@ -0,0 +1,21 @@
1
+ import { type IntlShape } from 'react-intl-next';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { BlockControlsPlugin } from '../blockControlsPluginType';
5
+ import { AnchorRectCache } from './utils/anchor-utils';
6
+ type VanillaQuickInsertProps = {
7
+ formatMessage: IntlShape['formatMessage'];
8
+ api: ExtractInjectionAPI<BlockControlsPlugin>;
9
+ view: EditorView;
10
+ getPos: () => number | undefined;
11
+ cleanupCallbacks: ((() => void) | undefined)[];
12
+ rootNodeType: string;
13
+ anchorRectCache?: AnchorRectCache;
14
+ anchorName: string;
15
+ rootAnchorName: string;
16
+ };
17
+ /**
18
+ * Create a Node which contains the quick insert button
19
+ */
20
+ export declare const createVanillaButton: (props: VanillaQuickInsertProps) => Node;
21
+ export {};
@@ -0,0 +1,27 @@
1
+ /**
2
+ * A tooltip component similar to "@atlaskit/tooltip" but built for vanilla scenarios
3
+ *
4
+ * Uses Popover API for accessibility + stacking context: https://developer.mozilla.org/en-US/docs/Web/API/Popover_API
5
+ * Uses popperJS for positioning
6
+ *
7
+ * @warning Still experimental. One day we can likely want to move this to a common package.
8
+ */
9
+ export declare class VanillaTooltip {
10
+ private button;
11
+ private timeout;
12
+ private popperInstance;
13
+ private listeners;
14
+ private currentTimeoutId;
15
+ private shouldHidePopover;
16
+ private tooltip;
17
+ private isDisplayed;
18
+ constructor(button: HTMLButtonElement, content: string,
19
+ /**
20
+ * Id associated to the tooltip - must be unique.
21
+ */
22
+ id: string, timeout?: number);
23
+ private createPopperInstance;
24
+ destroy(): void;
25
+ private hide;
26
+ private show;
27
+ }