@atlaskit/editor-plugin-alignment 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/.eslintrc.js +18 -0
  2. package/CHANGELOG.md +1 -0
  3. package/LICENSE.md +13 -0
  4. package/README.md +30 -0
  5. package/dist/cjs/commands/index.js +62 -0
  6. package/dist/cjs/index.js +12 -0
  7. package/dist/cjs/plugin.js +69 -0
  8. package/dist/cjs/pm-plugins/keymap.js +14 -0
  9. package/dist/cjs/pm-plugins/main.js +45 -0
  10. package/dist/cjs/pm-plugins/types.js +5 -0
  11. package/dist/cjs/ui/Alignment/AlignmentButton/index.js +38 -0
  12. package/dist/cjs/ui/Alignment/index.js +57 -0
  13. package/dist/cjs/ui/Alignment/styles.js +11 -0
  14. package/dist/cjs/ui/ToolbarAlignment/icon-map.js +36 -0
  15. package/dist/cjs/ui/ToolbarAlignment/index.js +174 -0
  16. package/dist/cjs/ui/ToolbarAlignment/messages.js +29 -0
  17. package/dist/cjs/ui/ToolbarAlignment/styles.js +13 -0
  18. package/dist/cjs/utils/index.js +27 -0
  19. package/dist/es2019/commands/index.js +56 -0
  20. package/dist/es2019/index.js +1 -0
  21. package/dist/es2019/plugin.js +57 -0
  22. package/dist/es2019/pm-plugins/keymap.js +8 -0
  23. package/dist/es2019/pm-plugins/main.js +34 -0
  24. package/dist/es2019/pm-plugins/types.js +1 -0
  25. package/dist/es2019/ui/Alignment/AlignmentButton/index.js +32 -0
  26. package/dist/es2019/ui/Alignment/index.js +52 -0
  27. package/dist/es2019/ui/Alignment/styles.js +7 -0
  28. package/dist/es2019/ui/ToolbarAlignment/icon-map.js +30 -0
  29. package/dist/es2019/ui/ToolbarAlignment/index.js +145 -0
  30. package/dist/es2019/ui/ToolbarAlignment/messages.js +23 -0
  31. package/dist/es2019/ui/ToolbarAlignment/styles.js +14 -0
  32. package/dist/es2019/utils/index.js +15 -0
  33. package/dist/esm/commands/index.js +56 -0
  34. package/dist/esm/index.js +1 -0
  35. package/dist/esm/plugin.js +62 -0
  36. package/dist/esm/pm-plugins/keymap.js +8 -0
  37. package/dist/esm/pm-plugins/main.js +36 -0
  38. package/dist/esm/pm-plugins/types.js +1 -0
  39. package/dist/esm/ui/Alignment/AlignmentButton/index.js +31 -0
  40. package/dist/esm/ui/Alignment/index.js +49 -0
  41. package/dist/esm/ui/Alignment/styles.js +4 -0
  42. package/dist/esm/ui/ToolbarAlignment/icon-map.js +29 -0
  43. package/dist/esm/ui/ToolbarAlignment/index.js +168 -0
  44. package/dist/esm/ui/ToolbarAlignment/messages.js +23 -0
  45. package/dist/esm/ui/ToolbarAlignment/styles.js +6 -0
  46. package/dist/esm/utils/index.js +21 -0
  47. package/dist/types/commands/index.d.ts +4 -0
  48. package/dist/types/index.d.ts +2 -0
  49. package/dist/types/plugin.d.ts +5 -0
  50. package/dist/types/pm-plugins/keymap.d.ts +2 -0
  51. package/dist/types/pm-plugins/main.d.ts +8 -0
  52. package/dist/types/pm-plugins/types.d.ts +5 -0
  53. package/dist/types/ui/Alignment/AlignmentButton/index.d.ts +13 -0
  54. package/dist/types/ui/Alignment/index.d.ts +12 -0
  55. package/dist/types/ui/Alignment/styles.d.ts +1 -0
  56. package/dist/types/ui/ToolbarAlignment/icon-map.d.ts +6 -0
  57. package/dist/types/ui/ToolbarAlignment/index.d.ts +33 -0
  58. package/dist/types/ui/ToolbarAlignment/messages.d.ts +22 -0
  59. package/dist/types/ui/ToolbarAlignment/styles.d.ts +3 -0
  60. package/dist/types/utils/index.d.ts +3 -0
  61. package/dist/types-ts4.5/commands/index.d.ts +4 -0
  62. package/dist/types-ts4.5/index.d.ts +2 -0
  63. package/dist/types-ts4.5/plugin.d.ts +5 -0
  64. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -0
  65. package/dist/types-ts4.5/pm-plugins/main.d.ts +8 -0
  66. package/dist/types-ts4.5/pm-plugins/types.d.ts +5 -0
  67. package/dist/types-ts4.5/ui/Alignment/AlignmentButton/index.d.ts +13 -0
  68. package/dist/types-ts4.5/ui/Alignment/index.d.ts +12 -0
  69. package/dist/types-ts4.5/ui/Alignment/styles.d.ts +1 -0
  70. package/dist/types-ts4.5/ui/ToolbarAlignment/icon-map.d.ts +6 -0
  71. package/dist/types-ts4.5/ui/ToolbarAlignment/index.d.ts +33 -0
  72. package/dist/types-ts4.5/ui/ToolbarAlignment/messages.d.ts +22 -0
  73. package/dist/types-ts4.5/ui/ToolbarAlignment/styles.d.ts +3 -0
  74. package/dist/types-ts4.5/utils/index.d.ts +3 -0
  75. package/package.json +96 -0
