@atlaskit/prosemirror-input-rules 3.6.2 → 3.6.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/prosemirror-input-rules
2
2
 
3
+ ## 3.6.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4f8a0e29aeb69`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4f8a0e29aeb69) -
8
+ [ux] [EDITOR-2762] fix whitespace issue with backwards matching for inline code behind
9
+ platform_editor_lovability_inline_code
10
+
3
11
  ## 3.6.2
4
12
 
5
13
  ### Patch Changes
@@ -101,9 +101,21 @@ function findMatchOnRules(_ref3) {
101
101
  // (which may be a typeahead trigger) and ignore the rest.
102
102
  var matchString = (0, _editorCommon.isGapCursorSelection)(state.selection) ? (_textToMatch$at = textToMatch.at(-1)) !== null && _textToMatch$at !== void 0 ? _textToMatch$at : '' : textToMatch;
103
103
 
104
- // EDITOR-2460
105
104
  // if the user is formatting text to inline code from R to L i.e. backwards
106
105
  if (rule.allowsBackwardMatch && isBackwardMatch && (0, _expValEquals.expValEquals)('platform_editor_lovability_inline_code', 'isEnabled', true)) {
106
+ // if the match has a parenthesis before it, but no whitespace or empty space before that, exit
107
+ var charBefore = state.doc.textBetween(from - 1, from);
108
+ if (charBefore === '(') {
109
+ var charBeforeParenthesis = state.doc.textBetween(from - 2, from - 1);
110
+ if (charBeforeParenthesis !== ' ' && charBeforeParenthesis !== '') {
111
+ continue;
112
+ }
113
+ }
114
+
115
+ // else if the match has no whitespace or empty space before it, exit
116
+ else if (charBefore !== ' ' && charBefore !== '') {
117
+ continue;
118
+ }
107
119
  var _match = rule.match.exec(matchString);
108
120
  if (!_match) {
109
121
  continue;
@@ -92,9 +92,21 @@ function findMatchOnRules({
92
92
  // (which may be a typeahead trigger) and ignore the rest.
93
93
  const matchString = isGapCursorSelection(state.selection) ? (_textToMatch$at = textToMatch.at(-1)) !== null && _textToMatch$at !== void 0 ? _textToMatch$at : '' : textToMatch;
94
94
 
95
- // EDITOR-2460
96
95
  // if the user is formatting text to inline code from R to L i.e. backwards
97
96
  if (rule.allowsBackwardMatch && isBackwardMatch && expValEquals('platform_editor_lovability_inline_code', 'isEnabled', true)) {
97
+ // if the match has a parenthesis before it, but no whitespace or empty space before that, exit
98
+ const charBefore = state.doc.textBetween(from - 1, from);
99
+ if (charBefore === '(') {
100
+ const charBeforeParenthesis = state.doc.textBetween(from - 2, from - 1);
101
+ if (charBeforeParenthesis !== ' ' && charBeforeParenthesis !== '') {
102
+ continue;
103
+ }
104
+ }
105
+
106
+ // else if the match has no whitespace or empty space before it, exit
107
+ else if (charBefore !== ' ' && charBefore !== '') {
108
+ continue;
109
+ }
98
110
  const match = rule.match.exec(matchString);
99
111
  if (!match) {
100
112
  continue;
@@ -94,9 +94,21 @@ function findMatchOnRules(_ref3) {
94
94
  // (which may be a typeahead trigger) and ignore the rest.
95
95
  var matchString = isGapCursorSelection(state.selection) ? (_textToMatch$at = textToMatch.at(-1)) !== null && _textToMatch$at !== void 0 ? _textToMatch$at : '' : textToMatch;
96
96
 
97
- // EDITOR-2460
98
97
  // if the user is formatting text to inline code from R to L i.e. backwards
99
98
  if (rule.allowsBackwardMatch && isBackwardMatch && expValEquals('platform_editor_lovability_inline_code', 'isEnabled', true)) {
99
+ // if the match has a parenthesis before it, but no whitespace or empty space before that, exit
100
+ var charBefore = state.doc.textBetween(from - 1, from);
101
+ if (charBefore === '(') {
102
+ var charBeforeParenthesis = state.doc.textBetween(from - 2, from - 1);
103
+ if (charBeforeParenthesis !== ' ' && charBeforeParenthesis !== '') {
104
+ continue;
105
+ }
106
+ }
107
+
108
+ // else if the match has no whitespace or empty space before it, exit
109
+ else if (charBefore !== ' ' && charBefore !== '') {
110
+ continue;
111
+ }
100
112
  var _match = rule.match.exec(matchString);
101
113
  if (!_match) {
102
114
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-input-rules",
3
- "version": "3.6.2",
3
+ "version": "3.6.3",
4
4
  "description": "A package that contains helpers to create autoformatting rules for ProseMirror",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,11 +29,11 @@
29
29
  "dependencies": {
30
30
  "@atlaskit/editor-prosemirror": "7.0.0",
31
31
  "@atlaskit/prosemirror-history": "^0.2.0",
32
- "@atlaskit/tmp-editor-statsig": "^13.42.0",
32
+ "@atlaskit/tmp-editor-statsig": "^13.44.0",
33
33
  "@babel/runtime": "^7.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@atlaskit/editor-common": "^110.34.0"
36
+ "@atlaskit/editor-common": "^110.35.0"
37
37
  },
38
38
  "techstack": {
39
39
  "@atlassian/frontend": {