@atlaskit/editor-plugin-block-controls 31.1.16 → 31.1.18

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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 31.1.18
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 31.1.17
10
+
11
+ ### Patch Changes
12
+
13
+ - [`76946179af203`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/76946179af203) -
14
+ [ux] Expand collapsed headings and insert a new paragraph with slash Quick Insert when pressing
15
+ the adjacent plus button, behind `platform_editor_collapsible_headings`. Quick Insert now declares
16
+ the optional block-collapse plugin dependency and preserves single-transaction insertion when the
17
+ existing block-control INP treatment is enabled.
18
+ - Updated dependencies
19
+
3
20
  ## 31.1.16
4
21
 
5
22
  ### Patch Changes
@@ -20,6 +20,7 @@ var _utils = require("@atlaskit/editor-prosemirror/utils");
20
20
  var _constants = require("@atlaskit/editor-shared-styles/constants");
21
21
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
22
22
  var _add = _interopRequireDefault(require("@atlaskit/icon/core/add"));
23
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
23
24
  var _box = require("@atlaskit/primitives/box");
24
25
  var _pressable = require("@atlaskit/primitives/pressable");
25
26
  var _xcss = require("@atlaskit/primitives/xcss/xcss");
@@ -267,11 +268,22 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
267
268
  };
268
269
  }, [calculatePosition, view.dom, rootAnchorName, rootNodeType]);
