@atlaskit/editor-plugin-paste-options-toolbar 14.0.4 → 15.0.0

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-paste-options-toolbar
2
2
 
3
+ ## 15.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 14.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`c78198dd074dd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c78198dd074dd) -
14
+ EDITOR-8420: show the paste options menu when a markdown list is pasted at the top level, behind
15
+ the platform_editor_markdown_conversion_improvements experiment
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 14.0.4
4
22
 
5
23
  ### Patch Changes
@@ -8,10 +8,28 @@ exports.isToolbarVisible = exports.getToolbarMenuConfig = exports.buildToolbar =
8
8
  var _messages = require("@atlaskit/editor-common/messages");
9
9
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
10
10
  var _clipboard = _interopRequireDefault(require("@atlaskit/icon/core/clipboard"));
11
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
11
12
  var _commands = require("../editor-commands/commands");
12
13
  var _constants = require("../pm-plugins/constants");
13
14
  var _util = require("../pm-plugins/util");
14
15
  var _types = require("../types/types");
16
+ var TOP_LEVEL_LIST_NODE_NAMES = ['bulletList', 'orderedList', 'taskList'];
17
+
18
+ /**
19
+ * Pasting markdown lists leaves the cursor at doc > list > listItem > paragraph, so the
20
+ * immediate grandparent is a listItem rather than the doc and the paste options are never
21
+ * offered. Treat a list that is itself a direct child of the doc as top level, while still
22
+ * excluding lists nested in other containers such as tables and panels.
23
+ */
24
+ var isInsideTopLevelList = function isInsideTopLevelList($from) {
25
+ if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_markdown_conversion_improvements')) {
26
+ return false;
27
+ }
28
+ if ($from.depth < 1) {
29
+ return false;
30
+ }
31
+ return TOP_LEVEL_LIST_NODE_NAMES.includes($from.node(1).type.name);
32
+ };
15
33
  var isToolbarVisible = exports.isToolbarVisible = function isToolbarVisible(state, lastContentPasted) {
16
34
  var _$from$parent, _$from$node, _state$schema$nodes$c;
17
35
  /**
@@ -27,7 +45,7 @@ var isToolbarVisible = exports.isToolbarVisible = function isToolbarVisible(stat
27
45
  }
28
46
  var parentNodeType = (_$from$parent = $from.parent) === null || _$from$parent === void 0 ? void 0 : _$from$parent.type;
29
47
  var grandParentNodeType = (_$from$node = $from.node($from.depth - 1)) === null || _$from$node === void 0 ? void 0 : _$from$node.type;
30
- if (grandParentNodeType && grandParentNodeType.name === state.schema.nodes.doc.name && parentNodeType.name !== ((_state$schema$nodes$c = state.schema.nodes.codeBlock) === null || _state$schema$nodes$c === void 0 ? void 0 : _state$schema$nodes$c.name) && !(0, _util.isPastedFromFabricEditor)(lastContentPasted.pasteSource) && !(0, _util.hasLinkMark)(lastContentPasted.pastedSlice) && !(0, _util.hasMediaNode)(lastContentPasted.pastedSlice)) {
48
+ if (((grandParentNodeType === null || grandParentNodeType === void 0 ? void 0 : grandParentNodeType.name) === state.schema.nodes.doc.name || isInsideTopLevelList($from)) && parentNodeType.name !== ((_state$schema$nodes$c = state.schema.nodes.codeBlock) === null || _state$schema$nodes$c === void 0 ? void 0 : _state$schema$nodes$c.name) && !(0, _util.isPastedFromFabricEditor)(lastContentPasted.pasteSource) && !(0, _util.hasLinkMark)(lastContentPasted.pastedSlice) && !(0, _util.hasMediaNode)(lastContentPasted.pastedSlice)) {
31
49
  return true;
32
50
  }
33
51
  return false;
@@ -1,10 +1,28 @@
1
1
  import { pasteOptionsToolbarMessages as messages } from '@atlaskit/editor-common/messages';
2
2
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
3
3
  import ClipboardIcon from '@atlaskit/icon/core/clipboard';
4
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
4
5
  import { changeToMarkdownWithAnalytics, changeToPlainTextWithAnalytics, changeToRichTextWithAnalytics, dropdownClickHandler } from '../editor-commands/commands';
5
6
  import { PASTE_OPTIONS_TEST_ID, PASTE_TOOLBAR_CLASS, PASTE_TOOLBAR_ITEM_CLASS } from '../pm-plugins/constants';
6
7
  import { hasLinkMark, hasMediaNode, hasRuleNode, isPastedFromFabricEditor } from '../pm-plugins/util';
7
8
  import { pasteOptionsPluginKey, ToolbarDropdownOption } from '../types/types';
9
+ const TOP_LEVEL_LIST_NODE_NAMES = ['bulletList', 'orderedList', 'taskList'];
10
+
11
+ /**
12
+ * Pasting markdown lists leaves the cursor at doc > list > listItem > paragraph, so the
13
+ * immediate grandparent is a listItem rather than the doc and the paste options are never
14
+ * offered. Treat a list that is itself a direct child of the doc as top level, while still
15
+ * excluding lists nested in other containers such as tables and panels.
16
+ */
17
+ const isInsideTopLevelList = $from => {
18
+ if (!isExperimentEnabled('platform_editor_markdown_conversion_improvements')) {
19
+ return false;
20
+ }
21
+ if ($from.depth < 1) {
22
+ return false;
23
+ }
24
+ return TOP_LEVEL_LIST_NODE_NAMES.includes($from.node(1).type.name);
25
+ };
8
26
  export const isToolbarVisible = (state, lastContentPasted) => {
9
27
  var _$from$parent, _$from$node, _state$schema$nodes$c;
10
28
  /**
@@ -20,7 +38,7 @@ export const isToolbarVisible = (state, lastContentPasted) => {
20
38
  }
21
39
  const parentNodeType = (_$from$parent = $from.parent) === null || _$from$parent === void 0 ? void 0 : _$from$parent.type;
22
40
  const grandParentNodeType = (_$from$node = $from.node($from.depth - 1)) === null || _$from$node === void 0 ? void 0 : _$from$node.type;
23
- if (grandParentNodeType && grandParentNodeType.name === state.schema.nodes.doc.name && parentNodeType.name !== ((_state$schema$nodes$c = state.schema.nodes.codeBlock) === null || _state$schema$nodes$c === void 0 ? void 0 : _state$schema$nodes$c.name) && !isPastedFromFabricEditor(lastContentPasted.pasteSource) && !hasLinkMark(lastContentPasted.pastedSlice) && !hasMediaNode(lastContentPasted.pastedSlice)) {
41
+ if (((grandParentNodeType === null || grandParentNodeType === void 0 ? void 0 : grandParentNodeType.name) === state.schema.nodes.doc.name || isInsideTopLevelList($from)) && parentNodeType.name !== ((_state$schema$nodes$c = state.schema.nodes.codeBlock) === null || _state$schema$nodes$c === void 0 ? void 0 : _state$schema$nodes$c.name) && !isPastedFromFabricEditor(lastContentPasted.pasteSource) && !hasLinkMark(lastContentPasted.pastedSlice) && !hasMediaNode(lastContentPasted.pastedSlice)) {
24
42
  return true;
25
43
  }
26
44
  return false;
@@ -1,10 +1,28 @@
1
1
  import { pasteOptionsToolbarMessages as messages } from '@atlaskit/editor-common/messages';
2
2
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
3
3
  import ClipboardIcon from '@atlaskit/icon/core/clipboard';
4
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
4
5
  import { changeToMarkdownWithAnalytics, changeToPlainTextWithAnalytics, changeToRichTextWithAnalytics, dropdownClickHandler } from '../editor-commands/commands';
5
6
  import { PASTE_OPTIONS_TEST_ID, PASTE_TOOLBAR_CLASS, PASTE_TOOLBAR_ITEM_CLASS } from '../pm-plugins/constants';
6
7
  import { hasLinkMark, hasMediaNode, hasRuleNode, isPastedFromFabricEditor } from '../pm-plugins/util';
7
8
  import { pasteOptionsPluginKey, ToolbarDropdownOption } from '../types/types';
9
+ var TOP_LEVEL_LIST_NODE_NAMES = ['bulletList', 'orderedList', 'taskList'];
10
+
11
+ /**
12
+ * Pasting markdown lists leaves the cursor at doc > list > listItem > paragraph, so the
13
+ * immediate grandparent is a listItem rather than the doc and the paste options are never
14
+ * offered. Treat a list that is itself a direct child of the doc as top level, while still
15
+ * excluding lists nested in other containers such as tables and panels.
16
+ */
17
+ var isInsideTopLevelList = function isInsideTopLevelList($from) {
18
+ if (!isExperimentEnabled('platform_editor_markdown_conversion_improvements')) {
19
+ return false;
20
+ }
21
+ if ($from.depth < 1) {
22
+ return false;
23
+ }
24
+ return TOP_LEVEL_LIST_NODE_NAMES.includes($from.node(1).type.name);
25
+ };
8
26
  export var isToolbarVisible = function isToolbarVisible(state, lastContentPasted) {
9
27
  var _$from$parent, _$from$node, _state$schema$nodes$c;
10
28
  /**
@@ -20,7 +38,7 @@ export var isToolbarVisible = function isToolbarVisible(state, lastContentPasted
20
38
  }
21
39
  var parentNodeType = (_$from$parent = $from.parent) === null || _$from$parent === void 0 ? void 0 : _$from$parent.type;
22
40
  var grandParentNodeType = (_$from$node = $from.node($from.depth - 1)) === null || _$from$node === void 0 ? void 0 : _$from$node.type;
23
- if (grandParentNodeType && grandParentNodeType.name === state.schema.nodes.doc.name && parentNodeType.name !== ((_state$schema$nodes$c = state.schema.nodes.codeBlock) === null || _state$schema$nodes$c === void 0 ? void 0 : _state$schema$nodes$c.name) && !isPastedFromFabricEditor(lastContentPasted.pasteSource) && !hasLinkMark(lastContentPasted.pastedSlice) && !hasMediaNode(lastContentPasted.pastedSlice)) {
41
+ if (((grandParentNodeType === null || grandParentNodeType === void 0 ? void 0 : grandParentNodeType.name) === state.schema.nodes.doc.name || isInsideTopLevelList($from)) && parentNodeType.name !== ((_state$schema$nodes$c = state.schema.nodes.codeBlock) === null || _state$schema$nodes$c === void 0 ? void 0 : _state$schema$nodes$c.name) && !isPastedFromFabricEditor(lastContentPasted.pasteSource) && !hasLinkMark(lastContentPasted.pastedSlice) && !hasMediaNode(lastContentPasted.pastedSlice)) {
24
42
  return true;
25
43
  }
26
44
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste-options-toolbar",
3
- "version": "14.0.4",
3
+ "version": "15.0.0",
4
4
  "description": "Paste options toolbar for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -24,14 +24,15 @@
24
24
  "@atlaskit/css": "^1.0.0",
25
25
  "@atlaskit/dropdown-menu": "^18.0.0",
26
26
  "@atlaskit/editor-markdown-transformer": "^6.1.0",
27
- "@atlaskit/editor-plugin-analytics": "^13.0.0",
28
- "@atlaskit/editor-plugin-paste": "^14.0.0",
29
- "@atlaskit/editor-plugin-ui-control-registry": "^7.0.0",
27
+ "@atlaskit/editor-plugin-analytics": "^14.0.0",
28
+ "@atlaskit/editor-plugin-paste": "^15.0.0",
29
+ "@atlaskit/editor-plugin-ui-control-registry": "^8.0.0",
30
30
  "@atlaskit/editor-prosemirror": "^8.0.0",
31
31
  "@atlaskit/editor-shared-styles": "^4.0.0",
32
32
  "@atlaskit/editor-toolbar": "^2.4.0",
33
33
  "@atlaskit/editor-ui-control-model": "^2.4.0",
34
34
  "@atlaskit/icon": "^37.3.0",
35
+ "@atlaskit/platform-feature-experiments": "^0.3.0",
35
36
  "@atlaskit/platform-feature-flags": "^2.1.0",
36
37
  "@atlaskit/primitives": "^22.2.0",
37
38
  "@atlaskit/tmp-editor-statsig": "^142.0.0",
@@ -41,7 +42,7 @@
41
42
  "@emotion/react": "^11.7.1"
42
43
  },
43
44
  "peerDependencies": {
44
- "@atlaskit/editor-common": "^117.4.0",
45
+ "@atlaskit/editor-common": "^118.0.0",
45
46
  "react": "^18.2.0 || ^19.2.0",
46
47
  "react-dom": "^18.2.0 || ^19.2.0",
47
48
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"