@atlaskit/editor-plugin-text-formatting 12.0.2 → 12.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-plugin-text-formatting
2
2
 
3
+ ## 12.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`c75659db298a9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c75659db298a9) -
8
+ Clean up prefer static regex violations
9
+ - Updated dependencies
10
+
3
11
  ## 12.0.2
4
12
 
5
13
  ### Patch Changes
@@ -6,14 +6,16 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
8
  var _state = require("@atlaskit/editor-prosemirror/state");
9
+ // Don't apply in Edge as per ED-4546
10
+ // Ignored via go/ees005
11
+ // eslint-disable-next-line require-unicode-regexp
12
+ var EDGE_USER_AGENT_REGEX = /Edge\/\d/;
9
13
  // eslint-disable-next-line import/no-anonymous-default-export
10
14
  var _default_1 = new _safePlugin.SafePlugin({
11
15
  props: {
12
16
  handleClick: function handleClick(view, clickPos, event) {
13
17
  // Don't apply in Edge as per ED-4546
14
- // Ignored via go/ees005
15
- // eslint-disable-next-line require-unicode-regexp
16
- if (navigator && /Edge\/\d/.test(navigator.userAgent)) {
18
+ if (navigator && EDGE_USER_AGENT_REGEX.test(navigator.userAgent)) {
17
19
  return false;
18
20
  }
19
21
 
@@ -13,6 +13,60 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
13
13
  var _utils = require("@atlaskit/editor-common/utils");
14
14
  var _state = require("@atlaskit/editor-prosemirror/state");
15
15
  var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
16
+ // We don't agressively upgrade single quotes to smart quotes because
17
+ // they may clash with an emoji. Only do that when we have a matching
18
+ // single quote, or a contraction.
19
+ // wrapped text
20
+ // Ignored via go/ees005
21
+ // eslint-disable-next-line require-unicode-regexp
22
+ var WRAPPED_SINGLE_QUOTE_REGEX = /(\s|^)'(\S+.*\S+)'$/;
23
+ // apostrophe
24
+ // Ignored via go/ees005
25
+ // eslint-disable-next-line require-unicode-regexp
26
+ var APOSTROPHE_REGEX = /(\w+)(')(\w+)$/;
27
+
28
+ // Product rules
29
+ // Ignored via go/ees005
30
+ // eslint-disable-next-line require-unicode-regexp
31
+ var ATLASSIAN_REGEX = /(\s+|^)(atlassian)(\s)$/;
32
+ // Ignored via go/ees005
33
+ // eslint-disable-next-line require-unicode-regexp
34
+ var JIRA_REGEX = /(\s+|^)(jira|JIRA)(\s)$/;
35
+ // Ignored via go/ees005
36
+ // eslint-disable-next-line require-unicode-regexp
37
+ var BITBUCKET_REGEX = /(\s+|^)(bitbucket|BitBucket)(\s)$/;
38
+ // Ignored via go/ees005
39
+ // eslint-disable-next-line require-unicode-regexp
40
+ var HIPCHAT_REGEX = /(\s+|^)(hipchat|HipChat)(\s)$/;
41
+ // Ignored via go/ees005
42
+ // eslint-disable-next-line require-unicode-regexp
43
+ var TRELLO_REGEX = /(\s+|^)(trello)(\s)$/;
44
+
45
+ // Symbol rules
46
+ // Ignored via go/ees005
47
+ // eslint-disable-next-line require-unicode-regexp
48
+ var ARROW_RIGHT_REGEX = /(\s+|^)(--?>)(\s)$/;
49
+ // Ignored via go/ees005
50
+ // eslint-disable-next-line require-unicode-regexp
51
+ var ARROW_LEFT_REGEX = /(\s+|^)(<--?)(\s)$/;
52
+ // Ignored via go/ees005
53
+ // eslint-disable-next-line require-unicode-regexp
54
+ var ARROW_DOUBLE_REGEX = /(\s+|^)(<->?)(\s)$/;
55
+
56
+ // Punctuation rules
57
+ // Ignored via go/ees005
58
+ // eslint-disable-next-line require-unicode-regexp
59
+ var DASH_REGEX = /(\s+|^)(--)(\s)$/;
60
+ // Ignored via go/ees005
61
+ // eslint-disable-next-line require-unicode-regexp
62
+ var ELLIPSIS_REGEX = /()(\.\.\.)$/;
63
+ // Ignored via go/ees005
64
+ // eslint-disable-next-line require-unicode-regexp
65
+ var OPEN_DOUBLE_QUOTE_REGEX = /((?:^|[\s\{\[\(\<'"\u2018\u201C]))(")$/;
66
+ // Ignored via go/ees005
67
+ // eslint-disable-next-line require-unicode-regexp
68
+ var CLOSE_DOUBLE_QUOTE_REGEX = /"$/;
69
+
16
70
  /**
17
71
  * Creates an InputRuleHandler that will match on a regular expression of the
18
72
  * form `(prefix, content, suffix?)`, and replace it with some given text,
@@ -65,8 +119,7 @@ function createReplacementRules(replMap, replacementRuleWithAnalytics) {
65
119
  function createSingleQuotesRules() {
66
120
  return [
67
121
  // wrapped text
68
- // eslint-disable-next-line require-unicode-regexp
69
- (0, _utils.createRule)(/(\s|^)'(\S+.*\S+)'$/, function (state, match, start, end) {
122
+ (0, _utils.createRule)(WRAPPED_SINGLE_QUOTE_REGEX, function (state, match, start, end) {
70
123
  var OPEN_SMART_QUOTE_CHAR = '‘';
71
124
  var CLOSED_SMART_QUOTE_CHAR = '’';
72
125
  var _match2 = (0, _slicedToArray2.default)(match, 3),
@@ -82,9 +135,7 @@ function createSingleQuotesRules() {
82
135
  return state.tr.insertText(CLOSED_SMART_QUOTE_CHAR, positionOfClosedQuote, end).insertText(openQuoteReplacement, start, start + openQuoteReplacement.length);
83
136
  }),
84
137
  // apostrophe
85
- // Ignored via go/ees005
86
- // eslint-disable-next-line require-unicode-regexp
87
- createReplacementRule('’', /(\w+)(')(\w+)$/)];
138
+ createReplacementRule('’', APOSTROPHE_REGEX)];
88
139
  }
89
140
 
90
141
  /**
@@ -106,21 +157,11 @@ function getProductRules(editorAnalyticsAPI) {
106
157
  }, editorAnalyticsAPI);
107
158
  };
108
159
  return createReplacementRules({
109
- // Ignored via go/ees005
110
- // eslint-disable-next-line require-unicode-regexp
111
- Atlassian: /(\s+|^)(atlassian)(\s)$/,
112
- // Ignored via go/ees005
113
- // eslint-disable-next-line require-unicode-regexp
114
- Jira: /(\s+|^)(jira|JIRA)(\s)$/,
115
- // Ignored via go/ees005
116
- // eslint-disable-next-line require-unicode-regexp
117
- Bitbucket: /(\s+|^)(bitbucket|BitBucket)(\s)$/,
118
- // Ignored via go/ees005
119
- // eslint-disable-next-line require-unicode-regexp
120
- Hipchat: /(\s+|^)(hipchat|HipChat)(\s)$/,
121
- // Ignored via go/ees005
122
- // eslint-disable-next-line require-unicode-regexp
123
- Trello: /(\s+|^)(trello)(\s)$/
160
+ Atlassian: ATLASSIAN_REGEX,
161
+ Jira: JIRA_REGEX,
162
+ Bitbucket: BITBUCKET_REGEX,
163
+ Hipchat: HIPCHAT_REGEX,
164
+ Trello: TRELLO_REGEX
124
165
  }, productRuleWithAnalytics);
125
166
  }
126
167
 
@@ -145,15 +186,9 @@ function getSymbolRules(editorAnalyticsAPI) {
145
186
  }, editorAnalyticsAPI);
146
187
  };
147
188
  return createReplacementRules({
148
- // Ignored via go/ees005
149
- // eslint-disable-next-line require-unicode-regexp
150
- '→': /(\s+|^)(--?>)(\s)$/,
151
- // Ignored via go/ees005
152
- // eslint-disable-next-line require-unicode-regexp
153
- '←': /(\s+|^)(<--?)(\s)$/,
154
- // Ignored via go/ees005
155
- // eslint-disable-next-line require-unicode-regexp
156
- '↔︎': /(\s+|^)(<->?)(\s)$/
189
+ '→': ARROW_RIGHT_REGEX,
190
+ '←': ARROW_LEFT_REGEX,
191
+ '↔︎': ARROW_DOUBLE_REGEX
157
192
  }, symbolRuleWithAnalytics);
158
193
  }
159
194
 
@@ -178,20 +213,12 @@ function getPunctuationRules(editorAnalyticsAPI) {
178
213
  }, editorAnalyticsAPI);
179
214
  };
180
215
  var dashEllipsisRules = createReplacementRules({
181
- // Ignored via go/ees005
182
- // eslint-disable-next-line require-unicode-regexp
183
- '–': /(\s+|^)(--)(\s)$/,
184
- // Ignored via go/ees005
185
- // eslint-disable-next-line require-unicode-regexp
186
- '…': /()(\.\.\.)$/
216
+ '–': DASH_REGEX,
217
+ '…': ELLIPSIS_REGEX
187
218
  }, punctuationRuleWithAnalytics);
188
219
  var doubleQuoteRules = createReplacementRules({
189
- // Ignored via go/ees005
190
- // eslint-disable-next-line require-unicode-regexp
191
- '“': /((?:^|[\s\{\[\(\<'"\u2018\u201C]))(")$/,
192
- // Ignored via go/ees005
193
- // eslint-disable-next-line require-unicode-regexp
194
- '”': /"$/
220
+ '“': OPEN_DOUBLE_QUOTE_REGEX,
221
+ '”': CLOSE_DOUBLE_QUOTE_REGEX
195
222
  }, punctuationRuleWithAnalytics);
196
223
  var singleQuoteRules = createSingleQuotesRules();
197
224
  return [].concat((0, _toConsumableArray2.default)(dashEllipsisRules), (0, _toConsumableArray2.default)(doubleQuoteRules), (0, _toConsumableArray2.default)(singleQuoteRules.map(function (rule) {
@@ -1,13 +1,15 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
+ // Don't apply in Edge as per ED-4546
4
+ // Ignored via go/ees005
5
+ // eslint-disable-next-line require-unicode-regexp
6
+ const EDGE_USER_AGENT_REGEX = /Edge\/\d/;
3
7
  // eslint-disable-next-line import/no-anonymous-default-export
4
8
  const _default_1 = new SafePlugin({
5
9
  props: {
6
10
  handleClick(view, clickPos, event) {
7
11
  // Don't apply in Edge as per ED-4546
8
- // Ignored via go/ees005
9
- // eslint-disable-next-line require-unicode-regexp
10
- if (navigator && /Edge\/\d/.test(navigator.userAgent)) {
12
+ if (navigator && EDGE_USER_AGENT_REGEX.test(navigator.userAgent)) {
11
13
  return false;
12
14
  }
13
15
 
@@ -4,6 +4,60 @@ import { createRule, inputRuleWithAnalytics } from '@atlaskit/editor-common/util
4
4
  import { Selection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { createPlugin } from '@atlaskit/prosemirror-input-rules';
6
6
 
7
+ // We don't agressively upgrade single quotes to smart quotes because
8
+ // they may clash with an emoji. Only do that when we have a matching
9
+ // single quote, or a contraction.
10
+ // wrapped text
11
+ // Ignored via go/ees005
12
+ // eslint-disable-next-line require-unicode-regexp
13
+ const WRAPPED_SINGLE_QUOTE_REGEX = /(\s|^)'(\S+.*\S+)'$/;
14
+ // apostrophe
15
+ // Ignored via go/ees005
16
+ // eslint-disable-next-line require-unicode-regexp
17
+ const APOSTROPHE_REGEX = /(\w+)(')(\w+)$/;
18
+
19
+ // Product rules
20
+ // Ignored via go/ees005
21
+ // eslint-disable-next-line require-unicode-regexp
22
+ const ATLASSIAN_REGEX = /(\s+|^)(atlassian)(\s)$/;
23
+ // Ignored via go/ees005
24
+ // eslint-disable-next-line require-unicode-regexp
25
+ const JIRA_REGEX = /(\s+|^)(jira|JIRA)(\s)$/;
26
+ // Ignored via go/ees005
27
+ // eslint-disable-next-line require-unicode-regexp
28
+ const BITBUCKET_REGEX = /(\s+|^)(bitbucket|BitBucket)(\s)$/;
29
+ // Ignored via go/ees005
30
+ // eslint-disable-next-line require-unicode-regexp
31
+ const HIPCHAT_REGEX = /(\s+|^)(hipchat|HipChat)(\s)$/;
32
+ // Ignored via go/ees005
33
+ // eslint-disable-next-line require-unicode-regexp
34
+ const TRELLO_REGEX = /(\s+|^)(trello)(\s)$/;
35
+
36
+ // Symbol rules
37
+ // Ignored via go/ees005
38
+ // eslint-disable-next-line require-unicode-regexp
39
+ const ARROW_RIGHT_REGEX = /(\s+|^)(--?>)(\s)$/;
40
+ // Ignored via go/ees005
41
+ // eslint-disable-next-line require-unicode-regexp
42
+ const ARROW_LEFT_REGEX = /(\s+|^)(<--?)(\s)$/;
43
+ // Ignored via go/ees005
44
+ // eslint-disable-next-line require-unicode-regexp
45
+ const ARROW_DOUBLE_REGEX = /(\s+|^)(<->?)(\s)$/;
46
+
47
+ // Punctuation rules
48
+ // Ignored via go/ees005
49
+ // eslint-disable-next-line require-unicode-regexp
50
+ const DASH_REGEX = /(\s+|^)(--)(\s)$/;
51
+ // Ignored via go/ees005
52
+ // eslint-disable-next-line require-unicode-regexp
53
+ const ELLIPSIS_REGEX = /()(\.\.\.)$/;
54
+ // Ignored via go/ees005
55
+ // eslint-disable-next-line require-unicode-regexp
56
+ const OPEN_DOUBLE_QUOTE_REGEX = /((?:^|[\s\{\[\(\<'"\u2018\u201C]))(")$/;
57
+ // Ignored via go/ees005
58
+ // eslint-disable-next-line require-unicode-regexp
59
+ const CLOSE_DOUBLE_QUOTE_REGEX = /"$/;
60
+
7
61
  /**
8
62
  * Creates an InputRuleHandler that will match on a regular expression of the
9
63
  * form `(prefix, content, suffix?)`, and replace it with some given text,
@@ -58,8 +112,7 @@ function createReplacementRules(replMap, replacementRuleWithAnalytics) {
58
112
  function createSingleQuotesRules() {
59
113
  return [
60
114
  // wrapped text
61
- // eslint-disable-next-line require-unicode-regexp
62
- createRule(/(\s|^)'(\S+.*\S+)'$/, (state, match, start, end) => {
115
+ createRule(WRAPPED_SINGLE_QUOTE_REGEX, (state, match, start, end) => {
63
116
  const OPEN_SMART_QUOTE_CHAR = '‘';
64
117
  const CLOSED_SMART_QUOTE_CHAR = '’';
65
118
  const [, spacing, innerContent] = match;
@@ -73,9 +126,7 @@ function createSingleQuotesRules() {
73
126
  return state.tr.insertText(CLOSED_SMART_QUOTE_CHAR, positionOfClosedQuote, end).insertText(openQuoteReplacement, start, start + openQuoteReplacement.length);
74
127
  }),
75
128
  // apostrophe
76
- // Ignored via go/ees005
77
- // eslint-disable-next-line require-unicode-regexp
78
- createReplacementRule('’', /(\w+)(')(\w+)$/)];
129
+ createReplacementRule('’', APOSTROPHE_REGEX)];
79
130
  }
80
131
 
81
132
  /**
@@ -93,21 +144,11 @@ function getProductRules(editorAnalyticsAPI) {
93
144
  }
94
145
  }), editorAnalyticsAPI);
95
146
  return createReplacementRules({
96
- // Ignored via go/ees005
97
- // eslint-disable-next-line require-unicode-regexp
98
- Atlassian: /(\s+|^)(atlassian)(\s)$/,
99
- // Ignored via go/ees005
100
- // eslint-disable-next-line require-unicode-regexp
101
- Jira: /(\s+|^)(jira|JIRA)(\s)$/,
102
- // Ignored via go/ees005
103
- // eslint-disable-next-line require-unicode-regexp
104
- Bitbucket: /(\s+|^)(bitbucket|BitBucket)(\s)$/,
105
- // Ignored via go/ees005
106
- // eslint-disable-next-line require-unicode-regexp
107
- Hipchat: /(\s+|^)(hipchat|HipChat)(\s)$/,
108
- // Ignored via go/ees005
109
- // eslint-disable-next-line require-unicode-regexp
110
- Trello: /(\s+|^)(trello)(\s)$/
147
+ Atlassian: ATLASSIAN_REGEX,
148
+ Jira: JIRA_REGEX,
149
+ Bitbucket: BITBUCKET_REGEX,
150
+ Hipchat: HIPCHAT_REGEX,
151
+ Trello: TRELLO_REGEX
111
152
  }, productRuleWithAnalytics);
112
153
  }
113
154
 
@@ -130,15 +171,9 @@ function getSymbolRules(editorAnalyticsAPI) {
130
171
  }
131
172
  }, editorAnalyticsAPI);
132
173
  return createReplacementRules({
133
- // Ignored via go/ees005
134
- // eslint-disable-next-line require-unicode-regexp
135
- '→': /(\s+|^)(--?>)(\s)$/,
136
- // Ignored via go/ees005
137
- // eslint-disable-next-line require-unicode-regexp
138
- '←': /(\s+|^)(<--?)(\s)$/,
139
- // Ignored via go/ees005
140
- // eslint-disable-next-line require-unicode-regexp
141
- '↔︎': /(\s+|^)(<->?)(\s)$/
174
+ '→': ARROW_RIGHT_REGEX,
175
+ '←': ARROW_LEFT_REGEX,
176
+ '↔︎': ARROW_DOUBLE_REGEX
142
177
  }, symbolRuleWithAnalytics);
143
178
  }
144
179
 
@@ -162,20 +197,12 @@ function getPunctuationRules(editorAnalyticsAPI) {
162
197
  }
163
198
  }, editorAnalyticsAPI);
164
199
  const dashEllipsisRules = createReplacementRules({
165
- // Ignored via go/ees005
166
- // eslint-disable-next-line require-unicode-regexp
167
- '–': /(\s+|^)(--)(\s)$/,
168
- // Ignored via go/ees005
169
- // eslint-disable-next-line require-unicode-regexp
170
- '…': /()(\.\.\.)$/
200
+ '–': DASH_REGEX,
201
+ '…': ELLIPSIS_REGEX
171
202
  }, punctuationRuleWithAnalytics);
172
203
  const doubleQuoteRules = createReplacementRules({
173
- // Ignored via go/ees005
174
- // eslint-disable-next-line require-unicode-regexp
175
- '“': /((?:^|[\s\{\[\(\<'"\u2018\u201C]))(")$/,
176
- // Ignored via go/ees005
177
- // eslint-disable-next-line require-unicode-regexp
178
- '”': /"$/
204
+ '“': OPEN_DOUBLE_QUOTE_REGEX,
205
+ '”': CLOSE_DOUBLE_QUOTE_REGEX
179
206
  }, punctuationRuleWithAnalytics);
180
207
  const singleQuoteRules = createSingleQuotesRules();
181
208
  return [...dashEllipsisRules, ...doubleQuoteRules, ...singleQuoteRules.map(rule => punctuationRuleWithAnalytics(PUNC.QUOTE_SINGLE)(rule))];
@@ -1,13 +1,15 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
+ // Don't apply in Edge as per ED-4546
4
+ // Ignored via go/ees005
5
+ // eslint-disable-next-line require-unicode-regexp
6
+ var EDGE_USER_AGENT_REGEX = /Edge\/\d/;
3
7
  // eslint-disable-next-line import/no-anonymous-default-export
4
8
  var _default_1 = new SafePlugin({
5
9
  props: {
6
10
  handleClick: function handleClick(view, clickPos, event) {
7
11
  // Don't apply in Edge as per ED-4546
8
- // Ignored via go/ees005
9
- // eslint-disable-next-line require-unicode-regexp
10
- if (navigator && /Edge\/\d/.test(navigator.userAgent)) {
12
+ if (navigator && EDGE_USER_AGENT_REGEX.test(navigator.userAgent)) {
11
13
  return false;
12
14
  }
13
15
 
@@ -7,6 +7,60 @@ import { createRule, inputRuleWithAnalytics } from '@atlaskit/editor-common/util
7
7
  import { Selection } from '@atlaskit/editor-prosemirror/state';
8
8
  import { createPlugin } from '@atlaskit/prosemirror-input-rules';
9
9
 
10
+ // We don't agressively upgrade single quotes to smart quotes because
11
+ // they may clash with an emoji. Only do that when we have a matching
12
+ // single quote, or a contraction.
13
+ // wrapped text
14
+ // Ignored via go/ees005
15
+ // eslint-disable-next-line require-unicode-regexp
16
+ var WRAPPED_SINGLE_QUOTE_REGEX = /(\s|^)'(\S+.*\S+)'$/;
17
+ // apostrophe
18
+ // Ignored via go/ees005
19
+ // eslint-disable-next-line require-unicode-regexp
20
+ var APOSTROPHE_REGEX = /(\w+)(')(\w+)$/;
21
+
22
+ // Product rules
23
+ // Ignored via go/ees005
24
+ // eslint-disable-next-line require-unicode-regexp
25
+ var ATLASSIAN_REGEX = /(\s+|^)(atlassian)(\s)$/;
26
+ // Ignored via go/ees005
27
+ // eslint-disable-next-line require-unicode-regexp
28
+ var JIRA_REGEX = /(\s+|^)(jira|JIRA)(\s)$/;
29
+ // Ignored via go/ees005
30
+ // eslint-disable-next-line require-unicode-regexp
31
+ var BITBUCKET_REGEX = /(\s+|^)(bitbucket|BitBucket)(\s)$/;
32
+ // Ignored via go/ees005
33
+ // eslint-disable-next-line require-unicode-regexp
34
+ var HIPCHAT_REGEX = /(\s+|^)(hipchat|HipChat)(\s)$/;
35
+ // Ignored via go/ees005
36
+ // eslint-disable-next-line require-unicode-regexp
37
+ var TRELLO_REGEX = /(\s+|^)(trello)(\s)$/;
38
+
39
+ // Symbol rules
40
+ // Ignored via go/ees005
41
+ // eslint-disable-next-line require-unicode-regexp
42
+ var ARROW_RIGHT_REGEX = /(\s+|^)(--?>)(\s)$/;
43
+ // Ignored via go/ees005
44
+ // eslint-disable-next-line require-unicode-regexp
45
+ var ARROW_LEFT_REGEX = /(\s+|^)(<--?)(\s)$/;
46
+ // Ignored via go/ees005
47
+ // eslint-disable-next-line require-unicode-regexp
48
+ var ARROW_DOUBLE_REGEX = /(\s+|^)(<->?)(\s)$/;
49
+
50
+ // Punctuation rules
51
+ // Ignored via go/ees005
52
+ // eslint-disable-next-line require-unicode-regexp
53
+ var DASH_REGEX = /(\s+|^)(--)(\s)$/;
54
+ // Ignored via go/ees005
55
+ // eslint-disable-next-line require-unicode-regexp
56
+ var ELLIPSIS_REGEX = /()(\.\.\.)$/;
57
+ // Ignored via go/ees005
58
+ // eslint-disable-next-line require-unicode-regexp
59
+ var OPEN_DOUBLE_QUOTE_REGEX = /((?:^|[\s\{\[\(\<'"\u2018\u201C]))(")$/;
60
+ // Ignored via go/ees005
61
+ // eslint-disable-next-line require-unicode-regexp
62
+ var CLOSE_DOUBLE_QUOTE_REGEX = /"$/;
63
+
10
64
  /**
11
65
  * Creates an InputRuleHandler that will match on a regular expression of the
12
66
  * form `(prefix, content, suffix?)`, and replace it with some given text,
@@ -59,8 +113,7 @@ function createReplacementRules(replMap, replacementRuleWithAnalytics) {
59
113
  function createSingleQuotesRules() {
60
114
  return [
61
115
  // wrapped text
62
- // eslint-disable-next-line require-unicode-regexp
63
- createRule(/(\s|^)'(\S+.*\S+)'$/, function (state, match, start, end) {
116
+ createRule(WRAPPED_SINGLE_QUOTE_REGEX, function (state, match, start, end) {
64
117
  var OPEN_SMART_QUOTE_CHAR = '‘';
65
118
  var CLOSED_SMART_QUOTE_CHAR = '’';
66
119
  var _match2 = _slicedToArray(match, 3),
@@ -76,9 +129,7 @@ function createSingleQuotesRules() {
76
129
  return state.tr.insertText(CLOSED_SMART_QUOTE_CHAR, positionOfClosedQuote, end).insertText(openQuoteReplacement, start, start + openQuoteReplacement.length);
77
130
  }),
78
131
  // apostrophe
79
- // Ignored via go/ees005
80
- // eslint-disable-next-line require-unicode-regexp
81
- createReplacementRule('’', /(\w+)(')(\w+)$/)];
132
+ createReplacementRule('’', APOSTROPHE_REGEX)];
82
133
  }
83
134
 
84
135
  /**
@@ -100,21 +151,11 @@ function getProductRules(editorAnalyticsAPI) {
100
151
  }, editorAnalyticsAPI);
101
152
  };
102
153
  return createReplacementRules({
103
- // Ignored via go/ees005
104
- // eslint-disable-next-line require-unicode-regexp
105
- Atlassian: /(\s+|^)(atlassian)(\s)$/,
106
- // Ignored via go/ees005
107
- // eslint-disable-next-line require-unicode-regexp
108
- Jira: /(\s+|^)(jira|JIRA)(\s)$/,
109
- // Ignored via go/ees005
110
- // eslint-disable-next-line require-unicode-regexp
111
- Bitbucket: /(\s+|^)(bitbucket|BitBucket)(\s)$/,
112
- // Ignored via go/ees005
113
- // eslint-disable-next-line require-unicode-regexp
114
- Hipchat: /(\s+|^)(hipchat|HipChat)(\s)$/,
115
- // Ignored via go/ees005
116
- // eslint-disable-next-line require-unicode-regexp
117
- Trello: /(\s+|^)(trello)(\s)$/
154
+ Atlassian: ATLASSIAN_REGEX,
155
+ Jira: JIRA_REGEX,
156
+ Bitbucket: BITBUCKET_REGEX,
157
+ Hipchat: HIPCHAT_REGEX,
158
+ Trello: TRELLO_REGEX
118
159
  }, productRuleWithAnalytics);
119
160
  }
120
161
 
@@ -139,15 +180,9 @@ function getSymbolRules(editorAnalyticsAPI) {
139
180
  }, editorAnalyticsAPI);
140
181
  };
141
182
  return createReplacementRules({
142
- // Ignored via go/ees005
143
- // eslint-disable-next-line require-unicode-regexp
144
- '→': /(\s+|^)(--?>)(\s)$/,
145
- // Ignored via go/ees005
146
- // eslint-disable-next-line require-unicode-regexp
147
- '←': /(\s+|^)(<--?)(\s)$/,
148
- // Ignored via go/ees005
149
- // eslint-disable-next-line require-unicode-regexp
150
- '↔︎': /(\s+|^)(<->?)(\s)$/
183
+ '→': ARROW_RIGHT_REGEX,
184
+ '←': ARROW_LEFT_REGEX,
185
+ '↔︎': ARROW_DOUBLE_REGEX
151
186
  }, symbolRuleWithAnalytics);
152
187
  }
153
188
 
@@ -172,20 +207,12 @@ function getPunctuationRules(editorAnalyticsAPI) {
172
207
  }, editorAnalyticsAPI);
173
208
  };
174
209
  var dashEllipsisRules = createReplacementRules({
175
- // Ignored via go/ees005
176
- // eslint-disable-next-line require-unicode-regexp
177
- '–': /(\s+|^)(--)(\s)$/,
178
- // Ignored via go/ees005
179
- // eslint-disable-next-line require-unicode-regexp
180
- '…': /()(\.\.\.)$/
210
+ '–': DASH_REGEX,
211
+ '…': ELLIPSIS_REGEX
181
212
  }, punctuationRuleWithAnalytics);
182
213
  var doubleQuoteRules = createReplacementRules({
183
- // Ignored via go/ees005
184
- // eslint-disable-next-line require-unicode-regexp
185
- '“': /((?:^|[\s\{\[\(\<'"\u2018\u201C]))(")$/,
186
- // Ignored via go/ees005
187
- // eslint-disable-next-line require-unicode-regexp
188
- '”': /"$/
214
+ '“': OPEN_DOUBLE_QUOTE_REGEX,
215
+ '”': CLOSE_DOUBLE_QUOTE_REGEX
189
216
  }, punctuationRuleWithAnalytics);
190
217
  var singleQuoteRules = createSingleQuotesRules();
191
218
  return [].concat(_toConsumableArray(dashEllipsisRules), _toConsumableArray(doubleQuoteRules), _toConsumableArray(singleQuoteRules.map(function (rule) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-text-formatting",
3
- "version": "12.0.2",
3
+ "version": "12.0.3",
4
4
  "description": "Text-formatting plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -24,7 +24,7 @@
24
24
  ],
25
25
  "atlaskit:src": "src/index.ts",
26
26
  "dependencies": {
27
- "@atlaskit/adf-schema": "^55.0.0",
27
+ "@atlaskit/adf-schema": "^55.2.0",
28
28
  "@atlaskit/editor-plugin-analytics": "^12.0.0",
29
29
  "@atlaskit/editor-plugin-base": "^13.0.0",
30
30
  "@atlaskit/editor-plugin-primary-toolbar": "^13.0.0",
@@ -38,13 +38,13 @@
38
38
  "@atlaskit/icon": "^36.0.0",
39
39
  "@atlaskit/platform-feature-flags": "^2.0.0",
40
40
  "@atlaskit/prosemirror-input-rules": "^4.0.0",
41
- "@atlaskit/tmp-editor-statsig": "^106.0.0",
41
+ "@atlaskit/tmp-editor-statsig": "^107.1.0",
42
42
  "@atlaskit/tokens": "^14.0.0",
43
43
  "@babel/runtime": "^7.0.0",
44
44
  "@emotion/react": "^11.7.1"
45
45
  },
46
46
  "peerDependencies": {
47
- "@atlaskit/editor-common": "^116.2.0",
47
+ "@atlaskit/editor-common": "^116.3.0",
48
48
  "react": "^18.2.0",
49
49
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
50
50
  },