@atlaskit/editor-plugin-text-formatting 1.16.5 → 1.16.6
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 +6 -0
- package/dist/cjs/editor-commands/clear-formatting.js +5 -0
- package/dist/cjs/editor-commands/transform-to-code.js +13 -1
- package/dist/cjs/editor-commands/utils/cell-selection.js +4 -1
- package/dist/cjs/pm-plugins/clear-formatting-keymap.js +4 -1
- package/dist/cjs/pm-plugins/clear-formatting.js +2 -0
- package/dist/cjs/pm-plugins/cursor.js +6 -1
- package/dist/cjs/pm-plugins/input-rule.js +13 -1
- package/dist/cjs/pm-plugins/keymap.js +28 -7
- package/dist/cjs/pm-plugins/main.js +7 -0
- package/dist/cjs/pm-plugins/smart-input-rule.js +30 -0
- package/dist/cjs/ui/FloatingToolbarComponent.js +8 -4
- package/dist/cjs/ui/Toolbar/dropdown-menu.js +4 -6
- package/dist/cjs/ui/Toolbar/index.js +8 -2
- package/dist/es2019/editor-commands/clear-formatting.js +7 -2
- package/dist/es2019/editor-commands/transform-to-code.js +13 -1
- package/dist/es2019/editor-commands/utils/cell-selection.js +4 -1
- package/dist/es2019/editor-commands/utils.js +1 -1
- package/dist/es2019/pm-plugins/clear-formatting-keymap.js +4 -1
- package/dist/es2019/pm-plugins/clear-formatting.js +2 -0
- package/dist/es2019/pm-plugins/cursor.js +6 -1
- package/dist/es2019/pm-plugins/input-rule.js +13 -1
- package/dist/es2019/pm-plugins/keymap.js +29 -8
- package/dist/es2019/pm-plugins/main.js +6 -0
- package/dist/es2019/pm-plugins/smart-input-rule.js +31 -1
- package/dist/es2019/ui/FloatingToolbarComponent.js +8 -2
- package/dist/es2019/ui/Toolbar/dropdown-menu.js +5 -5
- package/dist/es2019/ui/Toolbar/index.js +8 -2
- package/dist/esm/editor-commands/clear-formatting.js +5 -0
- package/dist/esm/editor-commands/transform-to-code.js +13 -1
- package/dist/esm/editor-commands/utils/cell-selection.js +4 -1
- package/dist/esm/pm-plugins/clear-formatting-keymap.js +4 -1
- package/dist/esm/pm-plugins/clear-formatting.js +2 -0
- package/dist/esm/pm-plugins/cursor.js +6 -1
- package/dist/esm/pm-plugins/input-rule.js +13 -1
- package/dist/esm/pm-plugins/keymap.js +28 -7
- package/dist/esm/pm-plugins/main.js +6 -0
- package/dist/esm/pm-plugins/smart-input-rule.js +30 -0
- package/dist/esm/ui/FloatingToolbarComponent.js +8 -3
- package/dist/esm/ui/Toolbar/dropdown-menu.js +5 -7
- package/dist/esm/ui/Toolbar/index.js +8 -2
- package/dist/types/ui/Toolbar/dropdown-menu.d.ts +3 -1
- package/dist/types-ts4.5/ui/Toolbar/dropdown-menu.d.ts +3 -1
- package/package.json +3 -3
|
@@ -8,6 +8,8 @@ import { shallowEqual } from '@atlaskit/editor-common/utils';
|
|
|
8
8
|
import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
|
|
9
9
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
10
|
import { createInlineCodeFromTextInputWithAnalytics } from '../editor-commands/text-formatting';
|
|
11
|
+
// Ignored via go/ees005
|
|
12
|
+
// eslint-disable-next-line import/no-namespace
|
|
11
13
|
import * as commands from '../editor-commands/text-formatting';
|
|
12
14
|
import { pluginKey } from './plugin-key';
|
|
13
15
|
const isSelectionInlineCursor = selection => {
|
|
@@ -77,6 +79,8 @@ export const plugin = (dispatch, editorAnalyticsAPI) => new SafePlugin({
|
|
|
77
79
|
init(_config, state) {
|
|
78
80
|
return getTextFormattingState(state, editorAnalyticsAPI);
|
|
79
81
|
},
|
|
82
|
+
// Ignored via go/ees005
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
80
84
|
apply(_tr, pluginState, _oldState, newState) {
|
|
81
85
|
const state = getTextFormattingState(newState, editorAnalyticsAPI);
|
|
82
86
|
if (!shallowEqual(pluginState, state)) {
|
|
@@ -100,6 +104,8 @@ export const plugin = (dispatch, editorAnalyticsAPI) => new SafePlugin({
|
|
|
100
104
|
}
|
|
101
105
|
return false;
|
|
102
106
|
},
|
|
107
|
+
// Ignored via go/ees005
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
103
109
|
handleTextInput(view, from, to, text) {
|
|
104
110
|
const {
|
|
105
111
|
state,
|
|
@@ -12,10 +12,12 @@ import { createPlugin } from '@atlaskit/prosemirror-input-rules';
|
|
|
12
12
|
* @param text text to replace with
|
|
13
13
|
*/
|
|
14
14
|
function replaceTextUsingCaptureGroup(text) {
|
|
15
|
+
// Ignored via go/ees005
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
15
17
|
return (state, match, start, end) => {
|
|
16
18
|
const [, prefix,, suffix] = match;
|
|
17
19
|
const replacement = text + (suffix || '');
|
|
18
|
-
|
|
20
|
+
const {
|
|
19
21
|
tr,
|
|
20
22
|
selection: {
|
|
21
23
|
$to
|
|
@@ -58,6 +60,8 @@ function createReplacementRules(replMap, replacementRuleWithAnalytics) {
|
|
|
58
60
|
function createSingleQuotesRules() {
|
|
59
61
|
return [
|
|
60
62
|
// wrapped text
|
|
63
|
+
// Ignored via go/ees005
|
|
64
|
+
// eslint-disable-next-line require-unicode-regexp, @typescript-eslint/max-params
|
|
61
65
|
createRule(/(\s|^)'(\S+.*\S+)'$/, (state, match, start, end) => {
|
|
62
66
|
const OPEN_SMART_QUOTE_CHAR = '‘';
|
|
63
67
|
const CLOSED_SMART_QUOTE_CHAR = '’';
|
|
@@ -72,6 +76,8 @@ function createSingleQuotesRules() {
|
|
|
72
76
|
return state.tr.insertText(CLOSED_SMART_QUOTE_CHAR, positionOfClosedQuote, end).insertText(openQuoteReplacement, start, start + openQuoteReplacement.length);
|
|
73
77
|
}),
|
|
74
78
|
// apostrophe
|
|
79
|
+
// Ignored via go/ees005
|
|
80
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
75
81
|
createReplacementRule('’', /(\w+)(')(\w+)$/)];
|
|
76
82
|
}
|
|
77
83
|
|
|
@@ -90,10 +96,20 @@ function getProductRules(editorAnalyticsAPI) {
|
|
|
90
96
|
}
|
|
91
97
|
}), editorAnalyticsAPI);
|
|
92
98
|
return createReplacementRules({
|
|
99
|
+
// Ignored via go/ees005
|
|
100
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
93
101
|
Atlassian: /(\s+|^)(atlassian)(\s)$/,
|
|
102
|
+
// Ignored via go/ees005
|
|
103
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
94
104
|
Jira: /(\s+|^)(jira|JIRA)(\s)$/,
|
|
105
|
+
// Ignored via go/ees005
|
|
106
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
95
107
|
Bitbucket: /(\s+|^)(bitbucket|BitBucket)(\s)$/,
|
|
108
|
+
// Ignored via go/ees005
|
|
109
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
96
110
|
Hipchat: /(\s+|^)(hipchat|HipChat)(\s)$/,
|
|
111
|
+
// Ignored via go/ees005
|
|
112
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
97
113
|
Trello: /(\s+|^)(trello)(\s)$/
|
|
98
114
|
}, productRuleWithAnalytics);
|
|
99
115
|
}
|
|
@@ -117,8 +133,14 @@ function getSymbolRules(editorAnalyticsAPI) {
|
|
|
117
133
|
}
|
|
118
134
|
}, editorAnalyticsAPI);
|
|
119
135
|
return createReplacementRules({
|
|
136
|
+
// Ignored via go/ees005
|
|
137
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
120
138
|
'→': /(\s+|^)(--?>)(\s)$/,
|
|
139
|
+
// Ignored via go/ees005
|
|
140
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
121
141
|
'←': /(\s+|^)(<--?)(\s)$/,
|
|
142
|
+
// Ignored via go/ees005
|
|
143
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
122
144
|
'↔︎': /(\s+|^)(<->?)(\s)$/
|
|
123
145
|
}, symbolRuleWithAnalytics);
|
|
124
146
|
}
|
|
@@ -143,11 +165,19 @@ function getPunctuationRules(editorAnalyticsAPI) {
|
|
|
143
165
|
}
|
|
144
166
|
}, editorAnalyticsAPI);
|
|
145
167
|
const dashEllipsisRules = createReplacementRules({
|
|
168
|
+
// Ignored via go/ees005
|
|
169
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
146
170
|
'–': /(\s+|^)(--)(\s)$/,
|
|
171
|
+
// Ignored via go/ees005
|
|
172
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
147
173
|
'…': /()(\.\.\.)$/
|
|
148
174
|
}, punctuationRuleWithAnalytics);
|
|
149
175
|
const doubleQuoteRules = createReplacementRules({
|
|
176
|
+
// Ignored via go/ees005
|
|
177
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
150
178
|
'“': /((?:^|[\s\{\[\(\<'"\u2018\u201C]))(")$/,
|
|
179
|
+
// Ignored via go/ees005
|
|
180
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
151
181
|
'”': /"$/
|
|
152
182
|
}, punctuationRuleWithAnalytics);
|
|
153
183
|
const singleQuoteRules = createSingleQuotesRules();
|
|
@@ -47,9 +47,15 @@ const FloatingToolbarTextFormat = ({
|
|
|
47
47
|
});
|
|
48
48
|
const items = useMemo(() => {
|
|
49
49
|
if (!clearIcon) {
|
|
50
|
-
return
|
|
50
|
+
return [{
|
|
51
|
+
items: defaultIcons
|
|
52
|
+
}];
|
|
51
53
|
}
|
|
52
|
-
return [
|
|
54
|
+
return [{
|
|
55
|
+
items: defaultIcons
|
|
56
|
+
}, {
|
|
57
|
+
items: [clearIcon]
|
|
58
|
+
}];
|
|
53
59
|
}, [clearIcon, defaultIcons]);
|
|
54
60
|
return jsx(FormattingTextDropdownMenu, {
|
|
55
61
|
editorView: editorView,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback,
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
2
|
import { toolbarMessages } from '@atlaskit/editor-common/messages';
|
|
3
3
|
import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
4
4
|
import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
|
|
@@ -20,9 +20,6 @@ export const FormattingTextDropdownMenu = /*#__PURE__*/React.memo(({
|
|
|
20
20
|
}) => {
|
|
21
21
|
const [isMenuOpen, toggleMenu, closeMenu] = useMenuState();
|
|
22
22
|
const [isOpenedByKeyboard, setIsOpenedByKeyboard] = useState(false);
|
|
23
|
-
const group = useMemo(() => [{
|
|
24
|
-
items
|
|
25
|
-
}], [items]);
|
|
26
23
|
const onItemActivated = useCallback(({
|
|
27
24
|
item,
|
|
28
25
|
shouldCloseMenu = true
|
|
@@ -41,11 +38,14 @@ export const FormattingTextDropdownMenu = /*#__PURE__*/React.memo(({
|
|
|
41
38
|
scrollableElement: popupsScrollableElement,
|
|
42
39
|
onItemActivated: onItemActivated,
|
|
43
40
|
isOpen: isMenuOpen,
|
|
44
|
-
items:
|
|
41
|
+
items: items,
|
|
45
42
|
zIndex: akEditorMenuZIndex,
|
|
46
43
|
fitHeight: 188,
|
|
47
44
|
fitWidth: 136,
|
|
48
45
|
shouldUseDefaultRole: true,
|
|
46
|
+
section: {
|
|
47
|
+
hasSeparator: true
|
|
48
|
+
},
|
|
49
49
|
shouldFocusFirstItem: () => {
|
|
50
50
|
if (isOpenedByKeyboard) {
|
|
51
51
|
setIsOpenedByKeyboard(false);
|
|
@@ -106,9 +106,15 @@ const ToolbarFormatting = ({
|
|
|
106
106
|
}
|
|
107
107
|
const items = useMemo(() => {
|
|
108
108
|
if (!clearIcon) {
|
|
109
|
-
return
|
|
109
|
+
return [{
|
|
110
|
+
items: dropdownItems
|
|
111
|
+
}];
|
|
110
112
|
}
|
|
111
|
-
return [
|
|
113
|
+
return [{
|
|
114
|
+
items: dropdownItems
|
|
115
|
+
}, {
|
|
116
|
+
items: [clearIcon]
|
|
117
|
+
}];
|
|
112
118
|
}, [clearIcon, dropdownItems]);
|
|
113
119
|
const moreFormattingButtonLabel = intl.formatMessage(toolbarMessages.moreFormatting);
|
|
114
120
|
const labelTextFormat = intl.formatMessage(toolbarMessages.textFormatting);
|
|
@@ -17,6 +17,9 @@ var formatTypes = {
|
|
|
17
17
|
export function clearFormattingWithAnalytics(inputMethod, editorAnalyticsAPI) {
|
|
18
18
|
return clearFormatting(inputMethod, editorAnalyticsAPI);
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
// Ignored via go/ees005
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
20
23
|
function clearNodeFormattingOnSelection(state, tr, formattedNodeType, nodeName, formattingCleared) {
|
|
21
24
|
return function (node, pos) {
|
|
22
25
|
if (node.type === formattedNodeType) {
|
|
@@ -33,6 +36,8 @@ function clearNodeFormattingOnSelection(state, tr, formattedNodeType, nodeName,
|
|
|
33
36
|
var targetLiftDepth = liftTarget(nodeRange);
|
|
34
37
|
if (targetLiftDepth || targetLiftDepth === 0) {
|
|
35
38
|
formattingCleared.push(nodeName);
|
|
39
|
+
// Ignored via go/ees005
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
36
41
|
tr.lift(nodeRange, targetLiftDepth);
|
|
37
42
|
}
|
|
38
43
|
}
|
|
@@ -9,8 +9,14 @@ var SMART_TO_ASCII = {
|
|
|
9
9
|
'‘': "'",
|
|
10
10
|
'’': "'"
|
|
11
11
|
};
|
|
12
|
+
|
|
13
|
+
// Ignored via go/ees005
|
|
14
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
12
15
|
var FIND_SMART_CHAR = new RegExp("[".concat(Object.keys(SMART_TO_ASCII).join(''), "]"), 'g');
|
|
13
|
-
var replaceMentionOrEmojiForTextContent = function replaceMentionOrEmojiForTextContent(position, nodeSize, textContent, tr
|
|
16
|
+
var replaceMentionOrEmojiForTextContent = function replaceMentionOrEmojiForTextContent(position, nodeSize, textContent, tr
|
|
17
|
+
// Ignored via go/ees005
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
19
|
+
) {
|
|
14
20
|
var currentPos = tr.mapping.map(position);
|
|
15
21
|
var schema = tr.doc.type.schema;
|
|
16
22
|
tr.replaceWith(currentPos, currentPos + nodeSize, schema.text(textContent));
|
|
@@ -18,6 +24,9 @@ var replaceMentionOrEmojiForTextContent = function replaceMentionOrEmojiForTextC
|
|
|
18
24
|
var replaceSmartCharsToAscii = function replaceSmartCharsToAscii(position, textContent, tr) {
|
|
19
25
|
var schema = tr.doc.type.schema;
|
|
20
26
|
var match;
|
|
27
|
+
|
|
28
|
+
// Ignored via go/ees005
|
|
29
|
+
// eslint-disable-next-line no-cond-assign
|
|
21
30
|
while (match = FIND_SMART_CHAR.exec(textContent)) {
|
|
22
31
|
var _match = match,
|
|
23
32
|
smartChar = _match[0],
|
|
@@ -32,6 +41,9 @@ var isNodeTextBlock = function isNodeTextBlock(schema) {
|
|
|
32
41
|
mention = _schema$nodes.mention,
|
|
33
42
|
text = _schema$nodes.text,
|
|
34
43
|
emoji = _schema$nodes.emoji;
|
|
44
|
+
|
|
45
|
+
// Ignored via go/ees005
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
47
|
return function (node, _, parent) {
|
|
36
48
|
if (node.type === mention || node.type === emoji || node.type === text) {
|
|
37
49
|
return parent === null || parent === void 0 ? void 0 : parent.isTextblock;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export var cellSelectionNodesBetween = function cellSelectionNodesBetween(selection, doc, f, startPos
|
|
1
|
+
export var cellSelectionNodesBetween = function cellSelectionNodesBetween(selection, doc, f, startPos
|
|
2
|
+
// Ignored via go/ees005
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
4
|
+
) {
|
|
2
5
|
selection.forEachCell(function (cell, cellPos) {
|
|
3
6
|
doc.nodesBetween(cellPos, cellPos + cell.nodeSize, f, startPos);
|
|
4
7
|
});
|
|
@@ -4,7 +4,10 @@ import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
|
4
4
|
import { clearFormattingWithAnalytics } from '../editor-commands/clear-formatting';
|
|
5
5
|
export function keymapPlugin(editorAnalyticsAPI) {
|
|
6
6
|
var list = {};
|
|
7
|
-
bindKeymapWithCommand(
|
|
7
|
+
bindKeymapWithCommand(
|
|
8
|
+
// Ignored via go/ees005
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
10
|
+
clearFormatting.common, clearFormattingWithAnalytics(INPUT_METHOD.SHORTCUT, editorAnalyticsAPI), list);
|
|
8
11
|
return keymap(list);
|
|
9
12
|
}
|
|
10
13
|
export default keymapPlugin;
|
|
@@ -10,6 +10,8 @@ export var plugin = function plugin(dispatch) {
|
|
|
10
10
|
formattingIsPresent: checkFormattingIsPresent(state)
|
|
11
11
|
};
|
|
12
12
|
},
|
|
13
|
+
// Ignored via go/ees005
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
13
15
|
apply: function apply(_tr, pluginState, _oldState, newState) {
|
|
14
16
|
var formattingIsPresent = checkFormattingIsPresent(newState);
|
|
15
17
|
if (formattingIsPresent !== pluginState.formattingIsPresent) {
|
|
@@ -5,6 +5,8 @@ export default new SafePlugin({
|
|
|
5
5
|
props: {
|
|
6
6
|
handleClick: function handleClick(view, clickPos, event) {
|
|
7
7
|
// Don't apply in Edge as per ED-4546
|
|
8
|
+
// Ignored via go/ees005
|
|
9
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
8
10
|
if (navigator && /Edge\/\d/.test(navigator.userAgent)) {
|
|
9
11
|
return false;
|
|
10
12
|
}
|
|
@@ -30,7 +32,10 @@ export default new SafePlugin({
|
|
|
30
32
|
// it was at a directly adjacent non-text node, so we skip this manual
|
|
31
33
|
// text selection logic to preserve that non-text node's selection
|
|
32
34
|
clickWasAtTextNode || clickWasAtEndOfAParagraphNode)) {
|
|
33
|
-
var clickWasInsideNodeDOM = event.target.parentNode === view.domAtPos(clickedDOMElementPosition).node &&
|
|
35
|
+
var clickWasInsideNodeDOM = event.target.parentNode === view.domAtPos(clickedDOMElementPosition).node &&
|
|
36
|
+
// Ignored via go/ees005
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
38
|
+
code.isInSet(view.state.doc.resolve(clickedDOMElementPosition).nodeAfter.marks);
|
|
34
39
|
var nodeNextToClick = $click.nodeBefore && code.isInSet($click.nodeBefore.marks) ? $click.nodeAfter : $click.nodeBefore;
|
|
35
40
|
|
|
36
41
|
// Need to set the selection here to allow clicking between [code('text'),{<>},emoji()]
|
|
@@ -52,6 +52,8 @@ ValidAutoformatChars.STRONG_MARKDOWN]), ValidAutoformatChars.CODE, [
|
|
|
52
52
|
// e.g: loko (`some code`
|
|
53
53
|
'( ']);
|
|
54
54
|
function addMark(markType, schema, char) {
|
|
55
|
+
// Ignored via go/ees005
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
55
57
|
return function (state, match, start, end) {
|
|
56
58
|
var _schema$marks;
|
|
57
59
|
var doc = state.doc,
|
|
@@ -134,7 +136,11 @@ var ReverseRegexExp = /*#__PURE__*/function (_RegExp) {
|
|
|
134
136
|
}]);
|
|
135
137
|
}( /*#__PURE__*/_wrapNativeSuper(RegExp));
|
|
136
138
|
var buildRegex = function buildRegex(char) {
|
|
139
|
+
// Ignored via go/ees005
|
|
140
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
137
141
|
var escapedChar = char.replace(/(\W)/g, '\\$1');
|
|
142
|
+
// Ignored via go/ees005
|
|
143
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
138
144
|
var combinations = ValidCombinations[char].map(function (c) {
|
|
139
145
|
return c.replace(/(\W)/g, '\\$1');
|
|
140
146
|
}).join('|');
|
|
@@ -142,7 +148,13 @@ var buildRegex = function buildRegex(char) {
|
|
|
142
148
|
// Single X - https://regex101.com/r/McT3yq/14/
|
|
143
149
|
// Double X - https://regex101.com/r/pQUgjx/1/
|
|
144
150
|
var baseRegex = '^X(?=[^X\\s]).*?[^\\sX]X(?=[\\sOBJECT_REPLACEMENT_CHARACTER]COMBINATIONS|$)'.replace('OBJECT_REPLACEMENT_CHARACTER', leafNodeReplacementCharacter).replace('COMBINATIONS', combinations ? "|".concat(combinations) : '');
|
|
145
|
-
var replacedRegex = String.prototype.hasOwnProperty('replaceAll') ?
|
|
151
|
+
var replacedRegex = String.prototype.hasOwnProperty('replaceAll') ?
|
|
152
|
+
// Ignored via go/ees005
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
154
|
+
baseRegex.replaceAll('X', escapedChar) :
|
|
155
|
+
// Ignored via go/ees005
|
|
156
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
157
|
+
baseRegex.replace(/X/g, escapedChar);
|
|
146
158
|
return new ReverseRegexExp(replacedRegex);
|
|
147
159
|
};
|
|
148
160
|
export var strongRegex1 = buildRegex(ValidAutoformatChars.STRONG);
|
|
@@ -6,25 +6,46 @@ import { toggleCodeWithAnalytics, toggleEmWithAnalytics, toggleStrikeWithAnalyti
|
|
|
6
6
|
export default function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
7
7
|
var list = {};
|
|
8
8
|
if (schema.marks.strong) {
|
|
9
|
-
bindKeymapWithEditorCommand(
|
|
9
|
+
bindKeymapWithEditorCommand(
|
|
10
|
+
// Ignored via go/ees005
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12
|
+
toggleBold.common, toggleStrongWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
10
13
|
}
|
|
11
14
|
if (schema.marks.em) {
|
|
12
|
-
bindKeymapWithEditorCommand(
|
|
15
|
+
bindKeymapWithEditorCommand(
|
|
16
|
+
// Ignored via go/ees005
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
18
|
+
toggleItalic.common, toggleEmWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
13
19
|
}
|
|
14
20
|
if (schema.marks.code) {
|
|
15
|
-
bindKeymapWithEditorCommand(
|
|
21
|
+
bindKeymapWithEditorCommand(
|
|
22
|
+
// Ignored via go/ees005
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
24
|
+
toggleCode.common, toggleCodeWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
16
25
|
}
|
|
17
26
|
if (schema.marks.strike) {
|
|
18
|
-
bindKeymapWithEditorCommand(
|
|
27
|
+
bindKeymapWithEditorCommand(
|
|
28
|
+
// Ignored via go/ees005
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
30
|
+
toggleStrikethrough.common, toggleStrikeWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
19
31
|
}
|
|
20
32
|
if (schema.marks.subsup) {
|
|
21
|
-
bindKeymapWithEditorCommand(
|
|
33
|
+
bindKeymapWithEditorCommand(
|
|
34
|
+
// Ignored via go/ees005
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
36
|
+
toggleSubscript.common, toggleSubscriptWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
22
37
|
}
|
|
23
38
|
if (schema.marks.subsup) {
|
|
24
|
-
bindKeymapWithEditorCommand(
|
|
39
|
+
bindKeymapWithEditorCommand(
|
|
40
|
+
// Ignored via go/ees005
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
42
|
+
toggleSuperscript.common, toggleSuperscriptWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
25
43
|
}
|
|
26
44
|
if (schema.marks.underline) {
|
|
27
|
-
bindKeymapWithEditorCommand(
|
|
45
|
+
bindKeymapWithEditorCommand(
|
|
46
|
+
// Ignored via go/ees005
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
48
|
+
toggleUnderline.common, toggleUnderlineWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.SHORTCUT), list);
|
|
28
49
|
}
|
|
29
50
|
return new SafePlugin({
|
|
30
51
|
props: {
|
|
@@ -8,6 +8,8 @@ import { shallowEqual } from '@atlaskit/editor-common/utils';
|
|
|
8
8
|
import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
|
|
9
9
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
10
|
import { createInlineCodeFromTextInputWithAnalytics } from '../editor-commands/text-formatting';
|
|
11
|
+
// Ignored via go/ees005
|
|
12
|
+
// eslint-disable-next-line import/no-namespace
|
|
11
13
|
import * as commands from '../editor-commands/text-formatting';
|
|
12
14
|
import { pluginKey } from './plugin-key';
|
|
13
15
|
var isSelectionInlineCursor = function isSelectionInlineCursor(selection) {
|
|
@@ -77,6 +79,8 @@ export var plugin = function plugin(dispatch, editorAnalyticsAPI) {
|
|
|
77
79
|
init: function init(_config, state) {
|
|
78
80
|
return getTextFormattingState(state, editorAnalyticsAPI);
|
|
79
81
|
},
|
|
82
|
+
// Ignored via go/ees005
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
80
84
|
apply: function apply(_tr, pluginState, _oldState, newState) {
|
|
81
85
|
var state = getTextFormattingState(newState, editorAnalyticsAPI);
|
|
82
86
|
if (!shallowEqual(pluginState, state)) {
|
|
@@ -98,6 +102,8 @@ export var plugin = function plugin(dispatch, editorAnalyticsAPI) {
|
|
|
98
102
|
}
|
|
99
103
|
return false;
|
|
100
104
|
},
|
|
105
|
+
// Ignored via go/ees005
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
101
107
|
handleTextInput: function handleTextInput(view, from, to, text) {
|
|
102
108
|
var state = view.state,
|
|
103
109
|
dispatch = view.dispatch;
|
|
@@ -15,6 +15,8 @@ import { createPlugin } from '@atlaskit/prosemirror-input-rules';
|
|
|
15
15
|
* @param text text to replace with
|
|
16
16
|
*/
|
|
17
17
|
function replaceTextUsingCaptureGroup(text) {
|
|
18
|
+
// Ignored via go/ees005
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
18
20
|
return function (state, match, start, end) {
|
|
19
21
|
var _match = _slicedToArray(match, 4),
|
|
20
22
|
prefix = _match[1],
|
|
@@ -59,6 +61,8 @@ function createReplacementRules(replMap, replacementRuleWithAnalytics) {
|
|
|
59
61
|
function createSingleQuotesRules() {
|
|
60
62
|
return [
|
|
61
63
|
// wrapped text
|
|
64
|
+
// Ignored via go/ees005
|
|
65
|
+
// eslint-disable-next-line require-unicode-regexp, @typescript-eslint/max-params
|
|
62
66
|
createRule(/(\s|^)'(\S+.*\S+)'$/, function (state, match, start, end) {
|
|
63
67
|
var OPEN_SMART_QUOTE_CHAR = '‘';
|
|
64
68
|
var CLOSED_SMART_QUOTE_CHAR = '’';
|
|
@@ -75,6 +79,8 @@ function createSingleQuotesRules() {
|
|
|
75
79
|
return state.tr.insertText(CLOSED_SMART_QUOTE_CHAR, positionOfClosedQuote, end).insertText(openQuoteReplacement, start, start + openQuoteReplacement.length);
|
|
76
80
|
}),
|
|
77
81
|
// apostrophe
|
|
82
|
+
// Ignored via go/ees005
|
|
83
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
78
84
|
createReplacementRule('’', /(\w+)(')(\w+)$/)];
|
|
79
85
|
}
|
|
80
86
|
|
|
@@ -97,10 +103,20 @@ function getProductRules(editorAnalyticsAPI) {
|
|
|
97
103
|
}, editorAnalyticsAPI);
|
|
98
104
|
};
|
|
99
105
|
return createReplacementRules({
|
|
106
|
+
// Ignored via go/ees005
|
|
107
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
100
108
|
Atlassian: /(\s+|^)(atlassian)(\s)$/,
|
|
109
|
+
// Ignored via go/ees005
|
|
110
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
101
111
|
Jira: /(\s+|^)(jira|JIRA)(\s)$/,
|
|
112
|
+
// Ignored via go/ees005
|
|
113
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
102
114
|
Bitbucket: /(\s+|^)(bitbucket|BitBucket)(\s)$/,
|
|
115
|
+
// Ignored via go/ees005
|
|
116
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
103
117
|
Hipchat: /(\s+|^)(hipchat|HipChat)(\s)$/,
|
|
118
|
+
// Ignored via go/ees005
|
|
119
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
104
120
|
Trello: /(\s+|^)(trello)(\s)$/
|
|
105
121
|
}, productRuleWithAnalytics);
|
|
106
122
|
}
|
|
@@ -126,8 +142,14 @@ function getSymbolRules(editorAnalyticsAPI) {
|
|
|
126
142
|
}, editorAnalyticsAPI);
|
|
127
143
|
};
|
|
128
144
|
return createReplacementRules({
|
|
145
|
+
// Ignored via go/ees005
|
|
146
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
129
147
|
'→': /(\s+|^)(--?>)(\s)$/,
|
|
148
|
+
// Ignored via go/ees005
|
|
149
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
130
150
|
'←': /(\s+|^)(<--?)(\s)$/,
|
|
151
|
+
// Ignored via go/ees005
|
|
152
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
131
153
|
'↔︎': /(\s+|^)(<->?)(\s)$/
|
|
132
154
|
}, symbolRuleWithAnalytics);
|
|
133
155
|
}
|
|
@@ -153,11 +175,19 @@ function getPunctuationRules(editorAnalyticsAPI) {
|
|
|
153
175
|
}, editorAnalyticsAPI);
|
|
154
176
|
};
|
|
155
177
|
var dashEllipsisRules = createReplacementRules({
|
|
178
|
+
// Ignored via go/ees005
|
|
179
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
156
180
|
'–': /(\s+|^)(--)(\s)$/,
|
|
181
|
+
// Ignored via go/ees005
|
|
182
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
157
183
|
'…': /()(\.\.\.)$/
|
|
158
184
|
}, punctuationRuleWithAnalytics);
|
|
159
185
|
var doubleQuoteRules = createReplacementRules({
|
|
186
|
+
// Ignored via go/ees005
|
|
187
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
160
188
|
'“': /((?:^|[\s\{\[\(\<'"\u2018\u201C]))(")$/,
|
|
189
|
+
// Ignored via go/ees005
|
|
190
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
161
191
|
'”': /"$/
|
|
162
192
|
}, punctuationRuleWithAnalytics);
|
|
163
193
|
var singleQuoteRules = createSingleQuotesRules();
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
1
|
/**
|
|
3
2
|
* @jsxRuntime classic
|
|
4
3
|
* @jsx jsx
|
|
@@ -46,9 +45,15 @@ var FloatingToolbarTextFormat = function FloatingToolbarTextFormat(_ref) {
|
|
|
46
45
|
});
|
|
47
46
|
var items = useMemo(function () {
|
|
48
47
|
if (!clearIcon) {
|
|
49
|
-
return
|
|
48
|
+
return [{
|
|
49
|
+
items: defaultIcons
|
|
50
|
+
}];
|
|
50
51
|
}
|
|
51
|
-
return [
|
|
52
|
+
return [{
|
|
53
|
+
items: defaultIcons
|
|
54
|
+
}, {
|
|
55
|
+
items: [clearIcon]
|
|
56
|
+
}];
|
|
52
57
|
}, [clearIcon, defaultIcons]);
|
|
53
58
|
return jsx(FormattingTextDropdownMenu, {
|
|
54
59
|
editorView: editorView,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, { useCallback,
|
|
2
|
+
import React, { useCallback, useState } from 'react';
|
|
3
3
|
import { toolbarMessages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
5
5
|
import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
|
|
@@ -27,11 +27,6 @@ export var FormattingTextDropdownMenu = /*#__PURE__*/React.memo(function (_ref)
|
|
|
27
27
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28
28
|
isOpenedByKeyboard = _useState2[0],
|
|
29
29
|
setIsOpenedByKeyboard = _useState2[1];
|
|
30
|
-
var group = useMemo(function () {
|
|
31
|
-
return [{
|
|
32
|
-
items: items
|
|
33
|
-
}];
|
|
34
|
-
}, [items]);
|
|
35
30
|
var onItemActivated = useCallback(function (_ref2) {
|
|
36
31
|
var item = _ref2.item,
|
|
37
32
|
_ref2$shouldCloseMenu = _ref2.shouldCloseMenu,
|
|
@@ -50,11 +45,14 @@ export var FormattingTextDropdownMenu = /*#__PURE__*/React.memo(function (_ref)
|
|
|
50
45
|
scrollableElement: popupsScrollableElement,
|
|
51
46
|
onItemActivated: onItemActivated,
|
|
52
47
|
isOpen: isMenuOpen,
|
|
53
|
-
items:
|
|
48
|
+
items: items,
|
|
54
49
|
zIndex: akEditorMenuZIndex,
|
|
55
50
|
fitHeight: 188,
|
|
56
51
|
fitWidth: 136,
|
|
57
52
|
shouldUseDefaultRole: true,
|
|
53
|
+
section: {
|
|
54
|
+
hasSeparator: true
|
|
55
|
+
},
|
|
58
56
|
shouldFocusFirstItem: function shouldFocusFirstItem() {
|
|
59
57
|
if (isOpenedByKeyboard) {
|
|
60
58
|
setIsOpenedByKeyboard(false);
|
|
@@ -111,9 +111,15 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
|
|
|
111
111
|
}
|
|
112
112
|
var items = useMemo(function () {
|
|
113
113
|
if (!clearIcon) {
|
|
114
|
-
return
|
|
114
|
+
return [{
|
|
115
|
+
items: dropdownItems
|
|
116
|
+
}];
|
|
115
117
|
}
|
|
116
|
-
return [
|
|
118
|
+
return [{
|
|
119
|
+
items: dropdownItems
|
|
120
|
+
}, {
|
|
121
|
+
items: [clearIcon]
|
|
122
|
+
}];
|
|
117
123
|
}, [clearIcon, dropdownItems]);
|
|
118
124
|
var moreFormattingButtonLabel = intl.formatMessage(toolbarMessages.moreFormatting);
|
|
119
125
|
var labelTextFormat = intl.formatMessage(toolbarMessages.textFormatting);
|
|
@@ -5,7 +5,9 @@ import { type MenuIconItem, ToolbarType } from './types';
|
|
|
5
5
|
type DropdownMenuProps = {
|
|
6
6
|
editorView: EditorView;
|
|
7
7
|
isReducedSpacing: boolean;
|
|
8
|
-
items:
|
|
8
|
+
items: {
|
|
9
|
+
items: MenuIconItem[];
|
|
10
|
+
}[];
|
|
9
11
|
moreButtonLabel: string;
|
|
10
12
|
hasFormattingActive: boolean;
|
|
11
13
|
popupsBoundariesElement?: HTMLElement;
|
|
@@ -5,7 +5,9 @@ import { type MenuIconItem, ToolbarType } from './types';
|
|
|
5
5
|
type DropdownMenuProps = {
|
|
6
6
|
editorView: EditorView;
|
|
7
7
|
isReducedSpacing: boolean;
|
|
8
|
-
items:
|
|
8
|
+
items: {
|
|
9
|
+
items: MenuIconItem[];
|
|
10
|
+
}[];
|
|
9
11
|
moreButtonLabel: string;
|
|
10
12
|
hasFormattingActive: boolean;
|
|
11
13
|
popupsBoundariesElement?: HTMLElement;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-text-formatting",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.6",
|
|
4
4
|
"description": "Text-formatting plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
35
|
-
"@atlaskit/editor-common": "^
|
|
35
|
+
"@atlaskit/editor-common": "^98.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
37
37
|
"@atlaskit/editor-plugin-primary-toolbar": "^2.1.0",
|
|
38
38
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@atlaskit/icon": "^23.1.0",
|
|
42
42
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
43
43
|
"@atlaskit/prosemirror-input-rules": "^3.2.0",
|
|
44
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
44
|
+
"@atlaskit/tmp-editor-statsig": "^2.31.0",
|
|
45
45
|
"@atlaskit/tokens": "^2.5.0",
|
|
46
46
|
"@babel/runtime": "^7.0.0",
|
|
47
47
|
"@emotion/react": "^11.7.1",
|