@atlaskit/editor-common 74.7.8 → 74.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/react-node-view/index.js +5 -3
- package/dist/cjs/selection-based-node-view/SelectionBasedNodeView.js +124 -0
- package/dist/cjs/selection-based-node-view/index.js +12 -0
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/PortalProvider/index.js +0 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/react-node-view/index.js +5 -3
- package/dist/es2019/selection-based-node-view/SelectionBasedNodeView.js +100 -0
- package/dist/es2019/selection-based-node-view/index.js +1 -0
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/PortalProvider/index.js +1 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/react-node-view/index.js +5 -3
- package/dist/esm/selection-based-node-view/SelectionBasedNodeView.js +117 -0
- package/dist/esm/selection-based-node-view/index.js +1 -0
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/PortalProvider/index.js +0 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/react-node-view/index.d.ts +4 -3
- package/dist/types/selection-based-node-view/SelectionBasedNodeView.d.ts +49 -0
- package/dist/types/selection-based-node-view/index.d.ts +1 -0
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/types/next-editor-plugin.d.ts +3 -0
- package/dist/types-ts4.5/react-node-view/index.d.ts +4 -3
- package/dist/types-ts4.5/selection-based-node-view/SelectionBasedNodeView.d.ts +49 -0
- package/dist/types-ts4.5/selection-based-node-view/index.d.ts +1 -0
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/dist/types-ts4.5/types/next-editor-plugin.d.ts +3 -0
- package/package.json +5 -4
- package/selection-based-node-view/package.json +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 74.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`5e01082b600`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5e01082b600) - Extracting SelectionBasedNodeView to editor-common.
|
|
8
|
+
|
|
9
|
+
## 74.7.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`87366c84531`](https://bitbucket.org/atlassian/atlassian-frontend/commits/87366c84531) - Extract context panel plugin to new package @atlaskit/editor-plugin-context-panel
|
|
14
|
+
|
|
3
15
|
## 74.7.8
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
16
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
17
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
18
18
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
19
|
-
var packageVersion = "74.
|
|
19
|
+
var packageVersion = "74.8.0";
|
|
20
20
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
21
21
|
// Remove URL as it has UGC
|
|
22
22
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -35,6 +35,7 @@ var ReactNodeView = /*#__PURE__*/function () {
|
|
|
35
35
|
var viewShouldUpdate = arguments.length > 8 ? arguments[8] : undefined;
|
|
36
36
|
var hasIntlContext = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
|
|
37
37
|
(0, _classCallCheck2.default)(this, ReactNodeView);
|
|
38
|
+
(0, _defineProperty2.default)(this, "decorations", []);
|
|
38
39
|
(0, _defineProperty2.default)(this, "handleRef", function (node) {
|
|
39
40
|
return _this._handleRef(node);
|
|
40
41
|
});
|
|
@@ -162,13 +163,14 @@ var ReactNodeView = /*#__PURE__*/function () {
|
|
|
162
163
|
}
|
|
163
164
|
}, {
|
|
164
165
|
key: "update",
|
|
165
|
-
value: function update(node,
|
|
166
|
+
value: function update(node, decorations, _innerDecorations) {
|
|
166
167
|
var _this4 = this;
|
|
167
168
|
var validUpdate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {
|
|
168
169
|
return true;
|
|
169
170
|
};
|
|
170
171
|
// @see https://github.com/ProseMirror/prosemirror/issues/648
|
|
171
172
|
var isValidUpdate = this.node.type === node.type && validUpdate(this.node, node);
|
|
173
|
+
this.decorations = decorations;
|
|
172
174
|
if (!isValidUpdate) {
|
|
173
175
|
return false;
|
|
174
176
|
}
|
|
@@ -178,7 +180,7 @@ var ReactNodeView = /*#__PURE__*/function () {
|
|
|
178
180
|
|
|
179
181
|
// View should not process a re-render if this is false.
|
|
180
182
|
// We dont want to destroy the view, so we return true.
|
|
181
|
-
if (!this.viewShouldUpdate(node)) {
|
|
183
|
+
if (!this.viewShouldUpdate(node, decorations)) {
|
|
182
184
|
this.node = node;
|
|
183
185
|
return true;
|
|
184
186
|
}
|
|
@@ -190,7 +192,7 @@ var ReactNodeView = /*#__PURE__*/function () {
|
|
|
190
192
|
}
|
|
191
193
|
}, {
|
|
192
194
|
key: "viewShouldUpdate",
|
|
193
|
-
value: function viewShouldUpdate(nextNode) {
|
|
195
|
+
value: function viewShouldUpdate(nextNode, decorations) {
|
|
194
196
|
if (this._viewShouldUpdate) {
|
|
195
197
|
return this._viewShouldUpdate(nextNode);
|
|
196
198
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
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 _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
var _reactNodeView = _interopRequireDefault(require("../react-node-view"));
|
|
16
|
+
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); }; }
|
|
17
|
+
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; } }
|
|
18
|
+
/**
|
|
19
|
+
* A ReactNodeView that handles React components sensitive
|
|
20
|
+
* to selection changes.
|
|
21
|
+
*
|
|
22
|
+
* If the selection changes, it will attempt to re-render the
|
|
23
|
+
* React component. Otherwise it does nothing.
|
|
24
|
+
*
|
|
25
|
+
* You can subclass `viewShouldUpdate` to include other
|
|
26
|
+
* props that your component might want to consider before
|
|
27
|
+
* entering the React lifecycle. These are usually props you
|
|
28
|
+
* compare in `shouldComponentUpdate`.
|
|
29
|
+
*
|
|
30
|
+
* An example:
|
|
31
|
+
*
|
|
32
|
+
* ```
|
|
33
|
+
* viewShouldUpdate(nextNode) {
|
|
34
|
+
* if (nextNode.attrs !== this.node.attrs) {
|
|
35
|
+
* return true;
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* return super.viewShouldUpdate(nextNode);
|
|
39
|
+
* }```
|
|
40
|
+
*/
|
|
41
|
+
var SelectionBasedNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
42
|
+
(0, _inherits2.default)(SelectionBasedNodeView, _ReactNodeView);
|
|
43
|
+
var _super = _createSuper(SelectionBasedNodeView);
|
|
44
|
+
function SelectionBasedNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, reactComponent) {
|
|
45
|
+
var _this;
|
|
46
|
+
var hasContext = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
47
|
+
var viewShouldUpdate = arguments.length > 8 ? arguments[8] : undefined;
|
|
48
|
+
var hasIntlContext = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
|
|
49
|
+
(0, _classCallCheck2.default)(this, SelectionBasedNodeView);
|
|
50
|
+
_this = _super.call(this, node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, reactComponent, hasContext, viewShouldUpdate, hasIntlContext);
|
|
51
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isSelectedNode", false);
|
|
52
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isNodeInsideSelection", function (from, to, pos, posEnd) {
|
|
53
|
+
var _this$getPositionsWit = _this.getPositionsWithDefault(pos, posEnd);
|
|
54
|
+
pos = _this$getPositionsWit.pos;
|
|
55
|
+
posEnd = _this$getPositionsWit.posEnd;
|
|
56
|
+
if (typeof pos !== 'number' || typeof posEnd !== 'number') {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return from <= pos && to >= posEnd;
|
|
60
|
+
});
|
|
61
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isSelectionInsideNode", function (from, to, pos, posEnd) {
|
|
62
|
+
var _this$getPositionsWit2 = _this.getPositionsWithDefault(pos, posEnd);
|
|
63
|
+
pos = _this$getPositionsWit2.pos;
|
|
64
|
+
posEnd = _this$getPositionsWit2.posEnd;
|
|
65
|
+
if (typeof pos !== 'number' || typeof posEnd !== 'number') {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return pos < from && to < posEnd;
|
|
69
|
+
});
|
|
70
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "insideSelection", function () {
|
|
71
|
+
var _this$view$state$sele = _this.view.state.selection,
|
|
72
|
+
from = _this$view$state$sele.from,
|
|
73
|
+
to = _this$view$state$sele.to;
|
|
74
|
+
return _this.isSelectedNode || _this.isSelectionInsideNode(from, to);
|
|
75
|
+
});
|
|
76
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "nodeInsideSelection", function () {
|
|
77
|
+
var selection = _this.view.state.selection;
|
|
78
|
+
var from = selection.from,
|
|
79
|
+
to = selection.to;
|
|
80
|
+
return _this.isSelectedNode || _this.isNodeInsideSelection(from, to);
|
|
81
|
+
});
|
|
82
|
+
_this.updatePos();
|
|
83
|
+
return _this;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Update current node's start and end positions.
|
|
88
|
+
*
|
|
89
|
+
* Prefer `this.pos` rather than getPos(), because calling getPos is
|
|
90
|
+
* expensive, unless you know you're definitely going to render.
|
|
91
|
+
*/
|
|
92
|
+
(0, _createClass2.default)(SelectionBasedNodeView, [{
|
|
93
|
+
key: "updatePos",
|
|
94
|
+
value: function updatePos() {
|
|
95
|
+
if (typeof this.getPos === 'boolean') {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
this.pos = this.getPos();
|
|
99
|
+
this.posEnd = this.pos + this.node.nodeSize;
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "getPositionsWithDefault",
|
|
103
|
+
value: function getPositionsWithDefault(pos, posEnd) {
|
|
104
|
+
return {
|
|
105
|
+
pos: typeof pos !== 'number' ? this.pos : pos,
|
|
106
|
+
posEnd: typeof posEnd !== 'number' ? this.posEnd : posEnd
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "selectNode",
|
|
111
|
+
value: function selectNode() {
|
|
112
|
+
this.isSelectedNode = true;
|
|
113
|
+
this.update(this.node, this.decorations);
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
116
|
+
key: "deselectNode",
|
|
117
|
+
value: function deselectNode() {
|
|
118
|
+
this.isSelectedNode = false;
|
|
119
|
+
this.update(this.node, this.decorations);
|
|
120
|
+
}
|
|
121
|
+
}]);
|
|
122
|
+
return SelectionBasedNodeView;
|
|
123
|
+
}(_reactNodeView.default);
|
|
124
|
+
exports.SelectionBasedNodeView = SelectionBasedNodeView;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "SelectionBasedNodeView", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _SelectionBasedNodeView.SelectionBasedNodeView;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _SelectionBasedNodeView = require("./SelectionBasedNodeView");
|
|
@@ -24,7 +24,7 @@ var _templateObject, _templateObject2, _templateObject3;
|
|
|
24
24
|
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); }; }
|
|
25
25
|
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; } } /** @jsx jsx */
|
|
26
26
|
var packageName = "@atlaskit/editor-common";
|
|
27
|
-
var packageVersion = "74.
|
|
27
|
+
var packageVersion = "74.8.0";
|
|
28
28
|
var halfFocusRing = 1;
|
|
29
29
|
var dropOffset = '0, 8';
|
|
30
30
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -111,7 +111,6 @@ var PortalProviderAPI = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
111
111
|
} catch (error) {
|
|
112
112
|
if (this.onAnalyticsEvent) {
|
|
113
113
|
this.onAnalyticsEvent({
|
|
114
|
-
// @ts-expect-error
|
|
115
114
|
payload: {
|
|
116
115
|
action: _analytics.ACTION.FAILED_TO_UNMOUNT,
|
|
117
116
|
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
2
2
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
3
|
-
const packageVersion = "74.
|
|
3
|
+
const packageVersion = "74.8.0";
|
|
4
4
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
5
5
|
// Remove URL as it has UGC
|
|
6
6
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -9,6 +9,7 @@ import { analyticsEventKey } from '../utils/analytics';
|
|
|
9
9
|
export { getInlineNodeViewProducer, inlineNodeViewClassname } from './getInlineNodeViewProducer';
|
|
10
10
|
export default class ReactNodeView {
|
|
11
11
|
constructor(_node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, reactComponent, hasAnalyticsContext = false, viewShouldUpdate, hasIntlContext = false) {
|
|
12
|
+
_defineProperty(this, "decorations", []);
|
|
12
13
|
_defineProperty(this, "handleRef", node => this._handleRef(node));
|
|
13
14
|
_defineProperty(this, "dispatchAnalyticsEvent", payload => {
|
|
14
15
|
if (this.eventDispatcher) {
|
|
@@ -118,9 +119,10 @@ export default class ReactNodeView {
|
|
|
118
119
|
forwardRef: forwardRef
|
|
119
120
|
}, props)) : null;
|
|
120
121
|
}
|
|
121
|
-
update(node,
|
|
122
|
+
update(node, decorations, _innerDecorations, validUpdate = () => true) {
|
|
122
123
|
// @see https://github.com/ProseMirror/prosemirror/issues/648
|
|
123
124
|
const isValidUpdate = this.node.type === node.type && validUpdate(this.node, node);
|
|
125
|
+
this.decorations = decorations;
|
|
124
126
|
if (!isValidUpdate) {
|
|
125
127
|
return false;
|
|
126
128
|
}
|
|
@@ -130,7 +132,7 @@ export default class ReactNodeView {
|
|
|
130
132
|
|
|
131
133
|
// View should not process a re-render if this is false.
|
|
132
134
|
// We dont want to destroy the view, so we return true.
|
|
133
|
-
if (!this.viewShouldUpdate(node)) {
|
|
135
|
+
if (!this.viewShouldUpdate(node, decorations)) {
|
|
134
136
|
this.node = node;
|
|
135
137
|
return true;
|
|
136
138
|
}
|
|
@@ -138,7 +140,7 @@ export default class ReactNodeView {
|
|
|
138
140
|
this.renderReactComponent(() => this.render(this.reactComponentProps, this.handleRef));
|
|
139
141
|
return true;
|
|
140
142
|
}
|
|
141
|
-
viewShouldUpdate(nextNode) {
|
|
143
|
+
viewShouldUpdate(nextNode, decorations) {
|
|
142
144
|
if (this._viewShouldUpdate) {
|
|
143
145
|
return this._viewShouldUpdate(nextNode);
|
|
144
146
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import ReactNodeView from '../react-node-view';
|
|
3
|
+
/**
|
|
4
|
+
* A ReactNodeView that handles React components sensitive
|
|
5
|
+
* to selection changes.
|
|
6
|
+
*
|
|
7
|
+
* If the selection changes, it will attempt to re-render the
|
|
8
|
+
* React component. Otherwise it does nothing.
|
|
9
|
+
*
|
|
10
|
+
* You can subclass `viewShouldUpdate` to include other
|
|
11
|
+
* props that your component might want to consider before
|
|
12
|
+
* entering the React lifecycle. These are usually props you
|
|
13
|
+
* compare in `shouldComponentUpdate`.
|
|
14
|
+
*
|
|
15
|
+
* An example:
|
|
16
|
+
*
|
|
17
|
+
* ```
|
|
18
|
+
* viewShouldUpdate(nextNode) {
|
|
19
|
+
* if (nextNode.attrs !== this.node.attrs) {
|
|
20
|
+
* return true;
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* return super.viewShouldUpdate(nextNode);
|
|
24
|
+
* }```
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export class SelectionBasedNodeView extends ReactNodeView {
|
|
28
|
+
constructor(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, reactComponent, hasContext = false, viewShouldUpdate, hasIntlContext = false) {
|
|
29
|
+
super(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, reactComponent, hasContext, viewShouldUpdate, hasIntlContext);
|
|
30
|
+
_defineProperty(this, "isSelectedNode", false);
|
|
31
|
+
_defineProperty(this, "isNodeInsideSelection", (from, to, pos, posEnd) => {
|
|
32
|
+
({
|
|
33
|
+
pos,
|
|
34
|
+
posEnd
|
|
35
|
+
} = this.getPositionsWithDefault(pos, posEnd));
|
|
36
|
+
if (typeof pos !== 'number' || typeof posEnd !== 'number') {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return from <= pos && to >= posEnd;
|
|
40
|
+
});
|
|
41
|
+
_defineProperty(this, "isSelectionInsideNode", (from, to, pos, posEnd) => {
|
|
42
|
+
({
|
|
43
|
+
pos,
|
|
44
|
+
posEnd
|
|
45
|
+
} = this.getPositionsWithDefault(pos, posEnd));
|
|
46
|
+
if (typeof pos !== 'number' || typeof posEnd !== 'number') {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return pos < from && to < posEnd;
|
|
50
|
+
});
|
|
51
|
+
_defineProperty(this, "insideSelection", () => {
|
|
52
|
+
const {
|
|
53
|
+
selection: {
|
|
54
|
+
from,
|
|
55
|
+
to
|
|
56
|
+
}
|
|
57
|
+
} = this.view.state;
|
|
58
|
+
return this.isSelectedNode || this.isSelectionInsideNode(from, to);
|
|
59
|
+
});
|
|
60
|
+
_defineProperty(this, "nodeInsideSelection", () => {
|
|
61
|
+
const {
|
|
62
|
+
selection
|
|
63
|
+
} = this.view.state;
|
|
64
|
+
const {
|
|
65
|
+
from,
|
|
66
|
+
to
|
|
67
|
+
} = selection;
|
|
68
|
+
return this.isSelectedNode || this.isNodeInsideSelection(from, to);
|
|
69
|
+
});
|
|
70
|
+
this.updatePos();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Update current node's start and end positions.
|
|
75
|
+
*
|
|
76
|
+
* Prefer `this.pos` rather than getPos(), because calling getPos is
|
|
77
|
+
* expensive, unless you know you're definitely going to render.
|
|
78
|
+
*/
|
|
79
|
+
updatePos() {
|
|
80
|
+
if (typeof this.getPos === 'boolean') {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this.pos = this.getPos();
|
|
84
|
+
this.posEnd = this.pos + this.node.nodeSize;
|
|
85
|
+
}
|
|
86
|
+
getPositionsWithDefault(pos, posEnd) {
|
|
87
|
+
return {
|
|
88
|
+
pos: typeof pos !== 'number' ? this.pos : pos,
|
|
89
|
+
posEnd: typeof posEnd !== 'number' ? this.posEnd : posEnd
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
selectNode() {
|
|
93
|
+
this.isSelectedNode = true;
|
|
94
|
+
this.update(this.node, this.decorations);
|
|
95
|
+
}
|
|
96
|
+
deselectNode() {
|
|
97
|
+
this.isSelectedNode = false;
|
|
98
|
+
this.update(this.node, this.decorations);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SelectionBasedNodeView } from './SelectionBasedNodeView';
|
|
@@ -8,7 +8,7 @@ import { themed } from '@atlaskit/theme/components';
|
|
|
8
8
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
9
9
|
import Layer from '../Layer';
|
|
10
10
|
const packageName = "@atlaskit/editor-common";
|
|
11
|
-
const packageVersion = "74.
|
|
11
|
+
const packageVersion = "74.8.0";
|
|
12
12
|
const halfFocusRing = 1;
|
|
13
13
|
const dropOffset = '0, 8';
|
|
14
14
|
class DropList extends Component {
|
|
@@ -82,13 +82,12 @@ export class PortalProviderAPI extends EventDispatcher {
|
|
|
82
82
|
} catch (error) {
|
|
83
83
|
if (this.onAnalyticsEvent) {
|
|
84
84
|
this.onAnalyticsEvent({
|
|
85
|
-
// @ts-expect-error
|
|
86
85
|
payload: {
|
|
87
86
|
action: ACTION.FAILED_TO_UNMOUNT,
|
|
88
87
|
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
89
88
|
actionSubjectId: ACTION_SUBJECT_ID.REACT_NODE_VIEW,
|
|
90
89
|
attributes: {
|
|
91
|
-
error,
|
|
90
|
+
error: error,
|
|
92
91
|
domNodes: {
|
|
93
92
|
container: container ? container.className : undefined,
|
|
94
93
|
child: container.firstElementChild ? container.firstElementChild.className : undefined
|
package/dist/es2019/version.json
CHANGED
|
@@ -6,7 +6,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
7
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
8
8
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
9
|
-
var packageVersion = "74.
|
|
9
|
+
var packageVersion = "74.8.0";
|
|
10
10
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
11
11
|
// Remove URL as it has UGC
|
|
12
12
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -16,6 +16,7 @@ var ReactNodeView = /*#__PURE__*/function () {
|
|
|
16
16
|
var viewShouldUpdate = arguments.length > 8 ? arguments[8] : undefined;
|
|
17
17
|
var hasIntlContext = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
|
|
18
18
|
_classCallCheck(this, ReactNodeView);
|
|
19
|
+
_defineProperty(this, "decorations", []);
|
|
19
20
|
_defineProperty(this, "handleRef", function (node) {
|
|
20
21
|
return _this._handleRef(node);
|
|
21
22
|
});
|
|
@@ -143,13 +144,14 @@ var ReactNodeView = /*#__PURE__*/function () {
|
|
|
143
144
|
}
|
|
144
145
|
}, {
|
|
145
146
|
key: "update",
|
|
146
|
-
value: function update(node,
|
|
147
|
+
value: function update(node, decorations, _innerDecorations) {
|
|
147
148
|
var _this4 = this;
|
|
148
149
|
var validUpdate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {
|
|
149
150
|
return true;
|
|
150
151
|
};
|
|
151
152
|
// @see https://github.com/ProseMirror/prosemirror/issues/648
|
|
152
153
|
var isValidUpdate = this.node.type === node.type && validUpdate(this.node, node);
|
|
154
|
+
this.decorations = decorations;
|
|
153
155
|
if (!isValidUpdate) {
|
|
154
156
|
return false;
|
|
155
157
|
}
|
|
@@ -159,7 +161,7 @@ var ReactNodeView = /*#__PURE__*/function () {
|
|
|
159
161
|
|
|
160
162
|
// View should not process a re-render if this is false.
|
|
161
163
|
// We dont want to destroy the view, so we return true.
|
|
162
|
-
if (!this.viewShouldUpdate(node)) {
|
|
164
|
+
if (!this.viewShouldUpdate(node, decorations)) {
|
|
163
165
|
this.node = node;
|
|
164
166
|
return true;
|
|
165
167
|
}
|
|
@@ -171,7 +173,7 @@ var ReactNodeView = /*#__PURE__*/function () {
|
|
|
171
173
|
}
|
|
172
174
|
}, {
|
|
173
175
|
key: "viewShouldUpdate",
|
|
174
|
-
value: function viewShouldUpdate(nextNode) {
|
|
176
|
+
value: function viewShouldUpdate(nextNode, decorations) {
|
|
175
177
|
if (this._viewShouldUpdate) {
|
|
176
178
|
return this._viewShouldUpdate(nextNode);
|
|
177
179
|
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
+
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; } }
|
|
10
|
+
import ReactNodeView from '../react-node-view';
|
|
11
|
+
/**
|
|
12
|
+
* A ReactNodeView that handles React components sensitive
|
|
13
|
+
* to selection changes.
|
|
14
|
+
*
|
|
15
|
+
* If the selection changes, it will attempt to re-render the
|
|
16
|
+
* React component. Otherwise it does nothing.
|
|
17
|
+
*
|
|
18
|
+
* You can subclass `viewShouldUpdate` to include other
|
|
19
|
+
* props that your component might want to consider before
|
|
20
|
+
* entering the React lifecycle. These are usually props you
|
|
21
|
+
* compare in `shouldComponentUpdate`.
|
|
22
|
+
*
|
|
23
|
+
* An example:
|
|
24
|
+
*
|
|
25
|
+
* ```
|
|
26
|
+
* viewShouldUpdate(nextNode) {
|
|
27
|
+
* if (nextNode.attrs !== this.node.attrs) {
|
|
28
|
+
* return true;
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* return super.viewShouldUpdate(nextNode);
|
|
32
|
+
* }```
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
export var SelectionBasedNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
36
|
+
_inherits(SelectionBasedNodeView, _ReactNodeView);
|
|
37
|
+
var _super = _createSuper(SelectionBasedNodeView);
|
|
38
|
+
function SelectionBasedNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, reactComponent) {
|
|
39
|
+
var _this;
|
|
40
|
+
var hasContext = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
41
|
+
var viewShouldUpdate = arguments.length > 8 ? arguments[8] : undefined;
|
|
42
|
+
var hasIntlContext = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
|
|
43
|
+
_classCallCheck(this, SelectionBasedNodeView);
|
|
44
|
+
_this = _super.call(this, node, view, getPos, portalProviderAPI, eventDispatcher, reactComponentProps, reactComponent, hasContext, viewShouldUpdate, hasIntlContext);
|
|
45
|
+
_defineProperty(_assertThisInitialized(_this), "isSelectedNode", false);
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "isNodeInsideSelection", function (from, to, pos, posEnd) {
|
|
47
|
+
var _this$getPositionsWit = _this.getPositionsWithDefault(pos, posEnd);
|
|
48
|
+
pos = _this$getPositionsWit.pos;
|
|
49
|
+
posEnd = _this$getPositionsWit.posEnd;
|
|
50
|
+
if (typeof pos !== 'number' || typeof posEnd !== 'number') {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return from <= pos && to >= posEnd;
|
|
54
|
+
});
|
|
55
|
+
_defineProperty(_assertThisInitialized(_this), "isSelectionInsideNode", function (from, to, pos, posEnd) {
|
|
56
|
+
var _this$getPositionsWit2 = _this.getPositionsWithDefault(pos, posEnd);
|
|
57
|
+
pos = _this$getPositionsWit2.pos;
|
|
58
|
+
posEnd = _this$getPositionsWit2.posEnd;
|
|
59
|
+
if (typeof pos !== 'number' || typeof posEnd !== 'number') {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return pos < from && to < posEnd;
|
|
63
|
+
});
|
|
64
|
+
_defineProperty(_assertThisInitialized(_this), "insideSelection", function () {
|
|
65
|
+
var _this$view$state$sele = _this.view.state.selection,
|
|
66
|
+
from = _this$view$state$sele.from,
|
|
67
|
+
to = _this$view$state$sele.to;
|
|
68
|
+
return _this.isSelectedNode || _this.isSelectionInsideNode(from, to);
|
|
69
|
+
});
|
|
70
|
+
_defineProperty(_assertThisInitialized(_this), "nodeInsideSelection", function () {
|
|
71
|
+
var selection = _this.view.state.selection;
|
|
72
|
+
var from = selection.from,
|
|
73
|
+
to = selection.to;
|
|
74
|
+
return _this.isSelectedNode || _this.isNodeInsideSelection(from, to);
|
|
75
|
+
});
|
|
76
|
+
_this.updatePos();
|
|
77
|
+
return _this;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Update current node's start and end positions.
|
|
82
|
+
*
|
|
83
|
+
* Prefer `this.pos` rather than getPos(), because calling getPos is
|
|
84
|
+
* expensive, unless you know you're definitely going to render.
|
|
85
|
+
*/
|
|
86
|
+
_createClass(SelectionBasedNodeView, [{
|
|
87
|
+
key: "updatePos",
|
|
88
|
+
value: function updatePos() {
|
|
89
|
+
if (typeof this.getPos === 'boolean') {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this.pos = this.getPos();
|
|
93
|
+
this.posEnd = this.pos + this.node.nodeSize;
|
|
94
|
+
}
|
|
95
|
+
}, {
|
|
96
|
+
key: "getPositionsWithDefault",
|
|
97
|
+
value: function getPositionsWithDefault(pos, posEnd) {
|
|
98
|
+
return {
|
|
99
|
+
pos: typeof pos !== 'number' ? this.pos : pos,
|
|
100
|
+
posEnd: typeof posEnd !== 'number' ? this.posEnd : posEnd
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
104
|
+
key: "selectNode",
|
|
105
|
+
value: function selectNode() {
|
|
106
|
+
this.isSelectedNode = true;
|
|
107
|
+
this.update(this.node, this.decorations);
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "deselectNode",
|
|
111
|
+
value: function deselectNode() {
|
|
112
|
+
this.isSelectedNode = false;
|
|
113
|
+
this.update(this.node, this.decorations);
|
|
114
|
+
}
|
|
115
|
+
}]);
|
|
116
|
+
return SelectionBasedNodeView;
|
|
117
|
+
}(ReactNodeView);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SelectionBasedNodeView } from './SelectionBasedNodeView';
|
|
@@ -18,7 +18,7 @@ import { themed } from '@atlaskit/theme/components';
|
|
|
18
18
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
19
19
|
import Layer from '../Layer';
|
|
20
20
|
var packageName = "@atlaskit/editor-common";
|
|
21
|
-
var packageVersion = "74.
|
|
21
|
+
var packageVersion = "74.8.0";
|
|
22
22
|
var halfFocusRing = 1;
|
|
23
23
|
var dropOffset = '0, 8';
|
|
24
24
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -104,7 +104,6 @@ export var PortalProviderAPI = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
104
104
|
} catch (error) {
|
|
105
105
|
if (this.onAnalyticsEvent) {
|
|
106
106
|
this.onAnalyticsEvent({
|
|
107
|
-
// @ts-expect-error
|
|
108
107
|
payload: {
|
|
109
108
|
action: ACTION.FAILED_TO_UNMOUNT,
|
|
110
109
|
actionSubject: ACTION_SUBJECT.EDITOR,
|
package/dist/esm/version.json
CHANGED
|
@@ -4,7 +4,7 @@ import { Decoration, EditorView, NodeView } from 'prosemirror-view';
|
|
|
4
4
|
import { EventDispatcher } from '../event-dispatcher';
|
|
5
5
|
import type { PortalProviderAPI } from '../ui/PortalProvider';
|
|
6
6
|
import { ForwardRef, getPosHandler, ReactComponentProps, shouldUpdate } from './types';
|
|
7
|
-
export type { getPosHandler, ReactComponentProps };
|
|
7
|
+
export type { getPosHandler, ReactComponentProps, shouldUpdate };
|
|
8
8
|
export type { InlineNodeViewComponentProps } from './getInlineNodeViewProducer';
|
|
9
9
|
export { getInlineNodeViewProducer, inlineNodeViewClassname, } from './getInlineNodeViewProducer';
|
|
10
10
|
export default class ReactNodeView<P = ReactComponentProps> implements NodeView {
|
|
@@ -16,6 +16,7 @@ export default class ReactNodeView<P = ReactComponentProps> implements NodeView
|
|
|
16
16
|
private _viewShouldUpdate?;
|
|
17
17
|
protected eventDispatcher?: EventDispatcher;
|
|
18
18
|
private hasIntlContext;
|
|
19
|
+
protected decorations: Decoration[];
|
|
19
20
|
reactComponentProps: P;
|
|
20
21
|
view: EditorView;
|
|
21
22
|
getPos: getPosHandler;
|
|
@@ -41,8 +42,8 @@ export default class ReactNodeView<P = ReactComponentProps> implements NodeView
|
|
|
41
42
|
handleRef: (node: HTMLElement | null) => void;
|
|
42
43
|
private _handleRef;
|
|
43
44
|
render(props: P, forwardRef?: ForwardRef): React.ReactElement<any> | null;
|
|
44
|
-
update(node: PMNode,
|
|
45
|
-
viewShouldUpdate(nextNode: PMNode): boolean;
|
|
45
|
+
update(node: PMNode, decorations: Array<Decoration>, _innerDecorations?: Array<Decoration>, validUpdate?: (currentNode: PMNode, newNode: PMNode) => boolean): boolean;
|
|
46
|
+
viewShouldUpdate(nextNode: PMNode, decorations?: Array<Decoration>): boolean;
|
|
46
47
|
/**
|
|
47
48
|
* Copies the attributes from a ProseMirror Node to a DOM node.
|
|
48
49
|
* @param node The Prosemirror Node from which to source the attributes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Node as PMNode } from 'prosemirror-model';
|
|
3
|
+
import { EditorView } from 'prosemirror-view';
|
|
4
|
+
import { EventDispatcher } from '../event-dispatcher';
|
|
5
|
+
import ReactNodeView, { getPosHandler, ReactComponentProps, shouldUpdate } from '../react-node-view';
|
|
6
|
+
import { PortalProviderAPI } from '../ui/PortalProvider';
|
|
7
|
+
/**
|
|
8
|
+
* A ReactNodeView that handles React components sensitive
|
|
9
|
+
* to selection changes.
|
|
10
|
+
*
|
|
11
|
+
* If the selection changes, it will attempt to re-render the
|
|
12
|
+
* React component. Otherwise it does nothing.
|
|
13
|
+
*
|
|
14
|
+
* You can subclass `viewShouldUpdate` to include other
|
|
15
|
+
* props that your component might want to consider before
|
|
16
|
+
* entering the React lifecycle. These are usually props you
|
|
17
|
+
* compare in `shouldComponentUpdate`.
|
|
18
|
+
*
|
|
19
|
+
* An example:
|
|
20
|
+
*
|
|
21
|
+
* ```
|
|
22
|
+
* viewShouldUpdate(nextNode) {
|
|
23
|
+
* if (nextNode.attrs !== this.node.attrs) {
|
|
24
|
+
* return true;
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* return super.viewShouldUpdate(nextNode);
|
|
28
|
+
* }```
|
|
29
|
+
*/
|
|
30
|
+
export declare class SelectionBasedNodeView<P = ReactComponentProps> extends ReactNodeView<P> {
|
|
31
|
+
protected isSelectedNode: boolean;
|
|
32
|
+
pos: number | undefined;
|
|
33
|
+
posEnd: number | undefined;
|
|
34
|
+
constructor(node: PMNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, reactComponentProps: P, reactComponent?: React.ComponentType<any>, hasContext?: boolean, viewShouldUpdate?: shouldUpdate, hasIntlContext?: boolean);
|
|
35
|
+
/**
|
|
36
|
+
* Update current node's start and end positions.
|
|
37
|
+
*
|
|
38
|
+
* Prefer `this.pos` rather than getPos(), because calling getPos is
|
|
39
|
+
* expensive, unless you know you're definitely going to render.
|
|
40
|
+
*/
|
|
41
|
+
private updatePos;
|
|
42
|
+
private getPositionsWithDefault;
|
|
43
|
+
private isNodeInsideSelection;
|
|
44
|
+
private isSelectionInsideNode;
|
|
45
|
+
insideSelection: () => boolean;
|
|
46
|
+
nodeInsideSelection: () => boolean;
|
|
47
|
+
selectNode(): void;
|
|
48
|
+
deselectNode(): void;
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SelectionBasedNodeView } from './SelectionBasedNodeView';
|
|
@@ -28,7 +28,7 @@ export type { EditorReactContext } from './editor-react-context';
|
|
|
28
28
|
export type { PMPluginFactoryParams, PMPluginFactory, PMPlugin, } from './plugin-factory';
|
|
29
29
|
export type { NodeConfig, MarkConfig, NodeViewConfig, } from './prosemirror-config';
|
|
30
30
|
export type { PluginsOptions, EditorPlugin, getPosHandler, getPosHandlerNode, } from './editor-plugin';
|
|
31
|
-
export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependency, } from './next-editor-plugin';
|
|
31
|
+
export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependency, PluginInjectionAPIWithDependencies, } from './next-editor-plugin';
|
|
32
32
|
export type IconProps = {
|
|
33
33
|
label?: string;
|
|
34
34
|
};
|
|
@@ -37,6 +37,9 @@ export type PluginInjectionAPIWithDependency<Plugin> = Plugin extends NextEditor
|
|
|
37
37
|
NextEditorPlugin<Name, Metadata>
|
|
38
38
|
]>;
|
|
39
39
|
} : never;
|
|
40
|
+
export type PluginInjectionAPIWithDependencies<Plugins> = Plugins extends NextEditorPlugin<infer Name, infer Metadata>[] ? {
|
|
41
|
+
dependencies: CreatePluginDependenciesAPI<Plugins>;
|
|
42
|
+
} : never;
|
|
40
43
|
type NextEditorPluginFunctionDefinition<Name extends string, Metadata extends NextEditorPluginMetadata, Configuration> = (config: Configuration, api?: PluginInjectionAPI<Name, Metadata>) => DefaultEditorPlugin<Name, Metadata>;
|
|
41
44
|
type NextEditorPluginFunctionOptionalConfigDefinition<Name extends string, Metadata extends NextEditorPluginMetadata, Configuration = undefined> = (config?: Configuration, api?: PluginInjectionAPI<Name, Metadata>) => DefaultEditorPlugin<Name, Metadata>;
|
|
42
45
|
type OptionalPrivateProperty = {
|
|
@@ -4,7 +4,7 @@ import { Decoration, EditorView, NodeView } from 'prosemirror-view';
|
|
|
4
4
|
import { EventDispatcher } from '../event-dispatcher';
|
|
5
5
|
import type { PortalProviderAPI } from '../ui/PortalProvider';
|
|
6
6
|
import { ForwardRef, getPosHandler, ReactComponentProps, shouldUpdate } from './types';
|
|
7
|
-
export type { getPosHandler, ReactComponentProps };
|
|
7
|
+
export type { getPosHandler, ReactComponentProps, shouldUpdate };
|
|
8
8
|
export type { InlineNodeViewComponentProps } from './getInlineNodeViewProducer';
|
|
9
9
|
export { getInlineNodeViewProducer, inlineNodeViewClassname, } from './getInlineNodeViewProducer';
|
|
10
10
|
export default class ReactNodeView<P = ReactComponentProps> implements NodeView {
|
|
@@ -16,6 +16,7 @@ export default class ReactNodeView<P = ReactComponentProps> implements NodeView
|
|
|
16
16
|
private _viewShouldUpdate?;
|
|
17
17
|
protected eventDispatcher?: EventDispatcher;
|
|
18
18
|
private hasIntlContext;
|
|
19
|
+
protected decorations: Decoration[];
|
|
19
20
|
reactComponentProps: P;
|
|
20
21
|
view: EditorView;
|
|
21
22
|
getPos: getPosHandler;
|
|
@@ -41,8 +42,8 @@ export default class ReactNodeView<P = ReactComponentProps> implements NodeView
|
|
|
41
42
|
handleRef: (node: HTMLElement | null) => void;
|
|
42
43
|
private _handleRef;
|
|
43
44
|
render(props: P, forwardRef?: ForwardRef): React.ReactElement<any> | null;
|
|
44
|
-
update(node: PMNode,
|
|
45
|
-
viewShouldUpdate(nextNode: PMNode): boolean;
|
|
45
|
+
update(node: PMNode, decorations: Array<Decoration>, _innerDecorations?: Array<Decoration>, validUpdate?: (currentNode: PMNode, newNode: PMNode) => boolean): boolean;
|
|
46
|
+
viewShouldUpdate(nextNode: PMNode, decorations?: Array<Decoration>): boolean;
|
|
46
47
|
/**
|
|
47
48
|
* Copies the attributes from a ProseMirror Node to a DOM node.
|
|
48
49
|
* @param node The Prosemirror Node from which to source the attributes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Node as PMNode } from 'prosemirror-model';
|
|
3
|
+
import { EditorView } from 'prosemirror-view';
|
|
4
|
+
import { EventDispatcher } from '../event-dispatcher';
|
|
5
|
+
import ReactNodeView, { getPosHandler, ReactComponentProps, shouldUpdate } from '../react-node-view';
|
|
6
|
+
import { PortalProviderAPI } from '../ui/PortalProvider';
|
|
7
|
+
/**
|
|
8
|
+
* A ReactNodeView that handles React components sensitive
|
|
9
|
+
* to selection changes.
|
|
10
|
+
*
|
|
11
|
+
* If the selection changes, it will attempt to re-render the
|
|
12
|
+
* React component. Otherwise it does nothing.
|
|
13
|
+
*
|
|
14
|
+
* You can subclass `viewShouldUpdate` to include other
|
|
15
|
+
* props that your component might want to consider before
|
|
16
|
+
* entering the React lifecycle. These are usually props you
|
|
17
|
+
* compare in `shouldComponentUpdate`.
|
|
18
|
+
*
|
|
19
|
+
* An example:
|
|
20
|
+
*
|
|
21
|
+
* ```
|
|
22
|
+
* viewShouldUpdate(nextNode) {
|
|
23
|
+
* if (nextNode.attrs !== this.node.attrs) {
|
|
24
|
+
* return true;
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* return super.viewShouldUpdate(nextNode);
|
|
28
|
+
* }```
|
|
29
|
+
*/
|
|
30
|
+
export declare class SelectionBasedNodeView<P = ReactComponentProps> extends ReactNodeView<P> {
|
|
31
|
+
protected isSelectedNode: boolean;
|
|
32
|
+
pos: number | undefined;
|
|
33
|
+
posEnd: number | undefined;
|
|
34
|
+
constructor(node: PMNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, reactComponentProps: P, reactComponent?: React.ComponentType<any>, hasContext?: boolean, viewShouldUpdate?: shouldUpdate, hasIntlContext?: boolean);
|
|
35
|
+
/**
|
|
36
|
+
* Update current node's start and end positions.
|
|
37
|
+
*
|
|
38
|
+
* Prefer `this.pos` rather than getPos(), because calling getPos is
|
|
39
|
+
* expensive, unless you know you're definitely going to render.
|
|
40
|
+
*/
|
|
41
|
+
private updatePos;
|
|
42
|
+
private getPositionsWithDefault;
|
|
43
|
+
private isNodeInsideSelection;
|
|
44
|
+
private isSelectionInsideNode;
|
|
45
|
+
insideSelection: () => boolean;
|
|
46
|
+
nodeInsideSelection: () => boolean;
|
|
47
|
+
selectNode(): void;
|
|
48
|
+
deselectNode(): void;
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SelectionBasedNodeView } from './SelectionBasedNodeView';
|
|
@@ -28,7 +28,7 @@ export type { EditorReactContext } from './editor-react-context';
|
|
|
28
28
|
export type { PMPluginFactoryParams, PMPluginFactory, PMPlugin, } from './plugin-factory';
|
|
29
29
|
export type { NodeConfig, MarkConfig, NodeViewConfig, } from './prosemirror-config';
|
|
30
30
|
export type { PluginsOptions, EditorPlugin, getPosHandler, getPosHandlerNode, } from './editor-plugin';
|
|
31
|
-
export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependency, } from './next-editor-plugin';
|
|
31
|
+
export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependency, PluginInjectionAPIWithDependencies, } from './next-editor-plugin';
|
|
32
32
|
export type IconProps = {
|
|
33
33
|
label?: string;
|
|
34
34
|
};
|
|
@@ -37,6 +37,9 @@ export type PluginInjectionAPIWithDependency<Plugin> = Plugin extends NextEditor
|
|
|
37
37
|
NextEditorPlugin<Name, Metadata>
|
|
38
38
|
]>;
|
|
39
39
|
} : never;
|
|
40
|
+
export type PluginInjectionAPIWithDependencies<Plugins> = Plugins extends NextEditorPlugin<infer Name, infer Metadata>[] ? {
|
|
41
|
+
dependencies: CreatePluginDependenciesAPI<Plugins>;
|
|
42
|
+
} : never;
|
|
40
43
|
type NextEditorPluginFunctionDefinition<Name extends string, Metadata extends NextEditorPluginMetadata, Configuration> = (config: Configuration, api?: PluginInjectionAPI<Name, Metadata>) => DefaultEditorPlugin<Name, Metadata>;
|
|
41
44
|
type NextEditorPluginFunctionOptionalConfigDefinition<Name extends string, Metadata extends NextEditorPluginMetadata, Configuration = undefined> = (config?: Configuration, api?: PluginInjectionAPI<Name, Metadata>) => DefaultEditorPlugin<Name, Metadata>;
|
|
42
45
|
type OptionalPrivateProperty = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "74.
|
|
3
|
+
"version": "74.8.0",
|
|
4
4
|
"description": "A package that contains common classes and components for editor and renderer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -67,7 +67,8 @@
|
|
|
67
67
|
"./monitoring": "./src/monitoring/index.ts",
|
|
68
68
|
"./paste": "./src/paste/index.ts",
|
|
69
69
|
"./resizer": "./src/resizer/index.ts",
|
|
70
|
-
"./editor-analytics": "./src/editor-analytics/index.ts"
|
|
70
|
+
"./editor-analytics": "./src/editor-analytics/index.ts",
|
|
71
|
+
"./selection-based-node-view": "./src/selection-based-node-view/index.ts"
|
|
71
72
|
},
|
|
72
73
|
"dependencies": {
|
|
73
74
|
"@atlaskit/activity-provider": "^2.4.0",
|
|
@@ -77,7 +78,7 @@
|
|
|
77
78
|
"@atlaskit/analytics-namespaced-context": "^6.7.0",
|
|
78
79
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
79
80
|
"@atlaskit/analytics-next-stable-react-context": "1.0.1",
|
|
80
|
-
"@atlaskit/button": "^16.
|
|
81
|
+
"@atlaskit/button": "^16.8.0",
|
|
81
82
|
"@atlaskit/code": "^14.6.0",
|
|
82
83
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
83
84
|
"@atlaskit/collab-provider": "^9.2.0",
|
|
@@ -143,7 +144,7 @@
|
|
|
143
144
|
"@atlaskit/editor-plugin-grid": "^0.1.0",
|
|
144
145
|
"@atlaskit/editor-plugin-table": "^1.6.0",
|
|
145
146
|
"@atlaskit/editor-plugin-width": "^0.1.0",
|
|
146
|
-
"@atlaskit/editor-test-helpers": "^18.
|
|
147
|
+
"@atlaskit/editor-test-helpers": "^18.7.0",
|
|
147
148
|
"@atlaskit/media-core": "^34.1.0",
|
|
148
149
|
"@atlaskit/media-test-helpers": "^33.0.0",
|
|
149
150
|
"@atlaskit/smart-card": "^26.5.0",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/editor-common/selection-based-node-view",
|
|
3
|
+
"main": "../dist/cjs/selection-based-node-view/index.js",
|
|
4
|
+
"module": "../dist/esm/selection-based-node-view/index.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/selection-based-node-view/index.js",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "../dist/types/selection-based-node-view/index.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.5 <4.9": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.5/selection-based-node-view/index.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|