@atlaskit/editor-core 190.1.6 → 190.1.8

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 (155) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/dist/cjs/plugins/index.js +0 -28
  4. package/dist/cjs/presets/universal.js +2 -16
  5. package/dist/cjs/ui/Addon/ClickAreaInline/index.js +1 -1
  6. package/dist/cjs/ui/AppearanceComponents/Mobile.js +3 -0
  7. package/dist/cjs/utils/action.js +0 -28
  8. package/dist/cjs/version-wrapper.js +1 -1
  9. package/dist/es2019/plugins/index.js +0 -4
  10. package/dist/es2019/presets/universal.js +2 -16
  11. package/dist/es2019/ui/Addon/ClickAreaInline/index.js +1 -1
  12. package/dist/es2019/ui/AppearanceComponents/Mobile.js +4 -0
  13. package/dist/es2019/utils/action.js +0 -28
  14. package/dist/es2019/version-wrapper.js +1 -1
  15. package/dist/esm/plugins/index.js +0 -4
  16. package/dist/esm/presets/universal.js +2 -16
  17. package/dist/esm/ui/Addon/ClickAreaInline/index.js +1 -1
  18. package/dist/esm/ui/AppearanceComponents/Mobile.js +4 -0
  19. package/dist/esm/utils/action.js +0 -28
  20. package/dist/esm/version-wrapper.js +1 -1
  21. package/dist/types/plugins/index.d.ts +0 -4
  22. package/dist/types/utils/action.d.ts +0 -6
  23. package/dist/types-ts4.5/plugins/index.d.ts +0 -4
  24. package/dist/types-ts4.5/utils/action.d.ts +0 -6
  25. package/package.json +2 -1
  26. package/dist/cjs/commands/index.js +0 -42
  27. package/dist/cjs/plugins/alignment/commands/index.js +0 -36
  28. package/dist/cjs/plugins/alignment/index.js +0 -70
  29. package/dist/cjs/plugins/alignment/pm-plugins/keymap.js +0 -14
  30. package/dist/cjs/plugins/alignment/pm-plugins/main.js +0 -45
  31. package/dist/cjs/plugins/alignment/pm-plugins/types.js +0 -5
  32. package/dist/cjs/plugins/alignment/ui/ToolbarAlignment/icon-map.js +0 -36
  33. package/dist/cjs/plugins/alignment/ui/ToolbarAlignment/index.js +0 -169
  34. package/dist/cjs/plugins/alignment/ui/ToolbarAlignment/messages.js +0 -29
  35. package/dist/cjs/plugins/alignment/ui/ToolbarAlignment/styles.js +0 -13
  36. package/dist/cjs/plugins/alignment/utils/index.js +0 -27
  37. package/dist/cjs/plugins/mobile-dimensions/actions.js +0 -12
  38. package/dist/cjs/plugins/mobile-dimensions/commands.js +0 -26
  39. package/dist/cjs/plugins/mobile-dimensions/index.js +0 -99
  40. package/dist/cjs/plugins/mobile-dimensions/plugin-factory.js +0 -15
  41. package/dist/cjs/plugins/mobile-dimensions/reducer.js +0 -28
  42. package/dist/cjs/plugins/mobile-dimensions/types.js +0 -5
  43. package/dist/cjs/plugins/mobile-selection/content-in-selection.js +0 -24
  44. package/dist/cjs/plugins/mobile-selection/index.js +0 -18
  45. package/dist/cjs/plugins/mobile-selection/mobile-selection-plugin.js +0 -59
  46. package/dist/cjs/plugins/mobile-selection/types.js +0 -5
  47. package/dist/cjs/plugins/view-update-subscription/index.js +0 -90
  48. package/dist/cjs/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +0 -109
  49. package/dist/cjs/ui/Alignment/AlignmentButton/index.js +0 -71
  50. package/dist/cjs/ui/Alignment/index.js +0 -74
  51. package/dist/cjs/ui/Alignment/styles.js +0 -11
  52. package/dist/es2019/commands/index.js +0 -1
  53. package/dist/es2019/plugins/alignment/commands/index.js +0 -30
  54. package/dist/es2019/plugins/alignment/index.js +0 -58
  55. package/dist/es2019/plugins/alignment/pm-plugins/keymap.js +0 -8
  56. package/dist/es2019/plugins/alignment/pm-plugins/main.js +0 -34
  57. package/dist/es2019/plugins/alignment/pm-plugins/types.js +0 -1
  58. package/dist/es2019/plugins/alignment/ui/ToolbarAlignment/icon-map.js +0 -30
  59. package/dist/es2019/plugins/alignment/ui/ToolbarAlignment/index.js +0 -140
  60. package/dist/es2019/plugins/alignment/ui/ToolbarAlignment/messages.js +0 -23
  61. package/dist/es2019/plugins/alignment/ui/ToolbarAlignment/styles.js +0 -14
  62. package/dist/es2019/plugins/alignment/utils/index.js +0 -15
  63. package/dist/es2019/plugins/mobile-dimensions/actions.js +0 -6
  64. package/dist/es2019/plugins/mobile-dimensions/commands.js +0 -14
  65. package/dist/es2019/plugins/mobile-dimensions/index.js +0 -88
  66. package/dist/es2019/plugins/mobile-dimensions/plugin-factory.js +0 -9
  67. package/dist/es2019/plugins/mobile-dimensions/reducer.js +0 -21
  68. package/dist/es2019/plugins/mobile-dimensions/types.js +0 -1
  69. package/dist/es2019/plugins/mobile-selection/content-in-selection.js +0 -17
  70. package/dist/es2019/plugins/mobile-selection/index.js +0 -1
  71. package/dist/es2019/plugins/mobile-selection/mobile-selection-plugin.js +0 -53
  72. package/dist/es2019/plugins/mobile-selection/types.js +0 -1
  73. package/dist/es2019/plugins/view-update-subscription/index.js +0 -73
  74. package/dist/es2019/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +0 -106
  75. package/dist/es2019/ui/Alignment/AlignmentButton/index.js +0 -44
  76. package/dist/es2019/ui/Alignment/index.js +0 -54
  77. package/dist/es2019/ui/Alignment/styles.js +0 -7
  78. package/dist/esm/commands/index.js +0 -1
  79. package/dist/esm/plugins/alignment/commands/index.js +0 -30
  80. package/dist/esm/plugins/alignment/index.js +0 -63
  81. package/dist/esm/plugins/alignment/pm-plugins/keymap.js +0 -8
  82. package/dist/esm/plugins/alignment/pm-plugins/main.js +0 -36
  83. package/dist/esm/plugins/alignment/pm-plugins/types.js +0 -1
  84. package/dist/esm/plugins/alignment/ui/ToolbarAlignment/icon-map.js +0 -29
  85. package/dist/esm/plugins/alignment/ui/ToolbarAlignment/index.js +0 -163
  86. package/dist/esm/plugins/alignment/ui/ToolbarAlignment/messages.js +0 -23
  87. package/dist/esm/plugins/alignment/ui/ToolbarAlignment/styles.js +0 -6
  88. package/dist/esm/plugins/alignment/utils/index.js +0 -21
  89. package/dist/esm/plugins/mobile-dimensions/actions.js +0 -6
  90. package/dist/esm/plugins/mobile-dimensions/commands.js +0 -20
  91. package/dist/esm/plugins/mobile-dimensions/index.js +0 -93
  92. package/dist/esm/plugins/mobile-dimensions/plugin-factory.js +0 -9
  93. package/dist/esm/plugins/mobile-dimensions/reducer.js +0 -21
  94. package/dist/esm/plugins/mobile-dimensions/types.js +0 -1
  95. package/dist/esm/plugins/mobile-selection/content-in-selection.js +0 -18
  96. package/dist/esm/plugins/mobile-selection/index.js +0 -1
  97. package/dist/esm/plugins/mobile-selection/mobile-selection-plugin.js +0 -53
  98. package/dist/esm/plugins/mobile-selection/types.js +0 -1
  99. package/dist/esm/plugins/view-update-subscription/index.js +0 -83
  100. package/dist/esm/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +0 -103
  101. package/dist/esm/ui/Alignment/AlignmentButton/index.js +0 -62
  102. package/dist/esm/ui/Alignment/index.js +0 -68
  103. package/dist/esm/ui/Alignment/styles.js +0 -4
  104. package/dist/types/commands/index.d.ts +0 -1
  105. package/dist/types/plugins/alignment/commands/index.d.ts +0 -4
  106. package/dist/types/plugins/alignment/index.d.ts +0 -5
  107. package/dist/types/plugins/alignment/pm-plugins/keymap.d.ts +0 -2
  108. package/dist/types/plugins/alignment/pm-plugins/main.d.ts +0 -8
  109. package/dist/types/plugins/alignment/pm-plugins/types.d.ts +0 -5
  110. package/dist/types/plugins/alignment/ui/ToolbarAlignment/icon-map.d.ts +0 -6
  111. package/dist/types/plugins/alignment/ui/ToolbarAlignment/index.d.ts +0 -33
  112. package/dist/types/plugins/alignment/ui/ToolbarAlignment/messages.d.ts +0 -22
  113. package/dist/types/plugins/alignment/ui/ToolbarAlignment/styles.d.ts +0 -3
  114. package/dist/types/plugins/alignment/utils/index.d.ts +0 -3
  115. package/dist/types/plugins/mobile-dimensions/actions.d.ts +0 -18
  116. package/dist/types/plugins/mobile-dimensions/commands.d.ts +0 -3
  117. package/dist/types/plugins/mobile-dimensions/index.d.ts +0 -7
  118. package/dist/types/plugins/mobile-dimensions/plugin-factory.d.ts +0 -5
  119. package/dist/types/plugins/mobile-dimensions/reducer.d.ts +0 -3
  120. package/dist/types/plugins/mobile-dimensions/types.d.ts +0 -8
  121. package/dist/types/plugins/mobile-selection/content-in-selection.d.ts +0 -5
  122. package/dist/types/plugins/mobile-selection/index.d.ts +0 -2
  123. package/dist/types/plugins/mobile-selection/mobile-selection-plugin.d.ts +0 -7
  124. package/dist/types/plugins/mobile-selection/types.d.ts +0 -32
  125. package/dist/types/plugins/view-update-subscription/index.d.ts +0 -19
  126. package/dist/types/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +0 -12
  127. package/dist/types/ui/Alignment/AlignmentButton/index.d.ts +0 -17
  128. package/dist/types/ui/Alignment/index.d.ts +0 -12
  129. package/dist/types/ui/Alignment/styles.d.ts +0 -1
  130. package/dist/types-ts4.5/commands/index.d.ts +0 -1
  131. package/dist/types-ts4.5/plugins/alignment/commands/index.d.ts +0 -4
  132. package/dist/types-ts4.5/plugins/alignment/index.d.ts +0 -5
  133. package/dist/types-ts4.5/plugins/alignment/pm-plugins/keymap.d.ts +0 -2
  134. package/dist/types-ts4.5/plugins/alignment/pm-plugins/main.d.ts +0 -8
  135. package/dist/types-ts4.5/plugins/alignment/pm-plugins/types.d.ts +0 -5
  136. package/dist/types-ts4.5/plugins/alignment/ui/ToolbarAlignment/icon-map.d.ts +0 -6
  137. package/dist/types-ts4.5/plugins/alignment/ui/ToolbarAlignment/index.d.ts +0 -33
  138. package/dist/types-ts4.5/plugins/alignment/ui/ToolbarAlignment/messages.d.ts +0 -22
  139. package/dist/types-ts4.5/plugins/alignment/ui/ToolbarAlignment/styles.d.ts +0 -3
  140. package/dist/types-ts4.5/plugins/alignment/utils/index.d.ts +0 -3
  141. package/dist/types-ts4.5/plugins/mobile-dimensions/actions.d.ts +0 -18
  142. package/dist/types-ts4.5/plugins/mobile-dimensions/commands.d.ts +0 -3
  143. package/dist/types-ts4.5/plugins/mobile-dimensions/index.d.ts +0 -7
  144. package/dist/types-ts4.5/plugins/mobile-dimensions/plugin-factory.d.ts +0 -5
  145. package/dist/types-ts4.5/plugins/mobile-dimensions/reducer.d.ts +0 -3
  146. package/dist/types-ts4.5/plugins/mobile-dimensions/types.d.ts +0 -8
  147. package/dist/types-ts4.5/plugins/mobile-selection/content-in-selection.d.ts +0 -5
  148. package/dist/types-ts4.5/plugins/mobile-selection/index.d.ts +0 -2
  149. package/dist/types-ts4.5/plugins/mobile-selection/mobile-selection-plugin.d.ts +0 -7
  150. package/dist/types-ts4.5/plugins/mobile-selection/types.d.ts +0 -32
  151. package/dist/types-ts4.5/plugins/view-update-subscription/index.d.ts +0 -19
  152. package/dist/types-ts4.5/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +0 -12
  153. package/dist/types-ts4.5/ui/Alignment/AlignmentButton/index.d.ts +0 -17
  154. package/dist/types-ts4.5/ui/Alignment/index.d.ts +0 -12
  155. package/dist/types-ts4.5/ui/Alignment/styles.d.ts +0 -1
