@atlaskit/editor-core 185.2.25 → 185.2.26

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 (154) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/editor-next/editor-internal.js +3 -3
  3. package/dist/cjs/index.js +4 -4
  4. package/dist/cjs/labs/next/Editor.js +3 -3
  5. package/dist/cjs/nodeviews/index.js +1 -16
  6. package/dist/cjs/plugins/annotation/index.js +31 -21
  7. package/dist/cjs/plugins/annotation/nodeviews/index.js +2 -2
  8. package/dist/cjs/plugins/base/index.js +0 -6
  9. package/dist/cjs/plugins/caption/index.js +1 -2
  10. package/dist/cjs/plugins/caption/nodeviews/index.js +3 -3
  11. package/dist/cjs/plugins/caption/pm-plugins/main.js +4 -2
  12. package/dist/cjs/plugins/card/nodeviews/embedCard.js +4 -4
  13. package/dist/cjs/plugins/extension/nodeviews/extension.js +2 -2
  14. package/dist/cjs/plugins/jira-issue/index.js +2 -2
  15. package/dist/cjs/plugins/media/index.js +2 -2
  16. package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +25 -19
  17. package/dist/cjs/plugins/media/nodeviews/mediaInline.js +3 -3
  18. package/dist/cjs/plugins/media/nodeviews/mediaNodeView/index.js +16 -10
  19. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +2 -2
  20. package/dist/cjs/plugins/media/pm-plugins/main.js +25 -8
  21. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +2 -2
  22. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +2 -2
  23. package/dist/cjs/plugins/unsupported-content/index.js +6 -4
  24. package/dist/cjs/test-utils.js +0 -7
  25. package/dist/cjs/version-wrapper.js +1 -1
  26. package/dist/cjs/version.json +1 -1
  27. package/dist/es2019/editor-next/editor-internal.js +1 -1
  28. package/dist/es2019/index.js +1 -1
  29. package/dist/es2019/labs/next/Editor.js +1 -1
  30. package/dist/es2019/nodeviews/index.js +1 -2
  31. package/dist/es2019/plugins/annotation/index.js +34 -23
  32. package/dist/es2019/plugins/annotation/nodeviews/index.js +1 -1
  33. package/dist/es2019/plugins/base/index.js +0 -4
  34. package/dist/es2019/plugins/caption/index.js +1 -4
  35. package/dist/es2019/plugins/caption/nodeviews/index.js +2 -2
  36. package/dist/es2019/plugins/caption/pm-plugins/main.js +4 -2
  37. package/dist/es2019/plugins/card/nodeviews/embedCard.js +2 -2
  38. package/dist/es2019/plugins/extension/nodeviews/extension.js +1 -1
  39. package/dist/es2019/plugins/jira-issue/index.js +1 -1
  40. package/dist/es2019/plugins/media/index.js +2 -2
  41. package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +21 -14
  42. package/dist/es2019/plugins/media/nodeviews/mediaInline.js +2 -2
  43. package/dist/es2019/plugins/media/nodeviews/mediaNodeView/index.js +13 -9
  44. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +1 -1
  45. package/dist/es2019/plugins/media/pm-plugins/main.js +28 -11
  46. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +1 -1
  47. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -1
  48. package/dist/es2019/plugins/unsupported-content/index.js +1 -1
  49. package/dist/es2019/test-utils.js +0 -1
  50. package/dist/es2019/version-wrapper.js +1 -1
  51. package/dist/es2019/version.json +1 -1
  52. package/dist/esm/editor-next/editor-internal.js +1 -1
  53. package/dist/esm/index.js +1 -1
  54. package/dist/esm/labs/next/Editor.js +1 -1
  55. package/dist/esm/nodeviews/index.js +1 -2
  56. package/dist/esm/plugins/annotation/index.js +32 -22
  57. package/dist/esm/plugins/annotation/nodeviews/index.js +1 -1
  58. package/dist/esm/plugins/base/index.js +0 -6
  59. package/dist/esm/plugins/caption/index.js +1 -2
  60. package/dist/esm/plugins/caption/nodeviews/index.js +2 -2
  61. package/dist/esm/plugins/caption/pm-plugins/main.js +4 -2
  62. package/dist/esm/plugins/card/nodeviews/embedCard.js +4 -4
  63. package/dist/esm/plugins/extension/nodeviews/extension.js +1 -1
  64. package/dist/esm/plugins/jira-issue/index.js +1 -1
  65. package/dist/esm/plugins/media/index.js +2 -2
  66. package/dist/esm/plugins/media/nodeviews/mediaGroup.js +24 -18
  67. package/dist/esm/plugins/media/nodeviews/mediaInline.js +2 -2
  68. package/dist/esm/plugins/media/nodeviews/mediaNodeView/index.js +15 -9
  69. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +1 -1
  70. package/dist/esm/plugins/media/pm-plugins/main.js +26 -9
  71. package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +1 -1
  72. package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -1
  73. package/dist/esm/plugins/unsupported-content/index.js +1 -1
  74. package/dist/esm/test-utils.js +0 -1
  75. package/dist/esm/version-wrapper.js +1 -1
  76. package/dist/esm/version.json +1 -1
  77. package/dist/types/create-editor/ReactEditorViewInternal.d.ts +1 -1
  78. package/dist/types/index.d.ts +1 -1
  79. package/dist/types/labs/next/internal/components/EditorInternal.d.ts +2 -2
  80. package/dist/types/labs/next/internal/editor-props-type.d.ts +1 -1
  81. package/dist/types/labs/next/internal/hooks/use-editor/create-editor.d.ts +1 -1
  82. package/dist/types/nodeviews/index.d.ts +0 -2
  83. package/dist/types/plugins/annotation/index.d.ts +3 -1
  84. package/dist/types/plugins/annotation/nodeviews/index.d.ts +2 -1
  85. package/dist/types/plugins/annotation/pm-plugins/types.d.ts +2 -2
  86. package/dist/types/plugins/caption/index.d.ts +1 -1
  87. package/dist/types/plugins/caption/nodeviews/index.d.ts +7 -4
  88. package/dist/types/plugins/caption/pm-plugins/main.d.ts +5 -4
  89. package/dist/types/plugins/card/nodeviews/embedCard.d.ts +2 -2
  90. package/dist/types/plugins/extension/nodeviews/extension.d.ts +3 -2
  91. package/dist/types/plugins/extension/pm-plugins/main.d.ts +2 -2
  92. package/dist/types/plugins/media/index.d.ts +3 -1
  93. package/dist/types/plugins/media/nodeviews/mediaGroup.d.ts +5 -3
  94. package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +6 -3
  95. package/dist/types/plugins/media/nodeviews/mediaNodeView/index.d.ts +6 -4
  96. package/dist/types/plugins/media/nodeviews/mediaSingle.d.ts +2 -2
  97. package/dist/types/plugins/media/types.d.ts +4 -0
  98. package/dist/types/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +1 -1
  99. package/dist/types/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +1 -1
  100. package/dist/types/plugins/tasks-and-decisions/pm-plugins/main.d.ts +1 -1
  101. package/dist/types/test-utils.d.ts +0 -1
  102. package/dist/types-ts4.5/create-editor/ReactEditorViewInternal.d.ts +1 -1
  103. package/dist/types-ts4.5/index.d.ts +1 -1
  104. package/dist/types-ts4.5/labs/next/internal/components/EditorInternal.d.ts +2 -2
  105. package/dist/types-ts4.5/labs/next/internal/editor-props-type.d.ts +1 -1
  106. package/dist/types-ts4.5/labs/next/internal/hooks/use-editor/create-editor.d.ts +1 -1
  107. package/dist/types-ts4.5/nodeviews/index.d.ts +0 -2
  108. package/dist/types-ts4.5/plugins/annotation/index.d.ts +3 -1
  109. package/dist/types-ts4.5/plugins/annotation/nodeviews/index.d.ts +2 -1
  110. package/dist/types-ts4.5/plugins/annotation/pm-plugins/types.d.ts +2 -2
  111. package/dist/types-ts4.5/plugins/caption/index.d.ts +1 -1
  112. package/dist/types-ts4.5/plugins/caption/nodeviews/index.d.ts +7 -4
  113. package/dist/types-ts4.5/plugins/caption/pm-plugins/main.d.ts +5 -4
  114. package/dist/types-ts4.5/plugins/card/nodeviews/embedCard.d.ts +2 -2
  115. package/dist/types-ts4.5/plugins/extension/nodeviews/extension.d.ts +3 -2
  116. package/dist/types-ts4.5/plugins/extension/pm-plugins/main.d.ts +2 -2
  117. package/dist/types-ts4.5/plugins/media/index.d.ts +3 -1
  118. package/dist/types-ts4.5/plugins/media/nodeviews/mediaGroup.d.ts +5 -3
  119. package/dist/types-ts4.5/plugins/media/nodeviews/mediaInline.d.ts +6 -3
  120. package/dist/types-ts4.5/plugins/media/nodeviews/mediaNodeView/index.d.ts +6 -4
  121. package/dist/types-ts4.5/plugins/media/nodeviews/mediaSingle.d.ts +2 -2
  122. package/dist/types-ts4.5/plugins/media/types.d.ts +4 -0
  123. package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +1 -1
  124. package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +1 -1
  125. package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/main.d.ts +1 -1
  126. package/dist/types-ts4.5/test-utils.d.ts +0 -1
  127. package/package.json +2 -2
  128. package/report.api.md +20 -85
  129. package/tmp/api-report-tmp.d.ts +18 -68
  130. package/dist/cjs/nodeviews/ReactNodeView.js +0 -224
  131. package/dist/cjs/nodeviews/SelectionBasedNodeView.js +0 -169
  132. package/dist/cjs/plugins/base/pm-plugins/react-nodeview.js +0 -72
  133. package/dist/cjs/ui/PortalProvider/PortalProviderThemesProvider.js +0 -43
  134. package/dist/cjs/ui/PortalProvider/index.js +0 -252
  135. package/dist/es2019/nodeviews/ReactNodeView.js +0 -170
  136. package/dist/es2019/nodeviews/SelectionBasedNodeView.js +0 -158
  137. package/dist/es2019/plugins/base/pm-plugins/react-nodeview.js +0 -48
  138. package/dist/es2019/ui/PortalProvider/PortalProviderThemesProvider.js +0 -37
  139. package/dist/es2019/ui/PortalProvider/index.js +0 -184
  140. package/dist/esm/nodeviews/ReactNodeView.js +0 -217
  141. package/dist/esm/nodeviews/SelectionBasedNodeView.js +0 -163
  142. package/dist/esm/plugins/base/pm-plugins/react-nodeview.js +0 -62
  143. package/dist/esm/ui/PortalProvider/PortalProviderThemesProvider.js +0 -36
  144. package/dist/esm/ui/PortalProvider/index.js +0 -242
  145. package/dist/types/nodeviews/ReactNodeView.d.ts +0 -52
  146. package/dist/types/nodeviews/SelectionBasedNodeView.d.ts +0 -53
  147. package/dist/types/plugins/base/pm-plugins/react-nodeview.d.ts +0 -13
  148. package/dist/types/ui/PortalProvider/PortalProviderThemesProvider.d.ts +0 -6
  149. package/dist/types/ui/PortalProvider/index.d.ts +0 -51
  150. package/dist/types-ts4.5/nodeviews/ReactNodeView.d.ts +0 -52
  151. package/dist/types-ts4.5/nodeviews/SelectionBasedNodeView.d.ts +0 -53
  152. package/dist/types-ts4.5/plugins/base/pm-plugins/react-nodeview.d.ts +0 -13
  153. package/dist/types-ts4.5/ui/PortalProvider/PortalProviderThemesProvider.d.ts +0 -6
  154. package/dist/types-ts4.5/ui/PortalProvider/index.d.ts +0 -51
