@atlaskit/editor-core 187.41.8 → 187.42.3

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 (138) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/labs/next/presets/default.js +2 -2
  3. package/dist/cjs/plugins/code-block/index.js +1 -1
  4. package/dist/cjs/plugins/help-dialog/ui/index.js +1 -1
  5. package/dist/cjs/plugins/index.js +0 -7
  6. package/dist/cjs/plugins/insert-block/index.js +11 -11
  7. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
  8. package/dist/cjs/plugins/panel/index.js +1 -1
  9. package/dist/cjs/ui/ContentStyles/index.js +1 -1
  10. package/dist/cjs/version-wrapper.js +1 -1
  11. package/dist/es2019/index.js +0 -6
  12. package/dist/es2019/labs/next/presets/default.js +1 -1
  13. package/dist/es2019/plugins/code-block/index.js +1 -1
  14. package/dist/es2019/plugins/help-dialog/ui/index.js +1 -1
  15. package/dist/es2019/plugins/index.js +0 -1
  16. package/dist/es2019/plugins/insert-block/index.js +1 -1
  17. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
  18. package/dist/es2019/plugins/panel/index.js +1 -1
  19. package/dist/es2019/ui/ContentStyles/index.js +1 -1
  20. package/dist/es2019/version-wrapper.js +1 -1
  21. package/dist/esm/index.js +0 -6
  22. package/dist/esm/labs/next/presets/default.js +1 -1
  23. package/dist/esm/plugins/code-block/index.js +1 -1
  24. package/dist/esm/plugins/help-dialog/ui/index.js +1 -1
  25. package/dist/esm/plugins/index.js +0 -1
  26. package/dist/esm/plugins/insert-block/index.js +1 -1
  27. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +1 -1
  28. package/dist/esm/plugins/panel/index.js +1 -1
  29. package/dist/esm/ui/ContentStyles/index.js +1 -1
  30. package/dist/esm/version-wrapper.js +1 -1
  31. package/dist/types/index.d.ts +0 -7
  32. package/dist/types/labs/next/presets/default.d.ts +1 -1
  33. package/dist/types/plugins/index.d.ts +0 -1
  34. package/dist/types/plugins/insert-block/types.d.ts +2 -2
  35. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
  36. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +1 -1
  37. package/dist/types/types/editor-props.d.ts +1 -1
  38. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  39. package/dist/types/ui/ColorPickerButton/index.d.ts +1 -1
  40. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  41. package/dist/types-ts4.5/index.d.ts +0 -7
  42. package/dist/types-ts4.5/labs/next/presets/default.d.ts +1 -1
  43. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  44. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +2 -2
  45. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
  46. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +1 -1
  47. package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
  48. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  49. package/dist/types-ts4.5/ui/ColorPickerButton/index.d.ts +1 -1
  50. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  51. package/package.json +9 -7
  52. package/report.api.md +1 -62
  53. package/tmp/api-report-tmp.d.ts +1 -51
  54. package/dist/cjs/plugins/block-type/commands/block-type.js +0 -202
  55. package/dist/cjs/plugins/block-type/commands/delete-and-move-cursor.js +0 -56
  56. package/dist/cjs/plugins/block-type/commands/delete-block-content.js +0 -45
  57. package/dist/cjs/plugins/block-type/commands/index.js +0 -68
  58. package/dist/cjs/plugins/block-type/consts.js +0 -15
  59. package/dist/cjs/plugins/block-type/index.js +0 -215
  60. package/dist/cjs/plugins/block-type/messages.js +0 -160
  61. package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +0 -104
  62. package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +0 -34
  63. package/dist/cjs/plugins/block-type/pm-plugins/main.js +0 -151
  64. package/dist/cjs/plugins/block-type/styles.js +0 -15
  65. package/dist/cjs/plugins/block-type/types.js +0 -115
  66. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +0 -54
  67. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +0 -193
  68. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +0 -34
  69. package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/toolbar-messages.js +0 -15
  70. package/dist/cjs/plugins/block-type/utils.js +0 -87
  71. package/dist/es2019/plugins/block-type/commands/block-type.js +0 -191
  72. package/dist/es2019/plugins/block-type/commands/delete-and-move-cursor.js +0 -54
  73. package/dist/es2019/plugins/block-type/commands/delete-block-content.js +0 -42
  74. package/dist/es2019/plugins/block-type/commands/index.js +0 -3
  75. package/dist/es2019/plugins/block-type/consts.js +0 -8
  76. package/dist/es2019/plugins/block-type/index.js +0 -201
  77. package/dist/es2019/plugins/block-type/messages.js +0 -153
  78. package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +0 -93
  79. package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +0 -25
  80. package/dist/es2019/plugins/block-type/pm-plugins/main.js +0 -137
  81. package/dist/es2019/plugins/block-type/styles.js +0 -8
  82. package/dist/es2019/plugins/block-type/types.js +0 -93
  83. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +0 -44
  84. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +0 -170
  85. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +0 -49
  86. package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/toolbar-messages.js +0 -8
  87. package/dist/es2019/plugins/block-type/utils.js +0 -76
  88. package/dist/esm/plugins/block-type/commands/block-type.js +0 -187
  89. package/dist/esm/plugins/block-type/commands/delete-and-move-cursor.js +0 -49
  90. package/dist/esm/plugins/block-type/commands/delete-block-content.js +0 -39
  91. package/dist/esm/plugins/block-type/commands/index.js +0 -3
  92. package/dist/esm/plugins/block-type/consts.js +0 -8
  93. package/dist/esm/plugins/block-type/index.js +0 -202
  94. package/dist/esm/plugins/block-type/messages.js +0 -153
  95. package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +0 -96
  96. package/dist/esm/plugins/block-type/pm-plugins/keymap.js +0 -25
  97. package/dist/esm/plugins/block-type/pm-plugins/main.js +0 -142
  98. package/dist/esm/plugins/block-type/styles.js +0 -7
  99. package/dist/esm/plugins/block-type/types.js +0 -93
  100. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +0 -44
  101. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +0 -186
  102. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +0 -20
  103. package/dist/esm/plugins/block-type/ui/ToolbarBlockType/toolbar-messages.js +0 -8
  104. package/dist/esm/plugins/block-type/utils.js +0 -77
  105. package/dist/types/plugins/block-type/commands/block-type.d.ts +0 -19
  106. package/dist/types/plugins/block-type/commands/delete-and-move-cursor.d.ts +0 -12
  107. package/dist/types/plugins/block-type/commands/delete-block-content.d.ts +0 -10
  108. package/dist/types/plugins/block-type/commands/index.d.ts +0 -4
  109. package/dist/types/plugins/block-type/consts.d.ts +0 -1
  110. package/dist/types/plugins/block-type/index.d.ts +0 -18
  111. package/dist/types/plugins/block-type/messages.d.ts +0 -152
  112. package/dist/types/plugins/block-type/pm-plugins/input-rule.d.ts +0 -6
  113. package/dist/types/plugins/block-type/pm-plugins/keymap.d.ts +0 -5
  114. package/dist/types/plugins/block-type/pm-plugins/main.d.ts +0 -17
  115. package/dist/types/plugins/block-type/styles.d.ts +0 -2
  116. package/dist/types/plugins/block-type/types.d.ts +0 -40
  117. package/dist/types/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +0 -22
  118. package/dist/types/plugins/block-type/ui/ToolbarBlockType/index.d.ts +0 -29
  119. package/dist/types/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +0 -8
  120. package/dist/types/plugins/block-type/ui/ToolbarBlockType/toolbar-messages.d.ts +0 -7
  121. package/dist/types/plugins/block-type/utils.d.ts +0 -16
  122. package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +0 -19
  123. package/dist/types-ts4.5/plugins/block-type/commands/delete-and-move-cursor.d.ts +0 -12
  124. package/dist/types-ts4.5/plugins/block-type/commands/delete-block-content.d.ts +0 -10
  125. package/dist/types-ts4.5/plugins/block-type/commands/index.d.ts +0 -4
  126. package/dist/types-ts4.5/plugins/block-type/consts.d.ts +0 -1
  127. package/dist/types-ts4.5/plugins/block-type/index.d.ts +0 -20
  128. package/dist/types-ts4.5/plugins/block-type/messages.d.ts +0 -152
  129. package/dist/types-ts4.5/plugins/block-type/pm-plugins/input-rule.d.ts +0 -6
  130. package/dist/types-ts4.5/plugins/block-type/pm-plugins/keymap.d.ts +0 -5
  131. package/dist/types-ts4.5/plugins/block-type/pm-plugins/main.d.ts +0 -17
  132. package/dist/types-ts4.5/plugins/block-type/styles.d.ts +0 -2
  133. package/dist/types-ts4.5/plugins/block-type/types.d.ts +0 -40
  134. package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +0 -22
  135. package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/index.d.ts +0 -29
  136. package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +0 -8
  137. package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/toolbar-messages.d.ts +0 -7
  138. package/dist/types-ts4.5/plugins/block-type/utils.d.ts +0 -16