@@ -0,0 +1,36 @@
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(_, 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
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { getAriaKeyshortcuts, tooltip, ToolTipContent } from '@atlaskit/editor-common/keymaps';
3
+ import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
4
+ function AlignmentButton(_ref) {
5
+ var label = _ref.label,
6
+ isSelected = _ref.isSelected,
7
+ content = _ref.content,
8
+ shortcut = _ref.shortcut,
9
+ onClick = _ref.onClick,
10
+ value = _ref.value;
11
+ var onClickCallback = function onClickCallback(e) {
12
+ // detect if the click event comes from keyboard where screenX and screenY are 0
13
+ var isMouseEvent = e instanceof MouseEvent;
14
+ e.preventDefault();
15
+ onClick(value, isMouseEvent);
16
+ };
17
+ return /*#__PURE__*/React.createElement(ToolbarButton, {
18
+ disabled: false,
19
+ selected: isSelected,
20
+ title: /*#__PURE__*/React.createElement(ToolTipContent, {
21
+ description: label,
22
+ keymap: shortcut
23
+ }),
24
+ "aria-label": shortcut ? tooltip(shortcut, label) : label,
25
+ "aria-pressed": isSelected,
26
+ "aria-keyshortcuts": getAriaKeyshortcuts(shortcut),
27
+ onClick: onClickCallback,
28
+ iconBefore: content
29
+ });
30
+ }
31
+ export default AlignmentButton;
@@ -0,0 +1,49 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import { injectIntl } from 'react-intl-next';
4
+ import { alignLeft } from '@atlaskit/editor-common/keymaps';
5
+ import { alignmentMessages } from '@atlaskit/editor-common/messages';
6
+ import { IconMap } from '../ToolbarAlignment/icon-map';
7
+ import AlignmentButton from './AlignmentButton';
8
+ import { alignmentWrapper } from './styles';
9
+ var alignmentOptions = [{
10
+ title: alignmentMessages.alignLeft,
11
+ shortcut: alignLeft,
12
+ value: 'start'
13
+ }, {
14
+ title: alignmentMessages.alignCenter,
15
+ value: 'center'
16
+ }, {
17
+ title: alignmentMessages.alignRight,
18
+ value: 'end'
19
+ }];
20
+ function Alignment(_ref) {
21
+ var onClick = _ref.onClick,
22
+ selectedAlignment = _ref.selectedAlignment,
23
+ className = _ref.className,
24
+ intl = _ref.intl;
25
+ return jsx("div", {
26
+ "data-testid": "alignment-buttons"
27
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
28
+ ,
29
+ css: alignmentWrapper,
30
+ className: className
31
+ }, alignmentOptions.map(function (alignment) {
32
+ var value = alignment.value,
33
+ title = alignment.title,
34
+ shortcut = alignment.shortcut;
35
+ var message = intl.formatMessage(title);
36
+ return jsx(AlignmentButton, {
37
+ content: jsx(IconMap, {
38
+ alignment: value
39
+ }),
40
+ key: value,
41
+ value: value,
42
+ label: message,
43
+ shortcut: shortcut,
44
+ onClick: onClick,
45
+ isSelected: value === selectedAlignment
46
+ });
47
+ }));
48
+ }
49
+ export default injectIntl(Alignment);
@@ -0,0 +1,4 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ var _templateObject;
3
+ import { css } from '@emotion/react';
4
+ export var alignmentWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 0 ", ";\n display: flex;\n flex-wrap: wrap;\n max-width: ", "px;\n"])), "var(--ds-space-100, 8px)", 3 * 32);
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { useIntl } from 'react-intl-next';
3
+ import EditorAlignCenterIcon from '@atlaskit/icon/glyph/editor/align-center';
4
+ import EditorAlignLeftIcon from '@atlaskit/icon/glyph/editor/align-left';
5
+ import EditorAlignRightIcon from '@atlaskit/icon/glyph/editor/align-right';
6
+ import { messages } from './messages';
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
+ };
@@ -0,0 +1,168 @@
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 { separatorStyles } from '@atlaskit/editor-common/styles';
15
+ import { ArrowKeyNavigationType, DropdownContainer as Dropdown, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
16
+ import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
17
+ import Alignment from '../Alignment';
18
+ import { IconMap } from './icon-map';
19
+ import { messages } from './messages';
20
+ import { expandIconWrapper, triggerWrapper, wrapper } from './styles';
21
+ // eslint-disable-next-line @repo/internal/react/no-class-components
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 (
88
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
89
+ jsx("span", {
90
+ css: wrapper
91
+ }, jsx(Dropdown, {
92
+ mountTo: popupsMountPoint,
93
+ boundariesElement: popupsBoundariesElement,
94
+ scrollableElement: popupsScrollableElement,
95
+ isOpen: isOpen,
96
+ handleClickOutside: function handleClickOutside(event) {
97
+ if (event instanceof MouseEvent) {
98
+ _this2.hide({
99
+ isOpen: false,
100
+ event: event
101
+ });
102
+ }
103
+ },
104
+ handleEscapeKeydown: this.hideOnEscape,
105
+ arrowKeyNavigationProviderOptions: {
106
+ type: ArrowKeyNavigationType.MENU
107
+ },
108
+ fitWidth: 112,
109
+ fitHeight: 80,
110
+ closeOnTab: true,
111
+ trigger: jsx(ToolbarButton, {
112
+ spacing: isReducedSpacing ? 'none' : 'default',
113
+ disabled: disabled,
114
+ selected: isOpen,
115
+ title: title,
116
+ className: "align-btn",
117
+ "aria-label": title,
118
+ "aria-expanded": isOpen,
119
+ "aria-haspopup": true,
120
+ onClick: this.toggleOpen,
121
+ onKeyDown: this.toggleOpenByKeyboard,
122
+ iconBefore:
123
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
124
+ jsx("div", {
125
+ css: triggerWrapper
126
+ }, jsx(IconMap, {
127
+ alignment: pluginState.align
128
+ }), jsx("span", {
129
+ css: expandIconWrapper
130
+ }, jsx(ExpandIcon, {
131
+ label: ""
132
+ }))),
133
+ ref: this.toolbarItemRef
134
+ })
135
+ }, jsx(Alignment, {
136
+ onClick: function onClick(align) {
137
+ return _this2.changeAlignment(align, false);
138
+ },
139
+ selectedAlignment: pluginState.align
140
+ })), jsx("span", {
141
+ css: separatorStyles
142
+ }))
143
+ );
144
+ }
145
+ }, {
146
+ key: "componentDidUpdate",
147
+ value: function componentDidUpdate(prevProps) {
148
+ var _this3 = this;
149
+ if (this.state.isOpen) {
150
+ // by triggering the keyboard event with a setTimeout, we ensure that the tooltip
151
+ // associated with the alignment button doesn't render until the next render cycle
152
+ // where the popup will be correctly positioned and the relative position of the tooltip
153
+ // will not overlap with the button.
154
+ setTimeout(function () {
155
+ var _this3$toolbarItemRef;
156
+ var keyboardEvent = new KeyboardEvent('keydown', {
157
+ bubbles: true,
158
+ key: 'ArrowDown'
159
+ });
160
+ (_this3$toolbarItemRef = _this3.toolbarItemRef.current) === null || _this3$toolbarItemRef === void 0 || _this3$toolbarItemRef.dispatchEvent(keyboardEvent);
161
+ }, 0);
162
+ }
163
+ }
164
+ }]);
165
+ return AlignmentToolbar;
166
+ }(React.Component);
167
+ _defineProperty(AlignmentToolbar, "displayName", 'AlignmentToolbar');
168
+ export default injectIntl(AlignmentToolbar);
@@ -0,0 +1,23 @@
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
+ });
@@ -0,0 +1,6 @@
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)");
@@ -0,0 +1,21 @@
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
+ };
@@ -0,0 +1,4 @@
1
+ import type { Command } from '@atlaskit/editor-common/types';
2
+ import type { AlignmentState } from '../pm-plugins/types';
3
+ export declare const isAlignable: (align?: AlignmentState) => Command;
4
+ export declare const changeAlignment: (align?: AlignmentState) => Command;
@@ -0,0 +1,2 @@
1
+ export { alignmentPlugin } from './plugin';
2
+ export type { AlignmentPlugin } from './plugin';
@@ -0,0 +1,5 @@
1
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+ import type { AlignmentPluginState } from './pm-plugins/types';
3
+ export declare const defaultConfig: AlignmentPluginState;
4
+ export type AlignmentPlugin = NextEditorPlugin<'alignment'>;
5
+ export declare const alignmentPlugin: AlignmentPlugin;
@@ -0,0 +1,2 @@
1
+ import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ export declare function keymapPlugin(): SafePlugin;
@@ -0,0 +1,8 @@
1
+ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
+ import type { AlignmentPluginState } from './types';
6
+ export declare function createInitialPluginState(editorState: EditorState, pluginConfig: AlignmentPluginState): AlignmentPluginState;
7
+ export declare const pluginKey: PluginKey<AlignmentPluginState>;
8
+ export declare function createPlugin(dispatch: Dispatch, pluginConfig: AlignmentPluginState): SafePlugin<AlignmentPluginState>;
@@ -0,0 +1,5 @@
1
+ export type AlignmentState = 'start' | 'end' | 'center';
2
+ export type AlignmentPluginState = {
3
+ align: AlignmentState;
4
+ isEnabled?: boolean;
5
+ };
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { Keymap } from '@atlaskit/editor-common/keymaps';
3
+ import type { AlignmentState } from '../../../pm-plugins/types';
4
+ export interface Props {
5
+ value: AlignmentState;
6
+ label: string;
7
+ isSelected?: boolean;
8
+ onClick: (value: AlignmentState, shouldClosePopup: boolean) => void;
9
+ content: React.ReactElement;
10
+ shortcut?: Keymap;
11
+ }
12
+ declare function AlignmentButton({ label, isSelected, content, shortcut, onClick, value, }: Props): JSX.Element;
13
+ export default AlignmentButton;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { AlignmentState } from '../../pm-plugins/types';
4
+ export interface Props {
5
+ selectedAlignment?: string;
6
+ onClick: (value: AlignmentState) => void;
7
+ className?: string;
8
+ }
9
+ declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
10
+ WrappedComponent: import("react").ComponentType<Props & WrappedComponentProps<"intl">>;
11
+ };
12
+ export default _default;
@@ -0,0 +1 @@
1
+ export declare const alignmentWrapper: import("@emotion/react").SerializedStyles;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ type Props = {
3
+ alignment: string;
4
+ };
5
+ export declare const IconMap: (props: Props) => JSX.Element;
6
+ export {};
@@ -0,0 +1,33 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { jsx } from '@emotion/react';
4
+ import type { WrappedComponentProps } from 'react-intl-next';
5
+ import type { AlignmentPluginState, AlignmentState } from '../../pm-plugins/types';
6
+ export interface State {
7
+ isOpen: boolean;
8
+ }
9
+ export interface Props {
10
+ pluginState: AlignmentPluginState;
11
+ changeAlignment: (align: AlignmentState) => void;
12
+ popupsMountPoint?: HTMLElement;
13
+ popupsBoundariesElement?: HTMLElement;
14
+ popupsScrollableElement?: HTMLElement;
15
+ isReducedSpacing?: boolean;
16
+ disabled?: boolean;
17
+ }
18
+ export declare class AlignmentToolbar extends React.Component<Props & WrappedComponentProps, State> {
19
+ static displayName: string;
20
+ private toolbarItemRef;
21
+ state: State;
22
+ render(): jsx.JSX.Element;
23
+ componentDidUpdate(prevProps: Props): void;
24
+ private changeAlignment;
25
+ private toggleOpen;
26
+ private toggleOpenByKeyboard;
27
+ private hide;
28
+ private hideOnEscape;
29
+ }
30
+ declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
31
+ WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
32
+ };
33
+ export default _default;
@@ -0,0 +1,22 @@
1
+ export declare const messages: {
2
+ alignment: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ alignLeft: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
12
+ alignRight: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ description: string;
16
+ };
17
+ alignCenter: {
18
+ id: string;
19
+ defaultMessage: string;
20
+ description: string;
21
+ };
22
+ };
@@ -0,0 +1,3 @@
1
+ export declare const triggerWrapper: import("@emotion/react").SerializedStyles;
2
+ export declare const wrapper: import("@emotion/react").SerializedStyles;
3
+ export declare const expandIconWrapper: import("@emotion/react").SerializedStyles;
@@ -0,0 +1,3 @@
1
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
+ import type { AlignmentState } from '../pm-plugins/types';
3
+ export declare const getActiveAlignment: (state: EditorState) => AlignmentState | undefined;
@@ -0,0 +1,4 @@
1
+ import type { Command } from '@atlaskit/editor-common/types';
2
+ import type { AlignmentState } from '../pm-plugins/types';
3
+ export declare const isAlignable: (align?: AlignmentState) => Command;
4
+ export declare const changeAlignment: (align?: AlignmentState) => Command;
@@ -0,0 +1,2 @@
1
+ export { alignmentPlugin } from './plugin';
2
+ export type { AlignmentPlugin } from './plugin';
@@ -0,0 +1,5 @@
1
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+ import type { AlignmentPluginState } from './pm-plugins/types';
3
+ export declare const defaultConfig: AlignmentPluginState;
4
+ export type AlignmentPlugin = NextEditorPlugin<'alignment'>;
5
+ export declare const alignmentPlugin: AlignmentPlugin;
@@ -0,0 +1,2 @@
1
+ import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ export declare function keymapPlugin(): SafePlugin;
@@ -0,0 +1,8 @@
1
+ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
+ import type { AlignmentPluginState } from './types';
6
+ export declare function createInitialPluginState(editorState: EditorState, pluginConfig: AlignmentPluginState): AlignmentPluginState;
7
+ export declare const pluginKey: PluginKey<AlignmentPluginState>;
8
+ export declare function createPlugin(dispatch: Dispatch, pluginConfig: AlignmentPluginState): SafePlugin<AlignmentPluginState>;
@@ -0,0 +1,5 @@
1
+ export type AlignmentState = 'start' | 'end' | 'center';
2
+ export type AlignmentPluginState = {
3
+ align: AlignmentState;
4
+ isEnabled?: boolean;
5
+ };
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { Keymap } from '@atlaskit/editor-common/keymaps';
3
+ import type { AlignmentState } from '../../../pm-plugins/types';
4
+ export interface Props {
5
+ value: AlignmentState;
6
+ label: string;
7
+ isSelected?: boolean;
8
+ onClick: (value: AlignmentState, shouldClosePopup: boolean) => void;
9
+ content: React.ReactElement;
10
+ shortcut?: Keymap;
11
+ }
12
+ declare function AlignmentButton({ label, isSelected, content, shortcut, onClick, value, }: Props): JSX.Element;
13
+ export default AlignmentButton;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { AlignmentState } from '../../pm-plugins/types';
4
+ export interface Props {
5
+ selectedAlignment?: string;
6
+ onClick: (value: AlignmentState) => void;
7
+ className?: string;
8
+ }
9
+ declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
10
+ WrappedComponent: import("react").ComponentType<Props & WrappedComponentProps<"intl">>;
11
+ };
12
+ export default _default;
@@ -0,0 +1 @@
1
+ export declare const alignmentWrapper: import("@emotion/react").SerializedStyles;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ type Props = {
3
+ alignment: string;
4
+ };
5
+ export declare const IconMap: (props: Props) => JSX.Element;
6
+ export {};
@@ -0,0 +1,33 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { jsx } from '@emotion/react';
4
+ import type { WrappedComponentProps } from 'react-intl-next';
5
+ import type { AlignmentPluginState, AlignmentState } from '../../pm-plugins/types';
6
+ export interface State {
7
+ isOpen: boolean;
8
+ }
9
+ export interface Props {
10
+ pluginState: AlignmentPluginState;
11
+ changeAlignment: (align: AlignmentState) => void;
12
+ popupsMountPoint?: HTMLElement;
13
+ popupsBoundariesElement?: HTMLElement;
14
+ popupsScrollableElement?: HTMLElement;
15
+ isReducedSpacing?: boolean;
16
+ disabled?: boolean;
17
+ }
18
+ export declare class AlignmentToolbar extends React.Component<Props & WrappedComponentProps, State> {
19
+ static displayName: string;
20
+ private toolbarItemRef;
21
+ state: State;
22
+ render(): jsx.JSX.Element;
23
+ componentDidUpdate(prevProps: Props): void;
24
+ private changeAlignment;
25
+ private toggleOpen;
26
+ private toggleOpenByKeyboard;
27
+ private hide;
28
+ private hideOnEscape;
29
+ }
30
+ declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
31
+ WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
32
+ };
33
+ export default _default;