@atlaskit/editor-plugin-block-type 14.1.3 → 14.1.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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-block-type
2
2
 
3
+ ## 14.1.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`41962dd9dccb2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/41962dd9dccb2) -
8
+ NO-ISSUE: adds a default toolbar state so we can render the toolbar on initial load without
9
+ relying on editor state
10
+ - Updated dependencies
11
+
12
+ ## 14.1.4
13
+
14
+ ### Patch Changes
15
+
16
+ - [`32dce97f78584`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/32dce97f78584) -
17
+ Fix preserved selection mapping when comment editors append a trailing paragraph after block menu
18
+ transforms.
19
+ - Updated dependencies
20
+
3
21
  ## 14.1.3
4
22
 
5
23
  ### Patch Changes
@@ -7,12 +7,14 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.pluginKey = exports.createPlugin = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
+ var _blockType = require("@atlaskit/editor-common/block-type");
10
11
  var _browser = require("@atlaskit/editor-common/browser");
11
12
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
12
13
  var _state = require("@atlaskit/editor-prosemirror/state");
14
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
15
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
14
16
  var _blockTypes = require("./block-types");
15
- var _blockType = require("./commands/block-type");
17
+ var _blockType2 = require("./commands/block-type");
16
18
  var _consts = require("./consts");
17
19
  var _utils = require("./utils");
18
20
  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; }
@@ -82,9 +84,9 @@ var detectBlockType = function detectBlockType(availableBlockTypes, state) {
82
84
  };
83
85
  var autoformatHeading = function autoformatHeading(headingLevel, editorAnalyticsApi) {
84
86
  if (headingLevel === 0) {
85
- return (0, _blockType.setNormalTextWithAnalytics)(_analytics.INPUT_METHOD.FORMATTING, editorAnalyticsApi);
87
+ return (0, _blockType2.setNormalTextWithAnalytics)(_analytics.INPUT_METHOD.FORMATTING, editorAnalyticsApi);
86
88
  }
87
- return (0, _blockType.setHeadingWithAnalytics)(headingLevel, _analytics.INPUT_METHOD.FORMATTING, editorAnalyticsApi);
89
+ return (0, _blockType2.setHeadingWithAnalytics)(headingLevel, _analytics.INPUT_METHOD.FORMATTING, editorAnalyticsApi);
88
90
  };
89
91
  var pluginKey = exports.pluginKey = new _state.PluginKey('blockTypePlugin');
90
92
  var createPlugin = exports.createPlugin = function createPlugin(editorAPI, dispatch, lastNodeMustBeParagraph, includeBlockQuoteAsTextstyleOption, allowFontSize) {
@@ -98,7 +100,8 @@ var createPlugin = exports.createPlugin = function createPlugin(editorAPI, dispa
98
100
  var lastNode = pos.node(1);
99
101
  var paragraph = newState.schema.nodes.paragraph;
100
102
  if (lastNode && lastNode.isBlock && lastNode.type !== paragraph) {
101
- return newState.tr.insert(newState.doc.content.size, newState.schema.nodes.paragraph.create());
103
+ var tr = newState.tr.insert(newState.doc.content.size, newState.schema.nodes.paragraph.create());
104
+ return (0, _platformFeatureFlags.fg)('platform_editor_block_menu_jira_patch_2') ? tr.setMeta(_blockType.INSERTED_TRAILING_PARAGRAPH_TO_LAST_NODE_META, true) : tr;
102
105
  }
103
106
  }
104
107
  },