@@ -1,140 +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 ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
7
- import ToolbarButton from '../../../../ui/ToolbarButton';
8
- import { ArrowKeyNavigationType, DropdownContainer as Dropdown } from '@atlaskit/editor-common/ui-menu';
9
- import Alignment from '../../../../ui/Alignment';
10
- import { expandIconWrapper, triggerWrapper, wrapper } from './styles';
11
- import { separatorStyles } from '@atlaskit/editor-common/styles';
12
- import { IconMap } from './icon-map';
13
- import { messages } from './messages';
14
- export class AlignmentToolbar extends React.Component {
15
- constructor(...args) {
16
- super(...args);
17
- _defineProperty(this, "toolbarItemRef", /*#__PURE__*/React.createRef());
18
- _defineProperty(this, "state", {
19
- isOpen: false
20
- });
21
- _defineProperty(this, "changeAlignment", (align, togglePopup) => {
22
- if (togglePopup) {
23
- this.toggleOpen();
24
- }
25
- return this.props.changeAlignment(align);
26
- });
27
- _defineProperty(this, "toggleOpen", () => {
28
- this.setState({
29
- isOpen: !this.state.isOpen
30
- });
31
- });
32
- _defineProperty(this, "toggleOpenByKeyboard", event => {
33
- if (event.key === 'Enter' || event.key === ' ') {
34
- event.preventDefault();
35
- this.setState({
36
- isOpen: !this.state.isOpen
37
- });
38
- }
39
- });
40
- _defineProperty(this, "hide", attrs => {
41
- if (this.state.isOpen) {
42
- this.setState({
43
- isOpen: false
44
- });
45
- if ((attrs === null || attrs === void 0 ? void 0 : attrs.event) instanceof KeyboardEvent && attrs.event.key === 'Escape') {
46
- var _this$toolbarItemRef, _this$toolbarItemRef$;
47
- (_this$toolbarItemRef = this.toolbarItemRef) === null || _this$toolbarItemRef === void 0 ? void 0 : (_this$toolbarItemRef$ = _this$toolbarItemRef.current) === null || _this$toolbarItemRef$ === void 0 ? void 0 : _this$toolbarItemRef$.focus();
48
- }
49
- }
50
- });
51
- _defineProperty(this, "hideOnEscape", () => {
52
- var _this$toolbarItemRef2, _this$toolbarItemRef3;
53
- this.hide();
54
- (_this$toolbarItemRef2 = this.toolbarItemRef) === null || _this$toolbarItemRef2 === void 0 ? void 0 : (_this$toolbarItemRef3 = _this$toolbarItemRef2.current) === null || _this$toolbarItemRef3 === void 0 ? void 0 : _this$toolbarItemRef3.focus();
55
- });
56
- }
57
- render() {
58
- const {
59
- isOpen
60
- } = this.state;
61
- const {
62
- popupsMountPoint,
63
- popupsBoundariesElement,
64
- popupsScrollableElement,
65
- isReducedSpacing,
66
- pluginState,
67
- disabled,
68
- intl
69
- } = this.props;
70
- const title = intl.formatMessage(messages.alignment);
71
- return jsx("span", {
72
- css: wrapper
73
- }, jsx(Dropdown, {
74
- mountTo: popupsMountPoint,
75
- boundariesElement: popupsBoundariesElement,
76
- scrollableElement: popupsScrollableElement,
77
- isOpen: isOpen,
78
- handleClickOutside: event => {
79
- if (event instanceof MouseEvent) {
80
- this.hide({
81
- isOpen: false,
82
- event
83
- });
84
- }
85
- },
86
- handleEscapeKeydown: this.hideOnEscape,
87
- arrowKeyNavigationProviderOptions: {
88
- type: ArrowKeyNavigationType.MENU
89
- },
90
- fitWidth: 112,
91
- fitHeight: 80,
92
- closeOnTab: true,
93
- trigger: jsx(ToolbarButton, {
94
- spacing: isReducedSpacing ? 'none' : 'default',
95
- disabled: disabled,
96
- selected: isOpen,
97
- title: title,
98
- className: "align-btn",
99
- "aria-label": title,
100
- "aria-expanded": isOpen,
101
- "aria-haspopup": true,
102
- onClick: this.toggleOpen,
103
- onKeyDown: this.toggleOpenByKeyboard,
104
- iconBefore: jsx("div", {
105
- css: triggerWrapper
106
- }, jsx(IconMap, {
107
- alignment: pluginState.align
108
- }), jsx("span", {
109
- css: expandIconWrapper
110
- }, jsx(ExpandIcon, {
111
- label: ""
112
- }))),
113
- ref: this.toolbarItemRef
114
- })
115
- }, jsx(Alignment, {
116
- onClick: align => this.changeAlignment(align, false),
117
- selectedAlignment: pluginState.align
118
- })), jsx("span", {
119
- css: separatorStyles
120
- }));
121
- }
122
- componentDidUpdate(prevProps) {
123
- if (this.state.isOpen) {
124
- // by triggering the keyboard event with a setTimeout, we ensure that the tooltip
125
- // associated with the alignment button doesn't render until the next render cycle
126
- // where the popup will be correctly positioned and the relative position of the tooltip
127
- // will not overlap with the button.
128
- setTimeout(() => {
129
- var _this$toolbarItemRef$2;
130
- const keyboardEvent = new KeyboardEvent('keydown', {
131
- bubbles: true,
132
- key: 'ArrowDown'
133
- });
134
- (_this$toolbarItemRef$2 = this.toolbarItemRef.current) === null || _this$toolbarItemRef$2 === void 0 ? void 0 : _this$toolbarItemRef$2.dispatchEvent(keyboardEvent);
135
- }, 0);
136
- }
137
- }
138
- }
139
- _defineProperty(AlignmentToolbar, "displayName", 'AlignmentToolbar');
140
- export default injectIntl(AlignmentToolbar);
@@ -1,23 +0,0 @@
1
- import { defineMessages } from 'react-intl-next';
2
- export const messages = defineMessages({
3
- alignment: {
4
- id: 'fabric.editor.alignment',
5
- defaultMessage: 'Text alignment',
6
- description: 'Opens drop down menu of options to configure text alignment'
7
- },
8
- alignLeft: {
9
- id: 'fabric.editor.alignLeft',
10
- defaultMessage: 'Align left',
11
- description: 'label stating that text is aligned left'
12
- },
13
- alignRight: {
14
- id: 'fabric.editor.alignRight',
15
- defaultMessage: 'Align Right',
16
- description: 'label stating that text is aligned right'
17
- },
18
- alignCenter: {
19
- id: 'fabric.editor.alignCenter',
20
- defaultMessage: 'Align Center',
21
- description: 'label stating that text is aligned center'
22
- }
23
- });
@@ -1,14 +0,0 @@
1
- import { css } from '@emotion/react';
2
- export const triggerWrapper = css`
3
- display: flex;
4
- `;
5
- export const wrapper = css`
6
- display: flex;
7
- align-items: center;
8
- div {
9
- display: flex;
10
- }
11
- `;
12
- export const expandIconWrapper = css`
13
- margin-left: ${"var(--ds-space-negative-100, -8px)"};
14
- `;
@@ -1,15 +0,0 @@
1
- import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
2
- import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
3
- export const getActiveAlignment = state => {
4
- if (state.selection instanceof CellSelection) {
5
- const marks = [];
6
- state.selection.forEachCell(cell => {
7
- const mark = cell.firstChild.marks.filter(mark => mark.type === state.schema.marks.alignment)[0];
8
- marks.push(mark ? mark.attrs.align : 'start');
9
- });
10
- return marks.every(mark => mark === marks[0]) ? marks[0] : 'start';
11
- }
12
- const node = findParentNodeOfType([state.schema.nodes.paragraph, state.schema.nodes.heading])(state.selection);
13
- const getMark = node && node.node.marks.filter(mark => mark.type === state.schema.marks.alignment)[0];
14
- return getMark && getMark.attrs.align || 'start';
15
- };
@@ -1,6 +0,0 @@
1
- export let MobileDimensionsActionTypes = /*#__PURE__*/function (MobileDimensionsActionTypes) {
2
- MobileDimensionsActionTypes["SET_WINDOW_HEIGHT"] = "SET_WINDOW_HEIGHT";
3
- MobileDimensionsActionTypes["SET_MOBILE_PADDING_TOP"] = "SET_MOBILE_PADDING_TOP";
4
- MobileDimensionsActionTypes["SET_IS_EXPANDED"] = "SET_IS_EXPANDED";
5
- return MobileDimensionsActionTypes;
6
- }({});
@@ -1,14 +0,0 @@
1
- import { MobileDimensionsActionTypes } from './actions';
2
- import { createCommand } from './plugin-factory';
3
- export const setWindowHeight = windowHeight => createCommand({
4
- type: MobileDimensionsActionTypes.SET_WINDOW_HEIGHT,
5
- windowHeight
6
- });
7
- export const setMobilePaddingTop = paddingTop => createCommand({
8
- type: MobileDimensionsActionTypes.SET_MOBILE_PADDING_TOP,
9
- paddingTop
10
- });
11
- export const setIsExpanded = isExpanded => createCommand({
12
- type: MobileDimensionsActionTypes.SET_IS_EXPANDED,
13
- isExpanded
14
- });
@@ -1,88 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { setWindowHeight } from './commands';
3
- import { createPluginState, mobileDimensionsPluginKey } from './plugin-factory';
4
- const getInitialState = () => ({
5
- mobilePaddingTop: 0,
6
- windowHeight: window.innerHeight,
7
- isExpanded: false
8
- });
9
-
10
- /**
11
- * Plugin to store the dimensions of the mobile such as keyboard height and window size
12
- */
13
-
14
- const createPlugin = dispatch => {
15
- let rafId;
16
- return new SafePlugin({
17
- state: createPluginState(dispatch, getInitialState),
18
- key: mobileDimensionsPluginKey,
19
- props: {
20
- scrollThreshold: {
21
- top: 12,
22
- left: 0,
23
- right: 0,
24
- bottom: 12
25
- },
26
- scrollMargin: {
27
- top: 12,
28
- bottom: 12,
29
- left: 0,
30
- right: 0
31
- }
32
- },
33
- view(editorView) {
34
- const handleResize = () => {
35
- if (rafId) {
36
- window.cancelAnimationFrame(rafId);
37
- }
38
- let windowInnerHeight = window.innerHeight;
39
- let count = 0;
40
- const checkWindowHeight = () => {
41
- // wait for height to stabilise before we commit to set it
42
- // this helps handle menu transitions in Android which we don't want to scroll for
43
- if (window.innerHeight === windowInnerHeight) {
44
- count++;
45
- if (count >= 5) {
46
- rafId = undefined;
47
- setWindowHeight(window.innerHeight)(editorView.state, editorView.dispatch);
48
- } else {
49
- rafId = requestAnimationFrame(checkWindowHeight);
50
- }
51
- } else {
52
- rafId = requestAnimationFrame(checkWindowHeight);
53
- }
54
- windowInnerHeight = window.innerHeight;
55
- };
56
- rafId = requestAnimationFrame(checkWindowHeight);
57
- };
58
- // the window will resize on Android when the keyboard shows/hides
59
- window.addEventListener('resize', handleResize);
60
- return {
61
- destroy() {
62
- window.removeEventListener('resize', handleResize);
63
- if (rafId) {
64
- window.cancelAnimationFrame(rafId);
65
- }
66
- }
67
- };
68
- }
69
- });
70
- };
71
- const mobileDimensionsPlugin = () => ({
72
- name: 'mobileDimensions',
73
- getSharedState(editorState) {
74
- if (!editorState) {
75
- return undefined;
76
- }
77
- return mobileDimensionsPluginKey.getState(editorState);
78
- },
79
- pmPlugins() {
80
- return [{
81
- name: 'mobileDimensions',
82
- plugin: ({
83
- dispatch
84
- }) => createPlugin(dispatch)
85
- }];
86
- }
87
- });
88
- export default mobileDimensionsPlugin;
@@ -1,9 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- import { pluginFactory } from '../../utils/plugin-state-factory';
3
- import reducer from './reducer';
4
- export const mobileDimensionsPluginKey = new PluginKey('mobileDimensions');
5
- export const {
6
- createPluginState,
7
- getPluginState,
8
- createCommand
9
- } = pluginFactory(mobileDimensionsPluginKey, reducer);
@@ -1,21 +0,0 @@
1
- import { MobileDimensionsActionTypes } from './actions';
2
- export default function (state, action) {
3
- switch (action.type) {
4
- case MobileDimensionsActionTypes.SET_WINDOW_HEIGHT:
5
- return {
6
- ...state,
7
- windowHeight: action.windowHeight
8
- };
9
- case MobileDimensionsActionTypes.SET_MOBILE_PADDING_TOP:
10
- return {
11
- ...state,
12
- mobilePaddingTop: action.paddingTop
13
- };
14
- case MobileDimensionsActionTypes.SET_IS_EXPANDED:
15
- return {
16
- ...state,
17
- isExpanded: action.isExpanded
18
- };
19
- }
20
- return state;
21
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- // Gets a plain text representation of the nodes in the current selection
2
- export const contentInSelection = ({
3
- selection,
4
- doc
5
- }) => {
6
- const nodes = new Array();
7
- const marks = new Array();
8
- doc.nodesBetween(selection.from, selection.to, node => {
9
- nodes.push(node.type.name);
10
- node.marks.forEach(mark => marks.push(mark.type.name));
11
- return true;
12
- });
13
- return {
14
- nodeTypes: Array.from(nodes),
15
- markTypes: Array.from(marks)
16
- };
17
- };
@@ -1 +0,0 @@
1
- export { mobileSelectionPlugin as default, selectionPluginKey } from './mobile-selection-plugin';
@@ -1,53 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
4
- import { contentInSelection } from './content-in-selection';
5
- export const selectionPluginKey = new PluginKey('mobile-selection');
6
- export const createProseMirrorPlugin = dispatch => {
7
- return new SafePlugin({
8
- view: editorView => {
9
- const domAtPos = editorView.domAtPos.bind(editorView);
10
- return {
11
- update: (view, previousState) => {
12
- const {
13
- state,
14
- state: {
15
- selection,
16
- doc
17
- }
18
- } = view;
19
- if (previousState.doc.eq(doc) && previousState.selection.eq(selection)) {
20
- return;
21
- }
22
- const ref = findDomRefAtPos(selection.$anchor.pos, domAtPos);
23
- const {
24
- top,
25
- left
26
- } = ref.getBoundingClientRect();
27
- const {
28
- nodeTypes,
29
- markTypes
30
- } = contentInSelection(state);
31
- dispatch(selectionPluginKey, {
32
- rect: {
33
- top: Math.round(top),
34
- left: Math.round(left)
35
- },
36
- selection: state.selection.toJSON(),
37
- nodeTypes,
38
- markTypes
39
- });
40
- }
41
- };
42
- }
43
- });
44
- };
45
- export const mobileSelectionPlugin = () => ({
46
- name: 'mobileSelection',
47
- pmPlugins: () => [{
48
- name: 'mobileSelection',
49
- plugin: ({
50
- dispatch
51
- }) => createProseMirrorPlugin(dispatch)
52
- }]
53
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,73 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
- export const trackerStore = new WeakMap();
5
- class Tracker {
6
- constructor() {
7
- _defineProperty(this, "update", props => {
8
- this.subscriptions.forEach(cb => cb(props));
9
- });
10
- _defineProperty(this, "add", subscription => {
11
- this.subscriptions.push(subscription);
12
- });
13
- _defineProperty(this, "remove", subscription => {
14
- this.subscriptions = this.subscriptions.filter(s => s !== subscription);
15
- });
16
- this.subscriptions = [];
17
- }
18
- }
19
- const pluginKey = new PluginKey('viewUpdateSubscriptionKey');
20
- const createViewUpdateSubscriptionPlugin = () => {
21
- let tracker;
22
- const lastUpdateRef = {
23
- current: null,
24
- initial: null,
25
- transactions: [],
26
- queued: false
27
- };
28
- return {
29
- name: 'viewUpdateSubscription',
30
- pmPlugins: () => {
31
- const createPlugin = () => new SafePlugin({
32
- key: pluginKey,
33
- view(editorView) {
34
- tracker = trackerStore.get(editorView);
35
- if (!tracker) {
36
- tracker = new Tracker();
37
- trackerStore.set(editorView, tracker);
38
- }
39
- return {};
40
- }
41
- });
42
- return [{
43
- name: 'viewUpdateSubscription',
44
- plugin: createPlugin
45
- }];
46
- },
47
- onEditorViewStateUpdated(props) {
48
- lastUpdateRef.current = props;
49
- lastUpdateRef.transactions.push(...props.transactions);
50
- if (!lastUpdateRef.queued) {
51
- lastUpdateRef.initial = props;
52
- lastUpdateRef.queued = true;
53
- queueMicrotask(() => {
54
- if (!lastUpdateRef.current || !lastUpdateRef.initial) {
55
- return;
56
- }
57
- if (tracker) {
58
- var _lastUpdateRef$initia;
59
- tracker.update({
60
- newEditorState: lastUpdateRef.current.newEditorState,
61
- oldEditorState: (_lastUpdateRef$initia = lastUpdateRef.initial) === null || _lastUpdateRef$initia === void 0 ? void 0 : _lastUpdateRef$initia.oldEditorState,
62
- transactions: lastUpdateRef.transactions
63
- });
64
- }
65
- lastUpdateRef.queued = false;
66
- lastUpdateRef.current = null;
67
- lastUpdateRef.transactions = [];
68
- });
69
- }
70
- }
71
- };
72
- };
73
- export default createViewUpdateSubscriptionPlugin;
@@ -1,106 +0,0 @@
1
- import { areSameItems } from '@atlaskit/editor-common/floating-toolbar';
2
- import { trackerStore } from '..';
3
- const areToolbarsSame = (left, right) => {
4
- if (!left && !right) {
5
- return true;
6
- }
7
- if (left && !right || !left && right) {
8
- return false;
9
- }
10
- const leftConfig = left.config;
11
- const rightConfig = right.config;
12
- if (!leftConfig && !rightConfig) {
13
- return true;
14
- }
15
- if (!leftConfig && rightConfig || leftConfig && !rightConfig) {
16
- return false;
17
- }
18
- const leftItems = Array.isArray(leftConfig.items) ? leftConfig.items : leftConfig.items(left.node);
19
- const rightItems = Array.isArray(rightConfig.items) ? rightConfig.items : rightConfig.items(right.node);
20
- return areSameItems(leftItems, rightItems);
21
- };
22
- export const subscribeToToolbarAndPickerUpdates = (editorView, cb) => {
23
- let lastUpdatedState = null;
24
- const subscription = ({
25
- newEditorState
26
- }) => {
27
- // Creating fake plugin keys for these plugins for the mean time until all these plugins are extracted.
28
- const typeAheadPluginKey = {
29
- key: 'typeAheadPlugin$',
30
- getState: state => {
31
- return state['typeAheadPlugin$'];
32
- }
33
- };
34
- const datePluginKey = {
35
- key: 'datePlugin$',
36
- getState: state => {
37
- return state['datePlugin$'];
38
- }
39
- };
40
- const statusPluginKey = {
41
- key: 'statusPlugin$',
42
- getState: state => {
43
- return state['statusPlugin$'];
44
- }
45
- };
46
- const floatingToolbarPluginKey = {
47
- key: 'floatingToolbarPluginKey$',
48
- getState: state => {
49
- return state['floatingToolbarPluginKey$'];
50
- }
51
- };
52
- const isTypeAheadOpen = editorState => {
53
- var _typeAheadState$decor;
54
- const typeAheadState = typeAheadPluginKey.getState(newEditorState);
55
- return !!((_typeAheadState$decor = typeAheadState.decorationSet) !== null && _typeAheadState$decor !== void 0 && _typeAheadState$decor.find().length);
56
- };
57
- // TypeAhead has priority in the mobile-bridge
58
- // In case it is open we don't need to send
59
- // any toolbar updates don't need to be send
60
- if (isTypeAheadOpen(newEditorState)) {
61
- return;
62
- }
63
- const dateState = datePluginKey.getState(newEditorState);
64
- const statusState = statusPluginKey.getState(newEditorState);
65
- const {
66
- getConfigWithNodeInfo
67
- } = floatingToolbarPluginKey.getState(newEditorState);
68
- const toolbarConfig = getConfigWithNodeInfo(newEditorState);
69
- let shouldCallback = false;
70
- if (lastUpdatedState) {
71
- const oldDateState = datePluginKey.getState(lastUpdatedState);
72
- const oldStatusState = statusPluginKey.getState(lastUpdatedState);
73
- const {
74
- getConfigWithNodeInfo: getOldConfigWithNodeInfo
75
- } = floatingToolbarPluginKey.getState(lastUpdatedState);
76
- const oldToolbarConfig = getOldConfigWithNodeInfo(lastUpdatedState);
77
- const isToolbarEqual = areToolbarsSame(toolbarConfig, oldToolbarConfig);
78
- if (dateState !== oldDateState || statusState !== oldStatusState ||
79
- // Sometimes the toolbar changes while a picker is open, we dont care about this
80
- // EG A nested status or date node in a table
81
- !isToolbarEqual && !(statusState !== null && statusState !== void 0 && statusState.showStatusPickerAt) && !(dateState !== null && dateState !== void 0 && dateState.showDatePickerAt)) {
82
- shouldCallback = true;
83
- }
84
- } else {
85
- shouldCallback = true;
86
- }
87
- if (shouldCallback) {
88
- cb({
89
- dateState,
90
- statusState,
91
- toolbarConfig
92
- });
93
- }
94
- lastUpdatedState = newEditorState;
95
- };
96
- const tracker = trackerStore.get(editorView);
97
- if (tracker) {
98
- tracker.add(subscription);
99
- }
100
- return () => {
101
- const tracker = trackerStore.get(editorView);
102
- if (tracker) {
103
- tracker.remove(subscription);
104
- }
105
- };
106
- };
@@ -1,44 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import React from 'react';
3
- import { PureComponent } from 'react';
4
- import ToolbarButton from '../../ToolbarButton';
5
- import { ToolTipContent, tooltip } from '../../../keymaps';
6
- import { getAriaKeyshortcuts } from '@atlaskit/editor-common/keymaps';
7
- class AlignmentButton extends PureComponent {
8
- constructor(...args) {
9
- super(...args);
10
- _defineProperty(this, "onClick", e => {
11
- const {
12
- onClick,
13
- value
14
- } = this.props;
15
-
16
- // detect if the click event comes from keyboard where screenX and screenY are 0
17
- const isMouseEvent = e instanceof MouseEvent;
18
- e.preventDefault();
19
- onClick(value, isMouseEvent);
20
- });
21
- }
22
- render() {
23
- const {
24
- label,
25
- isSelected,
26
- content,
27
- shortcut
28
- } = this.props;
29
- return /*#__PURE__*/React.createElement(ToolbarButton, {
30
- disabled: false,
31
- selected: isSelected,
32
- title: /*#__PURE__*/React.createElement(ToolTipContent, {
33
- description: label,
34
- keymap: shortcut
35
- }),
36
- "aria-label": shortcut ? tooltip(shortcut, label) : label,
37
- "aria-pressed": isSelected,
38
- "aria-keyshortcuts": getAriaKeyshortcuts(shortcut),
39
- onClick: this.onClick,
40
- iconBefore: content
41
- });
42
- }
43
- }
44
- export default AlignmentButton;