@atlaskit/editor-plugin-text-formatting 30.2.9 → 31.0.1
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,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-formatting
|
|
2
2
|
|
|
3
|
+
## 31.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 31.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- [`656ef3137dfaa`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/656ef3137dfaa) -
|
|
14
|
+
[FFCLEANUP-144040] clean up the `platform_editor_lovability_inline_code` experiment – this change
|
|
15
|
+
removes the `codeRegexWithBackwardMatch` export, and uses `codeRegex` instead which supports
|
|
16
|
+
backwards matching for inline code autoformatting.
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 30.2.9
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/compass.yml
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = exports.
|
|
7
|
+
exports.default = exports.codeRegex = exports.ValidCombinations = void 0;
|
|
8
8
|
exports.inputRulePlugin = inputRulePlugin;
|
|
9
9
|
exports.strongRegex2 = exports.strongRegex1 = exports.strikeRegex = exports.italicRegex2 = exports.italicRegex1 = void 0;
|
|
10
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
@@ -22,7 +22,6 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
22
22
|
var _inputRules = require("@atlaskit/editor-common/utils/input-rules");
|
|
23
23
|
var _constants = require("@atlaskit/prosemirror-input-rules/constants");
|
|
24
24
|
var _utils2 = require("@atlaskit/prosemirror-input-rules/utils");
|
|
25
|
-
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
26
25
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
27
26
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
28
27
|
function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
|
|
@@ -73,9 +72,6 @@ function addMark(markType, _schema, char, api) {
|
|
|
73
72
|
// fixes the following case: my `*name` is *
|
|
74
73
|
// expected result: should ignore special characters inside "code"
|
|
75
74
|
if (textPrefix !== char || schema !== null && schema !== void 0 && (_schema$marks = schema.marks) !== null && _schema$marks !== void 0 && (_schema$marks = _schema$marks.code) !== null && _schema$marks !== void 0 && _schema$marks.isInSet(doc.resolve(start + 1).marks())) {
|
|
76
|
-
if (!(0, _expValEquals.expValEquals)('platform_editor_lovability_inline_code', 'isEnabled', true)) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
75
|
// if the prefix is not a character but the suffix is, continue
|
|
80
76
|
var suffix = state.doc.textBetween(end - char.length, end);
|
|
81
77
|
if (suffix !== char) {
|
|
@@ -153,28 +149,6 @@ var ReverseRegexExp = /*#__PURE__*/function (_RegExp) {
|
|
|
153
149
|
}]);
|
|
154
150
|
}( /*#__PURE__*/(0, _wrapNativeSuper2.default)(RegExp));
|
|
155
151
|
var buildRegex = function buildRegex(char) {
|
|
156
|
-
// Ignored via go/ees005
|
|
157
|
-
// eslint-disable-next-line require-unicode-regexp
|
|
158
|
-
var escapedChar = char.replace(/(\W)/g, '\\$1');
|
|
159
|
-
// Ignored via go/ees005
|
|
160
|
-
// eslint-disable-next-line require-unicode-regexp, @atlassian/perf-linting/no-expensive-split-replace -- Ignored via go/ees017 (to be fixed)
|
|
161
|
-
var combinations = ValidCombinations[char].map(function (c) {
|
|
162
|
-
return c.replace(/(\W)/g, '\\$1');
|
|
163
|
-
}).join('|');
|
|
164
|
-
|
|
165
|
-
// Single X - https://regex101.com/r/McT3yq/14/
|
|
166
|
-
// Double X - https://regex101.com/r/pQUgjx/1/
|
|
167
|
-
var baseRegex = '^X(?=[^X\\s]).*?[^\\sX]X(?=[\\sOBJECT_REPLACEMENT_CHARACTER]COMBINATIONS|$)'.replace('OBJECT_REPLACEMENT_CHARACTER', _constants.leafNodeReplacementCharacter).replace('COMBINATIONS', combinations ? "|".concat(combinations) : '');
|
|
168
|
-
var replacedRegex = String.prototype.hasOwnProperty('replaceAll') ?
|
|
169
|
-
// Ignored via go/ees005
|
|
170
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
171
|
-
baseRegex.replaceAll('X', escapedChar) :
|
|
172
|
-
// Ignored via go/ees005
|
|
173
|
-
// eslint-disable-next-line require-unicode-regexp
|
|
174
|
-
baseRegex.replace(/X/g, escapedChar);
|
|
175
|
-
return new ReverseRegexExp(replacedRegex);
|
|
176
|
-
};
|
|
177
|
-
var buildRegexNew = function buildRegexNew(char) {
|
|
178
152
|
var allowsBackwardMatch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
179
153
|
// Ignored via go/ees005
|
|
180
154
|
// eslint-disable-next-line require-unicode-regexp
|
|
@@ -205,8 +179,7 @@ var strongRegex2 = exports.strongRegex2 = buildRegex(ValidAutoformatChars.STRONG
|
|
|
205
179
|
var italicRegex1 = exports.italicRegex1 = buildRegex(ValidAutoformatChars.ITALIC);
|
|
206
180
|
var italicRegex2 = exports.italicRegex2 = buildRegex(ValidAutoformatChars.ITALIC_MARKDOWN);
|
|
207
181
|
var strikeRegex = exports.strikeRegex = buildRegex(ValidAutoformatChars.STRIKE);
|
|
208
|
-
var codeRegex = exports.codeRegex = buildRegex(ValidAutoformatChars.CODE);
|
|
209
|
-
var codeRegexWithBackwardMatch = exports.codeRegexWithBackwardMatch = buildRegexNew(ValidAutoformatChars.CODE, true);
|
|
182
|
+
var codeRegex = exports.codeRegex = buildRegex(ValidAutoformatChars.CODE, true);
|
|
210
183
|
|
|
211
184
|
/**
|
|
212
185
|
* Create input rules for strong mark
|
|
@@ -287,8 +260,7 @@ function getCodeInputRules(schema, editorAnalyticsAPI, api) {
|
|
|
287
260
|
inputMethod: _enums.INPUT_METHOD.FORMATTING
|
|
288
261
|
}
|
|
289
262
|
}, editorAnalyticsAPI);
|
|
290
|
-
var
|
|
291
|
-
var backTickRule = (0, _utils.createRule)(allowsBackwardMatch ? codeRegexWithBackwardMatch : codeRegex, addMark(schema.marks.code, schema, ValidAutoformatChars.CODE, api), allowsBackwardMatch);
|
|
263
|
+
var backTickRule = (0, _utils.createRule)(codeRegex, addMark(schema.marks.code, schema, ValidAutoformatChars.CODE, api), true);
|
|
292
264
|
return [ruleWithCodeAnalytics(backTickRule)];
|
|
293
265
|
}
|
|
294
266
|
function inputRulePlugin(schema, editorAnalyticsAPI, api) {
|
|
@@ -4,7 +4,6 @@ import { createRule } from '@atlaskit/editor-common/utils';
|
|
|
4
4
|
import { inputRuleWithAnalytics } from '@atlaskit/editor-common/utils/input-rules';
|
|
5
5
|
import { leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules/constants';
|
|
6
6
|
import { createPlugin } from '@atlaskit/prosemirror-input-rules/utils';
|
|
7
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
7
|
var ValidAutoformatChars = /*#__PURE__*/function (ValidAutoformatChars) {
|
|
9
8
|
ValidAutoformatChars["STRONG"] = "__";
|
|
10
9
|
ValidAutoformatChars["STRIKE"] = "~~";
|
|
@@ -61,9 +60,6 @@ function addMark(markType, _schema, char, api) {
|
|
|
61
60
|
// fixes the following case: my `*name` is *
|
|
62
61
|
// expected result: should ignore special characters inside "code"
|
|
63
62
|
if (textPrefix !== char || schema !== null && schema !== void 0 && (_schema$marks = schema.marks) !== null && _schema$marks !== void 0 && (_schema$marks$code = _schema$marks.code) !== null && _schema$marks$code !== void 0 && _schema$marks$code.isInSet(doc.resolve(start + 1).marks())) {
|
|
64
|
-
if (!expValEquals('platform_editor_lovability_inline_code', 'isEnabled', true)) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
63
|
// if the prefix is not a character but the suffix is, continue
|
|
68
64
|
const suffix = state.doc.textBetween(end - char.length, end);
|
|
69
65
|
if (suffix !== char) {
|
|
@@ -132,27 +128,7 @@ class ReverseRegexExp extends RegExp {
|
|
|
132
128
|
return result;
|
|
133
129
|
}
|
|
134
130
|
}
|
|
135
|
-
const buildRegex = char => {
|
|
136
|
-
// Ignored via go/ees005
|
|
137
|
-
// eslint-disable-next-line require-unicode-regexp
|
|
138
|
-
const escapedChar = char.replace(/(\W)/g, '\\$1');
|
|
139
|
-
// Ignored via go/ees005
|
|
140
|
-
// eslint-disable-next-line require-unicode-regexp, @atlassian/perf-linting/no-expensive-split-replace -- Ignored via go/ees017 (to be fixed)
|
|
141
|
-
const combinations = ValidCombinations[char].map(c => c.replace(/(\W)/g, '\\$1')).join('|');
|
|
142
|
-
|
|
143
|
-
// Single X - https://regex101.com/r/McT3yq/14/
|
|
144
|
-
// Double X - https://regex101.com/r/pQUgjx/1/
|
|
145
|
-
const baseRegex = '^X(?=[^X\\s]).*?[^\\sX]X(?=[\\sOBJECT_REPLACEMENT_CHARACTER]COMBINATIONS|$)'.replace('OBJECT_REPLACEMENT_CHARACTER', leafNodeReplacementCharacter).replace('COMBINATIONS', combinations ? `|${combinations}` : '');
|
|
146
|
-
const replacedRegex = String.prototype.hasOwnProperty('replaceAll') ?
|
|
147
|
-
// Ignored via go/ees005
|
|
148
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
149
|
-
baseRegex.replaceAll('X', escapedChar) :
|
|
150
|
-
// Ignored via go/ees005
|
|
151
|
-
// eslint-disable-next-line require-unicode-regexp
|
|
152
|
-
baseRegex.replace(/X/g, escapedChar);
|
|
153
|
-
return new ReverseRegexExp(replacedRegex);
|
|
154
|
-
};
|
|
155
|
-
const buildRegexNew = (char, allowsBackwardMatch = false) => {
|
|
131
|
+
const buildRegex = (char, allowsBackwardMatch = false) => {
|
|
156
132
|
// Ignored via go/ees005
|
|
157
133
|
// eslint-disable-next-line require-unicode-regexp
|
|
158
134
|
const escapedChar = char.replace(/(\W)/g, '\\$1');
|
|
@@ -180,8 +156,7 @@ export const strongRegex2 = buildRegex(ValidAutoformatChars.STRONG_MARKDOWN);
|
|
|
180
156
|
export const italicRegex1 = buildRegex(ValidAutoformatChars.ITALIC);
|
|
181
157
|
export const italicRegex2 = buildRegex(ValidAutoformatChars.ITALIC_MARKDOWN);
|
|
182
158
|
export const strikeRegex = buildRegex(ValidAutoformatChars.STRIKE);
|
|
183
|
-
export const codeRegex = buildRegex(ValidAutoformatChars.CODE);
|
|
184
|
-
export const codeRegexWithBackwardMatch = buildRegexNew(ValidAutoformatChars.CODE, true);
|
|
159
|
+
export const codeRegex = buildRegex(ValidAutoformatChars.CODE, true);
|
|
185
160
|
|
|
186
161
|
/**
|
|
187
162
|
* Create input rules for strong mark
|
|
@@ -262,8 +237,7 @@ function getCodeInputRules(schema, editorAnalyticsAPI, api) {
|
|
|
262
237
|
inputMethod: INPUT_METHOD.FORMATTING
|
|
263
238
|
}
|
|
264
239
|
}, editorAnalyticsAPI);
|
|
265
|
-
const
|
|
266
|
-
const backTickRule = createRule(allowsBackwardMatch ? codeRegexWithBackwardMatch : codeRegex, addMark(schema.marks.code, schema, ValidAutoformatChars.CODE, api), allowsBackwardMatch);
|
|
240
|
+
const backTickRule = createRule(codeRegex, addMark(schema.marks.code, schema, ValidAutoformatChars.CODE, api), true);
|
|
267
241
|
return [ruleWithCodeAnalytics(backTickRule)];
|
|
268
242
|
}
|
|
269
243
|
export function inputRulePlugin(schema, editorAnalyticsAPI, api) {
|
|
@@ -16,7 +16,6 @@ import { createRule } from '@atlaskit/editor-common/utils';
|
|
|
16
16
|
import { inputRuleWithAnalytics } from '@atlaskit/editor-common/utils/input-rules';
|
|
17
17
|
import { leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules/constants';
|
|
18
18
|
import { createPlugin } from '@atlaskit/prosemirror-input-rules/utils';
|
|
19
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
20
19
|
var ValidAutoformatChars = /*#__PURE__*/function (ValidAutoformatChars) {
|
|
21
20
|
ValidAutoformatChars["STRONG"] = "__";
|
|
22
21
|
ValidAutoformatChars["STRIKE"] = "~~";
|
|
@@ -64,9 +63,6 @@ function addMark(markType, _schema, char, api) {
|
|
|
64
63
|
// fixes the following case: my `*name` is *
|
|
65
64
|
// expected result: should ignore special characters inside "code"
|
|
66
65
|
if (textPrefix !== char || schema !== null && schema !== void 0 && (_schema$marks = schema.marks) !== null && _schema$marks !== void 0 && (_schema$marks = _schema$marks.code) !== null && _schema$marks !== void 0 && _schema$marks.isInSet(doc.resolve(start + 1).marks())) {
|
|
67
|
-
if (!expValEquals('platform_editor_lovability_inline_code', 'isEnabled', true)) {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
66
|
// if the prefix is not a character but the suffix is, continue
|
|
71
67
|
var suffix = state.doc.textBetween(end - char.length, end);
|
|
72
68
|
if (suffix !== char) {
|
|
@@ -144,28 +140,6 @@ var ReverseRegexExp = /*#__PURE__*/function (_RegExp) {
|
|
|
144
140
|
}]);
|
|
145
141
|
}( /*#__PURE__*/_wrapNativeSuper(RegExp));
|
|
146
142
|
var buildRegex = function buildRegex(char) {
|
|
147
|
-
// Ignored via go/ees005
|
|
148
|
-
// eslint-disable-next-line require-unicode-regexp
|
|
149
|
-
var escapedChar = char.replace(/(\W)/g, '\\$1');
|
|
150
|
-
// Ignored via go/ees005
|
|
151
|
-
// eslint-disable-next-line require-unicode-regexp, @atlassian/perf-linting/no-expensive-split-replace -- Ignored via go/ees017 (to be fixed)
|
|
152
|
-
var combinations = ValidCombinations[char].map(function (c) {
|
|
153
|
-
return c.replace(/(\W)/g, '\\$1');
|
|
154
|
-
}).join('|');
|
|
155
|
-
|
|
156
|
-
// Single X - https://regex101.com/r/McT3yq/14/
|
|
157
|
-
// Double X - https://regex101.com/r/pQUgjx/1/
|
|
158
|
-
var baseRegex = '^X(?=[^X\\s]).*?[^\\sX]X(?=[\\sOBJECT_REPLACEMENT_CHARACTER]COMBINATIONS|$)'.replace('OBJECT_REPLACEMENT_CHARACTER', leafNodeReplacementCharacter).replace('COMBINATIONS', combinations ? "|".concat(combinations) : '');
|
|
159
|
-
var replacedRegex = String.prototype.hasOwnProperty('replaceAll') ?
|
|
160
|
-
// Ignored via go/ees005
|
|
161
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
162
|
-
baseRegex.replaceAll('X', escapedChar) :
|
|
163
|
-
// Ignored via go/ees005
|
|
164
|
-
// eslint-disable-next-line require-unicode-regexp
|
|
165
|
-
baseRegex.replace(/X/g, escapedChar);
|
|
166
|
-
return new ReverseRegexExp(replacedRegex);
|
|
167
|
-
};
|
|
168
|
-
var buildRegexNew = function buildRegexNew(char) {
|
|
169
143
|
var allowsBackwardMatch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
170
144
|
// Ignored via go/ees005
|
|
171
145
|
// eslint-disable-next-line require-unicode-regexp
|
|
@@ -196,8 +170,7 @@ export var strongRegex2 = buildRegex(ValidAutoformatChars.STRONG_MARKDOWN);
|
|
|
196
170
|
export var italicRegex1 = buildRegex(ValidAutoformatChars.ITALIC);
|
|
197
171
|
export var italicRegex2 = buildRegex(ValidAutoformatChars.ITALIC_MARKDOWN);
|
|
198
172
|
export var strikeRegex = buildRegex(ValidAutoformatChars.STRIKE);
|
|
199
|
-
export var codeRegex = buildRegex(ValidAutoformatChars.CODE);
|
|
200
|
-
export var codeRegexWithBackwardMatch = buildRegexNew(ValidAutoformatChars.CODE, true);
|
|
173
|
+
export var codeRegex = buildRegex(ValidAutoformatChars.CODE, true);
|
|
201
174
|
|
|
202
175
|
/**
|
|
203
176
|
* Create input rules for strong mark
|
|
@@ -278,8 +251,7 @@ function getCodeInputRules(schema, editorAnalyticsAPI, api) {
|
|
|
278
251
|
inputMethod: INPUT_METHOD.FORMATTING
|
|
279
252
|
}
|
|
280
253
|
}, editorAnalyticsAPI);
|
|
281
|
-
var
|
|
282
|
-
var backTickRule = createRule(allowsBackwardMatch ? codeRegexWithBackwardMatch : codeRegex, addMark(schema.marks.code, schema, ValidAutoformatChars.CODE, api), allowsBackwardMatch);
|
|
254
|
+
var backTickRule = createRule(codeRegex, addMark(schema.marks.code, schema, ValidAutoformatChars.CODE, api), true);
|
|
283
255
|
return [ruleWithCodeAnalytics(backTickRule)];
|
|
284
256
|
}
|
|
285
257
|
export function inputRulePlugin(schema, editorAnalyticsAPI, api) {
|
|
@@ -21,6 +21,5 @@ export declare const italicRegex1: ReverseRegexExp;
|
|
|
21
21
|
export declare const italicRegex2: ReverseRegexExp;
|
|
22
22
|
export declare const strikeRegex: ReverseRegexExp;
|
|
23
23
|
export declare const codeRegex: ReverseRegexExp;
|
|
24
|
-
export declare const codeRegexWithBackwardMatch: ReverseRegexExp;
|
|
25
24
|
export declare function inputRulePlugin(schema: Schema, editorAnalyticsAPI: EditorAnalyticsAPI | undefined, api: ExtractInjectionAPI<TextFormattingPlugin> | undefined): SafePlugin | undefined;
|
|
26
25
|
export default inputRulePlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-text-formatting",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "31.0.1",
|
|
4
4
|
"description": "Text-formatting plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -39,18 +39,18 @@
|
|
|
39
39
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
40
40
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
41
41
|
"@atlaskit/prosemirror-input-rules": "^4.1.0",
|
|
42
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
43
|
-
"@atlaskit/tokens": "^20.
|
|
42
|
+
"@atlaskit/tmp-editor-statsig": "^261.0.0",
|
|
43
|
+
"@atlaskit/tokens": "^20.11.0",
|
|
44
44
|
"@babel/runtime": "^7.0.0",
|
|
45
45
|
"@emotion/react": "^11.7.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@atlaskit/editor-common": "^134.
|
|
48
|
+
"@atlaskit/editor-common": "^134.16.0",
|
|
49
49
|
"react": "^18.2.0 || ^19.2.0",
|
|
50
50
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@atlaskit/editor-common": "^134.
|
|
53
|
+
"@atlaskit/editor-common": "^134.16.0",
|
|
54
54
|
"react": "^19.2.0",
|
|
55
55
|
"react-intl": "^7.0.0"
|
|
56
56
|
},
|