@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.
- package/CHANGELOG.md +7 -0
- package/dist/cjs/editor-next/editor-internal.js +3 -3
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/labs/next/Editor.js +3 -3
- package/dist/cjs/nodeviews/index.js +1 -16
- package/dist/cjs/plugins/annotation/index.js +31 -21
- package/dist/cjs/plugins/annotation/nodeviews/index.js +2 -2
- package/dist/cjs/plugins/base/index.js +0 -6
- package/dist/cjs/plugins/caption/index.js +1 -2
- package/dist/cjs/plugins/caption/nodeviews/index.js +3 -3
- package/dist/cjs/plugins/caption/pm-plugins/main.js +4 -2
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +4 -4
- package/dist/cjs/plugins/extension/nodeviews/extension.js +2 -2
- package/dist/cjs/plugins/jira-issue/index.js +2 -2
- package/dist/cjs/plugins/media/index.js +2 -2
- package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +25 -19
- package/dist/cjs/plugins/media/nodeviews/mediaInline.js +3 -3
- package/dist/cjs/plugins/media/nodeviews/mediaNodeView/index.js +16 -10
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +2 -2
- package/dist/cjs/plugins/media/pm-plugins/main.js +25 -8
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +2 -2
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +2 -2
- package/dist/cjs/plugins/unsupported-content/index.js +6 -4
- package/dist/cjs/test-utils.js +0 -7
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/editor-next/editor-internal.js +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/labs/next/Editor.js +1 -1
- package/dist/es2019/nodeviews/index.js +1 -2
- package/dist/es2019/plugins/annotation/index.js +34 -23
- package/dist/es2019/plugins/annotation/nodeviews/index.js +1 -1
- package/dist/es2019/plugins/base/index.js +0 -4
- package/dist/es2019/plugins/caption/index.js +1 -4
- package/dist/es2019/plugins/caption/nodeviews/index.js +2 -2
- package/dist/es2019/plugins/caption/pm-plugins/main.js +4 -2
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +2 -2
- package/dist/es2019/plugins/extension/nodeviews/extension.js +1 -1
- package/dist/es2019/plugins/jira-issue/index.js +1 -1
- package/dist/es2019/plugins/media/index.js +2 -2
- package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +21 -14
- package/dist/es2019/plugins/media/nodeviews/mediaInline.js +2 -2
- package/dist/es2019/plugins/media/nodeviews/mediaNodeView/index.js +13 -9
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/es2019/plugins/media/pm-plugins/main.js +28 -11
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +1 -1
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -1
- package/dist/es2019/plugins/unsupported-content/index.js +1 -1
- package/dist/es2019/test-utils.js +0 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/editor-next/editor-internal.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/labs/next/Editor.js +1 -1
- package/dist/esm/nodeviews/index.js +1 -2
- package/dist/esm/plugins/annotation/index.js +32 -22
- package/dist/esm/plugins/annotation/nodeviews/index.js +1 -1
- package/dist/esm/plugins/base/index.js +0 -6
- package/dist/esm/plugins/caption/index.js +1 -2
- package/dist/esm/plugins/caption/nodeviews/index.js +2 -2
- package/dist/esm/plugins/caption/pm-plugins/main.js +4 -2
- package/dist/esm/plugins/card/nodeviews/embedCard.js +4 -4
- package/dist/esm/plugins/extension/nodeviews/extension.js +1 -1
- package/dist/esm/plugins/jira-issue/index.js +1 -1
- package/dist/esm/plugins/media/index.js +2 -2
- package/dist/esm/plugins/media/nodeviews/mediaGroup.js +24 -18
- package/dist/esm/plugins/media/nodeviews/mediaInline.js +2 -2
- package/dist/esm/plugins/media/nodeviews/mediaNodeView/index.js +15 -9
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/esm/plugins/media/pm-plugins/main.js +26 -9
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +1 -1
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -1
- package/dist/esm/plugins/unsupported-content/index.js +1 -1
- package/dist/esm/test-utils.js +0 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/create-editor/ReactEditorViewInternal.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/labs/next/internal/components/EditorInternal.d.ts +2 -2
- package/dist/types/labs/next/internal/editor-props-type.d.ts +1 -1
- package/dist/types/labs/next/internal/hooks/use-editor/create-editor.d.ts +1 -1
- package/dist/types/nodeviews/index.d.ts +0 -2
- package/dist/types/plugins/annotation/index.d.ts +3 -1
- package/dist/types/plugins/annotation/nodeviews/index.d.ts +2 -1
- package/dist/types/plugins/annotation/pm-plugins/types.d.ts +2 -2
- package/dist/types/plugins/caption/index.d.ts +1 -1
- package/dist/types/plugins/caption/nodeviews/index.d.ts +7 -4
- package/dist/types/plugins/caption/pm-plugins/main.d.ts +5 -4
- package/dist/types/plugins/card/nodeviews/embedCard.d.ts +2 -2
- package/dist/types/plugins/extension/nodeviews/extension.d.ts +3 -2
- package/dist/types/plugins/extension/pm-plugins/main.d.ts +2 -2
- package/dist/types/plugins/media/index.d.ts +3 -1
- package/dist/types/plugins/media/nodeviews/mediaGroup.d.ts +5 -3
- package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +6 -3
- package/dist/types/plugins/media/nodeviews/mediaNodeView/index.d.ts +6 -4
- package/dist/types/plugins/media/nodeviews/mediaSingle.d.ts +2 -2
- package/dist/types/plugins/media/types.d.ts +4 -0
- package/dist/types/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +1 -1
- package/dist/types/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +1 -1
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/main.d.ts +1 -1
- package/dist/types/test-utils.d.ts +0 -1
- package/dist/types-ts4.5/create-editor/ReactEditorViewInternal.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/labs/next/internal/components/EditorInternal.d.ts +2 -2
- package/dist/types-ts4.5/labs/next/internal/editor-props-type.d.ts +1 -1
- package/dist/types-ts4.5/labs/next/internal/hooks/use-editor/create-editor.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/annotation/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/annotation/nodeviews/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/annotation/pm-plugins/types.d.ts +2 -2
- package/dist/types-ts4.5/plugins/caption/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/caption/nodeviews/index.d.ts +7 -4
- package/dist/types-ts4.5/plugins/caption/pm-plugins/main.d.ts +5 -4
- package/dist/types-ts4.5/plugins/card/nodeviews/embedCard.d.ts +2 -2
- package/dist/types-ts4.5/plugins/extension/nodeviews/extension.d.ts +3 -2
- package/dist/types-ts4.5/plugins/extension/pm-plugins/main.d.ts +2 -2
- package/dist/types-ts4.5/plugins/media/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaGroup.d.ts +5 -3
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaInline.d.ts +6 -3
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaNodeView/index.d.ts +6 -4
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaSingle.d.ts +2 -2
- package/dist/types-ts4.5/plugins/media/types.d.ts +4 -0
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +1 -1
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +1 -1
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/test-utils.d.ts +0 -1
- package/package.json +2 -2
- package/report.api.md +20 -85
- package/tmp/api-report-tmp.d.ts +18 -68
- package/dist/cjs/nodeviews/ReactNodeView.js +0 -224
- package/dist/cjs/nodeviews/SelectionBasedNodeView.js +0 -169
- package/dist/cjs/plugins/base/pm-plugins/react-nodeview.js +0 -72
- package/dist/cjs/ui/PortalProvider/PortalProviderThemesProvider.js +0 -43
- package/dist/cjs/ui/PortalProvider/index.js +0 -252
- package/dist/es2019/nodeviews/ReactNodeView.js +0 -170
- package/dist/es2019/nodeviews/SelectionBasedNodeView.js +0 -158
- package/dist/es2019/plugins/base/pm-plugins/react-nodeview.js +0 -48
- package/dist/es2019/ui/PortalProvider/PortalProviderThemesProvider.js +0 -37
- package/dist/es2019/ui/PortalProvider/index.js +0 -184
- package/dist/esm/nodeviews/ReactNodeView.js +0 -217
- package/dist/esm/nodeviews/SelectionBasedNodeView.js +0 -163
- package/dist/esm/plugins/base/pm-plugins/react-nodeview.js +0 -62
- package/dist/esm/ui/PortalProvider/PortalProviderThemesProvider.js +0 -36
- package/dist/esm/ui/PortalProvider/index.js +0 -242
- package/dist/types/nodeviews/ReactNodeView.d.ts +0 -52
- package/dist/types/nodeviews/SelectionBasedNodeView.d.ts +0 -53
- package/dist/types/plugins/base/pm-plugins/react-nodeview.d.ts +0 -13
- package/dist/types/ui/PortalProvider/PortalProviderThemesProvider.d.ts +0 -6
- package/dist/types/ui/PortalProvider/index.d.ts +0 -51
- package/dist/types-ts4.5/nodeviews/ReactNodeView.d.ts +0 -52
- package/dist/types-ts4.5/nodeviews/SelectionBasedNodeView.d.ts +0 -53
- package/dist/types-ts4.5/plugins/base/pm-plugins/react-nodeview.d.ts +0 -13
- package/dist/types-ts4.5/ui/PortalProvider/PortalProviderThemesProvider.d.ts +0 -6
- package/dist/types-ts4.5/ui/PortalProvider/index.d.ts +0 -51
|
@@ -1,224 +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.default = void 0;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
var _eventDispatcher = require("../event-dispatcher");
|
|
14
|
-
var _analytics = require("../plugins/analytics");
|
|
15
|
-
var _consts = require("../plugins/analytics/consts");
|
|
16
|
-
var _ErrorBoundary = require("../ui/ErrorBoundary");
|
|
17
|
-
var _getPerformanceOptions = require("./getPerformanceOptions");
|
|
18
|
-
var ReactNodeView = /*#__PURE__*/function () {
|
|
19
|
-
function ReactNodeView(_node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, reactComponent) {
|
|
20
|
-
var _this = this;
|
|
21
|
-
var hasAnalyticsContext = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
22
|
-
var viewShouldUpdate = arguments.length > 8 ? arguments[8] : undefined;
|
|
23
|
-
var hasIntlContext = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
|
|
24
|
-
(0, _classCallCheck2.default)(this, ReactNodeView);
|
|
25
|
-
(0, _defineProperty2.default)(this, "handleRef", function (node) {
|
|
26
|
-
return _this._handleRef(node);
|
|
27
|
-
});
|
|
28
|
-
(0, _defineProperty2.default)(this, "dispatchAnalyticsEvent", function (payload) {
|
|
29
|
-
if (_this.eventDispatcher) {
|
|
30
|
-
var dispatch = (0, _eventDispatcher.createDispatch)(_this.eventDispatcher);
|
|
31
|
-
dispatch(_consts.analyticsEventKey, {
|
|
32
|
-
payload: payload
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
this.node = _node;
|
|
37
|
-
this.view = view;
|
|
38
|
-
this.getPos = getPos;
|
|
39
|
-
this.portalProviderAPI = portalProviderAPI;
|
|
40
|
-
this.reactComponentProps = reactComponentProps || {};
|
|
41
|
-
this.reactComponent = reactComponent;
|
|
42
|
-
this.hasAnalyticsContext = hasAnalyticsContext;
|
|
43
|
-
this._viewShouldUpdate = viewShouldUpdate;
|
|
44
|
-
this.eventDispatcher = eventDispatcher;
|
|
45
|
-
this.hasIntlContext = hasIntlContext;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* This method exists to move initialization logic out of the constructor,
|
|
50
|
-
* so object can be initialized properly before calling render first time.
|
|
51
|
-
*
|
|
52
|
-
* Example:
|
|
53
|
-
* Instance properties get added to an object only after super call in
|
|
54
|
-
* constructor, which leads to some methods being undefined during the
|
|
55
|
-
* first render.
|
|
56
|
-
*/
|
|
57
|
-
(0, _createClass2.default)(ReactNodeView, [{
|
|
58
|
-
key: "init",
|
|
59
|
-
value: function init() {
|
|
60
|
-
var _this2 = this;
|
|
61
|
-
this.domRef = this.createDomRef();
|
|
62
|
-
this.setDomAttrs(this.node, this.domRef);
|
|
63
|
-
var _ref = this.getContentDOM() || {
|
|
64
|
-
dom: undefined,
|
|
65
|
-
contentDOM: undefined
|
|
66
|
-
},
|
|
67
|
-
contentDOMWrapper = _ref.dom,
|
|
68
|
-
contentDOM = _ref.contentDOM;
|
|
69
|
-
if (this.domRef && contentDOMWrapper) {
|
|
70
|
-
this.domRef.appendChild(contentDOMWrapper);
|
|
71
|
-
this.contentDOM = contentDOM ? contentDOM : contentDOMWrapper;
|
|
72
|
-
this.contentDOMWrapper = contentDOMWrapper || contentDOM;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// @see ED-3790
|
|
76
|
-
// something gets messed up during mutation processing inside of a
|
|
77
|
-
// nodeView if DOM structure has nested plain "div"s, it doesn't see the
|
|
78
|
-
// difference between them and it kills the nodeView
|
|
79
|
-
this.domRef.classList.add("".concat(this.node.type.name, "View-content-wrap"));
|
|
80
|
-
var _getPerformanceOption = (0, _getPerformanceOptions.getPerformanceOptions)(this.view),
|
|
81
|
-
samplingRate = _getPerformanceOption.samplingRate,
|
|
82
|
-
slowThreshold = _getPerformanceOption.slowThreshold,
|
|
83
|
-
trackingEnabled = _getPerformanceOption.trackingEnabled;
|
|
84
|
-
trackingEnabled && (0, _getPerformanceOptions.startMeasureReactNodeViewRendered)({
|
|
85
|
-
nodeTypeName: this.node.type.name
|
|
86
|
-
});
|
|
87
|
-
this.renderReactComponent(function () {
|
|
88
|
-
return _this2.render(_this2.reactComponentProps, _this2.handleRef);
|
|
89
|
-
});
|
|
90
|
-
trackingEnabled && (0, _getPerformanceOptions.stopMeasureReactNodeViewRendered)({
|
|
91
|
-
nodeTypeName: this.node.type.name,
|
|
92
|
-
dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
|
|
93
|
-
editorState: this.view.state,
|
|
94
|
-
samplingRate: samplingRate,
|
|
95
|
-
slowThreshold: slowThreshold
|
|
96
|
-
});
|
|
97
|
-
return this;
|
|
98
|
-
}
|
|
99
|
-
}, {
|
|
100
|
-
key: "renderReactComponent",
|
|
101
|
-
value: function renderReactComponent(component) {
|
|
102
|
-
var _this3 = this;
|
|
103
|
-
if (!this.domRef || !component) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
var componentWithErrorBoundary = function componentWithErrorBoundary() {
|
|
107
|
-
var _this3$node$type$name, _this3$node, _this3$node$type;
|
|
108
|
-
return /*#__PURE__*/_react.default.createElement(_ErrorBoundary.ErrorBoundary, {
|
|
109
|
-
component: _analytics.ACTION_SUBJECT.REACT_NODE_VIEW,
|
|
110
|
-
componentId: (_this3$node$type$name = _this3 === null || _this3 === void 0 ? void 0 : (_this3$node = _this3.node) === null || _this3$node === void 0 ? void 0 : (_this3$node$type = _this3$node.type) === null || _this3$node$type === void 0 ? void 0 : _this3$node$type.name) !== null && _this3$node$type$name !== void 0 ? _this3$node$type$name : _analytics.ACTION_SUBJECT_ID.UNKNOWN_NODE,
|
|
111
|
-
dispatchAnalyticsEvent: _this3.dispatchAnalyticsEvent
|
|
112
|
-
}, component());
|
|
113
|
-
};
|
|
114
|
-
this.portalProviderAPI.render(componentWithErrorBoundary, this.domRef, this.hasAnalyticsContext, this.hasIntlContext);
|
|
115
|
-
}
|
|
116
|
-
}, {
|
|
117
|
-
key: "createDomRef",
|
|
118
|
-
value: function createDomRef() {
|
|
119
|
-
if (!this.node.isInline) {
|
|
120
|
-
return document.createElement('div');
|
|
121
|
-
}
|
|
122
|
-
var htmlElement = document.createElement('span');
|
|
123
|
-
return htmlElement;
|
|
124
|
-
}
|
|
125
|
-
}, {
|
|
126
|
-
key: "getContentDOM",
|
|
127
|
-
value: function getContentDOM() {
|
|
128
|
-
return undefined;
|
|
129
|
-
}
|
|
130
|
-
}, {
|
|
131
|
-
key: "_handleRef",
|
|
132
|
-
value: function _handleRef(node) {
|
|
133
|
-
var contentDOM = this.contentDOMWrapper || this.contentDOM;
|
|
134
|
-
|
|
135
|
-
// move the contentDOM node inside the inner reference after rendering
|
|
136
|
-
if (node && contentDOM && !node.contains(contentDOM)) {
|
|
137
|
-
node.appendChild(contentDOM);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}, {
|
|
141
|
-
key: "render",
|
|
142
|
-
value: function render(props, forwardRef) {
|
|
143
|
-
return this.reactComponent ? /*#__PURE__*/_react.default.createElement(this.reactComponent, (0, _extends2.default)({
|
|
144
|
-
view: this.view,
|
|
145
|
-
getPos: this.getPos,
|
|
146
|
-
node: this.node,
|
|
147
|
-
forwardRef: forwardRef
|
|
148
|
-
}, props)) : null;
|
|
149
|
-
}
|
|
150
|
-
}, {
|
|
151
|
-
key: "update",
|
|
152
|
-
value: function update(node, _decorations, _innerDecorations) {
|
|
153
|
-
var _this4 = this;
|
|
154
|
-
var validUpdate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {
|
|
155
|
-
return true;
|
|
156
|
-
};
|
|
157
|
-
// @see https://github.com/ProseMirror/prosemirror/issues/648
|
|
158
|
-
var isValidUpdate = this.node.type === node.type && validUpdate(this.node, node);
|
|
159
|
-
if (!isValidUpdate) {
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
if (this.domRef && !this.node.sameMarkup(node)) {
|
|
163
|
-
this.setDomAttrs(node, this.domRef);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// View should not process a re-render if this is false.
|
|
167
|
-
// We dont want to destroy the view, so we return true.
|
|
168
|
-
if (!this.viewShouldUpdate(node)) {
|
|
169
|
-
this.node = node;
|
|
170
|
-
return true;
|
|
171
|
-
}
|
|
172
|
-
this.node = node;
|
|
173
|
-
this.renderReactComponent(function () {
|
|
174
|
-
return _this4.render(_this4.reactComponentProps, _this4.handleRef);
|
|
175
|
-
});
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
}, {
|
|
179
|
-
key: "viewShouldUpdate",
|
|
180
|
-
value: function viewShouldUpdate(nextNode) {
|
|
181
|
-
if (this._viewShouldUpdate) {
|
|
182
|
-
return this._viewShouldUpdate(nextNode);
|
|
183
|
-
}
|
|
184
|
-
return true;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Copies the attributes from a ProseMirror Node to a DOM node.
|
|
189
|
-
* @param node The Prosemirror Node from which to source the attributes
|
|
190
|
-
*/
|
|
191
|
-
}, {
|
|
192
|
-
key: "setDomAttrs",
|
|
193
|
-
value: function setDomAttrs(node, element) {
|
|
194
|
-
Object.keys(node.attrs || {}).forEach(function (attr) {
|
|
195
|
-
element.setAttribute(attr, node.attrs[attr]);
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
}, {
|
|
199
|
-
key: "dom",
|
|
200
|
-
get: function get() {
|
|
201
|
-
return this.domRef;
|
|
202
|
-
}
|
|
203
|
-
}, {
|
|
204
|
-
key: "destroy",
|
|
205
|
-
value: function destroy() {
|
|
206
|
-
if (!this.domRef) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
this.portalProviderAPI.remove(this.domRef);
|
|
210
|
-
this.domRef = undefined;
|
|
211
|
-
this.contentDOM = undefined;
|
|
212
|
-
}
|
|
213
|
-
}], [{
|
|
214
|
-
key: "fromComponent",
|
|
215
|
-
value: function fromComponent(component, portalProviderAPI, eventDispatcher, props, viewShouldUpdate) {
|
|
216
|
-
var hasIntlContext = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
217
|
-
return function (node, view, getPos) {
|
|
218
|
-
return new ReactNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, props, component, false, viewShouldUpdate, hasIntlContext).init();
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
}]);
|
|
222
|
-
return ReactNodeView;
|
|
223
|
-
}();
|
|
224
|
-
exports.default = ReactNodeView;
|
|
@@ -1,169 +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.SelectionBasedNodeView = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
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 _prosemirrorState = require("prosemirror-state");
|
|
17
|
-
var _reactNodeview = require("../plugins/base/pm-plugins/react-nodeview");
|
|
18
|
-
var _ReactNodeView2 = _interopRequireDefault(require("./ReactNodeView"));
|
|
19
|
-
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); }; }
|
|
20
|
-
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; } }
|
|
21
|
-
/**
|
|
22
|
-
* A ReactNodeView that handles React components sensitive
|
|
23
|
-
* to selection changes.
|
|
24
|
-
*
|
|
25
|
-
* If the selection changes, it will attempt to re-render the
|
|
26
|
-
* React component. Otherwise it does nothing.
|
|
27
|
-
*
|
|
28
|
-
* You can subclass `viewShouldUpdate` to include other
|
|
29
|
-
* props that your component might want to consider before
|
|
30
|
-
* entering the React lifecycle. These are usually props you
|
|
31
|
-
* compare in `shouldComponentUpdate`.
|
|
32
|
-
*
|
|
33
|
-
* An example:
|
|
34
|
-
*
|
|
35
|
-
* ```
|
|
36
|
-
* viewShouldUpdate(nextNode) {
|
|
37
|
-
* if (nextNode.attrs !== this.node.attrs) {
|
|
38
|
-
* return true;
|
|
39
|
-
* }
|
|
40
|
-
*
|
|
41
|
-
* return super.viewShouldUpdate(nextNode);
|
|
42
|
-
* }```
|
|
43
|
-
*/
|
|
44
|
-
var SelectionBasedNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
45
|
-
(0, _inherits2.default)(SelectionBasedNodeView, _ReactNodeView);
|
|
46
|
-
var _super = _createSuper(SelectionBasedNodeView);
|
|
47
|
-
function SelectionBasedNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, reactComponent) {
|
|
48
|
-
var _this;
|
|
49
|
-
var hasContext = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
50
|
-
var viewShouldUpdate = arguments.length > 8 ? arguments[8] : undefined;
|
|
51
|
-
var hasIntlContext = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
|
|
52
|
-
(0, _classCallCheck2.default)(this, SelectionBasedNodeView);
|
|
53
|
-
_this = _super.call(this, node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, reactComponent, hasContext, viewShouldUpdate, hasIntlContext);
|
|
54
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isNodeInsideSelection", function (from, to, pos, posEnd) {
|
|
55
|
-
var _this$getPositionsWit = _this.getPositionsWithDefault(pos, posEnd);
|
|
56
|
-
pos = _this$getPositionsWit.pos;
|
|
57
|
-
posEnd = _this$getPositionsWit.posEnd;
|
|
58
|
-
if (typeof pos !== 'number' || typeof posEnd !== 'number') {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
return from <= pos && to >= posEnd;
|
|
62
|
-
});
|
|
63
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isSelectionInsideNode", function (from, to, pos, posEnd) {
|
|
64
|
-
var _this$getPositionsWit2 = _this.getPositionsWithDefault(pos, posEnd);
|
|
65
|
-
pos = _this$getPositionsWit2.pos;
|
|
66
|
-
posEnd = _this$getPositionsWit2.posEnd;
|
|
67
|
-
if (typeof pos !== 'number' || typeof posEnd !== 'number') {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
return pos < from && to < posEnd;
|
|
71
|
-
});
|
|
72
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isSelectedNode", function (selection) {
|
|
73
|
-
if (selection instanceof _prosemirrorState.NodeSelection) {
|
|
74
|
-
var _this$view$state$sele = _this.view.state.selection,
|
|
75
|
-
from = _this$view$state$sele.from,
|
|
76
|
-
to = _this$view$state$sele.to;
|
|
77
|
-
return selection.node === _this.node ||
|
|
78
|
-
// If nodes are not the same object, we check if they are referring to the same document node
|
|
79
|
-
_this.pos === from && _this.posEnd === to && selection.node.eq(_this.node);
|
|
80
|
-
}
|
|
81
|
-
return false;
|
|
82
|
-
});
|
|
83
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "insideSelection", function () {
|
|
84
|
-
var _this$view$state$sele2 = _this.view.state.selection,
|
|
85
|
-
from = _this$view$state$sele2.from,
|
|
86
|
-
to = _this$view$state$sele2.to;
|
|
87
|
-
return _this.isSelectedNode(_this.view.state.selection) || _this.isSelectionInsideNode(from, to);
|
|
88
|
-
});
|
|
89
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "nodeInsideSelection", function () {
|
|
90
|
-
var selection = _this.view.state.selection;
|
|
91
|
-
var from = selection.from,
|
|
92
|
-
to = selection.to;
|
|
93
|
-
return _this.isSelectedNode(selection) || _this.isNodeInsideSelection(from, to);
|
|
94
|
-
});
|
|
95
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onSelectionChange", function () {
|
|
96
|
-
_this.update(_this.node, []);
|
|
97
|
-
});
|
|
98
|
-
_this.updatePos();
|
|
99
|
-
_this.oldSelection = view.state.selection;
|
|
100
|
-
_this.selectionChangeState = _reactNodeview.stateKey.getState(_this.view.state);
|
|
101
|
-
_this.selectionChangeState.subscribe(_this.onSelectionChange);
|
|
102
|
-
return _this;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Update current node's start and end positions.
|
|
107
|
-
*
|
|
108
|
-
* Prefer `this.pos` rather than getPos(), because calling getPos is
|
|
109
|
-
* expensive, unless you know you're definitely going to render.
|
|
110
|
-
*/
|
|
111
|
-
(0, _createClass2.default)(SelectionBasedNodeView, [{
|
|
112
|
-
key: "updatePos",
|
|
113
|
-
value: function updatePos() {
|
|
114
|
-
if (typeof this.getPos === 'boolean') {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
this.pos = this.getPos();
|
|
118
|
-
this.posEnd = this.pos + this.node.nodeSize;
|
|
119
|
-
}
|
|
120
|
-
}, {
|
|
121
|
-
key: "getPositionsWithDefault",
|
|
122
|
-
value: function getPositionsWithDefault(pos, posEnd) {
|
|
123
|
-
return {
|
|
124
|
-
pos: typeof pos !== 'number' ? this.pos : pos,
|
|
125
|
-
posEnd: typeof posEnd !== 'number' ? this.posEnd : posEnd
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
}, {
|
|
129
|
-
key: "viewShouldUpdate",
|
|
130
|
-
value: function viewShouldUpdate(_nextNode) {
|
|
131
|
-
var selection = this.view.state.selection;
|
|
132
|
-
|
|
133
|
-
// update selection
|
|
134
|
-
var oldSelection = this.oldSelection;
|
|
135
|
-
this.oldSelection = selection;
|
|
136
|
-
|
|
137
|
-
// update cached positions
|
|
138
|
-
var oldPos = this.pos,
|
|
139
|
-
oldPosEnd = this.posEnd;
|
|
140
|
-
this.updatePos();
|
|
141
|
-
var from = selection.from,
|
|
142
|
-
to = selection.to;
|
|
143
|
-
var oldFrom = oldSelection.from,
|
|
144
|
-
oldTo = oldSelection.to;
|
|
145
|
-
if (this.node.type.spec.selectable) {
|
|
146
|
-
var newNodeSelection = selection instanceof _prosemirrorState.NodeSelection && selection.from === this.pos;
|
|
147
|
-
var oldNodeSelection = oldSelection instanceof _prosemirrorState.NodeSelection && oldSelection.from === this.pos;
|
|
148
|
-
if (newNodeSelection && !oldNodeSelection || oldNodeSelection && !newNodeSelection) {
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
var movedInToSelection = this.isNodeInsideSelection(from, to) && !this.isNodeInsideSelection(oldFrom, oldTo);
|
|
153
|
-
var movedOutOfSelection = !this.isNodeInsideSelection(from, to) && this.isNodeInsideSelection(oldFrom, oldTo);
|
|
154
|
-
var moveOutFromOldSelection = this.isNodeInsideSelection(from, to, oldPos, oldPosEnd) && !this.isNodeInsideSelection(from, to);
|
|
155
|
-
if (movedInToSelection || movedOutOfSelection || moveOutFromOldSelection) {
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
}, {
|
|
161
|
-
key: "destroy",
|
|
162
|
-
value: function destroy() {
|
|
163
|
-
this.selectionChangeState.unsubscribe(this.onSelectionChange);
|
|
164
|
-
(0, _get2.default)((0, _getPrototypeOf2.default)(SelectionBasedNodeView.prototype), "destroy", this).call(this);
|
|
165
|
-
}
|
|
166
|
-
}]);
|
|
167
|
-
return SelectionBasedNodeView;
|
|
168
|
-
}(_ReactNodeView2.default);
|
|
169
|
-
exports.SelectionBasedNodeView = SelectionBasedNodeView;
|
|
@@ -1,72 +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.stateKey = exports.plugin = exports.ReactNodeViewState = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
13
|
-
var ReactNodeViewState = /*#__PURE__*/function () {
|
|
14
|
-
function ReactNodeViewState() {
|
|
15
|
-
(0, _classCallCheck2.default)(this, ReactNodeViewState);
|
|
16
|
-
(0, _defineProperty2.default)(this, "changeHandlers", []);
|
|
17
|
-
this.changeHandlers = [];
|
|
18
|
-
}
|
|
19
|
-
(0, _createClass2.default)(ReactNodeViewState, [{
|
|
20
|
-
key: "subscribe",
|
|
21
|
-
value: function subscribe(cb) {
|
|
22
|
-
this.changeHandlers.push(cb);
|
|
23
|
-
}
|
|
24
|
-
}, {
|
|
25
|
-
key: "unsubscribe",
|
|
26
|
-
value: function unsubscribe(cb) {
|
|
27
|
-
this.changeHandlers = this.changeHandlers.filter(function (ch) {
|
|
28
|
-
return ch !== cb;
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}, {
|
|
32
|
-
key: "notifyNewSelection",
|
|
33
|
-
value: function notifyNewSelection(fromPos, toPos) {
|
|
34
|
-
this.changeHandlers.forEach(function (cb) {
|
|
35
|
-
return cb(fromPos, toPos);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}]);
|
|
39
|
-
return ReactNodeViewState;
|
|
40
|
-
}();
|
|
41
|
-
exports.ReactNodeViewState = ReactNodeViewState;
|
|
42
|
-
var stateKey = new _prosemirrorState.PluginKey('reactNodeView');
|
|
43
|
-
exports.stateKey = stateKey;
|
|
44
|
-
var plugin = new _safePlugin.SafePlugin({
|
|
45
|
-
state: {
|
|
46
|
-
init: function init() {
|
|
47
|
-
return new ReactNodeViewState();
|
|
48
|
-
},
|
|
49
|
-
apply: function apply(_tr, pluginState) {
|
|
50
|
-
return pluginState;
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
key: stateKey,
|
|
54
|
-
view: function view(_view) {
|
|
55
|
-
var pluginState = stateKey.getState(_view.state);
|
|
56
|
-
var prevFrom = -1;
|
|
57
|
-
var prevTo = -1;
|
|
58
|
-
return {
|
|
59
|
-
update: function update(view) {
|
|
60
|
-
var _view$state$selection = view.state.selection,
|
|
61
|
-
from = _view$state$selection.from,
|
|
62
|
-
to = _view$state$selection.to;
|
|
63
|
-
if (from !== prevFrom || to !== prevTo) {
|
|
64
|
-
pluginState.notifyNewSelection(from, to);
|
|
65
|
-
prevFrom = from;
|
|
66
|
-
prevTo = to;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
exports.plugin = plugin;
|
|
@@ -1,43 +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.PortalProviderThemeProviders = PortalProviderThemeProviders;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _components = _interopRequireDefault(require("@atlaskit/theme/components"));
|
|
11
|
-
var _constants = require("@atlaskit/theme/constants");
|
|
12
|
-
var _react2 = require("@emotion/react");
|
|
13
|
-
function PortalProviderThemeProviders(props) {
|
|
14
|
-
var children = props.children,
|
|
15
|
-
mode = props.mode;
|
|
16
|
-
var styledComponentsAndEmotionTheme = _react.default.useMemo(
|
|
17
|
-
// This return value should only be one of the following
|
|
18
|
-
// - { [CHANNEL]: { mode },
|
|
19
|
-
// - { theme: { [CHANNEL]: { mode } }
|
|
20
|
-
// However, it appears that consumers have inconsistent expectations
|
|
21
|
-
// regarding the shape.
|
|
22
|
-
// This can be revisited in future work, and for the purposes of
|
|
23
|
-
// fixing https://product-fabric.atlassian.net/browse/ED-14956
|
|
24
|
-
// we are merging the two shapes consumers expect.
|
|
25
|
-
function () {
|
|
26
|
-
var _ref;
|
|
27
|
-
return _ref = {}, (0, _defineProperty2.default)(_ref, _constants.CHANNEL, {
|
|
28
|
-
mode: mode
|
|
29
|
-
}), (0, _defineProperty2.default)(_ref, "theme", (0, _defineProperty2.default)({}, _constants.CHANNEL, {
|
|
30
|
-
mode: mode
|
|
31
|
-
})), _ref;
|
|
32
|
-
}, [mode]);
|
|
33
|
-
var atlaskitTheme = _react.default.useCallback(function () {
|
|
34
|
-
return {
|
|
35
|
-
mode: mode
|
|
36
|
-
};
|
|
37
|
-
}, [mode]);
|
|
38
|
-
return /*#__PURE__*/_react.default.createElement(_react2.ThemeProvider, {
|
|
39
|
-
theme: styledComponentsAndEmotionTheme
|
|
40
|
-
}, /*#__PURE__*/_react.default.createElement(_components.default.Provider, {
|
|
41
|
-
value: atlaskitTheme
|
|
42
|
-
}, children));
|
|
43
|
-
}
|