@atlaskit/editor-plugin-block-type 30.0.3 → 30.0.5
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 +12 -0
- package/dist/cjs/blockTypePlugin.js +25 -24
- package/dist/cjs/pm-plugins/block-types.js +52 -43
- package/dist/cjs/pm-plugins/commands/block-type.js +39 -38
- package/dist/cjs/pm-plugins/commands/clear-formatting.js +8 -8
- package/dist/cjs/pm-plugins/input-rule.js +25 -23
- package/dist/cjs/pm-plugins/keymap.js +12 -11
- package/dist/cjs/pm-plugins/main.js +5 -5
- package/dist/cjs/pm-plugins/ui/FloatingToolbarComponent.js +6 -6
- package/dist/cjs/pm-plugins/ui/PrimaryToolbarComponent.js +6 -6
- package/dist/cjs/pm-plugins/ui/ToolbarBlockType/HeadingButton.js +18 -17
- package/dist/cjs/pm-plugins/ui/ToolbarBlockType/QuoteButton.js +9 -8
- package/dist/cjs/pm-plugins/ui/ToolbarBlockType/TextStylesMenuButton.js +16 -14
- package/dist/cjs/pm-plugins/ui/ToolbarBlockType/blocktype-button.js +9 -8
- package/dist/cjs/pm-plugins/ui/ToolbarBlockType/index.js +12 -12
- package/dist/cjs/pm-plugins/ui/ToolbarBlockType/styled.js +5 -4
- package/dist/cjs/pm-plugins/ui/toolbar-components.js +25 -24
- package/dist/cjs/pm-plugins/utils.js +2 -1
- package/dist/cjs/ui/HeadingBlockMenuItem.js +7 -7
- package/dist/cjs/ui/ParagraphBlockMenuItem.js +7 -7
- package/dist/cjs/ui/QuoteBlockMenuItem.js +7 -7
- package/dist/cjs/ui/SmallTextBlockMenuItem.js +9 -8
- package/dist/cjs/ui/index.js +19 -20
- package/dist/cjs/ui/quick-insert/BlockTypeQuickInsertMenuItem.js +28 -28
- package/dist/cjs/ui/quick-insert/getBlockTypeQuickInsertComponents.js +3 -3
- package/dist/es2019/blockTypePlugin.js +4 -3
- package/dist/es2019/pm-plugins/block-types.js +12 -3
- package/dist/es2019/pm-plugins/commands/block-type.js +5 -4
- package/dist/es2019/pm-plugins/commands/clear-formatting.js +1 -1
- package/dist/es2019/pm-plugins/input-rule.js +6 -4
- package/dist/es2019/pm-plugins/keymap.js +4 -3
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/pm-plugins/ui/FloatingToolbarComponent.js +2 -2
- package/dist/es2019/pm-plugins/ui/PrimaryToolbarComponent.js +2 -2
- package/dist/es2019/pm-plugins/ui/ToolbarBlockType/HeadingButton.js +6 -5
- package/dist/es2019/pm-plugins/ui/ToolbarBlockType/QuoteButton.js +5 -4
- package/dist/es2019/pm-plugins/ui/ToolbarBlockType/TextStylesMenuButton.js +6 -4
- package/dist/es2019/pm-plugins/ui/ToolbarBlockType/blocktype-button.js +4 -3
- package/dist/es2019/pm-plugins/ui/ToolbarBlockType/index.js +4 -4
- package/dist/es2019/pm-plugins/ui/ToolbarBlockType/styled.js +3 -2
- package/dist/es2019/pm-plugins/ui/toolbar-components.js +2 -1
- package/dist/es2019/pm-plugins/utils.js +2 -1
- package/dist/es2019/ui/HeadingBlockMenuItem.js +3 -3
- package/dist/es2019/ui/ParagraphBlockMenuItem.js +3 -3
- package/dist/es2019/ui/QuoteBlockMenuItem.js +3 -3
- package/dist/es2019/ui/SmallTextBlockMenuItem.js +4 -3
- package/dist/es2019/ui/index.js +2 -3
- package/dist/es2019/ui/quick-insert/BlockTypeQuickInsertMenuItem.js +2 -2
- package/dist/es2019/ui/quick-insert/getBlockTypeQuickInsertComponents.js +1 -1
- package/dist/esm/blockTypePlugin.js +4 -3
- package/dist/esm/pm-plugins/block-types.js +12 -3
- package/dist/esm/pm-plugins/commands/block-type.js +5 -4
- package/dist/esm/pm-plugins/commands/clear-formatting.js +1 -1
- package/dist/esm/pm-plugins/input-rule.js +6 -4
- package/dist/esm/pm-plugins/keymap.js +4 -3
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/pm-plugins/ui/FloatingToolbarComponent.js +2 -2
- package/dist/esm/pm-plugins/ui/PrimaryToolbarComponent.js +2 -2
- package/dist/esm/pm-plugins/ui/ToolbarBlockType/HeadingButton.js +6 -5
- package/dist/esm/pm-plugins/ui/ToolbarBlockType/QuoteButton.js +5 -4
- package/dist/esm/pm-plugins/ui/ToolbarBlockType/TextStylesMenuButton.js +6 -4
- package/dist/esm/pm-plugins/ui/ToolbarBlockType/blocktype-button.js +4 -3
- package/dist/esm/pm-plugins/ui/ToolbarBlockType/index.js +4 -4
- package/dist/esm/pm-plugins/ui/ToolbarBlockType/styled.js +3 -2
- package/dist/esm/pm-plugins/ui/toolbar-components.js +2 -1
- package/dist/esm/pm-plugins/utils.js +2 -1
- package/dist/esm/ui/HeadingBlockMenuItem.js +3 -3
- package/dist/esm/ui/ParagraphBlockMenuItem.js +3 -3
- package/dist/esm/ui/QuoteBlockMenuItem.js +3 -3
- package/dist/esm/ui/SmallTextBlockMenuItem.js +4 -3
- package/dist/esm/ui/index.js +2 -3
- package/dist/esm/ui/quick-insert/BlockTypeQuickInsertMenuItem.js +2 -2
- package/dist/esm/ui/quick-insert/getBlockTypeQuickInsertComponents.js +1 -1
- package/dist/types/blockTypePluginType.d.ts +13 -11
- package/dist/types/pm-plugins/commands/block-type.d.ts +5 -2
- package/dist/types/pm-plugins/commands/delete-and-move-cursor.d.ts +1 -1
- package/dist/types/pm-plugins/commands/delete-block-content.d.ts +1 -1
- package/dist/types/pm-plugins/commands/split-heading-with-trailing-space.d.ts +1 -1
- package/dist/types/pm-plugins/commands/wrapSelectionIn.d.ts +1 -1
- package/dist/types/pm-plugins/input-rule.d.ts +2 -2
- package/dist/types/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/types.d.ts +1 -1
- package/dist/types/pm-plugins/ui/FloatingToolbarComponent.d.ts +1 -1
- package/dist/types/pm-plugins/ui/PrimaryToolbarComponent.d.ts +1 -1
- package/dist/types/pm-plugins/ui/ToolbarBlockType/HeadingButton.d.ts +1 -1
- package/dist/types/pm-plugins/ui/ToolbarBlockType/QuoteButton.d.ts +1 -1
- package/dist/types/pm-plugins/ui/ToolbarBlockType/TextStylesMenuButton.d.ts +1 -1
- package/dist/types/pm-plugins/ui/ToolbarBlockType/index.d.ts +2 -2
- package/dist/types/pm-plugins/ui/toolbar-components.d.ts +2 -2
- package/dist/types/pm-plugins/utils.d.ts +1 -1
- package/dist/types/ui/HeadingBlockMenuItem.d.ts +1 -1
- package/dist/types/ui/ParagraphBlockMenuItem.d.ts +1 -1
- package/dist/types/ui/QuoteBlockMenuItem.d.ts +1 -1
- package/dist/types/ui/SmallTextBlockMenuItem.d.ts +1 -1
- package/dist/types/ui/index.d.ts +2 -2
- package/dist/types/ui/quick-insert/BlockTypeQuickInsertMenuItem.d.ts +2 -1
- package/dist/types/ui/quick-insert/getBlockTypeQuickInsertComponents.d.ts +1 -1
- package/package.json +2 -2
|
@@ -6,12 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var _enums = require("@atlaskit/editor-common/analytics/types/enums");
|
|
10
|
+
var _insertBlock = require("@atlaskit/editor-common/commands/insert-block");
|
|
11
11
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
12
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
|
-
var
|
|
14
|
-
var
|
|
13
|
+
var _inputRules = require("@atlaskit/editor-common/utils/input-rules");
|
|
14
|
+
var _constants = require("@atlaskit/prosemirror-input-rules/constants");
|
|
15
|
+
var _utils2 = require("@atlaskit/prosemirror-input-rules/utils");
|
|
16
|
+
var _utils3 = require("./utils");
|
|
15
17
|
var MAX_HEADING_LEVEL = 6;
|
|
16
18
|
|
|
17
19
|
// Ignored via go/ees005
|
|
@@ -23,7 +25,7 @@ function getHeadingLevel(match) {
|
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
function headingRule(nodeType, maxLevel) {
|
|
26
|
-
return (0,
|
|
28
|
+
return (0, _utils3.createWrappingTextBlockRule)({
|
|
27
29
|
// Ignored via go/ees005
|
|
28
30
|
// eslint-disable-next-line require-unicode-regexp
|
|
29
31
|
match: new RegExp('^(#{1,' + maxLevel + '})\\s$'),
|
|
@@ -32,7 +34,7 @@ function headingRule(nodeType, maxLevel) {
|
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
36
|
function blockQuoteRule(nodeType) {
|
|
35
|
-
return (0,
|
|
37
|
+
return (0, _utils3.createJoinNodesRule)(BLOCK_QUOTE_REGEX, nodeType);
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
/**
|
|
@@ -47,22 +49,22 @@ function getHeadingRules(editorAnalyticsAPI, schema) {
|
|
|
47
49
|
var leftNodeReplacementHashRule = (0, _utils.createRule)(
|
|
48
50
|
// Ignored via go/ees005
|
|
49
51
|
// eslint-disable-next-line require-unicode-regexp
|
|
50
|
-
new RegExp("".concat(
|
|
52
|
+
new RegExp("".concat(_constants.leafNodeReplacementCharacter, "(#{1,6})\\s$")), function (state, match, start, end) {
|
|
51
53
|
var level = match[1].length;
|
|
52
|
-
return (0,
|
|
54
|
+
return (0, _insertBlock.insertBlock)(state, schema.nodes.heading, start, end, {
|
|
53
55
|
level: level
|
|
54
56
|
});
|
|
55
57
|
});
|
|
56
58
|
|
|
57
59
|
// New analytics handler
|
|
58
|
-
var ruleWithHeadingAnalytics = (0,
|
|
60
|
+
var ruleWithHeadingAnalytics = (0, _inputRules.inputRuleWithAnalytics)(function (_state, matchResult) {
|
|
59
61
|
return {
|
|
60
|
-
action:
|
|
61
|
-
actionSubject:
|
|
62
|
-
eventType:
|
|
63
|
-
actionSubjectId:
|
|
62
|
+
action: _enums.ACTION.FORMATTED,
|
|
63
|
+
actionSubject: _enums.ACTION_SUBJECT.TEXT,
|
|
64
|
+
eventType: _enums.EVENT_TYPE.TRACK,
|
|
65
|
+
actionSubjectId: _enums.ACTION_SUBJECT_ID.FORMAT_HEADING,
|
|
64
66
|
attributes: {
|
|
65
|
-
inputMethod:
|
|
67
|
+
inputMethod: _enums.INPUT_METHOD.FORMATTING,
|
|
66
68
|
newHeadingLevel: getHeadingLevel(matchResult).level
|
|
67
69
|
}
|
|
68
70
|
};
|
|
@@ -82,18 +84,18 @@ function getBlockQuoteRules(editorAnalyticsAPI, schema) {
|
|
|
82
84
|
var leftNodeReplacementGreatherRule = (0, _utils.createRule)(
|
|
83
85
|
// Ignored via go/ees005
|
|
84
86
|
// eslint-disable-next-line require-unicode-regexp
|
|
85
|
-
new RegExp("".concat(
|
|
86
|
-
return (0,
|
|
87
|
+
new RegExp("".concat(_constants.leafNodeReplacementCharacter, "\\s*>\\s$")), function (state, _match, start, end) {
|
|
88
|
+
return (0, _insertBlock.insertBlock)(state, schema.nodes.blockquote, start, end);
|
|
87
89
|
});
|
|
88
90
|
|
|
89
91
|
// Analytics V3 handler
|
|
90
|
-
var ruleWithBlockQuoteAnalytics = (0,
|
|
91
|
-
action:
|
|
92
|
-
actionSubject:
|
|
93
|
-
eventType:
|
|
94
|
-
actionSubjectId:
|
|
92
|
+
var ruleWithBlockQuoteAnalytics = (0, _inputRules.inputRuleWithAnalytics)({
|
|
93
|
+
action: _enums.ACTION.FORMATTED,
|
|
94
|
+
actionSubject: _enums.ACTION_SUBJECT.TEXT,
|
|
95
|
+
eventType: _enums.EVENT_TYPE.TRACK,
|
|
96
|
+
actionSubjectId: _enums.ACTION_SUBJECT_ID.FORMAT_BLOCK_QUOTE,
|
|
95
97
|
attributes: {
|
|
96
|
-
inputMethod:
|
|
98
|
+
inputMethod: _enums.INPUT_METHOD.FORMATTING
|
|
97
99
|
}
|
|
98
100
|
}, editorAnalyticsAPI);
|
|
99
101
|
return [ruleWithBlockQuoteAnalytics(greatherThanRule), ruleWithBlockQuoteAnalytics(leftNodeReplacementGreatherRule)];
|
|
@@ -107,7 +109,7 @@ function inputRulePlugin(editorAnalyticsAPI, schema, featureFlags) {
|
|
|
107
109
|
rules.push.apply(rules, (0, _toConsumableArray2.default)(getBlockQuoteRules(editorAnalyticsAPI, schema)));
|
|
108
110
|
}
|
|
109
111
|
if (rules.length !== 0) {
|
|
110
|
-
return new _safePlugin.SafePlugin((0,
|
|
112
|
+
return new _safePlugin.SafePlugin((0, _utils2.createPlugin)('block-type', rules, {
|
|
111
113
|
isBlockNodeRule: true
|
|
112
114
|
}));
|
|
113
115
|
}
|
|
@@ -5,10 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = keymapPlugin;
|
|
8
|
-
var
|
|
8
|
+
var _enums = require("@atlaskit/editor-common/analytics/types/enums");
|
|
9
|
+
var _keymap = require("@atlaskit/editor-common/keymap");
|
|
9
10
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
10
|
-
var
|
|
11
|
-
var
|
|
11
|
+
var _commands = require("@atlaskit/editor-common/utils/commands");
|
|
12
|
+
var _commands2 = require("@atlaskit/editor-prosemirror/commands");
|
|
12
13
|
var _redo = require("@atlaskit/prosemirror-history/redo");
|
|
13
14
|
var _undo = require("@atlaskit/prosemirror-history/undo");
|
|
14
15
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
@@ -17,19 +18,19 @@ var _blockType = require("./commands/block-type");
|
|
|
17
18
|
var _deleteAndMoveCursor = require("./commands/delete-and-move-cursor");
|
|
18
19
|
var _deleteBlockContent = require("./commands/delete-block-content");
|
|
19
20
|
var _splitHeadingWithTrailingSpace = require("./commands/split-heading-with-trailing-space");
|
|
20
|
-
var
|
|
21
|
+
var _utils = require("./utils");
|
|
21
22
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
22
23
|
// Ignored via go/ees005
|
|
23
24
|
// eslint-disable-next-line import/no-namespace
|
|
24
25
|
|
|
25
|
-
var backspaceCommand = (0,
|
|
26
|
-
var del = (0,
|
|
26
|
+
var backspaceCommand = (0, _commands2.chainCommands)(_blockType.cleanUpAtTheStartOfDocument, (0, _deleteBlockContent.deleteBlockContent)(_utils.isNodeAWrappingBlockNode), _deleteAndMoveCursor.deleteAndMoveCursor);
|
|
27
|
+
var del = (0, _commands2.chainCommands)((0, _commands.deleteEmptyParagraphAndMoveBlockUp)(_utils.isNodeAWrappingBlockNode), (0, _deleteBlockContent.deleteBlockContent)(_utils.isNodeAWrappingBlockNode), _deleteAndMoveCursor.deleteAndMoveCursor);
|
|
27
28
|
function keymapPlugin(editorAnalyticsApi, schema, _featureFlags) {
|
|
28
29
|
var list = {};
|
|
29
30
|
(0, _keymaps.bindKeymapWithCommand)(
|
|
30
31
|
// Ignored via go/ees005
|
|
31
32
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
32
|
-
_keymaps.insertNewLine.common, (0,
|
|
33
|
+
_keymaps.insertNewLine.common, (0, _commands.insertNewLineWithAnalytics)(editorAnalyticsApi), list);
|
|
33
34
|
|
|
34
35
|
// Fixes the "Enter after a heading with trailing whitespace creates another
|
|
35
36
|
// heading instead of a paragraph" bug. The command is a no-op (returns false)
|
|
@@ -41,10 +42,10 @@ function keymapPlugin(editorAnalyticsApi, schema, _featureFlags) {
|
|
|
41
42
|
}
|
|
42
43
|
// Ignored via go/ees005
|
|
43
44
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
44
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveUp.common,
|
|
45
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveUp.common, _commands.createNewParagraphAbove, list);
|
|
45
46
|
// Ignored via go/ees005
|
|
46
47
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
47
|
-
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveDown.common,
|
|
48
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveDown.common, _commands.createNewParagraphBelow, list);
|
|
48
49
|
// Ignored via go/ees005
|
|
49
50
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
50
51
|
(0, _keymaps.bindKeymapWithCommand)((0, _keymaps.findKeyMapForBrowser)(_keymaps.redo), _redo.redo, list);
|
|
@@ -65,7 +66,7 @@ function keymapPlugin(editorAnalyticsApi, schema, _featureFlags) {
|
|
|
65
66
|
(0, _keymaps.bindKeymapWithCommand)(
|
|
66
67
|
// Ignored via go/ees005
|
|
67
68
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
68
|
-
(0, _keymaps.findShortcutByKeymap)(_keymaps.toggleBlockQuote), (0, _blockType.insertBlockQuoteWithAnalytics)(
|
|
69
|
+
(0, _keymaps.findShortcutByKeymap)(_keymaps.toggleBlockQuote), (0, _blockType.insertBlockQuoteWithAnalytics)(_enums.INPUT_METHOD.KEYBOARD, editorAnalyticsApi), list);
|
|
69
70
|
}
|
|
70
|
-
return (0,
|
|
71
|
+
return (0, _keymap.keymap)(list);
|
|
71
72
|
}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.pluginKey = exports.createPlugin = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var
|
|
9
|
+
var _enums = require("@atlaskit/editor-common/analytics/types/enums");
|
|
10
10
|
var _blockType = require("@atlaskit/editor-common/block-type");
|
|
11
11
|
var _browser = require("@atlaskit/editor-common/browser");
|
|
12
12
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
@@ -82,9 +82,9 @@ var detectBlockType = function detectBlockType(availableBlockTypes, state) {
|
|
|
82
82
|
};
|
|
83
83
|
var autoformatHeading = function autoformatHeading(headingLevel, editorAnalyticsApi) {
|
|
84
84
|
if (headingLevel === 0) {
|
|
85
|
-
return (0, _blockType2.setNormalTextWithAnalytics)(
|
|
85
|
+
return (0, _blockType2.setNormalTextWithAnalytics)(_enums.INPUT_METHOD.FORMATTING, editorAnalyticsApi);
|
|
86
86
|
}
|
|
87
|
-
return (0, _blockType2.setHeadingWithAnalytics)(headingLevel,
|
|
87
|
+
return (0, _blockType2.setHeadingWithAnalytics)(headingLevel, _enums.INPUT_METHOD.FORMATTING, editorAnalyticsApi);
|
|
88
88
|
};
|
|
89
89
|
var pluginKey = exports.pluginKey = new _state.PluginKey('blockTypePlugin');
|
|
90
90
|
var createPlugin = exports.createPlugin = function createPlugin(editorAPI, dispatch, lastNodeMustBeParagraph, includeBlockQuoteAsTextstyleOption, allowFontSize) {
|
|
@@ -163,10 +163,10 @@ var createPlugin = exports.createPlugin = function createPlugin(editorAPI, dispa
|
|
|
163
163
|
} else if (event.keyCode === _consts.KEY_7 && event.altKey) {
|
|
164
164
|
if (browser.mac && event.metaKey) {
|
|
165
165
|
var _editorAPI$core$actio3, _editorAPI$core3;
|
|
166
|
-
return (_editorAPI$core$actio3 = editorAPI === null || editorAPI === void 0 || (_editorAPI$core3 = editorAPI.core) === null || _editorAPI$core3 === void 0 ? void 0 : _editorAPI$core3.actions.execute((0, _blockType2.setSmallTextWithAnalytics)(
|
|
166
|
+
return (_editorAPI$core$actio3 = editorAPI === null || editorAPI === void 0 || (_editorAPI$core3 = editorAPI.core) === null || _editorAPI$core3 === void 0 ? void 0 : _editorAPI$core3.actions.execute((0, _blockType2.setSmallTextWithAnalytics)(_enums.INPUT_METHOD.SHORTCUT, editorAnalyticsApi))) !== null && _editorAPI$core$actio3 !== void 0 ? _editorAPI$core$actio3 : false;
|
|
167
167
|
} else if (!browser.mac && event.ctrlKey && altKeyLocation !== event.DOM_KEY_LOCATION_RIGHT) {
|
|
168
168
|
var _editorAPI$core$actio4, _editorAPI$core4;
|
|
169
|
-
return (_editorAPI$core$actio4 = editorAPI === null || editorAPI === void 0 || (_editorAPI$core4 = editorAPI.core) === null || _editorAPI$core4 === void 0 ? void 0 : _editorAPI$core4.actions.execute((0, _blockType2.setSmallTextWithAnalytics)(
|
|
169
|
+
return (_editorAPI$core$actio4 = editorAPI === null || editorAPI === void 0 || (_editorAPI$core4 = editorAPI.core) === null || _editorAPI$core4 === void 0 ? void 0 : _editorAPI$core4.actions.execute((0, _blockType2.setSmallTextWithAnalytics)(_enums.INPUT_METHOD.SHORTCUT, editorAnalyticsApi))) !== null && _editorAPI$core$actio4 !== void 0 ? _editorAPI$core$actio4 : false;
|
|
170
170
|
}
|
|
171
171
|
} else if (event.key === 'Alt') {
|
|
172
172
|
// event.location is for the current key only; when a user hits Ctrl-Alt-1 the
|
|
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.FloatingToolbarComponent = FloatingToolbarComponent;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var
|
|
11
|
-
var
|
|
10
|
+
var _enums = require("@atlaskit/editor-common/analytics/types/enums");
|
|
11
|
+
var _useSharedPluginStateWithSelector = require("@atlaskit/editor-common/useSharedPluginStateWithSelector");
|
|
12
12
|
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
13
13
|
var _ToolbarBlockType = _interopRequireDefault(require("./ToolbarBlockType"));
|
|
14
14
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -20,7 +20,7 @@ var FloatingToolbarSettings = {
|
|
|
20
20
|
};
|
|
21
21
|
function FloatingToolbarComponent(_ref) {
|
|
22
22
|
var api = _ref.api;
|
|
23
|
-
var _useSharedPluginState = (0,
|
|
23
|
+
var _useSharedPluginState = (0, _useSharedPluginStateWithSelector.useSharedPluginStateWithSelector)(api, ['blockType'], function (states) {
|
|
24
24
|
var _states$blockTypeStat, _states$blockTypeStat2, _states$blockTypeStat3, _states$blockTypeStat4, _states$blockTypeStat5;
|
|
25
25
|
return {
|
|
26
26
|
currentBlockType: (_states$blockTypeStat = states.blockTypeState) === null || _states$blockTypeStat === void 0 ? void 0 : _states$blockTypeStat.currentBlockType,
|
|
@@ -37,15 +37,15 @@ function FloatingToolbarComponent(_ref) {
|
|
|
37
37
|
formattingIsPresent = _useSharedPluginState.formattingIsPresent;
|
|
38
38
|
var boundSetBlockType = (0, _react.useCallback)(function (name, fromBlockQuote) {
|
|
39
39
|
var _api$core, _api$blockType;
|
|
40
|
-
return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? 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(name,
|
|
40
|
+
return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? 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(name, _enums.INPUT_METHOD.FLOATING_TB, fromBlockQuote));
|
|
41
41
|
}, [api]);
|
|
42
42
|
var wrapBlockQuote = (0, _react.useCallback)(function () {
|
|
43
43
|
var _api$core2, _api$blockType2;
|
|
44
|
-
return api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(api === null || api === void 0 || (_api$blockType2 = api.blockType) === null || _api$blockType2 === void 0 || (_api$blockType2 = _api$blockType2.commands) === null || _api$blockType2 === void 0 ? void 0 : _api$blockType2.insertBlockQuote(
|
|
44
|
+
return api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(api === null || api === void 0 || (_api$blockType2 = api.blockType) === null || _api$blockType2 === void 0 || (_api$blockType2 = _api$blockType2.commands) === null || _api$blockType2 === void 0 ? void 0 : _api$blockType2.insertBlockQuote(_enums.INPUT_METHOD.FLOATING_TB));
|
|
45
45
|
}, [api]);
|
|
46
46
|
var clearFormatting = (0, _react.useCallback)(function () {
|
|
47
47
|
var _api$core3, _api$blockType3;
|
|
48
|
-
return api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(api === null || api === void 0 || (_api$blockType3 = api.blockType) === null || _api$blockType3 === void 0 || (_api$blockType3 = _api$blockType3.commands) === null || _api$blockType3 === void 0 ? void 0 : _api$blockType3.clearFormatting(
|
|
48
|
+
return api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(api === null || api === void 0 || (_api$blockType3 = api.blockType) === null || _api$blockType3 === void 0 || (_api$blockType3 = _api$blockType3.commands) === null || _api$blockType3 === void 0 ? void 0 : _api$blockType3.clearFormatting(_enums.INPUT_METHOD.FLOATING_TB));
|
|
49
49
|
}, [api]);
|
|
50
50
|
return /*#__PURE__*/_react.default.createElement(_ToolbarBlockType.default, {
|
|
51
51
|
isSmall: FloatingToolbarSettings.isSmall,
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.PrimaryToolbarComponent = PrimaryToolbarComponent;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var _enums = require("@atlaskit/editor-common/analytics/types/enums");
|
|
10
|
+
var _useSharedPluginStateWithSelector = require("@atlaskit/editor-common/useSharedPluginStateWithSelector");
|
|
11
11
|
var _ToolbarBlockType = _interopRequireDefault(require("./ToolbarBlockType"));
|
|
12
12
|
function PrimaryToolbarComponent(_ref) {
|
|
13
13
|
var api = _ref.api,
|
|
@@ -18,7 +18,7 @@ function PrimaryToolbarComponent(_ref) {
|
|
|
18
18
|
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
19
19
|
popupsScrollableElement = _ref.popupsScrollableElement,
|
|
20
20
|
shouldUseDefaultRole = _ref.shouldUseDefaultRole;
|
|
21
|
-
var _useSharedPluginState = (0,
|
|
21
|
+
var _useSharedPluginState = (0, _useSharedPluginStateWithSelector.useSharedPluginStateWithSelector)(api, ['blockType'], function (states) {
|
|
22
22
|
var _states$blockTypeStat, _states$blockTypeStat2, _states$blockTypeStat3, _states$blockTypeStat4, _states$blockTypeStat5;
|
|
23
23
|
return {
|
|
24
24
|
currentBlockType: (_states$blockTypeStat = states.blockTypeState) === null || _states$blockTypeStat === void 0 ? void 0 : _states$blockTypeStat.currentBlockType,
|
|
@@ -35,15 +35,15 @@ function PrimaryToolbarComponent(_ref) {
|
|
|
35
35
|
formattingIsPresent = _useSharedPluginState.formattingIsPresent;
|
|
36
36
|
var boundSetBlockType = function boundSetBlockType(name, fromBlockQuote) {
|
|
37
37
|
var _api$core, _api$blockType;
|
|
38
|
-
return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? 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(name,
|
|
38
|
+
return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? 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(name, _enums.INPUT_METHOD.TOOLBAR, fromBlockQuote));
|
|
39
39
|
};
|
|
40
40
|
var wrapBlockQuote = function wrapBlockQuote() {
|
|
41
41
|
var _api$core2, _api$blockType2;
|
|
42
|
-
return api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(api === null || api === void 0 || (_api$blockType2 = api.blockType) === null || _api$blockType2 === void 0 || (_api$blockType2 = _api$blockType2.commands) === null || _api$blockType2 === void 0 ? void 0 : _api$blockType2.insertBlockQuote(
|
|
42
|
+
return api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(api === null || api === void 0 || (_api$blockType2 = api.blockType) === null || _api$blockType2 === void 0 || (_api$blockType2 = _api$blockType2.commands) === null || _api$blockType2 === void 0 ? void 0 : _api$blockType2.insertBlockQuote(_enums.INPUT_METHOD.TOOLBAR));
|
|
43
43
|
};
|
|
44
44
|
var clearFormatting = function clearFormatting() {
|
|
45
45
|
var _api$core3, _api$blockType3;
|
|
46
|
-
return api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(api === null || api === void 0 || (_api$blockType3 = api.blockType) === null || _api$blockType3 === void 0 || (_api$blockType3 = _api$blockType3.commands) === null || _api$blockType3 === void 0 ? void 0 : _api$blockType3.clearFormatting(
|
|
46
|
+
return api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(api === null || api === void 0 || (_api$blockType3 = api.blockType) === null || _api$blockType3 === void 0 || (_api$blockType3 = _api$blockType3.commands) === null || _api$blockType3 === void 0 ? void 0 : _api$blockType3.clearFormatting(_enums.INPUT_METHOD.TOOLBAR));
|
|
47
47
|
};
|
|
48
48
|
return /*#__PURE__*/_react.default.createElement(_ToolbarBlockType.default, {
|
|
49
49
|
isSmall: isSmall,
|
|
@@ -9,12 +9,13 @@ exports.HeadingButton = void 0;
|
|
|
9
9
|
var _runtime = require("@compiled/react/runtime");
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
var _reactIntl = require("react-intl");
|
|
12
|
-
var
|
|
12
|
+
var _enums = require("@atlaskit/editor-common/analytics/types/enums");
|
|
13
|
+
var _getEditorUgcToken = _interopRequireDefault(require("@atlaskit/editor-common/get-editor-ugc-token"));
|
|
13
14
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
15
|
+
var _context = require("@atlaskit/editor-common/toolbar/context");
|
|
16
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/useSharedPluginStateSelector");
|
|
17
|
+
var _toolbarDropdownItem = require("@atlaskit/editor-toolbar/toolbar-dropdown-item");
|
|
18
|
+
var _toolbarKeyboardShortcutHint = require("@atlaskit/editor-toolbar/toolbar-keyboard-shortcut-hint");
|
|
18
19
|
var _utils = require("../../utils");
|
|
19
20
|
var _editorUGCToken;
|
|
20
21
|
/* eslint-disable @atlaskit/ui-styling-standard/no-unsafe-values */
|
|
@@ -22,42 +23,42 @@ var _editorUGCToken;
|
|
|
22
23
|
var headingTextProps = {
|
|
23
24
|
normal: {
|
|
24
25
|
style: {
|
|
25
|
-
font: (0,
|
|
26
|
+
font: (0, _getEditorUgcToken.default)('editor.font.body')
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
29
|
smallText: {
|
|
29
30
|
style: {
|
|
30
|
-
font: (_editorUGCToken = (0,
|
|
31
|
+
font: (_editorUGCToken = (0, _getEditorUgcToken.default)('editor.font.body.small')) !== null && _editorUGCToken !== void 0 ? _editorUGCToken : (0, _getEditorUgcToken.default)('editor.font.body')
|
|
31
32
|
}
|
|
32
33
|
},
|
|
33
34
|
heading1: {
|
|
34
35
|
style: {
|
|
35
|
-
font: (0,
|
|
36
|
+
font: (0, _getEditorUgcToken.default)('editor.font.heading.h1')
|
|
36
37
|
}
|
|
37
38
|
},
|
|
38
39
|
heading2: {
|
|
39
40
|
style: {
|
|
40
|
-
font: (0,
|
|
41
|
+
font: (0, _getEditorUgcToken.default)('editor.font.heading.h2')
|
|
41
42
|
}
|
|
42
43
|
},
|
|
43
44
|
heading3: {
|
|
44
45
|
style: {
|
|
45
|
-
font: (0,
|
|
46
|
+
font: (0, _getEditorUgcToken.default)('editor.font.heading.h3')
|
|
46
47
|
}
|
|
47
48
|
},
|
|
48
49
|
heading4: {
|
|
49
50
|
style: {
|
|
50
|
-
font: (0,
|
|
51
|
+
font: (0, _getEditorUgcToken.default)('editor.font.heading.h4')
|
|
51
52
|
}
|
|
52
53
|
},
|
|
53
54
|
heading5: {
|
|
54
55
|
style: {
|
|
55
|
-
font: (0,
|
|
56
|
+
font: (0, _getEditorUgcToken.default)('editor.font.heading.h5')
|
|
56
57
|
}
|
|
57
58
|
},
|
|
58
59
|
heading6: {
|
|
59
60
|
style: {
|
|
60
|
-
font: (0,
|
|
61
|
+
font: (0, _getEditorUgcToken.default)('editor.font.heading.h6')
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
};
|
|
@@ -89,7 +90,7 @@ var HeadingButton = exports.HeadingButton = function HeadingButton(_ref2) {
|
|
|
89
90
|
formatMessage = _useIntl.formatMessage;
|
|
90
91
|
var currentBlockType = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.currentBlockType');
|
|
91
92
|
var availableBlockTypesInDropdown = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.availableBlockTypesInDropdown');
|
|
92
|
-
var _useEditorToolbar = (0,
|
|
93
|
+
var _useEditorToolbar = (0, _context.useEditorToolbar)(),
|
|
93
94
|
editorView = _useEditorToolbar.editorView;
|
|
94
95
|
if (!(availableBlockTypesInDropdown !== null && availableBlockTypesInDropdown !== void 0 && availableBlockTypesInDropdown.some(function (availableBlockType) {
|
|
95
96
|
return availableBlockType.name === blockType.name;
|
|
@@ -103,13 +104,13 @@ var HeadingButton = exports.HeadingButton = function HeadingButton(_ref2) {
|
|
|
103
104
|
if (isDisabled) {
|
|
104
105
|
return;
|
|
105
106
|
}
|
|
106
|
-
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,
|
|
107
|
+
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, _enums.INPUT_METHOD.TOOLBAR, fromBlockQuote));
|
|
107
108
|
};
|
|
108
109
|
var shortcut = (0, _keymaps.formatShortcut)(shortcuts[blockType.name]);
|
|
109
110
|
var isSelected = (currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name) === blockType.name;
|
|
110
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
111
|
+
return /*#__PURE__*/_react.default.createElement(_toolbarDropdownItem.ToolbarDropdownItem, {
|
|
111
112
|
elemBefore: blockType.icon,
|
|
112
|
-
elemAfter: shortcut ? /*#__PURE__*/_react.default.createElement(
|
|
113
|
+
elemAfter: shortcut ? /*#__PURE__*/_react.default.createElement(_toolbarKeyboardShortcutHint.ToolbarKeyboardShortcutHint, {
|
|
113
114
|
shortcut: shortcut
|
|
114
115
|
}) : undefined,
|
|
115
116
|
onClick: onClick,
|
|
@@ -7,11 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.QuoteButton = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactIntl = require("react-intl");
|
|
10
|
-
var
|
|
10
|
+
var _enums = require("@atlaskit/editor-common/analytics/types/enums");
|
|
11
11
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
12
|
-
var
|
|
13
|
-
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/
|
|
14
|
-
var
|
|
12
|
+
var _context = require("@atlaskit/editor-common/toolbar/context");
|
|
13
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/useSharedPluginStateSelector");
|
|
14
|
+
var _toolbarDropdownItem = require("@atlaskit/editor-toolbar/toolbar-dropdown-item");
|
|
15
|
+
var _toolbarKeyboardShortcutHint = require("@atlaskit/editor-toolbar/toolbar-keyboard-shortcut-hint");
|
|
15
16
|
var _utils = require("../../utils");
|
|
16
17
|
var shouldDisableQuoteButton = function shouldDisableQuoteButton(state) {
|
|
17
18
|
if (!state) {
|
|
@@ -26,7 +27,7 @@ var QuoteButton = exports.QuoteButton = function QuoteButton(_ref) {
|
|
|
26
27
|
formatMessage = _useIntl.formatMessage;
|
|
27
28
|
var availableBlockTypesInDropdown = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.availableBlockTypesInDropdown');
|
|
28
29
|
var currentBlockType = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.currentBlockType');
|
|
29
|
-
var _useEditorToolbar = (0,
|
|
30
|
+
var _useEditorToolbar = (0, _context.useEditorToolbar)(),
|
|
30
31
|
editorView = _useEditorToolbar.editorView;
|
|
31
32
|
if (!(availableBlockTypesInDropdown !== null && availableBlockTypesInDropdown !== void 0 && availableBlockTypesInDropdown.some(function (availableBlockType) {
|
|
32
33
|
return availableBlockType.name === blockType.name;
|
|
@@ -39,13 +40,13 @@ var QuoteButton = exports.QuoteButton = function QuoteButton(_ref) {
|
|
|
39
40
|
if (isDisabled) {
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
|
-
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(
|
|
43
|
+
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(_enums.INPUT_METHOD.TOOLBAR));
|
|
43
44
|
};
|
|
44
45
|
var shortcut = (0, _keymaps.formatShortcut)(_keymaps.toggleBlockQuote);
|
|
45
46
|
var isSelected = currentBlockType === blockType;
|
|
46
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
47
|
+
return /*#__PURE__*/_react.default.createElement(_toolbarDropdownItem.ToolbarDropdownItem, {
|
|
47
48
|
elemBefore: blockType.icon,
|
|
48
|
-
elemAfter: shortcut ? /*#__PURE__*/_react.default.createElement(
|
|
49
|
+
elemAfter: shortcut ? /*#__PURE__*/_react.default.createElement(_toolbarKeyboardShortcutHint.ToolbarKeyboardShortcutHint, {
|
|
49
50
|
shortcut: shortcut
|
|
50
51
|
}) : undefined,
|
|
51
52
|
onClick: onClick,
|
|
@@ -7,10 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.TextStylesMenuButton = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _reactIntl = require("react-intl");
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
10
|
+
var _toolbar = require("@atlaskit/editor-common/messages/toolbar");
|
|
11
|
+
var _context = require("@atlaskit/editor-common/toolbar/context");
|
|
12
|
+
var _useSharedPluginStateWithSelector = require("@atlaskit/editor-common/useSharedPluginStateWithSelector");
|
|
13
|
+
var _textIcon = require("@atlaskit/editor-toolbar/text-icon");
|
|
14
|
+
var _toolbarDropdownMenu = require("@atlaskit/editor-toolbar/toolbar-dropdown-menu");
|
|
15
|
+
var _toolbarTooltip = require("@atlaskit/editor-toolbar/toolbar-tooltip");
|
|
14
16
|
var _blockTypes = require("../../block-types");
|
|
15
17
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
16
18
|
var selectPluginState = function selectPluginState(state) {
|
|
@@ -21,7 +23,7 @@ var selectPluginState = function selectPluginState(state) {
|
|
|
21
23
|
};
|
|
22
24
|
};
|
|
23
25
|
var usePluginState = function usePluginState(api) {
|
|
24
|
-
return (0,
|
|
26
|
+
return (0, _useSharedPluginStateWithSelector.useSharedPluginStateWithSelector)(api, ['blockType'], selectPluginState);
|
|
25
27
|
};
|
|
26
28
|
var TextStylesMenuButton = exports.TextStylesMenuButton = function TextStylesMenuButton(_ref) {
|
|
27
29
|
var _Object$values$find;
|
|
@@ -36,7 +38,7 @@ var TextStylesMenuButton = exports.TextStylesMenuButton = function TextStylesMen
|
|
|
36
38
|
var blockTypes = (0, _blockTypes.toolbarBlockTypesWithRank)({
|
|
37
39
|
allowFontSize: allowFontSize
|
|
38
40
|
});
|
|
39
|
-
var _useEditorToolbar = (0,
|
|
41
|
+
var _useEditorToolbar = (0, _context.useEditorToolbar)(),
|
|
40
42
|
editorAppearance = _useEditorToolbar.editorAppearance;
|
|
41
43
|
var CurrentIcon = (_Object$values$find = Object.values(blockTypes).find(function (blockType) {
|
|
42
44
|
return blockType.name === (currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name);
|
|
@@ -45,27 +47,27 @@ var TextStylesMenuButton = exports.TextStylesMenuButton = function TextStylesMen
|
|
|
45
47
|
var TriggerIcon = (0, _react.useMemo)(function () {
|
|
46
48
|
if (editorAppearance === 'full-page') {
|
|
47
49
|
var hasCurrentBlockType = currentBlockType && CurrentIcon;
|
|
48
|
-
var Icon = hasCurrentBlockType ? CurrentIcon :
|
|
50
|
+
var Icon = hasCurrentBlockType ? CurrentIcon : _textIcon.TextIcon;
|
|
49
51
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Icon, {
|
|
50
52
|
label: "",
|
|
51
53
|
size: "small"
|
|
52
54
|
}), hasCurrentBlockType ? formatMessage(currentBlockType.title) : formatMessage(normalText.title));
|
|
53
55
|
}
|
|
54
56
|
return CurrentIcon ? /*#__PURE__*/_react.default.createElement(CurrentIcon, {
|
|
55
|
-
label: "".concat(currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name, " ").concat(formatMessage(
|
|
57
|
+
label: "".concat(currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name, " ").concat(formatMessage(_toolbar.toolbarMessages.textStylesTooltip)),
|
|
56
58
|
size: "small"
|
|
57
|
-
}) : /*#__PURE__*/_react.default.createElement(
|
|
58
|
-
label: formatMessage(
|
|
59
|
+
}) : /*#__PURE__*/_react.default.createElement(_textIcon.TextIcon, {
|
|
60
|
+
label: formatMessage(_toolbar.toolbarMessages.textStylesTooltip),
|
|
59
61
|
size: "small"
|
|
60
62
|
});
|
|
61
63
|
}, [editorAppearance, currentBlockType, CurrentIcon, normalText, formatMessage]);
|
|
62
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
64
|
+
return /*#__PURE__*/_react.default.createElement(_toolbarDropdownMenu.ToolbarDropdownMenu, {
|
|
63
65
|
isDisabled: blockTypesDisabled,
|
|
64
66
|
iconBefore: TriggerIcon,
|
|
65
|
-
tooltipComponent: /*#__PURE__*/_react.default.createElement(
|
|
66
|
-
content: formatMessage(
|
|
67
|
+
tooltipComponent: /*#__PURE__*/_react.default.createElement(_toolbarTooltip.ToolbarTooltip, {
|
|
68
|
+
content: formatMessage(_toolbar.toolbarMessages.textStylesTooltip)
|
|
67
69
|
}),
|
|
68
|
-
label: formatMessage(
|
|
70
|
+
label: formatMessage(_toolbar.toolbarMessages.textStyles, {
|
|
69
71
|
blockTypeName: currentBlockType === null || currentBlockType === void 0 ? void 0 : currentBlockType.name
|
|
70
72
|
}),
|
|
71
73
|
shouldRenderToParent: true
|
|
@@ -8,9 +8,10 @@ exports.BlockTypeButton = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _react2 = require("@emotion/react");
|
|
10
10
|
var _reactIntl = require("react-intl");
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
11
|
+
var _toolbar = require("@atlaskit/editor-common/messages/toolbar");
|
|
12
|
+
var _expand = require("@atlaskit/editor-common/styles/expand");
|
|
13
|
+
var _plugins = require("@atlaskit/editor-common/styles/plugins");
|
|
14
|
+
var _ToolbarButton = _interopRequireDefault(require("@atlaskit/editor-common/ui-menu/ToolbarButton"));
|
|
14
15
|
var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/core/chevron-down"));
|
|
15
16
|
var _text = _interopRequireDefault(require("@atlaskit/icon/core/text"));
|
|
16
17
|
var _primitives = require("@atlaskit/primitives");
|
|
@@ -37,10 +38,10 @@ var buttonContentReducedSpacingStyle = (0, _primitives.xcss)({
|
|
|
37
38
|
});
|
|
38
39
|
var BlockTypeButton = exports.BlockTypeButton = function BlockTypeButton(props) {
|
|
39
40
|
var blockTypeName = props.blockTypeName || '';
|
|
40
|
-
var labelTextStyles = props.formatMessage(
|
|
41
|
+
var labelTextStyles = props.formatMessage(_toolbar.toolbarMessages.textStyles, {
|
|
41
42
|
blockTypeName: blockTypeName
|
|
42
43
|
});
|
|
43
|
-
var toolipTextStyles = props.formatMessage(
|
|
44
|
+
var toolipTextStyles = props.formatMessage(_toolbar.toolbarMessages.textStylesTooltip);
|
|
44
45
|
var icon = (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') && props.blockTypeIcon ? props.blockTypeIcon : (0, _react2.jsx)(_text.default, {
|
|
45
46
|
label: labelTextStyles,
|
|
46
47
|
spacing: "spacious",
|
|
@@ -48,7 +49,7 @@ var BlockTypeButton = exports.BlockTypeButton = function BlockTypeButton(props)
|
|
|
48
49
|
});
|
|
49
50
|
var chevronIconSpacing = (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') ? 'spacious' : 'none';
|
|
50
51
|
var shouldUseIconAsButton = props.isSmall || (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1');
|
|
51
|
-
return (0, _react2.jsx)(
|
|
52
|
+
return (0, _react2.jsx)(_ToolbarButton.default, {
|
|
52
53
|
spacing: props.isReducedSpacing ? 'none' : 'default',
|
|
53
54
|
selected: props.selected
|
|
54
55
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -63,11 +64,11 @@ var BlockTypeButton = exports.BlockTypeButton = function BlockTypeButton(props)
|
|
|
63
64
|
"aria-expanded": props['aria-expanded'],
|
|
64
65
|
iconAfter: (0, _react2.jsx)("span", {
|
|
65
66
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
66
|
-
css: [
|
|
67
|
+
css: [_plugins.wrapperStyle, props.isSmall && _styled.wrapperSmallStyle],
|
|
67
68
|
"data-testid": "toolbar-block-type-text-styles-icon"
|
|
68
69
|
}, (0, _react2.jsx)(_react.default.Fragment, null, shouldUseIconAsButton && icon, (0, _react2.jsx)("span", {
|
|
69
70
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
70
|
-
css:
|
|
71
|
+
css: _expand.expandIconContainerStyle
|
|
71
72
|
}, (0, _react2.jsx)(_chevronDown.default, {
|
|
72
73
|
spacing: chevronIconSpacing,
|
|
73
74
|
label: "",
|