@atlaskit/editor-plugin-block-menu 5.0.24 → 5.1.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,12 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 5.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`bd911d5eca1cb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bd911d5eca1cb) -
8
+ Use new transfromNode command in existing block menu items. Update transformNode analytics type.
9
+
3
10
  ## 5.0.24
4
11
 
5
12
  ### Patch Changes
@@ -6,25 +6,30 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.transformNode = void 0;
7
7
  var _utils = require("../editor-commands/transform-node-utils/utils");
8
8
  var _transform = require("./transform-node-utils/transform");
9
- var transformNode = exports.transformNode = function transformNode(api) {
10
- return function (targetType, analyticsAttrs) {
11
- return function (_ref) {
12
- var tr = _ref.tr;
13
- var selection = tr.selection;
14
- var source = (0, _utils.getSelectedNode)(selection);
15
- if (!source) {
9
+ var transformNode = exports.transformNode =
10
+ // eslint-disable-next-line no-unused-vars
11
+ function transformNode(api) {
12
+ return (
13
+ // eslint-disable-next-line no-unused-vars
14
+ function (targetType, analyticsAttrs) {
15
+ return function (_ref) {
16
+ var tr = _ref.tr;
17
+ var selection = tr.selection;
18
+ var source = (0, _utils.getSelectedNode)(selection);
19
+ if (!source) {
20
+ return tr;
21
+ }
22
+ var outputNodes = (0, _transform.getOutputNodes)({
23
+ sourceNode: source.node,
24
+ targetNodeType: targetType,
25
+ schema: selection.$from.doc.type.schema
26
+ });
27
+ if (!outputNodes) {
28
+ return tr;
29
+ }
30
+ tr.replaceWith(source.pos, source.pos + source.node.nodeSize, outputNodes);
16
31
  return tr;
17
- }
18
- var outputNodes = (0, _transform.getOutputNodes)({
19
- sourceNode: source.node,
20
- targetNodeType: targetType,
21
- schema: selection.$from.doc.type.schema
22
- });
23
- if (!outputNodes) {
24
- return tr;
25
- }
26
- tr.replaceWith(source.pos, source.pos + source.node.nodeSize, outputNodes);
27
- return tr;
28
- };
29
- };
32
+ };
33
+ }
34
+ );
30
35
  };
@@ -1,6 +1,10 @@
1
1
  import { getSelectedNode } from '../editor-commands/transform-node-utils/utils';
2
2
  import { getOutputNodes } from './transform-node-utils/transform';
3
- export const transformNode = api => (targetType, analyticsAttrs) => {
3
+ export const transformNode =
4
+ // eslint-disable-next-line no-unused-vars
5
+ api =>
6
+ // eslint-disable-next-line no-unused-vars
7
+ (targetType, analyticsAttrs) => {
4
8
  return ({
5
9
  tr
6
10
  }) => {
@@ -1,24 +1,29 @@
1
1
  import { getSelectedNode } from '../editor-commands/transform-node-utils/utils';
2
2
  import { getOutputNodes } from './transform-node-utils/transform';
3
- export var transformNode = function transformNode(api) {
4
- return function (targetType, analyticsAttrs) {
5
- return function (_ref) {
6
- var tr = _ref.tr;
7
- var selection = tr.selection;
8
- var source = getSelectedNode(selection);
9
- if (!source) {
3
+ export var transformNode =
4
+ // eslint-disable-next-line no-unused-vars
5
+ function transformNode(api) {
6
+ return (
7
+ // eslint-disable-next-line no-unused-vars
8
+ function (targetType, analyticsAttrs) {
9
+ return function (_ref) {
10
+ var tr = _ref.tr;
11
+ var selection = tr.selection;
12
+ var source = getSelectedNode(selection);
13
+ if (!source) {
14
+ return tr;
15
+ }
16
+ var outputNodes = getOutputNodes({
17
+ sourceNode: source.node,
18
+ targetNodeType: targetType,
19
+ schema: selection.$from.doc.type.schema
20
+ });
21
+ if (!outputNodes) {
22
+ return tr;
23
+ }
24
+ tr.replaceWith(source.pos, source.pos + source.node.nodeSize, outputNodes);
10
25
  return tr;
11
- }
12
- var outputNodes = getOutputNodes({
13
- sourceNode: source.node,
14
- targetNodeType: targetType,
15
- schema: selection.$from.doc.type.schema
16
- });
17
- if (!outputNodes) {
18
- return tr;
19
- }
20
- tr.replaceWith(source.pos, source.pos + source.node.nodeSize, outputNodes);
21
- return tr;
22
- };
23
- };
26
+ };
27
+ }
28
+ );
24
29
  };
@@ -5,12 +5,12 @@ import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
5
5
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
6
6
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
7
7
  import type { NodeType } from '@atlaskit/editor-prosemirror/model';
8
- import type { FormatNodeTargetType, FormatNodeAnalyticsAttrs } from './editor-commands/transforms/types';
8
+ import type { FormatNodeAnalyticsAttrs, FormatNodeTargetType, TransformNodeAnalyticsAttrs } from './editor-commands/transforms/types';
9
9
  export declare enum FLAG_ID {
10
10
  LINK_COPIED_TO_CLIPBOARD = "link-copied-to-clipboard"
11
11
  }
12
12
  type FormatNodeCommand = (targetType: FormatNodeTargetType, analyticsAttrs?: FormatNodeAnalyticsAttrs) => EditorCommand;
13
- type TransformNodeCommand = (targetType: NodeType, analyticsAttrs?: FormatNodeAnalyticsAttrs) => EditorCommand;
13
+ type TransformNodeCommand = (targetType: NodeType, analyticsAttrs?: TransformNodeAnalyticsAttrs) => EditorCommand;
14
14
  export type BlockMenuPlugin = NextEditorPlugin<'blockMenu', {
15
15
  actions: {
16
16
  getBlockMenuComponents: () => Array<RegisterBlockMenuComponent>;
@@ -1,5 +1,5 @@
1
1
  import type { EditorCommand, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
2
  import type { NodeType } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { BlockMenuPlugin } from '../blockMenuPluginType';
4
- import type { FormatNodeAnalyticsAttrs } from './transforms/types';
5
- export declare const transformNode: (api?: ExtractInjectionAPI<BlockMenuPlugin>) => (targetType: NodeType, analyticsAttrs?: FormatNodeAnalyticsAttrs) => EditorCommand;
4
+ import type { TransformNodeAnalyticsAttrs } from './transforms/types';
5
+ export declare const transformNode: (api?: ExtractInjectionAPI<BlockMenuPlugin>) => (targetType: NodeType, analyticsAttrs?: TransformNodeAnalyticsAttrs) => EditorCommand;
@@ -2,8 +2,12 @@ import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import type { TransformContext } from '@atlaskit/editor-common/transforms';
3
3
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  export type FormatNodeTargetType = 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'blockquote' | 'expand' | 'layoutSection' | 'panel' | 'codeBlock' | 'bulletList' | 'orderedList' | 'taskList';
5
+ export type TransfromNodeTargetType = FormatNodeTargetType;
5
6
  export type FormatNodeAnalyticsAttrs = {
6
7
  inputMethod: INPUT_METHOD.BLOCK_MENU;
7
8
  triggeredFrom: INPUT_METHOD.MOUSE | INPUT_METHOD.KEYBOARD;
8
9
  };
10
+ export type TransformNodeAnalyticsAttrs = FormatNodeAnalyticsAttrs & {
11
+ targetTypeName: TransfromNodeTargetType;
12
+ };
9
13
  export type TransformFunction = (context: TransformContext) => Transaction | null;
@@ -5,12 +5,12 @@ import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
5
5
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
6
6
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
7
7
  import type { NodeType } from '@atlaskit/editor-prosemirror/model';
8
- import type { FormatNodeTargetType, FormatNodeAnalyticsAttrs } from './editor-commands/transforms/types';
8
+ import type { FormatNodeAnalyticsAttrs, FormatNodeTargetType, TransformNodeAnalyticsAttrs } from './editor-commands/transforms/types';
9
9
  export declare enum FLAG_ID {
10
10
  LINK_COPIED_TO_CLIPBOARD = "link-copied-to-clipboard"
11
11
  }
12
12
  type FormatNodeCommand = (targetType: FormatNodeTargetType, analyticsAttrs?: FormatNodeAnalyticsAttrs) => EditorCommand;
13
- type TransformNodeCommand = (targetType: NodeType, analyticsAttrs?: FormatNodeAnalyticsAttrs) => EditorCommand;
13
+ type TransformNodeCommand = (targetType: NodeType, analyticsAttrs?: TransformNodeAnalyticsAttrs) => EditorCommand;
14
14
  export type BlockMenuPlugin = NextEditorPlugin<'blockMenu', {
15
15
  actions: {
16
16
  getBlockMenuComponents: () => Array<RegisterBlockMenuComponent>;
@@ -1,5 +1,5 @@
1
1
  import type { EditorCommand, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
2
  import type { NodeType } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { BlockMenuPlugin } from '../blockMenuPluginType';
4
- import type { FormatNodeAnalyticsAttrs } from './transforms/types';
5
- export declare const transformNode: (api?: ExtractInjectionAPI<BlockMenuPlugin>) => (targetType: NodeType, analyticsAttrs?: FormatNodeAnalyticsAttrs) => EditorCommand;
4
+ import type { TransformNodeAnalyticsAttrs } from './transforms/types';
5
+ export declare const transformNode: (api?: ExtractInjectionAPI<BlockMenuPlugin>) => (targetType: NodeType, analyticsAttrs?: TransformNodeAnalyticsAttrs) => EditorCommand;
@@ -2,8 +2,12 @@ import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import type { TransformContext } from '@atlaskit/editor-common/transforms';
3
3
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  export type FormatNodeTargetType = 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'blockquote' | 'expand' | 'layoutSection' | 'panel' | 'codeBlock' | 'bulletList' | 'orderedList' | 'taskList';
5
+ export type TransfromNodeTargetType = FormatNodeTargetType;
5
6
  export type FormatNodeAnalyticsAttrs = {
6
7
  inputMethod: INPUT_METHOD.BLOCK_MENU;
7
8
  triggeredFrom: INPUT_METHOD.MOUSE | INPUT_METHOD.KEYBOARD;
8
9
  };
10
+ export type TransformNodeAnalyticsAttrs = FormatNodeAnalyticsAttrs & {
11
+ targetTypeName: TransfromNodeTargetType;
12
+ };
9
13
  export type TransformFunction = (context: TransformContext) => Transaction | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "5.0.24",
3
+ "version": "5.1.0",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  "@atlaskit/css": "^0.17.0",
32
32
  "@atlaskit/dropdown-menu": "^16.3.0",
33
33
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
34
- "@atlaskit/editor-plugin-block-controls": "^7.10.0",
34
+ "@atlaskit/editor-plugin-block-controls": "^7.11.0",
35
35
  "@atlaskit/editor-plugin-decorations": "^6.1.0",
36
36
  "@atlaskit/editor-plugin-selection": "^6.1.0",
37
37
  "@atlaskit/editor-plugin-user-intent": "^4.0.0",
@@ -44,7 +44,7 @@
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
46
46
  "@atlaskit/primitives": "^16.4.0",
47
- "@atlaskit/tmp-editor-statsig": "^14.1.0",
47
+ "@atlaskit/tmp-editor-statsig": "^14.2.0",
48
48
  "@atlaskit/tokens": "^8.4.0",
49
49
  "@babel/runtime": "^7.0.0"
50
50
  },