@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.
Files changed (160) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/i18n/cs.js +1 -17
  3. package/dist/cjs/i18n/da.js +1 -17
  4. package/dist/cjs/i18n/de.js +1 -17
  5. package/dist/cjs/i18n/en.js +1 -17
  6. package/dist/cjs/i18n/en_GB.js +1 -17
  7. package/dist/cjs/i18n/en_ZZ.js +1 -17
  8. package/dist/cjs/i18n/es.js +1 -17
  9. package/dist/cjs/i18n/fi.js +1 -17
  10. package/dist/cjs/i18n/fr.js +1 -17
  11. package/dist/cjs/i18n/hu.js +1 -17
  12. package/dist/cjs/i18n/it.js +1 -17
  13. package/dist/cjs/i18n/ja.js +1 -17
  14. package/dist/cjs/i18n/ko.js +1 -17
  15. package/dist/cjs/i18n/nb.js +1 -17
  16. package/dist/cjs/i18n/nl.js +1 -17
  17. package/dist/cjs/i18n/pl.js +1 -17
  18. package/dist/cjs/i18n/pt_BR.js +1 -17
  19. package/dist/cjs/i18n/ru.js +1 -17
  20. package/dist/cjs/i18n/sv.js +1 -17
  21. package/dist/cjs/i18n/th.js +1 -17
  22. package/dist/cjs/i18n/tr.js +1 -17
  23. package/dist/cjs/i18n/uk.js +1 -17
  24. package/dist/cjs/i18n/vi.js +1 -17
  25. package/dist/cjs/i18n/zh.js +1 -17
  26. package/dist/cjs/i18n/zh_TW.js +1 -17
  27. package/dist/cjs/plugins/extension/actions.js +135 -126
  28. package/dist/cjs/plugins/extension/extension-api.js +11 -9
  29. package/dist/cjs/plugins/extension/index.js +6 -4
  30. package/dist/cjs/plugins/extension/toolbar.js +5 -4
  31. package/dist/cjs/plugins/insert-block/index.js +2 -2
  32. package/dist/cjs/plugins/macro/actions.js +94 -93
  33. package/dist/cjs/version-wrapper.js +1 -1
  34. package/dist/es2019/i18n/cs.js +1 -17
  35. package/dist/es2019/i18n/da.js +1 -17
  36. package/dist/es2019/i18n/de.js +1 -17
  37. package/dist/es2019/i18n/en.js +1 -17
  38. package/dist/es2019/i18n/en_GB.js +1 -17
  39. package/dist/es2019/i18n/en_ZZ.js +1 -17
  40. package/dist/es2019/i18n/es.js +1 -17
  41. package/dist/es2019/i18n/fi.js +1 -17
  42. package/dist/es2019/i18n/fr.js +1 -17
  43. package/dist/es2019/i18n/hu.js +1 -17
  44. package/dist/es2019/i18n/it.js +1 -17
  45. package/dist/es2019/i18n/ja.js +1 -17
  46. package/dist/es2019/i18n/ko.js +1 -17
  47. package/dist/es2019/i18n/nb.js +1 -17
  48. package/dist/es2019/i18n/nl.js +1 -17
  49. package/dist/es2019/i18n/pl.js +1 -17
  50. package/dist/es2019/i18n/pt_BR.js +1 -17
  51. package/dist/es2019/i18n/ru.js +1 -17
  52. package/dist/es2019/i18n/sv.js +1 -17
  53. package/dist/es2019/i18n/th.js +1 -17
  54. package/dist/es2019/i18n/tr.js +1 -17
  55. package/dist/es2019/i18n/uk.js +1 -17
  56. package/dist/es2019/i18n/vi.js +1 -17
  57. package/dist/es2019/i18n/zh.js +1 -17
  58. package/dist/es2019/i18n/zh_TW.js +1 -17
  59. package/dist/es2019/plugins/extension/actions.js +17 -11
  60. package/dist/es2019/plugins/extension/extension-api.js +11 -9
  61. package/dist/es2019/plugins/extension/index.js +6 -4
  62. package/dist/es2019/plugins/extension/toolbar.js +5 -4
  63. package/dist/es2019/plugins/insert-block/index.js +2 -2
  64. package/dist/es2019/plugins/macro/actions.js +3 -4
  65. package/dist/es2019/version-wrapper.js +1 -1
  66. package/dist/esm/i18n/cs.js +1 -17
  67. package/dist/esm/i18n/da.js +1 -17
  68. package/dist/esm/i18n/de.js +1 -17
  69. package/dist/esm/i18n/en.js +1 -17
  70. package/dist/esm/i18n/en_GB.js +1 -17
  71. package/dist/esm/i18n/en_ZZ.js +1 -17
  72. package/dist/esm/i18n/es.js +1 -17
  73. package/dist/esm/i18n/fi.js +1 -17
  74. package/dist/esm/i18n/fr.js +1 -17
  75. package/dist/esm/i18n/hu.js +1 -17
  76. package/dist/esm/i18n/it.js +1 -17
  77. package/dist/esm/i18n/ja.js +1 -17
  78. package/dist/esm/i18n/ko.js +1 -17
  79. package/dist/esm/i18n/nb.js +1 -17
  80. package/dist/esm/i18n/nl.js +1 -17
  81. package/dist/esm/i18n/pl.js +1 -17
  82. package/dist/esm/i18n/pt_BR.js +1 -17
  83. package/dist/esm/i18n/ru.js +1 -17
  84. package/dist/esm/i18n/sv.js +1 -17
  85. package/dist/esm/i18n/th.js +1 -17
  86. package/dist/esm/i18n/tr.js +1 -17
  87. package/dist/esm/i18n/uk.js +1 -17
  88. package/dist/esm/i18n/vi.js +1 -17
  89. package/dist/esm/i18n/zh.js +1 -17
  90. package/dist/esm/i18n/zh_TW.js +1 -17
  91. package/dist/esm/plugins/extension/actions.js +135 -125
  92. package/dist/esm/plugins/extension/extension-api.js +11 -9
  93. package/dist/esm/plugins/extension/index.js +6 -4
  94. package/dist/esm/plugins/extension/toolbar.js +5 -4
  95. package/dist/esm/plugins/insert-block/index.js +2 -2
  96. package/dist/esm/plugins/macro/actions.js +94 -93
  97. package/dist/esm/version-wrapper.js +1 -1
  98. package/dist/types/i18n/cs.d.ts +0 -16
  99. package/dist/types/i18n/da.d.ts +0 -16
  100. package/dist/types/i18n/de.d.ts +0 -16
  101. package/dist/types/i18n/en.d.ts +0 -16
  102. package/dist/types/i18n/en_GB.d.ts +0 -16
  103. package/dist/types/i18n/en_ZZ.d.ts +0 -16
  104. package/dist/types/i18n/es.d.ts +0 -16
  105. package/dist/types/i18n/fi.d.ts +0 -16
  106. package/dist/types/i18n/fr.d.ts +0 -16
  107. package/dist/types/i18n/hu.d.ts +0 -16
  108. package/dist/types/i18n/it.d.ts +0 -16
  109. package/dist/types/i18n/ja.d.ts +0 -16
  110. package/dist/types/i18n/ko.d.ts +0 -16
  111. package/dist/types/i18n/nb.d.ts +0 -16
  112. package/dist/types/i18n/nl.d.ts +0 -16
  113. package/dist/types/i18n/pl.d.ts +0 -16
  114. package/dist/types/i18n/pt_BR.d.ts +0 -16
  115. package/dist/types/i18n/ru.d.ts +0 -16
  116. package/dist/types/i18n/sv.d.ts +0 -16
  117. package/dist/types/i18n/th.d.ts +0 -16
  118. package/dist/types/i18n/tr.d.ts +0 -16
  119. package/dist/types/i18n/uk.d.ts +0 -16
  120. package/dist/types/i18n/vi.d.ts +0 -16
  121. package/dist/types/i18n/zh.d.ts +0 -16
  122. package/dist/types/i18n/zh_TW.d.ts +0 -16
  123. package/dist/types/plugins/expand/pm-plugins/main.d.ts +2 -2
  124. package/dist/types/plugins/extension/actions.d.ts +5 -10
  125. package/dist/types/plugins/extension/extension-api.d.ts +3 -1
  126. package/dist/types/plugins/extension/toolbar.d.ts +3 -1
  127. package/dist/types/plugins/macro/actions.d.ts +2 -1
  128. package/dist/types/presets/default.d.ts +52 -4
  129. package/dist/types-ts4.5/i18n/cs.d.ts +0 -16
  130. package/dist/types-ts4.5/i18n/da.d.ts +0 -16
  131. package/dist/types-ts4.5/i18n/de.d.ts +0 -16
  132. package/dist/types-ts4.5/i18n/en.d.ts +0 -16
  133. package/dist/types-ts4.5/i18n/en_GB.d.ts +0 -16
  134. package/dist/types-ts4.5/i18n/en_ZZ.d.ts +0 -16
  135. package/dist/types-ts4.5/i18n/es.d.ts +0 -16
  136. package/dist/types-ts4.5/i18n/fi.d.ts +0 -16
  137. package/dist/types-ts4.5/i18n/fr.d.ts +0 -16
  138. package/dist/types-ts4.5/i18n/hu.d.ts +0 -16
  139. package/dist/types-ts4.5/i18n/it.d.ts +0 -16
  140. package/dist/types-ts4.5/i18n/ja.d.ts +0 -16
  141. package/dist/types-ts4.5/i18n/ko.d.ts +0 -16
  142. package/dist/types-ts4.5/i18n/nb.d.ts +0 -16
  143. package/dist/types-ts4.5/i18n/nl.d.ts +0 -16
  144. package/dist/types-ts4.5/i18n/pl.d.ts +0 -16
  145. package/dist/types-ts4.5/i18n/pt_BR.d.ts +0 -16
  146. package/dist/types-ts4.5/i18n/ru.d.ts +0 -16
  147. package/dist/types-ts4.5/i18n/sv.d.ts +0 -16
  148. package/dist/types-ts4.5/i18n/th.d.ts +0 -16
  149. package/dist/types-ts4.5/i18n/tr.d.ts +0 -16
  150. package/dist/types-ts4.5/i18n/uk.d.ts +0 -16
  151. package/dist/types-ts4.5/i18n/vi.d.ts +0 -16
  152. package/dist/types-ts4.5/i18n/zh.d.ts +0 -16
  153. package/dist/types-ts4.5/i18n/zh_TW.d.ts +0 -16
  154. package/dist/types-ts4.5/plugins/expand/pm-plugins/main.d.ts +2 -2
  155. package/dist/types-ts4.5/plugins/extension/actions.d.ts +5 -10
  156. package/dist/types-ts4.5/plugins/extension/extension-api.d.ts +3 -1
  157. package/dist/types-ts4.5/plugins/extension/toolbar.d.ts +3 -1
  158. package/dist/types-ts4.5/plugins/macro/actions.d.ts +2 -1
  159. package/dist/types-ts4.5/presets/default.d.ts +60 -0
  160. package/package.json +2 -2
