@atlaskit/editor-plugin-block-type 1.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.
Files changed (120) hide show
  1. package/.eslintrc.js +14 -0
  2. package/CHANGELOG.md +1 -0
  3. package/LICENSE.md +13 -0
  4. package/README.md +32 -0
  5. package/consts/package.json +15 -0
  6. package/dist/cjs/consts.js +66 -0
  7. package/dist/cjs/index.js +12 -0
  8. package/dist/cjs/messages.js +19 -0
  9. package/dist/cjs/plugin/block-types.js +106 -0
  10. package/dist/cjs/plugin/commands/block-type.js +183 -0
  11. package/dist/cjs/plugin/commands/delete-and-move-cursor.js +56 -0
  12. package/dist/cjs/plugin/commands/delete-block-content.js +45 -0
  13. package/dist/cjs/plugin/commands/index.js +69 -0
  14. package/dist/cjs/plugin/consts.js +15 -0
  15. package/dist/cjs/plugin/index.js +217 -0
  16. package/dist/cjs/plugin/messages.js +160 -0
  17. package/dist/cjs/plugin/pm-plugins/input-rule.js +104 -0
  18. package/dist/cjs/plugin/pm-plugins/keymap.js +34 -0
  19. package/dist/cjs/plugin/pm-plugins/main.js +151 -0
  20. package/dist/cjs/plugin/styles.js +15 -0
  21. package/dist/cjs/plugin/types.js +5 -0
  22. package/dist/cjs/plugin/ui/ToolbarBlockType/blocktype-button.js +60 -0
  23. package/dist/cjs/plugin/ui/ToolbarBlockType/index.js +208 -0
  24. package/dist/cjs/plugin/ui/ToolbarBlockType/styled.js +34 -0
  25. package/dist/cjs/plugin/ui/ToolbarBlockType/toolbar-messages.js +15 -0
  26. package/dist/cjs/plugin/utils.js +87 -0
  27. package/dist/cjs/styles.js +12 -0
  28. package/dist/es2019/consts.js +1 -0
  29. package/dist/es2019/index.js +1 -0
  30. package/dist/es2019/messages.js +2 -0
  31. package/dist/es2019/plugin/block-types.js +84 -0
  32. package/dist/es2019/plugin/commands/block-type.js +170 -0
  33. package/dist/es2019/plugin/commands/delete-and-move-cursor.js +55 -0
  34. package/dist/es2019/plugin/commands/delete-block-content.js +42 -0
  35. package/dist/es2019/plugin/commands/index.js +8 -0
  36. package/dist/es2019/plugin/consts.js +8 -0
  37. package/dist/es2019/plugin/index.js +204 -0
  38. package/dist/es2019/plugin/messages.js +153 -0
  39. package/dist/es2019/plugin/pm-plugins/input-rule.js +93 -0
  40. package/dist/es2019/plugin/pm-plugins/keymap.js +25 -0
  41. package/dist/es2019/plugin/pm-plugins/main.js +137 -0
  42. package/dist/es2019/plugin/styles.js +8 -0
  43. package/dist/es2019/plugin/types.js +1 -0
  44. package/dist/es2019/plugin/ui/ToolbarBlockType/blocktype-button.js +50 -0
  45. package/dist/es2019/plugin/ui/ToolbarBlockType/index.js +185 -0
  46. package/dist/es2019/plugin/ui/ToolbarBlockType/styled.js +49 -0
  47. package/dist/es2019/plugin/ui/ToolbarBlockType/toolbar-messages.js +8 -0
  48. package/dist/es2019/plugin/utils.js +76 -0
  49. package/dist/es2019/styles.js +1 -0
  50. package/dist/esm/consts.js +1 -0
  51. package/dist/esm/index.js +1 -0
  52. package/dist/esm/messages.js +2 -0
  53. package/dist/esm/plugin/block-types.js +84 -0
  54. package/dist/esm/plugin/commands/block-type.js +169 -0
  55. package/dist/esm/plugin/commands/delete-and-move-cursor.js +50 -0
  56. package/dist/esm/plugin/commands/delete-block-content.js +39 -0
  57. package/dist/esm/plugin/commands/index.js +8 -0
  58. package/dist/esm/plugin/consts.js +8 -0
  59. package/dist/esm/plugin/index.js +205 -0
  60. package/dist/esm/plugin/messages.js +153 -0
  61. package/dist/esm/plugin/pm-plugins/input-rule.js +96 -0
  62. package/dist/esm/plugin/pm-plugins/keymap.js +25 -0
  63. package/dist/esm/plugin/pm-plugins/main.js +142 -0
  64. package/dist/esm/plugin/styles.js +7 -0
  65. package/dist/esm/plugin/types.js +1 -0
  66. package/dist/esm/plugin/ui/ToolbarBlockType/blocktype-button.js +50 -0
  67. package/dist/esm/plugin/ui/ToolbarBlockType/index.js +201 -0
  68. package/dist/esm/plugin/ui/ToolbarBlockType/styled.js +20 -0
  69. package/dist/esm/plugin/ui/ToolbarBlockType/toolbar-messages.js +8 -0
  70. package/dist/esm/plugin/utils.js +77 -0
  71. package/dist/esm/styles.js +1 -0
  72. package/dist/types/consts.d.ts +1 -0
  73. package/dist/types/index.d.ts +6 -0
  74. package/dist/types/messages.d.ts +2 -0
  75. package/dist/types/plugin/block-types.d.ts +19 -0
  76. package/dist/types/plugin/commands/block-type.d.ts +18 -0
  77. package/dist/types/plugin/commands/delete-and-move-cursor.d.ts +12 -0
  78. package/dist/types/plugin/commands/delete-block-content.d.ts +10 -0
  79. package/dist/types/plugin/commands/index.d.ts +9 -0
  80. package/dist/types/plugin/consts.d.ts +1 -0
  81. package/dist/types/plugin/index.d.ts +18 -0
  82. package/dist/types/plugin/messages.d.ts +152 -0
  83. package/dist/types/plugin/pm-plugins/input-rule.d.ts +6 -0
  84. package/dist/types/plugin/pm-plugins/keymap.d.ts +5 -0
  85. package/dist/types/plugin/pm-plugins/main.d.ts +17 -0
  86. package/dist/types/plugin/styles.d.ts +2 -0
  87. package/dist/types/plugin/types.d.ts +22 -0
  88. package/dist/types/plugin/ui/ToolbarBlockType/blocktype-button.d.ts +22 -0
  89. package/dist/types/plugin/ui/ToolbarBlockType/index.d.ts +29 -0
  90. package/dist/types/plugin/ui/ToolbarBlockType/styled.d.ts +8 -0
  91. package/dist/types/plugin/ui/ToolbarBlockType/toolbar-messages.d.ts +7 -0
  92. package/dist/types/plugin/utils.d.ts +16 -0
  93. package/dist/types/styles.d.ts +1 -0
  94. package/dist/types-ts4.5/consts.d.ts +1 -0
  95. package/dist/types-ts4.5/index.d.ts +6 -0
  96. package/dist/types-ts4.5/messages.d.ts +2 -0
  97. package/dist/types-ts4.5/plugin/block-types.d.ts +19 -0
  98. package/dist/types-ts4.5/plugin/commands/block-type.d.ts +18 -0
  99. package/dist/types-ts4.5/plugin/commands/delete-and-move-cursor.d.ts +12 -0
  100. package/dist/types-ts4.5/plugin/commands/delete-block-content.d.ts +10 -0
  101. package/dist/types-ts4.5/plugin/commands/index.d.ts +9 -0
  102. package/dist/types-ts4.5/plugin/consts.d.ts +1 -0
  103. package/dist/types-ts4.5/plugin/index.d.ts +20 -0
  104. package/dist/types-ts4.5/plugin/messages.d.ts +152 -0
  105. package/dist/types-ts4.5/plugin/pm-plugins/input-rule.d.ts +6 -0
  106. package/dist/types-ts4.5/plugin/pm-plugins/keymap.d.ts +5 -0
  107. package/dist/types-ts4.5/plugin/pm-plugins/main.d.ts +17 -0
  108. package/dist/types-ts4.5/plugin/styles.d.ts +2 -0
  109. package/dist/types-ts4.5/plugin/types.d.ts +22 -0
  110. package/dist/types-ts4.5/plugin/ui/ToolbarBlockType/blocktype-button.d.ts +22 -0
  111. package/dist/types-ts4.5/plugin/ui/ToolbarBlockType/index.d.ts +29 -0
  112. package/dist/types-ts4.5/plugin/ui/ToolbarBlockType/styled.d.ts +8 -0
  113. package/dist/types-ts4.5/plugin/ui/ToolbarBlockType/toolbar-messages.d.ts +7 -0
  114. package/dist/types-ts4.5/plugin/utils.d.ts +16 -0
  115. package/dist/types-ts4.5/styles.d.ts +1 -0
  116. package/messages/package.json +15 -0
  117. package/package.json +105 -0
  118. package/report.api.md +108 -0
  119. package/styles/package.json +15 -0
  120. package/tmp/api-report-tmp.d.ts +75 -0
