@atlaskit/editor-plugin-block-controls 34.0.3 → 34.0.5
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 +22 -0
- package/dist/cjs/blockControlsPlugin.js +2 -10
- package/dist/cjs/pm-plugins/interaction-tracking/handle-key-down.js +8 -0
- package/dist/cjs/pm-plugins/interaction-tracking/handle-mouse-move.js +121 -2
- package/dist/cjs/pm-plugins/interaction-tracking/pm-plugin.js +3 -0
- package/dist/cjs/pm-plugins/sparse-gutter-hover.js +17 -57
- package/dist/cjs/pm-plugins/sparse-surfaces.js +2 -2
- package/dist/cjs/pm-plugins/utils/after-render-scheduler.js +39 -0
- package/dist/cjs/ui/block-controls-left-surface.js +19 -83
- package/dist/cjs/ui/block-controls-right-surface.js +19 -70
- package/dist/cjs/ui/block-controls-surface-targets.js +1 -1
- package/dist/es2019/blockControlsPlugin.js +2 -10
- package/dist/es2019/pm-plugins/interaction-tracking/handle-key-down.js +8 -0
- package/dist/es2019/pm-plugins/interaction-tracking/handle-mouse-move.js +118 -1
- package/dist/es2019/pm-plugins/interaction-tracking/pm-plugin.js +4 -1
- package/dist/es2019/pm-plugins/sparse-gutter-hover.js +16 -56
- package/dist/es2019/pm-plugins/sparse-surfaces.js +2 -2
- package/dist/es2019/pm-plugins/utils/after-render-scheduler.js +33 -0
- package/dist/es2019/ui/block-controls-left-surface.js +10 -76
- package/dist/es2019/ui/block-controls-right-surface.js +10 -63
- package/dist/es2019/ui/block-controls-surface-targets.js +1 -1
- package/dist/esm/blockControlsPlugin.js +2 -10
- package/dist/esm/pm-plugins/interaction-tracking/handle-key-down.js +8 -0
- package/dist/esm/pm-plugins/interaction-tracking/handle-mouse-move.js +120 -1
- package/dist/esm/pm-plugins/interaction-tracking/pm-plugin.js +4 -1
- package/dist/esm/pm-plugins/sparse-gutter-hover.js +16 -56
- package/dist/esm/pm-plugins/sparse-surfaces.js +2 -2
- package/dist/esm/pm-plugins/utils/after-render-scheduler.js +33 -0
- package/dist/esm/ui/block-controls-left-surface.js +19 -83
- package/dist/esm/ui/block-controls-right-surface.js +19 -70
- package/dist/esm/ui/block-controls-surface-targets.js +1 -1
- package/dist/types/pm-plugins/interaction-tracking/handle-mouse-move.d.ts +1 -0
- package/dist/types/pm-plugins/utils/after-render-scheduler.d.ts +9 -0
- package/dist/types/ui/block-controls-left-surface.d.ts +1 -1
- package/dist/types/ui/block-controls-right-surface.d.ts +1 -1
- package/dist/types/ui/block-controls-surface-targets.d.ts +1 -1
- package/package.json +4 -4
- package/dist/cjs/pm-plugins/sparse-surfaces-view.js +0 -149
- package/dist/cjs/ui/block-controls-left-surfaces.js +0 -294
- package/dist/cjs/ui/block-controls-right-surfaces.js +0 -285
- package/dist/es2019/pm-plugins/sparse-surfaces-view.js +0 -136
- package/dist/es2019/ui/block-controls-left-surfaces.js +0 -259
- package/dist/es2019/ui/block-controls-right-surfaces.js +0 -245
- package/dist/esm/pm-plugins/sparse-surfaces-view.js +0 -142
- package/dist/esm/ui/block-controls-left-surfaces.js +0 -285
- package/dist/esm/ui/block-controls-right-surfaces.js +0 -276
- package/dist/types/pm-plugins/sparse-surfaces-view.d.ts +0 -16
- package/dist/types/ui/block-controls-left-surfaces.d.ts +0 -15
- package/dist/types/ui/block-controls-right-surfaces.d.ts +0 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 34.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`cc413c0ae0c16`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cc413c0ae0c16) -
|
|
8
|
+
Clean up `platform_editor_block_controls_cls_fix`, keeping the block-controls CLS fixes and
|
|
9
|
+
removing the legacy surface rendering paths.
|
|
10
|
+
|
|
11
|
+
## 34.0.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`3c72b5a721bca`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3c72b5a721bca) -
|
|
16
|
+
[EDITOR-9730] Behind `platform_editor_improve_inp_batch_3`, reduce mousemove cost when resolving
|
|
17
|
+
the hover side: use a single hit test instead of scanning all top-level blocks for the
|
|
18
|
+
right-margin target, and coalesce hover processing through requestAnimationFrame followed by a
|
|
19
|
+
timeout to give the browser an opportunity to update layout before reading current content
|
|
20
|
+
geometry. Coalesced processing uses the latest mouse event and plugin API together, skips
|
|
21
|
+
suppressed hover states, and finishes geometry classification before updating editing or hover
|
|
22
|
+
state.
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 34.0.3
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -31,8 +31,6 @@ var _sparseSurfaces = require("./pm-plugins/sparse-surfaces");
|
|
|
31
31
|
var _expandAndUpdateSelection2 = require("./pm-plugins/utils/expand-and-update-selection");
|
|
32
32
|
var _getSelection = require("./pm-plugins/utils/getSelection");
|
|
33
33
|
var _blockControlsSurfaces = require("./surface-lifecycle/block-controls-surfaces");
|
|
34
|
-
var _blockControlsLeftSurfaces = require("./ui/block-controls-left-surfaces");
|
|
35
|
-
var _blockControlsRightSurfaces = require("./ui/block-controls-right-surfaces");
|
|
36
34
|
var _blockControlsSurfaceDragHandleRegistration = require("./ui/block-controls-surface-drag-handle-registration");
|
|
37
35
|
var _globalStyles = require("./ui/global-styles");
|
|
38
36
|
var _surfaceEditorViewContext = require("./ui/surface-editor-view-context");
|
|
@@ -498,16 +496,10 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
498
496
|
api: api
|
|
499
497
|
}), registryBlockControlsEnabled && editorView && api ? /*#__PURE__*/_react.default.createElement(_surfaceEditorViewContext.SurfaceEditorViewContext.Provider, {
|
|
500
498
|
value: editorView
|
|
501
|
-
},
|
|
499
|
+
}, /*#__PURE__*/_react.default.createElement(_blockControlsSurfaces.CommittedBlockControlsSurfaces, {
|
|
502
500
|
api: api,
|
|
503
501
|
editorView: editorView
|
|
504
|
-
}) :
|
|
505
|
-
api: api,
|
|
506
|
-
editorView: editorView
|
|
507
|
-
}), /*#__PURE__*/_react.default.createElement(_blockControlsRightSurfaces.BlockControlsRightSurfaces, {
|
|
508
|
-
api: api,
|
|
509
|
-
editorView: editorView
|
|
510
|
-
}))) : null);
|
|
502
|
+
})) : null);
|
|
511
503
|
}
|
|
512
504
|
};
|
|
513
505
|
};
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.handleKeyDown = void 0;
|
|
7
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
7
8
|
var _commands = require("./commands");
|
|
9
|
+
var _handleMouseMove = require("./handle-mouse-move");
|
|
8
10
|
var _pmPlugin = require("./pm-plugin");
|
|
9
11
|
var handleKeyDown = exports.handleKeyDown = function handleKeyDown(view, event) {
|
|
10
12
|
// Check if this is a keyboard shortcut (Ctrl/Cmd + key)
|
|
@@ -22,6 +24,12 @@ var handleKeyDown = exports.handleKeyDown = function handleKeyDown(view, event)
|
|
|
22
24
|
if (!isTypingKey) {
|
|
23
25
|
return false;
|
|
24
26
|
}
|
|
27
|
+
|
|
28
|
+
// With the experiment, a queued mousemove clears the typing state when it finally runs. Typing
|
|
29
|
+
// is newer than that move, so drop it, even if we are already editing.
|
|
30
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_improve_inp_batch_3')) {
|
|
31
|
+
(0, _handleMouseMove.clearPendingHoverSide)(view);
|
|
32
|
+
}
|
|
25
33
|
var state = (0, _pmPlugin.getInteractionTrackingState)(view.state);
|
|
26
34
|
|
|
27
35
|
// if user hasnt started typing yet, start timer
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.handleMouseMove = exports.handleMouseLeave = exports.handleMouseEnter = void 0;
|
|
6
|
+
exports.handleMouseMove = exports.handleMouseLeave = exports.handleMouseEnter = exports.clearPendingHoverSide = void 0;
|
|
7
7
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
8
8
|
var _handleMouseOver = require("../handle-mouse-over");
|
|
9
|
+
var _afterRenderScheduler = require("../utils/after-render-scheduler");
|
|
9
10
|
var _commands = require("./commands");
|
|
10
11
|
var _constants = require("./constants");
|
|
11
12
|
var _pmPlugin = require("./pm-plugin");
|
|
@@ -24,9 +25,12 @@ var cancelScheduledProcessForView = function cancelScheduledProcessForView(view)
|
|
|
24
25
|
rafIdByView.delete(view);
|
|
25
26
|
}
|
|
26
27
|
};
|
|
27
|
-
var clearPendingHoverSide = function clearPendingHoverSide(view) {
|
|
28
|
+
var clearPendingHoverSide = exports.clearPendingHoverSide = function clearPendingHoverSide(view) {
|
|
28
29
|
pendingByView.delete(view);
|
|
29
30
|
cancelScheduledProcessForView(view);
|
|
31
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_improve_inp_batch_3')) {
|
|
32
|
+
cancelHoverSideAfterRender(view);
|
|
33
|
+
}
|
|
30
34
|
};
|
|
31
35
|
var BLOCK_SELECTORS = '[data-node-anchor], [data-drag-handler-anchor-name]';
|
|
32
36
|
var LEGACY_RIGHT_EDGE_SELECTOR = '[data-blocks-right-edge-button-container]';
|
|
@@ -79,6 +83,9 @@ var getRightMarginBoundary = function getRightMarginBoundary(view) {
|
|
|
79
83
|
// Classify where the cursor sits in the right margin beside the block at its height, running the
|
|
80
84
|
// block lookup once so the caller doesn't traverse the DOM twice per mousemove.
|
|
81
85
|
var classifyRightMarginPosition = function classifyRightMarginPosition(view, event) {
|
|
86
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_improve_inp_batch_3')) {
|
|
87
|
+
return classifyRightMarginPositionByHitTest(view, event);
|
|
88
|
+
}
|
|
82
89
|
var found = findBlockAtY(view, event.clientY);
|
|
83
90
|
if (!found) {
|
|
84
91
|
return null;
|
|
@@ -188,6 +195,9 @@ var processHoverSide = function processHoverSide(view, api) {
|
|
|
188
195
|
}
|
|
189
196
|
};
|
|
190
197
|
var handleMouseMove = exports.handleMouseMove = function handleMouseMove(view, event, rightSideControlsEnabled, api) {
|
|
198
|
+
if (rightSideControlsEnabled && event instanceof MouseEvent && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_improve_inp_batch_3')) {
|
|
199
|
+
return handleMouseMoveAfterRender(view, event, api);
|
|
200
|
+
}
|
|
191
201
|
var state = (0, _pmPlugin.getInteractionTrackingState)(view.state);
|
|
192
202
|
// if user has stopped editing and moved their mouse, show block controls again
|
|
193
203
|
if (state !== null && state !== void 0 && state.isEditing) {
|
|
@@ -219,4 +229,113 @@ var handleMouseLeave = exports.handleMouseLeave = function handleMouseLeave(view
|
|
|
219
229
|
var handleMouseEnter = exports.handleMouseEnter = function handleMouseEnter(view) {
|
|
220
230
|
(0, _commands.mouseEnter)(view);
|
|
221
231
|
return false;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/* -------------------------------------------------------------------------------------------------
|
|
235
|
+
* EDITOR-9730: platform_editor_improve_inp_batch_3
|
|
236
|
+
*
|
|
237
|
+
* Everything below is the treatment path, reached through these gates only:
|
|
238
|
+
* - handleMouseMove -> handleMouseMoveAfterRender
|
|
239
|
+
* - classifyRightMarginPosition -> classifyRightMarginPositionByHitTest
|
|
240
|
+
* - clearPendingHoverSide -> cancelHoverSideAfterRender
|
|
241
|
+
* Clean-up when the experiment ships: delete this section, take the treatment branch at each gate
|
|
242
|
+
* (dropping findBlockAtY, getRootBlocks, the rAF bookkeeping and the legacy handleMouseMove body),
|
|
243
|
+
* and remove the gated calls in pm-plugin.ts and handle-key-down.ts.
|
|
244
|
+
* ---------------------------------------------------------------------------------------------- */
|
|
245
|
+
|
|
246
|
+
/** Per-view scheduler plus the latest plugin API to use when it runs. */
|
|
247
|
+
var afterRenderByView = new WeakMap();
|
|
248
|
+
var cancelHoverSideAfterRender = function cancelHoverSideAfterRender(view) {
|
|
249
|
+
var _afterRenderByView$ge;
|
|
250
|
+
(_afterRenderByView$ge = afterRenderByView.get(view)) === null || _afterRenderByView$ge === void 0 || _afterRenderByView$ge.scheduler.cancel();
|
|
251
|
+
};
|
|
252
|
+
var processHoverSideAfterRender = function processHoverSideAfterRender(view) {
|
|
253
|
+
var _getInteractionTracki;
|
|
254
|
+
var state = afterRenderByView.get(view);
|
|
255
|
+
if (!state || view.isDestroyed || !pendingByView.has(view)) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
processHoverSide(view, state.api);
|
|
259
|
+
|
|
260
|
+
// The typing state is cleared last, after every read above has finished, so no layout read
|
|
261
|
+
// follows one of our own writes. Typing cancels pending work (see handle-key-down.ts), so this
|
|
262
|
+
// never undoes a newer keystroke.
|
|
263
|
+
if ((_getInteractionTracki = (0, _pmPlugin.getInteractionTrackingState)(view.state)) !== null && _getInteractionTracki !== void 0 && _getInteractionTracki.isEditing) {
|
|
264
|
+
(0, _commands.stopEditing)(view);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
var handleMouseMoveAfterRender = function handleMouseMoveAfterRender(view, event, api) {
|
|
268
|
+
var win = view.dom.ownerDocument.defaultView;
|
|
269
|
+
if (!win) {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
pendingByView.set(view, event);
|
|
273
|
+
var state = afterRenderByView.get(view);
|
|
274
|
+
if (!state) {
|
|
275
|
+
state = {
|
|
276
|
+
api: api,
|
|
277
|
+
scheduler: (0, _afterRenderScheduler.createAfterRenderScheduler)(win, function () {
|
|
278
|
+
return processHoverSideAfterRender(view);
|
|
279
|
+
})
|
|
280
|
+
};
|
|
281
|
+
afterRenderByView.set(view, state);
|
|
282
|
+
}
|
|
283
|
+
// The latest event and API win when several moves coalesce into one run.
|
|
284
|
+
state.api = api;
|
|
285
|
+
// Reads run after the next frame renders, giving the browser an opportunity to update layout
|
|
286
|
+
// first (other work can still dirty it).
|
|
287
|
+
state.scheduler.schedule();
|
|
288
|
+
return false;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
// Walk up from a block to its top-level block (no block ancestor). Cost is bounded by nesting
|
|
292
|
+
// depth, matching getRootBlocks' filter without scanning the whole document.
|
|
293
|
+
var toRootBlock = function toRootBlock(block) {
|
|
294
|
+
var _root$parentElement;
|
|
295
|
+
var root = block;
|
|
296
|
+
var parent = (_root$parentElement = root.parentElement) === null || _root$parentElement === void 0 ? void 0 : _root$parentElement.closest(BLOCK_SELECTORS);
|
|
297
|
+
while (parent instanceof HTMLElement) {
|
|
298
|
+
var _root$parentElement2;
|
|
299
|
+
root = parent;
|
|
300
|
+
parent = (_root$parentElement2 = root.parentElement) === null || _root$parentElement2 === void 0 ? void 0 : _root$parentElement2.closest(BLOCK_SELECTORS);
|
|
301
|
+
}
|
|
302
|
+
return root;
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
// Right-margin lookup without the document-wide scan (EDITOR-9730): when the cursor is past the
|
|
306
|
+
// right edge of the editor content, hit-test once just inside that edge at the cursor's height and
|
|
307
|
+
// resolve the top-level block there.
|
|
308
|
+
//
|
|
309
|
+
// This still reads layout (getBoundingClientRect and elementFromPoint), so like findBlockAtY it
|
|
310
|
+
// forces a synchronous layout if layout is dirty when it runs. What changes is how much and when:
|
|
311
|
+
// one rect and one hit test instead of a rect per top-level block, and it runs in the
|
|
312
|
+
// after-render callback, where the browser has had an opportunity to update layout first.
|
|
313
|
+
var findRootBlockBesideCursor = function findRootBlockBesideCursor(view, event) {
|
|
314
|
+
var _root$elementFromPoin;
|
|
315
|
+
var contentRight = view.dom.getBoundingClientRect().right;
|
|
316
|
+
if (event.clientX <= contentRight) {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
var root = view.root;
|
|
320
|
+
if (typeof root.elementFromPoint !== 'function') {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
var block = (_root$elementFromPoin = root.elementFromPoint(contentRight - 1, event.clientY)) === null || _root$elementFromPoin === void 0 ? void 0 : _root$elementFromPoin.closest(BLOCK_SELECTORS);
|
|
324
|
+
if (!(block instanceof HTMLElement)) {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
var rootBlock = toRootBlock(block);
|
|
328
|
+
return view.dom.contains(rootBlock) ? rootBlock : null;
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// Same classification as the legacy path, with the block found by a hit test.
|
|
332
|
+
var classifyRightMarginPositionByHitTest = function classifyRightMarginPositionByHitTest(view, event) {
|
|
333
|
+
var block = findRootBlockBesideCursor(view, event);
|
|
334
|
+
if (!block) {
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
return {
|
|
338
|
+
type: 'active',
|
|
339
|
+
block: block
|
|
340
|
+
};
|
|
222
341
|
};
|
|
@@ -224,6 +224,9 @@ var createInteractionTrackingPlugin = exports.createInteractionTrackingPlugin =
|
|
|
224
224
|
var _unbindDocumentMouseM;
|
|
225
225
|
cancelScheduledMouseLeave();
|
|
226
226
|
(_unbindDocumentMouseM = unbindDocumentMouseMove) === null || _unbindDocumentMouseM === void 0 || _unbindDocumentMouseM();
|
|
227
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_improve_inp_batch_3')) {
|
|
228
|
+
(0, _handleMouseMove.clearPendingHoverSide)(_view);
|
|
229
|
+
}
|
|
227
230
|
}
|
|
228
231
|
(_unbindMouseEnter = unbindMouseEnter) === null || _unbindMouseEnter === void 0 || _unbindMouseEnter();
|
|
229
232
|
(_unbindMouseLeave = unbindMouseLeave) === null || _unbindMouseLeave === void 0 || _unbindMouseLeave();
|
|
@@ -7,13 +7,13 @@ exports.isPossibleGutterElement = exports.createGutterBlockFinder = exports.bind
|
|
|
7
7
|
var _bindEventListener = require("bind-event-listener");
|
|
8
8
|
var _dragHandle = require("@atlaskit/editor-common/styles/drag-handle");
|
|
9
9
|
var _constants = require("@atlaskit/editor-shared-styles/constants");
|
|
10
|
-
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
11
10
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
12
11
|
var _consts = require("../ui/consts");
|
|
13
12
|
var _handleSparseHoverTarget = require("./handle-sparse-hover-target");
|
|
14
13
|
var _commands = require("./interaction-tracking/commands");
|
|
15
14
|
var _handleMouseMove = require("./interaction-tracking/handle-mouse-move");
|
|
16
15
|
var _pmPlugin = require("./interaction-tracking/pm-plugin");
|
|
16
|
+
var _afterRenderScheduler = require("./utils/after-render-scheduler");
|
|
17
17
|
var _visibleBox = require("./utils/visible-box");
|
|
18
18
|
var BLOCK_SELECTOR = '[data-prosemirror-node-block="true"]';
|
|
19
19
|
var TABLE_STRUCTURE_NODES = new Set(['table', 'tableRow', 'tableCell', 'tableHeader']);
|
|
@@ -150,40 +150,6 @@ var classifyGutterHover = function classifyGutterHover(view, findGutterBlock, _r
|
|
|
150
150
|
};
|
|
151
151
|
};
|
|
152
152
|
|
|
153
|
-
/**
|
|
154
|
-
* Runs `callback` once after the next frame renders (`requestAnimationFrame`, then `setTimeout`).
|
|
155
|
-
* Layout is clean then, so reading positions never forces a synchronous layout. Calls made while a
|
|
156
|
-
* run is already scheduled are ignored.
|
|
157
|
-
*/
|
|
158
|
-
var createAfterRenderScheduler = function createAfterRenderScheduler(win, callback) {
|
|
159
|
-
var frame;
|
|
160
|
-
var timeout;
|
|
161
|
-
return {
|
|
162
|
-
schedule: function schedule() {
|
|
163
|
-
if (frame !== undefined || timeout !== undefined) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
frame = win.requestAnimationFrame(function () {
|
|
167
|
-
frame = undefined;
|
|
168
|
-
timeout = win.setTimeout(function () {
|
|
169
|
-
timeout = undefined;
|
|
170
|
-
callback();
|
|
171
|
-
}, 0);
|
|
172
|
-
});
|
|
173
|
-
},
|
|
174
|
-
cancel: function cancel() {
|
|
175
|
-
if (frame !== undefined) {
|
|
176
|
-
win.cancelAnimationFrame(frame);
|
|
177
|
-
frame = undefined;
|
|
178
|
-
}
|
|
179
|
-
if (timeout !== undefined) {
|
|
180
|
-
win.clearTimeout(timeout);
|
|
181
|
-
timeout = undefined;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
|
|
187
153
|
/**
|
|
188
154
|
* Keeps interaction tracking in step with gutter hover, as the legacy hover zones did. They sat
|
|
189
155
|
* inside the block tree, so hovering one cleared the typing state, counted as inside the editor even
|
|
@@ -256,7 +222,7 @@ var bindSparseGutterHover = exports.bindSparseGutterHover = function bindSparseG
|
|
|
256
222
|
}
|
|
257
223
|
syncInteractionTracking(pointer.event, hover.kind === 'block');
|
|
258
224
|
};
|
|
259
|
-
var scheduler = createAfterRenderScheduler(win, handlePendingPointer);
|
|
225
|
+
var scheduler = (0, _afterRenderScheduler.createAfterRenderScheduler)(win, handlePendingPointer);
|
|
260
226
|
var queueGutterEvent = function queueGutterEvent(event, reachedNewElement) {
|
|
261
227
|
var _pending;
|
|
262
228
|
pending = {
|
|
@@ -307,28 +273,22 @@ var bindSparseGutterHover = exports.bindSparseGutterHover = function bindSparseG
|
|
|
307
273
|
}
|
|
308
274
|
});
|
|
309
275
|
};
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
276
|
+
|
|
277
|
+
// Ignore hover from a resting pointer until it first moves.
|
|
278
|
+
var pointerHasMoved = false;
|
|
279
|
+
var unbindMouseOver = bindMouseListener('mouseover', function (event) {
|
|
280
|
+
if (!pointerHasMoved) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
onMouseOver(event);
|
|
284
|
+
});
|
|
285
|
+
var unbindMouseMove = bindMouseListener('mousemove', function (event) {
|
|
286
|
+
if (!pointerHasMoved) {
|
|
287
|
+
pointerHasMoved = true;
|
|
319
288
|
onMouseOver(event);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
pointerHasMoved = true;
|
|
324
|
-
onMouseOver(event);
|
|
325
|
-
}
|
|
326
|
-
onMouseMove(event);
|
|
327
|
-
});
|
|
328
|
-
} else {
|
|
329
|
-
unbindMouseOver = bindMouseListener('mouseover', onMouseOver);
|
|
330
|
-
unbindMouseMove = bindMouseListener('mousemove', onMouseMove);
|
|
331
|
-
}
|
|
289
|
+
}
|
|
290
|
+
onMouseMove(event);
|
|
291
|
+
});
|
|
332
292
|
return function () {
|
|
333
293
|
unbindMouseOver();
|
|
334
294
|
unbindMouseMove();
|
|
@@ -8,8 +8,8 @@ var _surfaceCandidateInvalidation = require("@atlaskit/editor-common/block-contr
|
|
|
8
8
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
9
9
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
10
|
var _view2 = require("@atlaskit/editor-prosemirror/view");
|
|
11
|
+
var _sparseSurfacesViewWithLifecycle = require("../surface-lifecycle/sparse-surfaces-view-with-lifecycle");
|
|
11
12
|
var _main = require("./main");
|
|
12
|
-
var _sparseSurfacesView = require("./sparse-surfaces-view");
|
|
13
13
|
var _sparseSurfaceCandidates = require("./utils/sparse-surface-candidates");
|
|
14
14
|
var _sparseSurfacesState = require("./utils/sparse-surfaces-state");
|
|
15
15
|
var sparseSurfacesKey = exports.sparseSurfacesKey = new _state.PluginKey('blockControlsSparseSurfaces');
|
|
@@ -39,7 +39,7 @@ var createSparseSurfacesPlugin = exports.createSparseSurfacesPlugin = function c
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
view: function view(_view) {
|
|
42
|
-
return (0,
|
|
42
|
+
return (0, _sparseSurfacesViewWithLifecycle.createSparseSurfacesViewWithLifecycle)({
|
|
43
43
|
api: api,
|
|
44
44
|
pluginKey: sparseSurfacesKey,
|
|
45
45
|
view: _view
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createAfterRenderScheduler = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Runs `callback` once after the next frame renders (`requestAnimationFrame`, then `setTimeout`).
|
|
9
|
+
* Deferring position reads gives the browser an opportunity to update layout first; other work
|
|
10
|
+
* can still invalidate layout before the callback. Calls made while a run is scheduled are ignored.
|
|
11
|
+
*/
|
|
12
|
+
var createAfterRenderScheduler = exports.createAfterRenderScheduler = function createAfterRenderScheduler(win, callback) {
|
|
13
|
+
var frame;
|
|
14
|
+
var timeout;
|
|
15
|
+
return {
|
|
16
|
+
schedule: function schedule() {
|
|
17
|
+
if (frame !== undefined || timeout !== undefined) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
frame = win.requestAnimationFrame(function () {
|
|
21
|
+
frame = undefined;
|
|
22
|
+
timeout = win.setTimeout(function () {
|
|
23
|
+
timeout = undefined;
|
|
24
|
+
callback();
|
|
25
|
+
}, 0);
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
cancel: function cancel() {
|
|
29
|
+
if (frame !== undefined) {
|
|
30
|
+
win.cancelAnimationFrame(frame);
|
|
31
|
+
frame = undefined;
|
|
32
|
+
}
|
|
33
|
+
if (timeout !== undefined) {
|
|
34
|
+
win.clearTimeout(timeout);
|
|
35
|
+
timeout = undefined;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -10,28 +10,13 @@ require("./block-controls-left-surface.compiled.css");
|
|
|
10
10
|
var _runtime = require("@compiled/react/runtime");
|
|
11
11
|
var _react = _interopRequireDefault(require("react"));
|
|
12
12
|
var _blockControlUiContext = require("@atlaskit/editor-common/block-controls/block-control-ui-context");
|
|
13
|
-
var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys");
|
|
14
|
-
var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
|
|
15
|
-
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
16
13
|
var _blockControlsSurfaceWithClsFix = require("../surface-lifecycle/block-controls-surface-with-cls-fix");
|
|
17
|
-
var _blockControlsSurfaceComponents = require("./block-controls-surface-components");
|
|
18
|
-
var _blockControlsSurfaceContext = require("./block-controls-surface-context");
|
|
19
|
-
var _visibilityContainer = require("./visibility-container");
|
|
20
14
|
var leftSurfaceHiddenWrapperStyles = null;
|
|
21
15
|
var leftSurfaceOuterStyles = null;
|
|
22
16
|
var leftSurfaceGutterStyles = {
|
|
23
17
|
container: "_1f38ffwv _7cca15wb _lcxvglyw",
|
|
24
18
|
row: "_1bahesu3 _lcxvglyw _w1y61wug _19vrglyw"
|
|
25
19
|
};
|
|
26
|
-
|
|
27
|
-
// Nested surfaces (e.g. a table inside an expand) can span the target node's full height and sit
|
|
28
|
-
// over controls rendered in the node's own gutter, such as the table row insert button. Let pointer
|
|
29
|
-
// events pass through the wrapper and row so those controls stay interactive, matching the top-level
|
|
30
|
-
// gutter behaviour without applying its container query sizing.
|
|
31
|
-
var nestedSurfacePointerEventsStyles = {
|
|
32
|
-
container: "_lcxvglyw",
|
|
33
|
-
row: "_lcxvglyw _w1y61wug"
|
|
34
|
-
};
|
|
35
20
|
var leftSurfaceRowStyles = null;
|
|
36
21
|
|
|
37
22
|
// Applied in addition to leftSurfaceRowStyles when the target node is sticky-eligible (e.g. long
|
|
@@ -42,50 +27,12 @@ var leftSurfaceStickyStyles = null;
|
|
|
42
27
|
|
|
43
28
|
// Keep in sync with STICKY_CONTROLS_TOP_MARGIN_FOR_STICKY_HEADER in ./consts (must be a static literal here)
|
|
44
29
|
var leftSurfaceStickyTableHeaderStyles = null;
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
components = _ref.components,
|
|
48
|
-
forceVisibleOnMouseOut = _ref.forceVisibleOnMouseOut,
|
|
30
|
+
var BlockControlsLeftSurfaceWrapper = function BlockControlsLeftSurfaceWrapper(_ref) {
|
|
31
|
+
var children = _ref.children,
|
|
49
32
|
placement = _ref.placement,
|
|
50
33
|
source = _ref.source,
|
|
51
34
|
surfaceContext = _ref.surfaceContext;
|
|
52
35
|
var blockControlsContext = surfaceContext.get(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT);
|
|
53
|
-
var controlSide = (0, _blockControlsSurfaceContext.getBlockControlsSurfaceControlSide)(blockControlsContext, (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_controls_reliable_anchor'));
|
|
54
|
-
var _useBlockControlsVisi = (0, _visibilityContainer.useBlockControlsVisibility)({
|
|
55
|
-
api: api,
|
|
56
|
-
controlSide: controlSide,
|
|
57
|
-
forceVisibleOnMouseOut: forceVisibleOnMouseOut
|
|
58
|
-
}),
|
|
59
|
-
shouldHideHoverControls = _useBlockControlsVisi.shouldHide,
|
|
60
|
-
useCssStyles = _useBlockControlsVisi.useCssStyles;
|
|
61
|
-
var isSticky = placement.isSticky;
|
|
62
|
-
var isTopLevel = (blockControlsContext === null || blockControlsContext === void 0 ? void 0 : blockControlsContext.targetNode.parentType) === 'doc';
|
|
63
|
-
var shouldPassThroughNestedPointerEvents = !isTopLevel && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_nested_left_surface_pointer_fix');
|
|
64
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
65
|
-
"data-editor-block-controls-surface": true,
|
|
66
|
-
"data-editor-block-controls-side": "left",
|
|
67
|
-
"data-testid": source === 'stored' ? 'block-controls-left-surface-stored' : source === 'active' ? 'block-controls-left-surface-active' : 'block-controls-left-surface'
|
|
68
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Placement is resolved per target node, from its runtime DOM geometry or from its CSS anchor.
|
|
69
|
-
,
|
|
70
|
-
style: placement.style,
|
|
71
|
-
className: (0, _runtime.ax)(["_kqswstnw _17c61i8t _1pbyb4wl", isTopLevel && leftSurfaceGutterStyles.container, shouldPassThroughNestedPointerEvents && nestedSurfacePointerEventsStyles.container])
|
|
72
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
73
|
-
className: (0, _runtime.ax)(["_zulpv77o _4cvr1h6o _1e0c1txw", isTopLevel && leftSurfaceGutterStyles.row, shouldPassThroughNestedPointerEvents && nestedSurfacePointerEventsStyles.row, isSticky && "_kqsw1if8 _154iu2gc", isSticky && (blockControlsContext === null || blockControlsContext === void 0 ? void 0 : blockControlsContext.targetNode.type.name) === 'table' && "_154i1ejb"])
|
|
74
|
-
}, /*#__PURE__*/_react.default.createElement(_blockControlsSurfaceComponents.BlockControlsVisibilityProvider, {
|
|
75
|
-
shouldHideHoverControls: shouldHideHoverControls,
|
|
76
|
-
useCssStyles: useCssStyles
|
|
77
|
-
}, /*#__PURE__*/_react.default.createElement(_surfaceRenderer.SurfaceRenderer, {
|
|
78
|
-
components: components,
|
|
79
|
-
surface: _surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE,
|
|
80
|
-
surfaceContext: surfaceContext
|
|
81
|
-
}))));
|
|
82
|
-
};
|
|
83
|
-
var BlockControlsLeftSurfaceWrapper = function BlockControlsLeftSurfaceWrapper(_ref2) {
|
|
84
|
-
var children = _ref2.children,
|
|
85
|
-
placement = _ref2.placement,
|
|
86
|
-
source = _ref2.source,
|
|
87
|
-
surfaceContext = _ref2.surfaceContext;
|
|
88
|
-
var blockControlsContext = surfaceContext.get(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT);
|
|
89
36
|
var isSticky = placement.isSticky;
|
|
90
37
|
var isTopLevel = (blockControlsContext === null || blockControlsContext === void 0 ? void 0 : blockControlsContext.targetNode.parentType) === 'doc';
|
|
91
38
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -102,35 +49,24 @@ var BlockControlsLeftSurfaceWrapper = function BlockControlsLeftSurfaceWrapper(_
|
|
|
102
49
|
};
|
|
103
50
|
|
|
104
51
|
/** Renders one left block-controls surface at a document position. */
|
|
105
|
-
var BlockControlsLeftSurface = exports.BlockControlsLeftSurface = function BlockControlsLeftSurface(
|
|
106
|
-
var api =
|
|
107
|
-
components =
|
|
108
|
-
forceVisibleOnMouseOut =
|
|
109
|
-
placement =
|
|
110
|
-
source =
|
|
111
|
-
surfaceContext =
|
|
52
|
+
var BlockControlsLeftSurface = exports.BlockControlsLeftSurface = function BlockControlsLeftSurface(_ref2) {
|
|
53
|
+
var api = _ref2.api,
|
|
54
|
+
components = _ref2.components,
|
|
55
|
+
forceVisibleOnMouseOut = _ref2.forceVisibleOnMouseOut,
|
|
56
|
+
placement = _ref2.placement,
|
|
57
|
+
source = _ref2.source,
|
|
58
|
+
surfaceContext = _ref2.surfaceContext;
|
|
112
59
|
if (!placement) {
|
|
113
60
|
return null;
|
|
114
61
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
});
|
|
126
|
-
} else {
|
|
127
|
-
return /*#__PURE__*/_react.default.createElement(BlockControlsLeftSurfaceContent, {
|
|
128
|
-
api: api,
|
|
129
|
-
components: components,
|
|
130
|
-
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
131
|
-
placement: placement,
|
|
132
|
-
source: source,
|
|
133
|
-
surfaceContext: surfaceContext
|
|
134
|
-
});
|
|
135
|
-
}
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement(_blockControlsSurfaceWithClsFix.BlockControlsSurfaceWithClsFix, {
|
|
63
|
+
side: "left",
|
|
64
|
+
SurfaceWrapper: BlockControlsLeftSurfaceWrapper,
|
|
65
|
+
api: api,
|
|
66
|
+
components: components,
|
|
67
|
+
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
68
|
+
placement: placement,
|
|
69
|
+
source: source,
|
|
70
|
+
surfaceContext: surfaceContext
|
|
71
|
+
});
|
|
136
72
|
};
|