@atlaskit/editor-core 189.3.10 → 189.3.11
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 +7 -0
- package/dist/cjs/i18n/cs.js +1 -17
- package/dist/cjs/i18n/da.js +1 -17
- package/dist/cjs/i18n/de.js +1 -17
- package/dist/cjs/i18n/en.js +1 -17
- package/dist/cjs/i18n/en_GB.js +1 -17
- package/dist/cjs/i18n/en_ZZ.js +1 -17
- package/dist/cjs/i18n/es.js +1 -17
- package/dist/cjs/i18n/fi.js +1 -17
- package/dist/cjs/i18n/fr.js +1 -17
- package/dist/cjs/i18n/hu.js +1 -17
- package/dist/cjs/i18n/it.js +1 -17
- package/dist/cjs/i18n/ja.js +1 -17
- package/dist/cjs/i18n/ko.js +1 -17
- package/dist/cjs/i18n/nb.js +1 -17
- package/dist/cjs/i18n/nl.js +1 -17
- package/dist/cjs/i18n/pl.js +1 -17
- package/dist/cjs/i18n/pt_BR.js +1 -17
- package/dist/cjs/i18n/ru.js +1 -17
- package/dist/cjs/i18n/sv.js +1 -17
- package/dist/cjs/i18n/th.js +1 -17
- package/dist/cjs/i18n/tr.js +1 -17
- package/dist/cjs/i18n/uk.js +1 -17
- package/dist/cjs/i18n/vi.js +1 -17
- package/dist/cjs/i18n/zh.js +1 -17
- package/dist/cjs/i18n/zh_TW.js +1 -17
- package/dist/cjs/plugins/extension/actions.js +135 -126
- package/dist/cjs/plugins/extension/extension-api.js +11 -9
- package/dist/cjs/plugins/extension/index.js +6 -4
- package/dist/cjs/plugins/extension/toolbar.js +5 -4
- package/dist/cjs/plugins/insert-block/index.js +2 -2
- package/dist/cjs/plugins/macro/actions.js +94 -93
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/i18n/cs.js +1 -17
- package/dist/es2019/i18n/da.js +1 -17
- package/dist/es2019/i18n/de.js +1 -17
- package/dist/es2019/i18n/en.js +1 -17
- package/dist/es2019/i18n/en_GB.js +1 -17
- package/dist/es2019/i18n/en_ZZ.js +1 -17
- package/dist/es2019/i18n/es.js +1 -17
- package/dist/es2019/i18n/fi.js +1 -17
- package/dist/es2019/i18n/fr.js +1 -17
- package/dist/es2019/i18n/hu.js +1 -17
- package/dist/es2019/i18n/it.js +1 -17
- package/dist/es2019/i18n/ja.js +1 -17
- package/dist/es2019/i18n/ko.js +1 -17
- package/dist/es2019/i18n/nb.js +1 -17
- package/dist/es2019/i18n/nl.js +1 -17
- package/dist/es2019/i18n/pl.js +1 -17
- package/dist/es2019/i18n/pt_BR.js +1 -17
- package/dist/es2019/i18n/ru.js +1 -17
- package/dist/es2019/i18n/sv.js +1 -17
- package/dist/es2019/i18n/th.js +1 -17
- package/dist/es2019/i18n/tr.js +1 -17
- package/dist/es2019/i18n/uk.js +1 -17
- package/dist/es2019/i18n/vi.js +1 -17
- package/dist/es2019/i18n/zh.js +1 -17
- package/dist/es2019/i18n/zh_TW.js +1 -17
- package/dist/es2019/plugins/extension/actions.js +17 -11
- package/dist/es2019/plugins/extension/extension-api.js +11 -9
- package/dist/es2019/plugins/extension/index.js +6 -4
- package/dist/es2019/plugins/extension/toolbar.js +5 -4
- package/dist/es2019/plugins/insert-block/index.js +2 -2
- package/dist/es2019/plugins/macro/actions.js +3 -4
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/i18n/cs.js +1 -17
- package/dist/esm/i18n/da.js +1 -17
- package/dist/esm/i18n/de.js +1 -17
- package/dist/esm/i18n/en.js +1 -17
- package/dist/esm/i18n/en_GB.js +1 -17
- package/dist/esm/i18n/en_ZZ.js +1 -17
- package/dist/esm/i18n/es.js +1 -17
- package/dist/esm/i18n/fi.js +1 -17
- package/dist/esm/i18n/fr.js +1 -17
- package/dist/esm/i18n/hu.js +1 -17
- package/dist/esm/i18n/it.js +1 -17
- package/dist/esm/i18n/ja.js +1 -17
- package/dist/esm/i18n/ko.js +1 -17
- package/dist/esm/i18n/nb.js +1 -17
- package/dist/esm/i18n/nl.js +1 -17
- package/dist/esm/i18n/pl.js +1 -17
- package/dist/esm/i18n/pt_BR.js +1 -17
- package/dist/esm/i18n/ru.js +1 -17
- package/dist/esm/i18n/sv.js +1 -17
- package/dist/esm/i18n/th.js +1 -17
- package/dist/esm/i18n/tr.js +1 -17
- package/dist/esm/i18n/uk.js +1 -17
- package/dist/esm/i18n/vi.js +1 -17
- package/dist/esm/i18n/zh.js +1 -17
- package/dist/esm/i18n/zh_TW.js +1 -17
- package/dist/esm/plugins/extension/actions.js +135 -125
- package/dist/esm/plugins/extension/extension-api.js +11 -9
- package/dist/esm/plugins/extension/index.js +6 -4
- package/dist/esm/plugins/extension/toolbar.js +5 -4
- package/dist/esm/plugins/insert-block/index.js +2 -2
- package/dist/esm/plugins/macro/actions.js +94 -93
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/i18n/cs.d.ts +0 -16
- package/dist/types/i18n/da.d.ts +0 -16
- package/dist/types/i18n/de.d.ts +0 -16
- package/dist/types/i18n/en.d.ts +0 -16
- package/dist/types/i18n/en_GB.d.ts +0 -16
- package/dist/types/i18n/en_ZZ.d.ts +0 -16
- package/dist/types/i18n/es.d.ts +0 -16
- package/dist/types/i18n/fi.d.ts +0 -16
- package/dist/types/i18n/fr.d.ts +0 -16
- package/dist/types/i18n/hu.d.ts +0 -16
- package/dist/types/i18n/it.d.ts +0 -16
- package/dist/types/i18n/ja.d.ts +0 -16
- package/dist/types/i18n/ko.d.ts +0 -16
- package/dist/types/i18n/nb.d.ts +0 -16
- package/dist/types/i18n/nl.d.ts +0 -16
- package/dist/types/i18n/pl.d.ts +0 -16
- package/dist/types/i18n/pt_BR.d.ts +0 -16
- package/dist/types/i18n/ru.d.ts +0 -16
- package/dist/types/i18n/sv.d.ts +0 -16
- package/dist/types/i18n/th.d.ts +0 -16
- package/dist/types/i18n/tr.d.ts +0 -16
- package/dist/types/i18n/uk.d.ts +0 -16
- package/dist/types/i18n/vi.d.ts +0 -16
- package/dist/types/i18n/zh.d.ts +0 -16
- package/dist/types/i18n/zh_TW.d.ts +0 -16
- package/dist/types/plugins/expand/pm-plugins/main.d.ts +2 -2
- package/dist/types/plugins/extension/actions.d.ts +5 -10
- package/dist/types/plugins/extension/extension-api.d.ts +3 -1
- package/dist/types/plugins/extension/toolbar.d.ts +3 -1
- package/dist/types/plugins/macro/actions.d.ts +2 -1
- package/dist/types/presets/default.d.ts +52 -4
- package/dist/types-ts4.5/i18n/cs.d.ts +0 -16
- package/dist/types-ts4.5/i18n/da.d.ts +0 -16
- package/dist/types-ts4.5/i18n/de.d.ts +0 -16
- package/dist/types-ts4.5/i18n/en.d.ts +0 -16
- package/dist/types-ts4.5/i18n/en_GB.d.ts +0 -16
- package/dist/types-ts4.5/i18n/en_ZZ.d.ts +0 -16
- package/dist/types-ts4.5/i18n/es.d.ts +0 -16
- package/dist/types-ts4.5/i18n/fi.d.ts +0 -16
- package/dist/types-ts4.5/i18n/fr.d.ts +0 -16
- package/dist/types-ts4.5/i18n/hu.d.ts +0 -16
- package/dist/types-ts4.5/i18n/it.d.ts +0 -16
- package/dist/types-ts4.5/i18n/ja.d.ts +0 -16
- package/dist/types-ts4.5/i18n/ko.d.ts +0 -16
- package/dist/types-ts4.5/i18n/nb.d.ts +0 -16
- package/dist/types-ts4.5/i18n/nl.d.ts +0 -16
- package/dist/types-ts4.5/i18n/pl.d.ts +0 -16
- package/dist/types-ts4.5/i18n/pt_BR.d.ts +0 -16
- package/dist/types-ts4.5/i18n/ru.d.ts +0 -16
- package/dist/types-ts4.5/i18n/sv.d.ts +0 -16
- package/dist/types-ts4.5/i18n/th.d.ts +0 -16
- package/dist/types-ts4.5/i18n/tr.d.ts +0 -16
- package/dist/types-ts4.5/i18n/uk.d.ts +0 -16
- package/dist/types-ts4.5/i18n/vi.d.ts +0 -16
- package/dist/types-ts4.5/i18n/zh.d.ts +0 -16
- package/dist/types-ts4.5/i18n/zh_TW.d.ts +0 -16
- package/dist/types-ts4.5/plugins/expand/pm-plugins/main.d.ts +2 -2
- package/dist/types-ts4.5/plugins/extension/actions.d.ts +5 -10
- package/dist/types-ts4.5/plugins/extension/extension-api.d.ts +3 -1
- package/dist/types-ts4.5/plugins/extension/toolbar.d.ts +3 -1
- package/dist/types-ts4.5/plugins/macro/actions.d.ts +2 -1
- package/dist/types-ts4.5/presets/default.d.ts +60 -0
- package/package.json +2 -2
|
@@ -11,7 +11,6 @@ Object.defineProperty(exports, "transformSliceToRemoveOpenBodiedExtension", {
|
|
|
11
11
|
return _transforms.transformSliceToRemoveOpenBodiedExtension;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
-
exports.updateExtensionParams = void 0;
|
|
15
14
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
16
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
16
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
@@ -19,7 +18,6 @@ var _state2 = require("@atlaskit/editor-prosemirror/state");
|
|
|
19
18
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
20
19
|
var _transforms = require("@atlaskit/editor-common/transforms");
|
|
21
20
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
22
|
-
var _analytics2 = require("../analytics");
|
|
23
21
|
var _extensionEvents = require("../analytics/types/extension-events");
|
|
24
22
|
var _utils2 = require("./utils");
|
|
25
23
|
var _main = require("./pm-plugins/main");
|
|
@@ -36,140 +34,149 @@ var buildExtensionNode = exports.buildExtensionNode = function buildExtensionNod
|
|
|
36
34
|
return schema.nodes.bodiedExtension.create(attrs, content, marks);
|
|
37
35
|
}
|
|
38
36
|
};
|
|
39
|
-
var performNodeUpdate = exports.performNodeUpdate = function performNodeUpdate(
|
|
40
|
-
return function (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// NOTE: `state` and `dispatch` are stale at this point so we need to grab
|
|
45
|
-
// the latest one from `view` @see HOT-93986
|
|
46
|
-
var state = view.state,
|
|
47
|
-
dispatch = view.dispatch;
|
|
48
|
-
var newNode = buildExtensionNode(type, state.schema, newAttrs, content, marks);
|
|
49
|
-
if (!newNode) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
var selection = state.selection,
|
|
53
|
-
schema = state.schema;
|
|
54
|
-
var _schema$nodes = schema.nodes,
|
|
55
|
-
extension = _schema$nodes.extension,
|
|
56
|
-
inlineExtension = _schema$nodes.inlineExtension,
|
|
57
|
-
bodiedExtension = _schema$nodes.bodiedExtension;
|
|
58
|
-
var isBodiedExtensionSelected = !!(0, _utils.findSelectedNodeOfType)([bodiedExtension])(selection);
|
|
59
|
-
var extensionState = (0, _main.getPluginState)(state);
|
|
60
|
-
var targetSelectionSource = _extensionEvents.TARGET_SELECTION_SOURCE.CURRENT_SELECTION;
|
|
61
|
-
var action = _analytics.ACTION.UPDATED;
|
|
62
|
-
var tr = state.tr;
|
|
63
|
-
|
|
64
|
-
// When it's a bodiedExtension but not selected
|
|
65
|
-
if (newNode.type === bodiedExtension && !isBodiedExtensionSelected) {
|
|
66
|
-
// Bodied extensions can trigger an update when the cursor is inside which means that there is no node selected.
|
|
67
|
-
// To work around that we replace the parent and create a text selection instead of new node selection
|
|
68
|
-
tr = (0, _utils.replaceParentNodeOfType)(state.schema.nodes.bodiedExtension, newNode)(tr);
|
|
69
|
-
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
70
|
-
tr.setSelection(_state2.TextSelection.create(tr.doc, state.selection.anchor));
|
|
71
|
-
}
|
|
72
|
-
// If any extension is currently selected
|
|
73
|
-
else if ((0, _utils.findSelectedNodeOfType)([extension, bodiedExtension, inlineExtension])(selection)) {
|
|
74
|
-
tr = (0, _utils.replaceSelectedNode)(newNode)(tr);
|
|
75
|
-
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
76
|
-
tr.setSelection(_state2.NodeSelection.create(tr.doc, tr.mapping.map(state.selection.anchor)));
|
|
77
|
-
}
|
|
78
|
-
// When we loose the selection. This usually happens when Synchrony resets or changes
|
|
79
|
-
// the selection when user is in the middle of updating an extension.
|
|
80
|
-
else if (extensionState.element) {
|
|
81
|
-
var pos = view.posAtDOM(extensionState.element, -1);
|
|
82
|
-
if (pos > -1) {
|
|
83
|
-
tr = tr.replaceWith(pos, pos + (content.size || 0) + 1, newNode);
|
|
84
|
-
tr.setSelection(_state2.Selection.near(tr.doc.resolve(pos)));
|
|
85
|
-
targetSelectionSource = _extensionEvents.TARGET_SELECTION_SOURCE.HTML_ELEMENT;
|
|
86
|
-
} else {
|
|
87
|
-
action = _analytics.ACTION.ERRORED;
|
|
37
|
+
var performNodeUpdate = exports.performNodeUpdate = function performNodeUpdate(editorAnalyticsAPI) {
|
|
38
|
+
return function (type, newAttrs, content, marks, shouldScrollIntoView) {
|
|
39
|
+
return function (_state, _dispatch, view) {
|
|
40
|
+
if (!view) {
|
|
41
|
+
throw Error('EditorView is required to perform node update!');
|
|
88
42
|
}
|
|
89
|
-
|
|
43
|
+
// NOTE: `state` and `dispatch` are stale at this point so we need to grab
|
|
44
|
+
// the latest one from `view` @see HOT-93986
|
|
45
|
+
var state = view.state,
|
|
46
|
+
dispatch = view.dispatch;
|
|
47
|
+
var newNode = buildExtensionNode(type, state.schema, newAttrs, content, marks);
|
|
48
|
+
if (!newNode) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
var selection = state.selection,
|
|
52
|
+
schema = state.schema;
|
|
53
|
+
var _schema$nodes = schema.nodes,
|
|
54
|
+
extension = _schema$nodes.extension,
|
|
55
|
+
inlineExtension = _schema$nodes.inlineExtension,
|
|
56
|
+
bodiedExtension = _schema$nodes.bodiedExtension;
|
|
57
|
+
var isBodiedExtensionSelected = !!(0, _utils.findSelectedNodeOfType)([bodiedExtension])(selection);
|
|
58
|
+
var extensionState = (0, _main.getPluginState)(state);
|
|
59
|
+
var targetSelectionSource = _extensionEvents.TARGET_SELECTION_SOURCE.CURRENT_SELECTION;
|
|
60
|
+
var action = _analytics.ACTION.UPDATED;
|
|
61
|
+
var tr = state.tr;
|
|
90
62
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
63
|
+
// When it's a bodiedExtension but not selected
|
|
64
|
+
if (newNode.type === bodiedExtension && !isBodiedExtensionSelected) {
|
|
65
|
+
// Bodied extensions can trigger an update when the cursor is inside which means that there is no node selected.
|
|
66
|
+
// To work around that we replace the parent and create a text selection instead of new node selection
|
|
67
|
+
tr = (0, _utils.replaceParentNodeOfType)(state.schema.nodes.bodiedExtension, newNode)(tr);
|
|
68
|
+
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
69
|
+
tr.setSelection(_state2.TextSelection.create(tr.doc, state.selection.anchor));
|
|
70
|
+
}
|
|
71
|
+
// If any extension is currently selected
|
|
72
|
+
else if ((0, _utils.findSelectedNodeOfType)([extension, bodiedExtension, inlineExtension])(selection)) {
|
|
73
|
+
tr = (0, _utils.replaceSelectedNode)(newNode)(tr);
|
|
74
|
+
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
75
|
+
tr.setSelection(_state2.NodeSelection.create(tr.doc, tr.mapping.map(state.selection.anchor)));
|
|
76
|
+
}
|
|
77
|
+
// When we loose the selection. This usually happens when Synchrony resets or changes
|
|
78
|
+
// the selection when user is in the middle of updating an extension.
|
|
79
|
+
else if (extensionState.element) {
|
|
80
|
+
var pos = view.posAtDOM(extensionState.element, -1);
|
|
81
|
+
if (pos > -1) {
|
|
82
|
+
tr = tr.replaceWith(pos, pos + (content.size || 0) + 1, newNode);
|
|
83
|
+
tr.setSelection(_state2.Selection.near(tr.doc.resolve(pos)));
|
|
84
|
+
targetSelectionSource = _extensionEvents.TARGET_SELECTION_SOURCE.HTML_ELEMENT;
|
|
85
|
+
} else {
|
|
86
|
+
action = _analytics.ACTION.ERRORED;
|
|
111
87
|
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Only scroll if we have anything to update, best to avoid surprise scroll
|
|
91
|
+
if (dispatch && tr.docChanged) {
|
|
92
|
+
var _newNode$attrs = newNode.attrs,
|
|
93
|
+
extensionType = _newNode$attrs.extensionType,
|
|
94
|
+
extensionKey = _newNode$attrs.extensionKey,
|
|
95
|
+
layout = _newNode$attrs.layout,
|
|
96
|
+
localId = _newNode$attrs.localId;
|
|
97
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
98
|
+
action: action,
|
|
99
|
+
actionSubject: _analytics.ACTION_SUBJECT.EXTENSION,
|
|
100
|
+
actionSubjectId: newNode.type.name,
|
|
101
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
102
|
+
attributes: {
|
|
103
|
+
inputMethod: _analytics.INPUT_METHOD.CONFIG_PANEL,
|
|
104
|
+
extensionType: extensionType,
|
|
105
|
+
extensionKey: extensionKey,
|
|
106
|
+
layout: layout,
|
|
107
|
+
localId: localId,
|
|
108
|
+
selection: tr.selection.toJSON(),
|
|
109
|
+
targetSelectionSource: targetSelectionSource
|
|
110
|
+
}
|
|
111
|
+
})(tr);
|
|
112
|
+
dispatch(shouldScrollIntoView ? tr.scrollIntoView() : tr);
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
};
|
|
116
116
|
};
|
|
117
117
|
};
|
|
118
|
-
var updateExtensionParams =
|
|
119
|
-
return
|
|
120
|
-
|
|
121
|
-
var
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
118
|
+
var updateExtensionParams = function updateExtensionParams(editorAnalyticsAPI) {
|
|
119
|
+
return function (updateExtension, node, actions) {
|
|
120
|
+
return /*#__PURE__*/function () {
|
|
121
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(state, dispatch, view) {
|
|
122
|
+
var _node$node, attrs, type, content, marks, parameters, newParameters, newAttrs;
|
|
123
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
124
|
+
while (1) switch (_context.prev = _context.next) {
|
|
125
|
+
case 0:
|
|
126
|
+
_node$node = node.node, attrs = _node$node.attrs, type = _node$node.type, content = _node$node.content, marks = _node$node.marks;
|
|
127
|
+
if (state.schema.nodes[type.name]) {
|
|
128
|
+
_context.next = 3;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
return _context.abrupt("return", false);
|
|
132
|
+
case 3:
|
|
133
|
+
parameters = attrs.parameters;
|
|
134
|
+
_context.prev = 4;
|
|
135
|
+
_context.next = 7;
|
|
136
|
+
return updateExtension(parameters, actions);
|
|
137
|
+
case 7:
|
|
138
|
+
newParameters = _context.sent;
|
|
139
|
+
if (!newParameters) {
|
|
140
|
+
_context.next = 11;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
newAttrs = _objectSpread(_objectSpread({}, attrs), {}, {
|
|
144
|
+
parameters: _objectSpread(_objectSpread({}, parameters), newParameters)
|
|
145
|
+
});
|
|
146
|
+
return _context.abrupt("return", performNodeUpdate(editorAnalyticsAPI)(type.name, newAttrs, content, marks, true)(state, dispatch, view));
|
|
147
|
+
case 11:
|
|
148
|
+
_context.next = 15;
|
|
140
149
|
break;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
}, _callee, null, [[4, 13]]);
|
|
159
|
-
}));
|
|
160
|
-
return function (_x, _x2, _x3) {
|
|
161
|
-
return _ref.apply(this, arguments);
|
|
162
|
-
};
|
|
163
|
-
}();
|
|
150
|
+
case 13:
|
|
151
|
+
_context.prev = 13;
|
|
152
|
+
_context.t0 = _context["catch"](4);
|
|
153
|
+
case 15:
|
|
154
|
+
return _context.abrupt("return", true);
|
|
155
|
+
case 16:
|
|
156
|
+
case "end":
|
|
157
|
+
return _context.stop();
|
|
158
|
+
}
|
|
159
|
+
}, _callee, null, [[4, 13]]);
|
|
160
|
+
}));
|
|
161
|
+
return function (_x, _x2, _x3) {
|
|
162
|
+
return _ref.apply(this, arguments);
|
|
163
|
+
};
|
|
164
|
+
}();
|
|
165
|
+
};
|
|
164
166
|
};
|
|
165
167
|
var editSelectedExtension = exports.editSelectedExtension = function editSelectedExtension(editorActions) {
|
|
166
168
|
var editorView = editorActions._privateGetEditorView();
|
|
167
169
|
var _getPluginState = (0, _main.getPluginState)(editorView.state),
|
|
168
170
|
updateExtension = _getPluginState.updateExtension,
|
|
169
171
|
applyChangeToContextPanel = _getPluginState.applyChangeToContextPanel;
|
|
170
|
-
|
|
172
|
+
// The analytics API cannot be accessed in this case because
|
|
173
|
+
// we do not have access to the plugin injection API. Rather
|
|
174
|
+
// than change the way this works - we just won't use analytics
|
|
175
|
+
// here for now.
|
|
176
|
+
var editorAnalyticsAPI = undefined;
|
|
177
|
+
return editExtension(null, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension)(editorView.state, editorView.dispatch, editorView);
|
|
171
178
|
};
|
|
172
|
-
var editExtension = exports.editExtension = function editExtension(macroProvider, applyChangeToContextPanel, updateExtension) {
|
|
179
|
+
var editExtension = exports.editExtension = function editExtension(macroProvider, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension) {
|
|
173
180
|
return function (state, dispatch, view) {
|
|
174
181
|
if (!view) {
|
|
175
182
|
return false;
|
|
@@ -182,7 +189,8 @@ var editExtension = exports.editExtension = function editExtension(macroProvider
|
|
|
182
189
|
}
|
|
183
190
|
var editInLegacyMacroBrowser = (0, _extensionApi.getEditInLegacyMacroBrowser)({
|
|
184
191
|
view: view,
|
|
185
|
-
macroProvider: macroProvider || undefined
|
|
192
|
+
macroProvider: macroProvider || undefined,
|
|
193
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
186
194
|
});
|
|
187
195
|
if (updateExtension) {
|
|
188
196
|
updateExtension.then(function (updateMethod) {
|
|
@@ -190,9 +198,10 @@ var editExtension = exports.editExtension = function editExtension(macroProvider
|
|
|
190
198
|
var actions = (0, _extensionApi.createExtensionAPI)({
|
|
191
199
|
editorView: view,
|
|
192
200
|
editInLegacyMacroBrowser: editInLegacyMacroBrowser,
|
|
193
|
-
applyChange: applyChangeToContextPanel
|
|
201
|
+
applyChange: applyChangeToContextPanel,
|
|
202
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
194
203
|
});
|
|
195
|
-
updateExtensionParams(updateMethod, nodeWithPos, actions)(state, dispatch, view);
|
|
204
|
+
updateExtensionParams(editorAnalyticsAPI)(updateMethod, nodeWithPos, actions)(state, dispatch, view);
|
|
196
205
|
return;
|
|
197
206
|
}
|
|
198
207
|
if (!updateMethod && macroProvider) {
|
|
@@ -16,11 +16,11 @@ var _utils = require("../../utils");
|
|
|
16
16
|
var _commands = require("./commands");
|
|
17
17
|
var _utils2 = require("./utils");
|
|
18
18
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
19
|
-
var _analytics2 = require("../analytics");
|
|
20
19
|
var _utils3 = require("@atlaskit/editor-prosemirror/utils");
|
|
21
20
|
var getEditInLegacyMacroBrowser = exports.getEditInLegacyMacroBrowser = function getEditInLegacyMacroBrowser(_ref) {
|
|
22
21
|
var view = _ref.view,
|
|
23
|
-
macroProvider = _ref.macroProvider
|
|
22
|
+
macroProvider = _ref.macroProvider,
|
|
23
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI;
|
|
24
24
|
return function () {
|
|
25
25
|
if (!view) {
|
|
26
26
|
throw new Error("Missing view. Can't update without EditorView");
|
|
@@ -32,7 +32,7 @@ var getEditInLegacyMacroBrowser = exports.getEditInLegacyMacroBrowser = function
|
|
|
32
32
|
if (!nodeWithPos) {
|
|
33
33
|
throw new Error("Missing nodeWithPos. Can't determine position of node");
|
|
34
34
|
}
|
|
35
|
-
(0, _macro.insertMacroFromMacroBrowser)(macroProvider, nodeWithPos.node, true)(view);
|
|
35
|
+
(0, _macro.insertMacroFromMacroBrowser)(editorAnalyticsAPI)(macroProvider, nodeWithPos.node, true)(view);
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
var extensionAPICallPayload = function extensionAPICallPayload(functionName) {
|
|
@@ -47,7 +47,8 @@ var extensionAPICallPayload = function extensionAPICallPayload(functionName) {
|
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
var createExtensionAPI = exports.createExtensionAPI = function createExtensionAPI(options) {
|
|
50
|
-
var schema = options.editorView.state.schema
|
|
50
|
+
var schema = options.editorView.state.schema,
|
|
51
|
+
editorAnalyticsAPI = options.editorAnalyticsAPI;
|
|
51
52
|
var nodes = Object.keys(schema.nodes);
|
|
52
53
|
var marks = Object.keys(schema.marks);
|
|
53
54
|
var validate = (0, _validator.validator)(nodes, marks, {
|
|
@@ -115,7 +116,7 @@ var createExtensionAPI = exports.createExtensionAPI = function createExtensionAP
|
|
|
115
116
|
|
|
116
117
|
// Analytics - tracking the api call
|
|
117
118
|
var apiCallPayload = extensionAPICallPayload('insertAfter');
|
|
118
|
-
|
|
119
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(apiCallPayload)(tr);
|
|
119
120
|
|
|
120
121
|
// Analytics - tracking node types added
|
|
121
122
|
var nodesAdded = [newNode];
|
|
@@ -149,7 +150,7 @@ var createExtensionAPI = exports.createExtensionAPI = function createExtensionAP
|
|
|
149
150
|
},
|
|
150
151
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
151
152
|
};
|
|
152
|
-
|
|
153
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
153
154
|
});
|
|
154
155
|
if (opt && opt.allowSelectionToNewNode) {
|
|
155
156
|
tr.setSelection(new _state.NodeSelection(tr.doc.resolve(insertPosition)));
|
|
@@ -167,7 +168,7 @@ var createExtensionAPI = exports.createExtensionAPI = function createExtensionAP
|
|
|
167
168
|
dispatch = _options$editorView.dispatch,
|
|
168
169
|
state = _options$editorView.state;
|
|
169
170
|
var tr = state.tr;
|
|
170
|
-
|
|
171
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(apiCallPayload)(tr);
|
|
171
172
|
tr = (0, _utils3.setTextSelection)(nodePos.pos)(tr);
|
|
172
173
|
tr = tr.scrollIntoView();
|
|
173
174
|
dispatch(tr);
|
|
@@ -238,7 +239,7 @@ var createExtensionAPI = exports.createExtensionAPI = function createExtensionAP
|
|
|
238
239
|
|
|
239
240
|
// Analytics - tracking the api call
|
|
240
241
|
var apiCallPayload = extensionAPICallPayload('update');
|
|
241
|
-
|
|
242
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(apiCallPayload)(tr);
|
|
242
243
|
dispatch(tr);
|
|
243
244
|
}
|
|
244
245
|
};
|
|
@@ -254,7 +255,8 @@ var createExtensionAPI = exports.createExtensionAPI = function createExtensionAP
|
|
|
254
255
|
var macroState = _pluginKey.pluginKey.getState(editorView.state);
|
|
255
256
|
editInLegacy = getEditInLegacyMacroBrowser({
|
|
256
257
|
view: options.editorView,
|
|
257
|
-
macroProvider: (macroState === null || macroState === void 0 ? void 0 : macroState.macroProvider) || undefined
|
|
258
|
+
macroProvider: (macroState === null || macroState === void 0 ? void 0 : macroState.macroProvider) || undefined,
|
|
259
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
258
260
|
});
|
|
259
261
|
}
|
|
260
262
|
editInLegacy();
|
|
@@ -14,7 +14,7 @@ var _toolbar = require("./toolbar");
|
|
|
14
14
|
var _contextPanel = require("./context-panel");
|
|
15
15
|
var _extensionApi = require("./extension-api");
|
|
16
16
|
var extensionPlugin = function extensionPlugin(_ref) {
|
|
17
|
-
var _api$featureFlags, _api$contextPanel3, _api$contextPanel4;
|
|
17
|
+
var _api$featureFlags, _api$contextPanel3, _api$analytics2, _api$contextPanel4;
|
|
18
18
|
var _ref$config = _ref.config,
|
|
19
19
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
20
20
|
_api = _ref.api;
|
|
@@ -80,10 +80,11 @@ var extensionPlugin = function extensionPlugin(_ref) {
|
|
|
80
80
|
},
|
|
81
81
|
actions: {
|
|
82
82
|
api: function api() {
|
|
83
|
-
var _api$contextPanel2;
|
|
83
|
+
var _api$contextPanel2, _api$analytics;
|
|
84
84
|
return (0, _extensionApi.createExtensionAPI)({
|
|
85
85
|
editorView: editorViewRef.current,
|
|
86
|
-
applyChange: _api === null || _api === void 0 || (_api$contextPanel2 = _api.contextPanel) === null || _api$contextPanel2 === void 0 ? void 0 : _api$contextPanel2.actions.applyChange
|
|
86
|
+
applyChange: _api === null || _api === void 0 || (_api$contextPanel2 = _api.contextPanel) === null || _api$contextPanel2 === void 0 ? void 0 : _api$contextPanel2.actions.applyChange,
|
|
87
|
+
editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics = _api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
90
|
},
|
|
@@ -91,7 +92,8 @@ var extensionPlugin = function extensionPlugin(_ref) {
|
|
|
91
92
|
floatingToolbar: (0, _toolbar.getToolbarConfig)({
|
|
92
93
|
breakoutEnabled: options.breakoutEnabled,
|
|
93
94
|
hoverDecoration: _api === null || _api === void 0 ? void 0 : _api.decorations.actions.hoverDecoration,
|
|
94
|
-
applyChangeToContextPanel: _api === null || _api === void 0 || (_api$contextPanel3 = _api.contextPanel) === null || _api$contextPanel3 === void 0 ? void 0 : _api$contextPanel3.actions.applyChange
|
|
95
|
+
applyChangeToContextPanel: _api === null || _api === void 0 || (_api$contextPanel3 = _api.contextPanel) === null || _api$contextPanel3 === void 0 ? void 0 : _api$contextPanel3.actions.applyChange,
|
|
96
|
+
editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics2 = _api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions
|
|
95
97
|
}),
|
|
96
98
|
contextPanel: (0, _contextPanel.getContextPanel)(options.allowAutoSave, featureFlags, _api === null || _api === void 0 || (_api$contextPanel4 = _api.contextPanel) === null || _api$contextPanel4 === void 0 ? void 0 : _api$contextPanel4.actions.applyChange)
|
|
97
99
|
}
|
|
@@ -96,7 +96,7 @@ var breakoutOptions = function breakoutOptions(state, formatMessage, extensionSt
|
|
|
96
96
|
}
|
|
97
97
|
return [];
|
|
98
98
|
};
|
|
99
|
-
var editButton = function editButton(formatMessage, extensionState, applyChangeToContextPanel) {
|
|
99
|
+
var editButton = function editButton(formatMessage, extensionState, applyChangeToContextPanel, editorAnalyticsAPI) {
|
|
100
100
|
if (!extensionState.showEditButton) {
|
|
101
101
|
return [];
|
|
102
102
|
}
|
|
@@ -110,7 +110,7 @@ var editButton = function editButton(formatMessage, extensionState, applyChangeT
|
|
|
110
110
|
var macroState = _pluginKey.pluginKey.getState(state);
|
|
111
111
|
var _getPluginState = (0, _main.getPluginState)(state),
|
|
112
112
|
updateExtension = _getPluginState.updateExtension;
|
|
113
|
-
(0, _actions.editExtension)(macroState && macroState.macroProvider, applyChangeToContextPanel, updateExtension)(state, dispatch, view);
|
|
113
|
+
(0, _actions.editExtension)(macroState && macroState.macroProvider, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension)(state, dispatch, view);
|
|
114
114
|
return true;
|
|
115
115
|
},
|
|
116
116
|
title: formatMessage(messages.edit),
|
|
@@ -122,13 +122,14 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(_ref
|
|
|
122
122
|
var _ref$breakoutEnabled = _ref.breakoutEnabled,
|
|
123
123
|
breakoutEnabled = _ref$breakoutEnabled === void 0 ? true : _ref$breakoutEnabled,
|
|
124
124
|
hoverDecoration = _ref.hoverDecoration,
|
|
125
|
-
applyChangeToContextPanel = _ref.applyChangeToContextPanel
|
|
125
|
+
applyChangeToContextPanel = _ref.applyChangeToContextPanel,
|
|
126
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI;
|
|
126
127
|
return function (state, intl) {
|
|
127
128
|
var formatMessage = intl.formatMessage;
|
|
128
129
|
var extensionState = (0, _main.getPluginState)(state);
|
|
129
130
|
if (extensionState && !extensionState.showContextPanel && extensionState.element) {
|
|
130
131
|
var nodeType = [state.schema.nodes.extension, state.schema.nodes.inlineExtension, state.schema.nodes.bodiedExtension];
|
|
131
|
-
var editButtonArray = editButton(formatMessage, extensionState, applyChangeToContextPanel);
|
|
132
|
+
var editButtonArray = editButton(formatMessage, extensionState, applyChangeToContextPanel, editorAnalyticsAPI);
|
|
132
133
|
var breakoutButtonArray = breakoutOptions(state, formatMessage, extensionState, breakoutEnabled);
|
|
133
134
|
var extensionObj = (0, _utils2.getSelectedExtension)(state, true);
|
|
134
135
|
|
|
@@ -108,7 +108,7 @@ var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
108
108
|
};
|
|
109
109
|
};
|
|
110
110
|
function ToolbarInsertBlockWithInjectionApi(_ref4) {
|
|
111
|
-
var _ref5, _ref6, _pluginInjectionApi$i, _pluginInjectionApi$c, _pluginInjectionApi$p, _pluginInjectionApi$b;
|
|
111
|
+
var _ref5, _ref6, _pluginInjectionApi$i, _pluginInjectionApi$c, _pluginInjectionApi$p, _pluginInjectionApi$b, _pluginInjectionApi$a;
|
|
112
112
|
var editorView = _ref4.editorView,
|
|
113
113
|
editorActions = _ref4.editorActions,
|
|
114
114
|
dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent,
|
|
@@ -165,7 +165,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
|
|
|
165
165
|
nativeStatusSupported: options.nativeStatusSupported,
|
|
166
166
|
horizontalRuleEnabled: options.horizontalRuleEnabled,
|
|
167
167
|
onInsertBlockType: handleInsertBlockType(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.codeBlock) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.insertCodeBlock, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$p = pluginInjectionApi.panel) === null || _pluginInjectionApi$p === void 0 ? void 0 : _pluginInjectionApi$p.actions.insertPanel, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$b = pluginInjectionApi.blockType) === null || _pluginInjectionApi$b === void 0 ? void 0 : _pluginInjectionApi$b.actions.insertBlockQuote),
|
|
168
|
-
onInsertMacroFromMacroBrowser: _macro.insertMacroFromMacroBrowser,
|
|
168
|
+
onInsertMacroFromMacroBrowser: (0, _macro.insertMacroFromMacroBrowser)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions),
|
|
169
169
|
macroProvider: macroState.macroProvider,
|
|
170
170
|
popupsMountPoint: popupsMountPoint,
|
|
171
171
|
popupsBoundariesElement: popupsBoundariesElement,
|