@atlaskit/editor-plugin-block-type 3.3.0 → 3.5.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.
- package/.eslintrc.js +12 -12
- package/CHANGELOG.md +225 -192
- package/LICENSE.md +6 -8
- package/dist/cjs/plugin/index.js +35 -28
- package/dist/cjs/plugin/styles.js +1 -1
- package/dist/cjs/plugin/ui/PrimaryToolbarComponent.js +2 -1
- package/dist/cjs/plugin/ui/ToolbarBlockType/blocktype-button.js +3 -1
- package/dist/cjs/plugin/ui/ToolbarBlockType/index.js +4 -3
- package/dist/cjs/plugin/ui/ToolbarBlockType/styled.js +2 -1
- package/dist/es2019/plugin/index.js +88 -79
- package/dist/es2019/plugin/styles.js +4 -4
- package/dist/es2019/plugin/ui/PrimaryToolbarComponent.js +2 -1
- package/dist/es2019/plugin/ui/ToolbarBlockType/blocktype-button.js +3 -1
- package/dist/es2019/plugin/ui/ToolbarBlockType/index.js +4 -3
- package/dist/es2019/plugin/ui/ToolbarBlockType/styled.js +2 -1
- package/dist/esm/plugin/index.js +36 -29
- package/dist/esm/plugin/styles.js +1 -1
- package/dist/esm/plugin/ui/PrimaryToolbarComponent.js +2 -1
- package/dist/esm/plugin/ui/ToolbarBlockType/blocktype-button.js +3 -1
- package/dist/esm/plugin/ui/ToolbarBlockType/index.js +4 -3
- package/dist/esm/plugin/ui/ToolbarBlockType/styled.js +2 -1
- package/dist/types/plugin/index.d.ts +3 -2
- package/dist/types/plugin/ui/ToolbarBlockType/index.d.ts +3 -0
- package/dist/types-ts4.5/plugin/index.d.ts +4 -2
- package/dist/types-ts4.5/plugin/ui/ToolbarBlockType/index.d.ts +3 -0
- package/package.json +5 -9
- package/report.api.md +51 -53
package/LICENSE.md
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
Copyright 2023 Atlassian Pty Ltd
|
2
2
|
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
|
5
|
-
You may obtain a copy of the License at
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
|
4
|
+
compliance with the License. You may obtain a copy of the License at
|
6
5
|
|
7
6
|
http://www.apache.org/licenses/LICENSE-2.0
|
8
7
|
|
9
|
-
Unless required by applicable law or agreed to in writing, software
|
10
|
-
distributed
|
11
|
-
|
12
|
-
|
13
|
-
limitations under the License.
|
8
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is
|
9
|
+
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
10
|
+
implied. See the License for the specific language governing permissions and limitations under the
|
11
|
+
License.
|
package/dist/cjs/plugin/index.js
CHANGED
@@ -104,14 +104,32 @@ var blockquotePluginOptions = function blockquotePluginOptions(_ref2, isAllowed,
|
|
104
104
|
var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3) {
|
105
105
|
var options = _ref3.config,
|
106
106
|
api = _ref3.api;
|
107
|
+
var primaryToolbarComponent = function primaryToolbarComponent(_ref4) {
|
108
|
+
var popupsMountPoint = _ref4.popupsMountPoint,
|
109
|
+
popupsBoundariesElement = _ref4.popupsBoundariesElement,
|
110
|
+
popupsScrollableElement = _ref4.popupsScrollableElement,
|
111
|
+
toolbarSize = _ref4.toolbarSize,
|
112
|
+
disabled = _ref4.disabled,
|
113
|
+
isToolbarReducedSpacing = _ref4.isToolbarReducedSpacing;
|
114
|
+
var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < _types.ToolbarSize.XXL : toolbarSize < _types.ToolbarSize.XL;
|
115
|
+
return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponent, {
|
116
|
+
isSmall: isSmall,
|
117
|
+
disabled: disabled,
|
118
|
+
isToolbarReducedSpacing: isToolbarReducedSpacing,
|
119
|
+
api: api,
|
120
|
+
popupsMountPoint: popupsMountPoint,
|
121
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
122
|
+
popupsScrollableElement: popupsScrollableElement,
|
123
|
+
shouldUseDefaultRole: false
|
124
|
+
});
|
125
|
+
};
|
107
126
|
return {
|
108
127
|
name: 'blockType',
|
109
128
|
nodes: function nodes() {
|
110
129
|
var blockquoteNode = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-list-in-blockquote') ? _adfSchema.blockquoteWithList : _adfSchema.blockquote;
|
111
|
-
var headingNode = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.enable-localid-for-paragraph-in-stage-0_cby7g') ? _adfSchema.headingStage0 : _adfSchema.heading;
|
112
130
|
var nodes = [{
|
113
131
|
name: 'heading',
|
114
|
-
node:
|
132
|
+
node: _adfSchema.heading
|
115
133
|
}, {
|
116
134
|
name: 'blockquote',
|
117
135
|
node: blockquoteNode
|
@@ -130,16 +148,16 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
|
|
130
148
|
pmPlugins: function pmPlugins() {
|
131
149
|
return [{
|
132
150
|
name: 'blockType',
|
133
|
-
plugin: function plugin(
|
134
|
-
var dispatch =
|
151
|
+
plugin: function plugin(_ref5) {
|
152
|
+
var dispatch = _ref5.dispatch;
|
135
153
|
return (0, _main.createPlugin)(api, dispatch, options && options.lastNodeMustBeParagraph);
|
136
154
|
}
|
137
155
|
}, {
|
138
156
|
name: 'blockTypeInputRule',
|
139
|
-
plugin: function plugin(
|
157
|
+
plugin: function plugin(_ref6) {
|
140
158
|
var _api$analytics;
|
141
|
-
var schema =
|
142
|
-
featureFlags =
|
159
|
+
var schema = _ref6.schema,
|
160
|
+
featureFlags = _ref6.featureFlags;
|
143
161
|
return (0, _inputRule.default)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, schema, featureFlags);
|
144
162
|
}
|
145
163
|
},
|
@@ -147,10 +165,10 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
|
|
147
165
|
// plugin as it is currently swallowing right/down arrow events inside tables
|
148
166
|
{
|
149
167
|
name: 'blockTypeKeyMap',
|
150
|
-
plugin: function plugin(
|
168
|
+
plugin: function plugin(_ref7) {
|
151
169
|
var _api$analytics2;
|
152
|
-
var schema =
|
153
|
-
featureFlags =
|
170
|
+
var schema = _ref7.schema,
|
171
|
+
featureFlags = _ref7.featureFlags;
|
154
172
|
return (0, _keymap.default)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, schema, featureFlags);
|
155
173
|
}
|
156
174
|
}];
|
@@ -173,25 +191,14 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
|
|
173
191
|
}
|
174
192
|
return _main.pluginKey.getState(editorState);
|
175
193
|
},
|
176
|
-
|
177
|
-
var
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
isToolbarReducedSpacing = _ref7.isToolbarReducedSpacing;
|
183
|
-
var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < _types.ToolbarSize.XXL : toolbarSize < _types.ToolbarSize.XL;
|
184
|
-
return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponent, {
|
185
|
-
isSmall: isSmall,
|
186
|
-
disabled: disabled,
|
187
|
-
isToolbarReducedSpacing: isToolbarReducedSpacing,
|
188
|
-
api: api,
|
189
|
-
popupsMountPoint: popupsMountPoint,
|
190
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
191
|
-
popupsScrollableElement: popupsScrollableElement,
|
192
|
-
shouldUseDefaultRole: false
|
193
|
-
});
|
194
|
+
usePluginHook: function usePluginHook() {
|
195
|
+
var _api$core, _api$primaryToolbar;
|
196
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.commands.registerComponent({
|
197
|
+
name: 'blockType',
|
198
|
+
component: primaryToolbarComponent
|
199
|
+
}));
|
194
200
|
},
|
201
|
+
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
|
195
202
|
pluginsOptions: {
|
196
203
|
quickInsert: function quickInsert(intl) {
|
197
204
|
var _api$analytics5, _api$analytics6;
|
@@ -11,5 +11,5 @@ var _styles = require("@atlaskit/editor-common/styles");
|
|
11
11
|
var _templateObject;
|
12
12
|
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- Imports are not safe in an object syntax
|
13
13
|
var blocktypeStyles = exports.blocktypeStyles = function blocktypeStyles() {
|
14
|
-
return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n
|
14
|
+
return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n\t.ProseMirror {\n\t\t", ";\n\t\t", ";\n\t}\n"])), _styles.blockquoteSharedStyles, (0, _styles.headingsSharedStyles)());
|
15
15
|
};
|
@@ -33,6 +33,7 @@ function PrimaryToolbarComponent(_ref) {
|
|
33
33
|
popupsMountPoint: popupsMountPoint,
|
34
34
|
popupsBoundariesElement: popupsBoundariesElement,
|
35
35
|
popupsScrollableElement: popupsScrollableElement,
|
36
|
-
shouldUseDefaultRole: shouldUseDefaultRole
|
36
|
+
shouldUseDefaultRole: shouldUseDefaultRole,
|
37
|
+
api: api
|
37
38
|
});
|
38
39
|
}
|
@@ -25,7 +25,9 @@ var BlockTypeButton = exports.BlockTypeButton = function BlockTypeButton(props)
|
|
25
25
|
var toolipTextStyles = props.formatMessage(_messages.toolbarMessages.textStylesTooltip);
|
26
26
|
return (0, _react2.jsx)(_uiMenu.ToolbarButton, {
|
27
27
|
spacing: props.isReducedSpacing ? 'none' : 'default',
|
28
|
-
selected: props.selected
|
28
|
+
selected: props.selected
|
29
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
30
|
+
,
|
29
31
|
className: "block-type-btn",
|
30
32
|
disabled: props.disabled,
|
31
33
|
onClick: props.onClick,
|
@@ -127,7 +127,8 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
127
127
|
blockTypesDisabled = _this$props$pluginSta2.blockTypesDisabled,
|
128
128
|
availableBlockTypes = _this$props$pluginSta2.availableBlockTypes,
|
129
129
|
shouldUseDefaultRole = _this$props.shouldUseDefaultRole,
|
130
|
-
formatMessage = _this$props.intl.formatMessage
|
130
|
+
formatMessage = _this$props.intl.formatMessage,
|
131
|
+
api = _this$props.api;
|
131
132
|
var isHeadingDisabled = !availableBlockTypes.some(function (blockType) {
|
132
133
|
return blockType.nodeName === 'heading';
|
133
134
|
});
|
@@ -177,7 +178,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
177
178
|
formatMessage: formatMessage,
|
178
179
|
"aria-expanded": active,
|
179
180
|
blockTypeName: currentBlockType.name
|
180
|
-
})), (0, _react2.jsx)("span", {
|
181
|
+
})), !(api !== null && api !== void 0 && api.primaryToolbar) && (0, _react2.jsx)("span", {
|
181
182
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
182
183
|
css: _styles.separatorStyles
|
183
184
|
}))
|
@@ -198,7 +199,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
198
199
|
formatMessage: formatMessage,
|
199
200
|
"aria-expanded": active,
|
200
201
|
blockTypeName: currentBlockType.name
|
201
|
-
}), (0, _react2.jsx)("span", {
|
202
|
+
}), !(api !== null && api !== void 0 && api.primaryToolbar) && (0, _react2.jsx)("span", {
|
202
203
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
203
204
|
css: _styles.separatorStyles
|
204
205
|
}))
|
@@ -24,7 +24,8 @@ var blockTypeMenuItemStyle = exports.blockTypeMenuItemStyle = function blockType
|
|
24
24
|
};
|
25
25
|
};
|
26
26
|
var keyboardShortcut = exports.keyboardShortcut = (0, _react.css)(_shortcut.shortcutStyle, {
|
27
|
-
marginLeft: "var(--ds-space-200, 16px)"
|
27
|
+
marginLeft: "var(--ds-space-200, 16px)",
|
28
|
+
color: "var(--ds-icon, ".concat(_colors.N400, ")")
|
28
29
|
});
|
29
30
|
var keyboardShortcutSelect = exports.keyboardShortcutSelect = (0, _react.css)({
|
30
31
|
color: "var(--ds-icon, ".concat(_colors.N400, ")")
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { blockquote, blockquoteWithList, hardBreak, heading
|
2
|
+
import { blockquote, blockquoteWithList, hardBreak, heading } from '@atlaskit/adf-schema';
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
4
4
|
import { keymap, toggleBlockQuote, tooltip } from '@atlaskit/editor-common/keymaps';
|
5
5
|
import { blockTypeMessages as messages } from '@atlaskit/editor-common/messages';
|
@@ -88,82 +88,15 @@ const blockquotePluginOptions = ({
|
|
88
88
|
const blockTypePlugin = ({
|
89
89
|
config: options,
|
90
90
|
api
|
91
|
-
}) =>
|
92
|
-
|
93
|
-
nodes() {
|
94
|
-
const blockquoteNode = getBooleanFF('platform.editor.allow-list-in-blockquote') ? blockquoteWithList : blockquote;
|
95
|
-
const headingNode = getBooleanFF('platform.editor.enable-localid-for-paragraph-in-stage-0_cby7g') ? headingStage0 : heading;
|
96
|
-
const nodes = [{
|
97
|
-
name: 'heading',
|
98
|
-
node: headingNode
|
99
|
-
}, {
|
100
|
-
name: 'blockquote',
|
101
|
-
node: blockquoteNode
|
102
|
-
}, {
|
103
|
-
name: 'hardBreak',
|
104
|
-
node: hardBreak
|
105
|
-
}];
|
106
|
-
if (options && options.allowBlockType) {
|
107
|
-
const exclude = options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
|
108
|
-
return nodes.filter(node => exclude.indexOf(node.name) === -1);
|
109
|
-
}
|
110
|
-
return nodes;
|
111
|
-
},
|
112
|
-
pmPlugins() {
|
113
|
-
return [{
|
114
|
-
name: 'blockType',
|
115
|
-
plugin: ({
|
116
|
-
dispatch
|
117
|
-
}) => createPlugin(api, dispatch, options && options.lastNodeMustBeParagraph)
|
118
|
-
}, {
|
119
|
-
name: 'blockTypeInputRule',
|
120
|
-
plugin: ({
|
121
|
-
schema,
|
122
|
-
featureFlags
|
123
|
-
}) => {
|
124
|
-
var _api$analytics;
|
125
|
-
return inputRulePlugin(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, schema, featureFlags);
|
126
|
-
}
|
127
|
-
},
|
128
|
-
// Needs to be lower priority than editor-tables.tableEditing
|
129
|
-
// plugin as it is currently swallowing right/down arrow events inside tables
|
130
|
-
{
|
131
|
-
name: 'blockTypeKeyMap',
|
132
|
-
plugin: ({
|
133
|
-
schema,
|
134
|
-
featureFlags
|
135
|
-
}) => {
|
136
|
-
var _api$analytics2;
|
137
|
-
return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, schema, featureFlags);
|
138
|
-
}
|
139
|
-
}];
|
140
|
-
},
|
141
|
-
actions: {
|
142
|
-
insertBlockQuote(inputMethod) {
|
143
|
-
var _api$analytics3;
|
144
|
-
return insertBlockQuoteWithAnalytics(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
145
|
-
}
|
146
|
-
},
|
147
|
-
commands: {
|
148
|
-
setTextLevel(level, inputMethod) {
|
149
|
-
var _api$analytics4;
|
150
|
-
return setBlockTypeWithAnalytics(level, inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
|
151
|
-
}
|
152
|
-
},
|
153
|
-
getSharedState(editorState) {
|
154
|
-
if (!editorState) {
|
155
|
-
return;
|
156
|
-
}
|
157
|
-
return pluginKey.getState(editorState);
|
158
|
-
},
|
159
|
-
primaryToolbarComponent({
|
91
|
+
}) => {
|
92
|
+
const primaryToolbarComponent = ({
|
160
93
|
popupsMountPoint,
|
161
94
|
popupsBoundariesElement,
|
162
95
|
popupsScrollableElement,
|
163
96
|
toolbarSize,
|
164
97
|
disabled,
|
165
98
|
isToolbarReducedSpacing
|
166
|
-
}) {
|
99
|
+
}) => {
|
167
100
|
const isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < ToolbarSize.XXL : toolbarSize < ToolbarSize.XL;
|
168
101
|
return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
|
169
102
|
isSmall: isSmall,
|
@@ -175,14 +108,90 @@ const blockTypePlugin = ({
|
|
175
108
|
popupsScrollableElement: popupsScrollableElement,
|
176
109
|
shouldUseDefaultRole: false
|
177
110
|
});
|
178
|
-
}
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
const
|
183
|
-
|
111
|
+
};
|
112
|
+
return {
|
113
|
+
name: 'blockType',
|
114
|
+
nodes() {
|
115
|
+
const blockquoteNode = getBooleanFF('platform.editor.allow-list-in-blockquote') ? blockquoteWithList : blockquote;
|
116
|
+
const nodes = [{
|
117
|
+
name: 'heading',
|
118
|
+
node: heading
|
119
|
+
}, {
|
120
|
+
name: 'blockquote',
|
121
|
+
node: blockquoteNode
|
122
|
+
}, {
|
123
|
+
name: 'hardBreak',
|
124
|
+
node: hardBreak
|
125
|
+
}];
|
126
|
+
if (options && options.allowBlockType) {
|
127
|
+
const exclude = options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
|
128
|
+
return nodes.filter(node => exclude.indexOf(node.name) === -1);
|
129
|
+
}
|
130
|
+
return nodes;
|
131
|
+
},
|
132
|
+
pmPlugins() {
|
133
|
+
return [{
|
134
|
+
name: 'blockType',
|
135
|
+
plugin: ({
|
136
|
+
dispatch
|
137
|
+
}) => createPlugin(api, dispatch, options && options.lastNodeMustBeParagraph)
|
138
|
+
}, {
|
139
|
+
name: 'blockTypeInputRule',
|
140
|
+
plugin: ({
|
141
|
+
schema,
|
142
|
+
featureFlags
|
143
|
+
}) => {
|
144
|
+
var _api$analytics;
|
145
|
+
return inputRulePlugin(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, schema, featureFlags);
|
146
|
+
}
|
147
|
+
},
|
148
|
+
// Needs to be lower priority than editor-tables.tableEditing
|
149
|
+
// plugin as it is currently swallowing right/down arrow events inside tables
|
150
|
+
{
|
151
|
+
name: 'blockTypeKeyMap',
|
152
|
+
plugin: ({
|
153
|
+
schema,
|
154
|
+
featureFlags
|
155
|
+
}) => {
|
156
|
+
var _api$analytics2;
|
157
|
+
return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, schema, featureFlags);
|
158
|
+
}
|
159
|
+
}];
|
160
|
+
},
|
161
|
+
actions: {
|
162
|
+
insertBlockQuote(inputMethod) {
|
163
|
+
var _api$analytics3;
|
164
|
+
return insertBlockQuoteWithAnalytics(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
165
|
+
}
|
166
|
+
},
|
167
|
+
commands: {
|
168
|
+
setTextLevel(level, inputMethod) {
|
169
|
+
var _api$analytics4;
|
170
|
+
return setBlockTypeWithAnalytics(level, inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
|
171
|
+
}
|
172
|
+
},
|
173
|
+
getSharedState(editorState) {
|
174
|
+
if (!editorState) {
|
175
|
+
return;
|
176
|
+
}
|
177
|
+
return pluginKey.getState(editorState);
|
178
|
+
},
|
179
|
+
usePluginHook: () => {
|
180
|
+
var _api$core, _api$primaryToolbar;
|
181
|
+
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.commands.registerComponent({
|
182
|
+
name: 'blockType',
|
183
|
+
component: primaryToolbarComponent
|
184
|
+
}));
|
185
|
+
},
|
186
|
+
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
|
187
|
+
pluginsOptions: {
|
188
|
+
quickInsert: intl => {
|
189
|
+
var _api$analytics5, _api$analytics6;
|
190
|
+
const exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
|
191
|
+
return [...blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions), ...headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions)];
|
192
|
+
}
|
184
193
|
}
|
185
|
-
}
|
186
|
-
}
|
194
|
+
};
|
195
|
+
};
|
187
196
|
export { blockTypePlugin };
|
188
197
|
export { pluginKey } from './pm-plugins/main';
|
@@ -3,8 +3,8 @@ import { blockquoteSharedStyles, headingsSharedStyles } from '@atlaskit/editor-c
|
|
3
3
|
|
4
4
|
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- Imports are not safe in an object syntax
|
5
5
|
export const blocktypeStyles = () => css`
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
.ProseMirror {
|
7
|
+
${blockquoteSharedStyles};
|
8
|
+
${headingsSharedStyles()};
|
9
|
+
}
|
10
10
|
`;
|
@@ -28,6 +28,7 @@ export function PrimaryToolbarComponent({
|
|
28
28
|
popupsMountPoint: popupsMountPoint,
|
29
29
|
popupsBoundariesElement: popupsBoundariesElement,
|
30
30
|
popupsScrollableElement: popupsScrollableElement,
|
31
|
-
shouldUseDefaultRole: shouldUseDefaultRole
|
31
|
+
shouldUseDefaultRole: shouldUseDefaultRole,
|
32
|
+
api: api
|
32
33
|
});
|
33
34
|
}
|
@@ -17,7 +17,9 @@ export const BlockTypeButton = props => {
|
|
17
17
|
const toolipTextStyles = props.formatMessage(toolbarMessages.textStylesTooltip);
|
18
18
|
return jsx(ToolbarButton, {
|
19
19
|
spacing: props.isReducedSpacing ? 'none' : 'default',
|
20
|
-
selected: props.selected
|
20
|
+
selected: props.selected
|
21
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
22
|
+
,
|
21
23
|
className: "block-type-btn",
|
22
24
|
disabled: props.disabled,
|
23
25
|
onClick: props.onClick,
|
@@ -111,7 +111,8 @@ class ToolbarBlockType extends React.PureComponent {
|
|
111
111
|
shouldUseDefaultRole,
|
112
112
|
intl: {
|
113
113
|
formatMessage
|
114
|
-
}
|
114
|
+
},
|
115
|
+
api
|
115
116
|
} = this.props;
|
116
117
|
const isHeadingDisabled = !availableBlockTypes.some(blockType => blockType.nodeName === 'heading');
|
117
118
|
if (isHeadingDisabled) {
|
@@ -157,7 +158,7 @@ class ToolbarBlockType extends React.PureComponent {
|
|
157
158
|
formatMessage: formatMessage,
|
158
159
|
"aria-expanded": active,
|
159
160
|
blockTypeName: currentBlockType.name
|
160
|
-
})), jsx("span", {
|
161
|
+
})), !(api !== null && api !== void 0 && api.primaryToolbar) && jsx("span", {
|
161
162
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
162
163
|
css: separatorStyles
|
163
164
|
}))
|
@@ -178,7 +179,7 @@ class ToolbarBlockType extends React.PureComponent {
|
|
178
179
|
formatMessage: formatMessage,
|
179
180
|
"aria-expanded": active,
|
180
181
|
blockTypeName: currentBlockType.name
|
181
|
-
}), jsx("span", {
|
182
|
+
}), !(api !== null && api !== void 0 && api.primaryToolbar) && jsx("span", {
|
182
183
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
183
184
|
css: separatorStyles
|
184
185
|
}))
|
@@ -15,7 +15,8 @@ export const blockTypeMenuItemStyle = (tagName, selected) => {
|
|
15
15
|
}, selectedStyle);
|
16
16
|
};
|
17
17
|
export const keyboardShortcut = css(shortcutStyle, {
|
18
|
-
marginLeft: "var(--ds-space-200, 16px)"
|
18
|
+
marginLeft: "var(--ds-space-200, 16px)",
|
19
|
+
color: `var(--ds-icon, ${N400})`
|
19
20
|
});
|
20
21
|
export const keyboardShortcutSelect = css({
|
21
22
|
color: `var(--ds-icon, ${N400})`
|
package/dist/esm/plugin/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
2
2
|
import React from 'react';
|
3
|
-
import { blockquote, blockquoteWithList, hardBreak, heading
|
3
|
+
import { blockquote, blockquoteWithList, hardBreak, heading } from '@atlaskit/adf-schema';
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
5
5
|
import { keymap, toggleBlockQuote, tooltip } from '@atlaskit/editor-common/keymaps';
|
6
6
|
import { blockTypeMessages as messages } from '@atlaskit/editor-common/messages';
|
@@ -91,14 +91,32 @@ var blockquotePluginOptions = function blockquotePluginOptions(_ref2, isAllowed,
|
|
91
91
|
var blockTypePlugin = function blockTypePlugin(_ref3) {
|
92
92
|
var options = _ref3.config,
|
93
93
|
api = _ref3.api;
|
94
|
+
var primaryToolbarComponent = function primaryToolbarComponent(_ref4) {
|
95
|
+
var popupsMountPoint = _ref4.popupsMountPoint,
|
96
|
+
popupsBoundariesElement = _ref4.popupsBoundariesElement,
|
97
|
+
popupsScrollableElement = _ref4.popupsScrollableElement,
|
98
|
+
toolbarSize = _ref4.toolbarSize,
|
99
|
+
disabled = _ref4.disabled,
|
100
|
+
isToolbarReducedSpacing = _ref4.isToolbarReducedSpacing;
|
101
|
+
var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < ToolbarSize.XXL : toolbarSize < ToolbarSize.XL;
|
102
|
+
return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
|
103
|
+
isSmall: isSmall,
|
104
|
+
disabled: disabled,
|
105
|
+
isToolbarReducedSpacing: isToolbarReducedSpacing,
|
106
|
+
api: api,
|
107
|
+
popupsMountPoint: popupsMountPoint,
|
108
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
109
|
+
popupsScrollableElement: popupsScrollableElement,
|
110
|
+
shouldUseDefaultRole: false
|
111
|
+
});
|
112
|
+
};
|
94
113
|
return {
|
95
114
|
name: 'blockType',
|
96
115
|
nodes: function nodes() {
|
97
116
|
var blockquoteNode = getBooleanFF('platform.editor.allow-list-in-blockquote') ? blockquoteWithList : blockquote;
|
98
|
-
var headingNode = getBooleanFF('platform.editor.enable-localid-for-paragraph-in-stage-0_cby7g') ? headingStage0 : heading;
|
99
117
|
var nodes = [{
|
100
118
|
name: 'heading',
|
101
|
-
node:
|
119
|
+
node: heading
|
102
120
|
}, {
|
103
121
|
name: 'blockquote',
|
104
122
|
node: blockquoteNode
|
@@ -117,16 +135,16 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
|
|
117
135
|
pmPlugins: function pmPlugins() {
|
118
136
|
return [{
|
119
137
|
name: 'blockType',
|
120
|
-
plugin: function plugin(
|
121
|
-
var dispatch =
|
138
|
+
plugin: function plugin(_ref5) {
|
139
|
+
var dispatch = _ref5.dispatch;
|
122
140
|
return createPlugin(api, dispatch, options && options.lastNodeMustBeParagraph);
|
123
141
|
}
|
124
142
|
}, {
|
125
143
|
name: 'blockTypeInputRule',
|
126
|
-
plugin: function plugin(
|
144
|
+
plugin: function plugin(_ref6) {
|
127
145
|
var _api$analytics;
|
128
|
-
var schema =
|
129
|
-
featureFlags =
|
146
|
+
var schema = _ref6.schema,
|
147
|
+
featureFlags = _ref6.featureFlags;
|
130
148
|
return inputRulePlugin(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, schema, featureFlags);
|
131
149
|
}
|
132
150
|
},
|
@@ -134,10 +152,10 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
|
|
134
152
|
// plugin as it is currently swallowing right/down arrow events inside tables
|
135
153
|
{
|
136
154
|
name: 'blockTypeKeyMap',
|
137
|
-
plugin: function plugin(
|
155
|
+
plugin: function plugin(_ref7) {
|
138
156
|
var _api$analytics2;
|
139
|
-
var schema =
|
140
|
-
featureFlags =
|
157
|
+
var schema = _ref7.schema,
|
158
|
+
featureFlags = _ref7.featureFlags;
|
141
159
|
return keymapPlugin(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, schema, featureFlags);
|
142
160
|
}
|
143
161
|
}];
|
@@ -160,25 +178,14 @@ var blockTypePlugin = function blockTypePlugin(_ref3) {
|
|
160
178
|
}
|
161
179
|
return pluginKey.getState(editorState);
|
162
180
|
},
|
163
|
-
|
164
|
-
var
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
isToolbarReducedSpacing = _ref7.isToolbarReducedSpacing;
|
170
|
-
var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < ToolbarSize.XXL : toolbarSize < ToolbarSize.XL;
|
171
|
-
return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
|
172
|
-
isSmall: isSmall,
|
173
|
-
disabled: disabled,
|
174
|
-
isToolbarReducedSpacing: isToolbarReducedSpacing,
|
175
|
-
api: api,
|
176
|
-
popupsMountPoint: popupsMountPoint,
|
177
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
178
|
-
popupsScrollableElement: popupsScrollableElement,
|
179
|
-
shouldUseDefaultRole: false
|
180
|
-
});
|
181
|
+
usePluginHook: function usePluginHook() {
|
182
|
+
var _api$core, _api$primaryToolbar;
|
183
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.commands.registerComponent({
|
184
|
+
name: 'blockType',
|
185
|
+
component: primaryToolbarComponent
|
186
|
+
}));
|
181
187
|
},
|
188
|
+
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
|
182
189
|
pluginsOptions: {
|
183
190
|
quickInsert: function quickInsert(intl) {
|
184
191
|
var _api$analytics5, _api$analytics6;
|
@@ -5,5 +5,5 @@ import { blockquoteSharedStyles, headingsSharedStyles } from '@atlaskit/editor-c
|
|
5
5
|
|
6
6
|
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- Imports are not safe in an object syntax
|
7
7
|
export var blocktypeStyles = function blocktypeStyles() {
|
8
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n
|
8
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\t.ProseMirror {\n\t\t", ";\n\t\t", ";\n\t}\n"])), blockquoteSharedStyles, headingsSharedStyles());
|
9
9
|
};
|
@@ -26,6 +26,7 @@ export function PrimaryToolbarComponent(_ref) {
|
|
26
26
|
popupsMountPoint: popupsMountPoint,
|
27
27
|
popupsBoundariesElement: popupsBoundariesElement,
|
28
28
|
popupsScrollableElement: popupsScrollableElement,
|
29
|
-
shouldUseDefaultRole: shouldUseDefaultRole
|
29
|
+
shouldUseDefaultRole: shouldUseDefaultRole,
|
30
|
+
api: api
|
30
31
|
});
|
31
32
|
}
|
@@ -17,7 +17,9 @@ export var BlockTypeButton = function BlockTypeButton(props) {
|
|
17
17
|
var toolipTextStyles = props.formatMessage(toolbarMessages.textStylesTooltip);
|
18
18
|
return jsx(ToolbarButton, {
|
19
19
|
spacing: props.isReducedSpacing ? 'none' : 'default',
|
20
|
-
selected: props.selected
|
20
|
+
selected: props.selected
|
21
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
22
|
+
,
|
21
23
|
className: "block-type-btn",
|
22
24
|
disabled: props.disabled,
|
23
25
|
onClick: props.onClick,
|
@@ -121,7 +121,8 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
121
121
|
blockTypesDisabled = _this$props$pluginSta2.blockTypesDisabled,
|
122
122
|
availableBlockTypes = _this$props$pluginSta2.availableBlockTypes,
|
123
123
|
shouldUseDefaultRole = _this$props.shouldUseDefaultRole,
|
124
|
-
formatMessage = _this$props.intl.formatMessage
|
124
|
+
formatMessage = _this$props.intl.formatMessage,
|
125
|
+
api = _this$props.api;
|
125
126
|
var isHeadingDisabled = !availableBlockTypes.some(function (blockType) {
|
126
127
|
return blockType.nodeName === 'heading';
|
127
128
|
});
|
@@ -171,7 +172,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
171
172
|
formatMessage: formatMessage,
|
172
173
|
"aria-expanded": active,
|
173
174
|
blockTypeName: currentBlockType.name
|
174
|
-
})), jsx("span", {
|
175
|
+
})), !(api !== null && api !== void 0 && api.primaryToolbar) && jsx("span", {
|
175
176
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
176
177
|
css: separatorStyles
|
177
178
|
}))
|
@@ -192,7 +193,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
192
193
|
formatMessage: formatMessage,
|
193
194
|
"aria-expanded": active,
|
194
195
|
blockTypeName: currentBlockType.name
|
195
|
-
}), jsx("span", {
|
196
|
+
}), !(api !== null && api !== void 0 && api.primaryToolbar) && jsx("span", {
|
196
197
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
197
198
|
css: separatorStyles
|
198
199
|
}))
|
@@ -17,7 +17,8 @@ export var blockTypeMenuItemStyle = function blockTypeMenuItemStyle(tagName, sel
|
|
17
17
|
};
|
18
18
|
};
|
19
19
|
export var keyboardShortcut = css(shortcutStyle, {
|
20
|
-
marginLeft: "var(--ds-space-200, 16px)"
|
20
|
+
marginLeft: "var(--ds-space-200, 16px)",
|
21
|
+
color: "var(--ds-icon, ".concat(N400, ")")
|
21
22
|
});
|
22
23
|
export var keyboardShortcutSelect = css({
|
23
24
|
color: "var(--ds-icon, ".concat(N400, ")")
|