@@ -162,10 +165,10 @@ var createPlugin = exports.createPlugin = function createPlugin(editorAPI, dispa
162
165
  } else if (event.keyCode === _consts.KEY_7 && event.altKey && (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true)) {
163
166
  if (browser.mac && event.metaKey) {
164
167
  var _editorAPI$core$actio3, _editorAPI$core3;
165
- return (_editorAPI$core$actio3 = editorAPI === null || editorAPI === void 0 || (_editorAPI$core3 = editorAPI.core) === null || _editorAPI$core3 === void 0 ? void 0 : _editorAPI$core3.actions.execute((0, _blockType.setSmallTextWithAnalytics)(_analytics.INPUT_METHOD.SHORTCUT, editorAnalyticsApi))) !== null && _editorAPI$core$actio3 !== void 0 ? _editorAPI$core$actio3 : false;
168
+ return (_editorAPI$core$actio3 = editorAPI === null || editorAPI === void 0 || (_editorAPI$core3 = editorAPI.core) === null || _editorAPI$core3 === void 0 ? void 0 : _editorAPI$core3.actions.execute((0, _blockType2.setSmallTextWithAnalytics)(_analytics.INPUT_METHOD.SHORTCUT, editorAnalyticsApi))) !== null && _editorAPI$core$actio3 !== void 0 ? _editorAPI$core$actio3 : false;
166
169
  } else if (!browser.mac && event.ctrlKey && altKeyLocation !== event.DOM_KEY_LOCATION_RIGHT) {
167
170
  var _editorAPI$core$actio4, _editorAPI$core4;
168
- return (_editorAPI$core$actio4 = editorAPI === null || editorAPI === void 0 || (_editorAPI$core4 = editorAPI.core) === null || _editorAPI$core4 === void 0 ? void 0 : _editorAPI$core4.actions.execute((0, _blockType.setSmallTextWithAnalytics)(_analytics.INPUT_METHOD.SHORTCUT, editorAnalyticsApi))) !== null && _editorAPI$core$actio4 !== void 0 ? _editorAPI$core$actio4 : false;
171
+ return (_editorAPI$core$actio4 = editorAPI === null || editorAPI === void 0 || (_editorAPI$core4 = editorAPI.core) === null || _editorAPI$core4 === void 0 ? void 0 : _editorAPI$core4.actions.execute((0, _blockType2.setSmallTextWithAnalytics)(_analytics.INPUT_METHOD.SHORTCUT, editorAnalyticsApi))) !== null && _editorAPI$core$actio4 !== void 0 ? _editorAPI$core$actio4 : false;
169
172
  }
170
173
  } else if (event.key === 'Alt') {
171
174
  // event.location is for the current key only; when a user hits Ctrl-Alt-1 the
@@ -11,14 +11,15 @@ var _hooks = require("@atlaskit/editor-common/hooks");
11
11
  var _messages = require("@atlaskit/editor-common/messages");
12
12
  var _toolbar = require("@atlaskit/editor-common/toolbar");
13
13
  var _editorToolbar = require("@atlaskit/editor-toolbar");
14
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
14
15
  var _blockTypes = require("../../block-types");
15
16
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
16
17
  var usePluginState = function usePluginState(api) {
17
- return (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockType'], function (state) {
18
- var _state$blockTypeState, _state$blockTypeState2;
18
+ return (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockType', 'interaction'], function (state) {
19
+ var _state$blockTypeState, _state$interactionSta, _state$blockTypeState2;
19
20
  return {
20
21
  blockTypesDisabled: (_state$blockTypeState = state.blockTypeState) === null || _state$blockTypeState === void 0 ? void 0 : _state$blockTypeState.blockTypesDisabled,
21
- currentBlockType: (_state$blockTypeState2 = state.blockTypeState) === null || _state$blockTypeState2 === void 0 ? void 0 : _state$blockTypeState2.currentBlockType
22
+ currentBlockType: ((_state$interactionSta = state.interactionState) === null || _state$interactionSta === void 0 ? void 0 : _state$interactionSta.interactionState) === 'hasNotHadInteraction' && (0, _expValEquals.expValEquals)('platform_editor_default_toolbar_state', 'isEnabled', true) ? undefined : (_state$blockTypeState2 = state.blockTypeState) === null || _state$blockTypeState2 === void 0 ? void 0 : _state$blockTypeState2.currentBlockType
22
23
  };
23
24
  });
24
25
  };
@@ -1,7 +1,9 @@
1
1
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ import { INSERTED_TRAILING_PARAGRAPH_TO_LAST_NODE_META } from '@atlaskit/editor-common/block-type';
2
3
  import { getBrowserInfo } from '@atlaskit/editor-common/browser';
3
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
5
7
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
8
  import { BLOCK_QUOTE, CODE_BLOCK, HEADING_1, HEADING_2, HEADING_3, HEADING_4, HEADING_5, HEADING_6, HEADINGS_BY_LEVEL, NORMAL_TEXT, OTHER, PANEL, TEXT_BLOCK_TYPES, WRAPPER_BLOCK_TYPES, getBlockTypesInDropdown, SMALL_TEXT } from './block-types';
7
9
  import { setHeadingWithAnalytics, setNormalTextWithAnalytics, setSmallTextWithAnalytics } from './commands/block-type';
@@ -87,7 +89,8 @@ export const createPlugin = (editorAPI, dispatch, lastNodeMustBeParagraph, inclu
87
89
  paragraph
88
90
  } = newState.schema.nodes;
89
91
  if (lastNode && lastNode.isBlock && lastNode.type !== paragraph) {
90
- return newState.tr.insert(newState.doc.content.size, newState.schema.nodes.paragraph.create());
92
+ const tr = newState.tr.insert(newState.doc.content.size, newState.schema.nodes.paragraph.create());
93
+ return fg('platform_editor_block_menu_jira_patch_2') ? tr.setMeta(INSERTED_TRAILING_PARAGRAPH_TO_LAST_NODE_META, true) : tr;
91
94
  }
92
95
  }
93
96
  },
@@ -4,13 +4,14 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
4
4
  import { toolbarMessages } from '@atlaskit/editor-common/messages';
