@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
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
rules: {
|
|
3
|
+
'no-duplicate-imports': 'off',
|
|
4
|
+
'@typescript-eslint/no-duplicate-imports': 'error',
|
|
5
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
6
|
+
},
|
|
7
|
+
overrides: [
|
|
8
|
+
{
|
|
9
|
+
files: ['**/__tests__/**/*.{js,ts,tsx}', '**/examples/**/*.{js,ts,tsx}'],
|
|
10
|
+
rules: {
|
|
11
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
};
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @atlaskit/editor-plugin-card
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Atlassian Pty Ltd
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.messages = void 0;
|
|
7
|
+
var _reactIntlNext = require("react-intl-next");
|
|
8
|
+
var messages = (0, _reactIntlNext.defineMessages)({
|
|
9
|
+
datasourceJiraIssue: {
|
|
10
|
+
id: 'fabric.editor.datasource.jiraIssue',
|
|
11
|
+
defaultMessage: 'Jira Issues',
|
|
12
|
+
description: 'Insert a jira datasource table'
|
|
13
|
+
},
|
|
14
|
+
datasourceJiraIssueDescription: {
|
|
15
|
+
id: 'fabric.editor.datasource.jiraIssue.description',
|
|
16
|
+
defaultMessage: 'Insert issues from Jira Cloud with enhanced search, filtering, and configuration',
|
|
17
|
+
description: 'Insert a jira datasource table'
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
exports.messages = messages;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.BlockCardComponent = exports.BlockCard = 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 _react = _interopRequireDefault(require("react"));
|
|
16
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
+
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
18
|
+
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
19
|
+
var _ui = require("@atlaskit/editor-common/ui");
|
|
20
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
21
|
+
var _smartCard = require("@atlaskit/smart-card");
|
|
22
|
+
var _actions = require("../pm-plugins/actions");
|
|
23
|
+
var _genericCard = require("./genericCard");
|
|
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
|
+
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; } }
|
|
26
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
27
|
+
var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
28
|
+
(0, _inherits2.default)(BlockCardComponent, _React$PureComponent);
|
|
29
|
+
var _super = _createSuper(BlockCardComponent);
|
|
30
|
+
function BlockCardComponent() {
|
|
31
|
+
var _this;
|
|
32
|
+
(0, _classCallCheck2.default)(this, BlockCardComponent);
|
|
33
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
34
|
+
args[_key] = arguments[_key];
|
|
35
|
+
}
|
|
36
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
37
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClick", function () {});
|
|
38
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onResolve", function (data) {
|
|
39
|
+
var _this$props = _this.props,
|
|
40
|
+
getPos = _this$props.getPos,
|
|
41
|
+
view = _this$props.view;
|
|
42
|
+
if (!getPos || typeof getPos === 'boolean') {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
var title = data.title,
|
|
46
|
+
url = data.url;
|
|
47
|
+
|
|
48
|
+
// don't dispatch immediately since we might be in the middle of
|
|
49
|
+
// rendering a nodeview
|
|
50
|
+
(0, _rafSchd.default)(function () {
|
|
51
|
+
var pos = getPos();
|
|
52
|
+
if (typeof pos !== 'number') {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
view.dispatch((0, _actions.registerCard)({
|
|
56
|
+
title: title,
|
|
57
|
+
url: url,
|
|
58
|
+
pos: pos
|
|
59
|
+
})(view.state.tr));
|
|
60
|
+
})();
|
|
61
|
+
});
|
|
62
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "gapCursorSpan", function () {
|
|
63
|
+
// Don't render in EdgeHTMl version <= 18 (Edge version 44)
|
|
64
|
+
// as it forces the edit popup to render 24px lower than it should
|
|
65
|
+
if (_utils.browser.ie && _utils.browser.ie_version < 79) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// render an empty span afterwards to get around Webkit bug
|
|
70
|
+
// that puts caret in next editable text element
|
|
71
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
72
|
+
contentEditable: true
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onError", function (_ref) {
|
|
76
|
+
var err = _ref.err;
|
|
77
|
+
if (err) {
|
|
78
|
+
throw err;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return _this;
|
|
82
|
+
}
|
|
83
|
+
(0, _createClass2.default)(BlockCardComponent, [{
|
|
84
|
+
key: "UNSAFE_componentWillMount",
|
|
85
|
+
value: function UNSAFE_componentWillMount() {
|
|
86
|
+
var view = this.props.view;
|
|
87
|
+
var scrollContainer = (0, _ui.findOverflowScrollParent)(view.dom);
|
|
88
|
+
this.scrollContainer = scrollContainer || undefined;
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "render",
|
|
92
|
+
value: function render() {
|
|
93
|
+
var _this$props2 = this.props,
|
|
94
|
+
node = _this$props2.node,
|
|
95
|
+
cardContext = _this$props2.cardContext,
|
|
96
|
+
platform = _this$props2.platform,
|
|
97
|
+
showServerActions = _this$props2.showServerActions;
|
|
98
|
+
var _node$attrs = node.attrs,
|
|
99
|
+
url = _node$attrs.url,
|
|
100
|
+
data = _node$attrs.data;
|
|
101
|
+
var cardInner = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_smartCard.Card, {
|
|
102
|
+
key: url,
|
|
103
|
+
url: url,
|
|
104
|
+
data: data,
|
|
105
|
+
container: this.scrollContainer,
|
|
106
|
+
appearance: "block",
|
|
107
|
+
onClick: this.onClick,
|
|
108
|
+
onResolve: this.onResolve,
|
|
109
|
+
onError: this.onError,
|
|
110
|
+
showActions: platform === 'web',
|
|
111
|
+
platform: platform,
|
|
112
|
+
showServerActions: showServerActions
|
|
113
|
+
}), this.gapCursorSpan());
|
|
114
|
+
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
115
|
+
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
116
|
+
return /*#__PURE__*/_react.default.createElement("div", null, cardContext && cardContext.value ? /*#__PURE__*/_react.default.createElement(cardContext.Provider, {
|
|
117
|
+
value: cardContext.value
|
|
118
|
+
}, cardInner) : data ? cardInner : null);
|
|
119
|
+
}
|
|
120
|
+
}]);
|
|
121
|
+
return BlockCardComponent;
|
|
122
|
+
}(_react.default.PureComponent);
|
|
123
|
+
exports.BlockCardComponent = BlockCardComponent;
|
|
124
|
+
(0, _defineProperty2.default)(BlockCardComponent, "contextTypes", {
|
|
125
|
+
contextAdapter: _propTypes.default.object
|
|
126
|
+
});
|
|
127
|
+
var WrappedBlockCard = (0, _genericCard.Card)(BlockCardComponent, _ui.UnsupportedBlock);
|
|
128
|
+
var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
129
|
+
(0, _inherits2.default)(BlockCard, _ReactNodeView);
|
|
130
|
+
var _super2 = _createSuper(BlockCard);
|
|
131
|
+
function BlockCard() {
|
|
132
|
+
(0, _classCallCheck2.default)(this, BlockCard);
|
|
133
|
+
return _super2.apply(this, arguments);
|
|
134
|
+
}
|
|
135
|
+
(0, _createClass2.default)(BlockCard, [{
|
|
136
|
+
key: "createDomRef",
|
|
137
|
+
value: function createDomRef() {
|
|
138
|
+
var domRef = document.createElement('div');
|
|
139
|
+
if (this.reactComponentProps.platform !== 'mobile') {
|
|
140
|
+
// workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
|
|
141
|
+
// see also: https://github.com/ProseMirror/prosemirror/issues/884
|
|
142
|
+
domRef.contentEditable = 'true';
|
|
143
|
+
domRef.setAttribute('spellcheck', 'false');
|
|
144
|
+
}
|
|
145
|
+
return domRef;
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "render",
|
|
149
|
+
value: function render() {
|
|
150
|
+
var _this$reactComponentP = this.reactComponentProps,
|
|
151
|
+
platform = _this$reactComponentP.platform,
|
|
152
|
+
showServerActions = _this$reactComponentP.showServerActions;
|
|
153
|
+
return /*#__PURE__*/_react.default.createElement(WrappedBlockCard, {
|
|
154
|
+
node: this.node,
|
|
155
|
+
view: this.view,
|
|
156
|
+
getPos: this.getPos,
|
|
157
|
+
platform: platform,
|
|
158
|
+
showServerActions: showServerActions
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}]);
|
|
162
|
+
return BlockCard;
|
|
163
|
+
}(_reactNodeView.default);
|
|
164
|
+
exports.BlockCard = BlockCard;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.DatasourceComponent = exports.Datasource = 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 _react = _interopRequireDefault(require("react"));
|
|
16
|
+
var _react2 = require("@emotion/react");
|
|
17
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
18
|
+
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
19
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
20
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
21
|
+
var _linkDatasource = require("@atlaskit/link-datasource");
|
|
22
|
+
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; }
|
|
23
|
+
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) { (0, _defineProperty2.default)(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; }
|
|
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
|
+
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
|
+
var containerStyles = (0, _react2.css)({
|
|
27
|
+
height: '500px',
|
|
28
|
+
overflow: 'auto'
|
|
29
|
+
});
|
|
30
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
31
|
+
var DatasourceComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
32
|
+
(0, _inherits2.default)(DatasourceComponent, _React$PureComponent);
|
|
33
|
+
var _super = _createSuper(DatasourceComponent);
|
|
34
|
+
function DatasourceComponent(props) {
|
|
35
|
+
var _this;
|
|
36
|
+
(0, _classCallCheck2.default)(this, DatasourceComponent);
|
|
37
|
+
_this = _super.call(this, props);
|
|
38
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getPosSafely", function () {
|
|
39
|
+
var getPos = _this.props.getPos;
|
|
40
|
+
if (!getPos || typeof getPos === 'boolean') {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
return getPos();
|
|
45
|
+
} catch (e) {
|
|
46
|
+
// Can blow up in rare cases, when node has been removed.
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getDatasource", function () {
|
|
50
|
+
return _this.props.node.attrs.datasource;
|
|
51
|
+
});
|
|
52
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getTableView", function (datasource) {
|
|
53
|
+
var views = (datasource || _this.getDatasource()).views;
|
|
54
|
+
return views.find(function (view) {
|
|
55
|
+
return view.type === 'table';
|
|
56
|
+
}) || undefined;
|
|
57
|
+
});
|
|
58
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleColumnChange", function (columnKeys) {
|
|
59
|
+
var _this$props$view = _this.props.view,
|
|
60
|
+
state = _this$props$view.state,
|
|
61
|
+
dispatch = _this$props$view.dispatch;
|
|
62
|
+
var pos = _this.getPosSafely();
|
|
63
|
+
if (pos === undefined) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
var attrs = _this.props.node.attrs;
|
|
67
|
+
var views = [{
|
|
68
|
+
type: 'table',
|
|
69
|
+
properties: {
|
|
70
|
+
columns: columnKeys.map(function (key) {
|
|
71
|
+
return {
|
|
72
|
+
key: key
|
|
73
|
+
};
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
}];
|
|
77
|
+
var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, attrs), {}, {
|
|
78
|
+
datasource: _objectSpread(_objectSpread({}, attrs.datasource), {}, {
|
|
79
|
+
views: views
|
|
80
|
+
})
|
|
81
|
+
}));
|
|
82
|
+
tr.setMeta('scrollIntoView', false);
|
|
83
|
+
dispatch(tr);
|
|
84
|
+
});
|
|
85
|
+
return _this;
|
|
86
|
+
}
|
|
87
|
+
(0, _createClass2.default)(DatasourceComponent, [{
|
|
88
|
+
key: "render",
|
|
89
|
+
value: function render() {
|
|
90
|
+
var cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
|
|
91
|
+
var datasource = this.getDatasource();
|
|
92
|
+
var tableView = this.getTableView();
|
|
93
|
+
if (tableView) {
|
|
94
|
+
var _tableView$properties;
|
|
95
|
+
var visibleColumnKeys = (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns.map(function (_ref) {
|
|
96
|
+
var key = _ref.key;
|
|
97
|
+
return key;
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// [WS-2307]: we only render card wrapped into a Provider when the value is ready
|
|
101
|
+
if (cardContext && cardContext.value) {
|
|
102
|
+
return (0, _react2.jsx)(cardContext.Provider, {
|
|
103
|
+
value: cardContext.value
|
|
104
|
+
}, (0, _react2.jsx)(_linkDatasource.DatasourceTableView, {
|
|
105
|
+
datasourceId: datasource.id,
|
|
106
|
+
parameters: datasource.parameters,
|
|
107
|
+
visibleColumnKeys: visibleColumnKeys,
|
|
108
|
+
onVisibleColumnKeysChange: this.handleColumnChange
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
}]);
|
|
115
|
+
return DatasourceComponent;
|
|
116
|
+
}(_react.default.PureComponent);
|
|
117
|
+
exports.DatasourceComponent = DatasourceComponent;
|
|
118
|
+
(0, _defineProperty2.default)(DatasourceComponent, "contextTypes", {
|
|
119
|
+
contextAdapter: _propTypes.default.object
|
|
120
|
+
});
|
|
121
|
+
var Datasource = /*#__PURE__*/function (_ReactNodeView) {
|
|
122
|
+
(0, _inherits2.default)(Datasource, _ReactNodeView);
|
|
123
|
+
var _super2 = _createSuper(Datasource);
|
|
124
|
+
function Datasource(props) {
|
|
125
|
+
var _props$pluginInjectio, _props$pluginInjectio2, _props$pluginInjectio3, _sharedState$currentS;
|
|
126
|
+
var _this2;
|
|
127
|
+
(0, _classCallCheck2.default)(this, Datasource);
|
|
128
|
+
_this2 = _super2.call(this, props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props, undefined, true, undefined, props.hasIntlContext);
|
|
129
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "calcTableWidth", function (layout, containerWidth) {
|
|
130
|
+
if (layout === 'center') {
|
|
131
|
+
return 'inherit';
|
|
132
|
+
}
|
|
133
|
+
return (0, _utils.calcBreakoutWidthPx)(layout, containerWidth);
|
|
134
|
+
});
|
|
135
|
+
var 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;
|
|
136
|
+
_this2.tableWidth = sharedState === null || sharedState === void 0 ? void 0 : (_sharedState$currentS = sharedState.currentState()) === null || _sharedState$currentS === void 0 ? void 0 : _sharedState$currentS.width;
|
|
137
|
+
sharedState === null || sharedState === void 0 ? void 0 : sharedState.onChange(function (_ref2) {
|
|
138
|
+
var nextSharedState = _ref2.nextSharedState;
|
|
139
|
+
if (nextSharedState !== null && nextSharedState !== void 0 && nextSharedState.width && _this2.tableWidth !== (nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.width)) {
|
|
140
|
+
_this2.tableWidth = nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.width;
|
|
141
|
+
_this2.update(_this2.node, []); // required to update the width when page is resized.
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
return _this2;
|
|
145
|
+
}
|
|
146
|
+
(0, _createClass2.default)(Datasource, [{
|
|
147
|
+
key: "createDomRef",
|
|
148
|
+
value: function createDomRef() {
|
|
149
|
+
var domRef = document.createElement('div');
|
|
150
|
+
domRef.classList.add(_styles.SmartCardSharedCssClassName.DATASOURCE_CONTAINER);
|
|
151
|
+
return domRef;
|
|
152
|
+
}
|
|
153
|
+
}, {
|
|
154
|
+
key: "render",
|
|
155
|
+
value: function render() {
|
|
156
|
+
var attrs = this.node.attrs;
|
|
157
|
+
var calculatedWidth = this.calcTableWidth(attrs.layout, this.tableWidth);
|
|
158
|
+
return (0, _react2.jsx)("div", {
|
|
159
|
+
className: _styles.DATASOURCE_INNER_CONTAINER_CLASSNAME,
|
|
160
|
+
css: containerStyles,
|
|
161
|
+
style: {
|
|
162
|
+
minWidth: calculatedWidth
|
|
163
|
+
}
|
|
164
|
+
}, (0, _react2.jsx)(DatasourceComponent, {
|
|
165
|
+
node: this.node,
|
|
166
|
+
view: this.view,
|
|
167
|
+
getPos: this.getPos
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
}]);
|
|
171
|
+
return Datasource;
|
|
172
|
+
}(_reactNodeView.default);
|
|
173
|
+
exports.Datasource = Datasource;
|