@atlaskit/editor-plugin-block-type 12.1.1 → 12.1.3
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/CHANGELOG.md +25 -0
- package/dist/cjs/blockTypePlugin.js +1 -1
- package/dist/cjs/pm-plugins/commands/block-type.js +125 -18
- package/dist/cjs/pm-plugins/main.js +3 -3
- package/dist/cjs/pm-plugins/ui/ToolbarBlockType/HeadingButton.compiled.css +1 -0
- package/dist/cjs/pm-plugins/ui/ToolbarBlockType/HeadingButton.js +23 -0
- package/dist/cjs/pm-plugins/ui/ToolbarBlockType/QuoteButton.js +16 -0
- package/dist/cjs/pm-plugins/utils.js +85 -11
- package/dist/es2019/blockTypePlugin.js +1 -1
- package/dist/es2019/pm-plugins/commands/block-type.js +105 -2
- package/dist/es2019/pm-plugins/main.js +3 -3
- package/dist/es2019/pm-plugins/ui/ToolbarBlockType/HeadingButton.compiled.css +1 -0
- package/dist/es2019/pm-plugins/ui/ToolbarBlockType/HeadingButton.js +24 -0
- package/dist/es2019/pm-plugins/ui/ToolbarBlockType/QuoteButton.js +17 -0
- package/dist/es2019/pm-plugins/utils.js +80 -5
- package/dist/esm/blockTypePlugin.js +1 -1
- package/dist/esm/pm-plugins/commands/block-type.js +123 -18
- package/dist/esm/pm-plugins/main.js +3 -3
- package/dist/esm/pm-plugins/ui/ToolbarBlockType/HeadingButton.compiled.css +1 -0
- package/dist/esm/pm-plugins/ui/ToolbarBlockType/HeadingButton.js +23 -0
- package/dist/esm/pm-plugins/ui/ToolbarBlockType/QuoteButton.js +16 -0
- package/dist/esm/pm-plugins/utils.js +81 -10
- package/dist/types/pm-plugins/commands/block-type.d.ts +2 -0
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/utils.d.ts +18 -2
- package/dist/types-ts4.5/pm-plugins/commands/block-type.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/utils.d.ts +18 -2
- package/package.json +4 -4
|
@@ -81,7 +81,7 @@ var autoformatHeading = function autoformatHeading(headingLevel, editorAnalytics
|
|
|
81
81
|
return setHeadingWithAnalytics(headingLevel, INPUT_METHOD.FORMATTING, editorAnalyticsApi);
|
|
82
82
|
};
|
|
83
83
|
export var pluginKey = new PluginKey('blockTypePlugin');
|
|
84
|
-
export var createPlugin = function createPlugin(editorAPI, dispatch, lastNodeMustBeParagraph, includeBlockQuoteAsTextstyleOption) {
|
|
84
|
+
export var createPlugin = function createPlugin(editorAPI, dispatch, lastNodeMustBeParagraph, includeBlockQuoteAsTextstyleOption, allowFontSize) {
|
|
85
85
|
var _editorAPI$analytics;
|
|
86
86
|
var editorAnalyticsApi = editorAPI === null || editorAPI === void 0 || (_editorAPI$analytics = editorAPI.analytics) === null || _editorAPI$analytics === void 0 ? void 0 : _editorAPI$analytics.actions;
|
|
87
87
|
var altKeyLocation = 0;
|
|
@@ -115,7 +115,7 @@ export var createPlugin = function createPlugin(editorAPI, dispatch, lastNodeMus
|
|
|
115
115
|
var formattingIsPresent = hasBlockQuoteInOptions(availableBlockTypesInDropdown) ? checkFormattingIsPresent(state) : undefined;
|
|
116
116
|
return {
|
|
117
117
|
currentBlockType: detectBlockType(availableBlockTypesInDropdown, state),
|
|
118
|
-
blockTypesDisabled: areBlockTypesDisabled(state),
|
|
118
|
+
blockTypesDisabled: areBlockTypesDisabled(state, allowFontSize),
|
|
119
119
|
availableBlockTypes: availableBlockTypes,
|
|
120
120
|
availableWrapperBlockTypes: availableWrapperBlockTypes,
|
|
121
121
|
availableBlockTypesInDropdown: availableBlockTypesInDropdown,
|
|
@@ -125,7 +125,7 @@ export var createPlugin = function createPlugin(editorAPI, dispatch, lastNodeMus
|
|
|
125
125
|
apply: function apply(_tr, oldPluginState, _oldState, newState) {
|
|
126
126
|
var newPluginState = _objectSpread(_objectSpread({}, oldPluginState), {}, {
|
|
127
127
|
currentBlockType: detectBlockType(oldPluginState.availableBlockTypesInDropdown, newState),
|
|
128
|
-
blockTypesDisabled: areBlockTypesDisabled(newState),
|
|
128
|
+
blockTypesDisabled: areBlockTypesDisabled(newState, allowFontSize),
|
|
129
129
|
formattingIsPresent: hasBlockQuoteInOptions(oldPluginState.availableBlockTypesInDropdown) ? checkFormattingIsPresent(newState) : undefined
|
|
130
130
|
});
|
|
131
131
|
if (newPluginState.currentBlockType !== oldPluginState.currentBlockType || newPluginState.blockTypesDisabled !== oldPluginState.blockTypesDisabled || newPluginState.formattingIsPresent !== oldPluginState.formattingIsPresent) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
._11c810sd{font:var(--ds-font-heading-large,normal 653 24px/28px "Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
|
|
2
2
|
._11c812ln{font:var(--ds-font-heading-xlarge,normal 653 28px/2pc "Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
|
|
3
3
|
._11c812rg{font:var(--_1h4o6ch)}
|
|
4
|
+
._11c8130a{font:var(--_1b6nbh6)}
|
|
4
5
|
._11c81af2{font:var(--ds-font-heading-medium,normal 653 20px/24px "Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
|
|
5
6
|
._11c81e3o{font:var(--ds-font-heading-small,normal 653 1pc/20px "Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
|
|
6
7
|
._11c81fq3{font:var(--_1d0ko3v)}
|
|
@@ -7,11 +7,14 @@ import { ax, ix } from "@compiled/react/runtime";
|
|
|
7
7
|
import { useIntl } from 'react-intl-next';
|
|
8
8
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
9
9
|
import { formatShortcut, setNormalText, toggleHeading1, toggleHeading2, toggleHeading3, toggleHeading4, toggleHeading5, toggleHeading6 } from '@atlaskit/editor-common/keymaps';
|
|
10
|
+
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
10
11
|
import { editorUGCToken } from '@atlaskit/editor-common/ugc-tokens';
|
|
11
12
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
12
13
|
import { ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
13
14
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
14
15
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
16
|
+
import { isSelectionInsideListNode } from '../../utils';
|
|
17
|
+
var smallTextStyle = null;
|
|
15
18
|
var normalStyle = null;
|
|
16
19
|
var heading1Style = null;
|
|
17
20
|
var heading2Style = null;
|
|
@@ -65,6 +68,13 @@ var HeadingText = function HeadingText(_ref) {
|
|
|
65
68
|
"--_1c98jvx": ix(editorUGCToken('editor.font.heading.h6'))
|
|
66
69
|
}
|
|
67
70
|
}, children);
|
|
71
|
+
case 'smallText':
|
|
72
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
className: ax(["_11c8130a"]),
|
|
74
|
+
style: {
|
|
75
|
+
"--_1b6nbh6": ix(editorUGCToken('editor.font.body.small'))
|
|
76
|
+
}
|
|
77
|
+
}, children);
|
|
68
78
|
case 'normal':
|
|
69
79
|
default:
|
|
70
80
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -99,6 +109,12 @@ var shortcuts = {
|
|
|
99
109
|
heading5: toggleHeading5,
|
|
100
110
|
heading6: toggleHeading6
|
|
101
111
|
};
|
|
112
|
+
var shouldDisableHeadingButton = function shouldDisableHeadingButton(state, blockType) {
|
|
113
|
+
if (!state) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return isSelectionInsideListNode(state) && blockType.name !== 'normal' && blockType.name !== 'smallText';
|
|
117
|
+
};
|
|
102
118
|
export var HeadingButton = function HeadingButton(_ref2) {
|
|
103
119
|
var blockType = _ref2.blockType,
|
|
104
120
|
api = _ref2.api;
|
|
@@ -106,14 +122,20 @@ export var HeadingButton = function HeadingButton(_ref2) {
|
|
|
106
122
|
formatMessage = _useIntl.formatMessage;
|
|
107
123
|
var currentBlockType = useSharedPluginStateSelector(api, 'blockType.currentBlockType');
|
|
108
124
|
var availableBlockTypesInDropdown = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown');
|
|
125
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
126
|
+
editorView = _useEditorToolbar.editorView;
|
|
109
127
|
if (!(availableBlockTypesInDropdown !== null && availableBlockTypesInDropdown !== void 0 && availableBlockTypesInDropdown.some(function (availableBlockType) {
|
|
110
128
|
return availableBlockType.name === blockType.name;
|
|
111
129
|
}))) {
|
|
112
130
|
return null;
|
|
113
131
|
}
|
|
132
|
+
var isDisabled = expValEquals('platform_editor_small_font_size', 'isEnabled', true) ? shouldDisableHeadingButton(editorView === null || editorView === void 0 ? void 0 : editorView.state, blockType) : false;
|
|
114
133
|
var fromBlockQuote = (currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name) === 'blockquote';
|
|
115
134
|
var onClick = function onClick() {
|
|
116
135
|
var _api$core, _api$blockType;
|
|
136
|
+
if (isDisabled) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
117
139
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(blockType.name, INPUT_METHOD.TOOLBAR, fromBlockQuote));
|
|
118
140
|
};
|
|
119
141
|
var shortcut = formatShortcut(shortcuts[blockType.name]);
|
|
@@ -125,6 +147,7 @@ export var HeadingButton = function HeadingButton(_ref2) {
|
|
|
125
147
|
}) : undefined,
|
|
126
148
|
onClick: onClick,
|
|
127
149
|
isSelected: isSelected,
|
|
150
|
+
isDisabled: isDisabled,
|
|
128
151
|
ariaKeyshortcuts: shortcut
|
|
129
152
|
}, expValEquals('platform_editor_toolbar_aifc_use_editor_typography', 'isEnabled', true) ? /*#__PURE__*/React.createElement(HeadingText, {
|
|
130
153
|
headingType: blockType.name
|
|
@@ -2,8 +2,17 @@ import React from 'react';
|
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
3
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { formatShortcut, toggleBlockQuote } from '@atlaskit/editor-common/keymaps';
|
|
5
|
+
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
5
6
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
6
7
|
import { ToolbarDropdownItem, ToolbarKeyboardShortcutHint } from '@atlaskit/editor-toolbar';
|
|
8
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
|
+
import { isSelectionInsideListNode } from '../../utils';
|
|
10
|
+
var shouldDisableQuoteButton = function shouldDisableQuoteButton(state) {
|
|
11
|
+
if (!state) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return isSelectionInsideListNode(state);
|
|
15
|
+
};
|
|
7
16
|
export var QuoteButton = function QuoteButton(_ref) {
|
|
8
17
|
var blockType = _ref.blockType,
|
|
9
18
|
api = _ref.api;
|
|
@@ -11,13 +20,19 @@ export var QuoteButton = function QuoteButton(_ref) {
|
|
|
11
20
|
formatMessage = _useIntl.formatMessage;
|
|
12
21
|
var availableBlockTypesInDropdown = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown');
|
|
13
22
|
var currentBlockType = useSharedPluginStateSelector(api, 'blockType.currentBlockType');
|
|
23
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
24
|
+
editorView = _useEditorToolbar.editorView;
|
|
14
25
|
if (!(availableBlockTypesInDropdown !== null && availableBlockTypesInDropdown !== void 0 && availableBlockTypesInDropdown.some(function (availableBlockType) {
|
|
15
26
|
return availableBlockType.name === blockType.name;
|
|
16
27
|
}))) {
|
|
17
28
|
return null;
|
|
18
29
|
}
|
|
30
|
+
var isDisabled = expValEquals('platform_editor_small_font_size', 'isEnabled', true) ? shouldDisableQuoteButton(editorView === null || editorView === void 0 ? void 0 : editorView.state) : false;
|
|
19
31
|
var onClick = function onClick() {
|
|
20
32
|
var _api$core, _api$blockType;
|
|
33
|
+
if (isDisabled) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
21
36
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.insertBlockQuote(INPUT_METHOD.TOOLBAR));
|
|
22
37
|
};
|
|
23
38
|
var shortcut = formatShortcut(toggleBlockQuote);
|
|
@@ -28,6 +43,7 @@ export var QuoteButton = function QuoteButton(_ref) {
|
|
|
28
43
|
}) : undefined,
|
|
29
44
|
onClick: onClick,
|
|
30
45
|
isSelected: currentBlockType === blockType,
|
|
46
|
+
isDisabled: isDisabled,
|
|
31
47
|
ariaKeyshortcuts: shortcut
|
|
32
48
|
}, formatMessage(blockType.title));
|
|
33
49
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { anyMarkActive } from '@atlaskit/editor-common/mark';
|
|
2
2
|
import { createRule, createWrappingJoinRule } from '@atlaskit/editor-common/utils';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
5
|
import { WRAPPER_BLOCK_TYPES, FORMATTING_NODE_TYPES, FORMATTING_MARK_TYPES } from './block-types';
|
|
5
6
|
export var isNodeAWrappingBlockNode = function isNodeAWrappingBlockNode(node) {
|
|
@@ -73,12 +74,19 @@ function getSelectedWrapperNodes(state) {
|
|
|
73
74
|
* Function will check if changing block types: Paragraph, Heading is enabled.
|
|
74
75
|
*/
|
|
75
76
|
export function areBlockTypesDisabled(state) {
|
|
77
|
+
var allowFontSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
76
78
|
var nodesTypes = getSelectedWrapperNodes(state);
|
|
77
79
|
var _state$schema$nodes2 = state.schema.nodes,
|
|
78
80
|
panel = _state$schema$nodes2.panel,
|
|
79
81
|
blockquote = _state$schema$nodes2.blockquote,
|
|
80
82
|
bulletList = _state$schema$nodes2.bulletList,
|
|
81
|
-
orderedList = _state$schema$nodes2.orderedList
|
|
83
|
+
orderedList = _state$schema$nodes2.orderedList,
|
|
84
|
+
listItem = _state$schema$nodes2.listItem;
|
|
85
|
+
|
|
86
|
+
// When the small font size experiment is enabled, allow block type changes inside lists
|
|
87
|
+
// so that users can toggle between Normal text and Small text within list contexts.
|
|
88
|
+
// Note: taskList/taskItem are not excluded here until blockTaskItem conversion is implemented (WI 4).
|
|
89
|
+
var excludedTypes = allowFontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true) ? [panel, bulletList, orderedList, listItem] : [panel];
|
|
82
90
|
if (editorExperiment('platform_editor_blockquote_in_text_formatting_menu', true)) {
|
|
83
91
|
var hasQuote = false;
|
|
84
92
|
var hasNestedListInQuote = false;
|
|
@@ -99,17 +107,44 @@ export function areBlockTypesDisabled(state) {
|
|
|
99
107
|
return !hasNestedListInQuote;
|
|
100
108
|
});
|
|
101
109
|
return nodesTypes.filter(function (type) {
|
|
102
|
-
return type
|
|
110
|
+
return !excludedTypes.includes(type);
|
|
103
111
|
}).length > 0 && (!hasQuote || hasNestedListInQuote);
|
|
104
112
|
}
|
|
105
113
|
return nodesTypes.filter(function (type) {
|
|
106
|
-
return type
|
|
114
|
+
return !excludedTypes.includes(type);
|
|
107
115
|
}).length > 0;
|
|
108
116
|
}
|
|
109
|
-
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Checks if the current selection is inside a list node (bulletList, orderedList, or taskList).
|
|
120
|
+
* Used to determine which text styles should be enabled when the small font size experiment is active.
|
|
121
|
+
*/
|
|
122
|
+
export function isSelectionInsideListNode(state) {
|
|
123
|
+
if (!state.selection) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
110
126
|
var _state$selection3 = state.selection,
|
|
111
|
-
from = _state$selection3
|
|
112
|
-
to = _state$selection3
|
|
127
|
+
$from = _state$selection3.$from,
|
|
128
|
+
$to = _state$selection3.$to;
|
|
129
|
+
var _state$schema$nodes3 = state.schema.nodes,
|
|
130
|
+
bulletList = _state$schema$nodes3.bulletList,
|
|
131
|
+
orderedList = _state$schema$nodes3.orderedList,
|
|
132
|
+
taskList = _state$schema$nodes3.taskList;
|
|
133
|
+
var listNodeTypes = [bulletList, orderedList, taskList];
|
|
134
|
+
var insideList = false;
|
|
135
|
+
state.doc.nodesBetween($from.pos, $to.pos, function (node) {
|
|
136
|
+
if (node.isBlock && listNodeTypes.indexOf(node.type) >= 0) {
|
|
137
|
+
insideList = true;
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
});
|
|
142
|
+
return insideList;
|
|
143
|
+
}
|
|
144
|
+
var blockStylingIsPresent = function blockStylingIsPresent(state) {
|
|
145
|
+
var _state$selection4 = state.selection,
|
|
146
|
+
from = _state$selection4.from,
|
|
147
|
+
to = _state$selection4.to;
|
|
113
148
|
var isBlockStyling = false;
|
|
114
149
|
state.doc.nodesBetween(from, to, function (node) {
|
|
115
150
|
if (FORMATTING_NODE_TYPES.indexOf(node.type.name) !== -1) {
|
|
@@ -123,9 +158,9 @@ var blockStylingIsPresent = function blockStylingIsPresent(state) {
|
|
|
123
158
|
var marksArePresent = function marksArePresent(state) {
|
|
124
159
|
var activeMarkTypes = FORMATTING_MARK_TYPES.filter(function (mark) {
|
|
125
160
|
if (!!state.schema.marks[mark]) {
|
|
126
|
-
var _state$
|
|
127
|
-
$from = _state$
|
|
128
|
-
empty = _state$
|
|
161
|
+
var _state$selection5 = state.selection,
|
|
162
|
+
$from = _state$selection5.$from,
|
|
163
|
+
empty = _state$selection5.empty;
|
|
129
164
|
var marks = state.schema.marks;
|
|
130
165
|
if (empty) {
|
|
131
166
|
return !!marks[mark].isInSet(state.storedMarks || $from.marks());
|
|
@@ -143,4 +178,40 @@ export var hasBlockQuoteInOptions = function hasBlockQuoteInOptions(dropdownOpti
|
|
|
143
178
|
return !!dropdownOptions.find(function (blockType) {
|
|
144
179
|
return blockType.name === 'blockquote';
|
|
145
180
|
});
|
|
146
|
-
};
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Returns a { from, to } range that extends the selection boundaries outward
|
|
185
|
+
* to include the entirety of any list nodes at either end. If the selection
|
|
186
|
+
* start is inside a list, `from` is pulled back to the list's start; if the
|
|
187
|
+
* selection end is inside a list, `to` is pushed forward to the list's end.
|
|
188
|
+
* Non-list content in the middle is included as-is.
|
|
189
|
+
*/
|
|
190
|
+
export function getSelectionRangeExpandedToLists(tr) {
|
|
191
|
+
var selection = tr.selection;
|
|
192
|
+
var _tr$doc$type$schema$n = tr.doc.type.schema.nodes,
|
|
193
|
+
bulletList = _tr$doc$type$schema$n.bulletList,
|
|
194
|
+
orderedList = _tr$doc$type$schema$n.orderedList,
|
|
195
|
+
taskList = _tr$doc$type$schema$n.taskList;
|
|
196
|
+
var listNodeTypes = [bulletList, orderedList, taskList];
|
|
197
|
+
var from = selection.from;
|
|
198
|
+
var to = selection.to;
|
|
199
|
+
for (var depth = selection.$from.depth; depth > 0; depth--) {
|
|
200
|
+
var node = selection.$from.node(depth);
|
|
201
|
+
if (listNodeTypes.indexOf(node.type) >= 0) {
|
|
202
|
+
from = selection.$from.before(depth);
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
for (var _depth = selection.$to.depth; _depth > 0; _depth--) {
|
|
207
|
+
var _node = selection.$to.node(_depth);
|
|
208
|
+
if (listNodeTypes.indexOf(_node.type) >= 0) {
|
|
209
|
+
to = selection.$to.after(_depth);
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
from: from,
|
|
215
|
+
to: to
|
|
216
|
+
};
|
|
217
|
+
}
|
|
@@ -6,6 +6,8 @@ export type ClearFormattingInputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHO
|
|
|
6
6
|
export declare function setBlockType(name: TextBlockTypes): EditorCommand;
|
|
7
7
|
export declare function setHeading(level: HeadingLevelsAndNormalText, fromBlockQuote?: boolean): EditorCommand;
|
|
8
8
|
export declare function setBlockTypeWithAnalytics(name: TextBlockTypes, inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined, fromBlockQuote?: boolean): EditorCommand;
|
|
9
|
+
export declare function setSmallText(): EditorCommand;
|
|
10
|
+
export declare function setSmallTextWithAnalytics(inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): EditorCommand;
|
|
9
11
|
export declare function setNormalText(fromBlockQuote?: boolean): EditorCommand;
|
|
10
12
|
export declare function clearFormatting(inputMethod: ClearFormattingInputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): EditorCommand;
|
|
11
13
|
export declare function setNormalTextWithAnalytics(inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined, fromBlockQuote?: boolean): EditorCommand;
|
|
@@ -12,4 +12,4 @@ export type BlockTypeState = {
|
|
|
12
12
|
formattingIsPresent?: boolean;
|
|
13
13
|
};
|
|
14
14
|
export declare const pluginKey: PluginKey<BlockTypeState>;
|
|
15
|
-
export declare const createPlugin: (editorAPI: ExtractInjectionAPI<BlockTypePlugin> | undefined, dispatch: (eventName: string | PluginKey, data: any) => void, lastNodeMustBeParagraph?: boolean, includeBlockQuoteAsTextstyleOption?: boolean) => SafePlugin<BlockTypeState>;
|
|
15
|
+
export declare const createPlugin: (editorAPI: ExtractInjectionAPI<BlockTypePlugin> | undefined, dispatch: (eventName: string | PluginKey, data: any) => void, lastNodeMustBeParagraph?: boolean, includeBlockQuoteAsTextstyleOption?: boolean, allowFontSize?: boolean) => SafePlugin<BlockTypeState>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InputRuleWrapper } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import type { BlockType } from './types';
|
|
5
5
|
export declare const isNodeAWrappingBlockNode: (node?: PMNode | null) => boolean;
|
|
6
6
|
export declare const createJoinNodesRule: (match: RegExp, nodeType: NodeType) => InputRuleWrapper;
|
|
@@ -13,7 +13,23 @@ export declare const createWrappingTextBlockRule: ({ match, nodeType, getAttrs,
|
|
|
13
13
|
/**
|
|
14
14
|
* Function will check if changing block types: Paragraph, Heading is enabled.
|
|
15
15
|
*/
|
|
16
|
-
export declare function areBlockTypesDisabled(state: EditorState): boolean;
|
|
16
|
+
export declare function areBlockTypesDisabled(state: EditorState, allowFontSize?: boolean): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if the current selection is inside a list node (bulletList, orderedList, or taskList).
|
|
19
|
+
* Used to determine which text styles should be enabled when the small font size experiment is active.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isSelectionInsideListNode(state: EditorState): boolean;
|
|
17
22
|
export declare const checkFormattingIsPresent: (state: EditorState) => boolean;
|
|
18
23
|
export declare const hasBlockQuoteInOptions: (dropdownOptions: BlockType[]) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Returns a { from, to } range that extends the selection boundaries outward
|
|
26
|
+
* to include the entirety of any list nodes at either end. If the selection
|
|
27
|
+
* start is inside a list, `from` is pulled back to the list's start; if the
|
|
28
|
+
* selection end is inside a list, `to` is pushed forward to the list's end.
|
|
29
|
+
* Non-list content in the middle is included as-is.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getSelectionRangeExpandedToLists(tr: Transaction): {
|
|
32
|
+
from: number;
|
|
33
|
+
to: number;
|
|
34
|
+
};
|
|
19
35
|
export {};
|
|
@@ -6,6 +6,8 @@ export type ClearFormattingInputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHO
|
|
|
6
6
|
export declare function setBlockType(name: TextBlockTypes): EditorCommand;
|
|
7
7
|
export declare function setHeading(level: HeadingLevelsAndNormalText, fromBlockQuote?: boolean): EditorCommand;
|
|
8
8
|
export declare function setBlockTypeWithAnalytics(name: TextBlockTypes, inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined, fromBlockQuote?: boolean): EditorCommand;
|
|
9
|
+
export declare function setSmallText(): EditorCommand;
|
|
10
|
+
export declare function setSmallTextWithAnalytics(inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): EditorCommand;
|
|
9
11
|
export declare function setNormalText(fromBlockQuote?: boolean): EditorCommand;
|
|
10
12
|
export declare function clearFormatting(inputMethod: ClearFormattingInputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): EditorCommand;
|
|
11
13
|
export declare function setNormalTextWithAnalytics(inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined, fromBlockQuote?: boolean): EditorCommand;
|
|
@@ -12,4 +12,4 @@ export type BlockTypeState = {
|
|
|
12
12
|
formattingIsPresent?: boolean;
|
|
13
13
|
};
|
|
14
14
|
export declare const pluginKey: PluginKey<BlockTypeState>;
|
|
15
|
-
export declare const createPlugin: (editorAPI: ExtractInjectionAPI<BlockTypePlugin> | undefined, dispatch: (eventName: string | PluginKey, data: any) => void, lastNodeMustBeParagraph?: boolean, includeBlockQuoteAsTextstyleOption?: boolean) => SafePlugin<BlockTypeState>;
|
|
15
|
+
export declare const createPlugin: (editorAPI: ExtractInjectionAPI<BlockTypePlugin> | undefined, dispatch: (eventName: string | PluginKey, data: any) => void, lastNodeMustBeParagraph?: boolean, includeBlockQuoteAsTextstyleOption?: boolean, allowFontSize?: boolean) => SafePlugin<BlockTypeState>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InputRuleWrapper } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import type { BlockType } from './types';
|
|
5
5
|
export declare const isNodeAWrappingBlockNode: (node?: PMNode | null) => boolean;
|
|
6
6
|
export declare const createJoinNodesRule: (match: RegExp, nodeType: NodeType) => InputRuleWrapper;
|
|
@@ -13,7 +13,23 @@ export declare const createWrappingTextBlockRule: ({ match, nodeType, getAttrs,
|
|
|
13
13
|
/**
|
|
14
14
|
* Function will check if changing block types: Paragraph, Heading is enabled.
|
|
15
15
|
*/
|
|
16
|
-
export declare function areBlockTypesDisabled(state: EditorState): boolean;
|
|
16
|
+
export declare function areBlockTypesDisabled(state: EditorState, allowFontSize?: boolean): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if the current selection is inside a list node (bulletList, orderedList, or taskList).
|
|
19
|
+
* Used to determine which text styles should be enabled when the small font size experiment is active.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isSelectionInsideListNode(state: EditorState): boolean;
|
|
17
22
|
export declare const checkFormattingIsPresent: (state: EditorState) => boolean;
|
|
18
23
|
export declare const hasBlockQuoteInOptions: (dropdownOptions: BlockType[]) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Returns a { from, to } range that extends the selection boundaries outward
|
|
26
|
+
* to include the entirety of any list nodes at either end. If the selection
|
|
27
|
+
* start is inside a list, `from` is pulled back to the list's start; if the
|
|
28
|
+
* selection end is inside a list, `to` is pushed forward to the list's end.
|
|
29
|
+
* Non-list content in the middle is included as-is.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getSelectionRangeExpandedToLists(tr: Transaction): {
|
|
32
|
+
from: number;
|
|
33
|
+
to: number;
|
|
34
|
+
};
|
|
19
35
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-type",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.1.3",
|
|
4
4
|
"description": "BlockType plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"atlaskit:src": "src/index.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@atlaskit/adf-schema": "^52.
|
|
32
|
+
"@atlaskit/adf-schema": "^52.4.0",
|
|
33
33
|
"@atlaskit/css": "^0.19.0",
|
|
34
34
|
"@atlaskit/editor-plugin-analytics": "^8.0.0",
|
|
35
35
|
"@atlaskit/editor-plugin-block-menu": "^7.0.0",
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
51
51
|
"@atlaskit/prosemirror-input-rules": "^3.6.0",
|
|
52
52
|
"@atlaskit/theme": "^22.0.0",
|
|
53
|
-
"@atlaskit/tmp-editor-statsig": "^40.
|
|
53
|
+
"@atlaskit/tmp-editor-statsig": "^40.6.0",
|
|
54
54
|
"@atlaskit/tokens": "^11.1.0",
|
|
55
55
|
"@babel/runtime": "^7.0.0",
|
|
56
56
|
"@compiled/react": "^0.20.0",
|
|
57
57
|
"@emotion/react": "^11.7.1"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@atlaskit/editor-common": "^112.
|
|
60
|
+
"@atlaskit/editor-common": "^112.5.0",
|
|
61
61
|
"react": "^18.2.0",
|
|
62
62
|
"react-dom": "^18.2.0",
|
|
63
63
|
"react-intl-next": "npm:react-intl@^5.18.1"
|