@atlaskit/editor-plugin-text-formatting 3.0.6 → 3.0.8
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 +18 -0
- package/dist/cjs/editor-commands/clear-formatting.js +94 -1
- package/dist/cjs/{pm-plugins/commands.js → editor-commands/toggle-mark.js} +1 -1
- package/dist/cjs/editor-commands/types.js +5 -0
- package/dist/cjs/pm-plugins/clear-formatting-keymap.js +2 -2
- package/dist/cjs/pm-plugins/keymap.js +15 -15
- package/dist/cjs/textFormattingPlugin.js +24 -15
- package/dist/cjs/ui/Toolbar/components/Component.js +144 -0
- package/dist/cjs/ui/Toolbar/components/utils.js +127 -0
- package/dist/cjs/ui/Toolbar/hooks/formatting-icons.js +8 -8
- package/dist/cjs/ui/Toolbar/types.js +11 -1
- package/dist/cjs/ui/toolbar-components.js +130 -0
- package/dist/es2019/editor-commands/clear-formatting.js +94 -1
- package/dist/es2019/{pm-plugins/commands.js → editor-commands/toggle-mark.js} +1 -1
- package/dist/es2019/editor-commands/types.js +1 -0
- package/dist/es2019/pm-plugins/clear-formatting-keymap.js +4 -4
- package/dist/es2019/pm-plugins/keymap.js +1 -1
- package/dist/es2019/textFormattingPlugin.js +17 -8
- package/dist/es2019/ui/Toolbar/components/Component.js +145 -0
- package/dist/es2019/ui/Toolbar/components/utils.js +121 -0
- package/dist/es2019/ui/Toolbar/hooks/formatting-icons.js +1 -1
- package/dist/es2019/ui/Toolbar/types.js +10 -0
- package/dist/es2019/ui/toolbar-components.js +122 -0
- package/dist/esm/editor-commands/clear-formatting.js +93 -1
- package/dist/esm/{pm-plugins/commands.js → editor-commands/toggle-mark.js} +1 -1
- package/dist/esm/editor-commands/types.js +1 -0
- package/dist/esm/pm-plugins/clear-formatting-keymap.js +4 -4
- package/dist/esm/pm-plugins/keymap.js +1 -1
- package/dist/esm/textFormattingPlugin.js +17 -8
- package/dist/esm/ui/Toolbar/components/Component.js +137 -0
- package/dist/esm/ui/Toolbar/components/utils.js +120 -0
- package/dist/esm/ui/Toolbar/hooks/formatting-icons.js +1 -1
- package/dist/esm/ui/Toolbar/types.js +10 -0
- package/dist/esm/ui/toolbar-components.js +123 -0
- package/dist/types/editor-commands/clear-formatting.d.ts +6 -0
- package/dist/{types-ts4.5/pm-plugins/commands.d.ts → types/editor-commands/toggle-mark.d.ts} +2 -5
- package/dist/types/editor-commands/types.d.ts +6 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/textFormattingPluginType.d.ts +4 -2
- package/dist/types/ui/Toolbar/components/Component.d.ts +11 -0
- package/dist/types/ui/Toolbar/components/utils.d.ts +38 -0
- package/dist/types/ui/Toolbar/types.d.ts +14 -0
- package/dist/types/ui/toolbar-components.d.ts +4 -0
- package/dist/types-ts4.5/editor-commands/clear-formatting.d.ts +6 -0
- package/dist/{types/pm-plugins/commands.d.ts → types-ts4.5/editor-commands/toggle-mark.d.ts} +2 -5
- package/dist/types-ts4.5/editor-commands/types.d.ts +6 -0
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/textFormattingPluginType.d.ts +4 -2
- package/dist/types-ts4.5/ui/Toolbar/components/Component.d.ts +11 -0
- package/dist/types-ts4.5/ui/Toolbar/components/utils.d.ts +38 -0
- package/dist/types-ts4.5/ui/Toolbar/types.d.ts +14 -0
- package/dist/types-ts4.5/ui/toolbar-components.d.ts +4 -0
- package/package.json +9 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-formatting
|
|
2
2
|
|
|
3
|
+
## 3.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#195899](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/195899)
|
|
8
|
+
[`345c0b6478f73`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/345c0b6478f73) -
|
|
9
|
+
[ux] [ED-28682] Register text formatting toolbar component following new toolbar AIFC design
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 3.0.7
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#195649](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/195649)
|
|
17
|
+
[`231bb33e06dfe`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/231bb33e06dfe) -
|
|
18
|
+
EDITOR-1131 Bump adf-schema version to 50.2.0
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 3.0.6
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.FORMATTING_NODE_TYPES = exports.FORMATTING_MARK_TYPES = void 0;
|
|
7
7
|
exports.clearFormatting = clearFormatting;
|
|
8
8
|
exports.clearFormattingWithAnalytics = clearFormattingWithAnalytics;
|
|
9
|
+
exports.clearFormattingWithAnalyticsNext = void 0;
|
|
9
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
11
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
11
12
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
@@ -22,9 +23,41 @@ var formatTypes = {
|
|
|
22
23
|
subsup: 'subsup',
|
|
23
24
|
backgroundColor: _analytics.ACTION_SUBJECT_ID.FORMAT_BACKGROUND_COLOR
|
|
24
25
|
};
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required
|
|
28
|
+
/**
|
|
29
|
+
* Consider removing this function when cleaning up platform_editor–toolbar_aifc
|
|
30
|
+
* @deprecated use `clearFormattingWithAnalyticsNext` instead, which returns EditorCommand
|
|
31
|
+
*/
|
|
25
32
|
function clearFormattingWithAnalytics(inputMethod, editorAnalyticsAPI) {
|
|
26
33
|
return clearFormatting(inputMethod, editorAnalyticsAPI);
|
|
27
34
|
}
|
|
35
|
+
var clearNodeFormattingOnSelectionNext = function clearNodeFormattingOnSelectionNext(schema, tr, formattedNodeType, nodeName, formattingCleared) {
|
|
36
|
+
return function (node, pos) {
|
|
37
|
+
if (node.type === formattedNodeType) {
|
|
38
|
+
if (formattedNodeType.isTextblock) {
|
|
39
|
+
tr.setNodeMarkup(pos, schema.nodes.paragraph);
|
|
40
|
+
formattingCleared.push(nodeName);
|
|
41
|
+
return false;
|
|
42
|
+
} else {
|
|
43
|
+
// In case of panel or blockquote
|
|
44
|
+
var fromPos = tr.doc.resolve(pos + 1);
|
|
45
|
+
var toPos = tr.doc.resolve(pos + node.nodeSize - 1);
|
|
46
|
+
var nodeRange = fromPos.blockRange(toPos);
|
|
47
|
+
if (nodeRange) {
|
|
48
|
+
var targetLiftDepth = (0, _transform.liftTarget)(nodeRange);
|
|
49
|
+
if (targetLiftDepth || targetLiftDepth === 0) {
|
|
50
|
+
formattingCleared.push(nodeName);
|
|
51
|
+
// Ignored via go/ees005
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
53
|
+
tr.lift(nodeRange, targetLiftDepth);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
28
61
|
function clearNodeFormattingOnSelection(state, tr, formattedNodeType, nodeName, formattingCleared) {
|
|
29
62
|
return function (node, pos) {
|
|
30
63
|
if (node.type === formattedNodeType) {
|
|
@@ -110,4 +143,64 @@ function clearFormatting(inputMethod, editorAnalyticsAPI) {
|
|
|
110
143
|
}
|
|
111
144
|
return true;
|
|
112
145
|
};
|
|
113
|
-
}
|
|
146
|
+
}
|
|
147
|
+
var clearFormattingWithAnalyticsNext = exports.clearFormattingWithAnalyticsNext = function clearFormattingWithAnalyticsNext(editorAnalyticsApi) {
|
|
148
|
+
return function (inputMethod) {
|
|
149
|
+
return function (_ref) {
|
|
150
|
+
var tr = _ref.tr;
|
|
151
|
+
var formattingCleared = [];
|
|
152
|
+
var schema = tr.doc.type.schema;
|
|
153
|
+
FORMATTING_MARK_TYPES.forEach(function (mark) {
|
|
154
|
+
var _tr$selection3 = tr.selection,
|
|
155
|
+
from = _tr$selection3.from,
|
|
156
|
+
to = _tr$selection3.to;
|
|
157
|
+
var markType = schema.marks[mark];
|
|
158
|
+
if (!markType) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (tr.selection instanceof _cellSelection.CellSelection) {
|
|
162
|
+
(0, _cellSelection2.cellSelectionNodesBetween)(tr.selection, tr.doc, function (node, pos) {
|
|
163
|
+
var isTableCell = node.type === tr.doc.type.schema.nodes.tableCell || node.type === schema.nodes.tableHeader;
|
|
164
|
+
if (!isTableCell) {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
if (tr.doc.rangeHasMark(pos, pos + node.nodeSize, markType)) {
|
|
168
|
+
formattingCleared.push(formatTypes[mark]);
|
|
169
|
+
tr.removeMark(pos, pos + node.nodeSize, markType);
|
|
170
|
+
}
|
|
171
|
+
return false;
|
|
172
|
+
});
|
|
173
|
+
} else if (tr.doc.rangeHasMark(from, to, markType)) {
|
|
174
|
+
formattingCleared.push(formatTypes[mark]);
|
|
175
|
+
tr.removeMark(from, to, markType);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
FORMATTING_NODE_TYPES.forEach(function (nodeName) {
|
|
179
|
+
var formattedNodeType = schema.nodes[nodeName];
|
|
180
|
+
var _tr$selection4 = tr.selection,
|
|
181
|
+
$from = _tr$selection4.$from,
|
|
182
|
+
$to = _tr$selection4.$to;
|
|
183
|
+
if (tr.selection instanceof _cellSelection.CellSelection) {
|
|
184
|
+
(0, _cellSelection2.cellSelectionNodesBetween)(tr.selection, tr.doc, clearNodeFormattingOnSelectionNext(schema, tr, formattedNodeType, nodeName, formattingCleared));
|
|
185
|
+
} else {
|
|
186
|
+
tr.doc.nodesBetween($from.pos, $to.pos, clearNodeFormattingOnSelectionNext(schema, tr, formattedNodeType, nodeName, formattingCleared));
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
tr.setStoredMarks([]);
|
|
190
|
+
if (formattingCleared.length && inputMethod) {
|
|
191
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
|
|
192
|
+
action: _analytics.ACTION.FORMATTED,
|
|
193
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
194
|
+
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
195
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_CLEAR,
|
|
196
|
+
attributes: {
|
|
197
|
+
inputMethod: inputMethod,
|
|
198
|
+
formattingCleared: formattingCleared,
|
|
199
|
+
dropdownMenu: inputMethod === _analytics.INPUT_METHOD.TOOLBAR || inputMethod === _analytics.INPUT_METHOD.FLOATING_TB ? 'textFormatting' : undefined
|
|
200
|
+
}
|
|
201
|
+
})(tr);
|
|
202
|
+
}
|
|
203
|
+
return tr;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
};
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.toggleUnderlineWithAnalytics = exports.toggleUnderline = exports.toggleSuperscriptWithAnalytics = exports.toggleSuperscript = exports.toggleSubscriptWithAnalytics = exports.toggleSubscript = exports.toggleStrongWithAnalytics = exports.toggleStrong = exports.toggleStrikeWithAnalytics = exports.toggleStrike = exports.toggleEmWithAnalytics = exports.toggleEm = exports.toggleCodeWithAnalytics = exports.toggleCode = void 0;
|
|
7
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
8
|
var _mark = require("@atlaskit/editor-common/mark");
|
|
9
|
-
var _marks = require("
|
|
9
|
+
var _marks = require("./utils/marks");
|
|
10
10
|
var toggleEm = exports.toggleEm = function toggleEm(_ref) {
|
|
11
11
|
var tr = _ref.tr;
|
|
12
12
|
var em = tr.doc.type.schema.marks.em;
|
|
@@ -11,10 +11,10 @@ var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
|
11
11
|
var _clearFormatting = require("../editor-commands/clear-formatting");
|
|
12
12
|
function keymapPlugin(editorAnalyticsAPI) {
|
|
13
13
|
var list = {};
|
|
14
|
-
(0, _keymaps.
|
|
14
|
+
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
15
15
|
// Ignored via go/ees005
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
17
|
-
_keymaps.clearFormatting.common, (0, _clearFormatting.
|
|
17
|
+
_keymaps.clearFormatting.common, (0, _clearFormatting.clearFormattingWithAnalyticsNext)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
18
18
|
return (0, _keymap.keymap)(list);
|
|
19
19
|
}
|
|
20
20
|
var _default = exports.default = keymapPlugin;
|
|
@@ -9,7 +9,7 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
|
9
9
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
10
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
11
11
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
|
-
var
|
|
12
|
+
var _toggleMark = require("../editor-commands/toggle-mark");
|
|
13
13
|
var _pluginKey = require("./plugin-key");
|
|
14
14
|
function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
15
15
|
var list = {};
|
|
@@ -17,43 +17,43 @@ function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
|
17
17
|
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
18
18
|
// Ignored via go/ees005
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
20
|
-
_keymaps.toggleBold.common, (0,
|
|
20
|
+
_keymaps.toggleBold.common, (0, _toggleMark.toggleStrongWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
21
21
|
}
|
|
22
22
|
if (schema.marks.em) {
|
|
23
23
|
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
24
24
|
// Ignored via go/ees005
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
26
|
-
_keymaps.toggleItalic.common, (0,
|
|
26
|
+
_keymaps.toggleItalic.common, (0, _toggleMark.toggleEmWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
27
27
|
}
|
|
28
28
|
if (schema.marks.code) {
|
|
29
29
|
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
30
30
|
// Ignored via go/ees005
|
|
31
31
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
32
|
-
_keymaps.toggleCode.common, (0,
|
|
32
|
+
_keymaps.toggleCode.common, (0, _toggleMark.toggleCodeWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
33
33
|
}
|
|
34
34
|
if (schema.marks.strike) {
|
|
35
35
|
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
36
36
|
// Ignored via go/ees005
|
|
37
37
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
38
|
-
_keymaps.toggleStrikethrough.common, (0,
|
|
38
|
+
_keymaps.toggleStrikethrough.common, (0, _toggleMark.toggleStrikeWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
39
39
|
}
|
|
40
40
|
if (schema.marks.subsup) {
|
|
41
41
|
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
42
42
|
// Ignored via go/ees005
|
|
43
43
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
44
|
-
_keymaps.toggleSubscript.common, (0,
|
|
44
|
+
_keymaps.toggleSubscript.common, (0, _toggleMark.toggleSubscriptWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
45
45
|
}
|
|
46
46
|
if (schema.marks.subsup) {
|
|
47
47
|
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
48
48
|
// Ignored via go/ees005
|
|
49
49
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
50
|
-
_keymaps.toggleSuperscript.common, (0,
|
|
50
|
+
_keymaps.toggleSuperscript.common, (0, _toggleMark.toggleSuperscriptWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
51
51
|
}
|
|
52
52
|
if (schema.marks.underline) {
|
|
53
53
|
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
54
54
|
// Ignored via go/ees005
|
|
55
55
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
56
|
-
_keymaps.toggleUnderline.common, (0,
|
|
56
|
+
_keymaps.toggleUnderline.common, (0, _toggleMark.toggleUnderlineWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
57
57
|
}
|
|
58
58
|
var getEnabledKeylist = function getEnabledKeylist(view) {
|
|
59
59
|
var textFormattingState = _pluginKey.pluginKey.getState(view.state);
|
|
@@ -62,43 +62,43 @@ function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
|
62
62
|
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
63
63
|
// Ignored via go/ees005
|
|
64
64
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
65
|
-
_keymaps.toggleBold.common, (0,
|
|
65
|
+
_keymaps.toggleBold.common, (0, _toggleMark.toggleStrongWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
66
66
|
}
|
|
67
67
|
if (schema.marks.em && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.emDisabled)) {
|
|
68
68
|
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
69
69
|
// Ignored via go/ees005
|
|
70
70
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
71
|
-
_keymaps.toggleItalic.common, (0,
|
|
71
|
+
_keymaps.toggleItalic.common, (0, _toggleMark.toggleEmWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
72
72
|
}
|
|
73
73
|
if (schema.marks.code && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.codeDisabled)) {
|
|
74
74
|
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
75
75
|
// Ignored via go/ees005
|
|
76
76
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
77
|
-
_keymaps.toggleCode.common, (0,
|
|
77
|
+
_keymaps.toggleCode.common, (0, _toggleMark.toggleCodeWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
78
78
|
}
|
|
79
79
|
if (schema.marks.strike && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.strikeDisabled)) {
|
|
80
80
|
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
81
81
|
// Ignored via go/ees005
|
|
82
82
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
83
|
-
_keymaps.toggleStrikethrough.common, (0,
|
|
83
|
+
_keymaps.toggleStrikethrough.common, (0, _toggleMark.toggleStrikeWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
84
84
|
}
|
|
85
85
|
if (schema.marks.subsup && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.subscriptDisabled)) {
|
|
86
86
|
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
87
87
|
// Ignored via go/ees005
|
|
88
88
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
89
|
-
_keymaps.toggleSubscript.common, (0,
|
|
89
|
+
_keymaps.toggleSubscript.common, (0, _toggleMark.toggleSubscriptWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
90
90
|
}
|
|
91
91
|
if (schema.marks.subsup && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.superscriptDisabled)) {
|
|
92
92
|
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
93
93
|
// Ignored via go/ees005
|
|
94
94
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
95
|
-
_keymaps.toggleSuperscript.common, (0,
|
|
95
|
+
_keymaps.toggleSuperscript.common, (0, _toggleMark.toggleSuperscriptWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
96
96
|
}
|
|
97
97
|
if (schema.marks.underline && !(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.underlineDisabled)) {
|
|
98
98
|
(0, _keymaps.bindKeymapWithEditorCommand)(
|
|
99
99
|
// Ignored via go/ees005
|
|
100
100
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
101
|
-
_keymaps.toggleUnderline.common, (0,
|
|
101
|
+
_keymaps.toggleUnderline.common, (0, _toggleMark.toggleUnderlineWithAnalytics)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
102
102
|
}
|
|
103
103
|
return list;
|
|
104
104
|
};
|
|
@@ -9,10 +9,11 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
11
11
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
12
13
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
14
|
+
var _toggleMark = require("./editor-commands/toggle-mark");
|
|
13
15
|
var _clearFormatting = require("./pm-plugins/clear-formatting");
|
|
14
16
|
var _clearFormattingKeymap = _interopRequireDefault(require("./pm-plugins/clear-formatting-keymap"));
|
|
15
|
-
var _commands = require("./pm-plugins/commands");
|
|
16
17
|
var _cursor = _interopRequireDefault(require("./pm-plugins/cursor"));
|
|
17
18
|
var _inputRule = _interopRequireDefault(require("./pm-plugins/input-rule"));
|
|
18
19
|
var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
|
|
@@ -21,6 +22,7 @@ var _pluginKey = require("./pm-plugins/plugin-key");
|
|
|
21
22
|
var _smartInputRule = _interopRequireDefault(require("./pm-plugins/smart-input-rule"));
|
|
22
23
|
var _FloatingToolbarComponent = require("./ui/FloatingToolbarComponent");
|
|
23
24
|
var _PrimaryToolbarComponent = require("./ui/PrimaryToolbarComponent");
|
|
25
|
+
var _toolbarComponents = require("./ui/toolbar-components");
|
|
24
26
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25
27
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
26
28
|
/**
|
|
@@ -28,9 +30,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
28
30
|
* from `@atlaskit/editor-core`.
|
|
29
31
|
*/
|
|
30
32
|
var textFormattingPlugin = exports.textFormattingPlugin = function textFormattingPlugin(_ref) {
|
|
31
|
-
var _api$
|
|
33
|
+
var _api$analytics7, _api$analytics8, _api$analytics9, _api$analytics0, _api$analytics1, _api$analytics10, _api$analytics11;
|
|
32
34
|
var options = _ref.config,
|
|
33
35
|
api = _ref.api;
|
|
36
|
+
var isToolbarAIFCEnabled = (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc', 'isEnabled', true);
|
|
34
37
|
var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
|
|
35
38
|
var editorView = _ref2.editorView,
|
|
36
39
|
popupsMountPoint = _ref2.popupsMountPoint,
|
|
@@ -63,10 +66,16 @@ var textFormattingPlugin = exports.textFormattingPlugin = function textFormattin
|
|
|
63
66
|
shouldUseResponsiveToolbar: Boolean(options === null || options === void 0 ? void 0 : options.responsiveToolbarMenu)
|
|
64
67
|
});
|
|
65
68
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
69
|
+
if (isToolbarAIFCEnabled) {
|
|
70
|
+
var _api$toolbar;
|
|
71
|
+
api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents((0, _toolbarComponents.getToolbarComponents)(api));
|
|
72
|
+
} else {
|
|
73
|
+
var _api$primaryToolbar;
|
|
74
|
+
api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
|
|
75
|
+
name: 'textFormatting',
|
|
76
|
+
component: primaryToolbarComponent
|
|
77
|
+
});
|
|
78
|
+
}
|
|
70
79
|
return {
|
|
71
80
|
name: 'textFormatting',
|
|
72
81
|
marks: function marks() {
|
|
@@ -148,7 +157,7 @@ var textFormattingPlugin = exports.textFormattingPlugin = function textFormattin
|
|
|
148
157
|
isInitialised: !!(textFormattingState !== null && textFormattingState !== void 0 && textFormattingState.isInitialised)
|
|
149
158
|
});
|
|
150
159
|
},
|
|
151
|
-
pluginsOptions: {
|
|
160
|
+
pluginsOptions: isToolbarAIFCEnabled ? {} : {
|
|
152
161
|
selectionToolbar: function selectionToolbar() {
|
|
153
162
|
var _api$userPreferences, _api$selectionToolbar;
|
|
154
163
|
var toolbarDocking = (0, _platformFeatureFlags.fg)('platform_editor_use_preferences_plugin') ? api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.preferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.toolbarDockingPosition : api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.currentState()) === null || _api$selectionToolbar === void 0 ? void 0 : _api$selectionToolbar.toolbarDocking;
|
|
@@ -181,15 +190,15 @@ var textFormattingPlugin = exports.textFormattingPlugin = function textFormattin
|
|
|
181
190
|
}
|
|
182
191
|
}
|
|
183
192
|
},
|
|
184
|
-
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
|
|
193
|
+
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) && !isToolbarAIFCEnabled ? primaryToolbarComponent : undefined,
|
|
185
194
|
commands: {
|
|
186
|
-
toggleSuperscript: (0,
|
|
187
|
-
toggleSubscript: (0,
|
|
188
|
-
toggleStrike: (0,
|
|
189
|
-
toggleCode: (0,
|
|
190
|
-
toggleUnderline: (0,
|
|
191
|
-
toggleEm: (0,
|
|
192
|
-
toggleStrong: (0,
|
|
195
|
+
toggleSuperscript: (0, _toggleMark.toggleSuperscriptWithAnalytics)(api === null || api === void 0 || (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions),
|
|
196
|
+
toggleSubscript: (0, _toggleMark.toggleSubscriptWithAnalytics)(api === null || api === void 0 || (_api$analytics8 = api.analytics) === null || _api$analytics8 === void 0 ? void 0 : _api$analytics8.actions),
|
|
197
|
+
toggleStrike: (0, _toggleMark.toggleStrikeWithAnalytics)(api === null || api === void 0 || (_api$analytics9 = api.analytics) === null || _api$analytics9 === void 0 ? void 0 : _api$analytics9.actions),
|
|
198
|
+
toggleCode: (0, _toggleMark.toggleCodeWithAnalytics)(api === null || api === void 0 || (_api$analytics0 = api.analytics) === null || _api$analytics0 === void 0 ? void 0 : _api$analytics0.actions),
|
|
199
|
+
toggleUnderline: (0, _toggleMark.toggleUnderlineWithAnalytics)(api === null || api === void 0 || (_api$analytics1 = api.analytics) === null || _api$analytics1 === void 0 ? void 0 : _api$analytics1.actions),
|
|
200
|
+
toggleEm: (0, _toggleMark.toggleEmWithAnalytics)(api === null || api === void 0 || (_api$analytics10 = api.analytics) === null || _api$analytics10 === void 0 ? void 0 : _api$analytics10.actions),
|
|
201
|
+
toggleStrong: (0, _toggleMark.toggleStrongWithAnalytics)(api === null || api === void 0 || (_api$analytics11 = api.analytics) === null || _api$analytics11 === void 0 ? void 0 : _api$analytics11.actions)
|
|
193
202
|
}
|
|
194
203
|
};
|
|
195
204
|
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.MoreFormattingMenu = exports.FormatMenuItem = exports.FormatButton = exports.ClearFormatMenuItem = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactIntlNext = require("react-intl-next");
|
|
10
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
|
+
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
12
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
|
+
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
14
|
+
var _clearFormatting = require("../../../editor-commands/clear-formatting");
|
|
15
|
+
var _utils = require("./utils");
|
|
16
|
+
var FormatMenuItem = exports.FormatMenuItem = function FormatMenuItem(_ref) {
|
|
17
|
+
var parents = _ref.parents,
|
|
18
|
+
api = _ref.api,
|
|
19
|
+
optionType = _ref.optionType,
|
|
20
|
+
toggleMarkWithAnalyticsCallback = _ref.toggleMarkWithAnalyticsCallback,
|
|
21
|
+
icon = _ref.icon,
|
|
22
|
+
shortcut = _ref.shortcut,
|
|
23
|
+
title = _ref.title;
|
|
24
|
+
var _useComponentInfo = (0, _utils.useComponentInfo)({
|
|
25
|
+
api: api,
|
|
26
|
+
optionType: optionType,
|
|
27
|
+
title: title,
|
|
28
|
+
shortcut: shortcut,
|
|
29
|
+
toggleMarkWithAnalyticsCallback: toggleMarkWithAnalyticsCallback,
|
|
30
|
+
parents: parents
|
|
31
|
+
}),
|
|
32
|
+
isActive = _useComponentInfo.isActive,
|
|
33
|
+
isDisabled = _useComponentInfo.isDisabled,
|
|
34
|
+
isHidden = _useComponentInfo.isHidden,
|
|
35
|
+
shortcutContent = _useComponentInfo.shortcutContent,
|
|
36
|
+
onClick = _useComponentInfo.onClick,
|
|
37
|
+
ariaLabel = _useComponentInfo.ariaLabel,
|
|
38
|
+
formatTitle = _useComponentInfo.formatTitle;
|
|
39
|
+
var Icon = icon;
|
|
40
|
+
if (isHidden) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
44
|
+
elemBefore: /*#__PURE__*/_react.default.createElement(Icon, {
|
|
45
|
+
label: ""
|
|
46
|
+
}),
|
|
47
|
+
elemAfter: shortcutContent && /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarKeyboardShortcutHint, {
|
|
48
|
+
shortcut: shortcutContent
|
|
49
|
+
}),
|
|
50
|
+
isDisabled: isDisabled,
|
|
51
|
+
isSelected: isActive,
|
|
52
|
+
onClick: onClick,
|
|
53
|
+
"aria-keyshortcuts": (0, _keymaps.getAriaKeyshortcuts)(shortcut),
|
|
54
|
+
"aria-label": ariaLabel
|
|
55
|
+
}, formatTitle);
|
|
56
|
+
};
|
|
57
|
+
var FormatButton = exports.FormatButton = function FormatButton(_ref2) {
|
|
58
|
+
var parents = _ref2.parents,
|
|
59
|
+
api = _ref2.api,
|
|
60
|
+
optionType = _ref2.optionType,
|
|
61
|
+
toggleMarkWithAnalyticsCallback = _ref2.toggleMarkWithAnalyticsCallback,
|
|
62
|
+
icon = _ref2.icon,
|
|
63
|
+
shortcut = _ref2.shortcut,
|
|
64
|
+
title = _ref2.title,
|
|
65
|
+
_ref2$groupLocation = _ref2.groupLocation,
|
|
66
|
+
groupLocation = _ref2$groupLocation === void 0 ? 'start' : _ref2$groupLocation;
|
|
67
|
+
var _useComponentInfo2 = (0, _utils.useComponentInfo)({
|
|
68
|
+
api: api,
|
|
69
|
+
optionType: optionType,
|
|
70
|
+
title: title,
|
|
71
|
+
shortcut: shortcut,
|
|
72
|
+
toggleMarkWithAnalyticsCallback: toggleMarkWithAnalyticsCallback,
|
|
73
|
+
parents: parents
|
|
74
|
+
}),
|
|
75
|
+
isActive = _useComponentInfo2.isActive,
|
|
76
|
+
isDisabled = _useComponentInfo2.isDisabled,
|
|
77
|
+
onClick = _useComponentInfo2.onClick,
|
|
78
|
+
ariaLabel = _useComponentInfo2.ariaLabel,
|
|
79
|
+
formatTitle = _useComponentInfo2.formatTitle;
|
|
80
|
+
var Icon = icon;
|
|
81
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarTooltip, {
|
|
82
|
+
content: formatTitle
|
|
83
|
+
}, /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarButton, {
|
|
84
|
+
iconBefore: /*#__PURE__*/_react.default.createElement(Icon, {
|
|
85
|
+
label: ariaLabel
|
|
86
|
+
}),
|
|
87
|
+
onClick: onClick,
|
|
88
|
+
isSelected: isActive,
|
|
89
|
+
isDisabled: isDisabled,
|
|
90
|
+
groupLocation: groupLocation,
|
|
91
|
+
ariaKeyshortcuts: (0, _keymaps.getAriaKeyshortcuts)(shortcut)
|
|
92
|
+
}));
|
|
93
|
+
};
|
|
94
|
+
var ClearFormatMenuItem = exports.ClearFormatMenuItem = function ClearFormatMenuItem(_ref3) {
|
|
95
|
+
var api = _ref3.api,
|
|
96
|
+
parents = _ref3.parents;
|
|
97
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['textFormatting'], function (states) {
|
|
98
|
+
var _states$textFormattin, _states$textFormattin2;
|
|
99
|
+
return {
|
|
100
|
+
isInitialised: (_states$textFormattin = states.textFormattingState) === null || _states$textFormattin === void 0 ? void 0 : _states$textFormattin.isInitialised,
|
|
101
|
+
isFormattingPresent: (_states$textFormattin2 = states.textFormattingState) === null || _states$textFormattin2 === void 0 ? void 0 : _states$textFormattin2.formattingIsPresent
|
|
102
|
+
};
|
|
103
|
+
}),
|
|
104
|
+
isInitialised = _useSharedPluginState.isInitialised,
|
|
105
|
+
isFormattingPresent = _useSharedPluginState.isFormattingPresent;
|
|
106
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
107
|
+
formatMessage = _useIntl.formatMessage;
|
|
108
|
+
if (!isInitialised) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
var formatTitle = formatMessage(_messages.toolbarMessages.clearFormatting);
|
|
112
|
+
var shortcutContent = (0, _keymaps.tooltip)(_keymaps.clearFormatting);
|
|
113
|
+
var ariaLabel = (0, _keymaps.tooltip)(_keymaps.clearFormatting, formatTitle);
|
|
114
|
+
var onClick = function onClick() {
|
|
115
|
+
var _api$analytics;
|
|
116
|
+
api === null || api === void 0 || api.core.actions.execute((0, _clearFormatting.clearFormattingWithAnalyticsNext)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)((0, _utils.getInputMethodFromParentKeys)(parents)));
|
|
117
|
+
};
|
|
118
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
119
|
+
elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.ClearFormattingIcon, {
|
|
120
|
+
label: ""
|
|
121
|
+
}),
|
|
122
|
+
elemAfter: shortcutContent && /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarKeyboardShortcutHint, {
|
|
123
|
+
shortcut: shortcutContent
|
|
124
|
+
}),
|
|
125
|
+
isDisabled: !isFormattingPresent,
|
|
126
|
+
onClick: onClick,
|
|
127
|
+
"aria-keyshortcuts": (0, _keymaps.getAriaKeyshortcuts)(_keymaps.clearFormatting),
|
|
128
|
+
"aria-label": ariaLabel
|
|
129
|
+
}, formatTitle);
|
|
130
|
+
};
|
|
131
|
+
var MoreFormattingMenu = exports.MoreFormattingMenu = function MoreFormattingMenu(_ref4) {
|
|
132
|
+
var children = _ref4.children,
|
|
133
|
+
groupLocation = _ref4.groupLocation;
|
|
134
|
+
var _useIntl2 = (0, _reactIntlNext.useIntl)(),
|
|
135
|
+
formatMessage = _useIntl2.formatMessage;
|
|
136
|
+
var content = formatMessage(_messages.toolbarMessages.moreFormatting);
|
|
137
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownMenu, {
|
|
138
|
+
iconBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.MoreItemsIcon, {
|
|
139
|
+
label: content,
|
|
140
|
+
testId: "more-formatting"
|
|
141
|
+
}),
|
|
142
|
+
groupLocation: groupLocation
|
|
143
|
+
}, children);
|
|
144
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useComponentInfo = exports.getInputMethodFromParentKeys = exports.formatOptions = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _reactIntlNext = require("react-intl-next");
|
|
10
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
|
+
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
12
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
14
|
+
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
15
|
+
var _toggleMark = require("../../../editor-commands/toggle-mark");
|
|
16
|
+
var _inputMethodUtils = require("../input-method-utils");
|
|
17
|
+
var _types = require("../types");
|
|
18
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
|
+
var getInputMethodFromParentKeys = exports.getInputMethodFromParentKeys = function getInputMethodFromParentKeys(parentKeys) {
|
|
21
|
+
var _parentKeys$at;
|
|
22
|
+
return (0, _inputMethodUtils.getInputMethod)(
|
|
23
|
+
// TODO: ED-28682 - replace with const
|
|
24
|
+
((_parentKeys$at = parentKeys.at(-1)) === null || _parentKeys$at === void 0 ? void 0 : _parentKeys$at.key) === 'inline-text-toolbar' ? _types.ToolbarType.FLOATING : _types.ToolbarType.PRIMARY);
|
|
25
|
+
};
|
|
26
|
+
var useComponentInfo = exports.useComponentInfo = function useComponentInfo(_ref) {
|
|
27
|
+
var api = _ref.api,
|
|
28
|
+
optionType = _ref.optionType,
|
|
29
|
+
title = _ref.title,
|
|
30
|
+
shortcut = _ref.shortcut,
|
|
31
|
+
toggleMarkWithAnalyticsCallback = _ref.toggleMarkWithAnalyticsCallback,
|
|
32
|
+
parents = _ref.parents;
|
|
33
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['textFormatting'], function (states) {
|
|
34
|
+
var _states$textFormattin, _states$textFormattin2, _states$textFormattin3, _states$textFormattin4;
|
|
35
|
+
return {
|
|
36
|
+
isActive: (_states$textFormattin = states.textFormattingState) === null || _states$textFormattin === void 0 ? void 0 : _states$textFormattin["".concat(optionType, "Active")],
|
|
37
|
+
isDisabled: (_states$textFormattin2 = states.textFormattingState) === null || _states$textFormattin2 === void 0 ? void 0 : _states$textFormattin2["".concat(optionType, "Disabled")],
|
|
38
|
+
isHidden: (_states$textFormattin3 = states.textFormattingState) === null || _states$textFormattin3 === void 0 ? void 0 : _states$textFormattin3["".concat(optionType, "Hidden")],
|
|
39
|
+
isPluginInitialised: (_states$textFormattin4 = states.textFormattingState) === null || _states$textFormattin4 === void 0 ? void 0 : _states$textFormattin4.isInitialised
|
|
40
|
+
};
|
|
41
|
+
}),
|
|
42
|
+
isActive = _useSharedPluginState.isActive,
|
|
43
|
+
isDisabled = _useSharedPluginState.isDisabled,
|
|
44
|
+
isHidden = _useSharedPluginState.isHidden,
|
|
45
|
+
isPluginInitialised = _useSharedPluginState.isPluginInitialised;
|
|
46
|
+
var formatOptionState;
|
|
47
|
+
if (!isPluginInitialised) {
|
|
48
|
+
formatOptionState = {
|
|
49
|
+
isActive: false,
|
|
50
|
+
isDisabled: true,
|
|
51
|
+
isHidden: false
|
|
52
|
+
};
|
|
53
|
+
} else {
|
|
54
|
+
formatOptionState = {
|
|
55
|
+
isActive: Boolean(isActive),
|
|
56
|
+
isDisabled: Boolean(isDisabled),
|
|
57
|
+
// TODO: ED-28682 - also need to check if mark is present in the schema
|
|
58
|
+
isHidden: Boolean(isHidden)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
62
|
+
formatMessage = _useIntl.formatMessage;
|
|
63
|
+
var formatTitle = formatMessage(title);
|
|
64
|
+
var shortcutContent = (0, _keymaps.tooltip)(shortcut);
|
|
65
|
+
var ariaLabel = (0, _keymaps.tooltip)(shortcut, formatTitle);
|
|
66
|
+
var onClick = function onClick() {
|
|
67
|
+
var _api$analytics;
|
|
68
|
+
api === null || api === void 0 || api.core.actions.execute(toggleMarkWithAnalyticsCallback(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(getInputMethodFromParentKeys(parents)));
|
|
69
|
+
};
|
|
70
|
+
return _objectSpread(_objectSpread({}, formatOptionState), {}, {
|
|
71
|
+
formatTitle: formatTitle,
|
|
72
|
+
shortcutContent: shortcutContent,
|
|
73
|
+
ariaLabel: ariaLabel || formatTitle,
|
|
74
|
+
onClick: onClick
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
var formatOptions = exports.formatOptions = {
|
|
78
|
+
strong: {
|
|
79
|
+
rank: _toolbar.TEXT_FORMAT_OPTION_MENU_RANK.BOLD,
|
|
80
|
+
icon: _editorToolbar.BoldIcon,
|
|
81
|
+
title: _messages.toolbarMessages.bold,
|
|
82
|
+
command: _toggleMark.toggleStrongWithAnalytics,
|
|
83
|
+
shortcut: _keymaps.toggleBold
|
|
84
|
+
},
|
|
85
|
+
em: {
|
|
86
|
+
rank: _toolbar.TEXT_FORMAT_OPTION_MENU_RANK.ITALIC,
|
|
87
|
+
icon: _editorToolbar.ItalicIcon,
|
|
88
|
+
title: _messages.toolbarMessages.italic,
|
|
89
|
+
command: _toggleMark.toggleEmWithAnalytics,
|
|
90
|
+
shortcut: _keymaps.toggleItalic
|
|
91
|
+
},
|
|
92
|
+
underline: {
|
|
93
|
+
rank: _toolbar.TEXT_FORMAT_OPTION_MENU_RANK.UNDERLINE,
|
|
94
|
+
icon: _editorToolbar.UnderlineIcon,
|
|
95
|
+
title: _messages.toolbarMessages.underline,
|
|
96
|
+
command: _toggleMark.toggleUnderlineWithAnalytics,
|
|
97
|
+
shortcut: _keymaps.toggleUnderline
|
|
98
|
+
},
|
|
99
|
+
strike: {
|
|
100
|
+
rank: _toolbar.TEXT_FORMAT_OPTION_MENU_RANK.STRIKETHROUGH,
|
|
101
|
+
icon: _editorToolbar.StrikeThroughIcon,
|
|
102
|
+
title: _messages.toolbarMessages.strike,
|
|
103
|
+
command: _toggleMark.toggleStrikeWithAnalytics,
|
|
104
|
+
shortcut: _keymaps.toggleStrikethrough
|
|
105
|
+
},
|
|
106
|
+
code: {
|
|
107
|
+
rank: _toolbar.TEXT_FORMAT_OPTION_MENU_RANK.CODE,
|
|
108
|
+
icon: _editorToolbar.CodeIcon,
|
|
109
|
+
title: _messages.toolbarMessages.code,
|
|
110
|
+
command: _toggleMark.toggleCodeWithAnalytics,
|
|
111
|
+
shortcut: _keymaps.toggleCode
|
|
112
|
+
},
|
|
113
|
+
subscript: {
|
|
114
|
+
rank: _toolbar.TEXT_FORMAT_OPTION_MENU_RANK.SUBSCRIPT,
|
|
115
|
+
icon: _editorToolbar.SubscriptIcon,
|
|
116
|
+
title: _messages.toolbarMessages.subscript,
|
|
117
|
+
command: _toggleMark.toggleSubscriptWithAnalytics,
|
|
118
|
+
shortcut: _keymaps.toggleSubscript
|
|
119
|
+
},
|
|
120
|
+
superscript: {
|
|
121
|
+
rank: _toolbar.TEXT_FORMAT_OPTION_MENU_RANK.SUPERSCRIPT,
|
|
122
|
+
icon: _editorToolbar.SuperscriptIcon,
|
|
123
|
+
title: _messages.toolbarMessages.superscript,
|
|
124
|
+
command: _toggleMark.toggleSuperscriptWithAnalytics,
|
|
125
|
+
shortcut: _keymaps.toggleSuperscript
|
|
126
|
+
}
|
|
127
|
+
};
|