@atlaskit/editor-core 187.8.10 → 187.8.13
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 +13 -0
- package/dist/cjs/plugins/text-formatting/index.js +23 -21
- package/dist/cjs/plugins/text-formatting/pm-plugins/input-rule.js +48 -54
- package/dist/cjs/plugins/text-formatting/pm-plugins/smart-input-rule.js +28 -33
- package/dist/cjs/ui/ElementBrowser/components/ElementSearch.js +5 -3
- package/dist/cjs/ui/ElementBrowser/components/StatelessElementBrowser.js +8 -6
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/text-formatting/index.js +15 -10
- package/dist/es2019/plugins/text-formatting/pm-plugins/input-rule.js +20 -18
- package/dist/es2019/plugins/text-formatting/pm-plugins/smart-input-rule.js +11 -12
- package/dist/es2019/ui/ElementBrowser/components/ElementSearch.js +5 -3
- package/dist/es2019/ui/ElementBrowser/components/StatelessElementBrowser.js +9 -6
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/text-formatting/index.js +23 -21
- package/dist/esm/plugins/text-formatting/pm-plugins/input-rule.js +48 -54
- package/dist/esm/plugins/text-formatting/pm-plugins/smart-input-rule.js +26 -31
- package/dist/esm/ui/ElementBrowser/components/ElementSearch.js +5 -3
- package/dist/esm/ui/ElementBrowser/components/StatelessElementBrowser.js +8 -6
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/text-formatting/pm-plugins/input-rule.d.ts +2 -1
- package/dist/types/plugins/text-formatting/pm-plugins/smart-input-rule.d.ts +2 -2
- package/dist/types/ui/ElementBrowser/components/ElementSearch.d.ts +2 -1
- package/dist/types/ui/ElementBrowser/components/StatelessElementBrowser.d.ts +4 -4
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/input-rule.d.ts +2 -1
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/smart-input-rule.d.ts +2 -2
- package/dist/types-ts4.5/ui/ElementBrowser/components/ElementSearch.d.ts +2 -1
- package/dist/types-ts4.5/ui/ElementBrowser/components/StatelessElementBrowser.d.ts +4 -4
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ruleWithAnalytics } from '../../../utils/input-rules';
|
|
2
1
|
import { createRule, createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
3
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
3
|
import { transformSmartCharsMentionsAndEmojis } from '@atlaskit/editor-common/mark';
|
|
4
|
+
import { inputRuleWithAnalytics } from '@atlaskit/editor-common/utils';
|
|
5
5
|
var ValidAutoformatChars = /*#__PURE__*/function (ValidAutoformatChars) {
|
|
6
6
|
ValidAutoformatChars["STRONG"] = "__";
|
|
7
7
|
ValidAutoformatChars["STRIKE"] = "~~";
|
|
@@ -144,8 +144,8 @@ export const codeRegex = buildRegex(ValidAutoformatChars.CODE);
|
|
|
144
144
|
* @param {Schema} schema
|
|
145
145
|
* @returns {InputRuleWrapper[]}
|
|
146
146
|
*/
|
|
147
|
-
function getStrongInputRules(schema) {
|
|
148
|
-
const ruleWithStrongAnalytics =
|
|
147
|
+
function getStrongInputRules(schema, editorAnalyticsAPI) {
|
|
148
|
+
const ruleWithStrongAnalytics = inputRuleWithAnalytics({
|
|
149
149
|
action: ACTION.FORMATTED,
|
|
150
150
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
151
151
|
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_STRONG,
|
|
@@ -153,7 +153,7 @@ function getStrongInputRules(schema) {
|
|
|
153
153
|
attributes: {
|
|
154
154
|
inputMethod: INPUT_METHOD.FORMATTING
|
|
155
155
|
}
|
|
156
|
-
})
|
|
156
|
+
}, editorAnalyticsAPI);
|
|
157
157
|
// **string** or __strong__ should bold the text
|
|
158
158
|
const doubleUnderscoreRule = createRule(strongRegex1, addMark(schema.marks.strong, schema, ValidAutoformatChars.STRONG));
|
|
159
159
|
const doubleAsterixRule = createRule(strongRegex2, addMark(schema.marks.strong, schema, ValidAutoformatChars.STRONG_MARKDOWN));
|
|
@@ -166,8 +166,8 @@ function getStrongInputRules(schema) {
|
|
|
166
166
|
* @param {Schema} schema
|
|
167
167
|
* @returns {InputRuleWrapper[]}
|
|
168
168
|
*/
|
|
169
|
-
function getItalicInputRules(schema) {
|
|
170
|
-
const ruleWithItalicAnalytics =
|
|
169
|
+
function getItalicInputRules(schema, editorAnalyticsAPI) {
|
|
170
|
+
const ruleWithItalicAnalytics = inputRuleWithAnalytics({
|
|
171
171
|
action: ACTION.FORMATTED,
|
|
172
172
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
173
173
|
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_ITALIC,
|
|
@@ -175,7 +175,7 @@ function getItalicInputRules(schema) {
|
|
|
175
175
|
attributes: {
|
|
176
176
|
inputMethod: INPUT_METHOD.FORMATTING
|
|
177
177
|
}
|
|
178
|
-
})
|
|
178
|
+
}, editorAnalyticsAPI);
|
|
179
179
|
const underscoreRule = createRule(italicRegex1, addMark(schema.marks.em, schema, ValidAutoformatChars.ITALIC));
|
|
180
180
|
const asterixRule = createRule(italicRegex2, addMark(schema.marks.em, schema, ValidAutoformatChars.ITALIC_MARKDOWN));
|
|
181
181
|
return [ruleWithItalicAnalytics(underscoreRule), ruleWithItalicAnalytics(asterixRule)];
|
|
@@ -187,8 +187,8 @@ function getItalicInputRules(schema) {
|
|
|
187
187
|
* @param {Schema} schema
|
|
188
188
|
* @returns {InputRuleWrapper[]}
|
|
189
189
|
*/
|
|
190
|
-
function getStrikeInputRules(schema) {
|
|
191
|
-
const ruleWithStrikeAnalytics =
|
|
190
|
+
function getStrikeInputRules(schema, editorAnalyticsAPI) {
|
|
191
|
+
const ruleWithStrikeAnalytics = inputRuleWithAnalytics({
|
|
192
192
|
action: ACTION.FORMATTED,
|
|
193
193
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
194
194
|
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_STRIKE,
|
|
@@ -196,7 +196,7 @@ function getStrikeInputRules(schema) {
|
|
|
196
196
|
attributes: {
|
|
197
197
|
inputMethod: INPUT_METHOD.FORMATTING
|
|
198
198
|
}
|
|
199
|
-
})
|
|
199
|
+
}, editorAnalyticsAPI);
|
|
200
200
|
const doubleTildeRule = createRule(strikeRegex, addMark(schema.marks.strike, schema, ValidAutoformatChars.STRIKE));
|
|
201
201
|
return [ruleWithStrikeAnalytics(doubleTildeRule)];
|
|
202
202
|
}
|
|
@@ -207,8 +207,8 @@ function getStrikeInputRules(schema) {
|
|
|
207
207
|
* @param {Schema} schema
|
|
208
208
|
* @returns {InputRuleWrapper[]}
|
|
209
209
|
*/
|
|
210
|
-
function getCodeInputRules(schema) {
|
|
211
|
-
const ruleWithCodeAnalytics =
|
|
210
|
+
function getCodeInputRules(schema, editorAnalyticsAPI) {
|
|
211
|
+
const ruleWithCodeAnalytics = inputRuleWithAnalytics({
|
|
212
212
|
action: ACTION.FORMATTED,
|
|
213
213
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
214
214
|
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_CODE,
|
|
@@ -216,23 +216,25 @@ function getCodeInputRules(schema) {
|
|
|
216
216
|
attributes: {
|
|
217
217
|
inputMethod: INPUT_METHOD.FORMATTING
|
|
218
218
|
}
|
|
219
|
-
})
|
|
219
|
+
}, editorAnalyticsAPI);
|
|
220
220
|
const backTickRule = createRule(codeRegex, addMark(schema.marks.code, schema, ValidAutoformatChars.CODE));
|
|
221
221
|
return [ruleWithCodeAnalytics(backTickRule)];
|
|
222
222
|
}
|
|
223
|
-
export function inputRulePlugin(schema,
|
|
223
|
+
export function inputRulePlugin(schema,
|
|
224
|
+
// Don't remove the unused featureFlags, this gets used to test if we're properly passing them to the PM plugin
|
|
225
|
+
_featureFlags, editorAnalyticsAPI) {
|
|
224
226
|
const rules = [];
|
|
225
227
|
if (schema.marks.strong) {
|
|
226
|
-
rules.push(...getStrongInputRules(schema));
|
|
228
|
+
rules.push(...getStrongInputRules(schema, editorAnalyticsAPI));
|
|
227
229
|
}
|
|
228
230
|
if (schema.marks.em) {
|
|
229
|
-
rules.push(...getItalicInputRules(schema));
|
|
231
|
+
rules.push(...getItalicInputRules(schema, editorAnalyticsAPI));
|
|
230
232
|
}
|
|
231
233
|
if (schema.marks.strike) {
|
|
232
|
-
rules.push(...getStrikeInputRules(schema));
|
|
234
|
+
rules.push(...getStrikeInputRules(schema, editorAnalyticsAPI));
|
|
233
235
|
}
|
|
234
236
|
if (schema.marks.code) {
|
|
235
|
-
rules.push(...getCodeInputRules(schema));
|
|
237
|
+
rules.push(...getCodeInputRules(schema, editorAnalyticsAPI));
|
|
236
238
|
}
|
|
237
239
|
if (rules.length !== 0) {
|
|
238
240
|
return createPlugin('text-formatting', rules);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { ruleWithAnalytics } from '../../../utils/input-rules';
|
|
3
2
|
import { createRule, createPlugin } from '@atlaskit/prosemirror-input-rules';
|
|
4
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, PUNC, SYMBOL } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { inputRuleWithAnalytics } from '@atlaskit/editor-common/utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Creates an InputRuleHandler that will match on a regular expression of the
|
|
@@ -77,8 +77,8 @@ function createSingleQuotesRules() {
|
|
|
77
77
|
/**
|
|
78
78
|
* Get replacement rules related to product
|
|
79
79
|
*/
|
|
80
|
-
function getProductRules() {
|
|
81
|
-
const productRuleWithAnalytics = product =>
|
|
80
|
+
function getProductRules(editorAnalyticsAPI) {
|
|
81
|
+
const productRuleWithAnalytics = product => inputRuleWithAnalytics((_, match) => ({
|
|
82
82
|
action: ACTION.SUBSTITUTED,
|
|
83
83
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
84
84
|
actionSubjectId: ACTION_SUBJECT_ID.PRODUCT_NAME,
|
|
@@ -87,7 +87,7 @@ function getProductRules() {
|
|
|
87
87
|
product,
|
|
88
88
|
originalSpelling: match[2]
|
|
89
89
|
}
|
|
90
|
-
}));
|
|
90
|
+
}), editorAnalyticsAPI);
|
|
91
91
|
return createReplacementRules({
|
|
92
92
|
Atlassian: /(\s+|^)(atlassian)(\s)$/,
|
|
93
93
|
Jira: /(\s+|^)(jira|JIRA)(\s)$/,
|
|
@@ -100,13 +100,13 @@ function getProductRules() {
|
|
|
100
100
|
/**
|
|
101
101
|
* Get replacement rules related to symbol
|
|
102
102
|
*/
|
|
103
|
-
function getSymbolRules() {
|
|
103
|
+
function getSymbolRules(editorAnalyticsAPI) {
|
|
104
104
|
const symbolToString = {
|
|
105
105
|
'→': SYMBOL.ARROW_RIGHT,
|
|
106
106
|
'←': SYMBOL.ARROW_LEFT,
|
|
107
107
|
'↔︎': SYMBOL.ARROW_DOUBLE
|
|
108
108
|
};
|
|
109
|
-
const symbolRuleWithAnalytics = symbol =>
|
|
109
|
+
const symbolRuleWithAnalytics = symbol => inputRuleWithAnalytics({
|
|
110
110
|
action: ACTION.SUBSTITUTED,
|
|
111
111
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
112
112
|
actionSubjectId: ACTION_SUBJECT_ID.SYMBOL,
|
|
@@ -114,7 +114,7 @@ function getSymbolRules() {
|
|
|
114
114
|
attributes: {
|
|
115
115
|
symbol: symbolToString[symbol]
|
|
116
116
|
}
|
|
117
|
-
})
|
|
117
|
+
}, editorAnalyticsAPI);
|
|
118
118
|
return createReplacementRules({
|
|
119
119
|
'→': /(\s+|^)(--?>)(\s)$/,
|
|
120
120
|
'←': /(\s+|^)(<--?)(\s)$/,
|
|
@@ -125,15 +125,14 @@ function getSymbolRules() {
|
|
|
125
125
|
/**
|
|
126
126
|
* Get replacement rules related to punctuation
|
|
127
127
|
*/
|
|
128
|
-
function getPunctuationRules() {
|
|
128
|
+
function getPunctuationRules(editorAnalyticsAPI) {
|
|
129
129
|
const punctuationToString = {
|
|
130
130
|
'–': PUNC.DASH,
|
|
131
131
|
'…': PUNC.ELLIPSIS,
|
|
132
|
-
'“': PUNC.QUOTE_DOUBLE,
|
|
133
132
|
'”': PUNC.QUOTE_DOUBLE,
|
|
134
133
|
[PUNC.QUOTE_SINGLE]: PUNC.QUOTE_SINGLE
|
|
135
134
|
};
|
|
136
|
-
const punctuationRuleWithAnalytics = punctuation =>
|
|
135
|
+
const punctuationRuleWithAnalytics = punctuation => inputRuleWithAnalytics({
|
|
137
136
|
action: ACTION.SUBSTITUTED,
|
|
138
137
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
139
138
|
actionSubjectId: ACTION_SUBJECT_ID.PUNC,
|
|
@@ -141,7 +140,7 @@ function getPunctuationRules() {
|
|
|
141
140
|
attributes: {
|
|
142
141
|
punctuation: punctuationToString[punctuation]
|
|
143
142
|
}
|
|
144
|
-
})
|
|
143
|
+
}, editorAnalyticsAPI);
|
|
145
144
|
const dashEllipsisRules = createReplacementRules({
|
|
146
145
|
'–': /(\s+|^)(--)(\s)$/,
|
|
147
146
|
'…': /()(\.\.\.)$/
|
|
@@ -153,4 +152,4 @@ function getPunctuationRules() {
|
|
|
153
152
|
const singleQuoteRules = createSingleQuotesRules();
|
|
154
153
|
return [...dashEllipsisRules, ...doubleQuoteRules, ...singleQuoteRules.map(rule => punctuationRuleWithAnalytics(PUNC.QUOTE_SINGLE)(rule))];
|
|
155
154
|
}
|
|
156
|
-
export default (
|
|
155
|
+
export default (editorAnalyticsAPI => createPlugin('text-formatting:smart-input', [...getProductRules(editorAnalyticsAPI), ...getSymbolRules(editorAnalyticsAPI), ...getPunctuationRules(editorAnalyticsAPI)]));
|
|
@@ -19,6 +19,7 @@ function ElementSearch({
|
|
|
19
19
|
},
|
|
20
20
|
focus,
|
|
21
21
|
onClick,
|
|
22
|
+
onKeyDown,
|
|
22
23
|
searchTerm
|
|
23
24
|
}) {
|
|
24
25
|
const ref = useFocus(focus);
|
|
@@ -38,6 +39,7 @@ function ElementSearch({
|
|
|
38
39
|
onChange: onChange,
|
|
39
40
|
onClick: onClick,
|
|
40
41
|
onFocus: onFocus,
|
|
42
|
+
onKeyDown: onKeyDown,
|
|
41
43
|
onBlur: onBlur,
|
|
42
44
|
elemBeforeInput: jsx("div", {
|
|
43
45
|
css: elementBeforeInput,
|
|
@@ -82,7 +84,7 @@ const wrapper = css`
|
|
|
82
84
|
& > [data-ds--text-field--input] {
|
|
83
85
|
margin-bottom: 3px;
|
|
84
86
|
font-size: ${relativeFontSizeToBase16(14)};
|
|
85
|
-
padding: ${GRID_SIZE}px 6px ${GRID_SIZE}px 0;
|
|
87
|
+
padding: ${GRID_SIZE}px ${"var(--ds-space-075, 6px)"} ${GRID_SIZE}px 0;
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
90
|
`;
|
|
@@ -94,7 +96,7 @@ const wrapperInline = css`
|
|
|
94
96
|
}
|
|
95
97
|
`;
|
|
96
98
|
const elementBeforeInput = css`
|
|
97
|
-
margin: 1px 6px 0 8px;
|
|
99
|
+
margin: 1px ${"var(--ds-space-075, 6px)"} 0 ${"var(--ds-space-100, 8px)"};
|
|
98
100
|
color: ${`var(--ds-icon, ${N200})`};
|
|
99
101
|
|
|
100
102
|
// Custom SearchIcon style
|
|
@@ -105,7 +107,7 @@ const elementBeforeInput = css`
|
|
|
105
107
|
}
|
|
106
108
|
`;
|
|
107
109
|
const elementAfterInput = css`
|
|
108
|
-
margin: 0 8px;
|
|
110
|
+
margin: 0 ${"var(--ds-space-100, 8px)"};
|
|
109
111
|
height: ${SEARCH_ITEM_HEIGHT_WIDTH};
|
|
110
112
|
text-align: center;
|
|
111
113
|
`;
|
|
@@ -49,7 +49,8 @@ const baseSidebarStyles = css`
|
|
|
49
49
|
const mobileSideBar = css`
|
|
50
50
|
${baseSidebarStyles};
|
|
51
51
|
flex: 0 0 ${INLINE_SIDEBAR_HEIGHT};
|
|
52
|
-
padding: 12px 12px 0
|
|
52
|
+
padding: ${"var(--ds-space-150, 12px)"} ${"var(--ds-space-150, 12px)"} 0
|
|
53
|
+
${"var(--ds-space-150, 12px)"};
|
|
53
54
|
`;
|
|
54
55
|
const mobileSideBarShowCategories = css`
|
|
55
56
|
flex: 0 0 auto;
|
|
@@ -111,6 +112,7 @@ function StatelessElementBrowser(props) {
|
|
|
111
112
|
const {
|
|
112
113
|
items,
|
|
113
114
|
onSelectItem,
|
|
115
|
+
onInsertItem,
|
|
114
116
|
viewMoreItem
|
|
115
117
|
} = props;
|
|
116
118
|
const {
|
|
@@ -160,10 +162,11 @@ function StatelessElementBrowser(props) {
|
|
|
160
162
|
if (e.key !== 'Enter') {
|
|
161
163
|
return;
|
|
162
164
|
}
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
+
if (onInsertItem && selectedItem != null) {
|
|
166
|
+
onInsertItem(selectedItem);
|
|
165
167
|
}
|
|
166
|
-
|
|
168
|
+
e.preventDefault();
|
|
169
|
+
}, [onInsertItem, selectedItem]);
|
|
167
170
|
|
|
168
171
|
/**
|
|
169
172
|
* On arrow key selection and clicks the selectedItemIndex will change.
|
|
@@ -225,13 +228,13 @@ function MobileBrowser({
|
|
|
225
228
|
}) {
|
|
226
229
|
return jsx("div", {
|
|
227
230
|
css: mobileElementBrowserContainer,
|
|
228
|
-
onKeyPress: onKeyPress,
|
|
229
231
|
onKeyDown: onKeyDown,
|
|
230
232
|
"data-testid": "mobile__element-browser"
|
|
231
233
|
}, jsx("div", {
|
|
232
234
|
css: showCategories ? [mobileSideBar, mobileSideBarShowCategories] : mobileSideBar
|
|
233
235
|
}, showSearch && jsx(ElementSearch, {
|
|
234
236
|
onSearch: onSearch,
|
|
237
|
+
onKeyDown: onKeyPress,
|
|
235
238
|
mode: mode,
|
|
236
239
|
focus: focusOnSearch,
|
|
237
240
|
onClick: setFocusOnSearch,
|
|
@@ -305,13 +308,13 @@ function DesktopBrowser({
|
|
|
305
308
|
createAnalyticsEvent: createAnalyticsEvent
|
|
306
309
|
}))), jsx("div", {
|
|
307
310
|
css: mainContent,
|
|
308
|
-
onKeyPress: onKeyPress,
|
|
309
311
|
onKeyDown: onKeyDown,
|
|
310
312
|
"data-testid": "main-content"
|
|
311
313
|
}, showSearch && jsx("div", {
|
|
312
314
|
css: searchContainer
|
|
313
315
|
}, jsx(ElementSearch, {
|
|
314
316
|
onSearch: onSearch,
|
|
317
|
+
onKeyDown: onKeyPress,
|
|
315
318
|
mode: mode,
|
|
316
319
|
focus: focusOnSearch,
|
|
317
320
|
onClick: setFocusOnSearch,
|
package/dist/es2019/version.json
CHANGED
|
@@ -50,52 +50,54 @@ var textFormatting = function textFormatting() {
|
|
|
50
50
|
}
|
|
51
51
|
}, {
|
|
52
52
|
name: 'textFormattingInputRule',
|
|
53
|
+
// Don't remove the unused featureFlags, this gets used to test if we're properly passing them to the PM plugin
|
|
53
54
|
plugin: function plugin(_ref2) {
|
|
55
|
+
var _api$dependencies$ana2;
|
|
54
56
|
var schema = _ref2.schema,
|
|
55
57
|
featureFlags = _ref2.featureFlags;
|
|
56
|
-
return textFormattingInputRulePlugin(schema, featureFlags);
|
|
58
|
+
return textFormattingInputRulePlugin(schema, featureFlags, api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions);
|
|
57
59
|
}
|
|
58
60
|
}, {
|
|
59
61
|
name: 'textFormattingSmartRule',
|
|
60
|
-
plugin: function plugin(
|
|
61
|
-
var
|
|
62
|
-
return !options.disableSmartTextCompletion ? textFormattingSmartInputRulePlugin(
|
|
62
|
+
plugin: function plugin() {
|
|
63
|
+
var _api$dependencies$ana3;
|
|
64
|
+
return !options.disableSmartTextCompletion ? textFormattingSmartInputRulePlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions) : undefined;
|
|
63
65
|
}
|
|
64
66
|
}, {
|
|
65
67
|
name: 'textFormattingClear',
|
|
66
|
-
plugin: function plugin(
|
|
67
|
-
var dispatch =
|
|
68
|
+
plugin: function plugin(_ref3) {
|
|
69
|
+
var dispatch = _ref3.dispatch;
|
|
68
70
|
return clearFormattingPlugin(dispatch);
|
|
69
71
|
}
|
|
70
72
|
}, {
|
|
71
73
|
name: 'textFormattingClearKeymap',
|
|
72
74
|
plugin: function plugin() {
|
|
73
|
-
var _api$dependencies$
|
|
74
|
-
return clearFormattingKeymapPlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
75
|
+
var _api$dependencies$ana4;
|
|
76
|
+
return clearFormattingKeymapPlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana4 = api.dependencies.analytics) === null || _api$dependencies$ana4 === void 0 ? void 0 : _api$dependencies$ana4.actions);
|
|
75
77
|
}
|
|
76
78
|
}, {
|
|
77
79
|
name: 'textFormattingKeymap',
|
|
78
|
-
plugin: function plugin(
|
|
79
|
-
var _api$dependencies$
|
|
80
|
-
var schema =
|
|
81
|
-
return keymapPlugin(schema, api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
80
|
+
plugin: function plugin(_ref4) {
|
|
81
|
+
var _api$dependencies$ana5;
|
|
82
|
+
var schema = _ref4.schema;
|
|
83
|
+
return keymapPlugin(schema, api === null || api === void 0 ? void 0 : (_api$dependencies$ana5 = api.dependencies.analytics) === null || _api$dependencies$ana5 === void 0 ? void 0 : _api$dependencies$ana5.actions);
|
|
82
84
|
}
|
|
83
85
|
}];
|
|
84
86
|
},
|
|
85
|
-
primaryToolbarComponent: function primaryToolbarComponent(
|
|
86
|
-
var editorView =
|
|
87
|
-
popupsMountPoint =
|
|
88
|
-
popupsScrollableElement =
|
|
89
|
-
isToolbarReducedSpacing =
|
|
90
|
-
toolbarSize =
|
|
91
|
-
disabled =
|
|
87
|
+
primaryToolbarComponent: function primaryToolbarComponent(_ref5) {
|
|
88
|
+
var editorView = _ref5.editorView,
|
|
89
|
+
popupsMountPoint = _ref5.popupsMountPoint,
|
|
90
|
+
popupsScrollableElement = _ref5.popupsScrollableElement,
|
|
91
|
+
isToolbarReducedSpacing = _ref5.isToolbarReducedSpacing,
|
|
92
|
+
toolbarSize = _ref5.toolbarSize,
|
|
93
|
+
disabled = _ref5.disabled;
|
|
92
94
|
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
93
95
|
plugins: {
|
|
94
96
|
textFormattingState: textFormattingPluginKey,
|
|
95
97
|
clearFormattingPluginState: clearFormattingPluginKey
|
|
96
98
|
},
|
|
97
99
|
render: function render() {
|
|
98
|
-
var _api$dependencies$
|
|
100
|
+
var _api$dependencies$ana6;
|
|
99
101
|
return /*#__PURE__*/React.createElement(Toolbar, {
|
|
100
102
|
editorState: editorView.state,
|
|
101
103
|
popupsMountPoint: popupsMountPoint,
|
|
@@ -105,7 +107,7 @@ var textFormatting = function textFormatting() {
|
|
|
105
107
|
editorView: editorView,
|
|
106
108
|
isToolbarDisabled: disabled,
|
|
107
109
|
shouldUseResponsiveToolbar: Boolean(options.responsiveToolbarMenu),
|
|
108
|
-
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
110
|
+
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$dependencies$ana6 = api.dependencies.analytics) === null || _api$dependencies$ana6 === void 0 ? void 0 : _api$dependencies$ana6.actions
|
|
109
111
|
});
|
|
110
112
|
}
|
|
111
113
|
});
|
|
@@ -10,10 +10,10 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
10
10
|
var _ValidCombinations;
|
|
11
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
12
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
|
-
import { ruleWithAnalytics } from '../../../utils/input-rules';
|
|
14
13
|
import { createRule, createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
15
14
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
16
15
|
import { transformSmartCharsMentionsAndEmojis } from '@atlaskit/editor-common/mark';
|
|
16
|
+
import { inputRuleWithAnalytics } from '@atlaskit/editor-common/utils';
|
|
17
17
|
var ValidAutoformatChars = /*#__PURE__*/function (ValidAutoformatChars) {
|
|
18
18
|
ValidAutoformatChars["STRONG"] = "__";
|
|
19
19
|
ValidAutoformatChars["STRIKE"] = "~~";
|
|
@@ -159,18 +159,16 @@ export var codeRegex = buildRegex(ValidAutoformatChars.CODE);
|
|
|
159
159
|
* @param {Schema} schema
|
|
160
160
|
* @returns {InputRuleWrapper[]}
|
|
161
161
|
*/
|
|
162
|
-
function getStrongInputRules(schema) {
|
|
163
|
-
var ruleWithStrongAnalytics =
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
};
|
|
173
|
-
});
|
|
162
|
+
function getStrongInputRules(schema, editorAnalyticsAPI) {
|
|
163
|
+
var ruleWithStrongAnalytics = inputRuleWithAnalytics({
|
|
164
|
+
action: ACTION.FORMATTED,
|
|
165
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
166
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_STRONG,
|
|
167
|
+
eventType: EVENT_TYPE.TRACK,
|
|
168
|
+
attributes: {
|
|
169
|
+
inputMethod: INPUT_METHOD.FORMATTING
|
|
170
|
+
}
|
|
171
|
+
}, editorAnalyticsAPI);
|
|
174
172
|
// **string** or __strong__ should bold the text
|
|
175
173
|
var doubleUnderscoreRule = createRule(strongRegex1, addMark(schema.marks.strong, schema, ValidAutoformatChars.STRONG));
|
|
176
174
|
var doubleAsterixRule = createRule(strongRegex2, addMark(schema.marks.strong, schema, ValidAutoformatChars.STRONG_MARKDOWN));
|
|
@@ -183,18 +181,16 @@ function getStrongInputRules(schema) {
|
|
|
183
181
|
* @param {Schema} schema
|
|
184
182
|
* @returns {InputRuleWrapper[]}
|
|
185
183
|
*/
|
|
186
|
-
function getItalicInputRules(schema) {
|
|
187
|
-
var ruleWithItalicAnalytics =
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
};
|
|
197
|
-
});
|
|
184
|
+
function getItalicInputRules(schema, editorAnalyticsAPI) {
|
|
185
|
+
var ruleWithItalicAnalytics = inputRuleWithAnalytics({
|
|
186
|
+
action: ACTION.FORMATTED,
|
|
187
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
188
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_ITALIC,
|
|
189
|
+
eventType: EVENT_TYPE.TRACK,
|
|
190
|
+
attributes: {
|
|
191
|
+
inputMethod: INPUT_METHOD.FORMATTING
|
|
192
|
+
}
|
|
193
|
+
}, editorAnalyticsAPI);
|
|
198
194
|
var underscoreRule = createRule(italicRegex1, addMark(schema.marks.em, schema, ValidAutoformatChars.ITALIC));
|
|
199
195
|
var asterixRule = createRule(italicRegex2, addMark(schema.marks.em, schema, ValidAutoformatChars.ITALIC_MARKDOWN));
|
|
200
196
|
return [ruleWithItalicAnalytics(underscoreRule), ruleWithItalicAnalytics(asterixRule)];
|
|
@@ -206,18 +202,16 @@ function getItalicInputRules(schema) {
|
|
|
206
202
|
* @param {Schema} schema
|
|
207
203
|
* @returns {InputRuleWrapper[]}
|
|
208
204
|
*/
|
|
209
|
-
function getStrikeInputRules(schema) {
|
|
210
|
-
var ruleWithStrikeAnalytics =
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
};
|
|
220
|
-
});
|
|
205
|
+
function getStrikeInputRules(schema, editorAnalyticsAPI) {
|
|
206
|
+
var ruleWithStrikeAnalytics = inputRuleWithAnalytics({
|
|
207
|
+
action: ACTION.FORMATTED,
|
|
208
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
209
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_STRIKE,
|
|
210
|
+
eventType: EVENT_TYPE.TRACK,
|
|
211
|
+
attributes: {
|
|
212
|
+
inputMethod: INPUT_METHOD.FORMATTING
|
|
213
|
+
}
|
|
214
|
+
}, editorAnalyticsAPI);
|
|
221
215
|
var doubleTildeRule = createRule(strikeRegex, addMark(schema.marks.strike, schema, ValidAutoformatChars.STRIKE));
|
|
222
216
|
return [ruleWithStrikeAnalytics(doubleTildeRule)];
|
|
223
217
|
}
|
|
@@ -228,34 +222,34 @@ function getStrikeInputRules(schema) {
|
|
|
228
222
|
* @param {Schema} schema
|
|
229
223
|
* @returns {InputRuleWrapper[]}
|
|
230
224
|
*/
|
|
231
|
-
function getCodeInputRules(schema) {
|
|
232
|
-
var ruleWithCodeAnalytics =
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
};
|
|
242
|
-
});
|
|
225
|
+
function getCodeInputRules(schema, editorAnalyticsAPI) {
|
|
226
|
+
var ruleWithCodeAnalytics = inputRuleWithAnalytics({
|
|
227
|
+
action: ACTION.FORMATTED,
|
|
228
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
229
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_CODE,
|
|
230
|
+
eventType: EVENT_TYPE.TRACK,
|
|
231
|
+
attributes: {
|
|
232
|
+
inputMethod: INPUT_METHOD.FORMATTING
|
|
233
|
+
}
|
|
234
|
+
}, editorAnalyticsAPI);
|
|
243
235
|
var backTickRule = createRule(codeRegex, addMark(schema.marks.code, schema, ValidAutoformatChars.CODE));
|
|
244
236
|
return [ruleWithCodeAnalytics(backTickRule)];
|
|
245
237
|
}
|
|
246
|
-
export function inputRulePlugin(schema,
|
|
238
|
+
export function inputRulePlugin(schema,
|
|
239
|
+
// Don't remove the unused featureFlags, this gets used to test if we're properly passing them to the PM plugin
|
|
240
|
+
_featureFlags, editorAnalyticsAPI) {
|
|
247
241
|
var rules = [];
|
|
248
242
|
if (schema.marks.strong) {
|
|
249
|
-
rules.push.apply(rules, _toConsumableArray(getStrongInputRules(schema)));
|
|
243
|
+
rules.push.apply(rules, _toConsumableArray(getStrongInputRules(schema, editorAnalyticsAPI)));
|
|
250
244
|
}
|
|
251
245
|
if (schema.marks.em) {
|
|
252
|
-
rules.push.apply(rules, _toConsumableArray(getItalicInputRules(schema)));
|
|
246
|
+
rules.push.apply(rules, _toConsumableArray(getItalicInputRules(schema, editorAnalyticsAPI)));
|
|
253
247
|
}
|
|
254
248
|
if (schema.marks.strike) {
|
|
255
|
-
rules.push.apply(rules, _toConsumableArray(getStrikeInputRules(schema)));
|
|
249
|
+
rules.push.apply(rules, _toConsumableArray(getStrikeInputRules(schema, editorAnalyticsAPI)));
|
|
256
250
|
}
|
|
257
251
|
if (schema.marks.code) {
|
|
258
|
-
rules.push.apply(rules, _toConsumableArray(getCodeInputRules(schema)));
|
|
252
|
+
rules.push.apply(rules, _toConsumableArray(getCodeInputRules(schema, editorAnalyticsAPI)));
|
|
259
253
|
}
|
|
260
254
|
if (rules.length !== 0) {
|
|
261
255
|
return createPlugin('text-formatting', rules);
|
|
@@ -2,9 +2,9 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
4
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import { ruleWithAnalytics } from '../../../utils/input-rules';
|
|
6
5
|
import { createRule, createPlugin } from '@atlaskit/prosemirror-input-rules';
|
|
7
6
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, PUNC, SYMBOL } from '@atlaskit/editor-common/analytics';
|
|
7
|
+
import { inputRuleWithAnalytics } from '@atlaskit/editor-common/utils';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Creates an InputRuleHandler that will match on a regular expression of the
|
|
@@ -80,9 +80,9 @@ function createSingleQuotesRules() {
|
|
|
80
80
|
/**
|
|
81
81
|
* Get replacement rules related to product
|
|
82
82
|
*/
|
|
83
|
-
function getProductRules() {
|
|
83
|
+
function getProductRules(editorAnalyticsAPI) {
|
|
84
84
|
var productRuleWithAnalytics = function productRuleWithAnalytics(product) {
|
|
85
|
-
return
|
|
85
|
+
return inputRuleWithAnalytics(function (_, match) {
|
|
86
86
|
return {
|
|
87
87
|
action: ACTION.SUBSTITUTED,
|
|
88
88
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
@@ -93,7 +93,7 @@ function getProductRules() {
|
|
|
93
93
|
originalSpelling: match[2]
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
});
|
|
96
|
+
}, editorAnalyticsAPI);
|
|
97
97
|
};
|
|
98
98
|
return createReplacementRules({
|
|
99
99
|
Atlassian: /(\s+|^)(atlassian)(\s)$/,
|
|
@@ -107,24 +107,22 @@ function getProductRules() {
|
|
|
107
107
|
/**
|
|
108
108
|
* Get replacement rules related to symbol
|
|
109
109
|
*/
|
|
110
|
-
function getSymbolRules() {
|
|
110
|
+
function getSymbolRules(editorAnalyticsAPI) {
|
|
111
111
|
var symbolToString = {
|
|
112
112
|
'→': SYMBOL.ARROW_RIGHT,
|
|
113
113
|
'←': SYMBOL.ARROW_LEFT,
|
|
114
114
|
'↔︎': SYMBOL.ARROW_DOUBLE
|
|
115
115
|
};
|
|
116
116
|
var symbolRuleWithAnalytics = function symbolRuleWithAnalytics(symbol) {
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
};
|
|
127
|
-
});
|
|
117
|
+
return inputRuleWithAnalytics({
|
|
118
|
+
action: ACTION.SUBSTITUTED,
|
|
119
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
120
|
+
actionSubjectId: ACTION_SUBJECT_ID.SYMBOL,
|
|
121
|
+
eventType: EVENT_TYPE.TRACK,
|
|
122
|
+
attributes: {
|
|
123
|
+
symbol: symbolToString[symbol]
|
|
124
|
+
}
|
|
125
|
+
}, editorAnalyticsAPI);
|
|
128
126
|
};
|
|
129
127
|
return createReplacementRules({
|
|
130
128
|
'→': /(\s+|^)(--?>)(\s)$/,
|
|
@@ -136,25 +134,22 @@ function getSymbolRules() {
|
|
|
136
134
|
/**
|
|
137
135
|
* Get replacement rules related to punctuation
|
|
138
136
|
*/
|
|
139
|
-
function getPunctuationRules() {
|
|
137
|
+
function getPunctuationRules(editorAnalyticsAPI) {
|
|
140
138
|
var punctuationToString = _defineProperty({
|
|
141
139
|
'–': PUNC.DASH,
|
|
142
140
|
'…': PUNC.ELLIPSIS,
|
|
143
|
-
'“': PUNC.QUOTE_DOUBLE,
|
|
144
141
|
'”': PUNC.QUOTE_DOUBLE
|
|
145
142
|
}, PUNC.QUOTE_SINGLE, PUNC.QUOTE_SINGLE);
|
|
146
143
|
var punctuationRuleWithAnalytics = function punctuationRuleWithAnalytics(punctuation) {
|
|
147
|
-
return
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
};
|
|
157
|
-
});
|
|
144
|
+
return inputRuleWithAnalytics({
|
|
145
|
+
action: ACTION.SUBSTITUTED,
|
|
146
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
147
|
+
actionSubjectId: ACTION_SUBJECT_ID.PUNC,
|
|
148
|
+
eventType: EVENT_TYPE.TRACK,
|
|
149
|
+
attributes: {
|
|
150
|
+
punctuation: punctuationToString[punctuation]
|
|
151
|
+
}
|
|
152
|
+
}, editorAnalyticsAPI);
|
|
158
153
|
};
|
|
159
154
|
var dashEllipsisRules = createReplacementRules({
|
|
160
155
|
'–': /(\s+|^)(--)(\s)$/,
|
|
@@ -169,6 +164,6 @@ function getPunctuationRules() {
|
|
|
169
164
|
return punctuationRuleWithAnalytics(PUNC.QUOTE_SINGLE)(rule);
|
|
170
165
|
})));
|
|
171
166
|
}
|
|
172
|
-
export default (function (
|
|
173
|
-
return createPlugin('text-formatting:smart-input', [].concat(_toConsumableArray(getProductRules()), _toConsumableArray(getSymbolRules()), _toConsumableArray(getPunctuationRules())));
|
|
167
|
+
export default (function (editorAnalyticsAPI) {
|
|
168
|
+
return createPlugin('text-formatting:smart-input', [].concat(_toConsumableArray(getProductRules(editorAnalyticsAPI)), _toConsumableArray(getSymbolRules(editorAnalyticsAPI)), _toConsumableArray(getPunctuationRules(editorAnalyticsAPI))));
|
|
174
169
|
});
|