@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,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.SmallerEditIcon = void 0;
|
|
8
|
+
var _react = require("@emotion/react");
|
|
9
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
10
|
+
var _edit = _interopRequireDefault(require("@atlaskit/icon/glyph/edit"));
|
|
11
|
+
/** @jsx jsx */
|
|
12
|
+
|
|
13
|
+
/* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
|
|
14
|
+
var SmallerEditIcon = function SmallerEditIcon() {
|
|
15
|
+
return (0, _react.jsx)("div", {
|
|
16
|
+
css: _styles.editIconStyles
|
|
17
|
+
}, (0, _react.jsx)(_edit.default, {
|
|
18
|
+
label: "edit"
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
/* eslint-enable @atlaskit/design-system/consistent-css-prop-usage */
|
|
22
|
+
exports.SmallerEditIcon = SmallerEditIcon;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.titleUrlPairFromNode = exports.selectedCardAppearance = exports.mergeCardInfo = exports.findCardInfo = exports.displayInfoForCard = exports.appearanceForNodeType = void 0;
|
|
7
|
+
var _prosemirrorState = require("prosemirror-state");
|
|
8
|
+
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
9
|
+
var appearanceForNodeType = function appearanceForNodeType(spec) {
|
|
10
|
+
if (spec.name === 'inlineCard') {
|
|
11
|
+
return 'inline';
|
|
12
|
+
} else if (spec.name === 'blockCard') {
|
|
13
|
+
return 'block';
|
|
14
|
+
} else if (spec.name === 'embedCard') {
|
|
15
|
+
return 'embed';
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
18
|
+
};
|
|
19
|
+
exports.appearanceForNodeType = appearanceForNodeType;
|
|
20
|
+
var selectedCardAppearance = function selectedCardAppearance(state) {
|
|
21
|
+
if (state.selection instanceof _prosemirrorState.NodeSelection) {
|
|
22
|
+
return appearanceForNodeType(state.selection.node.type);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.selectedCardAppearance = selectedCardAppearance;
|
|
26
|
+
var titleUrlPairFromNode = function titleUrlPairFromNode(node) {
|
|
27
|
+
var attrs = node.attrs;
|
|
28
|
+
return {
|
|
29
|
+
url: attrs.url || attrs.data && attrs.data.url,
|
|
30
|
+
title: attrs.data && attrs.data.title
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Merges the title and url from attributes and CardInfo from the resolved view, preferring the CardInfo.
|
|
36
|
+
* @param titleUrlPair title and url information from the node attributes
|
|
37
|
+
* @param info information stored in state from the resolved UI component view
|
|
38
|
+
*/
|
|
39
|
+
exports.titleUrlPairFromNode = titleUrlPairFromNode;
|
|
40
|
+
var mergeCardInfo = function mergeCardInfo(titleUrlPair, info) {
|
|
41
|
+
return {
|
|
42
|
+
title: info && info.title || titleUrlPair.title,
|
|
43
|
+
url: info && info.url || titleUrlPair.url
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
exports.mergeCardInfo = mergeCardInfo;
|
|
47
|
+
var displayInfoForCard = function displayInfoForCard(node, info) {
|
|
48
|
+
return mergeCardInfo(titleUrlPairFromNode(node), info);
|
|
49
|
+
};
|
|
50
|
+
exports.displayInfoForCard = displayInfoForCard;
|
|
51
|
+
var findCardInfo = function findCardInfo(state) {
|
|
52
|
+
var pluginState = _pluginKey.pluginKey.getState(state);
|
|
53
|
+
if (!pluginState) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
return pluginState.cards.find(function (cardInfo) {
|
|
57
|
+
return cardInfo.pos === state.selection.from;
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
exports.findCardInfo = findCardInfo;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cardPlugin } from './plugin';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export const messages = defineMessages({
|
|
3
|
+
datasourceJiraIssue: {
|
|
4
|
+
id: 'fabric.editor.datasource.jiraIssue',
|
|
5
|
+
defaultMessage: 'Jira Issues',
|
|
6
|
+
description: 'Insert a jira datasource table'
|
|
7
|
+
},
|
|
8
|
+
datasourceJiraIssueDescription: {
|
|
9
|
+
id: 'fabric.editor.datasource.jiraIssue.description',
|
|
10
|
+
defaultMessage: 'Insert issues from Jira Cloud with enhanced search, filtering, and configuration',
|
|
11
|
+
description: 'Insert a jira datasource table'
|
|
12
|
+
}
|
|
13
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import rafSchedule from 'raf-schd';
|
|
5
|
+
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
6
|
+
import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
|
|
7
|
+
import { browser } from '@atlaskit/editor-common/utils';
|
|
8
|
+
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
9
|
+
import { registerCard } from '../pm-plugins/actions';
|
|
10
|
+
import { Card } from './genericCard';
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
13
|
+
export class BlockCardComponent extends React.PureComponent {
|
|
14
|
+
constructor(...args) {
|
|
15
|
+
super(...args);
|
|
16
|
+
_defineProperty(this, "onClick", () => {});
|
|
17
|
+
_defineProperty(this, "onResolve", data => {
|
|
18
|
+
const {
|
|
19
|
+
getPos,
|
|
20
|
+
view
|
|
21
|
+
} = this.props;
|
|
22
|
+
if (!getPos || typeof getPos === 'boolean') {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const {
|
|
26
|
+
title,
|
|
27
|
+
url
|
|
28
|
+
} = data;
|
|
29
|
+
|
|
30
|
+
// don't dispatch immediately since we might be in the middle of
|
|
31
|
+
// rendering a nodeview
|
|
32
|
+
rafSchedule(() => {
|
|
33
|
+
const pos = getPos();
|
|
34
|
+
if (typeof pos !== 'number') {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
view.dispatch(registerCard({
|
|
38
|
+
title,
|
|
39
|
+
url,
|
|
40
|
+
pos
|
|
41
|
+
})(view.state.tr));
|
|
42
|
+
})();
|
|
43
|
+
});
|
|
44
|
+
_defineProperty(this, "gapCursorSpan", () => {
|
|
45
|
+
// Don't render in EdgeHTMl version <= 18 (Edge version 44)
|
|
46
|
+
// as it forces the edit popup to render 24px lower than it should
|
|
47
|
+
if (browser.ie && browser.ie_version < 79) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// render an empty span afterwards to get around Webkit bug
|
|
52
|
+
// that puts caret in next editable text element
|
|
53
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
54
|
+
contentEditable: true
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
_defineProperty(this, "onError", ({
|
|
58
|
+
err
|
|
59
|
+
}) => {
|
|
60
|
+
if (err) {
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
UNSAFE_componentWillMount() {
|
|
66
|
+
const {
|
|
67
|
+
view
|
|
68
|
+
} = this.props;
|
|
69
|
+
const scrollContainer = findOverflowScrollParent(view.dom);
|
|
70
|
+
this.scrollContainer = scrollContainer || undefined;
|
|
71
|
+
}
|
|
72
|
+
render() {
|
|
73
|
+
const {
|
|
74
|
+
node,
|
|
75
|
+
cardContext,
|
|
76
|
+
platform,
|
|
77
|
+
showServerActions
|
|
78
|
+
} = this.props;
|
|
79
|
+
const {
|
|
80
|
+
url,
|
|
81
|
+
data
|
|
82
|
+
} = node.attrs;
|
|
83
|
+
const cardInner = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SmartCard, {
|
|
84
|
+
key: url,
|
|
85
|
+
url: url,
|
|
86
|
+
data: data,
|
|
87
|
+
container: this.scrollContainer,
|
|
88
|
+
appearance: "block",
|
|
89
|
+
onClick: this.onClick,
|
|
90
|
+
onResolve: this.onResolve,
|
|
91
|
+
onError: this.onError,
|
|
92
|
+
showActions: platform === 'web',
|
|
93
|
+
platform: platform,
|
|
94
|
+
showServerActions: showServerActions
|
|
95
|
+
}), this.gapCursorSpan());
|
|
96
|
+
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
97
|
+
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
98
|
+
return /*#__PURE__*/React.createElement("div", null, cardContext && cardContext.value ? /*#__PURE__*/React.createElement(cardContext.Provider, {
|
|
99
|
+
value: cardContext.value
|
|
100
|
+
}, cardInner) : data ? cardInner : null);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
_defineProperty(BlockCardComponent, "contextTypes", {
|
|
104
|
+
contextAdapter: PropTypes.object
|
|
105
|
+
});
|
|
106
|
+
const WrappedBlockCard = Card(BlockCardComponent, UnsupportedBlock);
|
|
107
|
+
export class BlockCard extends ReactNodeView {
|
|
108
|
+
createDomRef() {
|
|
109
|
+
const domRef = document.createElement('div');
|
|
110
|
+
if (this.reactComponentProps.platform !== 'mobile') {
|
|
111
|
+
// workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
|
|
112
|
+
// see also: https://github.com/ProseMirror/prosemirror/issues/884
|
|
113
|
+
domRef.contentEditable = 'true';
|
|
114
|
+
domRef.setAttribute('spellcheck', 'false');
|
|
115
|
+
}
|
|
116
|
+
return domRef;
|
|
117
|
+
}
|
|
118
|
+
render() {
|
|
119
|
+
const {
|
|
120
|
+
platform,
|
|
121
|
+
showServerActions
|
|
122
|
+
} = this.reactComponentProps;
|
|
123
|
+
return /*#__PURE__*/React.createElement(WrappedBlockCard, {
|
|
124
|
+
node: this.node,
|
|
125
|
+
view: this.view,
|
|
126
|
+
getPos: this.getPos,
|
|
127
|
+
platform: platform,
|
|
128
|
+
showServerActions: showServerActions
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { css, jsx } from '@emotion/react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
7
|
+
import { DATASOURCE_INNER_CONTAINER_CLASSNAME, SmartCardSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
8
|
+
import { calcBreakoutWidthPx } from '@atlaskit/editor-common/utils';
|
|
9
|
+
import { DatasourceTableView } from '@atlaskit/link-datasource';
|
|
10
|
+
const containerStyles = css({
|
|
11
|
+
height: '500px',
|
|
12
|
+
overflow: 'auto'
|
|
13
|
+
});
|
|
14
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
15
|
+
export class DatasourceComponent extends React.PureComponent {
|
|
16
|
+
constructor(props) {
|
|
17
|
+
super(props);
|
|
18
|
+
_defineProperty(this, "getPosSafely", () => {
|
|
19
|
+
const {
|
|
20
|
+
getPos
|
|
21
|
+
} = this.props;
|
|
22
|
+
if (!getPos || typeof getPos === 'boolean') {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
return getPos();
|
|
27
|
+
} catch (e) {
|
|
28
|
+
// Can blow up in rare cases, when node has been removed.
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
_defineProperty(this, "getDatasource", () => this.props.node.attrs.datasource);
|
|
32
|
+
_defineProperty(this, "getTableView", datasource => {
|
|
33
|
+
const views = (datasource || this.getDatasource()).views;
|
|
34
|
+
return views.find(view => view.type === 'table') || undefined;
|
|
35
|
+
});
|
|
36
|
+
_defineProperty(this, "handleColumnChange", columnKeys => {
|
|
37
|
+
const {
|
|
38
|
+
state,
|
|
39
|
+
dispatch
|
|
40
|
+
} = this.props.view;
|
|
41
|
+
const pos = this.getPosSafely();
|
|
42
|
+
if (pos === undefined) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const attrs = this.props.node.attrs;
|
|
46
|
+
const views = [{
|
|
47
|
+
type: 'table',
|
|
48
|
+
properties: {
|
|
49
|
+
columns: columnKeys.map(key => ({
|
|
50
|
+
key
|
|
51
|
+
}))
|
|
52
|
+
}
|
|
53
|
+
}];
|
|
54
|
+
const tr = state.tr.setNodeMarkup(pos, undefined, {
|
|
55
|
+
...attrs,
|
|
56
|
+
datasource: {
|
|
57
|
+
...attrs.datasource,
|
|
58
|
+
views
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
tr.setMeta('scrollIntoView', false);
|
|
62
|
+
dispatch(tr);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
render() {
|
|
66
|
+
const cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
|
|
67
|
+
const datasource = this.getDatasource();
|
|
68
|
+
const tableView = this.getTableView();
|
|
69
|
+
if (tableView) {
|
|
70
|
+
var _tableView$properties;
|
|
71
|
+
const visibleColumnKeys = (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns.map(({
|
|
72
|
+
key
|
|
73
|
+
}) => key);
|
|
74
|
+
|
|
75
|
+
// [WS-2307]: we only render card wrapped into a Provider when the value is ready
|
|
76
|
+
if (cardContext && cardContext.value) {
|
|
77
|
+
return jsx(cardContext.Provider, {
|
|
78
|
+
value: cardContext.value
|
|
79
|
+
}, jsx(DatasourceTableView, {
|
|
80
|
+
datasourceId: datasource.id,
|
|
81
|
+
parameters: datasource.parameters,
|
|
82
|
+
visibleColumnKeys: visibleColumnKeys,
|
|
83
|
+
onVisibleColumnKeysChange: this.handleColumnChange
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
_defineProperty(DatasourceComponent, "contextTypes", {
|
|
91
|
+
contextAdapter: PropTypes.object
|
|
92
|
+
});
|
|
93
|
+
export class Datasource extends ReactNodeView {
|
|
94
|
+
constructor(props) {
|
|
95
|
+
var _props$pluginInjectio, _props$pluginInjectio2, _props$pluginInjectio3, _sharedState$currentS;
|
|
96
|
+
super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props, undefined, true, undefined, props.hasIntlContext);
|
|
97
|
+
_defineProperty(this, "calcTableWidth", (layout, containerWidth) => {
|
|
98
|
+
if (layout === 'center') {
|
|
99
|
+
return 'inherit';
|
|
100
|
+
}
|
|
101
|
+
return calcBreakoutWidthPx(layout, containerWidth);
|
|
102
|
+
});
|
|
103
|
+
const sharedState = props === null || props === void 0 ? void 0 : (_props$pluginInjectio = props.pluginInjectionApi) === null || _props$pluginInjectio === void 0 ? void 0 : (_props$pluginInjectio2 = _props$pluginInjectio.dependencies) === null || _props$pluginInjectio2 === void 0 ? void 0 : (_props$pluginInjectio3 = _props$pluginInjectio2.width) === null || _props$pluginInjectio3 === void 0 ? void 0 : _props$pluginInjectio3.sharedState;
|
|
104
|
+
this.tableWidth = sharedState === null || sharedState === void 0 ? void 0 : (_sharedState$currentS = sharedState.currentState()) === null || _sharedState$currentS === void 0 ? void 0 : _sharedState$currentS.width;
|
|
105
|
+
sharedState === null || sharedState === void 0 ? void 0 : sharedState.onChange(({
|
|
106
|
+
nextSharedState
|
|
107
|
+
}) => {
|
|
108
|
+
if (nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.width && this.tableWidth !== (nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.width)) {
|
|
109
|
+
this.tableWidth = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.width;
|
|
110
|
+
this.update(this.node, []); // required to update the width when page is resized.
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
createDomRef() {
|
|
116
|
+
const domRef = document.createElement('div');
|
|
117
|
+
domRef.classList.add(SmartCardSharedCssClassName.DATASOURCE_CONTAINER);
|
|
118
|
+
return domRef;
|
|
119
|
+
}
|
|
120
|
+
render() {
|
|
121
|
+
const {
|
|
122
|
+
attrs
|
|
123
|
+
} = this.node;
|
|
124
|
+
const calculatedWidth = this.calcTableWidth(attrs.layout, this.tableWidth);
|
|
125
|
+
return jsx("div", {
|
|
126
|
+
className: DATASOURCE_INNER_CONTAINER_CLASSNAME,
|
|
127
|
+
css: containerStyles,
|
|
128
|
+
style: {
|
|
129
|
+
minWidth: calculatedWidth
|
|
130
|
+
}
|
|
131
|
+
}, jsx(DatasourceComponent, {
|
|
132
|
+
node: this.node,
|
|
133
|
+
view: this.view,
|
|
134
|
+
getPos: this.getPos
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
}
|