@@ -34,7 +34,6 @@ export default {
34
34
  'fabric.editor.edit': '編輯',
35
35
  'fabric.editor.editorAssistiveLabel': '主要內容區域,打字即可輸入文字。',
36
36
  'fabric.editor.editors': '編輯者',
37
- 'fabric.editor.error': '錯誤',
38
37
  'fabric.editor.extension.confirmDeleteLinkedModalMessage': '刪除 {nodeName} 將中斷與其連結的任何內容。',
39
38
  'fabric.editor.extension.confirmDeleteLinkedModalOKButton': '刪除',
40
39
  'fabric.editor.extension.deleteElementTitle': '刪除元素',
@@ -46,28 +45,13 @@ export default {
46
45
  'fabric.editor.floatingToolbar.confirmModalCheckboxLabel': '同時刪除已連結的元素',
47
46
  'fabric.editor.headingLink.toolbarHelpTitle': '開啟說明對話方塊',
48
47
  'fabric.editor.indent': '增加縮排',
49
- 'fabric.editor.info': '資訊',
50
- 'fabric.editor.leftSidebar': '左側資訊看板',
51
48
  'fabric.editor.matchCase': '大小寫須相符',
52
49
  'fabric.editor.noResultsFound': '沒有結果',
53
- 'fabric.editor.note': '附註',
54
50
  'fabric.editor.outdent': '減少縮排',
55
- 'fabric.editor.panel.backgroundColor': '背景顏色',
56
- 'fabric.editor.panel.emoji': '新增表情符號',
57
- 'fabric.editor.placeholderTextPlaceholder': '新增預留位置文字',
58
51
  'fabric.editor.replace': '取代',
59
52
  'fabric.editor.replaceAll': '全部取代',
60
53
  'fabric.editor.replaceWith': '取代為',
61
54
  'fabric.editor.resultsCount': '第 {selectedMatchPosition} 個,共 {totalResultsCount} 個',
62
- 'fabric.editor.rightSidebar': '右側資訊看板',
63
55
  'fabric.editor.selectLanguage': '選取語言',
64
- 'fabric.editor.single': '單欄',
65
- 'fabric.editor.success': '成功',
66
- 'fabric.editor.taskPlaceholder': '輸入動作,使用「@」以指派給他人。',
67
- 'fabric.editor.threeColumns': '三欄',
68
- 'fabric.editor.threeColumnsWithSidebars': '三個包含資訊看板的直欄',
69
- 'fabric.editor.twoColumns': '兩欄',
70
- 'fabric.editor.warning': '警告',
71
- 'fabric.editor.wrapLeft': '靠左圍繞',
72
- 'fabric.editor.wrapRight': '靠右圍繞'
56
+ 'fabric.editor.taskPlaceholder': '輸入動作,使用「@」以指派給他人。'
73
57
  };
@@ -7,7 +7,6 @@ import { Selection, NodeSelection, TextSelection } from '@atlaskit/editor-prosem
7
7
  import { replaceSelectedNode, findSelectedNodeOfType, replaceParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
8
8
  export { transformSliceToRemoveOpenBodiedExtension } from '@atlaskit/editor-common/transforms';
9
9
  import { ACTION, ACTION_SUBJECT, INPUT_METHOD, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
10
- import { addAnalytics } from '../analytics';
11
10
  import { TARGET_SELECTION_SOURCE } from '../analytics/types/extension-events';
12
11
  import { findExtensionWithLocalId } from './utils';
13
12
  import { getPluginState } from './pm-plugins/main';
@@ -22,140 +21,149 @@ export var buildExtensionNode = function buildExtensionNode(type, schema, attrs,
22
21
  return schema.nodes.bodiedExtension.create(attrs, content, marks);
23
22
  }
24
23
  };
25
- export var performNodeUpdate = function performNodeUpdate(type, newAttrs, content, marks, shouldScrollIntoView) {
26
- return function (_state, _dispatch, view) {
27
- if (!view) {
28
- throw Error('EditorView is required to perform node update!');
29
- }
30
- // NOTE: `state` and `dispatch` are stale at this point so we need to grab
31
- // the latest one from `view` @see HOT-93986
32
- var state = view.state,
33
- dispatch = view.dispatch;
34
- var newNode = buildExtensionNode(type, state.schema, newAttrs, content, marks);
35
- if (!newNode) {
36
- return false;
37
- }
38
- var selection = state.selection,
39
- schema = state.schema;
40
- var _schema$nodes = schema.nodes,
41
- extension = _schema$nodes.extension,
42
- inlineExtension = _schema$nodes.inlineExtension,
43
- bodiedExtension = _schema$nodes.bodiedExtension;
44
- var isBodiedExtensionSelected = !!findSelectedNodeOfType([bodiedExtension])(selection);
45
- var extensionState = getPluginState(state);
46
- var targetSelectionSource = TARGET_SELECTION_SOURCE.CURRENT_SELECTION;
47
- var action = ACTION.UPDATED;
48
- var tr = state.tr;
49
-
50
- // When it's a bodiedExtension but not selected
51
- if (newNode.type === bodiedExtension && !isBodiedExtensionSelected) {
52
- // Bodied extensions can trigger an update when the cursor is inside which means that there is no node selected.
53
- // To work around that we replace the parent and create a text selection instead of new node selection
54
- tr = replaceParentNodeOfType(state.schema.nodes.bodiedExtension, newNode)(tr);
55
- // Replacing selected node doesn't update the selection. `selection.node` still returns the old node
56
- tr.setSelection(TextSelection.create(tr.doc, state.selection.anchor));
57
- }
58
- // If any extension is currently selected
59
- else if (findSelectedNodeOfType([extension, bodiedExtension, inlineExtension])(selection)) {
60
- tr = replaceSelectedNode(newNode)(tr);
61
- // Replacing selected node doesn't update the selection. `selection.node` still returns the old node
62
- tr.setSelection(NodeSelection.create(tr.doc, tr.mapping.map(state.selection.anchor)));
63
- }
64
- // When we loose the selection. This usually happens when Synchrony resets or changes
65
- // the selection when user is in the middle of updating an extension.
66
- else if (extensionState.element) {
67
- var pos = view.posAtDOM(extensionState.element, -1);
68
- if (pos > -1) {
69
- tr = tr.replaceWith(pos, pos + (content.size || 0) + 1, newNode);
70
- tr.setSelection(Selection.near(tr.doc.resolve(pos)));
71
- targetSelectionSource = TARGET_SELECTION_SOURCE.HTML_ELEMENT;
72
- } else {
73
- action = ACTION.ERRORED;
24
+ export var performNodeUpdate = function performNodeUpdate(editorAnalyticsAPI) {
25
+ return function (type, newAttrs, content, marks, shouldScrollIntoView) {
26
+ return function (_state, _dispatch, view) {
27
+ if (!view) {
28
+ throw Error('EditorView is required to perform node update!');
74
29
  }
75
- }
30
+ // NOTE: `state` and `dispatch` are stale at this point so we need to grab
31
+ // the latest one from `view` @see HOT-93986
32
+ var state = view.state,
33
+ dispatch = view.dispatch;
34
+ var newNode = buildExtensionNode(type, state.schema, newAttrs, content, marks);
35
+ if (!newNode) {
36
+ return false;
37
+ }
38
+ var selection = state.selection,
39
+ schema = state.schema;
40
+ var _schema$nodes = schema.nodes,
41
+ extension = _schema$nodes.extension,
42
+ inlineExtension = _schema$nodes.inlineExtension,
43
+ bodiedExtension = _schema$nodes.bodiedExtension;
44
+ var isBodiedExtensionSelected = !!findSelectedNodeOfType([bodiedExtension])(selection);
45
+ var extensionState = getPluginState(state);
46
+ var targetSelectionSource = TARGET_SELECTION_SOURCE.CURRENT_SELECTION;
47
+ var action = ACTION.UPDATED;
48
+ var tr = state.tr;
76
49
 
77
- // Only scroll if we have anything to update, best to avoid surprise scroll
78
- if (dispatch && tr.docChanged) {
79
- var _newNode$attrs = newNode.attrs,
80
- extensionType = _newNode$attrs.extensionType,
81
- extensionKey = _newNode$attrs.extensionKey,
82
- layout = _newNode$attrs.layout,
83
- localId = _newNode$attrs.localId;
84
- addAnalytics(state, tr, {
85
- action: action,
86
- actionSubject: ACTION_SUBJECT.EXTENSION,
87
- actionSubjectId: newNode.type.name,
88
- eventType: EVENT_TYPE.TRACK,
89
- attributes: {
90
- inputMethod: INPUT_METHOD.CONFIG_PANEL,
91
- extensionType: extensionType,
92
- extensionKey: extensionKey,
93
- layout: layout,
94
- localId: localId,
95
- selection: tr.selection.toJSON(),
96
- targetSelectionSource: targetSelectionSource
50
+ // When it's a bodiedExtension but not selected
51
+ if (newNode.type === bodiedExtension && !isBodiedExtensionSelected) {
52
+ // Bodied extensions can trigger an update when the cursor is inside which means that there is no node selected.
53
+ // To work around that we replace the parent and create a text selection instead of new node selection
54
+ tr = replaceParentNodeOfType(state.schema.nodes.bodiedExtension, newNode)(tr);
55
+ // Replacing selected node doesn't update the selection. `selection.node` still returns the old node
56
+ tr.setSelection(TextSelection.create(tr.doc, state.selection.anchor));
57
+ }
58
+ // If any extension is currently selected
59
+ else if (findSelectedNodeOfType([extension, bodiedExtension, inlineExtension])(selection)) {
60
+ tr = replaceSelectedNode(newNode)(tr);
61
+ // Replacing selected node doesn't update the selection. `selection.node` still returns the old node
62
+ tr.setSelection(NodeSelection.create(tr.doc, tr.mapping.map(state.selection.anchor)));
63
+ }
64
+ // When we loose the selection. This usually happens when Synchrony resets or changes
65
+ // the selection when user is in the middle of updating an extension.
66
+ else if (extensionState.element) {
67
+ var pos = view.posAtDOM(extensionState.element, -1);
68
+ if (pos > -1) {
69
+ tr = tr.replaceWith(pos, pos + (content.size || 0) + 1, newNode);
70
+ tr.setSelection(Selection.near(tr.doc.resolve(pos)));
71
+ targetSelectionSource = TARGET_SELECTION_SOURCE.HTML_ELEMENT;
72
+ } else {
73
+ action = ACTION.ERRORED;
97
74
  }
98
- });
99
- dispatch(shouldScrollIntoView ? tr.scrollIntoView() : tr);
100
- }
101
- return true;
75
+ }
76
+
77
+ // Only scroll if we have anything to update, best to avoid surprise scroll
78
+ if (dispatch && tr.docChanged) {
79
+ var _newNode$attrs = newNode.attrs,
80
+ extensionType = _newNode$attrs.extensionType,
81
+ extensionKey = _newNode$attrs.extensionKey,
82
+ layout = _newNode$attrs.layout,
83
+ localId = _newNode$attrs.localId;
84
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
85
+ action: action,
86
+ actionSubject: ACTION_SUBJECT.EXTENSION,
87
+ actionSubjectId: newNode.type.name,
88
+ eventType: EVENT_TYPE.TRACK,
89
+ attributes: {
90
+ inputMethod: INPUT_METHOD.CONFIG_PANEL,
91
+ extensionType: extensionType,
92
+ extensionKey: extensionKey,
93
+ layout: layout,
94
+ localId: localId,
95
+ selection: tr.selection.toJSON(),
96
+ targetSelectionSource: targetSelectionSource
97
+ }
98
+ })(tr);
99
+ dispatch(shouldScrollIntoView ? tr.scrollIntoView() : tr);
100
+ }
101
+ return true;
102
+ };
102
103
  };
103
104
  };
104
- export var updateExtensionParams = function updateExtensionParams(updateExtension, node, actions) {
105
- return /*#__PURE__*/function () {
106
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(state, dispatch, view) {
107
- var _node$node, attrs, type, content, marks, parameters, newParameters, newAttrs;
108
- return _regeneratorRuntime.wrap(function _callee$(_context) {
109
- while (1) switch (_context.prev = _context.next) {
110
- case 0:
111
- _node$node = node.node, attrs = _node$node.attrs, type = _node$node.type, content = _node$node.content, marks = _node$node.marks;
112
- if (state.schema.nodes[type.name]) {
113
- _context.next = 3;
114
- break;
115
- }
116
- return _context.abrupt("return", false);
117
- case 3:
118
- parameters = attrs.parameters;
119
- _context.prev = 4;
120
- _context.next = 7;
121
- return updateExtension(parameters, actions);
122
- case 7:
123
- newParameters = _context.sent;
124
- if (!newParameters) {
125
- _context.next = 11;
105
+ var updateExtensionParams = function updateExtensionParams(editorAnalyticsAPI) {
106
+ return function (updateExtension, node, actions) {
107
+ return /*#__PURE__*/function () {
108
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(state, dispatch, view) {
109
+ var _node$node, attrs, type, content, marks, parameters, newParameters, newAttrs;
110
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
111
+ while (1) switch (_context.prev = _context.next) {
112
+ case 0:
113
+ _node$node = node.node, attrs = _node$node.attrs, type = _node$node.type, content = _node$node.content, marks = _node$node.marks;
114
+ if (state.schema.nodes[type.name]) {
115
+ _context.next = 3;
116
+ break;
117
+ }
118
+ return _context.abrupt("return", false);
119
+ case 3:
120
+ parameters = attrs.parameters;
121
+ _context.prev = 4;
122
+ _context.next = 7;
123
+ return updateExtension(parameters, actions);
124
+ case 7:
125
+ newParameters = _context.sent;
126
+ if (!newParameters) {
127
+ _context.next = 11;
128
+ break;
129
+ }
130
+ newAttrs = _objectSpread(_objectSpread({}, attrs), {}, {
131
+ parameters: _objectSpread(_objectSpread({}, parameters), newParameters)
132
+ });
133
+ return _context.abrupt("return", performNodeUpdate(editorAnalyticsAPI)(type.name, newAttrs, content, marks, true)(state, dispatch, view));
134
+ case 11:
135
+ _context.next = 15;
126
136
  break;
127
- }
128
- newAttrs = _objectSpread(_objectSpread({}, attrs), {}, {
129
- parameters: _objectSpread(_objectSpread({}, parameters), newParameters)
130
- });
131
- return _context.abrupt("return", performNodeUpdate(type.name, newAttrs, content, marks, true)(state, dispatch, view));
132
- case 11:
133
- _context.next = 15;
134
- break;
135
- case 13:
136
- _context.prev = 13;
137
- _context.t0 = _context["catch"](4);
138
- case 15:
139
- return _context.abrupt("return", true);
140
- case 16:
141
- case "end":
142
- return _context.stop();
143
- }
144
- }, _callee, null, [[4, 13]]);
145
- }));
146
- return function (_x, _x2, _x3) {
147
- return _ref.apply(this, arguments);
148
- };
149
- }();
137
+ case 13:
138
+ _context.prev = 13;
139
+ _context.t0 = _context["catch"](4);
140
+ case 15:
141
+ return _context.abrupt("return", true);
142
+ case 16:
143
+ case "end":
144
+ return _context.stop();
145
+ }
146
+ }, _callee, null, [[4, 13]]);
147
+ }));
148
+ return function (_x, _x2, _x3) {
149
+ return _ref.apply(this, arguments);
150
+ };
151
+ }();
152
+ };
150
153
  };