@@ -1,252 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.PortalRenderer = exports.PortalProviderWithThemeProviders = exports.PortalProviderAPI = exports.PortalProvider = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
- var _react = _interopRequireDefault(require("react"));
17
- var _reactDom = require("react-dom");
18
- var _propTypes = _interopRequireDefault(require("prop-types"));
19
- var _analyticsNextStableReactContext = _interopRequireDefault(require("@atlaskit/analytics-next-stable-react-context"));
20
- var _eventDispatcher = require("../../event-dispatcher");
21
- var _analytics = require("@atlaskit/editor-common/analytics");
22
- var _reactIntlNext = require("react-intl-next");
23
- var _components = require("@atlaskit/theme/components");
24
- var _PortalProviderThemesProvider = require("./PortalProviderThemesProvider");
25
- var _ui = require("@atlaskit/editor-common/ui");
26
- var _class;
27
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
28
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
29
- var PortalProviderAPI = /*#__PURE__*/function (_EventDispatcher) {
30
- (0, _inherits2.default)(PortalProviderAPI, _EventDispatcher);
31
- var _super = _createSuper(PortalProviderAPI);
32
- function PortalProviderAPI(intl, onAnalyticsEvent, analyticsContext, themeMode) {
33
- var _this;
34
- (0, _classCallCheck2.default)(this, PortalProviderAPI);
35
- _this = _super.call(this);
36
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "portals", new Map());
37
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setContext", function (context) {
38
- _this.context = context;
39
- });
40
- _this.intl = intl;
41
- _this.onAnalyticsEvent = onAnalyticsEvent;
42
- _this.useAnalyticsContext = analyticsContext;
43
- _this.themeMode = themeMode;
44
- return _this;
45
- }
46
- (0, _createClass2.default)(PortalProviderAPI, [{
47
- key: "render",
48
- value: function render(children, container) {
49
- var hasAnalyticsContext = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
50
- var hasIntlContext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
51
- this.portals.set(container, {
52
- children: children,
53
- hasAnalyticsContext: hasAnalyticsContext,
54
- hasIntlContext: hasIntlContext
55
- });
56
- var childrenWithThemeProviders = /*#__PURE__*/_react.default.createElement(_PortalProviderThemesProvider.PortalProviderThemeProviders, {
57
- mode: this.themeMode
58
- }, children());
59
- var wrappedChildren = this.useAnalyticsContext ? /*#__PURE__*/_react.default.createElement(AnalyticsContextWrapper, null, childrenWithThemeProviders) : childrenWithThemeProviders;
60
- if (hasIntlContext) {
61
- wrappedChildren = /*#__PURE__*/_react.default.createElement(_reactIntlNext.RawIntlProvider, {
62
- value: this.intl
63
- }, wrappedChildren);
64
- }
65
- (0, _reactDom.unstable_renderSubtreeIntoContainer)(this.context, wrappedChildren, container);
66
- }
67
-
68
- // TODO: until https://product-fabric.atlassian.net/browse/ED-5013
69
- // we (unfortunately) need to re-render to pass down any updated context.
70
- // selectively do this for nodeviews that opt-in via `hasAnalyticsContext`
71
- }, {
72
- key: "forceUpdate",
73
- value: function forceUpdate(_ref) {
74
- var _this2 = this;
75
- var intl = _ref.intl,
76
- themeMode = _ref.themeMode;
77
- this.intl = intl;
78
- this.themeMode = themeMode;
79
- this.portals.forEach(function (portal, container) {
80
- if (!portal.hasAnalyticsContext && !_this2.useAnalyticsContext && !portal.hasIntlContext) {
81
- return;
82
- }
83
- var wrappedChildren = portal.children();
84
- var childrenWithThemeProviders = /*#__PURE__*/_react.default.createElement(_PortalProviderThemesProvider.PortalProviderThemeProviders, {
85
- mode: themeMode
86
- }, wrappedChildren);
87
- if (portal.hasAnalyticsContext && _this2.useAnalyticsContext) {
88
- wrappedChildren = /*#__PURE__*/_react.default.createElement(AnalyticsContextWrapper, null, childrenWithThemeProviders);
89
- }
90
- if (portal.hasIntlContext) {
91
- wrappedChildren = /*#__PURE__*/_react.default.createElement(_reactIntlNext.RawIntlProvider, {
92
- value: _this2.intl
93
- }, childrenWithThemeProviders);
94
- }
95
- (0, _reactDom.unstable_renderSubtreeIntoContainer)(_this2.context, wrappedChildren, container);
96
- });
97
- }
98
- }, {
99
- key: "remove",
100
- value: function remove(container) {
101
- this.portals.delete(container);
102
-
103
- // There is a race condition that can happen caused by Prosemirror vs React,
104
- // where Prosemirror removes the container from the DOM before React gets
105
- // around to removing the child from the container
106
- // This will throw a NotFoundError: The node to be removed is not a child of this node
107
- // Both Prosemirror and React remove the elements asynchronously, and in edge
108
- // cases Prosemirror beats React
109
- try {
110
- (0, _reactDom.unmountComponentAtNode)(container);
111
- } catch (error) {
112
- if (this.onAnalyticsEvent) {
113
- this.onAnalyticsEvent({
114
- payload: {
115
- action: _analytics.ACTION.FAILED_TO_UNMOUNT,
116
- actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
117
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.REACT_NODE_VIEW,
118
- attributes: {
119
- error: error,
120
- domNodes: {
121
- container: container ? container.className : undefined,
122
- child: container.firstElementChild ? container.firstElementChild.className : undefined
123
- }
124
- },
125
- eventType: _analytics.EVENT_TYPE.OPERATIONAL
126
- }
127
- });
128
- }
129
- }
130
- }
131
- }]);
132
- return PortalProviderAPI;
133
- }(_eventDispatcher.EventDispatcher);
134
- exports.PortalProviderAPI = PortalProviderAPI;
135
- var BasePortalProvider = /*#__PURE__*/function (_React$Component) {
136
- (0, _inherits2.default)(BasePortalProvider, _React$Component);
137
- var _super2 = _createSuper(BasePortalProvider);
138
- function BasePortalProvider(props) {
139
- var _this3;
140
- (0, _classCallCheck2.default)(this, BasePortalProvider);
141
- _this3 = _super2.call(this, props);
142
- _this3.portalProviderAPI = new PortalProviderAPI(props.intl, props.onAnalyticsEvent, props.useAnalyticsContext, props.themeMode);
143
- return _this3;
144
- }
145
- (0, _createClass2.default)(BasePortalProvider, [{
146
- key: "render",
147
- value: function render() {
148
- return this.props.render(this.portalProviderAPI);
149
- }
150
- }, {
151
- key: "componentDidUpdate",
152
- value: function componentDidUpdate() {
153
- this.portalProviderAPI.forceUpdate({
154
- intl: this.props.intl,
155
- themeMode: this.props.themeMode
156
- });
157
- }
158
- }]);
159
- return BasePortalProvider;
160
- }(_react.default.Component);
161
- (0, _defineProperty2.default)(BasePortalProvider, "displayName", 'PortalProvider');
162
- var PortalProvider = (0, _reactIntlNext.injectIntl)(BasePortalProvider);
163
- exports.PortalProvider = PortalProvider;
164
- var PortalProviderWithThemeProviders = function PortalProviderWithThemeProviders(_ref2) {
165
- var onAnalyticsEvent = _ref2.onAnalyticsEvent,
166
- useAnalyticsContext = _ref2.useAnalyticsContext,
167
- render = _ref2.render;
168
- return /*#__PURE__*/_react.default.createElement(_ui.IntlProviderIfMissingWrapper, null, /*#__PURE__*/_react.default.createElement(PortalProviderWithThemeAndIntlProviders, {
169
- onAnalyticsEvent: onAnalyticsEvent,
170
- useAnalyticsContext: useAnalyticsContext,
171
- render: render
172
- }));
173
- };
174
- exports.PortalProviderWithThemeProviders = PortalProviderWithThemeProviders;
175
- var PortalProviderWithThemeAndIntlProviders = function PortalProviderWithThemeAndIntlProviders(_ref3) {
176
- var onAnalyticsEvent = _ref3.onAnalyticsEvent,
177
- useAnalyticsContext = _ref3.useAnalyticsContext,
178
- render = _ref3.render;
179
- var intl = (0, _reactIntlNext.useIntl)();
180
- var globalTheme = (0, _components.useGlobalTheme)();
181
- return /*#__PURE__*/_react.default.createElement(BasePortalProvider, {
182
- intl: intl,
183
- themeMode: globalTheme.mode,
184
- onAnalyticsEvent: onAnalyticsEvent,
185
- useAnalyticsContext: useAnalyticsContext,
186
- render: render
187
- });
188
- };
189
- var PortalRenderer = /*#__PURE__*/function (_React$Component2) {
190
- (0, _inherits2.default)(PortalRenderer, _React$Component2);
191
- var _super3 = _createSuper(PortalRenderer);
192
- function PortalRenderer(props) {
193
- var _this4;
194
- (0, _classCallCheck2.default)(this, PortalRenderer);
195
- _this4 = _super3.call(this, props);
196
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this4), "handleUpdate", function (portals) {
197
- return _this4.setState({
198
- portals: portals
199
- });
200
- });
201
- props.portalProviderAPI.setContext((0, _assertThisInitialized2.default)(_this4));
202
- props.portalProviderAPI.on('update', _this4.handleUpdate);
203
- _this4.state = {
204
- portals: new Map()
205
- };
206
- return _this4;
207
- }
208
- (0, _createClass2.default)(PortalRenderer, [{
209
- key: "render",
210
- value: function render() {
211
- var portals = this.state.portals;
212
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, Array.from(portals.entries()).map(function (_ref4) {
213
- var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
214
- container = _ref5[0],
215
- children = _ref5[1];
216
- return /*#__PURE__*/(0, _reactDom.createPortal)(children, container);
217
- }));
218
- }
219
- }]);
220
- return PortalRenderer;
221
- }(_react.default.Component);
222
- /**
223
- * Wrapper to re-provide modern analytics context to ReactNodeViews.
224
- */
225
- exports.PortalRenderer = PortalRenderer;
226
- var dummyAnalyticsContext = {
227
- getAtlaskitAnalyticsContext: function getAtlaskitAnalyticsContext() {},
228
- getAtlaskitAnalyticsEventHandlers: function getAtlaskitAnalyticsEventHandlers() {}
229
- };
230
- var AnalyticsContextWrapper = (_class = /*#__PURE__*/function (_React$Component3) {
231
- (0, _inherits2.default)(AnalyticsContextWrapper, _React$Component3);
232
- var _super4 = _createSuper(AnalyticsContextWrapper);
233
- function AnalyticsContextWrapper() {
234
- (0, _classCallCheck2.default)(this, AnalyticsContextWrapper);
235
- return _super4.apply(this, arguments);
236
- }
237
- (0, _createClass2.default)(AnalyticsContextWrapper, [{
238
- key: "render",
239
- value: function render() {
240
- var _ref6 = this.context.contextAdapter.analytics || {
241
- value: dummyAnalyticsContext
242
- },
243
- value = _ref6.value;
244
- return /*#__PURE__*/_react.default.createElement(_analyticsNextStableReactContext.default.Provider, {
245
- value: value
246
- }, this.props.children);
247
- }
248
- }]);
249
- return AnalyticsContextWrapper;
250
- }(_react.default.Component), (0, _defineProperty2.default)(_class, "contextTypes", {
251
- contextAdapter: _propTypes.default.object
252
- }), _class);
@@ -1,170 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import React from 'react';
4
- import { createDispatch } from '../event-dispatcher';
5
- import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../plugins/analytics';
6
- import { analyticsEventKey } from '../plugins/analytics/consts';
7
- import { ErrorBoundary } from '../ui/ErrorBoundary';
8
- import { getPerformanceOptions, startMeasureReactNodeViewRendered, stopMeasureReactNodeViewRendered } from './getPerformanceOptions';
9
- export default class ReactNodeView {
10
- constructor(_node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, reactComponent, hasAnalyticsContext = false, viewShouldUpdate, hasIntlContext = false) {
11
- _defineProperty(this, "handleRef", node => this._handleRef(node));
12
- _defineProperty(this, "dispatchAnalyticsEvent", payload => {
13
- if (this.eventDispatcher) {
14
- const dispatch = createDispatch(this.eventDispatcher);
15
- dispatch(analyticsEventKey, {
16
- payload
17
- });
18
- }
19
- });
20
- this.node = _node;
21
- this.view = view;
22
- this.getPos = getPos;
23
- this.portalProviderAPI = portalProviderAPI;
24
- this.reactComponentProps = reactComponentProps || {};
25
- this.reactComponent = reactComponent;
26
- this.hasAnalyticsContext = hasAnalyticsContext;
27
- this._viewShouldUpdate = viewShouldUpdate;
28
- this.eventDispatcher = eventDispatcher;
29
- this.hasIntlContext = hasIntlContext;
30
- }
31
-
32
- /**
33
- * This method exists to move initialization logic out of the constructor,
34
- * so object can be initialized properly before calling render first time.
35
- *
36
- * Example:
37
- * Instance properties get added to an object only after super call in
38
- * constructor, which leads to some methods being undefined during the
39
- * first render.
40
- */
41
- init() {
42
- this.domRef = this.createDomRef();
43
- this.setDomAttrs(this.node, this.domRef);
44
- const {
45
- dom: contentDOMWrapper,
46
- contentDOM
47
- } = this.getContentDOM() || {
48
- dom: undefined,
49
- contentDOM: undefined
50
- };
51
- if (this.domRef && contentDOMWrapper) {
52
- this.domRef.appendChild(contentDOMWrapper);
53
- this.contentDOM = contentDOM ? contentDOM : contentDOMWrapper;
54
- this.contentDOMWrapper = contentDOMWrapper || contentDOM;
55
- }
56
-
57
- // @see ED-3790
58
- // something gets messed up during mutation processing inside of a
59
- // nodeView if DOM structure has nested plain "div"s, it doesn't see the
60
- // difference between them and it kills the nodeView
61
- this.domRef.classList.add(`${this.node.type.name}View-content-wrap`);
62
- const {
63
- samplingRate,
64
- slowThreshold,
65
- trackingEnabled
66
- } = getPerformanceOptions(this.view);
67
- trackingEnabled && startMeasureReactNodeViewRendered({
68
- nodeTypeName: this.node.type.name
69
- });
70
- this.renderReactComponent(() => this.render(this.reactComponentProps, this.handleRef));
71
- trackingEnabled && stopMeasureReactNodeViewRendered({
72
- nodeTypeName: this.node.type.name,
73
- dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
74
- editorState: this.view.state,
75
- samplingRate,
76
- slowThreshold
77
- });
78
- return this;
79
- }
80
- renderReactComponent(component) {
81
- if (!this.domRef || !component) {
82
- return;
83
- }
84
- const componentWithErrorBoundary = () => {
85
- var _this$node$type$name, _this$node, _this$node$type;
86
- return /*#__PURE__*/React.createElement(ErrorBoundary, {
87
- component: ACTION_SUBJECT.REACT_NODE_VIEW,
88
- componentId: (_this$node$type$name = this === null || this === void 0 ? void 0 : (_this$node = this.node) === null || _this$node === void 0 ? void 0 : (_this$node$type = _this$node.type) === null || _this$node$type === void 0 ? void 0 : _this$node$type.name) !== null && _this$node$type$name !== void 0 ? _this$node$type$name : ACTION_SUBJECT_ID.UNKNOWN_NODE,
89
- dispatchAnalyticsEvent: this.dispatchAnalyticsEvent
90
- }, component());
91
- };
92
- this.portalProviderAPI.render(componentWithErrorBoundary, this.domRef, this.hasAnalyticsContext, this.hasIntlContext);
93
- }
94
- createDomRef() {
95
- if (!this.node.isInline) {
96
- return document.createElement('div');
97
- }
98
- const htmlElement = document.createElement('span');
99
- return htmlElement;
100
- }
101
- getContentDOM() {
102
- return undefined;
103
- }
104
- _handleRef(node) {
105
- const contentDOM = this.contentDOMWrapper || this.contentDOM;
106
-
107
- // move the contentDOM node inside the inner reference after rendering
108
- if (node && contentDOM && !node.contains(contentDOM)) {
109
- node.appendChild(contentDOM);
110
- }
111
- }
112
- render(props, forwardRef) {
113
- return this.reactComponent ? /*#__PURE__*/React.createElement(this.reactComponent, _extends({
114
- view: this.view,
115
- getPos: this.getPos,
116
- node: this.node,
117
- forwardRef: forwardRef
118
- }, props)) : null;
119
- }
120
- update(node, _decorations, _innerDecorations, validUpdate = () => true) {
121
- // @see https://github.com/ProseMirror/prosemirror/issues/648
122
- const isValidUpdate = this.node.type === node.type && validUpdate(this.node, node);
123
- if (!isValidUpdate) {
124
- return false;
125
- }
126
- if (this.domRef && !this.node.sameMarkup(node)) {
127
- this.setDomAttrs(node, this.domRef);
128
- }
129
-
130
- // View should not process a re-render if this is false.
131
- // We dont want to destroy the view, so we return true.
132
- if (!this.viewShouldUpdate(node)) {
133
- this.node = node;
134
- return true;
135
- }
136
- this.node = node;
137
- this.renderReactComponent(() => this.render(this.reactComponentProps, this.handleRef));
138
- return true;
139
- }
140
- viewShouldUpdate(nextNode) {
141
- if (this._viewShouldUpdate) {
142
- return this._viewShouldUpdate(nextNode);
143
- }
144
- return true;
145
- }
146
-
147
- /**
148
- * Copies the attributes from a ProseMirror Node to a DOM node.
149
- * @param node The Prosemirror Node from which to source the attributes
150
- */
151
- setDomAttrs(node, element) {
152
- Object.keys(node.attrs || {}).forEach(attr => {
153
- element.setAttribute(attr, node.attrs[attr]);
154
- });
155
- }
156
- get dom() {
157
- return this.domRef;
158
- }
159
- destroy() {
160
- if (!this.domRef) {
161
- return;
162
- }
163
- this.portalProviderAPI.remove(this.domRef);
164
- this.domRef = undefined;
165
- this.contentDOM = undefined;
166
- }
167
- static fromComponent(component, portalProviderAPI, eventDispatcher, props, viewShouldUpdate, hasIntlContext = false) {
168
- return (node, view, getPos) => new ReactNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, props, component, false, viewShouldUpdate, hasIntlContext).init();
169
- }
170
- }
@@ -1,158 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import { NodeSelection } from 'prosemirror-state';
3
- import { stateKey as SelectionChangePluginKey } from '../plugins/base/pm-plugins/react-nodeview';
4
- import ReactNodeView from './ReactNodeView';
5
-
6
- /**
7
- * A ReactNodeView that handles React components sensitive
8
- * to selection changes.
9
- *
10
- * If the selection changes, it will attempt to re-render the
11
- * React component. Otherwise it does nothing.
12
- *
13
- * You can subclass `viewShouldUpdate` to include other
14
- * props that your component might want to consider before
15
- * entering the React lifecycle. These are usually props you
16
- * compare in `shouldComponentUpdate`.
17
- *
18
- * An example:
19
- *
20
- * ```
21
- * viewShouldUpdate(nextNode) {
22
- * if (nextNode.attrs !== this.node.attrs) {
23
- * return true;
24
- * }
25
- *
26
- * return super.viewShouldUpdate(nextNode);
27
- * }```
28
- */
29
-
30
- export class SelectionBasedNodeView extends ReactNodeView {
31
- constructor(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, reactComponent, hasContext = false, viewShouldUpdate, hasIntlContext = false) {
32
- super(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, reactComponent, hasContext, viewShouldUpdate, hasIntlContext);
33
- _defineProperty(this, "isNodeInsideSelection", (from, to, pos, posEnd) => {
34
- ({
35
- pos,
36
- posEnd
37
- } = this.getPositionsWithDefault(pos, posEnd));
38
- if (typeof pos !== 'number' || typeof posEnd !== 'number') {
39
- return false;
40
- }
41
- return from <= pos && to >= posEnd;
42
- });
43
- _defineProperty(this, "isSelectionInsideNode", (from, to, pos, posEnd) => {
44
- ({
45
- pos,
46
- posEnd
47
- } = this.getPositionsWithDefault(pos, posEnd));
48
- if (typeof pos !== 'number' || typeof posEnd !== 'number') {
49
- return false;
50
- }
51
- return pos < from && to < posEnd;
52
- });
53
- _defineProperty(this, "isSelectedNode", selection => {
54
- if (selection instanceof NodeSelection) {
55
- const {
56
- selection: {
57
- from,
58
- to
59
- }
60
- } = this.view.state;
61
- return selection.node === this.node ||
62
- // If nodes are not the same object, we check if they are referring to the same document node
63
- this.pos === from && this.posEnd === to && selection.node.eq(this.node);
64
- }
65
- return false;
66
- });
67
- _defineProperty(this, "insideSelection", () => {
68
- const {
69
- selection: {
70
- from,
71
- to
72
- }
73
- } = this.view.state;
74
- return this.isSelectedNode(this.view.state.selection) || this.isSelectionInsideNode(from, to);
75
- });
76
- _defineProperty(this, "nodeInsideSelection", () => {
77
- const {
78
- selection
79
- } = this.view.state;
80
- const {
81
- from,
82
- to
83
- } = selection;
84
- return this.isSelectedNode(selection) || this.isNodeInsideSelection(from, to);
85
- });
86
- _defineProperty(this, "onSelectionChange", () => {
87
- this.update(this.node, []);
88
- });
89
- this.updatePos();
90
- this.oldSelection = view.state.selection;
91
- this.selectionChangeState = SelectionChangePluginKey.getState(this.view.state);
92
- this.selectionChangeState.subscribe(this.onSelectionChange);
93
- }
94
-
95
- /**
96
- * Update current node's start and end positions.
97
- *
98
- * Prefer `this.pos` rather than getPos(), because calling getPos is
99
- * expensive, unless you know you're definitely going to render.
100
- */
101
- updatePos() {
102
- if (typeof this.getPos === 'boolean') {
103
- return;
104
- }
105
- this.pos = this.getPos();
106
- this.posEnd = this.pos + this.node.nodeSize;
107
- }
108
- getPositionsWithDefault(pos, posEnd) {
109
- return {
110
- pos: typeof pos !== 'number' ? this.pos : pos,
111
- posEnd: typeof posEnd !== 'number' ? this.posEnd : posEnd
112
- };
113
- }
114
- viewShouldUpdate(_nextNode) {
115
- const {
116
- state: {
117
- selection
118
- }
119
- } = this.view;
120
-
121
- // update selection
122
- const oldSelection = this.oldSelection;
123
- this.oldSelection = selection;
124
-
125
- // update cached positions
126
- const {
127
- pos: oldPos,
128
- posEnd: oldPosEnd
129
- } = this;
130
- this.updatePos();
131
- const {
132
- from,
133
- to
134
- } = selection;
135
- const {
136
- from: oldFrom,
137
- to: oldTo
138
- } = oldSelection;
139
- if (this.node.type.spec.selectable) {
140
- const newNodeSelection = selection instanceof NodeSelection && selection.from === this.pos;
141
- const oldNodeSelection = oldSelection instanceof NodeSelection && oldSelection.from === this.pos;
142
- if (newNodeSelection && !oldNodeSelection || oldNodeSelection && !newNodeSelection) {
143
- return true;
144
- }
145
- }
146
- const movedInToSelection = this.isNodeInsideSelection(from, to) && !this.isNodeInsideSelection(oldFrom, oldTo);
147
- const movedOutOfSelection = !this.isNodeInsideSelection(from, to) && this.isNodeInsideSelection(oldFrom, oldTo);
148
- const moveOutFromOldSelection = this.isNodeInsideSelection(from, to, oldPos, oldPosEnd) && !this.isNodeInsideSelection(from, to);
149
- if (movedInToSelection || movedOutOfSelection || moveOutFromOldSelection) {
150
- return true;
151
- }
152
- return false;
153
- }
154
- destroy() {
155
- this.selectionChangeState.unsubscribe(this.onSelectionChange);
156
- super.destroy();
157
- }
158
- }
@@ -1,48 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import { PluginKey } from 'prosemirror-state';
4
- export class ReactNodeViewState {
5
- constructor() {
6
- _defineProperty(this, "changeHandlers", []);
7
- this.changeHandlers = [];
8
- }
9
- subscribe(cb) {
10
- this.changeHandlers.push(cb);
11
- }
12
- unsubscribe(cb) {
13
- this.changeHandlers = this.changeHandlers.filter(ch => ch !== cb);
14
- }
15
- notifyNewSelection(fromPos, toPos) {
16
- this.changeHandlers.forEach(cb => cb(fromPos, toPos));
17
- }
18
- }
19
- export const stateKey = new PluginKey('reactNodeView');
20
- export const plugin = new SafePlugin({
21
- state: {
22
- init() {
23
- return new ReactNodeViewState();
24
- },
25
- apply(_tr, pluginState) {
26
- return pluginState;
27
- }
28
- },
29
- key: stateKey,
30
- view: view => {
31
- const pluginState = stateKey.getState(view.state);
32
- let prevFrom = -1;
33
- let prevTo = -1;
34
- return {
35
- update: view => {
36
- const {
37
- from,
38
- to
39
- } = view.state.selection;
40
- if (from !== prevFrom || to !== prevTo) {
41
- pluginState.notifyNewSelection(from, to);
42
- prevFrom = from;
43
- prevTo = to;
44
- }
45
- }
46
- };
47
- }
48
- });
@@ -1,37 +0,0 @@
1
- import React from 'react';
2
- import AtlaskitTheme from '@atlaskit/theme/components';
3
- import { CHANNEL } from '@atlaskit/theme/constants';
4
- import { ThemeProvider } from '@emotion/react';
5
- export function PortalProviderThemeProviders(props) {
6
- const {
7
- children,
8
- mode
9
- } = props;
10
- const styledComponentsAndEmotionTheme = React.useMemo(
11
- // This return value should only be one of the following
12
- // - { [CHANNEL]: { mode },
13
- // - { theme: { [CHANNEL]: { mode } }
14
- // However, it appears that consumers have inconsistent expectations
15
- // regarding the shape.
16
- // This can be revisited in future work, and for the purposes of
17
- // fixing https://product-fabric.atlassian.net/browse/ED-14956
18
- // we are merging the two shapes consumers expect.
19
- () => ({
20
- [CHANNEL]: {
21
- mode
22
- },
23
- theme: {
24
- [CHANNEL]: {
25
- mode
26
- }
27
- }
28
- }), [mode]);
29
- const atlaskitTheme = React.useCallback(() => ({
30
- mode
31
- }), [mode]);
32
- return /*#__PURE__*/React.createElement(ThemeProvider, {
33
- theme: styledComponentsAndEmotionTheme
34
- }, /*#__PURE__*/React.createElement(AtlaskitTheme.Provider, {
35
- value: atlaskitTheme
36
- }, children));
37
- }