@atlaskit/editor-plugin-block-type 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/.eslintrc.js +14 -0
  2. package/CHANGELOG.md +1 -0
  3. package/LICENSE.md +13 -0
  4. package/README.md +32 -0
  5. package/consts/package.json +15 -0
  6. package/dist/cjs/consts.js +66 -0
  7. package/dist/cjs/index.js +12 -0
  8. package/dist/cjs/messages.js +19 -0
  9. package/dist/cjs/plugin/block-types.js +106 -0
  10. package/dist/cjs/plugin/commands/block-type.js +183 -0
  11. package/dist/cjs/plugin/commands/delete-and-move-cursor.js +56 -0
  12. package/dist/cjs/plugin/commands/delete-block-content.js +45 -0
  13. package/dist/cjs/plugin/commands/index.js +69 -0
  14. package/dist/cjs/plugin/consts.js +15 -0
  15. package/dist/cjs/plugin/index.js +217 -0
  16. package/dist/cjs/plugin/messages.js +160 -0
  17. package/dist/cjs/plugin/pm-plugins/input-rule.js +104 -0
  18. package/dist/cjs/plugin/pm-plugins/keymap.js +34 -0
  19. package/dist/cjs/plugin/pm-plugins/main.js +151 -0
  20. package/dist/cjs/plugin/styles.js +15 -0
  21. package/dist/cjs/plugin/types.js +5 -0
  22. package/dist/cjs/plugin/ui/ToolbarBlockType/blocktype-button.js +60 -0
  23. package/dist/cjs/plugin/ui/ToolbarBlockType/index.js +208 -0
  24. package/dist/cjs/plugin/ui/ToolbarBlockType/styled.js +34 -0
  25. package/dist/cjs/plugin/ui/ToolbarBlockType/toolbar-messages.js +15 -0
  26. package/dist/cjs/plugin/utils.js +87 -0
  27. package/dist/cjs/styles.js +12 -0
  28. package/dist/es2019/consts.js +1 -0
  29. package/dist/es2019/index.js +1 -0
  30. package/dist/es2019/messages.js +2 -0
  31. package/dist/es2019/plugin/block-types.js +84 -0
  32. package/dist/es2019/plugin/commands/block-type.js +170 -0
  33. package/dist/es2019/plugin/commands/delete-and-move-cursor.js +55 -0
  34. package/dist/es2019/plugin/commands/delete-block-content.js +42 -0
  35. package/dist/es2019/plugin/commands/index.js +8 -0
  36. package/dist/es2019/plugin/consts.js +8 -0
  37. package/dist/es2019/plugin/index.js +204 -0
  38. package/dist/es2019/plugin/messages.js +153 -0
  39. package/dist/es2019/plugin/pm-plugins/input-rule.js +93 -0
  40. package/dist/es2019/plugin/pm-plugins/keymap.js +25 -0
  41. package/dist/es2019/plugin/pm-plugins/main.js +137 -0
  42. package/dist/es2019/plugin/styles.js +8 -0
  43. package/dist/es2019/plugin/types.js +1 -0
  44. package/dist/es2019/plugin/ui/ToolbarBlockType/blocktype-button.js +50 -0
  45. package/dist/es2019/plugin/ui/ToolbarBlockType/index.js +185 -0
  46. package/dist/es2019/plugin/ui/ToolbarBlockType/styled.js +49 -0
  47. package/dist/es2019/plugin/ui/ToolbarBlockType/toolbar-messages.js +8 -0
  48. package/dist/es2019/plugin/utils.js +76 -0
  49. package/dist/es2019/styles.js +1 -0
  50. package/dist/esm/consts.js +1 -0
  51. package/dist/esm/index.js +1 -0
  52. package/dist/esm/messages.js +2 -0
  53. package/dist/esm/plugin/block-types.js +84 -0
  54. package/dist/esm/plugin/commands/block-type.js +169 -0
  55. package/dist/esm/plugin/commands/delete-and-move-cursor.js +50 -0
  56. package/dist/esm/plugin/commands/delete-block-content.js +39 -0
  57. package/dist/esm/plugin/commands/index.js +8 -0
  58. package/dist/esm/plugin/consts.js +8 -0
  59. package/dist/esm/plugin/index.js +205 -0
  60. package/dist/esm/plugin/messages.js +153 -0
  61. package/dist/esm/plugin/pm-plugins/input-rule.js +96 -0
  62. package/dist/esm/plugin/pm-plugins/keymap.js +25 -0
  63. package/dist/esm/plugin/pm-plugins/main.js +142 -0
  64. package/dist/esm/plugin/styles.js +7 -0
  65. package/dist/esm/plugin/types.js +1 -0
  66. package/dist/esm/plugin/ui/ToolbarBlockType/blocktype-button.js +50 -0
  67. package/dist/esm/plugin/ui/ToolbarBlockType/index.js +201 -0
  68. package/dist/esm/plugin/ui/ToolbarBlockType/styled.js +20 -0
  69. package/dist/esm/plugin/ui/ToolbarBlockType/toolbar-messages.js +8 -0
  70. package/dist/esm/plugin/utils.js +77 -0
  71. package/dist/esm/styles.js +1 -0
  72. package/dist/types/consts.d.ts +1 -0
  73. package/dist/types/index.d.ts +6 -0
  74. package/dist/types/messages.d.ts +2 -0
  75. package/dist/types/plugin/block-types.d.ts +19 -0
  76. package/dist/types/plugin/commands/block-type.d.ts +18 -0
  77. package/dist/types/plugin/commands/delete-and-move-cursor.d.ts +12 -0
  78. package/dist/types/plugin/commands/delete-block-content.d.ts +10 -0
  79. package/dist/types/plugin/commands/index.d.ts +9 -0
  80. package/dist/types/plugin/consts.d.ts +1 -0
  81. package/dist/types/plugin/index.d.ts +18 -0
  82. package/dist/types/plugin/messages.d.ts +152 -0
  83. package/dist/types/plugin/pm-plugins/input-rule.d.ts +6 -0
  84. package/dist/types/plugin/pm-plugins/keymap.d.ts +5 -0
  85. package/dist/types/plugin/pm-plugins/main.d.ts +17 -0
  86. package/dist/types/plugin/styles.d.ts +2 -0
  87. package/dist/types/plugin/types.d.ts +22 -0
  88. package/dist/types/plugin/ui/ToolbarBlockType/blocktype-button.d.ts +22 -0
  89. package/dist/types/plugin/ui/ToolbarBlockType/index.d.ts +29 -0
  90. package/dist/types/plugin/ui/ToolbarBlockType/styled.d.ts +8 -0
  91. package/dist/types/plugin/ui/ToolbarBlockType/toolbar-messages.d.ts +7 -0
  92. package/dist/types/plugin/utils.d.ts +16 -0
  93. package/dist/types/styles.d.ts +1 -0
  94. package/dist/types-ts4.5/consts.d.ts +1 -0
  95. package/dist/types-ts4.5/index.d.ts +6 -0
  96. package/dist/types-ts4.5/messages.d.ts +2 -0
  97. package/dist/types-ts4.5/plugin/block-types.d.ts +19 -0
  98. package/dist/types-ts4.5/plugin/commands/block-type.d.ts +18 -0
  99. package/dist/types-ts4.5/plugin/commands/delete-and-move-cursor.d.ts +12 -0
  100. package/dist/types-ts4.5/plugin/commands/delete-block-content.d.ts +10 -0
  101. package/dist/types-ts4.5/plugin/commands/index.d.ts +9 -0
  102. package/dist/types-ts4.5/plugin/consts.d.ts +1 -0
  103. package/dist/types-ts4.5/plugin/index.d.ts +20 -0
  104. package/dist/types-ts4.5/plugin/messages.d.ts +152 -0
  105. package/dist/types-ts4.5/plugin/pm-plugins/input-rule.d.ts +6 -0
  106. package/dist/types-ts4.5/plugin/pm-plugins/keymap.d.ts +5 -0
  107. package/dist/types-ts4.5/plugin/pm-plugins/main.d.ts +17 -0
  108. package/dist/types-ts4.5/plugin/styles.d.ts +2 -0
  109. package/dist/types-ts4.5/plugin/types.d.ts +22 -0
  110. package/dist/types-ts4.5/plugin/ui/ToolbarBlockType/blocktype-button.d.ts +22 -0
  111. package/dist/types-ts4.5/plugin/ui/ToolbarBlockType/index.d.ts +29 -0
  112. package/dist/types-ts4.5/plugin/ui/ToolbarBlockType/styled.d.ts +8 -0
  113. package/dist/types-ts4.5/plugin/ui/ToolbarBlockType/toolbar-messages.d.ts +7 -0
  114. package/dist/types-ts4.5/plugin/utils.d.ts +16 -0
  115. package/dist/types-ts4.5/styles.d.ts +1 -0
  116. package/messages/package.json +15 -0
  117. package/package.json +105 -0
  118. package/report.api.md +108 -0
  119. package/styles/package.json +15 -0
  120. package/tmp/api-report-tmp.d.ts +75 -0
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.blocktypeStyles = void 0;
8
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
+ var _react = require("@emotion/react");
10
+ var _styles = require("@atlaskit/editor-common/styles");
11
+ var _templateObject;
12
+ var blocktypeStyles = function blocktypeStyles(props) {
13
+ return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .ProseMirror {\n ", ";\n ", ";\n }\n"])), _styles.blockquoteSharedStyles, (0, _styles.headingsSharedStyles)(props));
14
+ };
15
+ exports.blocktypeStyles = blocktypeStyles;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.messages = exports.BlockTypeButton = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _react2 = require("@emotion/react");
10
+ var _reactIntlNext = require("react-intl-next");
11
+ var _styles = require("@atlaskit/editor-common/styles");
12
+ var _uiMenu = require("@atlaskit/editor-common/ui-menu");
13
+ var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-down"));
14
+ var _textStyle = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/text-style"));
15
+ var _blockTypes = require("../../block-types");
16
+ var _styled = require("./styled");
17
+ /** @jsx jsx */
18
+
19
+ var messages = (0, _reactIntlNext.defineMessages)({
20
+ textStyles: {
21
+ id: 'fabric.editor.textStyles',
22
+ defaultMessage: 'Text styles',
23
+ description: 'Menu provides access to various heading styles or normal text'
24
+ }
25
+ });
26
+ exports.messages = messages;
27
+ var BlockTypeButton = function BlockTypeButton(props) {
28
+ var labelTextStyles = props.formatMessage(messages.textStyles);
29
+ return (0, _react2.jsx)(_uiMenu.ToolbarButton, {
30
+ spacing: props.isReducedSpacing ? 'none' : 'default',
31
+ selected: props.selected,
32
+ className: "block-type-btn",
33
+ disabled: props.disabled,
34
+ onClick: props.onClick,
35
+ onKeyDown: props.onKeyDown,
36
+ title: labelTextStyles,
37
+ "aria-label": labelTextStyles,
38
+ "aria-haspopup": true,
39
+ "aria-expanded": props['aria-expanded'],
40
+ iconAfter: (0, _react2.jsx)("span", {
41
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
42
+ css: [_styles.wrapperStyle, props.isSmall && _styled.wrapperSmallStyle],
43
+ "data-testid": "toolbar-block-type-text-styles-icon"
44
+ }, props.isSmall && (0, _react2.jsx)(_textStyle.default, {
45
+ label: labelTextStyles
46
+ }), (0, _react2.jsx)("span", {
47
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
48
+ css: _styled.expandIconWrapperStyle
49
+ }, (0, _react2.jsx)(_chevronDown.default, {
50
+ label: ""
51
+ })))
52
+ }, !props.isSmall && (0, _react2.jsx)("span", {
53
+ css: [
54
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
55
+ _styled.buttonContentStyle,
56
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
57
+ props.isReducedSpacing && _styled.buttonContentReducedSpacingStyle]
58
+ }, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, props.title || _blockTypes.NORMAL_TEXT.title)));
59
+ };
60
+ exports.BlockTypeButton = BlockTypeButton;
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
11
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+ var _react = _interopRequireDefault(require("react"));
16
+ var _react2 = require("@emotion/react");
17
+ var _reactIntlNext = require("react-intl-next");
18
+ var _keymaps = require("@atlaskit/editor-common/keymaps");
19
+ var _styles = require("@atlaskit/editor-common/styles");
20
+ var _uiMenu = require("@atlaskit/editor-common/ui-menu");
21
+ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
22
+ var _blocktypeButton = require("./blocktype-button");
23
+ var _styled = require("./styled");
24
+ 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; }
25
+ 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) { (0, _defineProperty2.default)(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; }
26
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
27
+ 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; } } /** @jsx jsx */
28
+ // eslint-disable-next-line @repo/internal/react/no-class-components
29
+ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
30
+ (0, _inherits2.default)(ToolbarBlockType, _React$PureComponent);
31
+ var _super = _createSuper(ToolbarBlockType);
32
+ function ToolbarBlockType() {
33
+ var _this;
34
+ (0, _classCallCheck2.default)(this, ToolbarBlockType);
35
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
36
+ args[_key] = arguments[_key];
37
+ }
38
+ _this = _super.call.apply(_super, [this].concat(args));
39
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
40
+ active: false,
41
+ isOpenedByKeyboard: false
42
+ });
43
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onOpenChange", function (attrs) {
45
+ _this.setState(_objectSpread(_objectSpread({}, _this.state), {}, {
46
+ active: attrs.isOpen,
47
+ isOpenedByKeyboard: attrs.isOpenedByKeyboard
48
+ }));
49
+ });
50
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleTriggerClick", function () {
51
+ _this.onOpenChange({
52
+ isOpen: !_this.state.active,
53
+ isOpenedByKeyboard: false
54
+ });
55
+ });
56
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleTriggerByKeyboard", function (event) {
57
+ if (event.key === 'Enter' || event.key === ' ') {
58
+ event.preventDefault();
59
+ _this.onOpenChange({
60
+ isOpen: !_this.state.active,
61
+ isOpenedByKeyboard: true
62
+ });
63
+ }
64
+ });
65
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "createItems", function () {
66
+ var formatMessage = _this.props.intl.formatMessage;
67
+ var _this$props$pluginSta = _this.props.pluginState,
68
+ currentBlockType = _this$props$pluginSta.currentBlockType,
69
+ availableBlockTypes = _this$props$pluginSta.availableBlockTypes;
70
+ var items = availableBlockTypes.map(function (blockType, index) {
71
+ var isActive = currentBlockType === blockType;
72
+ var tagName = blockType.tagName || 'p';
73
+ var Tag = tagName;
74
+ var keyMap = (0, _keymaps.findKeymapByDescription)(blockType.title.defaultMessage);
75
+ return {
76
+ content:
77
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
78
+ (0, _react2.jsx)("div", {
79
+ css: (0, _styled.blockTypeMenuItemStyle)(tagName, isActive)
80
+ }, (0, _react2.jsx)(Tag, null, formatMessage(blockType.title))),
81
+ value: blockType,
82
+ label: formatMessage(blockType.title),
83
+ 'aria-label': (0, _keymaps.tooltip)(keyMap, formatMessage(blockType.title)),
84
+ keyShortcuts: (0, _keymaps.getAriaKeyshortcuts)(keyMap),
85
+ key: "".concat(blockType.name, "-").concat(index),
86
+ elemAfter:
87
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
88
+ (0, _react2.jsx)("div", {
89
+ css: [_styled.keyboardShortcut, isActive && _styled.keyboardShortcutSelect]
90
+ }, (0, _keymaps.tooltip)(keyMap)),
91
+ isActive: isActive
92
+ };
93
+ });
94
+ return [{
95
+ items: items
96
+ }];
97
+ });
98
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleSelectBlockType", function (_ref) {
99
+ var item = _ref.item,
100
+ _ref$shouldCloseMenu = _ref.shouldCloseMenu,
101
+ shouldCloseMenu = _ref$shouldCloseMenu === void 0 ? true : _ref$shouldCloseMenu;
102
+ var blockType = item.value;
103
+ _this.props.setBlockType(blockType.name);
104
+ if (shouldCloseMenu) {
105
+ _this.setState(_objectSpread(_objectSpread({}, _this.state), {}, {
106
+ active: false
107
+ }));
108
+ }
109
+ });
110
+ return _this;
111
+ }
112
+ (0, _createClass2.default)(ToolbarBlockType, [{
113
+ key: "render",
114
+ value: function render() {
115
+ var _this2 = this;
116
+ var _this$state = this.state,
117
+ active = _this$state.active,
118
+ isOpenedByKeyboard = _this$state.isOpenedByKeyboard;
119
+ var _this$props = this.props,
120
+ popupsMountPoint = _this$props.popupsMountPoint,
121
+ popupsBoundariesElement = _this$props.popupsBoundariesElement,
122
+ popupsScrollableElement = _this$props.popupsScrollableElement,
123
+ isSmall = _this$props.isSmall,
124
+ isReducedSpacing = _this$props.isReducedSpacing,
125
+ _this$props$pluginSta2 = _this$props.pluginState,
126
+ currentBlockType = _this$props$pluginSta2.currentBlockType,
127
+ blockTypesDisabled = _this$props$pluginSta2.blockTypesDisabled,
128
+ availableBlockTypes = _this$props$pluginSta2.availableBlockTypes,
129
+ formatMessage = _this$props.intl.formatMessage;
130
+ var isHeadingDisabled = !availableBlockTypes.some(function (blockType) {
131
+ return blockType.nodeName === 'heading';
132
+ });
133
+ if (isHeadingDisabled) {
134
+ return null;
135
+ }
136
+ var blockTypeTitles = availableBlockTypes.filter(function (blockType) {
137
+ return blockType.name === currentBlockType.name;
138
+ }).map(function (blockType) {
139
+ return blockType.title;
140
+ });
141
+ if (!this.props.isDisabled && !blockTypesDisabled) {
142
+ var items = this.createItems();
143
+ return (
144
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
145
+ (0, _react2.jsx)("span", {
146
+ css: _styles.wrapperStyle
147
+ }, (0, _react2.jsx)(_uiMenu.DropdownMenuWithKeyboardNavigation, {
148
+ items: items,
149
+ onOpenChange: this.onOpenChange,
150
+ onItemActivated: this.handleSelectBlockType,
151
+ isOpen: active,
152
+ mountTo: popupsMountPoint,
153
+ boundariesElement: popupsBoundariesElement,
154
+ scrollableElement: popupsScrollableElement,
155
+ zIndex: _editorSharedStyles.akEditorMenuZIndex,
156
+ fitHeight: 360,
157
+ fitWidth: 106,
158
+ shouldUseDefaultRole: true,
159
+ shouldFocusFirstItem: function shouldFocusFirstItem() {
160
+ if (isOpenedByKeyboard) {
161
+ // eslint-disable-next-line @repo/internal/react/no-set-state-inside-render
162
+ _this2.setState(_objectSpread(_objectSpread({}, _this2.state), {}, {
163
+ isOpenedByKeyboard: false
164
+ }));
165
+ }
166
+ return isOpenedByKeyboard;
167
+ }
168
+ }, (0, _react2.jsx)(_blocktypeButton.BlockTypeButton, {
169
+ isSmall: isSmall,
170
+ isReducedSpacing: isReducedSpacing,
171
+ selected: active,
172
+ disabled: false,
173
+ title: blockTypeTitles[0],
174
+ onClick: this.handleTriggerClick,
175
+ onKeyDown: this.handleTriggerByKeyboard,
176
+ formatMessage: formatMessage,
177
+ "aria-expanded": active
178
+ })), (0, _react2.jsx)("span", {
179
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
180
+ css: _styles.separatorStyles
181
+ }))
182
+ );
183
+ }
184
+ return (
185
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
186
+ (0, _react2.jsx)("span", {
187
+ css: _styles.wrapperStyle
188
+ }, (0, _react2.jsx)(_blocktypeButton.BlockTypeButton, {
189
+ isSmall: isSmall,
190
+ isReducedSpacing: isReducedSpacing,
191
+ selected: active,
192
+ disabled: true,
193
+ title: blockTypeTitles[0],
194
+ onClick: this.handleTriggerClick,
195
+ onKeyDown: this.handleTriggerByKeyboard,
196
+ formatMessage: formatMessage,
197
+ "aria-expanded": active
198
+ }), (0, _react2.jsx)("span", {
199
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
200
+ css: _styles.separatorStyles
201
+ }))
202
+ );
203
+ }
204
+ }]);
205
+ return ToolbarBlockType;
206
+ }(_react.default.PureComponent);
207
+ var _default = (0, _reactIntlNext.injectIntl)(ToolbarBlockType);
208
+ exports.default = _default;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.wrapperSmallStyle = exports.keyboardShortcutSelect = exports.keyboardShortcut = exports.expandIconWrapperStyle = exports.buttonContentStyle = exports.buttonContentReducedSpacingStyle = exports.blockTypeMenuItemStyle = void 0;
8
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
+ var _react = require("@emotion/react");
10
+ var _styles = require("@atlaskit/editor-common/styles");
11
+ var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
12
+ var _colors = require("@atlaskit/theme/colors");
13
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
14
+ /** @jsx jsx */
15
+ var blockTypeMenuItemStyle = function blockTypeMenuItemStyle(tagName, selected) {
16
+ // TEMP FIX: See https://product-fabric.atlassian.net/browse/ED-13878
17
+ var selectedStyle = selected ? "".concat(tagName, " { color: ", "var(--ds-text, white)", " !important; }") : '';
18
+ return function (themeProps) {
19
+ return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n ", ";\n > {\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-top: 0;\n }\n }\n ", ";\n "])), (0, _styles.headingsSharedStyles)(themeProps), selectedStyle);
20
+ };
21
+ };
22
+ exports.blockTypeMenuItemStyle = blockTypeMenuItemStyle;
23
+ var keyboardShortcut = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n margin-left: ", ";\n"])), _shortcut.shortcutStyle, "var(--ds-space-200, 16px)");
24
+ exports.keyboardShortcut = keyboardShortcut;
25
+ var keyboardShortcutSelect = (0, _react.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n"])), "var(--ds-icon, ".concat(_colors.N400, ")"));
26
+ exports.keyboardShortcutSelect = keyboardShortcutSelect;
27
+ var buttonContentStyle = (0, _react.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n min-width: 80px;\n align-items: center;\n overflow: hidden;\n justify-content: center;\n flex-direction: column;\n padding: ", ";\n"])), "var(--ds-space-075, 6px)");
28
+ exports.buttonContentStyle = buttonContentStyle;
29
+ var buttonContentReducedSpacingStyle = (0, _react.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n padding: ", ";\n"])), "var(--ds-space-100, 8px)");
30
+ exports.buttonContentReducedSpacingStyle = buttonContentReducedSpacingStyle;
31
+ var wrapperSmallStyle = (0, _react.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n margin-left: ", ";\n min-width: 40px;\n"])), "var(--ds-space-050, 4px)");
32
+ exports.wrapperSmallStyle = wrapperSmallStyle;
33
+ var expandIconWrapperStyle = (0, _react.css)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n margin-left: -8px;\n"])));
34
+ exports.expandIconWrapperStyle = expandIconWrapperStyle;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toolbarMessages = void 0;
7
+ var _reactIntlNext = require("react-intl-next");
8
+ var toolbarMessages = (0, _reactIntlNext.defineMessages)({
9
+ textStyles: {
10
+ id: 'fabric.editor.textStyles',
11
+ defaultMessage: 'Text styles',
12
+ description: 'Menu provides access to various heading styles or normal text'
13
+ }
14
+ });
15
+ exports.toolbarMessages = toolbarMessages;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.areBlockTypesDisabled = areBlockTypesDisabled;
7
+ exports.isNodeAWrappingBlockNode = exports.createWrappingTextBlockRule = exports.createJoinNodesRule = void 0;
8
+ var _utils = require("@atlaskit/editor-common/utils");
9
+ var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
10
+ var _blockTypes = require("./block-types");
11
+ var isNodeAWrappingBlockNode = function isNodeAWrappingBlockNode(node) {
12
+ if (!node) {
13
+ return false;
14
+ }
15
+ return _blockTypes.WRAPPER_BLOCK_TYPES.some(function (blockNode) {
16
+ return blockNode.name === node.type.name;
17
+ });
18
+ };
19
+ exports.isNodeAWrappingBlockNode = isNodeAWrappingBlockNode;
20
+ var createJoinNodesRule = function createJoinNodesRule(match, nodeType) {
21
+ return (0, _utils.createWrappingJoinRule)({
22
+ nodeType: nodeType,
23
+ match: match,
24
+ getAttrs: {},
25
+ joinPredicate: function joinPredicate(_, node) {
26
+ return node.type === nodeType;
27
+ }
28
+ });
29
+ };
30
+ exports.createJoinNodesRule = createJoinNodesRule;
31
+ var createWrappingTextBlockRule = function createWrappingTextBlockRule(_ref) {
32
+ var match = _ref.match,
33
+ nodeType = _ref.nodeType,
34
+ getAttrs = _ref.getAttrs;
35
+ var handler = function handler(state, match, start, end) {
36
+ var fixedStart = Math.max(start, 1);
37
+ var $start = state.doc.resolve(fixedStart);
38
+ var attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
39
+ var nodeBefore = $start.node(-1);
40
+ if (nodeBefore && !nodeBefore.canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType)) {
41
+ return null;
42
+ }
43
+ return state.tr.delete(fixedStart, end).setBlockType(fixedStart, fixedStart, nodeType, attrs);
44
+ };
45
+ return (0, _prosemirrorInputRules.createRule)(match, handler);
46
+ };
47
+
48
+ /**
49
+ * Function will create a list of wrapper blocks present in a selection.
50
+ */
51
+ exports.createWrappingTextBlockRule = createWrappingTextBlockRule;
52
+ function getSelectedWrapperNodes(state) {
53
+ var nodes = [];
54
+ if (state.selection) {
55
+ var _state$selection = state.selection,
56
+ $from = _state$selection.$from,
57
+ $to = _state$selection.$to;
58
+ var _state$schema$nodes = state.schema.nodes,
59
+ blockquote = _state$schema$nodes.blockquote,
60
+ panel = _state$schema$nodes.panel,
61
+ orderedList = _state$schema$nodes.orderedList,
62
+ bulletList = _state$schema$nodes.bulletList,
63
+ listItem = _state$schema$nodes.listItem,
64
+ codeBlock = _state$schema$nodes.codeBlock,
65
+ decisionItem = _state$schema$nodes.decisionItem,
66
+ decisionList = _state$schema$nodes.decisionList,
67
+ taskItem = _state$schema$nodes.taskItem,
68
+ taskList = _state$schema$nodes.taskList;
69
+ state.doc.nodesBetween($from.pos, $to.pos, function (node) {
70
+ if (node.isBlock && [blockquote, panel, orderedList, bulletList, listItem, codeBlock, decisionItem, decisionList, taskItem, taskList].indexOf(node.type) >= 0) {
71
+ nodes.push(node.type);
72
+ }
73
+ });
74
+ }
75
+ return nodes;
76
+ }
77
+
78
+ /**
79
+ * Function will check if changing block types: Paragraph, Heading is enabled.
80
+ */
81
+ function areBlockTypesDisabled(state) {
82
+ var nodesTypes = getSelectedWrapperNodes(state);
83
+ var panel = state.schema.nodes.panel;
84
+ return nodesTypes.filter(function (type) {
85
+ return type !== panel;
86
+ }).length > 0;
87
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "blocktypeStyles", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _styles.blocktypeStyles;
10
+ }
11
+ });
12
+ var _styles = require("./plugin/styles");
@@ -0,0 +1 @@
1
+ export { BLOCK_QUOTE, CODE_BLOCK, HEADING_1, HEADING_2, HEADING_3, HEADING_4, HEADING_5, HEADING_6, NORMAL_TEXT, PANEL } from './plugin/block-types';
@@ -0,0 +1 @@
1
+ export { blockTypePlugin } from './plugin';
@@ -0,0 +1,2 @@
1
+ export { messages } from './plugin/messages';
2
+ export { toolbarMessages } from './plugin/ui/ToolbarBlockType/toolbar-messages';
@@ -0,0 +1,84 @@
1
+ import { messages } from './messages';
2
+ export const NORMAL_TEXT = {
3
+ name: 'normal',
4
+ title: messages.normal,
5
+ nodeName: 'paragraph',
6
+ tagName: 'p'
7
+ };
8
+ export const HEADING_1 = {
9
+ name: 'heading1',
10
+ title: messages.heading1,
11
+ nodeName: 'heading',
12
+ tagName: 'h1',
13
+ level: 1
14
+ };
15
+ export const HEADING_2 = {
16
+ name: 'heading2',
17
+ title: messages.heading2,
18
+ nodeName: 'heading',
19
+ tagName: 'h2',
20
+ level: 2
21
+ };
22
+ export const HEADING_3 = {
23
+ name: 'heading3',
24
+ title: messages.heading3,
25
+ nodeName: 'heading',
26
+ tagName: 'h3',
27
+ level: 3
28
+ };
29
+ export const HEADING_4 = {
30
+ name: 'heading4',
31
+ title: messages.heading4,
32
+ nodeName: 'heading',
33
+ tagName: 'h4',
34
+ level: 4
35
+ };
36
+ export const HEADING_5 = {
37
+ name: 'heading5',
38
+ title: messages.heading5,
39
+ nodeName: 'heading',
40
+ tagName: 'h5',
41
+ level: 5
42
+ };
43
+ export const HEADING_6 = {
44
+ name: 'heading6',
45
+ title: messages.heading6,
46
+ nodeName: 'heading',
47
+ tagName: 'h6',
48
+ level: 6
49
+ };
50
+ export const BLOCK_QUOTE = {
51
+ name: 'blockquote',
52
+ title: messages.blockquote,
53
+ nodeName: 'blockquote'
54
+ };
55
+ export const CODE_BLOCK = {
56
+ name: 'codeblock',
57
+ title: messages.codeblock,
58
+ nodeName: 'codeBlock'
59
+ };
60
+ export const PANEL = {
61
+ name: 'panel',
62
+ title: messages.infoPanel,
63
+ nodeName: 'panel'
64
+ };
65
+ export const OTHER = {
66
+ name: 'other',
67
+ title: messages.other,
68
+ nodeName: ''
69
+ };
70
+ export const TEXT_BLOCK_TYPES = [NORMAL_TEXT, HEADING_1, HEADING_2, HEADING_3, HEADING_4, HEADING_5, HEADING_6];
71
+ export const WRAPPER_BLOCK_TYPES = [BLOCK_QUOTE, CODE_BLOCK, PANEL];
72
+ export const ALL_BLOCK_TYPES = TEXT_BLOCK_TYPES.concat(WRAPPER_BLOCK_TYPES);
73
+ export const HEADINGS_BY_LEVEL = TEXT_BLOCK_TYPES.reduce((acc, blockType) => {
74
+ if (blockType.level && blockType.nodeName === 'heading') {
75
+ acc[blockType.level] = blockType;
76
+ }
77
+ return acc;
78
+ }, {});
79
+ export const HEADINGS_BY_NAME = TEXT_BLOCK_TYPES.reduce((acc, blockType) => {
80
+ if (blockType.level && blockType.nodeName === 'heading') {
81
+ acc[blockType.name] = blockType;
82
+ }
83
+ return acc;
84
+ }, {});