@@ -1,93 +0,0 @@
1
- // The names of the blocks don't map precisely to schema nodes, because
2
- // of concepts like "paragraph" <-> "Normal text" and "Unknown".
3
- //
4
- // (there are also different blocks for different types of panel, when
5
- // they're really all just a panel node)
6
- //
7
- // Rather than half-match half-not, this plugin introduces its own
8
- // nomenclature for what 'block type' is active.
9
-
10
- import { messages } from './messages';
11
- export const NORMAL_TEXT = {
12
- name: 'normal',
13
- title: messages.normal,
14
- nodeName: 'paragraph',
15
- tagName: 'p'
16
- };
17
- export const HEADING_1 = {
18
- name: 'heading1',
19
- title: messages.heading1,
20
- nodeName: 'heading',
21
- tagName: 'h1',
22
- level: 1
23
- };
24
- export const HEADING_2 = {
25
- name: 'heading2',
26
- title: messages.heading2,
27
- nodeName: 'heading',
28
- tagName: 'h2',
29
- level: 2
30
- };
31
- export const HEADING_3 = {
32
- name: 'heading3',
33
- title: messages.heading3,
34
- nodeName: 'heading',
35
- tagName: 'h3',
36
- level: 3
37
- };
38
- export const HEADING_4 = {
39
- name: 'heading4',
40
- title: messages.heading4,
41
- nodeName: 'heading',
42
- tagName: 'h4',
43
- level: 4
44
- };
45
- export const HEADING_5 = {
46
- name: 'heading5',
47
- title: messages.heading5,
48
- nodeName: 'heading',
49
- tagName: 'h5',
50
- level: 5
51
- };
52
- export const HEADING_6 = {
53
- name: 'heading6',
54
- title: messages.heading6,
55
- nodeName: 'heading',
56
- tagName: 'h6',
57
- level: 6
58
- };
59
- export const BLOCK_QUOTE = {
60
- name: 'blockquote',
61
- title: messages.blockquote,
62
- nodeName: 'blockquote'
63
- };
64
- export const CODE_BLOCK = {
65
- name: 'codeblock',
66
- title: messages.codeblock,
67
- nodeName: 'codeBlock'
68
- };
69
- export const PANEL = {
70
- name: 'panel',
71
- title: messages.infoPanel,
72
- nodeName: 'panel'
73
- };
74
- export const OTHER = {
75
- name: 'other',
76
- title: messages.other,
77
- nodeName: ''
78
- };
79
- export const TEXT_BLOCK_TYPES = [NORMAL_TEXT, HEADING_1, HEADING_2, HEADING_3, HEADING_4, HEADING_5, HEADING_6];
80
- export const WRAPPER_BLOCK_TYPES = [BLOCK_QUOTE, CODE_BLOCK, PANEL];
81
- export const ALL_BLOCK_TYPES = TEXT_BLOCK_TYPES.concat(WRAPPER_BLOCK_TYPES);
82
- export const HEADINGS_BY_LEVEL = TEXT_BLOCK_TYPES.reduce((acc, blockType) => {
83
- if (blockType.level && blockType.nodeName === 'heading') {
84
- acc[blockType.level] = blockType;
85
- }
86
- return acc;
87
- }, {});
88
- export const HEADINGS_BY_NAME = TEXT_BLOCK_TYPES.reduce((acc, blockType) => {
89
- if (blockType.level && blockType.nodeName === 'heading') {
90
- acc[blockType.name] = blockType;
91
- }
92
- return acc;
93
- }, {});
@@ -1,44 +0,0 @@
1
- /** @jsx jsx */
2
- import React from 'react';
3
- import { jsx } from '@emotion/react';
4
- import { FormattedMessage, defineMessages } from 'react-intl-next';
5
- import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
6
- import TextStyleIcon from '@atlaskit/icon/glyph/editor/text-style';
7
- import { wrapperStyle } from '@atlaskit/editor-common/styles';
8
- import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
9
- import { NORMAL_TEXT } from '../../types';
10
- import { buttonContentStyle, buttonContentReducedSpacingStyle, wrapperSmallStyle, expandIconWrapperStyle } from './styled';
11
- export const messages = defineMessages({
12
- textStyles: {
13
- id: 'fabric.editor.textStyles',
14
- defaultMessage: 'Text styles',
15
- description: 'Menu provides access to various heading styles or normal text'
16
- }
17
- });
18
- export const BlockTypeButton = props => {
19
- const labelTextStyles = props.formatMessage(messages.textStyles);
20
- return jsx(ToolbarButton, {
21
- spacing: props.isReducedSpacing ? 'none' : 'default',
22
- selected: props.selected,
23
- className: "block-type-btn",
24
- disabled: props.disabled,
25
- onClick: props.onClick,
26
- onKeyDown: props.onKeyDown,
27
- title: labelTextStyles,
28
- "aria-label": labelTextStyles,
29
- "aria-haspopup": true,
30
- "aria-expanded": props['aria-expanded'],
31
- iconAfter: jsx("span", {
32
- css: [wrapperStyle, props.isSmall && wrapperSmallStyle],
33
- "data-testid": "toolbar-block-type-text-styles-icon"
34
- }, props.isSmall && jsx(TextStyleIcon, {
35
- label: labelTextStyles
36
- }), jsx("span", {
37
- css: expandIconWrapperStyle
38
- }, jsx(ExpandIcon, {
39
- label: ""
40
- })))
41
- }, !props.isSmall && jsx("span", {
42
- css: [buttonContentStyle, props.isReducedSpacing && buttonContentReducedSpacingStyle]
43
- }, jsx(FormattedMessage, props.title || NORMAL_TEXT.title)));
44
- };
@@ -1,170 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- /** @jsx jsx */
3
- import React from 'react';
4
- import { jsx } from '@emotion/react';
5
- import { injectIntl } from 'react-intl-next';
6
- import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
7
- import { getAriaKeyshortcuts, tooltip, findKeymapByDescription } from '@atlaskit/editor-common/keymaps';
8
- import { separatorStyles, wrapperStyle } from '@atlaskit/editor-common/styles';
9
- import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
10
- import { blockTypeMenuItemStyle, keyboardShortcut, keyboardShortcutSelect } from './styled';
11
- import { BlockTypeButton } from './blocktype-button';
12
- class ToolbarBlockType extends React.PureComponent {
13
- constructor(...args) {
14
- super(...args);
15
- _defineProperty(this, "state", {
16
- active: false,
17
- isOpenedByKeyboard: false
18
- });
19
- _defineProperty(this, "onOpenChange", attrs => {
20
- this.setState({
21
- ...this.state,
22
- active: attrs.isOpen,
23
- isOpenedByKeyboard: attrs.isOpenedByKeyboard
24
- });
25
- });
26
- _defineProperty(this, "handleTriggerClick", () => {
27
- this.onOpenChange({
28
- isOpen: !this.state.active,
29
- isOpenedByKeyboard: false
30
- });
31
- });
32
- _defineProperty(this, "handleTriggerByKeyboard", event => {
33
- if (event.key === 'Enter' || event.key === ' ') {
34
- event.preventDefault();
35
- this.onOpenChange({
36
- isOpen: !this.state.active,
37
- isOpenedByKeyboard: true
38
- });
39
- }
40
- });
41
- _defineProperty(this, "createItems", () => {
42
- const {
43
- intl: {
44
- formatMessage
45
- }
46
- } = this.props;
47
- const {
48
- currentBlockType,
49
- availableBlockTypes
50
- } = this.props.pluginState;
51
- const items = availableBlockTypes.map((blockType, index) => {
52
- const isActive = currentBlockType === blockType;
53
- const tagName = blockType.tagName || 'p';
54
- const Tag = tagName;
55
- const keyMap = findKeymapByDescription(blockType.title.defaultMessage);
56
- return {
57
- content: jsx("div", {
58
- css: blockTypeMenuItemStyle(tagName, isActive)
59
- }, jsx(Tag, null, formatMessage(blockType.title))),
60
- value: blockType,
61
- label: formatMessage(blockType.title),
62
- 'aria-label': tooltip(keyMap, formatMessage(blockType.title)),
63
- keyShortcuts: getAriaKeyshortcuts(keyMap),
64
- key: `${blockType.name}-${index}`,
65
- elemAfter: jsx("div", {
66
- css: [keyboardShortcut, isActive && keyboardShortcutSelect]
67
- }, tooltip(keyMap)),
68
- isActive
69
- };
70
- });
71
- return [{
72
- items
73
- }];
74
- });
75
- _defineProperty(this, "handleSelectBlockType", ({
76
- item,
77
- shouldCloseMenu = true
78
- }) => {
79
- const blockType = item.value;
80
- this.props.setBlockType(blockType.name);
81
- if (shouldCloseMenu) {
82
- this.setState({
83
- ...this.state,
84
- active: false
85
- });
86
- }
87
- });
88
- }
89
- render() {
90
- const {
91
- active,
92
- isOpenedByKeyboard
93
- } = this.state;
94
- const {
95
- popupsMountPoint,
96
- popupsBoundariesElement,
97
- popupsScrollableElement,
98
- isSmall,
99
- isReducedSpacing,
100
- pluginState: {
101
- currentBlockType,
102
- blockTypesDisabled,
103
- availableBlockTypes
104
- },
105
- intl: {
106
- formatMessage
107
- }
108
- } = this.props;
109
- const isHeadingDisabled = !availableBlockTypes.some(blockType => blockType.nodeName === 'heading');
110
- if (isHeadingDisabled) {
111
- return null;
112
- }
113
- const blockTypeTitles = availableBlockTypes.filter(blockType => blockType.name === currentBlockType.name).map(blockType => blockType.title);
114
- if (!this.props.isDisabled && !blockTypesDisabled) {
115
- const items = this.createItems();
116
- return jsx("span", {
117
- css: wrapperStyle
118
- }, jsx(DropdownMenu, {
119
- items: items,
120
- onOpenChange: this.onOpenChange,
121
- onItemActivated: this.handleSelectBlockType,
122
- isOpen: active,
123
- mountTo: popupsMountPoint,
124
- boundariesElement: popupsBoundariesElement,
125
- scrollableElement: popupsScrollableElement,
126
- zIndex: akEditorMenuZIndex,
127
- fitHeight: 360,
128
- fitWidth: 106,
129
- shouldUseDefaultRole: true,
130
- shouldFocusFirstItem: () => {
131
- if (isOpenedByKeyboard) {
132
- this.setState({
133
- ...this.state,
134
- isOpenedByKeyboard: false
135
- });
136
- }
137
- return isOpenedByKeyboard;
138
- }
139
- }, jsx(BlockTypeButton, {
140
- isSmall: isSmall,
141
- isReducedSpacing: isReducedSpacing,
142
- selected: active,
143
- disabled: false,
144
- title: blockTypeTitles[0],
145
- onClick: this.handleTriggerClick,
146
- onKeyDown: this.handleTriggerByKeyboard,
147
- formatMessage: formatMessage,
148
- "aria-expanded": active
149
- })), jsx("span", {
150
- css: separatorStyles
151
- }));
152
- }
153
- return jsx("span", {
154
- css: wrapperStyle
155
- }, jsx(BlockTypeButton, {
156
- isSmall: isSmall,
157
- isReducedSpacing: isReducedSpacing,
158
- selected: active,
159
- disabled: true,
160
- title: blockTypeTitles[0],
161
- onClick: this.handleTriggerClick,
162
- onKeyDown: this.handleTriggerByKeyboard,
163
- formatMessage: formatMessage,
164
- "aria-expanded": active
165
- }), jsx("span", {
166
- css: separatorStyles
167
- }));
168
- }
169
- }
170
- export default injectIntl(ToolbarBlockType);
@@ -1,49 +0,0 @@
1
- /** @jsx jsx */
2
- import { css } from '@emotion/react';
3
- import { N400 } from '@atlaskit/theme/colors';
4
- import { headingsSharedStyles } from '@atlaskit/editor-common/styles';
5
- import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
6
- export const blockTypeMenuItemStyle = (tagName, selected) => {
7
- // TEMP FIX: See https://product-fabric.atlassian.net/browse/ED-13878
8
- const selectedStyle = selected ? `${tagName} { color: ${"var(--ds-text, white)"} !important; }` : '';
9
- return themeProps => css`
10
- ${headingsSharedStyles(themeProps)};
11
- > {
12
- h1,
13
- h2,
14
- h3,
15
- h4,
16
- h5,
17
- h6 {
18
- margin-top: 0;
19
- }
20
- }
21
- ${selectedStyle};
22
- `;
23
- };
24
- export const keyboardShortcut = css`
25
- ${shortcutStyle}
26
- margin-left: ${"var(--ds-space-200, 16px)"};
27
- `;
28
- export const keyboardShortcutSelect = css`
29
- color: ${`var(--ds-icon, ${N400})`};
30
- `;
31
- export const buttonContentStyle = css`
32
- display: flex;
33
- min-width: 80px;
34
- align-items: center;
35
- overflow: hidden;
36
- justify-content: center;
37
- flex-direction: column;
38
- padding: ${"var(--ds-space-075, 6px)"};
39
- `;
40
- export const buttonContentReducedSpacingStyle = css`
41
- padding: ${"var(--ds-space-100, 8px)"};
42
- `;
43
- export const wrapperSmallStyle = css`
44
- margin-left: ${"var(--ds-space-050, 4px)"};
45
- min-width: 40px;
46
- `;
47
- export const expandIconWrapperStyle = css`
48
- margin-left: -8px;
49
- `;
@@ -1,8 +0,0 @@
1
- import { defineMessages } from 'react-intl-next';
2
- export const toolbarMessages = defineMessages({
3
- textStyles: {
4
- id: 'fabric.editor.textStyles',
5
- defaultMessage: 'Text styles',
6
- description: 'Menu provides access to various heading styles or normal text'
7
- }
8
- });
@@ -1,76 +0,0 @@
1
- import { createRule } from '@atlaskit/prosemirror-input-rules';
2
- import { createWrappingJoinRule } from '@atlaskit/editor-common/utils';
3
- import { WRAPPER_BLOCK_TYPES } from './types';
4
- export const isNodeAWrappingBlockNode = node => {
5
- if (!node) {
6
- return false;
7
- }
8
- return WRAPPER_BLOCK_TYPES.some(blockNode => blockNode.name === node.type.name);
9
- };
10
- export const createJoinNodesRule = (match, nodeType) => {
11
- return createWrappingJoinRule({
12
- nodeType,
13
- match,
14
- getAttrs: {},
15
- joinPredicate: (_, node) => node.type === nodeType
16
- });
17
- };
18
- export const createWrappingTextBlockRule = ({
19
- match,
20
- nodeType,
21
- getAttrs
22
- }) => {
23
- const handler = (state, match, start, end) => {
24
- const fixedStart = Math.max(start, 1);
25
- const $start = state.doc.resolve(fixedStart);
26
- const attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
27
- const nodeBefore = $start.node(-1);
28
- if (nodeBefore && !nodeBefore.canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType)) {
29
- return null;
30
- }
31
- return state.tr.delete(fixedStart, end).setBlockType(fixedStart, fixedStart, nodeType, attrs);
32
- };
33
- return createRule(match, handler);
34
- };
35
-
36
- /**
37
- * Function will create a list of wrapper blocks present in a selection.
38
- */
39
- function getSelectedWrapperNodes(state) {
40
- const nodes = [];
41
- if (state.selection) {
42
- const {
43
- $from,
44
- $to
45
- } = state.selection;
46
- const {
47
- blockquote,
48
- panel,
49
- orderedList,
50
- bulletList,
51
- listItem,
52
- codeBlock,
53
- decisionItem,
54
- decisionList,
55
- taskItem,
56
- taskList
57
- } = state.schema.nodes;
58
- state.doc.nodesBetween($from.pos, $to.pos, node => {
59
- if (node.isBlock && [blockquote, panel, orderedList, bulletList, listItem, codeBlock, decisionItem, decisionList, taskItem, taskList].indexOf(node.type) >= 0) {
60
- nodes.push(node.type);
61
- }
62
- });
63
- }
64
- return nodes;
65
- }
66
-
67
- /**
68
- * Function will check if changing block types: Paragraph, Heading is enabled.
69
- */
70
- export function areBlockTypesDisabled(state) {
71
- const nodesTypes = getSelectedWrapperNodes(state);
72
- const {
73
- panel
74
- } = state.schema.nodes;
75
- return nodesTypes.filter(type => type !== panel).length > 0;
76
- }
@@ -1,187 +0,0 @@
1
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
- import { CellSelection } from '@atlaskit/editor-tables';
5
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
6
- import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
7
- import { filterChildrenBetween, wrapSelectionIn } from '@atlaskit/editor-common/utils';
8
- import { HEADINGS_BY_NAME, NORMAL_TEXT } from '../types';
9
- export function setBlockType(name) {
10
- return function (state, dispatch) {
11
- var nodes = state.schema.nodes;
12
- if (name === NORMAL_TEXT.name && nodes.paragraph) {
13
- return setNormalText()(state, dispatch);
14
- }
15
- var headingBlockType = HEADINGS_BY_NAME[name];
16
- if (headingBlockType && nodes.heading && headingBlockType.level) {
17
- return setHeading(headingBlockType.level)(state, dispatch);
18
- }
19
- return false;
20
- };
21
- }
22
- export function setBlockTypeWithAnalytics(name, inputMethod, editorAnalyticsApi) {
23
- return function (state, dispatch) {
24
- var nodes = state.schema.nodes;
25
- if (name === NORMAL_TEXT.name && nodes.paragraph) {
26
- return setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi)(state, dispatch);
27
- }
28
- var headingBlockType = HEADINGS_BY_NAME[name];
29
- if (headingBlockType && nodes.heading && headingBlockType.level) {
30
- return setHeadingWithAnalytics(headingBlockType.level, inputMethod, editorAnalyticsApi)(state, dispatch);
31
- }
32
- return false;
33
- };
34
- }
35
- export function setNormalText() {
36
- return function (state, dispatch) {
37
- var selection = state.selection,
38
- schema = state.schema,
39
- tr = state.tr;
40
- var ranges = selection instanceof CellSelection ? selection.ranges : [selection];
41
- ranges.forEach(function (_ref) {
42
- var $from = _ref.$from,
43
- $to = _ref.$to;
44
- tr.setBlockType($from.pos, $to.pos, schema.nodes.paragraph);
45
- });
46
- if (dispatch) {
47
- dispatch(tr);
48
- }
49
- return true;
50
- };
51
- }
52
- function withCurrentHeadingLevel(fn) {
53
- return function (state, dispatch, view) {
54
- // Find all headings and paragraphs of text
55
- var _state$schema$nodes = state.schema.nodes,
56
- heading = _state$schema$nodes.heading,
57
- paragraph = _state$schema$nodes.paragraph;
58
- var nodes = filterChildrenBetween(state.doc, state.selection.from, state.selection.to, function (node) {
59
- return node.type === heading || node.type === paragraph;
60
- });
61
-
62
- // Check each paragraph and/or heading and check for consistent level
63
- var level;
64
- var _iterator = _createForOfIteratorHelper(nodes),
65
- _step;
66
- try {
67
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
68
- var node = _step.value;
69
- var nodeLevel = node.node.type === heading ? node.node.attrs.level : 0;
70
- if (!level) {
71
- level = nodeLevel;
72
- } else if (nodeLevel !== level) {
73
- // Conflict in level, therefore inconsistent and undefined
74
- level = undefined;
75
- break;
76
- }
77
- }
78
- } catch (err) {
79
- _iterator.e(err);
80
- } finally {
81
- _iterator.f();
82
- }
83
- return fn(level)(state, dispatch, view);
84
- };
85
- }
86
- export function setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi) {
87
- return withCurrentHeadingLevel(function (previousHeadingLevel) {
88
- return withAnalytics(editorAnalyticsApi, {
89
- action: ACTION.FORMATTED,
90
- actionSubject: ACTION_SUBJECT.TEXT,
91
- eventType: EVENT_TYPE.TRACK,
92
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_HEADING,
93
- attributes: {
94
- inputMethod: inputMethod,
95
- newHeadingLevel: 0,
96
- previousHeadingLevel: previousHeadingLevel
97
- }
98
- })(setNormalText());
99
- });
100
- }
101
- export function setHeading(level) {
102
- return function (state, dispatch) {
103
- var selection = state.selection,
104
- schema = state.schema,
105
- tr = state.tr;
106
- var ranges = selection instanceof CellSelection ? selection.ranges : [selection];
107
- ranges.forEach(function (_ref2) {
108
- var $from = _ref2.$from,
109
- $to = _ref2.$to;
110
- tr.setBlockType($from.pos, $to.pos, schema.nodes.heading, {
111
- level: level
112
- });
113
- });
114
- if (dispatch) {
115
- dispatch(tr);
116
- }
117
- return true;
118
- };
119
- }
120
- export var setHeadingWithAnalytics = function setHeadingWithAnalytics(newHeadingLevel, inputMethod, editorAnalyticsApi) {
121
- return withCurrentHeadingLevel(function (previousHeadingLevel) {
122
- return withAnalytics(editorAnalyticsApi, {
123
- action: ACTION.FORMATTED,
124
- actionSubject: ACTION_SUBJECT.TEXT,
125
- eventType: EVENT_TYPE.TRACK,
126
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_HEADING,
127
- attributes: {
128
- inputMethod: inputMethod,
129
- newHeadingLevel: newHeadingLevel,
130
- previousHeadingLevel: previousHeadingLevel
131
- }
132
- })(setHeading(newHeadingLevel));
133
- });
134
- };
135
- function insertBlockQuote() {
136
- return function (state, dispatch) {
137
- var nodes = state.schema.nodes;
138
- if (nodes.paragraph && nodes.blockquote) {
139
- return wrapSelectionIn(nodes.blockquote)(state, dispatch);
140
- }
141
- return false;
142
- };
143
- }
144
-
145
- /**
146
- *
147
- * @param name - block type name
148
- * @param inputMethod - input method
149
- * @param editorAnalyticsApi - analytics api, undefined if not available either because it failed to load or wasn't added
150
- * otherwise Editor becomes very sad and crashes
151
- * @returns - command that inserts block type
152
- */
153
- export var insertBlockQuoteWithAnalytics = function insertBlockQuoteWithAnalytics(inputMethod, editorAnalyticsApi) {
154
- return withAnalytics(editorAnalyticsApi, {
155
- action: ACTION.FORMATTED,
156
- actionSubject: ACTION_SUBJECT.TEXT,
157
- eventType: EVENT_TYPE.TRACK,
158
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_BLOCK_QUOTE,
159
- attributes: {
160
- inputMethod: inputMethod
161
- }
162
- })(insertBlockQuote());
163
- };
164
- export var cleanUpAtTheStartOfDocument = function cleanUpAtTheStartOfDocument(state, dispatch) {
165
- var _ref3 = state.selection,
166
- $cursor = _ref3.$cursor;
167
- if ($cursor && !$cursor.nodeBefore && !$cursor.nodeAfter && $cursor.pos === 1) {
168
- var tr = state.tr,
169
- schema = state.schema;
170
- var paragraph = schema.nodes.paragraph;
171
- var parent = $cursor.parent;
172
-
173
- /**
174
- * Use cases:
175
- * 1. Change `heading` to `paragraph`
176
- * 2. Remove block marks
177
- *
178
- * NOTE: We already know it's an empty doc so it's safe to use 0
179
- */
180
- tr.setNodeMarkup(0, paragraph, parent.attrs, []);
181
- if (dispatch) {
182
- dispatch(tr);
183
- }
184
- return true;
185
- }
186
- return false;
187
- };
@@ -1,49 +0,0 @@
1
- import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
2
- // We should override default behaviour when selection spans node depths or
3
- // ends at a node junction
4
- var shouldMoveCursorAfterDelete = function shouldMoveCursorAfterDelete(state) {
5
- var _state$selection = state.selection,
6
- $from = _state$selection.$from,
7
- $to = _state$selection.$to;
8
- var nodeRange = $from.blockRange($to);
9
- if (!nodeRange) {
10
- return false;
11
- }
12
- var hasSameAncestor = $from.depth === $to.depth && $from.depth - 1 === nodeRange.depth;
13
- var toPositionHasNodeAfter = !!$to.nodeAfter;
14
- if (hasSameAncestor || toPositionHasNodeAfter) {
15
- return false;
16
- }
17
- return true;
18
- };
19
-
20
- /**
21
- * Fixes cursor position after delete for list/task in panel and table
22
- *
23
- * ED-13873 fixes a bug where after deleting a list the cursor would move
24
- * to the cell to the right. Uses setSelection to position the cursor as expected after deleting.
25
- *
26
- * @param state EditorState
27
- * @param dispatch CommandDispatch
28
- * @returns boolean
29
- */
30
- export var deleteAndMoveCursor = function deleteAndMoveCursor(state, dispatch) {
31
- if (state.selection.empty || !(state.selection instanceof TextSelection)) {
32
- return false;
33
- }
34
- if (!shouldMoveCursorAfterDelete(state)) {
35
- return false;
36
- }
37
- var tr = state.tr;
38
- tr.deleteSelection();
39
-
40
- // Make sure the next position is not out of boundaries
41
- var previousPosition = Math.min(Math.max(state.selection.$from.pos, 0), tr.doc.content.size);
42
- // Override default delete behaviour that moves the cursor to first suitable position after selection (postive bias).
43
- // See. selectionToInsertionEnd. We will override behavior with negative bias (search for suitable cursor position backwards).
44
- tr.setSelection(Selection.near(tr.doc.resolve(previousPosition), -1));
45
- if (dispatch) {
46
- dispatch(tr.scrollIntoView());
47
- }
48
- return true;
49
- };