@atlaskit/prosemirror-input-rules 3.6.1 → 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,21 @@
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
+
11
+ ## 3.6.2
12
+
13
+ ### Patch Changes
14
+
15
+ - [`4d676bbdb3ce6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4d676bbdb3ce6) -
16
+ ts-ignore added temporarily to unblock local consumption for help-center, will be removed once
17
+ project refs are setup
18
+
3
19
  ## 3.6.1
4
20
 
5
21
  ### 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;
@@ -27,6 +27,7 @@ function createInputRulePlugin(pluginName, rules) {
27
27
  init: function init() {
28
28
  return null;
29
29
  },
30
+ // @ts-ignore - Workaround for help-center local consumption
30
31
  apply: function apply(tr, prev) {
31
32
  var stored = tr.getMeta(pluginKey);
32
33
  if (stored) {
@@ -35,7 +36,9 @@ function createInputRulePlugin(pluginName, rules) {
35
36
  return tr.selectionSet || tr.docChanged ? null : prev;
36
37
  }
37
38
  },
39
+ // @ts-ignore - Workaround for help-center local consumption
38
40
  appendTransaction: function appendTransaction(transactions, oldState, newState) {
41
+ // @ts-ignore - Workaround for help-center local consumption
39
42
  var transactionWithInputRuleMeta = transactions.find(function (tr) {
40
43
  return tr.getMeta(pluginKey);
41
44
  });
@@ -67,6 +70,7 @@ function createInputRulePlugin(pluginName, rules) {
67
70
  return tr;
68
71
  },
69
72
  props: {
73
+ // @ts-ignore - Workaround for help-center local consumption
70
74
  handleTextInput: function handleTextInput(view, from, to, text) {
71
75
  return inputEvent({
72
76
  view: view,
@@ -76,6 +80,7 @@ function createInputRulePlugin(pluginName, rules) {
76
80
  });
77
81
  },
78
82
  handleDOMEvents: {
83
+ // @ts-ignore - Workaround for help-center local consumption
79
84
  blur: function blur(view) {
80
85
  if (!(options !== null && options !== void 0 && options.checkOnBlur)) {
81
86
  return false;
@@ -96,6 +101,7 @@ function createInputRulePlugin(pluginName, rules) {
96
101
  }
97
102
  return false;
98
103
  },
104
+ // @ts-ignore - Workaround for help-center local consumption
99
105
  compositionend: function compositionend(view) {
100
106
  setTimeout(function () {
101
107
  var selection = view.state.selection;
@@ -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;
@@ -20,6 +20,7 @@ export function createInputRulePlugin(pluginName, rules, options = {}) {
20
20
  init() {
21
21
  return null;
22
22
  },
23
+ // @ts-ignore - Workaround for help-center local consumption
23
24
  apply(tr, prev) {
24
25
  const stored = tr.getMeta(pluginKey);
25
26
  if (stored) {
@@ -28,7 +29,9 @@ export function createInputRulePlugin(pluginName, rules, options = {}) {
28
29
  return tr.selectionSet || tr.docChanged ? null : prev;
29
30
  }
30
31
  },
32
+ // @ts-ignore - Workaround for help-center local consumption
31
33
  appendTransaction: (transactions, oldState, newState) => {
34
+ // @ts-ignore - Workaround for help-center local consumption
32
35
  const transactionWithInputRuleMeta = transactions.find(tr => tr.getMeta(pluginKey));
33
36
  const pluginState = transactionWithInputRuleMeta === null || transactionWithInputRuleMeta === void 0 ? void 0 : transactionWithInputRuleMeta.getMeta(pluginKey);
34
37
  if (!pluginState || !transactionWithInputRuleMeta) {
@@ -62,6 +65,7 @@ export function createInputRulePlugin(pluginName, rules, options = {}) {
62
65
  return tr;
63
66
  },
64
67
  props: {
68
+ // @ts-ignore - Workaround for help-center local consumption
65
69
  handleTextInput(view, from, to, text) {
66
70
  return inputEvent({
67
71
  view,
@@ -71,6 +75,7 @@ export function createInputRulePlugin(pluginName, rules, options = {}) {
71
75
  });
72
76
  },
73
77
  handleDOMEvents: {
78
+ // @ts-ignore - Workaround for help-center local consumption
74
79
  blur: view => {
75
80
  if (!(options !== null && options !== void 0 && options.checkOnBlur)) {
76
81
  return false;
@@ -93,6 +98,7 @@ export function createInputRulePlugin(pluginName, rules, options = {}) {
93
98
  }
94
99
  return false;
95
100
  },
101
+ // @ts-ignore - Workaround for help-center local consumption
96
102
  compositionend: view => {
97
103
  setTimeout(() => {
98
104
  const selection = view.state.selection;
@@ -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;
@@ -21,6 +21,7 @@ export function createInputRulePlugin(pluginName, rules) {
21
21
  init: function init() {
22
22
  return null;
23
23
  },
24
+ // @ts-ignore - Workaround for help-center local consumption
24
25
  apply: function apply(tr, prev) {
25
26
  var stored = tr.getMeta(pluginKey);
26
27
  if (stored) {
@@ -29,7 +30,9 @@ export function createInputRulePlugin(pluginName, rules) {
29
30
  return tr.selectionSet || tr.docChanged ? null : prev;
30
31
  }
31
32
  },
33
+ // @ts-ignore - Workaround for help-center local consumption
32
34
  appendTransaction: function appendTransaction(transactions, oldState, newState) {
35
+ // @ts-ignore - Workaround for help-center local consumption
33
36
  var transactionWithInputRuleMeta = transactions.find(function (tr) {
34
37
  return tr.getMeta(pluginKey);
35
38
  });
@@ -61,6 +64,7 @@ export function createInputRulePlugin(pluginName, rules) {
61
64
  return tr;
62
65
  },
63
66
  props: {
67
+ // @ts-ignore - Workaround for help-center local consumption
64
68
  handleTextInput: function handleTextInput(view, from, to, text) {
65
69
  return inputEvent({
66
70
  view: view,
@@ -70,6 +74,7 @@ export function createInputRulePlugin(pluginName, rules) {
70
74
  });
71
75
  },
72
76
  handleDOMEvents: {
77
+ // @ts-ignore - Workaround for help-center local consumption
73
78
  blur: function blur(view) {
74
79
  if (!(options !== null && options !== void 0 && options.checkOnBlur)) {
75
80
  return false;
@@ -90,6 +95,7 @@ export function createInputRulePlugin(pluginName, rules) {
90
95
  }
91
96
  return false;
92
97
  },
98
+ // @ts-ignore - Workaround for help-center local consumption
93
99
  compositionend: function compositionend(view) {
94
100
  setTimeout(function () {
95
101
  var selection = view.state.selection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-input-rules",
3
- "version": "3.6.1",
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.37.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.27.0"
36
+ "@atlaskit/editor-common": "^110.35.0"
37
37
  },
38
38
  "techstack": {
39
39
  "@atlassian/frontend": {