@atlaskit/editor-core 185.16.0 → 185.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/plugins/card/pm-plugins/doc.js +1 -1
- package/dist/cjs/plugins/text-formatting/commands/clear-formatting.js +5 -6
- package/dist/cjs/plugins/text-formatting/index.js +6 -2
- package/dist/cjs/plugins/text-formatting/pm-plugins/clear-formatting-keymap.js +2 -2
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +6 -3
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/index.js +8 -4
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/card/pm-plugins/doc.js +4 -1
- package/dist/es2019/plugins/text-formatting/commands/clear-formatting.js +5 -6
- package/dist/es2019/plugins/text-formatting/index.js +8 -3
- package/dist/es2019/plugins/text-formatting/pm-plugins/clear-formatting-keymap.js +2 -2
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +5 -4
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/index.js +8 -4
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/card/pm-plugins/doc.js +1 -1
- package/dist/esm/plugins/text-formatting/commands/clear-formatting.js +5 -6
- package/dist/esm/plugins/text-formatting/index.js +6 -2
- package/dist/esm/plugins/text-formatting/pm-plugins/clear-formatting-keymap.js +2 -2
- package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +7 -4
- package/dist/esm/plugins/text-formatting/ui/Toolbar/index.js +8 -4
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/labs/next/presets/cxhtml.d.ts +58 -0
- package/dist/types/labs/next/presets/default.d.ts +116 -0
- package/dist/types/labs/next/presets/mobile.d.ts +58 -0
- package/dist/types/plugins/text-formatting/commands/clear-formatting.d.ts +3 -3
- package/dist/types/plugins/text-formatting/index.d.ts +3 -1
- package/dist/types/plugins/text-formatting/pm-plugins/clear-formatting-keymap.d.ts +2 -1
- package/dist/types/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.d.ts +6 -1
- package/dist/types/plugins/text-formatting/ui/Toolbar/index.d.ts +2 -0
- package/dist/types-ts4.5/labs/next/presets/cxhtml.d.ts +70 -0
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +140 -0
- package/dist/types-ts4.5/labs/next/presets/mobile.d.ts +70 -0
- package/dist/types-ts4.5/plugins/text-formatting/commands/clear-formatting.d.ts +3 -3
- package/dist/types-ts4.5/plugins/text-formatting/index.d.ts +5 -1
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/clear-formatting-keymap.d.ts +2 -1
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.d.ts +6 -1
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/index.d.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 185.16.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`6e113937892`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6e113937892) - switched use of analytics plugin to new EditorAnalyticsAPI for text-formatting pluginModified file
|
|
8
|
+
|
|
9
|
+
## 185.16.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`75520758a9d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/75520758a9d) - Fix layout not persisting on edits of datasource
|
|
14
|
+
|
|
3
15
|
## 185.16.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -451,7 +451,7 @@ var updateExistingDatasource = function updateExistingDatasource(state, node, ne
|
|
|
451
451
|
var isColumnChange = !(0, _isEqual.default)(oldColumnKeys, newColumnKeys);
|
|
452
452
|
var isUrlChange = ((_newAdf$attrs = newAdf.attrs) === null || _newAdf$attrs === void 0 ? void 0 : _newAdf$attrs.url) !== ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.url);
|
|
453
453
|
if (isColumnChange || isUrlChange) {
|
|
454
|
-
tr.setNodeMarkup(from, schemaNodes.blockCard, newAdf.attrs);
|
|
454
|
+
tr.setNodeMarkup(from, schemaNodes.blockCard, _objectSpread(_objectSpread({}, node.attrs), newAdf.attrs));
|
|
455
455
|
}
|
|
456
456
|
} else if (newAdf.type === 'inlineCard') {
|
|
457
457
|
// datasource to inline
|
|
@@ -10,7 +10,6 @@ var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
|
10
10
|
var _prosemirrorTransform = require("prosemirror-transform");
|
|
11
11
|
var _cellSelection2 = require("../../../utils/cell-selection");
|
|
12
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
-
var _analytics2 = require("../../analytics");
|
|
14
13
|
var FORMATTING_NODE_TYPES = ['heading', 'codeBlock', 'blockquote'];
|
|
15
14
|
exports.FORMATTING_NODE_TYPES = FORMATTING_NODE_TYPES;
|
|
16
15
|
var FORMATTING_MARK_TYPES = ['em', 'code', 'strike', 'strong', 'underline', 'textColor', 'subsup'];
|
|
@@ -24,8 +23,8 @@ var formatTypes = {
|
|
|
24
23
|
textColor: _analytics.ACTION_SUBJECT_ID.FORMAT_COLOR,
|
|
25
24
|
subsup: 'subsup'
|
|
26
25
|
};
|
|
27
|
-
function clearFormattingWithAnalytics(inputMethod) {
|
|
28
|
-
return clearFormatting(inputMethod);
|
|
26
|
+
function clearFormattingWithAnalytics(inputMethod, editorAnalyticsAPI) {
|
|
27
|
+
return clearFormatting(inputMethod, editorAnalyticsAPI);
|
|
29
28
|
}
|
|
30
29
|
function clearNodeFormattingOnSelection(state, tr, formattedNodeType, nodeName, formattingCleared) {
|
|
31
30
|
return function (node, pos) {
|
|
@@ -51,7 +50,7 @@ function clearNodeFormattingOnSelection(state, tr, formattedNodeType, nodeName,
|
|
|
51
50
|
return true;
|
|
52
51
|
};
|
|
53
52
|
}
|
|
54
|
-
function clearFormatting(inputMethod) {
|
|
53
|
+
function clearFormatting(inputMethod, editorAnalyticsAPI) {
|
|
55
54
|
return function (state, dispatch) {
|
|
56
55
|
var tr = state.tr;
|
|
57
56
|
var formattingCleared = [];
|
|
@@ -93,7 +92,7 @@ function clearFormatting(inputMethod) {
|
|
|
93
92
|
});
|
|
94
93
|
tr.setStoredMarks([]);
|
|
95
94
|
if (formattingCleared.length && inputMethod) {
|
|
96
|
-
|
|
95
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
97
96
|
action: _analytics.ACTION.FORMATTED,
|
|
98
97
|
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
99
98
|
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
@@ -102,7 +101,7 @@ function clearFormatting(inputMethod) {
|
|
|
102
101
|
inputMethod: inputMethod,
|
|
103
102
|
formattingCleared: formattingCleared
|
|
104
103
|
}
|
|
105
|
-
});
|
|
104
|
+
})(tr);
|
|
106
105
|
}
|
|
107
106
|
if (dispatch) {
|
|
108
107
|
dispatch(tr);
|
|
@@ -18,6 +18,7 @@ var _smartInputRule = _interopRequireDefault(require("./pm-plugins/smart-input-r
|
|
|
18
18
|
var _Toolbar = _interopRequireDefault(require("./ui/Toolbar"));
|
|
19
19
|
var textFormatting = function textFormatting() {
|
|
20
20
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
21
|
+
var api = arguments.length > 1 ? arguments[1] : undefined;
|
|
21
22
|
return {
|
|
22
23
|
name: 'textFormatting',
|
|
23
24
|
marks: function marks() {
|
|
@@ -75,7 +76,8 @@ var textFormatting = function textFormatting() {
|
|
|
75
76
|
}, {
|
|
76
77
|
name: 'textFormattingClearKeymap',
|
|
77
78
|
plugin: function plugin() {
|
|
78
|
-
|
|
79
|
+
var _api$dependencies$ana;
|
|
80
|
+
return (0, _clearFormattingKeymap.default)(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);
|
|
79
81
|
}
|
|
80
82
|
}, {
|
|
81
83
|
name: 'textFormattingKeymap',
|
|
@@ -98,6 +100,7 @@ var textFormatting = function textFormatting() {
|
|
|
98
100
|
clearFormattingPluginState: _clearFormatting.pluginKey
|
|
99
101
|
},
|
|
100
102
|
render: function render() {
|
|
103
|
+
var _api$dependencies$ana2;
|
|
101
104
|
return /*#__PURE__*/_react.default.createElement(_Toolbar.default, {
|
|
102
105
|
editorState: editorView.state,
|
|
103
106
|
popupsMountPoint: popupsMountPoint,
|
|
@@ -106,7 +109,8 @@ var textFormatting = function textFormatting() {
|
|
|
106
109
|
isReducedSpacing: isToolbarReducedSpacing,
|
|
107
110
|
editorView: editorView,
|
|
108
111
|
isToolbarDisabled: disabled,
|
|
109
|
-
shouldUseResponsiveToolbar: Boolean(options.responsiveToolbarMenu)
|
|
112
|
+
shouldUseResponsiveToolbar: Boolean(options.responsiveToolbarMenu),
|
|
113
|
+
editorAnalyticsAPI: 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
|
|
110
114
|
});
|
|
111
115
|
}
|
|
112
116
|
});
|
|
@@ -12,9 +12,9 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
12
12
|
var _clearFormatting = require("../commands/clear-formatting");
|
|
13
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
-
function keymapPlugin() {
|
|
15
|
+
function keymapPlugin(editorAnalyticsAPI) {
|
|
16
16
|
var list = {};
|
|
17
|
-
keymaps.bindKeymapWithCommand(keymaps.clearFormatting.common, (0, _clearFormatting.clearFormattingWithAnalytics)(_analytics.INPUT_METHOD.SHORTCUT), list);
|
|
17
|
+
keymaps.bindKeymapWithCommand(keymaps.clearFormatting.common, (0, _clearFormatting.clearFormattingWithAnalytics)(_analytics.INPUT_METHOD.SHORTCUT, editorAnalyticsAPI), list);
|
|
18
18
|
return (0, _prosemirrorKeymap.keymap)(list);
|
|
19
19
|
}
|
|
20
20
|
var _default = keymapPlugin;
|
|
@@ -14,7 +14,6 @@ var _keymaps = require("../../../../../keymaps");
|
|
|
14
14
|
var _enums = require("../../../../analytics/types/enums");
|
|
15
15
|
/** @jsx jsx */
|
|
16
16
|
|
|
17
|
-
var clearFormattingToolbar = (0, _clearFormatting.clearFormattingWithAnalytics)(_enums.INPUT_METHOD.TOOLBAR);
|
|
18
17
|
var useClearFormattingPluginState = function useClearFormattingPluginState(editorState) {
|
|
19
18
|
return (0, _react.useMemo)(function () {
|
|
20
19
|
return _clearFormatting2.pluginKey.getState(editorState);
|
|
@@ -22,11 +21,15 @@ var useClearFormattingPluginState = function useClearFormattingPluginState(edito
|
|
|
22
21
|
};
|
|
23
22
|
var useClearIcon = function useClearIcon(_ref) {
|
|
24
23
|
var intl = _ref.intl,
|
|
25
|
-
editorState = _ref.editorState
|
|
24
|
+
editorState = _ref.editorState,
|
|
25
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI;
|
|
26
26
|
var pluginState = useClearFormattingPluginState(editorState);
|
|
27
27
|
var isPluginAvailable = Boolean(pluginState);
|
|
28
28
|
var formattingIsPresent = Boolean(pluginState === null || pluginState === void 0 ? void 0 : pluginState.formattingIsPresent);
|
|
29
29
|
var clearFormattingLabel = intl.formatMessage(_toolbarMessages.toolbarMessages.clearFormatting);
|
|
30
|
+
var clearFormattingToolbar = (0, _react.useCallback)(function (state, dispatch) {
|
|
31
|
+
return (0, _clearFormatting.clearFormattingWithAnalytics)(_enums.INPUT_METHOD.TOOLBAR, editorAnalyticsAPI)(state, dispatch);
|
|
32
|
+
}, [editorAnalyticsAPI]);
|
|
30
33
|
return (0, _react.useMemo)(function () {
|
|
31
34
|
if (!isPluginAvailable) {
|
|
32
35
|
return null;
|
|
@@ -45,6 +48,6 @@ var useClearIcon = function useClearIcon(_ref) {
|
|
|
45
48
|
isDisabled: !formattingIsPresent,
|
|
46
49
|
'aria-label': _keymaps.clearFormatting ? (0, _keymaps.tooltip)(_keymaps.clearFormatting, String(clearFormattingLabel)) : String(clearFormattingLabel)
|
|
47
50
|
};
|
|
48
|
-
}, [
|
|
51
|
+
}, [isPluginAvailable, clearFormattingToolbar, clearFormattingLabel, formattingIsPresent]);
|
|
49
52
|
};
|
|
50
53
|
exports.useClearIcon = useClearIcon;
|
|
@@ -41,7 +41,8 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
|
|
|
41
41
|
toolbarSize = _ref.toolbarSize,
|
|
42
42
|
isReducedSpacing = _ref.isReducedSpacing,
|
|
43
43
|
isToolbarDisabled = _ref.isToolbarDisabled,
|
|
44
|
-
intl = _ref.intl
|
|
44
|
+
intl = _ref.intl,
|
|
45
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI;
|
|
45
46
|
var editorState = (0, _react.useMemo)(function () {
|
|
46
47
|
return editorView.state;
|
|
47
48
|
}, [editorView.state]);
|
|
@@ -56,7 +57,8 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
|
|
|
56
57
|
});
|
|
57
58
|
var clearIcon = (0, _clearFormattingIcon.useClearIcon)({
|
|
58
59
|
editorState: editorState,
|
|
59
|
-
intl: intl
|
|
60
|
+
intl: intl,
|
|
61
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
60
62
|
});
|
|
61
63
|
var menuIconTypeList = (0, _responsiveToolbarButtons.useResponsiveIconTypeMenu)({
|
|
62
64
|
toolbarSize: toolbarSize,
|
|
@@ -177,7 +179,8 @@ var Toolbar = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
177
179
|
editorView = _this$props.editorView,
|
|
178
180
|
isToolbarDisabled = _this$props.isToolbarDisabled,
|
|
179
181
|
shouldUseResponsiveToolbar = _this$props.shouldUseResponsiveToolbar,
|
|
180
|
-
intl = _this$props.intl
|
|
182
|
+
intl = _this$props.intl,
|
|
183
|
+
editorAnalyticsAPI = _this$props.editorAnalyticsAPI;
|
|
181
184
|
return (0, _react2.jsx)(ToolbarFormatting, {
|
|
182
185
|
popupsMountPoint: popupsMountPoint,
|
|
183
186
|
popupsScrollableElement: popupsScrollableElement,
|
|
@@ -186,7 +189,8 @@ var Toolbar = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
186
189
|
editorView: editorView,
|
|
187
190
|
isToolbarDisabled: isToolbarDisabled,
|
|
188
191
|
shouldUseResponsiveToolbar: shouldUseResponsiveToolbar,
|
|
189
|
-
intl: intl
|
|
192
|
+
intl: intl,
|
|
193
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
190
194
|
});
|
|
191
195
|
}
|
|
192
196
|
}]);
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/editor-core";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "185.16.
|
|
9
|
+
var version = "185.16.3";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
package/dist/cjs/version.json
CHANGED
|
@@ -415,7 +415,10 @@ export const updateExistingDatasource = (state, node, newAdf, view) => {
|
|
|
415
415
|
const isColumnChange = !isEqual(oldColumnKeys, newColumnKeys);
|
|
416
416
|
const isUrlChange = ((_newAdf$attrs = newAdf.attrs) === null || _newAdf$attrs === void 0 ? void 0 : _newAdf$attrs.url) !== ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.url);
|
|
417
417
|
if (isColumnChange || isUrlChange) {
|
|
418
|
-
tr.setNodeMarkup(from, schemaNodes.blockCard,
|
|
418
|
+
tr.setNodeMarkup(from, schemaNodes.blockCard, {
|
|
419
|
+
...node.attrs,
|
|
420
|
+
...newAdf.attrs
|
|
421
|
+
});
|
|
419
422
|
}
|
|
420
423
|
} else if (newAdf.type === 'inlineCard') {
|
|
421
424
|
// datasource to inline
|
|
@@ -2,7 +2,6 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
2
2
|
import { liftTarget } from 'prosemirror-transform';
|
|
3
3
|
import { cellSelectionNodesBetween } from '../../../utils/cell-selection';
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
import { addAnalytics } from '../../analytics';
|
|
6
5
|
export const FORMATTING_NODE_TYPES = ['heading', 'codeBlock', 'blockquote'];
|
|
7
6
|
export const FORMATTING_MARK_TYPES = ['em', 'code', 'strike', 'strong', 'underline', 'textColor', 'subsup'];
|
|
8
7
|
const formatTypes = {
|
|
@@ -14,8 +13,8 @@ const formatTypes = {
|
|
|
14
13
|
textColor: ACTION_SUBJECT_ID.FORMAT_COLOR,
|
|
15
14
|
subsup: 'subsup'
|
|
16
15
|
};
|
|
17
|
-
export function clearFormattingWithAnalytics(inputMethod) {
|
|
18
|
-
return clearFormatting(inputMethod);
|
|
16
|
+
export function clearFormattingWithAnalytics(inputMethod, editorAnalyticsAPI) {
|
|
17
|
+
return clearFormatting(inputMethod, editorAnalyticsAPI);
|
|
19
18
|
}
|
|
20
19
|
function clearNodeFormattingOnSelection(state, tr, formattedNodeType, nodeName, formattingCleared) {
|
|
21
20
|
return function (node, pos) {
|
|
@@ -41,7 +40,7 @@ function clearNodeFormattingOnSelection(state, tr, formattedNodeType, nodeName,
|
|
|
41
40
|
return true;
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
|
-
export function clearFormatting(inputMethod) {
|
|
43
|
+
export function clearFormatting(inputMethod, editorAnalyticsAPI) {
|
|
45
44
|
return function (state, dispatch) {
|
|
46
45
|
const {
|
|
47
46
|
tr
|
|
@@ -87,7 +86,7 @@ export function clearFormatting(inputMethod) {
|
|
|
87
86
|
});
|
|
88
87
|
tr.setStoredMarks([]);
|
|
89
88
|
if (formattingCleared.length && inputMethod) {
|
|
90
|
-
|
|
89
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
91
90
|
action: ACTION.FORMATTED,
|
|
92
91
|
eventType: EVENT_TYPE.TRACK,
|
|
93
92
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
@@ -96,7 +95,7 @@ export function clearFormatting(inputMethod) {
|
|
|
96
95
|
inputMethod,
|
|
97
96
|
formattingCleared
|
|
98
97
|
}
|
|
99
|
-
});
|
|
98
|
+
})(tr);
|
|
100
99
|
}
|
|
101
100
|
if (dispatch) {
|
|
102
101
|
dispatch(tr);
|
|
@@ -9,7 +9,7 @@ import textFormattingInputRulePlugin from './pm-plugins/input-rule';
|
|
|
9
9
|
import keymapPlugin from './pm-plugins/keymap';
|
|
10
10
|
import textFormattingSmartInputRulePlugin from './pm-plugins/smart-input-rule';
|
|
11
11
|
import Toolbar from './ui/Toolbar';
|
|
12
|
-
const textFormatting = (options = {}) => ({
|
|
12
|
+
const textFormatting = (options = {}, api) => ({
|
|
13
13
|
name: 'textFormatting',
|
|
14
14
|
marks() {
|
|
15
15
|
return [{
|
|
@@ -59,7 +59,10 @@ const textFormatting = (options = {}) => ({
|
|
|
59
59
|
}) => clearFormattingPlugin(dispatch)
|
|
60
60
|
}, {
|
|
61
61
|
name: 'textFormattingClearKeymap',
|
|
62
|
-
plugin: () =>
|
|
62
|
+
plugin: () => {
|
|
63
|
+
var _api$dependencies$ana;
|
|
64
|
+
return clearFormattingKeymapPlugin(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);
|
|
65
|
+
}
|
|
63
66
|
}, {
|
|
64
67
|
name: 'textFormattingKeymap',
|
|
65
68
|
plugin: ({
|
|
@@ -81,6 +84,7 @@ const textFormatting = (options = {}) => ({
|
|
|
81
84
|
clearFormattingPluginState: clearFormattingPluginKey
|
|
82
85
|
},
|
|
83
86
|
render: () => {
|
|
87
|
+
var _api$dependencies$ana2;
|
|
84
88
|
return /*#__PURE__*/React.createElement(Toolbar, {
|
|
85
89
|
editorState: editorView.state,
|
|
86
90
|
popupsMountPoint: popupsMountPoint,
|
|
@@ -89,7 +93,8 @@ const textFormatting = (options = {}) => ({
|
|
|
89
93
|
isReducedSpacing: isToolbarReducedSpacing,
|
|
90
94
|
editorView: editorView,
|
|
91
95
|
isToolbarDisabled: disabled,
|
|
92
|
-
shouldUseResponsiveToolbar: Boolean(options.responsiveToolbarMenu)
|
|
96
|
+
shouldUseResponsiveToolbar: Boolean(options.responsiveToolbarMenu),
|
|
97
|
+
editorAnalyticsAPI: 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
|
|
93
98
|
});
|
|
94
99
|
}
|
|
95
100
|
});
|
|
@@ -2,9 +2,9 @@ import { keymap } from 'prosemirror-keymap';
|
|
|
2
2
|
import * as keymaps from '../../../keymaps';
|
|
3
3
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { clearFormattingWithAnalytics } from '../commands/clear-formatting';
|
|
5
|
-
export function keymapPlugin() {
|
|
5
|
+
export function keymapPlugin(editorAnalyticsAPI) {
|
|
6
6
|
const list = {};
|
|
7
|
-
keymaps.bindKeymapWithCommand(keymaps.clearFormatting.common, clearFormattingWithAnalytics(INPUT_METHOD.SHORTCUT), list);
|
|
7
|
+
keymaps.bindKeymapWithCommand(keymaps.clearFormatting.common, clearFormattingWithAnalytics(INPUT_METHOD.SHORTCUT, editorAnalyticsAPI), list);
|
|
8
8
|
return keymap(list);
|
|
9
9
|
}
|
|
10
10
|
export default keymapPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { useMemo } from 'react';
|
|
2
|
+
import { useCallback, useMemo } from 'react';
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
4
|
import { shortcutStyle } from '../../../../../ui/styles';
|
|
5
5
|
import { toolbarMessages } from '../toolbar-messages';
|
|
@@ -7,18 +7,19 @@ import { clearFormattingWithAnalytics } from '../../../commands/clear-formatting
|
|
|
7
7
|
import { pluginKey as clearFormattingPluginKey } from '../../../pm-plugins/clear-formatting';
|
|
8
8
|
import { clearFormatting as clearFormattingKeymap, tooltip } from '../../../../../keymaps';
|
|
9
9
|
import { INPUT_METHOD } from '../../../../analytics/types/enums';
|
|
10
|
-
const clearFormattingToolbar = clearFormattingWithAnalytics(INPUT_METHOD.TOOLBAR);
|
|
11
10
|
const useClearFormattingPluginState = editorState => {
|
|
12
11
|
return useMemo(() => clearFormattingPluginKey.getState(editorState), [editorState]);
|
|
13
12
|
};
|
|
14
13
|
export const useClearIcon = ({
|
|
15
14
|
intl,
|
|
16
|
-
editorState
|
|
15
|
+
editorState,
|
|
16
|
+
editorAnalyticsAPI
|
|
17
17
|
}) => {
|
|
18
18
|
const pluginState = useClearFormattingPluginState(editorState);
|
|
19
19
|
const isPluginAvailable = Boolean(pluginState);
|
|
20
20
|
const formattingIsPresent = Boolean(pluginState === null || pluginState === void 0 ? void 0 : pluginState.formattingIsPresent);
|
|
21
21
|
const clearFormattingLabel = intl.formatMessage(toolbarMessages.clearFormatting);
|
|
22
|
+
const clearFormattingToolbar = useCallback((state, dispatch) => clearFormattingWithAnalytics(INPUT_METHOD.TOOLBAR, editorAnalyticsAPI)(state, dispatch), [editorAnalyticsAPI]);
|
|
22
23
|
return useMemo(() => {
|
|
23
24
|
if (!isPluginAvailable) {
|
|
24
25
|
return null;
|
|
@@ -37,5 +38,5 @@ export const useClearIcon = ({
|
|
|
37
38
|
isDisabled: !formattingIsPresent,
|
|
38
39
|
'aria-label': clearFormattingKeymap ? tooltip(clearFormattingKeymap, String(clearFormattingLabel)) : String(clearFormattingLabel)
|
|
39
40
|
};
|
|
40
|
-
}, [
|
|
41
|
+
}, [isPluginAvailable, clearFormattingToolbar, clearFormattingLabel, formattingIsPresent]);
|
|
41
42
|
};
|
|
@@ -22,7 +22,8 @@ const ToolbarFormatting = ({
|
|
|
22
22
|
toolbarSize,
|
|
23
23
|
isReducedSpacing,
|
|
24
24
|
isToolbarDisabled,
|
|
25
|
-
intl
|
|
25
|
+
intl,
|
|
26
|
+
editorAnalyticsAPI
|
|
26
27
|
}) => {
|
|
27
28
|
var _usePreviousState;
|
|
28
29
|
const editorState = useMemo(() => editorView.state, [editorView.state]);
|
|
@@ -34,7 +35,8 @@ const ToolbarFormatting = ({
|
|
|
34
35
|
});
|
|
35
36
|
const clearIcon = useClearIcon({
|
|
36
37
|
editorState,
|
|
37
|
-
intl
|
|
38
|
+
intl,
|
|
39
|
+
editorAnalyticsAPI
|
|
38
40
|
});
|
|
39
41
|
const menuIconTypeList = useResponsiveIconTypeMenu({
|
|
40
42
|
toolbarSize,
|
|
@@ -146,7 +148,8 @@ class Toolbar extends React.PureComponent {
|
|
|
146
148
|
editorView,
|
|
147
149
|
isToolbarDisabled,
|
|
148
150
|
shouldUseResponsiveToolbar,
|
|
149
|
-
intl
|
|
151
|
+
intl,
|
|
152
|
+
editorAnalyticsAPI
|
|
150
153
|
} = this.props;
|
|
151
154
|
return jsx(ToolbarFormatting, {
|
|
152
155
|
popupsMountPoint: popupsMountPoint,
|
|
@@ -156,7 +159,8 @@ class Toolbar extends React.PureComponent {
|
|
|
156
159
|
editorView: editorView,
|
|
157
160
|
isToolbarDisabled: isToolbarDisabled,
|
|
158
161
|
shouldUseResponsiveToolbar: shouldUseResponsiveToolbar,
|
|
159
|
-
intl: intl
|
|
162
|
+
intl: intl,
|
|
163
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
160
164
|
});
|
|
161
165
|
}
|
|
162
166
|
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -435,7 +435,7 @@ export var updateExistingDatasource = function updateExistingDatasource(state, n
|
|
|
435
435
|
var isColumnChange = !isEqual(oldColumnKeys, newColumnKeys);
|
|
436
436
|
var isUrlChange = ((_newAdf$attrs = newAdf.attrs) === null || _newAdf$attrs === void 0 ? void 0 : _newAdf$attrs.url) !== ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.url);
|
|
437
437
|
if (isColumnChange || isUrlChange) {
|
|
438
|
-
tr.setNodeMarkup(from, schemaNodes.blockCard, newAdf.attrs);
|
|
438
|
+
tr.setNodeMarkup(from, schemaNodes.blockCard, _objectSpread(_objectSpread({}, node.attrs), newAdf.attrs));
|
|
439
439
|
}
|
|
440
440
|
} else if (newAdf.type === 'inlineCard') {
|
|
441
441
|
// datasource to inline
|
|
@@ -2,7 +2,6 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
2
2
|
import { liftTarget } from 'prosemirror-transform';
|
|
3
3
|
import { cellSelectionNodesBetween } from '../../../utils/cell-selection';
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
import { addAnalytics } from '../../analytics';
|
|
6
5
|
export var FORMATTING_NODE_TYPES = ['heading', 'codeBlock', 'blockquote'];
|
|
7
6
|
export var FORMATTING_MARK_TYPES = ['em', 'code', 'strike', 'strong', 'underline', 'textColor', 'subsup'];
|
|
8
7
|
var formatTypes = {
|
|
@@ -14,8 +13,8 @@ var formatTypes = {
|
|
|
14
13
|
textColor: ACTION_SUBJECT_ID.FORMAT_COLOR,
|
|
15
14
|
subsup: 'subsup'
|
|
16
15
|
};
|
|
17
|
-
export function clearFormattingWithAnalytics(inputMethod) {
|
|
18
|
-
return clearFormatting(inputMethod);
|
|
16
|
+
export function clearFormattingWithAnalytics(inputMethod, editorAnalyticsAPI) {
|
|
17
|
+
return clearFormatting(inputMethod, editorAnalyticsAPI);
|
|
19
18
|
}
|
|
20
19
|
function clearNodeFormattingOnSelection(state, tr, formattedNodeType, nodeName, formattingCleared) {
|
|
21
20
|
return function (node, pos) {
|
|
@@ -41,7 +40,7 @@ function clearNodeFormattingOnSelection(state, tr, formattedNodeType, nodeName,
|
|
|
41
40
|
return true;
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
|
-
export function clearFormatting(inputMethod) {
|
|
43
|
+
export function clearFormatting(inputMethod, editorAnalyticsAPI) {
|
|
45
44
|
return function (state, dispatch) {
|
|
46
45
|
var tr = state.tr;
|
|
47
46
|
var formattingCleared = [];
|
|
@@ -83,7 +82,7 @@ export function clearFormatting(inputMethod) {
|
|
|
83
82
|
});
|
|
84
83
|
tr.setStoredMarks([]);
|
|
85
84
|
if (formattingCleared.length && inputMethod) {
|
|
86
|
-
|
|
85
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
87
86
|
action: ACTION.FORMATTED,
|
|
88
87
|
eventType: EVENT_TYPE.TRACK,
|
|
89
88
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
@@ -92,7 +91,7 @@ export function clearFormatting(inputMethod) {
|
|
|
92
91
|
inputMethod: inputMethod,
|
|
93
92
|
formattingCleared: formattingCleared
|
|
94
93
|
}
|
|
95
|
-
});
|
|
94
|
+
})(tr);
|
|
96
95
|
}
|
|
97
96
|
if (dispatch) {
|
|
98
97
|
dispatch(tr);
|
|
@@ -11,6 +11,7 @@ import textFormattingSmartInputRulePlugin from './pm-plugins/smart-input-rule';
|
|
|
11
11
|
import Toolbar from './ui/Toolbar';
|
|
12
12
|
var textFormatting = function textFormatting() {
|
|
13
13
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
14
|
+
var api = arguments.length > 1 ? arguments[1] : undefined;
|
|
14
15
|
return {
|
|
15
16
|
name: 'textFormatting',
|
|
16
17
|
marks: function marks() {
|
|
@@ -68,7 +69,8 @@ var textFormatting = function textFormatting() {
|
|
|
68
69
|
}, {
|
|
69
70
|
name: 'textFormattingClearKeymap',
|
|
70
71
|
plugin: function plugin() {
|
|
71
|
-
|
|
72
|
+
var _api$dependencies$ana;
|
|
73
|
+
return clearFormattingKeymapPlugin(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);
|
|
72
74
|
}
|
|
73
75
|
}, {
|
|
74
76
|
name: 'textFormattingKeymap',
|
|
@@ -91,6 +93,7 @@ var textFormatting = function textFormatting() {
|
|
|
91
93
|
clearFormattingPluginState: clearFormattingPluginKey
|
|
92
94
|
},
|
|
93
95
|
render: function render() {
|
|
96
|
+
var _api$dependencies$ana2;
|
|
94
97
|
return /*#__PURE__*/React.createElement(Toolbar, {
|
|
95
98
|
editorState: editorView.state,
|
|
96
99
|
popupsMountPoint: popupsMountPoint,
|
|
@@ -99,7 +102,8 @@ var textFormatting = function textFormatting() {
|
|
|
99
102
|
isReducedSpacing: isToolbarReducedSpacing,
|
|
100
103
|
editorView: editorView,
|
|
101
104
|
isToolbarDisabled: disabled,
|
|
102
|
-
shouldUseResponsiveToolbar: Boolean(options.responsiveToolbarMenu)
|
|
105
|
+
shouldUseResponsiveToolbar: Boolean(options.responsiveToolbarMenu),
|
|
106
|
+
editorAnalyticsAPI: 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
|
|
103
107
|
});
|
|
104
108
|
}
|
|
105
109
|
});
|
|
@@ -2,9 +2,9 @@ import { keymap } from 'prosemirror-keymap';
|
|
|
2
2
|
import * as keymaps from '../../../keymaps';
|
|
3
3
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { clearFormattingWithAnalytics } from '../commands/clear-formatting';
|
|
5
|
-
export function keymapPlugin() {
|
|
5
|
+
export function keymapPlugin(editorAnalyticsAPI) {
|
|
6
6
|
var list = {};
|
|
7
|
-
keymaps.bindKeymapWithCommand(keymaps.clearFormatting.common, clearFormattingWithAnalytics(INPUT_METHOD.SHORTCUT), list);
|
|
7
|
+
keymaps.bindKeymapWithCommand(keymaps.clearFormatting.common, clearFormattingWithAnalytics(INPUT_METHOD.SHORTCUT, editorAnalyticsAPI), list);
|
|
8
8
|
return keymap(list);
|
|
9
9
|
}
|
|
10
10
|
export default keymapPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { useMemo } from 'react';
|
|
2
|
+
import { useCallback, useMemo } from 'react';
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
4
|
import { shortcutStyle } from '../../../../../ui/styles';
|
|
5
5
|
import { toolbarMessages } from '../toolbar-messages';
|
|
@@ -7,7 +7,6 @@ import { clearFormattingWithAnalytics } from '../../../commands/clear-formatting
|
|
|
7
7
|
import { pluginKey as clearFormattingPluginKey } from '../../../pm-plugins/clear-formatting';
|
|
8
8
|
import { clearFormatting as clearFormattingKeymap, tooltip } from '../../../../../keymaps';
|
|
9
9
|
import { INPUT_METHOD } from '../../../../analytics/types/enums';
|
|
10
|
-
var clearFormattingToolbar = clearFormattingWithAnalytics(INPUT_METHOD.TOOLBAR);
|
|
11
10
|
var useClearFormattingPluginState = function useClearFormattingPluginState(editorState) {
|
|
12
11
|
return useMemo(function () {
|
|
13
12
|
return clearFormattingPluginKey.getState(editorState);
|
|
@@ -15,11 +14,15 @@ var useClearFormattingPluginState = function useClearFormattingPluginState(edito
|
|
|
15
14
|
};
|
|
16
15
|
export var useClearIcon = function useClearIcon(_ref) {
|
|
17
16
|
var intl = _ref.intl,
|
|
18
|
-
editorState = _ref.editorState
|
|
17
|
+
editorState = _ref.editorState,
|
|
18
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI;
|
|
19
19
|
var pluginState = useClearFormattingPluginState(editorState);
|
|
20
20
|
var isPluginAvailable = Boolean(pluginState);
|
|
21
21
|
var formattingIsPresent = Boolean(pluginState === null || pluginState === void 0 ? void 0 : pluginState.formattingIsPresent);
|
|
22
22
|
var clearFormattingLabel = intl.formatMessage(toolbarMessages.clearFormatting);
|
|
23
|
+
var clearFormattingToolbar = useCallback(function (state, dispatch) {
|
|
24
|
+
return clearFormattingWithAnalytics(INPUT_METHOD.TOOLBAR, editorAnalyticsAPI)(state, dispatch);
|
|
25
|
+
}, [editorAnalyticsAPI]);
|
|
23
26
|
return useMemo(function () {
|
|
24
27
|
if (!isPluginAvailable) {
|
|
25
28
|
return null;
|
|
@@ -38,5 +41,5 @@ export var useClearIcon = function useClearIcon(_ref) {
|
|
|
38
41
|
isDisabled: !formattingIsPresent,
|
|
39
42
|
'aria-label': clearFormattingKeymap ? tooltip(clearFormattingKeymap, String(clearFormattingLabel)) : String(clearFormattingLabel)
|
|
40
43
|
};
|
|
41
|
-
}, [
|
|
44
|
+
}, [isPluginAvailable, clearFormattingToolbar, clearFormattingLabel, formattingIsPresent]);
|
|
42
45
|
};
|
|
@@ -32,7 +32,8 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
|
|
|
32
32
|
toolbarSize = _ref.toolbarSize,
|
|
33
33
|
isReducedSpacing = _ref.isReducedSpacing,
|
|
34
34
|
isToolbarDisabled = _ref.isToolbarDisabled,
|
|
35
|
-
intl = _ref.intl
|
|
35
|
+
intl = _ref.intl,
|
|
36
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI;
|
|
36
37
|
var editorState = useMemo(function () {
|
|
37
38
|
return editorView.state;
|
|
38
39
|
}, [editorView.state]);
|
|
@@ -47,7 +48,8 @@ var ToolbarFormatting = function ToolbarFormatting(_ref) {
|
|
|
47
48
|
});
|
|
48
49
|
var clearIcon = useClearIcon({
|
|
49
50
|
editorState: editorState,
|
|
50
|
-
intl: intl
|
|
51
|
+
intl: intl,
|
|
52
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
51
53
|
});
|
|
52
54
|
var menuIconTypeList = useResponsiveIconTypeMenu({
|
|
53
55
|
toolbarSize: toolbarSize,
|
|
@@ -168,7 +170,8 @@ var Toolbar = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
168
170
|
editorView = _this$props.editorView,
|
|
169
171
|
isToolbarDisabled = _this$props.isToolbarDisabled,
|
|
170
172
|
shouldUseResponsiveToolbar = _this$props.shouldUseResponsiveToolbar,
|
|
171
|
-
intl = _this$props.intl
|
|
173
|
+
intl = _this$props.intl,
|
|
174
|
+
editorAnalyticsAPI = _this$props.editorAnalyticsAPI;
|
|
172
175
|
return jsx(ToolbarFormatting, {
|
|
173
176
|
popupsMountPoint: popupsMountPoint,
|
|
174
177
|
popupsScrollableElement: popupsScrollableElement,
|
|
@@ -177,7 +180,8 @@ var Toolbar = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
177
180
|
editorView: editorView,
|
|
178
181
|
isToolbarDisabled: isToolbarDisabled,
|
|
179
182
|
shouldUseResponsiveToolbar: shouldUseResponsiveToolbar,
|
|
180
|
-
intl: intl
|
|
183
|
+
intl: intl,
|
|
184
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
181
185
|
});
|
|
182
186
|
}
|
|
183
187
|
}]);
|
package/dist/esm/version.json
CHANGED