@atlaskit/editor-common 63.0.1 → 64.0.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 +26 -0
- package/dist/cjs/safe-plugin/index.js +42 -0
- package/dist/cjs/styles/index.js +0 -8
- package/dist/cjs/styles/shared/block-marks.js +1 -1
- package/dist/cjs/styles/shared/lists.js +3 -1
- package/dist/cjs/types/collab.js +5 -0
- package/dist/cjs/ui/MediaSingle/index.js +3 -1
- package/dist/cjs/ui/Mention/index.js +1 -3
- package/dist/cjs/ui/Mention/mention-with-profilecard.js +33 -194
- package/dist/cjs/ui/Mention/mention-with-providers.js +1 -5
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/safe-plugin/index.js +10 -0
- package/dist/es2019/styles/index.js +0 -1
- package/dist/es2019/styles/shared/block-marks.js +2 -1
- package/dist/es2019/styles/shared/lists.js +16 -0
- package/dist/es2019/types/collab.js +1 -0
- package/dist/es2019/ui/MediaSingle/index.js +3 -1
- package/dist/es2019/ui/Mention/index.js +1 -3
- package/dist/es2019/ui/Mention/mention-with-profilecard.js +33 -146
- package/dist/es2019/ui/Mention/mention-with-providers.js +1 -5
- package/dist/es2019/version.json +1 -1
- package/dist/esm/safe-plugin/index.js +27 -0
- package/dist/esm/styles/index.js +0 -1
- package/dist/esm/styles/shared/block-marks.js +1 -1
- package/dist/esm/styles/shared/lists.js +2 -1
- package/dist/esm/types/collab.js +1 -0
- package/dist/esm/ui/MediaSingle/index.js +3 -1
- package/dist/esm/ui/Mention/index.js +1 -3
- package/dist/esm/ui/Mention/mention-with-profilecard.js +33 -189
- package/dist/esm/ui/Mention/mention-with-providers.js +1 -5
- package/dist/esm/version.json +1 -1
- package/dist/types/collab/types.d.ts +14 -2
- package/dist/types/collab.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/safe-plugin/index.d.ts +6 -0
- package/dist/types/styles/index.d.ts +0 -1
- package/dist/types/types/collab.d.ts +8 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/ui/MediaSingle/index.d.ts +2 -1
- package/dist/types/ui/MediaSingle/styled.d.ts +2 -2
- package/dist/types/ui/Mention/index.d.ts +0 -3
- package/dist/types/ui/Mention/mention-with-profilecard.d.ts +2 -25
- package/dist/types/ui/Mention/mention-with-providers.d.ts +0 -3
- package/dist/types/ui/index.d.ts +1 -1
- package/package.json +11 -10
- package/safe-plugin/package.json +7 -0
- package/dist/cjs/styles/shared/inline-nodes.js +0 -17
- package/dist/es2019/styles/shared/inline-nodes.js +0 -7
- package/dist/esm/styles/shared/inline-nodes.js +0 -7
- package/dist/types/styles/shared/inline-nodes.d.ts +0 -2
|
@@ -1,148 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { PureComponent } from 'react';
|
|
3
|
-
import { findDOMNode } from 'react-dom';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
4
2
|
import { ResourcedMention } from '@atlaskit/mention';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
event.stopPropagation();
|
|
40
|
-
const [popupAlignX, popupAlignY] = this.calculateLayerPosition();
|
|
41
|
-
this.setState({
|
|
42
|
-
popupAlignX,
|
|
43
|
-
popupAlignY,
|
|
44
|
-
visible: true
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
_defineProperty(this, "hideProfilecard", () => {
|
|
49
|
-
this.setState({
|
|
50
|
-
visible: false
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
calculateLayerPosition() {
|
|
56
|
-
const domNodeCentreCoords = this.getDomNodeCenterCoords();
|
|
57
|
-
const visibleAreaCentreCoords = this.getVisibleAreaCentreCoords();
|
|
58
|
-
const popupAlignY = domNodeCentreCoords.y > visibleAreaCentreCoords.y ? 'top' : 'bottom';
|
|
59
|
-
const popupAlignX = domNodeCentreCoords.x > visibleAreaCentreCoords.x ? 'right' : 'left';
|
|
60
|
-
return [popupAlignX, popupAlignY];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
getDomNodeCenterCoords() {
|
|
64
|
-
const rect = this.domNode.getBoundingClientRect();
|
|
65
|
-
return {
|
|
66
|
-
x: rect.left + rect.width / 2,
|
|
67
|
-
y: rect.top + rect.height / 2
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
getVisibleAreaCentreCoords() {
|
|
72
|
-
return {
|
|
73
|
-
x: window.innerWidth / 2,
|
|
74
|
-
y: window.innerHeight / 2
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
getActions(id, text, accessLevel) {
|
|
79
|
-
const {
|
|
80
|
-
profilecardProvider
|
|
81
|
-
} = this.props;
|
|
82
|
-
const actions = profilecardProvider.getActions(id, text, accessLevel);
|
|
83
|
-
return actions.map(action => {
|
|
84
|
-
return { ...action,
|
|
85
|
-
callback: () => {
|
|
86
|
-
this.setState({
|
|
87
|
-
visible: false
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
if (action && action.callback) {
|
|
91
|
-
action.callback();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
render() {
|
|
99
|
-
const {
|
|
100
|
-
accessLevel,
|
|
101
|
-
id,
|
|
102
|
-
mentionProvider,
|
|
103
|
-
profilecardProvider,
|
|
104
|
-
text,
|
|
105
|
-
onClick,
|
|
106
|
-
onMouseEnter,
|
|
107
|
-
onMouseLeave,
|
|
108
|
-
portal
|
|
109
|
-
} = this.props;
|
|
110
|
-
const {
|
|
111
|
-
popupAlignX,
|
|
112
|
-
popupAlignY,
|
|
113
|
-
target,
|
|
114
|
-
visible
|
|
115
|
-
} = this.state;
|
|
116
|
-
const {
|
|
117
|
-
cloudId,
|
|
118
|
-
resourceClient
|
|
119
|
-
} = profilecardProvider;
|
|
120
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
121
|
-
ref: this.handleRef,
|
|
122
|
-
onClick: this.showProfilecard
|
|
123
|
-
}, /*#__PURE__*/React.createElement(ResourcedMention, {
|
|
124
|
-
ref: this.handleMentionNodeRef,
|
|
125
|
-
id: id,
|
|
126
|
-
text: text,
|
|
127
|
-
accessLevel: accessLevel,
|
|
128
|
-
mentionProvider: mentionProvider,
|
|
129
|
-
onClick: onClick,
|
|
130
|
-
onMouseEnter: onMouseEnter,
|
|
131
|
-
onMouseLeave: onMouseLeave
|
|
132
|
-
}), target && portal && visible && /*#__PURE__*/React.createElement(Popup, {
|
|
133
|
-
offset: [0, 8],
|
|
134
|
-
target: target,
|
|
135
|
-
mountTo: portal,
|
|
136
|
-
alignX: popupAlignX,
|
|
137
|
-
alignY: popupAlignY
|
|
138
|
-
}, /*#__PURE__*/React.createElement(ProfilecardResourcedWithListeners, {
|
|
139
|
-
handleClickOutside: this.hideProfilecard,
|
|
140
|
-
handleEscapeKeydown: this.hideProfilecard,
|
|
141
|
-
cloudId: cloudId,
|
|
142
|
-
userId: id,
|
|
143
|
-
resourceClient: resourceClient,
|
|
144
|
-
actions: this.getActions(id, text, accessLevel)
|
|
145
|
-
})));
|
|
146
|
-
}
|
|
147
|
-
|
|
3
|
+
import { ProfileCardTrigger } from '@atlaskit/profilecard';
|
|
4
|
+
export default function MentionWithProfileCard({
|
|
5
|
+
id,
|
|
6
|
+
text,
|
|
7
|
+
accessLevel,
|
|
8
|
+
mentionProvider,
|
|
9
|
+
profilecardProvider,
|
|
10
|
+
onClick,
|
|
11
|
+
onMouseEnter,
|
|
12
|
+
onMouseLeave
|
|
13
|
+
}) {
|
|
14
|
+
const {
|
|
15
|
+
cloudId,
|
|
16
|
+
resourceClient
|
|
17
|
+
} = profilecardProvider;
|
|
18
|
+
const actions = useMemo(() => profilecardProvider.getActions(id, text, accessLevel), [accessLevel, id, profilecardProvider, text]);
|
|
19
|
+
return /*#__PURE__*/React.createElement(ProfileCardTrigger, {
|
|
20
|
+
cloudId: cloudId,
|
|
21
|
+
userId: id,
|
|
22
|
+
resourceClient: resourceClient,
|
|
23
|
+
actions: actions,
|
|
24
|
+
trigger: "click",
|
|
25
|
+
position: "bottom-end"
|
|
26
|
+
}, /*#__PURE__*/React.createElement(ResourcedMention, {
|
|
27
|
+
id: id,
|
|
28
|
+
text: text,
|
|
29
|
+
accessLevel: accessLevel,
|
|
30
|
+
mentionProvider: mentionProvider,
|
|
31
|
+
onClick: onClick,
|
|
32
|
+
onMouseEnter: onMouseEnter,
|
|
33
|
+
onMouseLeave: onMouseLeave
|
|
34
|
+
}));
|
|
148
35
|
}
|
|
@@ -51,11 +51,9 @@ export default class MentionWithProviders extends PureComponent {
|
|
|
51
51
|
render() {
|
|
52
52
|
const {
|
|
53
53
|
accessLevel,
|
|
54
|
-
userType,
|
|
55
54
|
eventHandlers,
|
|
56
55
|
id,
|
|
57
56
|
mentionProvider,
|
|
58
|
-
portal,
|
|
59
57
|
text
|
|
60
58
|
} = this.props;
|
|
61
59
|
const {
|
|
@@ -70,10 +68,8 @@ export default class MentionWithProviders extends PureComponent {
|
|
|
70
68
|
id: id,
|
|
71
69
|
text: text,
|
|
72
70
|
accessLevel: accessLevel,
|
|
73
|
-
userType: userType,
|
|
74
71
|
mentionProvider: mentionProvider,
|
|
75
|
-
profilecardProvider: profilecardProvider
|
|
76
|
-
portal: portal
|
|
72
|
+
profilecardProvider: profilecardProvider
|
|
77
73
|
}, actionHandlers));
|
|
78
74
|
}
|
|
79
75
|
|
package/dist/es2019/version.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
|
|
7
|
+
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); }; }
|
|
8
|
+
|
|
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
|
+
|
|
11
|
+
import { Plugin } from 'prosemirror-state';
|
|
12
|
+
export var SafePlugin = /*#__PURE__*/function (_Plugin) {
|
|
13
|
+
_inherits(SafePlugin, _Plugin);
|
|
14
|
+
|
|
15
|
+
var _super = _createSuper(SafePlugin);
|
|
16
|
+
|
|
17
|
+
// This variable isn't (and shouldn't) be used anywhere. Its purpose is
|
|
18
|
+
// to distinguish Plugin from SafePlugin, thus ensuring that an 'unsafe'
|
|
19
|
+
// Plugin cannot be assigned as an item in EditorPlugin → pmPlugins.
|
|
20
|
+
function SafePlugin(spec) {
|
|
21
|
+
_classCallCheck(this, SafePlugin);
|
|
22
|
+
|
|
23
|
+
return _super.call(this, spec);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return _createClass(SafePlugin);
|
|
27
|
+
}(Plugin);
|
package/dist/esm/styles/index.js
CHANGED
|
@@ -9,7 +9,6 @@ export { getPanelTypeBackground, darkPanelColors, getPanelDarkColor, panelShared
|
|
|
9
9
|
export { ruleSharedStyles } from './shared/rule';
|
|
10
10
|
export { whitespaceSharedStyles } from './shared/whitespace';
|
|
11
11
|
export { paragraphSharedStyles } from './shared/paragraph';
|
|
12
|
-
export { inlineNodeSharedStyle } from './shared/inline-nodes';
|
|
13
12
|
export { linkSharedStyle } from './shared/link';
|
|
14
13
|
export { listsSharedStyles } from './shared/lists';
|
|
15
14
|
export { indentationSharedStyles } from './shared/indentation';
|
|
@@ -3,4 +3,4 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
|
|
|
3
3
|
var _templateObject;
|
|
4
4
|
|
|
5
5
|
import { css } from 'styled-components';
|
|
6
|
-
export var blockMarksSharedStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /**\n * We need to remove margin-top from first item\n * inside doc, tableCell, tableHeader, blockquote, etc.\n */\n *:not(.fabric-editor-block-mark) >,\n /* For nested block marks */\n *:not(.fabric-editor-block-mark) > div.fabric-editor-block-mark:first-child {\n p,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n &:first-child {\n margin-top: 0;\n }\n }\n }\n"])));
|
|
6
|
+
export var blockMarksSharedStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /**\n * We need to remove margin-top from first item\n * inside doc, tableCell, tableHeader, blockquote, etc.\n */\n *:not(.fabric-editor-block-mark) >,\n /* For nested block marks */\n *:not(.fabric-editor-block-mark) > div.fabric-editor-block-mark:first-child {\n p,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n .heading-wrapper {\n &:first-child {\n margin-top: 0;\n }\n }\n }\n"])));
|
|
@@ -4,4 +4,5 @@ var _templateObject;
|
|
|
4
4
|
|
|
5
5
|
import { css } from 'styled-components';
|
|
6
6
|
import { bulletListSelector, orderedListSelector } from '@atlaskit/adf-schema';
|
|
7
|
-
|
|
7
|
+
import browser from '../../utils/browser';
|
|
8
|
+
export var listsSharedStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /* =============== INDENTATION SPACING ========= */\n\n ul,\n ol {\n box-sizing: border-box;\n padding-left: 24px;\n\n /*\n Firefox does not handle empty block element inside li tag.\n If there is not block element inside li tag,\n then firefox sets inherited height to li\n However, if there is any block element and if it's empty\n (or has empty inline element) then\n firefox sets li tag height to zero.\n More details at\n https://product-fabric.atlassian.net/wiki/spaces/~455502413/pages/3149365890/ED-14110+Investigation\n */\n li p:empty,\n li p > span:empty {\n ", "\n }\n }\n\n ", ", ", " {\n /*\n Ensures list item content adheres to the list's margin instead\n of filling the entire block row. This is important to allow\n clicking interactive elements which are floated next to a list.\n\n For some history and context on this block, see PRs related to tickets.:\n @see ED-6551 - original issue.\n @see ED-7015 - follow up issue.\n @see ED-7447 - flow-root change.\n\n We use 'display: table' (old clear fix / new block formatting context hack)\n for older browsers and 'flow-root' for modern browsers.\n\n @see https://css-tricks.com/display-flow-root/\n */\n // For older browsers the do not support flow-root.\n display: table;\n display: flow-root;\n }\n\n /* =============== INDENTATION AESTHETICS ========= */\n\n /**\n We support nested lists up to six levels deep.\n **/\n\n /* LEGACY LISTS */\n\n ul,\n ul ul ul ul {\n list-style-type: disc;\n }\n\n ul ul,\n ul ul ul ul ul {\n list-style-type: circle;\n }\n\n ul ul ul,\n ul ul ul ul ul ul {\n list-style-type: square;\n }\n\n ol,\n ol ol ol ol {\n list-style-type: decimal;\n }\n ol ol,\n ol ol ol ol ol {\n list-style-type: lower-alpha;\n }\n ol ol ol,\n ol ol ol ol ol ol {\n list-style-type: lower-roman;\n }\n\n /* PREDICTABLE LISTS */\n\n ol[data-indent-level='1'],\n ol[data-indent-level='4'] {\n list-style-type: decimal;\n }\n\n ol[data-indent-level='2'],\n ol[data-indent-level='5'] {\n list-style-type: lower-alpha;\n }\n\n ol[data-indent-level='3'],\n ol[data-indent-level='6'] {\n list-style-type: lower-roman;\n }\n\n ul[data-indent-level='1'],\n ul[data-indent-level='4'] {\n list-style-type: disc;\n }\n\n ul[data-indent-level='2'],\n ul[data-indent-level='5'] {\n list-style-type: circle;\n }\n\n ul[data-indent-level='3'],\n ul[data-indent-level='6'] {\n list-style-type: square;\n }\n"])), browser.gecko ? 'display: inline-block;' : '', orderedListSelector, bulletListSelector);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -26,7 +26,8 @@ export default function MediaSingle(_ref) {
|
|
|
26
26
|
fullWidthMode = _ref.fullWidthMode,
|
|
27
27
|
lineLength = _ref.lineLength,
|
|
28
28
|
_ref$hasFallbackConta = _ref.hasFallbackContainer,
|
|
29
|
-
hasFallbackContainer = _ref$hasFallbackConta === void 0 ? true : _ref$hasFallbackConta
|
|
29
|
+
hasFallbackContainer = _ref$hasFallbackConta === void 0 ? true : _ref$hasFallbackConta,
|
|
30
|
+
handleMediaSingleRef = _ref.handleMediaSingleRef;
|
|
30
31
|
var children = React.Children.toArray(propsChildren);
|
|
31
32
|
|
|
32
33
|
if (!pctWidth && shouldAddDefaultWrappedWidth(layout, width, lineLength)) {
|
|
@@ -81,6 +82,7 @@ export default function MediaSingle(_ref) {
|
|
|
81
82
|
caption = _children[1];
|
|
82
83
|
|
|
83
84
|
return /*#__PURE__*/React.createElement(MediaSingleWrapper, {
|
|
85
|
+
innerRef: handleMediaSingleRef,
|
|
84
86
|
width: width,
|
|
85
87
|
layout: layout,
|
|
86
88
|
containerWidth: containerWidth,
|
|
@@ -31,7 +31,6 @@ var Mention = /*#__PURE__*/function (_PureComponent) {
|
|
|
31
31
|
accessLevel = _this$props.accessLevel,
|
|
32
32
|
eventHandlers = _this$props.eventHandlers,
|
|
33
33
|
id = _this$props.id,
|
|
34
|
-
portal = _this$props.portal,
|
|
35
34
|
text = _this$props.text;
|
|
36
35
|
var mentionProvider = providers.mentionProvider,
|
|
37
36
|
profilecardProvider = providers.profilecardProvider;
|
|
@@ -41,8 +40,7 @@ var Mention = /*#__PURE__*/function (_PureComponent) {
|
|
|
41
40
|
accessLevel: accessLevel,
|
|
42
41
|
eventHandlers: eventHandlers,
|
|
43
42
|
mentionProvider: mentionProvider,
|
|
44
|
-
profilecardProvider: profilecardProvider
|
|
45
|
-
portal: portal
|
|
43
|
+
profilecardProvider: profilecardProvider
|
|
46
44
|
});
|
|
47
45
|
});
|
|
48
46
|
|
|
@@ -1,190 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
|
|
10
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
-
|
|
12
|
-
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; }
|
|
13
|
-
|
|
14
|
-
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); }; }
|
|
15
|
-
|
|
16
|
-
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; } }
|
|
17
|
-
|
|
18
|
-
import React, { PureComponent } from 'react';
|
|
19
|
-
import { findDOMNode } from 'react-dom';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
20
2
|
import { ResourcedMention } from '@atlaskit/mention';
|
|
21
|
-
import
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
_defineProperty(_assertThisInitialized(_this), "handleMentionNodeRef", function (component) {
|
|
56
|
-
if (!component) {
|
|
57
|
-
_this.domNode = null;
|
|
58
|
-
} else {
|
|
59
|
-
_this.domNode = findDOMNode(component);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
_defineProperty(_assertThisInitialized(_this), "showProfilecard", function (event) {
|
|
64
|
-
if (!_this.domNode) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
event.stopPropagation();
|
|
69
|
-
|
|
70
|
-
var _this$calculateLayerP = _this.calculateLayerPosition(),
|
|
71
|
-
_this$calculateLayerP2 = _slicedToArray(_this$calculateLayerP, 2),
|
|
72
|
-
popupAlignX = _this$calculateLayerP2[0],
|
|
73
|
-
popupAlignY = _this$calculateLayerP2[1];
|
|
74
|
-
|
|
75
|
-
_this.setState({
|
|
76
|
-
popupAlignX: popupAlignX,
|
|
77
|
-
popupAlignY: popupAlignY,
|
|
78
|
-
visible: true
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
_defineProperty(_assertThisInitialized(_this), "hideProfilecard", function () {
|
|
83
|
-
_this.setState({
|
|
84
|
-
visible: false
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
return _this;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
_createClass(MentionWithProfileCard, [{
|
|
92
|
-
key: "calculateLayerPosition",
|
|
93
|
-
value: function calculateLayerPosition() {
|
|
94
|
-
var domNodeCentreCoords = this.getDomNodeCenterCoords();
|
|
95
|
-
var visibleAreaCentreCoords = this.getVisibleAreaCentreCoords();
|
|
96
|
-
var popupAlignY = domNodeCentreCoords.y > visibleAreaCentreCoords.y ? 'top' : 'bottom';
|
|
97
|
-
var popupAlignX = domNodeCentreCoords.x > visibleAreaCentreCoords.x ? 'right' : 'left';
|
|
98
|
-
return [popupAlignX, popupAlignY];
|
|
99
|
-
}
|
|
100
|
-
}, {
|
|
101
|
-
key: "getDomNodeCenterCoords",
|
|
102
|
-
value: function getDomNodeCenterCoords() {
|
|
103
|
-
var rect = this.domNode.getBoundingClientRect();
|
|
104
|
-
return {
|
|
105
|
-
x: rect.left + rect.width / 2,
|
|
106
|
-
y: rect.top + rect.height / 2
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
}, {
|
|
110
|
-
key: "getVisibleAreaCentreCoords",
|
|
111
|
-
value: function getVisibleAreaCentreCoords() {
|
|
112
|
-
return {
|
|
113
|
-
x: window.innerWidth / 2,
|
|
114
|
-
y: window.innerHeight / 2
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}, {
|
|
118
|
-
key: "getActions",
|
|
119
|
-
value: function getActions(id, text, accessLevel) {
|
|
120
|
-
var _this2 = this;
|
|
121
|
-
|
|
122
|
-
var profilecardProvider = this.props.profilecardProvider;
|
|
123
|
-
var actions = profilecardProvider.getActions(id, text, accessLevel);
|
|
124
|
-
return actions.map(function (action) {
|
|
125
|
-
return _objectSpread(_objectSpread({}, action), {}, {
|
|
126
|
-
callback: function callback() {
|
|
127
|
-
_this2.setState({
|
|
128
|
-
visible: false
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
if (action && action.callback) {
|
|
132
|
-
action.callback();
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}, {
|
|
139
|
-
key: "render",
|
|
140
|
-
value: function render() {
|
|
141
|
-
var _this$props = this.props,
|
|
142
|
-
accessLevel = _this$props.accessLevel,
|
|
143
|
-
id = _this$props.id,
|
|
144
|
-
mentionProvider = _this$props.mentionProvider,
|
|
145
|
-
profilecardProvider = _this$props.profilecardProvider,
|
|
146
|
-
text = _this$props.text,
|
|
147
|
-
onClick = _this$props.onClick,
|
|
148
|
-
onMouseEnter = _this$props.onMouseEnter,
|
|
149
|
-
onMouseLeave = _this$props.onMouseLeave,
|
|
150
|
-
portal = _this$props.portal;
|
|
151
|
-
var _this$state = this.state,
|
|
152
|
-
popupAlignX = _this$state.popupAlignX,
|
|
153
|
-
popupAlignY = _this$state.popupAlignY,
|
|
154
|
-
target = _this$state.target,
|
|
155
|
-
visible = _this$state.visible;
|
|
156
|
-
var cloudId = profilecardProvider.cloudId,
|
|
157
|
-
resourceClient = profilecardProvider.resourceClient;
|
|
158
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
159
|
-
ref: this.handleRef,
|
|
160
|
-
onClick: this.showProfilecard
|
|
161
|
-
}, /*#__PURE__*/React.createElement(ResourcedMention, {
|
|
162
|
-
ref: this.handleMentionNodeRef,
|
|
163
|
-
id: id,
|
|
164
|
-
text: text,
|
|
165
|
-
accessLevel: accessLevel,
|
|
166
|
-
mentionProvider: mentionProvider,
|
|
167
|
-
onClick: onClick,
|
|
168
|
-
onMouseEnter: onMouseEnter,
|
|
169
|
-
onMouseLeave: onMouseLeave
|
|
170
|
-
}), target && portal && visible && /*#__PURE__*/React.createElement(Popup, {
|
|
171
|
-
offset: [0, 8],
|
|
172
|
-
target: target,
|
|
173
|
-
mountTo: portal,
|
|
174
|
-
alignX: popupAlignX,
|
|
175
|
-
alignY: popupAlignY
|
|
176
|
-
}, /*#__PURE__*/React.createElement(ProfilecardResourcedWithListeners, {
|
|
177
|
-
handleClickOutside: this.hideProfilecard,
|
|
178
|
-
handleEscapeKeydown: this.hideProfilecard,
|
|
179
|
-
cloudId: cloudId,
|
|
180
|
-
userId: id,
|
|
181
|
-
resourceClient: resourceClient,
|
|
182
|
-
actions: this.getActions(id, text, accessLevel)
|
|
183
|
-
})));
|
|
184
|
-
}
|
|
185
|
-
}]);
|
|
186
|
-
|
|
187
|
-
return MentionWithProfileCard;
|
|
188
|
-
}(PureComponent);
|
|
189
|
-
|
|
190
|
-
export { MentionWithProfileCard as default };
|
|
3
|
+
import { ProfileCardTrigger } from '@atlaskit/profilecard';
|
|
4
|
+
export default function MentionWithProfileCard(_ref) {
|
|
5
|
+
var id = _ref.id,
|
|
6
|
+
text = _ref.text,
|
|
7
|
+
accessLevel = _ref.accessLevel,
|
|
8
|
+
mentionProvider = _ref.mentionProvider,
|
|
9
|
+
profilecardProvider = _ref.profilecardProvider,
|
|
10
|
+
onClick = _ref.onClick,
|
|
11
|
+
onMouseEnter = _ref.onMouseEnter,
|
|
12
|
+
onMouseLeave = _ref.onMouseLeave;
|
|
13
|
+
var cloudId = profilecardProvider.cloudId,
|
|
14
|
+
resourceClient = profilecardProvider.resourceClient;
|
|
15
|
+
var actions = useMemo(function () {
|
|
16
|
+
return profilecardProvider.getActions(id, text, accessLevel);
|
|
17
|
+
}, [accessLevel, id, profilecardProvider, text]);
|
|
18
|
+
return /*#__PURE__*/React.createElement(ProfileCardTrigger, {
|
|
19
|
+
cloudId: cloudId,
|
|
20
|
+
userId: id,
|
|
21
|
+
resourceClient: resourceClient,
|
|
22
|
+
actions: actions,
|
|
23
|
+
trigger: "click",
|
|
24
|
+
position: "bottom-end"
|
|
25
|
+
}, /*#__PURE__*/React.createElement(ResourcedMention, {
|
|
26
|
+
id: id,
|
|
27
|
+
text: text,
|
|
28
|
+
accessLevel: accessLevel,
|
|
29
|
+
mentionProvider: mentionProvider,
|
|
30
|
+
onClick: onClick,
|
|
31
|
+
onMouseEnter: onMouseEnter,
|
|
32
|
+
onMouseLeave: onMouseLeave
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
@@ -83,11 +83,9 @@ var MentionWithProviders = /*#__PURE__*/function (_PureComponent) {
|
|
|
83
83
|
value: function render() {
|
|
84
84
|
var _this$props = this.props,
|
|
85
85
|
accessLevel = _this$props.accessLevel,
|
|
86
|
-
userType = _this$props.userType,
|
|
87
86
|
eventHandlers = _this$props.eventHandlers,
|
|
88
87
|
id = _this$props.id,
|
|
89
88
|
mentionProvider = _this$props.mentionProvider,
|
|
90
|
-
portal = _this$props.portal,
|
|
91
89
|
text = _this$props.text;
|
|
92
90
|
var profilecardProvider = this.state.profilecardProvider;
|
|
93
91
|
var actionHandlers = {};
|
|
@@ -99,10 +97,8 @@ var MentionWithProviders = /*#__PURE__*/function (_PureComponent) {
|
|
|
99
97
|
id: id,
|
|
100
98
|
text: text,
|
|
101
99
|
accessLevel: accessLevel,
|
|
102
|
-
userType: userType,
|
|
103
100
|
mentionProvider: mentionProvider,
|
|
104
|
-
profilecardProvider: profilecardProvider
|
|
105
|
-
portal: portal
|
|
101
|
+
profilecardProvider: profilecardProvider
|
|
106
102
|
}, actionHandlers));
|
|
107
103
|
}
|
|
108
104
|
}]);
|
package/dist/esm/version.json
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { EditorState, Transaction } from 'prosemirror-state';
|
|
2
2
|
import { Step } from 'prosemirror-transform';
|
|
3
|
+
import { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
4
|
+
import { SyncUpErrorFunction } from '../types';
|
|
3
5
|
export interface CollabParticipant {
|
|
4
6
|
lastActive: number;
|
|
5
7
|
sessionId: string;
|
|
@@ -23,7 +25,7 @@ export interface CollabEventRemoteData {
|
|
|
23
25
|
export interface CollabEventConnectionData {
|
|
24
26
|
sid: string;
|
|
25
27
|
}
|
|
26
|
-
export interface
|
|
28
|
+
export interface CollabEventDisconnectedData {
|
|
27
29
|
sid: string;
|
|
28
30
|
reason: 'CLIENT_DISCONNECT' | 'SERVER_DISCONNECT' | 'SOCKET_CLOSED' | 'SOCKET_ERROR' | 'SOCKET_TIMEOUT' | 'UNKNOWN_DISCONNECT';
|
|
29
31
|
}
|
|
@@ -50,7 +52,7 @@ export declare type CollabEvent = keyof CollabEventData;
|
|
|
50
52
|
export interface CollabEventData {
|
|
51
53
|
init: CollabEventInitData;
|
|
52
54
|
connected: CollabEventConnectionData;
|
|
53
|
-
disconnected:
|
|
55
|
+
disconnected: CollabEventDisconnectedData;
|
|
54
56
|
data: CollabEventRemoteData;
|
|
55
57
|
telepointer: CollabEventTelepointerData;
|
|
56
58
|
presence: CollabEventPresenceData;
|
|
@@ -58,8 +60,17 @@ export interface CollabEventData {
|
|
|
58
60
|
'local-steps': any;
|
|
59
61
|
entity: any;
|
|
60
62
|
}
|
|
63
|
+
export declare type ResolvedEditorState = {
|
|
64
|
+
content: JSONDocNode;
|
|
65
|
+
title: string | null;
|
|
66
|
+
stepVersion: number;
|
|
67
|
+
};
|
|
61
68
|
export interface CollabEditProvider<Events extends CollabEventData = CollabEventData> {
|
|
62
69
|
initialize(getState: () => any, createStep: (json: object) => Step): this;
|
|
70
|
+
setup(props: {
|
|
71
|
+
getState: () => EditorState;
|
|
72
|
+
onSyncUpError?: SyncUpErrorFunction;
|
|
73
|
+
}): this;
|
|
63
74
|
send(tr: Transaction, oldState: EditorState, newState: EditorState): void;
|
|
64
75
|
on(evt: keyof Events, handler: (...args: any) => void): this;
|
|
65
76
|
off(evt: keyof Events, handler: (...args: any) => void): this;
|
|
@@ -67,4 +78,5 @@ export interface CollabEditProvider<Events extends CollabEventData = CollabEvent
|
|
|
67
78
|
sendMessage<K extends keyof Events>(data: {
|
|
68
79
|
type: K;
|
|
69
80
|
} & Events[K]): void;
|
|
81
|
+
getFinalAcknowledgedState(): Promise<ResolvedEditorState>;
|
|
70
82
|
}
|
package/dist/types/collab.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { CollabEditProvider, CollabEventPresenceData, CollabEvent, CollabEventConnectionData, CollabEventData, CollabEventInitData, CollabEventRemoteData, CollabEventTelepointerData, CollabParticipant, CollabSendableSelection, CollabEventLocalStepData, } from './collab/types';
|
|
1
|
+
export type { CollabEditProvider, CollabEventPresenceData, CollabEvent, CollabEventConnectionData, CollabEventData, CollabEventInitData, CollabEventRemoteData, CollabEventTelepointerData, CollabParticipant, CollabSendableSelection, CollabEventLocalStepData, ResolvedEditorState, } from './collab/types';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -12,3 +12,4 @@ export type { EventHandlers, // temporarily keep for confluence
|
|
|
12
12
|
LinkEventClickHandler, // temporarily keep for confluence
|
|
13
13
|
MentionEventHandler, // temporarily keep for confluence
|
|
14
14
|
SmartCardEventClickHandler, } from './ui';
|
|
15
|
+
export type { SafePlugin } from './safe-plugin';
|
|
@@ -9,7 +9,6 @@ export { getPanelTypeBackground, darkPanelColors, getPanelDarkColor, panelShared
|
|
|
9
9
|
export { ruleSharedStyles } from './shared/rule';
|
|
10
10
|
export { whitespaceSharedStyles } from './shared/whitespace';
|
|
11
11
|
export { paragraphSharedStyles } from './shared/paragraph';
|
|
12
|
-
export { inlineNodeSharedStyle } from './shared/inline-nodes';
|
|
13
12
|
export { linkSharedStyle } from './shared/link';
|
|
14
13
|
export { listsSharedStyles } from './shared/lists';
|
|
15
14
|
export { indentationSharedStyles } from './shared/indentation';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare type NewCollabSyncUpErrorAttributes = {
|
|
2
|
+
lengthOfUnconfirmedSteps?: number;
|
|
3
|
+
tries: number;
|
|
4
|
+
maxRetries: number;
|
|
5
|
+
clientId?: string;
|
|
6
|
+
version: number;
|
|
7
|
+
};
|
|
8
|
+
export declare type SyncUpErrorFunction = (attributes: NewCollabSyncUpErrorAttributes) => void;
|