@@ -0,0 +1,29 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import type { WrappedComponentProps } from 'react-intl-next';
4
+ import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { BlockTypeState } from '../../pm-plugins/main';
7
+ import type { BlockType } from '../../types';
8
+ export type DropdownItem = MenuItem & {
9
+ value: BlockType;
10
+ };
11
+ export interface Props {
12
+ isDisabled?: boolean;
13
+ isSmall?: boolean;
14
+ isReducedSpacing?: boolean;
15
+ pluginState: BlockTypeState;
16
+ popupsMountPoint?: HTMLElement;
17
+ popupsBoundariesElement?: HTMLElement;
18
+ popupsScrollableElement?: HTMLElement;
19
+ editorView?: EditorView;
20
+ setBlockType: (type: string) => void;
21
+ }
22
+ export interface State {
23
+ active: boolean;
24
+ isOpenedByKeyboard: boolean;
25
+ }
26
+ declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
27
+ WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
28
+ };
29
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import type { ThemeProps } from '@atlaskit/theme/types';
2
+ export declare const blockTypeMenuItemStyle: (tagName: string, selected?: boolean) => (themeProps: ThemeProps) => import("@emotion/react").SerializedStyles;
3
+ export declare const keyboardShortcut: import("@emotion/react").SerializedStyles;
4
+ export declare const keyboardShortcutSelect: import("@emotion/react").SerializedStyles;
5
+ export declare const buttonContentStyle: import("@emotion/react").SerializedStyles;
6
+ export declare const buttonContentReducedSpacingStyle: import("@emotion/react").SerializedStyles;
7
+ export declare const wrapperSmallStyle: import("@emotion/react").SerializedStyles;
8
+ export declare const expandIconWrapperStyle: import("@emotion/react").SerializedStyles;
@@ -0,0 +1,7 @@
1
+ export declare const toolbarMessages: {
2
+ textStyles: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ };
@@ -0,0 +1,16 @@
1
+ import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
3
+ import type { InputRuleWrapper } from '@atlaskit/prosemirror-input-rules';
4
+ export declare const isNodeAWrappingBlockNode: (node?: PMNode | null) => boolean;
5
+ export declare const createJoinNodesRule: (match: RegExp, nodeType: NodeType) => InputRuleWrapper;
6
+ type WrappingTextRuleProps = {
7
+ match: RegExp;
8
+ nodeType: NodeType;
9
+ getAttrs?: Record<string, any> | ((matchResult: RegExpExecArray) => Record<string, any>);
10
+ };
11
+ export declare const createWrappingTextBlockRule: ({ match, nodeType, getAttrs, }: WrappingTextRuleProps) => InputRuleWrapper;
12
+ /**
13
+ * Function will check if changing block types: Paragraph, Heading is enabled.
14
+ */
15
+ export declare function areBlockTypesDisabled(state: EditorState): boolean;
16
+ export {};
@@ -0,0 +1 @@
1
+ export { blocktypeStyles } from './plugin/styles';
@@ -0,0 +1 @@
1
+ export { BLOCK_QUOTE, CODE_BLOCK, HEADING_1, HEADING_2, HEADING_3, HEADING_4, HEADING_5, HEADING_6, NORMAL_TEXT, PANEL, } from './plugin/block-types';
@@ -0,0 +1,6 @@
1
+ export { blockTypePlugin } from './plugin';
2
+ export type { BlockTypePlugin } from './plugin';
3
+ export type { BlockTypePluginOptions, BlockType } from './plugin/types';
4
+ export type { BlockTypeState } from './plugin/pm-plugins/main';
5
+ export type { InputMethod } from './plugin/commands';
6
+ export type { DropdownItem } from './plugin/ui/ToolbarBlockType';
@@ -0,0 +1,2 @@
1
+ export { messages } from './plugin/messages';
2
+ export { toolbarMessages } from './plugin/ui/ToolbarBlockType/toolbar-messages';
@@ -0,0 +1,19 @@
1
+ import type { BlockType } from './types';
2
+ export declare const NORMAL_TEXT: BlockType;
3
+ export declare const HEADING_1: BlockType;
4
+ export declare const HEADING_2: BlockType;
5
+ export declare const HEADING_3: BlockType;
6
+ export declare const HEADING_4: BlockType;
7
+ export declare const HEADING_5: BlockType;
8
+ export declare const HEADING_6: BlockType;
9
+ export declare const BLOCK_QUOTE: BlockType;
10
+ export declare const CODE_BLOCK: BlockType;
11
+ export declare const PANEL: BlockType;
12
+ export declare const OTHER: BlockType;
13
+ export declare const TEXT_BLOCK_TYPES: BlockType[];
14
+ export declare const WRAPPER_BLOCK_TYPES: BlockType[];
15
+ export declare const ALL_BLOCK_TYPES: BlockType[];
16
+ export declare const HEADINGS_BY_LEVEL: Record<number, BlockType>;
17
+ export declare const HEADINGS_BY_NAME: {
18
+ [blockType: string]: BlockType;
19
+ };
@@ -0,0 +1,18 @@
1
+ import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ import type { Command, HeadingLevelsAndNormalText } from '@atlaskit/editor-common/types';
3
+ export type InputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FORMATTING | INPUT_METHOD.KEYBOARD;
4
+ export declare function setBlockType(name: string): Command;
5
+ export declare function setBlockTypeWithAnalytics(name: string, inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
6
+ export declare function setNormalText(): Command;
7
+ export declare function setNormalTextWithAnalytics(inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
8
+ export declare const setHeadingWithAnalytics: (newHeadingLevel: HeadingLevelsAndNormalText, inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
9
+ /**
10
+ *
11
+ * @param name - block type name
12
+ * @param inputMethod - input method
13
+ * @param editorAnalyticsApi - analytics api, undefined if not available either because it failed to load or wasn't added
14
+ * otherwise Editor becomes very sad and crashes
15
+ * @returns - command that inserts block type
16
+ */
17
+ export declare const insertBlockQuoteWithAnalytics: (inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined) => Command;
18
+ export declare const cleanUpAtTheStartOfDocument: Command;
@@ -0,0 +1,12 @@
1
+ import type { Command } from '@atlaskit/editor-common/types';
2
+ /**
3
+ * Fixes cursor position after delete for list/task in panel and table
4
+ *
5
+ * ED-13873 fixes a bug where after deleting a list the cursor would move
6
+ * to the cell to the right. Uses setSelection to position the cursor as expected after deleting.
7
+ *
8
+ * @param state EditorState
9
+ * @param dispatch CommandDispatch
10
+ * @returns boolean
11
+ */
12
+ export declare const deleteAndMoveCursor: Command;
@@ -0,0 +1,10 @@
1
+ import type { Command } from '@atlaskit/editor-common/types';
2
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ /**
4
+ * Prevent removing the block when deleting block content
5
+ *
6
+ * @param state EditorState
7
+ * @param dispatch CommandDispatch
8
+ * @returns boolean
9
+ */
10
+ export declare function deleteBlockContent(isNodeAWrappingBlockNode: (node?: PMNode | null) => boolean): Command;
@@ -0,0 +1,9 @@
1
+ export { cleanUpAtTheStartOfDocument, insertBlockQuoteWithAnalytics, setBlockType, setBlockTypeWithAnalytics, setHeadingWithAnalytics, setNormalText, setNormalTextWithAnalytics, } from './block-type';
2
+ export type { InputMethod } from './block-type';
3
+ export { deleteAndMoveCursor } from './delete-and-move-cursor';
4
+ export { deleteBlockContent } from './delete-block-content';
5
+ /**
6
+ * @private
7
+ * @deprecated use import from @atlaskit/editor-common/commands
8
+ */
9
+ export { setHeading } from '@atlaskit/editor-common/commands';
@@ -0,0 +1 @@
1
+ export declare const HEADING_KEYS: number[];
@@ -0,0 +1,20 @@
1
+ import type { Command, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
+ import type { InputMethod } from './commands/block-type';
4
+ import type { BlockTypeState } from './pm-plugins/main';
5
+ import type { BlockTypePluginOptions } from './types';
6
+ export type BlockTypePlugin = NextEditorPlugin<'blockType', {
7
+ pluginConfiguration: BlockTypePluginOptions | undefined;
8
+ dependencies: [
9
+ OptionalPlugin<typeof analyticsPlugin>
10
+ ];
11
+ sharedState: BlockTypeState | undefined;
12
+ actions: {
13
+ insertBlockQuote: (inputMethod: InputMethod) => Command;
14
+ setBlockType: (name: string, inputMethod: InputMethod) => Command;
15
+ };
16
+ }>;
17
+ declare const blockTypePlugin: BlockTypePlugin;
18
+ export { blockTypePlugin };
19
+ export { pluginKey } from './pm-plugins/main';
20
+ export type { BlockTypeState } from './pm-plugins/main';
@@ -0,0 +1,152 @@
1
+ export declare const messages: {
2
+ normal: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ heading1: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
12
+ heading1Description: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ description: string;
16
+ };
17
+ heading2: {
18
+ id: string;
19
+ defaultMessage: string;
20
+ description: string;
21
+ };
22
+ heading2Description: {
23
+ id: string;
24
+ defaultMessage: string;
25
+ description: string;
26
+ };
27
+ heading3: {
28
+ id: string;
29
+ defaultMessage: string;
30
+ description: string;
31
+ };
32
+ heading3Description: {
33
+ id: string;
34
+ defaultMessage: string;
35
+ description: string;
36
+ };
37
+ heading4: {
38
+ id: string;
39
+ defaultMessage: string;
40
+ description: string;
41
+ };
42
+ heading4Description: {
43
+ id: string;
44
+ defaultMessage: string;
45
+ description: string;
46
+ };
47
+ heading5: {
48
+ id: string;
49
+ defaultMessage: string;
50
+ description: string;
51
+ };
52
+ heading5Description: {
53
+ id: string;
54
+ defaultMessage: string;
55
+ description: string;
56
+ };
57
+ heading6: {
58
+ id: string;
59
+ defaultMessage: string;
60
+ description: string;
61
+ };
62
+ heading6Description: {
63
+ id: string;
64
+ defaultMessage: string;
65
+ description: string;
66
+ };
67
+ blockquote: {
68
+ id: string;
69
+ defaultMessage: string;
70
+ description: string;
71
+ };
72
+ blockquoteDescription: {
73
+ id: string;
74
+ defaultMessage: string;
75
+ description: string;
76
+ };
77
+ codeblock: {
78
+ id: string;
79
+ defaultMessage: string;
80
+ description: string;
81
+ };
82
+ codeblockDescription: {
83
+ id: string;
84
+ defaultMessage: string;
85
+ description: string;
86
+ };
87
+ infoPanel: {
88
+ id: string;
89
+ defaultMessage: string;
90
+ description: string;
91
+ };
92
+ infoPanelDescription: {
93
+ id: string;
94
+ defaultMessage: string;
95
+ description: string;
96
+ };
97
+ notePanel: {
98
+ id: string;
99
+ defaultMessage: string;
100
+ description: string;
101
+ };
102
+ notePanelDescription: {
103
+ id: string;
104
+ defaultMessage: string;
105
+ description: string;
106
+ };
107
+ successPanel: {
108
+ id: string;
109
+ defaultMessage: string;
110
+ description: string;
111
+ };
112
+ successPanelDescription: {
113
+ id: string;
114
+ defaultMessage: string;
115
+ description: string;
116
+ };
117
+ warningPanel: {
118
+ id: string;
119
+ defaultMessage: string;
120
+ description: string;
121
+ };
122
+ warningPanelDescription: {
123
+ id: string;
124
+ defaultMessage: string;
125
+ description: string;
126
+ };
127
+ errorPanel: {
128
+ id: string;
129
+ defaultMessage: string;
130
+ description: string;
131
+ };
132
+ errorPanelDescription: {
133
+ id: string;
134
+ defaultMessage: string;
135
+ description: string;
136
+ };
137
+ customPanel: {
138
+ id: string;
139
+ defaultMessage: string;
140
+ description: string;
141
+ };
142
+ customPanelDescription: {
143
+ id: string;
144
+ defaultMessage: string;
145
+ description: string;
146
+ };
147
+ other: {
148
+ id: string;
149
+ defaultMessage: string;
150
+ description: string;
151
+ };
152
+ };
@@ -0,0 +1,6 @@
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import type { FeatureFlags } from '@atlaskit/editor-common/types';
4
+ import type { Schema } from '@atlaskit/editor-prosemirror/model';
5
+ declare function inputRulePlugin(editorAnalyticsAPI: EditorAnalyticsAPI | undefined, schema: Schema, featureFlags: FeatureFlags): SafePlugin | undefined;
6
+ export default inputRulePlugin;
@@ -0,0 +1,5 @@
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import type { FeatureFlags } from '@atlaskit/editor-common/types';
4
+ import type { Schema } from '@atlaskit/editor-prosemirror/model';
5
+ export default function keymapPlugin(editorAnalyticsApi: EditorAnalyticsAPI | undefined, schema: Schema, _featureFlags: FeatureFlags): SafePlugin;
@@ -0,0 +1,17 @@
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
+ import type { BlockType } from '../types';
5
+ export type BlockTypeState = {
6
+ currentBlockType: BlockType;
7
+ blockTypesDisabled: boolean;
8
+ availableBlockTypes: BlockType[];
9
+ availableWrapperBlockTypes: BlockType[];
10
+ };
11
+ export declare const pluginKey: PluginKey<BlockTypeState>;
12
+ export declare const createPlugin: (editorAnalyticsApi: EditorAnalyticsAPI | undefined, dispatch: (eventName: string | PluginKey, data: any) => void, lastNodeMustBeParagraph?: boolean) => SafePlugin<{
13
+ currentBlockType: BlockType;
14
+ blockTypesDisabled: boolean;
15
+ availableBlockTypes: BlockType[];
16
+ availableWrapperBlockTypes: BlockType[];
17
+ }>;
@@ -0,0 +1,2 @@
1
+ import type { ThemeProps } from '@atlaskit/theme/types';
2
+ export declare const blocktypeStyles: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
@@ -0,0 +1,22 @@
1
+ import type { MessageDescriptor } from 'react-intl-next';
2
+ import type { AllowedBlockTypes, HeadingLevelsAndNormalText } from '@atlaskit/editor-common/types';
3
+ import type { NodeSpec } from '@atlaskit/editor-prosemirror/model';
4
+ export type BlockTypeName = 'normal' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'blockquote' | 'codeblock' | 'panel' | 'notePanel' | 'successPanel' | 'warningPanel' | 'errorPanel' | 'other';
5
+ export interface BlockType {
6
+ name: string;
7
+ title: MessageDescriptor;
8
+ nodeName: string;
9
+ tagName?: string;
10
+ level?: HeadingLevelsAndNormalText;
11
+ }
12
+ export interface BlockTypeNode {
13
+ name: AllowedBlockTypes;
14
+ node: NodeSpec;
15
+ }
16
+ export interface BlockTypePluginOptions {
17
+ lastNodeMustBeParagraph?: boolean;
18
+ allowBlockType?: {
19
+ exclude?: Array<AllowedBlockTypes>;
20
+ };
21
+ isUndoRedoButtonsEnabled?: boolean;
22
+ }
@@ -0,0 +1,22 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import type { MessageDescriptor, WrappedComponentProps } from 'react-intl-next';
4
+ export interface BlockTypeButtonProps {
5
+ isSmall?: boolean;
6
+ isReducedSpacing?: boolean;
7
+ 'aria-expanded': React.AriaAttributes['aria-expanded'];
8
+ selected: boolean;
9
+ disabled: boolean;
10
+ title: MessageDescriptor;
11
+ onClick(e: React.MouseEvent): void;
12
+ onKeyDown(e: React.KeyboardEvent): void;
13
+ formatMessage: WrappedComponentProps['intl']['formatMessage'];
14
+ }
15
+ export declare const messages: {
16
+ textStyles: {
17
+ id: string;
18
+ defaultMessage: string;
19
+ description: string;
20
+ };
21
+ };
22
+ export declare const BlockTypeButton: React.StatelessComponent<BlockTypeButtonProps>;
@@ -0,0 +1,29 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import type { WrappedComponentProps } from 'react-intl-next';
4
+ import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { BlockTypeState } from '../../pm-plugins/main';
7
+ import type { BlockType } from '../../types';
8
+ export type DropdownItem = MenuItem & {
9
+ value: BlockType;
10
+ };
11
+ export interface Props {
12
+ isDisabled?: boolean;
13
+ isSmall?: boolean;
14
+ isReducedSpacing?: boolean;
15
+ pluginState: BlockTypeState;
16
+ popupsMountPoint?: HTMLElement;
17
+ popupsBoundariesElement?: HTMLElement;
18
+ popupsScrollableElement?: HTMLElement;
19
+ editorView?: EditorView;
20
+ setBlockType: (type: string) => void;
21
+ }
22
+ export interface State {
23
+ active: boolean;
24
+ isOpenedByKeyboard: boolean;
25
+ }
26
+ declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
27
+ WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
28
+ };
29
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import type { ThemeProps } from '@atlaskit/theme/types';
2
+ export declare const blockTypeMenuItemStyle: (tagName: string, selected?: boolean) => (themeProps: ThemeProps) => import("@emotion/react").SerializedStyles;
3
+ export declare const keyboardShortcut: import("@emotion/react").SerializedStyles;
4
+ export declare const keyboardShortcutSelect: import("@emotion/react").SerializedStyles;
5
+ export declare const buttonContentStyle: import("@emotion/react").SerializedStyles;
6
+ export declare const buttonContentReducedSpacingStyle: import("@emotion/react").SerializedStyles;
7
+ export declare const wrapperSmallStyle: import("@emotion/react").SerializedStyles;
8
+ export declare const expandIconWrapperStyle: import("@emotion/react").SerializedStyles;
@@ -0,0 +1,7 @@
1
+ export declare const toolbarMessages: {
2
+ textStyles: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ };
@@ -0,0 +1,16 @@
1
+ import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
3
+ import type { InputRuleWrapper } from '@atlaskit/prosemirror-input-rules';
4
+ export declare const isNodeAWrappingBlockNode: (node?: PMNode | null) => boolean;
5
+ export declare const createJoinNodesRule: (match: RegExp, nodeType: NodeType) => InputRuleWrapper;
6
+ type WrappingTextRuleProps = {
7
+ match: RegExp;
8
+ nodeType: NodeType;
9
+ getAttrs?: Record<string, any> | ((matchResult: RegExpExecArray) => Record<string, any>);
10
+ };
11
+ export declare const createWrappingTextBlockRule: ({ match, nodeType, getAttrs, }: WrappingTextRuleProps) => InputRuleWrapper;
12
+ /**
13
+ * Function will check if changing block types: Paragraph, Heading is enabled.
14
+ */
15
+ export declare function areBlockTypesDisabled(state: EditorState): boolean;
16
+ export {};
@@ -0,0 +1 @@
1
+ export { blocktypeStyles } from './plugin/styles';
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-block-type/messages",
3
+ "main": "../dist/cjs/messages.js",
4
+ "module": "../dist/esm/messages.js",
5
+ "module:es2019": "../dist/es2019/messages.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/messages.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <4.9": {
10
+ "*": [
11
+ "../dist/types-ts4.5/messages.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
package/package.json ADDED
@@ -0,0 +1,105 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-block-type",
3
+ "version": "1.0.0",
4
+ "description": "BlockType plugin for @atlaskit/editor-core",
5
+ "author": "Atlassian Pty Ltd",
6
+ "license": "Apache-2.0",
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org/"
9
+ },
10
+ "atlassian": {
11
+ "team": "Editor: Lego",
12
+ "inPublicMirror": false,
13
+ "releaseModel": "continuous",
14
+ "website": {
15
+ "name": "EditorPluginBlockType",
16
+ "category": "Components"
17
+ }
18
+ },
19
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend",
20
+ "main": "dist/cjs/index.js",
21
+ "module": "dist/esm/index.js",
22
+ "module:es2019": "dist/es2019/index.js",
23
+ "types": "dist/types/index.d.ts",
24
+ "typesVersions": {
25
+ ">=4.5 <4.9": {
26
+ "*": [
27
+ "dist/types-ts4.5/*",
28
+ "dist/types-ts4.5/index.d.ts"
29
+ ]
30
+ }
31
+ },
32
+ "sideEffects": false,
33
+ "atlaskit:src": "src/index.ts",
34
+ "af:exports": {
35
+ ".": "./src/index.ts",
36
+ "./consts": "./src/consts.ts",
37
+ "./messages": "./src/messages.ts",
38
+ "./styles": "./src/styles.ts"
39
+ },
40
+ "dependencies": {
41
+ "@atlaskit/adf-schema": "^29.1.0",
42
+ "@atlaskit/editor-common": "^74.59.0",
43
+ "@atlaskit/editor-plugin-analytics": "^0.2.0",
44
+ "@atlaskit/editor-prosemirror": "1.1.0",
45
+ "@atlaskit/editor-shared-styles": "^2.6.0",
46
+ "@atlaskit/editor-tables": "^2.3.0",
47
+ "@atlaskit/icon": "^21.12.0",
48
+ "@atlaskit/prosemirror-input-rules": "^2.4.0",
49
+ "@atlaskit/theme": "^12.6.0",
50
+ "@atlaskit/tokens": "^1.18.0",
51
+ "@babel/runtime": "^7.0.0",
52
+ "@emotion/react": "^11.7.1"
53
+ },
54
+ "peerDependencies": {
55
+ "react": "^16.8.0",
56
+ "react-intl-next": "npm:react-intl@^5.18.1"
57
+ },
58
+ "devDependencies": {
59
+ "@af/visual-regression": "*",
60
+ "@atlaskit/ssr": "*",
61
+ "@atlaskit/visual-regression": "*",
62
+ "@atlaskit/webdriver-runner": "*",
63
+ "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
64
+ "@testing-library/react": "^12.1.5",
65
+ "react-dom": "^16.8.0",
66
+ "typescript": "~4.9.5",
67
+ "wait-for-expect": "^1.2.0"
68
+ },
69
+ "techstack": {
70
+ "@atlassian/frontend": {
71
+ "import-structure": [
72
+ "atlassian-conventions"
73
+ ],
74
+ "circular-dependencies": [
75
+ "file-and-folder-level"
76
+ ]
77
+ },
78
+ "@repo/internal": {
79
+ "dom-events": "use-bind-event-listener",
80
+ "analytics": [
81
+ "analytics-next"
82
+ ],
83
+ "design-tokens": [
84
+ "color"
85
+ ],
86
+ "theming": [
87
+ "react-context"
88
+ ],
89
+ "ui-components": [
90
+ "lite-mode"
91
+ ],
92
+ "deprecation": [
93
+ "no-deprecated-imports"
94
+ ],
95
+ "styling": [
96
+ "static",
97
+ "emotion"
98
+ ],
99
+ "imports": [
100
+ "import-no-extraneous-disable-for-examples-and-docs"
101
+ ]
102
+ }
103
+ },
104
+ "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
105
+ }