5
5
  import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
6
6
  import { ToolbarDropdownMenu, ToolbarTooltip, TextIcon } from '@atlaskit/editor-toolbar';
7
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
8
  import { toolbarBlockTypesWithRank } from '../../block-types';
8
9
  const usePluginState = api => {
9
- return useSharedPluginStateWithSelector(api, ['blockType'], state => {
10
- var _state$blockTypeState, _state$blockTypeState2;
10
+ return useSharedPluginStateWithSelector(api, ['blockType', 'interaction'], state => {
11
+ var _state$blockTypeState, _state$interactionSta, _state$blockTypeState2;
11
12
  return {
12
13
  blockTypesDisabled: (_state$blockTypeState = state.blockTypeState) === null || _state$blockTypeState === void 0 ? void 0 : _state$blockTypeState.blockTypesDisabled,
13
- currentBlockType: (_state$blockTypeState2 = state.blockTypeState) === null || _state$blockTypeState2 === void 0 ? void 0 : _state$blockTypeState2.currentBlockType
14
+ currentBlockType: ((_state$interactionSta = state.interactionState) === null || _state$interactionSta === void 0 ? void 0 : _state$interactionSta.interactionState) === 'hasNotHadInteraction' && expValEquals('platform_editor_default_toolbar_state', 'isEnabled', true) ? undefined : (_state$blockTypeState2 = state.blockTypeState) === null || _state$blockTypeState2 === void 0 ? void 0 : _state$blockTypeState2.currentBlockType
14
15
  };
15
16
  });
16
17
  };
@@ -2,9 +2,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
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
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
4
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
+ import { INSERTED_TRAILING_PARAGRAPH_TO_LAST_NODE_META } from '@atlaskit/editor-common/block-type';
5
6
  import { getBrowserInfo } from '@atlaskit/editor-common/browser';
6
7
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
8
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
8
10
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
9
11
  import { BLOCK_QUOTE, CODE_BLOCK, HEADING_1, HEADING_2, HEADING_3, HEADING_4, HEADING_5, HEADING_6, HEADINGS_BY_LEVEL, NORMAL_TEXT, OTHER, PANEL, TEXT_BLOCK_TYPES, WRAPPER_BLOCK_TYPES, getBlockTypesInDropdown, SMALL_TEXT } from './block-types';
10
12
  import { setHeadingWithAnalytics, setNormalTextWithAnalytics, setSmallTextWithAnalytics } from './commands/block-type';
@@ -91,7 +93,8 @@ export var createPlugin = function createPlugin(editorAPI, dispatch, lastNodeMus
91
93
  var lastNode = pos.node(1);
92
94
  var paragraph = newState.schema.nodes.paragraph;
93
95
  if (lastNode && lastNode.isBlock && lastNode.type !== paragraph) {
94
- return newState.tr.insert(newState.doc.content.size, newState.schema.nodes.paragraph.create());
96
+ var tr = newState.tr.insert(newState.doc.content.size, newState.schema.nodes.paragraph.create());
97
+ return fg('platform_editor_block_menu_jira_patch_2') ? tr.setMeta(INSERTED_TRAILING_PARAGRAPH_TO_LAST_NODE_META, true) : tr;
95
98
  }
96
99
  }
97
100
  },
@@ -4,13 +4,14 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
4
4
  import { toolbarMessages } from '@atlaskit/editor-common/messages';
5
5
  import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
6
6
  import { ToolbarDropdownMenu, ToolbarTooltip, TextIcon } from '@atlaskit/editor-toolbar';
7
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
8
  import { toolbarBlockTypesWithRank } from '../../block-types';
8
9
  var usePluginState = function usePluginState(api) {
9
- return useSharedPluginStateWithSelector(api, ['blockType'], function (state) {
10
- var _state$blockTypeState, _state$blockTypeState2;
10
+ return useSharedPluginStateWithSelector(api, ['blockType', 'interaction'], function (state) {
11
+ var _state$blockTypeState, _state$interactionSta, _state$blockTypeState2;
11
12
  return {
12
13
  blockTypesDisabled: (_state$blockTypeState = state.blockTypeState) === null || _state$blockTypeState === void 0 ? void 0 : _state$blockTypeState.blockTypesDisabled,
13
- currentBlockType: (_state$blockTypeState2 = state.blockTypeState) === null || _state$blockTypeState2 === void 0 ? void 0 : _state$blockTypeState2.currentBlockType
14
+ currentBlockType: ((_state$interactionSta = state.interactionState) === null || _state$interactionSta === void 0 ? void 0 : _state$interactionSta.interactionState) === 'hasNotHadInteraction' && expValEquals('platform_editor_default_toolbar_state', 'isEnabled', true) ? undefined : (_state$blockTypeState2 = state.blockTypeState) === null || _state$blockTypeState2 === void 0 ? void 0 : _state$blockTypeState2.currentBlockType
14
15
  };
15
16
  });
16
17
  };
@@ -1,6 +1,7 @@
1
1
  import type { Command, EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
4
+ import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
4
5
  import type { ListPlugin } from '@atlaskit/editor-plugin-list';
5
6
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
6
7
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
@@ -28,7 +29,8 @@ export type BlockTypePlugin = NextEditorPlugin<'blockType', {
28
29
  OptionalPlugin<ToolbarPlugin>,
29
30
  OptionalPlugin<BlockMenuPlugin>,
30
31
  OptionalPlugin<ListPlugin>,
31
- OptionalPlugin<SelectionPlugin>
32
+ OptionalPlugin<SelectionPlugin>,
33
+ OptionalPlugin<InteractionPlugin>
32
34
  ];
33
35
  pluginConfiguration: BlockTypePluginOptions | undefined;
34
36
  sharedState: BlockTypeState | undefined;
@@ -1,6 +1,7 @@
1
1
  import type { Command, EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
4
+ import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
4
5
  import type { ListPlugin } from '@atlaskit/editor-plugin-list';
5
6
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
6
7
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
@@ -28,7 +29,8 @@ export type BlockTypePlugin = NextEditorPlugin<'blockType', {
28
29
  OptionalPlugin<ToolbarPlugin>,
29
30
  OptionalPlugin<BlockMenuPlugin>,
30
31
  OptionalPlugin<ListPlugin>,
31
- OptionalPlugin<SelectionPlugin>
32
+ OptionalPlugin<SelectionPlugin>,
33
+ OptionalPlugin<InteractionPlugin>
32
34
  ];
33
35
  pluginConfiguration: BlockTypePluginOptions | undefined;
34
36
  sharedState: BlockTypeState | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-type",
3
- "version": "14.1.3",
3
+ "version": "14.1.5",
4
4
  "description": "BlockType plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,6 +33,7 @@
33
33
  "@atlaskit/css": "^0.19.0",
34
34
  "@atlaskit/editor-plugin-analytics": "^10.1.0",
35
35
  "@atlaskit/editor-plugin-block-menu": "^9.2.0",
36
+ "@atlaskit/editor-plugin-interaction": "^19.1.0",
36
37
  "@atlaskit/editor-plugin-list": "^12.1.0",
37
38
  "@atlaskit/editor-plugin-primary-toolbar": "^11.1.0",
38
39
  "@atlaskit/editor-plugin-selection": "^10.1.0",
@@ -41,7 +42,7 @@
41
42
  "@atlaskit/editor-prosemirror": "^7.3.0",
42
43
  "@atlaskit/editor-shared-styles": "^3.11.0",
43
44
  "@atlaskit/editor-tables": "^2.10.0",
44
- "@atlaskit/editor-toolbar": "^1.6.0",
45
+ "@atlaskit/editor-toolbar": "^1.7.0",
45
46
  "@atlaskit/editor-toolbar-model": "^0.5.0",
46
47
  "@atlaskit/icon": "^35.0.0",
47
48
  "@atlaskit/icon-lab": "^6.9.0",
@@ -49,14 +50,14 @@
49
50
  "@atlaskit/primitives": "^19.0.0",
50
51
  "@atlaskit/prosemirror-history": "^0.2.0",
51
52
  "@atlaskit/prosemirror-input-rules": "^3.7.0",
52
- "@atlaskit/tmp-editor-statsig": "^82.0.0",
53
+ "@atlaskit/tmp-editor-statsig": "^82.4.0",
53
54
  "@atlaskit/tokens": "^13.0.0",
54
55
  "@babel/runtime": "^7.0.0",
55
56
  "@compiled/react": "^0.20.0",
56
57
  "@emotion/react": "^11.7.1"
57
58
  },
58
59
  "peerDependencies": {
59
- "@atlaskit/editor-common": "^114.36.0",
60
+ "@atlaskit/editor-common": "^114.41.0",
60
61
  "react": "^18.2.0",
61
62
  "react-dom": "^18.2.0",
62
63
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -64,6 +65,8 @@
64
65
  "devDependencies": {
65
66
  "@testing-library/react": "^16.3.0",
66
67
  "@testing-library/user-event": "^14.4.3",
68
+ "react": "^18.2.0",
69
+ "react-dom": "^18.2.0",
67
70
  "react-intl": "^6.6.2",
68
71
  "wait-for-expect": "^1.2.0"
69
72
  },
@@ -104,6 +107,9 @@
104
107
  }
105
108
  },
106
109
  "platform-feature-flags": {
110
+ "platform_editor_block_menu_jira_patch_2": {
111
+ "type": "boolean"
112
+ },
107
113
  "platform_editor_change_normal_text_icon": {
108
114
  "type": "boolean"
109
115
  },