@atlaskit/editor-core 187.9.0 → 187.10.0
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 +17 -0
- package/dist/cjs/commands/index.js +8 -134
- package/dist/cjs/plugins/base/index.js +2 -2
- package/dist/cjs/plugins/block-type/commands/block-type.js +34 -36
- package/dist/cjs/plugins/block-type/commands/transform-to-code-block.js +1 -2
- package/dist/cjs/plugins/block-type/index.js +16 -13
- package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +19 -18
- package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +12 -14
- package/dist/cjs/plugins/block-type/pm-plugins/main.js +9 -9
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +7 -7
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +3 -4
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +13 -5
- package/dist/cjs/plugins/block-type/utils.js +73 -2
- package/dist/cjs/plugins/caption/pm-plugins/keymap.js +2 -2
- package/dist/cjs/plugins/emoji/commands/insert-emoji.js +31 -28
- package/dist/cjs/plugins/emoji/index.js +4 -3
- package/dist/cjs/plugins/emoji/pm-plugins/ascii-input-rules.js +23 -18
- package/dist/cjs/plugins/extension/pm-plugins/main.js +54 -9
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +1 -1
- package/dist/cjs/plugins/media/utils/media-common.js +5 -5
- package/dist/cjs/plugins/selection/pm-plugins/events/keydown.js +61 -25
- package/dist/cjs/plugins/undo-redo/pm-plugins/keymaps.js +2 -2
- package/dist/cjs/ui/styles.js +4 -11
- package/dist/cjs/utils/index.js +4 -80
- package/dist/cjs/utils/input-rules.js +6 -66
- package/dist/cjs/utils/mark.js +2 -38
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/commands/index.js +1 -128
- package/dist/es2019/plugins/base/index.js +1 -1
- package/dist/es2019/plugins/block-type/commands/block-type.js +11 -13
- package/dist/es2019/plugins/block-type/commands/transform-to-code-block.js +1 -2
- package/dist/es2019/plugins/block-type/index.js +21 -12
- package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +18 -18
- package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +8 -9
- package/dist/es2019/plugins/block-type/pm-plugins/main.js +9 -9
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -2
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +2 -3
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +21 -2
- package/dist/es2019/plugins/block-type/utils.js +70 -1
- package/dist/es2019/plugins/caption/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/emoji/commands/insert-emoji.js +5 -5
- package/dist/es2019/plugins/emoji/index.js +6 -3
- package/dist/es2019/plugins/emoji/pm-plugins/ascii-input-rules.js +14 -11
- package/dist/es2019/plugins/extension/pm-plugins/main.js +50 -0
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +1 -1
- package/dist/es2019/plugins/media/utils/media-common.js +1 -1
- package/dist/es2019/plugins/selection/pm-plugins/events/keydown.js +60 -24
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -1
- package/dist/es2019/plugins/undo-redo/pm-plugins/keymaps.js +1 -1
- package/dist/es2019/ui/styles.js +0 -16
- package/dist/es2019/utils/index.js +0 -80
- package/dist/es2019/utils/input-rules.js +4 -61
- package/dist/es2019/utils/mark.js +0 -33
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/commands/index.js +7 -125
- package/dist/esm/plugins/base/index.js +1 -1
- package/dist/esm/plugins/block-type/commands/block-type.js +11 -13
- package/dist/esm/plugins/block-type/commands/transform-to-code-block.js +1 -2
- package/dist/esm/plugins/block-type/index.js +15 -12
- package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +18 -18
- package/dist/esm/plugins/block-type/pm-plugins/keymap.js +8 -9
- package/dist/esm/plugins/block-type/pm-plugins/main.js +9 -9
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -2
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +2 -3
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +8 -4
- package/dist/esm/plugins/block-type/utils.js +69 -1
- package/dist/esm/plugins/caption/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/emoji/commands/insert-emoji.js +29 -27
- package/dist/esm/plugins/emoji/index.js +4 -3
- package/dist/esm/plugins/emoji/pm-plugins/ascii-input-rules.js +23 -18
- package/dist/esm/plugins/extension/pm-plugins/main.js +45 -0
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +1 -1
- package/dist/esm/plugins/media/utils/media-common.js +1 -1
- package/dist/esm/plugins/selection/pm-plugins/events/keydown.js +62 -25
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -1
- package/dist/esm/plugins/undo-redo/pm-plugins/keymaps.js +1 -1
- package/dist/esm/ui/styles.js +3 -6
- package/dist/esm/utils/index.js +3 -77
- package/dist/esm/utils/input-rules.js +4 -61
- package/dist/esm/utils/mark.js +0 -35
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/commands/index.d.ts +0 -6
- package/dist/types/plugins/block-type/commands/block-type.d.ts +5 -6
- package/dist/types/plugins/block-type/commands/delete-and-move-cursor.d.ts +1 -1
- package/dist/types/plugins/block-type/commands/delete-block-content.d.ts +1 -1
- package/dist/types/plugins/block-type/index.d.ts +1 -1
- package/dist/types/plugins/block-type/pm-plugins/input-rule.d.ts +3 -2
- package/dist/types/plugins/block-type/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/plugins/block-type/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/block-type/styles.d.ts +1 -1
- package/dist/types/plugins/block-type/types.d.ts +2 -3
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +1 -2
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/index.d.ts +2 -2
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +5 -1
- package/dist/types/plugins/block-type/utils.d.ts +15 -1
- package/dist/types/plugins/emoji/commands/insert-emoji.d.ts +2 -2
- package/dist/types/plugins/emoji/pm-plugins/ascii-input-rules.d.ts +3 -2
- package/dist/types/plugins/extension/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +1 -0
- package/dist/types/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/ui/styles.d.ts +0 -3
- package/dist/types/utils/index.d.ts +0 -6
- package/dist/types/utils/input-rules.d.ts +4 -16
- package/dist/types/utils/mark.d.ts +0 -1
- package/dist/types-ts4.5/commands/index.d.ts +0 -6
- package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +5 -6
- package/dist/types-ts4.5/plugins/block-type/commands/delete-and-move-cursor.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/commands/delete-block-content.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/input-rule.d.ts +3 -2
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/plugins/block-type/styles.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/types.d.ts +2 -3
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +1 -2
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +5 -1
- package/dist/types-ts4.5/plugins/block-type/utils.d.ts +15 -1
- package/dist/types-ts4.5/plugins/emoji/commands/insert-emoji.d.ts +2 -2
- package/dist/types-ts4.5/plugins/emoji/pm-plugins/ascii-input-rules.d.ts +3 -2
- package/dist/types-ts4.5/plugins/extension/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/styles.d.ts +0 -3
- package/dist/types-ts4.5/utils/index.d.ts +0 -6
- package/dist/types-ts4.5/utils/input-rules.d.ts +4 -16
- package/dist/types-ts4.5/utils/mark.d.ts +0 -1
- package/package.json +4 -4
- package/report.api.md +6 -16
- package/tmp/api-report-tmp.d.ts +5 -16
- package/dist/cjs/types/allowed-block-types.js +0 -5
- package/dist/cjs/utils/keymap.js +0 -38
- package/dist/es2019/types/allowed-block-types.js +0 -1
- package/dist/es2019/utils/keymap.js +0 -33
- package/dist/esm/types/allowed-block-types.js +0 -1
- package/dist/esm/utils/keymap.js +0 -33
- package/dist/types/types/allowed-block-types.d.ts +0 -1
- package/dist/types/utils/keymap.d.ts +0 -11
- package/dist/types-ts4.5/types/allowed-block-types.d.ts +0 -1
- package/dist/types-ts4.5/utils/keymap.d.ts +0 -11
- /package/dist/cjs/{keymaps → plugins/block-type}/consts.js +0 -0
- /package/dist/es2019/{keymaps → plugins/block-type}/consts.js +0 -0
- /package/dist/esm/{keymaps → plugins/block-type}/consts.js +0 -0
- /package/dist/types/{keymaps → plugins/block-type}/consts.d.ts +0 -0
- /package/dist/types-ts4.5/{keymaps → plugins/block-type}/consts.d.ts +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { blockquote, hardBreak, heading } from '@atlaskit/adf-schema';
|
|
4
|
+
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
5
|
+
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
6
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
|
+
import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
|
|
8
|
+
import * as keymaps from '@atlaskit/editor-common/keymaps';
|
|
4
9
|
import { createPlugin, pluginKey } from './pm-plugins/main';
|
|
5
10
|
import keymapPlugin from './pm-plugins/keymap';
|
|
6
11
|
import inputRulePlugin from './pm-plugins/input-rule';
|
|
7
12
|
import ToolbarBlockType from './ui/ToolbarBlockType';
|
|
8
|
-
import WithPluginState from '../../ui/WithPluginState';
|
|
9
13
|
import { setBlockTypeWithAnalytics } from './commands';
|
|
10
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
11
|
-
import * as keymaps from '../../keymaps';
|
|
12
|
-
import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
|
|
13
14
|
import { messages } from './messages';
|
|
14
|
-
import { ToolbarSize } from '../../ui/Toolbar/types';
|
|
15
15
|
var headingPluginOptions = function headingPluginOptions(_ref, isAllowed, editorAnalyticsApi) {
|
|
16
16
|
var formatMessage = _ref.formatMessage;
|
|
17
17
|
if (!isAllowed) {
|
|
@@ -110,15 +110,17 @@ var blockTypePlugin = function blockTypePlugin(options, api) {
|
|
|
110
110
|
return [{
|
|
111
111
|
name: 'blockType',
|
|
112
112
|
plugin: function plugin(_ref3) {
|
|
113
|
+
var _api$dependencies$ana;
|
|
113
114
|
var dispatch = _ref3.dispatch;
|
|
114
|
-
return createPlugin(dispatch, options && options.lastNodeMustBeParagraph);
|
|
115
|
+
return createPlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions, dispatch, options && options.lastNodeMustBeParagraph);
|
|
115
116
|
}
|
|
116
117
|
}, {
|
|
117
118
|
name: 'blockTypeInputRule',
|
|
118
119
|
plugin: function plugin(_ref4) {
|
|
120
|
+
var _api$dependencies$ana2;
|
|
119
121
|
var schema = _ref4.schema,
|
|
120
122
|
featureFlags = _ref4.featureFlags;
|
|
121
|
-
return inputRulePlugin(schema, featureFlags);
|
|
123
|
+
return inputRulePlugin(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, schema, featureFlags);
|
|
122
124
|
}
|
|
123
125
|
},
|
|
124
126
|
// Needs to be lower priority than editor-tables.tableEditing
|
|
@@ -126,10 +128,10 @@ var blockTypePlugin = function blockTypePlugin(options, api) {
|
|
|
126
128
|
{
|
|
127
129
|
name: 'blockTypeKeyMap',
|
|
128
130
|
plugin: function plugin(_ref5) {
|
|
129
|
-
var _api$dependencies$
|
|
131
|
+
var _api$dependencies$ana3;
|
|
130
132
|
var schema = _ref5.schema,
|
|
131
133
|
featureFlags = _ref5.featureFlags;
|
|
132
|
-
return keymapPlugin(
|
|
134
|
+
return keymapPlugin(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, schema, featureFlags);
|
|
133
135
|
}
|
|
134
136
|
}];
|
|
135
137
|
},
|
|
@@ -144,7 +146,8 @@ var blockTypePlugin = function blockTypePlugin(options, api) {
|
|
|
144
146
|
eventDispatcher = _ref6.eventDispatcher;
|
|
145
147
|
var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < ToolbarSize.XXL : toolbarSize < ToolbarSize.XL;
|
|
146
148
|
var boundSetBlockType = function boundSetBlockType(name) {
|
|
147
|
-
|
|
149
|
+
var _api$dependencies$ana4;
|
|
150
|
+
return setBlockTypeWithAnalytics(name, INPUT_METHOD.TOOLBAR, 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)(editorView.state, editorView.dispatch);
|
|
148
151
|
};
|
|
149
152
|
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
150
153
|
editorView: editorView,
|
|
@@ -169,9 +172,9 @@ var blockTypePlugin = function blockTypePlugin(options, api) {
|
|
|
169
172
|
},
|
|
170
173
|
pluginsOptions: {
|
|
171
174
|
quickInsert: function quickInsert(intl) {
|
|
172
|
-
var _api$dependencies$
|
|
175
|
+
var _api$dependencies$ana5, _api$dependencies$ana6;
|
|
173
176
|
var exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
|
|
174
|
-
return [].concat(_toConsumableArray(blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
177
|
+
return [].concat(_toConsumableArray(blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, 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)), _toConsumableArray(headingPluginOptions(intl, exclude.indexOf('heading') === -1, 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)));
|
|
175
178
|
}
|
|
176
179
|
}
|
|
177
180
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import { createJoinNodesRule, createWrappingTextBlockRule, ruleWithAnalytics } from '../../../utils/input-rules';
|
|
3
|
-
import { createRule, createPlugin } from '@atlaskit/prosemirror-input-rules';
|
|
4
|
-
import { leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
5
|
-
import { isConvertableToCodeBlock, transformToCodeBlockAction } from '../commands/transform-to-code-block';
|
|
6
|
-
import { insertBlock } from '../commands/insert-block';
|
|
7
2
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
import { createRule, createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
8
4
|
import { INPUT_METHOD, ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import { inputRuleWithAnalytics } from '@atlaskit/editor-common/utils';
|
|
6
|
+
import { isConvertableToCodeBlock, transformToCodeBlockAction } from '../commands/transform-to-code-block';
|
|
7
|
+
import { insertBlock } from '../commands/insert-block';
|
|
8
|
+
import { createJoinNodesRule, createWrappingTextBlockRule } from '../utils';
|
|
9
9
|
var MAX_HEADING_LEVEL = 6;
|
|
10
10
|
function getHeadingLevel(match) {
|
|
11
11
|
return {
|
|
@@ -29,7 +29,7 @@ function blockQuoteRule(nodeType) {
|
|
|
29
29
|
* @param {Schema} schema
|
|
30
30
|
* @returns {InputRuleWithHandler[]}
|
|
31
31
|
*/
|
|
32
|
-
function getHeadingRules(schema) {
|
|
32
|
+
function getHeadingRules(editorAnalyticsAPI, schema) {
|
|
33
33
|
// '# ' for h1, '## ' for h2 and etc
|
|
34
34
|
var hashRule = headingRule(schema.nodes.heading, MAX_HEADING_LEVEL);
|
|
35
35
|
var leftNodeReplacementHashRule = createRule(new RegExp("".concat(leafNodeReplacementCharacter, "(#{1,6})\\s$")), function (state, match, start, end) {
|
|
@@ -40,7 +40,7 @@ function getHeadingRules(schema) {
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
// New analytics handler
|
|
43
|
-
var ruleWithHeadingAnalytics =
|
|
43
|
+
var ruleWithHeadingAnalytics = inputRuleWithAnalytics(function (_state, matchResult) {
|
|
44
44
|
return {
|
|
45
45
|
action: ACTION.FORMATTED,
|
|
46
46
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
@@ -51,7 +51,7 @@ function getHeadingRules(schema) {
|
|
|
51
51
|
newHeadingLevel: getHeadingLevel(matchResult).level
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
-
});
|
|
54
|
+
}, editorAnalyticsAPI);
|
|
55
55
|
return [ruleWithHeadingAnalytics(hashRule), ruleWithHeadingAnalytics(leftNodeReplacementHashRule)];
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -61,7 +61,7 @@ function getHeadingRules(schema) {
|
|
|
61
61
|
* @param {Schema} schema
|
|
62
62
|
* @returns {InputRuleWithHandler[]}
|
|
63
63
|
*/
|
|
64
|
-
function getBlockQuoteRules(schema) {
|
|
64
|
+
function getBlockQuoteRules(editorAnalyticsAPI, schema) {
|
|
65
65
|
// '> ' for blockquote
|
|
66
66
|
var greatherThanRule = blockQuoteRule(schema.nodes.blockquote);
|
|
67
67
|
var leftNodeReplacementGreatherRule = createRule(new RegExp("".concat(leafNodeReplacementCharacter, "\\s*>\\s$")), function (state, _match, start, end) {
|
|
@@ -69,7 +69,7 @@ function getBlockQuoteRules(schema) {
|
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
// Analytics V3 handler
|
|
72
|
-
var ruleWithBlockQuoteAnalytics =
|
|
72
|
+
var ruleWithBlockQuoteAnalytics = inputRuleWithAnalytics({
|
|
73
73
|
action: ACTION.FORMATTED,
|
|
74
74
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
75
75
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -77,7 +77,7 @@ function getBlockQuoteRules(schema) {
|
|
|
77
77
|
attributes: {
|
|
78
78
|
inputMethod: INPUT_METHOD.FORMATTING
|
|
79
79
|
}
|
|
80
|
-
});
|
|
80
|
+
}, editorAnalyticsAPI);
|
|
81
81
|
return [ruleWithBlockQuoteAnalytics(greatherThanRule), ruleWithBlockQuoteAnalytics(leftNodeReplacementGreatherRule)];
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -87,8 +87,8 @@ function getBlockQuoteRules(schema) {
|
|
|
87
87
|
* @param {Schema} schema
|
|
88
88
|
* @returns {InputRuleWithHandler[]}
|
|
89
89
|
*/
|
|
90
|
-
function getCodeBlockRules(schema) {
|
|
91
|
-
var ruleAnalytics =
|
|
90
|
+
function getCodeBlockRules(editorAnalyticsAPI, schema) {
|
|
91
|
+
var ruleAnalytics = inputRuleWithAnalytics({
|
|
92
92
|
action: ACTION.INSERTED,
|
|
93
93
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
94
94
|
actionSubjectId: ACTION_SUBJECT_ID.CODE_BLOCK,
|
|
@@ -96,7 +96,7 @@ function getCodeBlockRules(schema) {
|
|
|
96
96
|
inputMethod: INPUT_METHOD.FORMATTING
|
|
97
97
|
},
|
|
98
98
|
eventType: EVENT_TYPE.TRACK
|
|
99
|
-
});
|
|
99
|
+
}, editorAnalyticsAPI);
|
|
100
100
|
var validMatchLength = function validMatchLength(match) {
|
|
101
101
|
return match.length > 0 && match[0].length === 3;
|
|
102
102
|
};
|
|
@@ -130,16 +130,16 @@ function getCodeBlockRules(schema) {
|
|
|
130
130
|
});
|
|
131
131
|
return [ruleAnalytics(threeTildeRule), ruleAnalytics(leftNodeReplacementThreeTildeRule)];
|
|
132
132
|
}
|
|
133
|
-
function inputRulePlugin(schema, featureFlags) {
|
|
133
|
+
function inputRulePlugin(editorAnalyticsAPI, schema, featureFlags) {
|
|
134
134
|
var rules = [];
|
|
135
135
|
if (schema.nodes.heading) {
|
|
136
|
-
rules.push.apply(rules, _toConsumableArray(getHeadingRules(schema)));
|
|
136
|
+
rules.push.apply(rules, _toConsumableArray(getHeadingRules(editorAnalyticsAPI, schema)));
|
|
137
137
|
}
|
|
138
138
|
if (schema.nodes.blockquote) {
|
|
139
|
-
rules.push.apply(rules, _toConsumableArray(getBlockQuoteRules(schema)));
|
|
139
|
+
rules.push.apply(rules, _toConsumableArray(getBlockQuoteRules(editorAnalyticsAPI, schema)));
|
|
140
140
|
}
|
|
141
141
|
if (schema.nodes.codeBlock) {
|
|
142
|
-
rules.push.apply(rules, _toConsumableArray(getCodeBlockRules(schema)));
|
|
142
|
+
rules.push.apply(rules, _toConsumableArray(getCodeBlockRules(editorAnalyticsAPI, schema)));
|
|
143
143
|
}
|
|
144
144
|
if (rules.length !== 0) {
|
|
145
145
|
return createPlugin('block-type', rules, {
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { redo, undo } from '@atlaskit/editor-prosemirror/history';
|
|
2
2
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
3
|
-
import
|
|
4
|
-
import * as
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import * as keymaps from '@atlaskit/editor-common/keymaps';
|
|
5
|
+
import { keymap } from '@atlaskit/editor-common/keymaps';
|
|
6
|
+
import { insertNewLineWithAnalytics, createNewParagraphAbove, createNewParagraphBelow, deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
|
|
5
7
|
import * as blockTypes from '../types';
|
|
6
|
-
import { keymap } from '../../../utils/keymap';
|
|
7
8
|
import { cleanUpAtTheStartOfDocument, deleteAndMoveCursor, deleteBlockContent, insertBlockTypesWithAnalytics } from '../commands';
|
|
8
|
-
import { deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
|
|
9
|
-
import { INPUT_METHOD } from '../../analytics';
|
|
10
9
|
import { isNodeAWrappingBlockNode } from '../utils';
|
|
11
10
|
var backspace = chainCommands(cleanUpAtTheStartOfDocument, deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
|
|
12
11
|
var del = chainCommands(deleteEmptyParagraphAndMoveBlockUp(isNodeAWrappingBlockNode), deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
|
|
13
|
-
export default function keymapPlugin(
|
|
12
|
+
export default function keymapPlugin(editorAnalyticsApi, schema, _featureFlags) {
|
|
14
13
|
var list = {};
|
|
15
|
-
keymaps.bindKeymapWithCommand(keymaps.insertNewLine.common,
|
|
16
|
-
keymaps.bindKeymapWithCommand(keymaps.moveUp.common,
|
|
17
|
-
keymaps.bindKeymapWithCommand(keymaps.moveDown.common,
|
|
14
|
+
keymaps.bindKeymapWithCommand(keymaps.insertNewLine.common, insertNewLineWithAnalytics(editorAnalyticsApi), list);
|
|
15
|
+
keymaps.bindKeymapWithCommand(keymaps.moveUp.common, createNewParagraphAbove, list);
|
|
16
|
+
keymaps.bindKeymapWithCommand(keymaps.moveDown.common, createNewParagraphBelow, list);
|
|
18
17
|
keymaps.bindKeymapWithCommand(keymaps.findKeyMapForBrowser(keymaps.redo), redo, list);
|
|
19
18
|
keymaps.bindKeymapWithCommand(keymaps.undo.common, undo, list);
|
|
20
19
|
keymaps.bindKeymapWithCommand(keymaps.backspace.common, backspace, list);
|
|
@@ -4,11 +4,11 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
5
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
7
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
8
|
import { NORMAL_TEXT, HEADING_1, HEADING_2, HEADING_3, HEADING_4, HEADING_5, HEADING_6, BLOCK_QUOTE, CODE_BLOCK, PANEL, OTHER, TEXT_BLOCK_TYPES, WRAPPER_BLOCK_TYPES, HEADINGS_BY_LEVEL } from '../types';
|
|
8
|
-
import {
|
|
9
|
+
import { HEADING_KEYS } from '../consts';
|
|
9
10
|
import { setHeadingWithAnalytics, setNormalTextWithAnalytics } from '../commands';
|
|
10
|
-
import {
|
|
11
|
-
import { HEADING_KEYS } from '../../../keymaps/consts';
|
|
11
|
+
import { areBlockTypesDisabled } from '../utils';
|
|
12
12
|
var blockTypeForNode = function blockTypeForNode(node, schema) {
|
|
13
13
|
if (node.type === schema.nodes.heading) {
|
|
14
14
|
var maybeNode = HEADINGS_BY_LEVEL[node.attrs['level']];
|
|
@@ -63,16 +63,16 @@ var detectBlockType = function detectBlockType(availableBlockTypes, state) {
|
|
|
63
63
|
});
|
|
64
64
|
return blockType || OTHER;
|
|
65
65
|
};
|
|
66
|
-
var autoformatHeading = function autoformatHeading(headingLevel, view) {
|
|
66
|
+
var autoformatHeading = function autoformatHeading(headingLevel, view, editorAnalyticsApi) {
|
|
67
67
|
if (headingLevel === 0) {
|
|
68
|
-
setNormalTextWithAnalytics(INPUT_METHOD.FORMATTING)(view.state, view.dispatch);
|
|
68
|
+
setNormalTextWithAnalytics(INPUT_METHOD.FORMATTING, editorAnalyticsApi)(view.state, view.dispatch);
|
|
69
69
|
} else {
|
|
70
|
-
setHeadingWithAnalytics(headingLevel, INPUT_METHOD.FORMATTING)(view.state, view.dispatch);
|
|
70
|
+
setHeadingWithAnalytics(headingLevel, INPUT_METHOD.FORMATTING, editorAnalyticsApi)(view.state, view.dispatch);
|
|
71
71
|
}
|
|
72
72
|
return true;
|
|
73
73
|
};
|
|
74
74
|
export var pluginKey = new PluginKey('blockTypePlugin');
|
|
75
|
-
export var createPlugin = function createPlugin(dispatch, lastNodeMustBeParagraph) {
|
|
75
|
+
export var createPlugin = function createPlugin(editorAnalyticsApi, dispatch, lastNodeMustBeParagraph) {
|
|
76
76
|
var altKeyLocation = 0;
|
|
77
77
|
return new SafePlugin({
|
|
78
78
|
appendTransaction: function appendTransaction(_transactions, _oldState, newState) {
|
|
@@ -123,9 +123,9 @@ export var createPlugin = function createPlugin(dispatch, lastNodeMustBeParagrap
|
|
|
123
123
|
var headingLevel = HEADING_KEYS.indexOf(event.keyCode);
|
|
124
124
|
if (headingLevel > -1 && event.altKey) {
|
|
125
125
|
if (browser.mac && event.metaKey) {
|
|
126
|
-
return autoformatHeading(headingLevel, view);
|
|
126
|
+
return autoformatHeading(headingLevel, view, editorAnalyticsApi);
|
|
127
127
|
} else if (!browser.mac && event.ctrlKey && altKeyLocation !== event.DOM_KEY_LOCATION_RIGHT) {
|
|
128
|
-
return autoformatHeading(headingLevel, view);
|
|
128
|
+
return autoformatHeading(headingLevel, view, editorAnalyticsApi);
|
|
129
129
|
}
|
|
130
130
|
} else if (event.key === 'Alt') {
|
|
131
131
|
// event.location is for the current key only; when a user hits Ctrl-Alt-1 the
|
|
@@ -4,10 +4,10 @@ import { jsx } from '@emotion/react';
|
|
|
4
4
|
import { FormattedMessage, defineMessages } from 'react-intl-next';
|
|
5
5
|
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
6
6
|
import TextStyleIcon from '@atlaskit/icon/glyph/editor/text-style';
|
|
7
|
-
import ToolbarButton from '../../../../ui/ToolbarButton';
|
|
8
|
-
import { buttonContentStyle, buttonContentReducedSpacingStyle, wrapperSmallStyle, expandIconWrapperStyle } from '../../../../ui/styles';
|
|
9
7
|
import { wrapperStyle } from '@atlaskit/editor-common/styles';
|
|
8
|
+
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
10
9
|
import { NORMAL_TEXT } from '../../types';
|
|
10
|
+
import { buttonContentStyle, buttonContentReducedSpacingStyle, wrapperSmallStyle, expandIconWrapperStyle } from './styled';
|
|
11
11
|
export var messages = defineMessages({
|
|
12
12
|
textStyles: {
|
|
13
13
|
id: 'fabric.editor.textStyles',
|
|
@@ -14,12 +14,11 @@ import React from 'react';
|
|
|
14
14
|
import { jsx } from '@emotion/react';
|
|
15
15
|
import { injectIntl } from 'react-intl-next';
|
|
16
16
|
import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
|
|
17
|
-
import {
|
|
17
|
+
import { getAriaKeyshortcuts, tooltip, findKeymapByDescription } from '@atlaskit/editor-common/keymaps';
|
|
18
18
|
import { separatorStyles, wrapperStyle } from '@atlaskit/editor-common/styles';
|
|
19
|
+
import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
19
20
|
import { blockTypeMenuItemStyle, keyboardShortcut, keyboardShortcutSelect } from './styled';
|
|
20
|
-
import { tooltip, findKeymapByDescription } from '../../../../keymaps';
|
|
21
21
|
import { BlockTypeButton } from './blocktype-button';
|
|
22
|
-
import { getAriaKeyshortcuts } from '@atlaskit/editor-common/keymaps';
|
|
23
22
|
var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
24
23
|
_inherits(ToolbarBlockType, _React$PureComponent);
|
|
25
24
|
var _super = _createSuper(ToolbarBlockType);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { css } from '@emotion/react';
|
|
5
5
|
import { N400 } from '@atlaskit/theme/colors';
|
|
6
6
|
import { headingsSharedStyles } from '@atlaskit/editor-common/styles';
|
|
7
|
-
import { shortcutStyle } from '
|
|
7
|
+
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
8
8
|
export var blockTypeMenuItemStyle = function blockTypeMenuItemStyle(tagName, selected) {
|
|
9
9
|
// TEMP FIX: See https://product-fabric.atlassian.net/browse/ED-13878
|
|
10
10
|
var selectedStyle = selected ? "".concat(tagName, " { color: ", "var(--ds-text, white)", " !important; }") : '';
|
|
@@ -12,5 +12,9 @@ export var blockTypeMenuItemStyle = function blockTypeMenuItemStyle(tagName, sel
|
|
|
12
12
|
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", ";\n > {\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-top: 0;\n }\n }\n ", ";\n "])), headingsSharedStyles(themeProps), selectedStyle);
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
export var keyboardShortcut = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n margin-left:
|
|
16
|
-
export var keyboardShortcutSelect = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: ", ";\n"])), "var(--ds-icon, ".concat(N400, ")"));
|
|
15
|
+
export var keyboardShortcut = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n margin-left: ", ";\n"])), shortcutStyle, "var(--ds-space-200, 16px)");
|
|
16
|
+
export var keyboardShortcutSelect = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: ", ";\n"])), "var(--ds-icon, ".concat(N400, ")"));
|
|
17
|
+
export var buttonContentStyle = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n min-width: 80px;\n align-items: center;\n overflow: hidden;\n justify-content: center;\n flex-direction: column;\n padding: ", ";\n"])), "var(--ds-space-075, 6px)");
|
|
18
|
+
export var buttonContentReducedSpacingStyle = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n padding: ", ";\n"])), "var(--ds-space-100, 8px)");
|
|
19
|
+
export var wrapperSmallStyle = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n margin-left: ", ";\n min-width: 40px;\n"])), "var(--ds-space-050, 4px)");
|
|
20
|
+
export var expandIconWrapperStyle = css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n margin-left: -8px;\n"])));
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createRule } from '@atlaskit/prosemirror-input-rules';
|
|
2
|
+
import { createWrappingJoinRule } from '@atlaskit/editor-common/utils';
|
|
1
3
|
import { WRAPPER_BLOCK_TYPES } from './types';
|
|
2
4
|
export var isNodeAWrappingBlockNode = function isNodeAWrappingBlockNode(node) {
|
|
3
5
|
if (!node) {
|
|
@@ -6,4 +8,70 @@ export var isNodeAWrappingBlockNode = function isNodeAWrappingBlockNode(node) {
|
|
|
6
8
|
return WRAPPER_BLOCK_TYPES.some(function (blockNode) {
|
|
7
9
|
return blockNode.name === node.type.name;
|
|
8
10
|
});
|
|
9
|
-
};
|
|
11
|
+
};
|
|
12
|
+
export var createJoinNodesRule = function createJoinNodesRule(match, nodeType) {
|
|
13
|
+
return createWrappingJoinRule({
|
|
14
|
+
nodeType: nodeType,
|
|
15
|
+
match: match,
|
|
16
|
+
getAttrs: {},
|
|
17
|
+
joinPredicate: function joinPredicate(_, node) {
|
|
18
|
+
return node.type === nodeType;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export var createWrappingTextBlockRule = function createWrappingTextBlockRule(_ref) {
|
|
23
|
+
var match = _ref.match,
|
|
24
|
+
nodeType = _ref.nodeType,
|
|
25
|
+
getAttrs = _ref.getAttrs;
|
|
26
|
+
var handler = function handler(state, match, start, end) {
|
|
27
|
+
var fixedStart = Math.max(start, 1);
|
|
28
|
+
var $start = state.doc.resolve(fixedStart);
|
|
29
|
+
var attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
|
|
30
|
+
var nodeBefore = $start.node(-1);
|
|
31
|
+
if (nodeBefore && !nodeBefore.canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType)) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return state.tr.delete(fixedStart, end).setBlockType(fixedStart, fixedStart, nodeType, attrs);
|
|
35
|
+
};
|
|
36
|
+
return createRule(match, handler);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Function will create a list of wrapper blocks present in a selection.
|
|
41
|
+
*/
|
|
42
|
+
function getSelectedWrapperNodes(state) {
|
|
43
|
+
var nodes = [];
|
|
44
|
+
if (state.selection) {
|
|
45
|
+
var _state$selection = state.selection,
|
|
46
|
+
$from = _state$selection.$from,
|
|
47
|
+
$to = _state$selection.$to;
|
|
48
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
49
|
+
blockquote = _state$schema$nodes.blockquote,
|
|
50
|
+
panel = _state$schema$nodes.panel,
|
|
51
|
+
orderedList = _state$schema$nodes.orderedList,
|
|
52
|
+
bulletList = _state$schema$nodes.bulletList,
|
|
53
|
+
listItem = _state$schema$nodes.listItem,
|
|
54
|
+
codeBlock = _state$schema$nodes.codeBlock,
|
|
55
|
+
decisionItem = _state$schema$nodes.decisionItem,
|
|
56
|
+
decisionList = _state$schema$nodes.decisionList,
|
|
57
|
+
taskItem = _state$schema$nodes.taskItem,
|
|
58
|
+
taskList = _state$schema$nodes.taskList;
|
|
59
|
+
state.doc.nodesBetween($from.pos, $to.pos, function (node) {
|
|
60
|
+
if (node.isBlock && [blockquote, panel, orderedList, bulletList, listItem, codeBlock, decisionItem, decisionList, taskItem, taskList].indexOf(node.type) >= 0) {
|
|
61
|
+
nodes.push(node.type);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return nodes;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Function will check if changing block types: Paragraph, Heading is enabled.
|
|
70
|
+
*/
|
|
71
|
+
export function areBlockTypesDisabled(state) {
|
|
72
|
+
var nodesTypes = getSelectedWrapperNodes(state);
|
|
73
|
+
var panel = state.schema.nodes.panel;
|
|
74
|
+
return nodesTypes.filter(function (type) {
|
|
75
|
+
return type !== panel;
|
|
76
|
+
}).length > 0;
|
|
77
|
+
}
|
|
@@ -2,7 +2,7 @@ import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
|
2
2
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import * as keymaps from '../../../keymaps';
|
|
4
4
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { createNewParagraphBelow } from '
|
|
5
|
+
import { createNewParagraphBelow } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { GapCursorSelection } from '../../selection/gap-cursor/selection';
|
|
7
7
|
export function captionKeymap() {
|
|
8
8
|
var list = {};
|
|
@@ -4,33 +4,35 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import {
|
|
8
|
-
export function insertEmoji(
|
|
9
|
-
return function (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
7
|
+
import { EVENT_TYPE, ACTION_SUBJECT_ID, ACTION_SUBJECT, ACTION } from '@atlaskit/editor-common/analytics';
|
|
8
|
+
export var insertEmoji = function insertEmoji(editorAnalyticsAPI) {
|
|
9
|
+
return function (emojiId, inputMethod) {
|
|
10
|
+
return function (state, dispatch) {
|
|
11
|
+
var emoji = state.schema.nodes.emoji;
|
|
12
|
+
if (emoji && emojiId) {
|
|
13
|
+
var node = emoji.createChecked(_objectSpread(_objectSpread({}, emojiId), {}, {
|
|
14
|
+
text: emojiId.fallback || emojiId.shortName
|
|
15
|
+
}));
|
|
16
|
+
var textNode = state.schema.text(' ');
|
|
17
|
+
if (dispatch) {
|
|
18
|
+
var fragment = Fragment.fromArray([node, textNode]);
|
|
19
|
+
var tr = safeInsert(fragment)(state.tr);
|
|
20
|
+
if (inputMethod) {
|
|
21
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
22
|
+
action: ACTION.INSERTED,
|
|
23
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
24
|
+
actionSubjectId: ACTION_SUBJECT_ID.EMOJI,
|
|
25
|
+
attributes: {
|
|
26
|
+
inputMethod: inputMethod
|
|
27
|
+
},
|
|
28
|
+
eventType: EVENT_TYPE.TRACK
|
|
29
|
+
})(tr);
|
|
30
|
+
}
|
|
31
|
+
dispatch(tr.setSelection(Selection.near(tr.doc.resolve(state.selection.$from.pos + fragment.size))));
|
|
29
32
|
}
|
|
30
|
-
|
|
33
|
+
return true;
|
|
31
34
|
}
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
return false;
|
|
35
|
+
return false;
|
|
36
|
+
};
|
|
35
37
|
};
|
|
36
|
-
}
|
|
38
|
+
};
|
|
@@ -174,10 +174,11 @@ var emojiPlugin = function emojiPlugin(options, api) {
|
|
|
174
174
|
}, {
|
|
175
175
|
name: 'emojiAsciiInputRule',
|
|
176
176
|
plugin: function plugin(_ref6) {
|
|
177
|
+
var _api$dependencies$ana8;
|
|
177
178
|
var schema = _ref6.schema,
|
|
178
179
|
providerFactory = _ref6.providerFactory,
|
|
179
180
|
featureFlags = _ref6.featureFlags;
|
|
180
|
-
return asciiInputRulePlugin(schema, providerFactory, featureFlags);
|
|
181
|
+
return asciiInputRulePlugin(schema, providerFactory, featureFlags, api === null || api === void 0 ? void 0 : (_api$dependencies$ana8 = api.dependencies.analytics) === null || _api$dependencies$ana8 === void 0 ? void 0 : _api$dependencies$ana8.actions);
|
|
181
182
|
}
|
|
182
183
|
}];
|
|
183
184
|
},
|
|
@@ -194,13 +195,13 @@ var emojiPlugin = function emojiPlugin(options, api) {
|
|
|
194
195
|
return /*#__PURE__*/React.createElement(IconEmoji, null);
|
|
195
196
|
},
|
|
196
197
|
action: function action(insert, state) {
|
|
197
|
-
var _api$dependencies$
|
|
198
|
+
var _api$dependencies$ana9;
|
|
198
199
|
var tr = insert(undefined);
|
|
199
200
|
openTypeAheadAtCursor({
|
|
200
201
|
triggerHandler: typeAhead,
|
|
201
202
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
202
203
|
})(tr);
|
|
203
|
-
api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
204
|
+
api === null || api === void 0 ? void 0 : (_api$dependencies$ana9 = api.dependencies.analytics) === null || _api$dependencies$ana9 === void 0 ? void 0 : _api$dependencies$ana9.actions.attachAnalyticsEvent({
|
|
204
205
|
action: ACTION.INVOKED,
|
|
205
206
|
actionSubject: ACTION_SUBJECT.TYPEAHEAD,
|
|
206
207
|
actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_EMOJI,
|
|
@@ -10,12 +10,12 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
10
10
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
11
11
|
import { createRule, createPlugin } from '@atlaskit/prosemirror-input-rules';
|
|
12
12
|
import { leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
13
|
-
import {
|
|
13
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
14
14
|
var matcher;
|
|
15
|
-
export function inputRulePlugin(schema, providerFactory, featureFlags) {
|
|
15
|
+
export function inputRulePlugin(schema, providerFactory, featureFlags, editorAnalyticsAPI) {
|
|
16
16
|
if (schema.nodes.emoji && providerFactory) {
|
|
17
17
|
initMatcher(providerFactory);
|
|
18
|
-
var asciiEmojiRule = createRule(AsciiEmojiMatcher.REGEX, inputRuleHandler);
|
|
18
|
+
var asciiEmojiRule = createRule(AsciiEmojiMatcher.REGEX, inputRuleHandler(editorAnalyticsAPI));
|
|
19
19
|
return createPlugin('emoji', [asciiEmojiRule]);
|
|
20
20
|
}
|
|
21
21
|
return;
|
|
@@ -33,17 +33,19 @@ function initMatcher(providerFactory) {
|
|
|
33
33
|
};
|
|
34
34
|
providerFactory.subscribe('emojiProvider', handleProvider);
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
var inputRuleHandler = function inputRuleHandler(editorAnalyticsAPI) {
|
|
37
|
+
return function (state, matchParts, start, end) {
|
|
38
|
+
if (!matcher) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
var match = matcher.match(matchParts);
|
|
42
|
+
if (match) {
|
|
43
|
+
var transactionCreator = new AsciiEmojiTransactionCreator(state, match, start, end, editorAnalyticsAPI);
|
|
44
|
+
return transactionCreator.create();
|
|
45
|
+
}
|
|
38
46
|
return null;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (match) {
|
|
42
|
-
var transactionCreator = new AsciiEmojiTransactionCreator(state, match, start, end);
|
|
43
|
-
return transactionCreator.create();
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
+
};
|
|
48
|
+
};
|
|
47
49
|
var REGEX_LEADING_CAPTURE_INDEX = 1;
|
|
48
50
|
var REGEX_EMOJI_LEADING_PARENTHESES = 2;
|
|
49
51
|
var REGEX_EMOJI_ASCII_CAPTURE_INDEX = 3;
|
|
@@ -142,18 +144,20 @@ var RecordingAsciiEmojiMatcher = /*#__PURE__*/function (_AsciiEmojiMatcher) {
|
|
|
142
144
|
return RecordingAsciiEmojiMatcher;
|
|
143
145
|
}(AsciiEmojiMatcher);
|
|
144
146
|
var AsciiEmojiTransactionCreator = /*#__PURE__*/function () {
|
|
145
|
-
function AsciiEmojiTransactionCreator(state, match, start, end) {
|
|
147
|
+
function AsciiEmojiTransactionCreator(state, match, start, end, editorAnalyticsAPI) {
|
|
146
148
|
_classCallCheck(this, AsciiEmojiTransactionCreator);
|
|
147
149
|
this.state = state;
|
|
148
150
|
this.match = match;
|
|
149
151
|
this.start = start;
|
|
150
152
|
this.end = end;
|
|
153
|
+
this.editorAnalyticsAPI = editorAnalyticsAPI;
|
|
151
154
|
}
|
|
152
155
|
_createClass(AsciiEmojiTransactionCreator, [{
|
|
153
156
|
key: "create",
|
|
154
157
|
value: function create() {
|
|
158
|
+
var _this$editorAnalytics;
|
|
155
159
|
var tr = this.state.tr.replaceWith(this.from, this.to, this.createNodes());
|
|
156
|
-
|
|
160
|
+
(_this$editorAnalytics = this.editorAnalyticsAPI) === null || _this$editorAnalytics === void 0 ? void 0 : _this$editorAnalytics.attachAnalyticsEvent({
|
|
157
161
|
action: ACTION.INSERTED,
|
|
158
162
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
159
163
|
actionSubjectId: ACTION_SUBJECT_ID.EMOJI,
|
|
@@ -161,7 +165,8 @@ var AsciiEmojiTransactionCreator = /*#__PURE__*/function () {
|
|
|
161
165
|
inputMethod: INPUT_METHOD.ASCII
|
|
162
166
|
},
|
|
163
167
|
eventType: EVENT_TYPE.TRACK
|
|
164
|
-
});
|
|
168
|
+
})(tr);
|
|
169
|
+
return tr;
|
|
165
170
|
}
|
|
166
171
|
}, {
|
|
167
172
|
key: "from",
|
|
@@ -212,8 +217,8 @@ var AsciiEmojiTransactionCreator = /*#__PURE__*/function () {
|
|
|
212
217
|
return AsciiEmojiTransactionCreator;
|
|
213
218
|
}();
|
|
214
219
|
export var stateKey = new PluginKey('asciiEmojiPlugin');
|
|
215
|
-
var plugins = function plugins(schema, providerFactory, featureFlags) {
|
|
216
|
-
return [inputRulePlugin(schema, providerFactory, featureFlags)].filter(function (plugin) {
|
|
220
|
+
var plugins = function plugins(schema, providerFactory, featureFlags, editorAnalyticsAPI) {
|
|
221
|
+
return [inputRulePlugin(schema, providerFactory, featureFlags, editorAnalyticsAPI)].filter(function (plugin) {
|
|
217
222
|
return !!plugin;
|
|
218
223
|
});
|
|
219
224
|
};
|