@atlaskit/editor-plugin-card 0.1.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/.eslintrc.js +15 -0
- package/CHANGELOG.md +1 -0
- package/LICENSE.md +13 -0
- package/README.md +7 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/messages.js +20 -0
- package/dist/cjs/nodeviews/blockCard.js +164 -0
- package/dist/cjs/nodeviews/datasource.js +173 -0
- package/dist/cjs/nodeviews/embedCard.js +398 -0
- package/dist/cjs/nodeviews/genericCard.js +118 -0
- package/dist/cjs/nodeviews/inlineCard.js +132 -0
- package/dist/cjs/plugin.js +138 -0
- package/dist/cjs/pm-plugins/actions.js +122 -0
- package/dist/cjs/pm-plugins/analytics/create-analytics-queue.js +48 -0
- package/dist/cjs/pm-plugins/analytics/events-from-tr.js +359 -0
- package/dist/cjs/pm-plugins/analytics/index.js +19 -0
- package/dist/cjs/pm-plugins/analytics/types.js +5 -0
- package/dist/cjs/pm-plugins/analytics/utils.js +178 -0
- package/dist/cjs/pm-plugins/doc.js +479 -0
- package/dist/cjs/pm-plugins/keymap.js +64 -0
- package/dist/cjs/pm-plugins/main.js +212 -0
- package/dist/cjs/pm-plugins/mountHyperlink.js +47 -0
- package/dist/cjs/pm-plugins/plugin-key.js +9 -0
- package/dist/cjs/pm-plugins/reducers.js +111 -0
- package/dist/cjs/pm-plugins/shouldReplaceLink.js +35 -0
- package/dist/cjs/pm-plugins/util/resolve.js +59 -0
- package/dist/cjs/pm-plugins/util/state.js +49 -0
- package/dist/cjs/toolbar.js +364 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/ui/DatasourceModal/ModalWithState.js +25 -0
- package/dist/cjs/ui/DatasourceModal/index.js +60 -0
- package/dist/cjs/ui/EditLinkToolbar.js +258 -0
- package/dist/cjs/ui/EditorSmartCardEvents.js +21 -0
- package/dist/cjs/ui/EditorSmartCardEventsNext.js +215 -0
- package/dist/cjs/ui/HyperlinkToolbarAppearance.js +174 -0
- package/dist/cjs/ui/LayoutButton/index.js +121 -0
- package/dist/cjs/ui/LayoutButton/types.js +5 -0
- package/dist/cjs/ui/LayoutButton/utils.js +19 -0
- package/dist/cjs/ui/LinkToolbarAppearance.js +152 -0
- package/dist/cjs/ui/ResizableEmbedCard.js +364 -0
- package/dist/cjs/ui/SmallerEditIcon.js +22 -0
- package/dist/cjs/utils.js +60 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/messages.js +13 -0
- package/dist/es2019/nodeviews/blockCard.js +131 -0
- package/dist/es2019/nodeviews/datasource.js +137 -0
- package/dist/es2019/nodeviews/embedCard.js +370 -0
- package/dist/es2019/nodeviews/genericCard.js +92 -0
- package/dist/es2019/nodeviews/inlineCard.js +113 -0
- package/dist/es2019/plugin.js +129 -0
- package/dist/es2019/pm-plugins/actions.js +57 -0
- package/dist/es2019/pm-plugins/analytics/create-analytics-queue.js +38 -0
- package/dist/es2019/pm-plugins/analytics/events-from-tr.js +339 -0
- package/dist/es2019/pm-plugins/analytics/index.js +2 -0
- package/dist/es2019/pm-plugins/analytics/types.js +1 -0
- package/dist/es2019/pm-plugins/analytics/utils.js +160 -0
- package/dist/es2019/pm-plugins/doc.js +451 -0
- package/dist/es2019/pm-plugins/keymap.js +59 -0
- package/dist/es2019/pm-plugins/main.js +208 -0
- package/dist/es2019/pm-plugins/mountHyperlink.js +37 -0
- package/dist/es2019/pm-plugins/plugin-key.js +2 -0
- package/dist/es2019/pm-plugins/reducers.js +110 -0
- package/dist/es2019/pm-plugins/shouldReplaceLink.js +25 -0
- package/dist/es2019/pm-plugins/util/resolve.js +50 -0
- package/dist/es2019/pm-plugins/util/state.js +26 -0
- package/dist/es2019/toolbar.js +359 -0
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/ui/DatasourceModal/ModalWithState.js +19 -0
- package/dist/es2019/ui/DatasourceModal/index.js +48 -0
- package/dist/es2019/ui/EditLinkToolbar.js +226 -0
- package/dist/es2019/ui/EditorSmartCardEvents.js +15 -0
- package/dist/es2019/ui/EditorSmartCardEventsNext.js +199 -0
- package/dist/es2019/ui/HyperlinkToolbarAppearance.js +86 -0
- package/dist/es2019/ui/LayoutButton/index.js +114 -0
- package/dist/es2019/ui/LayoutButton/types.js +1 -0
- package/dist/es2019/ui/LayoutButton/utils.js +15 -0
- package/dist/es2019/ui/LinkToolbarAppearance.js +118 -0
- package/dist/es2019/ui/ResizableEmbedCard.js +335 -0
- package/dist/es2019/ui/SmallerEditIcon.js +14 -0
- package/dist/es2019/utils.js +46 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/messages.js +13 -0
- package/dist/esm/nodeviews/blockCard.js +156 -0
- package/dist/esm/nodeviews/datasource.js +165 -0
- package/dist/esm/nodeviews/embedCard.js +389 -0
- package/dist/esm/nodeviews/genericCard.js +111 -0
- package/dist/esm/nodeviews/inlineCard.js +124 -0
- package/dist/esm/plugin.js +130 -0
- package/dist/esm/pm-plugins/actions.js +102 -0
- package/dist/esm/pm-plugins/analytics/create-analytics-queue.js +41 -0
- package/dist/esm/pm-plugins/analytics/events-from-tr.js +350 -0
- package/dist/esm/pm-plugins/analytics/index.js +2 -0
- package/dist/esm/pm-plugins/analytics/types.js +1 -0
- package/dist/esm/pm-plugins/analytics/utils.js +160 -0
- package/dist/esm/pm-plugins/doc.js +460 -0
- package/dist/esm/pm-plugins/keymap.js +58 -0
- package/dist/esm/pm-plugins/main.js +199 -0
- package/dist/esm/pm-plugins/mountHyperlink.js +39 -0
- package/dist/esm/pm-plugins/plugin-key.js +2 -0
- package/dist/esm/pm-plugins/reducers.js +103 -0
- package/dist/esm/pm-plugins/shouldReplaceLink.js +29 -0
- package/dist/esm/pm-plugins/util/resolve.js +52 -0
- package/dist/esm/pm-plugins/util/state.js +40 -0
- package/dist/esm/toolbar.js +350 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/ui/DatasourceModal/ModalWithState.js +17 -0
- package/dist/esm/ui/DatasourceModal/index.js +49 -0
- package/dist/esm/ui/EditLinkToolbar.js +244 -0
- package/dist/esm/ui/EditorSmartCardEvents.js +14 -0
- package/dist/esm/ui/EditorSmartCardEventsNext.js +203 -0
- package/dist/esm/ui/HyperlinkToolbarAppearance.js +163 -0
- package/dist/esm/ui/LayoutButton/index.js +110 -0
- package/dist/esm/ui/LayoutButton/types.js +1 -0
- package/dist/esm/ui/LayoutButton/utils.js +12 -0
- package/dist/esm/ui/LinkToolbarAppearance.js +141 -0
- package/dist/esm/ui/ResizableEmbedCard.js +358 -0
- package/dist/esm/ui/SmallerEditIcon.js +14 -0
- package/dist/esm/utils.js +48 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/messages.d.ts +12 -0
- package/dist/types/nodeviews/blockCard.d.ts +26 -0
- package/dist/types/nodeviews/datasource.d.ts +42 -0
- package/dist/types/nodeviews/embedCard.d.ts +46 -0
- package/dist/types/nodeviews/genericCard.d.ts +37 -0
- package/dist/types/nodeviews/inlineCard.d.ts +23 -0
- package/dist/types/plugin.d.ts +24 -0
- package/dist/types/pm-plugins/actions.d.ts +23 -0
- package/dist/types/pm-plugins/analytics/create-analytics-queue.d.ts +10 -0
- package/dist/types/pm-plugins/analytics/events-from-tr.d.ts +17 -0
- package/dist/types/pm-plugins/analytics/index.d.ts +2 -0
- package/dist/types/pm-plugins/analytics/types.d.ts +12 -0
- package/dist/types/pm-plugins/analytics/utils.d.ts +32 -0
- package/dist/types/pm-plugins/doc.d.ts +22 -0
- package/dist/types/pm-plugins/keymap.d.ts +3 -0
- package/dist/types/pm-plugins/main.d.ts +6 -0
- package/dist/types/pm-plugins/mountHyperlink.d.ts +5 -0
- package/dist/types/pm-plugins/plugin-key.d.ts +3 -0
- package/dist/types/pm-plugins/reducers.d.ts +3 -0
- package/dist/types/pm-plugins/shouldReplaceLink.d.ts +2 -0
- package/dist/types/pm-plugins/util/resolve.d.ts +8 -0
- package/dist/types/pm-plugins/util/state.d.ts +31 -0
- package/dist/types/toolbar.d.ts +9 -0
- package/dist/types/types.d.ts +163 -0
- package/dist/types/ui/DatasourceModal/ModalWithState.d.ts +9 -0
- package/dist/types/ui/DatasourceModal/index.d.ts +11 -0
- package/dist/types/ui/EditLinkToolbar.d.ts +47 -0
- package/dist/types/ui/EditorSmartCardEvents.d.ts +5 -0
- package/dist/types/ui/EditorSmartCardEventsNext.d.ts +18 -0
- package/dist/types/ui/HyperlinkToolbarAppearance.d.ts +32 -0
- package/dist/types/ui/LayoutButton/index.d.ts +9 -0
- package/dist/types/ui/LayoutButton/types.d.ts +19 -0
- package/dist/types/ui/LayoutButton/utils.d.ts +5 -0
- package/dist/types/ui/LinkToolbarAppearance.d.ts +29 -0
- package/dist/types/ui/ResizableEmbedCard.d.ts +61 -0
- package/dist/types/ui/SmallerEditIcon.d.ts +3 -0
- package/dist/types/utils.d.ts +19 -0
- package/dist/types-ts4.5/index.d.ts +2 -0
- package/dist/types-ts4.5/messages.d.ts +12 -0
- package/dist/types-ts4.5/nodeviews/blockCard.d.ts +26 -0
- package/dist/types-ts4.5/nodeviews/datasource.d.ts +42 -0
- package/dist/types-ts4.5/nodeviews/embedCard.d.ts +46 -0
- package/dist/types-ts4.5/nodeviews/genericCard.d.ts +37 -0
- package/dist/types-ts4.5/nodeviews/inlineCard.d.ts +23 -0
- package/dist/types-ts4.5/plugin.d.ts +24 -0
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +23 -0
- package/dist/types-ts4.5/pm-plugins/analytics/create-analytics-queue.d.ts +10 -0
- package/dist/types-ts4.5/pm-plugins/analytics/events-from-tr.d.ts +17 -0
- package/dist/types-ts4.5/pm-plugins/analytics/index.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/analytics/types.d.ts +12 -0
- package/dist/types-ts4.5/pm-plugins/analytics/utils.d.ts +32 -0
- package/dist/types-ts4.5/pm-plugins/doc.d.ts +22 -0
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugins/mountHyperlink.d.ts +5 -0
- package/dist/types-ts4.5/pm-plugins/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/reducers.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/shouldReplaceLink.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/util/resolve.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/util/state.d.ts +31 -0
- package/dist/types-ts4.5/toolbar.d.ts +9 -0
- package/dist/types-ts4.5/types.d.ts +163 -0
- package/dist/types-ts4.5/ui/DatasourceModal/ModalWithState.d.ts +9 -0
- package/dist/types-ts4.5/ui/DatasourceModal/index.d.ts +11 -0
- package/dist/types-ts4.5/ui/EditLinkToolbar.d.ts +47 -0
- package/dist/types-ts4.5/ui/EditorSmartCardEvents.d.ts +5 -0
- package/dist/types-ts4.5/ui/EditorSmartCardEventsNext.d.ts +18 -0
- package/dist/types-ts4.5/ui/HyperlinkToolbarAppearance.d.ts +32 -0
- package/dist/types-ts4.5/ui/LayoutButton/index.d.ts +9 -0
- package/dist/types-ts4.5/ui/LayoutButton/types.d.ts +19 -0
- package/dist/types-ts4.5/ui/LayoutButton/utils.d.ts +5 -0
- package/dist/types-ts4.5/ui/LinkToolbarAppearance.d.ts +29 -0
- package/dist/types-ts4.5/ui/ResizableEmbedCard.d.ts +61 -0
- package/dist/types-ts4.5/ui/SmallerEditIcon.d.ts +3 -0
- package/dist/types-ts4.5/utils.d.ts +19 -0
- package/package.json +126 -0
- package/report.api.md +146 -0
- package/tmp/api-report-tmp.d.ts +117 -0
|
@@ -0,0 +1,124 @@
|
|
|
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 React from 'react';
|
|
11
|
+
import PropTypes from 'prop-types';
|
|
12
|
+
import rafSchedule from 'raf-schd';
|
|
13
|
+
import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
14
|
+
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
15
|
+
import { registerCard } from '../pm-plugins/actions';
|
|
16
|
+
import { Card } from './genericCard';
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
19
|
+
export var InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
20
|
+
_inherits(InlineCardComponent, _React$PureComponent);
|
|
21
|
+
var _super = _createSuper(InlineCardComponent);
|
|
22
|
+
function InlineCardComponent() {
|
|
23
|
+
var _this;
|
|
24
|
+
_classCallCheck(this, InlineCardComponent);
|
|
25
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
26
|
+
args[_key] = arguments[_key];
|
|
27
|
+
}
|
|
28
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
29
|
+
_defineProperty(_assertThisInitialized(_this), "onClick", function () {});
|
|
30
|
+
_defineProperty(_assertThisInitialized(_this), "onResolve", function (data) {
|
|
31
|
+
var _this$props = _this.props,
|
|
32
|
+
getPos = _this$props.getPos,
|
|
33
|
+
view = _this$props.view;
|
|
34
|
+
if (!getPos || typeof getPos === 'boolean') {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
var title = data.title,
|
|
38
|
+
url = data.url;
|
|
39
|
+
// don't dispatch immediately since we might be in the middle of
|
|
40
|
+
// rendering a nodeview
|
|
41
|
+
rafSchedule(function () {
|
|
42
|
+
// prosemirror-bump-fix
|
|
43
|
+
var pos = getPos();
|
|
44
|
+
if (typeof pos !== 'number') {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
view.dispatch(registerCard({
|
|
48
|
+
title: title,
|
|
49
|
+
url: url,
|
|
50
|
+
pos: pos
|
|
51
|
+
})(view.state.tr));
|
|
52
|
+
})();
|
|
53
|
+
});
|
|
54
|
+
_defineProperty(_assertThisInitialized(_this), "onError", function (data) {
|
|
55
|
+
var url = data.url,
|
|
56
|
+
err = data.err;
|
|
57
|
+
if (err) {
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
_this.onResolve({
|
|
61
|
+
url: url
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
return _this;
|
|
65
|
+
}
|
|
66
|
+
_createClass(InlineCardComponent, [{
|
|
67
|
+
key: "UNSAFE_componentWillMount",
|
|
68
|
+
value: function UNSAFE_componentWillMount() {
|
|
69
|
+
var view = this.props.view;
|
|
70
|
+
var scrollContainer = findOverflowScrollParent(view.dom);
|
|
71
|
+
this.scrollContainer = scrollContainer || undefined;
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "render",
|
|
75
|
+
value: function render() {
|
|
76
|
+
var _this$props2 = this.props,
|
|
77
|
+
node = _this$props2.node,
|
|
78
|
+
cardContext = _this$props2.cardContext,
|
|
79
|
+
showServerActions = _this$props2.showServerActions,
|
|
80
|
+
useAlternativePreloader = _this$props2.useAlternativePreloader;
|
|
81
|
+
var _node$attrs = node.attrs,
|
|
82
|
+
url = _node$attrs.url,
|
|
83
|
+
data = _node$attrs.data;
|
|
84
|
+
var card = /*#__PURE__*/React.createElement("span", {
|
|
85
|
+
className: "card"
|
|
86
|
+
}, /*#__PURE__*/React.createElement(SmartCard, {
|
|
87
|
+
key: url,
|
|
88
|
+
url: url,
|
|
89
|
+
data: data,
|
|
90
|
+
appearance: "inline",
|
|
91
|
+
onClick: this.onClick,
|
|
92
|
+
container: this.scrollContainer,
|
|
93
|
+
onResolve: this.onResolve,
|
|
94
|
+
onError: this.onError,
|
|
95
|
+
inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
|
|
96
|
+
showServerActions: showServerActions
|
|
97
|
+
}));
|
|
98
|
+
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
99
|
+
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
100
|
+
return cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
101
|
+
value: cardContext.value
|
|
102
|
+
}, card) : data ? card : null;
|
|
103
|
+
}
|
|
104
|
+
}]);
|
|
105
|
+
return InlineCardComponent;
|
|
106
|
+
}(React.PureComponent);
|
|
107
|
+
_defineProperty(InlineCardComponent, "contextTypes", {
|
|
108
|
+
contextAdapter: PropTypes.object
|
|
109
|
+
});
|
|
110
|
+
var WrappedInlineCard = Card(InlineCardComponent, UnsupportedInline);
|
|
111
|
+
export function InlineCardNodeView(props) {
|
|
112
|
+
var useAlternativePreloader = props.useAlternativePreloader,
|
|
113
|
+
node = props.node,
|
|
114
|
+
view = props.view,
|
|
115
|
+
getPos = props.getPos,
|
|
116
|
+
showServerActions = props.showServerActions;
|
|
117
|
+
return /*#__PURE__*/React.createElement(WrappedInlineCard, {
|
|
118
|
+
node: node,
|
|
119
|
+
view: view,
|
|
120
|
+
getPos: getPos,
|
|
121
|
+
showServerActions: showServerActions,
|
|
122
|
+
useAlternativePreloader: useAlternativePreloader
|
|
123
|
+
});
|
|
124
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { blockCard, embedCard, inlineCard } from '@atlaskit/adf-schema';
|
|
6
|
+
import { IconDatasourceJiraIssue } from '@atlaskit/editor-common/quick-insert';
|
|
7
|
+
import { canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
8
|
+
import { JIRA_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource';
|
|
9
|
+
import { messages } from './messages';
|
|
10
|
+
import { hideLinkToolbar, showDatasourceModal } from './pm-plugins/actions';
|
|
11
|
+
import { changeSelectedCardToLink, queueCardsFromChangedTr, setSelectedCardAppearance } from './pm-plugins/doc';
|
|
12
|
+
import { cardKeymap } from './pm-plugins/keymap';
|
|
13
|
+
import { createPlugin } from './pm-plugins/main';
|
|
14
|
+
import { mountHyperlinkPlugin } from './pm-plugins/mountHyperlink';
|
|
15
|
+
import { pluginKey } from './pm-plugins/plugin-key';
|
|
16
|
+
import { floatingToolbar } from './toolbar';
|
|
17
|
+
import DatasourceModalWithState from './ui/DatasourceModal/ModalWithState';
|
|
18
|
+
import { EditorSmartCardEvents } from './ui/EditorSmartCardEvents';
|
|
19
|
+
import { EditorSmartCardEventsNext } from './ui/EditorSmartCardEventsNext';
|
|
20
|
+
import LayoutButton from './ui/LayoutButton';
|
|
21
|
+
export var cardPlugin = function cardPlugin(options, api) {
|
|
22
|
+
var _api$dependencies, _api$dependencies$fea;
|
|
23
|
+
var featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
|
|
24
|
+
return {
|
|
25
|
+
name: 'card',
|
|
26
|
+
getSharedState: function getSharedState(editorState) {
|
|
27
|
+
if (!editorState) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return pluginKey.getState(editorState) || null;
|
|
31
|
+
},
|
|
32
|
+
nodes: function nodes() {
|
|
33
|
+
var nodes = [{
|
|
34
|
+
name: 'inlineCard',
|
|
35
|
+
node: inlineCard
|
|
36
|
+
}, {
|
|
37
|
+
name: 'blockCard',
|
|
38
|
+
node: blockCard
|
|
39
|
+
}];
|
|
40
|
+
if (options.allowEmbeds) {
|
|
41
|
+
nodes.push({
|
|
42
|
+
name: 'embedCard',
|
|
43
|
+
node: embedCard
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return nodes;
|
|
47
|
+
},
|
|
48
|
+
pmPlugins: function pmPlugins() {
|
|
49
|
+
var _options$allowBlockCa, _options$allowResizin, _options$useAlternati, _options$allowWrappin, _options$allowAlignme;
|
|
50
|
+
var allowBlockCards = (_options$allowBlockCa = options.allowBlockCards) !== null && _options$allowBlockCa !== void 0 ? _options$allowBlockCa : true;
|
|
51
|
+
var allowResizing = (_options$allowResizin = options.allowResizing) !== null && _options$allowResizin !== void 0 ? _options$allowResizin : true;
|
|
52
|
+
var useAlternativePreloader = (_options$useAlternati = options.useAlternativePreloader) !== null && _options$useAlternati !== void 0 ? _options$useAlternati : true;
|
|
53
|
+
var allowWrapping = (_options$allowWrappin = options.allowWrapping) !== null && _options$allowWrappin !== void 0 ? _options$allowWrappin : true;
|
|
54
|
+
var allowAlignment = (_options$allowAlignme = options.allowAlignment) !== null && _options$allowAlignme !== void 0 ? _options$allowAlignme : true;
|
|
55
|
+
var plugins = [{
|
|
56
|
+
name: 'card',
|
|
57
|
+
plugin: createPlugin(_objectSpread(_objectSpread({}, options), {}, {
|
|
58
|
+
allowBlockCards: allowBlockCards,
|
|
59
|
+
allowResizing: allowResizing,
|
|
60
|
+
useAlternativePreloader: useAlternativePreloader,
|
|
61
|
+
allowWrapping: allowWrapping,
|
|
62
|
+
allowAlignment: allowAlignment
|
|
63
|
+
}), api)
|
|
64
|
+
}, {
|
|
65
|
+
name: 'cardHyperlink',
|
|
66
|
+
plugin: function plugin() {
|
|
67
|
+
return mountHyperlinkPlugin(api, options);
|
|
68
|
+
}
|
|
69
|
+
}];
|
|
70
|
+
plugins.push({
|
|
71
|
+
name: 'cardKeymap',
|
|
72
|
+
plugin: function plugin(_ref) {
|
|
73
|
+
var featureFlags = _ref.featureFlags;
|
|
74
|
+
return cardKeymap(featureFlags);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return plugins;
|
|
78
|
+
},
|
|
79
|
+
contentComponent: function contentComponent(_ref2) {
|
|
80
|
+
var editorView = _ref2.editorView,
|
|
81
|
+
popupsMountPoint = _ref2.popupsMountPoint,
|
|
82
|
+
popupsScrollableElement = _ref2.popupsScrollableElement,
|
|
83
|
+
popupsBoundariesElement = _ref2.popupsBoundariesElement;
|
|
84
|
+
var lpAnalyticsEventsNext = featureFlags.lpAnalyticsEventsNext;
|
|
85
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorSmartCardEvents, {
|
|
86
|
+
editorView: editorView
|
|
87
|
+
}), lpAnalyticsEventsNext && /*#__PURE__*/React.createElement(EditorSmartCardEventsNext, {
|
|
88
|
+
editorView: editorView
|
|
89
|
+
}), /*#__PURE__*/React.createElement(LayoutButton, {
|
|
90
|
+
api: api,
|
|
91
|
+
editorView: editorView,
|
|
92
|
+
mountPoint: popupsMountPoint,
|
|
93
|
+
scrollableElement: popupsScrollableElement,
|
|
94
|
+
boundariesElement: popupsBoundariesElement
|
|
95
|
+
}), /*#__PURE__*/React.createElement(DatasourceModalWithState, {
|
|
96
|
+
api: api,
|
|
97
|
+
editorView: editorView
|
|
98
|
+
}));
|
|
99
|
+
},
|
|
100
|
+
actions: {
|
|
101
|
+
hideLinkToolbar: hideLinkToolbar,
|
|
102
|
+
queueCardsFromChangedTr: queueCardsFromChangedTr,
|
|
103
|
+
changeSelectedCardToLink: changeSelectedCardToLink,
|
|
104
|
+
setSelectedCardAppearance: setSelectedCardAppearance
|
|
105
|
+
},
|
|
106
|
+
pluginsOptions: {
|
|
107
|
+
floatingToolbar: floatingToolbar(options, featureFlags, options.platform, options.linkPicker, api),
|
|
108
|
+
quickInsert: function quickInsert(_ref3) {
|
|
109
|
+
var formatMessage = _ref3.formatMessage;
|
|
110
|
+
if (canRenderDatasource(JIRA_LIST_OF_LINKS_DATASOURCE_ID)) {
|
|
111
|
+
return [{
|
|
112
|
+
id: 'datasource',
|
|
113
|
+
title: formatMessage(messages.datasourceJiraIssue),
|
|
114
|
+
description: formatMessage(messages.datasourceJiraIssueDescription),
|
|
115
|
+
keywords: ['jira'],
|
|
116
|
+
icon: function icon() {
|
|
117
|
+
return /*#__PURE__*/React.createElement(IconDatasourceJiraIssue, null);
|
|
118
|
+
},
|
|
119
|
+
action: function action(insert) {
|
|
120
|
+
var tr = insert(undefined);
|
|
121
|
+
showDatasourceModal('jira')(tr);
|
|
122
|
+
return tr;
|
|
123
|
+
}
|
|
124
|
+
}];
|
|
125
|
+
}
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { pluginKey } from './plugin-key';
|
|
2
|
+
export var cardAction = function cardAction(tr, action) {
|
|
3
|
+
return tr.setMeta(pluginKey, action);
|
|
4
|
+
};
|
|
5
|
+
export var resolveCard = function resolveCard(url) {
|
|
6
|
+
return function (tr) {
|
|
7
|
+
return cardAction(tr, {
|
|
8
|
+
type: 'RESOLVE',
|
|
9
|
+
url: url
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export var queueCards = function queueCards(requests) {
|
|
14
|
+
return function (tr) {
|
|
15
|
+
return cardAction(tr, {
|
|
16
|
+
type: 'QUEUE',
|
|
17
|
+
requests: requests
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export var registerCard = function registerCard(info) {
|
|
22
|
+
return function (tr) {
|
|
23
|
+
return cardAction(tr, {
|
|
24
|
+
type: 'REGISTER',
|
|
25
|
+
info: info
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export var registerSmartCardEvents = function registerSmartCardEvents(smartLinkEvents) {
|
|
30
|
+
return function (tr) {
|
|
31
|
+
return cardAction(tr, {
|
|
32
|
+
type: 'REGISTER_EVENTS',
|
|
33
|
+
smartLinkEvents: smartLinkEvents
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export var registerSmartCardEventsNext = function registerSmartCardEventsNext(smartLinkEvents) {
|
|
38
|
+
return function (tr) {
|
|
39
|
+
return cardAction(tr, {
|
|
40
|
+
type: 'REGISTER_EVENTS_NEXT',
|
|
41
|
+
smartLinkEvents: smartLinkEvents
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export var setProvider = function setProvider(cardProvider) {
|
|
46
|
+
return function (tr) {
|
|
47
|
+
return cardAction(tr, {
|
|
48
|
+
type: 'SET_PROVIDER',
|
|
49
|
+
provider: cardProvider
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export var setDatasourceTableRef = function setDatasourceTableRef(datasourceTableRef) {
|
|
54
|
+
return function (tr) {
|
|
55
|
+
return cardAction(tr, {
|
|
56
|
+
type: 'SET_DATASOURCE_TABLE_REF',
|
|
57
|
+
datasourceTableRef: datasourceTableRef
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export var setCardLayout = function setCardLayout(layout) {
|
|
62
|
+
return function (tr) {
|
|
63
|
+
return cardAction(tr, {
|
|
64
|
+
type: 'SET_CARD_LAYOUT',
|
|
65
|
+
layout: layout
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export var setCardLayoutAndDatasourceTableRef = function setCardLayoutAndDatasourceTableRef(_ref) {
|
|
70
|
+
var layout = _ref.layout,
|
|
71
|
+
datasourceTableRef = _ref.datasourceTableRef;
|
|
72
|
+
return function (tr) {
|
|
73
|
+
return cardAction(tr, {
|
|
74
|
+
type: 'SET_CARD_LAYOUT_AND_DATASOURCE_TABLE_REF',
|
|
75
|
+
layout: layout,
|
|
76
|
+
datasourceTableRef: datasourceTableRef
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
export var showLinkToolbar = function showLinkToolbar(tr) {
|
|
81
|
+
return cardAction(tr, {
|
|
82
|
+
type: 'SHOW_LINK_TOOLBAR'
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
export var hideLinkToolbar = function hideLinkToolbar(tr) {
|
|
86
|
+
return cardAction(tr, {
|
|
87
|
+
type: 'HIDE_LINK_TOOLBAR'
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
export var showDatasourceModal = function showDatasourceModal(modalType) {
|
|
91
|
+
return function (tr) {
|
|
92
|
+
return cardAction(tr, {
|
|
93
|
+
type: 'SHOW_DATASOURCE_MODAL',
|
|
94
|
+
modalType: modalType
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
export var hideDatasourceModal = function hideDatasourceModal(tr) {
|
|
99
|
+
return cardAction(tr, {
|
|
100
|
+
type: 'HIDE_DATASOURCE_MODAL'
|
|
101
|
+
});
|
|
102
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple mechanism to defer analytics related callbacks
|
|
3
|
+
*/
|
|
4
|
+
export var createAnalyticsQueue = function createAnalyticsQueue() {
|
|
5
|
+
var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
6
|
+
var queue = [];
|
|
7
|
+
var callbacksRef = {
|
|
8
|
+
current: null
|
|
9
|
+
};
|
|
10
|
+
var setCallbacks = function setCallbacks(callbacks) {
|
|
11
|
+
callbacksRef.current = callbacks;
|
|
12
|
+
};
|
|
13
|
+
var push = function push() {
|
|
14
|
+
var callbacks = callbacksRef.current;
|
|
15
|
+
if (!enabled || !callbacks) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
queue.push.apply(queue, arguments);
|
|
19
|
+
};
|
|
20
|
+
var flush = function flush() {
|
|
21
|
+
var callbacks = callbacksRef.current;
|
|
22
|
+
if (!enabled || !callbacks) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
while (queue.length) {
|
|
26
|
+
var event = queue.pop();
|
|
27
|
+
if (event) {
|
|
28
|
+
callbacks[event.type](event.data);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var getSize = function getSize() {
|
|
33
|
+
return queue.length;
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
push: push,
|
|
37
|
+
flush: flush,
|
|
38
|
+
setCallbacks: setCallbacks,
|
|
39
|
+
getSize: getSize
|
|
40
|
+
};
|
|
41
|
+
};
|