@atlaskit/embedded-document 0.7.29
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 +978 -0
- package/LICENSE +13 -0
- package/build/tsconfig.json +17 -0
- package/dist/cjs/components/document.js +157 -0
- package/dist/cjs/components/toolbar.js +89 -0
- package/dist/cjs/consumers/consumer.js +102 -0
- package/dist/cjs/consumers/document-body.js +95 -0
- package/dist/cjs/consumers/with-document-actions.js +139 -0
- package/dist/cjs/context/context.js +71 -0
- package/dist/cjs/context/embedded-document.js +396 -0
- package/dist/cjs/index.js +47 -0
- package/dist/cjs/model/index.js +5 -0
- package/dist/cjs/provider/index.js +35 -0
- package/dist/cjs/provider/provider.js +5 -0
- package/dist/cjs/provider/service-provider.js +240 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/components/document.js +107 -0
- package/dist/es2019/components/toolbar.js +45 -0
- package/dist/es2019/consumers/consumer.js +62 -0
- package/dist/es2019/consumers/document-body.js +49 -0
- package/dist/es2019/consumers/with-document-actions.js +35 -0
- package/dist/es2019/context/context.js +19 -0
- package/dist/es2019/context/embedded-document.js +216 -0
- package/dist/es2019/index.js +5 -0
- package/dist/es2019/model/index.js +1 -0
- package/dist/es2019/provider/index.js +18 -0
- package/dist/es2019/provider/provider.js +1 -0
- package/dist/es2019/provider/service-provider.js +101 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/components/document.js +136 -0
- package/dist/esm/components/toolbar.js +70 -0
- package/dist/esm/consumers/consumer.js +84 -0
- package/dist/esm/consumers/document-body.js +77 -0
- package/dist/esm/consumers/with-document-actions.js +119 -0
- package/dist/esm/context/context.js +59 -0
- package/dist/esm/context/embedded-document.js +375 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/model/index.js +1 -0
- package/dist/esm/provider/index.js +18 -0
- package/dist/esm/provider/provider.js +1 -0
- package/dist/esm/provider/service-provider.js +229 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/components/document.d.ts +20 -0
- package/dist/types/components/toolbar.d.ts +6 -0
- package/dist/types/consumers/consumer.d.ts +23 -0
- package/dist/types/consumers/document-body.d.ts +13 -0
- package/dist/types/consumers/with-document-actions.d.ts +16 -0
- package/dist/types/context/context.d.ts +22 -0
- package/dist/types/context/embedded-document.d.ts +41 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/model/index.d.ts +19 -0
- package/dist/types/provider/index.d.ts +9 -0
- package/dist/types/provider/provider.d.ts +7 -0
- package/dist/types/provider/service-provider.d.ts +13 -0
- package/package.json +44 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { utils } from '@atlaskit/util-service-support';
|
|
2
|
+
|
|
3
|
+
function queryBuilder(data) {
|
|
4
|
+
return Object.keys(data).map(key => {
|
|
5
|
+
return [key, data[key]].map(encodeURIComponent).join('=');
|
|
6
|
+
}).join('&');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default class ServiceProvider {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async getDocument(documentId, language) {
|
|
15
|
+
try {
|
|
16
|
+
const document = await utils.requestService(this.config, {
|
|
17
|
+
path: `document/${documentId}/${language || ''}`
|
|
18
|
+
});
|
|
19
|
+
return document;
|
|
20
|
+
} catch (err) {
|
|
21
|
+
// eslint-disable-next-line no-console
|
|
22
|
+
console.warn(`Failed to get document: ${JSON.stringify(err)}`);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async getDocumentByObjectId(objectId, language) {
|
|
28
|
+
try {
|
|
29
|
+
const queryString = queryBuilder({
|
|
30
|
+
objectId,
|
|
31
|
+
...(language ? {
|
|
32
|
+
language
|
|
33
|
+
} : {})
|
|
34
|
+
});
|
|
35
|
+
const documents = await utils.requestService(this.config, {
|
|
36
|
+
path: `document?${queryString}`
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (documents && documents.length) {
|
|
40
|
+
return documents[0].language[language || 'default'].versions[0];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
} catch (err) {
|
|
45
|
+
// eslint-disable-next-line no-console
|
|
46
|
+
console.warn(`Failed to get document: ${JSON.stringify(err)}`);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async updateDocument(documentId, body, objectId, title, language) {
|
|
52
|
+
try {
|
|
53
|
+
const document = await utils.requestService(this.config, {
|
|
54
|
+
path: `document/${documentId}`,
|
|
55
|
+
requestInit: {
|
|
56
|
+
headers: {
|
|
57
|
+
'Content-Type': 'application/json'
|
|
58
|
+
},
|
|
59
|
+
method: 'PUT',
|
|
60
|
+
body: JSON.stringify({
|
|
61
|
+
body,
|
|
62
|
+
objectId,
|
|
63
|
+
title,
|
|
64
|
+
language
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return document;
|
|
69
|
+
} catch (err) {
|
|
70
|
+
// eslint-disable-next-line no-console
|
|
71
|
+
console.warn(`Failed to update document: ${JSON.stringify(err)}`);
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async createDocument(body, objectId, title, language) {
|
|
77
|
+
try {
|
|
78
|
+
const document = await utils.requestService(this.config, {
|
|
79
|
+
path: `document`,
|
|
80
|
+
requestInit: {
|
|
81
|
+
headers: {
|
|
82
|
+
'Content-Type': 'application/json'
|
|
83
|
+
},
|
|
84
|
+
method: 'POST',
|
|
85
|
+
body: JSON.stringify({
|
|
86
|
+
body,
|
|
87
|
+
objectId,
|
|
88
|
+
title,
|
|
89
|
+
language
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return document;
|
|
94
|
+
} catch (err) {
|
|
95
|
+
// eslint-disable-next-line no-console
|
|
96
|
+
console.warn(`Failed to update document: ${JSON.stringify(err)}`);
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
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
|
+
|
|
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
|
+
|
|
10
|
+
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; } }
|
|
11
|
+
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { Component } from 'react';
|
|
14
|
+
import { Editor, EditorContext, WithEditorActions } from '@atlaskit/editor-core';
|
|
15
|
+
import { ReactRenderer } from '@atlaskit/renderer';
|
|
16
|
+
import { ProviderFactory } from '@atlaskit/editor-common';
|
|
17
|
+
var emptyDoc = '{ "type": "doc", "version": 1, "content": [] }';
|
|
18
|
+
|
|
19
|
+
var Document = /*#__PURE__*/function (_Component) {
|
|
20
|
+
_inherits(Document, _Component);
|
|
21
|
+
|
|
22
|
+
var _super = _createSuper(Document);
|
|
23
|
+
|
|
24
|
+
function Document() {
|
|
25
|
+
_classCallCheck(this, Document);
|
|
26
|
+
|
|
27
|
+
return _super.apply(this, arguments);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_createClass(Document, [{
|
|
31
|
+
key: "renderToolbar",
|
|
32
|
+
value: function renderToolbar() {
|
|
33
|
+
var _this$props = this.props,
|
|
34
|
+
mode = _this$props.mode,
|
|
35
|
+
renderToolbar = _this$props.renderToolbar;
|
|
36
|
+
|
|
37
|
+
if (renderToolbar) {
|
|
38
|
+
return /*#__PURE__*/React.createElement(WithEditorActions, {
|
|
39
|
+
render: function render(actions) {
|
|
40
|
+
return renderToolbar(mode, actions);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
key: "renderTitle",
|
|
49
|
+
value: function renderTitle() {
|
|
50
|
+
var _this$props2 = this.props,
|
|
51
|
+
renderTitle = _this$props2.renderTitle,
|
|
52
|
+
mode = _this$props2.mode,
|
|
53
|
+
doc = _this$props2.doc;
|
|
54
|
+
|
|
55
|
+
if (renderTitle) {
|
|
56
|
+
return renderTitle(mode, doc);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "renderEditor",
|
|
63
|
+
value: function renderEditor() {
|
|
64
|
+
var _this$props3 = this.props,
|
|
65
|
+
doc = _this$props3.doc,
|
|
66
|
+
editorProps = _this$props3.editorProps;
|
|
67
|
+
|
|
68
|
+
var _ref = doc || {},
|
|
69
|
+
_ref$body = _ref.body,
|
|
70
|
+
body = _ref$body === void 0 ? emptyDoc : _ref$body;
|
|
71
|
+
|
|
72
|
+
return /*#__PURE__*/React.createElement(EditorContext, null, /*#__PURE__*/React.createElement(Editor, _extends({
|
|
73
|
+
appearance: "full-page",
|
|
74
|
+
placeholder: "Write something...",
|
|
75
|
+
defaultValue: body,
|
|
76
|
+
primaryToolbarComponents: this.renderToolbar(),
|
|
77
|
+
contentComponents: this.renderTitle()
|
|
78
|
+
}, editorProps)));
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "render",
|
|
82
|
+
value: function render() {
|
|
83
|
+
var _this$props4 = this.props,
|
|
84
|
+
doc = _this$props4.doc,
|
|
85
|
+
isLoading = _this$props4.isLoading,
|
|
86
|
+
hasError = _this$props4.hasError,
|
|
87
|
+
mode = _this$props4.mode,
|
|
88
|
+
editorProps = _this$props4.editorProps,
|
|
89
|
+
rendererProps = _this$props4.rendererProps;
|
|
90
|
+
|
|
91
|
+
if (hasError) {
|
|
92
|
+
return /*#__PURE__*/React.createElement("div", null, "Something went wrong \uD83D\uDE14");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (isLoading) {
|
|
96
|
+
return /*#__PURE__*/React.createElement("div", null, "Loading document... \uD83D\uDC28");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
switch (mode) {
|
|
100
|
+
case 'create':
|
|
101
|
+
case 'edit':
|
|
102
|
+
return this.renderEditor();
|
|
103
|
+
|
|
104
|
+
default:
|
|
105
|
+
var _ref2 = doc || {},
|
|
106
|
+
_ref2$body = _ref2.body,
|
|
107
|
+
body = _ref2$body === void 0 ? emptyDoc : _ref2$body;
|
|
108
|
+
|
|
109
|
+
var dataProviders;
|
|
110
|
+
|
|
111
|
+
if (editorProps) {
|
|
112
|
+
var mentionProvider = editorProps.mentionProvider,
|
|
113
|
+
emojiProvider = editorProps.emojiProvider,
|
|
114
|
+
media = editorProps.media;
|
|
115
|
+
dataProviders = ProviderFactory.create({
|
|
116
|
+
mentionProvider: mentionProvider,
|
|
117
|
+
emojiProvider: emojiProvider
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
if (media && media.provider) {
|
|
121
|
+
dataProviders.setProvider('mediaProvider', media.provider);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return /*#__PURE__*/React.createElement(ReactRenderer, _extends({
|
|
126
|
+
dataProviders: dataProviders,
|
|
127
|
+
document: JSON.parse(body)
|
|
128
|
+
}, rendererProps));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}]);
|
|
132
|
+
|
|
133
|
+
return Document;
|
|
134
|
+
}(Component);
|
|
135
|
+
|
|
136
|
+
export { Document as default };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
4
|
+
|
|
5
|
+
var _templateObject;
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import ButtonGroup from '@atlaskit/button/button-group';
|
|
9
|
+
import Button from '@atlaskit/button/custom-theme-button';
|
|
10
|
+
import styled from 'styled-components';
|
|
11
|
+
import WithDocumentActions from '../consumers/with-document-actions';
|
|
12
|
+
var Toolbar = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: flex-end;\n padding: 0 20px;\n height: 80px;\n"])));
|
|
13
|
+
export default (function (props) {
|
|
14
|
+
var mode = props.mode,
|
|
15
|
+
editorActions = props.editorActions;
|
|
16
|
+
return /*#__PURE__*/React.createElement(WithDocumentActions, {
|
|
17
|
+
render: function render(actions) {
|
|
18
|
+
switch (mode) {
|
|
19
|
+
case 'edit':
|
|
20
|
+
case 'create':
|
|
21
|
+
return /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
|
|
22
|
+
appearance: "primary",
|
|
23
|
+
onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
24
|
+
var value;
|
|
25
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
26
|
+
while (1) {
|
|
27
|
+
switch (_context.prev = _context.next) {
|
|
28
|
+
case 0:
|
|
29
|
+
_context.next = 2;
|
|
30
|
+
return editorActions.getValue();
|
|
31
|
+
|
|
32
|
+
case 2:
|
|
33
|
+
value = _context.sent;
|
|
34
|
+
_context.prev = 3;
|
|
35
|
+
_context.next = 6;
|
|
36
|
+
return mode === 'create' ? actions.createDocument(value) : actions.updateDocument(value);
|
|
37
|
+
|
|
38
|
+
case 6:
|
|
39
|
+
_context.next = 10;
|
|
40
|
+
break;
|
|
41
|
+
|
|
42
|
+
case 8:
|
|
43
|
+
_context.prev = 8;
|
|
44
|
+
_context.t0 = _context["catch"](3);
|
|
45
|
+
|
|
46
|
+
case 10:
|
|
47
|
+
case "end":
|
|
48
|
+
return _context.stop();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}, _callee, null, [[3, 8]]);
|
|
52
|
+
}))
|
|
53
|
+
}, "Publish"), /*#__PURE__*/React.createElement(Button, {
|
|
54
|
+
appearance: "subtle",
|
|
55
|
+
onClick: function onClick() {
|
|
56
|
+
return actions.cancelEdit();
|
|
57
|
+
}
|
|
58
|
+
}, "Close"));
|
|
59
|
+
|
|
60
|
+
default:
|
|
61
|
+
return /*#__PURE__*/React.createElement(Toolbar, null, /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
|
|
62
|
+
appearance: "primary",
|
|
63
|
+
onClick: function onClick() {
|
|
64
|
+
return actions.editDocument();
|
|
65
|
+
}
|
|
66
|
+
}, "Edit")));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
|
|
9
|
+
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); }; }
|
|
10
|
+
|
|
11
|
+
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; } }
|
|
12
|
+
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { PureComponent } from 'react';
|
|
15
|
+
import { Context } from '../context/context';
|
|
16
|
+
export var Consumer = /*#__PURE__*/function (_PureComponent) {
|
|
17
|
+
_inherits(Consumer, _PureComponent);
|
|
18
|
+
|
|
19
|
+
var _super = _createSuper(Consumer);
|
|
20
|
+
|
|
21
|
+
function Consumer() {
|
|
22
|
+
var _this;
|
|
23
|
+
|
|
24
|
+
_classCallCheck(this, Consumer);
|
|
25
|
+
|
|
26
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
27
|
+
args[_key] = arguments[_key];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
31
|
+
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "getPropsFromActions", function (actions) {
|
|
33
|
+
var actionsMapper = _this.props.actionsMapper;
|
|
34
|
+
|
|
35
|
+
if (actionsMapper) {
|
|
36
|
+
if (!_this.previousActions || !_this.propsFromActions || _this.previousActions !== actions) {
|
|
37
|
+
_this.propsFromActions = actionsMapper(actions);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
_this.previousActions = actions;
|
|
42
|
+
return _this.propsFromActions;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
_defineProperty(_assertThisInitialized(_this), "getPropsFromState", function (state) {
|
|
46
|
+
var stateMapper = _this.props.stateMapper;
|
|
47
|
+
|
|
48
|
+
if (stateMapper) {
|
|
49
|
+
return stateMapper(state);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return undefined;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
_defineProperty(_assertThisInitialized(_this), "getRenderProps", function (renderProps) {
|
|
56
|
+
var renderPropsMapper = _this.props.renderPropsMapper;
|
|
57
|
+
|
|
58
|
+
if (renderPropsMapper) {
|
|
59
|
+
return renderPropsMapper(renderProps);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return undefined;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
_defineProperty(_assertThisInitialized(_this), "renderChildren", function (_ref) {
|
|
66
|
+
var actions = _ref.actions,
|
|
67
|
+
value = _ref.value,
|
|
68
|
+
renderProps = _ref.renderProps;
|
|
69
|
+
var props = Object.assign({}, _this.getPropsFromState(value), _this.getPropsFromActions(actions), _this.getRenderProps(renderProps));
|
|
70
|
+
return _this.props.children(props);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return _this;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_createClass(Consumer, [{
|
|
77
|
+
key: "render",
|
|
78
|
+
value: function render() {
|
|
79
|
+
return /*#__PURE__*/React.createElement(Context.Consumer, null, this.renderChildren);
|
|
80
|
+
}
|
|
81
|
+
}]);
|
|
82
|
+
|
|
83
|
+
return Consumer;
|
|
84
|
+
}(PureComponent);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
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 _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); }; }
|
|
11
|
+
|
|
12
|
+
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; } }
|
|
13
|
+
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import { PureComponent } from 'react';
|
|
16
|
+
import { Consumer } from './consumer';
|
|
17
|
+
import { default as Document } from '../components/document';
|
|
18
|
+
|
|
19
|
+
var DocumentBody = /*#__PURE__*/function (_PureComponent) {
|
|
20
|
+
_inherits(DocumentBody, _PureComponent);
|
|
21
|
+
|
|
22
|
+
var _super = _createSuper(DocumentBody);
|
|
23
|
+
|
|
24
|
+
function DocumentBody() {
|
|
25
|
+
var _this;
|
|
26
|
+
|
|
27
|
+
_classCallCheck(this, DocumentBody);
|
|
28
|
+
|
|
29
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
|
+
args[_key] = arguments[_key];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
+
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "renderChild", function (props) {
|
|
36
|
+
return /*#__PURE__*/React.createElement(Document, _extends({}, _this.props, props));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
_defineProperty(_assertThisInitialized(_this), "stateMapper", function (state) {
|
|
40
|
+
var doc = state.doc,
|
|
41
|
+
hasError = state.hasError,
|
|
42
|
+
isLoading = state.isLoading,
|
|
43
|
+
mode = state.mode;
|
|
44
|
+
return {
|
|
45
|
+
doc: doc,
|
|
46
|
+
hasError: hasError,
|
|
47
|
+
isLoading: isLoading,
|
|
48
|
+
mode: mode
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
_defineProperty(_assertThisInitialized(_this), "renderPropsMapper", function (renderProps) {
|
|
53
|
+
var renderTitle = renderProps.renderTitle,
|
|
54
|
+
renderToolbar = renderProps.renderToolbar;
|
|
55
|
+
return {
|
|
56
|
+
renderTitle: renderTitle,
|
|
57
|
+
renderToolbar: renderToolbar
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return _this;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
_createClass(DocumentBody, [{
|
|
65
|
+
key: "render",
|
|
66
|
+
value: function render() {
|
|
67
|
+
return /*#__PURE__*/React.createElement(Consumer, {
|
|
68
|
+
stateMapper: this.stateMapper,
|
|
69
|
+
renderPropsMapper: this.renderPropsMapper
|
|
70
|
+
}, this.renderChild);
|
|
71
|
+
}
|
|
72
|
+
}]);
|
|
73
|
+
|
|
74
|
+
return DocumentBody;
|
|
75
|
+
}(PureComponent);
|
|
76
|
+
|
|
77
|
+
export { DocumentBody as default };
|