151
154
  export var editSelectedExtension = function editSelectedExtension(editorActions) {
152
155
  var editorView = editorActions._privateGetEditorView();
153
156
  var _getPluginState = getPluginState(editorView.state),
154
157
  updateExtension = _getPluginState.updateExtension,
155
158
  applyChangeToContextPanel = _getPluginState.applyChangeToContextPanel;
156
- return editExtension(null, applyChangeToContextPanel, updateExtension)(editorView.state, editorView.dispatch, editorView);
159
+ // The analytics API cannot be accessed in this case because
160
+ // we do not have access to the plugin injection API. Rather
161
+ // than change the way this works - we just won't use analytics
162
+ // here for now.
163
+ var editorAnalyticsAPI = undefined;
164
+ return editExtension(null, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension)(editorView.state, editorView.dispatch, editorView);
157
165
  };
158
- export var editExtension = function editExtension(macroProvider, applyChangeToContextPanel, updateExtension) {
166
+ export var editExtension = function editExtension(macroProvider, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension) {
159
167
  return function (state, dispatch, view) {
160
168
  if (!view) {
161
169
  return false;
@@ -168,7 +176,8 @@ export var editExtension = function editExtension(macroProvider, applyChangeToCo
168
176
  }
169
177
  var editInLegacyMacroBrowser = getEditInLegacyMacroBrowser({
170
178
  view: view,
171
- macroProvider: macroProvider || undefined
179
+ macroProvider: macroProvider || undefined,
180
+ editorAnalyticsAPI: editorAnalyticsAPI
172
181
  });
173
182
  if (updateExtension) {
174
183
  updateExtension.then(function (updateMethod) {
@@ -176,9 +185,10 @@ export var editExtension = function editExtension(macroProvider, applyChangeToCo
176
185
  var actions = createExtensionAPI({
177
186
  editorView: view,
178
187
  editInLegacyMacroBrowser: editInLegacyMacroBrowser,
179
- applyChange: applyChangeToContextPanel
188
+ applyChange: applyChangeToContextPanel,
189
+ editorAnalyticsAPI: editorAnalyticsAPI
180
190
  });
181
- updateExtensionParams(updateMethod, nodeWithPos, actions)(state, dispatch, view);
191
+ updateExtensionParams(editorAnalyticsAPI)(updateMethod, nodeWithPos, actions)(state, dispatch, view);
182
192
  return;
183
193
  }
184
194
  if (!updateMethod && macroProvider) {
@@ -9,11 +9,11 @@ import { nodeToJSON } from '../../utils';
9
9
  import { setEditingContextToContextPanel } from './commands';
10
10
  import { findNodePosWithLocalId, getDataConsumerMark, getNodeTypesReferenced, getSelectedExtension } from './utils';
11
11
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
12
- import { addAnalytics } from '../analytics';
13
12
  import { setTextSelection } from '@atlaskit/editor-prosemirror/utils';
14
13
  export var getEditInLegacyMacroBrowser = function getEditInLegacyMacroBrowser(_ref) {
15
14
  var view = _ref.view,
16
- macroProvider = _ref.macroProvider;
15
+ macroProvider = _ref.macroProvider,
16
+ editorAnalyticsAPI = _ref.editorAnalyticsAPI;
17
17
  return function () {
18
18
  if (!view) {
19
19
  throw new Error("Missing view. Can't update without EditorView");
@@ -25,7 +25,7 @@ export var getEditInLegacyMacroBrowser = function getEditInLegacyMacroBrowser(_r
25
25
  if (!nodeWithPos) {
26
26
  throw new Error("Missing nodeWithPos. Can't determine position of node");
27
27
  }
28
- insertMacroFromMacroBrowser(macroProvider, nodeWithPos.node, true)(view);
28
+ insertMacroFromMacroBrowser(editorAnalyticsAPI)(macroProvider, nodeWithPos.node, true)(view);
29
29
  };
30
30
  };
31
31
  var extensionAPICallPayload = function extensionAPICallPayload(functionName) {
@@ -40,7 +40,8 @@ var extensionAPICallPayload = function extensionAPICallPayload(functionName) {
40
40
  };
41
41
  };
42
42
  export var createExtensionAPI = function createExtensionAPI(options) {
43
- var schema = options.editorView.state.schema;
43
+ var schema = options.editorView.state.schema,
44
+ editorAnalyticsAPI = options.editorAnalyticsAPI;
44
45
  var nodes = Object.keys(schema.nodes);
45
46
  var marks = Object.keys(schema.marks);
46
47
  var validate = validator(nodes, marks, {
@@ -108,7 +109,7 @@ export var createExtensionAPI = function createExtensionAPI(options) {
108
109
 
109
110
  // Analytics - tracking the api call
110
111
  var apiCallPayload = extensionAPICallPayload('insertAfter');
111
- addAnalytics(state, tr, apiCallPayload);
112
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(apiCallPayload)(tr);
112
113
 
113
114
  // Analytics - tracking node types added
114
115
  var nodesAdded = [newNode];
@@ -142,7 +143,7 @@ export var createExtensionAPI = function createExtensionAPI(options) {
142
143
  },
143
144
  eventType: EVENT_TYPE.TRACK
144
145
  };
145
- addAnalytics(state, tr, payload);
146
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
146
147
  });
147
148
  if (opt && opt.allowSelectionToNewNode) {
148
149
  tr.setSelection(new NodeSelection(tr.doc.resolve(insertPosition)));
@@ -160,7 +161,7 @@ export var createExtensionAPI = function createExtensionAPI(options) {
160
161
  dispatch = _options$editorView.dispatch,
161
162
  state = _options$editorView.state;
162
163
  var tr = state.tr;
163
- tr = addAnalytics(state, tr, apiCallPayload);
164
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(apiCallPayload)(tr);
164
165
  tr = setTextSelection(nodePos.pos)(tr);
165
166
  tr = tr.scrollIntoView();
166
167
  dispatch(tr);
@@ -231,7 +232,7 @@ export var createExtensionAPI = function createExtensionAPI(options) {
231
232
 
232
233
  // Analytics - tracking the api call
233
234
  var apiCallPayload = extensionAPICallPayload('update');
234
- addAnalytics(state, tr, apiCallPayload);
235
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(apiCallPayload)(tr);
235
236
  dispatch(tr);
236
237
  }
237
238
  };
@@ -247,7 +248,8 @@ export var createExtensionAPI = function createExtensionAPI(options) {
247
248
  var macroState = macroPluginKey.getState(editorView.state);
248
249
  editInLegacy = getEditInLegacyMacroBrowser({
249
250
  view: options.editorView,
250
- macroProvider: (macroState === null || macroState === void 0 ? void 0 : macroState.macroProvider) || undefined
251
+ macroProvider: (macroState === null || macroState === void 0 ? void 0 : macroState.macroProvider) || undefined,
252
+ editorAnalyticsAPI: editorAnalyticsAPI
251
253
  });
252
254
  }
253
255
  editInLegacy();
@@ -7,7 +7,7 @@ import { getToolbarConfig } from './toolbar';
7
7
  import { getContextPanel } from './context-panel';
8
8
  import { createExtensionAPI } from './extension-api';
9
9
  var extensionPlugin = function extensionPlugin(_ref) {
10
- var _api$featureFlags, _api$contextPanel3, _api$contextPanel4;
10
+ var _api$featureFlags, _api$contextPanel3, _api$analytics2, _api$contextPanel4;
11
11
  var _ref$config = _ref.config,
12
12
  options = _ref$config === void 0 ? {} : _ref$config,
13
13
  _api = _ref.api;
@@ -73,10 +73,11 @@ var extensionPlugin = function extensionPlugin(_ref) {
73
73
  },
74
74
  actions: {
75
75
  api: function api() {
76
- var _api$contextPanel2;
76
+ var _api$contextPanel2, _api$analytics;
77
77
  return createExtensionAPI({
78
78
  editorView: editorViewRef.current,
79
- applyChange: _api === null || _api === void 0 || (_api$contextPanel2 = _api.contextPanel) === null || _api$contextPanel2 === void 0 ? void 0 : _api$contextPanel2.actions.applyChange
79
+ applyChange: _api === null || _api === void 0 || (_api$contextPanel2 = _api.contextPanel) === null || _api$contextPanel2 === void 0 ? void 0 : _api$contextPanel2.actions.applyChange,
80
+ editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics = _api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
80
81
  });
81
82
  }
82
83
  },
@@ -84,7 +85,8 @@ var extensionPlugin = function extensionPlugin(_ref) {
84
85
  floatingToolbar: getToolbarConfig({
85
86
  breakoutEnabled: options.breakoutEnabled,
86
87
  hoverDecoration: _api === null || _api === void 0 ? void 0 : _api.decorations.actions.hoverDecoration,
87
- applyChangeToContextPanel: _api === null || _api === void 0 || (_api$contextPanel3 = _api.contextPanel) === null || _api$contextPanel3 === void 0 ? void 0 : _api$contextPanel3.actions.applyChange
88
+ applyChangeToContextPanel: _api === null || _api === void 0 || (_api$contextPanel3 = _api.contextPanel) === null || _api$contextPanel3 === void 0 ? void 0 : _api$contextPanel3.actions.applyChange,
89
+ editorAnalyticsAPI: _api === null || _api === void 0 || (_api$analytics2 = _api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions
88
90
  }),
89
91
  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)
90
92
  }
@@ -89,7 +89,7 @@ var breakoutOptions = function breakoutOptions(state, formatMessage, extensionSt
89
89
  }
90
90
  return [];
91
91
  };
92
- var editButton = function editButton(formatMessage, extensionState, applyChangeToContextPanel) {
92
+ var editButton = function editButton(formatMessage, extensionState, applyChangeToContextPanel, editorAnalyticsAPI) {
93
93
  if (!extensionState.showEditButton) {
94
94
  return [];
95
95
  }
@@ -103,7 +103,7 @@ var editButton = function editButton(formatMessage, extensionState, applyChangeT
103
103
  var macroState = macroPluginKey.getState(state);
104
104
  var _getPluginState = getPluginState(state),
105
105
  updateExtension = _getPluginState.updateExtension;
106
- editExtension(macroState && macroState.macroProvider, applyChangeToContextPanel, updateExtension)(state, dispatch, view);
106
+ editExtension(macroState && macroState.macroProvider, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension)(state, dispatch, view);
107
107
  return true;
108
108
  },
109
109
  title: formatMessage(messages.edit),
@@ -115,13 +115,14 @@ export var getToolbarConfig = function getToolbarConfig(_ref) {
115
115
  var _ref$breakoutEnabled = _ref.breakoutEnabled,
116
116
  breakoutEnabled = _ref$breakoutEnabled === void 0 ? true : _ref$breakoutEnabled,
117
117
  hoverDecoration = _ref.hoverDecoration,
118
- applyChangeToContextPanel = _ref.applyChangeToContextPanel;
118
+ applyChangeToContextPanel = _ref.applyChangeToContextPanel,
119
+ editorAnalyticsAPI = _ref.editorAnalyticsAPI;
119
120
  return function (state, intl) {
120
121
  var formatMessage = intl.formatMessage;
121
122
  var extensionState = getPluginState(state);
122
123
  if (extensionState && !extensionState.showContextPanel && extensionState.element) {
123
124
  var nodeType = [state.schema.nodes.extension, state.schema.nodes.inlineExtension, state.schema.nodes.bodiedExtension];
124
- var editButtonArray = editButton(formatMessage, extensionState, applyChangeToContextPanel);
125
+ var editButtonArray = editButton(formatMessage, extensionState, applyChangeToContextPanel, editorAnalyticsAPI);
125
126
  var breakoutButtonArray = breakoutOptions(state, formatMessage, extensionState, breakoutEnabled);
126
127
  var extensionObj = getSelectedExtension(state, true);
127
128
 
@@ -101,7 +101,7 @@ var insertBlockPlugin = function insertBlockPlugin(_ref) {
101
101
  };
102
102
  };
103
103
  function ToolbarInsertBlockWithInjectionApi(_ref4) {
104
- var _ref5, _ref6, _pluginInjectionApi$i, _pluginInjectionApi$c, _pluginInjectionApi$p, _pluginInjectionApi$b;
104
+ var _ref5, _ref6, _pluginInjectionApi$i, _pluginInjectionApi$c, _pluginInjectionApi$p, _pluginInjectionApi$b, _pluginInjectionApi$a;
105
105
  var editorView = _ref4.editorView,
106
106
  editorActions = _ref4.editorActions,
107
107
  dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent,
@@ -158,7 +158,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
158
158
  nativeStatusSupported: options.nativeStatusSupported,
159
159
  horizontalRuleEnabled: options.horizontalRuleEnabled,
160
160
  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),
161
- onInsertMacroFromMacroBrowser: insertMacroFromMacroBrowser,
161
+ onInsertMacroFromMacroBrowser: insertMacroFromMacroBrowser(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions),
162
162
  macroProvider: macroState.macroProvider,
163
163
  popupsMountPoint: popupsMountPoint,
164
164
  popupsBoundariesElement: popupsBoundariesElement,