@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,54 +0,0 @@
1
- /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
3
- import { PureComponent } from 'react';
4
- import { injectIntl } from 'react-intl-next';
5
- import { IconMap } from '../../plugins/alignment/ui/ToolbarAlignment/icon-map';
6
- import AlignmentButton from './AlignmentButton';
7
- import { alignmentMessages } from '@atlaskit/editor-common/messages';
8
- import { alignmentWrapper } from './styles';
9
- import { alignLeft } from '../../keymaps';
10
- const alignmentOptions = [{
11
- title: alignmentMessages.alignLeft,
12
- shortcut: alignLeft,
13
- value: 'start'
14
- }, {
15
- title: alignmentMessages.alignCenter,
16
- value: 'center'
17
- }, {
18
- title: alignmentMessages.alignRight,
19
- value: 'end'
20
- }];
21
- class Alignment extends PureComponent {
22
- render() {
23
- const {
24
- onClick,
25
- selectedAlignment,
26
- className,
27
- intl
28
- } = this.props;
29
- return jsx("div", {
30
- "data-testid": "alignment-buttons",
31
- css: alignmentWrapper,
32
- className: className
33
- }, alignmentOptions.map(alignment => {
34
- const {
35
- value,
36
- title,
37
- shortcut
38
- } = alignment;
39
- const message = intl.formatMessage(title);
40
- return jsx(AlignmentButton, {
41
- content: jsx(IconMap, {
42
- alignment: value
43
- }),
44
- key: value,
45
- value: value,
46
- label: message,
47
- shortcut: shortcut,
48
- onClick: onClick,
49
- isSelected: value === selectedAlignment
50
- });
51
- }));
52
- }
53
- }
54
- export default injectIntl(Alignment);
@@ -1,7 +0,0 @@
1
- import { css } from '@emotion/react';
2
- export const alignmentWrapper = css`
3
- padding: 0 ${"var(--ds-space-100, 8px)"};
4
- display: flex;
5
- flex-wrap: wrap;
6
- max-width: ${3 * 32}px;
7
- `;
@@ -1 +0,0 @@
1
- export { addParagraphAtEnd, createParagraphAtEnd, changeImageAlignment, createToggleBlockMarkOnRange, toggleBlockMark, clearEditorContent } from '@atlaskit/editor-common/commands';
@@ -1,30 +0,0 @@
1
- import { toggleBlockMark, changeImageAlignment } from '../../../commands';
2
- import { cascadeCommands } from '../../../utils/action';
3
- export var isAlignable = function isAlignable(align) {
4
- return function (state, dispatch) {
5
- var _state$schema = state.schema,
6
- _state$schema$nodes = _state$schema.nodes,
7
- paragraph = _state$schema$nodes.paragraph,
8
- heading = _state$schema$nodes.heading,
9
- alignment = _state$schema.marks.alignment;
10
- return toggleBlockMark(alignment, function () {
11
- return !align ? undefined : align === 'start' ? false : {
12
- align: align
13
- };
14
- }, [paragraph, heading])(state, dispatch);
15
- };
16
- };
17
- export var changeAlignment = function changeAlignment(align) {
18
- return function (state, dispatch) {
19
- var _state$schema2 = state.schema,
20
- _state$schema2$nodes = _state$schema2.nodes,
21
- paragraph = _state$schema2$nodes.paragraph,
22
- heading = _state$schema2$nodes.heading,
23
- alignment = _state$schema2.marks.alignment;
24
- return cascadeCommands([changeImageAlignment(align), toggleBlockMark(alignment, function () {
25
- return !align ? undefined : align === 'start' ? false : {
26
- align: align
27
- };
28
- }, [paragraph, heading])])(state, dispatch);
29
- };
30
- };
@@ -1,63 +0,0 @@
1
- import React from 'react';
2
- import { alignment } from '@atlaskit/adf-schema';
3
- import WithPluginState from '../../ui/WithPluginState';
4
- import { pluginKey, createPlugin } from './pm-plugins/main';
5
- import { changeAlignment as _changeAlignment } from './commands';
6
- import ToolbarAlignment from './ui/ToolbarAlignment';
7
- import { keymapPlugin } from './pm-plugins/keymap';
8
- export var defaultConfig = {
9
- align: 'start'
10
- };
11
- var alignmentPlugin = function alignmentPlugin() {
12
- return {
13
- name: 'alignment',
14
- marks: function marks() {
15
- return [{
16
- name: 'alignment',
17
- mark: alignment
18
- }];
19
- },
20
- pmPlugins: function pmPlugins() {
21
- return [{
22
- name: 'alignmentPlugin',
23
- plugin: function plugin(_ref) {
24
- var dispatch = _ref.dispatch;
25
- return createPlugin(dispatch, defaultConfig);
26
- }
27
- }, {
28
- name: 'annotationKeymap',
29
- plugin: function plugin() {
30
- return keymapPlugin();
31
- }
32
- }];
33
- },
34
- primaryToolbarComponent: function primaryToolbarComponent(_ref2) {
35
- var editorView = _ref2.editorView,
36
- popupsMountPoint = _ref2.popupsMountPoint,
37
- popupsBoundariesElement = _ref2.popupsBoundariesElement,
38
- popupsScrollableElement = _ref2.popupsScrollableElement,
39
- disabled = _ref2.disabled,
40
- isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing;
41
- return /*#__PURE__*/React.createElement(WithPluginState, {
42
- plugins: {
43
- align: pluginKey
44
- },
45
- render: function render(_ref3) {
46
- var align = _ref3.align;
47
- return /*#__PURE__*/React.createElement(ToolbarAlignment, {
48
- pluginState: align,
49
- isReducedSpacing: isToolbarReducedSpacing,
50
- changeAlignment: function changeAlignment(align) {
51
- return _changeAlignment(align)(editorView.state, editorView.dispatch);
52
- },
53
- disabled: disabled || !align.isEnabled,
54
- popupsMountPoint: popupsMountPoint,
55
- popupsBoundariesElement: popupsBoundariesElement,
56
- popupsScrollableElement: popupsScrollableElement
57
- });
58
- }
59
- });
60
- }
61
- };
62
- };
63
- export default alignmentPlugin;
@@ -1,8 +0,0 @@
1
- import { keymap } from '@atlaskit/editor-prosemirror/keymap';
2
- import { bindKeymapWithCommand, alignLeft } from '../../../keymaps';
3
- import { changeAlignment } from '../commands';
4
- export function keymapPlugin() {
5
- var list = {};
6
- bindKeymapWithCommand(alignLeft.common, changeAlignment('start'), list);
7
- return keymap(list);
8
- }
@@ -1,36 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
- import { isAlignable } from '../commands';
7
- import { getActiveAlignment } from '../utils';
8
- export function createInitialPluginState(editorState, pluginConfig) {
9
- return {
10
- align: getActiveAlignment(editorState) || pluginConfig.align,
11
- isEnabled: true
12
- };
13
- }
14
- export var pluginKey = new PluginKey('alignmentPlugin');
15
- export function createPlugin(dispatch, pluginConfig) {
16
- return new SafePlugin({
17
- key: pluginKey,
18
- state: {
19
- init: function init(_config, editorState) {
20
- return createInitialPluginState(editorState, pluginConfig);
21
- },
22
- apply: function apply(_tr, state, _prevState, nextState) {
23
- var nextPluginState = getActiveAlignment(nextState);
24
- var isEnabled = isAlignable(nextPluginState)(nextState);
25
- var newState = _objectSpread(_objectSpread({}, state), {}, {
26
- align: nextPluginState,
27
- isEnabled: isEnabled
28
- });
29
- if (nextPluginState !== state.align || isEnabled !== state.isEnabled) {
30
- dispatch(pluginKey, newState);
31
- }
32
- return newState;
33
- }
34
- }
35
- });
36
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,29 +0,0 @@
1
- import EditorAlignLeftIcon from '@atlaskit/icon/glyph/editor/align-left';
2
- import EditorAlignRightIcon from '@atlaskit/icon/glyph/editor/align-right';
3
- import EditorAlignCenterIcon from '@atlaskit/icon/glyph/editor/align-center';
4
- import { useIntl } from 'react-intl-next';
5
- import { messages } from './messages';
6
- import React from 'react';
7
- var iconAndMessageMap = {
8
- start: {
9
- Component: EditorAlignLeftIcon,
10
- label: messages.alignLeft
11
- },
12
- end: {
13
- Component: EditorAlignRightIcon,
14
- label: messages.alignRight
15
- },
16
- center: {
17
- Component: EditorAlignCenterIcon,
18
- label: messages.alignCenter
19
- }
20
- };
21
- export var IconMap = function IconMap(props) {
22
- var _iconAndMessageMap$pr = iconAndMessageMap[props.alignment],
23
- Component = _iconAndMessageMap$pr.Component,
24
- label = _iconAndMessageMap$pr.label;
25
- var intl = useIntl();
26
- return /*#__PURE__*/React.createElement(Component, {
27
- label: intl.formatMessage(label)
28
- });
29
- };
@@ -1,163 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
- /** @jsx jsx */
11
- import React from 'react';
12
- import { jsx } from '@emotion/react';
13
- import { injectIntl } from 'react-intl-next';
14
- import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
15
- import ToolbarButton from '../../../../ui/ToolbarButton';
16
- import { ArrowKeyNavigationType, DropdownContainer as Dropdown } from '@atlaskit/editor-common/ui-menu';
17
- import Alignment from '../../../../ui/Alignment';
18
- import { expandIconWrapper, triggerWrapper, wrapper } from './styles';
19
- import { separatorStyles } from '@atlaskit/editor-common/styles';
20
- import { IconMap } from './icon-map';
21
- import { messages } from './messages';
22
- export var AlignmentToolbar = /*#__PURE__*/function (_React$Component) {
23
- _inherits(AlignmentToolbar, _React$Component);
24
- var _super = _createSuper(AlignmentToolbar);
25
- function AlignmentToolbar() {
26
- var _this;
27
- _classCallCheck(this, AlignmentToolbar);
28
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29
- args[_key] = arguments[_key];
30
- }
31
- _this = _super.call.apply(_super, [this].concat(args));
32
- _defineProperty(_assertThisInitialized(_this), "toolbarItemRef", /*#__PURE__*/React.createRef());
33
- _defineProperty(_assertThisInitialized(_this), "state", {
34
- isOpen: false
35
- });
36
- _defineProperty(_assertThisInitialized(_this), "changeAlignment", function (align, togglePopup) {
37
- if (togglePopup) {
38
- _this.toggleOpen();
39
- }
40
- return _this.props.changeAlignment(align);
41
- });
42
- _defineProperty(_assertThisInitialized(_this), "toggleOpen", function () {
43
- _this.setState({
44
- isOpen: !_this.state.isOpen
45
- });
46
- });
47
- _defineProperty(_assertThisInitialized(_this), "toggleOpenByKeyboard", function (event) {
48
- if (event.key === 'Enter' || event.key === ' ') {
49
- event.preventDefault();
50
- _this.setState({
51
- isOpen: !_this.state.isOpen
52
- });
53
- }
54
- });
55
- _defineProperty(_assertThisInitialized(_this), "hide", function (attrs) {
56
- if (_this.state.isOpen) {
57
- _this.setState({
58
- isOpen: false
59
- });
60
- if ((attrs === null || attrs === void 0 ? void 0 : attrs.event) instanceof KeyboardEvent && attrs.event.key === 'Escape') {
61
- var _this$toolbarItemRef;
62
- (_this$toolbarItemRef = _this.toolbarItemRef) === null || _this$toolbarItemRef === void 0 || (_this$toolbarItemRef = _this$toolbarItemRef.current) === null || _this$toolbarItemRef === void 0 || _this$toolbarItemRef.focus();
63
- }
64
- }
65
- });
66
- _defineProperty(_assertThisInitialized(_this), "hideOnEscape", function () {
67
- var _this$toolbarItemRef2;
68
- _this.hide();
69
- (_this$toolbarItemRef2 = _this.toolbarItemRef) === null || _this$toolbarItemRef2 === void 0 || (_this$toolbarItemRef2 = _this$toolbarItemRef2.current) === null || _this$toolbarItemRef2 === void 0 || _this$toolbarItemRef2.focus();
70
- });
71
- return _this;
72
- }
73
- _createClass(AlignmentToolbar, [{
74
- key: "render",
75
- value: function render() {
76
- var _this2 = this;
77
- var isOpen = this.state.isOpen;
78
- var _this$props = this.props,
79
- popupsMountPoint = _this$props.popupsMountPoint,
80
- popupsBoundariesElement = _this$props.popupsBoundariesElement,
81
- popupsScrollableElement = _this$props.popupsScrollableElement,
82
- isReducedSpacing = _this$props.isReducedSpacing,
83
- pluginState = _this$props.pluginState,
84
- disabled = _this$props.disabled,
85
- intl = _this$props.intl;
86
- var title = intl.formatMessage(messages.alignment);
87
- return jsx("span", {
88
- css: wrapper
89
- }, jsx(Dropdown, {
90
- mountTo: popupsMountPoint,
91
- boundariesElement: popupsBoundariesElement,
92
- scrollableElement: popupsScrollableElement,
93
- isOpen: isOpen,
94
- handleClickOutside: function handleClickOutside(event) {
95
- if (event instanceof MouseEvent) {
96
- _this2.hide({
97
- isOpen: false,
98
- event: event
99
- });
100
- }
101
- },
102
- handleEscapeKeydown: this.hideOnEscape,
103
- arrowKeyNavigationProviderOptions: {
104
- type: ArrowKeyNavigationType.MENU
105
- },
106
- fitWidth: 112,
107
- fitHeight: 80,
108
- closeOnTab: true,
109
- trigger: jsx(ToolbarButton, {
110
- spacing: isReducedSpacing ? 'none' : 'default',
111
- disabled: disabled,
112
- selected: isOpen,
113
- title: title,
114
- className: "align-btn",
115
- "aria-label": title,
116
- "aria-expanded": isOpen,
117
- "aria-haspopup": true,
118
- onClick: this.toggleOpen,
119
- onKeyDown: this.toggleOpenByKeyboard,
120
- iconBefore: jsx("div", {
121
- css: triggerWrapper
122
- }, jsx(IconMap, {
123
- alignment: pluginState.align
124
- }), jsx("span", {
125
- css: expandIconWrapper
126
- }, jsx(ExpandIcon, {
127
- label: ""
128
- }))),
129
- ref: this.toolbarItemRef
130
- })
131
- }, jsx(Alignment, {
132
- onClick: function onClick(align) {
133
- return _this2.changeAlignment(align, false);
134
- },
135
- selectedAlignment: pluginState.align
136
- })), jsx("span", {
137
- css: separatorStyles
138
- }));
139
- }
140
- }, {
141
- key: "componentDidUpdate",
142
- value: function componentDidUpdate(prevProps) {
143
- var _this3 = this;
144
- if (this.state.isOpen) {
145
- // by triggering the keyboard event with a setTimeout, we ensure that the tooltip
146
- // associated with the alignment button doesn't render until the next render cycle
147
- // where the popup will be correctly positioned and the relative position of the tooltip
148
- // will not overlap with the button.
149
- setTimeout(function () {
150
- var _this3$toolbarItemRef;
151
- var keyboardEvent = new KeyboardEvent('keydown', {
152
- bubbles: true,
153
- key: 'ArrowDown'
154
- });
155
- (_this3$toolbarItemRef = _this3.toolbarItemRef.current) === null || _this3$toolbarItemRef === void 0 || _this3$toolbarItemRef.dispatchEvent(keyboardEvent);
156
- }, 0);
157
- }
158
- }
159
- }]);
160
- return AlignmentToolbar;
161
- }(React.Component);
162
- _defineProperty(AlignmentToolbar, "displayName", 'AlignmentToolbar');
163
- export default injectIntl(AlignmentToolbar);
@@ -1,23 +0,0 @@
1
- import { defineMessages } from 'react-intl-next';
2
- export var 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,6 +0,0 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2, _templateObject3;
3
- import { css } from '@emotion/react';
4
- export var triggerWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n"])));
5
- export var wrapper = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n div {\n display: flex;\n }\n"])));
6
- export var expandIconWrapper = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n margin-left: ", ";\n"])), "var(--ds-space-negative-100, -8px)");
@@ -1,21 +0,0 @@
1
- import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
2
- import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
3
- export var getActiveAlignment = function getActiveAlignment(state) {
4
- if (state.selection instanceof CellSelection) {
5
- var marks = [];
6
- state.selection.forEachCell(function (cell) {
7
- var mark = cell.firstChild.marks.filter(function (mark) {
8
- return mark.type === state.schema.marks.alignment;
9
- })[0];
10
- marks.push(mark ? mark.attrs.align : 'start');
11
- });
12
- return marks.every(function (mark) {
13
- return mark === marks[0];
14
- }) ? marks[0] : 'start';
15
- }
16
- var node = findParentNodeOfType([state.schema.nodes.paragraph, state.schema.nodes.heading])(state.selection);
17
- var getMark = node && node.node.marks.filter(function (mark) {
18
- return mark.type === state.schema.marks.alignment;
19
- })[0];
20
- return getMark && getMark.attrs.align || 'start';
21
- };
@@ -1,6 +0,0 @@
1
- export var 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,20 +0,0 @@
1
- import { MobileDimensionsActionTypes } from './actions';
2
- import { createCommand } from './plugin-factory';
3
- export var setWindowHeight = function setWindowHeight(windowHeight) {
4
- return createCommand({
5
- type: MobileDimensionsActionTypes.SET_WINDOW_HEIGHT,
6
- windowHeight: windowHeight
7
- });
8
- };
9
- export var setMobilePaddingTop = function setMobilePaddingTop(paddingTop) {
10
- return createCommand({
11
- type: MobileDimensionsActionTypes.SET_MOBILE_PADDING_TOP,
12
- paddingTop: paddingTop
13
- });
14
- };
15
- export var setIsExpanded = function setIsExpanded(isExpanded) {
16
- return createCommand({
17
- type: MobileDimensionsActionTypes.SET_IS_EXPANDED,
18
- isExpanded: isExpanded
19
- });
20
- };
@@ -1,93 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { setWindowHeight } from './commands';
3
- import { createPluginState, mobileDimensionsPluginKey } from './plugin-factory';
4
- var getInitialState = function getInitialState() {
5
- return {
6
- mobilePaddingTop: 0,
7
- windowHeight: window.innerHeight,
8
- isExpanded: false
9
- };
10
- };
11
-
12
- /**
13
- * Plugin to store the dimensions of the mobile such as keyboard height and window size
14
- */
15
-
16
- var createPlugin = function createPlugin(dispatch) {
17
- var rafId;
18
- return new SafePlugin({
19
- state: createPluginState(dispatch, getInitialState),
20
- key: mobileDimensionsPluginKey,
21
- props: {
22
- scrollThreshold: {
23
- top: 12,
24
- left: 0,
25
- right: 0,
26
- bottom: 12
27
- },
28
- scrollMargin: {
29
- top: 12,
30
- bottom: 12,
31
- left: 0,
32
- right: 0
33
- }
34
- },
35
- view: function view(editorView) {
36
- var handleResize = function handleResize() {
37
- if (rafId) {
38
- window.cancelAnimationFrame(rafId);
39
- }
40
- var windowInnerHeight = window.innerHeight;
41
- var count = 0;
42
- var checkWindowHeight = function checkWindowHeight() {
43
- // wait for height to stabilise before we commit to set it
44
- // this helps handle menu transitions in Android which we don't want to scroll for
45
- if (window.innerHeight === windowInnerHeight) {
46
- count++;
47
- if (count >= 5) {
48
- rafId = undefined;
49
- setWindowHeight(window.innerHeight)(editorView.state, editorView.dispatch);
50
- } else {
51
- rafId = requestAnimationFrame(checkWindowHeight);
52
- }
53
- } else {
54
- rafId = requestAnimationFrame(checkWindowHeight);
55
- }
56
- windowInnerHeight = window.innerHeight;
57
- };
58
- rafId = requestAnimationFrame(checkWindowHeight);
59
- };
60
- // the window will resize on Android when the keyboard shows/hides
61
- window.addEventListener('resize', handleResize);
62
- return {
63
- destroy: function destroy() {
64
- window.removeEventListener('resize', handleResize);
65
- if (rafId) {
66
- window.cancelAnimationFrame(rafId);
67
- }
68
- }
69
- };
70
- }
71
- });
72
- };
73
- var mobileDimensionsPlugin = function mobileDimensionsPlugin() {
74
- return {
75
- name: 'mobileDimensions',
76
- getSharedState: function getSharedState(editorState) {
77
- if (!editorState) {
78
- return undefined;
79
- }
80
- return mobileDimensionsPluginKey.getState(editorState);
81
- },
82
- pmPlugins: function pmPlugins() {
83
- return [{
84
- name: 'mobileDimensions',
85
- plugin: function plugin(_ref) {
86
- var dispatch = _ref.dispatch;
87
- return createPlugin(dispatch);
88
- }
89
- }];
90
- }
91
- };
92
- };
93
- 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 var mobileDimensionsPluginKey = new PluginKey('mobileDimensions');
5
- var _pluginFactory = pluginFactory(mobileDimensionsPluginKey, reducer),
6
- createPluginState = _pluginFactory.createPluginState,
7
- getPluginState = _pluginFactory.getPluginState,
8
- createCommand = _pluginFactory.createCommand;
9
- export { createPluginState, getPluginState, createCommand };
@@ -1,21 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- import { MobileDimensionsActionTypes } from './actions';
5
- export default function (state, action) {
6
- switch (action.type) {
7
- case MobileDimensionsActionTypes.SET_WINDOW_HEIGHT:
8
- return _objectSpread(_objectSpread({}, state), {}, {
9
- windowHeight: action.windowHeight
10
- });
11
- case MobileDimensionsActionTypes.SET_MOBILE_PADDING_TOP:
12
- return _objectSpread(_objectSpread({}, state), {}, {
13
- mobilePaddingTop: action.paddingTop
14
- });
15
- case MobileDimensionsActionTypes.SET_IS_EXPANDED:
16
- return _objectSpread(_objectSpread({}, state), {}, {
17
- isExpanded: action.isExpanded
18
- });
19
- }
20
- return state;
21
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,18 +0,0 @@
1
- // Gets a plain text representation of the nodes in the current selection
2
- export var contentInSelection = function contentInSelection(_ref) {
3
- var selection = _ref.selection,
4
- doc = _ref.doc;
5
- var nodes = new Array();
6
- var marks = new Array();
7
- doc.nodesBetween(selection.from, selection.to, function (node) {
8
- nodes.push(node.type.name);
9
- node.marks.forEach(function (mark) {
10
- return marks.push(mark.type.name);
11
- });
12
- return true;
13
- });
14
- return {
15
- nodeTypes: Array.from(nodes),
16
- markTypes: Array.from(marks)
17
- };
18
- };
@@ -1 +0,0 @@
1
- export { mobileSelectionPlugin as default, selectionPluginKey } from './mobile-selection-plugin';