269
270
  var handleQuickInsert = (0, _react.useCallback)(function () {
270
- var _api$quickInsert;
271
+ var _api$blockCollapse, _api$quickInsert;
271
272
  // if the selection is not within the node this decoration is rendered at
272
273
  // then insert a newline and trigger quick insert
273
274
  var start = getPos();
274
- if (start !== undefined) {
275
+ if (start !== undefined && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_collapsible_headings') && (_api$blockCollapse = api.blockCollapse) !== null && _api$blockCollapse !== void 0 && (_api$blockCollapse = _api$blockCollapse.sharedState.currentState()) !== null && _api$blockCollapse !== void 0 && _api$blockCollapse.collapsedHeadingPositions.has(start)) {
276
+ api.core.actions.execute(function (_ref3) {
277
+ var _api$blockCollapse2;
278
+ var tr = _ref3.tr;
279
+ (_api$blockCollapse2 = api.blockCollapse) === null || _api$blockCollapse2 === void 0 || _api$blockCollapse2.commands.expandHeading(start)({
280
+ tr: tr
281
+ });
282
+ return (0, _editorCommands.createNewLine)(start)({
283
+ tr: tr
284
+ });
285
+ });
286
+ } else if (start !== undefined) {
275
287
  // if the selection is not within the node this decoration is rendered at
276
288
  // or the node is non-editable, then insert a newline and trigger quick insert
277
289
  var isSelectionInsideNode = (0, _documentChecks.isSelectionInNode)(start, view);
@@ -296,8 +308,8 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
296
308
  var newPos =
297
309
  //if the current selection is selected from right to left, then set the selection to the start of the paragraph
298
310
  currentSelection.anchor === currentSelection.to ? currentParagraphNode.pos : currentParagraphNode.pos + currentParagraphNode.node.nodeSize - 1;
299
- api.core.actions.execute(function (_ref3) {
300
- var tr = _ref3.tr;
311
+ api.core.actions.execute(function (_ref4) {
312
+ var tr = _ref4.tr;
301
313
  tr.setSelection(_state.TextSelection.create(view.state.selection.$from.doc, newPos));
302
314
  return tr;
303
315
  });
@@ -311,8 +323,8 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
311
323
  // otherwise need to force the selection to be at the start of the node, because
312
324
  // prosemirror is keeping it as NodeSelection for nested nodes. Do this to keep it
313
325
  // consistent NodeSelection for root level nodes.
314
- api.core.actions.execute(function (_ref4) {
315
- var tr = _ref4.tr;
326
+ api.core.actions.execute(function (_ref5) {
327
+ var tr = _ref5.tr;
316
328
  (0, _editorCommands.createNewLine)(view.state.selection.from)({
317
329
  tr: tr
318
330
  });
@@ -324,8 +336,8 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
324
336
  if (currentSelection instanceof _cellSelection.CellSelection) {
325
337
  // find the last inline position in the selection
326
338
  var lastInlinePosition = _state.TextSelection.near(view.state.selection.$to, -1);
327
- lastInlinePosition && api.core.actions.execute(function (_ref5) {
328
- var tr = _ref5.tr;
339
+ lastInlinePosition && api.core.actions.execute(function (_ref6) {
340
+ var tr = _ref6.tr;
329
341
  if (!(lastInlinePosition instanceof _state.TextSelection)) {
330
342
  // this will create a new line after the node
331
343
  (0, _editorCommands.createNewLine)(lastInlinePosition.from)({
@@ -384,16 +396,16 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
384
396
  css: [tooltipContainerStyles, tooltipContainerImprovedStylesStickyHeader, tooltipContainerStylesImprovedStickyHeaderWithMarksFix]
385
397
  }, tooltipPressable()));
386
398
  };
387
- var QuickInsertWithVisibility = exports.QuickInsertWithVisibility = function QuickInsertWithVisibility(_ref6) {
388
- var view = _ref6.view,
389
- api = _ref6.api,
390
- formatMessage = _ref6.formatMessage,
391
- getPos = _ref6.getPos,
392
- nodeType = _ref6.nodeType,
393
- anchorName = _ref6.anchorName,
394
- rootAnchorName = _ref6.rootAnchorName,
395
- rootNodeType = _ref6.rootNodeType,
396
- anchorRectCache = _ref6.anchorRectCache;
399
+ var QuickInsertWithVisibility = exports.QuickInsertWithVisibility = function QuickInsertWithVisibility(_ref7) {
400
+ var view = _ref7.view,
401
+ api = _ref7.api,
402
+ formatMessage = _ref7.formatMessage,
403
+ getPos = _ref7.getPos,
404
+ nodeType = _ref7.nodeType,
405
+ anchorName = _ref7.anchorName,
406
+ rootAnchorName = _ref7.rootAnchorName,
407
+ rootNodeType = _ref7.rootNodeType,
408
+ anchorRectCache = _ref7.anchorRectCache;
397
409
  var rightSideControlsEnabled = (0, _useSharedPluginStateWithSelector.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
398
410
  var _states$blockControls, _states$blockControls2;
399
411
  return {
@@ -16,6 +16,7 @@ import { findParentNode, findParentNodeOfType } from '@atlaskit/editor-prosemirr
16
16
  import { relativeSizeToBaseFontSize } from '@atlaskit/editor-shared-styles/constants';
17
17
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
18
18
  import AddIcon from '@atlaskit/icon/core/add';
19
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
19
20
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
20
21
  import { Box } from '@atlaskit/primitives/box';
21
22
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
@@ -259,11 +260,23 @@ export const TypeAheadControl = ({
259
260
  };
260
261
  }, [calculatePosition, view.dom, rootAnchorName, rootNodeType]);
261
262
  const handleQuickInsert = useCallback(() => {
262
- var _api$quickInsert;
263
+ var _api$blockCollapse, _api$blockCollapse$sh, _api$quickInsert;
263
264
  // if the selection is not within the node this decoration is rendered at
264
265
  // then insert a newline and trigger quick insert
265
266
  const start = getPos();
266
- if (start !== undefined) {
267
+ if (start !== undefined && isExperimentEnabled('platform_editor_collapsible_headings') && (_api$blockCollapse = api.blockCollapse) !== null && _api$blockCollapse !== void 0 && (_api$blockCollapse$sh = _api$blockCollapse.sharedState.currentState()) !== null && _api$blockCollapse$sh !== void 0 && _api$blockCollapse$sh.collapsedHeadingPositions.has(start)) {
268
+ api.core.actions.execute(({
269
+ tr
270
+ }) => {
271
+ var _api$blockCollapse2;
272
+ (_api$blockCollapse2 = api.blockCollapse) === null || _api$blockCollapse2 === void 0 ? void 0 : _api$blockCollapse2.commands.expandHeading(start)({
273
+ tr
274
+ });
275
+ return createNewLine(start)({
276
+ tr
277
+ });
278
+ });
279
+ } else if (start !== undefined) {
267
280
  // if the selection is not within the node this decoration is rendered at
268
281
  // or the node is non-editable, then insert a newline and trigger quick insert
269
282
  const isSelectionInsideNode = isSelectionInNode(start, view);
@@ -20,6 +20,7 @@ import { findParentNode, findParentNodeOfType } from '@atlaskit/editor-prosemirr
20
20
  import { relativeSizeToBaseFontSize } from '@atlaskit/editor-shared-styles/constants';
21
21
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
22
22
  import AddIcon from '@atlaskit/icon/core/add';
23
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
23
24
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
24
25
  import { Box } from '@atlaskit/primitives/box';
25
26
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
@@ -261,11 +262,22 @@ export var TypeAheadControl = function TypeAheadControl(_ref2) {
261
262
  };
262
263
  }, [calculatePosition, view.dom, rootAnchorName, rootNodeType]);
263
264
  var handleQuickInsert = useCallback(function () {
264
- var _api$quickInsert;
265
+ var _api$blockCollapse, _api$quickInsert;
265
266
  // if the selection is not within the node this decoration is rendered at
266
267
  // then insert a newline and trigger quick insert
267
268
  var start = getPos();
268
- if (start !== undefined) {
269
+ if (start !== undefined && isExperimentEnabled('platform_editor_collapsible_headings') && (_api$blockCollapse = api.blockCollapse) !== null && _api$blockCollapse !== void 0 && (_api$blockCollapse = _api$blockCollapse.sharedState.currentState()) !== null && _api$blockCollapse !== void 0 && _api$blockCollapse.collapsedHeadingPositions.has(start)) {
270
+ api.core.actions.execute(function (_ref3) {
271
+ var _api$blockCollapse2;
272
+ var tr = _ref3.tr;
273
+ (_api$blockCollapse2 = api.blockCollapse) === null || _api$blockCollapse2 === void 0 || _api$blockCollapse2.commands.expandHeading(start)({
274
+ tr: tr
275
+ });
276
+ return createNewLine(start)({
277
+ tr: tr
278
+ });
279
+ });
280
+ } else if (start !== undefined) {
269
281
  // if the selection is not within the node this decoration is rendered at
270
282
  // or the node is non-editable, then insert a newline and trigger quick insert
271
283
  var isSelectionInsideNode = isSelectionInNode(start, view);
@@ -290,8 +302,8 @@ export var TypeAheadControl = function TypeAheadControl(_ref2) {
290
302
  var newPos =
291
303
  //if the current selection is selected from right to left, then set the selection to the start of the paragraph
292
304
  currentSelection.anchor === currentSelection.to ? currentParagraphNode.pos : currentParagraphNode.pos + currentParagraphNode.node.nodeSize - 1;
293
- api.core.actions.execute(function (_ref3) {
294
- var tr = _ref3.tr;
305
+ api.core.actions.execute(function (_ref4) {
306
+ var tr = _ref4.tr;
295
307
  tr.setSelection(TextSelection.create(view.state.selection.$from.doc, newPos));
296
308
  return tr;
297
309
  });
@@ -305,8 +317,8 @@ export var TypeAheadControl = function TypeAheadControl(_ref2) {
305
317
  // otherwise need to force the selection to be at the start of the node, because
306
318
  // prosemirror is keeping it as NodeSelection for nested nodes. Do this to keep it
307
319
  // consistent NodeSelection for root level nodes.
308
- api.core.actions.execute(function (_ref4) {
309
- var tr = _ref4.tr;
320
+ api.core.actions.execute(function (_ref5) {
321
+ var tr = _ref5.tr;
310
322
  createNewLine(view.state.selection.from)({
311
323
  tr: tr
312
324
  });
@@ -318,8 +330,8 @@ export var TypeAheadControl = function TypeAheadControl(_ref2) {
318
330
  if (currentSelection instanceof CellSelection) {
319
331
  // find the last inline position in the selection
320
332
  var lastInlinePosition = TextSelection.near(view.state.selection.$to, -1);
321
- lastInlinePosition && api.core.actions.execute(function (_ref5) {
322
- var tr = _ref5.tr;
333
+ lastInlinePosition && api.core.actions.execute(function (_ref6) {
334
+ var tr = _ref6.tr;
323
335
  if (!(lastInlinePosition instanceof TextSelection)) {
324
336
  // this will create a new line after the node
325
337
  createNewLine(lastInlinePosition.from)({
@@ -378,16 +390,16 @@ export var TypeAheadControl = function TypeAheadControl(_ref2) {
378
390
  css: [tooltipContainerStyles, tooltipContainerImprovedStylesStickyHeader, tooltipContainerStylesImprovedStickyHeaderWithMarksFix]
379
391
  }, tooltipPressable()));
380
392
  };
381
- export var QuickInsertWithVisibility = function QuickInsertWithVisibility(_ref6) {
382
- var view = _ref6.view,
383
- api = _ref6.api,
384
- formatMessage = _ref6.formatMessage,
385
- getPos = _ref6.getPos,
386
- nodeType = _ref6.nodeType,
387
- anchorName = _ref6.anchorName,
388
- rootAnchorName = _ref6.rootAnchorName,
389
- rootNodeType = _ref6.rootNodeType,
390
- anchorRectCache = _ref6.anchorRectCache;
393
+ export var QuickInsertWithVisibility = function QuickInsertWithVisibility(_ref7) {
394
+ var view = _ref7.view,
395
+ api = _ref7.api,
396
+ formatMessage = _ref7.formatMessage,
397
+ getPos = _ref7.getPos,
398
+ nodeType = _ref7.nodeType,
399
+ anchorName = _ref7.anchorName,
400
+ rootAnchorName = _ref7.rootAnchorName,
401
+ rootNodeType = _ref7.rootNodeType,
402
+ anchorRectCache = _ref7.anchorRectCache;
391
403
  var rightSideControlsEnabled = useSharedPluginStateWithSelector(api, ['blockControls'], function (states) {
392
404
  var _states$blockControls, _states$blockControls2;
393
405
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "31.1.16",
3
+ "version": "31.1.18",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -38,10 +38,10 @@
38
38
  "@atlaskit/editor-plugin-interaction": "^44.0.0",
39
39
  "@atlaskit/editor-plugin-limited-mode": "^27.0.0",
40
40
  "@atlaskit/editor-plugin-metrics": "^31.0.0",
41
- "@atlaskit/editor-plugin-quick-insert": "^30.0.0",
41
+ "@atlaskit/editor-plugin-quick-insert": "^30.1.0",
42
42
  "@atlaskit/editor-plugin-selection": "^30.0.0",
43
43
  "@atlaskit/editor-plugin-show-diff": "^30.0.0",
44
- "@atlaskit/editor-plugin-toolbar": "^27.0.0",
44
+ "@atlaskit/editor-plugin-toolbar": "^27.1.0",
45
45
  "@atlaskit/editor-plugin-type-ahead": "^31.0.0",
46
46
  "@atlaskit/editor-plugin-ui-control-registry": "^24.0.0",
47
47
  "@atlaskit/editor-plugin-user-intent": "^28.0.0",
@@ -50,18 +50,18 @@
50
50
  "@atlaskit/editor-shared-styles": "^5.1.0",
51
51
  "@atlaskit/editor-tables": "^3.2.0",
52
52
  "@atlaskit/editor-ui-control-model": "^3.0.0",
53
- "@atlaskit/icon": "^38.0.0",
53
+ "@atlaskit/icon": "^38.1.0",
54
54
  "@atlaskit/link": "^5.1.0",
55
55
  "@atlaskit/platform-feature-experiments": "^0.3.0",
56
56
  "@atlaskit/platform-feature-flags": "^2.2.0",
57
57
  "@atlaskit/pragmatic-drag-and-drop": "^4.0.0",
58
58
  "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^3.2.0",
59
- "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^4.2.0",
59
+ "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^4.3.0",
60
60
  "@atlaskit/primitives": "^22.7.0",
61
- "@atlaskit/section-message": "^10.2.0",
61
+ "@atlaskit/section-message": "^10.3.0",
62
62
  "@atlaskit/theme": "^28.2.0",
63
- "@atlaskit/tmp-editor-statsig": "^262.0.0",
64
- "@atlaskit/tokens": "^20.11.0",
63
+ "@atlaskit/tmp-editor-statsig": "^263.0.0",
64
+ "@atlaskit/tokens": "^20.12.0",
65
65
  "@atlaskit/tooltip": "^24.4.0",
66
66
  "@babel/runtime": "^7.0.0",
67
67
  "@compiled/react": "^1.0.2",
@@ -72,7 +72,7 @@
72
72
  "uuid": "^11.1.1"
73
73
  },
74
74
  "peerDependencies": {
75
- "@atlaskit/editor-common": "^134.16.0",
75
+ "@atlaskit/editor-common": "^134.20.0",
76
76
  "react": "^18.2.0 || ^19.2.0",
77
77
  "react-dom": "^18.2.0 || ^19.2.0",
78
78
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -96,7 +96,7 @@
96
96
  }
97
97
  },
98
98
  "devDependencies": {
99
- "@atlaskit/editor-common": "^134.16.0",
99
+ "@atlaskit/editor-common": "^134.20.0",
100
100
  "@atlassian/structured-docs-types": "workspace:^",
101
101
  "@atlassian/workbench": "workspace:*",
102
102
  "react": "^19.2.0",